unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe
@ 2020-06-01 14:07 Lukasz Majewski
  2020-06-01 14:07 ` [RFC 01/12] doc: Fix wording and formattine in ./support/README Lukasz Majewski
                   ` (13 more replies)
  0 siblings, 14 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

This patch set is the first attempt to convert functions utilized by nptl and
pthreads to support 64 bit time.

First timespec* functions are renamed to have common "__" prefix for internal
functions. This is a preparatory work for further conversion.

One question with this patch set is how shall we tackle the conversion
of time related functions (like e.g. ./support/timespec_add) used internally in
glibc as helper functions for internal code or tests.
I could follow the approach used for glibc syscalls (like clock_settime) to have
two versions depending on __TIMESIZE and __WORDSIZE, but this seems to be an
overkill for internally used functions.

Patches with "Convert:" prefix replace struct timespec with struct __timespec64
in timespec_* functions. This is necessary to have in-glibc proper support for
64 bit time.
The problem is with instant replacement of struct timespec with struct 
__timespec64 in glibc internal code (and tests). 

For replacing timesize with __timesize64 I could:
- Replace its occurences in relevant directories - like ./nptl or
  ./sysdeps/pthreads

- Replace them in functions (tests) and use explicit conversion functions - like
  valid_timespec_to_timespec64()

- Replace _all_ occurences of struct timespec with struct __timespec64 at once
  with using sed on glibc tree.

The last option seems to be the most appealing as we already use __timespec64
(with its aliassing) for some core system syscalls (like clock_gettime).
However, such patch shall be applied just after the release of new stable
version to have time for potential fixes.

Lukasz Majewski (12):
  doc: Fix wording and formattine in ./support/README
  y2038: Rename timespec_compare to __timespec_compare
  y2038: Rename make_timespec to __make_timespec
  y2038: Rename xclock_gettime to __xclock_gettime
  y2038: Rename xclock_now to __xclock_now
  y2038: Rename timespec_sub to __timespec_sub
  y2038: Rename timespec_add to __timespec_add
  y2038: Convert __make_timespec to be Y2038 safe
  y2038: Convert __xclock_gettime to be Y2038 safe
  y2038: Convert __xclock_now to be Y2038 safe
  y2038: Convert timespec* files in ./support to be Y2038 safe
  y2038: Convert timespec_* from posix-timer.h to be Y2038 safe

 nptl/tst-eintr2.c                |  4 ++--
 nptl/tst-eintr5.c                |  4 ++--
 nptl/tst-rwlock6.c               | 14 +++++++-------
 nptl/tst-rwlock7.c               | 10 +++++-----
 nptl/tst-rwlock9.c               | 10 +++++-----
 nptl/tst-sem17.c                 |  2 +-
 nptl/tst-sem5.c                  |  4 ++--
 support/README                   |  4 ++--
 support/timespec-add.c           | 12 ++++++------
 support/timespec-sub.c           | 18 +++++++++---------
 support/timespec.c               | 12 ++++++------
 support/timespec.h               | 27 ++++++++++++++-------------
 support/xclock_gettime.c         |  5 ++---
 support/xtime.h                  |  9 +++++----
 sysdeps/mach/clock_nanosleep.c   |  4 ++--
 sysdeps/pthread/posix-timer.h    | 11 ++++++-----
 sysdeps/pthread/timer_gettime.c  |  4 ++--
 sysdeps/pthread/timer_routines.c | 14 +++++++-------
 sysdeps/pthread/timer_settime.c  |  4 ++--
 sysdeps/pthread/tst-cond11.c     |  2 +-
 sysdeps/pthread/tst-cond26.c     |  2 +-
 sysdeps/pthread/tst-cond27.c     |  4 ++--
 sysdeps/pthread/tst-join14.c     |  2 +-
 sysdeps/pthread/tst-join3.c      |  8 ++++----
 sysdeps/pthread/tst-join5.c      | 12 ++++++------
 sysdeps/pthread/tst-mutex5.c     | 12 ++++++------
 sysdeps/pthread/tst-mutex9.c     |  4 ++--
 sysdeps/pthread/tst-rwlock14.c   |  2 +-
 28 files changed, 111 insertions(+), 109 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [RFC 01/12] doc: Fix wording and formattine in ./support/README
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 02/12] y2038: Rename timespec_compare to __timespec_compare Lukasz Majewski
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

---
 support/README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/support/README b/support/README
index ae2c41caa8..bbd3d588f2 100644
--- a/support/README
+++ b/support/README
@@ -4,8 +4,8 @@ not) and tests.
 
 # Error-checking wrappers
 
