summaryrefslogtreecommitdiffstats
path: root/generic/tclThread.c
diff options
context:
space:
mode:
authorJoe Mistachkin <joe@mistachkin.com>2004-06-24 01:29:02 (GMT)
committerJoe Mistachkin <joe@mistachkin.com>2004-06-24 01:29:02 (GMT)
commit29cd385014b7d98f9e1209da72adade7679e3cf2 (patch)
tree0b6812d3b041207d523101080164445b27a293f1 /generic/tclThread.c
parentbef0b360b4ebda09db57f196d096f72baf469670 (diff)
downloadtcl-29cd385014b7d98f9e1209da72adade7679e3cf2.zip
tcl-29cd385014b7d98f9e1209da72adade7679e3cf2.tar.gz
tcl-29cd385014b7d98f9e1209da72adade7679e3cf2.tar.bz2
Version 5 of [Patch 976496]
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r--generic/tclThread.c41
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) {