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

tools: Simplify BITS_PER_LONG define

Do it using (__CHAR_BIT__ * __SIZEOF_LONG__), simpler, works everywhere,
reduces the complexity by ditching CONFIG_64BIT, that was being
synthesized from yet another set of defines, which proved fragile,
breaking the build on linux-next for no obvious reasons.

Committer Note:

Except on:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)

Fallback to __WORDSIZE in that case...

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160715072243.GP30154@twins.programming.kicks-ass.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Peter Zijlstra and committed by
Arnaldo Carvalho de Melo
e81fcd43 32a951b4

+2 -21
+2 -21
tools/include/asm-generic/bitsperlong.h
··· 3 3 4 4 #include <uapi/asm-generic/bitsperlong.h> 5 5 6 - /* 7 - * In the kernel, where this file comes from, we can rely on CONFIG_64BIT, 8 - * here we have to make amends with what the various compilers provides us 9 - * to figure out if we're on a 64-bit machine... 10 - */ 11 6 #ifdef __SIZEOF_LONG__ 12 - # if __SIZEOF_LONG__ == 8 13 - # define CONFIG_64BIT 14 - # endif 7 + #define BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__) 15 8 #else 16 - # ifdef __WORDSIZE 17 - # if __WORDSIZE == 64 18 - # define CONFIG_64BIT 19 - # endif 20 - # else 21 - # error Failed to determine BITS_PER_LONG value 22 - # endif 9 + #define BITS_PER_LONG __WORDSIZE 23 10 #endif 24 - 25 - #ifdef CONFIG_64BIT 26 - #define BITS_PER_LONG 64 27 - #else 28 - #define BITS_PER_LONG 32 29 - #endif /* CONFIG_64BIT */ 30 11 31 12 #if BITS_PER_LONG != __BITS_PER_LONG 32 13 #error Inconsistent word size. Check asm/bitsperlong.h