-These wrappers test for error return codes an terminate the process on
-error.  They are declared in these header files:
+These wrappers test for error return codes and terminate the process on
+error. They are declared in these header files:
 
 * support.h
 * xsignal.h
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 02/12] y2038: Rename timespec_compare to __timespec_compare
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
  2020-06-01 14:07 ` [RFC 01/12] doc: Fix wording and formattine in ./support/README Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 03/12] y2038: Rename make_timespec to __make_timespec Lukasz Majewski
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

As the timespec_compare is used locally in glibc, its name shall begin with
"__". This change adds this prefix.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 sysdeps/pthread/posix-timer.h    | 2 +-
 sysdeps/pthread/timer_gettime.c  | 2 +-
 sysdeps/pthread/timer_routines.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h
index 81fc8a2394..7d9207e23d 100644
--- a/sysdeps/pthread/posix-timer.h
+++ b/sysdeps/pthread/posix-timer.h
@@ -115,7 +115,7 @@ 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 timespec *left, const struct timespec *right)
 {
   if (left->tv_sec < right->tv_sec)
     return -1;
diff --git a/sysdeps/pthread/timer_gettime.c b/sysdeps/pthread/timer_gettime.c
index 5723e5f818..6cbf87f434 100644
--- a/sysdeps/pthread/timer_gettime.c
+++ b/sysdeps/pthread/timer_gettime.c
@@ -51,7 +51,7 @@ timer_gettime (timer_t timerid, struct itimerspec *value)
       if (armed)
 	{
 	  __clock_gettime (clock, &now);
-	  if (timespec_compare (&now, &expiry) < 0)
+	  if (__timespec_compare (&now, &expiry) < 0)
 	    timespec_sub (&value->it_value, &expiry, &now);
 	  else
 	    {
diff --git a/sysdeps/pthread/timer_routines.c b/sysdeps/pthread/timer_routines.c
index 05e83d7d52..be9b09a832 100644
--- a/sysdeps/pthread/timer_routines.c
+++ b/sysdeps/pthread/timer_routines.c
@@ -383,7 +383,7 @@ thread_func (void *arg)
 	      /* If the timer is due or overdue, remove it from the queue.
 		 If it's a periodic timer, re-compute its new time and
 		 requeue it.  Either way, perform the timer expiry. */
-	      if (timespec_compare (&now, &timer->expirytime) < 0)
+	      if (__timespec_compare (&now, &timer->expirytime) < 0)
 		break;
 
 	      list_unlink_ip (first);
@@ -394,7 +394,7 @@ thread_func (void *arg)
 		  timer->overrun_count = 0;
 		  timespec_add (&timer->expirytime, &timer->expirytime,
 				&timer->value.it_interval);
-		  while (timespec_compare (&timer->expirytime, &now) < 0)
+		  while (__timespec_compare (&timer->expirytime, &now) < 0)
 		    {
 		      timespec_add (&timer->expirytime, &timer->expirytime,
 				    &timer->value.it_interval);
@@ -447,7 +447,7 @@ __timer_thread_queue_timer (struct thread_node *thread,
     {
       struct timer_node *timer = timer_links2ptr (iter);
 
-      if (timespec_compare (&insert->expirytime, &timer->expirytime) < 0)
+      if (__timespec_compare (&insert->expirytime, &timer->expirytime) < 0)
 	  break;
       athead = 0;
     }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 03/12] y2038: Rename make_timespec to __make_timespec
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
  2020-06-01 14:07 ` [RFC 01/12] doc: Fix wording and formattine in ./support/README Lukasz Majewski
  2020-06-01 14:07 ` [RFC 02/12] y2038: Rename timespec_compare to __timespec_compare Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 04/12] y2038: Rename xclock_gettime to __xclock_gettime Lukasz Majewski
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

As the make_timespec is used locally in glibc, its name shall begin with
"__". This change adds this prefix.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 nptl/tst-eintr2.c            | 2 +-
 nptl/tst-eintr5.c            | 2 +-
 nptl/tst-rwlock6.c           | 2 +-
 nptl/tst-rwlock7.c           | 2 +-
 nptl/tst-sem17.c             | 2 +-
 nptl/tst-sem5.c              | 2 +-
 support/timespec-add.c       | 2 +-
 support/timespec-sub.c       | 2 +-
 support/timespec.h           | 2 +-
 sysdeps/pthread/tst-cond26.c | 2 +-
 sysdeps/pthread/tst-cond27.c | 2 +-
 sysdeps/pthread/tst-join14.c | 2 +-
 sysdeps/pthread/tst-join3.c  | 4 ++--
 sysdeps/pthread/tst-join5.c  | 6 +++---
 sysdeps/pthread/tst-mutex5.c | 6 +++---
 sysdeps/pthread/tst-mutex9.c | 2 +-
 16 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/nptl/tst-eintr2.c b/nptl/tst-eintr2.c
index 4f26ccad04..eba8065236 100644
--- a/nptl/tst-eintr2.c
+++ b/nptl/tst-eintr2.c
@@ -38,7 +38,7 @@ static void *
 tf1 (void *arg)
 {
   struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
-                                     make_timespec (10000, 0));
+                                     __make_timespec (10000, 0));
 
   /* This call must never return.  */
   int e = pthread_mutex_timedlock (&m1, &ts);
diff --git a/nptl/tst-eintr5.c b/nptl/tst-eintr5.c
index bc6c0fef53..4edfbaaef6 100644
--- a/nptl/tst-eintr5.c
+++ b/nptl/tst-eintr5.c
@@ -39,7 +39,7 @@ static void *
 tf (void *arg)
 {
   struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
-                                     make_timespec (10000, 0));
+                                     __make_timespec (10000, 0));
 
   /* This call must never return.  */
   TEST_COMPARE (pthread_cond_timedwait (&c, &m, &ts), 0);
diff --git a/nptl/tst-rwlock6.c b/nptl/tst-rwlock6.c
index 36afa22da4..8714381a16 100644
--- a/nptl/tst-rwlock6.c
+++ b/nptl/tst-rwlock6.c
@@ -63,7 +63,7 @@ tf (void *arg)
   xclock_gettime (clockid_for_get, &ts_start);
 
   struct timespec ts_timeout = timespec_add (ts_start,
-                                             make_timespec (0, 300000000));
+                                             __make_timespec (0, 300000000));
 
   verbose_printf ("child calling %srdlock\n", fnname);
 
diff --git a/nptl/tst-rwlock7.c b/nptl/tst-rwlock7.c
index 1dcc4f0425..bdbfb5dac9 100644
--- a/nptl/tst-rwlock7.c
+++ b/nptl/tst-rwlock7.c
@@ -61,7 +61,7 @@ tf (void *arg)
   struct timespec ts_start;
   xclock_gettime (clockid_for_get, &ts_start);
   const struct timespec ts_timeout = timespec_add (ts_start,
-                                                   make_timespec (0, 300000000));
+                                                   __make_timespec (0, 300000000));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
     TEST_COMPARE (pthread_rwlock_timedwrlock (r, &ts_timeout), ETIMEDOUT);
diff --git a/nptl/tst-sem17.c b/nptl/tst-sem17.c
index 80658b85c7..090e390507 100644
--- a/nptl/tst-sem17.c
+++ b/nptl/tst-sem17.c
@@ -35,7 +35,7 @@ do_test (void)
   sem_t s;
   TEST_COMPARE (sem_init (&s, 0, 1), 0);
 
-  const struct timespec ts = make_timespec (0, 0);
+  const struct timespec ts = __make_timespec (0, 0);
 
   /* These clocks are meaningless to sem_clockwait.  */
 #if defined(CLOCK_PROCESS_CPUTIME_ID)
diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c
index 766274e50d..8f5c5b9bb1 100644
--- a/nptl/tst-sem5.c
+++ b/nptl/tst-sem5.c
@@ -42,7 +42,7 @@ do_test_clock (clockid_t clockid)
 
   /* We wait for half a second.  */
   xclock_gettime (clockid_for_get, &ts);
-  ts = timespec_add (ts, make_timespec (0, TIMESPEC_HZ/2));
+  ts = timespec_add (ts, __make_timespec (0, TIMESPEC_HZ/2));
 
   errno = 0;
   TEST_COMPARE (TEMP_FAILURE_RETRY ((clockid == CLOCK_USE_TIMEDWAIT)
diff --git a/support/timespec-add.c b/support/timespec-add.c
index 57bf6682e1..bb22b12e9b 100644
--- a/support/timespec-add.c
+++ b/support/timespec-add.c
@@ -61,5 +61,5 @@ timespec_add (struct timespec a, struct timespec b)
         }
     }
 
-  return make_timespec (rs, rns);
+  return __make_timespec (rs, rns);
 }
diff --git a/support/timespec-sub.c b/support/timespec-sub.c
index a1d1a8df92..535a3b155b 100644
--- a/support/timespec-sub.c
+++ b/support/timespec-sub.c
@@ -61,5 +61,5 @@ timespec_sub (struct timespec a, struct timespec b)
         }
     }
 
-  return make_timespec (rs, rns);
+  return __make_timespec (rs, rns);
 }
diff --git a/support/timespec.h b/support/timespec.h
index c5852dfe75..dbe12938d8 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -30,7 +30,7 @@ struct timespec timespec_sub (struct timespec, struct timespec)
   __attribute__((const));
 
 static inline struct timespec
-make_timespec (time_t s, long int ns)
+__make_timespec (time_t s, long int ns)
 {
   struct timespec r;
   r.tv_sec = s;
diff --git a/sysdeps/pthread/tst-cond26.c b/sysdeps/pthread/tst-cond26.c
index e647da00c2..5caf7aaaa7 100644
--- a/sysdeps/pthread/tst-cond26.c
+++ b/sysdeps/pthread/tst-cond26.c
@@ -36,7 +36,7 @@ do_test (void)
 {
   xpthread_mutex_lock (&mut);
 
-  const struct timespec ts = make_timespec (0, 0);
+  const struct timespec ts = __make_timespec (0, 0);
 
   /* These clocks are meaningless to sem_clockwait.  */
 #if defined(CLOCK_PROCESS_CPUTIME_ID)
diff --git a/sysdeps/pthread/tst-cond27.c b/sysdeps/pthread/tst-cond27.c
index c8142abf9e..3d7b8240b1 100644
--- a/sysdeps/pthread/tst-cond27.c
+++ b/sysdeps/pthread/tst-cond27.c
@@ -42,7 +42,7 @@ do_test_clock (clockid_t clockid)
   /* Waiting for the condition will fail.  But we want the timeout here.  */
   const struct timespec ts_now = xclock_now (clockid);
   const struct timespec ts_timeout =
-    timespec_add (ts_now, make_timespec (0, 500000000));
+    timespec_add (ts_now, __make_timespec (0, 500000000));
 
   /* In theory pthread_cond_clockwait could return zero here due to
      spurious wakeup. However that can't happen without a signal or an
diff --git a/sysdeps/pthread/tst-join14.c b/sysdeps/pthread/tst-join14.c
index 0109324453..092f454449 100644
--- a/sysdeps/pthread/tst-join14.c
+++ b/sysdeps/pthread/tst-join14.c
@@ -34,7 +34,7 @@
 static void *
 tf (void *arg)
 {
-  struct timespec ts = make_timespec(0, 100000);
+  struct timespec ts = __make_timespec(0, 100000);
   nanosleep(&ts, NULL);
 
   return (void *) 42l;
diff --git a/sysdeps/pthread/tst-join3.c b/sysdeps/pthread/tst-join3.c
index ffebcf586f..fc54f12cc9 100644
--- a/sysdeps/pthread/tst-join3.c
+++ b/sysdeps/pthread/tst-join3.c
@@ -54,7 +54,7 @@ do_test_clock (clockid_t clockid)
 
   void *status;
   struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
-                                          make_timespec (0, 200000000));
+                                          __make_timespec (0, 200000000));
 
   int val;
   if (clockid == CLOCK_USE_TIMEDJOIN)
@@ -69,7 +69,7 @@ do_test_clock (clockid_t clockid)
   while (1)
     {
       timeout = timespec_add (xclock_now (clockid_for_get),
-                              make_timespec (0, 200000000));
+                              __make_timespec (0, 200000000));
 
       if (clockid == CLOCK_USE_TIMEDJOIN)
         val = pthread_timedjoin_np (th, &status, &timeout);
diff --git a/sysdeps/pthread/tst-join5.c b/sysdeps/pthread/tst-join5.c
index acdc365c05..525f349a4b 100644
--- a/sysdeps/pthread/tst-join5.c
+++ b/sysdeps/pthread/tst-join5.c
@@ -46,15 +46,15 @@ thread_join (pthread_t thread, void **retval)
 {
 #if defined USE_PTHREAD_TIMEDJOIN_NP
   const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
-                                           make_timespec (1000, 0));
+                                           __make_timespec (1000, 0));
   return pthread_timedjoin_np (thread, retval, &ts);
 #elif defined USE_PTHREAD_CLOCKJOIN_NP_REALTIME
   const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
-                                           make_timespec (1000, 0));
+                                           __make_timespec (1000, 0));
   return pthread_clockjoin_np (thread, retval, CLOCK_REALTIME, &ts);
 #elif defined USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC
   const struct timespec ts = timespec_add (xclock_now (CLOCK_MONOTONIC),
-                                           make_timespec (1000, 0));
+                                           __make_timespec (1000, 0));
   return pthread_clockjoin_np (thread, retval, CLOCK_MONOTONIC, &ts);
 #else
   return pthread_join (thread, retval);
diff --git a/sysdeps/pthread/tst-mutex5.c b/sysdeps/pthread/tst-mutex5.c
index 14490768c3..72fdbdaea5 100644
--- a/sysdeps/pthread/tst-mutex5.c
+++ b/sysdeps/pthread/tst-mutex5.c
@@ -68,7 +68,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
 
   /* Wait 2 seconds.  */
   struct timespec ts_timeout = timespec_add (xclock_now (clockid_for_get),
-                                             make_timespec (2, 0));
+                                             __make_timespec (2, 0));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
     TEST_COMPARE (pthread_mutex_timedlock (&m, &ts_timeout), ETIMEDOUT);
@@ -89,7 +89,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
   const struct timespec ts_start = xclock_now (CLOCK_REALTIME);
 
   /* Wait 2 seconds.  */
-  ts_timeout = timespec_add (ts_start, make_timespec (2, 0));
+  ts_timeout = timespec_add (ts_start, __make_timespec (2, 0));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
     TEST_COMPARE (pthread_mutex_timedlock (&m, &ts_timeout), 0);
@@ -100,7 +100,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
 
   /* Check that timedlock didn't delay.  We use a limit of 0.1 secs.  */
   TEST_TIMESPEC_BEFORE (ts_end,
-                        timespec_add (ts_start, make_timespec (0, 100000000)));
+                        timespec_add (ts_start, __make_timespec (0, 100000000)));
 
   TEST_COMPARE (pthread_mutex_unlock (&m), 0);
   TEST_COMPARE (pthread_mutex_destroy (&m), 0);
diff --git a/sysdeps/pthread/tst-mutex9.c b/sysdeps/pthread/tst-mutex9.c
index 2d7927b7c2..d03a22b97a 100644
--- a/sysdeps/pthread/tst-mutex9.c
+++ b/sysdeps/pthread/tst-mutex9.c
@@ -102,7 +102,7 @@ do_test_clock (clockid_t clockid)
         FAIL_EXIT1 ("child: mutex_unlock succeeded");
 
       const struct timespec ts = timespec_add (xclock_now (clockid_for_get),
-                                               make_timespec (0, 500000000));
+                                               __make_timespec (0, 500000000));
 
       if (clockid == CLOCK_USE_TIMEDLOCK)
         TEST_COMPARE (pthread_mutex_timedlock (m, &ts), ETIMEDOUT);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 04/12] y2038: Rename xclock_gettime to __xclock_gettime
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (2 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 03/12] y2038: Rename make_timespec to __make_timespec Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 05/12] y2038: Rename xclock_now to __xclock_now Lukasz Majewski
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

As the xclock_gettime is used locally in glibc, its name shall begin with
"__". This change adds this prefix.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 nptl/tst-rwlock6.c             | 10 +++++-----
 nptl/tst-rwlock7.c             |  6 +++---
 nptl/tst-rwlock9.c             |  4 ++--
 nptl/tst-sem5.c                |  2 +-
 support/timespec.h             |  4 ++--
 support/xclock_gettime.c       |  3 +--
 support/xtime.h                |  5 +++--
 sysdeps/pthread/tst-cond11.c   |  2 +-
 sysdeps/pthread/tst-rwlock14.c |  2 +-
 9 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/nptl/tst-rwlock6.c b/nptl/tst-rwlock6.c
index 8714381a16..ade2b3050b 100644
--- a/nptl/tst-rwlock6.c
+++ b/nptl/tst-rwlock6.c
@@ -60,7 +60,7 @@ tf (void *arg)
 
   /* Timeout: 0.3 secs.  */
   struct timespec ts_start;
-  xclock_gettime (clockid_for_get, &ts_start);
+  __xclock_gettime (clockid_for_get, &ts_start);
 
   struct timespec ts_timeout = timespec_add (ts_start,
                                              __make_timespec (0, 300000000));
@@ -77,7 +77,7 @@ tf (void *arg)
 
   TEST_TIMESPEC_NOW_OR_AFTER (CLOCK_REALTIME, ts_timeout);
 
-  xclock_gettime (clockid_for_get, &ts_timeout);
+  __xclock_gettime (clockid_for_get, &ts_timeout);
   ts_timeout.tv_sec += 10;
   /* Note that the following operation makes ts invalid.  */
   ts_timeout.tv_nsec += 1000000000;
@@ -117,7 +117,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
         FAIL_EXIT1 ("round %Zu: rwlockattr_destroy failed\n", cnt);
 
       struct timespec ts;
-      xclock_gettime (clockid_for_get, &ts);
+      __xclock_gettime (clockid_for_get, &ts);
       ++ts.tv_sec;
 
       /* Get a write lock.  */
@@ -130,7 +130,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
 
       verbose_printf ("1st %swrlock done\n", fnname);
 
-      xclock_gettime (clockid_for_get, &ts);
+      __xclock_gettime (clockid_for_get, &ts);
       ++ts.tv_sec;
       if (clockid == CLOCK_USE_TIMEDLOCK)
         TEST_COMPARE (pthread_rwlock_timedrdlock (&r, &ts), EDEADLK);
@@ -139,7 +139,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
 
       verbose_printf ("1st %srdlock done\n", fnname);
 
-      xclock_gettime (clockid_for_get, &ts);
+      __xclock_gettime (clockid_for_get, &ts);
       ++ts.tv_sec;
       if (clockid == CLOCK_USE_TIMEDLOCK)
         TEST_COMPARE (pthread_rwlock_timedwrlock (&r, &ts), EDEADLK);
diff --git a/nptl/tst-rwlock7.c b/nptl/tst-rwlock7.c
index bdbfb5dac9..7dcb2d17ae 100644
--- a/nptl/tst-rwlock7.c
+++ b/nptl/tst-rwlock7.c
@@ -59,7 +59,7 @@ tf (void *arg)
 
   /* Timeout: 0.3 secs.  */
   struct timespec ts_start;
-  xclock_gettime (clockid_for_get, &ts_start);
+  __xclock_gettime (clockid_for_get, &ts_start);
   const struct timespec ts_timeout = timespec_add (ts_start,
                                                    __make_timespec (0, 300000000));
 
@@ -73,7 +73,7 @@ tf (void *arg)
   TEST_TIMESPEC_NOW_OR_AFTER (clockid_for_get, ts_timeout);
 
   struct timespec ts_invalid;
-  xclock_gettime (clockid_for_get, &ts_invalid);
+  __xclock_gettime (clockid_for_get, &ts_invalid);
   ts_invalid.tv_sec += 10;
   /* Note that the following operation makes ts invalid.  */
   ts_invalid.tv_nsec += 1000000000;
@@ -113,7 +113,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
         FAIL_EXIT1 ("round %Zu: rwlockattr_destroy failed\n", cnt);
 
       struct timespec ts;
-      xclock_gettime (clockid_for_get, &ts);
+      __xclock_gettime (clockid_for_get, &ts);
 
       ++ts.tv_sec;
 
diff --git a/nptl/tst-rwlock9.c b/nptl/tst-rwlock9.c
index 408bbcdd5d..f35ed6feaa 100644
--- a/nptl/tst-rwlock9.c
+++ b/nptl/tst-rwlock9.c
@@ -73,7 +73,7 @@ writer_thread (void *arg)
       int e;
       do
 	{
-	  xclock_gettime (clockid_for_get, &ts);
+	  __xclock_gettime (clockid_for_get, &ts);
 
           ts = timespec_add (ts, timeout);
           ts = timespec_add (ts, timeout);
@@ -120,7 +120,7 @@ reader_thread (void *arg)
       int e;
       do
 	{
-	  xclock_gettime (clockid_for_get, &ts);
+	  __xclock_gettime (clockid_for_get, &ts);
 
           ts = timespec_add (ts, timeout);
 
diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c
index 8f5c5b9bb1..611fff3e69 100644
--- a/nptl/tst-sem5.c
+++ b/nptl/tst-sem5.c
@@ -41,7 +41,7 @@ do_test_clock (clockid_t clockid)
   TEST_COMPARE (TEMP_FAILURE_RETRY (sem_wait (&s)), 0);
 
   /* We wait for half a second.  */
-  xclock_gettime (clockid_for_get, &ts);
+  __xclock_gettime (clockid_for_get, &ts);
   ts = timespec_add (ts, __make_timespec (0, TIMESPEC_HZ/2));
 
   errno = 0;
diff --git a/support/timespec.h b/support/timespec.h
index dbe12938d8..08df1d473b 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -57,7 +57,7 @@ void test_timespec_equal_or_after_impl (const char *file, int line,
   ({                                                            \
     struct timespec now;                                        \
     const int saved_errno = errno;                              \
-    xclock_gettime ((clockid), &now);                           \
+    __xclock_gettime ((clockid), &now);                         \
     TEST_TIMESPEC_BEFORE ((left), now);                         \
     errno = saved_errno;                                        \
   })
@@ -71,7 +71,7 @@ void test_timespec_equal_or_after_impl (const char *file, int line,
   ({                                                            \
     struct timespec now;                                        \
     const int saved_errno = errno;                              \
-    xclock_gettime ((clockid), &now);                           \
+    __xclock_gettime ((clockid), &now);                         \
     TEST_TIMESPEC_EQUAL_OR_AFTER (now, (right));                \
     errno = saved_errno;                                        \
   })
diff --git a/support/xclock_gettime.c b/support/xclock_gettime.c
index 47f78016a0..fed397b784 100644
--- a/support/xclock_gettime.c
+++ b/support/xclock_gettime.c
@@ -21,8 +21,7 @@
 #include <support/xthread.h>
 
 void
-xclock_gettime (clockid_t clockid,
-                struct timespec *ts)
+__xclock_gettime (clockid_t clockid, struct timespec *ts)
 {
   const int ret = clock_gettime (clockid, ts);
   if (ret < 0)
diff --git a/support/xtime.h b/support/xtime.h
index 65edbb01d3..0912ead0ec 100644
--- a/support/xtime.h
+++ b/support/xtime.h
@@ -20,13 +20,14 @@
 #define SUPPORT_TIME_H
 
 #include <time.h>
+#include <struct___timespec64.h>
 
 __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 timespec *ts);
 
 /* This helper can often simplify tests by avoiding an explicit
    variable declaration or allowing that declaration to be const. */
@@ -34,7 +35,7 @@ void xclock_gettime (clockid_t clock, struct timespec *ts);
 static inline struct timespec xclock_now (clockid_t clock)
 {
   struct timespec ts;
-  xclock_gettime (clock, &ts);
+  __xclock_gettime (clock, &ts);
   return ts;
 }
 
diff --git a/sysdeps/pthread/tst-cond11.c b/sysdeps/pthread/tst-cond11.c
index 209e2f0c8d..5d510859a0 100644
--- a/sysdeps/pthread/tst-cond11.c
+++ b/sysdeps/pthread/tst-cond11.c
@@ -61,7 +61,7 @@ run_test (clockid_t attr_clock, clockid_t wait_clock)
   TEST_COMPARE (pthread_mutex_lock (&mut), EDEADLK);
 
   struct timespec ts_timeout;
-  xclock_gettime (wait_clock == CLOCK_USE_ATTR_CLOCK ? attr_clock : wait_clock,
+  __xclock_gettime (wait_clock == CLOCK_USE_ATTR_CLOCK ? attr_clock : wait_clock,
                   &ts_timeout);
 
   /* Wait one second.  */
diff --git a/sysdeps/pthread/tst-rwlock14.c b/sysdeps/pthread/tst-rwlock14.c
index 3583b19e3c..225bfae486 100644
--- a/sysdeps/pthread/tst-rwlock14.c
+++ b/sysdeps/pthread/tst-rwlock14.c
@@ -52,7 +52,7 @@ do_test (void)
 {
   struct timespec ts;
 
-  xclock_gettime (CLOCK_REALTIME, &ts);
+  __xclock_gettime (CLOCK_REALTIME, &ts);
   xpthread_barrier_init (&b, NULL, 2);
 
   pthread_t me = pthread_self ();
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 05/12] y2038: Rename xclock_now to __xclock_now
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (3 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 04/12] y2038: Rename xclock_gettime to __xclock_gettime Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 06/12] y2038: Rename timespec_sub to __timespec_sub Lukasz Majewski
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

As the xclock_now is used locally in glibc, its name shall begin with
"__". This change adds this prefix.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 nptl/tst-eintr2.c            | 2 +-
 nptl/tst-eintr5.c            | 2 +-
 support/xtime.h              | 2 +-
 sysdeps/pthread/tst-cond27.c | 2 +-
 sysdeps/pthread/tst-join3.c  | 4 ++--
 sysdeps/pthread/tst-join5.c  | 6 +++---
 sysdeps/pthread/tst-mutex5.c | 6 +++---
 sysdeps/pthread/tst-mutex9.c | 2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/nptl/tst-eintr2.c b/nptl/tst-eintr2.c
index eba8065236..68a8453f34 100644
--- a/nptl/tst-eintr2.c
+++ b/nptl/tst-eintr2.c
@@ -37,7 +37,7 @@ static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
 static void *
 tf1 (void *arg)
 {
-  struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
+  struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
                                      __make_timespec (10000, 0));
 
   /* This call must never return.  */
diff --git a/nptl/tst-eintr5.c b/nptl/tst-eintr5.c
index 4edfbaaef6..3130f0fa08 100644
--- a/nptl/tst-eintr5.c
+++ b/nptl/tst-eintr5.c
@@ -38,7 +38,7 @@ static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
 static void *
 tf (void *arg)
 {
-  struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
+  struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
                                      __make_timespec (10000, 0));
 
   /* This call must never return.  */
diff --git a/support/xtime.h b/support/xtime.h
index 0912ead0ec..0fce19a78d 100644
--- a/support/xtime.h
+++ b/support/xtime.h
@@ -32,7 +32,7 @@ void __xclock_gettime (clockid_t clock, struct timespec *ts);
 /* This helper can often simplify tests by avoiding an explicit
    variable declaration or allowing that declaration to be const. */
 
-static inline struct timespec xclock_now (clockid_t clock)
+static inline struct timespec __xclock_now (clockid_t clock)
 {
   struct timespec ts;
   __xclock_gettime (clock, &ts);
diff --git a/sysdeps/pthread/tst-cond27.c b/sysdeps/pthread/tst-cond27.c
index 3d7b8240b1..5755d25ec8 100644
--- a/sysdeps/pthread/tst-cond27.c
+++ b/sysdeps/pthread/tst-cond27.c
@@ -40,7 +40,7 @@ do_test_clock (clockid_t clockid)
   xpthread_mutex_lock (&mut);
 
   /* Waiting for the condition will fail.  But we want the timeout here.  */
-  const struct timespec ts_now = xclock_now (clockid);
+  const struct timespec ts_now = __xclock_now (clockid);
   const struct timespec ts_timeout =
     timespec_add (ts_now, __make_timespec (0, 500000000));
 
diff --git a/sysdeps/pthread/tst-join3.c b/sysdeps/pthread/tst-join3.c
index fc54f12cc9..76df44c49e 100644
--- a/sysdeps/pthread/tst-join3.c
+++ b/sysdeps/pthread/tst-join3.c
@@ -53,7 +53,7 @@ do_test_clock (clockid_t clockid)
   pthread_t th = xpthread_create (NULL, tf, NULL);
 
   void *status;
-  struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
+  struct timespec timeout = timespec_add (__xclock_now (clockid_for_get),
                                           __make_timespec (0, 200000000));
 
   int val;
@@ -68,7 +68,7 @@ do_test_clock (clockid_t clockid)
 
   while (1)
     {
-      timeout = timespec_add (xclock_now (clockid_for_get),
+      timeout = timespec_add (__xclock_now (clockid_for_get),
                               __make_timespec (0, 200000000));
 
       if (clockid == CLOCK_USE_TIMEDJOIN)
diff --git a/sysdeps/pthread/tst-join5.c b/sysdeps/pthread/tst-join5.c
index 525f349a4b..a72760a9ff 100644
--- a/sysdeps/pthread/tst-join5.c
+++ b/sysdeps/pthread/tst-join5.c
@@ -45,15 +45,15 @@ static int
 thread_join (pthread_t thread, void **retval)
 {
 #if defined USE_PTHREAD_TIMEDJOIN_NP
-  const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
+  const struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
                                            __make_timespec (1000, 0));
   return pthread_timedjoin_np (thread, retval, &ts);
 #elif defined USE_PTHREAD_CLOCKJOIN_NP_REALTIME
-  const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
+  const struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
                                            __make_timespec (1000, 0));
   return pthread_clockjoin_np (thread, retval, CLOCK_REALTIME, &ts);
 #elif defined USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC
-  const struct timespec ts = timespec_add (xclock_now (CLOCK_MONOTONIC),
+  const struct timespec ts = timespec_add (__xclock_now (CLOCK_MONOTONIC),
                                            __make_timespec (1000, 0));
   return pthread_clockjoin_np (thread, retval, CLOCK_MONOTONIC, &ts);
 #else
diff --git a/sysdeps/pthread/tst-mutex5.c b/sysdeps/pthread/tst-mutex5.c
index 72fdbdaea5..86f383a193 100644
--- a/sysdeps/pthread/tst-mutex5.c
+++ b/sysdeps/pthread/tst-mutex5.c
@@ -67,7 +67,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
     FAIL_EXIT1 ("mutex_trylock succeeded");
 
   /* Wait 2 seconds.  */
-  struct timespec ts_timeout = timespec_add (xclock_now (clockid_for_get),
+  struct timespec ts_timeout = timespec_add (__xclock_now (clockid_for_get),
                                              __make_timespec (2, 0));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
@@ -86,7 +86,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
     TEST_COMPARE (pthread_mutex_clocklock (&m, clockid, &ts_timeout), EINVAL);
   TEST_COMPARE (pthread_mutex_unlock (&m), 0);
 
-  const struct timespec ts_start = xclock_now (CLOCK_REALTIME);
+  const struct timespec ts_start = __xclock_now (CLOCK_REALTIME);
 
   /* Wait 2 seconds.  */
   ts_timeout = timespec_add (ts_start, __make_timespec (2, 0));
@@ -96,7 +96,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
   else
     TEST_COMPARE (pthread_mutex_clocklock (&m, clockid, &ts_timeout), 0);
 
-  const struct timespec ts_end = xclock_now (clockid_for_get);
+  const struct timespec ts_end = __xclock_now (clockid_for_get);
 
   /* Check that timedlock didn't delay.  We use a limit of 0.1 secs.  */
   TEST_TIMESPEC_BEFORE (ts_end,
diff --git a/sysdeps/pthread/tst-mutex9.c b/sysdeps/pthread/tst-mutex9.c
index d03a22b97a..20e6d8d009 100644
--- a/sysdeps/pthread/tst-mutex9.c
+++ b/sysdeps/pthread/tst-mutex9.c
@@ -101,7 +101,7 @@ do_test_clock (clockid_t clockid)
       if (pthread_mutex_unlock (m) == 0)
         FAIL_EXIT1 ("child: mutex_unlock succeeded");
 
-      const struct timespec ts = timespec_add (xclock_now (clockid_for_get),
+      const struct timespec ts = timespec_add (__xclock_now (clockid_for_get),
                                                __make_timespec (0, 500000000));
 
       if (clockid == CLOCK_USE_TIMEDLOCK)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 06/12] y2038: Rename timespec_sub to __timespec_sub
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (4 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 05/12] y2038: Rename xclock_now to __xclock_now Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 07/12] y2038: Rename timespec_add to __timespec_add Lukasz Majewski
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

As the timespec_sub is used locally in glibc, its name shall begin with
"__". This change adds this prefix.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 support/timespec-sub.c          | 2 +-
 support/timespec.c              | 4 ++--
 support/timespec.h              | 2 +-
 sysdeps/mach/clock_nanosleep.c  | 4 ++--
 sysdeps/pthread/posix-timer.h   | 4 ++--
 sysdeps/pthread/timer_gettime.c | 2 +-
 sysdeps/pthread/timer_settime.c | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/support/timespec-sub.c b/support/timespec-sub.c
index 535a3b155b..836f1e4f70 100644
--- a/support/timespec-sub.c
+++ b/support/timespec-sub.c
@@ -27,7 +27,7 @@
 #include "intprops.h"
 
 struct timespec
-timespec_sub (struct timespec a, struct timespec b)
+__timespec_sub (struct timespec a, struct timespec b)
 {
   time_t rs = a.tv_sec;
   time_t bs = b.tv_sec;
diff --git a/support/timespec.c b/support/timespec.c
index ea6b947546..3647caed36 100644
--- a/support/timespec.c
+++ b/support/timespec.c
@@ -29,7 +29,7 @@ test_timespec_before_impl (const char *file, int line,
       || (left.tv_sec == right.tv_sec
 	  && left.tv_nsec > right.tv_nsec)) {
     support_record_failure ();
-    const struct timespec diff = timespec_sub (left, right);
+    const struct timespec diff = __timespec_sub (left, right);
     printf ("%s:%d: %jd.%09jds not before %jd.%09jds "
 	    "(difference %jd.%09jds)\n",
 	    file, line,
@@ -48,7 +48,7 @@ test_timespec_equal_or_after_impl (const char *file, int line,
       || (left.tv_sec == right.tv_sec
 	  && left.tv_nsec < right.tv_nsec)) {
     support_record_failure ();
-    const struct timespec diff = timespec_sub (right, left);
+    const struct timespec diff = __timespec_sub (right, left);
     printf ("%s:%d: %jd.%09jds not after %jd.%09jds "
 	    "(difference %jd.%09jds)\n",
 	    file, line,
diff --git a/support/timespec.h b/support/timespec.h
index 08df1d473b..9fdcea2fa4 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -26,7 +26,7 @@
 
 struct timespec timespec_add (struct timespec, struct timespec)
   __attribute__((const));
-struct timespec timespec_sub (struct timespec, struct timespec)
+struct timespec __timespec_sub (struct timespec, struct timespec)
   __attribute__((const));
 
 static inline struct timespec
diff --git a/sysdeps/mach/clock_nanosleep.c b/sysdeps/mach/clock_nanosleep.c
index 23ebc15274..bb3c76a8ac 100644
--- a/sysdeps/mach/clock_nanosleep.c
+++ b/sysdeps/mach/clock_nanosleep.c
@@ -53,8 +53,8 @@ nanosleep_call (const struct timespec *req, struct timespec *rem)
 	{
 	  struct timespec after, elapsed;
 	  __clock_gettime (CLOCK_REALTIME, &after);
-	  timespec_sub (&elapsed, &after, &before);
-	  timespec_sub (rem, req, &elapsed);
+	  __timespec_sub (&elapsed, &after, &before);
+	  __timespec_sub (rem, req, &elapsed);
 	}
 
       return EINTR;
diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h
index 7d9207e23d..115e5c931d 100644
--- a/sysdeps/pthread/posix-timer.h
+++ b/sysdeps/pthread/posix-timer.h
@@ -145,8 +145,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 timespec *diff, const struct timespec *left,
+                const struct timespec *right)
 {
   diff->tv_sec = left->tv_sec - right->tv_sec;
   diff->tv_nsec = left->tv_nsec - right->tv_nsec;
diff --git a/sysdeps/pthread/timer_gettime.c b/sysdeps/pthread/timer_gettime.c
index 6cbf87f434..3f5e1bbab1 100644
--- a/sysdeps/pthread/timer_gettime.c
+++ b/sysdeps/pthread/timer_gettime.c
@@ -52,7 +52,7 @@ timer_gettime (timer_t timerid, struct itimerspec *value)
 	{
 	  __clock_gettime (clock, &now);
 	  if (__timespec_compare (&now, &expiry) < 0)
-	    timespec_sub (&value->it_value, &expiry, &now);
+	    __timespec_sub (&value->it_value, &expiry, &now);
 	  else
 	    {
 	      value->it_value.tv_sec = 0;
diff --git a/sysdeps/pthread/timer_settime.c b/sysdeps/pthread/timer_settime.c
index b84da6e09f..fe4b32089d 100644
--- a/sysdeps/pthread/timer_settime.c
+++ b/sysdeps/pthread/timer_settime.c
@@ -84,7 +84,7 @@ timer_settime (timer_t timerid, int flags, const struct itimerspec *value,
 	      timer_addref (timer);
 	    }
 
-	  timespec_sub (&ovalue->it_value, &timer->expirytime, &now);
+	  __timespec_sub (&ovalue->it_value, &timer->expirytime, &now);
 	}
       else
 	{
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 07/12] y2038: Rename timespec_add to __timespec_add
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (5 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 06/12] y2038: Rename timespec_sub to __timespec_sub Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 08/12] y2038: Convert __make_timespec to be Y2038 safe Lukasz Majewski
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

As the timespec_add is used locally in glibc, its name shall begin with
"__". This change adds this prefix.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 nptl/tst-eintr2.c                |  4 ++--
 nptl/tst-eintr5.c                |  4 ++--
 nptl/tst-rwlock6.c               |  4 ++--
 nptl/tst-rwlock7.c               |  4 ++--
 nptl/tst-rwlock9.c               |  6 +++---
 nptl/tst-sem5.c                  |  2 +-
 support/timespec-add.c           |  2 +-
 support/timespec.h               |  2 +-
 sysdeps/pthread/posix-timer.h    |  4 ++--
 sysdeps/pthread/timer_routines.c |  8 ++++----
 sysdeps/pthread/timer_settime.c  |  2 +-
 sysdeps/pthread/tst-cond27.c     |  2 +-
 sysdeps/pthread/tst-join3.c      |  8 ++++----
 sysdeps/pthread/tst-join5.c      | 12 ++++++------
 sysdeps/pthread/tst-mutex5.c     |  8 ++++----
 sysdeps/pthread/tst-mutex9.c     |  4 ++--
 16 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/nptl/tst-eintr2.c b/nptl/tst-eintr2.c
index 68a8453f34..b7c3f21265 100644
--- a/nptl/tst-eintr2.c
+++ b/nptl/tst-eintr2.c
@@ -37,8 +37,8 @@ static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
 static void *
 tf1 (void *arg)
 {
-  struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
-                                     __make_timespec (10000, 0));
+  struct timespec ts = __timespec_add (__xclock_now (CLOCK_REALTIME),
+                                       __make_timespec (10000, 0));
 
   /* This call must never return.  */
   int e = pthread_mutex_timedlock (&m1, &ts);
diff --git a/nptl/tst-eintr5.c b/nptl/tst-eintr5.c
index 3130f0fa08..b286fdff77 100644
--- a/nptl/tst-eintr5.c
+++ b/nptl/tst-eintr5.c
@@ -38,8 +38,8 @@ static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
 static void *
 tf (void *arg)
 {
-  struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
-                                     __make_timespec (10000, 0));
+  struct timespec ts = __timespec_add (__xclock_now (CLOCK_REALTIME),
+                                       __make_timespec (10000, 0));
 
   /* This call must never return.  */
   TEST_COMPARE (pthread_cond_timedwait (&c, &m, &ts), 0);
diff --git a/nptl/tst-rwlock6.c b/nptl/tst-rwlock6.c
index ade2b3050b..37bc2d2c0b 100644
--- a/nptl/tst-rwlock6.c
+++ b/nptl/tst-rwlock6.c
@@ -62,8 +62,8 @@ tf (void *arg)
   struct timespec ts_start;
   __xclock_gettime (clockid_for_get, &ts_start);
 
-  struct timespec ts_timeout = timespec_add (ts_start,
-                                             __make_timespec (0, 300000000));
+  struct timespec ts_timeout = __timespec_add (ts_start,
+                                               __make_timespec (0, 300000000));
 
   verbose_printf ("child calling %srdlock\n", fnname);
 
diff --git a/nptl/tst-rwlock7.c b/nptl/tst-rwlock7.c
index 7dcb2d17ae..c13ad20f54 100644
--- a/nptl/tst-rwlock7.c
+++ b/nptl/tst-rwlock7.c
@@ -60,8 +60,8 @@ tf (void *arg)
   /* Timeout: 0.3 secs.  */
   struct timespec ts_start;
   __xclock_gettime (clockid_for_get, &ts_start);
-  const struct timespec ts_timeout = timespec_add (ts_start,
-                                                   __make_timespec (0, 300000000));
+  const struct timespec ts_timeout = __timespec_add (ts_start,
+                                                     __make_timespec (0, 300000000));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
     TEST_COMPARE (pthread_rwlock_timedwrlock (r, &ts_timeout), ETIMEDOUT);
diff --git a/nptl/tst-rwlock9.c b/nptl/tst-rwlock9.c
index f35ed6feaa..14232c89a1 100644
--- a/nptl/tst-rwlock9.c
+++ b/nptl/tst-rwlock9.c
@@ -75,8 +75,8 @@ writer_thread (void *arg)
 	{
 	  __xclock_gettime (clockid_for_get, &ts);
 
-          ts = timespec_add (ts, timeout);
-          ts = timespec_add (ts, timeout);
+          ts = __timespec_add (ts, timeout);
+          ts = __timespec_add (ts, timeout);
 
 	  printf ("writer thread %d tries again\n", nr);
 
@@ -122,7 +122,7 @@ reader_thread (void *arg)
 	{
 	  __xclock_gettime (clockid_for_get, &ts);
 
-          ts = timespec_add (ts, timeout);
+          ts = __timespec_add (ts, timeout);
 
 	  printf ("reader thread %d tries again\n", nr);
 
diff --git a/nptl/tst-sem5.c b/nptl/tst-sem5.c
index 611fff3e69..6519dcce8b 100644
--- a/nptl/tst-sem5.c
+++ b/nptl/tst-sem5.c
@@ -42,7 +42,7 @@ do_test_clock (clockid_t clockid)
 
   /* We wait for half a second.  */
   __xclock_gettime (clockid_for_get, &ts);
-  ts = timespec_add (ts, __make_timespec (0, TIMESPEC_HZ/2));
+  ts = __timespec_add (ts, __make_timespec (0, TIMESPEC_HZ/2));
 
   errno = 0;
   TEST_COMPARE (TEMP_FAILURE_RETRY ((clockid == CLOCK_USE_TIMEDWAIT)
diff --git a/support/timespec-add.c b/support/timespec-add.c
index bb22b12e9b..a2eb43791e 100644
--- a/support/timespec-add.c
+++ b/support/timespec-add.c
@@ -26,7 +26,7 @@
 #include "intprops.h"
 
 struct timespec
-timespec_add (struct timespec a, struct timespec b)
+__timespec_add (struct timespec a, struct timespec b)
 {
   time_t rs = a.tv_sec;
   time_t bs = b.tv_sec;
diff --git a/support/timespec.h b/support/timespec.h
index 9fdcea2fa4..936d0b0d84 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -24,7 +24,7 @@
 #include <support/check.h>
 #include <support/xtime.h>
 
-struct timespec timespec_add (struct timespec, struct timespec)
+struct timespec __timespec_add (struct timespec, struct timespec)
   __attribute__((const));
 struct timespec __timespec_sub (struct timespec, struct timespec)
   __attribute__((const));
diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h
index 115e5c931d..312cf2b3bd 100644
--- a/sysdeps/pthread/posix-timer.h
+++ b/sysdeps/pthread/posix-timer.h
@@ -131,8 +131,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 timespec *sum, const struct timespec *left,
+                const struct timespec *right)
 {
   sum->tv_sec = left->tv_sec + right->tv_sec;
   sum->tv_nsec = left->tv_nsec + right->tv_nsec;
diff --git a/sysdeps/pthread/timer_routines.c b/sysdeps/pthread/timer_routines.c
index be9b09a832..d866c705b1 100644
--- a/sysdeps/pthread/timer_routines.c
+++ b/sysdeps/pthread/timer_routines.c
@@ -392,12 +392,12 @@ thread_func (void *arg)
 		  || timer->value.it_interval.tv_nsec != 0)
 		{
 		  timer->overrun_count = 0;
-		  timespec_add (&timer->expirytime, &timer->expirytime,
-				&timer->value.it_interval);
+		  __timespec_add (&timer->expirytime, &timer->expirytime,
+		                  &timer->value.it_interval);
 		  while (__timespec_compare (&timer->expirytime, &now) < 0)
 		    {
-		      timespec_add (&timer->expirytime, &timer->expirytime,
-				    &timer->value.it_interval);
+		      __timespec_add (&timer->expirytime, &timer->expirytime,
+		                      &timer->value.it_interval);
 		      if (timer->overrun_count < DELAYTIMER_MAX)
 			++timer->overrun_count;
 		    }
diff --git a/sysdeps/pthread/timer_settime.c b/sysdeps/pthread/timer_settime.c
index fe4b32089d..77aa3460d5 100644
--- a/sysdeps/pthread/timer_settime.c
+++ b/sysdeps/pthread/timer_settime.c
@@ -108,7 +108,7 @@ timer_settime (timer_t timerid, int flags, const struct itimerspec *value,
 	/* The user specified the expiration time.  */
 	timer->expirytime = value->it_value;
       else
-	timespec_add (&timer->expirytime, &now, &value->it_value);
+	__timespec_add (&timer->expirytime, &now, &value->it_value);
 
       /* Only need to wake up the thread if timer is inserted
 	 at the head of the queue. */
diff --git a/sysdeps/pthread/tst-cond27.c b/sysdeps/pthread/tst-cond27.c
index 5755d25ec8..adc77bd008 100644
--- a/sysdeps/pthread/tst-cond27.c
+++ b/sysdeps/pthread/tst-cond27.c
@@ -42,7 +42,7 @@ do_test_clock (clockid_t clockid)
   /* Waiting for the condition will fail.  But we want the timeout here.  */
   const struct timespec ts_now = __xclock_now (clockid);
   const struct timespec ts_timeout =
-    timespec_add (ts_now, __make_timespec (0, 500000000));
+    __timespec_add (ts_now, __make_timespec (0, 500000000));
 
   /* In theory pthread_cond_clockwait could return zero here due to
      spurious wakeup. However that can't happen without a signal or an
diff --git a/sysdeps/pthread/tst-join3.c b/sysdeps/pthread/tst-join3.c
index 76df44c49e..f69f81a1b4 100644
--- a/sysdeps/pthread/tst-join3.c
+++ b/sysdeps/pthread/tst-join3.c
@@ -53,8 +53,8 @@ do_test_clock (clockid_t clockid)
   pthread_t th = xpthread_create (NULL, tf, NULL);
 
   void *status;
-  struct timespec timeout = timespec_add (__xclock_now (clockid_for_get),
-                                          __make_timespec (0, 200000000));
+  struct timespec timeout = __timespec_add (__xclock_now (clockid_for_get),
+                                            __make_timespec (0, 200000000));
 
   int val;
   if (clockid == CLOCK_USE_TIMEDJOIN)
@@ -68,8 +68,8 @@ do_test_clock (clockid_t clockid)
 
   while (1)
     {
-      timeout = timespec_add (__xclock_now (clockid_for_get),
-                              __make_timespec (0, 200000000));
+      timeout = __timespec_add (__xclock_now (clockid_for_get),
+                                __make_timespec (0, 200000000));
 
       if (clockid == CLOCK_USE_TIMEDJOIN)
         val = pthread_timedjoin_np (th, &status, &timeout);
diff --git a/sysdeps/pthread/tst-join5.c b/sysdeps/pthread/tst-join5.c
index a72760a9ff..797e73725e 100644
--- a/sysdeps/pthread/tst-join5.c
+++ b/sysdeps/pthread/tst-join5.c
@@ -45,16 +45,16 @@ static int
 thread_join (pthread_t thread, void **retval)
 {
 #if defined USE_PTHREAD_TIMEDJOIN_NP
-  const struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
-                                           __make_timespec (1000, 0));
+  const struct timespec ts = __timespec_add (__xclock_now (CLOCK_REALTIME),
+                                             __make_timespec (1000, 0));
   return pthread_timedjoin_np (thread, retval, &ts);
 #elif defined USE_PTHREAD_CLOCKJOIN_NP_REALTIME
-  const struct timespec ts = timespec_add (__xclock_now (CLOCK_REALTIME),
-                                           __make_timespec (1000, 0));
+  const struct timespec ts = __timespec_add (__xclock_now (CLOCK_REALTIME),
+                                             __make_timespec (1000, 0));
   return pthread_clockjoin_np (thread, retval, CLOCK_REALTIME, &ts);
 #elif defined USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC
-  const struct timespec ts = timespec_add (__xclock_now (CLOCK_MONOTONIC),
-                                           __make_timespec (1000, 0));
+  const struct timespec ts = __timespec_add (__xclock_now (CLOCK_MONOTONIC),
+                                             __make_timespec (1000, 0));
   return pthread_clockjoin_np (thread, retval, CLOCK_MONOTONIC, &ts);
 #else
   return pthread_join (thread, retval);
diff --git a/sysdeps/pthread/tst-mutex5.c b/sysdeps/pthread/tst-mutex5.c
index 86f383a193..fa21aac4e3 100644
--- a/sysdeps/pthread/tst-mutex5.c
+++ b/sysdeps/pthread/tst-mutex5.c
@@ -67,8 +67,8 @@ do_test_clock (clockid_t clockid, const char *fnname)
     FAIL_EXIT1 ("mutex_trylock succeeded");
 
   /* Wait 2 seconds.  */
-  struct timespec ts_timeout = timespec_add (__xclock_now (clockid_for_get),
-                                             __make_timespec (2, 0));
+  struct timespec ts_timeout = __timespec_add (__xclock_now (clockid_for_get),
+                                               __make_timespec (2, 0));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
     TEST_COMPARE (pthread_mutex_timedlock (&m, &ts_timeout), ETIMEDOUT);
@@ -89,7 +89,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
   const struct timespec ts_start = __xclock_now (CLOCK_REALTIME);
 
   /* Wait 2 seconds.  */
-  ts_timeout = timespec_add (ts_start, __make_timespec (2, 0));
+  ts_timeout = __timespec_add (ts_start, __make_timespec (2, 0));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
     TEST_COMPARE (pthread_mutex_timedlock (&m, &ts_timeout), 0);
@@ -100,7 +100,7 @@ do_test_clock (clockid_t clockid, const char *fnname)
 
   /* Check that timedlock didn't delay.  We use a limit of 0.1 secs.  */
   TEST_TIMESPEC_BEFORE (ts_end,
-                        timespec_add (ts_start, __make_timespec (0, 100000000)));
+                        __timespec_add (ts_start, __make_timespec (0, 100000000)));
 
   TEST_COMPARE (pthread_mutex_unlock (&m), 0);
   TEST_COMPARE (pthread_mutex_destroy (&m), 0);
diff --git a/sysdeps/pthread/tst-mutex9.c b/sysdeps/pthread/tst-mutex9.c
index 20e6d8d009..27451f000f 100644
--- a/sysdeps/pthread/tst-mutex9.c
+++ b/sysdeps/pthread/tst-mutex9.c
@@ -101,8 +101,8 @@ do_test_clock (clockid_t clockid)
       if (pthread_mutex_unlock (m) == 0)
         FAIL_EXIT1 ("child: mutex_unlock succeeded");
 
-      const struct timespec ts = timespec_add (__xclock_now (clockid_for_get),
-                                               __make_timespec (0, 500000000));
+      const struct timespec ts = __timespec_add (__xclock_now (clockid_for_get),
+                                                 __make_timespec (0, 500000000));
 
       if (clockid == CLOCK_USE_TIMEDLOCK)
         TEST_COMPARE (pthread_mutex_timedlock (m, &ts), ETIMEDOUT);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 08/12] y2038: Convert __make_timespec to be Y2038 safe
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (6 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 07/12] y2038: Rename timespec_add to __timespec_add Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 09/12] y2038: Convert __xclock_gettime " Lukasz Majewski
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

The conversion was to use Y2038 safe struct __timespec64 and __time64_t.
---
 support/timespec.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/support/timespec.h b/support/timespec.h
index 936d0b0d84..8de40d25f4 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -29,10 +29,10 @@ struct timespec __timespec_add (struct timespec, struct timespec)
 struct timespec __timespec_sub (struct timespec, struct timespec)
   __attribute__((const));
 
-static inline struct timespec
-__make_timespec (time_t s, long int ns)
+static inline struct __timespec64
+__make_timespec (__time64_t s, long int ns)
 {
-  struct timespec r;
+  struct __timespec64 r;
   r.tv_sec = s;
   r.tv_nsec = ns;
   return r;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 09/12] y2038: Convert __xclock_gettime to be Y2038 safe
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (7 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 08/12] y2038: Convert __make_timespec to be Y2038 safe Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 10/12] y2038: Convert __xclock_now " Lukasz Majewski
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

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


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 10/12] y2038: Convert __xclock_now to be Y2038 safe
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (8 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 09/12] y2038: Convert __xclock_gettime " Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 11/12] y2038: Convert timespec* files in ./support " Lukasz Majewski
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

The struct timespec has been replaced with Y2038 safe struct __timespec64.

Tested with glibc/glibc-many-build --keep failed glibcs
---
 support/xtime.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/support/xtime.h b/support/xtime.h
index f04dac14fd..91fac43711 100644
--- a/support/xtime.h
+++ b/support/xtime.h
@@ -32,9 +32,9 @@ 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. */
 
-static inline struct timespec __xclock_now (clockid_t clock)
+static inline struct __timespec64 __xclock_now (clockid_t clock)
 {
-  struct timespec ts;
+  struct __timespec64 ts;
   __xclock_gettime (clock, &ts);
   return ts;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 11/12] y2038: Convert timespec* files in ./support to be Y2038 safe
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (9 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 10/12] y2038: Convert __xclock_now " Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-01 14:07 ` [RFC 12/12] y2038: Convert timespec_* from posix-timer.h " Lukasz Majewski
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

