----------------------------------------
Date: Sat, 10 Oct 2015 22:38:44 -0700
Subject: Re: what is the best binding for stat() on Linux
From: chighland@xxxxxxxxx
To: luajit@xxxxxxxxxxxxx
On Sat, Oct 10, 2015 at 10:51 AM, William Adams
<william_a_adams@xxxxxxxxxxx> wrote:
It would be nice if there were a middle project, something like
ljplatform. This is where all the platform specific #defines, and
syscalls would go. Then projects such as ljsyscall, which intends to
avoid the use of libc could take that as a dependency. Similarly,
LJIT2libc, which intends to utilize the embedded libc, and avoid using
syscall, could also take a dependency, because they both end up
defining a ton of the same stuff.
It could also make sense to export this data from glibc. glibc
already generates regular system call wrappers from a table.
Not quite sure I understand this comment.
what is needed are the hundreds of declarations wrapped up in ffi.cdef
blocks.
Are you implying that you can get that automatically out of glibc?
For example, the definitions for the epoll structure, the NR_xxx constants,
the
inode_t and all the other special typedefs and defines. You need those to be
platform and OS specific, easily selectable from LJIT2libc or ljsyscall.
-- William
If nothing else, gcc -E will get you fully-preprocessed source for a
desired header file. From there you only need to recognize a few
important patterns (not full C-language parsing) to know what to pull
out and cdef.
You can do this in the build process; once you've digested the
headers, it should remain valid for that platform more or less
indefinitely.
/s/ Adam