3 * Copyright 2008-2009 Katholieke Universiteit Leuven
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege, K.U.Leuven, Departement
8 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
13 uint32_t isl_gmp_hash(mpz_t v
, uint32_t hash
)
15 int sa
= v
[0]._mp_size
;
16 int abs_sa
= sa
< 0 ? -sa
: sa
;
17 unsigned char *data
= (unsigned char *)v
[0]._mp_d
;
18 unsigned char *end
= data
+ abs_sa
* sizeof(v
[0]._mp_d
[0]);
21 isl_hash_byte(hash
, 0xFF);
22 for (; data
< end
; ++data
)
23 isl_hash_byte(hash
, *data
);
27 /* This function tries to produce outputs that do not depend on
28 * the version of GMP that is being used.
30 * In particular, when computing the extended gcd of -1 and 9,
31 * some versions will produce
35 * while other versions will produce
39 * If configure detects that we are in the former case, then
40 * mpz_gcdext will be called directly. Otherwise, this function
41 * is called and then we try to mimic the behavior of the other versions.
43 void isl_gmp_gcdext(mpz_t G
, mpz_t S
, mpz_t T
, mpz_t A
, mpz_t B
)
45 if (mpz_divisible_p(B
, A
)) {
46 mpz_set_si(S
, mpz_sgn(A
));
51 if (mpz_divisible_p(A
, B
)) {
53 mpz_set_si(T
, mpz_sgn(B
));
57 mpz_gcdext(G
, S
, T
, A
, B
);