diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCompExpr.c | 6 | ||||
-rw-r--r-- | generic/tclEncoding.c | 10 | ||||
-rw-r--r-- | generic/tclEvent.c | 4 | ||||
-rw-r--r-- | generic/tclExecute.c | 8 | ||||
-rw-r--r-- | generic/tclHash.c | 14 | ||||
-rw-r--r-- | generic/tclIO.c | 4 | ||||
-rw-r--r-- | generic/tclInt.h | 27 | ||||
-rw-r--r-- | generic/tclProc.c | 12 | ||||
-rw-r--r-- | generic/tclTest.c | 28 | ||||
-rw-r--r-- | generic/tclThreadStorage.c | 6 | ||||
-rw-r--r-- | generic/tclTimer.c | 6 | ||||
-rw-r--r-- | generic/tclUtil.c | 8 |
12 files changed, 79 insertions, 54 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index c4d2829..81f6b3a 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompExpr.c,v 1.35 2006/11/09 16:52:30 dgp Exp $ + * RCS: @(#) $Id: tclCompExpr.c,v 1.36 2006/11/13 08:23:07 das Exp $ */ #include "tclInt.h" @@ -1246,7 +1246,7 @@ TclCompileExpr( Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(&opHashTable, operatorTable[i].name, &new); if (new) { - Tcl_SetHashValue(hPtr, (ClientData) i); + Tcl_SetHashValue(hPtr, (ClientData) INT2PTR(i)); } } opTableInitialized = 1; @@ -1387,7 +1387,7 @@ CompileSubExpr( break; } Tcl_DStringFree(&opBuf); - opIndex = (int) Tcl_GetHashValue(hPtr); + opIndex = PTR2INT(Tcl_GetHashValue(hPtr)); opDescPtr = &(operatorTable[opIndex]); /* diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 1d26c34..69c7f28 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEncoding.c,v 1.50 2006/11/02 16:14:20 dkf Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.51 2006/11/13 08:23:07 das Exp $ */ #include "tclInt.h" @@ -2760,7 +2760,7 @@ EscapeToUtfProc( dstStart = dst; dstEnd = dst + dstLen - TCL_UTF_MAX; - state = (int) *statePtr; + state = PTR2INT(*statePtr); if (flags & TCL_ENCODING_START) { state = 0; } @@ -2899,7 +2899,7 @@ EscapeToUtfProc( numChars++; } - *statePtr = (Tcl_EncodingState) state; + *statePtr = (Tcl_EncodingState) INT2PTR(state); *srcReadPtr = src - srcStart; *dstWrotePtr = dst - dstStart; *dstCharsPtr = numChars; @@ -2989,7 +2989,7 @@ EscapeFromUtfProc( memcpy((VOID *)dst, (VOID *)dataPtr->init, (size_t)dataPtr->initLen); dst += dataPtr->initLen; } else { - state = (int) *statePtr; + state = PTR2INT(*statePtr); } encodingPtr = GetTableEncoding(dataPtr, state); @@ -3103,7 +3103,7 @@ EscapeFromUtfProc( } } - *statePtr = (Tcl_EncodingState) state; + *statePtr = (Tcl_EncodingState) INT2PTR(state); *srcReadPtr = src - srcStart; *dstWrotePtr = dst - dstStart; *dstCharsPtr = numChars; diff --git a/generic/tclEvent.c b/generic/tclEvent.c index b2fc70e..8c0c34c 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEvent.c,v 1.68 2006/09/19 22:07:34 dkf Exp $ + * RCS: @(#) $Id: tclEvent.c,v 1.69 2006/11/13 08:23:07 das Exp $ */ #include "tclInt.h" @@ -721,7 +721,7 @@ Tcl_Exit( * returns, so critical is this dependcy. */ - currentAppExitPtr((ClientData) status); + currentAppExitPtr((ClientData) INT2PTR(status)); Tcl_Panic("AppExitProc returned unexpectedly"); } else { /* diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 11a0354..9809b94 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclExecute.c,v 1.249 2006/11/02 15:58:08 dgp Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.250 2006/11/13 08:23:07 das Exp $ */ #include "tclInt.h" @@ -659,7 +659,7 @@ TclStackAlloc( eePtr->tosPtr += numWords; *(eePtr->tosPtr-1) = (Tcl_Obj *) stackRefCountPtr; - *(eePtr->tosPtr) = (Tcl_Obj *) numWords; + *(eePtr->tosPtr) = (Tcl_Obj *) INT2PTR(numWords); return (char *) (tosPtr+1); } @@ -673,7 +673,7 @@ TclStackFree( char **stackRefCountPtr; stackRefCountPtr = (char **) *(eePtr->tosPtr-1); - eePtr->tosPtr -= (int) *(eePtr->tosPtr); + eePtr->tosPtr -= PTR2INT(*(eePtr->tosPtr)); --*stackRefCountPtr; if (*stackRefCountPtr == (char *) 0) { @@ -2645,7 +2645,7 @@ TclExecuteByteCode( TRACE(("%d => %.20s ", opnd, O2S(*tosPtr))); hPtr = Tcl_FindHashEntry(&jtPtr->hashTable, Tcl_GetString(*tosPtr)); if (hPtr != NULL) { - int jumpOffset = (int) Tcl_GetHashValue(hPtr); + int jumpOffset = PTR2INT(Tcl_GetHashValue(hPtr)); TRACE_APPEND(("found in table, new pc %u\n", (unsigned int)(pc - codePtr->codeStart + jumpOffset))); diff --git a/generic/tclHash.c b/generic/tclHash.c index cabf02a..61837d5 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclHash.c,v 1.26 2006/10/22 00:13:29 msofer Exp $ + * RCS: @(#) $Id: tclHash.c,v 1.27 2006/11/13 08:23:08 das Exp $ */ #include "tclInt.h" @@ -329,7 +329,7 @@ Tcl_CreateHashEntry( index = hash & tablePtr->mask; } } else { - hash = (unsigned int) key; + hash = PTR2UINT(key); index = RANDOM_INDEX (tablePtr, hash); } @@ -342,7 +342,7 @@ Tcl_CreateHashEntry( for (hPtr = tablePtr->buckets[index]; hPtr != NULL; hPtr = hPtr->nextPtr) { #if TCL_HASH_KEY_STORE_HASH - if (hash != (unsigned int) hPtr->hash) { + if (hash != PTR2UINT(hPtr->hash)) { continue; } #endif @@ -356,7 +356,7 @@ Tcl_CreateHashEntry( for (hPtr = tablePtr->buckets[index]; hPtr != NULL; hPtr = hPtr->nextPtr) { #if TCL_HASH_KEY_STORE_HASH - if (hash != (unsigned int) hPtr->hash) { + if (hash != PTR2UINT(hPtr->hash)) { continue; } #endif @@ -387,7 +387,7 @@ Tcl_CreateHashEntry( hPtr->tablePtr = tablePtr; #if TCL_HASH_KEY_STORE_HASH # if TCL_PRESERVE_BINARY_COMPATABILITY - hPtr->hash = (VOID *) hash; + hPtr->hash = UINT2PTR(hash); # else hPtr->hash = hash; # endif @@ -464,7 +464,7 @@ Tcl_DeleteHashEntry( || typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) { index = RANDOM_INDEX (tablePtr, entryPtr->hash); } else { - index = ((unsigned int) entryPtr->hash) & tablePtr->mask; + index = PTR2UINT(entryPtr->hash) & tablePtr->mask; } bucketPtr = &(tablePtr->buckets[index]); @@ -1127,7 +1127,7 @@ RebuildTable( || typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) { index = RANDOM_INDEX (tablePtr, hPtr->hash); } else { - index = ((unsigned int) hPtr->hash) & tablePtr->mask; + index = PTR2UINT(hPtr->hash) & tablePtr->mask; } hPtr->nextPtr = tablePtr->buckets[index]; tablePtr->buckets[index] = hPtr; diff --git a/generic/tclIO.c b/generic/tclIO.c index 9016cef..f8e541d 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.110 2006/11/08 11:41:44 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.111 2006/11/13 08:23:08 das Exp $ */ #include "tclInt.h" @@ -9414,7 +9414,7 @@ HaveVersion( { Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr); - return ((int)actualVersion) >= ((int)minimumVersion); + return (PTR2INT(actualVersion)) >= (PTR2INT(minimumVersion)); } /* diff --git a/generic/tclInt.h b/generic/tclInt.h index 67be30e..915d2fa 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.294 2006/11/12 23:15:41 dkf Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.295 2006/11/13 08:23:08 das Exp $ */ #ifndef _TCLINT @@ -113,6 +113,31 @@ typedef int ptrdiff_t; #endif /* + * Macros used to cast between pointers and integers (e.g. when storing an int + * in ClientData), on 64-bit architectures they avoid gcc warning about "cast + * to/from pointer from/to integer of different size". + */ + +#if !defined(INT2PTR) && !defined(PTR2INT) +# if defined(HAVE_INTPTR_T) || defined(intptr_t) +# define INT2PTR(p) ((void*)(intptr_t)(p)) +# define PTR2INT(p) ((int)(intptr_t)(p)) +# else +# define INT2PTR(p) ((void*)(p)) +# define PTR2INT(p) ((int)(p)) +# endif +#endif +#if !defined(UINT2PTR) && !defined(PTR2UINT) +# if defined(HAVE_UINTPTR_T) || defined(uintptr_t) +# define UINT2PTR(p) ((void*)(uintptr_t)(p)) +# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) +# else +# define UINT2PTR(p) ((void*)(p)) +# define PTR2UINT(p) ((unsigned int)(p)) +# endif +#endif + +/* * The following procedures allow namespaces to be customized to support * special name resolution rules for commands/variables. */ diff --git a/generic/tclProc.c b/generic/tclProc.c index cb92d30..3a1121d 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclProc.c,v 1.105 2006/11/02 16:39:07 dkf Exp $ + * RCS: @(#) $Id: tclProc.c,v 1.106 2006/11/13 08:23:09 das Exp $ */ #include "tclInt.h" @@ -682,10 +682,10 @@ TclObjGetFrame( result = 1; curLevel = iPtr->varFramePtr->level; if (objPtr->typePtr == &levelReferenceType) { - if ((int) objPtr->internalRep.twoPtrValue.ptr1) { - level = curLevel - (int) objPtr->internalRep.twoPtrValue.ptr2; + if (PTR2INT(objPtr->internalRep.twoPtrValue.ptr1)) { + level = curLevel - PTR2INT(objPtr->internalRep.twoPtrValue.ptr2); } else { - level = (int) objPtr->internalRep.twoPtrValue.ptr2; + level = PTR2INT(objPtr->internalRep.twoPtrValue.ptr2); } if (level < 0) { goto levelError; @@ -715,7 +715,7 @@ TclObjGetFrame( TclFreeIntRep(objPtr); objPtr->typePtr = &levelReferenceType; objPtr->internalRep.twoPtrValue.ptr1 = (void *) 0; - objPtr->internalRep.twoPtrValue.ptr2 = (void *) level; + objPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(level); } else if (isdigit(UCHAR(*name))) { /* INTL: digit */ if (Tcl_GetInt(interp, name, &level) != TCL_OK) { return -1; @@ -730,7 +730,7 @@ TclObjGetFrame( TclFreeIntRep(objPtr); objPtr->typePtr = &levelReferenceType; objPtr->internalRep.twoPtrValue.ptr1 = (void *) 1; - objPtr->internalRep.twoPtrValue.ptr2 = (void *) level; + objPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(level); level = curLevel - level; } else { /* diff --git a/generic/tclTest.c b/generic/tclTest.c index 2e0f4ae..11d1d56 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTest.c,v 1.105 2006/09/22 18:13:29 andreas_kupries Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.106 2006/11/13 08:23:09 das Exp $ */ #define TCL_TEST @@ -1440,10 +1440,10 @@ TestdcallCmd(dummy, interp, argc, argv) } if (id < 0) { Tcl_DontCallWhenDeleted(delInterp, DelCallbackProc, - (ClientData) (-id)); + (ClientData) INT2PTR(-id)); } else { Tcl_CallWhenDeleted(delInterp, DelCallbackProc, - (ClientData) id); + (ClientData) INT2PTR(id)); } } Tcl_DeleteInterp(delInterp); @@ -1461,7 +1461,7 @@ DelCallbackProc(clientData, interp) * delString. */ Tcl_Interp *interp; /* Interpreter being deleted. */ { - int id = (int) clientData; + int id = PTR2INT(clientData); char buffer[TCL_INTEGER_SPACE]; TclFormatInt(buffer, id); @@ -2181,10 +2181,10 @@ TestexithandlerCmd(clientData, interp, argc, argv) } if (strcmp(argv[1], "create") == 0) { Tcl_CreateExitHandler((value & 1) ? ExitProcOdd : ExitProcEven, - (ClientData) value); + (ClientData) INT2PTR(value)); } else if (strcmp(argv[1], "delete") == 0) { Tcl_DeleteExitHandler((value & 1) ? ExitProcOdd : ExitProcEven, - (ClientData) value); + (ClientData) INT2PTR(value)); } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be create or delete", NULL); @@ -2199,7 +2199,7 @@ ExitProcOdd(clientData) { char buf[16 + TCL_INTEGER_SPACE]; - sprintf(buf, "odd %d\n", (int) clientData); + sprintf(buf, "odd %d\n", PTR2INT(clientData)); write(1, buf, strlen(buf)); } @@ -2209,7 +2209,7 @@ ExitProcEven(clientData) { char buf[16 + TCL_INTEGER_SPACE]; - sprintf(buf, "even %d\n", (int) clientData); + sprintf(buf, "even %d\n", PTR2INT(clientData)); write(1, buf, strlen(buf)); } @@ -3159,7 +3159,7 @@ TestMathFunc(clientData, interp, args, resultPtr) Tcl_Value *resultPtr; /* Where to store result. */ { resultPtr->type = TCL_INT; - resultPtr->intValue = (int) clientData; + resultPtr->intValue = PTR2INT(clientData); return TCL_OK; } @@ -4813,7 +4813,7 @@ TestsetCmd(data, interp, argc, argv) int argc; /* Number of arguments. */ CONST char **argv; /* Argument strings. */ { - int flags = (int) data; + int flags = PTR2INT(data); CONST char *value; if (argc == 2) { @@ -6953,14 +6953,14 @@ TestHashSystemHashCmd(clientData, interp, objc, objv) } for (i=0 ; i<limit ; i++) { - hPtr = Tcl_CreateHashEntry(&hash, (char *)i, &isNew); + hPtr = Tcl_CreateHashEntry(&hash, (char*) INT2PTR(i), &isNew); if (!isNew) { Tcl_SetObjResult(interp, Tcl_NewIntObj(i)); Tcl_AppendToObj(Tcl_GetObjResult(interp)," creation problem",-1); Tcl_DeleteHashTable(&hash); return TCL_ERROR; } - Tcl_SetHashValue(hPtr, (ClientData) (i+42)); + Tcl_SetHashValue(hPtr, (ClientData) INT2PTR(i+42)); } if (hash.numEntries != limit) { @@ -6970,14 +6970,14 @@ TestHashSystemHashCmd(clientData, interp, objc, objv) } for (i=0 ; i<limit ; i++) { - hPtr = Tcl_FindHashEntry(&hash, (char *)i); + hPtr = Tcl_FindHashEntry(&hash, (char*) INT2PTR(i)); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewIntObj(i)); Tcl_AppendToObj(Tcl_GetObjResult(interp)," lookup problem",-1); Tcl_DeleteHashTable(&hash); return TCL_ERROR; } - if ((int)(Tcl_GetHashValue(hPtr)) != i+42) { + if (PTR2INT(Tcl_GetHashValue(hPtr)) != i+42) { Tcl_SetObjResult(interp, Tcl_NewIntObj(i)); Tcl_AppendToObj(Tcl_GetObjResult(interp)," value problem",-1); Tcl_DeleteHashTable(&hash); diff --git a/generic/tclThreadStorage.c b/generic/tclThreadStorage.c index 33db5a2..c0ab032 100644 --- a/generic/tclThreadStorage.c +++ b/generic/tclThreadStorage.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclThreadStorage.c,v 1.10 2006/11/07 14:26:26 dkf Exp $ + * RCS: @(#) $Id: tclThreadStorage.c,v 1.11 2006/11/13 08:23:09 das Exp $ */ #include "tclInt.h" @@ -189,7 +189,7 @@ static Tcl_HashTable * ThreadStorageGetHashTable( Tcl_ThreadId id) /* Id of thread to get hash table for */ { - int index = (unsigned) id % STORAGE_CACHE_SLOTS; + int index = PTR2UINT(id) % STORAGE_CACHE_SLOTS; Tcl_HashEntry *hPtr; int new; @@ -397,7 +397,7 @@ TclpFinalizeThreadDataThread(void) { Tcl_ThreadId id = Tcl_GetCurrentThread(); /* Id of the thread to finalize. */ - int index = (unsigned int)id % STORAGE_CACHE_SLOTS; + int index = PTR2UINT(id) % STORAGE_CACHE_SLOTS; Tcl_HashEntry *hPtr; /* Hash entry for current thread in master * table. */ Tcl_HashTable* hashTablePtr;/* Pointer to the hash table holding TSD diff --git a/generic/tclTimer.c b/generic/tclTimer.c index 2e7ca49..866c114 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTimer.c,v 1.26 2006/11/02 15:58:09 dgp Exp $ + * RCS: @(#) $Id: tclTimer.c,v 1.27 2006/11/13 08:23:09 das Exp $ */ #include "tclInt.h" @@ -293,7 +293,7 @@ TclCreateAbsoluteTimerHandler( timerHandlerPtr->proc = proc; timerHandlerPtr->clientData = clientData; tsdPtr->lastTimerId++; - timerHandlerPtr->token = (Tcl_TimerToken) tsdPtr->lastTimerId; + timerHandlerPtr->token = (Tcl_TimerToken) INT2PTR(tsdPtr->lastTimerId); /* * Add the event to the queue in the correct position @@ -567,7 +567,7 @@ TimerHandlerEventProc( * Bail out if the next timer is of a newer generation. */ - if ((currentTimerId - (int)timerHandlerPtr->token) < 0) { + if ((currentTimerId - PTR2INT(timerHandlerPtr->token)) < 0) { break; } diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 7357a91..399fae7 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUtil.c,v 1.74 2006/11/02 15:58:09 dgp Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.75 2006/11/13 08:23:09 das Exp $ */ #include "tclInt.h" @@ -2635,7 +2635,7 @@ TclSetProcessGlobalValue( Tcl_IncrRefCount(newValue); cacheMap = GetThreadHash(&pgvPtr->key); ClearHash(cacheMap); - hPtr = Tcl_CreateHashEntry(cacheMap, (char *)pgvPtr->epoch, &dummy); + hPtr = Tcl_CreateHashEntry(cacheMap, (char *) INT2PTR(pgvPtr->epoch), &dummy); Tcl_SetHashValue(hPtr, (ClientData) newValue); Tcl_MutexUnlock(&pgvPtr->mutex); } @@ -2697,7 +2697,7 @@ TclGetProcessGlobalValue( } } cacheMap = GetThreadHash(&pgvPtr->key); - hPtr = Tcl_FindHashEntry(cacheMap, (char *)epoch); + hPtr = Tcl_FindHashEntry(cacheMap, (char *) INT2PTR(epoch)); if (NULL == hPtr) { int dummy; @@ -2730,7 +2730,7 @@ TclGetProcessGlobalValue( */ value = Tcl_NewStringObj(pgvPtr->value, pgvPtr->numBytes); - hPtr = Tcl_CreateHashEntry(cacheMap, (char *)pgvPtr->epoch, &dummy); + hPtr = Tcl_CreateHashEntry(cacheMap, (char *) INT2PTR(pgvPtr->epoch), &dummy); Tcl_MutexUnlock(&pgvPtr->mutex); Tcl_SetHashValue(hPtr, (ClientData) value); Tcl_IncrRefCount(value); |