[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: (E)GLIBC: inline syscalls

The GNU/kFreeBSD port of the GNU libc uses normal syscalls (each syscall
is mapped to a function), while the GNU/Linux version only uses inline
syscalls (each syscall is mapped to asm inline code). The difference
mainly comes from the fact that the FreeBSD kernel is also using the
architecture ABI convention for the syscalls, while the Linux kernel
uses its own convention.

Unfortunately, there is one more problem, the signaling of failure
of a function and how to set up errno.

The Linux syscals return negative value between -1 and -4095,
the errno is this value negated.
The FreeBSD syscalls sets carry flag and return value is directly errno.
I have not found a way, how I can from gcc inline asm correctly test
carry flag using some specification of a register.
We have to put the check in one block of inline asm.

For i386 the situation is more complex. We need to pass up to 8
arguments to a syscall (especially when passing 64-bit values in
two arguments), which is exactly the number of registers we have on
this CPU. And they should in fine all be passed on the stack.

Does anyone has an idea of a technical solution (not gcc version
dependent) to get this working on i386? Does anyone has an opinion to
share about that?

There are two different macros INTERNAL_SYSCALL and INLINE_SYSCALL.
It remains to persuade Ulrich Drepper to distinct between them :-(

There is only limited number of INTERNAL_SYSCALL invocations,
which really might need direct inline asm. We could provide

#define INTERNAL_SYSCALL(name, err, nr, args...) INTERNAL_SYSCALL_##name(err,args...)

and provide only limited set of such entry point. The main problem is how in general detect whether an argument is 64bit value. For each function name we would know.


Reply to: