Package: mlgmp / 20021123-19

0004-Fix-wrong-conversion-from-int-on-64-bits-computers.patch Patch series | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
From: Mehdi Dogguy <mehdi@debian.org>
Date: Mon, 17 Jul 2017 09:54:18 +0200
Subject: Fix wrong conversion from int on 64 bits computers
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

Author: Jean-Christophe FilliĆ¢tre
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=573978
---
 mlgmp_z.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/mlgmp_z.c b/mlgmp_z.c
index 35c8583..35d65fc 100644
--- a/mlgmp_z.c
+++ b/mlgmp_z.c
@@ -70,7 +70,7 @@ value _mlgmp_z_from_int(value ml_val)
   CAMLparam1(ml_val);
   CAMLlocal1(r);
   r=alloc_mpz();
-  mpz_init_set_si(*mpz_val(r), Int_val(ml_val));
+  mpz_init_set_si(*mpz_val(r), Long_val(ml_val)); /* FIX */
   CAMLreturn(r);
 }
 
@@ -95,7 +95,7 @@ value _mlgmp_z_from_float(value ml_val)
 value _mlgmp_z2_from_int(value r, value ml_val)
 {
   CAMLparam2(r, ml_val);
-  mpz_set_si(*mpz_val(r), Int_val(ml_val));
+  mpz_set_si(*mpz_val(r), Long_val(ml_val));
   CAMLreturn(Val_unit);
 }
 
@@ -158,14 +158,14 @@ value _mlgmp_z_##op(value a, value b)		        \
   CAMLparam2(a, b);                                     \
   CAMLlocal1(r);                                        \
   r=alloc_init_mpz();				        \
-  mpz_##op(*mpz_val(r), *mpz_val(a), Int_val(b));	\
+  mpz_##op(*mpz_val(r), *mpz_val(a), Long_val(b));	\
   CAMLreturn(r);					\
 }                                                       \
                                                         \
 value _mlgmp_z2_##op(value r, value a, value b)		\
 {							\
   CAMLparam3(r, a, b);                                  \
-  mpz_##op(*mpz_val(r), *mpz_val(a), Int_val(b));	\
+  mpz_##op(*mpz_val(r), *mpz_val(a), Long_val(b));	\
   CAMLreturn(Val_unit);					\
 }
 
@@ -203,7 +203,7 @@ value _mlgmp_z_powm_ui(value a, value b, value modulus)
   CAMLparam3(a, b, modulus);
   CAMLlocal1(r);
   r=alloc_init_mpz();
-  mpz_powm_ui(*mpz_val(r), *mpz_val(a), Int_val(b), *mpz_val(modulus));
+  mpz_powm_ui(*mpz_val(r), *mpz_val(a), Long_val(b), *mpz_val(modulus));
   CAMLreturn(r);
 }
 
@@ -212,7 +212,7 @@ value _mlgmp_z_ui_pow_ui(value a, value b)
   CAMLparam2(a, b);
   CAMLlocal1(r);
   r=alloc_init_mpz();
-  mpz_ui_pow_ui(*mpz_val(r), Int_val(a), Int_val(b));
+  mpz_ui_pow_ui(*mpz_val(r), Long_val(a), Long_val(b));
   CAMLreturn(r);
 }
 
@@ -228,14 +228,14 @@ value _mlgmp_z_powm(value a, value b, value modulus)
 value _mlgmp_z2_powm_ui(value r, value a, value b, value modulus)
 {
   CAMLparam4(r, a, b, modulus);
-  mpz_powm_ui(*mpz_val(r), *mpz_val(a), Int_val(b), *mpz_val(modulus));
+  mpz_powm_ui(*mpz_val(r), *mpz_val(a), Long_val(b), *mpz_val(modulus));
   CAMLreturn(Val_unit);
 }
 
 value _mlgmp_z2_ui_pow_ui(value r, value a, value b)
 {
   CAMLparam3(r, a, b);
-  mpz_ui_pow_ui(*mpz_val(r), Int_val(a), Int_val(b));
+  mpz_ui_pow_ui(*mpz_val(r), Long_val(a), Long_val(b));
   CAMLreturn(Val_unit);
 }
 
