Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

asm-generic/bitsperlong.h: Add sanity checks for __BITS_PER_LONG

The value of __BITS_PER_LONG from architecture-specific logic should
always match the generic one if that is available. It should also match
the actual C type 'long'.

Mismatches can happen for example when building the compat vDSO. Either
during the compilation, see commit 9a6d3ff10f7f ("arm64: uapi: Provide
correct __BITS_PER_LONG for the compat vDSO"), or when running sparse
when mismatched CHECKFLAGS are inherited from the kernel build.

Add some consistency checks which detect such issues early and clearly.

The kernel-internal BITS_PER_LONG is not checked as it is derived from
CONFIG_64BIT and therefore breaks for the compat vDSO. See the similar,
deactivated check above.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260302-vdso-compat-checkflags-v2-5-78e55baa58ba@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
62357a58 9b444349

+9
+9
include/asm-generic/bitsperlong.h
··· 19 19 #error Inconsistent word size. Check asm/bitsperlong.h 20 20 #endif 21 21 22 + #if __CHAR_BIT__ * __SIZEOF_LONG__ != __BITS_PER_LONG 23 + #error Inconsistent word size. Check asm/bitsperlong.h 24 + #endif 25 + 26 + #ifndef __ASSEMBLER__ 27 + _Static_assert(sizeof(long) * 8 == __BITS_PER_LONG, 28 + "Inconsistent word size. Check asm/bitsperlong.h"); 29 + #endif 30 + 22 31 #ifndef BITS_PER_LONG_LONG 23 32 #define BITS_PER_LONG_LONG 64 24 33 #endif