aboutsummaryrefslogtreecommitdiff
path: root/libc/inc/assert.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inc/assert.h')
-rw-r--r--libc/inc/assert.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/libc/inc/assert.h b/libc/inc/assert.h
new file mode 100644
index 0000000..91c4ccd
--- /dev/null
+++ b/libc/inc/assert.h
@@ -0,0 +1,14 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef ASSERT_H
+#define ASSERT_H
+
+#include <print.h>
+
+#define assert(exp) \
+ if (!(exp)) { \
+ printf("%s:%d: %s: Assertion '%s' failed\n", __FILE__, __LINE__, __func__, #exp); \
+ __asm__ volatile("cli\nhlt"); \
+ }
+
+#endif