@ -16,6 +16,9 @@
# define _pure __attribute__((const))
# define _readonly __attribute__((pure))
# define _cold __attribute__((cold))
# define _hot __attribute__((hot))
# ifndef __cplusplus
# define noreturn __attribute__((noreturn))
# define deprecated __attribute__((deprecated))
@ -71,6 +74,21 @@
# define ifL(x) if(LIKELY((x)))
# define ifU(x) if(UNLIKELY((x)))
# define COLD_EXPR(expr) ({ \
goto _cold_expr ; \
UNREACHABLE_UNSAFE ( ) ; \
_cold_expr : \
__attribute__ ( ( cold ) ) ; \
expr ; \
} )
# define HOT_EXPR(expr) ({ \
goto _hot_expr ; \
UNREACHABLE_UNSAFE ( ) ; \
_hot_expr : \
__attribute__ ( ( hot ) ) ; \
expr ; \
} )
/// Equivalent to GNU C `x ?: y` operator.
# define TERN_OR(x, y) ({ let _x = (x); _x ? _x : (y); })
@ -100,6 +118,14 @@ _mixin void _drain_val(void* x, ...) { IGNORE(x); } // This compiles to no-op on
# define assert_msg(expr, ...) ( (expr) ? 1 : FATAL(__VA_ARGS__))
# define UNREACHABLE_UNSAFE() __builtin_unreachable()
# ifdef DEBUG
# define UNREACHABLE() do { COLD_EXPR(FATAL("unreachable code entered")); } while(0)
# else
# define UNREACHABLE() UNREACHABLE_UNSAFE()
# endif
# ifdef DEBUG
# define debug_assert(x) assert((x))
# elif defined(_EVAL_DEBUG_ONLY_STMTS)