Pyrogenesis  trunk
Functions | Variables
unique_range.cpp File Reference
#include "precompiled.h"
#include "lib/allocators/unique_range.h"
#include "lib/bits.h"
#include "lib/sysdep/cpu.h"
#include "lib/sysdep/rtl.h"
Include dependency graph for unique_range.cpp:

Functions

static void FreeNone (void *pointer, size_t size)
 
static void FreeAligned (void *pointer, size_t size)
 
void RegisterUniqueRangeDeleter (UniqueRangeDeleter deleter, volatile IdxDeleter *idxDeleterOut)
 register a deleter, returning its index within the table. More...
 
NOTHROW_DEFINE void CallUniqueRangeDeleter (void *pointer, size_t size, IdxDeleter idxDeleter)
 
UniqueRange AllocateAligned (size_t size, size_t alignment)
 
UniqueRange AllocateVM (size_t size, vm::PageType pageType, int prot)
 

Variables

static UniqueRangeDeleter deleters [allocationAlignment] = { FreeNone, FreeAligned }
 
static IdxDeleter numDeleters = 2
 

Function Documentation

UniqueRange AllocateAligned ( size_t  size,
size_t  alignment 
)
UniqueRange AllocateVM ( size_t  size,
vm::PageType  pageType,
int  prot 
)
NOTHROW_DEFINE void CallUniqueRangeDeleter ( void *  pointer,
size_t  size,
IdxDeleter  idxDeleter 
)
static void FreeAligned ( void *  pointer,
size_t  size 
)
static
static void FreeNone ( void *  pointer,
size_t  size 
)
static
void RegisterUniqueRangeDeleter ( UniqueRangeDeleter  deleter,
volatile IdxDeleter idxDeleter 
)

register a deleter, returning its index within the table.

Parameters
deleterfunction pointer. must be uniquely associated with the idxDeleter storage location.
idxDeleterlocation where to store the next available index. if it is already non-zero, skip the call to this function to avoid overhead.

thread-safe. idxDeleter is used for mutual exclusion between multiple callers for the same deleter. concurrent registration of different deleters is also safe due to atomic increments.

halts the program if more than allocationAlignment deleters are to be registered.

Variable Documentation

IdxDeleter numDeleters = 2
static