about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2021-06-07 22:10:19 +0900
committerStafford Horne <shorne@gmail.com>2021-08-15 07:09:58 +0900
commit6e8a0aac2f883a23efb1683b120499138f9e6021 (patch)
tree86beef99917497f8d66fd1df6e4be6b25bb550b2 /time
parent0f62fe053273ff6c62ac95c59b7687c964737b00 (diff)
downloadglibc-6e8a0aac2f883a23efb1683b120499138f9e6021.tar.gz
glibc-6e8a0aac2f883a23efb1683b120499138f9e6021.tar.xz
glibc-6e8a0aac2f883a23efb1683b120499138f9e6021.zip
time: Fix overflow itimer tests on 32-bit systems
On the port of OpenRISC I am working on and it appears the rv32 port
we have sets __TIMESIZE == 64 && __WORDSIZE == 32.  This causes the
size of time_t to be 8 bytes, but the tv_sec in the kernel is still 32-bit
causing truncation.

The truncations are unavoidable on these systems so skip the
testing/failures by guarding with __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64.

Also, futher in the tests and in other parts of code checking for time_t
overflow does not work on 32-bit systems when time_t is 64-bit.  As
suggested by Adhemerval, update the in_time_t_range function to assume
32-bits by using int32_t.

This also brings in the header for stdint.h so we can update other
usages of __int32_t to int32_t as suggested by Adhemerval.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'time')
-rw-r--r--time/tst-itimer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/time/tst-itimer.c b/time/tst-itimer.c
index 929c2b74c7..bd7d7afe83 100644
--- a/time/tst-itimer.c
+++ b/time/tst-itimer.c
@@ -100,7 +100,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 (sizeof (__time_t) == 8)
+      if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64)
 	{
 	  TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);
 	  TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 },
@@ -131,7 +131,7 @@ do_test (void)
       it.it_interval.tv_usec = 20;
       it.it_value.tv_sec = 30;
       it.it_value.tv_usec = 40;
-      if (sizeof (__time_t) == 8)
+      if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64)
 	{
 	  TEST_COMPARE (setitimer (timers[i], &it, NULL), 0);