ASSERT_OR_FATAL
Description
Expression-form fatal assertion. When cond is false, logs msg at the caller’s __func__ / __LINE__ at FATAL severity and aborts; otherwise evaluates to 0. Designed for use inside designated- initializer literals and comma expressions where the statement-style LOG_FATAL(...) (do { ... } while (0)) does not fit.
Args are evaluated as a normal C ternary: cond once; msg only on the failure path. The whole macro has type int, so it composes inside ternaries and comma chains without further casting.
Parameters
| Name | Direction | Description |
|---|---|---|
cond |
in | Boolean condition that must hold. |
msg |
in | Constant Zstr (string literal preferred). |
Success
Evaluates to 0 when cond is true.
Failure
LogWrite(...) then Abort(); never returns.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Budget.h:191:
///
#define BudgetAllocatorInitAligned(buf_ptr, total_bytes, slot_size_bytes, alignment_value) \
(ASSERT_OR_FATAL((buf_ptr) != NULL, "BudgetAllocatorInit: NULL buf"), \
ASSERT_OR_FATAL((total_bytes) > 0, "BudgetAllocatorInit: zero buf_bytes"), \
ASSERT_OR_FATAL((slot_size_bytes) > 0, "BudgetAllocatorInit: zero slot_size"), \- In
Budget.h:192:
#define BudgetAllocatorInitAligned(buf_ptr, total_bytes, slot_size_bytes, alignment_value) \
(ASSERT_OR_FATAL((buf_ptr) != NULL, "BudgetAllocatorInit: NULL buf"), \
ASSERT_OR_FATAL((total_bytes) > 0, "BudgetAllocatorInit: zero buf_bytes"), \
ASSERT_OR_FATAL((slot_size_bytes) > 0, "BudgetAllocatorInit: zero slot_size"), \
ASSERT_OR_FATAL( \- In
Budget.h:193:
(ASSERT_OR_FATAL((buf_ptr) != NULL, "BudgetAllocatorInit: NULL buf"), \
ASSERT_OR_FATAL((total_bytes) > 0, "BudgetAllocatorInit: zero buf_bytes"), \
ASSERT_OR_FATAL((slot_size_bytes) > 0, "BudgetAllocatorInit: zero slot_size"), \
ASSERT_OR_FATAL( \
(alignment_value) >= sizeof(void *) && ((alignment_value) & ((alignment_value) - 1)) == 0, \
- In
Budget.h:194:
ASSERT_OR_FATAL((total_bytes) > 0, "BudgetAllocatorInit: zero buf_bytes"), \
ASSERT_OR_FATAL((slot_size_bytes) > 0, "BudgetAllocatorInit: zero slot_size"), \
ASSERT_OR_FATAL( \
(alignment_value) >= sizeof(void *) && ((alignment_value) & ((alignment_value) - 1)) == 0, \
"BudgetAllocatorInit: alignment must be a power of two >= sizeof(void *)" \
- In
Budget.h:198:
"BudgetAllocatorInit: alignment must be a power of two >= sizeof(void *)" \
), \
ASSERT_OR_FATAL( \
(size)(total_bytes) >= (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr)) + sizeof(u64) + \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)) + ((alignment_value) - 1), \
- In
TypeMatch.h:79:
#define Match(x) \
for (bool MisraMatched = false, UNPL(tm_once) = true; UNPL(tm_once); UNPL(tm_once) = false, \
ASSERT_OR_FATAL(MisraMatched, "Match: no arm matched and no Otherwise (non-exhaustive)")) \
for (TYPE_OF(x) MisraSubject = (x), *UNPL(tm_loop) = &MisraSubject; UNPL(tm_loop); UNPL(tm_loop) = NULL)
Last updated on