# HG changeset patch # User Paul Eggert # Date 1462129837 25200 # Node ID e04e8b486f7093be7ff498f67c998fc039e3d1f7 # Parent 8b34efae5441109386df89977c033e940687e626 mktime: simplify DEBUG_MKTIME * lib/mktime.c (DEBUG_MKTIME): Define to 0 if not defined. Simplify later usage accordingly. diff -r 8b34efae5441 -r e04e8b486f70 ChangeLog --- a/ChangeLog Sun May 01 11:44:51 2016 -0700 +++ b/ChangeLog Sun May 01 12:10:37 2016 -0700 @@ -1,11 +1,16 @@ 2016-05-01 Paul Eggert + mktime: simplify DEBUG_MKTIME + * lib/mktime.c (DEBUG_MKTIME): Define to 0 if not defined. + Simplify later usage accordingly. + 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. diff -r 8b34efae5441 -r e04e8b486f70 lib/mktime.c --- a/lib/mktime.c Sun May 01 11:44:51 2016 -0700 +++ b/lib/mktime.c Sun May 01 12:10:37 2016 -0700 @@ -17,9 +17,11 @@ License along with the GNU C Library; if not, see . */ -/* Define this to have a standalone program to test this implementation of +/* Define this to 1 to have a standalone program to test this implementation of mktime. */ -/* #define DEBUG_MKTIME 1 */ +#ifndef DEBUG_MKTIME +# define DEBUG_MKTIME 0 +#endif #ifndef _LIBC # include @@ -40,13 +42,13 @@ #include #include -#if defined DEBUG_MKTIME && DEBUG_MKTIME +#if DEBUG_MKTIME # include # include /* Make it work even if the system's libc has its own mktime routine. */ # undef mktime # define mktime my_mktime -#endif /* DEBUG_MKTIME */ +#endif /* Some of the code in this file assumes that signed integer overflow silently wraps around. This assumption can't easily be programmed @@ -545,7 +547,7 @@ libc_hidden_weak (timelocal) #endif -#if defined DEBUG_MKTIME && DEBUG_MKTIME +#if DEBUG_MKTIME static int not_equal_tm (const struct tm *a, const struct tm *b)