os::printc(c < 10 ? c + '0' : c + 'A' - 10);
}
}
-void os::print(std::uint32_t v) {
- for (int i = 28; i >= 0; i -= 4) {
- const int c = (v >> i) & 0xF;
- os::printc(c < 10 ? c + '0' : c + 'A' - 10);
- }
-}
-void os::print(std::uint16_t v) {
- for (int i = 12; i >= 0; i -= 4) {
- const int c = (v >> i) & 0xF;
- os::printc(c < 10 ? c + '0' : c + 'A' - 10);
- }
-}
-void os::print(std::uint8_t v) {
- for (int i = 4; i >= 0; i -= 4) {
- const int c = (v >> i) & 0xF;
- os::printc(c < 10 ? c + '0' : c + 'A' - 10);
- }
-}
void os::print(std::int64_t v) {
if (v < 0) {
os::printc('-');
os::print(std::uint64_t(v));
}
}
-void os::print(std::int32_t v) {
- if (v < 0) {
- os::printc('-');
- os::print(std::uint32_t(-v));
- } else {
- os::printc(' ');
- os::print(std::uint32_t(v));
- }
-}
-void os::print(std::int16_t v) {
- if (v < 0) {
- os::printc('-');
- os::print(std::uint16_t(-v));
- } else {
- os::printc(' ');
- os::print(std::uint16_t(v));
- }
-}
-void os::print(std::int8_t v) {
- if (v < 0) {
- os::printc('-');
- os::print(std::uint8_t(-v));
- } else {
- os::printc(' ');
- os::print(std::uint8_t(v));
- }
-}
-void os::println(const char* str) {
- os::print(str);
- os::printc('\n');
-}
+void os::print(std::uint32_t v) { os::print(std::uint64_t(v)); }
+void os::print(std::uint16_t v) { os::print(std::uint64_t(v)); }
+void os::print(std::uint8_t v) { os::print(std::uint64_t(v)); }
+void os::print(std::int32_t v) { os::print(std::int64_t(v)); }
+void os::print(std::int16_t v) { os::print(std::int64_t(v)); }
+void os::print(std::int8_t v) { os::print(std::int64_t(v)); }
void os::assert(bool cond, const char* diagnostic) {
if (!cond) {
os::print("Error: ");
os::println(diagnostic);
+ while (true) { os::hlt(); }
}
}
void print(std::int32_t v);
void print(std::int16_t v);
void print(std::int8_t v);
-void println(const char* str);
+template <typename T>
+void println(const T& v) {
+ print(v);
+ printc('\n');
+}
void assert(bool cond, const char* diagnostic);
}