Fossil SCM

Eliminate the need for the Tcl stub library to be linked with. Fossil uses public Tcl functions only, so tclStubPtr is the only variable which needs to be present and initialized. The function Tcl_InitStubs reduces to only 15 lines of code, which as well can be put in directly. Advantage: Presence of 3 header files (tcl.h, tclDecls.h and tclPlatDecls.h) from whatever Tcl version is sufficient to compile Fossil with Tcl support through stubs.

jan.nijtmans 2013-09-13 11:55 trunk
Commit 9f77be88a2da8ea675010efa268f8a37a963d00d
+5 -7
--- auto.def
+++ auto.def
@@ -122,24 +122,22 @@
122122
define USE_TCL_STUBS
123123
} else {
124124
set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
125125
}
126126
set cflags $tclconfig(TCL_INCLUDE_SPEC)
127
- cc-with [list -cflags $cflags -libs $libs] {
128
- if {$tclstubs} {
129
- if {![cc-check-functions Tcl_InitStubs]} {
130
- user-error "Cannot find a usable Tcl stubs library $msg"
131
- }
132
- } else {
127
+ if {!$tclstubs} {
128
+ cc-with [list -cflags $cflags -libs $libs] {
133129
if {![cc-check-functions Tcl_CreateInterp]} {
134130
user-error "Cannot find a usable Tcl library $msg"
135131
}
136132
}
137133
}
138134
set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
139135
msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
140
- define-append LIBS $libs
136
+ if {!$tclstubs} {
137
+ define-append LIBS $libs
138
+ }
141139
define-append EXTRA_CFLAGS $cflags
142140
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
143141
define FOSSIL_ENABLE_TCL
144142
}
145143
146144
--- auto.def
+++ auto.def
@@ -122,24 +122,22 @@
122 define USE_TCL_STUBS
123 } else {
124 set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
125 }
126 set cflags $tclconfig(TCL_INCLUDE_SPEC)
127 cc-with [list -cflags $cflags -libs $libs] {
128 if {$tclstubs} {
129 if {![cc-check-functions Tcl_InitStubs]} {
130 user-error "Cannot find a usable Tcl stubs library $msg"
131 }
132 } else {
133 if {![cc-check-functions Tcl_CreateInterp]} {
134 user-error "Cannot find a usable Tcl library $msg"
135 }
136 }
137 }
138 set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
139 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
140 define-append LIBS $libs
 
 
141 define-append EXTRA_CFLAGS $cflags
142 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
143 define FOSSIL_ENABLE_TCL
144 }
145
146
--- auto.def
+++ auto.def
@@ -122,24 +122,22 @@
122 define USE_TCL_STUBS
123 } else {
124 set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
125 }
126 set cflags $tclconfig(TCL_INCLUDE_SPEC)
127 if {!$tclstubs} {
128 cc-with [list -cflags $cflags -libs $libs] {
 
 
 
 
129 if {![cc-check-functions Tcl_CreateInterp]} {
130 user-error "Cannot find a usable Tcl library $msg"
131 }
132 }
133 }
134 set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
135 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
136 if {!$tclstubs} {
137 define-append LIBS $libs
138 }
139 define-append EXTRA_CFLAGS $cflags
140 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
141 define FOSSIL_ENABLE_TCL
142 }
143
144
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -449,13 +449,11 @@
449449
TCLINCDIR = $(TCLDIR)/include
450450
TCLLIBDIR = $(TCLDIR)/lib
451451
452452
#### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
453453
#
454
-ifdef FOSSIL_ENABLE_TCL_STUBS
455
-LIBTCL = -ltclstub86
456
-else
454
+ifndef FOSSIL_ENABLE_TCL_STUBS
457455
LIBTCL = -ltcl86
458456
endif
459457
460458
#### C Compile and options for use in building executables that
461459
# will run on the target platform. This is usually the same
462460
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -449,13 +449,11 @@
449 TCLINCDIR = $(TCLDIR)/include
450 TCLLIBDIR = $(TCLDIR)/lib
451
452 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
453 #
454 ifdef FOSSIL_ENABLE_TCL_STUBS
455 LIBTCL = -ltclstub86
456 else
457 LIBTCL = -ltcl86
458 endif
459
460 #### C Compile and options for use in building executables that
461 # will run on the target platform. This is usually the same
462
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -449,13 +449,11 @@
449 TCLINCDIR = $(TCLDIR)/include
450 TCLLIBDIR = $(TCLDIR)/lib
451
452 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
453 #
454 ifndef FOSSIL_ENABLE_TCL_STUBS
 
 
455 LIBTCL = -ltcl86
456 endif
457
458 #### C Compile and options for use in building executables that
459 # will run on the target platform. This is usually the same
460
+25 -2
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -119,10 +119,18 @@
119119
# define TCL_FINDEXECUTABLE_NAME "_Tcl_FindExecutable"
120120
# endif
121121
# ifndef TCL_CREATEINTERP_NAME
122122
# define TCL_CREATEINTERP_NAME "_Tcl_CreateInterp"
123123
# endif
124
+#define tclStubsPtr staticTclStubsPtr
125
+static const TclStubs *tclStubsPtr = NULL;
126
+typedef struct {
127
+ char *notused1;
128
+ Tcl_FreeProc *notused2;
129
+ int notused3;
130
+ const struct TclStubs *stubTable;
131
+} Interp;
124132
#endif /* defined(USE_TCL_STUBS) */
125133
126134
/*
127135
** The function types for Tcl_FindExecutable and Tcl_CreateInterp are needed
128136
** when the Tcl library is being loaded dynamically by a stubs-enabled
@@ -673,14 +681,29 @@
673681
if( argc>0 && argv ){
674682
argv0 = argv[0];
675683
}
676684
tclContext->xFindExecutable(argv0);
677685
tclInterp = tclContext->xCreateInterp();
678
- if( !tclInterp ||
686
+
679687
#if defined(USE_TCL_STUBS)
680
- !Tcl_InitStubs(tclInterp, "8.4", 0) ||
688
+ if( tclInterp ){
689
+ tclStubsPtr = ((Interp *) tclInterp)->stubTable;
690
+ if (!tclStubsPtr || (tclStubsPtr->magic != TCL_STUB_MAGIC)) {
691
+ Th_ErrorMessage(interp,
692
+ "could not create Tcl interpreter: "
693
+ "incompatible stubs mechanism", (const char *)"", 0);
694
+ return TH_ERROR;
695
+ }
696
+ if( Tcl_PkgRequireEx(tclInterp, "Tcl", "8.4", 0, (void *)&tclStubsPtr)==0 ){
697
+ Th_ErrorMessage(interp,
698
+ "could not create Tcl interpreter: "
699
+ "incompatible version", (const char *)"", 0);
700
+ return TH_ERROR;
701
+ }
702
+ }
681703
#endif
704
+ if( !tclInterp ||
682705
Tcl_InterpDeleted(tclInterp) ){
683706
Th_ErrorMessage(interp,
684707
"could not create Tcl interpreter", (const char *)"", 0);
685708
return TH_ERROR;
686709
}
687710
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -119,10 +119,18 @@
119 # define TCL_FINDEXECUTABLE_NAME "_Tcl_FindExecutable"
120 # endif
121 # ifndef TCL_CREATEINTERP_NAME
122 # define TCL_CREATEINTERP_NAME "_Tcl_CreateInterp"
123 # endif
 
 
 
 
 
 
 
 
124 #endif /* defined(USE_TCL_STUBS) */
125
126 /*
127 ** The function types for Tcl_FindExecutable and Tcl_CreateInterp are needed
128 ** when the Tcl library is being loaded dynamically by a stubs-enabled
@@ -673,14 +681,29 @@
673 if( argc>0 && argv ){
674 argv0 = argv[0];
675 }
676 tclContext->xFindExecutable(argv0);
677 tclInterp = tclContext->xCreateInterp();
678 if( !tclInterp ||
679 #if defined(USE_TCL_STUBS)
680 !Tcl_InitStubs(tclInterp, "8.4", 0) ||
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681 #endif
 
682 Tcl_InterpDeleted(tclInterp) ){
683 Th_ErrorMessage(interp,
684 "could not create Tcl interpreter", (const char *)"", 0);
685 return TH_ERROR;
686 }
687
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -119,10 +119,18 @@
119 # define TCL_FINDEXECUTABLE_NAME "_Tcl_FindExecutable"
120 # endif
121 # ifndef TCL_CREATEINTERP_NAME
122 # define TCL_CREATEINTERP_NAME "_Tcl_CreateInterp"
123 # endif
124 #define tclStubsPtr staticTclStubsPtr
125 static const TclStubs *tclStubsPtr = NULL;
126 typedef struct {
127 char *notused1;
128 Tcl_FreeProc *notused2;
129 int notused3;
130 const struct TclStubs *stubTable;
131 } Interp;
132 #endif /* defined(USE_TCL_STUBS) */
133
134 /*
135 ** The function types for Tcl_FindExecutable and Tcl_CreateInterp are needed
136 ** when the Tcl library is being loaded dynamically by a stubs-enabled
@@ -673,14 +681,29 @@
681 if( argc>0 && argv ){
682 argv0 = argv[0];
683 }
684 tclContext->xFindExecutable(argv0);
685 tclInterp = tclContext->xCreateInterp();
686
687 #if defined(USE_TCL_STUBS)
688 if( tclInterp ){
689 tclStubsPtr = ((Interp *) tclInterp)->stubTable;
690 if (!tclStubsPtr || (tclStubsPtr->magic != TCL_STUB_MAGIC)) {
691 Th_ErrorMessage(interp,
692 "could not create Tcl interpreter: "
693 "incompatible stubs mechanism", (const char *)"", 0);
694 return TH_ERROR;
695 }
696 if( Tcl_PkgRequireEx(tclInterp, "Tcl", "8.4", 0, (void *)&tclStubsPtr)==0 ){
697 Th_ErrorMessage(interp,
698 "could not create Tcl interpreter: "
699 "incompatible version", (const char *)"", 0);
700 return TH_ERROR;
701 }
702 }
703 #endif
704 if( !tclInterp ||
705 Tcl_InterpDeleted(tclInterp) ){
706 Th_ErrorMessage(interp,
707 "could not create Tcl interpreter", (const char *)"", 0);
708 return TH_ERROR;
709 }
710
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -110,13 +110,11 @@
110110
TCLINCDIR = $(TCLDIR)/include
111111
TCLLIBDIR = $(TCLDIR)/lib
112112
113113
#### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
114114
#
115
-ifdef FOSSIL_ENABLE_TCL_STUBS
116
-LIBTCL = -ltclstub86
117
-else
115
+ifndef FOSSIL_ENABLE_TCL_STUBS
118116
LIBTCL = -ltcl86
119117
endif
120118
121119
#### C Compile and options for use in building executables that
122120
# will run on the target platform. This is usually the same
123121
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -110,13 +110,11 @@
110 TCLINCDIR = $(TCLDIR)/include
111 TCLLIBDIR = $(TCLDIR)/lib
112
113 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
114 #
115 ifdef FOSSIL_ENABLE_TCL_STUBS
116 LIBTCL = -ltclstub86
117 else
118 LIBTCL = -ltcl86
119 endif
120
121 #### C Compile and options for use in building executables that
122 # will run on the target platform. This is usually the same
123
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -110,13 +110,11 @@
110 TCLINCDIR = $(TCLDIR)/include
111 TCLLIBDIR = $(TCLDIR)/lib
112
113 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
114 #
115 ifndef FOSSIL_ENABLE_TCL_STUBS
 
 
116 LIBTCL = -ltcl86
117 endif
118
119 #### C Compile and options for use in building executables that
120 # will run on the target platform. This is usually the same
121
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -110,13 +110,11 @@
110110
TCLINCDIR = $(TCLDIR)/include
111111
TCLLIBDIR = $(TCLDIR)/lib
112112
113113
#### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
114114
#
115
-ifdef FOSSIL_ENABLE_TCL_STUBS
116
-LIBTCL = -ltclstub86
117
-else
115
+ifndef FOSSIL_ENABLE_TCL_STUBS
118116
LIBTCL = -ltcl86
119117
endif
120118
121119
#### C Compile and options for use in building executables that
122120
# will run on the target platform. This is usually the same
123121
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -110,13 +110,11 @@
110 TCLINCDIR = $(TCLDIR)/include
111 TCLLIBDIR = $(TCLDIR)/lib
112
113 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
114 #
115 ifdef FOSSIL_ENABLE_TCL_STUBS
116 LIBTCL = -ltclstub86
117 else
118 LIBTCL = -ltcl86
119 endif
120
121 #### C Compile and options for use in building executables that
122 # will run on the target platform. This is usually the same
123
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -110,13 +110,11 @@
110 TCLINCDIR = $(TCLDIR)/include
111 TCLLIBDIR = $(TCLDIR)/lib
112
113 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
114 #
115 ifndef FOSSIL_ENABLE_TCL_STUBS
 
 
116 LIBTCL = -ltcl86
117 endif
118
119 #### C Compile and options for use in building executables that
120 # will run on the target platform. This is usually the same
121

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button