diff options
author | mistachkin <mistachkin@noemail.net> | 2004-06-24 01:29:01 (GMT) |
---|---|---|
committer | mistachkin <mistachkin@noemail.net> | 2004-06-24 01:29:01 (GMT) |
commit | 4bb48ce5b00f0b32b8882be080878e1a78cd3c6f (patch) | |
tree | 0b6812d3b041207d523101080164445b27a293f1 /generic/tclThread.c | |
parent | 17588e267f1685a2e103026b47c6e314f6d4a3ac (diff) | |
download | tcl-4bb48ce5b00f0b32b8882be080878e1a78cd3c6f.zip tcl-4bb48ce5b00f0b32b8882be080878e1a78cd3c6f.tar.gz tcl-4bb48ce5b00f0b32b8882be080878e1a78cd3c6f.tar.bz2 |
Version 5 of [Patch 976496]
FossilOrigin-Name: 6d178830b81c01d342d2ce36817551611136302b
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r-- | generic/tclThread.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c index 4a2d4b8..7cc8b68 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.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: tclThread.c,v 1.7 2004/04/23 07:21:36 davygrvy Exp $ + * RCS: @(#) $Id: tclThread.c,v 1.8 2004/06/24 01:29:02 mistachkin Exp $ */ #include "tclInt.h" @@ -89,18 +89,30 @@ Tcl_GetThreadData(keyPtr, size) */ if (*keyPtr == NULL) { +#ifdef USE_THREAD_STORAGE + TclThreadStorageDataKeyInit(keyPtr); +#else TclpThreadDataKeyInit(keyPtr); +#endif } /* * Initialize the key for this thread. */ - +#ifdef USE_THREAD_STORAGE + result = TclThreadStorageDataKeyGet(keyPtr); +#else result = TclpThreadDataKeyGet(keyPtr); +#endif + if (result == NULL) { result = (VOID *)ckalloc((size_t)size); memset(result, 0, (size_t)size); +#ifdef USE_THREAD_STORAGE + TclThreadStorageDataKeySet(keyPtr, result); +#else TclpThreadDataKeySet(keyPtr, result); +#endif } #else if (*keyPtr == NULL) { @@ -137,7 +149,11 @@ TclThreadDataKeyGet(keyPtr) * really (pthread_key_t **) */ { #ifdef TCL_THREADS +#ifdef USE_THREAD_STORAGE + return (VOID *)TclThreadStorageDataKeyGet(keyPtr); +#else return (VOID *)TclpThreadDataKeyGet(keyPtr); +#endif #else char *result = *(char **)keyPtr; return (VOID *)result; @@ -169,9 +185,17 @@ TclThreadDataKeySet(keyPtr, data) { #ifdef TCL_THREADS if (*keyPtr == NULL) { +#ifdef USE_THREAD_STORAGE + TclThreadStorageDataKeyInit(keyPtr); +#else TclpThreadDataKeyInit(keyPtr); +#endif } +#ifdef USE_THREAD_STORAGE + TclThreadStorageDataKeySet(keyPtr, data); +#else TclpThreadDataKeySet(keyPtr, data); +#endif #else *keyPtr = (Tcl_ThreadDataKey)data; #endif /* TCL_THREADS */ @@ -409,7 +433,11 @@ TclFinalizeThreadData() for (i=0 ; i<keyRecord.num ; i++) { keyPtr = (Tcl_ThreadDataKey *) keyRecord.list[i]; #ifdef TCL_THREADS +#ifdef USE_THREAD_STORAGE + TclFinalizeThreadStorageData(keyPtr); +#else TclpFinalizeThreadData(keyPtr); +#endif #else if (*keyPtr != NULL) { ckfree((char *)*keyPtr); @@ -449,7 +477,11 @@ TclFinalizeSynchronization() TclpMasterLock(); for (i=0 ; i<keyRecord.num ; i++) { keyPtr = (Tcl_ThreadDataKey *)keyRecord.list[i]; +#ifdef USE_THREAD_STORAGE + TclFinalizeThreadStorageDataKey(keyPtr); +#else TclpFinalizeThreadDataKey(keyPtr); +#endif } if (keyRecord.list != NULL) { ckfree((char *)keyRecord.list); @@ -458,6 +490,11 @@ TclFinalizeSynchronization() keyRecord.max = 0; keyRecord.num = 0; +#ifdef USE_THREAD_STORAGE + /* call platform specific thread storage master cleanup */ + TclFinalizeThreadStorage(); +#endif + for (i=0 ; i<mutexRecord.num ; i++) { mutexPtr = (Tcl_Mutex *)mutexRecord.list[i]; if (mutexPtr != NULL) { |