diff options
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r-- | generic/tclThread.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c index 8384107..46e4139 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -5,6 +5,7 @@ * 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. @@ -24,7 +25,7 @@ typedef struct { int num; /* Number of objects remembered */ int max; /* Max size of the array */ - char **list; /* List of pointers */ + void **list; /* List of pointers */ } SyncObjRecord; static SyncObjRecord keyRecord = {0, 0, NULL}; @@ -35,8 +36,8 @@ static SyncObjRecord condRecord = {0, 0, NULL}; * Prototypes of functions used only in this file. */ -static void ForgetSyncObject(char *objPtr, SyncObjRecord *recPtr); -static void RememberSyncObject(char *objPtr, +static void ForgetSyncObject(void *objPtr, SyncObjRecord *recPtr); +static void RememberSyncObject(void *objPtr, SyncObjRecord *recPtr); /* @@ -82,21 +83,22 @@ Tcl_GetThreadData( /* * Initialize the key for this thread. */ - result = TclpThreadDataKeyGet(keyPtr); + result = TclThreadStorageKeyGet(keyPtr); if (result == NULL) { - result = ckalloc((size_t) size); + result = ckalloc((size_t)size); memset(result, 0, (size_t) size); - TclpThreadDataKeySet(keyPtr, result); + TclThreadStorageKeySet(keyPtr, result); } #else /* TCL_THREADS */ if (*keyPtr == NULL) { - result = ckalloc((size_t) size); - memset(result, 0, (size_t) size); - *keyPtr = (Tcl_ThreadDataKey)result; - RememberSyncObject((char *) keyPtr, &keyRecord); + result = ckalloc((size_t)size); + memset(result, 0, (size_t)size); + *keyPtr = result; + RememberSyncObject(keyPtr, &keyRecord); + } else { + result = *keyPtr; } - result = * (void **) keyPtr; #endif /* TCL_THREADS */ return result; } @@ -120,17 +122,15 @@ 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 */ } - /* *---------------------------------------------------------------------- @@ -153,10 +153,10 @@ TclThreadDataKeyGet( static void RememberSyncObject( - char *objPtr, /* Pointer to sync object */ + void *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { - char **newList; + void **newList; int i, j; @@ -178,7 +178,7 @@ RememberSyncObject( if (recPtr->num >= recPtr->max) { recPtr->max += 8; - newList = (char **) ckalloc(recPtr->max * sizeof(char *)); + newList = (void **) ckalloc(recPtr->max * sizeof(void *)); for (i=0,j=0 ; i<recPtr->num ; i++) { if (recPtr->list[i] != NULL) { newList[j++] = recPtr->list[i]; @@ -214,7 +214,7 @@ RememberSyncObject( static void ForgetSyncObject( - char *objPtr, /* Pointer to sync object */ + void *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { int i; @@ -248,7 +248,7 @@ void TclRememberMutex( Tcl_Mutex *mutexPtr) { - RememberSyncObject((char *)mutexPtr, &mutexRecord); + RememberSyncObject(mutexPtr, &mutexRecord); } /* @@ -276,7 +276,7 @@ Tcl_MutexFinalize( TclpFinalizeMutex(mutexPtr); #endif TclpMasterLock(); - ForgetSyncObject((char *) mutexPtr, &mutexRecord); + ForgetSyncObject(mutexPtr, &mutexRecord); TclpMasterUnlock(); } @@ -301,7 +301,7 @@ void TclRememberCondition( Tcl_Condition *condPtr) { - RememberSyncObject((char *) condPtr, &condRecord); + RememberSyncObject(condPtr, &condRecord); } /* @@ -329,7 +329,7 @@ Tcl_ConditionFinalize( TclpFinalizeCondition(condPtr); #endif TclpMasterLock(); - ForgetSyncObject((char *) condPtr, &condRecord); + ForgetSyncObject(condPtr, &condRecord); TclpMasterUnlock(); } @@ -353,7 +353,7 @@ Tcl_ConditionFinalize( void TclFinalizeThreadData(void) { - TclpFinalizeThreadDataThread(); + TclFinalizeThreadDataThread(); } /* @@ -394,7 +394,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); @@ -402,7 +402,7 @@ TclFinalizeSynchronization(void) } keyRecord.max = 0; keyRecord.num = 0; - + #ifdef TCL_THREADS /* * Call thread storage master cleanup. @@ -493,7 +493,7 @@ void Tcl_ConditionWait( Tcl_Condition *condPtr, /* Really (pthread_cond_t **) */ Tcl_Mutex *mutexPtr, /* Really (pthread_mutex_t **) */ - Tcl_Time *timePtr) /* Timeout on waiting period */ + const Tcl_Time *timePtr) /* Timeout on waiting period */ { } |