]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
time: Fix compile error in itimer test affecting hurd
authorStafford Horne <shorne@gmail.com>
Thu, 19 Aug 2021 14:47:07 +0000 (23:47 +0900)
committerStafford Horne <shorne@gmail.com>
Wed, 15 Sep 2021 20:21:08 +0000 (05:21 +0900)
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 support helper 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>
support/support.h
time/tst-itimer.c

index c219e0d9d1aef046f06c2f23a89c2d2af895739e..837a80653109b1ae1cb1a9229cc60c90704c834d 100644 (file)
@@ -152,6 +152,18 @@ static __inline bool support_path_support_time64 (const char *path)
                                            0x80000002ULL);
 }
 
+/* Return true if the setitimer and getitimer syscalls support 64-bit time_t
+   values without resulting in overflow.  This is not true on some linux systems
+   which have 64-bit time_t due to legacy kernel API's.  */
+static __inline bool support_itimer_support_time64 (void)
+{
+#ifdef __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
+  return __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64;
+#else
+  return sizeof (__time_t) == 8;
+#endif
+}
+
 /* Return true if stat supports nanoseconds resolution.  PATH is used
    for tests and its ctime may change.  */
 extern bool support_stat_nanoseconds (const char *path);
index bd7d7afe838d6626e8ec2fcc98a25bce1c0fb468..c6d623cb19744da3d2fc4068e5cccd64b14f26dc 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include <support/check.h>
+#include <support/support.h>
 #include <support/xsignal.h>
 #include <unistd.h>
 #include <time.h>
@@ -100,7 +101,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 (support_itimer_support_time64())
        {
          TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
          TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 },
@@ -131,7 +132,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 (support_itimer_support_time64())
        {
          TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);