0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 08:13:46 +02:00

ircd: Move assert related macros from portable.h to assert.h; simplify.

This commit is contained in:
Jason Volk 2020-12-09 21:37:39 -08:00
parent 09d7822de9
commit 9c75d72120
2 changed files with 17 additions and 23 deletions

View file

@ -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.
///

View file

@ -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