diff options
| author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2009-01-22 16:04:28 +0000 |
|---|---|---|
| committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2009-01-22 16:04:28 +0000 |
| commit | 91772298b0377ab805e19085f60a7808fe62d157 (patch) | |
| tree | 520a9015fd8ce7aebbd503814b5758dfe9b07cba /libc/sysdeps/linux | |
| parent | 2f22f00640b79531879bf21afc9727483934ac65 (diff) | |
| download | uClibc-alpine-91772298b0377ab805e19085f60a7808fe62d157.tar.bz2 uClibc-alpine-91772298b0377ab805e19085f60a7808fe62d157.tar.xz | |
Synch with trunk: miscellaneous changes, mostly cleanup,
code styling, comments. No object-code changes.
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/sysdeps/linux')
| -rw-r--r-- | libc/sysdeps/linux/arm/posix_fadvise.c | 19 | ||||
| -rw-r--r-- | libc/sysdeps/linux/arm/posix_fadvise64.c | 17 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/_exit.c | 10 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/bits/sigcontext.h | 3 | ||||
| -rw-r--r-- | libc/sysdeps/linux/i386/posix_fadvise64.S | 26 | ||||
| -rw-r--r-- | libc/sysdeps/linux/ia64/bits/syscalls.h | 191 |
6 files changed, 170 insertions, 96 deletions
diff --git a/libc/sysdeps/linux/arm/posix_fadvise.c b/libc/sysdeps/linux/arm/posix_fadvise.c index bb4ac7b0c..b23eb3d6b 100644 --- a/libc/sysdeps/linux/arm/posix_fadvise.c +++ b/libc/sysdeps/linux/arm/posix_fadvise.c @@ -9,12 +9,21 @@ */ #include <sys/syscall.h> #include <fcntl.h> + #if defined __NR_arm_fadvise64_64 + +/* Was named __libc_posix_fadvise for some inexplicable reason. +** google says only uclibc has *__libc*_posix_fadviseXXX, +** so it cannot be compat with anything. +** +** Remove this comment and one at the end after 0.9.31 +*/ + /* This is for the ARM version of fadvise64_64 which swaps the params * * about to avoid having ABI compat issues * */ #define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64 -int __libc_posix_fadvise(int fd, off_t offset, off_t len, int advise) +int posix_fadvise(int fd, off_t offset, off_t len, int advise) { INTERNAL_SYSCALL_DECL (err); int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise, @@ -24,13 +33,15 @@ int __libc_posix_fadvise(int fd, off_t offset, off_t len, int advise) if (INTERNAL_SYSCALL_ERROR_P (ret, err)) return INTERNAL_SYSCALL_ERRNO (ret, err); return 0; - } -weak_alias(__libc_posix_fadvise, posix_fadvise); + +/* weak_alias(__libc_posix_fadvise, posix_fadvise); */ + #else + int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused) { return ENOSYS; } -#endif +#endif diff --git a/libc/sysdeps/linux/arm/posix_fadvise64.c b/libc/sysdeps/linux/arm/posix_fadvise64.c index 479b0c5a2..4b27381d1 100644 --- a/libc/sysdeps/linux/arm/posix_fadvise64.c +++ b/libc/sysdeps/linux/arm/posix_fadvise64.c @@ -20,11 +20,19 @@ #ifdef __UCLIBC_HAS_LFS__ #if defined __NR_arm_fadvise64_64 + +/* Was named __libc_posix_fadvise64 for some inexplicable reason. +** google says only uclibc has *__libc*_posix_fadviseXXX, +** so it cannot be compat with anything. +** +** Remove this comment and one at the end after 0.9.31 +*/ + /* This is for the ARM version of fadvise64_64 which swaps the params * about to avoid having ABI compat issues */ #define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64 -int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise) +int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise) { INTERNAL_SYSCALL_DECL (err); int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise, @@ -36,11 +44,16 @@ int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise) return INTERNAL_SYSCALL_ERRNO (ret, err); return 0; } -weak_alias(__libc_posix_fadvise64, posix_fadvise64); + +/* weak_alias(__libc_posix_fadvise64, posix_fadvise64); */ + #else + int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise) { return ENOSYS; } + #endif + #endif diff --git a/libc/sysdeps/linux/common/_exit.c b/libc/sysdeps/linux/common/_exit.c index 518a6d2e8..a0b891d25 100644 --- a/libc/sysdeps/linux/common/_exit.c +++ b/libc/sysdeps/linux/common/_exit.c @@ -12,6 +12,9 @@ #include <unistd.h> #include <sys/types.h> #include <sys/syscall.h> +#ifdef __UCLIBC_HAS_THREADS__ +#include <sysdep.h> +#endif /* libc_hidden_proto(_exit) */ @@ -25,6 +28,13 @@ void attribute_noreturn _exit(int status) { /* The loop is added only to keep gcc happy. */ while(1) + { +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# ifdef __NR_exit_group + INLINE_SYSCALL(exit_group, 1, status); +# endif +#endif INLINE_SYSCALL(exit, 1, status); + } } libc_hidden_def(_exit) diff --git a/libc/sysdeps/linux/common/bits/sigcontext.h b/libc/sysdeps/linux/common/bits/sigcontext.h index 67dcf9498..35bf5bc89 100644 --- a/libc/sysdeps/linux/common/bits/sigcontext.h +++ b/libc/sysdeps/linux/common/bits/sigcontext.h @@ -25,5 +25,8 @@ we need sigcontext. */ # define sigcontext_struct sigcontext +# ifndef __user +# define __user +# endif # include <asm/sigcontext.h> #endif diff --git a/libc/sysdeps/linux/i386/posix_fadvise64.S b/libc/sysdeps/linux/i386/posix_fadvise64.S index b99b35ee7..17f006aa8 100644 --- a/libc/sysdeps/linux/i386/posix_fadvise64.S +++ b/libc/sysdeps/linux/i386/posix_fadvise64.S @@ -22,10 +22,17 @@ #include <bits/errno.h> #include <sys/syscall.h> +/* Was named __libc_posix_fadvise64 for some inexplicable reason. +** google says only uclibc has *__libc*_posix_fadviseXXX, +** so it cannot be compat with anything. +** +** Remove this comment and one at the end after 0.9.31 +*/ + .text -.global __libc_posix_fadvise64 -.type __libc_posix_fadvise64,%function -__libc_posix_fadvise64: +.global posix_fadvise64 +.type posix_fadvise64,%function +posix_fadvise64: #if defined __NR_fadvise64_64 /* Save regs */ pushl %ebp @@ -91,10 +98,11 @@ overflow: /* Successful; return the syscall's value. */ ret -.size __libc_posix_fadvise64,.-__libc_posix_fadvise64 - -libc_hidden_def(__libc_posix_fadvise64) -#if defined __UCLIBC_HAS_LFS__ && defined __UCLIBC_HAS_ADVANCED_REALTIME__ -weak_alias(__libc_posix_fadvise64,posix_fadvise64) -#endif +.size posix_fadvise64,.-posix_fadvise64 +/* +** libc_hidden_def(__libc_posix_fadvise64) +** #if defined __UCLIBC_HAS_LFS__ && defined __UCLIBC_HAS_ADVANCED_REALTIME__ +** weak_alias(__libc_posix_fadvise64,posix_fadvise64) +** #endif +*/ diff --git a/libc/sysdeps/linux/ia64/bits/syscalls.h b/libc/sysdeps/linux/ia64/bits/syscalls.h index 0c3d6ca3a..6722da933 100644 --- a/libc/sysdeps/linux/ia64/bits/syscalls.h +++ b/libc/sysdeps/linux/ia64/bits/syscalls.h @@ -30,30 +30,118 @@ #include <errno.h> -#define SYS_ify(syscall_name) (__NR_##syscall_name) - #undef IA64_USE_NEW_STUB -/* taken from asm-ia64/break.h */ +#undef _syscall0 +#define _syscall0(type,name) \ + type name(void) \ +{ \ +return (type) (INLINE_SYSCALL(name, 0)); \ +} + +#undef _syscall1 +#define _syscall1(type,name,type1,arg1) \ + type name(type1 arg1) \ +{ \ +return (type) (INLINE_SYSCALL(name, 1, arg1)); \ +} + +#undef _syscall2 +#define _syscall2(type,name,type1,arg1,type2,arg2) \ + type name(type1 arg1,type2 arg2) \ +{ \ +return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \ +} + +#undef _syscall3 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ + type name(type1 arg1,type2 arg2,type3 arg3) \ +{ \ +return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \ +} +#undef _syscall4 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ + type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ +return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \ +} + +#undef _syscall5 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +{ \ +return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \ +} + +#undef _syscall6 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ +{ \ +return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \ +} + #define __IA64_BREAK_SYSCALL 0x100000 -#define ___IA64_BREAK_SYSCALL "0x100000" - -#define _DO_SYSCALL(name, nr, args...) \ - LOAD_ARGS_##nr (args) \ - register long _r8 __asm__ ("r8"); \ - register long _r10 __asm__ ("r10"); \ - register long _r15 __asm__ ("r15") = SYS_ify(name); \ - long _retval; \ - LOAD_REGS_##nr \ - __asm__ __volatile__ ("break " ___IA64_BREAK_SYSCALL ";;\n\t" \ - : "=r" (_r8), "=r" (_r10), "=r" (_r15) ASM_OUTARGS_##nr \ - : "2" (_r15) ASM_ARGS_##nr \ - : "memory" ASM_CLOBBERS_##nr); \ - _retval = _r8; \ - if (_r10 == -1) { \ - __set_errno (_retval); \ - _retval = -1; \ - } + +/* mostly taken from glibc sysdeps/unix/sysv/linux/ia64/sysdep.h */ +#define BREAK_INSN_1(num) "break " #num ";;\n\t" +#define BREAK_INSN(num) BREAK_INSN_1(num) + +/* On IA-64 we have stacked registers for passing arguments. The + "out" registers end up being the called function's "in" + registers. + + Also, since we have plenty of registers we have two return values + from a syscall. r10 is set to -1 on error, whilst r8 contains the + (non-negative) errno on error or the return value on success. + */ + +# define DO_INLINE_SYSCALL_NCS(name, nr, args...) \ + LOAD_ARGS_##nr (args) \ + register long _r8 __asm__ ("r8"); \ + register long _r10 __asm__ ("r10"); \ + register long _r15 __asm__ ("r15") = name; \ + long _retval; \ + LOAD_REGS_##nr \ + __asm __volatile (BREAK_INSN (__IA64_BREAK_SYSCALL) \ + : "=r" (_r8), "=r" (_r10), "=r" (_r15) \ + ASM_OUTARGS_##nr \ + : "2" (_r15) ASM_ARGS_##nr \ + : "memory" ASM_CLOBBERS_##nr); \ + _retval = _r8; + +#define DO_INLINE_SYSCALL(name, nr, args...) \ + DO_INLINE_SYSCALL_NCS (__NR_##name, nr, ##args) + +#undef INLINE_SYSCALL +#define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + DO_INLINE_SYSCALL_NCS (__NR_##name, nr, args) \ + if (_r10 == -1) \ + { \ + __set_errno (_retval); \ + _retval = -1; \ + } \ + _retval; }) + +#undef INTERNAL_SYSCALL_DECL +#define INTERNAL_SYSCALL_DECL(err) long int err + +#undef INTERNAL_SYSCALL +#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ + ({ \ + DO_INLINE_SYSCALL_NCS (name, nr, args) \ + err = _r10; \ + _retval; }) +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args) + +#undef INTERNAL_SYSCALL_ERROR_P +#define INTERNAL_SYSCALL_ERROR_P(val, err) (err == -1) + +#undef INTERNAL_SYSCALL_ERRNO +#define INTERNAL_SYSCALL_ERRNO(val, err) (val) #define LOAD_ARGS_0() #define LOAD_REGS_0 @@ -102,15 +190,6 @@ #define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4) #define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5) -#ifdef IA64_USE_NEW_STUB -#define ASM_ARGS_0 -#define ASM_ARGS_1 ASM_ARGS_0, "4" (_out0) -#define ASM_ARGS_2 ASM_ARGS_1, "5" (_out1) -#define ASM_ARGS_3 ASM_ARGS_2, "6" (_out2) -#define ASM_ARGS_4 ASM_ARGS_3, "7" (_out3) -#define ASM_ARGS_5 ASM_ARGS_4, "8" (_out4) -#define ASM_ARGS_6 ASM_ARGS_5, "9" (_out5) -#else #define ASM_ARGS_0 #define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0) #define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1) @@ -118,7 +197,6 @@ #define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3) #define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4) #define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5) -#endif #define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0" #define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1" @@ -126,6 +204,7 @@ #define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3" #define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4" #define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5" +#define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON , "b7" #define ASM_CLOBBERS_6_COMMON , "out6", "out7", \ /* Non-stacked integer registers, minus r8, r10, r15. */ \ "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \ @@ -138,55 +217,5 @@ /* Branch registers. */ \ "b6" -#ifdef IA64_USE_NEW_STUB -# define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON -#else -# define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON , "b7" -#endif - - - -#define _syscall0(type,name) \ -type name(void) \ -{ \ - _DO_SYSCALL(name, 0); return (type) _retval; \ -} - -#define _syscall1(type,name,type1,arg1) \ -type name(type1 arg1) \ -{ \ - _DO_SYSCALL(name, 1, arg1); return (type) _retval; \ -} - -#define _syscall2(type,name,type1,arg1,type2,arg2) \ -type name(type1 arg1, type2 arg2) \ -{ \ - _DO_SYSCALL(name, 2, arg1, arg2); return (type) _retval; \ -} - -#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -type name(type1 arg1, type2 arg2, type3 arg3) \ -{ \ - _DO_SYSCALL(name, 3, arg1, arg2, arg3); return (type) _retval; \ -} - -#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -{ \ - _DO_SYSCALL(name, 4, arg1, arg2, arg3, arg4); return (type) _retval; \ -} - -#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ -{ \ - _DO_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); return (type) _retval; \ -} - -#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ -{ \ - _DO_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); return (type) _retval; \ -} - #endif /* __ASSEMBLER__ */ #endif /* _BITS_SYSCALLS_H */ |
