3 #include <libcopp/utils/config/libcopp_build_features.h>
11 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
12 # include <valgrind/valgrind.h>
15 #ifdef COPP_HAS_ABI_HEADERS
16 # include COPP_ABI_PREFIX
31 LIBCOPP_COPP_NAMESPACE_BEGIN
39 std::size_t max_size) LIBCOPP_MACRO_NOEXCEPT
40 : start_ptr_(start_ptr),
41 memory_size_(max_size),
45 : start_ptr_(
nullptr),
48 if (!other.is_used_) {
54 : start_ptr_(
nullptr),
57 if (!other.is_used_) {
65 LIBCOPP_MACRO_NOEXCEPT {
66 if (!other.is_used_) {
73 LIBCOPP_MACRO_NOEXCEPT {
74 if (!other.is_used_) {
88 start_ptr_ = start_ptr;
89 memory_size_ = max_size;
94 if (
nullptr == start_ptr_ || is_used_) {
101 size = (std::min)(
size, memory_size_);
104 assert(
size > 0 && size_ > 0 && size_ <= memory_size_);
107 ctx.sp =
static_cast<char *
>(start_ptr_) + ctx.size;
109 #
if defined(LIBCOPP_MACRO_USE_VALGRIND)
110 ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER(ctx.sp, start_ptr_);
116 LIBCOPP_MACRO_NOEXCEPT {
121 #if defined(LIBCOPP_MACRO_USE_VALGRIND)
122 VALGRIND_STACK_DEREGISTER(ctx.valgrind_stack_id);
127 LIBCOPP_COPP_NAMESPACE_END
129 #ifdef COPP_HAS_ABI_HEADERS
130 # include COPP_ABI_SUFFIX
memory allocator this allocator will return address of specified memory section
void attach(void *start_ptr, std::size_t max_size) LIBCOPP_MACRO_NOEXCEPT
void deallocate(stack_context &ctx) LIBCOPP_MACRO_NOEXCEPT
void swap(stack_allocator_memory &other)
~stack_allocator_memory()
stack_allocator_memory & operator=(stack_allocator_memory &other) LIBCOPP_MACRO_NOEXCEPT
stack_allocator_memory() LIBCOPP_MACRO_NOEXCEPT
void allocate(stack_context &ctx, std::size_t size) LIBCOPP_MACRO_NOEXCEPT
导入继承关系约束 Licensed under the MIT licenses.
#define EXPLICIT_UNUSED_ATTR
maybe_unused, 标记忽略unused警告 usage: EXPLICIT_UNUSED_ATTR int a; class EXPLICIT_UNUSED_ATTR a; EXPLICIT_...
constexpr auto size(TCONTAINER &&container) -> decltype(container.size())
void swap(intrusive_ptr< T > &lhs, intrusive_ptr< T > &rhs)
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