3 ?RCS: Copyright (c) 2008 H.Merijn Brand
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
8 ?MAKE:sGMTIME_max sGMTIME_min sLOCALTIME_max sLOCALTIME_min: cat rm_try \
9 Setvar Compile run i_values
10 ?MAKE: -pick add $@ %<
12 ?S: This variable defines the maximum value of the time_t offset that
13 ?S: the system function gmtime () accepts
16 ?S: This variable defines the minimum value of the time_t offset that
17 ?S: the system function gmtime () accepts
20 ?S: This variable defines the maximum value of the time_t offset that
21 ?S: the system function localtime () accepts
24 ?S: This variable defines the minimum value of the time_t offset that
25 ?S: the system function localtime () accepts
28 ?C: This symbol contains the maximum value for the time_t offset that
29 ?C: the system function gmtime () accepts, and defaults to 0
32 ?C: This symbol contains the minimum value for the time_t offset that
33 ?C: the system function gmtime () accepts, and defaults to 0
36 ?C: This symbol contains the maximum value for the time_t offset that
37 ?C: the system function localtime () accepts, and defaults to 0
40 ?C: This symbol contains the minimum value for the time_t offset that
41 ?C: the system function localtime () accepts, and defaults to 0
43 ?H:#define GMTIME_MAX $sGMTIME_max /**/
44 ?H:#define GMTIME_MIN $sGMTIME_min /**/
45 ?H:#define LOCALTIME_MAX $sLOCALTIME_max /**/
46 ?H:#define LOCALTIME_MIN $sLOCALTIME_min /**/
54 : Check the max offset that gmtime and localtime accept
55 echo "Checking max offsets that gmtime () accepts"
58 define) yyy="#include <values.h>" ;;
62 case "$sGMTIME_min/$sGMTIME_max" in
65 #include <sys/types.h>
74 void gm_check (time_t t)
77 if (tmp == NULL || tmp->tm_year < -1900)
90 if (tmp == NULL || tmp->tm_year < 0) {
91 for (i = 63; i >= 0; i--) {
92 time_t x = pt | ((time_t)1 << i);
97 printf ("sGMTIME_max=%ld\n", pt);
109 for (i = 36; i >= 0; i--) {
110 time_t x = pt - ((time_t)1 << i);
115 printf ("sGMTIME_min=%ld\n", pt);
119 int main (int argc, char *argv[])
121 fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t));
128 if eval $compile; then
131 echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
137 echo "Checking max offsets that localtime () accepts"
139 case "$sLOCALTIME_min/$sLOCALTIME_max" in
142 #include <sys/types.h>
151 void local_check (time_t t)
153 if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
156 tmp = localtime (&t);
157 if (tmp == NULL || tmp->tm_year < -1900)
168 local_check (MAXLONG);
170 if (tmp == NULL || tmp->tm_year < 0) {
171 for (i = 63; i >= 0; i--) {
172 time_t x = pt | ((time_t)1 << i);
177 printf ("sLOCALTIME_max=%ld\n", pt);
186 local_check (MINLONG);
189 for (i = 36; i >= 0; i--) {
190 time_t x = pt - ((time_t)1 << i);
195 printf ("sLOCALTIME_min=%ld\n", pt);
199 int main (int argc, char *argv[])
207 if eval $compile; then
210 echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4