Skip to content

Commit 8386f58

Browse files
seehearfeelarndb
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 <xry111@xry111.site> Link: https://lore.kernel.org/all/d3e255e4746de44c9903c4433616d44ffcf18d1b.camel@xry111.site/ Suggested-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/linux-arch/a3a4f48a-07d4-4ed9-bc53-5d383428bdd2@app.fastmail.com/ Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 3b1ddbb commit 8386f58

File tree

9 files changed

+25
-102
lines changed

9 files changed

+25
-102
lines changed

arch/arm64/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

arch/loongarch/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

arch/riscv/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

include/uapi/asm-generic/bitsperlong.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22
#ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG
33
#define _UAPI__ASM_GENERIC_BITS_PER_LONG
44

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/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/
12+
*/
13+
#if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__)
14+
#define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__)
15+
#else
516
/*
617
* There seems to be no way of detecting this automatically from user
718
* space, so 64 bit architectures should override this in their
819
* bitsperlong.h. In particular, an architecture that supports
920
* both 32 and 64 bit user space must not rely on CONFIG_64BIT
1021
* to decide it, but rather check a compiler provided macro.
1122
*/
12-
#ifndef __BITS_PER_LONG
1323
#define __BITS_PER_LONG 32
1424
#endif
25+
#endif
1526

1627
#endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */

tools/arch/arm64/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

tools/arch/loongarch/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

tools/arch/riscv/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 14 deletions
This file was deleted.
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/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/
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 */

tools/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#if defined(__i386__) || defined(__x86_64__)
33
#include "../../../arch/x86/include/uapi/asm/bitsperlong.h"
4-
#elif defined(__aarch64__)
5-
#include "../../../arch/arm64/include/uapi/asm/bitsperlong.h"
64
#elif defined(__powerpc__)
75
#include "../../../arch/powerpc/include/uapi/asm/bitsperlong.h"
86
#elif defined(__s390__)
@@ -13,12 +11,8 @@
1311
#include "../../../arch/mips/include/uapi/asm/bitsperlong.h"
1412
#elif defined(__ia64__)
1513
#include "../../../arch/ia64/include/uapi/asm/bitsperlong.h"
16-
#elif defined(__riscv)
17-
#include "../../../arch/riscv/include/uapi/asm/bitsperlong.h"
1814
#elif defined(__alpha__)
1915
#include "../../../arch/alpha/include/uapi/asm/bitsperlong.h"
20-
#elif defined(__loongarch__)
21-
#include "../../../arch/loongarch/include/uapi/asm/bitsperlong.h"
2216
#else
2317
#include <asm-generic/bitsperlong.h>
2418
#endif

0 commit comments

Comments
 (0)