X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libiberty%2Fhashtab.c;h=04607ea6a0167bb2c48a7ac847bc5ac968b3a783;hb=f91ca6bc00c1e3c70c1d2f4527d4297b76e2eaca;hp=359e3ea569ec084fb58fda182cb0a3526ad20420;hpb=219a461e6c1b65b12a6b08ba167560c00dd2174d;p=external%2Fbinutils.git diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index 359e3ea..04607ea 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -194,14 +194,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 @@ -333,9 +325,9 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f, /* -@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size}, -htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f}, -htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f}, +@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size}, @ +htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f}, @ +htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f}, @ htab_free @var{free_f}) This function creates a hash table that uses two different allocators @@ -988,3 +980,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; +}