| 1 |
Fromscip-debian debian mlgmp 20021123-23 mlgmp/patches/`0009-Fix-compilation-with-OCaml-5.x.patch`#From.: Stephane Glondu <[email protected]scip-debian . . . identity/`[email protected]`.> |
| 2 |
Datescip-debian debian mlgmp 20021123-23 mlgmp/patches/`0009-Fix-compilation-with-OCaml-5.x.patch`#Date.: Tue, 18 Jun 2024 08:27:50 +0200 |
| 3 |
Subjectscip-debian debian mlgmp 20021123-23 mlgmp/patches/`0009-Fix-compilation-with-OCaml-5.x.patch`#Subject.: Fix compilation with OCaml 5.x |
| 4 |
|
| 5 |
--- |
| 6 |
config.h | 10 +++++----- |
| 7 |
conversions.c | 8 ++++---- |
| 8 |
gmp.ml | 8 ++++---- |
| 9 |
mlgmp_f.c | 26 +++++++++++++------------- |
| 10 |
mlgmp_fr.c | 26 +++++++++++++------------- |
| 11 |
mlgmp_misc.c | 10 +++++----- |
| 12 |
mlgmp_q.c | 20 ++++++++++---------- |
| 13 |
mlgmp_random.c | 2 +- |
| 14 |
mlgmp_z.c | 28 ++++++++++++++-------------- |
| 15 |
9 files changed, 69 insertions(+), 69 deletions(-) |
| 16 |
|
| 17 |
diff --git a/config.hscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`config.h`: b/config.hscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`config.h`: |
| 18 |
index 809a87b..8d93a52 100644 |
| 19 |
--- a/config.h |
| 20 |
+++ b/config.h |
| 21 |
@@ -60,11 +60,11 @@ |
| 22 |
|
| 23 |
#include <stdint.h> |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
+extern void caml_serialize_int_4(int32_t i); |
| 28 |
+extern void caml_serialize_block_1(void * data, long len); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
+extern uint32_t caml_deserialize_uint_4(void); |
| 34 |
+extern int32_t caml_deserialize_sint_4(void); |
| 35 |
+extern void caml_deserialize_block_1(void * data, long len); |
| 36 |
|
| 37 |
#endif /* SERIALIZE */ |
| 38 |
diff --git a/conversions.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`conversions.c`: b/conversions.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`conversions.c`: |
| 39 |
index b57abd1..268d464 100644 |
| 40 |
--- a/conversions.c |
| 41 |
+++ b/conversions.c |
| 42 |
@@ -52,7 +52,7 @@ static inline mpz_t * mpz_val (value val) |
| 43 |
|
| 44 |
static inline value alloc_mpz (void) |
| 45 |
{ |
| 46 |
|
| 47 |
+ return caml_alloc_custom(&_mlgmp_custom_z, |
| 48 |
sizeof(mpz_t), |
| 49 |
0, |
| 50 |
1); |
| 51 |
@@ -76,7 +76,7 @@ static inline mpq_t * mpq_val (value val) |
| 52 |
|
| 53 |
static inline value alloc_mpq (void) |
| 54 |
{ |
| 55 |
|
| 56 |
+ return caml_alloc_custom(&_mlgmp_custom_q, |
| 57 |
sizeof(mpq_t), |
| 58 |
0, |
| 59 |
1); |
| 60 |
@@ -101,7 +101,7 @@ static inline mpf_t * mpf_val (value val) |
| 61 |
|
| 62 |
static inline value alloc_mpf (void) |
| 63 |
{ |
| 64 |
|
| 65 |
+ return caml_alloc_custom(&_mlgmp_custom_f, |
| 66 |
sizeof(mpf_t), |
| 67 |
0, |
| 68 |
1); |
| 69 |
@@ -130,7 +130,7 @@ static inline mp_rnd_t Mode_val (value val) |
| 70 |
|
| 71 |
static inline value alloc_mpfr (void) |
| 72 |
{ |
| 73 |
|
| 74 |
+ return caml_alloc_custom(&_mlgmp_custom_fr, |
| 75 |
sizeof(mpfr_t), |
| 76 |
0, |
| 77 |
1); |
| 78 |
diff --git a/gmp.mlscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`gmp.ml`: b/gmp.mlscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`gmp.ml`: |
| 79 |
index bac73ea..2f0b6ad 100644 |
| 80 |
--- a/gmp.ml |
| 81 |
+++ b/gmp.ml |
| 82 |
@@ -402,10 +402,10 @@ module F = struct |
| 83 |
((if sign < 0 then "-" else "") |
| 84 |
^ (let lm=String.length mantissa |
| 85 |
in if lm > 1 |
| 86 |
|
| 87 |
+ then let tmp = Bytes.create (succ lm) |
| 88 |
in String.blit mantissa 0 tmp 0 1; |
| 89 |
String.blit mantissa 1 tmp 2 (pred lm); |
| 90 |
|
| 91 |
+ Bytes.set tmp 1 '.'; |
| 92 |
Bytes.to_string tmp |
| 93 |
else mantissa) |
| 94 |
^ (if base <= 10 then "E" else "@") |
| 95 |
@@ -540,10 +540,10 @@ module FR = struct |
| 96 |
then "Inf" |
| 97 |
else (let lm=String.length mantissa |
| 98 |
in if lm > 1 |
| 99 |
|
| 100 |
+ then let tmp = Bytes.create (succ lm) |
| 101 |
in String.blit mantissa 0 tmp 0 1; |
| 102 |
String.blit mantissa 1 tmp 2 (pred lm); |
| 103 |
|
| 104 |
+ Bytes.set tmp 1 '.'; |
| 105 |
Bytes.to_string tmp |
| 106 |
else mantissa) |
| 107 |
^ (if base <= 10 then "E" else "@") |
| 108 |
diff --git a/mlgmp_f.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_f.c`: b/mlgmp_f.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_f.c`: |
| 109 |
index c925dcb..8879202 100644 |
| 110 |
--- a/mlgmp_f.c |
| 111 |
+++ b/mlgmp_f.c |
| 112 |
@@ -90,7 +90,7 @@ value _mlgmp_f_to_float(value v) |
| 113 |
{ |
| 114 |
CAMLparam1(v); |
| 115 |
CAMLlocal1(r); |
| 116 |
|
| 117 |
+ r = caml_copy_double(mpf_get_d(*mpf_val(v))); |
| 118 |
CAMLreturn(r); |
| 119 |
} |
| 120 |
|
| 121 |
@@ -101,10 +101,10 @@ value _mlgmp_f_to_string_exp_base_digits(value base, value digits, value val) |
| 122 |
mp_exp_t exponent; |
| 123 |
char *s= mpf_get_str(NULL, &exponent, Int_val(base), Int_val(digits), |
| 124 |
*mpf_val(val)); |
| 125 |
|
| 126 |
|
| 127 |
+ rs=caml_alloc_string(strlen(s)); |
| 128 |
+ strcpy(Bytes_val(rs), s); |
| 129 |
free(s); |
| 130 |
|
| 131 |
+ r=caml_alloc_tuple(2); |
| 132 |
Store_field(r, 0, rs); |
| 133 |
Store_field(r, 1, Val_int(exponent)); |
| 134 |
CAMLreturn(r); |
| 135 |
@@ -284,7 +284,7 @@ value _mlgmp_f_random2(value prec, value nlimbs, value max_exp) |
| 136 |
value _mlgmp_f_initialize() |
| 137 |
{ |
| 138 |
CAMLparam0(); |
| 139 |
|
| 140 |
+ caml_register_custom_operations(& _mlgmp_custom_f); |
| 141 |
CAMLreturn(Val_unit); |
| 142 |
} |
| 143 |
|
| 144 |
@@ -302,18 +302,18 @@ void _mlgmp_f_serialize(value v, |
| 145 |
*wsize_32 = MPF_SIZE_ARCH32; |
| 146 |
*wsize_64 = MPF_SIZE_ARCH64; |
| 147 |
|
| 148 |
|
| 149 |
+ caml_serialize_int_4(mpf_get_prec(*mpf_val(v))); |
| 150 |
|
| 151 |
s = mpf_get_str (NULL, &exponent, 16, 0, *mpf_val(v)); |
| 152 |
len = strlen(s); |
| 153 |
|
| 154 |
+ caml_serialize_int_4(len + 11); |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
+ caml_serialize_block_1("0.", 2); |
| 159 |
+ caml_serialize_block_1(s, len); |
| 160 |
free(s); |
| 161 |
|
| 162 |
sprintf(exponent_buf, "@%08lx", (exponent & 0xFFFFFFFFUL)); |
| 163 |
|
| 164 |
+ caml_serialize_block_1(exponent_buf, 9); |
| 165 |
|
| 166 |
CAMLreturn0; |
| 167 |
} |
| 168 |
@@ -323,11 +323,11 @@ unsigned long _mlgmp_f_deserialize(void * dst) |
| 169 |
char *s; |
| 170 |
int len; |
| 171 |
|
| 172 |
|
| 173 |
+ mpf_init2(*((mpf_t*) dst), caml_deserialize_uint_4()); |
| 174 |
|
| 175 |
|
| 176 |
+ len = caml_deserialize_uint_4(); |
| 177 |
s = malloc(len+1); |
| 178 |
|
| 179 |
+ caml_deserialize_block_1(s, len); |
| 180 |
s[len] = 0; |
| 181 |
mpf_set_str (*((mpf_t*) dst), s, 16); |
| 182 |
free(s); |
| 183 |
diff --git a/mlgmp_fr.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_fr.c`: b/mlgmp_fr.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_fr.c`: |
| 184 |
index 7933bd8..b51c4e4 100644 |
| 185 |
--- a/mlgmp_fr.c |
| 186 |
+++ b/mlgmp_fr.c |
| 187 |
@@ -117,7 +117,7 @@ value _mlgmp_fr_to_float(value mode, value v) |
| 188 |
#ifdef USE_MPFR |
| 189 |
CAMLparam1(v); |
| 190 |
CAMLlocal1(r); |
| 191 |
|
| 192 |
+ r = caml_copy_double(mpfr_get_d(*mpfr_val(v), Mode_val(mode))); |
| 193 |
CAMLreturn(r); |
| 194 |
#else |
| 195 |
unimplemented(to_float); |
| 196 |
@@ -129,7 +129,7 @@ value _mlgmp_fr_to_z_exp(value v) |
| 197 |
#ifdef USE_MPFR |
| 198 |
CAMLparam1(v); |
| 199 |
CAMLlocal2(r, z); |
| 200 |
|
| 201 |
+ r = caml_alloc_tuple(2); |
| 202 |
z = alloc_init_mpz(); |
| 203 |
Store_field(r, 0, z); |
| 204 |
Store_field(r, 1, Val_int(mpfr_get_z_exp(*mpz_val(z), *mpfr_val(v)))); |
| 205 |
@@ -148,10 +148,10 @@ value _mlgmp_fr_to_string_exp_base_digits(value mode, |
| 206 |
mp_exp_t exponent; |
| 207 |
char *s= mpfr_get_str(NULL, &exponent, Int_val(base), Int_val(digits), |
| 208 |
*mpfr_val(val), Mode_val(mode)); |
| 209 |
|
| 210 |
+ rs=caml_alloc_string(strlen(s)); |
| 211 |
strcpy(String_val(rs), s); |
| 212 |
free(s); |
| 213 |
|
| 214 |
+ r=caml_alloc_tuple(2); |
| 215 |
Store_field(r, 0, rs); |
| 216 |
Store_field(r, 1, Val_int(exponent)); |
| 217 |
CAMLreturn(r); |
| 218 |
@@ -404,7 +404,7 @@ value _mlgmp_fr_initialize(void) |
| 219 |
{ |
| 220 |
#ifdef USE_MPFR |
| 221 |
CAMLparam0(); |
| 222 |
|
| 223 |
+ caml_register_custom_operations(& _mlgmp_custom_f); |
| 224 |
CAMLreturn(Val_unit); |
| 225 |
#endif |
| 226 |
} |
| 227 |
@@ -423,18 +423,18 @@ void _mlgmp_fr_serialize(value v, |
| 228 |
*wsize_32 = MPFR_SIZE_ARCH32; |
| 229 |
*wsize_64 = MPFR_SIZE_ARCH64; |
| 230 |
|
| 231 |
|
| 232 |
+ caml_serialize_int_4(mpfr_get_prec(*mpfr_val(v))); |
| 233 |
|
| 234 |
s = mpfr_get_str (NULL, &exponent, 16, 0, *mpfr_val(v), GMP_RNDN); |
| 235 |
len = strlen(s); |
| 236 |
|
| 237 |
+ caml_serialize_int_4(len + 11); |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
+ caml_serialize_block_1("0.", 2); |
| 242 |
+ caml_serialize_block_1(s, len); |
| 243 |
free(s); |
| 244 |
|
| 245 |
sprintf(exponent_buf, "@%08lx", (exponent & 0xFFFFFFFFUL)); |
| 246 |
|
| 247 |
+ caml_serialize_block_1(exponent_buf, 9); |
| 248 |
|
| 249 |
CAMLreturn0; |
| 250 |
} |
| 251 |
@@ -444,11 +444,11 @@ unsigned long _mlgmp_fr_deserialize(void * dst) |
| 252 |
char *s; |
| 253 |
int len; |
| 254 |
|
| 255 |
|
| 256 |
+ mpfr_init2(*((mpfr_t*) dst), caml_deserialize_uint_4()); |
| 257 |
|
| 258 |
|
| 259 |
+ len = caml_deserialize_uint_4(); |
| 260 |
s = malloc(len+1); |
| 261 |
|
| 262 |
+ caml_deserialize_block_1(s, len); |
| 263 |
s[len] = 0; |
| 264 |
mpfr_set_str (*((mpfr_t*) dst), s, 16, GMP_RNDN); |
| 265 |
free(s); |
| 266 |
diff --git a/mlgmp_misc.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_misc.c`: b/mlgmp_misc.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_misc.c`: |
| 267 |
index 56aac98..e36f950 100644 |
| 268 |
--- a/mlgmp_misc.c |
| 269 |
+++ b/mlgmp_misc.c |
| 270 |
@@ -17,8 +17,8 @@ value _mlgmp_get_runtime_version(value dummy) |
| 271 |
{ |
| 272 |
CAMLparam0(); |
| 273 |
CAMLlocal1(r); |
| 274 |
|
| 275 |
|
| 276 |
+ r = caml_alloc_string(strlen(gmp_version)); |
| 277 |
+ strcpy(Bytes_val(r), gmp_version); |
| 278 |
CAMLreturn(r); |
| 279 |
} |
| 280 |
|
| 281 |
@@ -26,7 +26,7 @@ value _mlgmp_get_compile_version(value dummy) |
| 282 |
{ |
| 283 |
CAMLparam0(); |
| 284 |
CAMLlocal1(r); |
| 285 |
|
| 286 |
+ r = caml_alloc_tuple(3); |
| 287 |
Store_field(r, 0, Val_int(__GNU_MP_VERSION)); |
| 288 |
Store_field(r, 1, Val_int(__GNU_MP_VERSION_MINOR)); |
| 289 |
Store_field(r, 2, Val_int(__GNU_MP_VERSION_PATCHLEVEL)); |
| 290 |
@@ -44,10 +44,10 @@ value _mlgmp_is_mpfr_available(value dummy) |
| 291 |
|
| 292 |
void division_by_zero(void) |
| 293 |
{ |
| 294 |
|
| 295 |
+ caml_raise_constant(*caml_named_value("Gmp.Division_by_zero")); |
| 296 |
} |
| 297 |
|
| 298 |
void raise_unimplemented(char *s) |
| 299 |
{ |
| 300 |
|
| 301 |
+ caml_raise_with_string(*caml_named_value("Gmp.Unimplemented"), s); |
| 302 |
} |
| 303 |
diff --git a/mlgmp_q.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_q.c`: b/mlgmp_q.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_q.c`: |
| 304 |
index fe6dffb..7acb013 100644 |
| 305 |
--- a/mlgmp_q.c |
| 306 |
+++ b/mlgmp_q.c |
| 307 |
@@ -93,7 +93,7 @@ value _mlgmp_q_to_float(value v) |
| 308 |
CAMLparam1(v); |
| 309 |
CAMLlocal1(r); |
| 310 |
trace(to_float); |
| 311 |
|
| 312 |
+ r = caml_copy_double(mpq_get_d(*mpq_val(v))); |
| 313 |
CAMLreturn(r); |
| 314 |
} |
| 315 |
|
| 316 |
@@ -177,7 +177,7 @@ value _mlgmp_q_sgn(value a) |
| 317 |
value _mlgmp_q_initialize() |
| 318 |
{ |
| 319 |
CAMLparam0(); |
| 320 |
|
| 321 |
+ caml_register_custom_operations(& _mlgmp_custom_q); |
| 322 |
CAMLreturn(Val_unit); |
| 323 |
} |
| 324 |
|
| 325 |
@@ -195,14 +195,14 @@ void _mlgmp_q_serialize(value v, |
| 326 |
|
| 327 |
s = mpz_get_str (NULL, 16, mpq_numref(*mpq_val(v))); |
| 328 |
len = strlen(s); |
| 329 |
|
| 330 |
|
| 331 |
+ caml_serialize_int_4(len); |
| 332 |
+ caml_serialize_block_1(s, len); |
| 333 |
free(s); |
| 334 |
|
| 335 |
s = mpz_get_str (NULL, 16, mpq_denref(*mpq_val(v))); |
| 336 |
len = strlen(s); |
| 337 |
|
| 338 |
|
| 339 |
+ caml_serialize_int_4(len); |
| 340 |
+ caml_serialize_block_1(s, len); |
| 341 |
free(s); |
| 342 |
|
| 343 |
CAMLreturn0; |
| 344 |
@@ -213,16 +213,16 @@ unsigned long _mlgmp_q_deserialize(void * dst) |
| 345 |
char *s; |
| 346 |
int len; |
| 347 |
|
| 348 |
|
| 349 |
+ len = caml_deserialize_uint_4(); |
| 350 |
s = malloc(len+1); |
| 351 |
|
| 352 |
+ caml_deserialize_block_1(s, len); |
| 353 |
s[len] = 0; |
| 354 |
mpz_init_set_str (mpq_numref(*((mpq_t*) dst)), s, 16); |
| 355 |
free(s); |
| 356 |
|
| 357 |
|
| 358 |
+ len = caml_deserialize_uint_4(); |
| 359 |
s = malloc(len+1); |
| 360 |
|
| 361 |
+ caml_deserialize_block_1(s, len); |
| 362 |
s[len] = 0; |
| 363 |
mpz_init_set_str (mpq_denref(*((mpq_t*) dst)), s, 16); |
| 364 |
free(s); |
| 365 |
diff --git a/mlgmp_random.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_random.c`: b/mlgmp_random.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_random.c`: |
| 366 |
index 3ce451a..10db7eb 100644 |
| 367 |
--- a/mlgmp_random.c |
| 368 |
+++ b/mlgmp_random.c |
| 369 |
@@ -34,7 +34,7 @@ value _mlgmp_randinit_lc(value n) |
| 370 |
{ |
| 371 |
CAMLparam1(n); |
| 372 |
CAMLlocal1(r); |
| 373 |
|
| 374 |
+ r = caml_alloc_custom(&_mlgmp_custom_random, |
| 375 |
sizeof(gmp_randstate_t), |
| 376 |
4, |
| 377 |
1000000); |
| 378 |
diff --git a/mlgmp_z.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_z.c`: b/mlgmp_z.cscip-debian debian mlgmp 20021123-23 mlgmp/upstream/`mlgmp_z.c`: |
| 379 |
index 35d65fc..d29af67 100644 |
| 380 |
--- a/mlgmp_z.c |
| 381 |
+++ b/mlgmp_z.c |
| 382 |
@@ -128,8 +128,8 @@ value _mlgmp_z_to_string_base(value ml_base, value ml_val) |
| 383 |
need a means of shortening the length of a pre-allocated |
| 384 |
Caml string (mpz_sizeinbase sometimes overestimates lengths). */ |
| 385 |
s=mpz_get_str(NULL, base, *mpz_val(ml_val)); |
| 386 |
|
| 387 |
|
| 388 |
+ r=caml_alloc_string(strlen(s)); |
| 389 |
+ strcpy(Bytes_val(r), s); |
| 390 |
free(s); |
| 391 |
|
| 392 |
CAMLreturn(r); |
| 393 |
@@ -145,7 +145,7 @@ value _mlgmp_z_to_float(value v) |
| 394 |
{ |
| 395 |
CAMLparam1(v); |
| 396 |
CAMLlocal1(r); |
| 397 |
|
| 398 |
+ r = caml_copy_double(mpz_get_d(*mpz_val(v))); |
| 399 |
CAMLreturn(r); |
| 400 |
} |
| 401 |
|
| 402 |
@@ -281,7 +281,7 @@ value _mlgmp_z_sqrtrem(value a) |
| 403 |
|
| 404 |
mpz_sqrtrem(*mpz_val(q), *mpz_val(r), *mpz_val(a)); |
| 405 |
|
| 406 |
|
| 407 |
+ qr=caml_alloc_tuple(2); |
| 408 |
Store_field(qr, 0, q); |
| 409 |
Store_field(qr, 1, r); |
| 410 |
CAMLreturn(qr); |
| 411 |
@@ -319,7 +319,7 @@ value _mlgmp_z_##kind##div_qr(value n, value d) \ |
| 412 |
\ |
| 413 |
mpz_##kind##div_qr(*mpz_val(q), *mpz_val(r), *mpz_val(n), *mpz_val(d));\ |
| 414 |
\ |
| 415 |
|
| 416 |
+ qr=caml_alloc_tuple(2); \ |
| 417 |
Store_field(qr, 0, q); \ |
| 418 |
Store_field(qr, 1, r); \ |
| 419 |
CAMLreturn(qr); \ |
| 420 |
@@ -392,7 +392,7 @@ value _mlgmp_z_##kind##div_qr_ui(value n, value d) \ |
| 421 |
\ |
| 422 |
mpz_##kind##div_qr_ui(*mpz_val(q), *mpz_val(r), *mpz_val(n), ui_d); \ |
| 423 |
\ |
| 424 |
|
| 425 |
+ qr=caml_alloc_tuple(2); \ |
| 426 |
Store_field(qr, 0, q); \ |
| 427 |
Store_field(qr, 1, r); \ |
| 428 |
CAMLreturn(qr); \ |
| 429 |
@@ -615,7 +615,7 @@ value _mlgmp_z_gcdext(value a, value b) |
| 430 |
s=alloc_init_mpz(); |
| 431 |
t=alloc_init_mpz(); |
| 432 |
mpz_gcdext(*mpz_val(g), *mpz_val(s), *mpz_val(t), *mpz_val(a), *mpz_val(b)); |
| 433 |
|
| 434 |
+ r=caml_alloc_tuple(3); |
| 435 |
Store_field(r, 0, g); |
| 436 |
Store_field(r, 1, s); |
| 437 |
Store_field(r, 2, t); |
| 438 |
@@ -633,7 +633,7 @@ value _mlgmp_z_invert(value a, value b) |
| 439 |
} |
| 440 |
else |
| 441 |
{ |
| 442 |
|
| 443 |
+ r=caml_alloc_tuple(1); |
| 444 |
Store_field(r, 0, i); |
| 445 |
} |
| 446 |
CAMLreturn(r); |
| 447 |
@@ -668,7 +668,7 @@ value _mlgmp_z_remove(value a, value b) |
| 448 |
CAMLlocal2(f, r); |
| 449 |
f = alloc_init_mpz(); |
| 450 |
x = mpz_remove(*mpz_val(f), *mpz_val(a), *mpz_val(b)); |
| 451 |
|
| 452 |
+ r=caml_alloc_tuple(2); |
| 453 |
Store_field(r, 0, f); |
| 454 |
Store_field(r, 1, Val_int(x)); |
| 455 |
CAMLreturn(r); |
| 456 |
@@ -753,7 +753,7 @@ z_random_op_ui(rrandomb) |
| 457 |
value _mlgmp_z_initialize() |
| 458 |
{ |
| 459 |
CAMLparam0(); |
| 460 |
|
| 461 |
+ caml_register_custom_operations(& _mlgmp_custom_z); |
| 462 |
CAMLreturn(Val_unit); |
| 463 |
} |
| 464 |
|
| 465 |
@@ -771,8 +771,8 @@ void _mlgmp_z_serialize(value v, |
| 466 |
|
| 467 |
s = mpz_get_str (NULL, 16, *mpz_val(v)); |
| 468 |
len = strlen(s); |
| 469 |
|
| 470 |
|
| 471 |
+ caml_serialize_int_4(len); |
| 472 |
+ caml_serialize_block_1(s, len); |
| 473 |
|
| 474 |
free(s); |
| 475 |
CAMLreturn0; |
| 476 |
@@ -783,9 +783,9 @@ unsigned long _mlgmp_z_deserialize(void * dst) |
| 477 |
char *s; |
| 478 |
int len; |
| 479 |
|
| 480 |
|
| 481 |
+ len = caml_deserialize_uint_4(); |
| 482 |
s = malloc(len+1); |
| 483 |
|
| 484 |
+ caml_deserialize_block_1(s, len); |
| 485 |
s[len] = 0; |
| 486 |
mpz_init_set_str (*((mpz_t*) dst), s, 16); |
| 487 |
free(s); |