aboutsummaryrefslogtreecommitdiff
path: root/libk/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'libk/stdlib')
-rw-r--r--libk/stdlib/abort.cc15
-rw-r--r--libk/stdlib/console.cc12
2 files changed, 15 insertions, 12 deletions
diff --git a/libk/stdlib/abort.cc b/libk/stdlib/abort.cc
new file mode 100644
index 0000000..56ca7ee
--- /dev/null
+++ b/libk/stdlib/abort.cc
@@ -0,0 +1,15 @@
+#include "stdlib.h"
+
+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
+ */
+
+ asm volatile("cli");
+ while (true) {
+ asm volatile("hlt");
+ }
+ __builtin_unreachable();
+}
diff --git a/libk/stdlib/console.cc b/libk/stdlib/console.cc
index a234e6b..c076297 100644
--- a/libk/stdlib/console.cc
+++ b/libk/stdlib/console.cc
@@ -13,15 +13,3 @@ void Console::set(Console* ptr) {
Iterator<Console*> Console::begin() {
return Iterator<Console*>(global_console, last_console);
}
-
-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();
-}