diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-11-12 12:11:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-11-12 12:11:05 (GMT) |
commit | 41e4211a15b085e6f456693fe2ef6ad980bde593 (patch) | |
tree | 2115df6e1746693165934fe335889d189f533313 /generic | |
parent | e512564f360551e1821bc646ce75314246b9a0ee (diff) | |
parent | 34714bcefaa3ba23593153c232829b2af6914528 (diff) | |
download | tcl-41e4211a15b085e6f456693fe2ef6ad980bde593.zip tcl-41e4211a15b085e6f456693fe2ef6ad980bde593.tar.gz tcl-41e4211a15b085e6f456693fe2ef6ad980bde593.tar.bz2 |
Merge 8.7. Finish implementation.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBasic.c | 2 | ||||
-rw-r--r-- | generic/tclBinary.c | 3 | ||||
-rw-r--r-- | generic/tclExecute.c | 4 | ||||
-rw-r--r-- | generic/tclObj.c | 2 | ||||
-rw-r--r-- | generic/tclScan.c | 6 | ||||
-rw-r--r-- | generic/tclStrToD.c | 38 | ||||
-rw-r--r-- | generic/tclStubInit.c | 35 | ||||
-rw-r--r-- | generic/tclTomMath.decls | 36 | ||||
-rw-r--r-- | generic/tclTomMath.h | 4 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 113 |
10 files changed, 129 insertions, 114 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index d8fc01f..ca6b9f9 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7891,7 +7891,7 @@ ExprAbsFunc( } goto unChanged; } else if (l == WIDE_MIN) { - mp_init_ll(&big, l); + mp_init_i64(&big, l); goto tooLarge; } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(-l)); diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 34e8fa6..8ba0fab 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2349,8 +2349,7 @@ ScanNumber( Tcl_Obj *bigObj = NULL; mp_int big; - if (mp_init(&big) == MP_OKAY) { - mp_set_u64(&big, uwvalue); + if (mp_init_u64(&big, uwvalue) == MP_OKAY) { bigObj = Tcl_NewBignumObj(&big); } return bigObj; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 5f2ae4c..a2f8ad5 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8072,7 +8072,7 @@ ExecuteExtendedBinaryMathOp( * Arguments are opposite sign; remainder is sum. */ - mp_init_ll(&big1, w1); + mp_init_i64(&big1, w1); mp_add(&big2, &big1, &big2); mp_clear(&big1); BIG_RESULT(&big2); @@ -8701,7 +8701,7 @@ ExecuteExtendedUnaryMathOp( if (w != WIDE_MIN) { WIDE_RESULT(-w); } - mp_init_ll(&big, w); + mp_init_i64(&big, w); break; default: Tcl_TakeBignumFromObj(NULL, valuePtr, &big); diff --git a/generic/tclObj.c b/generic/tclObj.c index 82038df..eb9334e 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3604,7 +3604,7 @@ GetBignumFromObj( return TCL_OK; } if (objPtr->typePtr == &tclIntType) { - mp_init_ll(bignumValue, + mp_init_i64(bignumValue, objPtr->internalRep.wideValue); return TCL_OK; } diff --git a/generic/tclScan.c b/generic/tclScan.c index 50a3fe3..ba24ecf 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -929,13 +929,12 @@ Tcl_ScanObjCmd( } if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) { mp_int big; - if (mp_init(&big) != MP_OKAY) { + if (mp_init_u64(&big, (Tcl_WideUInt)wideValue) != MP_OKAY) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "insufficient memory to create bignum", -1)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); return TCL_ERROR; } else { - mp_set_u64(&big, (Tcl_WideUInt)wideValue); Tcl_SetBignumObj(objPtr, &big); } } else { @@ -976,13 +975,12 @@ Tcl_ScanObjCmd( if ((flags & SCAN_UNSIGNED) && (value < 0)) { #ifdef TCL_WIDE_INT_IS_LONG mp_int big; - if (mp_init(&big) != MP_OKAY) { + if (mp_init_u64(&big, (unsigned long)value) != MP_OKAY) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "insufficient memory to create bignum", -1)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); return TCL_ERROR; } else { - mp_set_u64(&big, (unsigned long)value); Tcl_SetBignumObj(objPtr, &big); } #else diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index d46c852..0ad5979 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -711,7 +711,7 @@ TclParseNumber( || (octalSignificandWide > ((Tcl_WideUInt)-1 >> shift)))) { octalSignificandOverflow = 1; - mp_init_ull(&octalSignificandBig, + mp_init_u64(&octalSignificandBig, octalSignificandWide); } } @@ -828,7 +828,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; - mp_init_ull(&significandBig, + mp_init_u64(&significandBig, significandWide); } } @@ -869,7 +869,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; - mp_init_ull(&significandBig, + mp_init_u64(&significandBig, significandWide); } } @@ -1214,7 +1214,7 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; - mp_init_ull(&significandBig, significandWide); + mp_init_u64(&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; - mp_init_ull(&significandBig, significandWide); + mp_init_u64(&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; - mp_init_ull(&octalSignificandBig, + mp_init_u64(&octalSignificandBig, octalSignificandWide); } if (shift) { @@ -1269,7 +1269,7 @@ TclParseNumber( } if (!octalSignificandOverflow) { if (octalSignificandWide > (MOST_BITS + signum)) { - mp_init_ull(&octalSignificandBig, + mp_init_u64(&octalSignificandBig, octalSignificandWide); octalSignificandOverflow = 1; } else { @@ -1297,12 +1297,12 @@ TclParseNumber( &significandWide, &significandBig, significandOverflow); if (!significandOverflow && (significandWide > MOST_BITS+signum)){ significandOverflow = 1; - mp_init_ull(&significandBig, significandWide); + mp_init_u64(&significandBig, significandWide); } returnInteger: if (!significandOverflow) { if (significandWide > MOST_BITS+signum) { - mp_init_ull(&significandBig, + mp_init_u64(&significandBig, significandWide); significandOverflow = 1; } else { @@ -1457,7 +1457,7 @@ AccumulateDecimalDigit( * bignum and fall through into the bignum case. */ - mp_init_ull(bignumRepPtr, w); + mp_init_u64(bignumRepPtr, w); } else { /* * Wide multiplication. @@ -1600,7 +1600,7 @@ MakeLowPrecisionDouble( * call MakeHighPrecisionDouble to do it the hard way. */ - mp_init_ull(&significandBig, significand); + mp_init_u64(&significandBig, significand); retval = MakeHighPrecisionDouble(0, &significandBig, numSigDigs, exponent); mp_clear(&significandBig); @@ -1889,7 +1889,7 @@ RefineApproximation( scale = binExponent - mantBits - 1; - mp_set(&twoMv, 1); + mp_set_u64(&twoMv, 1); for (i=0; i<=8; ++i) { if (M5 & (1 << i)) { mp_mul(&twoMv, pow5+i, &twoMv); @@ -3267,7 +3267,7 @@ ShorteningBignumConversionPowD( * mminus = 5**m5 */ - mp_init_ull(&b, bw); + mp_init_u64(&b, bw); mp_init_set(&mminus, 1); MulPow5(&b, b5, &b); mp_mul_2d(&b, b2, &b); @@ -3451,7 +3451,7 @@ StrictBignumConversionPowD( * b = bw * 2**b2 * 5**b5 */ - mp_init_ull(&b, bw); + mp_init_u64(&b, bw); MulPow5(&b, b5, &b); mp_mul_2d(&b, b2, &b); @@ -3651,7 +3651,7 @@ ShorteningBignumConversion( * S = 2**s2 * 5*s5 */ - mp_init_ull(&b, bw); + mp_init_u64(&b, bw); mp_mul_2d(&b, b2, &b); mp_init_set(&S, 1); MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S); @@ -3860,7 +3860,7 @@ StrictBignumConversion( */ mp_init_multi(&dig, NULL); - mp_init_ull(&b, bw); + mp_init_u64(&b, bw); mp_mul_2d(&b, b2, &b); mp_init_set(&S, 1); MulPow5(&S, s5, &S); mp_mul_2d(&S, s2, &S); @@ -4381,11 +4381,11 @@ TclInitDoubleConversion(void) for (i=0; i<9; ++i) { mp_init(pow5 + i); } - mp_set(pow5, 5); + mp_set_u64(pow5, 5); for (i=0; i<8; ++i) { mp_sqr(pow5+i, pow5+i+1); } - mp_init_ul(pow5_13, 1220703125); + mp_init_u64(pow5_13, 1220703125); for (i = 1; i < 5; ++i) { mp_init(pow5_13 + i); mp_sqr(pow5_13 + i - 1, pow5_13 + i); @@ -4503,7 +4503,7 @@ Tcl_InitBignumFromDouble( Tcl_WideInt w = (Tcl_WideInt) ldexp(fract, mantBits); int shift = expt - mantBits; - mp_init_ll(b, w); + mp_init_i64(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 0ae187a..c54d78a 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -79,16 +79,13 @@ #define TclBN_mp_div_2d mp_div_2d #define TclBN_mp_exch mp_exch #define TclBN_mp_get_mag_u64 mp_get_mag_u64 -#define TclBN_mp_get_mag_ul mp_get_mag_ul #define TclBN_mp_grow mp_grow #define TclBN_mp_init mp_init #define TclBN_mp_init_copy mp_init_copy #define TclBN_mp_init_multi mp_init_multi #define TclBN_mp_init_size mp_init_size -#define TclBN_mp_init_l mp_init_l #define TclBN_mp_init_i64 mp_init_i64 #define TclBN_mp_init_u64 mp_init_u64 -#define TclBN_mp_init_ul mp_init_ul #define TclBN_mp_lshd mp_lshd #define TclBN_mp_mod mp_mod #define TclBN_mp_mod_2d mp_mod_2d @@ -101,7 +98,6 @@ #define TclBN_mp_reverse mp_reverse #define TclBN_mp_read_radix mp_read_radix #define TclBN_mp_rshd mp_rshd -#define TclBN_mp_set_l mp_set_l #define TclBN_mp_set_i64 mp_set_i64 #define TclBN_mp_set_u64 mp_set_u64 #define TclBN_mp_shrink mp_shrink @@ -147,13 +143,13 @@ static int TclSockMinimumBuffersOld(int sock, int size) mp_err TclBN_mp_set_int(mp_int *a, unsigned long i) { - mp_set_ul(a, i); + mp_set_u64(a, i); return MP_OKAY; } static mp_err TclBN_mp_set_long(mp_int *a, unsigned long i) { - mp_set_ul(a, i); + mp_set_u64(a, i); return MP_OKAY; } @@ -198,11 +194,6 @@ mp_err TclBN_mp_init_set(mp_int *a, unsigned int b) { mp_err TclBN_mp_mul_d(const mp_int *a, unsigned int b, mp_int *c) { return mp_mul_d(a, b, c); } -void TclBN_mp_set(mp_int *a, unsigned int b) { - mp_set(a, b); -} - - #if defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 # define TclBN_mp_expt_d_ex 0 @@ -210,9 +201,13 @@ void TclBN_mp_set(mp_int *a, unsigned int b) { # define TclBN_mp_to_unsigned_bin_n 0 # undef TclBN_mp_toradix_n # define TclBN_mp_toradix_n 0 +# undef TclBN_mp_sqr # define TclBN_mp_sqr 0 # undef TclBN_mp_div_3 # define TclBN_mp_div_3 0 +# define TclBN_mp_init_l 0 +# define TclBN_mp_init_ul 0 +# define TclBN_mp_set 0 # define TclSetStartupScriptPath 0 # define TclGetStartupScriptPath 0 # define TclSetStartupScriptFileName 0 @@ -278,6 +273,20 @@ void TclBN_reverse(unsigned char *s, int len) } } +mp_err TclBN_mp_init_ul(mp_int *a, unsigned long b) +{ + return TclBN_mp_init_u64(a,b); +} + +mp_err TclBN_mp_init_l(mp_int *a, long b) +{ + return TclBN_mp_init_i64(a,b); +} + +void TclBN_mp_set(mp_int *a, unsigned int b) { + mp_set_u64(a, b); +} + mp_err TclBN_mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) { if (maxlen < 0) { @@ -1129,8 +1138,8 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_set_u64, /* 68 */ TclBN_mp_get_mag_u64, /* 69 */ TclBN_mp_set_i64, /* 70 */ - TclBN_mp_get_mag_ul, /* 71 */ - TclBN_mp_set_l, /* 72 */ + 0, /* 71 */ + 0, /* 72 */ TclBN_mp_tc_and, /* 73 */ TclBN_mp_tc_or, /* 74 */ TclBN_mp_tc_xor, /* 75 */ diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 45579f4..e059ba0 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -75,7 +75,7 @@ declare 16 { mp_err MP_WUR TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q, mp_int *r) } declare 17 {deprecated {is private function in libtommath}} { - mp_err MP_WUR TclBN_mp_div_3(const mp_int *a, mp_int *q, unsigned int *r) + mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, unsigned int *r) } declare 18 { void TclBN_mp_exch(mp_int *a, mp_int *b) @@ -140,11 +140,11 @@ declare 37 { declare 38 { mp_err MP_WUR TclBN_mp_shrink(mp_int *a) } -declare 39 { +declare 39 {deprecated {macro calling mp_set_u64}} { void TclBN_mp_set(mp_int *a, unsigned int b) } -declare 40 {nostub {is private function in libtommath}} { - mp_err MP_WUR TclBN_mp_sqr(const mp_int *a, mp_int *b) +declare 40 {deprecated {is private function in libtommath}} { + mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b) } declare 41 { mp_err MP_WUR TclBN_mp_sqrt(const mp_int *a, mp_int *b) @@ -211,17 +211,17 @@ declare 59 {deprecated {is private function in libtommath}} { declare 60 {deprecated {is private function in libtommath}} { mp_err TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) } -declare 61 { - mp_err MP_WUR TclBN_mp_init_ul(mp_int *a, unsigned long i) +declare 61 {deprecated {macro calling mp_init_u64}} { + mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i) } -declare 62 { +declare 62 {deprecated {macro calling mp_set_u64}} { void TclBN_mp_set_ul(mp_int *a, unsigned long i) } declare 63 { int MP_WUR TclBN_mp_cnt_lsb(const mp_int *a) } -declare 64 { - int MP_WUR TclBN_mp_init_l(mp_int *bignum, long initVal) +declare 64 {deprecated {macro calling mp_init_i64}} { + int TclBN_mp_init_l(mp_int *bignum, long initVal) } declare 65 { int MP_WUR TclBN_mp_init_i64(mp_int *bignum, int64_t initVal) @@ -244,22 +244,16 @@ declare 69 { declare 70 { void TclBN_mp_set_i64(mp_int *a, int64_t i) } -declare 71 { - unsigned long MP_WUR TclBN_mp_get_mag_ul(const mp_int *a) -} -declare 72 { - void TclBN_mp_set_l(mp_int *a, long i) -} # Added in libtommath 1.1.0 -declare 73 { - mp_err MP_WUR TclBN_mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c) +declare 73 {deprecated {merged with mp_and}} { + mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c) } -declare 74 { - mp_err MP_WUR TclBN_mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c) +declare 74 {deprecated {merged with mp_or}} { + mp_err TclBN_mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c) } -declare 75 { - mp_err MP_WUR TclBN_mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c) +declare 75 {deprecated {merged with mp_xor}} { + mp_err TclBN_mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c) } declare 76 { mp_err MP_WUR TclBN_mp_signed_rsh(const mp_int *a, int b, mp_int *c) diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index caa2f05..4c80770 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -11,8 +11,4 @@ #include <tommath.h> #include "tclTomMathDecls.h" -#undef mp_iseven -#undef mp_isodd -#define mp_iseven(a) (!mp_isodd(a)) -#define mp_isodd(a) (((a)->used != 0 && (((a)->dp[0] & 1) != 0)) ? MP_YES : MP_NO) #endif diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 159cf8f..34e0ec1 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -89,16 +89,13 @@ MODULE_SCOPE mp_err TclBN_s_mp_expt_u32(const mp_int *a, unsigned int b, mp_int #define mp_expt_d_ex TclBN_mp_expt_d_ex #define mp_get_bit TclBN_mp_get_bit #define mp_get_mag_u64 TclBN_mp_get_mag_u64 -#define mp_get_mag_ul TclBN_mp_get_mag_ul #define mp_grow TclBN_mp_grow #define mp_init TclBN_mp_init #define mp_init_copy TclBN_mp_init_copy #define mp_init_i64 TclBN_mp_init_i64 -#define mp_init_l TclBN_mp_init_l #define mp_init_multi TclBN_mp_init_multi #define mp_init_size TclBN_mp_init_size #define mp_init_u64 TclBN_mp_init_u64 -#define mp_init_ul TclBN_mp_init_ul #define mp_lshd TclBN_mp_lshd #define mp_mod TclBN_mp_mod #define mp_mod_2d TclBN_mp_mod_2d @@ -110,10 +107,7 @@ MODULE_SCOPE mp_err TclBN_s_mp_expt_u32(const mp_int *a, unsigned int b, mp_int #define mp_radix_size TclBN_mp_radix_size #define mp_read_radix TclBN_mp_read_radix #define mp_rshd TclBN_mp_rshd -#define mp_set_l TclBN_mp_set_l #define mp_set_i64 TclBN_mp_set_i64 -#define mp_set_ul TclBN_mp_set_ul -#define mp_set_ull TclBN_mp_set_ull #define mp_shrink TclBN_mp_shrink #define mp_sqrt TclBN_mp_sqrt #define mp_sub TclBN_mp_sub @@ -145,10 +139,10 @@ MODULE_SCOPE mp_err TclBN_s_mp_expt_u32(const mp_int *a, unsigned int b, mp_int #define s_mp_toom_sqr TclBN_mp_toom_sqr #endif /* !TCL_WITH_EXTERNAL_TOMMATH */ -#define mp_init_set_int(a,i) (MP_DEPRECATED_PRAGMA("replaced by mp_init_ul") TclBN_mp_init_ul(a,(unsigned int)(i))) -#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_ul((a),((unsigned int)(b))),MP_OKAY)) -#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_ul((a),(b)),MP_OKAY)) -#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_u64") (TclBN_mp_set_ull((a),(b)),MP_OKAY)) +#define mp_init_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_init_ul") TclBN_mp_init_u64(a,(unsigned int)(b))) +#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_u64((a),((unsigned int)(b))),MP_OKAY)) +#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_u64((a),(long)(b)),MP_OKAY)) +#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ull") (TclBN_mp_set_u64((a),(b)),MP_OKAY)) #define mp_unsigned_bin_size(mp) (MP_DEPRECATED_PRAGMA("replaced by mp_ubin_size") (int)TclBN_mp_ubin_size(mp)) #undef TCL_STORAGE_CLASS @@ -220,8 +214,8 @@ EXTERN mp_err TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q, mp_int *r) MP_WUR; /* 17 */ TCL_DEPRECATED("is private function in libtommath") -mp_err MP_WUR TclBN_mp_div_3(const mp_int *a, mp_int *q, - unsigned int *r) MP_WUR; +mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, + unsigned int *r); /* 18 */ EXTERN void TclBN_mp_exch(mp_int *a, mp_int *b); /* 19 */ @@ -272,9 +266,11 @@ EXTERN void TclBN_mp_rshd(mp_int *a, int shift); /* 38 */ EXTERN mp_err TclBN_mp_shrink(mp_int *a) MP_WUR; /* 39 */ -EXTERN void TclBN_mp_set(mp_int *a, unsigned int b); +TCL_DEPRECATED("macro calling mp_set_u64") +void TclBN_mp_set(mp_int *a, unsigned int b); /* 40 */ -EXTERN mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b) MP_WUR; +TCL_DEPRECATED("is private function in libtommath") +mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b); /* 41 */ EXTERN mp_err TclBN_mp_sqrt(const mp_int *a, mp_int *b) MP_WUR; /* 42 */ @@ -342,13 +338,16 @@ TCL_DEPRECATED("is private function in libtommath") mp_err TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c); /* 61 */ -EXTERN mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i) MP_WUR; +TCL_DEPRECATED("macro calling mp_init_u64") +mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i); /* 62 */ -EXTERN void TclBN_mp_set_ul(mp_int *a, unsigned long i); +TCL_DEPRECATED("macro calling mp_set_u64") +void TclBN_mp_set_ul(mp_int *a, unsigned long i); /* 63 */ EXTERN int TclBN_mp_cnt_lsb(const mp_int *a) MP_WUR; /* 64 */ -EXTERN int TclBN_mp_init_l(mp_int *bignum, long initVal) MP_WUR; +TCL_DEPRECATED("macro calling mp_init_i64") +int TclBN_mp_init_l(mp_int *bignum, long initVal); /* 65 */ EXTERN int TclBN_mp_init_i64(mp_int *bignum, int64_t initVal) MP_WUR; /* 66 */ @@ -363,19 +362,20 @@ EXTERN void TclBN_mp_set_u64(mp_int *a, uint64_t i); EXTERN uint64_t TclBN_mp_get_mag_u64(const mp_int *a) MP_WUR; /* 70 */ EXTERN void TclBN_mp_set_i64(mp_int *a, int64_t i); -/* 71 */ -EXTERN unsigned long TclBN_mp_get_mag_ul(const mp_int *a) MP_WUR; -/* 72 */ -EXTERN void TclBN_mp_set_l(mp_int *a, long i); +/* Slot 71 is reserved */ +/* Slot 72 is reserved */ /* 73 */ -EXTERN mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b, - mp_int *c) MP_WUR; +TCL_DEPRECATED("merged with mp_and") +mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b, + mp_int *c); /* 74 */ -EXTERN mp_err TclBN_mp_tc_or(const mp_int *a, const mp_int *b, - mp_int *c) MP_WUR; +TCL_DEPRECATED("merged with mp_or") +mp_err TclBN_mp_tc_or(const mp_int *a, const mp_int *b, + mp_int *c); /* 75 */ -EXTERN mp_err TclBN_mp_tc_xor(const mp_int *a, const mp_int *b, - mp_int *c) MP_WUR; +TCL_DEPRECATED("merged with mp_xor") +mp_err TclBN_mp_tc_xor(const mp_int *a, const mp_int *b, + mp_int *c); /* 76 */ EXTERN mp_err TclBN_mp_signed_rsh(const mp_int *a, int b, mp_int *c) MP_WUR; @@ -413,7 +413,7 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_div_d) (const mp_int *a, unsigned int b, mp_int *q, unsigned int *r) MP_WUR; /* 14 */ mp_err (*tclBN_mp_div_2) (const mp_int *a, mp_int *q) MP_WUR; /* 15 */ mp_err (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r) MP_WUR; /* 16 */ - TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_mp_div_3) (const mp_int *a, mp_int *q, unsigned int *r) MP_WUR; /* 17 */ + TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_mp_div_3) (const mp_int *a, mp_int *q, unsigned int *r); /* 17 */ void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */ mp_err (*tclBN_mp_expt_u32) (const mp_int *a, unsigned int b, mp_int *c) MP_WUR; /* 19 */ mp_err (*tclBN_mp_grow) (mp_int *a, int size) MP_WUR; /* 20 */ @@ -435,8 +435,8 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix) MP_WUR; /* 36 */ void (*tclBN_mp_rshd) (mp_int *a, int shift); /* 37 */ mp_err (*tclBN_mp_shrink) (mp_int *a) MP_WUR; /* 38 */ - void (*tclBN_mp_set) (mp_int *a, unsigned int b); /* 39 */ - TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_mp_sqr) (const mp_int *a, mp_int *b) MP_WUR; /* 40 */ + TCL_DEPRECATED_API("macro calling mp_set_u64") void (*tclBN_mp_set) (mp_int *a, unsigned int b); /* 39 */ + TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_mp_sqr) (const mp_int *a, mp_int *b); /* 40 */ mp_err (*tclBN_mp_sqrt) (const mp_int *a, mp_int *b) MP_WUR; /* 41 */ mp_err (*tclBN_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 42 */ mp_err (*tclBN_mp_sub_d) (const mp_int *a, unsigned int b, mp_int *c) MP_WUR; /* 43 */ @@ -457,21 +457,21 @@ typedef struct TclTomMathStubs { TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 58 */ TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_s_mp_sqr) (const mp_int *a, mp_int *b); /* 59 */ TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_s_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 60 */ - mp_err (*tclBN_mp_init_ul) (mp_int *a, unsigned long i) MP_WUR; /* 61 */ - void (*tclBN_mp_set_ul) (mp_int *a, unsigned long i); /* 62 */ + TCL_DEPRECATED_API("macro calling mp_init_u64") mp_err (*tclBN_mp_init_ul) (mp_int *a, unsigned long i); /* 61 */ + TCL_DEPRECATED_API("macro calling mp_set_u64") void (*tclBN_mp_set_ul) (mp_int *a, unsigned long i); /* 62 */ int (*tclBN_mp_cnt_lsb) (const mp_int *a) MP_WUR; /* 63 */ - int (*tclBN_mp_init_l) (mp_int *bignum, long initVal) MP_WUR; /* 64 */ + TCL_DEPRECATED_API("macro calling mp_init_i64") int (*tclBN_mp_init_l) (mp_int *bignum, long initVal); /* 64 */ int (*tclBN_mp_init_i64) (mp_int *bignum, int64_t initVal) MP_WUR; /* 65 */ int (*tclBN_mp_init_u64) (mp_int *bignum, uint64_t initVal) MP_WUR; /* 66 */ TCL_DEPRECATED_API("Use mp_expt_u32") mp_err (*tclBN_mp_expt_d_ex) (const mp_int *a, unsigned int b, mp_int *c, int fast); /* 67 */ void (*tclBN_mp_set_u64) (mp_int *a, uint64_t i); /* 68 */ uint64_t (*tclBN_mp_get_mag_u64) (const mp_int *a) MP_WUR; /* 69 */ void (*tclBN_mp_set_i64) (mp_int *a, int64_t i); /* 70 */ - unsigned long (*tclBN_mp_get_mag_ul) (const mp_int *a) MP_WUR; /* 71 */ - void (*tclBN_mp_set_l) (mp_int *a, long i); /* 72 */ - mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 73 */ - mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 74 */ - mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c) MP_WUR; /* 75 */ + void (*reserved71)(void); + void (*reserved72)(void); + TCL_DEPRECATED_API("merged with mp_and") mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */ + TCL_DEPRECATED_API("merged with mp_or") mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 74 */ + TCL_DEPRECATED_API("merged with mp_xor") mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 75 */ mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c) MP_WUR; /* 76 */ TCL_DEPRECATED_API("is private function in libtommath") mp_bool (*tclBN_mp_get_bit) (const mp_int *a, unsigned int b); /* 77 */ int (*tclBN_mp_to_ubin) (const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) MP_WUR; /* 78 */ @@ -633,10 +633,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_get_mag_u64) /* 69 */ #define TclBN_mp_set_i64 \ (tclTomMathStubsPtr->tclBN_mp_set_i64) /* 70 */ -#define TclBN_mp_get_mag_ul \ - (tclTomMathStubsPtr->tclBN_mp_get_mag_ul) /* 71 */ -#define TclBN_mp_set_l \ - (tclTomMathStubsPtr->tclBN_mp_set_l) /* 72 */ +/* Slot 71 is reserved */ +/* Slot 72 is reserved */ #define TclBN_mp_tc_and \ (tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */ #define TclBN_mp_tc_or \ @@ -676,7 +674,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; #define TclBNInitBignumFromLong(a,b) \ do { \ (a)->dp = NULL; \ - (void)mp_init_l((a),(b)); \ + (void)mp_init_i64((a),(b)); \ if ((a)->dp == NULL) { \ Tcl_Panic("initialization failure in TclBNInitBignumFromLong"); \ } \ @@ -699,11 +697,32 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt"); \ } \ } while (0) -#define mp_init_i32(a,b) mp_init_l((a),(int32_t)(b)) -#define mp_init_ll(a,b) mp_init_i64((a),(b)) +#undef mp_get_ll +#define mp_get_ll(a) ((long long)mp_get_i64(a)) +#undef mp_set_ll +#define mp_set_ll(a,b) mp_set_i64(a,b) +#undef mp_init_ll +#define mp_init_ll(a,b) mp_init_i64(a,b) +#undef mp_get_ull +#define mp_get_ull(a) ((unsigned long long)mp_get_i64(a)) +#undef mp_set_ull +#define mp_set_ull(a,b) mp_set_u64(a,b) +#undef mp_init_ull +#define mp_init_ull(a,b) mp_init_u64(a,b) +#undef mp_set +#define mp_set(a,b) mp_set_i64((a),(int32_t)(b)) +#define mp_set_i32(a,b) mp_set_i64((a),(int32_t)(b)) +#define mp_set_l(a,b) mp_set_i64((a),(long)(b)) +#define mp_set_u32(a,b) mp_set_u64((a),(uint32_t)(b)) +#define mp_set_ul(a,b) mp_set_u64((a),(unsigned long)(b)) +#define mp_init_i32(a,b) mp_init_i64((a),(int32_t)(b)) +#define mp_init_l(a,b) mp_init_i64((a),(long)(b)) #define mp_init_u32(a,b) mp_init_u64((a),(uint32_t)(b)) -#define mp_init_ull(a,b) mp_init_u64((a),(b)) - +#define mp_init_ul(a,b) mp_init_u64((a),(unsigned long)(b)) +#undef mp_iseven +#undef mp_isodd +#define mp_iseven(a) (!mp_isodd(a)) +#define mp_isodd(a) (((a)->used != 0 && (((a)->dp[0] & 1) != 0)) ? MP_YES : MP_NO) #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT |