Discussion:
mktime.m4 - working mktime fails if TIME_T_IS_SIGNED us undefined.
John E. Malmberg
2017-09-22 00:27:20 UTC
Permalink
The TIME_T_IS_SIGNED macro not defined if time_t is unsigned.

This causes the test for working mtime to fail to compile on such
systems such as OpenVMS.

configure:33308: cc -o conftest -g conftest.c >&5

time_t_max = (! TIME_T_IS_SIGNED
..................^
%CC-E-UNDECLARED, In this statement, "TIME_T_IS_SIGNED" is not declared.
at line number 452 in file LCL_ROOT:[gnulib]conftest.c;1


A simple hack gets the test to run.

--- /trunk_root/gnulib/m4/mktime.m4 2017-07-15 15:24:28 -0500
+++ /vms_root/gnulib/m4/mktime.m4 2017-09-21 19:20:43 -0500
@@ -195,6 +195,10 @@
alarm (60);
#endif

+#ifndef TIME_T_IS_SIGNED
+# define TIME_T_IS_SIGNED 0
+#endif
+
time_t_max = (! TIME_T_IS_SIGNED
? (time_t) -1
: ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)

Unfortunately after the test actually runs it shows that the OpenVMS
supplied mktime() fails on the spring_forward_gap() test.

Regards,
-John
Paul Eggert
2017-09-22 04:41:33 UTC
Permalink
Thanks for the heads-up. I installed the attached. It's not surprising that
OpenVMS mktime fails the test.
Bruno Haible
2017-09-22 09:42:43 UTC
Permalink
Post by John E. Malmberg
The TIME_T_IS_SIGNED macro not defined if time_t is unsigned.
This causes the test for working mtime to fail to compile on such
systems such as OpenVMS.
Given that the bug was introduced on 2016-05-01, and that a web search for
"checking whether time_t is signed... no" reveals hardly any results,
it looks like OpenVMS is the only platform with an unsigned time_t type.

This leads to a testing problem: When we make changes to time_t related
code, how to verify that it works with an unsigned time_t type?

Maybe just use a hacked glibc system: Edit
/usr/include/x86_64-linux-gnu/bits/typesizes.h
changing the line
#define __TIME_T_TYPE __SYSCALL_SLONG_TYPE
to
#define __TIME_T_TYPE __SYSCALL_ULONG_TYPE
?

Bruno
Paul Eggert
2017-09-22 15:50:44 UTC
Permalink
Post by Bruno Haible
When we make changes to time_t related
code, how to verify that it works with an unsigned time_t type?
The way I do it in tzdb
<https://www.iana.org/time-zones/repository/tzdb-latest.tar.lz> is to
replace the system time_t and its related low-level functions. It's a
pain, and it does the job, and it's hard to explain. I vaguely recall
trying simpler tricks something like what you describe, but don't
remember why I abandoned that; perhaps I was trying for something that
would work outside glibc.

Loading...