diff --git a/BAN/BAN/Memory.cpp b/BAN/BAN/Memory.cpp deleted file mode 100644 index b0d87769ec..0000000000 --- a/BAN/BAN/Memory.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -void* operator new(size_t size) { return BAN::allocator(size); } -void* operator new[](size_t size) { return BAN::allocator(size); } - -void operator delete(void* addr) { BAN::deallocator(addr); } -void operator delete[](void* addr) { BAN::deallocator(addr); } -void operator delete(void* addr, size_t) { BAN::deallocator(addr); } -void operator delete[](void* addr, size_t) { BAN::deallocator(addr); } diff --git a/BAN/BAN/New.cpp b/BAN/BAN/New.cpp new file mode 100644 index 0000000000..51d3577dce --- /dev/null +++ b/BAN/BAN/New.cpp @@ -0,0 +1,9 @@ +#include + +void* operator new(size_t size) { return BAN::allocator(size); } +void* operator new[](size_t size) { return BAN::allocator(size); } + +void operator delete(void* addr) { BAN::deallocator(addr); } +void operator delete[](void* addr) { BAN::deallocator(addr); } +void operator delete(void* addr, size_t) { BAN::deallocator(addr); } +void operator delete[](void* addr, size_t) { BAN::deallocator(addr); } diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp index 536cb3c299..24d67892a7 100644 --- a/BAN/BAN/String.cpp +++ b/BAN/BAN/String.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include diff --git a/BAN/include/BAN/Function.h b/BAN/include/BAN/Function.h index fed03695f8..478f9ee60a 100644 --- a/BAN/include/BAN/Function.h +++ b/BAN/include/BAN/Function.h @@ -2,7 +2,7 @@ #include #include -#include +#include namespace BAN { diff --git a/BAN/include/BAN/LinkedList.h b/BAN/include/BAN/LinkedList.h index 2098d707b9..6e8ecc0f86 100644 --- a/BAN/include/BAN/LinkedList.h +++ b/BAN/include/BAN/LinkedList.h @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include namespace BAN { diff --git a/BAN/include/BAN/New.h b/BAN/include/BAN/New.h new file mode 100644 index 0000000000..8876c70899 --- /dev/null +++ b/BAN/include/BAN/New.h @@ -0,0 +1,18 @@ +#pragma once + +#if defined(__is_kernel) + #include +#else + #include +#endif + +namespace BAN +{ + #if defined(__is_kernel) + static constexpr void*(&allocator)(size_t) = kmalloc; + static constexpr void(&deallocator)(void*) = kfree; + #else + static constexpr void*(&allocator)(size_t) = malloc; + static constexpr void(&deallocator)(void*) = free; + #endif +} diff --git a/BAN/include/BAN/Queue.h b/BAN/include/BAN/Queue.h index 49cd72f351..db5f1e42d0 100644 --- a/BAN/include/BAN/Queue.h +++ b/BAN/include/BAN/Queue.h @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include namespace BAN { diff --git a/BAN/include/BAN/Memory.h b/BAN/include/BAN/RefPtr.h similarity index 85% rename from BAN/include/BAN/Memory.h rename to BAN/include/BAN/RefPtr.h index 127ba944e2..e717485d38 100644 --- a/BAN/include/BAN/Memory.h +++ b/BAN/include/BAN/RefPtr.h @@ -1,27 +1,12 @@ #pragma once - #include #include #include - -#if defined(__is_kernel) - #include -#else - #include -#endif - #include namespace BAN { - #if defined(__is_kernel) - static constexpr void*(&allocator)(size_t) = kmalloc; - static constexpr void(&deallocator)(void*) = kfree; - #else - static constexpr void*(&allocator)(size_t) = malloc; - static constexpr void(&deallocator)(void*) = free; - #endif template class RefCounted @@ -131,4 +116,4 @@ namespace BAN T* m_pointer = nullptr; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index 93636522b1..c4334edbe1 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include namespace BAN diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 667406bd12..e6b063024e 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -79,7 +79,7 @@ else() endif() set(BAN_SOURCES - ../BAN/BAN/Memory.cpp + ../BAN/BAN/New.cpp ../BAN/BAN/String.cpp ../BAN/BAN/StringView.cpp ../BAN/BAN/Time.cpp diff --git a/kernel/include/kernel/FS/FileSystem.h b/kernel/include/kernel/FS/FileSystem.h index 673d596c38..1c97a81be6 100644 --- a/kernel/include/kernel/FS/FileSystem.h +++ b/kernel/include/kernel/FS/FileSystem.h @@ -1,6 +1,5 @@ #pragma once -#include #include namespace Kernel diff --git a/kernel/include/kernel/FS/Inode.h b/kernel/include/kernel/FS/Inode.h index 1ecffd0e05..354b8332a7 100644 --- a/kernel/include/kernel/FS/Inode.h +++ b/kernel/include/kernel/FS/Inode.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/kernel/include/kernel/Scheduler.h b/kernel/include/kernel/Scheduler.h index fd7fcc1ed1..adb24856b6 100644 --- a/kernel/include/kernel/Scheduler.h +++ b/kernel/include/kernel/Scheduler.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/kernel/include/kernel/Thread.h b/kernel/include/kernel/Thread.h index c401dcc3b9..6e68fe817a 100644 --- a/kernel/include/kernel/Thread.h +++ b/kernel/include/kernel/Thread.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include