diff options
author | dgp <dgp@users.sourceforge.net> | 2017-09-14 14:12:26 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-09-14 14:12:26 (GMT) |
commit | 415a0e9de392a6d195f45a417443aaab4b3371d0 (patch) | |
tree | be17c1c3e0a0ff0f191d17819b900574054c3621 /generic | |
parent | 41765c8938c367e0824c280bbfe292bec64d52e1 (diff) | |
parent | bf01a303da2833ef352dae626b2a8d4929aaca37 (diff) | |
download | tcl-415a0e9de392a6d195f45a417443aaab4b3371d0.zip tcl-415a0e9de392a6d195f45a417443aaab4b3371d0.tar.gz tcl-415a0e9de392a6d195f45a417443aaab4b3371d0.tar.bz2 |
merge trunk
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBasic.c | 4 | ||||
-rw-r--r-- | generic/tclBinary.c | 2 | ||||
-rw-r--r-- | generic/tclDecls.h | 9 | ||||
-rw-r--r-- | generic/tclExecute.c | 6 | ||||
-rw-r--r-- | generic/tclHash.c | 13 | ||||
-rw-r--r-- | generic/tclInt.h | 3 | ||||
-rw-r--r-- | generic/tclObj.c | 6 | ||||
-rw-r--r-- | generic/tclStrToD.c | 32 | ||||
-rw-r--r-- | generic/tclStubInit.c | 6 | ||||
-rw-r--r-- | generic/tclTomMath.decls | 12 | ||||
-rw-r--r-- | generic/tclTomMath.h | 2 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 17 | ||||
-rw-r--r-- | generic/tclTomMathInterface.c | 166 |
13 files changed, 87 insertions, 191 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 5a33445..14d4fe1 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7491,7 +7491,7 @@ ExprAbsFunc( } goto unChanged; } else if (l == LONG_MIN) { - TclBNInitBignumFromLong(&big, l); + TclInitBignumFromLong(&big, l); goto tooLarge; } Tcl_SetObjResult(interp, Tcl_NewLongObj(-l)); @@ -7526,7 +7526,7 @@ ExprAbsFunc( goto unChanged; } if (w == LLONG_MIN) { - TclBNInitBignumFromWideInt(&big, w); + TclInitBignumFromWideInt(&big, w); goto tooLarge; } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-w)); diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 936a3ac..45cafdf 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2339,7 +2339,7 @@ ScanNumber( Tcl_Obj *bigObj = NULL; mp_int big; - TclBNInitBignumFromWideUInt(&big, uwvalue); + TclInitBignumFromWideUInt(&big, uwvalue); bigObj = Tcl_NewBignumObj(&big); return bigObj; } diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 59d83b8..0aecc9f 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -23,6 +23,15 @@ # endif #endif +#if !defined(BUILD_tcl) +# define TCL_DEPRECATED(msg) EXTERN TCL_DEPRECATED_API(msg) +#elif defined(TCL_NO_DEPRECATED) +# define TCL_DEPRECATED(msg) MODULE_SCOPE +#else +# define TCL_DEPRECATED(msg) EXTERN +#endif + + /* * WARNING: This file is automatically generated by the tools/genStubs.tcl * script. Any modifications to the function declarations below should be made diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 8389bef..8abce42 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8235,7 +8235,7 @@ ExecuteExtendedBinaryMathOp( * Arguments are opposite sign; remainder is sum. */ - TclBNInitBignumFromWideInt(&big1, w1); + TclInitBignumFromWideInt(&big1, w1); mp_add(&big2, &big1, &big2); mp_clear(&big1); BIG_RESULT(&big2); @@ -9201,7 +9201,7 @@ ExecuteExtendedUnaryMathOp( if (w != LLONG_MIN) { WIDE_RESULT(-w); } - TclBNInitBignumFromLong(&big, *(const long *) ptr); + TclInitBignumFromLong(&big, *(const long *) ptr); break; #ifndef TCL_WIDE_INT_IS_LONG case TCL_NUMBER_WIDE: @@ -9209,7 +9209,7 @@ ExecuteExtendedUnaryMathOp( if (w != LLONG_MIN) { WIDE_RESULT(-w); } - TclBNInitBignumFromWideInt(&big, w); + TclInitBignumFromWideInt(&big, w); break; #endif default: diff --git a/generic/tclHash.c b/generic/tclHash.c index 78ad514..3c820c0 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -46,19 +46,6 @@ static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr); static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); /* - * Prototypes for the one word hash key methods. Not actually declared because - * this is a critical path that is implemented in the core hash table access - * function. - */ - -#if 0 -static Tcl_HashEntry * AllocOneWordEntry(Tcl_HashTable *tablePtr, - void *keyPtr); -static int CompareOneWordKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr); -#endif - -/* * Prototypes for the string hash key methods. */ diff --git a/generic/tclInt.h b/generic/tclInt.h index 8b9e6a1..e1651da 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3009,6 +3009,9 @@ MODULE_SCOPE int TclInfoLocalsCmd(ClientData dummy, Tcl_Interp *interp, MODULE_SCOPE int TclInfoVarsCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TclInitAlloc(void); +MODULE_SCOPE void TclInitBignumFromLong(mp_int *, long); +MODULE_SCOPE void TclInitBignumFromWideInt(mp_int *, Tcl_WideInt); +MODULE_SCOPE void TclInitBignumFromWideUInt(mp_int *, Tcl_WideUInt); MODULE_SCOPE void TclInitDbCkalloc(void); MODULE_SCOPE void TclInitDoubleConversion(void); MODULE_SCOPE void TclInitEmbeddedConfigurationInformation( diff --git a/generic/tclObj.c b/generic/tclObj.c index 6e4011e..9301d9d 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3234,7 +3234,7 @@ Tcl_SetWideIntObj( #else mp_int big; - TclBNInitBignumFromWideInt(&big, wideValue); + TclInitBignumFromWideInt(&big, wideValue); Tcl_SetBignumObj(objPtr, &big); #endif } @@ -3603,12 +3603,12 @@ GetBignumFromObj( return TCL_OK; } if (objPtr->typePtr == &tclIntType) { - TclBNInitBignumFromLong(bignumValue, objPtr->internalRep.longValue); + TclInitBignumFromLong(bignumValue, objPtr->internalRep.longValue); return TCL_OK; } #ifndef TCL_WIDE_INT_IS_LONG if (objPtr->typePtr == &tclWideIntType) { - TclBNInitBignumFromWideInt(bignumValue, + TclInitBignumFromWideInt(bignumValue, objPtr->internalRep.wideValue); return TCL_OK; } diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 539a92c..630e498 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -711,7 +711,7 @@ TclParseNumber( || (octalSignificandWide > (~(Tcl_WideUInt)0 >> shift)))) { octalSignificandOverflow = 1; - TclBNInitBignumFromWideUInt(&octalSignificandBig, + TclInitBignumFromWideUInt(&octalSignificandBig, octalSignificandWide); } } @@ -828,7 +828,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (~(Tcl_WideUInt)0 >> shift))) { significandOverflow = 1; - TclBNInitBignumFromWideUInt(&significandBig, + TclInitBignumFromWideUInt(&significandBig, significandWide); } } @@ -869,7 +869,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (~(Tcl_WideUInt)0 >> shift))) { significandOverflow = 1; - TclBNInitBignumFromWideUInt(&significandBig, + TclInitBignumFromWideUInt(&significandBig, significandWide); } } @@ -1214,7 +1214,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; - TclBNInitBignumFromWideUInt(&significandBig, significandWide); + TclInitBignumFromWideUInt(&significandBig, significandWide); } if (shift) { if (!significandOverflow) { @@ -1235,7 +1235,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; - TclBNInitBignumFromWideUInt(&significandBig, significandWide); + TclInitBignumFromWideUInt(&significandBig, significandWide); } if (shift) { if (!significandOverflow) { @@ -1256,7 +1256,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || octalSignificandWide > (MOST_BITS + signum) >> shift)) { octalSignificandOverflow = 1; - TclBNInitBignumFromWideUInt(&octalSignificandBig, + TclInitBignumFromWideUInt(&octalSignificandBig, octalSignificandWide); } if (shift) { @@ -1283,7 +1283,7 @@ TclParseNumber( break; } #endif - TclBNInitBignumFromWideUInt(&octalSignificandBig, + TclInitBignumFromWideUInt(&octalSignificandBig, octalSignificandWide); octalSignificandOverflow = 1; } else { @@ -1311,7 +1311,7 @@ TclParseNumber( &significandWide, &significandBig, significandOverflow); if (!significandOverflow && (significandWide > MOST_BITS+signum)){ significandOverflow = 1; - TclBNInitBignumFromWideUInt(&significandBig, significandWide); + TclInitBignumFromWideUInt(&significandBig, significandWide); } returnInteger: if (!significandOverflow) { @@ -1330,7 +1330,7 @@ TclParseNumber( break; } #endif - TclBNInitBignumFromWideUInt(&significandBig, + TclInitBignumFromWideUInt(&significandBig, significandWide); significandOverflow = 1; } else { @@ -1485,7 +1485,7 @@ AccumulateDecimalDigit( * bignum and fall through into the bignum case. */ - TclBNInitBignumFromWideUInt(bignumRepPtr, w); + TclInitBignumFromWideUInt(bignumRepPtr, w); } else { /* * Wide multiplication. @@ -1628,7 +1628,7 @@ MakeLowPrecisionDouble( * call MakeHighPrecisionDouble to do it the hard way. */ - TclBNInitBignumFromWideUInt(&significandBig, significand); + TclInitBignumFromWideUInt(&significandBig, significand); retval = MakeHighPrecisionDouble(0, &significandBig, numSigDigs, exponent); mp_clear(&significandBig); @@ -3315,7 +3315,7 @@ ShorteningBignumConversionPowD( * mminus = 5**m5 */ - TclBNInitBignumFromWideUInt(&b, bw); + TclInitBignumFromWideUInt(&b, bw); mp_init_set_int(&mminus, 1); MulPow5(&b, b5, &b); mp_mul_2d(&b, b2, &b); @@ -3502,7 +3502,7 @@ StrictBignumConversionPowD( * b = bw * 2**b2 * 5**b5 */ - TclBNInitBignumFromWideUInt(&b, bw); + TclInitBignumFromWideUInt(&b, bw); MulPow5(&b, b5, &b); mp_mul_2d(&b, b2, &b); @@ -3710,7 +3710,7 @@ ShorteningBignumConversion( * S = 2**s2 * 5*s5 */ - TclBNInitBignumFromWideUInt(&b, bw); + TclInitBignumFromWideUInt(&b, bw); mp_mul_2d(&b, b2, &b); mp_init_set_int(&S, 1); MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S); @@ -3923,7 +3923,7 @@ StrictBignumConversion( */ mp_init_multi(&temp, &dig, NULL); - TclBNInitBignumFromWideUInt(&b, bw); + TclInitBignumFromWideUInt(&b, bw); mp_mul_2d(&b, b2, &b); mp_init_set_int(&S, 1); MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S); @@ -4579,7 +4579,7 @@ Tcl_InitBignumFromDouble( Tcl_WideInt w = (Tcl_WideInt) ldexp(fract, mantBits); int shift = expt - mantBits; - TclBNInitBignumFromWideInt(b, w); + TclInitBignumFromWideInt(b, w); if (shift < 0) { mp_div_2d(b, -shift, b, NULL); } else if (shift > 0) { diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index cd5e715..8c0fdf8 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -69,6 +69,9 @@ static int TclSockMinimumBuffersOld(int sock, int size) # define TclWinGetSockOpt 0 # define TclWinSetSockOpt 0 # define TclWinNToHS 0 +# define TclBNInitBignumFromWideUInt 0 +# define TclBNInitBignumFromWideInt 0 +# define TclBNInitBignumFromLong 0 #else #define TclSetStartupScriptPath setStartupScriptPath static void TclSetStartupScriptPath(Tcl_Obj *path) @@ -103,6 +106,9 @@ static unsigned short TclWinNToHS(unsigned short ns) { return ntohs(ns); } #endif +# define TclBNInitBignumFromWideUInt TclInitBignumFromWideUInt +# define TclBNInitBignumFromWideInt TclInitBignumFromWideInt +# define TclBNInitBignumFromLong TclInitBignumFromLong #endif /* TCL_NO_DEPRECATED */ #ifdef _WIN32 diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 5d1c8e8..d628cfe 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -223,13 +223,13 @@ declare 63 { # Formerly internal API to allow initialisation of bignums without knowing the # typedefs of how a bignum works internally. -declare 64 { +declare 64 {deprecated {Use mp_init() + mp_set_long_long()}} { void TclBNInitBignumFromLong(mp_int *bignum, long initVal) } -declare 65 { +declare 65 {deprecated {Use mp_init() + mp_set_long_long()}} { void TclBNInitBignumFromWideInt(mp_int *bignum, Tcl_WideInt initVal) } -declare 66 { +declare 66 {deprecated {Use mp_init() + mp_set_long_long()}} { void TclBNInitBignumFromWideUInt(mp_int *bignum, Tcl_WideUInt initVal) } @@ -244,6 +244,12 @@ declare 68 { declare 69 { Tcl_WideUInt TclBN_mp_get_long_long(const mp_int *a) } +declare 70 { + int TclBN_mp_set_long(mp_int *a, unsigned long i) +} +declare 71 { + unsigned long TclBN_mp_get_long(const mp_int *a) +} # Local Variables: # mode: tcl diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index 2ce8194..f110490 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -27,7 +27,7 @@ extern "C" { #endif /* detect 64-bit mode if possible */ -#if defined(NEVER) +#if defined(NEVER) /* 128-bit ints fail in too many places */ #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) #define MP_64BIT #endif diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 9d683dc..03f383f 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -75,6 +75,7 @@ #define mp_expt_d TclBN_mp_expt_d #define mp_expt_d_ex TclBN_mp_expt_d_ex #define mp_get_int TclBN_mp_get_int +#define mp_get_long TclBN_mp_get_long #define mp_get_long_long TclBN_mp_get_long_long #define mp_grow TclBN_mp_grow #define mp_init TclBN_mp_init @@ -100,6 +101,7 @@ #define mp_s_rmap TclBNMpSRmap #define mp_set TclBN_mp_set #define mp_set_int TclBN_mp_set_int +#define mp_set_long TclBN_mp_set_long #define mp_set_long_long TclBN_mp_set_long_long #define mp_shrink TclBN_mp_shrink #define mp_sqr TclBN_mp_sqr @@ -298,12 +300,15 @@ EXTERN int TclBN_mp_set_int(mp_int *a, unsigned long i); /* 63 */ EXTERN int TclBN_mp_cnt_lsb(const mp_int *a); /* 64 */ -EXTERN void TclBNInitBignumFromLong(mp_int *bignum, long initVal); +TCL_DEPRECATED("Use mp_init() + mp_set_long() or mp_set_long_long()") +void TclBNInitBignumFromLong(mp_int *bignum, long initVal); /* 65 */ -EXTERN void TclBNInitBignumFromWideInt(mp_int *bignum, +TCL_DEPRECATED("Use mp_init() + mp_set_long_long()") +void TclBNInitBignumFromWideInt(mp_int *bignum, Tcl_WideInt initVal); /* 66 */ -EXTERN void TclBNInitBignumFromWideUInt(mp_int *bignum, +TCL_DEPRECATED("Use mp_init() + mp_set_long_long()") +void TclBNInitBignumFromWideUInt(mp_int *bignum, Tcl_WideUInt initVal); /* 67 */ EXTERN int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, @@ -381,9 +386,9 @@ typedef struct TclTomMathStubs { int (*tclBN_mp_init_set_int) (mp_int *a, unsigned long i); /* 61 */ int (*tclBN_mp_set_int) (mp_int *a, unsigned long i); /* 62 */ int (*tclBN_mp_cnt_lsb) (const mp_int *a); /* 63 */ - void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */ - void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */ - void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */ + TCL_DEPRECATED_API("Use mp_init() + mp_set_long() or mp_set_long_long()") void (*tclBNInitBignumFromLong) (mp_int *bignum, long initVal); /* 64 */ + TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromWideInt) (mp_int *bignum, Tcl_WideInt initVal); /* 65 */ + TCL_DEPRECATED_API("Use mp_init() + mp_set_long_long()") void (*tclBNInitBignumFromWideUInt) (mp_int *bignum, Tcl_WideUInt initVal); /* 66 */ int (*tclBN_mp_expt_d_ex) (const mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */ int (*tclBN_mp_set_long_long) (mp_int *a, Tcl_WideUInt i); /* 68 */ Tcl_WideUInt (*tclBN_mp_get_long_long) (const mp_int *a); /* 69 */ diff --git a/generic/tclTomMathInterface.c b/generic/tclTomMathInterface.c index 48db8c3..9e7bf4b 100644 --- a/generic/tclTomMathInterface.c +++ b/generic/tclTomMathInterface.c @@ -89,86 +89,11 @@ TclBN_revision(void) { return TCLTOMMATH_REVISION; } -#if 0 /* *---------------------------------------------------------------------- * - * TclBNAlloc -- - * - * Allocate memory for libtommath. - * - * Results: - * Returns a pointer to the allocated block. - * - * This procedure is a wrapper around Tcl_Alloc, needed because of a - * mismatched type signature between Tcl_Alloc and malloc. - * - *---------------------------------------------------------------------- - */ - -extern void * -TclBNAlloc( - size_t x) -{ - return (void *) ckalloc((unsigned int) x); -} - -/* - *---------------------------------------------------------------------- - * - * TclBNRealloc -- - * - * Change the size of an allocated block of memory in libtommath - * - * Results: - * Returns a pointer to the allocated block. - * - * This procedure is a wrapper around Tcl_Realloc, needed because of a - * mismatched type signature between Tcl_Realloc and realloc. - * - *---------------------------------------------------------------------- - */ - -void * -TclBNRealloc( - void *p, - size_t s) -{ - return (void *) ckrealloc((char *) p, (unsigned int) s); -} - -/* - *---------------------------------------------------------------------- - * - * TclBNFree -- - * - * Free allocated memory in libtommath. - * - * Results: - * None. - * - * Side effects: - * Memory is freed. - * - * This function is simply a wrapper around Tcl_Free, needed in libtommath - * because of a type mismatch between free and Tcl_Free. - * - *---------------------------------------------------------------------- - */ - -extern void -TclBNFree( - void *p) -{ - ckree((char *) p); -} -#endif - -/* - *---------------------------------------------------------------------- - * - * TclBNInitBignumFromLong -- + * TclInitBignumFromLong -- * * Allocate and initialize a 'bignum' from a native 'long'. * @@ -181,47 +106,20 @@ TclBNFree( *---------------------------------------------------------------------- */ -extern void -TclBNInitBignumFromLong( +void +TclInitBignumFromLong( mp_int *a, - long initVal) + long v) { - int status; - unsigned long v; - mp_digit *p; - - /* - * Allocate enough memory to hold the largest possible long - */ - - status = mp_init_size(a, - (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT); - if (status != MP_OKAY) { - Tcl_Panic("initialization failure in TclBNInitBignumFromLong"); + if (mp_init_size(a, (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { + Tcl_Panic("initialization failure in TclInitBignumFromLong"); } - - /* - * Convert arg to sign and magnitude. - */ - - if (initVal < 0) { - a->sign = MP_NEG; - v = -initVal; + if (v < (long)0) { + mp_set_long_long(a, (Tcl_WideUInt)(-(Tcl_WideInt)v)); + mp_neg(a, a); } else { - a->sign = MP_ZPOS; - v = initVal; - } - - /* - * Store the magnitude in the bignum. - */ - - p = a->dp; - while (v) { - *p++ = (mp_digit) (v & MP_MASK); - v >>= MP_DIGIT_BIT; + mp_set_long_long(a, (Tcl_WideUInt)v); } - a->used = p - a->dp; } /* @@ -240,16 +138,19 @@ TclBNInitBignumFromLong( *---------------------------------------------------------------------- */ -extern void -TclBNInitBignumFromWideInt( +void +TclInitBignumFromWideInt( mp_int *a, /* Bignum to initialize */ Tcl_WideInt v) /* Initial value */ { + if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { + Tcl_Panic("initialization failure in TclInitBignumFromWideInt"); + } if (v < (Tcl_WideInt)0) { - TclBNInitBignumFromWideUInt(a, (Tcl_WideUInt)(-v)); + mp_set_long_long(a, (Tcl_WideUInt)(-v)); mp_neg(a, a); } else { - TclBNInitBignumFromWideUInt(a, (Tcl_WideUInt)v); + mp_set_long_long(a, (Tcl_WideUInt)v); } } @@ -269,36 +170,15 @@ TclBNInitBignumFromWideInt( *---------------------------------------------------------------------- */ -extern void -TclBNInitBignumFromWideUInt( +void +TclInitBignumFromWideUInt( mp_int *a, /* Bignum to initialize */ Tcl_WideUInt v) /* Initial value */ { - int status; - mp_digit *p; - - /* - * Allocate enough memory to hold the largest possible Tcl_WideUInt. - */ - - status = mp_init_size(a, - (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT); - if (status != MP_OKAY) { - Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt"); - } - - a->sign = MP_ZPOS; - - /* - * Store the magnitude in the bignum. - */ - - p = a->dp; - while (v) { - *p++ = (mp_digit) (v & MP_MASK); - v >>= MP_DIGIT_BIT; - } - a->used = p - a->dp; + if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { + Tcl_Panic("initialization failure in TclInitBignumFromWideUInt"); + } + mp_set_long_long(a, v); } /* |