[PATCH v2 10/16] unreachable: Unify

From: Peter Zijlstra
Date: Thu Nov 28 2024 - 04:45:30 EST


Since barrier_before_unreachable() is empty for !GCC it is trivial to
unify the two definitions. Less is more.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
include/linux/compiler-gcc.h | 12 ------------
include/linux/compiler.h | 10 +++++++---
2 files changed, 7 insertions(+), 15 deletions(-)

--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -52,18 +52,6 @@
*/
#define barrier_before_unreachable() asm volatile("")

-/*
- * Mark a position in code as unreachable. This can be used to
- * suppress control flow warnings after asm blocks that transfer
- * control elsewhere.
- */
-#define unreachable() \
- do { \
- annotate_unreachable(); \
- barrier_before_unreachable(); \
- __builtin_unreachable(); \
- } while (0)
-
#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
#define __HAVE_BUILTIN_BSWAP32__
#define __HAVE_BUILTIN_BSWAP64__
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -141,12 +141,16 @@ void ftrace_likely_update(struct ftrace_
#define __annotate_jump_table
#endif /* CONFIG_OBJTOOL */

-#ifndef unreachable
-# define unreachable() do { \
+/*
+ * Mark a position in code as unreachable. This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ */
+#define unreachable() do { \
annotate_unreachable(); \
+ barrier_before_unreachable(); \
__builtin_unreachable(); \
} while (0)
-#endif

/*
* KENTRY - kernel entry point