diff mbox series

[kvm-unit-tests,2/3] x86: Commit to using __ASSEMBLER__ instead of __ASSEMBLY__

Message ID 20250221225406.2228938-3-seanjc@google.com (mailing list archive)
State New
Headers show
Series x86: Use macros for selectors in asm | expand

Commit Message

Sean Christopherson Feb. 21, 2025, 10:54 p.m. UTC
Convert all two of x86's anti-assembly #ifdefs from __ASSEMBLY__ to
__ASSEMBLER__.  Usage of __ASSEMBLY__ was inherited blindly from the Linux
kernel, and must be manually defined, e.g. through build rules or with
explicit #defines in assembly code.  __ASSEMBLER__ on the other hand is
automatically defined by the compiler when preprocessing assembly, i.e.
doesn't require manually #defines for the code to function correctly.

Convert only x86 for the time being, as x86 doesn't actually rely on
__ASSEMBLY__ (a clever observer will note that it's never #defined on x86).
E.g. trying to include x86's page.h doesn't work as is.  All other
architectures actually rely on __ASSEMBLY__, and will be dealt with
separately.

Note, while only gcc appears to officially document __ASSEMBLER__, clang
has followed suit since at least clang 6.0, and clang 6.0 doesn't come
remotely close to being able to comple KVM-Unit-Tests.

Link: https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 lib/x86/asm/page.h | 4 ++--
 lib/x86/desc.h     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
index 298e7e8e..bc0e78c7 100644
--- a/lib/x86/asm/page.h
+++ b/lib/x86/asm/page.h
@@ -15,7 +15,7 @@  typedef unsigned long pgd_t;
 
 #include <asm-generic/page.h>
 
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
 
 #define PAGE_ALIGN(addr)        ALIGN(addr, PAGE_SIZE)
 
@@ -79,5 +79,5 @@  extern unsigned long long get_amd_sev_addr_upperbound(void);
 #define PGDIR_BITS(lvl)        (((lvl) - 1) * PGDIR_WIDTH + PAGE_SHIFT)
 #define PGDIR_OFFSET(va, lvl)  (((va) >> PGDIR_BITS(lvl)) & PGDIR_MASK)
 
-#endif /* !__ASSEMBLY__ */
+#endif /* !__ASSEMBLER__ */
 #endif
diff --git a/lib/x86/desc.h b/lib/x86/desc.h
index a4459127..aa6213d1 100644
--- a/lib/x86/desc.h
+++ b/lib/x86/desc.h
@@ -57,7 +57,7 @@ 
 #define FIRST_SPARE_SEL 0x50
 #define TSS_MAIN 0x80
 
-#ifdef __ASSEMBLY__
+#ifdef __ASSEMBLER__
 #define __ASM_FORM(x, ...)	x,## __VA_ARGS__
 #else
 #define __ASM_FORM(x, ...)	" " xstr(x,##__VA_ARGS__) " "