The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
assert.h File Reference
#include "panic.h"

Go to the source code of this file.

Macros

#define ASSERT(condition)
 assert that a condition is true.
#define KASSERT(condition, msg)
 debug-only assertion.

Macro Definition Documentation

◆ ASSERT

#define ASSERT ( condition)
Value:
do \
{ \
if (!(condition)) \
{ \
kernel_panic("Assertion failed: " #condition); \
} \
} while (0)

assert that a condition is true.

if false, trigger a kernel panic.

Parameters
conditionboolean expression to test.

this macro is NOT compiled out in any build configuration. it expands to a direct call to kernel_panic(), which halts the CPU unconditionally. use for invariants that must hold regardless of build type.

◆ KASSERT

#define KASSERT ( condition,
msg )
Value:
do \
{ \
if (!(condition)) \
{ \
kernel_panic("KASSERT failed: " msg \
" (" #condition ")"); \
} \
} while (0)

debug-only assertion.

stripped when NDEBUG is defined (release builds). use for expensive checks or invariants only needed during development.

Parameters
conditionboolean expression to test.
msgstring literal describing the failure.