summaryrefslogtreecommitdiffstats
path: root/gl/m4/mktime.m4
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 23:27:12 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 23:27:12 +0200
commit26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch)
treec4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/m4/mktime.m4
parent5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff)
downloadmonitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/m4/mktime.m4')
-rw-r--r--gl/m4/mktime.m4145
1 files changed, 82 insertions, 63 deletions
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index 44b8d878..faefb770 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,5 +1,5 @@
1# serial 15 1# serial 25
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,24 +7,24 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl From Jim Meyering. 8dnl From Jim Meyering.
9 9
10# Redefine AC_FUNC_MKTIME, to fix a bug in Autoconf 2.61a and earlier. 10AC_DEFUN([gl_FUNC_MKTIME],
11# This redefinition can be removed once a new version of Autoconf is assumed. 11[
12# The redefinition is taken from 12 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
13# <http://cvs.sv.gnu.org/viewcvs/*checkout*/autoconf/autoconf/lib/autoconf/functions.m4?rev=1.119>. 13
14# AC_FUNC_MKTIME 14 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained
15# -------------- 15 dnl in Autoconf and because it invokes AC_LIBOBJ.
16AC_DEFUN([AC_FUNC_MKTIME], 16 AC_CHECK_HEADERS_ONCE([unistd.h])
17[AC_CHECK_HEADERS_ONCE([unistd.h]) 17 AC_CHECK_DECLS_ONCE([alarm])
18AC_CHECK_FUNCS_ONCE([alarm]) 18 AC_REQUIRE([gl_MULTIARCH])
19AC_REQUIRE([gl_MULTIARCH]) 19 if test $APPLE_UNIVERSAL_BUILD = 1; then
20if test $APPLE_UNIVERSAL_BUILD = 1; then 20 # A universal build on Apple Mac OS X platforms.
21 # A universal build on Apple MacOS X platforms. 21 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
22 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. 22 # But we need a configuration result that is valid in both modes.
23 # But we need a configuration result that is valid in both modes. 23 gl_cv_func_working_mktime=no
24 ac_cv_func_working_mktime=no 24 fi
25fi 25 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
26AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime], 26 [AC_RUN_IFELSE(
27[AC_RUN_IFELSE([AC_LANG_SOURCE( 27 [AC_LANG_SOURCE(
28[[/* Test program from Paul Eggert and Tony Leneis. */ 28[[/* Test program from Paul Eggert and Tony Leneis. */
29#include <limits.h> 29#include <limits.h>
30#include <stdlib.h> 30#include <stdlib.h>
@@ -34,8 +34,8 @@ AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime],
34# include <unistd.h> 34# include <unistd.h>
35#endif 35#endif
36 36
37#ifndef HAVE_ALARM 37#if HAVE_DECL_ALARM
38# define alarm(X) /* empty */ 38# include <signal.h>
39#endif 39#endif
40 40
41/* Work around redefinition to rpl_putenv by other config tests. */ 41/* Work around redefinition to rpl_putenv by other config tests. */
@@ -165,22 +165,29 @@ year_2050_test ()
165int 165int
166main () 166main ()
167{ 167{
168 int result = 0;
168 time_t t, delta; 169 time_t t, delta;
169 int i, j; 170 int i, j;
171 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
172 int time_t_signed = ! ((time_t) 0 < (time_t) -1);
170 173
174#if HAVE_DECL_ALARM
171 /* This test makes some buggy mktime implementations loop. 175 /* This test makes some buggy mktime implementations loop.
172 Give up after 60 seconds; a mktime slower than that 176 Give up after 60 seconds; a mktime slower than that
173 isn't worth using anyway. */ 177 isn't worth using anyway. */
178 signal (SIGALRM, SIG_DFL);
174 alarm (60); 179 alarm (60);
180#endif
175 181
176 for (;;) 182 time_t_max = (! time_t_signed
177 { 183 ? (time_t) -1
178 t = (time_t_max << 1) + 1; 184 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
179 if (t <= time_t_max) 185 * 2 + 1));
180 break; 186 time_t_min = (! time_t_signed
181 time_t_max = t; 187 ? (time_t) 0
182 } 188 : time_t_signed_magnitude
183 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; 189 ? ~ (time_t) 0
190 : ~ time_t_max);
184 191
185 delta = time_t_max / 997; /* a suitable prime number */ 192 delta = time_t_max / 997; /* a suitable prime number */
186 for (i = 0; i < N_STRINGS; i++) 193 for (i = 0; i < N_STRINGS; i++)
@@ -188,47 +195,59 @@ main ()
188 if (tz_strings[i]) 195 if (tz_strings[i])
189 putenv (tz_strings[i]); 196 putenv (tz_strings[i]);
190 197
191 for (t = 0; t <= time_t_max - delta; t += delta) 198 for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta)
192 if (! mktime_test (t)) 199 if (! mktime_test (t))
193 return 1; 200 result |= 1;
194 if (! (mktime_test ((time_t) 1) 201 if ((result & 2) == 0
195 && mktime_test ((time_t) (60 * 60)) 202 && ! (mktime_test ((time_t) 1)
196 && mktime_test ((time_t) (60 * 60 * 24)))) 203 && mktime_test ((time_t) (60 * 60))
197 return 1; 204 && mktime_test ((time_t) (60 * 60 * 24))))
198 205 result |= 2;
199 for (j = 1; ; j <<= 1) 206
200 if (! bigtime_test (j)) 207 for (j = 1; (result & 4) == 0; j <<= 1)
201 return 1; 208 {
202 else if (INT_MAX / 2 < j) 209 if (! bigtime_test (j))
203 break; 210 result |= 4;
204 if (! bigtime_test (INT_MAX)) 211 if (INT_MAX / 2 < j)
205 return 1; 212 break;
213 }
214 if ((result & 8) == 0 && ! bigtime_test (INT_MAX))
215 result |= 8;
206 } 216 }
207 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); 217 if (! irix_6_4_bug ())
218 result |= 16;
219 if (! spring_forward_gap ())
220 result |= 32;
221 if (! year_2050_test ())
222 result |= 64;
223 return result;
208}]])], 224}]])],
209 [ac_cv_func_working_mktime=yes], 225 [gl_cv_func_working_mktime=yes],
210 [ac_cv_func_working_mktime=no], 226 [gl_cv_func_working_mktime=no],
211 [ac_cv_func_working_mktime=no])]) 227 [gl_cv_func_working_mktime=no])
212if test $ac_cv_func_working_mktime = no; then 228 ])
213 AC_LIBOBJ([mktime])
214fi
215])# AC_FUNC_MKTIME
216 229
217AC_DEFUN([gl_FUNC_MKTIME], 230 if test $gl_cv_func_working_mktime = no; then
218[
219 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
220 AC_FUNC_MKTIME
221 dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
222 if test $ac_cv_func_working_mktime = no; then
223 REPLACE_MKTIME=1 231 REPLACE_MKTIME=1
224 gl_PREREQ_MKTIME
225 else 232 else
226 REPLACE_MKTIME=0 233 REPLACE_MKTIME=0
227 fi 234 fi
228]) 235])
229 236
230# Prerequisites of lib/mktime.c. 237AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
231AC_DEFUN([gl_PREREQ_MKTIME], 238 AC_REQUIRE([gl_FUNC_MKTIME])
232[ 239 if test $REPLACE_MKTIME = 0; then
233 AC_REQUIRE([AC_C_INLINE]) 240 dnl BeOS has __mktime_internal in libc, but other platforms don't.
241 AC_CHECK_FUNC([__mktime_internal],
242 [AC_DEFINE([mktime_internal], [__mktime_internal],
243 [Define to the real name of the mktime_internal function.])
244 ],
245 [dnl mktime works but it doesn't export __mktime_internal,
246 dnl so we need to substitute our own mktime implementation.
247 REPLACE_MKTIME=1
248 ])
249 fi
234]) 250])
251
252# Prerequisites of lib/mktime.c.
253AC_DEFUN([gl_PREREQ_MKTIME], [:])