From f08200baa9a3306fc4662313bd5c99ecdedf84cf Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Sun, 27 Nov 2005 03:47:17 +0000 Subject: -- Change to make blender with game engine disabled build without errors on 64-bit machines. This code only seems to be used by the game engine anyway; maybe it's only linux which always compiles it regardless of whether game engine is enabled? --- source/kernel/gen_system/GEN_HashedPtr.cpp | 16 +++++++++++++--- source/kernel/gen_system/GEN_HashedPtr.h | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'source/kernel') diff --git a/source/kernel/gen_system/GEN_HashedPtr.cpp b/source/kernel/gen_system/GEN_HashedPtr.cpp index f852530fa53..4da40e6696d 100644 --- a/source/kernel/gen_system/GEN_HashedPtr.cpp +++ b/source/kernel/gen_system/GEN_HashedPtr.cpp @@ -36,9 +36,19 @@ #include #endif -unsigned int GEN_Hash(unsigned int inDWord) +// +// Build hash index from pointer. Even though the final result +// is a 32-bit integer, use all the bits of the pointer as long +// as possible. +// + +unsigned int GEN_Hash(void * inDWord) { - unsigned int key = inDWord; +#if defined(_WIN64) + unsigned __int64 key = (unsigned __int64)inDWord; +#else + unsigned long key = (unsigned long)inDWord; +#endif key += ~(key << 16); key ^= (key >> 5); @@ -47,5 +57,5 @@ unsigned int GEN_Hash(unsigned int inDWord) key += ~(key << 9); key ^= (key >> 17); - return key; + return (unsigned int)(key & 0xffffffff); } diff --git a/source/kernel/gen_system/GEN_HashedPtr.h b/source/kernel/gen_system/GEN_HashedPtr.h index 8fabc9a5516..51a89905409 100644 --- a/source/kernel/gen_system/GEN_HashedPtr.h +++ b/source/kernel/gen_system/GEN_HashedPtr.h @@ -33,14 +33,14 @@ #ifndef __GEN_HASHEDPTR #define __GEN_HASHEDPTR -unsigned int GEN_Hash(unsigned int inDWord); +unsigned int GEN_Hash(void * inDWord); class GEN_HashedPtr { void* m_valptr; public: GEN_HashedPtr(void* val) : m_valptr(val) {}; - unsigned int hash() const { return GEN_Hash((unsigned int) m_valptr);}; + unsigned int hash() const { return GEN_Hash(m_valptr);}; inline friend bool operator ==(const GEN_HashedPtr & rhs, const GEN_HashedPtr & lhs) { return rhs.m_valptr == lhs.m_valptr;}; }; -- cgit v1.2.3