+2006-09-08 Paul Eggert <eggert@cs.ucla.edu>
+
+ * lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Add year_2050_test
+ to catch glibc bug 2821
+ <http://sourceware.org/bugzilla/show_bug.cgi?id=2821>.
+
+ Merge from gnulib as follows: Use AC_CHECK_HEADERS_ONCE instead of
+ AC_CHECK_HEADERS, and likewise for AC_CHECK_FUNCS_ONCE and
+ AC_CHECK_FUNCS. Don't check for stdlib.h, since we now
+ assume C89.
+
2006-09-08 Stepan Kasal <kasal@ucw.cz>
* lib/autom4te.in (Autoconf-without-aclocal-m4): Move the
AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
AC_DEFUN([AC_FUNC_MKTIME],
[AC_REQUIRE([AC_HEADER_TIME])dnl
-AC_CHECK_HEADERS(stdlib.h sys/time.h unistd.h)
-AC_CHECK_FUNCS(alarm)
+AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
+AC_CHECK_FUNCS_ONCE(alarm)
AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
[AC_RUN_IFELSE([AC_LANG_SOURCE(
[[/* Test program from Paul Eggert and Tony Leneis. */
# endif
#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
return 1;
}
+static int
+year_2050_test ()
+{
+ /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
+ ignoring leap seconds. */
+ unsigned long int answer = 2527315200UL;
+
+ struct tm tm;
+ time_t t;
+ tm.tm_year = 2050 - 1900;
+ tm.tm_mon = 2 - 1;
+ tm.tm_mday = 1;
+ tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
+ tm.tm_isdst = -1;
+
+ /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
+ instead of "TZ=America/Vancouver" in order to detect the bug even
+ on systems that don't support the Olson extension, or don't have the
+ full zoneinfo tables installed. */
+ putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+
+ t = mktime (&tm);
+
+ /* Check that the result is either a failure, or close enough
+ to the correct answer that we can assume the discrepancy is
+ due to leap seconds. */
+ return (t == (time_t) -1
+ || (0 < t && answer - 120 <= t && t <= answer + 120));
+}
+
int
main ()
{
if (! bigtime_test (j - 1))
return 1;
}
- return ! (irix_6_4_bug () && spring_forward_gap ());
+ return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
}]])],
[ac_cv_func_working_mktime=yes],
[ac_cv_func_working_mktime=no],