The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
panic.h
"
4
5
/**
6
* assert that a condition is true. if false, trigger a kernel panic.
7
* @param condition boolean expression to test.
8
*
9
* this macro is NOT compiled out in any build configuration. it expands to a
10
* direct call to kernel_panic(), which halts the CPU unconditionally.
11
* use for invariants that must hold regardless of build type.
12
*/
13
#define ASSERT(condition) \
14
do \
15
{ \
16
if (!(condition)) \
17
{ \
18
kernel_panic("Assertion failed: " #condition); \
19
} \
20
} while (0)
21
22
/**
23
* debug-only assertion. stripped when NDEBUG is defined (release builds).
24
* use for expensive checks or invariants only needed during development.
25
*
26
* @param condition boolean expression to test.
27
* @param msg string literal describing the failure.
28
*/
29
#ifdef NDEBUG
30
#define KASSERT(condition, msg) ((void)0)
31
#else
32
#define KASSERT(condition, msg) \
33
do \
34
{ \
35
if (!(condition)) \
36
{ \
37
kernel_panic("KASSERT failed: " msg \
38
" (" #condition ")"); \
39
} \
40
} while (0)
41
#endif
panic.h
src
kernel
assert.h
Generated by
1.18.0