From db7033a958fbb8e4bb4adb4cba7ab5298af2b969 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 9 Jun 2004 20:43:43 +0000 Subject: [PATCH] 2004-06-09 Jeff Johnston * libc/sys/linux/Makefile.am: Change siglist.inc to be generated from /usr/include/asm/signal.h instead of kernel sources. Also default max to 32 if not found in header file. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/machine/i386/socketcall.h: Fix for Fedora Core 2 systems where __syscall_return is not defined. * libc/sys/linux/machine/i386/syscall.h: Change for Fedora Core 2 systems to use syscall() function instead of assembler interrupt. --- newlib/ChangeLog | 11 ++ newlib/libc/sys/linux/Makefile.am | 5 +- newlib/libc/sys/linux/Makefile.in | 5 +- .../libc/sys/linux/machine/i386/socketcall.h | 26 ++++ newlib/libc/sys/linux/machine/i386/syscall.h | 118 +++++++++++++----- 5 files changed, 130 insertions(+), 35 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 5377f63f8..c23c73e35 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,14 @@ +2004-06-09 Jeff Johnston + + * libc/sys/linux/Makefile.am: Change siglist.inc to be generated + from /usr/include/asm/signal.h instead of kernel sources. Also + default max to 32 if not found in header file. + * libc/sys/linux/Makefile.in: Regenerated. + * libc/sys/linux/machine/i386/socketcall.h: Fix for Fedora Core 2 + systems where __syscall_return is not defined. + * libc/sys/linux/machine/i386/syscall.h: Change for Fedora Core 2 + systems to use syscall() function instead of assembler interrupt. + 2004-06-09 Toralf Lund * libc/sys/arm/setjmp.S, libc/sys/arm/access.c: Move diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am index 1579368c3..56842cebb 100644 --- a/newlib/libc/sys/linux/Makefile.am +++ b/newlib/libc/sys/linux/Makefile.am @@ -166,7 +166,7 @@ endif # This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1) # and also /usr/src/linux/include/asm/signal.h in older versions of Red Hat Linux -SIGNAL_H = /usr/src/$(shell ls /usr/src/ | grep ^linux | head -n 1)/include/asm/signal.h +SIGNAL_H = /usr/include/asm/signal.h liblinux_la_LDFLAGS = -Xcompiler -nostdlib @@ -230,7 +230,8 @@ machine/crt0.o: ; @true sig.$(oext): siglist.inc siglist.inc: - $(AWK) '/#define.SIG.*[1-9][0-9]*/ { n[$$3] = $$2 } \ + $(AWK) '{ max = 32 } \ + /#define.SIG.*[1-9][0-9]*/ { n[$$3] = $$2 } \ /#define.NSIG.*[1-9][0-9]*/ { max = $$3 } \ /#define.SIGUNUSED/ \ { for (i = 0; i <= max; i++) print "\"" n[i] "\"," }' \ diff --git a/newlib/libc/sys/linux/Makefile.in b/newlib/libc/sys/linux/Makefile.in index 5b548c797..3f110fab2 100644 --- a/newlib/libc/sys/linux/Makefile.in +++ b/newlib/libc/sys/linux/Makefile.in @@ -127,7 +127,7 @@ ELIX_4_OBJS = getlogin.$(oext) getpwnam.$(oext) getpwuid.$(oext) stack.$(oe # This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1) # and also /usr/src/linux/include/asm/signal.h in older versions of Red Hat Linux -SIGNAL_H = /usr/src/$(shell ls /usr/src/ | grep ^linux | head -n 1)/include/asm/signal.h +SIGNAL_H = /usr/include/asm/signal.h liblinux_la_LDFLAGS = -Xcompiler -nostdlib @@ -590,7 +590,8 @@ machine/crt0.o: ; @true sig.$(oext): siglist.inc siglist.inc: - $(AWK) '/#define.SIG.*[1-9][0-9]*/ { n[$$3] = $$2 } \ + $(AWK) '{ max = 32 } \ + /#define.SIG.*[1-9][0-9]*/ { n[$$3] = $$2 } \ /#define.NSIG.*[1-9][0-9]*/ { max = $$3 } \ /#define.SIGUNUSED/ \ { for (i = 0; i <= max; i++) print "\"" n[i] "\"," }' \ 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,8 @@ * PIC uses %ebx, so we need to save it during system calls */ +#ifdef __syscall_return + #define __sockcall_base(type, name) \ { \ long __res; \ @@ -24,6 +26,30 @@ __asm__ volatile ("push %%ebx; movl %2,%%ebx; lea 8(%%ebp),%%ecx; int $0x80; pop __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; \ +__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); \ +} + +#endif /* !defined(__syscall_return) */ + #undef _sockcall1 #define _sockcall1(type,name,type1,arg1) \ type __libc_##name(type1 arg1) \ diff --git a/newlib/libc/sys/linux/machine/i386/syscall.h b/newlib/libc/sys/linux/machine/i386/syscall.h index 380f1bcdf..2dbb84f55 100644 --- a/newlib/libc/sys/linux/machine/i386/syscall.h +++ b/newlib/libc/sys/linux/machine/i386/syscall.h @@ -8,6 +8,7 @@ #include #include #include +#include /* @@ -23,6 +24,8 @@ * PIC uses %ebx, so we need to save it during system calls */ +#ifdef __syscall_return + #undef __inline_syscall0 #define __inline_syscall0(name,ret) \ __asm__ volatile ("int $0x80" \ @@ -77,11 +80,6 @@ __inline_syscall0(name,__res) \ __syscall_return(type,__res); \ } -#undef _syscall0 -#define _syscall0(type,name) \ -_syscall0_base(type,name) \ -weak_alias(__libc_##name,name); - #undef _syscall1_base #define _syscall1_base(type,name,type1,arg1) \ type __libc_##name (type1 arg1) \ @@ -91,11 +89,6 @@ __inline_syscall1(name,__res,arg1) \ __syscall_return(type,__res); \ } -#undef _syscall1 -#define _syscall1(type,name,type1,arg1) \ -_syscall1_base(type,name,type1,arg1) \ -weak_alias(__libc_##name,name); - #undef _syscall2_base #define _syscall2_base(type,name,type1,arg1,type2,arg2) \ type __libc_##name (type1 arg1,type2 arg2) \ @@ -105,11 +98,6 @@ __inline_syscall2(name,__res,arg1,arg2) \ __syscall_return(type,__res); \ } -#undef _syscall2 -#define _syscall2(type,name,type1,arg1,type2,arg2) \ -_syscall2_base(type,name,type1,arg1,type2,arg2) \ -weak_alias(__libc_##name,name); - #undef _syscall3_base #define _syscall3_base(type,name,type1,arg1,type2,arg2,type3,arg3) \ type __libc_##name (type1 arg1,type2 arg2,type3 arg3) \ @@ -119,11 +107,6 @@ __inline_syscall3(name,__res,arg1,arg2,arg3) \ __syscall_return(type,__res); \ } -#undef _syscall3 -#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -_syscall3_base(type,name,type1,arg1,type2,arg2,type3,arg3) \ -weak_alias(__libc_##name,name); - #undef _syscall4_base #define _syscall4_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ type __libc_##name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ @@ -133,11 +116,6 @@ __inline_syscall4(name,__res,arg1,arg2,arg3,arg4) \ __syscall_return(type,__res); \ } -#undef _syscall4 -#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -_syscall4_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -weak_alias(__libc_##name,name); - #undef _syscall5_base #define _syscall5_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5) \ @@ -148,12 +126,6 @@ __inline_syscall5(name,__res,arg1,arg2,arg3,arg4,arg5) \ __syscall_return(type,__res); \ } \ -#undef _syscall5 -#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5) \ -_syscall5_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ -weak_alias(__libc_##name,name); - #undef _syscall6_base #define _syscall6_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5,type6,arg6) \ @@ -164,6 +136,90 @@ __inline_syscall6(name,__res,arg1,arg2,arg3,arg4,arg5,arg6) \ __syscall_return(type,__res); \ } +#else /* !__syscall_return */ + +#undef _syscall0_base +#define _syscall0_base(type,name) \ +type __libc_##name (void) \ +{ \ + return (type)syscall (__NR_##name); \ +} + +#undef _syscall1_base +#define _syscall1_base(type,name,type1,arg1) \ +type __libc_##name (type1 arg1) \ +{ \ + return (type)syscall (__NR_##name, arg1); \ +} + +#undef _syscall2_base +#define _syscall2_base(type,name,type1,arg1,type2,arg2) \ +type __libc_##name (type1 arg1, type2 arg2) \ +{ \ + return (type)syscall (__NR_##name, arg1, arg2); \ +} + +#undef _syscall3_base +#define _syscall3_base(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type __libc_##name (type1 arg1, type2 arg2, type3 arg3) \ +{ \ + return (type)syscall (__NR_##name, arg1, arg2, arg3); \ +} + +#undef _syscall4_base +#define _syscall4_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type __libc_##name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ + return (type)syscall (__NR_##name, arg1, arg2, arg3, arg4); \ +} + +#undef _syscall5_base +#define _syscall5_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ +type __libc_##name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +{ \ + return (type)syscall (__NR_##name, arg1, arg2, arg3, arg4, arg5); \ +} + +#undef _syscall6_base +#define _syscall6_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ +type __libc_##name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ +{ \ + return (type)syscall (__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ +} + +#endif /* !__syscall_return */ + +#undef _syscall0 +#define _syscall0(type,name) \ +_syscall0_base(type,name) \ +weak_alias(__libc_##name,name); + +#undef _syscall1 +#define _syscall1(type,name,type1,arg1) \ +_syscall1_base(type,name,type1,arg1) \ +weak_alias(__libc_##name,name); + +#undef _syscall2 +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +_syscall2_base(type,name,type1,arg1,type2,arg2) \ +weak_alias(__libc_##name,name); + +#undef _syscall3 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +_syscall3_base(type,name,type1,arg1,type2,arg2,type3,arg3) \ +weak_alias(__libc_##name,name); + +#undef _syscall4 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +_syscall4_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +weak_alias(__libc_##name,name); + +#undef _syscall5 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +_syscall5_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ +weak_alias(__libc_##name,name); + #undef _syscall6 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5,type6,arg6) \