[Bf-committers] AMD64 bit support issues

Ken Hughes khughes at pacific.edu
Fri Oct 28 19:52:07 CEST 2005

Andre De Michiel wrote:
> I'm getting an amd64 box soon and have been looking up some of the
> porting issues myself... maybe a couple of these urls will be helpful
> for you.
> http://gcc.fyxm.net/summit/2003/Porting%20to%2064%20bit.pdf
> http://www.x86-64.org/lists/discuss/msg02621.html
> http://www.intel.com/cd/ids/developer/asmo-na/eng/197664.htm?page=2
> It appears from everything I've read that the 'correct' way to handle
> the pointer<->number issue is make sure it doesn't occur. I honestly
> don't know the blender code that well so I don't know how large a
> challenge this would be :)

Thanks; some good articles there.  Wish it explained a little more how 
other OSes define 64-bit values, but it's clear that just switching to 
long won't solve the problem.

I don't know if we can entirely get away from casting pointers to 
numbers, if for no other reason than we need to compare addresses 
sometimes and I don't know what the C89 standard says about comparing 
two pointers (for example).

I did a little experiment to see what happens in gcc with void *, 
uintptr_t and intptr_t types:

void main()
         void * x, *y;
         int i;
         i = ( (intptr_t)x < (intptr_t)y ); /* test 1 */
         i = ( (uintptr_t)x < (uintptr_t)y ); /* test 2 */
         i = ( x < y ); /* test 3 */

It generated the same code for tests 2 and 3, which is nice (I guess).

So just to get the ball rolling, I'd propose we first just concentrate 
on getting the code to compile using the correct size pointer objects, 
and with the correct comparisons between pointers (<, >, == ).  I 
remember last summer finding something in the mesh edit code which cast 
pointers to unsigned ints in one place and ints in another.  I propose 
we pick a universal type (i.e., one everyone agrees on, not necessarily 
one supported out-of-the-box by each compiler), and then put the 
necessary includes/definitions in one include file (maybe blendef.h) to 
make it easy to find.

The next steps will be getting the code to RUN correctly; the MEM_* 
routines, examining hashing algorithms based on addresses, etc.

(Slightly OT; I'm not a Windows person but have access to the MSDN 
through the university and can get just about all the compilers and OS 
stuff I want.  If I wanted to try compiling for 64-bit WinXP, can anyone 
point me toward what I would need from MSDN?.  Feel free to e-mail me 
outside the list.)


More information about the Bf-committers mailing list