mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
Kernel: Add MAKE_ALIGNED_ALLOCATED helper macro
This macro inserts operator new/delete into a class, allowing you to very easily specify a specific heap alignment.
This commit is contained in:
parent
96fb3d4a11
commit
4fcc637e29
1 changed files with 7 additions and 0 deletions
|
@ -32,6 +32,13 @@
|
|||
#define KMALLOC_SCRUB_BYTE 0xbb
|
||||
#define KFREE_SCRUB_BYTE 0xaa
|
||||
|
||||
#define MAKE_ALIGNED_ALLOCATED(type, alignment) \
|
||||
public: \
|
||||
void* operator new(size_t) { return kmalloc_aligned<alignment>(sizeof(type)); } \
|
||||
void operator delete(void* ptr) { kfree_aligned(ptr); } \
|
||||
\
|
||||
private:
|
||||
|
||||
void kmalloc_init();
|
||||
[[gnu::malloc, gnu::returns_nonnull, gnu::alloc_size(1)]] void* kmalloc_impl(size_t);
|
||||
[[gnu::malloc, gnu::returns_nonnull, gnu::alloc_size(1)]] void* kmalloc_eternal(size_t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue