1#pragma once
2
3/*
4 * Assertions and panic
5 *
6 * Unlike assertions from standard library they cannot be
7 * turned off and can be used for input parameters validation.
8 */
9
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16[[noreturn]]
17void pw_panic(char* fmt, ...);
18
19/*
20 * Hard assertion
21 */
22
23#define pw_hard_assert(condition) \
24 __extension__ \
25 ({ \
26 if (_pw_unlikely( !(condition) )) { \
27 pw_panic("PW assertion failed at %s:%s:%d: " #condition "\n", __FILE__, __func__, __LINE__); \
28 } \
29 })
30
31/*
32 * Soft assertion
33 */
34
35#define pw_assert(condition) \
36 { \
37 if (_pw_unlikely(!(condition))) { \
38 pw_set_status(PwStatus(PweAssertion, #condition)); \
39 return false; \
40 } \
41 }
42
43
44#ifdef __cplusplus
45}
46#endif