diff options
Diffstat (limited to 'newlib/libc/sys/linux/machine/i386/socketcall.h')
-rw-r--r-- | newlib/libc/sys/linux/machine/i386/socketcall.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/newlib/libc/sys/linux/machine/i386/socketcall.h b/newlib/libc/sys/linux/machine/i386/socketcall.h index 07908767f..afb1e5808 100644 --- a/newlib/libc/sys/linux/machine/i386/socketcall.h +++ b/newlib/libc/sys/linux/machine/i386/socketcall.h @@ -15,6 +15,30 @@ * PIC uses %ebx, so we need to save it during system calls */ +#ifdef __syscall_return + +#define __sockcall_base(type, name) \ +{ \ +long __res; \ +__asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%ebp),%%ecx; int $0x80; pop %%ebx" \ + : "=a" (__res) \ + : "0" (__NR_socketcall),"r" (SOCK_##name)); \ +__syscall_return(type,__res); \ +} + +#else /* !defined(__syscall_return) */ + +/* FIXME: we need to rewrite this for a vsyscall system. */ + +#define __syscall_return(type, res) \ +do { \ + if ((unsigned long)(res) >= (unsigned long)(-125)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type) (res); \ +} while (0) + #define __sockcall_base(type, name) \ { \ long __res; \ @@ -24,6 +48,8 @@ __asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%ebp),%%ecx; int $0x80; pop __syscall_return(type,__res); \ } +#endif /* !defined(__syscall_return) */ + #undef _sockcall1 #define _sockcall1(type,name,type1,arg1) \ type __libc_##name(type1 arg1) \ |