[Various] errno assignment in _syscall macros and glibc

Andreas Jaeger aj@suse.de
Sun Jun 25 23:46:00 GMT 2000


On the MIPS list is currently a discussion about the inclusion of
<asm/unistd.h> in <sys/syscalls.h> (I'm appending some emails from the
discussion below).  <asm/unistd.h> contains all those __NR_* defines
for the syscalls (which we also get via <bits/syscall.h> as SYS_) and
also syscall defines which use errno directly (here's the ia32 version):
#define __syscall_return(type, res) \
do { \
        if ((unsigned long)(res) >= (unsigned long)(-125)) { \
                errno = -(res); \
                res = -1; \
        } \
        return (type) (res); \
} while (0)

Since these are obviously wrong for glibc, we shouldn't import them at
all.

What shall we do?  I would remove just the inclusion of <asm/unistd.h>
from <sys/syscalls.h>.

Ralf seems to even suggest to remove <sys/syscalls.h> completly.

The manual page for llseek mentions:
       _syscall5(int,  _llseek,  uint,  fd, ulong, hi, ulong, lo,
       loff_t *, res, uint, wh);

_syscall5 uses __syscall_return.  Either we should forbid _syscall5
etc. or we should add in <sys/syscalls.h> a multithread-safe version
instead of the broken one from the kernel.

What do you think?

Andreas



More information about the Libc-alpha mailing list