1#ifndef SBL_SYSTEM_ASSERT_HPP_
2#define SBL_SYSTEM_ASSERT_HPP_
48#ifndef SBL_FAULT_OUTPUT
49namespace sbl::system::fault::detail {
50struct NullFaultOutput {
51 static void write(
const char*) {}
54#define SBL_FAULT_OUTPUT sbl::system::fault::detail::NullFaultOutput
67[[noreturn]]
inline void panic(
const char* msg,
const char* file,
int line) {
68 __asm
volatile(
"cpsid i");
71 sbl::log::format(buf,
sizeof(buf),
"\r\n!!! %s\r\n at %s:%d\r\n", msg, file, line);
72 SBL_FAULT_OUTPUT::write(buf);
75 __asm
volatile(
"bkpt #0");
83#define SBL_PANIC(msg) sbl::system::fault::panic("PANIC: " msg, __FILE__, __LINE__)
85#ifndef SBL_ASSERT_ENABLED
86#define SBL_ASSERT_ENABLED 1
90#define SBL_ASSERT(cond) \
93 sbl::system::fault::panic("ASSERT FAILED: " #cond, __FILE__, __LINE__); \
97#define SBL_ASSERT(cond) ((void)0)
int format(char *buf, size_t size, const char *fmt,...)
Format a string into a buffer (snprintf-style)
Assertions, panic and the HardFault handler.
void panic(const char *msg, const char *file, int line)
Halt with a diagnostic message. Does not return.