Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
page_aligned.h File Reference
#include "lib/posix/posix_mman.h"

Go to the source code of this file.

Functions

LIB_API Status mem_Reserve (size_t size, u8 **pp)
 
LIB_API Status mem_Release (u8 *p, size_t size)
 
LIB_API Status mem_Commit (u8 *p, size_t size, int prot)
 
LIB_API Status mem_Decommit (u8 *p, size_t size)
 
LIB_API Status mem_Protect (u8 *p, size_t size, int prot)
 
LIB_API void * page_aligned_alloc (size_t unaligned_size)
 allocate memory aligned to the system page size. More...
 
LIB_API void page_aligned_free (void *p, size_t unaligned_size)
 free a previously allocated page-aligned region. More...
 

Function Documentation

LIB_API Status mem_Commit ( u8 p,
size_t  size,
int  prot 
)

Definition at line 65 of file page_aligned.cpp.

LIB_API Status mem_Decommit ( u8 p,
size_t  size 
)

Definition at line 76 of file page_aligned.cpp.

LIB_API Status mem_Protect ( u8 p,
size_t  size,
int  prot 
)

Definition at line 83 of file page_aligned.cpp.

LIB_API Status mem_Release ( u8 p,
size_t  size 
)

Definition at line 57 of file page_aligned.cpp.

LIB_API Status mem_Reserve ( size_t  size,
u8 **  pp 
)

Definition at line 49 of file page_aligned.cpp.

LIB_API void* page_aligned_alloc ( size_t  unaligned_size)

allocate memory aligned to the system page size.

this is useful for file_cache_alloc, which uses this allocator to get sector-aligned (hopefully; see sys_max_sector_size) IO buffers.

note that this allocator is stateless and very little error checking can be performed.

the memory is initially writable and you can use mprotect to set other access permissions if desired.

Parameters
unaligned_sizeminimum size [bytes] to allocate.
Returns
page-aligned and -padded memory or 0 on error / out of memory.

Definition at line 95 of file page_aligned.cpp.

LIB_API void page_aligned_free ( void *  p,
size_t  unaligned_size 
)

free a previously allocated page-aligned region.

Parameters
pExact value returned from page_aligned_alloc
unaligned_sizeExact value passed to page_aligned_alloc

Definition at line 105 of file page_aligned.cpp.