1
0
forked from 0ad/0ad
0ad/source/lib/allocators/mem_util.h
janwas d43636f8ae work-related additions:
x86_x64.cpp: detect TLBs (a major undertaking :/)
mem_util: export functions
win.h: hopefully avoid warnings from either vc2008 and vc2005 about
already defined win32 version macros
wnuma: revise large page heuristic (cause of slowdown is now known)

This was SVN commit r6600.
2009-01-06 20:17:06 +00:00

37 lines
1.4 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
LIB_API bool mem_IsPageMultiple(uintptr_t x);
LIB_API size_t mem_RoundUpToPage(size_t size);
LIB_API 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)
LIB_API LibError mem_Reserve(size_t size, u8** pp);
LIB_API LibError mem_Release(u8* p, size_t size);
LIB_API LibError mem_Commit(u8* p, size_t size, int prot);
LIB_API LibError mem_Decommit(u8* p, size_t size);
LIB_API 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.
LIB_API void mem_freelist_AddToFront(void*& freelist, void* el);
LIB_API void* mem_freelist_Detach(void*& freelist);
#endif // #ifndef INCLUDED_MEM_UTIL