Patchwork libgo patch committed: Fix hash function for big-endian 32bit systems

login
register
mail settings
Submitter Ian Taylor
Date Feb. 14, 2012, 6:02 p.m.
Message ID <mcrhaytb8ex.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/141157/
State New
Headers show

Comments

Ian Taylor - Feb. 14, 2012, 6:02 p.m.
This libgo patch fixes the identity hash function for big-endian 32-bit
systems.  Before this patch the hash code for a 32-bit value always
turned out to be zero on a big-endian 32-bit system.  This patch fixes
the problem.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r fcaf380a2380 libgo/runtime/go-type-identity.c
--- a/libgo/runtime/go-type-identity.c	Mon Feb 13 16:31:57 2012 -0800
+++ b/libgo/runtime/go-type-identity.c	Tue Feb 14 09:59:20 2012 -0800
@@ -32,7 +32,10 @@ 
       } u;
       u.v = 0;
       __builtin_memcpy (&u.a, key, key_size);
-      return (uintptr_t) u.v;
+      if (sizeof (uintptr_t) >= 8)
+	return (uintptr_t) u.v;
+      else
+	return (uintptr_t) ((u.v >> 32) ^ (u.v & 0xffffffff));
     }
 
   ret = 5381;