aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2025-02-20 10:07:03 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2025-02-20 10:07:03 +0000
commitbff6c39a8d4571cd5c41e3926d5fc1428916f32c (patch)
tree311137d6c51e3a78179bbe5a786eb84c5e4435c8 /arch/x86_64/include
parent9438c9203b7be20147b990ff05e1d99190d18928 (diff)
downloadteachos-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.hpp46
-rw-r--r--arch/x86_64/include/arch/memory/heap/new_delete_override.hpp27
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