1 #include "precompiled.h"
35 while(*idxDeleterOut <= 0)
42 deleters[idxDeleter] = deleter;
44 *idxDeleterOut = idxDeleter;
50 ASSERT(idxDeleter < numDeleters);
53 deleters[idxDeleter](pointer, size);
62 const size_t alignedSize =
round_up(size, alignment);
66 if(idxDeleterAligned == 0)
#define RVALUE(lvalue)
convert anything (lvalue or rvalue) to an rvalue
void * rtl_AllocateAligned(size_t size, size_t align)
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
#define COMPILER_FENCE
prevent the compiler from reordering loads or stores across this point.
void(* UniqueRangeDeleter)(void *pointer, size_t size)
static UniqueRangeDeleter deleters[allocationAlignment]
T round_up(T n, T multiple)
round number up/down to the next given multiple.
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
intptr_t cpu_AtomicAdd(volatile intptr_t *location, intptr_t increment)
add a signed value to a variable without the possibility of interference from other threads/CPUs...
void RegisterUniqueRangeDeleter(UniqueRangeDeleter deleter, volatile IdxDeleter *idxDeleterOut)
register a deleter, returning its index within the table.
NOTHROW_DEFINE void CallUniqueRangeDeleter(void *pointer, size_t size, IdxDeleter idxDeleter)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
static void FreeAligned(void *pointer, size_t size)
static IdxDeleter numDeleters
static Status AllocateAligned(shared_ptr< T > &p, size_t size, size_t alignment=cacheLineSize)
static const IdxDeleter idxDeleterNone
static void FreeNone(void *pointer, size_t size)
bool cpu_CAS(volatile intptr_t *location, intptr_t expected, intptr_t newValue)
atomic "compare and swap".
void * Allocate(size_t size, PageType pageType, int prot)
reserve address space and commit memory.
void rtl_FreeAligned(void *alignedPointer)
UniqueRange AllocateVM(size_t size, vm::PageType pageType, int prot)
void Free(void *p, size_t size)
decommit memory and release address space.
static const size_t allocationAlignment
void cpu_Pause()
pause in spin-wait loops, as a performance optimisation.