xo-arena: annex ArenaConfig.*pp from xo-alloc2/
This commit is contained in:
parent
e2cf88eb10
commit
c4734e2960
4 changed files with 1 additions and 89 deletions
|
|
@ -1,70 +0,0 @@
|
||||||
/** @file ArenaConfig.hpp
|
|
||||||
*
|
|
||||||
* @author Roland Conybeare, Dec 2025
|
|
||||||
**/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace xo {
|
|
||||||
namespace mm {
|
|
||||||
|
|
||||||
/** @class ArenaConfig
|
|
||||||
* @brief configuration for a @ref DArena instance
|
|
||||||
**/
|
|
||||||
struct ArenaConfig {
|
|
||||||
/** @defgroup mm-arenaconfig-ctors ArenaConfig ctors **/
|
|
||||||
///@{
|
|
||||||
|
|
||||||
/** create anonymous arena with size @p z **/
|
|
||||||
static ArenaConfig simple(std::size_t z);
|
|
||||||
|
|
||||||
///@}
|
|
||||||
|
|
||||||
/** @defgroup mm-arenaconfig-instance-vars ArenaConfig members **/
|
|
||||||
///@{
|
|
||||||
|
|
||||||
/** optional name, for diagnostics **/
|
|
||||||
std::string name_;
|
|
||||||
/** desired arena size -- hard max = reserved virtual memory **/
|
|
||||||
std::size_t size_;
|
|
||||||
/** hugepage size -- using huge pages relieves some TLB pressure
|
|
||||||
* (provided you use their full extent :)
|
|
||||||
**/
|
|
||||||
std::size_t hugepage_z_ = 2 * 1024 * 1024;
|
|
||||||
/** if non-zero, allocate extra space between allocs, and fill
|
|
||||||
* with fixed test-pattern contents. Allows for simple
|
|
||||||
* runtime arena sanitizing checks.
|
|
||||||
* Will be rounded up to multiple of @ref padding::c_alloc_alignment
|
|
||||||
**/
|
|
||||||
std::size_t guard_z_ = 0;
|
|
||||||
/** if guard_z_ > 0, write at least that many copies
|
|
||||||
* of this guard byte following each complete allocation
|
|
||||||
**/
|
|
||||||
std::uint8_t guard_byte_ = 0xfd;
|
|
||||||
/** if store_header_flag_ is true: mask bits for allocation size.
|
|
||||||
* remaining bits can be stolen for other purposes
|
|
||||||
* otherwise ignored
|
|
||||||
**/
|
|
||||||
/** true to store header (8 bytes) at the beginning of each allocation.
|
|
||||||
* necessary and sufficient to allows iterating over allocs
|
|
||||||
* present in arena
|
|
||||||
**/
|
|
||||||
bool store_header_flag_ = false;
|
|
||||||
/** mask applied to 8-byte alloc header.
|
|
||||||
* bits set to 1 store alloc size; remaining
|
|
||||||
* bits in alloc header can be used for other purposes.
|
|
||||||
**/
|
|
||||||
std::uint64_t header_size_mask_ = 0xffffffff;
|
|
||||||
/** true to enable debug logging **/
|
|
||||||
bool debug_flag_ = false;
|
|
||||||
|
|
||||||
///@}
|
|
||||||
};
|
|
||||||
|
|
||||||
} /*namespace mm*/
|
|
||||||
} /*namespace xo*/
|
|
||||||
|
|
||||||
/* end ArenaConfig.hpp */
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AllocHeaderConfig.hpp"
|
#include "AllocHeaderConfig.hpp"
|
||||||
//#include "alloc/AllocError.hpp"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/** @file ArenaConfig.cpp
|
|
||||||
*
|
|
||||||
* @author Roland Conybeare, Dec 2025
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "ArenaConfig.hpp"
|
|
||||||
namespace xo {
|
|
||||||
namespace mm {
|
|
||||||
ArenaConfig
|
|
||||||
ArenaConfig::simple(std::size_t z)
|
|
||||||
{
|
|
||||||
return ArenaConfig { .name_ = "anonymous", .size_ = z };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* end ArenaConfig.cpp */
|
|
||||||
|
|
@ -8,7 +8,7 @@ set(SELF_SRCS
|
||||||
cmpresult.cpp
|
cmpresult.cpp
|
||||||
|
|
||||||
AAllocator.cpp
|
AAllocator.cpp
|
||||||
ArenaConfig.cpp
|
# ArenaConfig.cpp
|
||||||
DArena.cpp
|
DArena.cpp
|
||||||
IAllocator_Any.cpp
|
IAllocator_Any.cpp
|
||||||
IAllocator_DArena.cpp
|
IAllocator_DArena.cpp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue