diff mbox series

[RFC,12/12] y2038: Convert timespec_* from posix-timer.h to be Y2038 safe

Message ID 20200601140740.16371-13-lukma@denx.de
State Dropped
Delegated to: Lukasz Majewski
Headers show
Series y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe | expand

Commit Message

Lukasz Majewski June 1, 2020, 2:07 p.m. UTC
Static inline functions - timespec_compare, timespec_sum and
timespec_diff - from ./sysdeps/pthread/posix-timer.h have been
converted to support 64 bit time on ports with __WORDSIZE == 32
&& __TIMESIZE != 64.
The change was focused on using struct __timespec64.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 sysdeps/pthread/posix-timer.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h
index 312cf2b3bd..f6572480c9 100644
--- a/sysdeps/pthread/posix-timer.h
+++ b/sysdeps/pthread/posix-timer.h
@@ -115,7 +115,8 @@  timer_delref (struct timer_node *timer)
 /* Timespec helper routines.  */
 static inline int
 __attribute ((always_inline))
-__timespec_compare (const struct timespec *left, const struct timespec *right)
+__timespec_compare (const struct __timespec64 *left,
+                    const struct __timespec64 *right)
 {
   if (left->tv_sec < right->tv_sec)
     return -1;
@@ -131,8 +132,8 @@  __timespec_compare (const struct timespec *left, const struct timespec *right)
 }
 
 static inline void
-__timespec_add (struct timespec *sum, const struct timespec *left,
-                const struct timespec *right)
+__timespec_add (struct __timespec64 *sum, const struct __timespec64 *left,
+                const struct __timespec64 *right)
 {
   sum->tv_sec = left->tv_sec + right->tv_sec;
   sum->tv_nsec = left->tv_nsec + right->tv_nsec;
@@ -145,8 +146,8 @@  __timespec_add (struct timespec *sum, const struct timespec *left,
 }
 
 static inline void
-__timespec_sub (struct timespec *diff, const struct timespec *left,
-                const struct timespec *right)
+__timespec_sub (struct __timespec64 *diff, const struct __timespec64 *left,
+                const struct __timespec64 *right)
 {
   diff->tv_sec = left->tv_sec - right->tv_sec;
   diff->tv_nsec = left->tv_nsec - right->tv_nsec;