diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-02-20 10:07:03 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-02-20 10:07:03 +0000 |
| commit | bff6c39a8d4571cd5c41e3926d5fc1428916f32c (patch) | |
| tree | 311137d6c51e3a78179bbe5a786eb84c5e4435c8 /arch/x86_64/include | |
| parent | 9438c9203b7be20147b990ff05e1d99190d18928 (diff) | |
| download | teachos-bff6c39a8d4571cd5c41e3926d5fc1428916f32c.tar.xz teachos-bff6c39a8d4571cd5c41e3926d5fc1428916f32c.zip | |
Create global heap allocator attempt
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp | 46 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/new_delete_override.hpp | 27 |
2 files changed, 46 insertions, 27 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp new file mode 100644 index 0000000..b7b2073 --- /dev/null +++ b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp @@ -0,0 +1,46 @@ +#ifndef TEACHOS_ARCH_X86_64_MEMORY_HEAP_GLOBAL_HEAP_ALLOCATOR_HPP +#define TEACHOS_ARCH_X86_64_MEMORY_HEAP_GLOBAL_HEAP_ALLOCATOR_HPP + +#include "arch/memory/heap/linked_list_allocator.hpp" + +namespace teachos::arch::memory::heap +{ + struct global_heap_allocator + { + static auto allocate(std::size_t size) -> void *; + + static auto deallocate(void * pointer, std::size_t size) -> void; + }; +} // namespace teachos::arch::memory::heap + +auto operator new(std::size_t size) -> void * +{ + return teachos::arch::memory::heap::global_heap_allocator::allocate(size); +} + +auto operator delete(void * pointer) noexcept -> void +{ + teachos::arch::memory::heap::global_heap_allocator::deallocate(pointer, 64); +} + +auto operator delete(void * pointer, std::size_t size) noexcept -> void +{ + teachos::arch::memory::heap::global_heap_allocator::deallocate(pointer, size); +} + +auto operator new[](std::size_t size) -> void * +{ + return teachos::arch::memory::heap::global_heap_allocator::allocate(size); +} + +auto operator delete[](void * pointer) noexcept -> void +{ + teachos::arch::memory::heap::global_heap_allocator::deallocate(pointer, 64); +} + +auto operator delete[](void * pointer, std::size_t size) noexcept -> void +{ + teachos::arch::memory::heap::global_heap_allocator::deallocate(pointer, size); +} + +#endif // TEACHOS_ARCH_X86_64_MEMORY_HEAP_GLOBAL_HEAP_ALLOCATOR_HPP diff --git a/arch/x86_64/include/arch/memory/heap/new_delete_override.hpp b/arch/x86_64/include/arch/memory/heap/new_delete_override.hpp deleted file mode 100644 index c51c737..0000000 --- a/arch/x86_64/include/arch/memory/heap/new_delete_override.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_MEMORY_NEW_DELETE_OVERRIDE_CONCEPT_HPP -#define TEACHOS_ARCH_X86_64_MEMORY_NEW_DELETE_OVERRIDE_CONCEPT_HPP - -#include "linked_list_allocator.hpp" -#include <cstdint> - -void * operator new(std::size_t size) { teachos::arch::memory::heap::kernel_heap.allocate(size); } - -void operator delete(void * pointer) noexcept { teachos::arch::memory::heap::kernel_heap.deallocate(pointer, 64); } - -void operator delete(void * pointer, std::size_t size) noexcept -{ - teachos::arch::memory::heap::kernel_heap.deallocate(pointer, size); -} - -void * operator new[](std::size_t size) { teachos::arch::memory::heap::kernel_heap.allocate(size); } - -void operator delete[](void * pointer) noexcept -{ - // NOPE -} - -void operator delete[](void * pointer, std::size_t size) noexcept -{ - teachos::arch::memory::heap::kernel_heap.deallocate(pointer, size); -} -#endif // TEACHOS_ARCH_X86_64_KERNEL_NEW_DELETE_OVERRIDE_HPP
\ No newline at end of file |
