diff options
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r-- | generic/tclThread.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c index 8c972a8..d6b5bcb 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -5,7 +5,6 @@ * 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. @@ -25,7 +24,7 @@ typedef struct { int num; /* Number of objects remembered */ int max; /* Max size of the array */ - void **list; /* List of pointers */ + char **list; /* List of pointers */ } SyncObjRecord; static SyncObjRecord keyRecord = {0, 0, NULL}; @@ -36,8 +35,8 @@ static SyncObjRecord condRecord = {0, 0, NULL}; * Prototypes of functions used only in this file. */ -static void ForgetSyncObject(void *objPtr, SyncObjRecord *recPtr); -static void RememberSyncObject(void *objPtr, +static void ForgetSyncObject(char *objPtr, SyncObjRecord *recPtr); +static void RememberSyncObject(char *objPtr, SyncObjRecord *recPtr); /* @@ -83,23 +82,21 @@ Tcl_GetThreadData( /* * Initialize the key for this thread. */ - - result = TclThreadStorageKeyGet(keyPtr); + result = TclpThreadDataKeyGet(keyPtr); if (result == NULL) { - result = ckalloc(size); + result = ckalloc((size_t) size); memset(result, 0, (size_t) size); - TclThreadStorageKeySet(keyPtr, result); + TclpThreadDataKeySet(keyPtr, result); } #else /* TCL_THREADS */ if (*keyPtr == NULL) { - result = ckalloc(size); - memset(result, 0, (size_t)size); - *keyPtr = result; - RememberSyncObject(keyPtr, &keyRecord); - } else { - result = *keyPtr; + result = ckalloc((size_t) size); + memset(result, 0, (size_t) size); + *keyPtr = (Tcl_ThreadDataKey)result; + RememberSyncObject((char *) keyPtr, &keyRecord); } + result = * (void **) keyPtr; #endif /* TCL_THREADS */ return result; } @@ -123,15 +120,17 @@ Tcl_GetThreadData( void * TclThreadDataKeyGet( - Tcl_ThreadDataKey *keyPtr) /* Identifier for the data chunk. */ - + Tcl_ThreadDataKey *keyPtr) /* Identifier for the data chunk, really + * (pthread_key_t **) */ { #ifdef TCL_THREADS - return TclThreadStorageKeyGet(keyPtr); + return TclpThreadDataKeyGet(keyPtr); #else /* TCL_THREADS */ - return *keyPtr; + char *result = *(char **) keyPtr; + return result; #endif /* TCL_THREADS */ } + /* *---------------------------------------------------------------------- @@ -154,10 +153,10 @@ TclThreadDataKeyGet( static void RememberSyncObject( - void *objPtr, /* Pointer to sync object */ + char *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { - void **newList; + char **newList; int i, j; @@ -179,14 +178,14 @@ RememberSyncObject( if (recPtr->num >= recPtr->max) { recPtr->max += 8; - newList = ckalloc(recPtr->max * sizeof(void *)); + newList = (char **) ckalloc(recPtr->max * sizeof(char *)); for (i=0,j=0 ; i<recPtr->num ; i++) { if (recPtr->list[i] != NULL) { newList[j++] = recPtr->list[i]; } } if (recPtr->list != NULL) { - ckfree(recPtr->list); + ckfree((char *) recPtr->list); } recPtr->list = newList; recPtr->num = j; @@ -215,7 +214,7 @@ RememberSyncObject( static void ForgetSyncObject( - void *objPtr, /* Pointer to sync object */ + char *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { int i; @@ -249,7 +248,7 @@ void TclRememberMutex( Tcl_Mutex *mutexPtr) { - RememberSyncObject(mutexPtr, &mutexRecord); + RememberSyncObject((char *)mutexPtr, &mutexRecord); } /* @@ -277,7 +276,7 @@ Tcl_MutexFinalize( TclpFinalizeMutex(mutexPtr); #endif TclpMasterLock(); - ForgetSyncObject(mutexPtr, &mutexRecord); + ForgetSyncObject((char *) mutexPtr, &mutexRecord); TclpMasterUnlock(); } @@ -302,7 +301,7 @@ void TclRememberCondition( Tcl_Condition *condPtr) { - RememberSyncObject(condPtr, &condRecord); + RememberSyncObject((char *) condPtr, &condRecord); } /* @@ -330,7 +329,7 @@ Tcl_ConditionFinalize( TclpFinalizeCondition(condPtr); #endif TclpMasterLock(); - ForgetSyncObject(condPtr, &condRecord); + ForgetSyncObject((char *) condPtr, &condRecord); TclpMasterUnlock(); } @@ -355,7 +354,7 @@ Tcl_ConditionFinalize( void TclFinalizeThreadData(void) { - TclFinalizeThreadDataThread(); + TclpFinalizeThreadDataThread(); #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) TclFinalizeThreadAllocThread(); #endif @@ -399,15 +398,15 @@ TclFinalizeSynchronization(void) if (keyRecord.list != NULL) { for (i=0 ; i<keyRecord.num ; i++) { keyPtr = (Tcl_ThreadDataKey *) keyRecord.list[i]; - blockPtr = *keyPtr; + blockPtr = (void *) *keyPtr; ckfree(blockPtr); } - ckfree(keyRecord.list); + ckfree((char *) keyRecord.list); keyRecord.list = NULL; } keyRecord.max = 0; keyRecord.num = 0; - + #ifdef TCL_THREADS /* * Call thread storage master cleanup. @@ -422,7 +421,7 @@ TclFinalizeSynchronization(void) } } if (mutexRecord.list != NULL) { - ckfree(mutexRecord.list); + ckfree((char *) mutexRecord.list); mutexRecord.list = NULL; } mutexRecord.max = 0; @@ -435,7 +434,7 @@ TclFinalizeSynchronization(void) } } if (condRecord.list != NULL) { - ckfree(condRecord.list); + ckfree((char *) condRecord.list); condRecord.list = NULL; } condRecord.max = 0; @@ -498,7 +497,7 @@ void Tcl_ConditionWait( Tcl_Condition *condPtr, /* Really (pthread_cond_t **) */ Tcl_Mutex *mutexPtr, /* Really (pthread_mutex_t **) */ - const Tcl_Time *timePtr) /* Timeout on waiting period */ + Tcl_Time *timePtr) /* Timeout on waiting period */ { } |