From d12a2d20059a5e4ff46fbf8a93cf1170f5862c33 Mon Sep 17 00:00:00 2001 From: hobbs Date: Mon, 30 May 2005 01:36:35 +0000 Subject: * win/tclWinThrd.c (TclpFinalizeThreadData): move tlsKey defn to top of file and clarify name (was 'key'). [Bug 1204064] --- ChangeLog | 5 +++++ win/tclWinThrd.c | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8077a6d..5d094da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-29 Jeff Hobbs + + * win/tclWinThrd.c (TclpFinalizeThreadData): move tlsKey defn + to top of file and clarify name (was 'key'). [Bug 1204064] + 2005-05-27 Jeff Hobbs * README: Bumped patchlevel to 8.4.10 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!"); } -- cgit v0.12