Make expect and check use unlikely
This commit is contained in:
parent
ea7893ba71
commit
7cc139c3f7
@ -8,6 +8,18 @@ extern _noreturn bool __check_failed(const char* file, const char* line, const c
|
||||
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
|
||||
#endif
|
||||
|
||||
#define check(expr) (expr) || __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr)
|
||||
#define expect(expr, message) \
|
||||
(expr) || __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, message)
|
||||
do { \
|
||||
if (!(expr)) [[unlikely]] \
|
||||
{ \
|
||||
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define check(expr) \
|
||||
do { \
|
||||
if (!(expr)) [[unlikely]] \
|
||||
{ \
|
||||
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
Loading…
Reference in New Issue
Block a user