diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2004-05-03 19:59:17 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2004-05-03 19:59:17 (GMT) |
commit | 0f128ef98cf49bba53ea19526bfb547cefbf4554 (patch) | |
tree | e68aa2c37a0879aee34b84661c2a24a762f1bd81 /generic | |
parent | d89a3ab9360808277923f70f08aa051dd1dbf3ad (diff) | |
download | tcl-0f128ef98cf49bba53ea19526bfb547cefbf4554.zip tcl-0f128ef98cf49bba53ea19526bfb547cefbf4554.tar.gz tcl-0f128ef98cf49bba53ea19526bfb547cefbf4554.tar.bz2 |
* generic/tclCompile.c:
* generic/tclInt.h: reverted fix for [Bug 926445] of 2004-04-02,
restoring TCL_ALIGN to the header file. Todd Helfter reported that
the macro is required by tbcload.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCompile.c | 29 | ||||
-rw-r--r-- | generic/tclInt.h | 20 |
2 files changed, 26 insertions, 23 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 2df8451..97e7126 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -11,28 +11,13 @@ * 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.61 2004/04/02 20:07:05 msofer Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.62 2004/05/03 19:59:17 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. */ @@ -1676,9 +1661,9 @@ TclInitByteCodeObj(objPtr, envPtr) */ structureSize = sizeof(ByteCode); - structureSize += ALIGN(codeBytes); /* align object array */ - structureSize += ALIGN(objArrayBytes); /* align exc range arr */ - structureSize += ALIGN(exceptArrayBytes); /* align AuxData array */ + structureSize += TCL_ALIGN(codeBytes); /* align object array */ + structureSize += TCL_ALIGN(objArrayBytes); /* align exc range arr */ + structureSize += TCL_ALIGN(exceptArrayBytes); /* align AuxData array */ structureSize += auxDataArrayBytes; structureSize += cmdLocBytes; @@ -1713,13 +1698,13 @@ TclInitByteCodeObj(objPtr, envPtr) codePtr->codeStart = p; memcpy((VOID *) p, (VOID *) envPtr->codeStart, (size_t) codeBytes); - p += ALIGN(codeBytes); /* align object array */ + p += TCL_ALIGN(codeBytes); /* align object array */ codePtr->objArrayPtr = (Tcl_Obj **) p; for (i = 0; i < numLitObjects; i++) { codePtr->objArrayPtr[i] = envPtr->literalArrayPtr[i].objPtr; } - p += ALIGN(objArrayBytes); /* align exception range array */ + p += TCL_ALIGN(objArrayBytes); /* align exception range array */ if (exceptArrayBytes > 0) { codePtr->exceptArrayPtr = (ExceptionRange *) p; memcpy((VOID *) p, (VOID *) envPtr->exceptArrayPtr, @@ -1728,7 +1713,7 @@ TclInitByteCodeObj(objPtr, envPtr) codePtr->exceptArrayPtr = NULL; } - p += ALIGN(exceptArrayBytes); /* align AuxData array */ + p += TCL_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 ff89229..9729ec7 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.155 2004/04/30 20:06:43 dgp Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.156 2004/05/03 19:59:18 msofer Exp $ */ #ifndef _TCLINT @@ -1410,6 +1410,24 @@ 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. + * + * This macro is only used by tclCompile.c in the core (Bug 926445). It + * however not be made file static, as extensions that touch bytecodes + * (notably tbcload) require it. + */ + +#define TCL_ALIGN(x) (((int)(x) + 7) & ~7) + /* * The following enum values are used to specify the runtime platform |