[[PATCH RFC 2] 19/63] Y2038: add function __timespec_get64
Albert ARIBAUD (3ADEV)
albert.aribaud@3adev.fr
Wed Apr 18 20:20:00 GMT 2018
---
sysdeps/unix/sysv/linux/timespec_get.c | 41 ++++++++++++++++++++++++++++++++++
time/Versions | 1 +
2 files changed, 42 insertions(+)
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;
}
}
--
2.14.1
More information about the Libc-alpha
mailing list