OSDN Git Service

time,times: stop interpreting negative return values ar errors
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Feb 2010 22:07:24 +0000 (23:07 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Feb 2010 22:07:24 +0000 (23:07 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libc/sysdeps/linux/common/bits/syscalls-common.h
libc/sysdeps/linux/common/time.c
libc/sysdeps/linux/common/times.c

index 78bbf6c..5e4e350 100644 (file)
@@ -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
        __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)
index 0d9e412..e13b44f 100644 (file)
 
 
 #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;
        }
index e71d1bd..37ae040 100644 (file)
@@ -11,5 +11,5 @@
 #include <sys/times.h>
 
 
-_syscall1(clock_t, times, struct tms *, buf)
+_syscall_noerr1(clock_t, times, struct tms *, buf)
 libc_hidden_def(times)