From: Paul Eggert Date: Fri, 8 Sep 2006 22:36:16 +0000 (+0000) Subject: * lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Add year_2050_test X-Git-Tag: AUTOCONF-2.60b~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b107b6f4f707ffca42cd5299b836e6268b0a327a;p=thirdparty%2Fautoconf.git * lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Add year_2050_test to catch glibc bug 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. --- diff --git a/ChangeLog b/ChangeLog index 5fd015b20..296555e86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-09-08 Paul Eggert + + * lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Add year_2050_test + to catch glibc bug 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 * lib/autom4te.in (Autoconf-without-aclocal-m4): Move the diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index b4d37c739..eb9c8f4e7 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -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 -#endif +#include #ifdef HAVE_UNISTD_H # include @@ -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],