diff options
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r-- | unix/tclUnixThrd.c | 45 |
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 */ /* |