mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd: Add always_assert() inline expression trap.
This commit is contained in:
parent
37cde44d58
commit
316d668a58
1 changed files with 12 additions and 1 deletions
|
@ -34,8 +34,9 @@
|
|||
// Our utils
|
||||
namespace ircd
|
||||
{
|
||||
void print_assertion(const char *const &, const char *const &, const unsigned &, const char *const &) noexcept;
|
||||
void debugtrap() noexcept;
|
||||
void always_assert(const bool &) noexcept;
|
||||
void print_assertion(const char *const &, const char *const &, const unsigned &, const char *const &) noexcept;
|
||||
}
|
||||
|
||||
/// Override the standard assert behavior, if enabled, to trap into the
|
||||
|
@ -84,3 +85,13 @@ noexcept
|
|||
__builtin_trap();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Trap on false expression whether or not NDEBUG.
|
||||
extern inline void
|
||||
__attribute__((always_inline, gnu_inline, artificial))
|
||||
ircd::always_assert(const bool &expr)
|
||||
noexcept
|
||||
{
|
||||
if(__builtin_expect(!expr, 0))
|
||||
debugtrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue