qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules


From: Jes Sorensen
Subject: Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules
Date: Thu, 19 Aug 2010 10:17:16 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Thunderbird/3.0.5

On 08/19/10 10:10, Avi Kivity wrote:
>  On 08/19/2010 10:58 AM, Jes Sorensen wrote:
>>
>>> In C99, bool is a real type.
>> Kinda real, I would qualify it more as a pseudo type. It doesn't map to
>> any register size or even instruction actions.
> 
> Neither do int, short, long, long long, or signed short long float.

Well most processors support 32 bit register ops, even when running in
64 bit mode. long is the maximum register size in pretty much any sane
setup, which is why it is such a mess that M$ took the easy way out when
they picked for win64. Tons of user code will have portability problems
because of this.

>> Most processors, at least
>> the ones I have programmed, tend to treat it as zero == false,
>> everything else == true.
> 
> Processors don't have _Bool.

No but something has to generate code to handle it.

>> For structure packing it's ugly.
> 
> Use uint*_t for externally visible structures.  use _Bool for internal
> booleans.

Structure packing is more than passing structures to external processes
or saving them, it's also cache line alignment. In your case we should
change pretty much any data structure in QEMU that is in a critical data
path to use *int*_t.

Jes





reply via email to

[Prev in Thread] Current Thread [Next in Thread]