-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch_assert.h
More file actions
21 lines (17 loc) · 1.05 KB
/
Copy pathch_assert.h
File metadata and controls
21 lines (17 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Always-on assertions for programmer-error invariants — states that cannot
// happen unless the code is wrong. Operational errors (bad peer input, short
// buffers, I/O failures) keep returning ch_err codes; CH_ASSERT is never for
// those. The host implementation prints and aborts; a device maps
// ch_assert_fail to its fault handler, and the failure domain is the
// session, not the board.
#ifndef CH_ASSERT_H
#define CH_ASSERT_H
#include <stdnoreturn.h>
noreturn void ch_assert_fail(const char *cond, const char *file, int line);
#define CH_ASSERT(cond) \
do { \
if (!(cond)) { \
ch_assert_fail(#cond, __FILE__, __LINE__); \
} \
} while (0)
#endif