]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* NEWS, doc/autoconf.texi (Particular Functions),
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 28 May 2003 20:03:52 +0000 (20:03 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 28 May 2003 20:03:52 +0000 (20:03 +0000)
lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Check that mktime
is the inverse of localtime.

ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/functions.m4

index fdcc666f03468fa2582331465b1421735bcf9c27..ccf3260f437e363c8dc53cde9728bc4b962da330 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-05-28  Paul Eggert  <eggert@twinsun.com>
+
+       * NEWS, doc/autoconf.texi (Particular Functions),
+       lib/autoconf/functions.m4 (AC_FUNC_MKTIME): Check that mktime
+       is the inverse of localtime.
+
 2003-05-25  Alexandre Duret-Lutz  <adl@gnu.org>
 
        * lib/Autom4te/General.pm (END): Print diagnostics to STDERR.
diff --git a/NEWS b/NEWS
index f1569040246fc5bb6104b219bedd9202c6a5e97a..f51df6678ca2c84a3c516537f4cca8ab6c67b3a8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@
 ** AC_DECL_SYS_SIGLIST
   Works again.
 
+** AC_FUNC_MKTIME
+  Now checks that mktime is the inverse of localtime.
+
 ** Improve DJGPP portability
   The Autoconf tools and configure behave better under DJGPP.
 
index adec2017e736dca95eb20376a61db1aa0d195807..47deef110bf4977344f50ea1a21c70c515dbc9ba 100644 (file)
@@ -3945,6 +3945,9 @@ type @code{mbstate_t} are properly declared.
 @prindex @code{mktime}
 If the @code{mktime} function is not available, or does not work
 correctly, require an @code{AC_LIBOBJ} replacement for @samp{mktime}.
+For the purposes of this test, @code{mktime} should conform to the
+@acronym{POSIX} standard and should be the inverse of
+@code{localtime}.
 @end defmac
 
 @defmac AC_FUNC_MMAP
index ae82e6a9bcaac31f8b375c4a46a7ab6c9847df3b..5d6165b9b9a227b9e7d94f07cb0dbcff3a5a1778 100644 (file)
@@ -940,7 +940,7 @@ 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(sys/time.h unistd.h)
+AC_CHECK_HEADERS(stdlib.h sys/time.h unistd.h)
 AC_CHECK_FUNCS(alarm)
 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -956,6 +956,10 @@ AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
 # endif
 #endif
 
+#if HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
 #if HAVE_UNISTD_H
 # include <unistd.h>
 #endif
@@ -968,10 +972,11 @@ AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
 #undef putenv
 
 static time_t time_t_max;
+static time_t time_t_min;
 
 /* Values we'll use to set the TZ environment variable.  */
-static const char *const tz_strings[] = {
-  (const char *) 0, "TZ=GMT0", "TZ=JST-9",
+static char *tz_strings[] = {
+  (char *) 0, "TZ=GMT0", "TZ=JST-9",
   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
 };
 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
@@ -1002,15 +1007,21 @@ spring_forward_gap ()
 }
 
 static void
-mktime_test (now)
+mktime_test1 (now)
      time_t now;
 {
   struct tm *lt;
   if ((lt = localtime (&now)) && mktime (lt) != now)
     exit (1);
-  now = time_t_max - now;
-  if ((lt = localtime (&now)) && mktime (lt) != now)
-    exit (1);
+}
+
+static void
+mktime_test (now)
+     time_t now;
+{
+  mktime_test1 (now);
+  mktime_test1 ((time_t) (time_t_max - now));
+  mktime_test1 ((time_t) (time_t_min + now));
 }
 
 static void
@@ -1070,6 +1081,9 @@ main ()
   for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
     continue;
   time_t_max--;
+  if ((time_t) -1 < 0)
+    for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
+      continue;
   delta = time_t_max / 997; /* a suitable prime number */
   for (i = 0; i < N_STRINGS; i++)
     {
@@ -1078,8 +1092,9 @@ main ()
 
       for (t = 0; t <= time_t_max - delta; t += delta)
        mktime_test (t);
-      mktime_test ((time_t) 60 * 60);
-      mktime_test ((time_t) 60 * 60 * 24);
+      mktime_test ((time_t) 1);
+      mktime_test ((time_t) (60 * 60));
+      mktime_test ((time_t) (60 * 60 * 24));
 
       for (j = 1; 0 < j; j *= 2)
        bigtime_test (j);