summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-09-08 00:41:38 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-04-18 06:54:13 +0200
commit818d45cc49c268591b8a185ecaaa7b0b98a8fa24 (patch)
tree6f132feae94d4a1796f94491390adf1ebc6f8f84
parentf4d2d74d440f1ec592b5f91eb7529254ed86dfc7 (diff)
downloadglibc-818d45cc49c268591b8a185ecaaa7b0b98a8fa24.tar.gz
Y2038: add function __timespec_get64
-rw-r--r--sysdeps/unix/sysv/linux/timespec_get.c41
-rw-r--r--time/Versions1
2 files changed, 42 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;
+}
diff --git a/time/Versions b/time/Versions
index 6fe9373913..668c134f12 100644
--- a/time/Versions
+++ b/time/Versions
@@ -78,5 +78,6 @@ libc {
__clock_settime64;
__clock_getres64;
__clock_nanosleep64;
+ __timespec_get64;
}
}