mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
022f7790db
This is quite nice, although I wish [[gnu::always_inline]] implied inline. Also "gnu::" is kind of a wart, but whatcha gonna do.
28 lines
648 B
C++
28 lines
648 B
C++
#pragma once
|
|
|
|
#if defined(SERENITY) && defined(KERNEL)
|
|
#define AK_MAKE_ETERNAL \
|
|
public: \
|
|
void* operator new(size_t size) { return kmalloc_eternal(size); } \
|
|
private:
|
|
#else
|
|
#define AK_MAKE_ETERNAL
|
|
#endif
|
|
|
|
#ifdef KERNEL
|
|
#include <Kernel/kmalloc.h>
|
|
#else
|
|
#include <LibC/stdlib.h>
|
|
|
|
extern "C" {
|
|
|
|
[[gnu::malloc, gnu::returns_nonnull]] void* kmalloc(size_t size);
|
|
[[gnu::malloc, gnu::returns_nonnull]] void* kmalloc_eternal(size_t);
|
|
[[gnu::returns_nonnull]] void* krealloc(void* ptr, size_t size);
|
|
void kfree(void* ptr);
|
|
|
|
}
|
|
|
|
inline void* operator new(size_t, void* p) { return p; }
|
|
inline void* operator new[](size_t, void* p) { return p; }
|
|
#endif
|