Why is sizeof(XID)==8 on AMD64?
Matthieu Herrb
matthieu.herrb at laas.fr
Mon Mar 28 07:35:05 PDT 2011
On Mon, Mar 28, 2011 at 04:11:35PM +0200, Clemens Eisserer wrote:
> Hi,
>
> I just ran in a couple of bugs because my code assumes sizeof(XID)==4
> on all platforms which doesn't seem to hold on AMD64.
> Whats the reason for XID to be 8bytes (unsigned long) on AMD64, I
> thought an x-id (in protocol sence) is defined as 4 bytes anyway?
>
> Will Xlib/xcb ever return values which don't fit in 4 bytes? If so, I
> guess I have to change a lot of java-code which assumes this -
> otherwise I would only need to adapt the Java<-->Xlib interface a bit.
>
> Thank you in advance, Clemens
This is a mistake done 25 years ago or so. It's hard to justify it,
but it is so. A number of things that are 32 bits on the wire
are represented as 64 bits long at the API level on LP64 machines.
You have to read the API manual pages carefully and follow them.
Changing the APIs now would break too many things, an no one as ever
considered doing a new major revisition of all those APIs.
The most commonly mis-used API is probably XChangeProperty(), but
others are similarly difficult.
We also just discovered a number of issues in the XI2 API.
--
Matthieu Herrb
More information about the xorg
mailing list