summaryrefslogtreecommitdiff
path: root/gmp-impl.h
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-05-01 01:42:01 +0200
committerKevin Ryde <user42@zip.com.au>2002-05-01 01:42:01 +0200
commit11bd5da26ff090cf5de699287cc2d8ba9670488e (patch)
tree1a6fda4e17c84a7db7153cce9b1a474039c85011 /gmp-impl.h
parenta9cc0fd7fe8376f16e2de4e453517f7836bd7c31 (diff)
downloadgmp-11bd5da26ff090cf5de699287cc2d8ba9670488e.tar.gz
* gmp-impl.h (JACOBI_MOD_OR_MODEXACT_1_ODD): Allow for odd
GMP_NUMB_BITS.
Diffstat (limited to 'gmp-impl.h')
-rw-r--r--gmp-impl.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/gmp-impl.h b/gmp-impl.h
index 88e3e748b..b97f3b5d4 100644
--- a/gmp-impl.h
+++ b/gmp-impl.h
@@ -2650,7 +2650,16 @@ void __gmp_sqrt_of_negative _PROTO ((void)) ATTRIBUTE_NORETURN;
/* Set a_rem to {a_ptr,a_size} reduced modulo b, either using mod_1 or
modexact_1_odd, but in either case leaving a_rem<b. b must be odd and
unsigned. modexact_1_odd effectively calculates -a mod b, and
- result_bit1 is adjusted for the factor of -1. */
+ result_bit1 is adjusted for the factor of -1.
+
+ The way mpn_modexact_1_odd sometimes bases its remainder on a_size and
+ sometimes on a_size-1 means if GMP_NUMB_BITS is odd we can't know what
+ factor to introduce into result_bit1, so for that case use mpn_mod_1
+ unconditionally.
+
+ FIXME: mpn_modexact_1_odd is more efficient, so some way to get it used
+ for odd GMP_NUMB_BITS would be good. Perhaps it could mung its result,
+ or not skip a divide step, or something. */
#define JACOBI_MOD_OR_MODEXACT_1_ODD(result_bit1, a_rem, a_ptr, a_size, b) \
do { \
@@ -2661,7 +2670,8 @@ void __gmp_sqrt_of_negative _PROTO ((void)) ATTRIBUTE_NORETURN;
ASSERT (__a_size >= 1); \
ASSERT (__b & 1); \
\
- if (BELOW_THRESHOLD (__a_size, MODEXACT_1_ODD_THRESHOLD)) \
+ if ((GMP_NUMB_BITS % 2) != 0 \
+ || BELOW_THRESHOLD (__a_size, MODEXACT_1_ODD_THRESHOLD)) \
{ \
(a_rem) = mpn_mod_1 (__a_ptr, __a_size, __b); \
} \