Skip to content

Commit

Permalink
unreachable: Unify
Browse files Browse the repository at this point in the history
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@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094311.924381359@infradead.org
  • Loading branch information
Peter Zijlstra committed Dec 2, 2024
1 parent bb81700 commit c837de3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
12 changes: 0 additions & 12 deletions include/linux/compiler-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
10 changes: 7 additions & 3 deletions include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,16 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
#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
Expand Down

0 comments on commit c837de3

Please sign in to comment.