summaryrefslogtreecommitdiffstats
path: root/mpi-patches/fix-bad-shifts
blob: acd77f510cde1ff785979601af003e393eb439f6 (plain)
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
Index: mpi-1.8.6/mpi.c
===================================================================
--- mpi-1.8.6.orig/mpi.c	2015-02-07 19:32:58.456517144 -0800
+++ mpi-1.8.6/mpi.c	2015-02-07 19:33:01.740459238 -0800
@@ -762,7 +762,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) {
@@ -3079,7 +3079,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 */
@@ -3112,7 +3112,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 */
@@ -3160,7 +3160,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--) {
@@ -3840,7 +3840,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;