diff --git a/Makefile b/Makefile index 6edc73cc..0e56af89 100644 --- a/Makefile +++ b/Makefile @@ -353,6 +353,7 @@ GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ # functions to be added to the time conversion library. # "offtime" is like "gmtime" except that it accepts a second (long) argument # that gives an offset to add to the time_t when converting it. +# "offtime_r" is to "offtime" what "gmtime_r" is to "gmtime". # "timelocal" is equivalent to "mktime". # "timeoff" is like "timegm" except that it accepts a second (long) argument # that gives an offset to use when converting to a time_t. diff --git a/localtime.c b/localtime.c index 818d58f8..585dfe13 100644 --- a/localtime.c +++ b/localtime.c @@ -1704,14 +1704,19 @@ gmtime(const time_t *timep) #if STD_INSPIRED struct tm * -offtime(const time_t *timep, long offset) +offtime_r(time_t const *restrict timep, long offset, struct tm *restrict tmp) { gmtcheck(); + return gmtsub(gmtptr, timep, offset, tmp); +} +struct tm * +offtime(const time_t *timep, long offset) +{ #if !SUPPORT_C89 static struct tm tm; #endif - return gmtsub(gmtptr, timep, offset, &tm); + return offtime_r(timep, offset, &tm); } #endif diff --git a/private.h b/private.h index 838ab2b2..5a1dbb02 100644 --- a/private.h +++ b/private.h @@ -626,6 +626,8 @@ typedef time_tz tz_time_t; # define mktime_z tz_mktime_z # undef offtime # define offtime tz_offtime +# undef offtime_r +# define offtime_r tz_offtime_r # undef posix2time # define posix2time tz_posix2time # undef posix2time_z @@ -750,6 +752,9 @@ extern long altzone; # if TZ_TIME_T || !defined offtime struct tm *offtime(time_t const *, long); # endif +# if TZ_TIME_T || !defined offtime_r +struct tm *offtime_r(time_t const *, long, struct tm *); +# endif # if TZ_TIME_T || !defined timelocal time_t timelocal(struct tm *); # endif