summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2013-04-23 04:05:04 +0000
committerDJ Delorie <dj@delorie.com>2013-04-23 04:05:04 +0000
commitce48e99d16abd777e09bf1e9ede2aaa48f542d9a (patch)
tree2f2903f478fb1272068fab61d6f4a46378d129d1 /libiberty
parent5def445818852aca4982a392e2ea6f25297ebd4e (diff)
downloadbinutils-redhat-ce48e99d16abd777e09bf1e9ede2aaa48f542d9a.tar.gz
merge from gcc
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog4
-rw-r--r--libiberty/hashtab.c33
2 files changed, 29 insertions, 8 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 717221dd89..1420ad402f 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-22 Andi Kleen <ak@linux.intel.com>
+
+ * hashtab.c (hash_pointer): Move to end of file and reimplement.
+
2013-04-03 Jason Merrill <jason@redhat.com>
* cp-demangle.c (cplus_demangle_type): Fix function quals.
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index dfaec0f31a..a2fe3ee3bd 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;
+}