Starting with version 4.5, GCC has a new built-in function __builtin_unreachable() that can be used in places like the kernel's BUG() where inline assembly is used to transfer control flow. This eliminated the need for an endless loop in these places.
The patch adds a new macro 'unreachable()' that will expand to either __builtin_unreachable() or an endless loop depending on the compiler version. Signed-off-by: David Daney <dda...@caviumnetworks.com> CC: Thomas Gleixner <t...@linutronix.de> CC: Ingo Molnar <mi...@redhat.com> CC: "H. Peter Anvin" <h...@zytor.com> CC: x...@kernel.org CC: r...@linux-mips.org CC: linux-m...@linux-mips.org CC: Martin Schwidefsky <schwidef...@de.ibm.com> CC: Heiko Carstens <heiko.carst...@de.ibm.com> CC: linux...@de.ibm.com CC: linux-s...@vger.kernel.org CC: David Howells <dhowe...@redhat.com> CC: Koichi Yasutake <yasutake.koi...@jp.panasonic.com> CC: linux-am33-l...@redhat.com CC: Kyle McMartin <k...@mcmartin.ca> CC: Helge Deller <del...@gmx.de> CC: linux-par...@vger.kernel.org CC: Benjamin Herrenschmidt <b...@kernel.crashing.org> CC: Paul Mackerras <pau...@samba.org> CC: linuxppc-...@ozlabs.org CC: Richard Henderson <r...@twiddle.net> CC: Ivan Kokshaysky <i...@jurassic.park.msu.ru> CC: linux-al...@vger.kernel.org CC: Haavard Skinnemoen <hskinnem...@atmel.com> CC: Mike Frysinger <vap...@gentoo.org> CC: uclinux-dist-de...@blackfin.uclinux.org --- include/linux/compiler-gcc4.h | 14 ++++++++++++++ include/linux/compiler.h | 5 +++++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h index 450fa59..ab3af40 100644 --- a/include/linux/compiler-gcc4.h +++ b/include/linux/compiler-gcc4.h @@ -36,4 +36,18 @@ the kernel context */ #define __cold __attribute__((__cold__)) + +#if __GNUC_MINOR__ >= 5 +/* + * Mark a position in code as unreachable. This can be used to + * suppress control flow warnings after asm blocks that transfer + * control elsewhere. + * + * Early snapshots of gcc 4.5 don't support this and we can't detect + * this in the preprocessor, but we can live with this because they're + * unreleased. Really, we need to have autoconf for the kernel. + */ +#define unreachable() __builtin_unreachable() +#endif + #endif diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 04fb513..7efd73f 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -144,6 +144,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); # define barrier() __memory_barrier() #endif +/* Unreachable code */ +#ifndef unreachable +# define unreachable() do { for (;;) ; } while (0) +#endif + #ifndef RELOC_HIDE # define RELOC_HIDE(ptr, off) \ ({ unsigned long __ptr; \ -- 1.6.2.5 _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev