[Top][All Lists]
[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: |
malc |
Subject: |
Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules |
Date: |
Thu, 19 Aug 2010 16:52:19 +0400 (MSD) |
User-agent: |
Alpine 2.00 (LNX 1167 2008-08-23) |
On Thu, 19 Aug 2010, Avi Kivity wrote:
> 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.
http://blogs.msdn.com/b/oldnewthing/archive/2005/01/31/363790.aspx
>
> > > > 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.
That's not what standard says:
6.2.5#2
An object declared as type _Bool is large enough to store the values 0 and
It later goes on to say (6.7.2.1 fn120):
While the number of bits in a _Bool object is at least CHAR_BIT, the width
(number of sign and value bits) of a _Bool may be just 1 bit.
>
> If you want to align explicitly, use alignment attributes.
>
>
--
mailto:address@hidden
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, (continued)
Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Richard Henderson, 2010/08/17
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Jes Sorensen, 2010/08/17
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/18
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Jes Sorensen, 2010/08/19
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/19
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Jes Sorensen, 2010/08/19
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/19
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules,
malc <=
- Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/19
[Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Paolo Bonzini, 2010/08/18
[Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Jes Sorensen, 2010/08/18
Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Kevin Wolf, 2010/08/18
Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Paolo Bonzini, 2010/08/18
Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/18
Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Paolo Bonzini, 2010/08/19
Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/19
Re: [Qemu-devel] [PATCH 2/5] CODING_STYLE: add C type rules, Avi Kivity, 2010/08/18