about summary refs log tree commit diff
path: root/time/mktime-internal.h
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-021-1/+1
| | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-011-1/+1
|
* Make mktime etc. compatible with __time64_tPaul Eggert2019-04-301-1/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep these functions compatible with Gnulib while adding __time64_t support. The basic idea is to move private API declarations from include/time.h to time/mktime-internal.h, since the former file cannot easily be shared with Gnulib whereas the latter can. Also, do some other minor cleanup while in the neighborhood. * include/time.h: Include stdbool.h, time/mktime-internal.h. (__mktime_internal): Move this prototype to time/mktime-internal.h, since Gnulib needs it. (__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]: Move these macros to time/mktime-internal.h, since Gnulib needs them. (__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes. (in_time_t_range): New static function. * posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]: Do not define as a macro in this case, so that portable code is less tempted to use __time64_t. * time/mktime-internal.h: Rewrite so that it does both glibc and Gnulib work. Include time.h if not _LIBC. (mktime_offset_t) [!_LIBC]: Define for gnulib. (__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64) [!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here from include/time.h. (__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]: New macros, taken from GNulib. (__mktime_internal): New prototype, moved here from include/time.h. * time/mktime.c (mktime_min, mktime_max, convert_time) (ranged_convert, __mktime_internal, __mktime64): * time/timegm.c (__timegm64): Use __time64_t, not time_t. * time/mktime.c: Stop worrying about whether time_t is floating-point. (__mktime64) [! (_LIBC && __TIMESIZE != 64)]: Rename from mktime. (mktime) [_LIBC && __TIMESIZE != 64]: New function. * time/timegm.c [!_LIBC]: Include libc-config.h, not config.h, for libc_hidden_def. Include errno.h. (__timegm64) [! (_LIBC && __TIMESIZE != 64)]: Rename from timegm. (timegm) [_LIBC && __TIMESIZE != 64]: New function. First cut at publicizing __time64_t
* Fix mktime localtime offset confusionPaul Eggert2018-09-191-1/+1
| | | | | | | | | | | [BZ #23603] * include/time.h (__mktime_internal): The localtime offset is now of type long int instead of time_t. This is the longstanding type in glibc, and it is more than enough to represent difference between localtime and gmtime even if it is 32 bits and time_t is 64. Changing it now will let us avoid an unnecessary change when time_t is widened to 64 bits on 32-bit platforms. * time/mktime-internal.h (mktime_offset_t): Now long int.
* Merge mktime, timegm from upstream GnulibPaul Eggert2018-09-191-0/+2
[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.