1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
Description: Fix name collision
Date: Tue Jan 15 12:35:56 2019 +0100
.
Fix Name Collision With Existing LibTomMath Function
.
fixes #1032
Author: Timo Paulssen <timonator@perpetuum-immobile.de>
--- a/src/math/bigintops.c
+++ b/src/math/bigintops.c
@@ -57,23 +57,23 @@
* https://github.com/czurnieden/libtommath/blob/master/bn_mp_get_double.c
* and slightly modified to fit MoarVM's setup.
*/
-static const int mp_get_double_digits_needed
+static const int MVM_mp_get_double_digits_needed
= ((MANTISSA_BITS_IN_DOUBLE + DIGIT_BIT) / DIGIT_BIT) + 1;
-static const double mp_get_double_multiplier = (double)(MP_MASK + 1);
+static const double MVM_mp_get_double_multiplier = (double)(MP_MASK + 1);
-static MVMnum64 mp_get_double(mp_int *a, int shift) {
+static MVMnum64 MVM_mp_get_double_shift(mp_int *a, int shift) {
MVMnum64 d;
int i, limit, final_shift;
d = 0.0;
mp_clamp(a);
i = a->used;
- limit = (i <= mp_get_double_digits_needed)
- ? 0 : i - mp_get_double_digits_needed;
+ limit = (i <= MVM_mp_get_double_digits_needed)
+ ? 0 : i - MVM_mp_get_double_digits_needed;
while (i-- > limit) {
d += a->dp[i];
- d *= mp_get_double_multiplier;
+ d *= MVM_mp_get_double_multiplier;
}
if (a->sign == MP_NEG)
@@ -714,8 +714,8 @@
}
}
else {
- MVMnum64 f_base = mp_get_double(base, 0);
- MVMnum64 f_exp = mp_get_double(exponent, 0);
+ MVMnum64 f_base = MVM_mp_get_double_shift(base, 0);
+ MVMnum64 f_exp = MVM_mp_get_double_shift(exponent, 0);
r = MVM_repr_box_num(tc, num_type, pow(f_base, f_exp));
}
clear_temp_bigints(tmp, 2);
@@ -1082,7 +1082,7 @@
if (MVM_BIGINT_IS_BIG(ba)) {
mp_int *ia = ba->u.bigint;
- return mp_get_double(ia, 0);
+ return MVM_mp_get_double_shift(ia, 0);
} else {
return (double)ba->u.smallint.value;
}
@@ -1132,7 +1132,7 @@
if (mp_div(&scaled, ib, &scaled, NULL) != MP_OKAY)
MVM_exception_throw_adhoc(tc,
"Failed to preform bigint division");
- c = mp_get_double(&scaled, bbits);
+ c = MVM_mp_get_double_shift(&scaled, bbits);
mp_clear(&scaled);
}
clear_temp_bigints(tmp, 2);
|