public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] time: Fix compile error in itimer test affecting hurd
@ 2021-08-19 14:58 Stafford Horne
  2021-08-19 20:57 ` Stafford Horne
  0 siblings, 1 reply; 2+ messages in thread
From: Stafford Horne @ 2021-08-19 14:58 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Stafford Horne, Adhemerval Zanella, Joseph Myers

The recent change to use __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 to avoid
doing 64-bit checks on some platforms broke the test for hurd where
__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 is not defined.  With error:

    tst-itimer.c: In function 'do_test':
    tst-itimer.c:103:11: error: '__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64' undeclared (first use in this function)
      103 |       if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64)
	  |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    tst-itimer.c:103:11: note: each undeclared identifier is reported only once for each function it appears in

Define a new macro that works for both hurd and linux to detect when
setitimer and getitimer support 64-bit time_t.

Fixes commit 6e8a0aac2f ("time: Fix overflow itimer tests on 32-bit
systems").

Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Joseph Myers <joseph@codesourcery.com>
---
Hi Joseph,

I know you mentioned defining a new macro, I was not sure if you meant in the
test or globally.  I opted to add this to the test as I don't see a good reason
to add the macro to hurd which is only needed for this test.

I build tested this on i686-gnu and ran my tests on or1k and it does work.

-Stafford

 time/tst-itimer.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/time/tst-itimer.c b/time/tst-itimer.c
index bd7d7afe83..af97ef6acf 100644
--- a/time/tst-itimer.c
+++ b/time/tst-itimer.c
@@ -25,6 +25,12 @@
 #include <unistd.h>
 #include <time.h>
 
+#ifdef __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
+# define ITIMER_SUPPORTS_TIMESPEC64 __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
+#else
+# define ITIMER_SUPPORTS_TIMESPEC64 (sizeof (__time_t) == 8)
+#endif
+
 static sig_atomic_t cnt;
 
 static void
@@ -100,7 +106,7 @@ do_test (void)
 
       /* Linux does not provide 64 bit time_t support for getitimer and
 	 setitimer on architectures with 32 bit time_t support.  */
-      if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64)
+      if (ITIMER_SUPPORTS_TIMESPEC64)
 	{
 	  TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
 	  TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 },
@@ -131,7 +137,7 @@ do_test (void)
       it.it_interval.tv_usec = 20;
       it.it_value.tv_sec = 30;
       it.it_value.tv_usec = 40;
-      if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64)
+      if (ITIMER_SUPPORTS_TIMESPEC64)
 	{
 	  TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
 
-- 
2.31.1


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

* Re: [PATCH] time: Fix compile error in itimer test affecting hurd
  2021-08-19 14:58 [PATCH] time: Fix compile error in itimer test affecting hurd Stafford Horne
@ 2021-08-19 20:57 ` Stafford Horne
  0 siblings, 0 replies; 2+ messages in thread
From: Stafford Horne @ 2021-08-19 20:57 UTC (permalink / raw)
  To: GLIBC patches; +Cc: Adhemerval Zanella, Joseph Myers

On Thu, Aug 19, 2021 at 11:58:53PM +0900, Stafford Horne wrote:
> The recent change to use __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 to avoid
> doing 64-bit checks on some platforms broke the test for hurd where
> __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 is not defined.  With error:
> 
>     tst-itimer.c: In function 'do_test':
>     tst-itimer.c:103:11: error: '__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64' undeclared (first use in this function)
>       103 |       if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64)
> 	  |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     tst-itimer.c:103:11: note: each undeclared identifier is reported only once for each function it appears in
> 
> Define a new macro that works for both hurd and linux to detect when
> setitimer and getitimer support 64-bit time_t.
> 
> Fixes commit 6e8a0aac2f ("time: Fix overflow itimer tests on 32-bit
> systems").
> 
> Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> Cc: Joseph Myers <joseph@codesourcery.com>
> ---
> Hi Joseph,
> 
> I know you mentioned defining a new macro, I was not sure if you meant in the
> test or globally.  I opted to add this to the test as I don't see a good reason
> to add the macro to hurd which is only needed for this test.
> 
> I build tested this on i686-gnu and ran my tests on or1k and it does work.
> 
> -Stafford
> 
>  time/tst-itimer.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/time/tst-itimer.c b/time/tst-itimer.c
> index bd7d7afe83..af97ef6acf 100644
> --- a/time/tst-itimer.c
> +++ b/time/tst-itimer.c
> @@ -25,6 +25,12 @@
>  #include <unistd.h>
>  #include <time.h>
>  
> +#ifdef __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
> +# define ITIMER_SUPPORTS_TIMESPEC64 __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
> +#else
> +# define ITIMER_SUPPORTS_TIMESPEC64 (sizeof (__time_t) == 8)
> +#endif
> +

As suggested by Adhemerval I will create a v2 of this patch moving the gist of
this into support/xtime.h.

-Stafford

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

end of thread, other threads:[~2021-08-19 20:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 14:58 [PATCH] time: Fix compile error in itimer test affecting hurd Stafford Horne
2021-08-19 20:57 ` Stafford Horne

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