[xproto: PATCH] Xmd.h: amd64-x32 ABI defines sizeof(long) == sizeof (void*) == 4

Alan Coopersmith alan.coopersmith at oracle.com
Wed Dec 28 12:45:03 PST 2011

On 12/28/11 12:29, Lu, Hongjiu wrote:
>>> From: "Lu, Hongjiu"<hongjiu.lu at intel.com>
>>> Date: Wed, 28 Dec 2011 14:34:09 +0000
>>> __AMD64__ is defined when 64bit x86 instruction set is used,
>>> which is true for x32. The difference is x32 doesn't define
>>> __LP64__.
>> Chapter 7, "Development Environment", of the AMD64 ABI (the non-x32
>> version) does not list __LP64__ as a predefined pre-processor symbol.
>> As far as I'm aware, it's just a GCC convention to define __LP64__ for
>> platforms that use the LP64 programming model, and even GCC didn't do
>> so very consistently in the past.
> __LP64__ isn't the part of x86-64 psABI while GCC always define __LP64__
> for 64bit long on x86.  I can check if other compilers do the same.
> In most cases, __amd64__ is checked for 64bit instructions and we have
> ported those we have found so far to x32 so that we can use one __amd64__
> block to support both x32 and x86-64.

C code checking __amd64__ mostly does so to find out the size of long & 
pointers.  Instructions are usually at the assembly level, not the C code level.

It would make far more sense for x32 to declare it's __i386__ with additional
instructions available (much like MMX, SSE, etc.) than to declare that it's
__amd64__ with incompatible types.

	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System

More information about the xorg-devel mailing list