diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-11 19:56:03 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-11 19:56:03 -0800 |
commit | 68fbc5322e282f41e2ee8c84cc16f6b6a4d39670 (patch) | |
tree | 8a8f3a52a29e05d9267d45b7774288450aaffee4 /mpi-patches | |
parent | af4986ea5e82d32f9699d41781f60d9b77ba9748 (diff) | |
download | txr-68fbc5322e282f41e2ee8c84cc16f6b6a4d39670.tar.gz txr-68fbc5322e282f41e2ee8c84cc16f6b6a4d39670.tar.bz2 txr-68fbc5322e282f41e2ee8c84cc16f6b6a4d39670.zip |
Bignum division implemented. More portability bugs found in MPI:
code like 1 << n, where n exceeds the width of the type int.
* arith.c (trunc): New function, reimplementation of removed
trunc from lib.c.
* lib.c (trunc): Removed.
* mpi-patches/fix-bad-shifts: New file.
Diffstat (limited to 'mpi-patches')
-rw-r--r-- | mpi-patches/fix-bad-shifts | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mpi-patches/fix-bad-shifts b/mpi-patches/fix-bad-shifts new file mode 100644 index 00000000..f6e7c979 --- /dev/null +++ b/mpi-patches/fix-bad-shifts @@ -0,0 +1,49 @@ +Index: mpi-1.8.6/mpi.c +=================================================================== +--- mpi-1.8.6.orig/mpi.c 2011-12-11 19:52:15.000000000 -0800 ++++ mpi-1.8.6/mpi.c 2011-12-11 19:53:09.000000000 -0800 +@@ -764,7 +764,7 @@ + if((pow = s_mp_ispow2d(d)) >= 0) { + mp_digit mask; + +- mask = (1 << pow) - 1; ++ mask = ((mp_digit) 1 << pow) - 1; + rem = DIGIT(a, 0) & mask; + + if(q) { +@@ -3068,7 +3068,7 @@ + return; + + /* Flush all the bits above 2^d in its digit */ +- dmask = (1 << nbit) - 1; ++ dmask = ((mp_digit) 1 << nbit) - 1; + dp[ndig] &= dmask; + + /* Flush all digits above the one with 2^d in it */ +@@ -3101,7 +3101,7 @@ + dp = DIGITS(mp); used = USED(mp); + d %= DIGIT_BIT; + +- mask = (1 << d) - 1; ++ mask = ((mp_digit) 1 << d) - 1; + + /* If the shift requires another digit, make sure we've got one to + work with */ +@@ -3149,7 +3149,7 @@ + s_mp_rshd(mp, d / DIGIT_BIT); + d %= DIGIT_BIT; + +- mask = (1 << d) - 1; ++ mask = ((mp_digit) 1 << d) - 1; + + save = 0; + for(ix = USED(mp) - 1; ix >= 0; ix--) { +@@ -3829,7 +3829,7 @@ + if((res = s_mp_pad(a, dig + 1)) != MP_OKAY) + return res; + +- DIGIT(a, dig) |= (1 << bit); ++ DIGIT(a, dig) |= ((mp_digit) 1 << bit); + + return MP_OKAY; + |