X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_gmp.c;h=d488fd2eb3038df004452499392aec33363191d7;hb=63fb8a7f484648c3caa25351c8c94ac2395ec563;hp=062276314227eac43f6424cfc30b5b984c0c85d7;hpb=cc726006058136865f8c2f496d3df57b9f937ea5;p=platform%2Fupstream%2Fisl.git diff --git a/isl_gmp.c b/isl_gmp.c index 0622763..d488fd2 100644 --- a/isl_gmp.c +++ b/isl_gmp.c @@ -1,19 +1,24 @@ -#include "isl_int.h" +/* + * Copyright 2008-2009 Katholieke Universiteit Leuven + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, K.U.Leuven, Departement + * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium + */ -u_int32_t isl_gmp_hash(mpz_t v, u_int32_t hash) +#include + +uint32_t isl_gmp_hash(mpz_t v, uint32_t hash) { int sa = v[0]._mp_size; int abs_sa = sa < 0 ? -sa : sa; unsigned char *data = (unsigned char *)v[0]._mp_d; unsigned char *end = data + abs_sa * sizeof(v[0]._mp_d[0]); - if (sa < 0) { - hash *= 16777619; - hash ^= 0xFF; - } - for (; data < end; ++data) { - hash *= 16777619; - hash ^= *data; - } + if (sa < 0) + isl_hash_byte(hash, 0xFF); + for (; data < end; ++data) + isl_hash_byte(hash, *data); return hash; }