[[PATCH,RFC,2] 19/63] Y2038: add function __timespec_get64
Commit Message
---
sysdeps/unix/sysv/linux/timespec_get.c | 41 ++++++++++++++++++++++++++++++++++
time/Versions | 1 +
2 files changed, 42 insertions(+)
@@ -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;
+}
@@ -78,5 +78,6 @@ libc {
__clock_settime64;
__clock_getres64;
__clock_nanosleep64;
+ __timespec_get64;
}
}