summaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authordaney <daney@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-25 20:28:57 +0000
committerdaney <daney@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-25 20:28:57 +0000
commit598767c938d0d001bbbe41e0a189104bb53e3580 (patch)
tree1102dce70bb5ef81361767f9dd212b754f1fbd30 /gcc/system.h
parentc4d13c5c0535f2eba2ab5b5dee94666ff6dc7e60 (diff)
downloadgcc-598767c938d0d001bbbe41e0a189104bb53e3580.tar.gz
* system.h (gcc_assert): Invoke __builtin_unreachable() instead of
fancy_abort() if !ENABLE_ASSERT_CHECKING. (gcc_unreachable): Invoke __builtin_unreachable() if !ENABLE_ASSERT_CHECKING. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150091 138bc75d-0d04-0410-961f-82ee72b054a4
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,