mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd: Move assert related macros from portable.h to assert.h; simplify.
This commit is contained in:
parent
09d7822de9
commit
9c75d72120
2 changed files with 17 additions and 23 deletions
|
@ -51,6 +51,23 @@ __assert_fail(const char *__assertion,
|
|||
const char *__function);
|
||||
#endif
|
||||
|
||||
// Custom assert
|
||||
#if defined(RB_ASSERT) && defined(RB_ASSERT_INTRINSIC) && !defined(NDEBUG)
|
||||
#undef assert
|
||||
#define assert(expr) \
|
||||
({ \
|
||||
if(__builtin_expect(!static_cast<bool>(expr), 0)) \
|
||||
__assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__); \
|
||||
})
|
||||
#endif
|
||||
|
||||
// Custom addl cases to avoid any trouble w/ clang
|
||||
#if defined(RB_ASSERT) && defined(__clang__) && !defined(assert)
|
||||
#ifdef NDEBUG
|
||||
#define assert(expr) (static_cast<void>(0))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// Override the standard assert behavior, if enabled, to trap into the
|
||||
/// debugger as close as possible to the offending site.
|
||||
///
|
||||
|
|
|
@ -64,26 +64,3 @@ namespace ircd
|
|||
#if defined(__FreeBSD__) && !defined(ulong)
|
||||
typedef u_long ulong;
|
||||
#endif
|
||||
|
||||
#if defined(RB_ASSERT) && defined(RB_ASSERT_INTRINSIC) && !defined(NDEBUG) && defined(__SSE2__)
|
||||
#undef assert
|
||||
#define assert(expr) \
|
||||
({ \
|
||||
if(unlikely(!static_cast<bool>(expr))) \
|
||||
__assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__); \
|
||||
})
|
||||
#endif
|
||||
|
||||
//
|
||||
// Trouble; clang w/ our custom assert
|
||||
//
|
||||
|
||||
#if defined(RB_ASSERT) && defined(__clang__) && !defined(assert)
|
||||
#ifdef NDEBUG
|
||||
#define assert(expr) \
|
||||
(static_cast<void>(0))
|
||||
#else
|
||||
#define assert(expr) \
|
||||
(static_cast<bool>(expr)? void(0): __assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue