Move userspace to a templated StrFormat.

This commit is contained in:
Drew Galbraith 2023-11-03 02:48:21 -07:00
parent d9df1212b7
commit 26b61db021
25 changed files with 263 additions and 217 deletions

View file

@ -1,27 +1,11 @@
#include "include/mammoth/debug.h"
#include <glacier/status/error.h>
#include <stdarg.h>
#include <stdio.h>
#include <zcall.h>
void dbgln_internal(const char* str) { // Safe to ignore the result since right
// now this doesn't throw.
uint64_t _ = ZDebug(str);
}
void dbgln(const char* fmt, ...) {
char str[1024];
va_list arg;
va_start(arg, fmt);
int ret = vsprintf(str, fmt, arg);
va_end(arg);
if (ret == -1 || ret > 1024) {
crash("Bad vsprintf", 1);
}
dbgln_internal(str);
void dbgln(const glcr::StringBuilder& builder) {
glcr::String str = builder.ToString();
(void)ZDebug(str.cstr());
}
void check(uint64_t code) {
@ -44,10 +28,10 @@ void check(uint64_t code) {
dbgln("Unhandled code");
break;
}
ZProcessExit(code);
(void)ZProcessExit(code);
}
void crash(const char* str, uint64_t code) {
dbgln(str);
ZProcessExit(code);
(void)ZProcessExit(code);
}