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

Message ID 20200707150827.20899-3-lukma@denx.de
State Dropped
Delegated to: Lukasz Majewski
Headers
Series y2038: nptl: futex: Provide support for futex_time64 |

Commit Message

Lukasz Majewski July 7, 2020, 3:08 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(-)
  

Patch

diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h
index 81fc8a2394..86bb123b7a 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;