diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-01-31 23:24:42 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-01-31 23:24:42 +0200 |
commit | 950f164a2eb851dbab0aacb44334f0b687d123e8 (patch) | |
tree | a31c6e3140de2b208eca99e82535d740e9ca4039 /libk/stdlib | |
parent | Initial commit (diff) | |
download | kernel.cpp-950f164a2eb851dbab0aacb44334f0b687d123e8.tar.xz |
libk: add its own makefile
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(); +} |