From 19adf834ad67410454baa51d05467d2b1d3537c4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 09:31:49 -0500 Subject: [PATCH] xo-alloc2: register DArena facet + subsystem init --- include/xo/alloc2/alloc2_register_facets.hpp | 15 ++++++++ include/xo/alloc2/init_alloc2.hpp | 23 +++++++++++++ src/alloc2/CMakeLists.txt | 10 ++---- src/alloc2/alloc2_register_facets.cpp | 33 ++++++++++++++++++ src/alloc2/init_alloc2.cpp | 36 ++++++++++++++++++++ 5 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 include/xo/alloc2/alloc2_register_facets.hpp create mode 100644 include/xo/alloc2/init_alloc2.hpp create mode 100644 src/alloc2/alloc2_register_facets.cpp create mode 100644 src/alloc2/init_alloc2.cpp diff --git a/include/xo/alloc2/alloc2_register_facets.hpp b/include/xo/alloc2/alloc2_register_facets.hpp new file mode 100644 index 0000000..a53248a --- /dev/null +++ b/include/xo/alloc2/alloc2_register_facets.hpp @@ -0,0 +1,15 @@ +/** @file alloc2_register_facets.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +namespace xo { + namespace mm { + /** Register alloc2 (facet,impl) combinations with Facet Registry **/ + bool alloc2_register_facets(); + } +} + +/* end alloc2_register_facets.hpp */ diff --git a/include/xo/alloc2/init_alloc2.hpp b/include/xo/alloc2/init_alloc2.hpp new file mode 100644 index 0000000..c13160b --- /dev/null +++ b/include/xo/alloc2/init_alloc2.hpp @@ -0,0 +1,23 @@ +/** @file init_alloc2.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-alloc2/ subsystem within ordered initialization */ + enum S_alloc2_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; + + +} /*namespace xo*/ + +/* end init_alloc2.hpp */ diff --git a/src/alloc2/CMakeLists.txt b/src/alloc2/CMakeLists.txt index 7cebc7a..29890c5 100644 --- a/src/alloc2/CMakeLists.txt +++ b/src/alloc2/CMakeLists.txt @@ -3,26 +3,22 @@ set(SELF_LIB xo_alloc2) set(SELF_SRCS -# AllocError.cpp -# AllocInfo.cpp -# cmpresult.cpp + init_alloc2.cpp + alloc2_register_facets.cpp AAllocator.cpp -# ArenaConfig.cpp -# DArena.cpp IAllocator_Any.cpp IAllocator_DArena.cpp IAllocIterator_Any.cpp -# DArenaIterator.cpp IAllocIterator_DArenaIterator.cpp IResourceVisitor_Any.cpp - ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_alloc2Config.cmake.in xo_dependency(${SELF_LIB} xo_arena) xo_dependency(${SELF_LIB} xo_facet) +xo_dependency(${SELF_LIB} subsys) xo_dependency(${SELF_LIB} indentlog) diff --git a/src/alloc2/alloc2_register_facets.cpp b/src/alloc2/alloc2_register_facets.cpp new file mode 100644 index 0000000..e03afde --- /dev/null +++ b/src/alloc2/alloc2_register_facets.cpp @@ -0,0 +1,33 @@ +/** @file alloc2_register_facets.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "alloc2_register_facets.hpp" +#include +#include +#include + +namespace xo { + using xo::facet::FacetRegistry; + //using xo::facet::TypeRegistry; + using xo::reflect::typeseq; + + namespace mm { + + bool + alloc2_register_facets() + { + scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); + + log && log(xtag("DArena.tseq", typeseq::id())); + + return true; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end alloc2_register_facets.cpp */ diff --git a/src/alloc2/init_alloc2.cpp b/src/alloc2/init_alloc2.cpp new file mode 100644 index 0000000..d3fb73f --- /dev/null +++ b/src/alloc2/init_alloc2.cpp @@ -0,0 +1,36 @@ +/** @file init_alloc2.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "init_alloc2.hpp" +#include "alloc2_register_facets.hpp" + +namespace xo { + using xo::mm::alloc2_register_facets; + // using xo::mm::alloc2_register_types; + // using xo::mm::CollectorTypeRegistry; + + void + InitSubsys::init() + { + alloc2_register_facets(); + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* direct subsystem deps for xo-alloc2/ (if/when) */ + //retval ^= InitSubsys>::require(); + + /* xo-alloc2/'s own initialization code */ + retval ^= Subsystem::provide("alloc2", &init); + + return retval; + } + +} /*namespace xo*/ + +/* end init_alloc2.cpp */