Commit f811f585 authored by Thomas Huth's avatar Thomas Huth Committed by Paul Walmsley
Browse files

riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers



While the GCC and Clang compilers already define __ASSEMBLER__
automatically when compiling assembly code, __ASSEMBLY__ is a
macro that only gets defined by the Makefiles in the kernel.
This can be very confusing when switching between userspace
and kernelspace coding, or when dealing with uapi headers that
rather should use __ASSEMBLER__ instead. So let's standardize on
the __ASSEMBLER__ macro that is provided by the compilers now.

This originally was a completely mechanical patch (done with a
simple "sed -i" statement), with some manual fixups during
rebasing of the patch later.

Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-riscv@lists.infradead.org
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/r/20250606070952.498274-3-thuth@redhat.com


Signed-off-by: default avatarPaul Walmsley <pjw@kernel.org>
parent 35ebe003
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

#ifdef CONFIG_RISCV_ALTERNATIVE

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__

.macro ALT_ENTRY oldptr newptr vendor_id patch_id new_len
	.4byte \oldptr - .
@@ -53,7 +53,7 @@
#define __ALTERNATIVE_CFG(...)		ALTERNATIVE_CFG __VA_ARGS__
#define __ALTERNATIVE_CFG_2(...)	ALTERNATIVE_CFG_2 __VA_ARGS__

#else /* !__ASSEMBLY__ */
#else /* !__ASSEMBLER__ */

#include <asm/asm.h>
#include <linux/stringify.h>
@@ -98,7 +98,7 @@
	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1)	\
	ALT_NEW_CONTENT(vendor_id_2, patch_id_2, enable_2, new_c_2)

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, CONFIG_k)	\
	__ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, IS_ENABLED(CONFIG_k))
@@ -109,7 +109,7 @@
				   new_c_2, vendor_id_2, patch_id_2, IS_ENABLED(CONFIG_k_2))

#else /* CONFIG_RISCV_ALTERNATIVE */
#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__

.macro ALTERNATIVE_CFG old_c
	\old_c
@@ -118,12 +118,12 @@
#define __ALTERNATIVE_CFG(old_c, ...)		ALTERNATIVE_CFG old_c
#define __ALTERNATIVE_CFG_2(old_c, ...)		ALTERNATIVE_CFG old_c

#else /* !__ASSEMBLY__ */
#else /* !__ASSEMBLER__ */

#define __ALTERNATIVE_CFG(old_c, ...)		old_c "\n"
#define __ALTERNATIVE_CFG_2(old_c, ...)		old_c "\n"

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#define _ALTERNATIVE_CFG(old_c, ...)		__ALTERNATIVE_CFG(old_c)
#define _ALTERNATIVE_CFG_2(old_c, ...)		__ALTERNATIVE_CFG_2(old_c)
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@

#include <asm/alternative-macros.h>

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#ifdef CONFIG_RISCV_ALTERNATIVE

+3 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@

#ifdef CONFIG_MMU

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__

#define __ASM_EXTABLE_RAW(insn, fixup, type, data)	\
	.pushsection	__ex_table, "a";		\
@@ -25,7 +25,7 @@
	__ASM_EXTABLE_RAW(\insn, \fixup, EX_TYPE_FIXUP, 0)
	.endm

#else /* __ASSEMBLY__ */
#else /* __ASSEMBLER__ */

#include <linux/bits.h>
#include <linux/stringify.h>
@@ -77,7 +77,7 @@
			    EX_DATA_REG(ADDR, addr)				\
			  ")")

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#else /* CONFIG_MMU */
	#define _ASM_EXTABLE_UACCESS_ERR(insn, fixup, err)
+5 −5
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#ifndef _ASM_RISCV_ASM_H
#define _ASM_RISCV_ASM_H

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__
#define __ASM_STR(x)	x
#else
#define __ASM_STR(x)	#x
@@ -30,7 +30,7 @@
#define SRLI		__REG_SEL(srliw, srli)

#if __SIZEOF_POINTER__ == 8
#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__
#define RISCV_PTR		.dword
#define RISCV_SZPTR		8
#define RISCV_LGPTR		3
@@ -40,7 +40,7 @@
#define RISCV_LGPTR		"3"
#endif
#elif __SIZEOF_POINTER__ == 4
#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__
#define RISCV_PTR		.word
#define RISCV_SZPTR		4
#define RISCV_LGPTR		2
@@ -69,7 +69,7 @@
#error "Unexpected __SIZEOF_SHORT__"
#endif

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__
#include <asm/asm-offsets.h>

/* Common assembly source macros */
@@ -194,6 +194,6 @@
#define ASM_NOKPROBE(name)
#endif

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#endif /* _ASM_RISCV_ASM_H */
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 * Author: Jee Heng Sia <jeeheng.sia@starfivetech.com>
 */

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
#error "Only include this from assembly code"
#endif

Loading