AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
#ifndef _CORE_ASSERT_H
2
#define _CORE_ASSERT_H
3
4
/* Panics if a condition isn't true, if a size isn't what's expected, or
5
* if a pointer isn't aligned as it should be. Each is one statement (a
6
* `do { } while (0)`), so that an `else` after one can't bind to its
7
* `if`. */
8
9
#define assert(x) \
10
do { \
11
if (!(x)) \
12
panic("Assertion " #x " failed"); \
13
} while (0)
14
15
#define assert_sizeof(o, sz) \
16
do { \
17
if (sizeof(o) != sz) \
18
panic("Assertion sizeof(" #o ") == " #sz " failed"); \
19
} while (0)
20
21
#define assert_alignof(o, al) \
22
do { \
23
if (((uintptr_t) o) & (al - 1)) \
24
panic("Assertion alignof(" #o ") == " #al " failed"); \
25
} while (0)
26
27
#endif
/* ! _CORE_ASSERT_H */
kernel
include
core
assert.h
Generated by
1.18.0