Flipper Zero Firmware
Loading...
Searching...
No Matches
check.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <m-core.h>
17#include "common_defines.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23// Flags instead of pointers will save ~4 bytes on furi_assert and furi_check calls.
24#define __FURI_ASSERT_MESSAGE_FLAG (0x01)
25#define __FURI_CHECK_MESSAGE_FLAG (0x02)
26
28FURI_NORETURN void __furi_crash_implementation(void);
29
31FURI_NORETURN void __furi_halt_implementation(void);
32
34#define __furi_crash(message) \
35 do { \
36 register const void* r12 asm("r12") = (void*)message; \
37 asm volatile("sukima%=:" : : "r"(r12)); \
38 __furi_crash_implementation(); \
39 } while(0)
40
45#define furi_crash(...) M_APPLY(__furi_crash, M_IF_EMPTY(__VA_ARGS__)((NULL), (__VA_ARGS__)))
46
48#define __furi_halt(message) \
49 do { \
50 register const void* r12 asm("r12") = (void*)message; \
51 asm volatile("sukima%=:" : : "r"(r12)); \
52 __furi_halt_implementation(); \
53 } while(0)
54
59#define furi_halt(...) M_APPLY(__furi_halt, M_IF_EMPTY(__VA_ARGS__)((NULL), (__VA_ARGS__)))
60
62#define __furi_check(__e, __m) \
63 do { \
64 if(!(__e)) { \
65 __furi_crash(__m); \
66 } \
67 } while(0)
68
73#define furi_check(...) \
74 M_APPLY(__furi_check, M_DEFAULT_ARGS(2, (__FURI_CHECK_MESSAGE_FLAG), __VA_ARGS__))
75
77#ifdef FURI_DEBUG
78#define __furi_assert(__e, __m) \
79 do { \
80 if(!(__e)) { \
81 __furi_crash(__m); \
82 } \
83 } while(0)
84#else
85#define __furi_assert(__e, __m) \
86 do { \
87 ((void)(__e)); \
88 ((void)(__m)); \
89 } while(0)
90#endif
91
98#define furi_assert(...) \
99 M_APPLY(__furi_assert, M_DEFAULT_ARGS(2, (__FURI_ASSERT_MESSAGE_FLAG), __VA_ARGS__))
100
101#define furi_break(__e) \
102 do { \
103 if(!(__e)) { \
104 asm volatile("bkpt 0"); \
105 } \
106 } while(0)
107
108#ifdef __cplusplus
109}
110#endif
FURI_NORETURN void __furi_halt_implementation(void)
Halt system.
Definition check.c:186
FURI_NORETURN void __furi_crash_implementation(void)
Crash system.
Definition check.c:135