Re: [PATCH 3/5] rust: sync: support using bool with READ_ONCE

From: Gary Guo

Date: Wed Jan 07 2026 - 13:12:45 EST


On Wed, 7 Jan 2026 09:33:27 +0100
Peter Zijlstra <peterz@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx> 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