0ad/source/lib/allocators/mem_util.h
janwas 2e5d9452aa part2: misc source/lib fixes/improvements
move all except user-specified config choices out of config.h and into
appropriate headers
CPU_IA32 -> ARCH_IA32
wsdl: disable use of ddraw (will soon be replaced by WMI)

use shared_ptr without namespace qualifier (it's in tr1)
debug_warn -> debug_assert(0)
LIB_API to allow building as DLL
smart pointers: reduce use of .get()
cache_adt: use map instead of hash_map (avoids needing a hashCompare
class). also remove spurious warning
code_annotation.h: better cassert implementation
move FPS measuring portion of timer.cpp into frequency_filter
move include of memory headers into mmgr.h (to avoid errors, we must
ensure they are included if mmgr is used)
posix_filesystem.h: move definition of mkdir to wfilesystem
stl: disable iterator checks in release mode
wmi: fix COM init bug, use smart pointers
wutil: add code to get DLL module handle (if compiled as such), add
WinScopedLock
timer: fix handling of raw ticks

This was SVN commit r5517.
2007-12-20 20:09:19 +00:00

45 lines
1.5 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
/**
* @return page size
*
* (this routine caches the result of cpu_PageSize and ensures the value
* is available before static initializers have run.)
**/
extern size_t mem_PageSize();
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