[RFC 09/12] y2038: Convert __xclock_gettime to be Y2038 safe

Lukasz Majewski lukma@denx.de
Mon Jun 1 14:07:37 GMT 2020


The clock_gettime has been replaced with Y2038 safe __clock_gettime64.
Morevoer, the struct timespec has been replaced with struct __timespec64.
---
 support/xclock_gettime.c | 4 ++--
 support/xtime.h          | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/support/xclock_gettime.c b/support/xclock_gettime.c
index fed397b784..6d32c00847 100644
--- a/support/xclock_gettime.c
+++ b/support/xclock_gettime.c
@@ -21,9 +21,9 @@
 #include <support/xthread.h>
 
 void
-__xclock_gettime (clockid_t clockid, struct timespec *ts)
+__xclock_gettime (clockid_t clockid, struct __timespec64 *ts)
 {
-  const int ret = clock_gettime (clockid, ts);
+  const int ret = __clock_gettime64 (clockid, ts);
   if (ret < 0)
     FAIL_EXIT1 ("clock_gettime (%d): %m",
                 clockid);
diff --git a/support/xtime.h b/support/xtime.h
index 0fce19a78d..f04dac14fd 100644
--- a/support/xtime.h
+++ b/support/xtime.h
@@ -27,7 +27,7 @@ __BEGIN_DECLS
 /* The following functions call the corresponding libc functions and
    terminate the process on error.  */
 
-void __xclock_gettime (clockid_t clock, struct timespec *ts);
+void __xclock_gettime (clockid_t clock, struct __timespec64 *ts);
 
 /* This helper can often simplify tests by avoiding an explicit
    variable declaration or allowing that declaration to be const. */
-- 
2.20.1



More information about the Libc-alpha mailing list