#include "arch/Serial.h" #include "arch/CPU.h" #include namespace Serial { void write(const char* str, usize size) { while (size--) putchar(*str++); } void print(const char* str) { while (*str) putchar(*str++); } void println(const char* str) { print(str); putchar('\n'); } Result printf(const char* format, ...) { va_list ap; va_start(ap, format); auto rc = cstyle_format( format, [](char c, void*) -> Result { putchar(c); return {}; }, nullptr, ap); va_end(ap); return rc; } } static bool g_check_already_failed = false; _noreturn bool __check_failed(const char* file, const char* line, const char* func, const char* expr) { if (!g_check_already_failed) { // Avoid endlessly failing when trying to report a failed check. g_check_already_failed = true; Serial::printf("ERROR: Check failed at %s:%s, in %s: %s\n", file, line, func, expr); } CPU::efficient_halt(); }