Skip to content

Commit 7f2b164

Browse files
seehearfeelqmonnet
authored andcommitted
asm-generic: Unify uapi bitsperlong.h for arm64, riscv and loongarch
Now we specify the minimal version of GCC as 5.1 and Clang/LLVM as 11.0.0 in Documentation/process/changes.rst, __CHAR_BIT__ and __SIZEOF_LONG__ are usable, it is probably fine to unify the definition of __BITS_PER_LONG as (__CHAR_BIT__ * __SIZEOF_LONG__) in asm-generic uapi bitsperlong.h. In order to keep safe and avoid regression, only unify uapi bitsperlong.h for some archs such as arm64, riscv and loongarch which are using newer toolchains that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__. Suggested-by: Xi Ruoyao <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Suggested-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/linux-arch/[email protected]/ Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 0839927 commit 7f2b164

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
12
#ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG
23
#define _UAPI__ASM_GENERIC_BITS_PER_LONG
34

5+
#ifndef __BITS_PER_LONG
6+
/*
7+
* In order to keep safe and avoid regression, only unify uapi
8+
* bitsperlong.h for some archs which are using newer toolchains
9+
* that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__.
10+
* See the following link for more info:
11+
* https://lore.kernel.org/linux-arch/[email protected]/
12+
*/
13+
#if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__)
14+
#define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__)
15+
#else
416
/*
517
* There seems to be no way of detecting this automatically from user
618
* space, so 64 bit architectures should override this in their
719
* bitsperlong.h. In particular, an architecture that supports
820
* both 32 and 64 bit user space must not rely on CONFIG_64BIT
921
* to decide it, but rather check a compiler provided macro.
1022
*/
11-
#ifndef __BITS_PER_LONG
1223
#define __BITS_PER_LONG 32
1324
#endif
25+
#endif
1426

1527
#endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */

0 commit comments

Comments
 (0)