summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-10-21 14:03:04 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-10-21 14:03:04 (GMT)
commitde1cef0dc80e5e6c32ee369b4e043cc4baf90145 (patch)
treef567884a345c0e830eb11c79205a22d9b430edf5 /generic
parent45c406a3db22a0349dfabba2c0c9edfb924a6ea9 (diff)
parent2119ee5eb73d55cc417be2146168a9892187e409 (diff)
downloadtcl-de1cef0dc80e5e6c32ee369b4e043cc4baf90145.zip
tcl-de1cef0dc80e5e6c32ee369b4e043cc4baf90145.tar.gz
tcl-de1cef0dc80e5e6c32ee369b4e043cc4baf90145.tar.bz2
Merge trunk. More simplifications, still WIP
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h28
-rw-r--r--generic/tclStubCall.c43
2 files changed, 36 insertions, 35 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index ab2b0a8..fe73018 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -265,7 +265,7 @@ typedef void *ClientData;
*/
#if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
-# if defined(_MSC_VER) || defined(_WIN32)
+# if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
# define TCL_WIDE_INT_TYPE __int64
# define TCL_LL_MODIFIER "I64"
# if defined(_WIN64)
@@ -2202,7 +2202,7 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv);
#endif
extern void TclStubMainEx(int index, int argc, const void *argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
-extern void *TclStubCall(int flags, void *arg1);
+extern void *TclStubCall(void *arg);
#if defined(_WIN32) && defined(UNICODE)
#ifndef USE_TCL_STUBS
# define Tcl_FindExecutable(arg) ((Tcl_FindExecutable)((const char *)(arg)))
@@ -2212,27 +2212,27 @@ extern void *TclStubCall(int flags, void *arg1);
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#endif
#ifdef USE_TCL_STUBS
+#define Tcl_SetPanicProc(panicProc) \
+ TclInitStubTable(((const char *(*)(Tcl_PanicProc *))TclStubCall((void *)panicProc))(panicProc))
#define Tcl_InitSubsystems() \
- TclInitStubTable(((const char *(*)(void))TclStubCall(0, NULL))())
+ TclInitStubTable(((const char *(*)(void))TclStubCall(INT2PTR(1)))())
#define Tcl_FindExecutable(argv0) \
- TclInitStubTable(((const char *(*)(const char *))TclStubCall(1, NULL))(argv0))
-#define Tcl_SetPanicProc(panicProc) \
- TclInitStubTable(((const char *(*)(Tcl_PanicProc *))TclStubCall(1, (void *)panicProc))(panicProc))
-#define TclZipfs_AppHook(argcp, argvp) \
- TclInitStubTable(((const char *(*)(int *, void *))TclStubCall(1, NULL))(argcp, argvp))
-#define Tcl_StaticPackage(interp, pkgName, initProc, safeInitProc) \
- ((void(*)(Tcl_Interp *, const char *, Tcl_PackageInitProc *, Tcl_PackageInitProc *)) \
- TclStubCall(4, NULL))(interp, pkgName, initProc, safeInitProc)
+ TclInitStubTable(((const char *(*)(const char *))TclStubCall(INT2PTR(1)))(argv0))
#if !defined(_WIN32) || !defined(UNICODE)
#define Tcl_MainEx(argc, argv, appInitProc, interp) \
((void(*)(int, const void *, Tcl_AppInitProc *, Tcl_Interp *)) \
- TclStubCall(5, NULL))(argc, argv, appInitProc, interp)
+ TclStubCall(INT2PTR(3)))(argc, argv, appInitProc, interp)
#endif
#define Tcl_MainExW(argc, argv, appInitProc, interp) \
((void(*)(int, const void *, Tcl_AppInitProc *, Tcl_Interp *)) \
- TclStubCall(6, NULL))(argc, argv, appInitProc, interp)
+ TclStubCall(INT2PTR(4)))(argc, argv, appInitProc, interp)
+#define Tcl_StaticPackage(interp, pkgName, initProc, safeInitProc) \
+ ((void(*)(Tcl_Interp *, const char *, Tcl_PackageInitProc *, Tcl_PackageInitProc *)) \
+ TclStubCall(INT2PTR(5)))(interp, pkgName, initProc, safeInitProc)
+#define TclZipfs_AppHook(argcp, argvp) \
+ ((const char *(*)(int *, void *))TclStubCall(INT2PTR(6)))(argcp, argvp)
#endif
-
+
/*
*----------------------------------------------------------------------------
* Include the public function declarations that are accessible via the stubs
diff --git a/generic/tclStubCall.c b/generic/tclStubCall.c
index ae6566f..da8d47a 100644
--- a/generic/tclStubCall.c
+++ b/generic/tclStubCall.c
@@ -19,27 +19,24 @@ MODULE_SCOPE void *tclStubsHandle;
/*
*----------------------------------------------------------------------
*
- * Tcl_InitSubsystems --
+ * TclStubCall --
*
* Load the Tcl core dynamically, version "9.0" (or higher, in future versions)
*
* Results:
- * Outputs the value of the "version" argument.
- *
- * Side effects:
- * Sets the stub table pointers.
+ * Outputs a function returning the value of the "version" argument or NULL.
*
*----------------------------------------------------------------------
*/
static const char PROCNAME[][24] = {
+ "_Tcl_SetPanicProc",
"_Tcl_InitSubsystems",
"_Tcl_FindExecutable",
- "_Tcl_SetPanicProc",
- "_TclZipfs_AppHook",
- "_Tcl_StaticPackage",
"_Tcl_MainEx",
- "_Tcl_MainExW"
+ "_Tcl_MainExW",
+ "_Tcl_StaticPackage",
+ "_TclZipfs_AppHook"
};
MODULE_SCOPE const void *nullVersionProc(void) {
@@ -50,14 +47,18 @@ static const char CANNOTCALL[] = "Cannot call %s from stubbed extension\n";
static const char CANNOTFIND[] = "Cannot find %s: %s\n";
MODULE_SCOPE void *
-TclStubCall(int index, void *arg1)
+TclStubCall(void *arg)
{
static void *stubFn[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
- const char *(*versionProc)(void) = (const char *(*)(void))nullVersionProc;
+ unsigned index = PTR2UINT(arg);
- if (tclStubsHandle == (void *)-1) {
- if (index == 2 && arg1 != NULL) {
- ((Tcl_PanicProc *)arg1)(CANNOTCALL, PROCNAME[index] + 1);
+ if (index > 6) {
+ /* Any other value means Tcl_SetPanicProc() with non-null panicProc */
+ index = 0;
+ }
+ if (tclStubsHandle == INT2PTR(-1)) {
+ if ((index == 0) && (arg != NULL)) {
+ ((Tcl_PanicProc *)arg)(CANNOTCALL, PROCNAME[index] + 1);
} else {
fprintf(stderr, CANNOTCALL, PROCNAME[index] + 1);
abort();
@@ -67,8 +68,8 @@ TclStubCall(int index, void *arg1)
if (!tclStubsHandle) {
tclStubsHandle = dlopen(TCL_DLL_FILE, RTLD_NOW|RTLD_LOCAL);
if (!tclStubsHandle) {
- if (index == 2 && arg1 != NULL) {
- ((Tcl_PanicProc *)arg1)(CANNOTFIND, TCL_DLL_FILE, dlerror());
+ if ((index == 0) && (arg != NULL)) {
+ ((Tcl_PanicProc *)arg)(CANNOTFIND, TCL_DLL_FILE, dlerror());
} else {
fprintf(stderr, CANNOTFIND, TCL_DLL_FILE, dlerror());
abort();
@@ -77,13 +78,13 @@ TclStubCall(int index, void *arg1)
}
stubFn[index] = dlsym(tclStubsHandle, PROCNAME[index] + 1);
if (!stubFn[index]) {
- stubFn[index] = dlsym(tclStubsHandle, PROCNAME[index]);
- }
- if (stubFn[index]) {
- versionProc = ((const char *(*)(void))stubFn[index]);
+ stubFn[index] = dlsym(tclStubsHandle, PROCNAME[index]);
+ if (!stubFn[index]) {
+ stubFn[index] = nullVersionProc;
+ }
}
}
- return versionProc;
+ return stubFn[index];
}
/*