diff options
Diffstat (limited to 'kernel/include')
| -rw-r--r-- | kernel/include/kernel/memory/block_list_allocator.hpp | 13 | ||||
| -rw-r--r-- | kernel/include/kernel/memory/heap_allocator.hpp | 5 |
2 files changed, 9 insertions, 9 deletions
diff --git a/kernel/include/kernel/memory/block_list_allocator.hpp b/kernel/include/kernel/memory/block_list_allocator.hpp index 5e81c44..f319097 100644 --- a/kernel/include/kernel/memory/block_list_allocator.hpp +++ b/kernel/include/kernel/memory/block_list_allocator.hpp @@ -6,6 +6,7 @@ #include "kernel/memory/heap_allocator.hpp" #include <kstd/mutex> +#include <kstd/units> #include <cstddef> #include <new> @@ -32,7 +33,7 @@ namespace kernel::memory //! @param size The size of the block to allocate //! @param alignment The desired alignment of the allocated block //! @return A pointer to the beginning of the block on success, @p nullptr otherwise. - [[nodiscard]] auto allocate(std::size_t size, std::align_val_t alignment) noexcept -> void * override; + [[nodiscard]] auto allocate(kstd::units::bytes size, kstd::units::bytes alignment) noexcept -> void * override; //! Deallocate a block of memory previously allocated. //! @@ -42,7 +43,7 @@ namespace kernel::memory private: struct block_header final { - std::size_t usable_size; + kstd::units::bytes usable_size; bool free; block_header * next; block_header * prev; @@ -52,16 +53,16 @@ namespace kernel::memory //! //! Each allocated block carries a block header, like any unallocated one, but in addition also has a back-pointer //! to the block header to support padding due to alignment. - constexpr auto static allocated_metadata_size = sizeof(block_header) + sizeof(block_header *); + constexpr auto static allocated_metadata_size = kstd::units::bytes{sizeof(block_header) + sizeof(block_header *)}; //! The minimum number of bytes for an allocation. - constexpr auto static minimum_allocation_size = 16uz; + constexpr auto static minimum_allocation_size = kstd::units::bytes{16uz}; //! Try to expand the heap to accommodate the given size. //! //! @param delta The size to expand the heap by. //! @return @p true if the heap was expanded, @p false otherwise. - auto expand(std::size_t delta) noexcept -> bool; + auto expand(kstd::units::bytes delta) noexcept -> bool; //! Split a given free block to accommodate and allocation. //! @@ -70,7 +71,7 @@ namespace kernel::memory //! @param block The block to split. //! @param size The size of the allocation. //! @param padding The amount of padding to apply. - auto split(block_header * block, std::size_t size, std::size_t padding) noexcept -> void; + auto split(block_header * block, kstd::units::bytes size, kstd::units::bytes padding) noexcept -> void; //! Try to coalesce a given block with it's preceding and/or following block. //! diff --git a/kernel/include/kernel/memory/heap_allocator.hpp b/kernel/include/kernel/memory/heap_allocator.hpp index bc771e3..55de7e4 100644 --- a/kernel/include/kernel/memory/heap_allocator.hpp +++ b/kernel/include/kernel/memory/heap_allocator.hpp @@ -1,9 +1,8 @@ #ifndef TEACHOS_KERNEL_MEMORY_HEAP_ALLOCATOR_HPP #define TEACHOS_KERNEL_MEMORY_HEAP_ALLOCATOR_HPP -#include <kstd/mutex> +#include <kstd/units> -#include <cstddef> #include <new> namespace kernel::memory @@ -19,7 +18,7 @@ namespace kernel::memory //! @param size The size of the block to allocate //! @param alignment The desired alignment of the allocated block //! @return A pointer to the beginning of the block on success, @p nullptr otherwise. - [[nodiscard]] virtual auto allocate(std::size_t size, std::align_val_t alignment) noexcept -> void * = 0; + [[nodiscard]] virtual auto allocate(kstd::units::bytes size, kstd::units::bytes alignment) noexcept -> void * = 0; //! Deallocate a block of memory previously allocated. //! |
