diff options
-rw-r--r-- | include/time.h | 7 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/timer_gettime.c | 44 |
2 files changed, 47 insertions, 4 deletions
diff --git a/include/time.h b/include/time.h index 1eb3d82740..51c0fce580 100644 --- a/include/time.h +++ b/include/time.h @@ -179,6 +179,13 @@ extern int __futimens64 (int fd, const struct __timespec64 tsp[2]); libc_hidden_proto (__futimens64); #endif +#if __TIMESIZE == 64 +# define __timer_gettime64 __timer_gettime +#else +extern int __timer_gettime64 (timer_t timerid, struct __itimerspec64 *value); +libc_hidden_proto (__timer_gettime64); +#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/timer_gettime.c b/sysdeps/unix/sysv/linux/timer_gettime.c index 8d9bef9196..20d34dbfa9 100644 --- a/sysdeps/unix/sysv/linux/timer_gettime.c +++ b/sysdeps/unix/sysv/linux/timer_gettime.c @@ -20,15 +20,51 @@ #include <stdlib.h> #include <time.h> #include <sysdep.h> +#include <kernel-features.h> #include "kernel-posix-timers.h" int -timer_gettime (timer_t timerid, struct itimerspec *value) +__timer_gettime64 (timer_t timerid, struct __itimerspec64 *value) { struct timer *kt = (struct timer *) timerid; - /* Delete the kernel timer object. */ - int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value); +#ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_timer_gettime64 +# define __NR_timer_gettime64 __NR_timer_gettime +# endif + return INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value); +#else +# ifdef __NR_timer_gettime64 + int ret = INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value); + if (ret == 0 || errno != ENOSYS) + return ret; +# endif + struct itimerspec its32; + int retval = INLINE_SYSCALL_CALL (timer_gettime, kt->ktimerid, &its32); + if (retval == 0) + { + value->it_interval = valid_timespec_to_timespec64 (its32.it_interval); + value->it_value = valid_timespec_to_timespec64 (its32.it_value); + } - return res; + return retval; +#endif } + +#if __TIMESIZE != 64 +int +__timer_gettime (timer_t timerid, struct itimerspec *value) +{ + struct __itimerspec64 its64; + int retval = __timer_gettime64 (timerid, &its64); + if (retval == 0) + { + value->it_interval = valid_timespec64_to_timespec (its64.it_interval); + value->it_value = valid_timespec64_to_timespec (its64.it_value); + } + + return retval; +} +#endif +weak_alias (__timer_gettime, timer_gettime) +libc_hidden_def (timer_gettime) |