diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclCompile.c | 29 | ||||
-rw-r--r-- | generic/tclInt.h | 15 |
3 files changed, 29 insertions, 21 deletions
@@ -1,5 +1,11 @@ 2004-04-02 Miguel Sofer <msofer@users.sf.net> + * generic/tclCompile.c: + * generic/tclInt.h: removed the macro TCL_ALIGN() from tclInt.h, + replaced by the static macro ALIGN() in tclCompile.c [Bug 926445] + +2004-04-02 Miguel Sofer <msofer@users.sf.net> + * generic/tclCompile.h: removed redundant #ifdef _TCLINT [Bug 928415], reported by tauvan. diff --git a/generic/tclCompile.c b/generic/tclCompile.c index def4e4d..2df8451 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -11,13 +11,28 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompile.c,v 1.60 2004/03/30 16:22:11 msofer Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.61 2004/04/02 20:07:05 msofer Exp $ */ #include "tclInt.h" #include "tclCompile.h" /* + * This macro is used to determine the offset needed to safely allocate any + * data structure in memory. Given a starting offset or size, it "rounds up" + * or "aligns" the offset to the next 8-byte boundary so that any data + * structure can be placed at the resulting offset without fear of an + * alignment error. + * + * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce + * the wrong result on platforms that allocate addresses that are divisible + * by 4 or 2. Only use it for offsets or sizes. + */ + +#define ALIGN(x) (((int)(x) + 7) & ~7) + + +/* * Table of all AuxData types. */ @@ -1661,9 +1676,9 @@ TclInitByteCodeObj(objPtr, envPtr) */ structureSize = sizeof(ByteCode); - structureSize += TCL_ALIGN(codeBytes); /* align object array */ - structureSize += TCL_ALIGN(objArrayBytes); /* align exc range arr */ - structureSize += TCL_ALIGN(exceptArrayBytes); /* align AuxData array */ + structureSize += ALIGN(codeBytes); /* align object array */ + structureSize += ALIGN(objArrayBytes); /* align exc range arr */ + structureSize += ALIGN(exceptArrayBytes); /* align AuxData array */ structureSize += auxDataArrayBytes; structureSize += cmdLocBytes; @@ -1698,13 +1713,13 @@ TclInitByteCodeObj(objPtr, envPtr) codePtr->codeStart = p; memcpy((VOID *) p, (VOID *) envPtr->codeStart, (size_t) codeBytes); - p += TCL_ALIGN(codeBytes); /* align object array */ + p += ALIGN(codeBytes); /* align object array */ codePtr->objArrayPtr = (Tcl_Obj **) p; for (i = 0; i < numLitObjects; i++) { codePtr->objArrayPtr[i] = envPtr->literalArrayPtr[i].objPtr; } - p += TCL_ALIGN(objArrayBytes); /* align exception range array */ + p += ALIGN(objArrayBytes); /* align exception range array */ if (exceptArrayBytes > 0) { codePtr->exceptArrayPtr = (ExceptionRange *) p; memcpy((VOID *) p, (VOID *) envPtr->exceptArrayPtr, @@ -1713,7 +1728,7 @@ TclInitByteCodeObj(objPtr, envPtr) codePtr->exceptArrayPtr = NULL; } - p += TCL_ALIGN(exceptArrayBytes); /* align AuxData array */ + p += ALIGN(exceptArrayBytes); /* align AuxData array */ if (auxDataArrayBytes > 0) { codePtr->auxDataArrayPtr = (AuxData *) p; memcpy((VOID *) p, (VOID *) envPtr->auxDataArrayPtr, diff --git a/generic/tclInt.h b/generic/tclInt.h index d7c2b40..0628c0a 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.149 2004/04/01 15:07:20 dgp Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.150 2004/04/02 20:07:06 msofer Exp $ */ #ifndef _TCLINT @@ -1410,19 +1410,6 @@ typedef struct Interp { #define UCHAR(c) ((unsigned char) (c)) -/* - * This macro is used to determine the offset needed to safely allocate any - * data structure in memory. Given a starting offset or size, it "rounds up" - * or "aligns" the offset to the next 8-byte boundary so that any data - * structure can be placed at the resulting offset without fear of an - * alignment error. - * - * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce - * the wrong result on platforms that allocate addresses that are divisible - * by 4 or 2. Only use it for offsets or sizes. - */ - -#define TCL_ALIGN(x) (((int)(x) + 7) & ~7) /* * The following enum values are used to specify the runtime platform |