X-Git-Url: https://perl5.git.perl.org/metaconfig.git/blobdiff_plain/f42a43f5eb2ad1bc26e878c102450ab82cf47c8c..977977526b4e4c4555bea768e15504fd8f34f1f0:/U/threads/d_localtime_r.U?ds=sidebyside diff --git a/U/threads/d_localtime_r.U b/U/threads/d_localtime_r.U index 9926755..53fa397 100644 --- a/U/threads/d_localtime_r.U +++ b/U/threads/d_localtime_r.U @@ -1,42 +1,70 @@ ?RCS: $Id: d_localtime_r.U,v 0RCS: -?RCS: Copyright (c) 2002 Jarkko Hietaniemi +?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi +?RCS: Copyright (c) 2006,2007 H.Merijn Brand ?RCS: ?RCS: You may distribute under the terms of either the GNU General Public ?RCS: License or the Artistic License, as specified in the README file. ?RCS: ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution. ?RCS: -?MAKE:d_localtime_r localtime_r_proto: Inlibc Protochk Hasproto i_systypes i_time +?MAKE:d_localtime_r d_localtime_r_needs_tzset localtime_r_proto: Inlibc \ + cat run Protochk Hasproto i_systypes usethreads i_time i_systime \ + rm_try Compile extern_C i_stdlib i_unistd i_malloc ?MAKE: -pick add $@ %< ?S:d_localtime_r: ?S: This variable conditionally defines the HAS_LOCALTIME_R symbol, ?S: which indicates to the C program that the localtime_r() ?S: routine is available. ?S:. +?S:d_localtime_r_needs_tzset: +?S: This variable conditionally defines the LOCALTIME_R_NEEDS_TZSET +?S: symbol, which makes us call tzset before localtime_r() +?S:. ?S:localtime_r_proto: ?S: This variable encodes the prototype of localtime_r. +?S: It is zero if d_localtime_r is undef, and one of the +?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_localtime_r +?S: is defined. ?S:. ?C:HAS_LOCALTIME_R: ?C: This symbol, if defined, indicates that the localtime_r routine ?C: is available to localtime re-entrantly. ?C:. +?C:LOCALTIME_R_NEEDS_TZSET: +?C: Many libc's localtime_r implementations do not call tzset, +?C: making them differ from localtime(), and making timezone +?C: changes using \$ENV{TZ} without explicitly calling tzset +?C: impossible. This symbol makes us call tzset before localtime_r +?C:. +?H:?%<:#$d_localtime_r_needs_tzset LOCALTIME_R_NEEDS_TZSET /**/ +?H:?%<:#ifdef LOCALTIME_R_NEEDS_TZSET +?H:?%<:#define L_R_TZSET tzset(), +?H:?%<:#else +?H:?%<:#define L_R_TZSET +?H:?%<:#endif +?H:. +?C:L_R_TZSET: +?C: If localtime_r() needs tzset, it is defined in this define +?C:. ?C:LOCALTIME_R_PROTO: ?C: This symbol encodes the prototype of localtime_r. +?C: It is zero if d_localtime_r is undef, and one of the +?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_localtime_r +?C: is defined. ?C:. -?H:#$d_localtime_r HAS_LOCALTIME_R /**/ -?H:#define LOCALTIME_R_PROTO $localtime_r_proto /**/ +?H:#$d_localtime_r HAS_LOCALTIME_R /**/ +?H:#define LOCALTIME_R_PROTO $localtime_r_proto /**/ ?H:. ?T:try hdrs d_localtime_r_proto -?LINT:set d_localtime_r -?LINT:set localtime_r_proto +?F:!try : see if localtime_r exists set localtime_r d_localtime_r eval $inlibc case "$d_localtime_r" in "$define") - hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h" - case "$d_localtime_r_proto" in - '') d_localtime_r_proto=define + hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h" + case "$d_localtime_r_proto:$usethreads" in + ":define") d_localtime_r_proto=define set d_localtime_r_proto localtime_r $hdrs eval $hasproto ;; *) ;; @@ -45,15 +73,15 @@ case "$d_localtime_r" in define) case "$localtime_r_proto" in ''|0) try='struct tm* localtime_r(const time_t*, struct tm*);' - ./protochk "extern $try" $hdrs && localtime_r_proto=S_TS ;; + ./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;; esac case "$localtime_r_proto" in ''|0) try='int localtime_r(const time_t*, struct tm*);' - ./protochk "extern $try" $hdrs && localtime_r_proto=I_TS ;; + ./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;; esac case "$localtime_r_proto" in - '') d_localtime_r=undef - localtime_r_proto=0 + ''|0) d_localtime_r=undef + localtime_r_proto=0 echo "Disabling localtime_r, cannot determine prototype." >&4 ;; * ) case "$localtime_r_proto" in REENTRANT_PROTO*) ;; @@ -62,10 +90,87 @@ case "$d_localtime_r" in echo "Prototype: $try" ;; esac ;; - *) echo "You have localtime_r but no prototype, not using it." >&4 ;; + *) case "$usethreads" in + define) echo "localtime_r has no prototype, not using it." >&4 ;; + esac + d_localtime_r=undef + localtime_r_proto=0 + ;; esac ;; *) localtime_r_proto=0 ;; esac +: see if localtime_r calls tzset +case "$localtime_r_proto" in +REENTRANT_PROTO*) + $cat >try.c < +#endif +#ifdef I_UNISTD +# include +#endif +#ifdef I_TIME +# include +#endif +#ifdef I_STDLIB +#include +#endif +#include +#ifdef I_MALLOC +# include +#endif +int main() +{ + int result = 0; + time_t t = time(0L); + char w_tz[]="TZ" "=GMT+5", + e_tz[]="TZ" "=GMT-5", + *tz_e = (char*)malloc(16), + *tz_w = (char*)malloc(16); + struct tm tm_e, tm_w; + memset(&tm_e,'\0',sizeof(struct tm)); + memset(&tm_w,'\0',sizeof(struct tm)); + strcpy(tz_e,e_tz); + strcpy(tz_w,w_tz); + + putenv(tz_e); + localtime_r(&t, &tm_e); + + putenv(tz_w); + localtime_r(&t, &tm_w); + + if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 ) + result = 1; + + free(tz_e);free(tz_w); + return result; +} +EOCP + set try + if eval $compile; then + if $run ./try; then + d_localtime_r_needs_tzset=undef; + else + d_localtime_r_needs_tzset=define; + fi; + else + d_localtime_r_needs_tzset=undef; + fi; + ;; + *) + d_localtime_r_needs_tzset=undef; + ;; +esac +$rm_try +