about summary refs log tree commit diff
path: root/time/mktime.c
Commit message (Collapse)AuthorAgeFilesLines
* * time/mktime.c: Update obsolete URL in comment.Paul Eggert2019-03-171-1/+1
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-011-1/+1
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* mktime: DEBUG_MKTIME cleanupPaul Eggert2018-11-151-160/+2
| | | | | | | The DEBUG_MKTIME code no longer works in glibc or in Gnulib. And it’s no longer needed now that glibc and Gnulib both have their own testing mechanisms for mktime. * time/mktime.c (DEBUG_MKTIME): Remove. All uses removed.
* mktime: fix non-EOVERFLOW errno handlingPaul Eggert2018-11-151-98/+99
| | | | | | | | | | | | | | | [BZ#23789] mktime was not properly reporting failures when the underlying localtime_r fails with errno != EOVERFLOW; it incorrectly treated them like EOVERFLOW failures, and set errno to EOVERFLOW. The problem could happen on non-glibc platforms, with Gnulib. * time/mktime.c (guess_time_tm): Remove, replacing with ... (tm_diff): ... this simpler function, which does not change errno. All callers changed to deal with errno themselves. (ranged_convert, __mktime_internal): Return failure immediately if the underlying function reports any failure other than EOVERFLOW. (__mktime_internal): Set errno to EOVERFLOW if the spring-forward gap code fails.
* mktime: fix bug with Y2038 DST transitionPaul Eggert2018-11-151-1/+3
| | | | | | | | [BZ#23789] * time/mktime.c (ranged_convert): On 32-bit platforms, don’t mishandle a DST transition that jumps over the Y2038 boundary. No such DST transitions are known so this is only a theoretical bug, but we might as well do things right.
* mktime: make more room for overflowPaul Eggert2018-11-151-9/+11
| | | | | | | [BZ#23789] * time/mktime.c (long_int): Now 4⨯ int, not just 3⨯. This is so that we can add tm_diff results to a previous guess, which will be useful in a later patch.
* mktime: simplify offset guessPaul Eggert2018-11-151-3/+3
| | | | | [BZ#23789] * time/mktime.c (__mktime_internal): Omit excess precision.
* mktime: fix EOVERFLOW bugPaul Eggert2018-11-151-7/+19
| | | | | | | [BZ#23789] * time/mktime.c [!_LIBC && !DEBUG_MKTIME]: Include libc-config.h, not config.h, for __set_errno. (guess_time_tm, __mktime_internal): Set errno to EOVERFLOW on overflow.
* mktime fix for Gnulib + coreutilsPaul Eggert2018-10-081-1/+1
| | | | | | | | | | | [BZ#23745] This fix affects only Gnulib. Problem discovered when mktime.c was used as part of Gnulib in bleeding-edge Coreutils. * time/mktime.c: (my_tzset) [!_LIBC && !NEED_MKTIME_WORKING && !NEED_MKTIME_WINDOWS]: Do not define since it is not used. Defining an unused static function prompts a warning from GCC when Coreutils is configured with --enable-gcc-warnings.
* Merge mktime, timegm from upstream GnulibPaul Eggert2018-09-191-298/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [BZ #23603][BZ #16346] This fixes some obscure problems with integer overflow. Although it looks scary, it is almost all a byte-for-byte copy from Gnulib, and the Gnulib code has been tested reasonably well. * include/intprops.h: New file, copied from Gnulib. * include/verify.h, time/mktime-internal.h: New tiny files, simplified from Gnulib. * time/mktime.c: Copy from Gnulib. This has the following changes: Do not include config.h if DEBUG_MKTIME is nonzero. Include stdbool.h, intprops.h, verify.h. Include string.h only if needed. Include stdlib.h on MS-Windows. Include mktime-internal.h. (DEBUG_MKTIME): Default to 0, and simplify later uses. (NEED_MKTIME_INTERNAL, NEED_MKTIME_WINDOWS) (NEED_MKTIME_WORKING): Give default values to pacify -Wundef, which glibc uses. Default NEED_MKTIME_WORKING to DEBUG_MKTIME, to simplify later conditionals; default the others to zero. Use these conditionals to express only the code needed on the current platform. In uses of these conditionals, explicitly spell out how _LIBC affects things, so it’s easier to review from a glibc viewpoint. (WRAPV): Remove; no longer needed now that we have systematic overflow checking. (my_tzset, __tzset) [!_LIBC]: New function and macro, to better compartmentalize tzset issues. Move system-dependent tzsettish code here from mktime. (verify): Remove; now done by verify.h. All uses changed. (long_int): Use a more-conservative definition, to avoid integer overflow. (SHR): Remove, replacing with ... (shr): New function, which means we needn’t worry about side effects in args, and conversion analysis is simpler. (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT, TYPE_SIGNED, TYPE_MINIMUM) (TYPE_MAXIMUM, TIME_T_MIN, TIME_T_MAX, TIME_T_MIDPOINT) (time_t_avg, time_t_add_ok): Remove. (mktime_min, mktime_max): New constants. (leapyear, isdst_differ): Use bool for booleans. (ydhms_diff, guess_time_tm, ranged_convert, __mktime_internal): Use long_int, not time_t, for mktime differences. (long_int_avg): New function, replacing time_t_avg. INT_ADD_WRAPV replaces time_t_add_ok. (guess_time_tm): 6th arg is now long_int, not time_t const *. All uses changed. (convert_time): New function. (ranged_convert): Use it. (__mktime_internal): Last arg now points to mktime_offset_t, not time_t. All uses changed. This is a no-op on glibc, where mktime_offset_t is always time_t. Use int, not time_t, for UTC offset guess. Directly check for integer overflow instead of using a heuristic that works only 99.9...% of the time. Access *OFFSET only once, to avoid an unlikely race if the compiler delays a load and if this cascades into a signed integer overflow. (mktime): Move tzsettish code to my_tzset, and move localtime_offset to within mktime so that it doesn’t need a separate ifdef. (main) [DEBUG_MKTIME]: Speed up by using localtime_r instead of localtime. * time/timegm.c: Copy from Gnulib. This has the following changes: Include mktime-internal.h. [!_LIBC]: Include config.h and time.h. Do not include timegm.h or time_r.h. Make __mktime_internal a macro, and include mktime-internal.h to get its declaration. (timegm): Temporary is now mktime_offset_t, not time_t. This affects only Gnulib.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-011-1/+1
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2017-01-011-1/+1
|
* Fix build failures with -DDEBUG.Martin Sebor2016-01-151-6/+6
| | | | | | | | | | | | | [BZ #19443] * crypt/crypt_util.c [DEBUG] (_ufc_prbits): Correct format string. [DEBUG] (_ufc_set_bits): Declare used. * iconv/gconv_dl.c [DEBUG]: Add a missing include directive. [DEBUG] (print_all): Declare used. * resolv/res_send.c [DEBUG] (__libc_res_nsend): Explicitly convert operands of the ternary ?: expression to target type. * stdlib/rshift.c [DEBUG] (mpn_rshift): Use assert() instead of calling the undeclared abort. * time/mktime.c [DEBUG] (DEBUG): Rename to DEBUG_MKTIME.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2016-01-041-1/+1
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2015-01-021-1/+1
|
* Sync up mktime with gnulibPaul Eggert2014-06-281-2/+2
| | | | | | | | | | | | | | | From the gnulib commit log: commit e2646b0c6b5acda25e9ffeb4c12a5513a1e3b5ac Author: Paul Eggert <eggert@cs.ucla.edu> Date: Fri Jun 27 11:35:44 2014 -0700 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
* Remove inline keyword from leapyear functionSiddhesh Poyarekar2014-06-271-1/+1
| | | | This syncs up the code with gnulib.
* Update copyright notices with scripts/update-copyrightsAllan McRae2014-01-011-1/+1
|
* Remove lots of inline keywords.Roland McGrath2013-02-071-1/+1
|
* Update copyright notices with scripts/update-copyrights.Joseph Myers2013-01-021-1/+1
|
* mktime: avoid signed integer overflowPaul Eggert2012-05-231-4/+4
| | | | | * time/mktime.c (__mktime_internal): Do not mishandle the case where diff == INT_MIN.
* mktime: simplify computation of averagePaul Eggert2012-05-231-3/+1
| | | | | * time/mktime.c (ranged_convert): Use new time_t_avg function instead of rolling our own (probably-slower) code.
* mktime: do not assume signed right shift propagates sign bitPaul Eggert2012-05-231-6/+12
| | | | | | | * time/mktime.c (isdst_differ): New static function. (__mktime_internal): No need to normalize tm_isdst now. (__mktime_internal, not_equal_tm): Use isdst_differ to compare tm_isdst values.
* mktime: merge another wrapv change from gnulibPaul Eggert2012-05-231-1/+1
| | | | | * time/mktime.c (TYPE_MAXIMUM): Rework slightly to avoid diagnostics from some compilers.
* mktime: remove incorrect attempt at unusual arithmeticsPaul Eggert2012-05-231-9/+6
| | | | | | | | * time/mktime.c (TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE): Remove. The code didn't really work on such machines anyway. (TYPE_MINIMUM): Assume two's complement. (twos_complement_arithmetic): Verify that long_int and time_t are two's complement (or unsigned, in the latter case).
* mktime: check signed shifts on long_int and time_t, tooPaul Eggert2012-05-231-3/+5
| | | | | | * time/mktime.c (SHR): Check that shifts work as desired on the types long_int and time_t too, as SHR is used on such types.
* mktime: do not assume 'long' is wide enoughPaul Eggert2012-05-231-12/+18
| | | | | | | | | * time/mktime.c (verify): Move decl up. (long_int): New type. (leapyear, ydhms_diff, guess_time_tm, __mktime_internal): Use it, to remove assumption in the code that 'long' is wide enough to store year values. This assumption is not true on x32 and on some non-glibc platforms.
* mktime: merge wrapv change from gnulibPaul Eggert2012-05-231-25/+90
| | | | | | | | * time/mktime.c (WRAPV): New macro. (time_t_avg, time_t_add_ok, time_t_int_add_ok): New static functions. (guess_time_tm, __mktime_internal): Do not assume that signed integer overflow wraps around; modern compilers generate code where this assumption is no longer valid.
* Update copyright years for time/mktime.cH.J. Lu2012-05-221-1/+1
|
* mktime: merge comment-quoting-style change from gnulibPaul Eggert2012-05-221-3/+3
|
* time/mktime.c (compile-command): Add "-I."Paul Eggert2012-05-221-1/+1
|
* mktime: merge mktime-internal.h change from gnulibPaul Eggert2012-05-221-0/+1
|
* mktime: merge time_r change from gnulibPaul Eggert2012-05-221-2/+1
|
* mktime: merge DEBUG change from gnulibPaul Eggert2012-05-221-0/+1
|
* mktime: merge <sys/types.h> change from gnulibPaul Eggert2012-05-221-1/+0
|
* mktime: merge HAVE_CONFIG_H change from gnulibPaul Eggert2012-05-221-1/+1
|
* Replace FSF snail mail address with URLs.Paul Eggert2012-02-091-3/+2
|
* (__mktime_internal): Normalize tp->tm_isdst value.Ulrich Drepper2008-07-061-2/+4
|
* * time/bug-getdate1.c (do_test): Don't use century values whichUlrich Drepper2007-12-121-2/+2
| | | | aren't valid on 32-bit systems.
* [BZ #2821] cvs/fedora-glibc-20060910T1832Ulrich Drepper2006-09-091-5/+6
| | | | | | * time/mktime.c (guess_time_tm): Fix overflow detection. * time/Makefile (tests): Add bug-mktime1. * time/bug-mktime1.c: New file.
* [BZ #1033, BZ #1061]Roland McGrath2005-09-081-20/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | 2005-07-11 Derek R. Price <derek@ximbiot.com> [BZ #1061] * sysdeps/generic/glob.c (glob): Only a 0 return from getlogin_r means success, according to POSIX 1003.2. 2005-06-23 Paul Eggert <eggert@cs.ucla.edu> [BZ #1033] * time/mktime.c: Import from gnulib. The following macros are now consistent with other gnulib code. This does not change mktime's behavior. (TYPE_IS_INTEGER): New macro. (time_t_is_integer): Use it. (TYPE_TWOS_COMPLEMENT): New macro. (twos_complement_arithmetic): Use it. (TYPE_ONES_COMPLEMENT): New macro. (TYPE_MINIMUM, TYPE_MAXIMUM): Now supports signed-magnitude. mktime doesn't use this, but the code now matches other gnulib code. (ranged_convert): Pacify GCC 4.0 in a different way, which generates a few bytes less 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.
* * time/mktime.c: Always include <string.h> for prototype ofUlrich Drepper2005-06-181-1/+2
| | | | | | | | | | implicitly used memcpy. * sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c (truncate64): Use __truncate, not truncate. (__have_no_truncate64): Renamed from have_no_truncate64. * sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c (__have_no_truncate64): Renamed from have_no_truncate64.
* * posix/regexec.c (check_node_accept_bytes): Correct cast to avoidUlrich Drepper2005-03-061-2/+3
| | | | | | | | | | | | | | | | | | | warning. * posix/regex_internal.c (re_string_reconstruct): Add cast to avoid warning. (build_wcs_upper_buffer): Change type of bug to plain char. * locale/weightwc.h (findidx): Add casts to avoid warnings. * time/mktime.c (ranged_convert): Initialize tm to make the compiler happy. * wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Add casts to avoid warnings. * wcsmbs/wcsnrtombs.c (__wcsnrtombs): Add casts to avoid warnings. * wcsmbs/mbsnrtowcs.c: Add casts to avoid warnings. * wcsmbs/wcsrtombs.c (__wcsrtombs): Add casts to avoid warnings. * wcsmbs/wcrtomb.c (__wcrtomb): Add casts to avoid warnings. * wcsmbs/mbrtowc.c (__mbrtowc): Use unsigned char for outbuf. * posix/regex_internal.c [_LIBC] (build_wcs_buffer): Avoid using dynamically sized array. (build_wcs_upper_buffer): Likewise.
* (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.Ulrich Drepper2004-12-221-48/+25
|
* 2.5-18.1Jakub Jelinek2007-07-121-25/+48
|
* * time/mktime.c (__mktime_internal): If SEC_REQUESTED != SEC,Roland McGrath2004-12-021-1/+2
| | | | | | | | convert T2, not T. * time/Makefile (tests): Add tst-mktime3. * time/tst-mktime3.c: New test. 2004-12-01 Jakub Jelinek <jakub@redhat.com>
* [BZ #541]Roland McGrath2004-11-111-15/+31
| | | | | | | | | | 2004-11-10 Paul Eggert <eggert@cs.ucla.edu> [BZ #541] * time/mktime.c (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>.
* [BZ #473, BZ #487]Roland McGrath2004-11-011-126/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2004-10-27 Derek R. Price <derek@ximbiot.com> [BZ #487] This change is imported from gnulib. * time/mktime.c (not_equal_tm) [DEBUG]: Remove redundant check. 2004-10-24 Paul Eggert <eggert@cs.ucla.edu> [BZ #473] * time/tst-mktime.c (main): Don't assume that mktime fails when given time stamps before 1970. It returns negative time_t values instead, for compatibility with BSD. * time/tst-mktime2.c: New file. * time/Makefile (tests): Add it. [BZ #473] Import from gnulib. Revamp to avoid several problems near time_t extrema, and on hosts with 64-bit time_t and 32-bit int. This fixes Debian bug 177940. * time/mktime.c (TIME_T_MIDPOINT): New macro. (ydhms_diff): Renamed from ydhms_tm_diff, with a new signature, which avoids overflow problems on hosts with 64-bit time_t and 32-bit int. All callers changed. Now an inline function. Verify at compile-time that long int is wide enough to avoid these overflow problems. (guess_time_tm): New function. (__mktime_internal): Use it. Avoid overflow when computing yday on hosts with 64-bit long and 32-bit int. Remove tests for 69; no longer needed. Use if rather than #ifdef for LEAP_SECONDS_POSSIBLE so that the code is checked by more compilers. Do not rely on floating point to probe: stick to integer arithmetic, to avoid potential porting problems. Repair potential overflow correctly in the Southern Hemisphere. (localtime_offset): Add a FIXME for the case where time_t is unsigned.
* [BZ #471] Fix imported from gnulib.Roland McGrath2004-10-221-3/+4
| | | | | | | | | * time/mktime.c (leapyear, ydms_tm_diff): Year is of type long int, not int, to avoid problems when tm_year == INT_MAX and tm_mon > 12. (__mktime_intenral): Compute year using long int arithmetic, not int arithmetic, to avoid problems on hosts where time_t and long are 64 bits but int is 32.
* [BZ #468] Import a fix from gnulib.Roland McGrath2004-10-221-1/+1
| | | | | * time/mktime.c [! DEBUG]: Do not include <string.h>. It's needed only if DEBUG is nonzero.