1
0
forked from 0ad/0ad
0ad/source/lib/allocators/mem_util.h
janwas ffdff6888d add NUMA and shared-L2-cache detect code (required at work)
enable most of IA-32 specific code to be used in amd64 (resides in
directory lib/sysdep/x86_x64)

bits: add IsBitSet
remove mem_PageSize (use os_cpu_PageSize instead)
cpuid: change interface to allow gracefully supporting later
subfunctions that require input parameters
amd64_asm.asm: add amd64 implementation of cpuid
cpu: move functions provided by OS to sysdep/os_cpu.cpp
cpu topology: avoid trouble when process affinity is set by remapping
processor numbers to 0..PopulationCount(processAffinity)
topology.cpp: move ex-ia32 topology code here.

This was SVN commit r5945.
2008-05-12 18:15:08 +00:00

37 lines
1.3 KiB
C

/**
* =========================================================================
* File : mem_util.h
* Project : 0 A.D.
* Description : memory allocator helper routines.
* =========================================================================
*/
// license: GPL; see lib/license.txt
#ifndef INCLUDED_MEM_UTIL
#define INCLUDED_MEM_UTIL
extern bool mem_IsPageMultiple(uintptr_t x);
extern size_t mem_RoundUpToPage(size_t size);
extern size_t mem_RoundUpToAlignment(size_t size);
// very thin wrapper on top of sys/mman.h that makes the intent more obvious
// (its commit/decommit semantics are difficult to tell apart)
extern LibError mem_Reserve(size_t size, u8** pp);
extern LibError mem_Release(u8* p, size_t size);
extern LibError mem_Commit(u8* p, size_t size, int prot);
extern LibError mem_Decommit(u8* p, size_t size);
extern LibError mem_Protect(u8* p, size_t size, int prot);
// note: element memory is used to store a pointer to the next free element.
// rationale for the function-based interface: a class encapsulating the
// freelist pointer would force each header to include mem_util.h;
// instead, implementations need only declare a void* pointer.
extern void mem_freelist_AddToFront(void*& freelist, void* el);
extern void* mem_freelist_Detach(void*& freelist);
#endif // #ifndef INCLUDED_MEM_UTIL