X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Fhashtab.c;h=9f917c3571d96a6ebd1e472f85bb85787f715a6c;hb=c6cbf900d42cf8f2ebbcf33d799c52c54b9aa9f0;hp=dfaec0f31aeef59dc0263ff1de078515f2b67c23;hpb=d4d868a28076273e828f299e896dbc1af827208a;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index dfaec0f31a..9f917c3571 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -1,6 +1,5 @@ /* An expandable hash tables datatype. - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1999-2019 Free Software Foundation, Inc. Contributed by Vladimir Makarov (vmakarov@cygnus.com). This file is part of the libiberty library. @@ -194,14 +193,6 @@ higher_prime_index (unsigned long n) return low; } -/* Returns a hash code for P. */ - -static hashval_t -hash_pointer (const PTR p) -{ - return (hashval_t) ((intptr_t)p >> 3); -} - /* Returns non-zero if P1 and P2 are equal. */ static int @@ -734,7 +725,7 @@ htab_remove_elt_with_hash (htab_t htab, PTR element, hashval_t hash) PTR *slot; slot = htab_find_slot_with_hash (htab, element, hash, NO_INSERT); - if (*slot == HTAB_EMPTY_ENTRY) + if (slot == NULL) return; if (htab->del_f) @@ -970,17 +961,17 @@ iterative_hash (const PTR k_in /* the key */, c += length; switch(len) /* all the case statements fall through */ { - case 11: c+=((hashval_t)k[10]<<24); - case 10: c+=((hashval_t)k[9]<<16); - case 9 : c+=((hashval_t)k[8]<<8); + case 11: c+=((hashval_t)k[10]<<24); /* fall through */ + case 10: c+=((hashval_t)k[9]<<16); /* fall through */ + case 9 : c+=((hashval_t)k[8]<<8); /* fall through */ /* the first byte of c is reserved for the length */ - case 8 : b+=((hashval_t)k[7]<<24); - case 7 : b+=((hashval_t)k[6]<<16); - case 6 : b+=((hashval_t)k[5]<<8); - case 5 : b+=k[4]; - case 4 : a+=((hashval_t)k[3]<<24); - case 3 : a+=((hashval_t)k[2]<<16); - case 2 : a+=((hashval_t)k[1]<<8); + case 8 : b+=((hashval_t)k[7]<<24); /* fall through */ + case 7 : b+=((hashval_t)k[6]<<16); /* fall through */ + case 6 : b+=((hashval_t)k[5]<<8); /* fall through */ + case 5 : b+=k[4]; /* fall through */ + case 4 : a+=((hashval_t)k[3]<<24); /* fall through */ + case 3 : a+=((hashval_t)k[2]<<16); /* fall through */ + case 2 : a+=((hashval_t)k[1]<<8); /* fall through */ case 1 : a+=k[0]; /* case 0: nothing left to add */ } @@ -988,3 +979,19 @@ iterative_hash (const PTR k_in /* the key */, /*-------------------------------------------- report the result */ return c; } + +/* Returns a hash code for pointer P. Simplified version of evahash */ + +static hashval_t +hash_pointer (const PTR p) +{ + intptr_t v = (intptr_t) p; + unsigned a, b, c; + + a = b = 0x9e3779b9; + a += v >> (sizeof (intptr_t) * CHAR_BIT / 2); + b += v & (((intptr_t) 1 << (sizeof (intptr_t) * CHAR_BIT / 2)) - 1); + c = 0x42135234; + mix (a, b, c); + return c; +}