summaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2009-07-25 20:28:57 +0000
committerDavid Daney <daney@gcc.gnu.org>2009-07-25 20:28:57 +0000
commit2df77822ee0974d84b2cb83fba19c4c4f6a3a4b8 (patch)
tree1102dce70bb5ef81361767f9dd212b754f1fbd30 /gcc/system.h
parent1e211590c3288acd5ea6ff4edb94a1efd5ec25f7 (diff)
downloadgcc-2df77822ee0974d84b2cb83fba19c4c4f6a3a4b8.tar.gz
system.h (gcc_assert): Invoke __builtin_unreachable() instead of fancy_abort() if !ENABLE_ASSERT_CHECKING.
* system.h (gcc_assert): Invoke __builtin_unreachable() instead of fancy_abort() if !ENABLE_ASSERT_CHECKING. (gcc_unreachable): Invoke __builtin_unreachable() if !ENABLE_ASSERT_CHECKING. From-SVN: r150091
Diffstat (limited to 'gcc/system.h')
-rw-r--r--gcc/system.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h
index 780fda410ce..51dcf54c1d8 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -576,6 +576,9 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
#if ENABLE_ASSERT_CHECKING
#define gcc_assert(EXPR) \
((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
+#elif (GCC_VERSION >= 4005)
+#define gcc_assert(EXPR) \
+ ((void)(__builtin_expect(!(EXPR), 0) ? __builtin_unreachable(), 0 : 0))
#else
/* Include EXPR, so that unused variable warnings do not occur. */
#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
@@ -583,7 +586,11 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
/* Use gcc_unreachable() to mark unreachable locations (like an
unreachable default case of a switch. Do not use gcc_assert(0). */
+#if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING
+#define gcc_unreachable() __builtin_unreachable()
+#else
#define gcc_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__))
+#endif
/* Provide a fake boolean type. We make no attempt to use the
C99 _Bool, as it may not be available in the bootstrap compiler,