summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.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 /unix/tclUnixThrd.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 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 0cb4b5d..63e8733 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -5,11 +5,12 @@
*
* Copyright (c) 1991-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 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: tclUnixThrd.c,v 1.57 2008/01/11 11:53:02 msofer Exp $
+ * RCS: @(#) $Id: tclUnixThrd.c,v 1.58 2008/05/09 04:58:54 georgeps Exp $
*/
#include "tclInt.h"
@@ -851,6 +852,48 @@ TclpSetAllocCache(
pthread_setspecific(key, arg);
}
#endif /* USE_THREAD_ALLOC */
+
+
+
+void *TclpThreadCreateKey(void) {
+ pthread_key_t *key;
+
+ key = TclpSysAlloc(sizeof *key, 0);
+ if (NULL == key) {
+ Tcl_Panic("unable to allocate thread key!");
+ }
+
+ if (pthread_key_create(key, NULL)) {
+ Tcl_Panic("unable to create pthread key!");
+ }
+
+ return key;
+}
+
+void TclpThreadDeleteKey(void *keyPtr) {
+ pthread_key_t *key = keyPtr;
+
+ if (pthread_key_delete(*key)) {
+ Tcl_Panic("unable to delete key!");
+ }
+
+ TclpSysFree(keyPtr);
+}
+
+void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr) {
+ pthread_key_t *key = tsdKeyPtr;
+
+ if (pthread_setspecific(*key, ptr)) {
+ Tcl_Panic("unable to set master TSD value");
+ }
+}
+
+void *TclpThreadGetMasterTSD(void *tsdKeyPtr) {
+ pthread_key_t *key = tsdKeyPtr;
+
+ return pthread_getspecific(*key);
+}
+
#endif /* TCL_THREADS */
/*