SST/macro
|
A management type to handle dividing mmap-ed memory for use as ucontext stack(s). More...
#include <stack_alloc.h>
Classes | |
class | chunk |
A chunk of allocated memory to be divided into fixed-size stacks. More... | |
Public Member Functions | |
stack_alloc () | |
Build. More... | |
size_t | stacksize () const |
bool | use_mprot () const |
size_t | chunksize () const |
virtual | ~stack_alloc () |
Goodbye. More... | |
void * | alloc () |
Get a stack memory region. More... | |
void | free (void *) |
Return the given memory region. More... | |
void | init (size_t stacksize, size_t alloc_unit, bool use_mprot) |
bool | initialized () const |
void | clear () |
Private Types | |
typedef std::vector< chunk * > | chunk_vec_t |
This is where we store the memory regions. More... | |
typedef std::vector< void * > | available_vec_t |
This is our list of un-allocated chunks: More... | |
Private Attributes | |
chunk_vec_t | chunks_ |
size_t | suggested_chunk_ |
Each chunk is of this suggested size. More... | |
size_t | stacksize_ |
Each stack request is of this size: More... | |
bool | use_mprot_ |
Do we want stacks separated by an mprot region? More... | |
available_vec_t | available_ |
A management type to handle dividing mmap-ed memory for use as ucontext stack(s).
This is basically a very simple malloc which allocates uniform-size chunks (with the NX bit unset) and sets guard pages on each side of the allocated stacks.
This allocator does not return memory to the system until it is deleted, but regions can be allocated and free-d repeatedly.
Definition at line 30 of file stack_alloc.h.
|
private |
This is our list of un-allocated chunks:
Definition at line 46 of file stack_alloc.h.
|
private |
This is where we store the memory regions.
Definition at line 34 of file stack_alloc.h.
sstmac::sw::stack_alloc::stack_alloc | ( | ) |
Build.
|
virtual |
Goodbye.
Referenced by chunksize().
void* sstmac::sw::stack_alloc::alloc | ( | ) |
Get a stack memory region.
Referenced by chunksize().
|
inline |
Definition at line 64 of file stack_alloc.h.
References alloc(), free(), init(), stacksize(), suggested_chunk_, use_mprot(), and ~stack_alloc().
void sstmac::sw::stack_alloc::clear | ( | ) |
Referenced by initialized().
void sstmac::sw::stack_alloc::free | ( | void * | ) |
Return the given memory region.
Referenced by chunksize().
void sstmac::sw::stack_alloc::init | ( | size_t | stacksize, |
size_t | alloc_unit, | ||
bool | use_mprot | ||
) |
Referenced by chunksize().
|
inline |
Definition at line 80 of file stack_alloc.h.
References clear(), and stacksize_.
|
inline |
|
inline |
|
private |
Definition at line 47 of file stack_alloc.h.
|
private |
Definition at line 37 of file stack_alloc.h.
|
private |
Each stack request is of this size:
Definition at line 41 of file stack_alloc.h.
Referenced by initialized(), and stacksize().
|
private |
Each chunk is of this suggested size.
Definition at line 39 of file stack_alloc.h.
Referenced by chunksize().
|
private |
Do we want stacks separated by an mprot region?
Definition at line 43 of file stack_alloc.h.
Referenced by use_mprot().