[PATCH 3/5] rust: sync: support using bool with READ_ONCE
Gary Guo
gary at garyguo.net
Wed Jan 7 10:12:40 PST 2026
On Wed, 7 Jan 2026 09:33:27 +0100
Peter Zijlstra <peterz at infradead.org> wrote:
> On Tue, Jan 06, 2026 at 06:12:01PM +0000, Gary Guo wrote:
> > On Tue, 6 Jan 2026 13:43:26 +0100
> > Peter Zijlstra <peterz at infradead.org> wrote:
>
> > > Does this hardcode that sizeof(_Bool) == 1? There are ABIs where this is
> > > not the case.
> >
> > Hi Peter,
> >
> > Do you have a concrete example on which ABI/arch this is not true?
> >
> > I know that the C spec doesn't mandate _Bool and char are of the same size
> > but we have tons of assumptions that is not guaranteed by standard C..
>
> Darwin/PowerPC famously has sizeof(_Bool) == 4
>
> Win32: Visual C++ 4.2 (and earlier) had sizeof(bool)==4 (they mapped
> bool to int), while Visual C++ 5.0 introduced a native _Bool and moved
> to 1 byte.
>
> Early RISC CPUs (MIPS, PowerPC, Alpha) had severe penalties for byte
> access and their compilers would've had sizeof(bool)=={4,8}.
>
> I think AVR/Arduino also has sizeof(bool) == sizeof(int) which is 2.
>
>
It sounds like that none of these matter for the kernel?
In which case I think it's good to keep the assertion; if someone is ought
to introduce a new arch where _Bool (or Rust bool) is not 1 then we should
know about it.
Best,
Gary
More information about the linux-arm-kernel
mailing list