29#include <EASTL/utility.h>
55template <
size_t N, Safe safety = Safe::Yes>
64 uint8_t *
ptr = m_current;
68 template <
typename T,
typename... Args>
70 size_t size =
sizeof(T);
71 uint8_t *
ptr = m_current;
72 if constexpr (
alignof(T) > 1) {
73 static constexpr size_t a =
alignof(T) - 1;
74 auto alignedptr =
reinterpret_cast<uint8_t *
>((
reinterpret_cast<uintptr_t
>(
ptr) + a) & ~a);
82 return *
new (
ptr) T(eastl::forward<Args>(args)...);
84 void reset() { m_current = m_memory; }
85 size_t remaining()
const {
return N - (m_current - m_memory); }
86 size_t used()
const {
return m_current - m_memory; }
89 uint8_t m_memory[N] __attribute__((aligned(4)));
90 uint8_t *m_current = m_memory;
A bump allocator for fragments.
Definition bump-allocator.hh:56
size_t remaining() const
Definition bump-allocator.hh:85
Fragments::SimpleFragment< P > & allocateFragment(Args &&...args)
Definition bump-allocator.hh:59
T & allocate(Args &&...args)
Definition bump-allocator.hh:69
size_t used() const
Definition bump-allocator.hh:86
void reset()
Definition bump-allocator.hh:84
The Primitive concept.
Definition primitive-concept.hh:38
volatile uint32_t * ptr
Definition cop0.c:80
void assert(bool condition, const char *message, std::source_location location=std::source_location::current())
A simple assert macro.
Definition kernel.hh:300
Definition cdrom-loader.hh:39
static int size
Definition string.h:32
A fragment containing a single primitive.
Definition fragments.hh:67