unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
@ 2020-05-05 18:16 Lukasz Majewski
  2020-05-19 19:51 ` Lukasz Majewski
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Lukasz Majewski @ 2020-05-05 18:16 UTC (permalink / raw)
  To: Joseph Myers, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis

The __clock_gettime internal function is not supporting 64 bit time on
architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32
bit).

The __clock_gettime64 function shall be used instead in the glibc itself as
it supports 64 bit time on those systems.
This patch does not bring any changes to systems with __WORDSIZE == 64 as
for them the __clock_gettime64 is aliased to __clock_gettime (in
./include/time.h).

---
Changes for v3:
- Fix the commit message (add missing "function" after __clock_gettime64)
- Refactor __nisfind_server() function to support 64 bit time
  with struct timespec instead of struct timeval
- Change expires to __time64_t

Changes for v2:
- Use only TIMESPEC_TO_TIMEVAL instead of valid_timespec64_to_timeval in
  logout.c and logwtmp.c as it is generic enough to also support struct
  __timespec64 conversion to struct timeval
---
 benchtests/bench-timing.h                        |  2 +-
 include/random-bits.h                            |  4 ++--
 login/logout.c                                   |  4 ++--
 login/logwtmp.c                                  |  5 +++--
 nis/nis_call.c                                   | 16 +++++++---------
 sysdeps/generic/hp-timing.h                      |  4 ++--
 sysdeps/generic/memusage.h                       |  4 ++--
 sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |  4 ++--
 sysdeps/unix/sysv/linux/clock.c                  |  7 ++-----
 9 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index 5b9a8384bb..a0d6f82465 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -18,7 +18,7 @@
 
 #undef attribute_hidden
 #define attribute_hidden
-#define __clock_gettime clock_gettime
+#define __clock_gettime __clock_gettime64
 #include <hp-timing.h>
 #include <stdint.h>
 
diff --git a/include/random-bits.h b/include/random-bits.h
index fd3fa01f9b..7561e55ca6 100644
--- a/include/random-bits.h
+++ b/include/random-bits.h
@@ -30,8 +30,8 @@
 static inline uint32_t
 random_bits (void)
 {
-  struct timespec tv;
-  __clock_gettime (CLOCK_MONOTONIC, &tv);
+  struct __timespec64 tv;
+  __clock_gettime64 (CLOCK_MONOTONIC, &tv);
   /* Shuffle the lower bits to minimize the clock bias.  */
   uint32_t ret = tv.tv_nsec ^ tv.tv_sec;
   ret ^= (ret << 24) | (ret >> 8);
diff --git a/login/logout.c b/login/logout.c
index 7653fe8886..091312eb1d 100644
--- a/login/logout.c
+++ b/login/logout.c
@@ -47,8 +47,8 @@ logout (const char *line)
       memset (ut->ut_name, '\0', sizeof ut->ut_name);
       memset (ut->ut_host, '\0', sizeof ut->ut_host);
 
-      struct timespec ts;
-      __clock_gettime (CLOCK_REALTIME, &ts);
+      struct __timespec64 ts;
+      __clock_gettime64 (CLOCK_REALTIME, &ts);
       TIMESPEC_TO_TIMEVAL (&ut->ut_tv, &ts);
       ut->ut_type = DEAD_PROCESS;
 
diff --git a/login/logwtmp.c b/login/logwtmp.c
index 90406acc3d..050219c153 100644
--- a/login/logwtmp.c
+++ b/login/logwtmp.c
@@ -21,6 +21,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <utmp.h>
+#include <struct___timespec64.h>
 
 
 void
@@ -36,8 +37,8 @@ logwtmp (const char *line, const char *name, const char *host)
   strncpy (ut.ut_name, name, sizeof ut.ut_name);
   strncpy (ut.ut_host, host, sizeof ut.ut_host);
 
-  struct timespec ts;
-  __clock_gettime (CLOCK_REALTIME, &ts);
+  struct __timespec64 ts;
+  __clock_gettime64 (CLOCK_REALTIME, &ts);
   TIMESPEC_TO_TIMEVAL (&ut.ut_tv, &ts);
 
   updwtmp (_PATH_WTMP, &ut);
diff --git a/nis/nis_call.c b/nis/nis_call.c
index 92c70e97aa..da4c52bdcd 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -575,7 +575,7 @@ static struct nis_server_cache
   unsigned int size;
   unsigned int server_used;
   unsigned int current_ep;
-  time_t expires;
+  __time64_t expires;
   char name[];
 } *nis_server_cache[16];
 static time_t nis_cold_start_mtime;
@@ -584,7 +584,7 @@ __libc_lock_define_initialized (static, nis_server_cache_lock)
 static directory_obj *
 nis_server_cache_search (const_nis_name name, int search_parent,
 			 unsigned int *server_used, unsigned int *current_ep,
-			 struct timeval *now)
+			 struct __timespec64 *now)
 {
   directory_obj *ret = NULL;
   int i;
@@ -642,7 +642,7 @@ nis_server_cache_search (const_nis_name name, int search_parent,
 static void
 nis_server_cache_add (const_nis_name name, int search_parent,
 		      directory_obj *dir, unsigned int server_used,
-		      unsigned int current_ep, struct timeval *now)
+		      unsigned int current_ep, struct __timespec64 *now)
 {
   struct nis_server_cache **loc;
   struct nis_server_cache *new;
@@ -708,8 +708,7 @@ __nisfind_server (const_nis_name name, int search_parent,
   nis_error result = NIS_SUCCESS;
   nis_error status;
   directory_obj *obj;
-  struct timeval now;
-  struct timespec ts;
+  struct __timespec64 ts;
   unsigned int server_used = ~0;
   unsigned int current_ep = ~0;
 
@@ -719,12 +718,11 @@ __nisfind_server (const_nis_name name, int search_parent,
   if (*dir != NULL)
     return NIS_SUCCESS;
 
-  __clock_gettime (CLOCK_REALTIME, &ts);
-  TIMESPEC_TO_TIMEVAL (&now, &ts);
+  __clock_gettime64 (CLOCK_REALTIME, &ts);
 
   if ((flags & NO_CACHE) == 0)
     *dir = nis_server_cache_search (name, search_parent, &server_used,
-				    &current_ep, &now);
+				    &current_ep, &ts);
   if (*dir != NULL)
     {
       unsigned int server_len = (*dir)->do_servers.do_servers_len;
@@ -783,7 +781,7 @@ __nisfind_server (const_nis_name name, int search_parent,
 	    }
 	  if ((flags & NO_CACHE) == 0)
 	    nis_server_cache_add (name, search_parent, obj,
-				  server_used, current_ep, &now);
+				  server_used, current_ep, &ts);
 	}
       else
 	{
diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
index e2d7447212..af9d92f7f7 100644
--- a/sysdeps/generic/hp-timing.h
+++ b/sysdeps/generic/hp-timing.h
@@ -34,8 +34,8 @@ typedef uint64_t hp_timing_t;
    vDSO symbol.  */
 #define HP_TIMING_NOW(var) \
 ({								\
-  struct timespec tv;						\
-  __clock_gettime (CLOCK_MONOTONIC, &tv);			\
+  struct __timespec64 tv;						\
+  __clock_gettime64 (CLOCK_MONOTONIC, &tv);			\
   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
 })
 
diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h
index a111864b0b..91e56d24de 100644
--- a/sysdeps/generic/memusage.h
+++ b/sysdeps/generic/memusage.h
@@ -28,9 +28,9 @@
 #ifndef GETTIME
 # define GETTIME(low,high)						   \
   {									   \
-    struct timespec now;						   \
+    struct __timespec64 now;						   \
     uint64_t usecs;							   \
-    clock_gettime (CLOCK_REALTIME, &now);				   \
+    __clock_gettime64 (CLOCK_REALTIME, &now);				   \
     usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \
     low = usecs & 0xffffffff;						   \
     high = usecs >> 32;							   \
diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
index 8cf5d303f9..5075ae0444 100644
--- a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
@@ -35,8 +35,8 @@ __gettimeofday_tv32 (struct __timeval32 *restrict tv32, void *restrict tz)
   if (__glibc_unlikely (tz != 0))
     memset (tz, 0, sizeof (struct timezone));
 
-  struct timespec ts;
-  __clock_gettime (CLOCK_REALTIME, &ts);
+  struct __timespec64 ts;
+  __clock_gettime64 (CLOCK_REALTIME, &ts);
 
   *tv32 = valid_timespec_to_timeval32 (ts);
   return 0;
diff --git a/sysdeps/unix/sysv/linux/clock.c b/sysdeps/unix/sysv/linux/clock.c
index 24a8df0cf5..157ae8eb3f 100644
--- a/sysdeps/unix/sysv/linux/clock.c
+++ b/sysdeps/unix/sysv/linux/clock.c
@@ -23,15 +23,12 @@
 clock_t
 clock (void)
 {
-  struct timespec ts;
+  struct __timespec64 ts;
 
   _Static_assert (CLOCKS_PER_SEC == 1000000,
 		  "CLOCKS_PER_SEC should be 1000000");
 
-  /* clock_gettime shouldn't fail here since CLOCK_PROCESS_CPUTIME_ID is
-     supported since 2.6.12.  Check the return value anyway in case the kernel
-     barfs on us for some reason.  */
-  if (__glibc_unlikely (__clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts) != 0))
+  if (__glibc_unlikely (__clock_gettime64 (CLOCK_PROCESS_CPUTIME_ID, &ts) != 0))
     return (clock_t) -1;
 
   return (ts.tv_sec * CLOCKS_PER_SEC
-- 
2.20.1


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

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-05 18:16 [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
@ 2020-05-19 19:51 ` Lukasz Majewski
  2020-05-20 10:29 ` Andreas Schwab
  2020-05-21  1:09 ` H.J. Lu via Libc-alpha
  2 siblings, 0 replies; 23+ messages in thread
From: Lukasz Majewski @ 2020-05-19 19:51 UTC (permalink / raw)
  To: Joseph Myers, Adhemerval Zanella
  Cc: Florian Weimer, GNU C Library, Alistair Francis, Andreas Schwab

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

Dear All,

> The __clock_gettime internal function is not supporting 64 bit time on
> architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g.
> ARM 32 bit).
> 
> The __clock_gettime64 function shall be used instead in the glibc
> itself as it supports 64 bit time on those systems.
> This patch does not bring any changes to systems with __WORDSIZE ==
> 64 as for them the __clock_gettime64 is aliased to __clock_gettime (in
> ./include/time.h).

Gentle ping on this patch. It has been on the glibc-alpha for 2 weeks
now ...

Is it OK to pull?

