summaryrefslogtreecommitdiffstats
path: root/gl/m4/mktime.m4
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-08 01:11:46 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-13 01:26:35 (GMT)
commit74da141e618ef99959d509cb2e7be35a348a39db (patch)
tree88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/m4/mktime.m4
parentc63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff)
downloadmonitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/m4/mktime.m4')
-rw-r--r--gl/m4/mktime.m467
1 files changed, 35 insertions, 32 deletions
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index 1e926e8..44b8d87 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,5 +1,6 @@
1# serial 15 1# serial 15
2dnl Copyright (C) 2002-2003, 2005-2007, 2009 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation,
3dnl Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -85,8 +86,8 @@ static int
85mktime_test (time_t now) 86mktime_test (time_t now)
86{ 87{
87 return (mktime_test1 (now) 88 return (mktime_test1 (now)
88 && mktime_test1 ((time_t) (time_t_max - now)) 89 && mktime_test1 ((time_t) (time_t_max - now))
89 && mktime_test1 ((time_t) (time_t_min + now))); 90 && mktime_test1 ((time_t) (time_t_min + now)));
90} 91}
91 92
92static int 93static int
@@ -116,17 +117,17 @@ bigtime_test (int j)
116 { 117 {
117 struct tm *lt = localtime (&now); 118 struct tm *lt = localtime (&now);
118 if (! (lt 119 if (! (lt
119 && lt->tm_year == tm.tm_year 120 && lt->tm_year == tm.tm_year
120 && lt->tm_mon == tm.tm_mon 121 && lt->tm_mon == tm.tm_mon
121 && lt->tm_mday == tm.tm_mday 122 && lt->tm_mday == tm.tm_mday
122 && lt->tm_hour == tm.tm_hour 123 && lt->tm_hour == tm.tm_hour
123 && lt->tm_min == tm.tm_min 124 && lt->tm_min == tm.tm_min
124 && lt->tm_sec == tm.tm_sec 125 && lt->tm_sec == tm.tm_sec
125 && lt->tm_yday == tm.tm_yday 126 && lt->tm_yday == tm.tm_yday
126 && lt->tm_wday == tm.tm_wday 127 && lt->tm_wday == tm.tm_wday
127 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) 128 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
128 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) 129 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
129 return 0; 130 return 0;
130 } 131 }
131 return 1; 132 return 1;
132} 133}
@@ -158,7 +159,7 @@ year_2050_test ()
158 to the correct answer that we can assume the discrepancy is 159 to the correct answer that we can assume the discrepancy is
159 due to leap seconds. */ 160 due to leap seconds. */
160 return (t == (time_t) -1 161 return (t == (time_t) -1
161 || (0 < t && answer - 120 <= t && t <= answer + 120)); 162 || (0 < t && answer - 120 <= t && t <= answer + 120));
162} 163}
163 164
164int 165int
@@ -176,7 +177,7 @@ main ()
176 { 177 {
177 t = (time_t_max << 1) + 1; 178 t = (time_t_max << 1) + 1;
178 if (t <= time_t_max) 179 if (t <= time_t_max)
179 break; 180 break;
180 time_t_max = t; 181 time_t_max = t;
181 } 182 }
182 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; 183 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
@@ -185,29 +186,29 @@ main ()
185 for (i = 0; i < N_STRINGS; i++) 186 for (i = 0; i < N_STRINGS; i++)
186 { 187 {
187 if (tz_strings[i]) 188 if (tz_strings[i])
188 putenv (tz_strings[i]); 189 putenv (tz_strings[i]);
189 190
190 for (t = 0; t <= time_t_max - delta; t += delta) 191 for (t = 0; t <= time_t_max - delta; t += delta)
191 if (! mktime_test (t)) 192 if (! mktime_test (t))
192 return 1; 193 return 1;
193 if (! (mktime_test ((time_t) 1) 194 if (! (mktime_test ((time_t) 1)
194 && mktime_test ((time_t) (60 * 60)) 195 && mktime_test ((time_t) (60 * 60))
195 && mktime_test ((time_t) (60 * 60 * 24)))) 196 && mktime_test ((time_t) (60 * 60 * 24))))
196 return 1; 197 return 1;
197 198
198 for (j = 1; ; j <<= 1) 199 for (j = 1; ; j <<= 1)
199 if (! bigtime_test (j)) 200 if (! bigtime_test (j))
200 return 1; 201 return 1;
201 else if (INT_MAX / 2 < j) 202 else if (INT_MAX / 2 < j)
202 break; 203 break;
203 if (! bigtime_test (INT_MAX)) 204 if (! bigtime_test (INT_MAX))
204 return 1; 205 return 1;
205 } 206 }
206 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); 207 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
207}]])], 208}]])],
208 [ac_cv_func_working_mktime=yes], 209 [ac_cv_func_working_mktime=yes],
209 [ac_cv_func_working_mktime=no], 210 [ac_cv_func_working_mktime=no],
210 [ac_cv_func_working_mktime=no])]) 211 [ac_cv_func_working_mktime=no])])
211if test $ac_cv_func_working_mktime = no; then 212if test $ac_cv_func_working_mktime = no; then
212 AC_LIBOBJ([mktime]) 213 AC_LIBOBJ([mktime])
213fi 214fi
@@ -215,12 +216,14 @@ fi
215 216
216AC_DEFUN([gl_FUNC_MKTIME], 217AC_DEFUN([gl_FUNC_MKTIME],
217[ 218[
219 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
218 AC_FUNC_MKTIME 220 AC_FUNC_MKTIME
219 dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]). 221 dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
220 if test $ac_cv_func_working_mktime = no; then 222 if test $ac_cv_func_working_mktime = no; then
221 AC_DEFINE([mktime], [rpl_mktime], 223 REPLACE_MKTIME=1
222 [Define to rpl_mktime if the replacement function should be used.])
223 gl_PREREQ_MKTIME 224 gl_PREREQ_MKTIME
225 else
226 REPLACE_MKTIME=0
224 fi 227 fi
225]) 228])
226 229