diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-10-29 10:39:30 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-10-29 10:39:30 +0100 |
| commit | acabbacdee68ad80e829bda56ae5363d04646d2d (patch) | |
| tree | faca32b951c286330ebb40205bb908fb2d51be54 /libs/kstd/src | |
| parent | 27a00c67d0110ddaebb4035e68860e00e32a3b8f (diff) | |
| download | teachos-acabbacdee68ad80e829bda56ae5363d04646d2d.tar.xz teachos-acabbacdee68ad80e829bda56ae5363d04646d2d.zip | |
kstd: clean up libc implementation
Diffstat (limited to 'libs/kstd/src')
| -rw-r--r-- | libs/kstd/src/bits/os.cpp | 6 | ||||
| -rw-r--r-- | libs/kstd/src/cstdlib.cpp | 18 | ||||
| -rw-r--r-- | libs/kstd/src/cstring.cpp | 10 | ||||
| -rw-r--r-- | libs/kstd/src/libc/stdlib.cpp | 11 | ||||
| -rw-r--r-- | libs/kstd/src/libc/string.cpp | 15 |
5 files changed, 29 insertions, 31 deletions
diff --git a/libs/kstd/src/bits/os.cpp b/libs/kstd/src/bits/os.cpp index fb64202..e6edbfd 100644 --- a/libs/kstd/src/bits/os.cpp +++ b/libs/kstd/src/bits/os.cpp @@ -2,9 +2,9 @@ namespace kstd::os { - [[gnu::weak]] - auto abort() -> bool + [[gnu::weak, noreturn]] + auto abort() -> void { - return false; + os::panic("Abort called."); } } // namespace kstd::os
\ No newline at end of file diff --git a/libs/kstd/src/cstdlib.cpp b/libs/kstd/src/cstdlib.cpp deleted file mode 100644 index 8fb5f63..0000000 --- a/libs/kstd/src/cstdlib.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#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 deleted file mode 100644 index 5419b7d..0000000 --- a/libs/kstd/src/cstring.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include <algorithm> -#include <cstddef> - -extern "C" -{ - auto strlen(const char * string) -> std::size_t - { - return std::distance(string, std::ranges::find(string, nullptr, '\0')); - } -} diff --git a/libs/kstd/src/libc/stdlib.cpp b/libs/kstd/src/libc/stdlib.cpp new file mode 100644 index 0000000..fe1bc95 --- /dev/null +++ b/libs/kstd/src/libc/stdlib.cpp @@ -0,0 +1,11 @@ +#include "kstd/bits/os.hpp" + +namespace kstd::libc +{ + + extern "C" + { + [[noreturn]] auto abort() -> void { kstd::os::abort(); } + } + +} // namespace kstd::libc
\ No newline at end of file diff --git a/libs/kstd/src/libc/string.cpp b/libs/kstd/src/libc/string.cpp new file mode 100644 index 0000000..c6b3847 --- /dev/null +++ b/libs/kstd/src/libc/string.cpp @@ -0,0 +1,15 @@ +#include <algorithm> +#include <cstddef> + +namespace kstd::libc +{ + + extern "C" + { + auto strlen(const char * string) -> std::size_t + { + return std::distance(string, std::ranges::find(string, nullptr, '\0')); + } + } + +} // namespace kstd::libc
\ No newline at end of file |
