diff options
Diffstat (limited to 'libk/stdlib')
-rw-r--r-- | libk/stdlib/console.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libk/stdlib/console.cc b/libk/stdlib/console.cc new file mode 100644 index 0000000..dbc9b86 --- /dev/null +++ b/libk/stdlib/console.cc @@ -0,0 +1,28 @@ +#include "stdlib.h" + +static Console *global_console = nullptr; + +void console_set(Console *ptr) { + if (ptr != nullptr) { + global_console = ptr; + } +} + +void printk(const String &msg) { + if (global_console == nullptr) + return; + + global_console->write(msg); +} + +void abort() { + /* + * On gcc, a 'while(true) {}' will infinitely loop + * but clang will optimize it away on -O2 if it's empty + * therefore, add no-op + */ + while (true) { + asm volatile("nop"); + } + __builtin_unreachable(); +} |