]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Add year_2050_test
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Sep 2006 22:36:16 +0000 (22:36 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Sep 2006 22:36:16 +0000 (22:36 +0000)
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.

ChangeLog
lib/autoconf/functions.m4

index 5fd015b20fba163143fc2f48b56c89b84714c5b5..296555e86816c35087133e029975988913440388 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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
index b4d37c739afc384bf59737730c74f92604dd94fa..eb9c8f4e733a9465869157eefa53837344af3957 100644 (file)
@@ -972,8 +972,8 @@ test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
 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.  */
@@ -988,9 +988,7 @@ AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
 # endif
 #endif
 
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
 
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
@@ -1097,6 +1095,36 @@ bigtime_test (j)
   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 ()
 {
@@ -1134,7 +1162,7 @@ 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],