diff options
Diffstat (limited to 'libs/kstd/src')
| -rw-r--r-- | libs/kstd/src/libc/stdlib.cpp | 19 | ||||
| -rw-r--r-- | libs/kstd/src/libc/string.cpp | 53 | ||||
| -rw-r--r-- | libs/kstd/src/mutex.cpp | 38 | ||||
| -rw-r--r-- | libs/kstd/src/os/error.cpp | 12 |
4 files changed, 0 insertions, 122 deletions
diff --git a/libs/kstd/src/libc/stdlib.cpp b/libs/kstd/src/libc/stdlib.cpp deleted file mode 100644 index 4a5c91f..0000000 --- a/libs/kstd/src/libc/stdlib.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "kstd/os/error.hpp" - -namespace kstd::libc -{ - - extern "C" - { - [[noreturn]] auto abort() -> void - { - kstd::os::abort(); - } - - [[noreturn, gnu::weak]] auto free(void *) -> void - { - kstd::os::panic("Tried to call free."); - } - } - -} // 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 deleted file mode 100644 index b7d4c6b..0000000 --- a/libs/kstd/src/libc/string.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include <algorithm> -#include <bit> -#include <cstddef> -#include <iterator> -#include <span> - -namespace kstd::libc -{ - - extern "C" - { - auto strlen(char const * string) -> std::size_t - { - return std::distance(string, std::ranges::find(string, nullptr, '\0')); - } - - auto memcmp(void const * lhs, void const * rhs, std::size_t size) -> std::size_t - { - auto left_span = std::span{static_cast<std::byte const *>(lhs), size}; - auto right_span = std::span{static_cast<std::byte const *>(rhs), size}; - auto mismatched = std::ranges::mismatch(left_span, right_span); - - if (mismatched.in1 == left_span.end()) - { - return 0; - } - - return std::bit_cast<char>(*mismatched.in1) - std::bit_cast<char>(*mismatched.in2); - } - - auto memmove(void * dest, void const * src, std::size_t size) -> void * - { - auto dest_span = std::span{static_cast<std::byte *>(dest), size}; - auto src_span = std::span{static_cast<std::byte const *>(src), size}; - if (dest < src) - { - for (std::size_t i = 0; i < size; ++i) - { - dest_span[i] = src_span[i]; - } - } - else - { - for (std::size_t i = size; i > 0; --i) - { - dest_span[i - 1] = src_span[i - 1]; - } - } - return dest; - } - } - -} // namespace kstd::libc
\ No newline at end of file diff --git a/libs/kstd/src/mutex.cpp b/libs/kstd/src/mutex.cpp deleted file mode 100644 index d66cb98..0000000 --- a/libs/kstd/src/mutex.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "kstd/mutex" - -#include "kstd/os/error.hpp" - -#include <atomic> - -namespace kstd -{ - - mutex::mutex() = default; - - mutex::~mutex() - { - if (m_locked.test(std::memory_order_relaxed)) - { - os::panic("[KSTD] Tried to destroy a locked mutex."); - } - } - - auto mutex::lock() -> void - { - while (!try_lock()) - { - asm volatile("nop"); - } - } - - auto mutex::try_lock() -> bool - { - return !m_locked.test_and_set(std::memory_order_acquire); - } - - auto mutex::unlock() -> void - { - m_locked.clear(std::memory_order_release); - } - -} // namespace kstd diff --git a/libs/kstd/src/os/error.cpp b/libs/kstd/src/os/error.cpp deleted file mode 100644 index b82158d..0000000 --- a/libs/kstd/src/os/error.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "kstd/os/error.hpp" - -namespace kstd::os -{ - - [[gnu::weak, noreturn]] - auto abort() -> void - { - os::panic("Abort called."); - } - -} // namespace kstd::os
\ No newline at end of file |