After this change functions in ./support/timespec* files:
- __timespec_add
- __timespec_sub
- test_timespec_before_impl
- test_timespec_equal_or_after_impl

are Y2038 safe, as the struct timespec and time_t have been replaced with
struct __timespec64 and __time64_t respectively.
---
 support/timespec-add.c | 10 +++++-----
 support/timespec-sub.c | 16 ++++++++--------
 support/timespec.c     | 12 ++++++------
 support/timespec.h     | 17 +++++++++--------
 4 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/support/timespec-add.c b/support/timespec-add.c
index a2eb43791e..d2bcdae8de 100644
--- a/support/timespec-add.c
+++ b/support/timespec-add.c
@@ -25,11 +25,11 @@
 
 #include "intprops.h"
 
-struct timespec
-__timespec_add (struct timespec a, struct timespec b)
+struct __timespec64
+__timespec_add (struct __timespec64 a, struct __timespec64 b)
 {
-  time_t rs = a.tv_sec;
-  time_t bs = b.tv_sec;
+  __time64_t rs = a.tv_sec;
+  __time64_t bs = b.tv_sec;
   int ns = a.tv_nsec + b.tv_nsec;
   int nsd = ns - TIMESPEC_HZ;
   int rns = ns;
@@ -37,7 +37,7 @@ __timespec_add (struct timespec a, struct timespec b)
   if (0 <= nsd)
     {
       rns = nsd;
-      time_t bs1;
+      __time64_t bs1;
       if (!INT_ADD_WRAPV (bs, 1, &bs1))
         bs = bs1;
       else if (rs < 0)
diff --git a/support/timespec-sub.c b/support/timespec-sub.c
index 836f1e4f70..f0ae821ea4 100644
--- a/support/timespec-sub.c
+++ b/support/timespec-sub.c
@@ -26,21 +26,21 @@
 
 #include "intprops.h"
 
-struct timespec
-__timespec_sub (struct timespec a, struct timespec b)
+struct __timespec64
+__timespec_sub (struct __timespec64 a, struct __timespec64 b)
 {
-  time_t rs = a.tv_sec;
-  time_t bs = b.tv_sec;
+  __time64_t rs = a.tv_sec;
+  __time64_t bs = b.tv_sec;
   int ns = a.tv_nsec - b.tv_nsec;
   int rns = ns;
 
   if (ns < 0)
     {
       rns = ns + TIMESPEC_HZ;
-      time_t bs1;
+      __time64_t bs1;
       if (!INT_ADD_WRAPV (bs, 1, &bs1))
         bs = bs1;
-      else if (- TYPE_SIGNED (time_t) < rs)
+      else if (- TYPE_SIGNED (__time64_t) < rs)
         rs--;
       else
         goto low_overflow;
@@ -51,12 +51,12 @@ __timespec_sub (struct timespec a, struct timespec b)
       if (0 < bs)
         {
         low_overflow:
-          rs = TYPE_MINIMUM (time_t);
+          rs = TYPE_MINIMUM (__time64_t);
           rns = 0;
         }
       else
         {
-          rs = TYPE_MAXIMUM (time_t);
+          rs = TYPE_MAXIMUM (__time64_t);
           rns = TIMESPEC_HZ - 1;
         }
     }
diff --git a/support/timespec.c b/support/timespec.c
index 3647caed36..b69ce61c93 100644
--- a/support/timespec.c
+++ b/support/timespec.c
@@ -22,14 +22,14 @@
 
 void
 test_timespec_before_impl (const char *file, int line,
-			   const struct timespec left,
-			   const struct timespec right)
+			   const struct __timespec64 left,
+			   const struct __timespec64 right)
 {
   if (left.tv_sec > right.tv_sec
       || (left.tv_sec == right.tv_sec
 	  && left.tv_nsec > right.tv_nsec)) {
     support_record_failure ();
-    const struct timespec diff = __timespec_sub (left, right);
+    const struct __timespec64 diff = __timespec_sub (left, right);
     printf ("%s:%d: %jd.%09jds not before %jd.%09jds "
 	    "(difference %jd.%09jds)\n",
 	    file, line,
@@ -41,14 +41,14 @@ test_timespec_before_impl (const char *file, int line,
 
 void
 test_timespec_equal_or_after_impl (const char *file, int line,
-				   const struct timespec left,
-				   const struct timespec right)
+				   const struct __timespec64 left,
+				   const struct __timespec64 right)
 {
   if (left.tv_sec < right.tv_sec
       || (left.tv_sec == right.tv_sec
 	  && left.tv_nsec < right.tv_nsec)) {
     support_record_failure ();
-    const struct timespec diff = __timespec_sub (right, left);
+    const struct __timespec64 diff = __timespec_sub (right, left);
     printf ("%s:%d: %jd.%09jds not after %jd.%09jds "
 	    "(difference %jd.%09jds)\n",
 	    file, line,
diff --git a/support/timespec.h b/support/timespec.h
index 8de40d25f4..f0b054f5e9 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -23,10 +23,11 @@
 #include <time.h>
 #include <support/check.h>
 #include <support/xtime.h>
+#include <struct___timespec64.h>
 
-struct timespec __timespec_add (struct timespec, struct timespec)
+struct __timespec64 __timespec_add (struct __timespec64, struct __timespec64)
   __attribute__((const));
-struct timespec __timespec_sub (struct timespec, struct timespec)
+struct __timespec64 __timespec_sub (struct __timespec64, struct __timespec64)
   __attribute__((const));
 
 static inline struct __timespec64
@@ -41,12 +42,12 @@ __make_timespec (__time64_t s, long int ns)
 enum { TIMESPEC_HZ = 1000000000 };
 
 void test_timespec_before_impl (const char *file, int line,
-                                const struct timespec left,
-                                const struct timespec right);
+                                const struct __timespec64 left,
+                                const struct __timespec64 right);
 
 void test_timespec_equal_or_after_impl (const char *file, int line,
-                                        const struct timespec left,
-                                        const struct timespec right);
+                                        const struct __timespec64 left,
+                                        const struct __timespec64 right);
 
 /* Check that the timespec on the left represents a time before the
    time on the right. */
@@ -55,7 +56,7 @@ void test_timespec_equal_or_after_impl (const char *file, int line,
 
 #define TEST_TIMESPEC_BEFORE_NOW(left, clockid)                 \
   ({                                                            \
-    struct timespec now;                                        \
+    struct __timespec64 now;                                    \
     const int saved_errno = errno;                              \
     __xclock_gettime ((clockid), &now);                         \
     TEST_TIMESPEC_BEFORE ((left), now);                         \
@@ -69,7 +70,7 @@ void test_timespec_equal_or_after_impl (const char *file, int line,
 
 #define TEST_TIMESPEC_NOW_OR_AFTER(clockid, right)              \
   ({                                                            \
-    struct timespec now;                                        \
+    struct __timespec64 now;                                    \
     const int saved_errno = errno;                              \
     __xclock_gettime ((clockid), &now);                         \
     TEST_TIMESPEC_EQUAL_OR_AFTER (now, (right));                \
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 12/12] y2038: Convert timespec_* from posix-timer.h to be Y2038 safe
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (10 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 11/12] y2038: Convert timespec* files in ./support " Lukasz Majewski
@ 2020-06-01 14:07 ` Lukasz Majewski
  2020-06-02 18:05 ` [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support " Joseph Myers
  2020-06-03 12:53 ` [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code Lukasz Majewski
  13 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-01 14:07 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

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 --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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (11 preceding siblings ...)
  2020-06-01 14:07 ` [RFC 12/12] y2038: Convert timespec_* from posix-timer.h " Lukasz Majewski
@ 2020-06-02 18:05 ` Joseph Myers
  2020-06-03 11:42   ` Lukasz Majewski
  2020-06-03 12:53 ` [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code Lukasz Majewski
  13 siblings, 1 reply; 24+ messages in thread
From: Joseph Myers @ 2020-06-02 18:05 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

On Mon, 1 Jun 2020, Lukasz Majewski wrote:

> First timespec* functions are renamed to have common "__" prefix for internal
> functions. This is a preparatory work for further conversion.

Leading "__" is *only* needed when the name is used in contexts where it 
could conflict with a user identifier.  For example, in installed headers 
or with external linkage.

In particular, static inline functions in non-installed headers never need 
a leading "__".  So there is no justification for renaming 
timespec_compare unless you plan to make it an extern, non-inline 
function, in which case you should say so explicitly in that patch's 
commit message.

xclock_gettime is inherently unsuitable for use in installed libraries, 
because it exits (FAIL_EXIT1) on error, which is not suitable for library 
code.  So there is no need to rename that function; any installed library 
code that uses it has to be fixed not to use it and instead to do 
appropriate error checks on the result of clock_gettime (returning an 
error from the caller if appropriate) itself; library code should almost 
never exit the process on error.  Likewise xclock_now, because it calls 
xclock_gettime, must not be used in installed libraries.

These function naming changes are only appropriate for external linkage 
functions whose semantics are appropriate for use in installed libraries 
and that are actually used in such libraries or that you intend to be used 
in such libraries.  Please review all those changes to make sure that you 
don't rename functions for which such library use is not appropriate or 
not planned.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe
  2020-06-02 18:05 ` [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support " Joseph Myers
@ 2020-06-03 11:42   ` Lukasz Majewski
  0 siblings, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-03 11:42 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]

Hi Joseph,

> On Mon, 1 Jun 2020, Lukasz Majewski wrote:
> 
> > First timespec* functions are renamed to have common "__" prefix
> > for internal functions. This is a preparatory work for further
> > conversion.  
> 
> Leading "__" is *only* needed when the name is used in contexts where
> it could conflict with a user identifier.  For example, in installed
> headers or with external linkage.
> 
> In particular, static inline functions in non-installed headers never
> need a leading "__".  So there is no justification for renaming 
> timespec_compare unless you plan to make it an extern, non-inline 
> function, in which case you should say so explicitly in that patch's 
> commit message.
> 
> xclock_gettime is inherently unsuitable for use in installed
> libraries, because it exits (FAIL_EXIT1) on error, which is not
> suitable for library code.  So there is no need to rename that
> function; any installed library code that uses it has to be fixed not
> to use it and instead to do appropriate error checks on the result of
> clock_gettime (returning an error from the caller if appropriate)
> itself; library code should almost never exit the process on error.
> Likewise xclock_now, because it calls xclock_gettime, must not be
> used in installed libraries.
> 
> These function naming changes are only appropriate for external
> linkage functions whose semantics are appropriate for use in
> installed libraries and that are actually used in such libraries or
> that you intend to be used in such libraries.  Please review all
> those changes to make sure that you don't rename functions for which
> such library use is not appropriate or not planned.
> 

Thanks for very detailed explanation. Considering the above arguments -
there is no point in converting timespec_* and xclock_* functions as
those are only used internally in glibc - either as helper functions or
for writing tests.

I will drop patches 02-07.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
                   ` (12 preceding siblings ...)
  2020-06-02 18:05 ` [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support " Joseph Myers
@ 2020-06-03 12:53 ` Lukasz Majewski
  2020-06-03 17:28   ` Joseph Myers
  2020-06-08 22:23   ` Samuel Thibault
  13 siblings, 2 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-03 12:53 UTC (permalink / raw)
  To: Joseph Myers, Paul Eggert, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, libc-help,
	Alistair Francis

[-- Attachment #1: Type: text/plain, Size: 2286 bytes --]

Dear Community,

I would like to bring up one relevant Y2038 support issue  - to be more
specific - the conversion/replacement of struct timespec to struct
__timespec64 in glibc internal code (source tree).

For example - I would like to convert nptl and pthreads to be Y2038
safe. To do that the timespec_* helpers and some functions, which use
futex_time64 syscall, (from 5.1+) need to use struct __timespec64. 

The problem is with instant replacement of struct timespec with
struct __timespec64 in glibc internal code (and tests). 


To do it I could:
- Replace its occurences in relevant directories - like ./nptl or
  ./sysdeps/pthread - i.e. rename all occurrences in a single directory
 
- Replace them in functions (tests) and use explicit conversion
  functions - like valid_timespec_to_timespec64() before passing struct
  __timespec64 arguments (like ones for futex_time64 for nptl).

- Replace _all_ occurrences in glibc tree of struct timespec with struct
  __timespec64 at once with using sed on the glibc tree.

The last option seems to be the most appealing as we already use
__timespec64 (with its aliasing) for some core system syscalls (like
clock_gettime). 
However, such patch shall be applied just after the release of new
stable glibc version (August 2020?) to have time for potential fixes.


Which options shall we use?



A few more related questions:
- Shall tests in ./nptl and ./sysdeps/pthread [*] use struct
  __timespec64 or struct timespec? 
  From my understanding tests (like ./nptl/tst-*) use exported headers
  so struct timespec for them is struct __timespec64 anyway for archs
  with __WORDSIZE == 32 and __TIMESIZE !=64.

- Other time related structures needs to be converted as well - like
  struct itimerspec. 


[*] - from running scripts/build-many-glibcs.py it looks like only
i686-gnu port (HURD) is using code in ./sysdeps/pthread. Will
./sysdeps/pthread be replaced by nptl in some near time in the future
(and removed)? 



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-03 12:53 ` [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code Lukasz Majewski
@ 2020-06-03 17:28   ` Joseph Myers
  2020-06-03 20:45     ` Lukasz Majewski
  2020-06-24 12:26     ` Lukasz Majewski
  2020-06-08 22:23   ` Samuel Thibault
  1 sibling, 2 replies; 24+ messages in thread
From: Joseph Myers @ 2020-06-03 17:28 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, libc-help,
	Alistair Francis

On Wed, 3 Jun 2020, Lukasz Majewski wrote:

> To do it I could:
> - Replace its occurences in relevant directories - like ./nptl or
>   ./sysdeps/pthread - i.e. rename all occurrences in a single directory
>  
> - Replace them in functions (tests) and use explicit conversion
>   functions - like valid_timespec_to_timespec64() before passing struct
>   __timespec64 arguments (like ones for futex_time64 for nptl).
> 
> - Replace _all_ occurrences in glibc tree of struct timespec with struct
>   __timespec64 at once with using sed on the glibc tree.

Using sed obviously won't work, since external interfaces need different 
handling from purely internal uses.  I think you need to change things bit 
by bit, in sufficiently small patches for convenient review.

Regarding tests, I expect many tests of time-related interfaces should end 
up being built and run twice on systems that currently use 32-bit time, 
once to test the interfaces with 32-bit time and once to test the 
interfaces with 64-bit time.  Also, tests can't generally use 64-bit time 
interfaces from libc until _TIME_BITS=64 support is actually implemented.  
So I think tests would be one of the last places to change (and similarly 
installed executables).  Whereas any internal use of time in a function in 
the libraries that does not involve time in its interface can be updated 
more or less independently of any other such use, provided the relevant 
internal interfaces using 64-bit time are now available.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-03 17:28   ` Joseph Myers
@ 2020-06-03 20:45     ` Lukasz Majewski
  2020-06-24 12:26     ` Lukasz Majewski
  1 sibling, 0 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-03 20:45 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, libc-help,
	Alistair Francis

[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]

Hi Joseph,

> On Wed, 3 Jun 2020, Lukasz Majewski wrote:
> 
> > To do it I could:
> > - Replace its occurences in relevant directories - like ./nptl or
> >   ./sysdeps/pthread - i.e. rename all occurrences in a single
> > directory 
> > - Replace them in functions (tests) and use explicit conversion
> >   functions - like valid_timespec_to_timespec64() before passing
> > struct __timespec64 arguments (like ones for futex_time64 for nptl).
> > 
> > - Replace _all_ occurrences in glibc tree of struct timespec with
> > struct __timespec64 at once with using sed on the glibc tree.  
> 
> Using sed obviously won't work, since external interfaces need
> different handling from purely internal uses.  I think you need to
> change things bit by bit, in sufficiently small patches for
> convenient review.

Considering the above comment - it seems like it would be best to
replace struct timespec with struct __timespec64 in directories - like
./nptl and omit tests from converison.

> 
> Regarding tests, I expect many tests of time-related interfaces
> should end up being built and run twice on systems that currently use
> 32-bit time, once to test the interfaces with 32-bit time and once to
> test the interfaces with 64-bit time.  Also, tests can't generally
> use 64-bit time interfaces from libc until _TIME_BITS=64 support is
> actually implemented. So I think tests would be one of the last
> places to change (and similarly installed executables).  Whereas any
> internal use of time in a function in the libraries that does not
> involve time in its interface can be updated more or less
> independently of any other such use, provided the relevant internal
> interfaces using 64-bit time are now available.
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-03 12:53 ` [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code Lukasz Majewski
  2020-06-03 17:28   ` Joseph Myers
@ 2020-06-08 22:23   ` Samuel Thibault
  1 sibling, 0 replies; 24+ messages in thread
From: Samuel Thibault @ 2020-06-08 22:23 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, libc-help,
	Alistair Francis, Joseph Myers

Hello,

Lukasz Majewski, le mer. 03 juin 2020 14:53:47 +0200, a ecrit:
> [*] - from running scripts/build-many-glibcs.py it looks like only
> i686-gnu port (HURD) is using code in ./sysdeps/pthread.

? No, nptl also uses e.g. the C11 threads implementation that is there.

> Will ./sysdeps/pthread be replaced by nptl in some near time in the
> future (and removed)?

Ideally nptl and htl (and fbtl of the freebsd port) would be merged.
Apparently nptl is not as linux-specific as I could fear, and now
that gnumach has a futex-like interface (gsync) possibly it could
just be used, but it won't be just a snap, htl implements at least
some cancel support that we need in userland filesystem support
(pthread_hurd_cond_timedwait_np), and also the pthread cancel, signal,
TLS supports need to be plugged. I tend to make htl interface like nptl
with the libc, so that should be feasibly long-term.

Samuel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-03 17:28   ` Joseph Myers
  2020-06-03 20:45     ` Lukasz Majewski
@ 2020-06-24 12:26     ` Lukasz Majewski
  2020-06-24 12:43       ` Andreas Schwab
  2020-06-24 17:43       ` Joseph Myers
  1 sibling, 2 replies; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-24 12:26 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, libc-help,
	Alistair Francis

[-- Attachment #1: Type: text/plain, Size: 3656 bytes --]

Hi Joseph,

> On Wed, 3 Jun 2020, Lukasz Majewski wrote:
> 
> > To do it I could:
> > - Replace its occurences in relevant directories - like ./nptl or
> >   ./sysdeps/pthread - i.e. rename all occurrences in a single
> > directory 
> > - Replace them in functions (tests) and use explicit conversion
> >   functions - like valid_timespec_to_timespec64() before passing
> > struct __timespec64 arguments (like ones for futex_time64 for nptl).
> > 
> > - Replace _all_ occurrences in glibc tree of struct timespec with
> > struct __timespec64 at once with using sed on the glibc tree.  
> 
> Using sed obviously won't work, since external interfaces need
> different handling from purely internal uses.  I think you need to
> change things bit by bit, in sufficiently small patches for
> convenient review.
> 
> Regarding tests, I expect many tests of time-related interfaces
> should end up being built and run twice on systems that currently use
> 32-bit time, once to test the interfaces with 32-bit time and once to
> test the interfaces with 64-bit time.  

Does it mean that I shall NOT make the struct timespec to struct
__timespec64 conversion in glibc tests (e.g.
./sysdeps/pthread/tst-mutex5.c). Would those tests build infrastructure
be changed to build them w/ _TIME_BITS=64 support?


One thing puzzles me though - it seems like xclock_gettime, xclock_now,
timespec_add, timespec_sub are used by glibc tests (#include
<support/timespec.h>).

Am I correct that those functions are not exported and used solely
inside glibc?

The problem is that I do need to convert them to support 64 bit time as
pthreads use them (sysdeps/pthread/timer_settime.c). This also means
that I would need to update tests (otherwise I would experience
build/tests errors), which you don't recommend before the _TIME_BITS=64
support is added.

How to proceed in this case? Two big parts of Y2038 support are still
missing:

- One is stat and friends (which may be simplified when we move forward
  with minimal kernel version supported)

- And second are pthreads (nptl).

Pthreads are important for user space applications - so they shall be
converted sooner than latter IMHO.

> Also, tests can't generally
> use 64-bit time interfaces from libc until _TIME_BITS=64 support is
> actually implemented. 

Does it mean that tests - like sysdeps/pthread/tst-mutex5.c - will
always use exported struct timespec? (aliased to 64 bit struct 
__timespec64 when needed)?

> So I think tests would be one of the last
> places to change (and similarly installed executables). 

> Whereas any
> internal use of time in a function in the libraries that does not
> involve time in its interface can be updated more or less
> independently of any other such use, provided the relevant internal
> interfaces using 64-bit time are now available.
> 

As I stated above - e.g. timespec_sub() helper function (from /support)
is used by both pthreats and tests.

Despite it is internal function - shall I follow the pattern and
rewrite it as:

__timespec_add64(... struct __timespec64)
{

..

}
#if __TIMESIZE != 64
libc_hidden_def (__timespec_add64)

__timespec_add(... struct timespec64)
{
	call __timespec_add64();

}

However, the above approach seems to me like an overkill to do this for
internally used support function.



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-24 12:26     ` Lukasz Majewski
@ 2020-06-24 12:43       ` Andreas Schwab
  2020-06-24 20:39         ` Lukasz Majewski
  2020-06-24 17:43       ` Joseph Myers
  1 sibling, 1 reply; 24+ messages in thread
From: Andreas Schwab @ 2020-06-24 12:43 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, libc-help, Alistair Francis,
	Joseph Myers

On Jun 24 2020, Lukasz Majewski wrote:

> As I stated above - e.g. timespec_sub() helper function (from /support)
> is used by both pthreats and tests.

There are two definitions of timespec_sub, in support/timespec-sub.c and
in sysdeps/pthread/posix-timer.h.  The former is for use in tests, the
latter is used by libpthread.

The functions in support/timespec-*.c should probably be renamed to
xtimespec_*.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-24 12:26     ` Lukasz Majewski
  2020-06-24 12:43       ` Andreas Schwab
@ 2020-06-24 17:43       ` Joseph Myers
  1 sibling, 0 replies; 24+ messages in thread
From: Joseph Myers @ 2020-06-24 17:43 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, Andreas Schwab, Alistair Francis, GNU C Library,
	libc-help

On Wed, 24 Jun 2020, Lukasz Majewski wrote:

> > Also, tests can't generally
> > use 64-bit time interfaces from libc until _TIME_BITS=64 support is
> > actually implemented. 
> 
> Does it mean that tests - like sysdeps/pthread/tst-mutex5.c - will
> always use exported struct timespec? (aliased to 64 bit struct 
> __timespec64 when needed)?

Yes.  Tests normally use public interfaces, not internal ones.  Where a 
test needs to use internal interfaces related to time, such interfaces may 
end up needing variants for different sizes of time_t (but unless they 
actually result in functions defined in installed shared libraries and 
used both from those shared libraries and from other installed libraries 
or executables, the hidden_def mechanism is not relevant for such 
interfaces).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-24 12:43       ` Andreas Schwab
@ 2020-06-24 20:39         ` Lukasz Majewski
  2020-06-24 22:10           ` Joseph Myers
  0 siblings, 1 reply; 24+ messages in thread
From: Lukasz Majewski @ 2020-06-24 20:39 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Florian Weimer, GNU C Library, libc-help, Alistair Francis,
	Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

Hi Andreas,

> On Jun 24 2020, Lukasz Majewski wrote:
> 
> > As I stated above - e.g. timespec_sub() helper function (from
> > /support) is used by both pthreats and tests.  
> 
> There are two definitions of timespec_sub, in support/timespec-sub.c
> and in sysdeps/pthread/posix-timer.h.  The former is for use in
> tests, the latter is used by libpthread.

So if I understood it correctly - the support/* functions are to
facilitate writing tests?

> 
> The functions in support/timespec-*.c should probably be renamed to
> xtimespec_*.

And the 'x' prefix means that those functions are supposed to be used
for testing?

> 
> Andreas.
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code
  2020-06-24 20:39         ` Lukasz Majewski
@ 2020-06-24 22:10           ` Joseph Myers
  0 siblings, 0 replies; 24+ messages in thread
From: Joseph Myers @ 2020-06-24 22:10 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, Andreas Schwab, Alistair Francis, GNU C Library,
	libc-help

On Wed, 24 Jun 2020, Lukasz Majewski wrote:

> > The functions in support/timespec-*.c should probably be renamed to
> > xtimespec_*.
> 
> And the 'x' prefix means that those functions are supposed to be used
> for testing?

The 'x' prefix is in the style of xmalloc as used in many GNU packages - 
checking for errors in a safer way than the default libc API.

Most of the 'x' functions are thereby unsuitable for use in library code, 
but may be used in tests and in code that goes into the various 
executables shipped with glibc, because they exit the program on error and 
library code should generally not do that.  (The 'x' names are also not in 
the implementation namespace; non-static internal functions used within 
library code need to have reserved names such as __*.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2020-06-24 22:10 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 14:07 [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support to be Y2038 safe Lukasz Majewski
2020-06-01 14:07 ` [RFC 01/12] doc: Fix wording and formattine in ./support/README Lukasz Majewski
2020-06-01 14:07 ` [RFC 02/12] y2038: Rename timespec_compare to __timespec_compare Lukasz Majewski
2020-06-01 14:07 ` [RFC 03/12] y2038: Rename make_timespec to __make_timespec Lukasz Majewski
2020-06-01 14:07 ` [RFC 04/12] y2038: Rename xclock_gettime to __xclock_gettime Lukasz Majewski
2020-06-01 14:07 ` [RFC 05/12] y2038: Rename xclock_now to __xclock_now Lukasz Majewski
2020-06-01 14:07 ` [RFC 06/12] y2038: Rename timespec_sub to __timespec_sub Lukasz Majewski
2020-06-01 14:07 ` [RFC 07/12] y2038: Rename timespec_add to __timespec_add Lukasz Majewski
2020-06-01 14:07 ` [RFC 08/12] y2038: Convert __make_timespec to be Y2038 safe Lukasz Majewski
2020-06-01 14:07 ` [RFC 09/12] y2038: Convert __xclock_gettime " Lukasz Majewski
2020-06-01 14:07 ` [RFC 10/12] y2038: Convert __xclock_now " Lukasz Majewski
2020-06-01 14:07 ` [RFC 11/12] y2038: Convert timespec* files in ./support " Lukasz Majewski
2020-06-01 14:07 ` [RFC 12/12] y2038: Convert timespec_* from posix-timer.h " Lukasz Majewski
2020-06-02 18:05 ` [RFC 00/12] [RFC] y2038: Convert timespec_{sub|add|create} in support " Joseph Myers
2020-06-03 11:42   ` Lukasz Majewski
2020-06-03 12:53 ` [Y2038] Replacement of struct timespec with struct __timespec64 in glibc internal code Lukasz Majewski
2020-06-03 17:28   ` Joseph Myers
2020-06-03 20:45     ` Lukasz Majewski
2020-06-24 12:26     ` Lukasz Majewski
2020-06-24 12:43       ` Andreas Schwab
2020-06-24 20:39         ` Lukasz Majewski
2020-06-24 22:10           ` Joseph Myers
2020-06-24 17:43       ` Joseph Myers
2020-06-08 22:23   ` Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).