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: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules
Date: Thu, 19 Aug 2010 15:24:52 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.1

 On 08/19/2010 11:17 AM, Jes Sorensen wrote:
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.

8-bit processors have 8-bit register size and 16-bit ints. Some processors have 36-bit ints. If you only code for processors which have Linux ports, and for those ports, then everything will be the same. Surprise!

long is the maximum register size in pretty much any sane
setup,

Not on those 8-bit machines.

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.

They did that to avoid portability problems, presumably.

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.

gcc

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.

Not at all, _Bool is smaller or equal to int and thus can only improve packing.

If you want to align explicitly, use alignment attributes.

--
error compiling committee.c: too many arguments to function




reply via email to

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