@@ -383,7 +383,7 @@ value _mlgmp_z_##kind##div_qr_ui(value n, value d)			\
 {									\
   CAMLparam2(n, d);                                                     \
   CAMLlocal3(q, r, qr);							\
-  unsigned long int ui_d = Int_val(d);					\
+  unsigned long int ui_d = Long_val(d);					\
 									\
   if (! ui_d) division_by_zero();					\
 									\
@@ -402,7 +402,7 @@ value _mlgmp_z_##kind##div_q_ui(value n, value d)			\
 {									\
   CAMLparam2(n, d);                                                     \
   CAMLlocal1(q);       							\
-  unsigned long int ui_d = Int_val(d);					\
+  unsigned long int ui_d = Long_val(d);					\
 									\
  if (! ui_d) division_by_zero();					\
 									\
@@ -416,7 +416,7 @@ value _mlgmp_z_##kind##div_q_ui(value n, value d)			\
 value _mlgmp_z2_##kind##div_q_ui(value q, value n, value d)		\
 {									\
   CAMLparam3(q, n, d);                                                     \
-  unsigned long int ui_d = Int_val(d);					\
+  unsigned long int ui_d = Long_val(d);					\
 									\
  if (! ui_d) division_by_zero();					\
 									\
@@ -429,7 +429,7 @@ value _mlgmp_z_##kind##div_r_ui(value n, value d)			\
 {									\
   CAMLparam2(n, d);                                                     \
   CAMLlocal1(r);       							\
-  unsigned long int ui_d = Int_val(d);					\
+  unsigned long int ui_d = Long_val(d);					\
 									\
   if (! ui_d) division_by_zero();					\
 									\
@@ -443,7 +443,7 @@ value _mlgmp_z_##kind##div_r_ui(value n, value d)			\
 value _mlgmp_z2_##kind##div_r_ui(value r, value n, value d)		\
 {									\
   CAMLparam3(r, n, d);                                                  \
-  unsigned long int ui_d = Int_val(d);					\
+  unsigned long int ui_d = Long_val(d);					\
 									\
  if (! ui_d) division_by_zero();					\
 									\
@@ -455,7 +455,7 @@ value _mlgmp_z2_##kind##div_r_ui(value r, value n, value d)		\
 value _mlgmp_z_##kind##div_ui(value n, value d)				\
 {									\
   CAMLparam2(n, d);                                                     \
-  unsigned long int ui_d = Int_val(d);					\
+  unsigned long int ui_d = Long_val(d);					\
 									\
   if (! ui_d) division_by_zero();					\
 									\
@@ -499,7 +499,7 @@ value _mlgmp_z_##op(value n, value d)		\
 {						\
   CAMLparam2(n, d);				\
   CAMLlocal1(q);				\
-  unsigned int ld = Int_val(d);			\
+  unsigned int ld = Long_val(d);			\
 						\
   if (! ld)	                 		\
     division_by_zero();				\
@@ -514,7 +514,7 @@ value _mlgmp_z_##op(value n, value d)		\
 value _mlgmp_z2_##op(value q, value n, value d)	\
 {						\
   CAMLparam3(q, n, d);				\
-  unsigned int ld = Int_val(d);			\
+  unsigned int ld = Long_val(d);			\
 						\
   if (! ld)			                \
     division_by_zero();				\
@@ -591,7 +591,7 @@ value _mlgmp_z_compare(value a, value b)
 value _mlgmp_z_compare_si(value a, value b)
 {
   CAMLparam2(a, b);
-  CAMLreturn(Val_int(mpz_cmp_si(*mpz_val(a), Int_val(b))));
+  CAMLreturn(Val_int(mpz_cmp_si(*mpz_val(a), Long_val(b))));
 }
 
 /*** Number theory */
@@ -652,13 +652,13 @@ z_int_binary_op(jacobi)
 value _mlgmp_z_kronecker_si(value a, value b)
 {
   CAMLparam2(a, b);
-  CAMLreturn(Val_int(mpz_kronecker_si(*mpz_val(a), Int_val(b))));
+  CAMLreturn(Val_int(mpz_kronecker_si(*mpz_val(a), Long_val(b))));
 }
 
 value _mlgmp_z_si_kronecker(value a, value b)
 {
   CAMLparam2(a, b);
-  CAMLreturn(Val_int(mpz_si_kronecker(Int_val(a), *mpz_val(b))));
+  CAMLreturn(Val_int(mpz_si_kronecker(Long_val(a), *mpz_val(b))));
 }
 
 value _mlgmp_z_remove(value a, value b)
@@ -680,7 +680,7 @@ value _mlgmp_z_##op(value a)			\
   CAMLparam1(a);				\
   CAMLlocal1(r);				\
   r = alloc_init_mpz();				\
-  mpz_##op(*mpz_val(r), Int_val(a));		\
+  mpz_##op(*mpz_val(r), Long_val(a));		\
   CAMLreturn(r);				\
 }
 
@@ -693,7 +693,7 @@ value _mlgmp_z_bin_uiui(value n, value k)
   CAMLparam2(n, k);
   CAMLlocal1(r);
   r = alloc_init_mpz();
-  mpz_bin_uiui(*mpz_val(r), Int_val(n), Int_val(k));
+  mpz_bin_uiui(*mpz_val(r), Long_val(n), Long_val(k));
   CAMLreturn(r);
 }
 
@@ -718,7 +718,7 @@ z_int_binary_op(hamdist)
 value _mlgmp_z_##op(value a, value b)				\
 {								\
   CAMLparam2(a, b);						\
-  CAMLreturn(Val_int(mpz_##op(*mpz_val(a), Int_val(b))));	\
+  CAMLreturn(Val_int(mpz_##op(*mpz_val(a), Long_val(b))));	\
 }
 
 z_int_binary_op_ui(scan0)
@@ -731,7 +731,7 @@ value _mlgmp_z_##op(value state, value n)			\
   CAMLparam2(state, n);						\
   CAMLlocal1(r);						\
   r = alloc_init_mpz();						\
-  mpz_##op(*mpz_val(r), *randstate_val(state), Int_val(n));	\
+  mpz_##op(*mpz_val(r), *randstate_val(state), Long_val(n));	\
   CAMLreturn(r);						\
 }