This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
libgo patch committed: Fix hash function for big-endian 32bit systems
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 14 Feb 2012 10:02:14 -0800
- Subject: libgo patch committed: Fix hash function for big-endian 32bit systems
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
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;