Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::stack_allocator Class Reference

#include <allocator.hpp>

Public Member Functions

 stack_allocator (std::size_t min_size)
 
 ~stack_allocator ()
 
void * top () const
 
 stack_allocator (std::size_t min_size)
 
 ~stack_allocator ()
 
void * top () const
 

Detailed Description

Definition at line 52 of file allocator.hpp.

Constructor & Destructor Documentation

◆ stack_allocator() [1/2]

sysio::vm::stack_allocator::stack_allocator ( std::size_t min_size)
inlineexplicit

Definition at line 54 of file allocator.hpp.

54 {
55 if(min_size > 4*1024*1024) {
56 std::size_t pagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
57 _size = ((min_size + pagesize - 1) & ~(pagesize - 1)) + 4*1024*1024;
58 int flags = MAP_PRIVATE | MAP_ANONYMOUS;
59#ifdef MAP_STACK
60 flags |= MAP_STACK;
61#endif
62 _ptr = ::mmap(nullptr, _size, PROT_READ | PROT_WRITE, flags, -1, 0);
63 }
64 }
pInfo flags

◆ ~stack_allocator() [1/2]

sysio::vm::stack_allocator::~stack_allocator ( )
inline

Definition at line 65 of file allocator.hpp.

65 {
66 if(_ptr) {
67 ::munmap(_ptr, _size);
68 }
69 }

◆ stack_allocator() [2/2]

sysio::vm::stack_allocator::stack_allocator ( std::size_t min_size)
inlineexplicit

Definition at line 54 of file allocator.hpp.

54 {
55 if(min_size > 4*1024*1024) {
56 std::size_t pagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
57 _size = ((min_size + pagesize - 1) & ~(pagesize - 1)) + 4*1024*1024;
58 int flags = MAP_PRIVATE | MAP_ANONYMOUS;
59#ifdef MAP_STACK
60 flags |= MAP_STACK;
61#endif
62 _ptr = ::mmap(nullptr, _size, PROT_READ | PROT_WRITE, flags, -1, 0);
63 }
64 }

◆ ~stack_allocator() [2/2]

sysio::vm::stack_allocator::~stack_allocator ( )
inline

Definition at line 65 of file allocator.hpp.

65 {
66 if(_ptr) {
67 ::munmap(_ptr, _size);
68 }
69 }

Member Function Documentation

◆ top() [1/2]

void * sysio::vm::stack_allocator::top ( ) const
inline

Definition at line 70 of file allocator.hpp.

70 {
71 if(_ptr) {
72 return static_cast<char*>(_ptr) + _size;
73 } else {
74 return nullptr;
75 }
76 }
Here is the caller graph for this function:

◆ top() [2/2]

void * sysio::vm::stack_allocator::top ( ) const
inline

Definition at line 70 of file allocator.hpp.

70 {
71 if(_ptr) {
72 return static_cast<char*>(_ptr) + _size;
73 } else {
74 return nullptr;
75 }
76 }

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