Move __check_failed to Log.cpp so it can be logged across all backends

This commit is contained in:
apio 2022-11-30 17:12:06 +01:00
parent 1d51935d43
commit 29dad5651d
2 changed files with 13 additions and 12 deletions

View File

@ -1,4 +1,5 @@
#include "Log.h" #include "Log.h"
#include "arch/CPU.h"
#include "arch/Serial.h" #include "arch/Serial.h"
#include "arch/Timer.h" #include "arch/Timer.h"
#include "video/TextConsole.h" #include "video/TextConsole.h"
@ -112,4 +113,16 @@ bool log_serial_enabled()
bool log_text_console_enabled() bool log_text_console_enabled()
{ {
return g_text_console_enabled; return g_text_console_enabled;
}
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;
kerrorln("ERROR: Check failed at %s:%s, in %s: %s", file, line, func, expr);
}
CPU::efficient_halt();
} }

View File

@ -34,16 +34,4 @@ namespace Serial
va_end(ap); va_end(ap);
return rc; 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();
} }