#include <allocator.hpp>
Definition at line 52 of file allocator.hpp.
◆ 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
61#endif
62 _ptr = ::mmap(
nullptr, _size, PROT_READ | PROT_WRITE,
flags, -1, 0);
63 }
64 }
◆ ~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
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 }
◆ 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 }
◆ 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: