diff options
Diffstat (limited to 'libcpp/system.h')
-rw-r--r-- | libcpp/system.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libcpp/system.h b/libcpp/system.h index 20f07bb..2250f10 100644 --- a/libcpp/system.h +++ b/libcpp/system.h @@ -391,13 +391,28 @@ extern void abort (void); #define __builtin_expect(a, b) (a) #endif -#ifdef ENABLE_CHECKING +/* Redefine abort to report an internal error w/o coredump, and + reporting the location of the error in the source file. */ +extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; +#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) + +/* Use gcc_assert(EXPR) to test invariants. */ +#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))) +#endif + +#if CHECKING_P #define gcc_checking_assert(EXPR) gcc_assert (EXPR) -#define CHECKING_P 1 #else /* N.B.: in release build EXPR is not evaluated. */ #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR))) -#define CHECKING_P 1 #endif /* Provide a fake boolean type. We make no attempt to use the |