T
tbroberg
I have some pretty heavily optimized old code written to be nice and
portable in a 32-bit environment.
In places, it needs to check the lowest few bits of various pointers
for alignment.
Now I am porting this code to 64-bit environments including MS and
gcc, and whatever modern and near-future systems my customers and
customers-to-be are likely to run on.
I need to cast pointers of arbitrary size to any arbitrary integer
class with at least 3 bits of length and then look at those few bits.
What are some good options to do this portably?
My best idea so far is to cast to a ptr_diff_t. Seems like that would
have to be an integer type which would have a strong tendency to be te
same size as the pointer type.
How big are the problems with that?
Any better ideas?
Thanks,
- Tim.
portable in a 32-bit environment.
In places, it needs to check the lowest few bits of various pointers
for alignment.
Now I am porting this code to 64-bit environments including MS and
gcc, and whatever modern and near-future systems my customers and
customers-to-be are likely to run on.
I need to cast pointers of arbitrary size to any arbitrary integer
class with at least 3 bits of length and then look at those few bits.
What are some good options to do this portably?
My best idea so far is to cast to a ptr_diff_t. Seems like that would
have to be an integer type which would have a strong tendency to be te
same size as the pointer type.
How big are the problems with that?
Any better ideas?
Thanks,
- Tim.