X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmktime.c;h=3dab58ad813fa1645500f938e872b28b7e9b0ad1;hb=b3b353659ac863c94e9705047710a99fa58fe0b1;hp=02acc5206797b0bb93bb04f5dd4cdfa41e9b7589;hpb=c80984f8e3a13a265c826301e53585ad87bd761b;p=gnulib.git diff --git a/lib/mktime.c b/lib/mktime.c index 02acc5206..3dab58ad8 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -25,10 +25,6 @@ # include #endif -#ifdef _LIBC -# define STDC_HEADERS 1 -#endif - /* Assume that leap seconds are possible, unless told otherwise. If the host has a `zic' command with a `-L leapsecondfilename' option, then it supports leap seconds; otherwise it probably doesn't. */ @@ -43,10 +39,8 @@ #if DEBUG # include -# if STDC_HEADERS -# include -# include -# endif +# include +# include /* Make it work even if the system's libc has its own mktime routine. */ # define mktime my_mktime #endif /* DEBUG */ @@ -106,22 +100,15 @@ const unsigned short int __mon_yday[2][13] = }; -#ifdef _LIBC -# define my_mktime_localtime_r __localtime_r -#else -/* If we're a mktime substitute in a GNU program, then prefer - localtime to localtime_r, since many localtime_r implementations - are buggy. */ -static struct tm * -my_mktime_localtime_r (const time_t *t, struct tm *tp) -{ - struct tm *l = localtime (t); - if (! l) - return 0; - *tp = *l; - return tp; -} -#endif /* ! _LIBC */ +#ifndef _LIBC +/* Portable standalone applications should supply a "time_r.h" that + declares a POSIX-compliant localtime_r, for the benefit of older + implementations that lack localtime_r or have a nonstandard one. + See the gnulib time_r module for one way to implement this. */ +# include "time_r.h" +# undef __localtime_r +# define __localtime_r localtime_r +#endif /* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks @@ -244,9 +231,6 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), Use *OFFSET to keep track of a guess at the offset of the result, compared to what the result would be for UTC without leap seconds. If *OFFSET's guess is correct, only one CONVERT call is needed. */ -#ifndef _LIBC -static -#endif time_t __mktime_internal (struct tm *tp, struct tm *(*convert) (const time_t *, struct tm *), @@ -486,7 +470,7 @@ mktime (struct tm *tp) __tzset (); #endif - return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); + return __mktime_internal (tp, __localtime_r, &localtime_offset); } #ifdef weak_alias @@ -635,6 +619,6 @@ main (int argc, char **argv) /* Local Variables: -compile-command: "gcc -DDEBUG -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime" +compile-command: "gcc -DDEBUG -Wall -W -O -g mktime.c -o mktime" End: */