diff options
author | DJ Delorie <dj@redhat.com> | 2013-04-23 04:05:04 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2013-04-23 04:05:04 +0000 |
commit | 29f045bb482a412d4f410f368c333df2dc8c771e (patch) | |
tree | 57cbbd23167e2d0cdef546f093f1f5f5fb6eaf09 /libiberty/hashtab.c | |
parent | a11cfd87c0caa54f54f52fc9712e8994e265d744 (diff) | |
download | gdb-29f045bb482a412d4f410f368c333df2dc8c771e.zip gdb-29f045bb482a412d4f410f368c333df2dc8c771e.tar.gz gdb-29f045bb482a412d4f410f368c333df2dc8c771e.tar.bz2 |
merge from gcc
Diffstat (limited to 'libiberty/hashtab.c')
-rw-r--r-- | libiberty/hashtab.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index dfaec0f..a2fe3ee 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 @@ -988,3 +980,28 @@ 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; + if (sizeof (intptr_t) == 4) + { + /* Mix as 16bit for now */ + a += v >> 16; + b += v & 0xffff; + } + else + { + a += v >> 32; + b += v & 0xffffffff; + } + c = 0x42135234; + mix (a, b, c); + return c; +} |