diff options
author | Kevin B Kenny <kennykb@acm.org> | 2004-05-14 21:41:04 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2004-05-14 21:41:04 (GMT) |
commit | 41107396231ee836612ef83c6b7b17324292171d (patch) | |
tree | c43bfd28868eb27530e825eb959a36371420aeb7 /win/tclWinTime.c | |
parent | 50c5a3a608df08ee498af5471cbb007b3332c7d1 (diff) | |
download | tcl-41107396231ee836612ef83c6b7b17324292171d.zip tcl-41107396231ee836612ef83c6b7b17324292171d.tar.gz tcl-41107396231ee836612ef83c6b7b17324292171d.tar.bz2 |
2004-05-14 Kevin B. Kenny <kennykb@acm.org>
* generic/tclInt.decls: Promoted TclpLocaltime and TclpGmtime
* generic/tclIntDecls.h: from Unix-specific stubs to the generic
* generic/tclIntPlatDecls.h: internal Stubs table. Reran 'genstubs'
* generic/tclStubInit.c:
* unix/tclUnixPort.h:
* generic/tclClock.c: Changed a buggy 'GMT' timezone specification
to the correct 'GMT0'. [Bug #922848]
* unix/tclUnixThrd.c: Moved TclpGmtime and TclpLocaltime to
unix/tclUnixTime.c where they belong.
* unix/tclUnixTime.c (TclpGmtime, TclpLocaltime, TclpGetTimeZone,
ThreadSafeGMTime [removed],
ThreadSafeLocalTime [removed],
SetTZIfNecessary, CleanupMemory):
Restructured to make sure that the same mutex protects
all calls to localtime, gmtime, and tzset. Added a check
in front of those calls to make sure that the TZ env var
hasn't changed since the last call to tzset, and repeat
tzset if necessary. [Bug #942078] Removed a buggy test
of the Daylight Saving Time information in 'gettimeofday'
in favor of applying 'localtime' to a known value.
[Bug #922848]
* tests/clock.test (clock-3.14): Added test to make sure that
changes to $env(TZ) take effect immediately.
* win/tclWinTime.c (TclpLocaltime, TclpGmtime):
Added porting layer for 'localtime' and 'gmtime' calls.
Diffstat (limited to 'win/tclWinTime.c')
-rw-r--r-- | win/tclWinTime.c | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 6bc7b10..539dd6c 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinTime.c,v 1.14.2.2 2003/04/15 21:06:36 kennykb Exp $ + * RCS: @(#) $Id: tclWinTime.c,v 1.14.2.3 2004/05/14 21:41:12 kennykb Exp $ */ #include "tclWinInt.h" @@ -1053,3 +1053,65 @@ AccumulateSample( Tcl_WideInt perfCounter, return estFreq; } } + +/* + *---------------------------------------------------------------------- + * + * TclpGmtime -- + * + * Wrapper around the 'gmtime' library function to make it thread + * safe. + * + * Results: + * Returns a pointer to a 'struct tm' in thread-specific data. + * + * Side effects: + * Invokes gmtime or gmtime_r as appropriate. + * + *---------------------------------------------------------------------- + */ + +struct tm * +TclpGmtime( timePtr ) + CONST time_t *timePtr; /* Pointer to the number of seconds + * since the local system's epoch */ + +{ + /* + * The MS implementation of gmtime is thread safe because + * it returns the time in a block of thread-local storage, + * and Windows does not provide a Posix gmtime_r function. + */ + return gmtime( timePtr ); +} + +/* + *---------------------------------------------------------------------- + * + * TclpLocaltime -- + * + * Wrapper around the 'localtime' library function to make it thread + * safe. + * + * Results: + * Returns a pointer to a 'struct tm' in thread-specific data. + * + * Side effects: + * Invokes localtime or localtime_r as appropriate. + * + *---------------------------------------------------------------------- + */ + +struct tm * +TclpLocaltime( timePtr ) + CONST time_t *timePtr; /* Pointer to the number of seconds + * since the local system's epoch */ + +{ + /* + * The MS implementation of localtime is thread safe because + * it returns the time in a block of thread-local storage, + * and Windows does not provide a Posix localtime_r function. + */ + return localtime( timePtr ); +} |