diff options
Diffstat (limited to 'generic/tclTomMathInterface.c')
-rw-r--r-- | generic/tclTomMathInterface.c | 90 |
1 files changed, 82 insertions, 8 deletions
diff --git a/generic/tclTomMathInterface.c b/generic/tclTomMathInterface.c index bf62963..48db8c3 100644 --- a/generic/tclTomMathInterface.c +++ b/generic/tclTomMathInterface.c @@ -10,13 +10,86 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tclTomMathInterface.c,v 1.5 2005/10/13 00:14:38 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" -#include <limits.h> + +MODULE_SCOPE const TclTomMathStubs tclTomMathStubs; + +/* + *---------------------------------------------------------------------- + * + * TclTommath_Init -- + * + * Initializes the TclTomMath 'package', which exists as a + * placeholder so that the package data can be used to hold + * a stub table pointer. + * + * Results: + * Returns a standard Tcl result. + * + * Side effects: + * Installs the stub table for tommath. + * + *---------------------------------------------------------------------- + */ + +int +TclTommath_Init( + Tcl_Interp *interp) /* Tcl interpreter */ +{ + /* TIP #268: Full patchlevel instead of just major.minor */ + + if (Tcl_PkgProvideEx(interp, "tcl::tommath", TCL_PATCH_LEVEL, + &tclTomMathStubs) != TCL_OK) { + return TCL_ERROR; + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * TclBN_epoch -- + * + * Return the epoch number of the TclTomMath stubs table + * + * Results: + * Returns an arbitrary integer that does not decrease with + * release. Stubs tables with different epochs are incompatible. + * + *---------------------------------------------------------------------- + */ + +int +TclBN_epoch(void) +{ + return TCLTOMMATH_EPOCH; +} + +/* + *---------------------------------------------------------------------- + * + * TclBN_revision -- + * + * Returns the revision level of the TclTomMath stubs table + * + * Results: + * Returns an arbitrary integer that increases with revisions. + * If a client requires a given epoch and revision, any Stubs table + * with the same epoch and an equal or higher revision satisfies + * the request. + * + *---------------------------------------------------------------------- + */ + +int +TclBN_revision(void) +{ + return TCLTOMMATH_REVISION; +} +#if 0 /* *---------------------------------------------------------------------- @@ -38,7 +111,7 @@ extern void * TclBNAlloc( size_t x) { - return (void *) Tcl_Alloc((unsigned int) x); + return (void *) ckalloc((unsigned int) x); } /* @@ -57,12 +130,12 @@ TclBNAlloc( *---------------------------------------------------------------------- */ -extern void * +void * TclBNRealloc( void *p, size_t s) { - return (void *) Tcl_Realloc((char *) p, (unsigned int) s); + return (void *) ckrealloc((char *) p, (unsigned int) s); } /* @@ -88,8 +161,9 @@ extern void TclBNFree( void *p) { - Tcl_Free((char *) p); + ckree((char *) p); } +#endif /* *---------------------------------------------------------------------- @@ -114,7 +188,7 @@ TclBNInitBignumFromLong( { int status; unsigned long v; - mp_digit* p; + mp_digit *p; /* * Allocate enough memory to hold the largest possible long |