diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | include/time.h | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_settime.c | 36 |
3 files changed, 51 insertions, 4 deletions
@@ -1,3 +1,14 @@ +2019-10-10 Ćukasz Majewski <lukma@denx.de> + + * include/time.h (__clock_settime64): + Add __clock_settime alias according to __TIMESIZE define + * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime): + Refactor this function to be used only on 32 bit machines as a + wrapper on __clock_settime64. + * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64): Add + * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64): + Use clock_settime64 kernel syscall (available from 5.1+ Linux) + 2019-10-09 Adhemerval Zanella <adhemerval.zanella@linaro.org> * include/spawn.h (__posix_spawn_file_actions_addopen): New diff --git a/include/time.h b/include/time.h index f6dc731ac6..d93b16a781 100644 --- a/include/time.h +++ b/include/time.h @@ -125,6 +125,14 @@ extern __time64_t __timegm64 (struct tm *__tp) __THROW; libc_hidden_proto (__timegm64) #endif +#if __TIMESIZE == 64 +# define __clock_settime64 __clock_settime +#else +extern int __clock_settime64 (clockid_t clock_id, + const struct __timespec64 *tp); +libc_hidden_proto (__clock_settime64) +#endif + /* Compute the `struct tm' representation of T, offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c index f76178e0f6..fb48de5d50 100644 --- a/sysdeps/unix/sysv/linux/clock_settime.c +++ b/sysdeps/unix/sysv/linux/clock_settime.c @@ -20,11 +20,9 @@ #include <time.h> #include <shlib-compat.h> -#include "kernel-posix-cpu-timers.h" - /* Set CLOCK to value TP. */ int -__clock_settime (clockid_t clock_id, const struct timespec *tp) +__clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp) { /* Make sure the time cvalue is OK. */ if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) @@ -33,8 +31,38 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp) return -1; } - return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp); +#ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_clock_settime64 +# define __NR_clock_settime64 __NR_clock_settime +# endif + return INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp); +#else +# ifdef __NR_clock_settime64 + int ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp); + if (ret == 0 || errno != ENOSYS) + return ret; +# endif + if (! in_time_t_range (tp->tv_sec)) + { + __set_errno (EOVERFLOW); + return -1; + } + + struct timespec ts32 = valid_timespec64_to_timespec (*tp); + return INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32); +#endif } + +#if __TIMESIZE != 64 +int +__clock_settime (clockid_t clock_id, const struct timespec *tp) +{ + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*tp); + + return __clock_settime64 (clock_id, &ts64); +} +#endif + libc_hidden_def (__clock_settime) versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17); |