From 14658604dc06848987405fc50bd939df33cd8796 Mon Sep 17 00:00:00 2001 From: das Date: Mon, 13 Nov 2006 08:23:06 +0000 Subject: * generic/tclCompExpr.c: fix gcc warnings about 'cast to/from * generic/tclEncoding.c: pointer from/to integer of different * generic/tclEvent.c: size' on 64-bit platforms by casting to * generic/tclExecute.c: intermediate types intptr_t/uintptr_t * generic/tclHash.c: via new PTR2INT(), INT2PTR(), * generic/tclIO.c: PTR2UINT() and UINT2PTR() macros. * generic/tclInt.h: [Patch 1592791] * generic/tclProc.c: * generic/tclTest.c: * generic/tclThreadStorage.c: * generic/tclTimer.c: * generic/tclUtil.c: * unix/configure.in: * unix/tclUnixChan.c: * unix/tclUnixPipe.c: * unix/tclUnixPort.h: * unix/tclUnixTest.c: * unix/tclUnixThrd.c: * unix/configure: autoconf-2.59 * unix/tclConfig.h.in: autoheader-2.59 --- ChangeLog | 24 ++++ generic/tclCompExpr.c | 6 +- generic/tclEncoding.c | 10 +- generic/tclEvent.c | 4 +- generic/tclExecute.c | 8 +- generic/tclHash.c | 14 +-- generic/tclIO.c | 4 +- generic/tclInt.h | 27 ++++- generic/tclProc.c | 12 +- generic/tclTest.c | 28 ++--- generic/tclThreadStorage.c | 6 +- generic/tclTimer.c | 6 +- generic/tclUtil.c | 8 +- unix/configure | 284 ++++++++++++++++++++++++++++++++++++++++++++- unix/configure.in | 40 ++++++- unix/tclConfig.h.in | 12 ++ unix/tclUnixChan.c | 16 +-- unix/tclUnixPipe.c | 22 ++-- unix/tclUnixPort.h | 8 +- unix/tclUnixTest.c | 8 +- unix/tclUnixThrd.c | 2 +- 21 files changed, 460 insertions(+), 89 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9832885..4061297 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2006-11-13 Daniel Steffen + + * generic/tclCompExpr.c: fix gcc warnings about 'cast to/from + * generic/tclEncoding.c: pointer from/to integer of different + * generic/tclEvent.c: size' on 64-bit platforms by casting to + * generic/tclExecute.c: intermediate types intptr_t/uintptr_t + * generic/tclHash.c: via new PTR2INT(), INT2PTR(), + * generic/tclIO.c: PTR2UINT() and UINT2PTR() macros. + * generic/tclInt.h: [Patch 1592791] + * generic/tclProc.c: + * generic/tclTest.c: + * generic/tclThreadStorage.c: + * generic/tclTimer.c: + * generic/tclUtil.c: + * unix/configure.in: + * unix/tclUnixChan.c: + * unix/tclUnixPipe.c: + * unix/tclUnixPort.h: + * unix/tclUnixTest.c: + * unix/tclUnixThrd.c: + + * unix/configure: autoconf-2.59 + * unix/tclConfig.h.in: autoheader-2.59 + 2006-11-12 Donal K. Fellows * generic/tclInt.h, generic/tclInt.decls: Transfer TclPtrMakeUpvar and 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 ; iproc = 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); diff --git a/unix/configure b/unix/configure index 4a0ae63..e2ce802 100755 --- a/unix/configure +++ b/unix/configure @@ -14275,7 +14275,7 @@ fi echo "$as_me:$LINENO: checking for socklen_t" >&5 echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 -if test "${ac_cv_type_socklen_t+set}" = set; then +if test "${tcl_cv_type_socklen_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -14296,16 +14296,16 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "(^|[^a-zA-Z_0-9])socklen_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then - ac_cv_type_socklen_t=yes + tcl_cv_type_socklen_t=yes else - ac_cv_type_socklen_t=no + tcl_cv_type_socklen_t=no fi rm -f conftest* fi -echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 -echo "${ECHO_T}$ac_cv_type_socklen_t" >&6 -if test $ac_cv_type_socklen_t = no; then +echo "$as_me:$LINENO: result: $tcl_cv_type_socklen_t" >&5 +echo "${ECHO_T}$tcl_cv_type_socklen_t" >&6 +if test $tcl_cv_type_socklen_t = no; then cat >>confdefs.h <<\_ACEOF #define socklen_t unsigned @@ -14313,6 +14313,278 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for intptr_t" >&5 +echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6 +if test "${ac_cv_type_intptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((intptr_t *) 0) + return 0; +if (sizeof (intptr_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_intptr_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_intptr_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_intptr_t" >&5 +echo "${ECHO_T}$ac_cv_type_intptr_t" >&6 +if test $ac_cv_type_intptr_t = yes; then + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INTPTR_T 1 +_ACEOF + +else + + echo "$as_me:$LINENO: checking for pointer-size signed integer type" >&5 +echo $ECHO_N "checking for pointer-size signed integer type... $ECHO_C" >&6 +if test "${tcl_cv_intptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + for tcl_cv_intptr_t in "int" "long" "long long" none; do + if test "$tcl_cv_intptr_t" != none; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_intptr_t))]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + tcl_ok=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +tcl_ok=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + test "$tcl_ok" = yes && break; fi + done +fi +echo "$as_me:$LINENO: result: $tcl_cv_intptr_t" >&5 +echo "${ECHO_T}$tcl_cv_intptr_t" >&6 + if test "$tcl_cv_intptr_t" != none; then + +cat >>confdefs.h <<_ACEOF +#define intptr_t $tcl_cv_intptr_t +_ACEOF + + fi + +fi + +echo "$as_me:$LINENO: checking for uintptr_t" >&5 +echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6 +if test "${ac_cv_type_uintptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((uintptr_t *) 0) + return 0; +if (sizeof (uintptr_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_uintptr_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_uintptr_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 +echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6 +if test $ac_cv_type_uintptr_t = yes; then + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_UINTPTR_T 1 +_ACEOF + +else + + echo "$as_me:$LINENO: checking for pointer-size unsigned integer type" >&5 +echo $ECHO_N "checking for pointer-size unsigned integer type... $ECHO_C" >&6 +if test "${tcl_cv_uintptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \ + none; do + if test "$tcl_cv_uintptr_t" != none; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_uintptr_t))]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + tcl_ok=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +tcl_ok=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + test "$tcl_ok" = yes && break; fi + done +fi +echo "$as_me:$LINENO: result: $tcl_cv_uintptr_t" >&5 +echo "${ECHO_T}$tcl_cv_uintptr_t" >&6 + if test "$tcl_cv_uintptr_t" != none; then + +cat >>confdefs.h <<_ACEOF +#define uintptr_t $tcl_cv_uintptr_t +_ACEOF + + fi + +fi + + #-------------------------------------------------------------------- # If a system doesn't have an opendir function (man, that's old!) # then we have to supply a different version of dirent.h which diff --git a/unix/configure.in b/unix/configure.in index c7db86c..12955c4 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tcl installation dnl to configure the system for the local environment. # -# RCS: @(#) $Id: configure.in,v 1.151 2006/11/10 01:55:58 das Exp $ +# RCS: @(#) $Id: configure.in,v 1.152 2006/11/13 08:23:11 das Exp $ AC_INIT([tcl],[8.5]) AC_PREREQ(2.59) @@ -315,7 +315,7 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_UID_T -AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, [ +AC_CACHE_CHECK([for socklen_t], tcl_cv_type_socklen_t, [ AC_EGREP_CPP(changequote(<<,>>)dnl <<(^|[^a-zA-Z_0-9])socklen_t[^a-zA-Z_0-9]>>dnl changequote([,]),[ @@ -325,11 +325,43 @@ changequote([,]),[ #include #include #endif - ], ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no)]) -if test $ac_cv_type_socklen_t = no; then + ], tcl_cv_type_socklen_t=yes, tcl_cv_type_socklen_t=no)]) +if test $tcl_cv_type_socklen_t = no; then AC_DEFINE(socklen_t, unsigned, [What is the type of socklen_t?]) fi +AC_CHECK_TYPE([intptr_t], [ + AC_DEFINE([HAVE_INTPTR_T], 1, [Do we have the intptr_t type?])], [ + AC_CACHE_CHECK([for pointer-size signed integer type], tcl_cv_intptr_t, [ + for tcl_cv_intptr_t in "int" "long" "long long" none; do + if test "$tcl_cv_intptr_t" != none; then + AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT], + [[sizeof (void *) <= sizeof ($tcl_cv_intptr_t)]])], + [tcl_ok=yes], [tcl_ok=no]) + test "$tcl_ok" = yes && break; fi + done]) + if test "$tcl_cv_intptr_t" != none; then + AC_DEFINE_UNQUOTED([intptr_t], [$tcl_cv_intptr_t], [Signed integer + type wide enough to hold a pointer.]) + fi +]) +AC_CHECK_TYPE([uintptr_t], [ + AC_DEFINE([HAVE_UINTPTR_T], 1, [Do we have the uintptr_t type?])], [ + AC_CACHE_CHECK([for pointer-size unsigned integer type], tcl_cv_uintptr_t, [ + for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \ + none; do + if test "$tcl_cv_uintptr_t" != none; then + AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT], + [[sizeof (void *) <= sizeof ($tcl_cv_uintptr_t)]])], + [tcl_ok=yes], [tcl_ok=no]) + test "$tcl_ok" = yes && break; fi + done]) + if test "$tcl_cv_uintptr_t" != none; then + AC_DEFINE_UNQUOTED([uintptr_t], [$tcl_cv_uintptr_t], [Unsigned integer + type wide enough to hold a pointer.]) + fi +]) + #-------------------------------------------------------------------- # If a system doesn't have an opendir function (man, that's old!) # then we have to supply a different version of dirent.h which diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in index 6bfdb61..0d3e650 100644 --- a/unix/tclConfig.h.in +++ b/unix/tclConfig.h.in @@ -100,6 +100,9 @@ /* Define to 1 if you have the `gmtime_r' function. */ #undef HAVE_GMTIME_R +/* Do we have the intptr_t type? */ +#undef HAVE_INTPTR_T + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -247,6 +250,9 @@ `tzname'. */ #undef HAVE_TZNAME +/* Do we have the uintptr_t type? */ +#undef HAVE_UINTPTR_T + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -463,6 +469,9 @@ /* Define to `int' if doesn't define. */ #undef gid_t +/* Signed integer type wide enough to hold a pointer. */ +#undef intptr_t + /* Define to `int' if does not define. */ #undef mode_t @@ -481,6 +490,9 @@ /* Define to `int' if doesn't define. */ #undef uid_t +/* Unsigned integer type wide enough to hold a pointer. */ +#undef uintptr_t + /* Undef unused package specific autoheader defines so that we can * include both tclConfig.h and tkConfig.h at the same time: */ diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index df51411..b737b09 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.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: tclUnixChan.c,v 1.72 2006/09/07 09:17:33 vasiljevic Exp $ + * RCS: @(#) $Id: tclUnixChan.c,v 1.73 2006/11/13 08:23:11 das Exp $ */ #include "tclInt.h" /* Internal definitions for Tcl. */ @@ -729,7 +729,7 @@ FileGetHandleProc( FileState *fsPtr = (FileState *) instanceData; if (direction & fsPtr->validMask) { - *handlePtr = (ClientData) fsPtr->fd; + *handlePtr = (ClientData) INT2PTR(fsPtr->fd); return TCL_OK; } else { return TCL_ERROR; @@ -1900,7 +1900,7 @@ Tcl_MakeFileChannel( { FileState *fsPtr; char channelName[16 + TCL_INTEGER_SPACE]; - int fd = (int) handle; + int fd = PTR2INT(handle); Tcl_ChannelType *channelTypePtr; struct sockaddr sockaddr; socklen_t sockaddrLen = sizeof(sockaddr); @@ -1921,7 +1921,7 @@ Tcl_MakeFileChannel( if (getsockname(fd, (struct sockaddr *)&sockaddr, &sockaddrLen) == 0 && sockaddrLen > 0 && sockaddr.sa_family == AF_INET) { - return MakeTcpClientChannelMode((ClientData) fd, mode); + return MakeTcpClientChannelMode((ClientData) INT2PTR(fd), mode); } else { channelTypePtr = &fileChannelType; fsPtr = (FileState *) ckalloc((unsigned) sizeof(FileState)); @@ -2423,7 +2423,7 @@ TcpGetHandleProc( { TcpState *statePtr = (TcpState *) instanceData; - *handlePtr = (ClientData)statePtr->fd; + *handlePtr = (ClientData) INT2PTR(statePtr->fd); return TCL_OK; } @@ -2792,7 +2792,7 @@ MakeTcpClientChannelMode( char channelName[16 + TCL_INTEGER_SPACE]; statePtr = (TcpState *) ckalloc((unsigned) sizeof(TcpState)); - statePtr->fd = (int) sock; + statePtr->fd = PTR2INT(sock); statePtr->flags = 0; statePtr->acceptProc = NULL; statePtr->acceptProcData = NULL; @@ -2998,7 +2998,7 @@ TclpGetDefaultStdChannel( #undef ZERO_OFFSET #undef ERROR_OFFSET - channel = Tcl_MakeFileChannel((ClientData) fd, mode); + channel = Tcl_MakeFileChannel((ClientData) INT2PTR(fd), mode); if (channel == NULL) { return NULL; } @@ -3088,7 +3088,7 @@ Tcl_GetOpenFile( if (Tcl_GetChannelHandle(chan, (forWriting ? TCL_WRITABLE : TCL_READABLE), (ClientData*) &data) == TCL_OK) { - fd = (int) data; + fd = PTR2INT(data); /* * The call to fdopen below is probably dangerous, since it will diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index c177f67..7cf9e2b 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.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: tclUnixPipe.c,v 1.35 2006/08/02 20:04:11 das Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.36 2006/11/13 08:23:11 das Exp $ */ #include "tclInt.h" @@ -25,8 +25,8 @@ * the same as NULL. */ -#define MakeFile(fd) ((TclFile)(((int)fd)+1)) -#define GetFd(file) (((int)file)-1) +#define MakeFile(fd) ((TclFile)INT2PTR(((int)(fd))+1)) +#define GetFd(file) (PTR2INT(file)-1) /* * This structure describes per-instance state of a pipe based channel. @@ -113,7 +113,7 @@ TclpMakeFile( if (Tcl_GetChannelHandle(channel, direction, (ClientData *) &data) == TCL_OK) { - return MakeFile((int) data); + return MakeFile(PTR2INT(data)); } else { return (TclFile) NULL; } @@ -513,7 +513,7 @@ TclpCreateProcess( } TclpCloseFile(errPipeIn); - *pidPtr = (Tcl_Pid) pid; + *pidPtr = (Tcl_Pid) INT2PTR(pid); return TCL_OK; error: @@ -525,7 +525,7 @@ TclpCreateProcess( * here, since this is the error case. [Bug: 6148] */ - Tcl_WaitPid((Tcl_Pid) pid, &status, 0); + Tcl_WaitPid((Tcl_Pid) INT2PTR(pid), &status, 0); } if (errPipeIn) { @@ -964,7 +964,7 @@ PipeCloseProc( if (pipePtr->errorFile) { errChan = Tcl_MakeFileChannel( - (ClientData) GetFd(pipePtr->errorFile), TCL_READABLE); + (ClientData) INT2PTR(GetFd(pipePtr->errorFile)), TCL_READABLE); } else { errChan = NULL; } @@ -1157,11 +1157,11 @@ PipeGetHandleProc( PipeState *psPtr = (PipeState *) instanceData; if (direction == TCL_READABLE && psPtr->inFile) { - *handlePtr = (ClientData) GetFd(psPtr->inFile); + *handlePtr = (ClientData) INT2PTR(GetFd(psPtr->inFile)); return TCL_OK; } if (direction == TCL_WRITABLE && psPtr->outFile) { - *handlePtr = (ClientData) GetFd(psPtr->outFile); + *handlePtr = (ClientData) INT2PTR(GetFd(psPtr->outFile)); return TCL_OK; } return TCL_ERROR; @@ -1192,11 +1192,11 @@ Tcl_WaitPid( int result; pid_t real_pid; - real_pid = (pid_t) pid; + real_pid = (pid_t) PTR2INT(pid); while (1) { result = (int) waitpid(real_pid, statPtr, options); if ((result != -1) || (errno != EINTR)) { - return (Tcl_Pid) result; + return (Tcl_Pid) INT2PTR(result); } } } diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 8472ec4..99dc65b 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -19,7 +19,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPort.h,v 1.55 2006/10/31 22:24:39 das Exp $ + * RCS: @(#) $Id: tclUnixPort.h,v 1.56 2006/11/13 08:23:11 das Exp $ */ #ifndef _TCLUNIXPORT @@ -104,6 +104,12 @@ EXTERN Tcl_WideUInt strtoull _ANSI_ARGS_((CONST char *string, #ifndef NO_SYS_WAIT_H # include #endif +#if HAVE_INTTYPES_H +# include +#endif +#if HAVE_STDINT_H +# include +#endif #ifdef HAVE_UNISTD_H # include #else diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c index 1110b07..54b77b7 100644 --- a/unix/tclUnixTest.c +++ b/unix/tclUnixTest.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: tclUnixTest.c,v 1.22 2006/03/14 19:34:30 vincentdarley Exp $ + * RCS: @(#) $Id: tclUnixTest.c,v 1.23 2006/11/13 08:23:12 das Exp $ */ #include "tclInt.h" @@ -28,8 +28,8 @@ * the same as NULL. Note that this code is duplicated from tclUnixPipe.c */ -#define MakeFile(fd) ((TclFile)((fd)+1)) -#define GetFd(file) (((int)file)-1) +#define MakeFile(fd) ((TclFile)INT2PTR(((int)(fd))+1)) +#define GetFd(file) (PTR2INT(file)-1) /* * The stuff below is used to keep track of file handlers created and @@ -402,7 +402,7 @@ TestfilewaitCmd( Tcl_SetResult(interp, "couldn't get channel file", TCL_STATIC); return TCL_ERROR; } - fd = (int) data; + fd = PTR2INT(data); if (Tcl_GetInt(interp, argv[3], &timeout) != TCL_OK) { return TCL_ERROR; } diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c index adc508f..815dc4f 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -191,7 +191,7 @@ void TclpThreadExit( int status) { - pthread_exit((VOID *)status); + pthread_exit(INT2PTR(status)); } #endif /* TCL_THREADS */ -- cgit v0.12