[PATCH] Fix cast int-to-pointer and pointer-to-int

Paulo César Pereira de Andrade pcpa at mandriva.com.br
Thu Feb 5 10:16:47 PST 2009

Simon Thum wrote:
> Tomas Carnecky wrote:
>> By first casting to long and then to the final type. Of course
>> this assumes that sizeof(long) == sizeof(void *). If the Win32

  Forgive my stupidity, but isn't it a C language rule that
sizeof(long) == sizeof(void *) is always true?

  This of course may have special handling inside the kernel
as one may be using a 32 bit cpu with more then 4GB of RAM,
or just file offsets...

  In Xorg, afaik this is only an issue for physical addresses,
but I don't know if there may be problems when mapping a
"physical address" above 4GB to a 32 bits virtual address.

> On this page:
> http://www.viva64.com/content/articles/64-bit-development/?f=20_issues_of_porting_C++_code_on_the_64-bit_platform.html&lang=en&content=64-bit-development#IDALZBTD

  It appears to be only showing that when sizeof(int) != sizeof(long)
you may have trouble addressing arrays larger then 4GB :-)

> they explain that indeed there are memory models where this doesn't hold.
> +1 for uintptr_t
>> folks care enough about warnings, we could make macros for this.


More information about the xorg mailing list