lib/mktime.c


Log

Author Commit Date CI Message
Paul Eggert 281b825e 2018-01-01T00:57:25 maint: Run 'make update-copyright'
Paul Eggert ca35d468 2017-09-13T00:48:18 all: prefer https: URLs
Bruno Haible aca75e96 2017-05-09T21:27:27 tzset: Expand comment about TZ problem on native Windows. * lib/tzset.c (tzset): Elaborate comment, based on explanations by Paul Eggert. * lib/ctime.c (rpl_ctime): Likewise. * lib/localtime.c (rpl_localtime): Likewise. * lib/mktime.c (mktime): Likewise. * lib/strftime-fixes.c (rpl_strftime): Likewise. * lib/wcsftime.c (rpl_wcsftime): Likewise.
Bruno Haible db1ee11e 2017-04-30T16:34:54 mktime: Work around TZ problem on native Windows. * lib/mktime.c: Add #ifs to make the algorithmic workaround independent from the native Windows workaround. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): New macro, extracted from gl_FUNC_MKTIME. If guessing, set gl_cv_func_working_mktime to 'guessing no'. (gl_FUNC_MKTIME): Require it. Require AC_CANONICAL_HOST. Set REPLACE_MKTIME to 1 on native Windows. Define NEED_MKTIME_WORKING, NEED_MKTIME_WINDOWS. (gl_FUNC_MKTIME_INTERNAL): Require gl_FUNC_MKTIME_WORKS, not gl_FUNC_MKTIME. Set WANT_MKTIME_INTERNAL, not REPLACE_MKTIME. Define NEED_MKTIME_INTERNAL. * m4/timegm.m4 (gl_FUNC_TIMEGM): Require gl_FUNC_MKTIME_WORKS, not gl_FUNC_MKTIME. Cope with 'guessing yes' value. * modules/mktime-internal (configure.ac): Test WANT_MKTIME_INTERNAL, not REPLACE_MKTIME. * doc/posix-functions/mktime.texi: Mention the native Windows workaround.
Paul Eggert e89646ad 2017-01-09T11:55:22 maint: time stamp -> timestamp Use the spelling "timestamp", as that is what POSIX uses.
Paul Eggert a3fd683d 2017-01-01T02:59:23 version-etc: new year * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
Paul Eggert 97173b26 2016-07-03T12:59:54 mktime: call tzset as per POSIX Problem reported by Ludovic Courtès in: http://lists.gnu.org/archive/html/bug-gnulib/2016-06/msg00068.html * lib/mktime.c (mktime) [!_LIBC && HAVE_TZSET]: Call tzset. * m4/mktime.m4 (gl_FUNC_MKTIME): Check for tzset.
Paul Eggert c382e8d7 2016-05-01T18:49:47 mktime: spelling fix in comment * lib/mktime.c: Fix spelling.
Paul Eggert e6a38a90 2016-05-01T17:25:16 mktime: port to stricter signed overflow checking * lib/mktime.c: Omit 'pragma GCC optimize ("wrapv")'. (long_int): Require width for INT_MAX * 3 * (seconds per year), instead of merely for INT_MAX * 2. In practice platforms that do the latter also do the former. (TIME_T_MIN, TIME_T_MAX, TIME_T_MIDPOINT, SHR): Remove. (shr): New static function, replacing SHR. All uses changed. (mktime_min, mktime_max): New constants, replacing TIME_T_MIN and TIME_T_MAX. All uses changed. (ydhms_diff, guess_time_tm, ranged_convert, __mktime_internal): Use long_int, not time_t. (long_int_avg): New static function, replacing time_t_avg. All uses changed. Round toward positive infinity, as that generates slightly better code. (time_t_add_ok, time_t_int_add_ok): Remove. All uses replaced by INT_ADD_WRAPV. (guess_time_tm): Accept time, not a pointer to it. All uses changed. (convert_time): New static function. (ranged_convert): Use it (ranged_convert): Check for *T out of [mktime_min, mktime_max] range. Use simpler test for loop exit. (__mktime_internal): Store negative of guessed offset, to simplify overflow checking. Remove no-longer-needed test for small time_t overflows.
Paul Eggert e8cf9231 2016-05-01T12:49:21 mktime: speed up DEBUG_MKTIME benchmarks Call tzset just once, at the start, rather than for every test case. This lets us measure the CPU cost of mktime as opposed to that of tzset. This is relevant when TZ is not set and glibc is being used. This speeds up tests by a factor of 40 on my Fedora 23 x86-64 platform. * lib/mktime.c (main) [DEBUG_MKTIME]: Call localtime at the start, to call tzset and as a sanity check. Later on, use localtime_r instead of localtime.
Paul Eggert b4a3de1d 2016-05-01T12:15:52 mktime: resurrect DEBUG_MKTIME testing * lib/mktime.c [DEBUG_MKTIME]: Do not include <config.h>. Include <string.h>, for strcmp.
Paul Eggert 549de1eb 2016-05-01T12:10:37 mktime: simplify DEBUG_MKTIME * lib/mktime.c (DEBUG_MKTIME): Define to 0 if not defined. Simplify later usage accordingly.
Paul Eggert b28c2cda 2016-05-01T11:44:51 Port mktime_internal offset to unsigned time_t This avoids some assumptions about wraparound arithmetic on signed integer overflow. * lib/mktime-internal.h (mktime_offset_t): New type. (mktime_internal): Use it in decl. * lib/mktime.c, lib/timegm.c (mktime_offset_t) [_LIBC]: New type. * lib/mktime.c (__mktime_internal, localtime_offset): * lib/timegm.c (timegm): Use it. * m4/mktime.m4 (gl_TIME_T_IS_SIGNED): New macro. (gl_FUNC_MKTIME): Require it.
Paul Eggert 464ba348 2016-04-13T10:53:56 mktime: improve integer overflow checking * lib/mktime.c: Include stdbool.h, intprops.h, verify.h. (WRAPV): Remove; no longer needed. (verify): Remove. Replace all uses with call to verify.h 'verify'. (TYPE_IS_INTEGER, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. Use intprops.h defns instead. (leapyear, isdst_differ, time_t_add_ok, time_t_int_ok): Use bool for Boolean, for clarity. (time_t_add_ok, time_t_int_add_ok): Use INT_ADD_WRAPV to detect integer overflow. * modules/mktime (Depends-on): Add intprops, stdbool, verify.
Paul Eggert a4910b94 2016-04-13T00:06:36 intprops, mktime, strtol: assume two's complement These macros were not portable to every conforming C11 ones' complement platform. It's not worth the hassle of porting to some platforms that use ones' complement or signed magnitude, as such platforms are almost purely theoretical nowadays and porting even to some of them makes the code harder to review for little practical benefit. Problem reported by Florian Weimer in: https://sourceware.org/ml/libc-alpha/2016-04/msg00295.html * lib/intprops.h (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT) (TYPE_SIGNED_MAGNITUDE, _GL_INT_TWOS_COMPLEMENT): * lib/mktime.c (TYPE_TWOS_COMPLEMENT): * lib/strtol.c (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT) (TYPE_SIGNED_MAGNITUDE): Remove. All uses rewritten to assume two's complement, which is all we can reasonably test nowadays anyway. * top/maint.mk (_intprops_names): Remove the removed macros.
Martin Sebor 0433724b 2016-01-12T23:09:35 mktime: rename macro to avoid glibc clash * lib/mktime.c [DEBUG] (DEBUG): Rename to DEBUG_MKTIME. See: https://sourceware.org/ml/libc-alpha/2016-01/msg00267.html
Paul Eggert 71090a2a 2016-01-01T00:56:19 version-etc: new year * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
Paul Eggert b9bfe784 2015-01-01T01:38:23 version-etc: new year * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
Paul Eggert e2646b0c 2014-06-27T11:35:44 mktime: merge #if/#ifdef usage from glibc * lib/mktime.c: Use "#if defined DEBUG && DEBUG", not "#if DEBUG", as that works with both Glibc's and Gnulib's style. See thread starting at Siddhesh Poyarekar's bug report at: http://lists.gnu.org/archive/html/bug-gnulib/2014-06/msg00102.html
Eric Blake 1276a2c5 2014-01-01T00:04:40 maint: update copyright I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 9fc81090 2013-01-01T00:50:58 maint: update all copyright year number ranges Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
Paul Eggert cd15de4a 2012-08-18T15:34:37 mktime: avoid 'static inline' * lib/mktime.c (leapyear, ydhms_diff): Now static, not static inline. * m4/mktime.m4 (gl_PREREQ_MKTIME): Do not require AC_C_INLINE.
Paul Eggert 4fb7ea20 2012-05-25T23:14:31 * lib/mktime.c: Revert autoupdate, which fetched the wrong version.
Karl Berry 3a5aa57f 2012-05-25T09:18:18 autoupdate
Paul Eggert 8c271894 2012-05-23T22:03:52 mktime: sync from glibc * config/srclist.txt: Uncomment mktime.c. * lib/mktime.c: Sync from glibc master. This incorporates 3 changes. First, indent with tabs, since glibc uses tabs and doesn't want to change and we'd rather be identical to glibc. Also, two small coding changes: (isdst_differ): Use &&, not &, as && is the usual style. (__mktime_internal): Rename local var from abs_diff to approx_abs_diff for clarity.
Paul Eggert 341111f6 2012-02-09T21:39:05 maint: replace FSF snail-mail addresses with URLs * config/argz.mk, lib/accept4.c, lib/alignof.h, lib/alloca.in.h: * lib/alphasort.c, lib/arcfour.c, lib/arcfour.h, lib/arctwo.c: * lib/arctwo.h, lib/argz.c, lib/arpa_inet.in.h, lib/asnprintf.c: * lib/asprintf.c, lib/assert.in.h, lib/base32.c, lib/base32.h: * lib/base64.c, lib/base64.h, lib/c-ctype.c, lib/c-ctype.h: * lib/c-strcase.h, lib/c-strcasecmp.c, lib/c-strncasecmp.c: * lib/check-version.c, lib/check-version.h, lib/config.charset: * lib/ctype.in.h, lib/des.c, lib/des.h, lib/dup3.c, lib/errno.in.h: * lib/float+.h, lib/fnmatch.c, lib/fnmatch.in.h, lib/fnmatch_loop.c: * lib/fseeko.c, lib/gai_strerror.c, lib/gc-gnulib.c: * lib/gc-libgcrypt.c, lib/gc-pbkdf2-sha1.c, lib/gc.h: * lib/getaddrinfo.c, lib/getdelim.c, lib/getfilecon.c, lib/getline.c: * lib/getlogin_r.c, lib/getpass.c, lib/getpass.h, lib/gettext.h: * lib/gettimeofday.c, lib/glob.in.h, lib/glthread/cond.c: * lib/glthread/cond.h, lib/glthread/lock.c, lib/glthread/lock.h: * lib/glthread/thread.c, lib/glthread/thread.h: * lib/glthread/threadlib.c, lib/glthread/yield.h, lib/hmac-md5.c: * lib/hmac-sha1.c, lib/hmac.h, lib/iconv.c, lib/iconv.in.h: * lib/iconv_close.c, lib/iconv_open.c, lib/inet_ntop.c, lib/isfinite.c: * lib/isinf.c, lib/iswblank.c, lib/langinfo.in.h, lib/link.c: * lib/localcharset.c, lib/localcharset.h, lib/lseek.c, lib/malloc.c: * lib/malloca.c, lib/malloca.h, lib/md2.c, lib/md2.h, lib/md4.c: * lib/md4.h, lib/md5.c, lib/md5.h, lib/memmem.c, lib/mempcpy.c: * lib/memset.c, lib/memxor.c, lib/memxor.h, lib/minmax.h, lib/mktime.c: * lib/msvc-inval.c, lib/msvc-inval.h, lib/msvc-nothrow.c: * lib/msvc-nothrow.h, lib/netdb.in.h, lib/netinet_in.in.h, lib/nproc.c: * lib/nproc.h, lib/obstack_printf.c, lib/pathmax.h, lib/pipe.c: * lib/pipe2.c, lib/poll.c, lib/poll.in.h, lib/printf-args.c: * lib/printf-args.h, lib/printf-parse.c, lib/printf-parse.h: * lib/pselect.c, lib/pthread.in.h, lib/pty-private.h, lib/pty.in.h: * lib/read-file.c, lib/read-file.h, lib/ref-add.sin, lib/ref-del.sin: * lib/regcomp.c, lib/regex.c, lib/regex.h, lib/regex_internal.c: * lib/regex_internal.h, lib/regexec.c, lib/rijndael-alg-fst.c: * lib/rijndael-alg-fst.h, lib/rijndael-api-fst.c: * lib/rijndael-api-fst.h, lib/rint.c, lib/rintf.c, lib/rintl.c: * lib/round.c, lib/roundf.c, lib/roundl.c, lib/scandir.c, lib/select.c: * lib/sha1.c, lib/sha1.h, lib/size_max.h, lib/snprintf.c: * lib/stdalign.in.h, lib/stdarg.in.h, lib/stdbool.in.h: * lib/stddef.in.h, lib/stdint.in.h, lib/stdio.in.h, lib/str-kmp.h: * lib/str-two-way.h, lib/strcasecmp.c, lib/strcasestr.c, lib/strdup.c: * lib/striconv.c, lib/striconv.h, lib/string.in.h, lib/strings.in.h: * lib/strncasecmp.c, lib/strndup.c, lib/strnlen.c, lib/strpbrk.c: * lib/strptime.c, lib/strsep.c, lib/strstr.c, lib/strverscmp.c: * lib/sys_file.in.h, lib/sys_ioctl.in.h, lib/sys_select.in.h: * lib/sys_socket.in.h, lib/sys_stat.in.h, lib/sys_time.in.h: * lib/sys_times.in.h, lib/sys_types.in.h, lib/sys_uio.in.h: * lib/sys_utsname.in.h, lib/sys_wait.in.h, lib/tcgetsid.c: * lib/termios.in.h, lib/time.in.h, lib/time_r.c, lib/timegm.c: * lib/times.c, lib/unictype/3level.h, lib/unictype/3levelbit.h: * lib/unistd.in.h, lib/vasnprintf.c, lib/vasnprintf.h, lib/vasprintf.c: * lib/vsnprintf.c, lib/waitpid.c, lib/wchar.in.h, lib/wctype.in.h: * lib/xsize.h, tests/test-closein.c, tests/test-des.c: * tests/test-fclose.c, tests/test-fgetc.c, tests/test-filevercmp.c: * tests/test-fputc.c, tests/test-fread.c, tests/test-fwrite.c: * tests/test-gc-arcfour.c, tests/test-gc-arctwo.c, tests/test-gc-des.c: * tests/test-gc-hmac-md5.c, tests/test-gc-hmac-sha1.c: * tests/test-gc-md2.c, tests/test-gc-md4.c, tests/test-gc-md5.c: * tests/test-gc-pbkdf2-sha1.c, tests/test-gc-rijndael.c: * tests/test-gc-sha1.c, tests/test-gc.c, tests/test-getdelim.c: * tests/test-getline.c, tests/test-getndelim2.c, tests/test-md2.c: * tests/test-md4.c, tests/test-parse-datetime.c, tests/test-perror.c: * tests/test-perror2.c, tests/test-pipe.c, tests/test-pipe2.c: * tests/test-poll.c, tests/test-quotearg-simple.c: * tests/test-quotearg.c, tests/test-quotearg.h: * tests/test-round-ieee.c, tests/test-round1.c: * tests/test-roundf-ieee.c, tests/test-roundf1.c: * tests/test-roundl-ieee.c, tests/test-roundl.c: * tests/test-safe-alloc.c, tests/test-sigpipe.c: * tests/test-spawn-pipe-child.c, tests/test-spawn-pipe-main.c: * tests/test-strerror.c, tests/test-strerror_r.c: * tests/test-strsignal.c, tests/test-strverscmp.c: * tests/test-xmemdup0.c: Replace FSF snail mail addresses with URLs, as per GNU coding standards. See glibc bug <http://sourceware.org/bugzilla/show_bug.cgi?id=13673>.
Bruno Haible e7b7d5dd 2012-01-08T19:07:23 mktime: Avoid compilation error on Solaris 11. * lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems.
Paul Eggert 51e801f2 2012-01-05T23:53:49 In commentary, do not use ` to quote.
Jim Meyering 1602f0af 2012-01-01T10:04:58 maint: update all copyright year number ranges Run "make update-copyright".
Paul Eggert 3d3eb663 2011-01-30T09:36:23 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>.
Paul Eggert ee9e39c0 2011-01-29T23:59:31 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>. * lib/strtol.c (TYPE_MINIMUM, TYPE_MAXIMUM): Likewise. * m4/mktime.m4 (AC_FUNC_MKTIME): Likewise. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise. * m4/parse-datetime.m4 (gl_PARSE_DATETIME): Likewise. * m4/stdint.m4 (gl_STDINT_H): Likewise. * lib/mktime.c (TYPE_MAXIMUM): Redo slightly to match the others.
Paul Eggert 56887e87 2011-01-29T23:04:27 mktime: #undef mktime before #defining it * lib/mktime.c (mktime) [DEBUG]: #undef mktime before #defining it.
Paul Eggert 7b359a23 2011-01-29T23:00:55 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.
Paul Eggert 385b9f9d 2011-01-29T15:47:04 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.
Paul Eggert b34d6825 2011-01-28T21:02:31 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.
Paul Eggert 9cb2237e 2011-01-28T15:57:13 mktime: fix misspelling in comment * lib/mktime.c (__mktime_internal): Fix misspelling in comment. This merges all recent glibc changes of importance.
Jim Meyering d60f3b0c 2011-01-01T20:17:23 maint: update almost all copyright ranges to include 2011 Run the new "make update-copyright" rule.
Jim Meyering b2e2010c 2010-01-01T10:31:12 update nearly all FSF copyright year lists to include 2010 Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
Bruno Haible 441aa304 2009-12-10T20:28:30 Use spaces for indentation, not tabs.
Eric Blake 2bb0a0ed 2009-11-02T11:39:38 mktime, timegm: share common declaration * lib/mktime-internal.h: New file. * lib/mktime.c: Use it rather than open-coding a declaration. * lib/timegm.c: Likewise. * modules/mktime (Files): Ship it. * modules/timegm (Files): Likewise. Suggested by Bruno Haible. Signed-off-by: Eric Blake <ebb9@byu.net>
Eric Blake 708e2420 2009-10-30T09:47:12 build: avoid compiler warnings * lib/fchmodat.c (lchmod): Mark unused variables. * lib/getopt.c (_getopt_initialize): Likewise. * lib/mktime.c (__mktime_internal): Provide prototype. * lib/inttostr.c (inttostr): Avoid compiler warning even with older gcc that do not understand #pragma GCC diagnostic. * lib/uinttostr.c (inttype_is_unsigned): Define. * lib/umaxtostr.c (inttype_is_unsigned): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
Bruno Haible 2b95db96 2009-09-17T08:07:50 Disable assertion that fails on NetBSD 5 / i386.
Ulrich Drepper 5490f5a9 2008-07-23T16:19:15 mktime.c: normalize tp->tm_isdst value to -1/0/1. * lib/mktime.c (__mktime_internal): Normalize tp->tm_isdst value. Reported by Michael Ringe <Michael.Ringe@gmx.de> in <http://sourceware.org/bugzilla/show_bug.cgi?id=6723>.
Paul Eggert 3ac95524 2007-02-12T18:49:19 New module 'time', so that apps can include <time.h> as per POSIX and GNU instead of separate include files like time_r.h and timegm.h. This implementation tries out a simpler approach for replacing decls in standard include files (as compared to the string module), somewhat as an experiment. * config/srclist.txt: Comment out mktime.c for now. * doc/gnulib-tool.texi (Initial import): Don't use time_r as an example since it doesn't apply any more. Use generic wording instead. * MODULES.html.sh (Support for systems lacking POSIX:2001): New module 'time'. * lib/time_.h, m4/time_h.m4, modules/time: New files. * lib/strptime.h, lib/time_r.h, lib/timegm.h: Remove. * lib/mktime.c: Include config.h depending on _LIBC, not HAVE_CONFIG_H. Don't include <sys/types.h>; no longer needed since we assume C89. * lib/mktime.c: Don't include "time_r.h"; no longer needed. * lib/strftime.c: Likewise. * lib/time_r.c: Likewise. * lib/nanosleep.c (nanosleep): #undef after include files, not before. * lib/nanosleep.c: Include <time.h> first, to check interface. * lib/strptime.c: Likewise. * lib/time_r.c: Likewise. * lib/timegm.c: Likewise. * lib/strptime.c: Don't include strptime.h or time_r.h; no longer needed. * lib/timegm.c: Don't include timegm.h; no longer needed. * lib/timespec.h: Don't include <sys/time.h> before <time.h>; time.h now handles any problems in that area. (struct timespec, nanosleep): Remove; time.h now arranges for these. * lib/xnanosleep.c: Don't include timespec.h; no longer needed now that time.h defines struct timespec. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check that nanosleep is declared. Set REPLACE_NANOSLEEP. Don't AC_DEFINE nanosleep; the time module now handles that. * m4/strptime.m4 (gl_FUNC_STPRTIME): Set REPLACE_STRPTIME. * m4/time_r.m4 (gl_TIME_R): Don't define HAVE_TIME_R_POSIX; no longer needed. Set REPLACE_LOCALTIME. * m4/timegm.m4 (gl_FUNC_TIMEGM): Set REPLACE_TIMEGM. * m4/timespec.m4 (gl_CHECK_TYPE_STRUCT_TIMESPEC): Move to time_h.m4. (gl_TIMESPEC): Don't check for sys/time.h or struct timespec or nanosleep; time_h.m4 now does that. Don't require gl_USE_SYSTEM_EXTENSIONS; no longer needed directly, and the time module handles this now. * modules/getdate (Depends-on): Remove timespec. Add time. * modules/nanosleep (Depends-on): Likewise. * modules/stat-time (Depends-on): Likewise. * modules/nanosleep (Include): Include time.h, not timespec.h. * modules/strptime (Files): Remove lib/strptime.h. (Depends-on): Add extensions, time. (Include): Include time.h, not strptime.h. * modules/time_r (Files): Remove lib/time_r.h. (Depends-on): Add time. (Include): Include time.h, not time_r.h. * modules/timegm: Likewise. * modules/timespec (Description): Now does timespec-related decls of our own, instead of struct timespec itself. (Depends-on): Add time; remove extensions. (Maintainer): Add self. * modules/utimecmp (Depends-on): Add time; remove timespec. * modules/utimens (Depends-on): Likewise. * modules/xnanosleep (Depends-on): Likewise.
Karl Berry 26bdd04d 2006-09-11T12:56:50 autoupdate
Paul Eggert 3ad2f5c4 2006-09-08T22:48:25 * config/srclist.txt: Temporarily comment out mktime.c until glibc bug 2821 is fixed. * lib/mktime.c (guess_time_tm): Fix bug where mktime returned the maximum time_t value rather than (time_t) -1. Problem originally reported by William Bardwell <http://sourceware.org/bugzilla/show_bug.cgi?id=2821>. * m4/mktime.m4 (AC_FUNC_MKTIME): Sync from Autoconf. Check for unistd.h too, since Autoconf doesn't assume POSIX. Also: 2006-09-08 Paul Eggert <eggert@cs.ucla.edu> Add year_2050_test to catch glibc bug 2821 <http://sourceware.org/bugzilla/show_bug.cgi?id=2821>. 2006-08-15 Paul Eggert <eggert@cs.ucla.edu> Prefer #ifdef to #if. 2006-04-02 Paul Eggert <eggert@cs.ucla.edu> Return from 'main' instead of calling 'exit'.
Karl Berry 69d12657 2005-09-18T12:30:04 srclist.update
Paul Eggert bf982dc2 2005-06-23T07:14:09 * mktime.c: Include <string.h> even if !DEBUG. (From glibc.) (ranged_convert): Don't save conversion in a temporary struct. This causes a warning with GCC 4.0.0, and anyway in the typical case it's not worth the extra 100 bytes or so of code. (ranged_convert, __mktime_internal): When calling a function via a pointer P, use P () rather than (*P) (), as we now assume C89 or better.
Paul Eggert 267a39ba 2005-05-14T06:03:57 *** empty log message ***
Paul Eggert 8d007e5a 2005-03-26T18:08:56 Propagate intprops.h comment fixes to mktime.c and strftime.c.
Paul Eggert f77aebf8 2005-03-15T00:39:17 * mktime.c (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE, TYPE_MINIMUM, TYPE_MAXIMUM): Sync from intprops.h. * strtol.c: Likewise.
Paul Eggert eef56b54 2005-03-09T19:11:23 Factor int-properties macros into a single file, except for glibc-related files. * lib/intprops.h: New file. * lib/getloadavg.c: Include it instead of limits.h. (INT_STRLEN_BOUND): Remove. * lib/human.c: Include intprops.h. (group_number): Use INT_STRLEN_BOUND instead of rolling it ourself. * lib/human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than 302/1000. * lib/inttostr.h: Include intprops.h instead of limits.h. (INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove. * lib/mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros, for consistency with intprops.h. (time_t_is_integer, twos_complement_arithmetic): Use them. * lib/sig2str.h: Include <signal.h>, intprops.h. (INT_STRLEN_BOUND): Remove. * lib/strftime.c (TYPE_SIGNED): Remove. (INT_STRLEN_BOUND): Switch to same implementation as intprops.h. * lib/strtol.c: Adjust comments to match intprops.h. * lib/userspec.c: Include intprops.h. (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. * lib/utimecmp.c, lib/xnanosleep.c, lib/xstrtol.c: Likewise. * lib/utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT instead of rolling our own expressions. * lib/xstrtol.c: Include xstrtol.h first, to test interface. * modules/getloadavg (Files): Add lib/intprops.h. * modules/human (Files): Likewise. * modules/inttostr (Files): Likewise. * modules/sig2str (Files): Likewise. * modules/userspec (Files): Likewise. * modules/utimecmp (Files): Likewise. * modules/xnanosleep (Files): Likewise. * modules/xstrtol (Files): Likewise.
Karl Berry 34d76dfe 2005-03-08T13:25:38 autoupdate
Paul Eggert cb48a016 2004-12-03T06:35:31 (__mktime_internal): If SEC_REQUESTED != SEC, convert T2, not T. (Imported from libc.)
Paul Eggert bdf8a3ff 2004-11-11T04:37:32 (SHR): New macro, which is a portable substitute for >> that should work even on Crays. (TIME_T_MIDPOINT, ydhms_diff, __mktime_internal): Use it. Problem reported by Mark D. Baushke in <http://lists.gnu.org/archive/html/bug-gnulib/2004-11/msg00071.html>.
Paul Eggert d5f3781d 2004-10-27T21:48:17 (not_equal_tm): Remove redundant check.
Paul Eggert ba17a19d 2004-10-22T20:19:01 (leapyear): Arg is long int, not int.
Jim Meyering d95c6009 2004-01-21T22:10:43 (__mktime_internal) [!_LIBC]: Define to mktime_internal so as not to conflict with a different-sized __mktime_internal function in GNU libc.
Paul Eggert 8b2c2981 2003-09-09T22:41:13 Remove K&R cruft.
Paul Eggert 7b224479 2003-09-06T21:34:07 Add time_r module. Change timegm, mktime, and strftime to use localtime_r and gmtime_r, now supplied by the time_r module. This fixes some timegm bugs and cleans up mktime and strftime a bit.
Paul Eggert c80984f8 2003-07-07T23:11:52 Fix some boundary cases and remove need for floating point. Issue a compile-time diagnostic if time_t is floating point, or if two's complement arithmetic is not in effect, or if arithmetic right shift does not propagate the sign. These assumptions were all in the original code but they weren't checked. (TIME_T_MIDPOINT, verify): New macros. (__isleap): Remove; it has integer overflow problems. (leapyear): New function, without those problems. (ydhms_tm_diff): Remove; splitting into two parts. (ydhms_diff): New function, containing the arithmetic part of the old ydhms_tm_diff function. Issue a compile-time diagnostic if we are not using C99 integer division. Avoid casts when possible. (guess_time_tm): New function, containing the checking part of the old ydhms_tm_diff function. Return the new value, rather than the difference between it and the old. Accept a new argument T so that *T specifies the old value. Check for overflow in the result. (__mktime_internal): Use a time_t offset, not a long int offset. This undoes the 2003-06-04 change, which is no longer needed now that we have better overflow checking. (localtime_offset): Likewise. (__mktime_internal): Avoid harmful overflow on hosts where time_t and long are 64-bit but int is only 32-bit. (ydhms_diff): Use long int to store year1 and yday1. Issue a compile-time diagnostic if long int is not wide enough. (__mktime_internal): Use long int to store adjusted year and yday. Use plain C rather than preprocessor commands, if that doesn't affect efficiency. Check for overflow (and try to repair) after each probe rather than checking only at the very end. This avoids some bugs (e.g., southern hemisphere, behind GMT, and GMT offset at minimum time does not equal GMT offset at maximum time). Use integer to check for overflow rather than floating point; this is more portable to non-IEEE hosts, and is a tad faster. When we detect that we are oscillating between two values, don't check whether tm_isdst has the requested value, since we already know the answer. When tm_isdst has the wrong value, use a different heuristic to find the right one, based on the extreme values actually observed in practice in tz2003a, rather than the (overly optimistic) "previous 3 calendar quarters". (not_equal_tm, print_tm, check_result): Use "const T" rather than "T const" to accommodate glibc style. (check_result): Use less-confusing report format. "long" -> "long int. (main): Likewise. Don't loop if the iteration overflows time_t. Allow a negative step in the iteration.
Paul Eggert bea5a055 2003-06-05T20:07:59 Assume freestanding C89 or better. (HAVE_LIMITS_H): Remove. Assume it's 1. (__P): Remove; not used. (INT_MIN, INT_MAX): Remove; <limits.h> defines them. (mktime, not_equal_tm, print_tm, check_result, main): Use prototypes. Use const * where appropriate. (main): Fix typo in testing code that uncovered by above changes.
Paul Eggert b2c42615 2003-06-05T06:43:15 Fix Debian bug 177940 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=177940>. (localtime_offset): Now long int, not time_t, because we want it to be guaranteed to be signed. All uses changed. (__mktime_internal): If overflow would occur when adding offset, don't add it.
Paul Eggert a76a349e 2003-06-04T20:09:47 Ensure we use gnulib mktime rather than glibc's mktime, on hosts where mktime isn't the inverse of localtime (negative time_t).
Karl Berry 54a64110 2003-05-30T15:06:41 mktime update from libc
Paul Eggert 3b59684c 2003-05-28T20:18:22 (__mktime_internal): Do not reject negative timestamps arbitrarily.
Jim Meyering 41d8937a 2002-11-25T15:31:05 Really sync with libc, not with my locally-modified copy. Thanks, Karl!
Jim Meyering 1bc47090 2002-11-25T13:22:20 Sync from libc, now that it has the latest fix.
Jim Meyering fd8e762e 2002-11-24T10:39:54 Merge in changes from libc.
Jim Meyering 9d7d2eaf 2002-11-24T10:06:16 Avoid a link-time failure on some Linux systems. (STATIC): Define to be empty (_LIBC) or `static' (otherwise). (__mon_yday): Declare with the STATIC attribute. (__mktime_internal): Likewise.
Jim Meyering 89f2b489 2000-08-07T15:48:18 back out Copyright date changes for files with no changes year
Jim Meyering d349992d 2000-07-09T07:22:43 update copyright date
Jim Meyering b0aca2f6 1999-02-17T14:58:41 tweak comment
Jim Meyering f979eb04 1999-02-16T21:35:48 new version from Uli
Jim Meyering 7f20e762 1999-01-19T04:47:24 (__mktime_internal): Adopt the traditional (and problematic) notion of what to do when tm_isdst doesn't match. From Paul Eggert.
Jim Meyering cf42d3e5 1998-12-07T03:12:10 ansideclify
Jim Meyering d37eda27 1998-10-18T14:08:35 Don't invoke localtime_r or gmtime_r unless it's the GNU C library's localtime_r and gmtime_r; there are too many buggy implementations of localtime_r and gmtime_r out there, and it's not worth keeping track of all the different bugs. * mktime.c (__EXTENSIONS__, HAVE_LOCALTIME_R): Remove. (my_mktime_localtime_r): Renamed from localtime_r; all uses changed. Base it on localtime unless _LIBC.
Jim Meyering 6579bcf6 1998-10-18T01:10:21 Declare localtime_r if necessary.
Jim Meyering 184e8608 1998-10-17T12:39:30 Some systems require <unistd.h> to be included before <time.h> for localtime_r to be declared properly.
Jim Meyering 599729fb 1998-10-12T02:00:59 (_REENTRANT): Define again -- linux-2.0.33 needs it.
Jim Meyering a5382999 1998-10-11T23:03:41 (__mktime_internal): When the requested time falls in a spring-forward gap of size DT, return a time that is DT away from the requested time, preferring a time whose tm_isdst differs from the requested value. Bump the max number of probes from 4 to 6 to account for the extra probes needed to discover a spring-forward gap in the worst case.
Jim Meyering c5da3fd9 1998-10-08T12:19:48 (my_mktime_localtime_r): Renamed from localtime_r. Define also if HAVE_LOCALTIME_R && defined (localtime_r), with a body that merely expands localtime_r; this works around a bug in Digital Unix 4.0A and 4.0D.
Jim Meyering 0eeff3be 1998-04-12T15:16:37 .
Jim Meyering 96462d30 1998-04-12T09:39:30 (TYPE_MAXIMUM): Update from system.h.
Jim Meyering 9300fc8b 1998-02-24T23:19:13 add comment
Jim Meyering bfd921d6 1998-01-23T22:02:54 (__mktime_internal): Work around bug in Irix4.0.5's C compiler. From Kaveh Ghazi. (TYPE_MINIMUM): Define. (TYPE_MAXIMUM): Define. (TIME_T_MIN): Use TYPE_MINIMUM. (TIME_T_MAX): Use TYPE_MAXIMUM.
Jim Meyering fd396561 1997-11-18T03:32:00 (_REENTRANT): #define, as some hosts need this to declare localtime_r properly. From Paul Eggert.
Jim Meyering 1873f591 1997-11-13T13:22:54 Update from FSF.
Jim Meyering 89b2adc0 1997-09-17T12:46:45 update from FSF .../copies
Jim Meyering 068f1a3a 1997-03-14T03:28:09 (TIME_T_MIN): Work around a bug in Cray C 5.0.3.0.
Jim Meyering 77d822a7 1997-02-21T02:16:54 update from FSF
Jim Meyering 1631b5c0 1996-11-05T04:22:40 Fix copyright.
Jim Meyering 6d8337bf 1996-07-15T03:36:16 update FSF address in copyright
Jim Meyering 870b659d 1995-11-03T19:56:08 New version from glibc.
Jim Meyering 2c5d56e2 1994-09-27T22:02:08 merge with 1.10n2
Jim Meyering c9aad3a0 1994-08-19T22:42:32 merge with 1.10g
Jim Meyering 8965f456 1994-07-26T04:06:26 merge with 1.10f
Jim Meyering 6a75c0b2 1994-02-12T17:23:51 merge with 1.9.2i
Jim Meyering 43e78b97 1992-11-01T05:44:30 Initial revision