diff options
author | sebres <sebres@users.sourceforge.net> | 2019-02-04 09:40:27 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2019-02-04 09:40:27 (GMT) |
commit | 08d4e75deb21fca30944b087b1fffd7ae542aab3 (patch) | |
tree | 61894fa88b8351c451827c3267379ca4fe852686 /generic | |
parent | bcd9ec5103a2be29face2bacfe44187ba8b1bd30 (diff) | |
download | tcl-08d4e75deb21fca30944b087b1fffd7ae542aab3.zip tcl-08d4e75deb21fca30944b087b1fffd7ae542aab3.tar.gz tcl-08d4e75deb21fca30944b087b1fffd7ae542aab3.tar.bz2 |
partial cherry pick of [e8e92eb381d689ab]: One more libtommath function, mp_tc_div_2d, which simplifies code.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclExecute.c | 11 | ||||
-rw-r--r-- | generic/tclStubInit.c | 1 | ||||
-rw-r--r-- | generic/tclTomMath.decls | 4 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 6 |
4 files changed, 12 insertions, 10 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 89e61b8..d1d729a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8520,16 +8520,7 @@ ExecuteExtendedBinaryMathOp( if (opcode == INST_LSHIFT) { mp_mul_2d(&big1, shift, &bigResult); } else { - mp_init(&bigRemainder); - mp_div_2d(&big1, shift, &bigResult, &bigRemainder); - if (mp_cmp_d(&bigRemainder, 0) == MP_LT) { - /* - * Convert to Tcl's integer division rules. - */ - - mp_sub_d(&bigResult, 1, &bigResult); - } - mp_clear(&bigRemainder); + mp_tc_div_2d(&big1, shift, &bigResult); } mp_clear(&big1); BIG_RESULT(&bigResult); diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index ced89c0..1a9a8d5 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -853,6 +853,7 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_tc_and, /* 73 */ TclBN_mp_tc_or, /* 74 */ TclBN_mp_tc_xor, /* 75 */ + TclBN_mp_tc_div_2d, /* 76 */ }; static const TclStubHooks tclStubHooks = { diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 6650067..65178c3 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -248,6 +248,10 @@ declare 74 { declare 75 { int TclBN_mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c) } +declare 76 { + int TclBN_mp_tc_div_2d(const mp_int *a, int b, mp_int *c) +} + # Local Variables: # mode: tcl diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 18739cd..d19df64 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -103,6 +103,7 @@ #define mp_sub TclBN_mp_sub #define mp_sub_d TclBN_mp_sub_d #define mp_tc_and TclBN_mp_tc_and +#define mp_tc_div_2d TclBN_mp_tc_div_2d #define mp_tc_or TclBN_mp_tc_or #define mp_tc_xor TclBN_mp_tc_xor #define mp_to_unsigned_bin TclBN_mp_to_unsigned_bin @@ -319,6 +320,8 @@ EXTERN int TclBN_mp_tc_or(const mp_int *a, const mp_int *b, /* 75 */ EXTERN int TclBN_mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c); +/* 76 */ +EXTERN int TclBN_mp_tc_div_2d(const mp_int *a, int b, mp_int *c); typedef struct TclTomMathStubs { int magic; @@ -395,6 +398,7 @@ typedef struct TclTomMathStubs { int (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */ int (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 74 */ int (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 75 */ + int (*tclBN_mp_tc_div_2d) (const mp_int *a, int b, mp_int *c); /* 76 */ } TclTomMathStubs; extern const TclTomMathStubs *tclTomMathStubsPtr; @@ -551,6 +555,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_tc_or) /* 74 */ #define TclBN_mp_tc_xor \ (tclTomMathStubsPtr->tclBN_mp_tc_xor) /* 75 */ +#define TclBN_mp_tc_div_2d \ + (tclTomMathStubsPtr->tclBN_mp_tc_div_2d) /* 76 */ #endif /* defined(USE_TCL_STUBS) */ |