summaryrefslogtreecommitdiffstats
path: root/generic/tclStubLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclStubLib.c')
-rw-r--r--generic/tclStubLib.c65
1 files changed, 60 insertions, 5 deletions
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index 7b62f5e..31fc865 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -12,12 +12,12 @@
*/
#include "tclInt.h"
-#include "tclPort.h"
TclStubs *tclStubsPtr = NULL;
TclPlatStubs *tclPlatStubsPtr = NULL;
TclIntStubs *tclIntStubsPtr = NULL;
TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
+TclTomMathStubs* tclTomMathStubsPtr = NULL;
/*
* Use our own ISDIGIT to avoid linking to libc on windows
@@ -44,10 +44,10 @@ TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
*/
#undef Tcl_InitStubs
CONST char *
-Tcl_InitStubs(interp, version, exact)
- Tcl_Interp *interp;
- CONST char *version;
- int exact;
+Tcl_InitStubs(
+ Tcl_Interp *interp,
+ CONST char *version,
+ int exact)
{
Interp *iPtr = (Interp *) interp;
CONST char *actualVersion = NULL;
@@ -112,6 +112,61 @@ Tcl_InitStubs(interp, version, exact)
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TclTomMathInitStubs --
+ *
+ * Initializes the Stubs table for Tcl's subset of libtommath
+ *
+ * Results:
+ * Returns a standard Tcl result.
+ *
+ * This procedure should not be called directly, but rather through
+ * the TclTomMath_InitStubs macro, to insure that the Stubs table
+ * matches the header files used in compilation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#undef TclTomMathInitializeStubs
+
+CONST char*
+TclTomMathInitializeStubs(
+ Tcl_Interp* interp, /* Tcl interpreter */
+ CONST char* version, /* Tcl version needed */
+ int epoch, /* Stubs table epoch from the header files */
+ int revision /* Stubs table revision number from the
+ * header files */
+) {
+ int exact = 0;
+ const char* packageName = "tcl::tommath";
+ const char* errMsg = NULL;
+ ClientData pkgClientData = NULL;
+ const char* actualVersion =
+ tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, exact, &pkgClientData);
+ TclTomMathStubs* stubsPtr = (TclTomMathStubs*) pkgClientData;
+ if (actualVersion == NULL) {
+ return NULL;
+ }
+ if (pkgClientData == NULL) {
+ errMsg = "missing stub table pointer";
+ } else if ((stubsPtr->tclBN_epoch)() != epoch) {
+ errMsg = "epoch number mismatch";
+ } else if ((stubsPtr->tclBN_revision)() != revision) {
+ errMsg = "requires a later revision";
+ } else {
+ tclTomMathStubsPtr = stubsPtr;
+ return actualVersion;
+ }
+ tclStubsPtr->tcl_ResetResult(interp);
+ tclStubsPtr->tcl_AppendResult(interp, "error loading ", packageName,
+ " (requested version ", version,
+ ", actual version ", actualVersion,
+ "): ", errMsg, NULL);
+ return NULL;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4