summaryrefslogtreecommitdiffstats
path: root/generic/tclThread.c
diff options
context:
space:
mode:
authorgeorgeps <georgeps>2008-05-09 04:58:52 (GMT)
committergeorgeps <georgeps>2008-05-09 04:58:52 (GMT)
commite782414ad0af468115d69e437d0d70c5895287ff (patch)
tree2a1b16698533508941b5316630a09d07a0ffac94 /generic/tclThread.c
parent78fea2db721429cce261b5621f85f6f7390ece78 (diff)
downloadtcl-e782414ad0af468115d69e437d0d70c5895287ff.zip
tcl-e782414ad0af468115d69e437d0d70c5895287ff.tar.gz
tcl-e782414ad0af468115d69e437d0d70c5895287ff.tar.bz2
* generic/tcl.h: Make Tcl_ThreadDataKey a void *.
* generic/tclInt.h: Change around some function names and add some new per-platform declarations for thread-specific data functions. * generic/tclThread.c: Make use of of the new function names that no longer have a Tclp prefix. * generic/tclThreadStorage.c: Replace the core thread-specific data (TSD) mechanism with an array offset solution that eliminates the hash tables, and only uses one slot of native TSD. Many thanks to Kevin B. Kenny for his help with this. * unix/tclUnixThrd.c: Add platform-specific TSD functions for use by tclThreadStorage.c. * win/tclWinThrd.c: Add platform-specific TSD functions for use by tclThreadStorage.c.
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r--generic/tclThread.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c
index 1ab4bc9..1a544e3 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.c
@@ -5,11 +5,12 @@
* the real work is done in the platform dependent files.
*
* Copyright (c) 1998 by Sun Microsystems, Inc.
+ * Copyright (c) 2008 by George Peter Staplin
*
* 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.19 2007/12/13 15:23:20 dgp Exp $
+ * RCS: @(#) $Id: tclThread.c,v 1.20 2008/05/09 04:58:54 georgeps Exp $
*/
#include "tclInt.h"
@@ -84,21 +85,22 @@ Tcl_GetThreadData(
/*
* Initialize the key for this thread.
*/
- result = TclpThreadDataKeyGet(keyPtr);
+ result = TclThreadStorageKeyGet(keyPtr);
if (result == NULL) {
- result = ckalloc((size_t) size);
- memset(result, 0, (size_t) size);
- TclpThreadDataKeySet(keyPtr, result);
+ result = ckalloc((size_t)size);
+ memset(result, 0, (size_t)size);
+ TclThreadStorageKeySet(keyPtr, result);
}
#else /* TCL_THREADS */
if (*keyPtr == NULL) {
- result = ckalloc((size_t) size);
- memset(result, 0, (size_t) size);
- *keyPtr = (Tcl_ThreadDataKey)result;
+ result = ckalloc((size_t)size);
+ memset(result, 0, (size_t)size);
+ *keyPtr = result;
RememberSyncObject((char *) keyPtr, &keyRecord);
+ } else {
+ result = *keyPtr;
}
- result = * (void **) keyPtr;
#endif /* TCL_THREADS */
return result;
}
@@ -122,14 +124,13 @@ Tcl_GetThreadData(
void *
TclThreadDataKeyGet(
- Tcl_ThreadDataKey *keyPtr) /* Identifier for the data chunk, really
- * (pthread_key_t **) */
+ Tcl_ThreadDataKey *keyPtr) /* Identifier for the data chunk. */
+
{
#ifdef TCL_THREADS
- return TclpThreadDataKeyGet(keyPtr);
+ return TclThreadStorageKeyGet(keyPtr);
#else /* TCL_THREADS */
- char *result = *(char **) keyPtr;
- return result;
+ return *keyPtr;
#endif /* TCL_THREADS */
}
@@ -355,7 +356,7 @@ Tcl_ConditionFinalize(
void
TclFinalizeThreadData(void)
{
- TclpFinalizeThreadDataThread();
+ TclFinalizeThreadDataThread();
}
/*
@@ -396,7 +397,7 @@ TclFinalizeSynchronization(void)
if (keyRecord.list != NULL) {
for (i=0 ; i<keyRecord.num ; i++) {
keyPtr = (Tcl_ThreadDataKey *) keyRecord.list[i];
- blockPtr = (void *) *keyPtr;
+ blockPtr = *keyPtr;
ckfree(blockPtr);
}
ckfree((char *) keyRecord.list);