isl_dim_map: extract from isl_map.c
[isl.git] / isl_gmp.c
blob0c8db59ae15d1010b8d25a9be9077f09c33c4f73
1 /*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8 */
10 #include <isl/int.h>
12 uint32_t isl_gmp_hash(mpz_t v, uint32_t hash)
14 int sa = v[0]._mp_size;
15 int abs_sa = sa < 0 ? -sa : sa;
16 unsigned char *data = (unsigned char *)v[0]._mp_d;
17 unsigned char *end = data + abs_sa * sizeof(v[0]._mp_d[0]);
19 if (sa < 0)
20 isl_hash_byte(hash, 0xFF);
21 for (; data < end; ++data)
22 isl_hash_byte(hash, *data);
23 return hash;