diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-02 22:27:27 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-02 22:27:27 +0200 |
commit | 36e8ee0cdaa904ee00710b1d2df16691729cc93d (patch) | |
tree | 16e3836af7ef9efa6da1bbde4248ae5ad956bf58 /libk/stdlib.h | |
parent | libk: add its own makefile (diff) | |
download | kernel.cpp-36e8ee0cdaa904ee00710b1d2df16691729cc93d.tar.xz |
Print some multiboot2 information
Diffstat (limited to 'libk/stdlib.h')
-rw-r--r-- | libk/stdlib.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/libk/stdlib.h b/libk/stdlib.h index 3e6619d..44bacf4 100644 --- a/libk/stdlib.h +++ b/libk/stdlib.h @@ -1,14 +1,32 @@ #pragma once #include <string.h> +#include <type_traits.h> class Console { public: + virtual void write(char c) = 0; virtual void write(const String &msg) = 0; + virtual void write(int n) = 0; + virtual void write(unsigned int n) = 0; + + static void set(Console *ptr); + static Console *get(); }; -void console_set(Console *ptr); +template <typename T> void printk(const T &a) { + if (auto *c = Console::get()) { + if constexpr (is_same<T, const char *>()) + c->write(String(a)); + else + c->write(a); + } +} -void printk(const String &msg); +template <typename T, typename... Args> +void printk(const T &a, const Args &...x) { + printk(a); + printk(x...); +} __attribute__((__noreturn__)) void abort(); |