| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
| |
* config/srclist.txt: Do not sync mktime.c for now.
* lib/mktime.c (shr, ydhms_diff):
Redo with neither ‘%’ nor conditional branches.
|
| |
|
| |
|
|
|
|
|
|
| |
This is a clerical change that mostly changes http: to https: in URLs
where either will work. It also updates some URLs that have moved,
removes some URLs that no longer work, and fixes related text.
|
| |
|
|
|
|
|
| |
* lib/stat-w32.c et al.: Update URLs after most of msdn.microsoft.com
was moved to docs.microsoft.com.
|
| |
|
| |
|
| |
|
|
|
|
| |
* lib/mktime.c (mktime): Fix typo (misspelled "_LIBC").
|
|
|
|
|
|
| |
* lib/mktime.c, lib/timegm.c [_LIBC]:
Include mktime-internal.h (a small file just for glibc)
instead of using a typedef.
|
|
|
|
|
|
|
|
| |
Problem reported by Alexandre Oliva in:
https://sourceware.org/bugzilla/show_bug.cgi?id=16346
* lib/mktime.c (__mktime_internal): Access *OFFSET only once,
to avoid an unlikely race if the compiler delays a load and
if this cascades into a signed integer overflow.
|
|
|
|
|
|
|
|
|
| |
* lib/mktime.c, lib/timegm.c (mktime_offset_t) [_LIBC]:
Now long int, not time_t, since long int is the longstanding type
for this in glibc and there is no need to change it even if time_t
becomes 64 bits - even int would do, though this would be a change
to the glibc generated code. When this change is merged into
glibc, it should simplify the time_t vs time64_t situation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move code around to make a merge to glibc easier to audit.
This should not change behavior.
* lib/mktime.c: Include more standard files unconditionally.
(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. In uses
of these conditionals, explicitly spell out how _LIBC affects
things, so it’s easier to review from a glibc viewpoint.
(my_tzset, __tzset) [!_LIBC]: New function and macro, to better
compartmentalize tzset issues. Move system-dependent tzsettish
code here from mktime.
(mktime): Move tzsettish code to my_tzset, and move
localtime_offset to within mktime so that it doesn’t
need a separate ifdef.
* lib/mktime-internal.h (__gmtime_r, __localtime_r, __mktime_internal):
Move these macros here from lib/mktime.c and lib/gmtime.c.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
Use the spelling "timestamp", as that is what POSIX uses.
|
|
|
|
|
|
|
|
|
|
| |
* 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'.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
* lib/mktime.c: Fix spelling.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* lib/mktime.c [DEBUG_MKTIME]: Do not include <config.h>.
Include <string.h>, for strcmp.
|
|
|
|
|
| |
* lib/mktime.c (DEBUG_MKTIME): Define to 0 if not defined.
Simplify later usage accordingly.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* lib/mktime.c [DEBUG] (DEBUG): Rename to DEBUG_MKTIME. See:
https://sourceware.org/ml/libc-alpha/2016-01/msg00267.html
|
|
|
|
|
|
|
|
|
|
| |
* 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'.
|
|
|
|
|
|
| |
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date.
* all files: Run 'make update-copyright'.
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
| |
I ran 'make update-copyright'.
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
|
|
|
| |
Run "make update-copyright". Compare to commit 1602f0a from last year.
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
|
|
| |
* lib/mktime.c (leapyear, ydhms_diff): Now static, not static inline.
* m4/mktime.m4 (gl_PREREQ_MKTIME): Do not require AC_C_INLINE.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>.
|
|
|
|
| |
* lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems.
|
| |
|
|
|
|
| |
Run "make update-copyright".
|
|
|
|
|
|
|
| |
* 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>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
* lib/mktime.c (mktime) [DEBUG]: #undef mktime before #defining it.
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|