[libvirt] [PATCH] openvz: Fix wordsize on 64 bit architectures

Eric Blake eblake at redhat.com
Tue Jun 19 22:46:18 UTC 2012


On 06/19/2012 04:40 PM, Eric Blake wrote:
> On 06/19/2012 01:11 AM, Guido Günther wrote:
>> On Mon, Jun 18, 2012 at 03:08:39PM -0600, Eric Blake wrote:
>>>> On 06/17/2012 11:18 AM, Guido Günther wrote:
>>>>>> The word size there is 64 bit not 8.
> 
>>>> Do we ever compile openvz on any platform where sizeof(int) = 4?
>>>> Shouldn't this really be checking sizeof(long)?
>> Or the actual pointer size? Patch attached.
> 
> Well, on the new i32 kernel ABI for 64-bit platforms, sizeof(void*)==4
> while sizeof(long)==8; on the other hand, for mingw64, sizeof(void*)==8
> while sizeof(long)==4.  You can't win for all platforms, but for the
> case of openvz, it seems like we are more likely to be compiled on Linux
> where sizeof(long) may indeed be the better choice.
> 
> But I'm okay with your patch to use void*, since the i32 ABI is not
> popular yet.

Correction - the x32 ABI; as mentioned here:
http://kernelnewbies.org/LinuxChanges#head-ec7868ff102658ddea67d09dcedb4a9cb9c60c81

has sizeof(long)==4 to match sizeof(void*), so sizeof(void*) is
reasonable after all.

> 
>> +++ b/src/openvz/openvz_conf.c
>> @@ -195,7 +195,7 @@ virCapsPtr openvzCapsInit(void)
>>      if ((guest = virCapabilitiesAddGuest(caps,
>>                                           "exe",
>>                                           utsname.machine,
>> -                                         sizeof(int) == 4 ? 32 : 64,
>> +                                         sizeof(void*) == 4 ? 32 : 64,
> 
> ACK.

Thus void* really is better than long here.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120619/b7c885d0/attachment-0001.sig>


More information about the libvir-list mailing list