> 
> ---
> Changes for v3:
> - Fix the commit message (add missing "function" after
> __clock_gettime64)
> - Refactor __nisfind_server() function to support 64 bit time
>   with struct timespec instead of struct timeval
> - Change expires to __time64_t
> 
> Changes for v2:
> - Use only TIMESPEC_TO_TIMEVAL instead of valid_timespec64_to_timeval
> in logout.c and logwtmp.c as it is generic enough to also support
> struct __timespec64 conversion to struct timeval
> ---
>  benchtests/bench-timing.h                        |  2 +-
>  include/random-bits.h                            |  4 ++--
>  login/logout.c                                   |  4 ++--
>  login/logwtmp.c                                  |  5 +++--
>  nis/nis_call.c                                   | 16
> +++++++--------- sysdeps/generic/hp-timing.h                      |
> 4 ++-- sysdeps/generic/memusage.h                       |  4 ++--
>  sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |  4 ++--
>  sysdeps/unix/sysv/linux/clock.c                  |  7 ++-----
>  9 files changed, 23 insertions(+), 27 deletions(-)
> 
> diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
> index 5b9a8384bb..a0d6f82465 100644
> --- a/benchtests/bench-timing.h
> +++ b/benchtests/bench-timing.h
> @@ -18,7 +18,7 @@
>  
>  #undef attribute_hidden
>  #define attribute_hidden
> -#define __clock_gettime clock_gettime
> +#define __clock_gettime __clock_gettime64
>  #include <hp-timing.h>
>  #include <stdint.h>
>  
> diff --git a/include/random-bits.h b/include/random-bits.h
> index fd3fa01f9b..7561e55ca6 100644
> --- a/include/random-bits.h
> +++ b/include/random-bits.h
> @@ -30,8 +30,8 @@
>  static inline uint32_t
>  random_bits (void)
>  {
> -  struct timespec tv;
> -  __clock_gettime (CLOCK_MONOTONIC, &tv);
> +  struct __timespec64 tv;
> +  __clock_gettime64 (CLOCK_MONOTONIC, &tv);
>    /* Shuffle the lower bits to minimize the clock bias.  */
>    uint32_t ret = tv.tv_nsec ^ tv.tv_sec;
>    ret ^= (ret << 24) | (ret >> 8);
> diff --git a/login/logout.c b/login/logout.c
> index 7653fe8886..091312eb1d 100644
> --- a/login/logout.c
> +++ b/login/logout.c
> @@ -47,8 +47,8 @@ logout (const char *line)
>        memset (ut->ut_name, '\0', sizeof ut->ut_name);
>        memset (ut->ut_host, '\0', sizeof ut->ut_host);
>  
> -      struct timespec ts;
> -      __clock_gettime (CLOCK_REALTIME, &ts);
> +      struct __timespec64 ts;
> +      __clock_gettime64 (CLOCK_REALTIME, &ts);
>        TIMESPEC_TO_TIMEVAL (&ut->ut_tv, &ts);
>        ut->ut_type = DEAD_PROCESS;
>  
> diff --git a/login/logwtmp.c b/login/logwtmp.c
> index 90406acc3d..050219c153 100644
> --- a/login/logwtmp.c
> +++ b/login/logwtmp.c
> @@ -21,6 +21,7 @@
>  #include <time.h>
>  #include <unistd.h>
>  #include <utmp.h>
> +#include <struct___timespec64.h>
>  
>  
>  void
> @@ -36,8 +37,8 @@ logwtmp (const char *line, const char *name, const
> char *host) strncpy (ut.ut_name, name, sizeof ut.ut_name);
>    strncpy (ut.ut_host, host, sizeof ut.ut_host);
>  
> -  struct timespec ts;
> -  __clock_gettime (CLOCK_REALTIME, &ts);
> +  struct __timespec64 ts;
> +  __clock_gettime64 (CLOCK_REALTIME, &ts);
>    TIMESPEC_TO_TIMEVAL (&ut.ut_tv, &ts);
>  
>    updwtmp (_PATH_WTMP, &ut);
> diff --git a/nis/nis_call.c b/nis/nis_call.c
> index 92c70e97aa..da4c52bdcd 100644
> --- a/nis/nis_call.c
> +++ b/nis/nis_call.c
> @@ -575,7 +575,7 @@ static struct nis_server_cache
>    unsigned int size;
>    unsigned int server_used;
>    unsigned int current_ep;
> -  time_t expires;
> +  __time64_t expires;
>    char name[];
>  } *nis_server_cache[16];
>  static time_t nis_cold_start_mtime;
> @@ -584,7 +584,7 @@ __libc_lock_define_initialized (static,
> nis_server_cache_lock) static directory_obj *
>  nis_server_cache_search (const_nis_name name, int search_parent,
>  			 unsigned int *server_used, unsigned int
> *current_ep,
> -			 struct timeval *now)
> +			 struct __timespec64 *now)
>  {
>    directory_obj *ret = NULL;
>    int i;
> @@ -642,7 +642,7 @@ nis_server_cache_search (const_nis_name name, int
> search_parent, static void
>  nis_server_cache_add (const_nis_name name, int search_parent,
>  		      directory_obj *dir, unsigned int server_used,
> -		      unsigned int current_ep, struct timeval *now)
> +		      unsigned int current_ep, struct __timespec64
> *now) {
>    struct nis_server_cache **loc;
>    struct nis_server_cache *new;
> @@ -708,8 +708,7 @@ __nisfind_server (const_nis_name name, int
> search_parent, nis_error result = NIS_SUCCESS;
>    nis_error status;
>    directory_obj *obj;
> -  struct timeval now;
> -  struct timespec ts;
> +  struct __timespec64 ts;
>    unsigned int server_used = ~0;
>    unsigned int current_ep = ~0;
>  
> @@ -719,12 +718,11 @@ __nisfind_server (const_nis_name name, int
> search_parent, if (*dir != NULL)
>      return NIS_SUCCESS;
>  
> -  __clock_gettime (CLOCK_REALTIME, &ts);
> -  TIMESPEC_TO_TIMEVAL (&now, &ts);
> +  __clock_gettime64 (CLOCK_REALTIME, &ts);
>  
>    if ((flags & NO_CACHE) == 0)
>      *dir = nis_server_cache_search (name, search_parent,
> &server_used,
> -				    &current_ep, &now);
> +				    &current_ep, &ts);
>    if (*dir != NULL)
>      {
>        unsigned int server_len = (*dir)->do_servers.do_servers_len;
> @@ -783,7 +781,7 @@ __nisfind_server (const_nis_name name, int
> search_parent, }
>  	  if ((flags & NO_CACHE) == 0)
>  	    nis_server_cache_add (name, search_parent, obj,
> -				  server_used, current_ep, &now);
> +				  server_used, current_ep, &ts);
>  	}
>        else
>  	{
> diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
> index e2d7447212..af9d92f7f7 100644
> --- a/sysdeps/generic/hp-timing.h
> +++ b/sysdeps/generic/hp-timing.h
> @@ -34,8 +34,8 @@ typedef uint64_t hp_timing_t;
>     vDSO symbol.  */
>  #define HP_TIMING_NOW(var) \
>  ({								\
> -  struct timespec tv;
> \
> -  __clock_gettime (CLOCK_MONOTONIC, &tv);			\
> +  struct __timespec64 tv;
> 	\
> +  __clock_gettime64 (CLOCK_MONOTONIC, &tv);			\
>    (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
>  })
>  
> diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h
> index a111864b0b..91e56d24de 100644
> --- a/sysdeps/generic/memusage.h
> +++ b/sysdeps/generic/memusage.h
> @@ -28,9 +28,9 @@
>  #ifndef GETTIME
>  # define GETTIME(low,high)
> 	   \ {
> 		   \
> -    struct timespec now;
> 	   \
> +    struct __timespec64 now;
> 	   \ uint64_t usecs;
> 		   \
> -    clock_gettime (CLOCK_REALTIME, &now);
> 	   \
> +    __clock_gettime64 (CLOCK_REALTIME, &now);
> 	   \ usecs = (uint64_t)now.tv_nsec / 1000 +
> (uint64_t)now.tv_sec * 1000000; \ low = usecs & 0xffffffff;
> 					   \ high = usecs >>
> 32;							   \ diff
> --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c
> b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c index
> 8cf5d303f9..5075ae0444 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c +++
> b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -35,8 +35,8 @@
> __gettimeofday_tv32 (struct __timeval32 *restrict tv32, void
> *restrict tz) if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof
> (struct timezone)); 
> -  struct timespec ts;
> -  __clock_gettime (CLOCK_REALTIME, &ts);
> +  struct __timespec64 ts;
> +  __clock_gettime64 (CLOCK_REALTIME, &ts);
>  
>    *tv32 = valid_timespec_to_timeval32 (ts);
>    return 0;
> diff --git a/sysdeps/unix/sysv/linux/clock.c
> b/sysdeps/unix/sysv/linux/clock.c index 24a8df0cf5..157ae8eb3f 100644
> --- a/sysdeps/unix/sysv/linux/clock.c
> +++ b/sysdeps/unix/sysv/linux/clock.c
> @@ -23,15 +23,12 @@
>  clock_t
>  clock (void)
>  {
> -  struct timespec ts;
> +  struct __timespec64 ts;
>  
>    _Static_assert (CLOCKS_PER_SEC == 1000000,
>  		  "CLOCKS_PER_SEC should be 1000000");
>  
> -  /* clock_gettime shouldn't fail here since
> CLOCK_PROCESS_CPUTIME_ID is
> -     supported since 2.6.12.  Check the return value anyway in case
> the kernel
> -     barfs on us for some reason.  */
> -  if (__glibc_unlikely (__clock_gettime (CLOCK_PROCESS_CPUTIME_ID,
> &ts) != 0))
> +  if (__glibc_unlikely (__clock_gettime64 (CLOCK_PROCESS_CPUTIME_ID,
> &ts) != 0)) return (clock_t) -1;
>  
>    return (ts.tv_sec * CLOCKS_PER_SEC




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] 23+ messages in thread

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-05 18:16 [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
  2020-05-19 19:51 ` Lukasz Majewski
@ 2020-05-20 10:29 ` Andreas Schwab
  2020-05-21  1:09 ` H.J. Lu via Libc-alpha
  2 siblings, 0 replies; 23+ messages in thread
From: Andreas Schwab @ 2020-05-20 10:29 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Alistair Francis, Joseph Myers

On Mai 05 2020, Lukasz Majewski wrote:

> The __clock_gettime internal function is not supporting 64 bit time on
> architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32
> bit).
>
> The __clock_gettime64 function shall be used instead in the glibc itself as
> it supports 64 bit time on those systems.
> This patch does not bring any changes to systems with __WORDSIZE == 64 as
> for them the __clock_gettime64 is aliased to __clock_gettime (in
> ./include/time.h).

Ok.

> diff --git a/nis/nis_call.c b/nis/nis_call.c
> index 92c70e97aa..da4c52bdcd 100644
> --- a/nis/nis_call.c
> +++ b/nis/nis_call.c
> @@ -575,7 +575,7 @@ static struct nis_server_cache
>    unsigned int size;
>    unsigned int server_used;
>    unsigned int current_ep;
> -  time_t expires;
> +  __time64_t expires;
>    char name[];
>  } *nis_server_cache[16];
>  static time_t nis_cold_start_mtime;

This will need to be promoted to __time64_t eventually (but not in this
patch).

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] 23+ messages in thread

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-05 18:16 [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
  2020-05-19 19:51 ` Lukasz Majewski
  2020-05-20 10:29 ` Andreas Schwab
@ 2020-05-21  1:09 ` H.J. Lu via Libc-alpha
  2020-05-21 10:24   ` Lukasz Majewski
  2020-05-25 10:57   ` [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Andreas Schwab
  2 siblings, 2 replies; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-21  1:09 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> The __clock_gettime internal function is not supporting 64 bit time on
> architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32
> bit).
>
> The __clock_gettime64 function shall be used instead in the glibc itself as
> it supports 64 bit time on those systems.
> This patch does not bring any changes to systems with __WORDSIZE == 64 as
> for them the __clock_gettime64 is aliased to __clock_gettime (in
> ./include/time.h).
>
> ---
> Changes for v3:
> - Fix the commit message (add missing "function" after __clock_gettime64)
> - Refactor __nisfind_server() function to support 64 bit time
>   with struct timespec instead of struct timeval
> - Change expires to __time64_t
>
> Changes for v2:
> - Use only TIMESPEC_TO_TIMEVAL instead of valid_timespec64_to_timeval in
>   logout.c and logwtmp.c as it is generic enough to also support struct
>   __timespec64 conversion to struct timeval
> ---
>  benchtests/bench-timing.h                        |  2 +-
>  include/random-bits.h                            |  4 ++--
>  login/logout.c                                   |  4 ++--
>  login/logwtmp.c                                  |  5 +++--
>  nis/nis_call.c                                   | 16 +++++++---------
>  sysdeps/generic/hp-timing.h                      |  4 ++--
>  sysdeps/generic/memusage.h                       |  4 ++--
>  sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |  4 ++--
>  sysdeps/unix/sysv/linux/clock.c                  |  7 ++-----
>  9 files changed, 23 insertions(+), 27 deletions(-)
>

Does this patch work with "make bench" when sysdeps/generic/hp-timing.h is used,
like on arm?  I got
In file included from ./bench-timing.h:23,
                 from ./bench-skeleton.c:25,
                 from
/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
./bench-skeleton.c: In function ‘main’:
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
   82 |        TIMING_NOW (start);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:38:3: error: implicit declaration of
function ‘__clock_gettime64’; did you mean ‘clock_gettime’?
[-Werror=implicit-function-declaration]
   38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
      |   ^~~~~~~~~~~~~~~~~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
   82 |        TIMING_NOW (start);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
[-Werror=unused-variable]
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
   82 |        TIMING_NOW (start);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
   86 |        TIMING_NOW (end);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
[-Werror=unused-variable]
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
   86 |        TIMING_NOW (end);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
   90 |        TIMING_NOW (start);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
[-Werror=unused-variable]
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
   90 |        TIMING_NOW (start);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
   94 |        TIMING_NOW (end);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
[-Werror=unused-variable]
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
   94 |        TIMING_NOW (end);
      |        ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
  103 |   TIMING_NOW (start);
      |   ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
[-Werror=unused-variable]
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
  103 |   TIMING_NOW (start);
      |   ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
  106 |   TIMING_NOW (end);
      |   ^~~~~~~~~~
../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
[-Werror=unused-variable]
   37 |   struct __timespec64 tv;      \
      |                       ^~
./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
   35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
      |                         ^~~~~~~~~~~~~
./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
  106 |   TIMING_NOW (end);
      |   ^~~~~~~~~~
cc1: all warnings being treated as errors

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

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-21  1:09 ` H.J. Lu via Libc-alpha
@ 2020-05-21 10:24   ` Lukasz Majewski
  2020-05-21 11:11     ` H.J. Lu via Libc-alpha
  2020-05-25 10:57   ` [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Andreas Schwab
  1 sibling, 1 reply; 23+ messages in thread
From: Lukasz Majewski @ 2020-05-21 10:24 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

Hi "H.J. Lu",

> On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski <lukma@denx.de> wrote:
> >
> > The __clock_gettime internal function is not supporting 64 bit time
> > on architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like
> > e.g. ARM 32 bit).
> >
> > The __clock_gettime64 function shall be used instead in the glibc
> > itself as it supports 64 bit time on those systems.
> > This patch does not bring any changes to systems with __WORDSIZE ==
> > 64 as for them the __clock_gettime64 is aliased to __clock_gettime
> > (in ./include/time.h).
> >
> > ---
> > Changes for v3:
> > - Fix the commit message (add missing "function" after
> > __clock_gettime64)
> > - Refactor __nisfind_server() function to support 64 bit time
> >   with struct timespec instead of struct timeval
> > - Change expires to __time64_t
> >
> > Changes for v2:
> > - Use only TIMESPEC_TO_TIMEVAL instead of
> > valid_timespec64_to_timeval in logout.c and logwtmp.c as it is
> > generic enough to also support struct __timespec64 conversion to
> > struct timeval ---
> >  benchtests/bench-timing.h                        |  2 +-
> >  include/random-bits.h                            |  4 ++--
> >  login/logout.c                                   |  4 ++--
> >  login/logwtmp.c                                  |  5 +++--
> >  nis/nis_call.c                                   | 16
> > +++++++--------- sysdeps/generic/hp-timing.h                      |
> >  4 ++-- sysdeps/generic/memusage.h                       |  4 ++--
> >  sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |  4 ++--
> >  sysdeps/unix/sysv/linux/clock.c                  |  7 ++-----
> >  9 files changed, 23 insertions(+), 27 deletions(-)
> >  
> 
> Does this patch work with "make bench" when
> sysdeps/generic/hp-timing.h is used, like on arm?  I got
> In file included from ./bench-timing.h:23,
>                  from ./bench-skeleton.c:25,
>                  from
> /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> ./bench-skeleton.c: In function ‘main’:
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> isn’t known 37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
>    82 |        TIMING_NOW (start);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:38:3: error: implicit declaration of
> function ‘__clock_gettime64’; did you mean ‘clock_gettime’?
> [-Werror=implicit-function-declaration]
>    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
>       |   ^~~~~~~~~~~~~~~~~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
>    82 |        TIMING_NOW (start);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> [-Werror=unused-variable]
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
>    82 |        TIMING_NOW (start);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> isn’t known 37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
>    86 |        TIMING_NOW (end);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> [-Werror=unused-variable]
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
>    86 |        TIMING_NOW (end);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> isn’t known 37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
>    90 |        TIMING_NOW (start);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> [-Werror=unused-variable]
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
>    90 |        TIMING_NOW (start);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> isn’t known 37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
>    94 |        TIMING_NOW (end);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> [-Werror=unused-variable]
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
>    94 |        TIMING_NOW (end);
>       |        ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> isn’t known 37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
>   103 |   TIMING_NOW (start);
>       |   ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> [-Werror=unused-variable]
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
>   103 |   TIMING_NOW (start);
>       |   ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> isn’t known 37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
>   106 |   TIMING_NOW (end);
>       |   ^~~~~~~~~~
> ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> [-Werror=unused-variable]
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
>    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
>       |                         ^~~~~~~~~~~~~
> ./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
>   106 |   TIMING_NOW (end);
>       |   ^~~~~~~~~~
> cc1: all warnings being treated as errors

How shall I reproduce this error?

Was it supposed to be catch with build-many-glibc.py ?


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] 23+ messages in thread

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-21 10:24   ` Lukasz Majewski
@ 2020-05-21 11:11     ` H.J. Lu via Libc-alpha
  2020-05-23 20:32       ` [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-21 11:11 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> Hi "H.J. Lu",
>
> > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski <lukma@denx.de> wrote:
> > >
> > > The __clock_gettime internal function is not supporting 64 bit time
> > > on architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like
> > > e.g. ARM 32 bit).
> > >
> > > The __clock_gettime64 function shall be used instead in the glibc
> > > itself as it supports 64 bit time on those systems.
> > > This patch does not bring any changes to systems with __WORDSIZE ==
> > > 64 as for them the __clock_gettime64 is aliased to __clock_gettime
> > > (in ./include/time.h).
> > >
> > > ---
> > > Changes for v3:
> > > - Fix the commit message (add missing "function" after
> > > __clock_gettime64)
> > > - Refactor __nisfind_server() function to support 64 bit time
> > >   with struct timespec instead of struct timeval
> > > - Change expires to __time64_t
> > >
> > > Changes for v2:
> > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > valid_timespec64_to_timeval in logout.c and logwtmp.c as it is
> > > generic enough to also support struct __timespec64 conversion to
> > > struct timeval ---
> > >  benchtests/bench-timing.h                        |  2 +-
> > >  include/random-bits.h                            |  4 ++--
> > >  login/logout.c                                   |  4 ++--
> > >  login/logwtmp.c                                  |  5 +++--
> > >  nis/nis_call.c                                   | 16
> > > +++++++--------- sysdeps/generic/hp-timing.h                      |
> > >  4 ++-- sysdeps/generic/memusage.h                       |  4 ++--
> > >  sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |  4 ++--
> > >  sysdeps/unix/sysv/linux/clock.c                  |  7 ++-----
> > >  9 files changed, 23 insertions(+), 27 deletions(-)
> > >
> >
> > Does this patch work with "make bench" when
> > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > In file included from ./bench-timing.h:23,
> >                  from ./bench-skeleton.c:25,
> >                  from
> > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > ./bench-skeleton.c: In function ‘main’:
> > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > isn’t known 37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
> >    82 |        TIMING_NOW (start);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:38:3: error: implicit declaration of
> > function ‘__clock_gettime64’; did you mean ‘clock_gettime’?
> > [-Werror=implicit-function-declaration]
> >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> >       |   ^~~~~~~~~~~~~~~~~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
> >    82 |        TIMING_NOW (start);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > [-Werror=unused-variable]
> >    37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
> >    82 |        TIMING_NOW (start);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > isn’t known 37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
> >    86 |        TIMING_NOW (end);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > [-Werror=unused-variable]
> >    37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
> >    86 |        TIMING_NOW (end);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > isn’t known 37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
> >    90 |        TIMING_NOW (start);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > [-Werror=unused-variable]
> >    37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
> >    90 |        TIMING_NOW (start);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > isn’t known 37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
> >    94 |        TIMING_NOW (end);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > [-Werror=unused-variable]
> >    37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
> >    94 |        TIMING_NOW (end);
> >       |        ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > isn’t known 37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
> >   103 |   TIMING_NOW (start);
> >       |   ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > [-Werror=unused-variable]
> >    37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
> >   103 |   TIMING_NOW (start);
> >       |   ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > isn’t known 37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
> >   106 |   TIMING_NOW (end);
> >       |   ^~~~~~~~~~
> > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > [-Werror=unused-variable]
> >    37 |   struct __timespec64 tv;      \
> >       |                       ^~
> > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> >       |                         ^~~~~~~~~~~~~
> > ./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
> >   106 |   TIMING_NOW (end);
> >       |   ^~~~~~~~~~
> > cc1: all warnings being treated as errors
>
> How shall I reproduce this error?

Apply the enclosed patch and do

$ make USE_CLOCK_GETTIME=1 bench

> Was it supposed to be catch with build-many-glibc.py ?
>

No, "make bench" isn't tested by build-many-glibc.py.

-- 
H.J.

[-- Attachment #2: 0001-benchtests-Restore-the-clock_gettime-option.patch --]
[-- Type: text/x-patch, Size: 2649 bytes --]

From aceff38980daad512ca9693647f5f641d0aa1f6e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 18 May 2020 17:28:42 -0700
Subject: [PATCH] benchtests: Restore the clock_gettime option

commit 7621e38bf3c58b2d0359545f1f2898017fd89d05
Author: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Date:   Tue Jan 29 17:43:45 2019 +0000

    Add generic hp-timing support

removed the clock_gettime option.  Restore the clock_gettime option for
some x86 CPUs on which value from RDTSC may not be incremented at a fixed
rate.
---
 benchtests/Makefile       | 6 ++++++
 benchtests/README         | 7 ++++++-
 benchtests/bench-timing.h | 6 +++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/benchtests/Makefile b/benchtests/Makefile
index 335d643ecb..99e90d17a0 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -132,11 +132,17 @@ endif
 
 CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC
 
+# Use clock_gettime to measure performance of functions.  The default is
+# to use the architecture-specific high precision timing instructions.
+ifdef USE_CLOCK_GETTIME
+CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME
+else
 # On x86 processors, use RDTSCP, instead of RDTSC, to measure performance
 # of functions.  All x86 processors since 2010 support RDTSCP instruction.
 ifdef USE_RDTSCP
 CPPFLAGS-nonlib += -DUSE_RDTSCP
 endif
+endif
 
 DETAILED_OPT :=
 
diff --git a/benchtests/README b/benchtests/README
index c4f03fd872..f440f3295a 100644
--- a/benchtests/README
+++ b/benchtests/README
@@ -27,7 +27,12 @@ BENCH_DURATION.
 
 The benchmark suite does function call measurements using architecture-specific
 high precision timing instructions whenever available.  When such support is
-not available, it uses clock_gettime (CLOCK_MONOTONIC).
+not available, it uses clock_gettime (CLOCK_MONOTONIC).  One can force the
+benchmark to use clock_gettime by invoking make as follows:
+
+  $ make USE_CLOCK_GETTIME=1 bench
+
+Again, one must run `make bench-clean' before changing the measurement method.
 
 On x86 processors, RDTSCP instruction provides more precise timing data
 than RDTSC instruction.  All x86 processors since 2010 support RDTSCP
diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index a0d6f82465..2baaa92b49 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -19,7 +19,11 @@
 #undef attribute_hidden
 #define attribute_hidden
 #define __clock_gettime __clock_gettime64
-#include <hp-timing.h>
+#ifdef USE_CLOCK_GETTIME
+# include <sysdeps/generic/hp-timing.h>
+#else
+# include <hp-timing.h>
+#endif
 #include <stdint.h>
 
 #define GL(x) _##x
-- 
2.26.2


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

* [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-21 11:11     ` H.J. Lu via Libc-alpha
@ 2020-05-23 20:32       ` H.J. Lu via Libc-alpha
  2020-05-24  9:03         ` Lukasz Majewski
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-23 20:32 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

On Thu, May 21, 2020 at 4:11 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de> wrote:
> >
> > Hi "H.J. Lu",
> >
> > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski <lukma@denx.de> wrote:
> > > >
> > > > The __clock_gettime internal function is not supporting 64 bit time
> > > > on architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like
> > > > e.g. ARM 32 bit).
> > > >
> > > > The __clock_gettime64 function shall be used instead in the glibc
> > > > itself as it supports 64 bit time on those systems.
> > > > This patch does not bring any changes to systems with __WORDSIZE ==
> > > > 64 as for them the __clock_gettime64 is aliased to __clock_gettime
> > > > (in ./include/time.h).
> > > >
> > > > ---
> > > > Changes for v3:
> > > > - Fix the commit message (add missing "function" after
> > > > __clock_gettime64)
> > > > - Refactor __nisfind_server() function to support 64 bit time
> > > >   with struct timespec instead of struct timeval
> > > > - Change expires to __time64_t
> > > >
> > > > Changes for v2:
> > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > valid_timespec64_to_timeval in logout.c and logwtmp.c as it is
> > > > generic enough to also support struct __timespec64 conversion to
> > > > struct timeval ---
> > > >  benchtests/bench-timing.h                        |  2 +-
> > > >  include/random-bits.h                            |  4 ++--
> > > >  login/logout.c                                   |  4 ++--
> > > >  login/logwtmp.c                                  |  5 +++--
> > > >  nis/nis_call.c                                   | 16
> > > > +++++++--------- sysdeps/generic/hp-timing.h                      |
> > > >  4 ++-- sysdeps/generic/memusage.h                       |  4 ++--
> > > >  sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |  4 ++--
> > > >  sysdeps/unix/sysv/linux/clock.c                  |  7 ++-----
> > > >  9 files changed, 23 insertions(+), 27 deletions(-)
> > > >
> > >
> > > Does this patch work with "make bench" when
> > > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > > In file included from ./bench-timing.h:23,
> > >                  from ./bench-skeleton.c:25,
> > >                  from
> > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > ./bench-skeleton.c: In function ‘main’:
> > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > > isn’t known 37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
> > >    82 |        TIMING_NOW (start);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit declaration of
> > > function ‘__clock_gettime64’; did you mean ‘clock_gettime’?
> > > [-Werror=implicit-function-declaration]
> > >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> > >       |   ^~~~~~~~~~~~~~~~~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
> > >    82 |        TIMING_NOW (start);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > > [-Werror=unused-variable]
> > >    37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:82:8: note: in expansion of macro ‘TIMING_NOW’
> > >    82 |        TIMING_NOW (start);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > > isn’t known 37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
> > >    86 |        TIMING_NOW (end);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > > [-Werror=unused-variable]
> > >    37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:86:8: note: in expansion of macro ‘TIMING_NOW’
> > >    86 |        TIMING_NOW (end);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > > isn’t known 37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
> > >    90 |        TIMING_NOW (start);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > > [-Werror=unused-variable]
> > >    37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:90:8: note: in expansion of macro ‘TIMING_NOW’
> > >    90 |        TIMING_NOW (start);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > > isn’t known 37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
> > >    94 |        TIMING_NOW (end);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > > [-Werror=unused-variable]
> > >    37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:94:8: note: in expansion of macro ‘TIMING_NOW’
> > >    94 |        TIMING_NOW (end);
> > >       |        ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > > isn’t known 37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
> > >   103 |   TIMING_NOW (start);
> > >       |   ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > > [-Werror=unused-variable]
> > >    37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:103:3: note: in expansion of macro ‘TIMING_NOW’
> > >   103 |   TIMING_NOW (start);
> > >       |   ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’
> > > isn’t known 37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
> > >   106 |   TIMING_NOW (end);
> > >       |   ^~~~~~~~~~
> > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable ‘tv’
> > > [-Werror=unused-variable]
> > >    37 |   struct __timespec64 tv;      \
> > >       |                       ^~
> > > ./bench-timing.h:35:25: note: in expansion of macro ‘HP_TIMING_NOW’
> > >    35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > >       |                         ^~~~~~~~~~~~~
> > > ./bench-skeleton.c:106:3: note: in expansion of macro ‘TIMING_NOW’
> > >   106 |   TIMING_NOW (end);
> > >       |   ^~~~~~~~~~
> > > cc1: all warnings being treated as errors
> >
> > How shall I reproduce this error?
>
> Apply the enclosed patch and do
>
> $ make USE_CLOCK_GETTIME=1 bench
>
> > Was it supposed to be catch with build-many-glibc.py ?
> >
>
> No, "make bench" isn't tested by build-many-glibc.py.
>

Here is the patch to fix __clock_gettime64 for sysdeps/generic/hp-timing.h.
OK for master?

-- 
H.J.

[-- Attachment #2: 0001-Fix-__clock_gettime64-for-sysdeps-generic-hp-timing..patch --]
[-- Type: text/x-patch, Size: 3552 bytes --]

From 912f3579b3034f3b375a43eed4592f9a81301b6f Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 23 May 2020 10:04:20 -0700
Subject: [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit e9698175b0b60407db1e89bcf29437ab224bca0b
Author: Lukasz Majewski <lukma@denx.de>
Date:   Mon Mar 16 08:31:41 2020 +0100

    y2038: Replace __clock_gettime with __clock_gettime64

breaks benchtests with sysdeps/generic/hp-timing.h:

In file included from ./bench-timing.h:23,
                 from ./bench-skeleton.c:25,
                 from
/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
./bench-skeleton.c: In function ‘main’:
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~

We should always provide __clock_gettime64 for sysdeps/generic/hp-timing.h.
Don't define __clock_gettime in benchtests/bench-timing.h since
it is no longer needed.
---
 benchtests/bench-timing.h   |  1 -
 include/time.h              | 12 +++++++++---
 sysdeps/generic/hp-timing.h |  1 +
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index a0d6f82465..d0176fb76e 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -18,7 +18,6 @@
 
 #undef attribute_hidden
 #define attribute_hidden
-#define __clock_gettime __clock_gettime64
 #include <hp-timing.h>
 #include <stdint.h>
 
diff --git a/include/time.h b/include/time.h
index fe4da9ca10..246683a1c5 100644
--- a/include/time.h
+++ b/include/time.h
@@ -1,6 +1,15 @@
 #ifndef _TIME_H
 #include <time/time.h>
 
+/* For sysdeps/generic/hp-timing.h.  */
+extern __typeof (clock_gettime) __clock_gettime;
+#if __TIMESIZE == 64
+# define __clock_gettime64 __clock_gettime
+#else
+struct __timespec64;
+extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
+#endif
+
 #ifndef _ISOMAC
 # include <bits/types/struct_timeval.h>
 # include <struct___timespec64.h>
@@ -23,7 +32,6 @@ libc_hidden_proto (localtime)
 libc_hidden_proto (strftime)
 libc_hidden_proto (strptime)
 
-extern __typeof (clock_gettime) __clock_gettime;
 libc_hidden_proto (__clock_gettime)
 extern __typeof (clock_settime) __clock_settime;
 libc_hidden_proto (__clock_settime)
@@ -295,14 +303,12 @@ extern double __difftime (time_t time1, time_t time0);
 
 #if __TIMESIZE == 64
 # define __clock_nanosleep_time64 __clock_nanosleep
-# define __clock_gettime64 __clock_gettime
 # define __timespec_get64 __timespec_get
 #else
 extern int __clock_nanosleep_time64 (clockid_t clock_id,
                                      int flags, const struct __timespec64 *req,
                                      struct __timespec64 *rem);
 libc_hidden_proto (__clock_nanosleep_time64)
-extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
 libc_hidden_proto (__clock_gettime64)
 extern int __timespec_get64 (struct __timespec64 *ts, int base);
 libc_hidden_proto (__timespec_get64)
diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
index af9d92f7f7..7e22d43151 100644
--- a/sysdeps/generic/hp-timing.h
+++ b/sysdeps/generic/hp-timing.h
@@ -23,6 +23,7 @@
 #include <time.h>
 #include <stdint.h>
 #include <hp-timing-common.h>
+#include <struct___timespec64.h>
 
 /* It should not be used for ld.so.  */
 #define HP_TIMING_INLINE	(0)
-- 
2.26.2


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

* Re: [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-23 20:32       ` [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
@ 2020-05-24  9:03         ` Lukasz Majewski
  2020-05-24 11:39           ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: Lukasz Majewski @ 2020-05-24  9:03 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

On Sat, 23 May 2020 13:32:05 -0700
"H.J. Lu" <hjl.tools@gmail.com> wrote:

> On Thu, May 21, 2020 at 4:11 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de>
> > wrote:  
> > >
> > > Hi "H.J. Lu",
> > >  
> > > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski <lukma@denx.de>
> > > > wrote:  
> > > > >
> > > > > The __clock_gettime internal function is not supporting 64
> > > > > bit time on architectures with __WORDSIZE == 32 and
> > > > > __TIMESIZE != 64 (like e.g. ARM 32 bit).
> > > > >
> > > > > The __clock_gettime64 function shall be used instead in the
> > > > > glibc itself as it supports 64 bit time on those systems.
> > > > > This patch does not bring any changes to systems with
> > > > > __WORDSIZE == 64 as for them the __clock_gettime64 is aliased
> > > > > to __clock_gettime (in ./include/time.h).
> > > > >
> > > > > ---
> > > > > Changes for v3:
> > > > > - Fix the commit message (add missing "function" after
> > > > > __clock_gettime64)
> > > > > - Refactor __nisfind_server() function to support 64 bit time
> > > > >   with struct timespec instead of struct timeval
> > > > > - Change expires to __time64_t
> > > > >
> > > > > Changes for v2:
> > > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > > valid_timespec64_to_timeval in logout.c and logwtmp.c as it is
> > > > > generic enough to also support struct __timespec64 conversion
> > > > > to struct timeval ---
> > > > >  benchtests/bench-timing.h                        |  2 +-
> > > > >  include/random-bits.h                            |  4 ++--
> > > > >  login/logout.c                                   |  4 ++--
> > > > >  login/logwtmp.c                                  |  5 +++--
> > > > >  nis/nis_call.c                                   | 16
> > > > > +++++++--------- sysdeps/generic/hp-timing.h
> > > > >     | 4 ++-- sysdeps/generic/memusage.h
> > > > > |  4 ++-- sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |
> > > > > 4 ++-- sysdeps/unix/sysv/linux/clock.c                  |  7
> > > > > ++----- 9 files changed, 23 insertions(+), 27 deletions(-)
> > > > >  
> > > >
> > > > Does this patch work with "make bench" when
> > > > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > > > In file included from ./bench-timing.h:23,
> > > >                  from ./bench-skeleton.c:25,
> > > >                  from
> > > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > > ./bench-skeleton.c: In function ‘main’:
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit
> > > > declaration of function ‘__clock_gettime64’; did you mean
> > > > ‘clock_gettime’? [-Werror=implicit-function-declaration]
> > > >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> > > >       |   ^~~~~~~~~~~~~~~~~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > ‘tv’ [-Werror=unused-variable]
> > > >    37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > ‘tv’ [-Werror=unused-variable]
> > > >    37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > ‘tv’ [-Werror=unused-variable]
> > > >    37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > ‘tv’ [-Werror=unused-variable]
> > > >    37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > >       |        ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > >       |   ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > ‘tv’ [-Werror=unused-variable]
> > > >    37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > >       |   ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > >       |   ^~~~~~~~~~
> > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > ‘tv’ [-Werror=unused-variable]
> > > >    37 |   struct __timespec64 tv;      \
> > > >       |                       ^~
> > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > >       |                         ^~~~~~~~~~~~~
> > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > >       |   ^~~~~~~~~~
> > > > cc1: all warnings being treated as errors  
> > >
> > > How shall I reproduce this error?  
> >
> > Apply the enclosed patch and do
> >
> > $ make USE_CLOCK_GETTIME=1 bench
> >  
> > > Was it supposed to be catch with build-many-glibc.py ?
> > >  
> >
> > No, "make bench" isn't tested by build-many-glibc.py.
> >  
> 
> Here is the patch to fix __clock_gettime64 for
> sysdeps/generic/hp-timing.h. OK for master?
> 

Thanks for preparing the fix.

If I may ask - I do have some question about the following code:
+#else
+struct __timespec64;
+extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64
*tp); +#endif

Why do we need the "struct __timespec64;" declaration there as
in ./sysdeps/generic/hp-timing.h you explicitly added:
#include <struct___timespec64.h> ?


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] 23+ messages in thread

* Re: [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-24  9:03         ` Lukasz Majewski
@ 2020-05-24 11:39           ` H.J. Lu via Libc-alpha
  2020-05-24 15:30             ` Lukasz Majewski
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-24 11:39 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

On Sun, May 24, 2020 at 2:03 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> On Sat, 23 May 2020 13:32:05 -0700
> "H.J. Lu" <hjl.tools@gmail.com> wrote:
>
> > On Thu, May 21, 2020 at 4:11 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de>
> > > wrote:
> > > >
> > > > Hi "H.J. Lu",
> > > >
> > > > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski <lukma@denx.de>
> > > > > wrote:
> > > > > >
> > > > > > The __clock_gettime internal function is not supporting 64
> > > > > > bit time on architectures with __WORDSIZE == 32 and
> > > > > > __TIMESIZE != 64 (like e.g. ARM 32 bit).
> > > > > >
> > > > > > The __clock_gettime64 function shall be used instead in the
> > > > > > glibc itself as it supports 64 bit time on those systems.
> > > > > > This patch does not bring any changes to systems with
> > > > > > __WORDSIZE == 64 as for them the __clock_gettime64 is aliased
> > > > > > to __clock_gettime (in ./include/time.h).
> > > > > >
> > > > > > ---
> > > > > > Changes for v3:
> > > > > > - Fix the commit message (add missing "function" after
> > > > > > __clock_gettime64)
> > > > > > - Refactor __nisfind_server() function to support 64 bit time
> > > > > >   with struct timespec instead of struct timeval
> > > > > > - Change expires to __time64_t
> > > > > >
> > > > > > Changes for v2:
> > > > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > > > valid_timespec64_to_timeval in logout.c and logwtmp.c as it is
> > > > > > generic enough to also support struct __timespec64 conversion
> > > > > > to struct timeval ---
> > > > > >  benchtests/bench-timing.h                        |  2 +-
> > > > > >  include/random-bits.h                            |  4 ++--
> > > > > >  login/logout.c                                   |  4 ++--
> > > > > >  login/logwtmp.c                                  |  5 +++--
> > > > > >  nis/nis_call.c                                   | 16
> > > > > > +++++++--------- sysdeps/generic/hp-timing.h
> > > > > >     | 4 ++-- sysdeps/generic/memusage.h
> > > > > > |  4 ++-- sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |
> > > > > > 4 ++-- sysdeps/unix/sysv/linux/clock.c                  |  7
> > > > > > ++----- 9 files changed, 23 insertions(+), 27 deletions(-)
> > > > > >
> > > > >
> > > > > Does this patch work with "make bench" when
> > > > > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > > > > In file included from ./bench-timing.h:23,
> > > > >                  from ./bench-skeleton.c:25,
> > > > >                  from
> > > > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > > > ./bench-skeleton.c: In function ‘main’:
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit
> > > > > declaration of function ‘__clock_gettime64’; did you mean
> > > > > ‘clock_gettime’? [-Werror=implicit-function-declaration]
> > > > >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> > > > >       |   ^~~~~~~~~~~~~~~~~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > ‘tv’ [-Werror=unused-variable]
> > > > >    37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > ‘tv’ [-Werror=unused-variable]
> > > > >    37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > ‘tv’ [-Werror=unused-variable]
> > > > >    37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > ‘tv’ [-Werror=unused-variable]
> > > > >    37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > >       |        ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > >       |   ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > ‘tv’ [-Werror=unused-variable]
> > > > >    37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > >       |   ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > >       |   ^~~~~~~~~~
> > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > ‘tv’ [-Werror=unused-variable]
> > > > >    37 |   struct __timespec64 tv;      \
> > > > >       |                       ^~
> > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW (var)
> > > > >       |                         ^~~~~~~~~~~~~
> > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > >       |   ^~~~~~~~~~
> > > > > cc1: all warnings being treated as errors
> > > >
> > > > How shall I reproduce this error?
> > >
> > > Apply the enclosed patch and do
> > >
> > > $ make USE_CLOCK_GETTIME=1 bench
> > >
> > > > Was it supposed to be catch with build-many-glibc.py ?
> > > >
> > >
> > > No, "make bench" isn't tested by build-many-glibc.py.
> > >
> >
> > Here is the patch to fix __clock_gettime64 for
> > sysdeps/generic/hp-timing.h. OK for master?
> >
>
> Thanks for preparing the fix.
>
> If I may ask - I do have some question about the following code:
> +#else
> +struct __timespec64;
> +extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64
> *tp); +#endif
>
> Why do we need the "struct __timespec64;" declaration there as
> in ./sysdeps/generic/hp-timing.h you explicitly added:
> #include <struct___timespec64.h> ?
>

include/time.h is also included by other files which may not include
<struct___timespec64.h>.

-- 
H.J.

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

* Re: [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-24 11:39           ` H.J. Lu via Libc-alpha
@ 2020-05-24 15:30             ` Lukasz Majewski
  2020-05-24 16:13               ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: Lukasz Majewski @ 2020-05-24 15:30 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

On Sun, 24 May 2020 04:39:47 -0700
"H.J. Lu" <hjl.tools@gmail.com> wrote:

> On Sun, May 24, 2020 at 2:03 AM Lukasz Majewski <lukma@denx.de> wrote:
> >
> > On Sat, 23 May 2020 13:32:05 -0700
> > "H.J. Lu" <hjl.tools@gmail.com> wrote:
> >  
> > > On Thu, May 21, 2020 at 4:11 AM H.J. Lu <hjl.tools@gmail.com>
> > > wrote:  
> > > >
> > > > On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de>
> > > > wrote:  
> > > > >
> > > > > Hi "H.J. Lu",
> > > > >  
> > > > > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski
> > > > > > <lukma@denx.de> wrote:  
> > > > > > >
> > > > > > > The __clock_gettime internal function is not supporting 64
> > > > > > > bit time on architectures with __WORDSIZE == 32 and
> > > > > > > __TIMESIZE != 64 (like e.g. ARM 32 bit).
> > > > > > >
> > > > > > > The __clock_gettime64 function shall be used instead in
> > > > > > > the glibc itself as it supports 64 bit time on those
> > > > > > > systems. This patch does not bring any changes to systems
> > > > > > > with __WORDSIZE == 64 as for them the __clock_gettime64
> > > > > > > is aliased to __clock_gettime (in ./include/time.h).
> > > > > > >
> > > > > > > ---
> > > > > > > Changes for v3:
> > > > > > > - Fix the commit message (add missing "function" after
> > > > > > > __clock_gettime64)
> > > > > > > - Refactor __nisfind_server() function to support 64 bit
> > > > > > > time with struct timespec instead of struct timeval
> > > > > > > - Change expires to __time64_t
> > > > > > >
> > > > > > > Changes for v2:
> > > > > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > > > > valid_timespec64_to_timeval in logout.c and logwtmp.c as
> > > > > > > it is generic enough to also support struct __timespec64
> > > > > > > conversion to struct timeval ---
> > > > > > >  benchtests/bench-timing.h                        |  2 +-
> > > > > > >  include/random-bits.h                            |  4
> > > > > > > ++-- login/logout.c                                   |
> > > > > > > 4 ++-- login/logwtmp.c                                  |
> > > > > > >  5 +++-- nis/nis_call.c
> > > > > > > | 16 +++++++--------- sysdeps/generic/hp-timing.h
> > > > > > >     | 4 ++-- sysdeps/generic/memusage.h
> > > > > > > |  4 ++--
> > > > > > > sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 4 ++--
> > > > > > > sysdeps/unix/sysv/linux/clock.c                  |  7
> > > > > > > ++----- 9 files changed, 23 insertions(+), 27
> > > > > > > deletions(-) 
> > > > > >
> > > > > > Does this patch work with "make bench" when
> > > > > > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > > > > > In file included from ./bench-timing.h:23,
> > > > > >                  from ./bench-skeleton.c:25,
> > > > > >                  from
> > > > > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > > > > ./bench-skeleton.c: In function ‘main’:
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit
> > > > > > declaration of function ‘__clock_gettime64’; did you mean
> > > > > > ‘clock_gettime’? [-Werror=implicit-function-declaration]
> > > > > >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> > > > > >       |   ^~~~~~~~~~~~~~~~~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > >    37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > >    37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > >    37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > >    37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > > >       |        ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > > >       |   ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > >    37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > > >       |   ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > > >       |   ^~~~~~~~~~
> > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > >    37 |   struct __timespec64 tv;      \
> > > > > >       |                       ^~
> > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > > >       |   ^~~~~~~~~~
> > > > > > cc1: all warnings being treated as errors  
> > > > >
> > > > > How shall I reproduce this error?  
> > > >
> > > > Apply the enclosed patch and do
> > > >
> > > > $ make USE_CLOCK_GETTIME=1 bench
> > > >  
> > > > > Was it supposed to be catch with build-many-glibc.py ?
> > > > >  
> > > >
> > > > No, "make bench" isn't tested by build-many-glibc.py.
> > > >  
> > >
> > > Here is the patch to fix __clock_gettime64 for
> > > sysdeps/generic/hp-timing.h. OK for master?
> > >  
> >
> > Thanks for preparing the fix.
> >
> > If I may ask - I do have some question about the following code:
> > +#else
> > +struct __timespec64;
> > +extern int __clock_gettime64 (clockid_t clock_id, struct
> > __timespec64 *tp); +#endif
> >
> > Why do we need the "struct __timespec64;" declaration there as
> > in ./sysdeps/generic/hp-timing.h you explicitly added:
> > #include <struct___timespec64.h> ?
> >  
> 
> include/time.h is also included by other files which may not include
> <struct___timespec64.h>.
> 

In which files you observe this situation?

The <struct___timespec64.h> was introduced to avoid including time.h
when only new, y2038 safe struct __timespec64 is necessary.




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] 23+ messages in thread

* Re: [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-24 15:30             ` Lukasz Majewski
@ 2020-05-24 16:13               ` H.J. Lu via Libc-alpha
  2020-05-24 23:34                 ` V2 " H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-24 16:13 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

On Sun, May 24, 2020 at 8:30 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> On Sun, 24 May 2020 04:39:47 -0700
> "H.J. Lu" <hjl.tools@gmail.com> wrote:
>
> > On Sun, May 24, 2020 at 2:03 AM Lukasz Majewski <lukma@denx.de> wrote:
> > >
> > > On Sat, 23 May 2020 13:32:05 -0700
> > > "H.J. Lu" <hjl.tools@gmail.com> wrote:
> > >
> > > > On Thu, May 21, 2020 at 4:11 AM H.J. Lu <hjl.tools@gmail.com>
> > > > wrote:
> > > > >
> > > > > On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de>
> > > > > wrote:
> > > > > >
> > > > > > Hi "H.J. Lu",
> > > > > >
> > > > > > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski
> > > > > > > <lukma@denx.de> wrote:
> > > > > > > >
> > > > > > > > The __clock_gettime internal function is not supporting 64
> > > > > > > > bit time on architectures with __WORDSIZE == 32 and
> > > > > > > > __TIMESIZE != 64 (like e.g. ARM 32 bit).
> > > > > > > >
> > > > > > > > The __clock_gettime64 function shall be used instead in
> > > > > > > > the glibc itself as it supports 64 bit time on those
> > > > > > > > systems. This patch does not bring any changes to systems
> > > > > > > > with __WORDSIZE == 64 as for them the __clock_gettime64
> > > > > > > > is aliased to __clock_gettime (in ./include/time.h).
> > > > > > > >
> > > > > > > > ---
> > > > > > > > Changes for v3:
> > > > > > > > - Fix the commit message (add missing "function" after
> > > > > > > > __clock_gettime64)
> > > > > > > > - Refactor __nisfind_server() function to support 64 bit
> > > > > > > > time with struct timespec instead of struct timeval
> > > > > > > > - Change expires to __time64_t
> > > > > > > >
> > > > > > > > Changes for v2:
> > > > > > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > > > > > valid_timespec64_to_timeval in logout.c and logwtmp.c as
> > > > > > > > it is generic enough to also support struct __timespec64
> > > > > > > > conversion to struct timeval ---
> > > > > > > >  benchtests/bench-timing.h                        |  2 +-
> > > > > > > >  include/random-bits.h                            |  4
> > > > > > > > ++-- login/logout.c                                   |
> > > > > > > > 4 ++-- login/logwtmp.c                                  |
> > > > > > > >  5 +++-- nis/nis_call.c
> > > > > > > > | 16 +++++++--------- sysdeps/generic/hp-timing.h
> > > > > > > >     | 4 ++-- sysdeps/generic/memusage.h
> > > > > > > > |  4 ++--
> > > > > > > > sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 4 ++--
> > > > > > > > sysdeps/unix/sysv/linux/clock.c                  |  7
> > > > > > > > ++----- 9 files changed, 23 insertions(+), 27
> > > > > > > > deletions(-)
> > > > > > >
> > > > > > > Does this patch work with "make bench" when
> > > > > > > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > > > > > > In file included from ./bench-timing.h:23,
> > > > > > >                  from ./bench-skeleton.c:25,
> > > > > > >                  from
> > > > > > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > > > > > ./bench-skeleton.c: In function ‘main’:
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit
> > > > > > > declaration of function ‘__clock_gettime64’; did you mean
> > > > > > > ‘clock_gettime’? [-Werror=implicit-function-declaration]
> > > > > > >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> > > > > > >       |   ^~~~~~~~~~~~~~~~~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > > > >       |        ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > > > >       |   ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > > > >       |   ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > > > >       |   ^~~~~~~~~~
> > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > >       |                       ^~
> > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > > > >       |   ^~~~~~~~~~
> > > > > > > cc1: all warnings being treated as errors
> > > > > >
> > > > > > How shall I reproduce this error?
> > > > >
> > > > > Apply the enclosed patch and do
> > > > >
> > > > > $ make USE_CLOCK_GETTIME=1 bench
> > > > >
> > > > > > Was it supposed to be catch with build-many-glibc.py ?
> > > > > >
> > > > >
> > > > > No, "make bench" isn't tested by build-many-glibc.py.
> > > > >
> > > >
> > > > Here is the patch to fix __clock_gettime64 for
> > > > sysdeps/generic/hp-timing.h. OK for master?
> > > >
> > >
> > > Thanks for preparing the fix.
> > >
> > > If I may ask - I do have some question about the following code:
> > > +#else
> > > +struct __timespec64;
> > > +extern int __clock_gettime64 (clockid_t clock_id, struct
> > > __timespec64 *tp); +#endif
> > >
> > > Why do we need the "struct __timespec64;" declaration there as
> > > in ./sysdeps/generic/hp-timing.h you explicitly added:
> > > #include <struct___timespec64.h> ?
> > >
> >
> > include/time.h is also included by other files which may not include
> > <struct___timespec64.h>.
> >
>
> In which files you observe this situation?
>
> The <struct___timespec64.h> was introduced to avoid including time.h
> when only new, y2038 safe struct __timespec64 is necessary.
>

Without it, I got

cc -m32 getprtent_r.c -c -std=gnu11 -fgnu89-inline  -O2 -g -march=i686
-Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants
-frounding-math -fno-stack-protector -Wstrict-prototypes
-Wold-style-definition -fmath-errno   -fPIC -Wa,-mtune=i686
-fexceptions  -ftls-model=initial-exec      -I../include
-I/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet
 -I/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux
-I../sysdeps/unix/sysv/linux/i386/i686  -I../sysdeps/i386/i686/nptl
-I../sysdeps/unix/sysv/linux/i386
-I../sysdeps/unix/sysv/linux/x86/include
-I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
-I../sysdeps/i386/nptl  -I../sysdeps/unix/sysv/linux/include
-I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread
-I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
-I../sysdeps/unix/i386  -I../sysdeps/unix  -I../sysdeps/posix
-I../sysdeps/i386/i686/fpu/multiarch  -I../sysdeps/i386/i686/fpu
-I../sysdeps/i386/i686/multiarch  -I../sysdeps/i386/i686
-I../sysdeps/i386/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/i386
-I../sysdeps/x86  -I../sysdeps/wordsize-32
-I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
-I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64
-I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754
-I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include
/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED
   -DTOP_NAMESPACE=glibc -o
/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os
-MD -MP -MF /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os.dt
-MT /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os
In file included from ../sysdeps/nptl/lowlevellock.h:24,
                 from ../sysdeps/unix/sysv/linux/x86/lowlevellock.h:23,
                 from ../nptl/descr.h:29,
                 from ../sysdeps/i386/nptl/tls.h:120,
                 from ../sysdeps/i386/i686/nptl/tls.h:33,
                 from ../include/link.h:51,
                 from ../include/dlfcn.h:4,
                 from ../nss/nsswitch.h:28,
                 from ../include/nsswitch.h:1,
                 from ../inet/netgroup.h:22,
                 from ../include/netdb.h:203,
                 from getprtent_r.c:18:
../include/time.h:9:58: error: ‘struct __timespec64’ declared inside
parameter list will not be visible outside of this definition or
declaration [-Werror]
    9 | extern int __clock_gettime64 (clockid_t clock_id, struct
__timespec64 *tp);
      |                                                          ^~~~~~~~~~~~
cc1: all warnings being treated as errors

This may happen for all 32-bit targets.

-- 
H.J.

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

* V2 [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-24 16:13               ` H.J. Lu via Libc-alpha
@ 2020-05-24 23:34                 ` H.J. Lu via Libc-alpha
  2020-05-25 10:40                   ` Lukasz Majewski
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-24 23:34 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

On Sun, May 24, 2020 at 9:13 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, May 24, 2020 at 8:30 AM Lukasz Majewski <lukma@denx.de> wrote:
> >
> > On Sun, 24 May 2020 04:39:47 -0700
> > "H.J. Lu" <hjl.tools@gmail.com> wrote:
> >
> > > On Sun, May 24, 2020 at 2:03 AM Lukasz Majewski <lukma@denx.de> wrote:
> > > >
> > > > On Sat, 23 May 2020 13:32:05 -0700
> > > > "H.J. Lu" <hjl.tools@gmail.com> wrote:
> > > >
> > > > > On Thu, May 21, 2020 at 4:11 AM H.J. Lu <hjl.tools@gmail.com>
> > > > > wrote:
> > > > > >
> > > > > > On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski <lukma@denx.de>
> > > > > > wrote:
> > > > > > >
> > > > > > > Hi "H.J. Lu",
> > > > > > >
> > > > > > > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski
> > > > > > > > <lukma@denx.de> wrote:
> > > > > > > > >
> > > > > > > > > The __clock_gettime internal function is not supporting 64
> > > > > > > > > bit time on architectures with __WORDSIZE == 32 and
> > > > > > > > > __TIMESIZE != 64 (like e.g. ARM 32 bit).
> > > > > > > > >
> > > > > > > > > The __clock_gettime64 function shall be used instead in
> > > > > > > > > the glibc itself as it supports 64 bit time on those
> > > > > > > > > systems. This patch does not bring any changes to systems
> > > > > > > > > with __WORDSIZE == 64 as for them the __clock_gettime64
> > > > > > > > > is aliased to __clock_gettime (in ./include/time.h).
> > > > > > > > >
> > > > > > > > > ---
> > > > > > > > > Changes for v3:
> > > > > > > > > - Fix the commit message (add missing "function" after
> > > > > > > > > __clock_gettime64)
> > > > > > > > > - Refactor __nisfind_server() function to support 64 bit
> > > > > > > > > time with struct timespec instead of struct timeval
> > > > > > > > > - Change expires to __time64_t
> > > > > > > > >
> > > > > > > > > Changes for v2:
> > > > > > > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > > > > > > valid_timespec64_to_timeval in logout.c and logwtmp.c as
> > > > > > > > > it is generic enough to also support struct __timespec64
> > > > > > > > > conversion to struct timeval ---
> > > > > > > > >  benchtests/bench-timing.h                        |  2 +-
> > > > > > > > >  include/random-bits.h                            |  4
> > > > > > > > > ++-- login/logout.c                                   |
> > > > > > > > > 4 ++-- login/logwtmp.c                                  |
> > > > > > > > >  5 +++-- nis/nis_call.c
> > > > > > > > > | 16 +++++++--------- sysdeps/generic/hp-timing.h
> > > > > > > > >     | 4 ++-- sysdeps/generic/memusage.h
> > > > > > > > > |  4 ++--
> > > > > > > > > sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 4 ++--
> > > > > > > > > sysdeps/unix/sysv/linux/clock.c                  |  7
> > > > > > > > > ++----- 9 files changed, 23 insertions(+), 27
> > > > > > > > > deletions(-)
> > > > > > > >
> > > > > > > > Does this patch work with "make bench" when
> > > > > > > > sysdeps/generic/hp-timing.h is used, like on arm?  I got
> > > > > > > > In file included from ./bench-timing.h:23,
> > > > > > > >                  from ./bench-skeleton.c:25,
> > > > > > > >                  from
> > > > > > > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > > > > > > ./bench-skeleton.c: In function ‘main’:
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit
> > > > > > > > declaration of function ‘__clock_gettime64’; did you mean
> > > > > > > > ‘clock_gettime’? [-Werror=implicit-function-declaration]
> > > > > > > >    38 |   __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \
> > > > > > > >       |   ^~~~~~~~~~~~~~~~~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:82:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 82 |        TIMING_NOW (start);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:86:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 86 |        TIMING_NOW (end);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:90:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 90 |        TIMING_NOW (start);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:94:8: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 94 |        TIMING_NOW (end);
> > > > > > > >       |        ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > > > > >       |   ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:103:3: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 103 |   TIMING_NOW (start);
> > > > > > > >       |   ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage size of
> > > > > > > > ‘tv’ isn’t known 37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > > > > >       |   ^~~~~~~~~~
> > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused variable
> > > > > > > > ‘tv’ [-Werror=unused-variable]
> > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > >       |                       ^~
> > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var) HP_TIMING_NOW
> > > > > > > > (var) |                         ^~~~~~~~~~~~~
> > > > > > > > ./bench-skeleton.c:106:3: note: in expansion of macro
> > > > > > > > ‘TIMING_NOW’ 106 |   TIMING_NOW (end);
> > > > > > > >       |   ^~~~~~~~~~
> > > > > > > > cc1: all warnings being treated as errors
> > > > > > >
> > > > > > > How shall I reproduce this error?
> > > > > >
> > > > > > Apply the enclosed patch and do
> > > > > >
> > > > > > $ make USE_CLOCK_GETTIME=1 bench
> > > > > >
> > > > > > > Was it supposed to be catch with build-many-glibc.py ?
> > > > > > >
> > > > > >
> > > > > > No, "make bench" isn't tested by build-many-glibc.py.
> > > > > >
> > > > >
> > > > > Here is the patch to fix __clock_gettime64 for
> > > > > sysdeps/generic/hp-timing.h. OK for master?
> > > > >
> > > >
> > > > Thanks for preparing the fix.
> > > >
> > > > If I may ask - I do have some question about the following code:
> > > > +#else
> > > > +struct __timespec64;
> > > > +extern int __clock_gettime64 (clockid_t clock_id, struct
> > > > __timespec64 *tp); +#endif
> > > >
> > > > Why do we need the "struct __timespec64;" declaration there as
> > > > in ./sysdeps/generic/hp-timing.h you explicitly added:
> > > > #include <struct___timespec64.h> ?
> > > >
> > >
> > > include/time.h is also included by other files which may not include
> > > <struct___timespec64.h>.
> > >
> >
> > In which files you observe this situation?
> >
> > The <struct___timespec64.h> was introduced to avoid including time.h
> > when only new, y2038 safe struct __timespec64 is necessary.
> >
>
> Without it, I got
>
> cc -m32 getprtent_r.c -c -std=gnu11 -fgnu89-inline  -O2 -g -march=i686
> -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants
> -frounding-math -fno-stack-protector -Wstrict-prototypes
> -Wold-style-definition -fmath-errno   -fPIC -Wa,-mtune=i686
> -fexceptions  -ftls-model=initial-exec      -I../include
> -I/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet
>  -I/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux
> -I../sysdeps/unix/sysv/linux/i386/i686  -I../sysdeps/i386/i686/nptl
> -I../sysdeps/unix/sysv/linux/i386
> -I../sysdeps/unix/sysv/linux/x86/include
> -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
> -I../sysdeps/i386/nptl  -I../sysdeps/unix/sysv/linux/include
> -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread
> -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
> -I../sysdeps/unix/i386  -I../sysdeps/unix  -I../sysdeps/posix
> -I../sysdeps/i386/i686/fpu/multiarch  -I../sysdeps/i386/i686/fpu
> -I../sysdeps/i386/i686/multiarch  -I../sysdeps/i386/i686
> -I../sysdeps/i386/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/i386
> -I../sysdeps/x86  -I../sysdeps/wordsize-32
> -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
> -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64
> -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754
> -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include
> /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc-modules.h
> -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED
>    -DTOP_NAMESPACE=glibc -o
> /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os
> -MD -MP -MF /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os.dt
> -MT /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os
> In file included from ../sysdeps/nptl/lowlevellock.h:24,
>                  from ../sysdeps/unix/sysv/linux/x86/lowlevellock.h:23,
>                  from ../nptl/descr.h:29,
>                  from ../sysdeps/i386/nptl/tls.h:120,
>                  from ../sysdeps/i386/i686/nptl/tls.h:33,
>                  from ../include/link.h:51,
>                  from ../include/dlfcn.h:4,
>                  from ../nss/nsswitch.h:28,
>                  from ../include/nsswitch.h:1,
>                  from ../inet/netgroup.h:22,
>                  from ../include/netdb.h:203,
>                  from getprtent_r.c:18:
> ../include/time.h:9:58: error: ‘struct __timespec64’ declared inside
> parameter list will not be visible outside of this definition or
> declaration [-Werror]
>     9 | extern int __clock_gettime64 (clockid_t clock_id, struct
> __timespec64 *tp);
>       |                                                          ^~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> This may happen for all 32-bit targets.

We can't change include/time.h.   Here is the updated patch
to put __clock_gettime64 in sysdeps/generic/hp-timing.h if
_ISOMAC is defined.

-- 
H.J.

[-- Attachment #2: 0001-Fix-__clock_gettime64-for-sysdeps-generic-hp-timing..patch --]
[-- Type: text/x-patch, Size: 2172 bytes --]

From f805c47d4ec1013cf04509538ee8935e38610e4f Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 23 May 2020 10:04:20 -0700
Subject: [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit e9698175b0b60407db1e89bcf29437ab224bca0b
Author: Lukasz Majewski <lukma@denx.de>
Date:   Mon Mar 16 08:31:41 2020 +0100

    y2038: Replace __clock_gettime with __clock_gettime64

breaks benchtests with sysdeps/generic/hp-timing.h:

In file included from ./bench-timing.h:23,
                 from ./bench-skeleton.c:25,
                 from
/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
./bench-skeleton.c: In function ‘main’:
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~

We should provide __clock_gettime64 in sysdeps/generic/hp-timing.h if
_ISOMAC is defined.  Don't define __clock_gettime since it is no longer
needed.
---
 benchtests/bench-timing.h   |  1 -
 sysdeps/generic/hp-timing.h | 10 ++++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index a0d6f82465..d0176fb76e 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -18,7 +18,6 @@
 
 #undef attribute_hidden
 #define attribute_hidden
-#define __clock_gettime __clock_gettime64
 #include <hp-timing.h>
 #include <stdint.h>
 
diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
index af9d92f7f7..2efd7a6e54 100644
--- a/sysdeps/generic/hp-timing.h
+++ b/sysdeps/generic/hp-timing.h
@@ -24,6 +24,16 @@
 #include <stdint.h>
 #include <hp-timing-common.h>
 
+#ifdef _ISOMAC
+# include <struct___timespec64.h>
+extern __typeof (clock_gettime) __clock_gettime;
+# if __TIMESIZE == 64
+#  define __clock_gettime64 __clock_gettime
+# else
+extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
+# endif
+#endif
+
 /* It should not be used for ld.so.  */
 #define HP_TIMING_INLINE	(0)
 
-- 
2.26.2


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

* Re: V2 [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h
  2020-05-24 23:34                 ` V2 " H.J. Lu via Libc-alpha
@ 2020-05-25 10:40                   ` Lukasz Majewski
  0 siblings, 0 replies; 23+ messages in thread
From: Lukasz Majewski @ 2020-05-25 10:40 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Florian Weimer, GNU C Library, Andreas Schwab, Alistair Francis,
	Joseph Myers

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

On Sun, 24 May 2020 16:34:44 -0700
"H.J. Lu" <hjl.tools@gmail.com> wrote:

> On Sun, May 24, 2020 at 9:13 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Sun, May 24, 2020 at 8:30 AM Lukasz Majewski <lukma@denx.de>
> > wrote:  
> > >
> > > On Sun, 24 May 2020 04:39:47 -0700
> > > "H.J. Lu" <hjl.tools@gmail.com> wrote:
> > >  
> > > > On Sun, May 24, 2020 at 2:03 AM Lukasz Majewski <lukma@denx.de>
> > > > wrote:  
> > > > >
> > > > > On Sat, 23 May 2020 13:32:05 -0700
> > > > > "H.J. Lu" <hjl.tools@gmail.com> wrote:
> > > > >  
> > > > > > On Thu, May 21, 2020 at 4:11 AM H.J. Lu
> > > > > > <hjl.tools@gmail.com> wrote:  
> > > > > > >
> > > > > > > On Thu, May 21, 2020 at 3:24 AM Lukasz Majewski
> > > > > > > <lukma@denx.de> wrote:  
> > > > > > > >
> > > > > > > > Hi "H.J. Lu",
> > > > > > > >  
> > > > > > > > > On Tue, May 5, 2020 at 11:21 AM Lukasz Majewski
> > > > > > > > > <lukma@denx.de> wrote:  
> > > > > > > > > >
> > > > > > > > > > The __clock_gettime internal function is not
> > > > > > > > > > supporting 64 bit time on architectures with
> > > > > > > > > > __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g.
> > > > > > > > > > ARM 32 bit).
> > > > > > > > > >
> > > > > > > > > > The __clock_gettime64 function shall be used
> > > > > > > > > > instead in the glibc itself as it supports 64 bit
> > > > > > > > > > time on those systems. This patch does not bring
> > > > > > > > > > any changes to systems with __WORDSIZE == 64 as for
> > > > > > > > > > them the __clock_gettime64 is aliased to
> > > > > > > > > > __clock_gettime (in ./include/time.h).
> > > > > > > > > >
> > > > > > > > > > ---
> > > > > > > > > > Changes for v3:
> > > > > > > > > > - Fix the commit message (add missing "function"
> > > > > > > > > > after __clock_gettime64)
> > > > > > > > > > - Refactor __nisfind_server() function to support
> > > > > > > > > > 64 bit time with struct timespec instead of struct
> > > > > > > > > > timeval
> > > > > > > > > > - Change expires to __time64_t
> > > > > > > > > >
> > > > > > > > > > Changes for v2:
> > > > > > > > > > - Use only TIMESPEC_TO_TIMEVAL instead of
> > > > > > > > > > valid_timespec64_to_timeval in logout.c and
> > > > > > > > > > logwtmp.c as it is generic enough to also support
> > > > > > > > > > struct __timespec64 conversion to struct timeval ---
> > > > > > > > > >  benchtests/bench-timing.h                        |
> > > > > > > > > >  2 +- include/random-bits.h
> > > > > > > > > >    |  4 ++-- login/logout.c
> > > > > > > > > >           | 4 ++-- login/logwtmp.c
> > > > > > > > > >                 | 5 +++-- nis/nis_call.c
> > > > > > > > > > | 16 +++++++--------- sysdeps/generic/hp-timing.h
> > > > > > > > > >     | 4 ++-- sysdeps/generic/memusage.h
> > > > > > > > > > |  4 ++--
> > > > > > > > > > sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c |
> > > > > > > > > > 4 ++-- sysdeps/unix/sysv/linux/clock.c
> > > > > > > > > >     |  7 ++----- 9 files changed, 23 insertions(+),
> > > > > > > > > > 27 deletions(-)  
> > > > > > > > >
> > > > > > > > > Does this patch work with "make bench" when
> > > > > > > > > sysdeps/generic/hp-timing.h is used, like on arm?  I
> > > > > > > > > got In file included from ./bench-timing.h:23,
> > > > > > > > >                  from ./bench-skeleton.c:25,
> > > > > > > > >                  from
> > > > > > > > > /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> > > > > > > > > ./bench-skeleton.c: In function ‘main’:
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage
> > > > > > > > > size of ‘tv’ isn’t known 37 |   struct __timespec64
> > > > > > > > > tv;      \ |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:82:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 82 |
> > > > > > > > > TIMING_NOW (start); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:38:3: error: implicit
> > > > > > > > > declaration of function ‘__clock_gettime64’; did you
> > > > > > > > > mean ‘clock_gettime’?
> > > > > > > > > [-Werror=implicit-function-declaration] 38 |
> > > > > > > > > __clock_gettime64 (CLOCK_MONOTONIC, &tv);   \ |
> > > > > > > > > ^~~~~~~~~~~~~~~~~ ./bench-timing.h:35:25: note: in
> > > > > > > > > expansion of macro ‘HP_TIMING_NOW’ 35 | #define
> > > > > > > > > TIMING_NOW(var) HP_TIMING_NOW (var) |
> > > > > > > > >         ^~~~~~~~~~~~~ ./bench-skeleton.c:82:8: note:
> > > > > > > > > in expansion of macro ‘TIMING_NOW’ 82 |
> > > > > > > > > TIMING_NOW (start); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused
> > > > > > > > > variable ‘tv’ [-Werror=unused-variable]
> > > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > > >       |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:82:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 82 |
> > > > > > > > > TIMING_NOW (start); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage
> > > > > > > > > size of ‘tv’ isn’t known 37 |   struct __timespec64
> > > > > > > > > tv;      \ |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:86:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 86 |
> > > > > > > > > TIMING_NOW (end); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused
> > > > > > > > > variable ‘tv’ [-Werror=unused-variable]
> > > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > > >       |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:86:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 86 |
> > > > > > > > > TIMING_NOW (end); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage
> > > > > > > > > size of ‘tv’ isn’t known 37 |   struct __timespec64
> > > > > > > > > tv;      \ |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:90:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 90 |
> > > > > > > > > TIMING_NOW (start); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused
> > > > > > > > > variable ‘tv’ [-Werror=unused-variable]
> > > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > > >       |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:90:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 90 |
> > > > > > > > > TIMING_NOW (start); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage
> > > > > > > > > size of ‘tv’ isn’t known 37 |   struct __timespec64
> > > > > > > > > tv;      \ |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:94:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 94 |
> > > > > > > > > TIMING_NOW (end); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused
> > > > > > > > > variable ‘tv’ [-Werror=unused-variable]
> > > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > > >       |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:94:8: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 94 |
> > > > > > > > > TIMING_NOW (end); |        ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage
> > > > > > > > > size of ‘tv’ isn’t known 37 |   struct __timespec64
> > > > > > > > > tv;      \ |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:103:3: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 103 |   TIMING_NOW
> > > > > > > > > (start); |   ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused
> > > > > > > > > variable ‘tv’ [-Werror=unused-variable]
> > > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > > >       |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:103:3: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 103 |   TIMING_NOW
> > > > > > > > > (start); |   ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: storage
> > > > > > > > > size of ‘tv’ isn’t known 37 |   struct __timespec64
> > > > > > > > > tv;      \ |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:106:3: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 106 |   TIMING_NOW
> > > > > > > > > (end); |   ^~~~~~~~~~
> > > > > > > > > ../sysdeps/generic/hp-timing.h:37:23: error: unused
> > > > > > > > > variable ‘tv’ [-Werror=unused-variable]
> > > > > > > > >    37 |   struct __timespec64 tv;      \
> > > > > > > > >       |                       ^~
> > > > > > > > > ./bench-timing.h:35:25: note: in expansion of macro
> > > > > > > > > ‘HP_TIMING_NOW’ 35 | #define TIMING_NOW(var)
> > > > > > > > > HP_TIMING_NOW (var) |
> > > > > > > > > ^~~~~~~~~~~~~ ./bench-skeleton.c:106:3: note: in
> > > > > > > > > expansion of macro ‘TIMING_NOW’ 106 |   TIMING_NOW
> > > > > > > > > (end); |   ^~~~~~~~~~
> > > > > > > > > cc1: all warnings being treated as errors  
> > > > > > > >
> > > > > > > > How shall I reproduce this error?  
> > > > > > >
> > > > > > > Apply the enclosed patch and do
> > > > > > >
> > > > > > > $ make USE_CLOCK_GETTIME=1 bench
> > > > > > >  
> > > > > > > > Was it supposed to be catch with build-many-glibc.py ?
> > > > > > > >  
> > > > > > >
> > > > > > > No, "make bench" isn't tested by build-many-glibc.py.
> > > > > > >  
> > > > > >
> > > > > > Here is the patch to fix __clock_gettime64 for
> > > > > > sysdeps/generic/hp-timing.h. OK for master?
> > > > > >  
> > > > >
> > > > > Thanks for preparing the fix.
> > > > >
> > > > > If I may ask - I do have some question about the following
> > > > > code: +#else
> > > > > +struct __timespec64;
> > > > > +extern int __clock_gettime64 (clockid_t clock_id, struct
> > > > > __timespec64 *tp); +#endif
> > > > >
> > > > > Why do we need the "struct __timespec64;" declaration there as
> > > > > in ./sysdeps/generic/hp-timing.h you explicitly added:
> > > > > #include <struct___timespec64.h> ?
> > > > >  
> > > >
> > > > include/time.h is also included by other files which may not
> > > > include <struct___timespec64.h>.
> > > >  
> > >
> > > In which files you observe this situation?
> > >
> > > The <struct___timespec64.h> was introduced to avoid including
> > > time.h when only new, y2038 safe struct __timespec64 is necessary.
> > >  
> >
> > Without it, I got
> >
> > cc -m32 getprtent_r.c -c -std=gnu11 -fgnu89-inline  -O2 -g
> > -march=i686 -Wall -Wwrite-strings -Wundef -Werror
> > -fmerge-all-constants -frounding-math -fno-stack-protector
> > -Wstrict-prototypes -Wold-style-definition -fmath-errno   -fPIC
> > -Wa,-mtune=i686 -fexceptions  -ftls-model=initial-exec
> > -I../include
> > -I/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet
> > -I/export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux
> > -I../sysdeps/unix/sysv/linux/i386/i686  -I../sysdeps/i386/i686/nptl
> > -I../sysdeps/unix/sysv/linux/i386
> > -I../sysdeps/unix/sysv/linux/x86/include
> > -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
> > -I../sysdeps/i386/nptl  -I../sysdeps/unix/sysv/linux/include
> > -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl
> > -I../sysdeps/pthread -I../sysdeps/gnu  -I../sysdeps/unix/inet
> > -I../sysdeps/unix/sysv -I../sysdeps/unix/i386  -I../sysdeps/unix
> > -I../sysdeps/posix -I../sysdeps/i386/i686/fpu/multiarch
> > -I../sysdeps/i386/i686/fpu -I../sysdeps/i386/i686/multiarch
> > -I../sysdeps/i386/i686 -I../sysdeps/i386/fpu  -I../sysdeps/x86/fpu
> > -I../sysdeps/i386 -I../sysdeps/x86  -I../sysdeps/wordsize-32
> > -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
> > -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64
> > -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754
> > -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT
> > -include
> > /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc-modules.h
> > -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC
> > -DSHARED -DTOP_NAMESPACE=glibc -o
> > /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os
> > -MD -MP -MF
> > /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os.dt
> > -MT
> > /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/inet/getprtent_r.os
> > In file included from ../sysdeps/nptl/lowlevellock.h:24, from
> > ../sysdeps/unix/sysv/linux/x86/lowlevellock.h:23, from
> > ../nptl/descr.h:29, from ../sysdeps/i386/nptl/tls.h:120, from
> > ../sysdeps/i386/i686/nptl/tls.h:33, from ../include/link.h:51, from
> > ../include/dlfcn.h:4, from ../nss/nsswitch.h:28, from
> > ../include/nsswitch.h:1, from ../inet/netgroup.h:22,
> >                  from ../include/netdb.h:203,
> >                  from getprtent_r.c:18:
> > ../include/time.h:9:58: error: ‘struct __timespec64’ declared inside
> > parameter list will not be visible outside of this definition or
> > declaration [-Werror]
> >     9 | extern int __clock_gettime64 (clockid_t clock_id, struct
> > __timespec64 *tp);
> >       |
> > ^~~~~~~~~~~~ cc1: all warnings being treated as errors
> >
> > This may happen for all 32-bit targets.  
> 
> We can't change include/time.h.   Here is the updated patch
> to put __clock_gettime64 in sysdeps/generic/hp-timing.h if
> _ISOMAC is defined.
> 

It looks fine for me, but I think that some other (i.e. Joseph, Florian)
glibc developers shall also review it.


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] 23+ messages in thread

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-21  1:09 ` H.J. Lu via Libc-alpha
  2020-05-21 10:24   ` Lukasz Majewski
@ 2020-05-25 10:57   ` Andreas Schwab
  2020-05-27 12:44     ` Florian Weimer via Libc-alpha
  1 sibling, 1 reply; 23+ messages in thread
From: Andreas Schwab @ 2020-05-25 10:57 UTC (permalink / raw)
  To: H.J. Lu via Libc-alpha; +Cc: Florian Weimer, Alistair Francis, Joseph Myers

I don't think it make sense for benchtests to define _ISMAC if it uses
glibc internal interfaces.

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] 23+ messages in thread

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-25 10:57   ` [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Andreas Schwab
@ 2020-05-27 12:44     ` Florian Weimer via Libc-alpha
  2020-05-27 12:47       ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-05-27 12:44 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Alistair Francis, H.J. Lu via Libc-alpha, Joseph Myers

* Andreas Schwab:

> I don't think it make sense for benchtests to define _ISMAC if it uses
> glibc internal interfaces.

We have some internal interfaces that are available for !_ISOMAC,
e.g. pretty much the entire support/ directory.

I assume this is about <hp-timing.h>?  We could decide that it should be
in this category as well.

Thanks,
Florian


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

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-27 12:44     ` Florian Weimer via Libc-alpha
@ 2020-05-27 12:47       ` H.J. Lu via Libc-alpha
  2020-05-27 12:50         ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-27 12:47 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Andreas Schwab, Alistair Francis, H.J. Lu via Libc-alpha,
	Joseph Myers

On Wed, May 27, 2020 at 5:44 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Andreas Schwab:
>
> > I don't think it make sense for benchtests to define _ISMAC if it uses
> > glibc internal interfaces.
>
> We have some internal interfaces that are available for !_ISOMAC,
> e.g. pretty much the entire support/ directory.
>
> I assume this is about <hp-timing.h>?  We could decide that it should be
> in this category as well.

To be precise, it is sysdeps/generic/hp-timing.h:

#define HP_TIMING_NOW(var) \
({ \
  struct __timespec64 tv; \
  __clock_gettime64 (CLOCK_MONOTONIC, &tv); \
  (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec); \
})

-- 
H.J.

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

* Re: [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64
  2020-05-27 12:47       ` H.J. Lu via Libc-alpha
@ 2020-05-27 12:50         ` Florian Weimer via Libc-alpha
  2020-05-28 12:28           ` [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-05-27 12:50 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Andreas Schwab, Alistair Francis, H.J. Lu via Libc-alpha,
	Joseph Myers

* H. J. Lu:

> On Wed, May 27, 2020 at 5:44 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * Andreas Schwab:
>>
>> > I don't think it make sense for benchtests to define _ISMAC if it uses
>> > glibc internal interfaces.
>>
>> We have some internal interfaces that are available for !_ISOMAC,
>> e.g. pretty much the entire support/ directory.
>>
>> I assume this is about <hp-timing.h>?  We could decide that it should be
>> in this category as well.
>
> To be precise, it is sysdeps/generic/hp-timing.h:
>
> #define HP_TIMING_NOW(var) \
> ({ \
>   struct __timespec64 tv; \
>   __clock_gettime64 (CLOCK_MONOTONIC, &tv); \
>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec); \
> })

Okay, then we could add an #ifdef _ISOMAC and use clock_gettime outside
glibc.  Temporarily, until we have clock_gettime64 available outside
glibc, too.

Or would that be too awkward?

Thanks,
Florian


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

* [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h
  2020-05-27 12:50         ` Florian Weimer via Libc-alpha
@ 2020-05-28 12:28           ` H.J. Lu via Libc-alpha
  2020-05-28 12:58             ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-28 12:28 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Andreas Schwab, Alistair Francis, H.J. Lu via Libc-alpha,
	Joseph Myers

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

On Wed, May 27, 2020 at 5:50 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Wed, May 27, 2020 at 5:44 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * Andreas Schwab:
> >>
> >> > I don't think it make sense for benchtests to define _ISMAC if it uses
> >> > glibc internal interfaces.
> >>
> >> We have some internal interfaces that are available for !_ISOMAC,
> >> e.g. pretty much the entire support/ directory.
> >>
> >> I assume this is about <hp-timing.h>?  We could decide that it should be
> >> in this category as well.
> >
> > To be precise, it is sysdeps/generic/hp-timing.h:
> >
> > #define HP_TIMING_NOW(var) \
> > ({ \
> >   struct __timespec64 tv; \
> >   __clock_gettime64 (CLOCK_MONOTONIC, &tv); \
> >   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec); \
> > })
>
> Okay, then we could add an #ifdef _ISOMAC and use clock_gettime outside
> glibc.  Temporarily, until we have clock_gettime64 available outside
> glibc, too.
>

Like this?

-- 
H.J.

[-- Attachment #2: 0001-Fix-__clock_gettime64-with-_ISOMAC-in-sysdeps-generi.patch --]
[-- Type: application/x-patch, Size: 2025 bytes --]

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

* Re: [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h
  2020-05-28 12:28           ` [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
@ 2020-05-28 12:58             ` Florian Weimer via Libc-alpha
  2020-05-28 13:07               ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-05-28 12:58 UTC (permalink / raw)
  To: H.J. Lu via Libc-alpha; +Cc: Alistair Francis, Joseph Myers, Andreas Schwab

* H. J. Lu via Libc-alpha:

> diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
> index af9d92f7f7..99b12995f1 100644
> --- a/sysdeps/generic/hp-timing.h
> +++ b/sysdeps/generic/hp-timing.h
> @@ -24,6 +24,11 @@
>  #include <stdint.h>
>  #include <hp-timing-common.h>
>  
> +#ifdef _ISOMAC
> +# define __timespec64 timespec
> +# define __clock_gettime64 clock_gettime
> +#endif
> +
>  /* It should not be used for ld.so.  */
>  #define HP_TIMING_INLINE	(0)

To be honest, I would have expected different definitions of the timing
macros.  This redirection looks a bit iffy for me for _ISOMAC.

Thanks,
Florian


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

* Re: [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h
  2020-05-28 12:58             ` Florian Weimer via Libc-alpha
@ 2020-05-28 13:07               ` H.J. Lu via Libc-alpha
  2020-05-28 14:28                 ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-28 13:07 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Andreas Schwab, Alistair Francis, H.J. Lu via Libc-alpha,
	Joseph Myers

On Thu, May 28, 2020 at 5:58 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
> > index af9d92f7f7..99b12995f1 100644
> > --- a/sysdeps/generic/hp-timing.h
> > +++ b/sysdeps/generic/hp-timing.h
> > @@ -24,6 +24,11 @@
> >  #include <stdint.h>
> >  #include <hp-timing-common.h>
> >
> > +#ifdef _ISOMAC
> > +# define __timespec64 timespec
> > +# define __clock_gettime64 clock_gettime
> > +#endif
> > +
> >  /* It should not be used for ld.so.  */
> >  #define HP_TIMING_INLINE     (0)
>
> To be honest, I would have expected different definitions of the timing
> macros.  This redirection looks a bit iffy for me for _ISOMAC.

What do you have in mind?

-- 
H.J.

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

* Re: [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h
  2020-05-28 13:07               ` H.J. Lu via Libc-alpha
@ 2020-05-28 14:28                 ` Florian Weimer via Libc-alpha
  2020-05-28 14:50                   ` [PATCH] Update HP_TIMING_NOW for " H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-05-28 14:28 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Andreas Schwab, Alistair Francis, H.J. Lu via Libc-alpha,
	Joseph Myers

* H. J. Lu:

> On Thu, May 28, 2020 at 5:58 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu via Libc-alpha:
>>
>> > diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
>> > index af9d92f7f7..99b12995f1 100644
>> > --- a/sysdeps/generic/hp-timing.h
>> > +++ b/sysdeps/generic/hp-timing.h
>> > @@ -24,6 +24,11 @@
>> >  #include <stdint.h>
>> >  #include <hp-timing-common.h>
>> >
>> > +#ifdef _ISOMAC
>> > +# define __timespec64 timespec
>> > +# define __clock_gettime64 clock_gettime
>> > +#endif
>> > +
>> >  /* It should not be used for ld.so.  */
>> >  #define HP_TIMING_INLINE     (0)
>>
>> To be honest, I would have expected different definitions of the timing
>> macros.  This redirection looks a bit iffy for me for _ISOMAC.
>
> What do you have in mind?

Something like this:

/* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
   nano-second accuracy, and for some architectues is implemented as
   vDSO symbol.  */
#ifdef _ISOMAC
# define HP_TIMING_NOW(var) \
({								\
  struct timespec tv;						\
  clock_gettime (CLOCK_MONOTONIC, &tv);				\
  (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
})
#else
# define HP_TIMING_NOW(var) \
({								\
  struct __timespec64 tv;					\
  __clock_gettime64 (CLOCK_MONOTONIC, &tv);			\
  (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
})
#endif

in sysdeps/generic/hp-timing.h.

Thanks,
Florian


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

* [PATCH] Update HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.h
  2020-05-28 14:28                 ` Florian Weimer via Libc-alpha
@ 2020-05-28 14:50                   ` H.J. Lu via Libc-alpha
  2020-06-05 16:26                     ` Carlos O'Donell via Libc-alpha
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-05-28 14:50 UTC (permalink / raw)
  To: Florian Weimer
  Cc: Andreas Schwab, Alistair Francis, H.J. Lu via Libc-alpha,
	Joseph Myers

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

On Thu, May 28, 2020 at 7:29 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Thu, May 28, 2020 at 5:58 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu via Libc-alpha:
> >>
> >> > diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
> >> > index af9d92f7f7..99b12995f1 100644
> >> > --- a/sysdeps/generic/hp-timing.h
> >> > +++ b/sysdeps/generic/hp-timing.h
> >> > @@ -24,6 +24,11 @@
> >> >  #include <stdint.h>
> >> >  #include <hp-timing-common.h>
> >> >
> >> > +#ifdef _ISOMAC
> >> > +# define __timespec64 timespec
> >> > +# define __clock_gettime64 clock_gettime
> >> > +#endif
> >> > +
> >> >  /* It should not be used for ld.so.  */
> >> >  #define HP_TIMING_INLINE     (0)
> >>
> >> To be honest, I would have expected different definitions of the timing
> >> macros.  This redirection looks a bit iffy for me for _ISOMAC.
> >
> > What do you have in mind?
>
> Something like this:
>
> /* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
>    nano-second accuracy, and for some architectues is implemented as
>    vDSO symbol.  */
> #ifdef _ISOMAC
> # define HP_TIMING_NOW(var) \
> ({                                                              \
>   struct timespec tv;                                           \
>   clock_gettime (CLOCK_MONOTONIC, &tv);                         \
>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);      \
> })
> #else
> # define HP_TIMING_NOW(var) \
> ({                                                              \
>   struct __timespec64 tv;                                       \
>   __clock_gettime64 (CLOCK_MONOTONIC, &tv);                     \
>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);      \
> })
> #endif
>
> in sysdeps/generic/hp-timing.h.
>

Here is the updated patch.  OK for master?

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Update-HP_TIMING_NOW-for-_ISOMAC-in-sysdeps-generic-.patch --]
[-- Type: text/x-patch, Size: 2468 bytes --]

From f312c52fa80828ecdc473594e160ef2f5d2a00d7 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 23 May 2020 10:04:20 -0700
Subject: [PATCH] Update HP_TIMING_NOW for _ISOMAC in
 sysdeps/generic/hp-timing.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit e9698175b0b60407db1e89bcf29437ab224bca0b
Author: Lukasz Majewski <lukma@denx.de>
Date:   Mon Mar 16 08:31:41 2020 +0100

    y2038: Replace __clock_gettime with __clock_gettime64

breaks benchtests with sysdeps/generic/hp-timing.h:

In file included from ./bench-timing.h:23,
                 from ./bench-skeleton.c:25,
                 from
/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
./bench-skeleton.c: In function ‘main’:
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~

Define HP_TIMING_NOW with clock_gettime in sysdeps/generic/hp-timing.h
if _ISOMAC is defined.  Don't define __clock_gettime in bench-timing.h
since it is no longer needed.
---
 benchtests/bench-timing.h   |  1 -
 sysdeps/generic/hp-timing.h | 11 ++++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index a0d6f82465..d0176fb76e 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -18,7 +18,6 @@
 
 #undef attribute_hidden
 #define attribute_hidden
-#define __clock_gettime __clock_gettime64
 #include <hp-timing.h>
 #include <stdint.h>
 
diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
index af9d92f7f7..1960a71c62 100644
--- a/sysdeps/generic/hp-timing.h
+++ b/sysdeps/generic/hp-timing.h
@@ -32,11 +32,20 @@ typedef uint64_t hp_timing_t;
 /* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
    nano-second accuracy, and for some architectues is implemented as
    vDSO symbol.  */
-#define HP_TIMING_NOW(var) \
+#ifdef _ISOMAC
+# define HP_TIMING_NOW(var) \
+({								\
+  struct timespec tv;						\
+  clock_gettime (CLOCK_MONOTONIC, &tv);				\
+  (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
+})
+#else
+# define HP_TIMING_NOW(var) \
 ({								\
   struct __timespec64 tv;						\
   __clock_gettime64 (CLOCK_MONOTONIC, &tv);			\
   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
 })
+#endif
 
 #endif	/* hp-timing.h */
-- 
2.26.2


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

* Re: [PATCH] Update HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.h
  2020-05-28 14:50                   ` [PATCH] Update HP_TIMING_NOW for " H.J. Lu via Libc-alpha
@ 2020-06-05 16:26                     ` Carlos O'Donell via Libc-alpha
  0 siblings, 0 replies; 23+ messages in thread
From: Carlos O'Donell via Libc-alpha @ 2020-06-05 16:26 UTC (permalink / raw)
  To: H.J. Lu, Florian Weimer
  Cc: Andreas Schwab, H.J. Lu via Libc-alpha, Alistair Francis,
	Joseph Myers

On 5/28/20 10:50 AM, H.J. Lu via Libc-alpha wrote:
> On Thu, May 28, 2020 at 7:29 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>>> On Thu, May 28, 2020 at 5:58 AM Florian Weimer <fweimer@redhat.com> wrote:
>>>>
>>>> * H. J. Lu via Libc-alpha:
>>>>
>>>>> diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
>>>>> index af9d92f7f7..99b12995f1 100644
>>>>> --- a/sysdeps/generic/hp-timing.h
>>>>> +++ b/sysdeps/generic/hp-timing.h
>>>>> @@ -24,6 +24,11 @@
>>>>>  #include <stdint.h>
>>>>>  #include <hp-timing-common.h>
>>>>>
>>>>> +#ifdef _ISOMAC
>>>>> +# define __timespec64 timespec
>>>>> +# define __clock_gettime64 clock_gettime
>>>>> +#endif
>>>>> +
>>>>>  /* It should not be used for ld.so.  */
>>>>>  #define HP_TIMING_INLINE     (0)
>>>>
>>>> To be honest, I would have expected different definitions of the timing
>>>> macros.  This redirection looks a bit iffy for me for _ISOMAC.
>>>
>>> What do you have in mind?
>>
>> Something like this:
>>
>> /* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
>>    nano-second accuracy, and for some architectues is implemented as
>>    vDSO symbol.  */
>> #ifdef _ISOMAC
>> # define HP_TIMING_NOW(var) \
>> ({                                                              \
>>   struct timespec tv;                                           \
>>   clock_gettime (CLOCK_MONOTONIC, &tv);                         \
>>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);      \
>> })
>> #else
>> # define HP_TIMING_NOW(var) \
>> ({                                                              \
>>   struct __timespec64 tv;                                       \
>>   __clock_gettime64 (CLOCK_MONOTONIC, &tv);                     \
>>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);      \
>> })
>> #endif
>>
>> in sysdeps/generic/hp-timing.h.
>>
> 
> Here is the updated patch.  OK for master?

OK for master.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> From f312c52fa80828ecdc473594e160ef2f5d2a00d7 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Sat, 23 May 2020 10:04:20 -0700
> Subject: [PATCH] Update HP_TIMING_NOW for _ISOMAC in
>  sysdeps/generic/hp-timing.h
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> commit e9698175b0b60407db1e89bcf29437ab224bca0b
> Author: Lukasz Majewski <lukma@denx.de>
> Date:   Mon Mar 16 08:31:41 2020 +0100
> 
>     y2038: Replace __clock_gettime with __clock_gettime64
> 
> breaks benchtests with sysdeps/generic/hp-timing.h:

Yes, Patsy Griffin in testing for Fedora Rawhide has seen this for
aarch64, s390x, and armv7hl. Patsy is testing this patch now.

> In file included from ./bench-timing.h:23,
>                  from ./bench-skeleton.c:25,
>                  from
> /export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
> ./bench-skeleton.c: In function ‘main’:
> ../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
>    37 |   struct __timespec64 tv;      \
>       |                       ^~
> 
> Define HP_TIMING_NOW with clock_gettime in sysdeps/generic/hp-timing.h
> if _ISOMAC is defined.  Don't define __clock_gettime in bench-timing.h
> since it is no longer needed.

OK.

> ---
>  benchtests/bench-timing.h   |  1 -
>  sysdeps/generic/hp-timing.h | 11 ++++++++++-
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
> index a0d6f82465..d0176fb76e 100644
> --- a/benchtests/bench-timing.h
> +++ b/benchtests/bench-timing.h
> @@ -18,7 +18,6 @@
>  
>  #undef attribute_hidden
>  #define attribute_hidden
> -#define __clock_gettime __clock_gettime64

OK.

>  #include <hp-timing.h>
>  #include <stdint.h>
>  
> diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
> index af9d92f7f7..1960a71c62 100644
> --- a/sysdeps/generic/hp-timing.h
> +++ b/sysdeps/generic/hp-timing.h
> @@ -32,11 +32,20 @@ typedef uint64_t hp_timing_t;
>  /* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
>     nano-second accuracy, and for some architectues is implemented as
>     vDSO symbol.  */
> -#define HP_TIMING_NOW(var) \
> +#ifdef _ISOMAC
> +# define HP_TIMING_NOW(var) \
> +({								\
> +  struct timespec tv;						\
> +  clock_gettime (CLOCK_MONOTONIC, &tv);				\
> +  (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
> +})
> +#else
> +# define HP_TIMING_NOW(var) \

OK.

>  ({								\
>    struct __timespec64 tv;						\
>    __clock_gettime64 (CLOCK_MONOTONIC, &tv);			\
>    (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
>  })
> +#endif
>  
>  #endif	/* hp-timing.h */
> -- 
> 2.26.2
> 

-- 
Cheers,
Carlos.


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

end of thread, other threads:[~2020-06-05 16:26 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 18:16 [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
2020-05-19 19:51 ` Lukasz Majewski
2020-05-20 10:29 ` Andreas Schwab
2020-05-21  1:09 ` H.J. Lu via Libc-alpha
2020-05-21 10:24   ` Lukasz Majewski
2020-05-21 11:11     ` H.J. Lu via Libc-alpha
2020-05-23 20:32       ` [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
2020-05-24  9:03         ` Lukasz Majewski
2020-05-24 11:39           ` H.J. Lu via Libc-alpha
2020-05-24 15:30             ` Lukasz Majewski
2020-05-24 16:13               ` H.J. Lu via Libc-alpha
2020-05-24 23:34                 ` V2 " H.J. Lu via Libc-alpha
2020-05-25 10:40                   ` Lukasz Majewski
2020-05-25 10:57   ` [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Andreas Schwab
2020-05-27 12:44     ` Florian Weimer via Libc-alpha
2020-05-27 12:47       ` H.J. Lu via Libc-alpha
2020-05-27 12:50         ` Florian Weimer via Libc-alpha
2020-05-28 12:28           ` [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
2020-05-28 12:58             ` Florian Weimer via Libc-alpha
2020-05-28 13:07               ` H.J. Lu via Libc-alpha
2020-05-28 14:28                 ` Florian Weimer via Libc-alpha
2020-05-28 14:50                   ` [PATCH] Update HP_TIMING_NOW for " H.J. Lu via Libc-alpha
2020-06-05 16:26                     ` Carlos O'Donell via Libc-alpha

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).