3 #include <libcopp/utils/config/libcopp_build_features.h>
10 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
11 # include <valgrind/valgrind.h>
19 #include <sys/resource.h>
22 #include <sys/types.h>
39 #ifdef COPP_HAS_ABI_HEADERS
40 # include COPP_ABI_PREFIX
43 LIBCOPP_COPP_NAMESPACE_BEGIN
49 LIBCOPP_MACRO_NOEXCEPT {
55 LIBCOPP_MACRO_NOEXCEPT {
64 assert(
size > 0 && size_ > 0);
68 #if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
69 ::mmap(0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
71 ::mmap(0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
74 if (!start_ptr || MAP_FAILED == start_ptr) {
83 ctx.sp =
static_cast<char *
>(start_ptr) + ctx.size;
85 #
if defined(LIBCOPP_MACRO_USE_VALGRIND)
86 ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER(ctx.sp, start_ptr);
95 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
96 VALGRIND_STACK_DEREGISTER(ctx.valgrind_stack_id);
99 void *start_ptr =
static_cast<char *
>(ctx.sp) - ctx.size;
100 ::munmap(start_ptr, ctx.size);
103 LIBCOPP_COPP_NAMESPACE_END
105 #ifdef COPP_HAS_ABI_HEADERS
106 # include COPP_ABI_SUFFIX
memory allocator this allocator will create buffer using posix api and protect it
void allocate(stack_context &, std::size_t) LIBCOPP_MACRO_NOEXCEPT
void deallocate(stack_context &) LIBCOPP_MACRO_NOEXCEPT
stack_allocator_posix & operator=(const stack_allocator_posix &other) LIBCOPP_MACRO_NOEXCEPT
stack_allocator_posix() LIBCOPP_MACRO_NOEXCEPT
constexpr auto size(TCONTAINER &&container) -> decltype(container.size())
static LIBCOPP_COPP_API std::size_t page_size() LIBCOPP_MACRO_NOEXCEPT
static LIBCOPP_COPP_API std::size_t maximum_size() LIBCOPP_MACRO_NOEXCEPT
static LIBCOPP_COPP_API std::size_t round_to_page_size(std::size_t stacksize) LIBCOPP_MACRO_NOEXCEPT
static LIBCOPP_COPP_API std::size_t minimum_size() LIBCOPP_MACRO_NOEXCEPT
static LIBCOPP_COPP_API bool is_unbounded() LIBCOPP_MACRO_NOEXCEPT