Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 64 bit addressing



On Friday, June 27, 2003, at 07:05 PM, Mike Vannorsdel wrote:
I haven't seen this asked yet nor did I find it in the archives, so sorry if it's been covered.

Now that the G5 has 64-bit addressing, how do you build your code to use 64-bit pointers with GCC3.3 (so that 'struct foo * bar' is an 8 byte pointer)?

Apart from all the other issues one could talk about, I'll talk about the basic library issue. If you do build a snippet of code using 64-bit pointers, make sure you don't link it with any 32-bit code, including all system libraries (including an existing libSystem.dylib). That code is expecting pointers to be 32-bit -- calling [32-bit] strlen() with a 64-bit pointer quantity may or may not work out. It depends on what the instructions inside the [32-bit] function are doing, and where sizeof(void *)==4 has been hard-coded into them by the compiler, such as in effective address computations. And I doubt that the "indexed" instructions like lswx, when executed by the processor in 32-bit mode, will do the right thing if there is a 64-bit pointer in the source register (except perhaps in 'lucky' situations). Vararg functions or functions with stack-based arguments (where the amount of data for each item on the stack has been hard-coded by compilation) will also be trouble. The same goes for kernel APIs potentially (depends on whether the kernel thinks that vm_address_t, vm_size_t, natural_t, int, and so on are 32-bit or 64-bits inside; though, in some cases it shouldn't matter, like a 32-bit flags argument being passed in, in a larger register).

libSystem could possibly rebuilt 64-bit, if you figure out how to do that (and I don't know). As long as there are no sizeof(void *)==4 assumptions in the C sources or in the hand-coded assembly. And the kernel APIs are still a separate issue that I don't know anything specific about.


If you already have a 32-bit addressed binary, how will the G5 deal with it and what penalties/problems will be encountered vs. 64-bit?

The OS will run the task in 32-bit mode. One would have to test to see if there is a performance difference. If the processor being in a 32-bit mode doesn't affect the bus/memory/cache subsystem (that is, the L1 cache is still filled in the same way with the same speed), then it's conceivable that a 32-bit program may run faster than a 64-bit one for certain operations, like searching through an array of N-bit ints (since the 32-bit program would be loading twice as many 32-bit ints into the L1 cache in the same amount of time), even if there were a small in-processor performance difference.


Chris Kane
CoreFoundation
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >64 bit addressing (From: Mike Vannorsdel <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.