[Bf-committers] build error amd64

Ken Hughes khughes at pacific.edu
Fri Nov 25 18:32:34 CET 2005

Mats Holmberg wrote:
> Ken Hughes wrote:
>> Mats Holmberg wrote:
>>> Hi,
>>> trying to build on my new amd64 system ends in the following:
>>>  ......
>> Ive got a commit for this ready, but wanted to talk to Ton first.  In 
>> the meantime, check #3264 in the bug tracker.  You can apply the patch 
>> there and it will build.
>> Ken
> Ok, thanks for that! I'll hold..

Since Ton isn't around on IRC, maybe he'll read this so I can do a commit:

The compiler error in source/kernel/gen_system/GEN_HashedPtr.cpp is 
caused by a function which is generating a hash key for an array index 
from a pointer.  It seems safe for now to let the hash function work on 
either a 32-bit or 64-bit pointer (since it's hashing the lower bits of 
the larger pointer, which should still vary enough to give a good result).

My proposed patch casts the pointer to a matching-sized long object, 
then masks and returns the lower 32-bits.  It should also work under 
64-bit Windows, at least until 64-bit cygwin support exists.  Roughly 
speaking here's the proposed code:

new in source/kernel/gen_system/GEN_HashedPtr.cpp:
unsigned int GEN_Hash(void * inDWord)
#if defined(_WIN64)
     unsigned __int64 key = (unsigned __int64)inDWord;
     unsigned long key = (unsigned long)inDWord;

     key += ~(key << 16);
     key ^=  (key >>  5);
     key +=  (key <<  3);
     key ^=  (key >> 13);
     key += ~(key <<  9);
     key ^=  (key >> 17);

     return (unsigned int)(key & 0xffffffff);

new source/kernel/gen_system/GEN_HashedPtr.h:

unsigned int GEN_Hash(void * inDWord);

More information about the Bf-committers mailing list