This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: support for calling Linux syscalls directly
On 02/12/2013 11:42 AM, chrubis@suse.cz wrote:
>
> Thanks for the pointer, there are a few syscall definitions there but
> it's far from complete. Some LTP testcases do carry a code like this:
>
> static inline long fallocate(int fd, int mode, loff_t offset, loff_t len)
> {
> #if __WORDSIZE == 32
> return (long)syscall(__NR_fallocate, fd, mode,
> __LONG_LONG_PAIR((off_t) (offset >> 32),
> (off_t) offset),
> __LONG_LONG_PAIR((off_t) (len >> 32),
> (off_t) len));
> #else
> return syscall(__NR_fallocate, fd, mode, offset, len);
> #endif
> }
>
> or contains definitions like this:
>
> #ifndef SYS_unshare
> #ifdef __NR_unshare
> #define SYS_unshare __NR_unshare
> #elif __i386__
> #define SYS_unshare 310
> #elif __ia64__
> #define SYS_unshare 1296
> #elif __x86_64__
> #define SYS_unshare 272
> #elif __s390x__ || __s390__
> #define SYS_unshare 303
> #elif __powerpc__
> #define SYS_unshare 282
> #else
> #error "unshare not supported on this architecure."
> #endif
> #endif
>
> or copies data structures needed for syscalls:
>
> #undef SA_RESTORER
> #define HAVE_SA_RESTORER
> #define SA_RESTORER 0x04000000
>
> struct kernel_sigaction {
> __sighandler_t k_sa_handler;
> unsigned long sa_flags;
> void (*sa_restorer) (void);
> sigset_t sa_mask;
> };
>
> ...
>
>
> And it's copied over and over. It would be be really cool is to have a
> common place for this code. The klibc may be a good starting point but
> not definitive answer.
>
Some of that you get from uapi; stuff like fallocate() and related evil
is exactly what klibc, uclibc, and glibc does. No, there is no database
and noone is really planning to write one at this point.
-hpa