diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-09-08 00:41:38 +0200 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-04-11 22:39:43 +0200 |
commit | 9330edc672c2c9c502ca854eaa34c536d9864819 (patch) | |
tree | f275f34e7ef2571de23d4c87ed82d0501e4f7980 /sysdeps | |
parent | 6e3710a0c6b342c279a09ae4f9c54ec0a54c8354 (diff) | |
download | glibc-9330edc672c2c9c502ca854eaa34c536d9864819.tar.gz |
Y2038: add function __timespec_get64
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/unix/sysv/linux/timespec_get.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/timespec_get.c b/sysdeps/unix/sysv/linux/timespec_get.c index b14a302ee9..b40bdedb57 100644 --- a/sysdeps/unix/sysv/linux/timespec_get.c +++ b/sysdeps/unix/sysv/linux/timespec_get.c @@ -44,3 +44,44 @@ timespec_get (struct timespec *ts, int base) return base; } + +/* 64-bit time version */ + +extern int __y2038_linux_support; + +int +__timespec_get64 (struct __timespec64 *ts, int base) +{ + switch (base) + { + int res; + INTERNAL_SYSCALL_DECL (err); + case TIME_UTC: + if (__y2038_linux_support) +/* Check that we are built with a 64-bit-time kernel */ +#ifdef __NR_clock_nanosleep64 + { + res = INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, ts); + } + else +#endif + { + res = -1; + __set_errno(ENOSYS); + } + if (res == -1 && errno == ENOSYS) + { + struct timespec ts32; + res = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, &ts32); + if (INTERNAL_SYSCALL_ERROR_P (res, err)) + return 0; + timespec_to_timespec64(&ts32, ts); + } + break; + + default: + return 0; + } + + return base; +} |