Luna/luna/Check.h

22 lines
472 B
C
Raw Normal View History

#pragma once
#ifdef IN_MOON
#include "arch/Serial.h"
[[noreturn]] inline bool __check_failed(const char* string)
{
Serial::print("CHECK FAILED: ");
Serial::println(string);
for (;;)
;
}
#else
[[noreturn]] inline bool __check_failed(const char*)
{
__builtin_trap();
}
#endif
#define STRINGIZE(x) #x
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
#define check(expr) (expr) || __check_failed("at " __FILE__ ":" STRINGIZE_VALUE_OF(__LINE__) ": " #expr)