SST/macro
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
sstmac::sw::stack_alloc Class Reference

A management type to handle dividing mmap-ed memory for use as ucontext stack(s). More...

#include <stack_alloc.h>

Collaboration diagram for sstmac::sw::stack_alloc:
Collaboration graph

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_
 

Detailed Description

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.

Member Typedef Documentation

typedef std::vector<void*> sstmac::sw::stack_alloc::available_vec_t
private

This is our list of un-allocated chunks:

Definition at line 46 of file stack_alloc.h.

typedef std::vector<chunk*> sstmac::sw::stack_alloc::chunk_vec_t
private

This is where we store the memory regions.

Definition at line 34 of file stack_alloc.h.

Constructor & Destructor Documentation

sstmac::sw::stack_alloc::stack_alloc ( )

Build.

virtual sstmac::sw::stack_alloc::~stack_alloc ( )
virtual

Goodbye.

Referenced by chunksize().

Member Function Documentation

void* sstmac::sw::stack_alloc::alloc ( )

Get a stack memory region.

Referenced by chunksize().

size_t sstmac::sw::stack_alloc::chunksize ( ) const
inline

Definition at line 64 of file stack_alloc.h.

References alloc(), free(), init(), stacksize(), suggested_chunk_, use_mprot(), and ~stack_alloc().

Here is the call graph for this function:

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().

bool sstmac::sw::stack_alloc::initialized ( ) const
inline

Definition at line 80 of file stack_alloc.h.

References clear(), and stacksize_.

Here is the call graph for this function:

size_t sstmac::sw::stack_alloc::stacksize ( ) const
inline

Definition at line 54 of file stack_alloc.h.

References stacksize_.

Referenced by chunksize().

bool sstmac::sw::stack_alloc::use_mprot ( ) const
inline

Definition at line 59 of file stack_alloc.h.

References use_mprot_.

Referenced by chunksize().

Member Data Documentation

available_vec_t sstmac::sw::stack_alloc::available_
private

Definition at line 47 of file stack_alloc.h.

chunk_vec_t sstmac::sw::stack_alloc::chunks_
private

Definition at line 37 of file stack_alloc.h.

size_t sstmac::sw::stack_alloc::stacksize_
private

Each stack request is of this size:

Definition at line 41 of file stack_alloc.h.

Referenced by initialized(), and stacksize().

size_t sstmac::sw::stack_alloc::suggested_chunk_
private

Each chunk is of this suggested size.

Definition at line 39 of file stack_alloc.h.

Referenced by chunksize().

bool sstmac::sw::stack_alloc::use_mprot_
private

Do we want stacks separated by an mprot region?

Definition at line 43 of file stack_alloc.h.

Referenced by use_mprot().


The documentation for this class was generated from the following file: