aboutsummaryrefslogtreecommitdiff
path: root/libk/stdlib.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-02-02 22:27:27 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-02-02 22:27:27 +0200
commit36e8ee0cdaa904ee00710b1d2df16691729cc93d (patch)
tree16e3836af7ef9efa6da1bbde4248ae5ad956bf58 /libk/stdlib.h
parentlibk: add its own makefile (diff)
downloadkernel.cpp-36e8ee0cdaa904ee00710b1d2df16691729cc93d.tar.xz
Print some multiboot2 information
Diffstat (limited to 'libk/stdlib.h')
-rw-r--r--libk/stdlib.h22
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();