Modify obstack.[hc] to avoid having to include other gnulib files
[deliverable/binutils-gdb.git] / libiberty / hashtab.c
index dfaec0f31aeef59dc0263ff1de078515f2b67c23..04607ea6a0167bb2c48a7ac847bc5ac968b3a783 100644 (file)
@@ -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,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;
+}
This page took 0.030559 seconds and 4 git commands to generate.