diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-09-08 00:41:47 +0200 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-10-24 12:53:27 +0200 |
commit | 9ae7229bb9bf3984c73d29deb1431eb17c19af90 (patch) | |
tree | 3dca1e93bb61e367cc7376c2291d4dcebd794515 /sysdeps | |
parent | a030a9e6b788b2a8542f18efb81f4a12ad01af08 (diff) | |
download | glibc-9ae7229bb9bf3984c73d29deb1431eb17c19af90.zip glibc-9ae7229bb9bf3984c73d29deb1431eb17c19af90.tar.gz glibc-9ae7229bb9bf3984c73d29deb1431eb17c19af90.tar.bz2 |
Y2038: add function __timer_settime64
For Linux this uses a 32-bit syscall, so it converts the syscall
input from 64-bit time into 32-bit time, and the syscall output
from 32-bit time into 64-bit time.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/unix/sysv/linux/arm/librt.abilist | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/timer_settime.c | 50 |
3 files changed, 52 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/arm/librt.abilist b/sysdeps/unix/sysv/linux/arm/librt.abilist index e18f5ee..b92173e 100644 --- a/sysdeps/unix/sysv/linux/arm/librt.abilist +++ b/sysdeps/unix/sysv/linux/arm/librt.abilist @@ -1,4 +1,5 @@ GLIBC_2.29 __timer_gettime64 F +GLIBC_2.29 __timer_settime64 F GLIBC_2.4 aio_cancel F GLIBC_2.4 aio_cancel64 F GLIBC_2.4 aio_error F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist index cb6ba72..e7774ee 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist @@ -28,6 +28,7 @@ GLIBC_2.2 timer_getoverrun F GLIBC_2.2 timer_gettime F GLIBC_2.2 timer_settime F GLIBC_2.29 __timer_gettime64 F +GLIBC_2.29 __timer_settime64 F GLIBC_2.3.4 mq_close F GLIBC_2.3.4 mq_getattr F GLIBC_2.3.4 mq_notify F diff --git a/sysdeps/unix/sysv/linux/timer_settime.c b/sysdeps/unix/sysv/linux/timer_settime.c index 7c938bd..bc876a9 100644 --- a/sysdeps/unix/sysv/linux/timer_settime.c +++ b/sysdeps/unix/sysv/linux/timer_settime.c @@ -20,6 +20,7 @@ #include <stdlib.h> #include <time.h> #include <sysdep.h> +#include <y2038-support.h> #include "kernel-posix-timers.h" @@ -41,3 +42,52 @@ timer_settime (timer_t timerid, int flags, const struct itimerspec *value, return res; } + +/* 64-bit time version */ + +int +__timer_settime64 (timer_t timerid, int flags, const struct itimerspec *value, + struct itimerspec *ovalue) +{ + int res; + struct timer *kt = (struct timer *) timerid; + struct itimerspec value32, ovalue32; + + if (value == NULL) + { + __set_errno(EFAULT); + return -1; + } + +#ifdef __NR_timer_settime64 + if (__y2038_get_kernel_support () > 0) + { + res = INLINE_SYSCALL (timer_settime, 3, kt->ktimerid, value, ovalue); + if (res == 0 || errno != ENOSYS) + return res; + __y2038_set_kernel_support (-1); + } +#endif + + if (value->it_value.tv_sec > INT_MAX + || value->it_interval.tv_sec > INT_MAX) + return EOVERFLOW; + + value32.it_value.tv_sec = value->it_value.tv_sec; + value32.it_value.tv_nsec = value->it_value.tv_nsec; + value32.it_interval.tv_sec = value->it_interval.tv_sec; + value32.it_interval.tv_nsec = value->it_interval.tv_nsec; + + res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags, + &value32, &ovalue32); + + if (res == 0 && ovalue != NULL) + { + ovalue->it_value.tv_sec = ovalue32.it_value.tv_sec; + ovalue->it_value.tv_nsec = ovalue32.it_value.tv_nsec; + ovalue->it_interval.tv_sec = ovalue32.it_interval.tv_sec; + ovalue->it_interval.tv_nsec = ovalue32.it_interval.tv_nsec; + } + + return res; +} |