X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flibpspp%2Fhmap-test.c;h=c7f4e5c8841c3c34e7b297b061df80f79a350838;hb=38492a3d6a1b4400357fb18aa17ecef9d9066cbb;hp=c8619a0511f5b60545e70d574798c2392f477243;hpb=b9a86e50c9e9631c98fea4b56732de92044e880b;p=pspp diff --git a/tests/libpspp/hmap-test.c b/tests/libpspp/hmap-test.c index c8619a0511..c7f4e5c884 100644 --- a/tests/libpspp/hmap-test.c +++ b/tests/libpspp/hmap-test.c @@ -287,7 +287,18 @@ typedef size_t hash_function (int data); static size_t identity_hash (int data) { - return data; + size_t hash; + int i; + + hash = 0; + for (i = 0; i < 32; i++) + if (data & (1u << i)) + { + size_t high_bit = (size_t) 1 << (sizeof (size_t) * CHAR_BIT - 1); + hash |= high_bit >> i; + } + + return hash; } static size_t @@ -684,7 +695,7 @@ test_insert_ordered (int max_elems, hash_function *hash) int max = INT_MIN; int j; - for (j = 0; j <= hmap.mask; j++) + for (j = 0; j < hmap_n_buckets (&hmap); j++) { int count = 0; struct hmap_node *node;