[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180411081502.GJ4082@hirez.programming.kicks-ass.net>
Date: Wed, 11 Apr 2018 10:15:02 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Joe Perches <joe@...ches.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Andy Whitcroft <apw@...onical.com>, yuankuiz@...eaurora.org,
Linux PM <linux-pm@...r.kernel.org>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Frederic Weisbecker <fweisbec@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
paulmck@...ux.vnet.ibm.com, Ingo Molnar <mingo@...nel.org>,
Len Brown <len.brown@...el.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] checkpatch: Add a --strict test for structs with bool
member definitions
On Tue, Apr 10, 2018 at 03:00:11PM -0700, Andrew Morton wrote:
> On Tue, 10 Apr 2018 14:53:51 -0700 Joe Perches <joe@...ches.com> wrote:
>
> > On Tue, 2018-04-10 at 14:39 -0700, Andrew Morton wrote:
> > > On Tue, 10 Apr 2018 11:19:54 -0700 Joe Perches <joe@...ches.com> wrote:
> > >
> > > > A struct with a bool member can have different sizes on various
> > > > architectures because neither bool size nor alignment is standardized.
> > >
> > > What's wrong with bools in structs?
> >
> > See above.
>
> Yeah, but so what? `long' has different sizes on different
> architectures too.
Right, so we have ILP32/LP64 for all our 32/64 bit archs respectively.
So only 2 possible variations to consider, and if you know your bitness
you know your layout.
(+- some really unfortunate alignment exceptions, the worst of which
Arnd recently removed, hooray!)
But neither says anything about sizeof(_Bool), and the standard leaves
it undefined and only mandates it is large enough to store either 0 or
1 (and I suspect this vagueness is because there are architectures that
either have no byte addressibility or it's more expensive than word
addressibility).
Typically GCC chooses a single byte to represent _Bool, but there are no
guarantees. This means that when you care about structure layout (as we
all really should) things go wobbly when you use _Bool.
If GCC were to guarantee a 1 byte _Bool for all Linux ABIs we could
reconsider.
Powered by blists - more mailing lists