blob: 44bacf4ea2ceaad76e812302995264b5ae4ab10e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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();
};
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);
}
}
template <typename T, typename... Args>
void printk(const T &a, const Args &...x) {
printk(a);
printk(x...);
}
__attribute__((__noreturn__)) void abort();
|