summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-07-27 12:57:27 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-07-27 12:57:27 (GMT)
commite4971bdffcb5ad9da61fec42904e83511c80108d (patch)
tree8daa550a2d6d16f4419440e4983a52a131fdb427
parentaf64c95042a9706c6d45118c8f341aafa5c26686 (diff)
downloadtcl-e4971bdffcb5ad9da61fec42904e83511c80108d.zip
tcl-e4971bdffcb5ad9da61fec42904e83511c80108d.tar.gz
tcl-e4971bdffcb5ad9da61fec42904e83511c80108d.tar.bz2
Proposed fix for [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc()
-rw-r--r--generic/tcl.h4
-rw-r--r--generic/tclInt.h14
2 files changed, 6 insertions, 12 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index cae8fb6..0dfa8a8 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -677,9 +677,9 @@ typedef struct Tcl_ObjType {
#if TCL_MAJOR_VERSION > 8
# define TCL_OBJTYPE_V0 0, \
0,0,0,0,0,0,0 /* Pre-Tcl 9 */
-# define TCL_OBJTYPE_V1(a) 1, \
+# define TCL_OBJTYPE_V1(a) offsetof(Tcl_ObjType, indexProc), \
a,0,0,0,0,0,0 /* Tcl 9 Version 1 */
-# define TCL_OBJTYPE_V2(a,b,c,d,e,f,g) 2, \
+# define TCL_OBJTYPE_V2(a,b,c,d,e,f,g) offsetof(Tcl_ObjType, reservedProc), \
a,b,c,d,e,f,g /* Tcl 9 - AbstractLists */
#else
# define TCL_OBJTYPE_V0 /* just empty */
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 9c7ad17..599fb2d 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -1084,16 +1084,10 @@ typedef struct ActiveInterpTrace {
#define TCL_TRACE_LEAVE_EXEC 2
#if TCL_MAJOR_VERSION > 8
-/*
- * Versions 0, 1, and 2 are currently supported concurrently for now
- */
-#define TclObjTypeHasProc(objPtr, proc) \
- (((objPtr)->typePtr \
- && ( (objPtr)->typePtr->version == 1 \
- || (objPtr)->typePtr->version == 2)) \
- ? ((objPtr)->typePtr)->proc \
- : NULL)
-
+#define TclObjTypeHasProc(objPtr, proc) (((objPtr)->typePtr \
+ && ((offsetof(Tcl_ObjType, proc) < offsetof(Tcl_ObjType, version)) \
+ || (offsetof(Tcl_ObjType, proc) < (objPtr)->typePtr->version))) ? \
+ ((objPtr)->typePtr)->proc : NULL)
MODULE_SCOPE Tcl_Size TclLengthOne(Tcl_Obj *);