diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-13 21:22:11 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-13 21:22:11 (GMT) |
commit | 676312d822af3fa126c18f6ba91f183a868f4259 (patch) | |
tree | 53fd54aeef287d9f96e9194d5a13e22504c81681 | |
parent | be44843404a002a18aca9b059109c34cb538a8f3 (diff) | |
parent | 9eeefad066a16a6e9a3407178f7629a8cd4c0e61 (diff) | |
download | tcl-676312d822af3fa126c18f6ba91f183a868f4259.zip tcl-676312d822af3fa126c18f6ba91f183a868f4259.tar.gz tcl-676312d822af3fa126c18f6ba91f183a868f4259.tar.bz2 |
Merge 8.7
-rw-r--r-- | generic/tclTomMathDecls.h | 3 | ||||
-rw-r--r-- | libtommath/bn_mp_mul.c | 6 | ||||
-rw-r--r-- | libtommath/tommath_private.h | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 9a13a1a..d6d8baf 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -589,6 +589,9 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; #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 mp_sqr +#define mp_sqr(a,b) mp_mul(a,a,b) + #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c index 91707cd..b00334d 100644 --- a/libtommath/bn_mp_mul.c +++ b/libtommath/bn_mp_mul.c @@ -12,12 +12,14 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c) digs = a->used + b->used + 1; mp_sign neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG; - if (MP_HAS(S_MP_BALANCE_MUL) && + if (a == b) { + return mp_sqr(a,c); + } else if (MP_HAS(S_MP_BALANCE_MUL) && /* Check sizes. The smaller one needs to be larger than the Karatsuba cut-off. * The bigger one needs to be at least about one MP_KARATSUBA_MUL_CUTOFF bigger * to make some sense, but it depends on architecture, OS, position of the * stars... so YMMV. - * Using it to cut the input into slices small enough for s_mp_mul_digs_fast + * Using it to cut the input into slices small enough for fast_s_mp_mul_digs * was actually slower on the author's machine, but YMMV. */ (min_len >= MP_KARATSUBA_MUL_CUTOFF) && diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h index 7cef443..60c8838 100644 --- a/libtommath/tommath_private.h +++ b/libtommath/tommath_private.h @@ -249,6 +249,9 @@ MP_DEPRECATED(s_mp_toom_mul) mp_err mp_toom_mul(const mp_int *a, const mp_int *b MP_DEPRECATED(s_mp_toom_sqr) mp_err mp_toom_sqr(const mp_int *a, mp_int *b); MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len); +#undef mp_sqr +#define mp_sqr TclBN_mp_sqr + #define MP_GET_ENDIANNESS(x) \ do{\ int16_t n = 0x1; \ |