[PATCH] kselftest/riscv: Replace __ASSEMBLY__ with __ASSEMBLER__

Thomas Huth posted 1 patch 1 month, 2 weeks ago
tools/testing/selftests/riscv/cfi/cfi_rv_test.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] kselftest/riscv: Replace __ASSEMBLY__ with __ASSEMBLER__
Posted by Thomas Huth 1 month, 2 weeks ago
From: Thomas Huth <thuth@redhat.com>

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 now
on the __ASSEMBLER__ macro that is provided by the compilers.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tools/testing/selftests/riscv/cfi/cfi_rv_test.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/riscv/cfi/cfi_rv_test.h b/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
index 1c8043f2b778b..184df6903d01c 100644
--- a/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
+++ b/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
@@ -56,7 +56,7 @@
 
 #define CSR_SSP 0x011
 
-#ifdef __ASSEMBLY__
+#ifdef __ASSEMBLER__
 #define __ASM_STR(x)    x
 #else
 #define __ASM_STR(x)    #x
-- 
2.55.0
Re: [PATCH] kselftest/riscv: Replace __ASSEMBLY__ with __ASSEMBLER__
Posted by Paul Walmsley 3 weeks, 6 days ago
On Thu, 13 Aug 2026, Thomas Huth wrote:

> From: Thomas Huth <thuth@redhat.com>
> 
> 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 now
> on the __ASSEMBLER__ macro that is provided by the compilers.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Thanks, queued for v7.3-rc.  Have you considered patching checkpatch.pl to 
catch this problem?  Might save a lot of time.


- Paul
Re: [PATCH] kselftest/riscv: Replace __ASSEMBLY__ with __ASSEMBLER__
Posted by Nick Desaulniers 1 month, 1 week ago
On Thu, Aug 13, 2026 at 12:53 AM Thomas Huth <thuth@redhat.com> wrote:
>
> From: Thomas Huth <thuth@redhat.com>
>
> 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.

Thank you for the patch.

Correct!
$ clang -dM -E -x assembler-with-cpp - < /dev/null | grep ASS
#define __ASSEMBLER__ 1
...

> 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 now
> on the __ASSEMBLER__ macro that is provided by the compilers.

Yes, thanks for cleaning up this legacy cruft. Godspeed on fixing the
rest of the kernel.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tools/testing/selftests/riscv/cfi/cfi_rv_test.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/riscv/cfi/cfi_rv_test.h b/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
> index 1c8043f2b778b..184df6903d01c 100644
> --- a/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
> +++ b/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
> @@ -56,7 +56,7 @@
>
>  #define CSR_SSP 0x011
>
> -#ifdef __ASSEMBLY__
> +#ifdef __ASSEMBLER__
>  #define __ASM_STR(x)    x
>  #else
>  #define __ASM_STR(x)    #x
> --
> 2.55.0
>


-- 
Thanks,
~Nick Desaulniers