[Libvir] Windows sizeof(long) != Linux sizeof(long)

Richard W.M. Jones rjones at redhat.com
Wed Jan 23 08:39:46 UTC 2008

Daniel P. Berrange wrote:
> Just discovered that on x86_64,  Windows and Linux differ in what they
> think sizeof(long) to be.
>   http://lists.xensource.com/archives/html/xen-devel/2008-01/msg00736.html
>   http://www.winehq.org/pipermail/wine-devel/2005-July/038602.html

Oh yes.  I haven't even tried Windows x86-64 (only 32 bit Windows).  I 
don't think there is even a version of MinGW which is available for it.

Another problem is going to be for all the places that we assume long == 
sizeof pointer (eg. all the XDR code, written originally for Sun OS 4 on 
SparcStations).  At least gcc warns about this one.  Portable XDR 
library coming up soon.

>   Windows i686:    sizeof(long) == 4,  sizeof(void*) == 4
>   Windows x86_64:  sizeof(long) == 4,  sizeof(void*) == 8
>   Linux i686:    sizeof(long) == 4,  sizeof(void*) == 4
>   Linux x86_64:  sizeof(long) == 8,  sizeof(void*) == 8
> Unfortunately we have a number of APIs which use 'long' in the public header
> file for dealing with VM memory. Fortunately they are all using memory in
> size of KB, so we are not totally doomed until people start wanting to 
> manage VMs with > 2 TB of RAM.  Also fortunately, the wire-encoding for
> these APIs all uses hyper, so on the wire everything is 64-bit guarenteed.
> Eventually though we might want to consider adding

This has come up before.  _Please_ can we use the definitions in 
stdint.h!  We want integers of a specific size, so let's use integers of 
a specific size, not just guess about what the size might be.


Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080123/c22920e4/attachment-0001.bin>

More information about the libvir-list mailing list