mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd::portable: Optimize redefined macro if conditions are favorable.
This commit is contained in:
parent
04020a91b7
commit
be07ae05b2
3 changed files with 18 additions and 2 deletions
|
@ -35,7 +35,7 @@ namespace ircd
|
|||
{
|
||||
void debugtrap() noexcept;
|
||||
template<class expr> void always_assert(expr&&) noexcept;
|
||||
void print_assertion(const char *const &, const char *const &, const unsigned &, const char *const &) noexcept;
|
||||
[[gnu::cold]] void print_assertion(const char *const &, const char *const &, const unsigned &, const char *const &) noexcept;
|
||||
}
|
||||
|
||||
/// Override the standard assert behavior to take one of several different
|
||||
|
|
|
@ -65,6 +65,19 @@ namespace ircd
|
|||
typedef u_long ulong;
|
||||
#endif
|
||||
|
||||
///TODO: XXX hoist lfence out of unlikely target block
|
||||
#if defined(RB_ASSERT) && defined(RB_ASSERT_INTRINSIC) && !defined(NDEBUG) && defined(__SSE2__)
|
||||
#undef assert
|
||||
#define assert(expr) \
|
||||
({ \
|
||||
if(unlikely(!static_cast<bool>(expr))) \
|
||||
{ \
|
||||
asm volatile ("lfence"); \
|
||||
__assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__); \
|
||||
} \
|
||||
})
|
||||
#endif
|
||||
|
||||
//
|
||||
// Trouble; clang w/ our custom assert
|
||||
//
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
#include <RB_INC_ASSERT_H
|
||||
#ifndef assert
|
||||
#include <RB_INC_ASSERT_H
|
||||
#endif
|
||||
|
||||
#include <RB_INC_STDARG_H
|
||||
#include <RB_INC_UNISTD_H
|
||||
#include <RB_INC_SYS_TYPES_H
|
||||
|
|
Loading…
Reference in a new issue