From d29d888dc616e6f2815075b28608f5ba03da3fd5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 20 Nov 2012 08:40:56 +0000 Subject: Add checks for the assumtions made in tclStubLib.c, making sure that those assumtions are maintained for Tcl 9! If not, extensions compiled for Tcl9 but loaded in Tcl8 (with an incompatible stub table) cannot produce a nice error-message any more.

This is probably not the best place to do the check, maybe it's better to do this in tclTest.c, as part of the test suite.

Feedback welcome! --- generic/tclBasic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 2735abc..63bc4b8 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -431,6 +431,14 @@ TclFinalizeEvaluation(void) *---------------------------------------------------------------------- */ +/* Template for internal Interp structure: the stubTable entry cannot move! */ +typedef struct { + char *dumm1; + Tcl_FreeProc *dummy2; + int dummy3; + const struct TclStubs *stubTable; +} InterpTemplate; + Tcl_Interp * Tcl_CreateInterp(void) { @@ -466,6 +474,21 @@ Tcl_CreateInterp(void) /*NOTREACHED*/ Tcl_Panic("Tcl_CallFrame must not be smaller than CallFrame"); } + if ((void *) tclStubs.tcl_SetObjResult + != (void *)((&(tclStubs.tcl_PkgProvideEx))[235])) { + /*NOTREACHED*/ + Tcl_Panic("Tcl_SetObjResult entry in the stub table must be kept"); + } + if ((void *) tclStubs.tcl_NewStringObj + != (void *)((&(tclStubs.tcl_PkgProvideEx))[56])) { + /*NOTREACHED*/ + Tcl_Panic("Tcl_NewStringObj entry in the stub table must be kept"); + } + if (offsetof(InterpTemplate, stubTable) + != offsetof(Interp, stubTable)) { + /*NOTREACHED*/ + Tcl_Panic("stubsTable entry in the Interp structure must be kept"); + } if (cancelTableInitialized == 0) { Tcl_MutexLock(&cancelLock); -- cgit v0.12