2016-05-02 01:36:38 +00:00
|
|
|
# serial 26
|
2016-01-01 09:12:52 +00:00
|
|
|
dnl Copyright (C) 2002-2003, 2005-2007, 2009-2016 Free Software Foundation,
|
2011-01-09 06:57:07 +00:00
|
|
|
dnl Inc.
|
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
|
|
|
dnl From Jim Meyering.
|
|
|
|
|
2016-05-02 01:36:38 +00:00
|
|
|
AC_DEFUN([gl_TIME_T_IS_SIGNED],
|
|
|
|
[
|
|
|
|
AC_CACHE_CHECK([whether time_t is signed],
|
|
|
|
[gl_cv_time_t_is_signed],
|
|
|
|
[AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#include <time.h>
|
|
|
|
char time_t_signed[(time_t) -1 < 0 ? 1 : -1];]])],
|
|
|
|
[gl_cv_time_t_is_signed=yes],
|
|
|
|
[gl_cv_time_t_is_signed=no])])
|
|
|
|
if test $gl_cv_time_t_is_signed = yes; then
|
|
|
|
AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed.])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2011-06-15 22:27:54 +00:00
|
|
|
AC_DEFUN([gl_FUNC_MKTIME],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
|
2016-05-02 01:36:38 +00:00
|
|
|
AC_REQUIRE([gl_TIME_T_IS_SIGNED])
|
2011-06-15 22:27:54 +00:00
|
|
|
|
|
|
|
dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained
|
|
|
|
dnl in Autoconf and because it invokes AC_LIBOBJ.
|
|
|
|
AC_CHECK_HEADERS_ONCE([unistd.h])
|
2013-03-13 00:38:42 +00:00
|
|
|
AC_CHECK_DECLS_ONCE([alarm])
|
2011-06-15 22:27:54 +00:00
|
|
|
AC_REQUIRE([gl_MULTIARCH])
|
|
|
|
if test $APPLE_UNIVERSAL_BUILD = 1; then
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
# A universal build on Apple Mac OS X platforms.
|
2011-06-15 22:27:54 +00:00
|
|
|
# The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
|
|
|
|
# But we need a configuration result that is valid in both modes.
|
|
|
|
gl_cv_func_working_mktime=no
|
|
|
|
fi
|
|
|
|
AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
|
|
|
|
[AC_RUN_IFELSE(
|
|
|
|
[AC_LANG_SOURCE(
|
2011-01-09 06:57:07 +00:00
|
|
|
[[/* Test program from Paul Eggert and Tony Leneis. */
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2013-03-13 00:38:42 +00:00
|
|
|
#if HAVE_DECL_ALARM
|
|
|
|
# include <signal.h>
|
2011-01-09 06:57:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Work around redefinition to rpl_putenv by other config tests. */
|
|
|
|
#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 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]))
|
|
|
|
|
|
|
|
/* Return 0 if mktime fails to convert a date in the spring-forward gap.
|
|
|
|
Based on a problem report from Andreas Jaeger. */
|
|
|
|
static int
|
|
|
|
spring_forward_gap ()
|
|
|
|
{
|
|
|
|
/* glibc (up to about 1998-10-07) failed this test. */
|
|
|
|
struct tm tm;
|
|
|
|
|
|
|
|
/* 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");
|
|
|
|
|
|
|
|
tm.tm_year = 98;
|
|
|
|
tm.tm_mon = 3;
|
|
|
|
tm.tm_mday = 5;
|
|
|
|
tm.tm_hour = 2;
|
|
|
|
tm.tm_min = 0;
|
|
|
|
tm.tm_sec = 0;
|
|
|
|
tm.tm_isdst = -1;
|
|
|
|
return mktime (&tm) != (time_t) -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mktime_test1 (time_t now)
|
|
|
|
{
|
|
|
|
struct tm *lt;
|
|
|
|
return ! (lt = localtime (&now)) || mktime (lt) == now;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mktime_test (time_t now)
|
|
|
|
{
|
|
|
|
return (mktime_test1 (now)
|
|
|
|
&& mktime_test1 ((time_t) (time_t_max - now))
|
|
|
|
&& mktime_test1 ((time_t) (time_t_min + now)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
irix_6_4_bug ()
|
|
|
|
{
|
|
|
|
/* Based on code from Ariel Faigon. */
|
|
|
|
struct tm tm;
|
|
|
|
tm.tm_year = 96;
|
|
|
|
tm.tm_mon = 3;
|
|
|
|
tm.tm_mday = 0;
|
|
|
|
tm.tm_hour = 0;
|
|
|
|
tm.tm_min = 0;
|
|
|
|
tm.tm_sec = 0;
|
|
|
|
tm.tm_isdst = -1;
|
|
|
|
mktime (&tm);
|
|
|
|
return tm.tm_mon == 2 && tm.tm_mday == 31;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bigtime_test (int j)
|
|
|
|
{
|
|
|
|
struct tm tm;
|
|
|
|
time_t now;
|
|
|
|
tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
|
|
|
|
now = mktime (&tm);
|
|
|
|
if (now != (time_t) -1)
|
|
|
|
{
|
|
|
|
struct tm *lt = localtime (&now);
|
|
|
|
if (! (lt
|
|
|
|
&& lt->tm_year == tm.tm_year
|
|
|
|
&& lt->tm_mon == tm.tm_mon
|
|
|
|
&& lt->tm_mday == tm.tm_mday
|
|
|
|
&& lt->tm_hour == tm.tm_hour
|
|
|
|
&& lt->tm_min == tm.tm_min
|
|
|
|
&& lt->tm_sec == tm.tm_sec
|
|
|
|
&& lt->tm_yday == tm.tm_yday
|
|
|
|
&& lt->tm_wday == tm.tm_wday
|
|
|
|
&& ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
|
|
|
|
== (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
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 ()
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
time_t t, delta;
|
|
|
|
int i, j;
|
gnulib: import mktime and move-if-change fixes from gnulib
* configure: Regenerate from the following.
2011-01-30 Paul Eggert <eggert@cs.ucla.edu>
mktime: clarify long_int width checking
* lib/mktime.c (long_int_is_wide_enough): Move this assertion to
the top level, to make it clearer that the assumption about
long_int width is being checked. See
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00554.html>.
2011-01-29 Paul Eggert <eggert@cs.ucla.edu>
TYPE_MAXIMUM: avoid theoretically undefined behavior
* lib/intprops.h (TYPE_MINIMUM, TYPE_MAXIMUM): Do not shift a
negative number, which the C Standard says has undefined behavior.
In practice this is not a problem, but might as well do it by the book.
Reported by Rich Felker and Eric Blake; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00493.html>.
* m4/mktime.m4 (AC_FUNC_MKTIME): Likewise.
* lib/mktime.c (TYPE_MAXIMUM): Redo slightly to match the others.
mktime: #undef mktime before #defining it
* lib/mktime.c (mktime) [DEBUG]: #undef mktime before #defining it.
mktime: systematically normalize tm_isdst comparisons
* lib/mktime.c (isdst_differ): New function.
(__mktime_internal): Use it systematically for all isdst comparisons.
This completes the fix for libc BZ #6723, and removes the need for
normalizing tm_isdst. See
<http://sourceware.org/bugzilla/show_bug.cgi?id=6723>
(not_equal_tm) [DEBUG]: Use isdst_differ here, too.
mktime: fix some integer overflow issues and sidestep the rest
This was prompted by a bug report by Benjamin Lindner for MinGW
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00472.html>.
His bug is due to signed integer overflow (0 - INT_MIN), and I
I scanned through mktime.c looking for other integer overflow
problems, fixing all the bugs I found.
Although the C Standard says the resulting code is still not safe
in the presence of integer overflow, in practice it should be good
enough for all real-world two's-complement implementations, except
for debugging environments that deliberately trap on integer
overflow (e.g., gcc -ftrapv).
* lib/mktime.c (WRAPV): New macro.
(SHR): Also check that long_int and time_t shift right in the
usual way, before using the fast-but-unportable method.
(TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE): Remove, no longer
used. The code already assumed two's complement, so there's
no need to test for alternatives. All uses removed.
(TYPE_MAXIMUM): Don't rely here on overflow behavior not defined by
the C standard. Problem reported by Rich Felker in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00488.html>.
(twos_complement_arithmetic): Also check long_int and time_t.
(time_t_avg, time_t_add_ok, time_t_int_add_ok): New functions.
(guess_time_tm, ranged_convert, __mktime_internal): Use them.
(__mktime_internal): Avoid integer overflow with unary subtraction
in two instances where -1 - X is an adequate replacement for -X,
since the calculations are approximate.
2011-01-29 Eric Blake <eblake@redhat.com>
mktime: avoid infinite loop
* m4/mktime.m4 (AC_FUNC_MKTIME): Avoid overflow on possibly-signed
type; behavior is still undefined but portable to all known targets.
Reported by Rich Felker.
2011-01-28 Paul Eggert <eggert@cs.ucla.edu>
mktime: avoid problems on NetBSD 5 / i386
* lib/mktime.c (long_int): New type. This works around a problem
on NetBSD 5 / i386, where 'long int' and 'int' are both 32 bits
but time_t is 64 bits, and where I expect the existing code is
wrong in some cases.
(leapyear, ydhms_diff, guess_time_tm, __mktime_internal): Use it.
(ydhms_diff): Bring back the compile-time check for wide-enough
year and yday.
mktime: fix misspelling in comment
* lib/mktime.c (__mktime_internal): Fix misspelling in comment.
This merges all recent glibc changes of importance.
2011-01-28 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
move-if-change: cope with concurrent mv of identical file.
* move-if-change (CMPPROG): Accept environment
variable as an override for `cmp'.
(usage): Document CMPPROG.
Adjust comparison to drop stdout. Cope with failure of mv if
the target file exists and is identical to the source, for
parallel builds.
Report from H.J. Lu against binutils in PR binutils/12283.
2011-01-30 19:22:02 +00:00
|
|
|
int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
|
2011-01-09 06:57:07 +00:00
|
|
|
|
2013-03-13 00:38:42 +00:00
|
|
|
#if HAVE_DECL_ALARM
|
2011-01-09 06:57:07 +00:00
|
|
|
/* This test makes some buggy mktime implementations loop.
|
|
|
|
Give up after 60 seconds; a mktime slower than that
|
|
|
|
isn't worth using anyway. */
|
2013-03-13 00:38:42 +00:00
|
|
|
signal (SIGALRM, SIG_DFL);
|
2011-01-09 06:57:07 +00:00
|
|
|
alarm (60);
|
2013-03-13 00:38:42 +00:00
|
|
|
#endif
|
2011-01-09 06:57:07 +00:00
|
|
|
|
2016-05-02 01:36:38 +00:00
|
|
|
time_t_max = (! TIME_T_IS_SIGNED
|
gnulib: import mktime and move-if-change fixes from gnulib
* configure: Regenerate from the following.
2011-01-30 Paul Eggert <eggert@cs.ucla.edu>
mktime: clarify long_int width checking
* lib/mktime.c (long_int_is_wide_enough): Move this assertion to
the top level, to make it clearer that the assumption about
long_int width is being checked. See
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00554.html>.
2011-01-29 Paul Eggert <eggert@cs.ucla.edu>
TYPE_MAXIMUM: avoid theoretically undefined behavior
* lib/intprops.h (TYPE_MINIMUM, TYPE_MAXIMUM): Do not shift a
negative number, which the C Standard says has undefined behavior.
In practice this is not a problem, but might as well do it by the book.
Reported by Rich Felker and Eric Blake; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00493.html>.
* m4/mktime.m4 (AC_FUNC_MKTIME): Likewise.
* lib/mktime.c (TYPE_MAXIMUM): Redo slightly to match the others.
mktime: #undef mktime before #defining it
* lib/mktime.c (mktime) [DEBUG]: #undef mktime before #defining it.
mktime: systematically normalize tm_isdst comparisons
* lib/mktime.c (isdst_differ): New function.
(__mktime_internal): Use it systematically for all isdst comparisons.
This completes the fix for libc BZ #6723, and removes the need for
normalizing tm_isdst. See
<http://sourceware.org/bugzilla/show_bug.cgi?id=6723>
(not_equal_tm) [DEBUG]: Use isdst_differ here, too.
mktime: fix some integer overflow issues and sidestep the rest
This was prompted by a bug report by Benjamin Lindner for MinGW
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00472.html>.
His bug is due to signed integer overflow (0 - INT_MIN), and I
I scanned through mktime.c looking for other integer overflow
problems, fixing all the bugs I found.
Although the C Standard says the resulting code is still not safe
in the presence of integer overflow, in practice it should be good
enough for all real-world two's-complement implementations, except
for debugging environments that deliberately trap on integer
overflow (e.g., gcc -ftrapv).
* lib/mktime.c (WRAPV): New macro.
(SHR): Also check that long_int and time_t shift right in the
usual way, before using the fast-but-unportable method.
(TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE): Remove, no longer
used. The code already assumed two's complement, so there's
no need to test for alternatives. All uses removed.
(TYPE_MAXIMUM): Don't rely here on overflow behavior not defined by
the C standard. Problem reported by Rich Felker in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00488.html>.
(twos_complement_arithmetic): Also check long_int and time_t.
(time_t_avg, time_t_add_ok, time_t_int_add_ok): New functions.
(guess_time_tm, ranged_convert, __mktime_internal): Use them.
(__mktime_internal): Avoid integer overflow with unary subtraction
in two instances where -1 - X is an adequate replacement for -X,
since the calculations are approximate.
2011-01-29 Eric Blake <eblake@redhat.com>
mktime: avoid infinite loop
* m4/mktime.m4 (AC_FUNC_MKTIME): Avoid overflow on possibly-signed
type; behavior is still undefined but portable to all known targets.
Reported by Rich Felker.
2011-01-28 Paul Eggert <eggert@cs.ucla.edu>
mktime: avoid problems on NetBSD 5 / i386
* lib/mktime.c (long_int): New type. This works around a problem
on NetBSD 5 / i386, where 'long int' and 'int' are both 32 bits
but time_t is 64 bits, and where I expect the existing code is
wrong in some cases.
(leapyear, ydhms_diff, guess_time_tm, __mktime_internal): Use it.
(ydhms_diff): Bring back the compile-time check for wide-enough
year and yday.
mktime: fix misspelling in comment
* lib/mktime.c (__mktime_internal): Fix misspelling in comment.
This merges all recent glibc changes of importance.
2011-01-28 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
move-if-change: cope with concurrent mv of identical file.
* move-if-change (CMPPROG): Accept environment
variable as an override for `cmp'.
(usage): Document CMPPROG.
Adjust comparison to drop stdout. Cope with failure of mv if
the target file exists and is identical to the source, for
parallel builds.
Report from H.J. Lu against binutils in PR binutils/12283.
2011-01-30 19:22:02 +00:00
|
|
|
? (time_t) -1
|
|
|
|
: ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
|
|
|
|
* 2 + 1));
|
2016-05-02 01:36:38 +00:00
|
|
|
time_t_min = (! TIME_T_IS_SIGNED
|
gnulib: import mktime and move-if-change fixes from gnulib
* configure: Regenerate from the following.
2011-01-30 Paul Eggert <eggert@cs.ucla.edu>
mktime: clarify long_int width checking
* lib/mktime.c (long_int_is_wide_enough): Move this assertion to
the top level, to make it clearer that the assumption about
long_int width is being checked. See
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00554.html>.
2011-01-29 Paul Eggert <eggert@cs.ucla.edu>
TYPE_MAXIMUM: avoid theoretically undefined behavior
* lib/intprops.h (TYPE_MINIMUM, TYPE_MAXIMUM): Do not shift a
negative number, which the C Standard says has undefined behavior.
In practice this is not a problem, but might as well do it by the book.
Reported by Rich Felker and Eric Blake; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00493.html>.
* m4/mktime.m4 (AC_FUNC_MKTIME): Likewise.
* lib/mktime.c (TYPE_MAXIMUM): Redo slightly to match the others.
mktime: #undef mktime before #defining it
* lib/mktime.c (mktime) [DEBUG]: #undef mktime before #defining it.
mktime: systematically normalize tm_isdst comparisons
* lib/mktime.c (isdst_differ): New function.
(__mktime_internal): Use it systematically for all isdst comparisons.
This completes the fix for libc BZ #6723, and removes the need for
normalizing tm_isdst. See
<http://sourceware.org/bugzilla/show_bug.cgi?id=6723>
(not_equal_tm) [DEBUG]: Use isdst_differ here, too.
mktime: fix some integer overflow issues and sidestep the rest
This was prompted by a bug report by Benjamin Lindner for MinGW
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00472.html>.
His bug is due to signed integer overflow (0 - INT_MIN), and I
I scanned through mktime.c looking for other integer overflow
problems, fixing all the bugs I found.
Although the C Standard says the resulting code is still not safe
in the presence of integer overflow, in practice it should be good
enough for all real-world two's-complement implementations, except
for debugging environments that deliberately trap on integer
overflow (e.g., gcc -ftrapv).
* lib/mktime.c (WRAPV): New macro.
(SHR): Also check that long_int and time_t shift right in the
usual way, before using the fast-but-unportable method.
(TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE): Remove, no longer
used. The code already assumed two's complement, so there's
no need to test for alternatives. All uses removed.
(TYPE_MAXIMUM): Don't rely here on overflow behavior not defined by
the C standard. Problem reported by Rich Felker in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00488.html>.
(twos_complement_arithmetic): Also check long_int and time_t.
(time_t_avg, time_t_add_ok, time_t_int_add_ok): New functions.
(guess_time_tm, ranged_convert, __mktime_internal): Use them.
(__mktime_internal): Avoid integer overflow with unary subtraction
in two instances where -1 - X is an adequate replacement for -X,
since the calculations are approximate.
2011-01-29 Eric Blake <eblake@redhat.com>
mktime: avoid infinite loop
* m4/mktime.m4 (AC_FUNC_MKTIME): Avoid overflow on possibly-signed
type; behavior is still undefined but portable to all known targets.
Reported by Rich Felker.
2011-01-28 Paul Eggert <eggert@cs.ucla.edu>
mktime: avoid problems on NetBSD 5 / i386
* lib/mktime.c (long_int): New type. This works around a problem
on NetBSD 5 / i386, where 'long int' and 'int' are both 32 bits
but time_t is 64 bits, and where I expect the existing code is
wrong in some cases.
(leapyear, ydhms_diff, guess_time_tm, __mktime_internal): Use it.
(ydhms_diff): Bring back the compile-time check for wide-enough
year and yday.
mktime: fix misspelling in comment
* lib/mktime.c (__mktime_internal): Fix misspelling in comment.
This merges all recent glibc changes of importance.
2011-01-28 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
move-if-change: cope with concurrent mv of identical file.
* move-if-change (CMPPROG): Accept environment
variable as an override for `cmp'.
(usage): Document CMPPROG.
Adjust comparison to drop stdout. Cope with failure of mv if
the target file exists and is identical to the source, for
parallel builds.
Report from H.J. Lu against binutils in PR binutils/12283.
2011-01-30 19:22:02 +00:00
|
|
|
? (time_t) 0
|
|
|
|
: time_t_signed_magnitude
|
|
|
|
? ~ (time_t) 0
|
|
|
|
: ~ time_t_max);
|
2011-01-09 06:57:07 +00:00
|
|
|
|
|
|
|
delta = time_t_max / 997; /* a suitable prime number */
|
|
|
|
for (i = 0; i < N_STRINGS; i++)
|
|
|
|
{
|
|
|
|
if (tz_strings[i])
|
|
|
|
putenv (tz_strings[i]);
|
|
|
|
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta)
|
2011-01-09 06:57:07 +00:00
|
|
|
if (! mktime_test (t))
|
|
|
|
result |= 1;
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
if ((result & 2) == 0
|
|
|
|
&& ! (mktime_test ((time_t) 1)
|
|
|
|
&& mktime_test ((time_t) (60 * 60))
|
|
|
|
&& mktime_test ((time_t) (60 * 60 * 24))))
|
2011-01-09 06:57:07 +00:00
|
|
|
result |= 2;
|
|
|
|
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
for (j = 1; (result & 4) == 0; j <<= 1)
|
|
|
|
{
|
|
|
|
if (! bigtime_test (j))
|
|
|
|
result |= 4;
|
|
|
|
if (INT_MAX / 2 < j)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((result & 8) == 0 && ! bigtime_test (INT_MAX))
|
2011-01-09 06:57:07 +00:00
|
|
|
result |= 8;
|
|
|
|
}
|
|
|
|
if (! irix_6_4_bug ())
|
|
|
|
result |= 16;
|
|
|
|
if (! spring_forward_gap ())
|
|
|
|
result |= 32;
|
|
|
|
if (! year_2050_test ())
|
|
|
|
result |= 64;
|
|
|
|
return result;
|
|
|
|
}]])],
|
2011-06-15 22:27:54 +00:00
|
|
|
[gl_cv_func_working_mktime=yes],
|
|
|
|
[gl_cv_func_working_mktime=no],
|
|
|
|
[gl_cv_func_working_mktime=no])
|
|
|
|
])
|
2011-01-09 06:57:07 +00:00
|
|
|
|
2011-06-15 22:27:54 +00:00
|
|
|
if test $gl_cv_func_working_mktime = no; then
|
2011-01-09 06:57:07 +00:00
|
|
|
REPLACE_MKTIME=1
|
|
|
|
else
|
|
|
|
REPLACE_MKTIME=0
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2011-05-22 21:02:48 +00:00
|
|
|
AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
|
|
|
|
AC_REQUIRE([gl_FUNC_MKTIME])
|
|
|
|
if test $REPLACE_MKTIME = 0; then
|
|
|
|
dnl BeOS has __mktime_internal in libc, but other platforms don't.
|
|
|
|
AC_CHECK_FUNC([__mktime_internal],
|
|
|
|
[AC_DEFINE([mktime_internal], [__mktime_internal],
|
|
|
|
[Define to the real name of the mktime_internal function.])
|
|
|
|
],
|
|
|
|
[dnl mktime works but it doesn't export __mktime_internal,
|
|
|
|
dnl so we need to substitute our own mktime implementation.
|
|
|
|
REPLACE_MKTIME=1
|
|
|
|
])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2011-01-09 06:57:07 +00:00
|
|
|
# Prerequisites of lib/mktime.c.
|
2012-08-19 23:31:24 +00:00
|
|
|
AC_DEFUN([gl_PREREQ_MKTIME], [:])
|