diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclExecute.c | 4 | ||||
-rw-r--r-- | generic/tclInt.h | 14 | ||||
-rw-r--r-- | generic/tclVar.c | 4 |
3 files changed, 17 insertions, 5 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 1112c40..fe625a8 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.307 2007/07/31 17:03:37 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.308 2007/08/01 13:27:47 patthoyts Exp $ */ #include "tclInt.h" @@ -181,7 +181,7 @@ static BuiltinFunc tclBuiltinFuncTable[] = { */ #define VarHashGetValue(hPtr) \ - ((Var *) ((char *)hPtr - offsetof(VarInHash, entry))) + ((Var *) ((char *)hPtr - TclOffset(VarInHash, entry))) static inline Var * VarHashCreateVar(TclVarHashTable *tablePtr, Tcl_Obj *key, int *newPtr) diff --git a/generic/tclInt.h b/generic/tclInt.h index 032a2f6..947d6ec 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.325 2007/07/31 17:03:38 msofer Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.326 2007/08/01 13:27:47 patthoyts Exp $ */ #ifndef _TCLINT @@ -3488,6 +3488,18 @@ MODULE_SCOPE void TclBNInitBignumFromWideUInt(mp_int *bignum, #endif /* + * ---------------------------------------------------------------------- + * Macro to use to find the offset of a field in a structure. + * Computes number of bytes from beginning of structure to a given field. + */ + +#ifdef offsetof +#define TclOffset(type, field) ((int) offsetof(type, field)) +#else +#define TclOffset(type, field) ((int) ((char *) &((type *) 0)->field)) +#endif + +/* *---------------------------------------------------------------- * Inline version of Tcl_GetCurrentNamespace and Tcl_GetGlobalNamespace */ diff --git a/generic/tclVar.c b/generic/tclVar.c index 967f539..58849c0 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclVar.c,v 1.146 2007/08/01 12:09:04 msofer Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.147 2007/08/01 13:27:48 patthoyts Exp $ */ #include "tclInt.h" @@ -46,7 +46,7 @@ static inline Var * VarHashNextVar(Tcl_HashSearch *searchPtr); static inline void CleanupVar(Var *varPtr, Var *arrayPtr); #define VarHashGetValue(hPtr) \ - ((Var *) ((char *)hPtr - offsetof(VarInHash, entry))) + ((Var *) ((char *)hPtr - TclOffset(VarInHash, entry))) static inline Var * VarHashCreateVar(TclVarHashTable *tablePtr, Tcl_Obj *key, int *newPtr) |