diff options
author | hobbs <hobbs> | 2005-05-30 01:36:35 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2005-05-30 01:36:35 (GMT) |
commit | d12a2d20059a5e4ff46fbf8a93cf1170f5862c33 (patch) | |
tree | 12c13b3a1ece58b84e228ef2ae648192d1c4717f /win/tclWinThrd.c | |
parent | 71b7a083e1bc15a4781e943883921eaa1440a346 (diff) | |
download | tcl-d12a2d20059a5e4ff46fbf8a93cf1170f5862c33.zip tcl-d12a2d20059a5e4ff46fbf8a93cf1170f5862c33.tar.gz tcl-d12a2d20059a5e4ff46fbf8a93cf1170f5862c33.tar.bz2 |
* win/tclWinThrd.c (TclpFinalizeThreadData): move tlsKey defn
to top of file and clarify name (was 'key'). [Bug 1204064]
Diffstat (limited to 'win/tclWinThrd.c')
-rw-r--r-- | win/tclWinThrd.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 953a154..e82b26a 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.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: tclWinThrd.c,v 1.24.2.10 2005/04/07 11:29:33 vasiljevic Exp $ + * RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.11 2005/05/30 01:36:53 hobbs Exp $ */ #include "tclWinInt.h" @@ -88,6 +88,20 @@ static Tcl_ThreadDataKey dataKey; #endif /* TCL_THREADS */ /* + * Additions by AOL for specialized thread memory allocator. + */ + +#if defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG) +static int once; +static DWORD tlsKey; + +typedef struct allocMutex { + Tcl_Mutex tlock; + CRITICAL_SECTION wlock; +} allocMutex; +#endif + +/* * State bits for the thread. * WIN_THREAD_UNINIT Uninitialized. Must be zero because * of the way ThreadSpecificData is created. @@ -685,10 +699,10 @@ TclpFinalizeThreadData(keyPtr) result = (VOID *)TlsGetValue(*indexPtr); if (result != NULL) { #if defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG) - if (indexPtr == &key) { - TclpFreeAllocCache(result); - return; - } + if (indexPtr == &tlsKey) { + TclpFreeAllocCache(result); + return; + } #endif ckfree((char *)result); success = TlsSetValue(*indexPtr, (void *)NULL); @@ -1042,14 +1056,6 @@ TclpFinalizeCondition(condPtr) */ #if defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG) -static int once; -static DWORD key; - -typedef struct allocMutex { - Tcl_Mutex tlock; - CRITICAL_SECTION wlock; -} allocMutex; - Tcl_Mutex * TclpNewAllocMutex(void) { @@ -1085,14 +1091,14 @@ TclpGetAllocCache(void) * on each thread that calls this, but only on threads that * call this. */ - key = TlsAlloc(); + tlsKey = TlsAlloc(); once = 1; - if (key == TLS_OUT_OF_INDEXES) { + if (tlsKey == TLS_OUT_OF_INDEXES) { panic("could not allocate thread local storage"); } } - result = TlsGetValue(key); + result = TlsGetValue(tlsKey); if ((result == NULL) && (GetLastError() != NO_ERROR)) { panic("TlsGetValue failed from TclpGetAllocCache!"); } @@ -1103,7 +1109,7 @@ void TclpSetAllocCache(void *ptr) { BOOL success; - success = TlsSetValue(key, ptr); + success = TlsSetValue(tlsKey, ptr); if (!success) { panic("TlsSetValue failed from TclpSetAllocCache!"); } @@ -1119,7 +1125,7 @@ TclpFreeAllocCache(void *ptr) * Called by the pthread lib when a thread exits */ TclFreeAllocCache(ptr); - success = TlsSetValue(key, NULL); + success = TlsSetValue(tlsKey, NULL); if (!success) { panic("TlsSetValue failed from TclpFreeAllocCache!"); } @@ -1127,8 +1133,8 @@ TclpFreeAllocCache(void *ptr) /* * Called by us in TclFinalizeThreadAlloc() during * the library finalization initiated from Tcl_Finalize() - */ - success = TlsFree(key); + */ + success = TlsFree(tlsKey); if (!success) { Tcl_Panic("TlsFree failed from TclpFreeAllocCache!"); } |