From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2020) id E08FF3858C39; Wed, 15 Sep 2021 20:22:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E08FF3858C39 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Stafford Horne To: glibc-cvs@sourceware.org Subject: [glibc] time: Fix compile error in itimer test affecting hurd X-Act-Checkin: glibc X-Git-Author: Stafford Horne X-Git-Refname: refs/heads/master X-Git-Oldrev: 2444ce5421c6036a503842d8dd8d93c27aad59ee X-Git-Newrev: 5604830dea207bbd5fd5dbe087cc7ca30b527bb5 Message-Id: <20210915202206.E08FF3858C39@sourceware.org> Date: Wed, 15 Sep 2021 20:22:06 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 20:22:07 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5604830dea207bbd5fd5dbe087cc7ca30b527bb5 commit 5604830dea207bbd5fd5dbe087cc7ca30b527bb5 Author: Stafford Horne Date: Thu Aug 19 23:47:07 2021 +0900 time: Fix compile error in itimer test affecting hurd 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 Cc: Joseph Myers Diff: --- support/support.h | 12 ++++++++++++ time/tst-itimer.c | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/support/support.h b/support/support.h index c219e0d9d1..837a806531 100644 --- a/support/support.h +++ b/support/support.h @@ -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); diff --git a/time/tst-itimer.c b/time/tst-itimer.c index bd7d7afe83..c6d623cb19 100644 --- a/time/tst-itimer.c +++ b/time/tst-itimer.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -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);