xo-alloc2: rename: AllocatorError -> AllocError
This commit is contained in:
parent
56bdaec94c
commit
2dec6dbee8
16 changed files with 113 additions and 69 deletions
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "AllocatorError.hpp"
|
||||
#include "AllocError.hpp"
|
||||
#include "AllocInfo.hpp"
|
||||
#include "xo/facet/facet_implementation.hpp"
|
||||
#include "xo/facet/typeseq.hpp"
|
||||
|
|
@ -74,7 +74,7 @@ namespace xo {
|
|||
**/
|
||||
virtual bool contains(Copaque d, const void * p) const noexcept = 0;
|
||||
/** report last error **/
|
||||
virtual AllocatorError last_error(Copaque d) const noexcept = 0;
|
||||
virtual AllocError last_error(Copaque d) const noexcept = 0;
|
||||
/** fetch alloc info: given memory @p mem previously obtained
|
||||
* from {@ref alloc, @ref super_alloc}, get {tseq, age, size} details
|
||||
* for that allocation.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/** @file AllocatorError.hpp
|
||||
/** @file AllocError.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
|
@ -31,15 +31,15 @@ namespace xo {
|
|||
alloc_info_address,
|
||||
};
|
||||
|
||||
struct AllocatorError {
|
||||
struct AllocError {
|
||||
using size_type = std::size_t;
|
||||
using value_type = std::byte*;
|
||||
|
||||
AllocatorError() = default;
|
||||
explicit AllocatorError(error err,
|
||||
AllocError() = default;
|
||||
explicit AllocError(error err,
|
||||
uint32_t seq) : error_{err},
|
||||
error_seq_{seq} {}
|
||||
AllocatorError(error err,
|
||||
AllocError(error err,
|
||||
uint32_t seq,
|
||||
size_type req_z,
|
||||
size_type com_z,
|
||||
|
|
@ -66,4 +66,4 @@ namespace xo {
|
|||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end AllocatorError.hpp */
|
||||
/* end AllocError.hpp */
|
||||
44
include/xo/alloc2/alloc/AllocInfo.hpp
Normal file
44
include/xo/alloc2/alloc/AllocInfo.hpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/** @file AllocInfo.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AllocHeader.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
/** @class AllocInfo
|
||||
* @brief bookkeeping information for an allocation
|
||||
*
|
||||
* AllocInfo instances are 1:1 with sum of calls to
|
||||
* {@ref AAllocator::alloc, @ref AAllocator::alloc_super}
|
||||
*
|
||||
**/
|
||||
struct AllocInfo {
|
||||
using size_type = AllocHeader::size_type;
|
||||
|
||||
AllocInfo(const AllocHeaderConfig * p_cfg, const AllocHeader * p_hdr)
|
||||
: p_config_{p_cfg}, p_header_{p_hdr} {}
|
||||
|
||||
/** error when alloc-header not configured **/
|
||||
static AllocInfo error_not_configured(AllocHeaderConfig * p_cfg) { return AllocInfo(p_cfg, nullptr); }
|
||||
|
||||
/** true for non-sentinel AllocInfo instance **/
|
||||
bool is_valid() const { return (p_config_ != nullptr) && (p_header_ != nullptr); }
|
||||
|
||||
/** Type sequence number in garbage collector **/
|
||||
std::uint32_t tseq() const noexcept { return p_config_->tseq(*p_header_); }
|
||||
/** Allocation age in garbage collector **/
|
||||
std::uint32_t age() const noexcept { return p_config_->age (*p_header_); }
|
||||
/** Allocation size (including allocator-supplied padding) **/
|
||||
size_type size() const noexcept { return p_config_->size(*p_header_); }
|
||||
|
||||
const AllocHeaderConfig * p_config_ = nullptr;
|
||||
const AllocHeader * p_header_ = nullptr;
|
||||
};
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end AllocInfo.hpp */
|
||||
|
|
@ -39,7 +39,7 @@ namespace xo {
|
|||
[[noreturn]] size_type available(Copaque) const noexcept override { _fatal(); }
|
||||
[[noreturn]] size_type allocated(Copaque) const noexcept override { _fatal(); }
|
||||
[[noreturn]] bool contains(Copaque, const void *) const noexcept override { _fatal(); }
|
||||
[[noreturn]] AllocatorError last_error(Copaque) const noexcept override { _fatal(); }
|
||||
[[noreturn]] AllocError last_error(Copaque) const noexcept override { _fatal(); }
|
||||
|
||||
// non-const methods
|
||||
[[noreturn]] AllocInfo alloc_info(Opaque, value_type) const noexcept override { _fatal(); }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace xo {
|
|||
bool contains(Copaque d, const void * p) const noexcept override {
|
||||
return I::contains(_dcast(d), p);
|
||||
}
|
||||
AllocatorError last_error(Copaque d) const noexcept override { return I::last_error(_dcast(d)); }
|
||||
AllocError last_error(Copaque d) const noexcept override { return I::last_error(_dcast(d)); }
|
||||
|
||||
// non-const methods
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace xo {
|
|||
size_type available() const noexcept { return O::iface()->available(O::data()); }
|
||||
size_type allocated() const noexcept { return O::iface()->allocated(O::data()); }
|
||||
bool contains(const void * p) const noexcept { return O::iface()->contains(O::data(), p); }
|
||||
AllocatorError last_error() const noexcept { return O::iface()->last_error(O::data()); }
|
||||
AllocError last_error() const noexcept { return O::iface()->last_error(O::data()); }
|
||||
|
||||
value_type alloc(size_type z) noexcept { return O::iface()->alloc(O::data(), z); }
|
||||
value_type super_alloc(size_type z) noexcept { return O::iface()->super_alloc(O::data(), z); }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "alloc/AllocHeader.hpp"
|
||||
#include "alloc/AllocatorError.hpp"
|
||||
#include "alloc/AllocError.hpp"
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ namespace xo {
|
|||
uint32_t error_count_ = 0;
|
||||
|
||||
/** capture some error details if/when error **/
|
||||
AllocatorError last_error_;
|
||||
AllocError last_error_;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace xo {
|
|||
static size_type available(const DArena &) noexcept;
|
||||
static size_type allocated(const DArena &) noexcept;
|
||||
static bool contains(const DArena &, const void * p) noexcept;
|
||||
static AllocatorError last_error(const DArena &) noexcept;
|
||||
static AllocError last_error(const DArena &) noexcept;
|
||||
|
||||
/** retrieve allocation bookkeeping info for @p mem from arena @p d **/
|
||||
static AllocInfo alloc_info(DArena &, value_type mem) noexcept;
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ namespace xo {
|
|||
bool contains(role r, const void * addr) const noexcept;
|
||||
|
||||
/** return details from last error (will be in gen0 to-space) **/
|
||||
AllocatorError last_error() const noexcept;
|
||||
AllocError last_error() const noexcept;
|
||||
|
||||
/** get allocation size from header **/
|
||||
std::size_t header2size(header_type hdr) const noexcept;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace xo {
|
|||
/** true iff address @p p comes from collector @p d **/
|
||||
static bool contains(const DX1Collector & d, const void * p) noexcept;
|
||||
/** report last error, if any, for collector @p d **/
|
||||
static AllocatorError last_error(const DX1Collector &) noexcept;
|
||||
static AllocError last_error(const DX1Collector &) noexcept;
|
||||
|
||||
/** always alloc in gen0 to-space **/
|
||||
static value_type alloc(DX1Collector & d, size_type z) noexcept;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue