From 779c35b7c4e47d9fc8f69ee582e822a2f6f45411 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 2 Feb 2010 23:07:24 +0100 Subject: time,times: stop interpreting negative return values ar errors Signed-off-by: Denys Vlasenko --- libc/sysdeps/linux/common/bits/syscalls-common.h | 17 +++++++++++++++++ libc/sysdeps/linux/common/time.c | 13 ++++++------- libc/sysdeps/linux/common/times.c | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/common/bits/syscalls-common.h b/libc/sysdeps/linux/common/bits/syscalls-common.h index 78bbf6c22..5e4e350c5 100644 --- a/libc/sysdeps/linux/common/bits/syscalls-common.h +++ b/libc/sysdeps/linux/common/bits/syscalls-common.h @@ -33,6 +33,9 @@ #ifndef INLINE_SYSCALL # define INLINE_SYSCALL(name, nr, args...) INLINE_SYSCALL_NCS(__NR_##name, nr, args) #endif +#ifndef INLINE_SYSCALL_NOERR +# define INLINE_SYSCALL_NOERR(name, nr, args...) INLINE_SYSCALL_NOERR_NCS(__NR_##name, nr, args) +#endif /* Just like INLINE_SYSCALL(), but take a non-constant syscall (NCS) argument */ #ifndef INLINE_SYSCALL_NCS @@ -47,6 +50,14 @@ __res; \ }) #endif +#ifndef INLINE_SYSCALL_NOERR_NCS +# define INLINE_SYSCALL_NOERR_NCS(name, nr, args...) \ +({ \ + INTERNAL_SYSCALL_DECL(__err); \ + long __res = INTERNAL_SYSCALL_NCS(name, __err, nr, args); \ + __res; \ +}) +#endif /* No point in forcing people to implement both when they only need one */ #ifndef INTERNAL_SYSCALL @@ -80,8 +91,14 @@ type name(C_DECL_ARGS_##nargs(args)) { \ return (type)INLINE_SYSCALL(name, nargs, C_ARGS_##nargs(args)); \ } +#define SYSCALL_NOERR_FUNC(nargs, type, name, args...) \ +type name(C_DECL_ARGS_##nargs(args)) { \ + return (type)INLINE_SYSCALL_NOERR(name, nargs, C_ARGS_##nargs(args)); \ +} + #define _syscall0(args...) SYSCALL_FUNC(0, args) #define _syscall1(args...) SYSCALL_FUNC(1, args) +#define _syscall_noerr1(args...) SYSCALL_NOERR_FUNC(1, args) #define _syscall2(args...) SYSCALL_FUNC(2, args) #define _syscall3(args...) SYSCALL_FUNC(3, args) #define _syscall4(args...) SYSCALL_FUNC(4, args) diff --git a/libc/sysdeps/linux/common/time.c b/libc/sysdeps/linux/common/time.c index 0d9e412bf..e13b44f4d 100644 --- a/libc/sysdeps/linux/common/time.c +++ b/libc/sysdeps/linux/common/time.c @@ -13,19 +13,18 @@ #ifdef __NR_time -_syscall1(time_t, time, time_t *, t) +_syscall_noerr1(time_t, time, time_t *, t) #else - time_t time(time_t * t) { time_t result; struct timeval tv; - if (gettimeofday(&tv, (struct timezone *) NULL)) { - result = (time_t) - 1; - } else { - result = (time_t) tv.tv_sec; - } + /* In Linux, gettimeofday fails only on bad parameter. + * We know that here parameter isn't bad. + */ + gettimeofday(&tv, NULL); + result = (time_t) tv.tv_sec; if (t != NULL) { *t = result; } diff --git a/libc/sysdeps/linux/common/times.c b/libc/sysdeps/linux/common/times.c index e71d1bd71..37ae040d4 100644 --- a/libc/sysdeps/linux/common/times.c +++ b/libc/sysdeps/linux/common/times.c @@ -11,5 +11,5 @@ #include -_syscall1(clock_t, times, struct tms *, buf) +_syscall_noerr1(clock_t, times, struct tms *, buf) libc_hidden_def(times) -- cgit v1.2.3 From 1043d24e77f82d729996fe8192b078e567b16113 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 2 Feb 2010 23:09:16 +0100 Subject: remove two checks for gettimeofday error Signed-off-by: Denys Vlasenko --- libc/sysdeps/linux/common/clock_gettime.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/common/clock_gettime.c b/libc/sysdeps/linux/common/clock_gettime.c index 888cd64b0..d3755a7a8 100644 --- a/libc/sysdeps/linux/common/clock_gettime.c +++ b/libc/sysdeps/linux/common/clock_gettime.c @@ -23,10 +23,12 @@ int clock_gettime(clockid_t clock_id, struct timespec* tp) switch (clock_id) { case CLOCK_REALTIME: - retval = gettimeofday(&tv, NULL); - if (retval == 0) { - TIMEVAL_TO_TIMESPEC(&tv, tp); - } + /* In Linux, gettimeofday fails only on bad parameter. + * We know that here parameter isn't bad. + */ + gettimeofday(&tv, NULL); + TIMEVAL_TO_TIMESPEC(&tv, tp); + retval = 0; break; default: -- cgit v1.2.3 From 80361b7c7421f4d7742e3a27b006ab9fe4420a32 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 3 Feb 2010 11:44:11 +0100 Subject: powerpc/bits/sysdep.h: move confusingly placed #undef Signed-off-by: Denys Vlasenko --- libc/sysdeps/linux/powerpc/bits/sysdep.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/powerpc/bits/sysdep.h b/libc/sysdeps/linux/powerpc/bits/sysdep.h index c42efbabd..478ebdd7a 100644 --- a/libc/sysdeps/linux/powerpc/bits/sysdep.h +++ b/libc/sysdeps/linux/powerpc/bits/sysdep.h @@ -182,7 +182,6 @@ # undef INTERNAL_SYSCALL_DECL # define INTERNAL_SYSCALL_DECL(err) long int err -# undef INTERNAL_SYSCALL # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ ({ \ register long int r0 __asm__ ("r0"); \ @@ -196,7 +195,7 @@ register long int r10 __asm__ ("r10"); \ register long int r11 __asm__ ("r11"); \ register long int r12 __asm__ ("r12"); \ - LOADARGS_##nr(name, args); \ + LOADARGS_##nr(name, args); \ __asm__ __volatile__ \ ("sc \n\t" \ "mfcr %0" \ @@ -208,6 +207,7 @@ err = r0; \ (int) r3; \ }) +# undef INTERNAL_SYSCALL # define INTERNAL_SYSCALL(name, err, nr, args...) \ INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args) @@ -218,11 +218,11 @@ # undef INTERNAL_SYSCALL_ERRNO # define INTERNAL_SYSCALL_ERRNO(val, err) (val) -# define LOADARGS_0(name, dummy) \ +# define LOADARGS_0(name, dummy) \ r0 = name # define LOADARGS_1(name, __arg1) \ - long int arg1 = (long int) (__arg1); \ - LOADARGS_0(name, 0); \ + long int arg1 = (long int) (__arg1); \ + LOADARGS_0(name, 0); \ extern void __illegally_sized_syscall_arg1 (void); \ if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \ __illegally_sized_syscall_arg1 (); \ -- cgit v1.2.3 From 5d5b6fe5f898ce6ef260b1648aaaf7f12a8c7988 Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Wed, 3 Feb 2010 12:12:10 -0800 Subject: Unbreak build for sparc on some config's Thanks to rob@landley.net Signed-off-by: Austin Foxley --- libc/sysdeps/linux/sparc/sigaction.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/sparc/sigaction.c b/libc/sysdeps/linux/sparc/sigaction.c index a22ac40af..7140fd3a4 100644 --- a/libc/sysdeps/linux/sparc/sigaction.c +++ b/libc/sysdeps/linux/sparc/sigaction.c @@ -34,7 +34,8 @@ _syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e); static void __rt_sigreturn_stub(void); static void __sigreturn_stub(void); -int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) +libc_hidden_proto(sigaction) +int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { int ret; struct sigaction kact, koact; @@ -65,10 +66,8 @@ int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oac return ret; } -#ifndef LIBC_SIGACTION -weak_alias(__libc_sigaction,sigaction) -libc_hidden_weak(sigaction) -#endif +libc_hidden_def(sigaction) +weak_alias(sigaction,__libc_sigaction) static void __rt_sigreturn_stub(void) -- cgit v1.2.3 From df1580676a48dc3a9faf7e508ad3ec822a8e5a05 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 5 Feb 2010 19:19:08 +0100 Subject: prctl: silence shadow warnings Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/prctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/common/prctl.c b/libc/sysdeps/linux/common/prctl.c index a6764c532..39c0d4fb0 100644 --- a/libc/sysdeps/linux/common/prctl.c +++ b/libc/sysdeps/linux/common/prctl.c @@ -13,5 +13,5 @@ #ifdef __NR_prctl extern int prctl (int, long, long, long, long); -_syscall5(int, prctl, int, option, long, arg2, long, arg3, long, arg4, long, arg5) +_syscall5(int, prctl, int, option, long, _a2, long, _a3, long, _a4, long, _a5) #endif -- cgit v1.2.3