Re: [PATCH 4/4] asm-generic/bitsperlong.h: Add sanity checks for __BITS_PER_LONG

Arnd Bergmann
2026-01-19T21:40:14Z

On Mon, Jan 19, 2026, at 22:12, H. Peter Anvin wrote:
> On 2026-01-19 07:39, Thomas Weißschuh wrote:
>>>
>>> Do we actually support any compilers which *don't* define __SIZEOF_LONG__?
>>
>> When building the kernel not. I used this pattern because it is used
>> further up in the file. There it makes sense as it is actually a userspace
>> header which needs to support all kinds of compilers.
>> But this new check is gated behind __KERNEL__ anyways...
>> For the next revision I will move it into the regular kernel-internal
>> bitsperlong.h. That will be less confusing and still handle the vDSO build,
>> due to the way our header hierarchy works.
>>
>
> The point is that we can simply do:
>
> #define __BITS_PER_LONG (__SIZEOF_LONG__ << 3)
>
> ... and it will always be consistent.

We have discussed this before, but decided it was too early to
assume that userspace compilers are recent enough for that.
According to godbolt.org, gcc-4.1 lacks __SIZEOF_LONG__ while
gcc-4.4 has it, as do all versions of clang. Not sure what other
compilers one may encounter using Linux kernel headers.

Arnd