Attachment "tcl-conststubs.diff" to
ticket [1938497fff]
added by
das
2008-04-16 21:50:11.
Index: generic/tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.296
diff -u -p -r1.296 tclBasic.c
--- generic/tclBasic.c 1 Apr 2008 16:23:40 -0000 1.296
+++ generic/tclBasic.c 16 Apr 2008 14:30:57 -0000
@@ -98,7 +98,7 @@ static int DTraceObjCmd(ClientData dummy
Tcl_Obj *const objv[]);
#endif
-extern TclStubs tclStubs;
+MODULE_SCOPE const TclStubs * const tclConstStubsPtr;
/*
* The following structure define the commands in the Tcl core.
@@ -582,7 +582,7 @@ Tcl_CreateInterp(void)
* Initialise the stub table pointer.
*/
- iPtr->stubTable = &tclStubs;
+ iPtr->stubTable = tclConstStubsPtr;
/*
* Initialize the ensemble error message rewriting support.
@@ -808,7 +808,8 @@ Tcl_CreateInterp(void)
* TIP #268: Full patchlevel instead of just major.minor
*/
- Tcl_PkgProvideEx(interp, "Tcl", TCL_PATCH_LEVEL, &tclStubs);
+ Tcl_PkgProvideEx(interp, "Tcl", TCL_PATCH_LEVEL,
+ (ClientData) tclConstStubsPtr);
if (TclTommath_Init(interp) != TCL_OK) {
Tcl_Panic(Tcl_GetString(Tcl_GetObjResult(interp)));
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.364
diff -u -p -r1.364 tclInt.h
--- generic/tclInt.h 16 Apr 2008 14:29:25 -0000 1.364
+++ generic/tclInt.h 16 Apr 2008 14:30:59 -0000
@@ -1605,7 +1605,8 @@ typedef struct Interp {
int errorLine; /* When TCL_ERROR is returned, this gives the
* line number in the command where the error
* occurred (1 means first line). */
- struct TclStubs *stubTable; /* Pointer to the exported Tcl stub table. On
+ const struct TclStubs *stubTable;
+ /* Pointer to the exported Tcl stub table. On
* previous versions of Tcl this is a pointer
* to the objResultPtr or a pointer to a
* buckets array in a hash table. We therefore
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.152
diff -u -p -r1.152 tclStubInit.c
--- generic/tclStubInit.c 16 Apr 2008 14:29:26 -0000 1.152
+++ generic/tclStubInit.c 16 Apr 2008 14:31:01 -0000
@@ -34,12 +34,6 @@
#undef Tcl_FindHashEntry
#undef Tcl_CreateHashEntry
-MODULE_SCOPE TclIntStubs tclIntStubs;
-MODULE_SCOPE TclIntPlatStubs tclIntPlatStubs;
-MODULE_SCOPE TclPlatStubs tclPlatStubs;
-MODULE_SCOPE TclStubs tclStubs;
-MODULE_SCOPE TclTomMathStubs tclTomMathStubs;
-
/*
* WARNING: The contents of this file is automatically generated by the
* tools/genStubs.tcl script. Any modifications to the function declarations
@@ -48,7 +42,7 @@ MODULE_SCOPE TclTomMathStubs tclTomMathS
/* !BEGIN!: Do not edit below this line. */
-TclIntStubs tclIntStubs = {
+static const TclIntStubs tclIntStubs = {
TCL_STUB_MAGIC,
NULL,
NULL, /* 0 */
@@ -314,7 +308,7 @@ TclIntStubs tclIntStubs = {
TclBackgroundException, /* 236 */
};
-TclIntPlatStubs tclIntPlatStubs = {
+static const TclIntPlatStubs tclIntPlatStubs = {
TCL_STUB_MAGIC,
NULL,
#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
@@ -389,7 +383,7 @@ TclIntPlatStubs tclIntPlatStubs = {
#endif /* MACOSX */
};
-TclPlatStubs tclPlatStubs = {
+static const TclPlatStubs tclPlatStubs = {
TCL_STUB_MAGIC,
NULL,
#ifdef __WIN32__ /* WIN */
@@ -402,7 +396,7 @@ TclPlatStubs tclPlatStubs = {
#endif /* MACOSX */
};
-TclTomMathStubs tclTomMathStubs = {
+static const TclTomMathStubs tclTomMathStubs = {
TCL_STUB_MAGIC,
NULL,
TclBN_epoch, /* 0 */
@@ -474,7 +468,7 @@ static const TclStubHooks tclStubHooks =
&tclIntPlatStubs
};
-TclStubs tclStubs = {
+static const TclStubs tclStubs = {
TCL_STUB_MAGIC,
&tclStubHooks,
Tcl_PkgProvideEx, /* 0 */
@@ -1108,3 +1102,14 @@ TclStubs tclStubs = {
};
/* !END!: Do not edit above this line. */
+
+/*
+ * Module-scope pointers to the main static stubs tables, used for package
+ * initialization via Tcl_PkgProvideEx().
+ */
+
+MODULE_SCOPE const TclStubs * const tclConstStubsPtr;
+MODULE_SCOPE const TclTomMathStubs * const tclTomMathConstStubsPtr;
+
+const TclStubs * const tclConstStubsPtr = &tclStubs;
+const TclTomMathStubs * const tclTomMathConstStubsPtr = &tclTomMathStubs;
Index: generic/tclStubLib.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubLib.c,v
retrieving revision 1.24
diff -u -p -r1.24 tclStubLib.c
--- generic/tclStubLib.c 2 Apr 2008 21:29:05 -0000 1.24
+++ generic/tclStubLib.c 16 Apr 2008 14:31:01 -0000
@@ -36,7 +36,7 @@ const TclIntStubs *tclIntStubsPtr = NULL
const TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
const TclTomMathStubs* tclTomMathStubsPtr = NULL;
-static TclStubs *
+static const TclStubs *
HasStubSupport(
Tcl_Interp *interp)
{
Index: generic/tclTomMathInterface.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTomMathInterface.c,v
retrieving revision 1.10
diff -u -p -r1.10 tclTomMathInterface.c
--- generic/tclTomMathInterface.c 13 Dec 2007 15:23:20 -0000 1.10
+++ generic/tclTomMathInterface.c 16 Apr 2008 14:31:04 -0000
@@ -18,7 +18,7 @@
#include "tommath.h"
#include <limits.h>
-extern TclTomMathStubs tclTomMathStubs;
+MODULE_SCOPE const TclTomMathStubs * const tclTomMathConstStubsPtr;
/*
*----------------------------------------------------------------------
@@ -45,7 +45,7 @@ TclTommath_Init(
/* TIP #268: Full patchlevel instead of just major.minor */
if (Tcl_PkgProvideEx(interp, "tcl::tommath", TCL_PATCH_LEVEL,
- (ClientData)&tclTomMathStubs) != TCL_OK) {
+ (ClientData) tclTomMathConstStubsPtr) != TCL_OK) {
return TCL_ERROR;
}
return TCL_OK;
Index: tools/genStubs.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tools/genStubs.tcl,v
retrieving revision 1.25
diff -u -p -r1.25 genStubs.tcl
--- tools/genStubs.tcl 8 Apr 2008 14:52:45 -0000 1.25
+++ tools/genStubs.tcl 16 Apr 2008 14:31:14 -0000
@@ -1056,7 +1056,7 @@ proc genStubs::emitInit {name textVar} {
}
append text "\n\};\n"
}
- append text "\n${capName}Stubs ${name}Stubs = \{\n"
+ append text "\nstatic const ${capName}Stubs ${name}Stubs = \{\n"
append text " TCL_STUB_MAGIC,\n"
if {[info exists hooks($name)]} {
append text " &${name}StubHooks,\n"