aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/include/kstd/asm_ptr42
-rw-r--r--libs/kstd/include/kstd/bits/shared_ptr.hpp2
-rw-r--r--libs/kstd/include/kstd/mutex17
-rw-r--r--libs/kstd/include/kstd/stack32
-rw-r--r--libs/kstd/include/kstd/vector9
-rw-r--r--libs/kstd/src/libc/stdlib.cpp5
6 files changed, 68 insertions, 39 deletions
diff --git a/libs/kstd/include/kstd/asm_ptr b/libs/kstd/include/kstd/asm_ptr
index e9072e2..e8636c3 100644
--- a/libs/kstd/include/kstd/asm_ptr
+++ b/libs/kstd/include/kstd/asm_ptr
@@ -23,28 +23,50 @@ namespace kstd
asm_ptr() = delete;
asm_ptr(asm_ptr const &) = delete;
asm_ptr(asm_ptr &&) = delete;
+ ~asm_ptr() = delete;
- auto constexpr operator=(asm_ptr const &) = delete;
- auto constexpr operator=(asm_ptr &&) = delete;
+ constexpr auto operator=(asm_ptr const &) = delete;
+ constexpr auto operator=(asm_ptr &&) = delete;
- auto get() const noexcept -> pointer { return m_ptr; }
+ auto get() const noexcept -> pointer
+ {
+ return m_ptr;
+ }
- auto constexpr operator+(std::ptrdiff_t offset) const noexcept -> pointer
+ constexpr auto operator+(std::ptrdiff_t offset) const noexcept -> pointer
{
return std::bit_cast<pointer>(m_ptr) + offset;
}
- auto constexpr operator*() noexcept -> reference { return *(std::bit_cast<pointer>(m_ptr)); }
+ constexpr auto operator*() noexcept -> reference
+ {
+ return *(std::bit_cast<pointer>(m_ptr));
+ }
- auto constexpr operator*() const noexcept -> const_reference { return *(std::bit_cast<const_pointer>(m_ptr)); }
+ constexpr auto operator*() const noexcept -> const_reference
+ {
+ return *(std::bit_cast<const_pointer>(m_ptr));
+ }
- auto constexpr operator[](std::ptrdiff_t offset) noexcept -> reference { return *(*this + offset); }
+ constexpr auto operator[](std::ptrdiff_t offset) noexcept -> reference
+ {
+ return *(*this + offset);
+ }
- auto constexpr operator[](std::ptrdiff_t offset) const noexcept -> const_reference { return *(*this + offset); }
+ constexpr auto operator[](std::ptrdiff_t offset) const noexcept -> const_reference
+ {
+ return *(*this + offset);
+ }
- auto constexpr operator->() noexcept -> pointer { return m_ptr; }
+ constexpr auto operator->() noexcept -> pointer
+ {
+ return m_ptr;
+ }
- auto constexpr operator->() const noexcept -> const_pointer { return m_ptr; }
+ constexpr auto operator->() const noexcept -> const_pointer
+ {
+ return m_ptr;
+ }
private:
pointer m_ptr;
diff --git a/libs/kstd/include/kstd/bits/shared_ptr.hpp b/libs/kstd/include/kstd/bits/shared_ptr.hpp
index 251c187..4bcf499 100644
--- a/libs/kstd/include/kstd/bits/shared_ptr.hpp
+++ b/libs/kstd/include/kstd/bits/shared_ptr.hpp
@@ -220,7 +220,7 @@ namespace kstd
private:
/**
- * @brief Releases ownership and deletes the object if this was the last ereference to the owned managed object.
+ * @brief Releases ownership and deletes the object if this was the last reference to the owned managed object.
*/
[[gnu::section(".stl_text")]]
auto cleanup() -> void
diff --git a/libs/kstd/include/kstd/mutex b/libs/kstd/include/kstd/mutex
index cf8549f..6ae3adf 100644
--- a/libs/kstd/include/kstd/mutex
+++ b/libs/kstd/include/kstd/mutex
@@ -24,12 +24,23 @@ namespace kstd
/**
* @brief Deleted copy constructor.
*/
- mutex(const mutex &) = delete;
+ mutex(mutex const &) = delete;
/**
- * @brief Deleted assignment operator.
+ * @brief Deleted move constructor.
+ *
+ */
+ mutex(mutex &&) = delete;
+
+ /**
+ * @brief Deleted copy assignment operator.
+ */
+ auto operator=(mutex const &) -> mutex & = delete;
+
+ /**
+ * @brief Deleted move assignment operator.
*/
- mutex & operator=(const mutex &) = delete;
+ auto operator=(mutex &&) -> mutex & = delete;
/**
* @brief Lock the mutex (blocks for as long as it is not available).
diff --git a/libs/kstd/include/kstd/stack b/libs/kstd/include/kstd/stack
index 8c702cf..8cd208a 100644
--- a/libs/kstd/include/kstd/stack
+++ b/libs/kstd/include/kstd/stack
@@ -1,8 +1,7 @@
#ifndef KSTD_STACK_HPP
#define KSTD_STACK_HPP
-#include "kstd/vector.hpp"
-
+#include "kstd/vector"
#include <utility>
namespace kstd
@@ -29,8 +28,12 @@ namespace kstd
*/
stack() = default;
+ stack(stack const &) = delete;
+ stack(stack &&) = delete;
+ auto operator=(stack const &) -> stack & = delete;
+ auto operator=(stack &&) -> stack & = delete;
/**
- * @brief Constructs data with the given amount of elements containg the given value or alterantively the default
+ * @brief Constructs data with the given amount of elements containing the given value or alternatively the default
* constructed value.
*
* @param n Amount of elements we want to create and set the given value for.
@@ -61,11 +64,11 @@ namespace kstd
/**
* @brief Construct data by copying all elements from the initializer list.
*
- * @param initalizer_list List we want to copy all elements from.
+ * @param elements List we want to copy all elements from.
*/
[[gnu::section(".stl_text")]]
- explicit stack(std::initializer_list<T> initalizer_list)
- : _container(initalizer_list)
+ explicit stack(std::initializer_list<T> elements)
+ : _container(elements)
{
// Nothing to do.
}
@@ -86,21 +89,6 @@ namespace kstd
}
/**
- * @brief Copy assignment operator.
- *
- * @note Allocates underlying data container with the same capacity as vector we are copying from and copies all
- * elements from it.
- *
- * @param other Other instance of vector we want to copy the data from.
- * @return Newly created copy.
- */
- [[gnu::section(".stl_text")]]
- stack<T> & operator=(stack<T> const & other)
- {
- _container = other;
- }
-
- /**
* @brief Destructor.
*/
~stack() = default;
@@ -194,7 +182,7 @@ namespace kstd
}
/**
- * @brief Wheter there are currently any items this container or not.
+ * @brief Whether there are currently any items this container or not.
*
* @return True if there are no elements, false if there are.
*/
diff --git a/libs/kstd/include/kstd/vector b/libs/kstd/include/kstd/vector
index 1009e81..9d96eb8 100644
--- a/libs/kstd/include/kstd/vector
+++ b/libs/kstd/include/kstd/vector
@@ -29,7 +29,7 @@ namespace kstd
vector() = default;
/**
- * @brief Constructs data with the given amount of elements containg the given value or alterantively the default
+ * @brief Constructs data with the given amount of elements containing the given value or alternatively the default
* constructed value.
*
* @param n Amount of elements we want to create and set the given value for.
@@ -99,7 +99,7 @@ namespace kstd
* @return Newly created copy.
*/
[[gnu::section(".stl_text")]]
- vector<value_type> & operator=(vector<value_type> const & other)
+ auto operator=(vector const & other) -> vector<value_type> &
{
delete[] _data;
_size = other._size;
@@ -112,7 +112,10 @@ namespace kstd
/**
* @brief Destructor.
*/
- ~vector() { delete[] _data; }
+ ~vector()
+ {
+ delete[] _data;
+ }
/**
* @brief Amount of elements currently contained in this vector, will fill up until we have reached the capacity. If
diff --git a/libs/kstd/src/libc/stdlib.cpp b/libs/kstd/src/libc/stdlib.cpp
index 752e616..a0f062a 100644
--- a/libs/kstd/src/libc/stdlib.cpp
+++ b/libs/kstd/src/libc/stdlib.cpp
@@ -9,6 +9,11 @@ namespace kstd::libc
{
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