summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-20 09:22:29 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-20 09:22:29 (GMT)
commit9af5d96e01768268b83a3e8310d8f2aa03106228 (patch)
tree862fdd08bd30525f7d37d00bc77ab88bb529be20
parentaf20d0a6435b665622c6da5f5460f60bba2a4933 (diff)
parenta3c9570c9f3b6544c471985ca89b8712daafa603 (diff)
downloadtcl-9af5d96e01768268b83a3e8310d8f2aa03106228.zip
tcl-9af5d96e01768268b83a3e8310d8f2aa03106228.tar.gz
tcl-9af5d96e01768268b83a3e8310d8f2aa03106228.tar.bz2
merge trunk
-rw-r--r--libtommath/bn_mp_div_d.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c
index 0e9dc95..d0131c3 100644
--- a/libtommath/bn_mp_div_d.c
+++ b/libtommath/bn_mp_div_d.c
@@ -19,13 +19,8 @@ static int s_is_power_of_two(mp_digit b, int *p)
{
int x;
- /* fast return if no power of two */
- if ((b & (b-1)) != 0) {
- return 0;
- }
-
- /* This loops gives the wrong result for b==1,
- * but this function is never called for those values. */
+ /* Gives the wrong result for b==1, but this function
+ * is never called for this value anyway. */
for (x = 1; x < DIGIT_BIT; x++) {
if (b == (((mp_digit)1)<<x)) {
*p = x;
@@ -60,7 +55,7 @@ int mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d)
}
/* power of two ? */
- if (s_is_power_of_two(b, &ix) == 1) {
+ if (((b & (b-1)) == 0) && s_is_power_of_two(b, &ix)) {
if (d != NULL) {
*d = a->dp[0] & ((((mp_digit)1)<<ix) - 1);
}