[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com>
Date: Thu, 10 Sep 2009 16:56:42 -0700
From: David Daney <ddaney@...iumnetworks.com>
To: torvalds@...ux-foundation.org, akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org,
David Daney <ddaney@...iumnetworks.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
ralf@...ux-mips.org, linux-mips@...ux-mips.org,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
linux390@...ibm.com, linux-s390@...r.kernel.org,
David Howells <dhowells@...hat.com>,
Koichi Yasutake <yasutake.koichi@...panasonic.com>,
linux-am33-list@...hat.com, Kyle McMartin <kyle@...artin.ca>,
Helge Deller <deller@....de>, linux-parisc@...r.kernel.org,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>, linuxppc-dev@...abs.org,
Richard Henderson <rth@...ddle.net>,
Ivan Kokshaysky <ink@...assic.park.msu.ru>,
linux-alpha@...r.kernel.org,
Haavard Skinnemoen <hskinnemoen@...el.com>,
Mike Frysinger <vapier@...too.org>,
uclinux-dist-devel@...ckfin.uclinux.org
Subject: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
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 <ddaney@...iumnetworks.com>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Ingo Molnar <mingo@...hat.com>
CC: "H. Peter Anvin" <hpa@...or.com>
CC: x86@...nel.org
CC: ralf@...ux-mips.org
CC: linux-mips@...ux-mips.org
CC: Martin Schwidefsky <schwidefsky@...ibm.com>
CC: Heiko Carstens <heiko.carstens@...ibm.com>
CC: linux390@...ibm.com
CC: linux-s390@...r.kernel.org
CC: David Howells <dhowells@...hat.com>
CC: Koichi Yasutake <yasutake.koichi@...panasonic.com>
CC: linux-am33-list@...hat.com
CC: Kyle McMartin <kyle@...artin.ca>
CC: Helge Deller <deller@....de>
CC: linux-parisc@...r.kernel.org
CC: Benjamin Herrenschmidt <benh@...nel.crashing.org>
CC: Paul Mackerras <paulus@...ba.org>
CC: linuxppc-dev@...abs.org
CC: Richard Henderson <rth@...ddle.net>
CC: Ivan Kokshaysky <ink@...assic.park.msu.ru>
CC: linux-alpha@...r.kernel.org
CC: Haavard Skinnemoen <hskinnemoen@...el.com>
CC: Mike Frysinger <vapier@...too.org>
CC: uclinux-dist-devel@...ckfin.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists