[RFC PATCH V3 21/43] rv64ilp32_abi: asm-generic: Add custom BITS_PER_LONG definition

guoren at kernel.org guoren at kernel.org
Tue Mar 25 05:16:02 PDT 2025


From: "Guo Ren (Alibaba DAMO Academy)" <guoren at kernel.org>

The RV64ILP32 ABI linux kernel is based on CONFIG_64BIT, but
BITS_PER_LONG is 32. So, give a custom architectural definition
of BITS_PER_LONG to match the correct macro definition.

Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren at kernel.org>
---
 arch/riscv/include/uapi/asm/bitsperlong.h | 6 ++++++
 include/asm-generic/bitsperlong.h         | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/arch/riscv/include/uapi/asm/bitsperlong.h b/arch/riscv/include/uapi/asm/bitsperlong.h
index 7d0b32e3b701..fec2ad91597c 100644
--- a/arch/riscv/include/uapi/asm/bitsperlong.h
+++ b/arch/riscv/include/uapi/asm/bitsperlong.h
@@ -9,6 +9,12 @@
 
 #define __BITS_PER_LONG (__SIZEOF_POINTER__ * 8)
 
+#if __BITS_PER_LONG == 64
+#define BITS_PER_LONG 64
+#else
+#define BITS_PER_LONG 32
+#endif
+
 #include <asm-generic/bitsperlong.h>
 
 #endif /* _UAPI_ASM_RISCV_BITSPERLONG_H */
diff --git a/include/asm-generic/bitsperlong.h b/include/asm-generic/bitsperlong.h
index 1023e2a4bd37..7ccbb7ce6610 100644
--- a/include/asm-generic/bitsperlong.h
+++ b/include/asm-generic/bitsperlong.h
@@ -6,7 +6,9 @@
 
 
 #ifdef CONFIG_64BIT
+#ifndef BITS_PER_LONG
 #define BITS_PER_LONG 64
+#endif
 #else
 #define BITS_PER_LONG 32
 #endif /* CONFIG_64BIT */
-- 
2.40.1




More information about the linux-riscv mailing list