short pointers (32 bit) in 64 bit apps

Nicholas Sherlock n.sherlock@gmail.com
Wed May 19 09:46:00 GMT 2010


On 19/05/2010 8:54 p.m., Reza Roboubi wrote:
> Nicholas Sherlock wrote:
>> On 19/05/2010 3:58 p.m., Reza Roboubi wrote:
>>> Do you know what it takes to do it? How much work for a newcomer to get
>>> up to speed with gcc? (Maybe this should go to the developer list?)
>>
>> You would need to write a memory allocator which divides the address
>> space into 4GB (32-bit pages). Then you could create a new malloc
>> routine which has an extra argument to allow you to allocate memory
>> from within a specified 4GB page. That way you can make all of your
>> allocations for a given data structure lie within the same region.
>
> Since we are trying to _compress_ these structs in the first place
> malloc'ing them individually is pointless anyway. We should probably
> have some sort of custom (fixed size) allocator.

If the pointers only have to refer to memory within the same memory 
allocation, and that allocation is smaller than 4GB, that's a 
significantly more restricted problem. You wouldn't need a custom memory 
allocator, you could just store the difference between the pointer 
target and the pointer's location instead of an absolute pointer. That 
sounds doable.

Cheers,
Nicholas Sherlock



More information about the Gcc-help mailing list