This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: support for calling Linux syscalls directly

> > But in reality I often end up with several testcases broken the same way
> > because they shared common ancestors and were copied all over with just
> > a slight modification. Complicated pieces of code are simply not worth
> > of duplication. I would rather have single place where I can fix bug in
> > way how syscall done because this code is complicated enough and does
> > exactly the same work in each project.
> >
> > There are, on the other hand, duplications that makes sense because the
> > resulting projects have different objectives. In LTP posix conformance
> > tests overlaps fairly with libc tests, which is fine.
> >
> If you want generic system call stubs you may want to look at the ones 
> in klibc.

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));
	return syscall(__NR_fallocate, fd, mode, offset, len);

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
#error "unshare not supported on this architecure."

or copies data structures needed for syscalls:

#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.

Cyril Hrubis

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]