aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/src
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kstd/src')
-rw-r--r--libs/kstd/src/bits/os.cpp10
-rw-r--r--libs/kstd/src/cstdlib.cpp18
-rw-r--r--libs/kstd/src/cstring.cpp10
3 files changed, 38 insertions, 0 deletions
diff --git a/libs/kstd/src/bits/os.cpp b/libs/kstd/src/bits/os.cpp
new file mode 100644
index 0000000..fb64202
--- /dev/null
+++ b/libs/kstd/src/bits/os.cpp
@@ -0,0 +1,10 @@
+#include "kstd/bits/os.hpp"
+
+namespace kstd::os
+{
+ [[gnu::weak]]
+ auto abort() -> bool
+ {
+ return false;
+ }
+} // namespace kstd::os \ No newline at end of file
diff --git a/libs/kstd/src/cstdlib.cpp b/libs/kstd/src/cstdlib.cpp
new file mode 100644
index 0000000..8fb5f63
--- /dev/null
+++ b/libs/kstd/src/cstdlib.cpp
@@ -0,0 +1,18 @@
+#include "kstd/bits/os.hpp"
+
+namespace kstd
+{
+
+ extern "C"
+ {
+ [[noreturn]] auto abort() -> void
+ {
+ if (!kstd::os::abort())
+ {
+ os::panic("System abort handler returned.");
+ }
+ __builtin_trap();
+ }
+ }
+
+} // namespace kstd \ No newline at end of file
diff --git a/libs/kstd/src/cstring.cpp b/libs/kstd/src/cstring.cpp
new file mode 100644
index 0000000..5419b7d
--- /dev/null
+++ b/libs/kstd/src/cstring.cpp
@@ -0,0 +1,10 @@
+#include <algorithm>
+#include <cstddef>
+
+extern "C"
+{
+ auto strlen(const char * string) -> std::size_t
+ {
+ return std::distance(string, std::ranges::find(string, nullptr, '\0'));
+ }
+}