[RFC,46/52] Y2038: add function __ntp_gettime_t64
Commit Message
Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
sysdeps/unix/sysv/linux/Versions | 1 +
sysdeps/unix/sysv/linux/ntp_gettime.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
@@ -178,5 +178,6 @@ libc {
GLIBC_Y2038 {
__msgctl_t64;
+ __ntp_gettime_t64;
}
}
@@ -18,6 +18,7 @@
#define ntp_gettime ntp_gettime_redirect
#include <sys/timex.h>
+#include <include/time.h>
#undef ntp_gettime
@@ -39,3 +40,27 @@ ntp_gettime (struct ntptimeval *ntv)
ntv->esterror = tntx.esterror;
return result;
}
+
+/* The 64-bit-time version */
+
+extern int __y2038_linux_support;
+
+int
+__ntp_gettime_t64 (struct __ntptimeval_t64 *ntv)
+{
+ struct timex tntx;
+ int result;
+
+ if (__y2038_linux_support)
+ {
+ // TODO: use 64-bit syscall if possible
+ }
+
+ tntx.modes = 0;
+ result = __adjtimex (&tntx);
+ ntv->time.tv_sec = tntx.time.tv_sec;
+ ntv->time.tv_usec = tntx.time.tv_usec;
+ ntv->maxerror = tntx.maxerror;
+ ntv->esterror = tntx.esterror;
+ return result;
+}