diff --git a/CMakeLists.txt b/CMakeLists.txt index b1dda88c..a55c8e22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,9 +75,10 @@ set(DOX_EXCLUDE_PATTERNS [=[ # in reverse topological order i.e. dependencies first add_subdirectory(xo-cmake) -add_subdirectory(xo-reflectutil) # header-only reflect support -add_subdirectory(xo-facet) # sep iface,data add_subdirectory(xo-indentlog) +add_subdirectory(xo-reflectutil) # header-only reflect support +add_subdirectory(xo-arena) # arena allocator (DArena) +add_subdirectory(xo-facet) # sep iface,data add_subdirectory(xo-allocutil) add_subdirectory(xo-refcnt) add_subdirectory(xo-subsys) diff --git a/xo-alloc2/cmake/xo_alloc2Config.cmake.in b/xo-alloc2/cmake/xo_alloc2Config.cmake.in index 65ab5b1c..e0b5e0b0 100644 --- a/xo-alloc2/cmake/xo_alloc2Config.cmake.in +++ b/xo-alloc2/cmake/xo_alloc2Config.cmake.in @@ -2,6 +2,7 @@ include(CMakeFindDependencyMacro) #find_dependency(indentlog) +find_depnedency(xo_arena) find_dependency(xo_facet) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/xo-alloc2/include/xo/alloc2/ArenaConfig.hpp b/xo-alloc2/include/xo/alloc2/ArenaConfig.hpp deleted file mode 100644 index 7d3f3478..00000000 --- a/xo-alloc2/include/xo/alloc2/ArenaConfig.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/** @file ArenaConfig.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include -#include - -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 */ diff --git a/xo-alloc2/include/xo/alloc2/alloc/AAllocIterator.hpp b/xo-alloc2/include/xo/alloc2/alloc/AAllocIterator.hpp index 4b9f4ab9..e7581dc4 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/AAllocIterator.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/AAllocIterator.hpp @@ -23,7 +23,7 @@ namespace xo { **/ struct AAllocIterator { using obj_AAllocIterator = xo::facet::obj; - using typeseq = xo::facet::typeseq; + using typeseq = xo::reflect::typeseq; /** @defgroup mm-allociterator-methods AllocIterator methods **/ ///@{ diff --git a/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp b/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp index 0fce475c..588b439b 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp @@ -5,7 +5,7 @@ #pragma once -#include "AllocError.hpp" +#include #include "AllocInfo.hpp" //#include "AllocIterator.hpp" #include "AllocRange.hpp" diff --git a/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Any.hpp b/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Any.hpp index f946c397..1bed0ff1 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Any.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Any.hpp @@ -20,7 +20,7 @@ namespace xo { * @brief AllocIterator implementation for empty variant instance **/ struct IAllocIterator_Any : public AAllocIterator { - using typeseq = xo::facet::typeseq; + using typeseq = xo::reflect::typeseq; const AAllocIterator * iface() const { return std::launder(this); } diff --git a/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Xfer.hpp b/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Xfer.hpp index e61e326c..251f4afd 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/IAllocIterator_Xfer.hpp @@ -18,7 +18,7 @@ namespace xo { typename IAllocIterator_DRepr> struct IAllocIterator_Xfer : public AAllocIterator { using Impl = IAllocIterator_DRepr; - using typeseq = xo::facet::typeseq; + using typeseq = xo::reflect::typeseq; static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } @@ -48,9 +48,9 @@ namespace xo { }; template - xo::facet::typeseq + xo::reflect::typeseq IAllocIterator_Xfer::s_typeseq - = facet::typeseq::id(); + = reflect::typeseq::id(); template bool diff --git a/xo-alloc2/include/xo/alloc2/alloc/RAllocIterator.hpp b/xo-alloc2/include/xo/alloc2/alloc/RAllocIterator.hpp index 4e1a95f8..47d59f29 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/RAllocIterator.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/RAllocIterator.hpp @@ -17,7 +17,7 @@ namespace xo { public: using ObjectType = Object; using DataPtr = Object::DataPtr; - using typeseq = xo::facet::typeseq; + using typeseq = xo::reflect::typeseq; RAllocIterator() {} RAllocIterator(Object::DataPtr data) : Object{std::move(data)} {} diff --git a/xo-alloc2/include/xo/alloc2/arena/IAllocIterator_DArenaIterator.hpp b/xo-alloc2/include/xo/alloc2/arena/IAllocIterator_DArenaIterator.hpp index dfe84005..5af231ac 100644 --- a/xo-alloc2/include/xo/alloc2/arena/IAllocIterator_DArenaIterator.hpp +++ b/xo-alloc2/include/xo/alloc2/arena/IAllocIterator_DArenaIterator.hpp @@ -6,7 +6,7 @@ #pragma once #include "alloc/IAllocIterator_Xfer.hpp" -#include "arena/DArenaIterator.hpp" +#include namespace xo { namespace mm { struct IAllocIterator_DArenaIterator; } diff --git a/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp b/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp index 9f18adc1..4a871822 100644 --- a/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp +++ b/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp @@ -5,7 +5,7 @@ #include "alloc/AAllocator.hpp" #include "alloc/IAllocator_Xfer.hpp" -#include "arena/DArena.hpp" +#include namespace xo { namespace mm { struct IAllocator_DArena; } diff --git a/xo-alloc2/src/alloc2/ArenaConfig.cpp b/xo-alloc2/src/alloc2/ArenaConfig.cpp deleted file mode 100644 index 7f4e4248..00000000 --- a/xo-alloc2/src/alloc2/ArenaConfig.cpp +++ /dev/null @@ -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 */ diff --git a/xo-alloc2/src/alloc2/CMakeLists.txt b/xo-alloc2/src/alloc2/CMakeLists.txt index 1d66ead5..3a279746 100644 --- a/xo-alloc2/src/alloc2/CMakeLists.txt +++ b/xo-alloc2/src/alloc2/CMakeLists.txt @@ -3,23 +3,24 @@ set(SELF_LIB xo_alloc2) set(SELF_SRCS - AllocError.cpp - AllocInfo.cpp - cmpresult.cpp +# AllocError.cpp +# AllocInfo.cpp +# cmpresult.cpp AAllocator.cpp - ArenaConfig.cpp - DArena.cpp +# ArenaConfig.cpp +# DArena.cpp IAllocator_Any.cpp IAllocator_DArena.cpp IAllocIterator_Any.cpp - DArenaIterator.cpp +# DArenaIterator.cpp IAllocIterator_DArenaIterator.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} indentlog) diff --git a/xo-alloc2/src/alloc2/IAllocIterator_Any.cpp b/xo-alloc2/src/alloc2/IAllocIterator_Any.cpp index befaea8c..86c2ba72 100644 --- a/xo-alloc2/src/alloc2/IAllocIterator_Any.cpp +++ b/xo-alloc2/src/alloc2/IAllocIterator_Any.cpp @@ -9,8 +9,8 @@ namespace xo { namespace mm { using xo::facet::DVariantPlaceholder; - using xo::facet::typeseq; using xo::facet::valid_facet_implementation; + using xo::reflect::typeseq; void IAllocIterator_Any::_fatal() { diff --git a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp index ed956240..a3bd9613 100644 --- a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp +++ b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp @@ -6,8 +6,8 @@ #include "AllocIterator.hpp" #include "arena/IAllocator_DArena.hpp" #include "arena/IAllocIterator_DArenaIterator.hpp" // for alloc_range -#include "arena/DArenaIterator.hpp" -#include "padding.hpp" +#include +#include #include #include #include diff --git a/xo-alloc2/utest/arena.test.cpp b/xo-alloc2/utest/arena.test.cpp index 6c3278ba..9bd87202 100644 --- a/xo-alloc2/utest/arena.test.cpp +++ b/xo-alloc2/utest/arena.test.cpp @@ -5,11 +5,9 @@ #include "xo/alloc2/Allocator.hpp" #include "xo/alloc2/alloc/IAllocator_Xfer.hpp" -//#include "xo/alloc2/DArena.hpp" #include "xo/alloc2/arena/IAllocator_DArena.hpp" -//#include "xo/alloc2/alloc/RAllocator.hpp" #include "xo/alloc2/print.hpp" -#include "xo/alloc2/padding.hpp" +#include "xo/arena/padding.hpp" #include #include #include diff --git a/xo-alloc2/utest/random_allocs.cpp b/xo-alloc2/utest/random_allocs.cpp index 654c6c9a..1f7f833f 100644 --- a/xo-alloc2/utest/random_allocs.cpp +++ b/xo-alloc2/utest/random_allocs.cpp @@ -4,8 +4,8 @@ **/ #include "random_allocs.hpp" -#include "arena/DArena.hpp" -#include "padding.hpp" +#include +#include #include #include #include diff --git a/xo-arena/CMakeLists.txt b/xo-arena/CMakeLists.txt new file mode 100644 index 00000000..24d544ec --- /dev/null +++ b/xo-arena/CMakeLists.txt @@ -0,0 +1,31 @@ +# xo-arena/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_arena VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +add_subdirectory(src/arena) +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# cmake export + +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# end CMakeLists.txt diff --git a/xo-arena/README.md b/xo-arena/README.md deleted file mode 100644 index 6c14c75c..00000000 --- a/xo-arena/README.md +++ /dev/null @@ -1 +0,0 @@ -# xo-arena diff --git a/xo-arena/cmake/xo-bootstrap-macros.cmake b/xo-arena/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..2cf387e5 --- /dev/null +++ b/xo-arena/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() diff --git a/xo-arena/cmake/xo_arenaConfig.cmake.in b/xo-arena/cmake/xo_arenaConfig.cmake.in new file mode 100644 index 00000000..1700fb8a --- /dev/null +++ b/xo-arena/cmake/xo_arenaConfig.cmake.in @@ -0,0 +1,13 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +find_dependency(xo_reflectutil) +find_dependency(indentlog) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/xo-arena/include/xo/arena/.gitkeep b/xo-arena/include/xo/arena/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/xo-alloc2/include/xo/alloc2/AllocError.hpp b/xo-arena/include/xo/arena/AllocError.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/AllocError.hpp rename to xo-arena/include/xo/arena/AllocError.hpp diff --git a/xo-alloc2/include/xo/alloc2/AllocHeader.hpp b/xo-arena/include/xo/arena/AllocHeader.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/AllocHeader.hpp rename to xo-arena/include/xo/arena/AllocHeader.hpp diff --git a/xo-alloc2/include/xo/alloc2/AllocHeaderConfig.hpp b/xo-arena/include/xo/arena/AllocHeaderConfig.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/AllocHeaderConfig.hpp rename to xo-arena/include/xo/arena/AllocHeaderConfig.hpp diff --git a/xo-alloc2/include/xo/alloc2/AllocInfo.hpp b/xo-arena/include/xo/arena/AllocInfo.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/AllocInfo.hpp rename to xo-arena/include/xo/arena/AllocInfo.hpp diff --git a/xo-alloc2/include/xo/alloc2/arena/ArenaConfig.hpp b/xo-arena/include/xo/arena/ArenaConfig.hpp similarity index 97% rename from xo-alloc2/include/xo/alloc2/arena/ArenaConfig.hpp rename to xo-arena/include/xo/arena/ArenaConfig.hpp index fcd95347..4d79637b 100644 --- a/xo-alloc2/include/xo/alloc2/arena/ArenaConfig.hpp +++ b/xo-arena/include/xo/arena/ArenaConfig.hpp @@ -6,7 +6,6 @@ #pragma once #include "AllocHeaderConfig.hpp" -//#include "alloc/AllocError.hpp" #include #include diff --git a/xo-alloc2/include/xo/alloc2/arena/DArena.hpp b/xo-arena/include/xo/arena/DArena.hpp similarity index 98% rename from xo-alloc2/include/xo/alloc2/arena/DArena.hpp rename to xo-arena/include/xo/arena/DArena.hpp index 45556d9f..f9c2e3c6 100644 --- a/xo-alloc2/include/xo/alloc2/arena/DArena.hpp +++ b/xo-arena/include/xo/arena/DArena.hpp @@ -8,7 +8,7 @@ #include "ArenaConfig.hpp" #include "AllocError.hpp" #include "AllocInfo.hpp" -#include +#include namespace xo { namespace mm { @@ -46,7 +46,7 @@ namespace xo { /** @brief type for allocation header (if enabled) **/ using header_type = AllocHeader; /** integer identifying a type (see xo::facet::typeid()) **/ - using typeseq = xo::facet::typeseq; + using typeseq = xo::reflect::typeseq; /** @brief mode argument for @ref _alloc **/ enum class alloc_mode : uint8_t { @@ -280,7 +280,7 @@ namespace xo { static T * construct_with(DArena & ialloc, Args&&... args) { - using xo::facet::typeseq; + using xo::reflect::typeseq; typeseq t = typeseq::id(); std::byte * mem = ialloc.alloc(t, sizeof(T)); diff --git a/xo-alloc2/include/xo/alloc2/arena/DArenaIterator.hpp b/xo-arena/include/xo/arena/DArenaIterator.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/arena/DArenaIterator.hpp rename to xo-arena/include/xo/arena/DArenaIterator.hpp diff --git a/xo-alloc2/include/xo/alloc2/cmpresult.hpp b/xo-arena/include/xo/arena/cmpresult.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/cmpresult.hpp rename to xo-arena/include/xo/arena/cmpresult.hpp diff --git a/xo-alloc2/include/xo/alloc2/padding.hpp b/xo-arena/include/xo/arena/padding.hpp similarity index 100% rename from xo-alloc2/include/xo/alloc2/padding.hpp rename to xo-arena/include/xo/arena/padding.hpp diff --git a/xo-alloc2/src/alloc2/AllocError.cpp b/xo-arena/src/arena/AllocError.cpp similarity index 100% rename from xo-alloc2/src/alloc2/AllocError.cpp rename to xo-arena/src/arena/AllocError.cpp diff --git a/xo-alloc2/src/alloc2/AllocInfo.cpp b/xo-arena/src/arena/AllocInfo.cpp similarity index 100% rename from xo-alloc2/src/alloc2/AllocInfo.cpp rename to xo-arena/src/arena/AllocInfo.cpp diff --git a/xo-arena/src/arena/CMakeLists.txt b/xo-arena/src/arena/CMakeLists.txt new file mode 100644 index 00000000..111bbe15 --- /dev/null +++ b/xo-arena/src/arena/CMakeLists.txt @@ -0,0 +1,24 @@ +# xo-arena/src/CMakeLists.txt + +set(SELF_LIB xo_arena) +set(SELF_SRCS + cmpresult.cpp + AllocError.cpp + AllocInfo.cpp + DArena.cpp + DArenaIterator.cpp +) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +xo_install_include_tree3(include/xo/arena) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# xo-arena/cmake/xo_arenaConfig.cmake.in + +xo_dependency(${SELF_LIB} xo_reflectutil) +xo_dependency(${SELF_LIB} indentlog) + +# end src/CMakeLists.txt diff --git a/xo-alloc2/src/alloc2/DArena.cpp b/xo-arena/src/arena/DArena.cpp similarity index 98% rename from xo-alloc2/src/alloc2/DArena.cpp rename to xo-arena/src/arena/DArena.cpp index 82557e4b..5c0e3641 100644 --- a/xo-alloc2/src/alloc2/DArena.cpp +++ b/xo-arena/src/arena/DArena.cpp @@ -3,19 +3,19 @@ * @author Roland Conybeare, Dec 2025 **/ -#include "alloc/AAllocator.hpp" -#include "arena/DArena.hpp" -#include "arena/DArenaIterator.hpp" -#include "xo/alloc2/padding.hpp" -#include "xo/indentlog/scope.hpp" -#include "xo/indentlog/print/tag.hpp" +//#include "alloc/AAllocator.hpp" +#include "DArena.hpp" +#include "DArenaIterator.hpp" +#include +#include +#include #include #include // for ::munmap() #include // for ::getpagesize() #include // for ::memset() namespace xo { - using xo::facet::typeseq; + using xo::reflect::typeseq; using std::byte; using std::cerr; using std::endl; diff --git a/xo-alloc2/src/alloc2/DArenaIterator.cpp b/xo-arena/src/arena/DArenaIterator.cpp similarity index 98% rename from xo-alloc2/src/alloc2/DArenaIterator.cpp rename to xo-arena/src/arena/DArenaIterator.cpp index b9873e31..931108bb 100644 --- a/xo-alloc2/src/alloc2/DArenaIterator.cpp +++ b/xo-arena/src/arena/DArenaIterator.cpp @@ -3,8 +3,8 @@ * @author Roland Conybeare, Dec 2025 **/ -#include "arena/DArenaIterator.hpp" -#include "arena/DArena.hpp" +#include "DArenaIterator.hpp" +#include "DArena.hpp" #include #include #include diff --git a/xo-alloc2/src/alloc2/cmpresult.cpp b/xo-arena/src/arena/cmpresult.cpp similarity index 100% rename from xo-alloc2/src/alloc2/cmpresult.cpp rename to xo-arena/src/arena/cmpresult.cpp diff --git a/xo-cmake/bin/scaffold-headeronly b/xo-cmake/bin/scaffold-headeronly new file mode 100755 index 00000000..b4455677 --- /dev/null +++ b/xo-cmake/bin/scaffold-headeronly @@ -0,0 +1,282 @@ +#!/usr/bin/env bash +# +# scaffold-headeronly - Create a new xo library subdirectory +# +# Usage: scaffold-headeronly [--mode=headeronly|shared] +# where is the short name (e.g., "arena" creates "xo-arena") +# + +set -euo pipefail + +usage() { + echo "Usage: $0 [--mode=headeronly|shared] " + echo " Creates xo-/ with library scaffolding" + echo "" + echo "Options:" + echo " --mode=headeronly Create header-only library (default)" + echo " --mode=shared Create shared library with src/ directory" + echo "" + echo "Example: $0 arena" + echo " Creates xo-arena/CMakeLists.txt" + echo " xo-arena/cmake/xo-bootstrap-macros.cmake" + echo " xo-arena/cmake/xo_arenaConfig.cmake.in" + echo " xo-arena/include/xo/arena/" + echo "" + echo "Example: $0 --mode=shared mylib" + echo " Creates xo-mylib/CMakeLists.txt" + echo " xo-mylib/cmake/xo-bootstrap-macros.cmake" + echo " xo-mylib/cmake/xo_mylibConfig.cmake.in" + echo " xo-mylib/include/xo/mylib/" + echo " xo-mylib/src/CMakeLists.txt" + exit 1 +} + +# Default mode +MODE="headeronly" + +# Parse arguments +while [[ $# -gt 0 ]]; do + case "$1" in + --mode=*) + MODE="${1#--mode=}" + if [[ "$MODE" != "headeronly" && "$MODE" != "shared" ]]; then + echo "Error: --mode must be 'headeronly' or 'shared'" + exit 1 + fi + shift + ;; + --help|-h) + usage + ;; + -*) + echo "Error: unknown option $1" + usage + ;; + *) + break + ;; + esac +done + +if [[ $# -ne 1 ]]; then + usage +fi + +NAME="$1" + +# Validate name: alphanumeric and underscores only +if [[ ! "$NAME" =~ ^[a-zA-Z][a-zA-Z0-9_]*$ ]]; then + echo "Error: name must start with letter and contain only alphanumeric/underscores" + exit 1 +fi + +# Derive names +DIR_NAME="xo-${NAME}" +LIB_NAME="xo_${NAME}" +PROJECT_NAME="xo_${NAME}" + +# Get script directory to find umbrella root +XO_UMBRELLA_ROOT=$(git rev-parse --show-toplevel) + +TARGET_DIR="${XO_UMBRELLA_ROOT}/${DIR_NAME}" + +if [[ -d "$TARGET_DIR" ]]; then + echo "Error: ${TARGET_DIR} already exists" + exit 1 +fi + +echo "Creating ${DIR_NAME} (${MODE}) in ${XO_UMBRELLA_ROOT}..." + +# Create directories +mkdir -p "${TARGET_DIR}/cmake" +mkdir -p "${TARGET_DIR}/include/xo/${NAME}" + +if [[ "$MODE" == "shared" ]]; then + mkdir -p "${TARGET_DIR}/src" +fi + +# Create CMakeLists.txt (different content based on mode) +if [[ "$MODE" == "headeronly" ]]; then + cat > "${TARGET_DIR}/CMakeLists.txt" << EOF +# ${DIR_NAME}/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(${PROJECT_NAME} VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(\${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# header-only library + +set(SELF_LIB ${LIB_NAME}) +xo_add_headeronly_library(\${SELF_LIB}) +xo_install_library4(\${SELF_LIB} \${PROJECT_NAME}Targets) +xo_export_cmake_config(\${PROJECT_NAME} \${PROJECT_VERSION} \${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in + +#xo_headeronly_dependency(\${SELF_LIB} xo_flatstring) + +# end CMakeLists.txt +EOF +else + # Shared library mode + cat > "${TARGET_DIR}/CMakeLists.txt" << EOF +# ${DIR_NAME}/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(${PROJECT_NAME} VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(\${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +add_subdirectory(src) +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# cmake export + +xo_export_cmake_config(\${PROJECT_NAME} \${PROJECT_VERSION} \${PROJECT_NAME}Targets) + +# end CMakeLists.txt +EOF +fi + +# Create cmake/xo-bootstrap-macros.cmake +cat > "${TARGET_DIR}/cmake/xo-bootstrap-macros.cmake" << EOF +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=\$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("\${CMAKE_MODULE_PATH}" STREQUAL "") OR ("\${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("\${CMAKE_MODULE_PATH}" STREQUAL "") OR ("\${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND \${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=\${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() +EOF + +# Create cmake/xo_${NAME}Config.cmake.in +cat > "${TARGET_DIR}/cmake/${LIB_NAME}Config.cmake.in" << EOF +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +#find_dependency(xo_flatstring) + +include("\${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") +EOF + +# Create src/CMakeLists.txt for shared library mode +if [[ "$MODE" == "shared" ]]; then + cat > "${TARGET_DIR}/src/CMakeLists.txt" << EOF +# ${DIR_NAME}/src/CMakeLists.txt + +set(SELF_LIB ${LIB_NAME}) +set(SELF_SRCS + # Add source files here, e.g.: + # ${NAME}.cpp +) + +xo_add_shared_library4(\${SELF_LIB} \${PROJECT_NAME}Targets \${PROJECT_VERSION} 1 \${SELF_SRCS}) +xo_install_include_tree3(include/xo/${NAME}) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in + +#xo_dependency(\${SELF_LIB} xo_indentlog) + +# end src/CMakeLists.txt +EOF +fi + +# Create placeholder .gitkeep in include dir +touch "${TARGET_DIR}/include/xo/${NAME}/.gitkeep" + +echo "" +echo "Created ${DIR_NAME}/ (${MODE}) with:" +echo " ${DIR_NAME}/CMakeLists.txt" +echo " ${DIR_NAME}/cmake/xo-bootstrap-macros.cmake" +echo " ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in" +echo " ${DIR_NAME}/include/xo/${NAME}/" +if [[ "$MODE" == "shared" ]]; then + echo " ${DIR_NAME}/src/CMakeLists.txt" +fi +echo "" +echo "Next steps:" +if [[ "$MODE" == "headeronly" ]]; then + echo " 1. Add header files to ${DIR_NAME}/include/xo/${NAME}/" + echo " 2. Add ${DIR_NAME} to umbrella CMakeLists.txt" + echo " 3. Uncomment dependencies as needed in CMakeLists.txt and Config.cmake.in" +else + echo " 1. Add header files to ${DIR_NAME}/include/xo/${NAME}/" + echo " 2. Add source files to ${DIR_NAME}/src/ and update src/CMakeLists.txt SELF_SRCS" + echo " 3. Add ${DIR_NAME} to umbrella CMakeLists.txt" + echo " 4. Uncomment dependencies as needed in src/CMakeLists.txt and Config.cmake.in" +fi diff --git a/xo-facet/include/xo/facet/OObject.hpp b/xo-facet/include/xo/facet/OObject.hpp index 93b532d7..37298fef 100644 --- a/xo-facet/include/xo/facet/OObject.hpp +++ b/xo-facet/include/xo/facet/OObject.hpp @@ -6,7 +6,7 @@ #pragma once #include "facet_implementation.hpp" -#include "typeseq.hpp" +#include #include #include #include @@ -64,6 +64,7 @@ namespace xo { using DataType = DRepr; using DataPtr = DRepr*; using Opaque = void *; + using typeseq = xo::reflect::typeseq; /* required for vtable swapping to work */ //static_assert(std::is_trivially_copyable_v); diff --git a/xo-facet/utest/CMakeLists.txt b/xo-facet/utest/CMakeLists.txt index 81ec6d99..eec41c06 100644 --- a/xo-facet/utest/CMakeLists.txt +++ b/xo-facet/utest/CMakeLists.txt @@ -8,6 +8,7 @@ set(UTEST_SRCS if (ENABLE_TESTING) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) + xo_self_dependency(${UTEST_EXE} xo_arena) xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) endif() diff --git a/xo-gc/include/xo/gc/DX1Collector.hpp b/xo-gc/include/xo/gc/DX1Collector.hpp index bde9f04d..33c9f56d 100644 --- a/xo-gc/include/xo/gc/DX1Collector.hpp +++ b/xo-gc/include/xo/gc/DX1Collector.hpp @@ -10,8 +10,8 @@ #include "object_age.hpp" #include "role.hpp" #include -#include -#include +#include +#include #include #include diff --git a/xo-gc/include/xo/gc/DX1CollectorIterator.hpp b/xo-gc/include/xo/gc/DX1CollectorIterator.hpp index af1e867a..98a1f1d2 100644 --- a/xo-gc/include/xo/gc/DX1CollectorIterator.hpp +++ b/xo-gc/include/xo/gc/DX1CollectorIterator.hpp @@ -7,8 +7,8 @@ #include "AllocInfo.hpp" #include "generation.hpp" -#include "arena/DArenaIterator.hpp" -#include "cmpresult.hpp" +#include +#include namespace xo { namespace mm { diff --git a/xo-gc/utest/DX1CollectorIterator.test.cpp b/xo-gc/utest/DX1CollectorIterator.test.cpp index 58a498c5..99347fad 100644 --- a/xo-gc/utest/DX1CollectorIterator.test.cpp +++ b/xo-gc/utest/DX1CollectorIterator.test.cpp @@ -8,7 +8,7 @@ #include "DX1CollectorIterator.hpp" #include "detail/IAllocator_DX1Collector.hpp" #include "detail/IAllocIterator_DX1CollectorIterator.hpp" -#include "arena/ArenaConfig.hpp" +#include #include "padding.hpp" #include #include diff --git a/xo-gc/utest/random_allocs.cpp b/xo-gc/utest/random_allocs.cpp index 654c6c9a..1f7f833f 100644 --- a/xo-gc/utest/random_allocs.cpp +++ b/xo-gc/utest/random_allocs.cpp @@ -4,8 +4,8 @@ **/ #include "random_allocs.hpp" -#include "arena/DArena.hpp" -#include "padding.hpp" +#include +#include #include #include #include diff --git a/xo-object2/include/xo/object2/DList.hpp b/xo-object2/include/xo/object2/DList.hpp index f6296933..dc0729bf 100644 --- a/xo-object2/include/xo/object2/DList.hpp +++ b/xo-object2/include/xo/object2/DList.hpp @@ -8,6 +8,7 @@ #include //#include "xo/alloc2/gcobject/RGCObject.hpp" #include +#include namespace xo { namespace scm { @@ -16,6 +17,7 @@ namespace xo { using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} diff --git a/xo-object2/src/object2/DList.cpp b/xo-object2/src/object2/DList.cpp index ea725773..65b18a69 100644 --- a/xo-object2/src/object2/DList.cpp +++ b/xo-object2/src/object2/DList.cpp @@ -4,6 +4,7 @@ **/ #include "DList.hpp" +#include #include namespace xo { @@ -84,7 +85,6 @@ namespace xo { return l->head_; } -#ifdef NOT_YET bool DList::pretty(const ppindentinfo & ppii) const { @@ -95,19 +95,24 @@ namespace xo { ppstate * pps = ppii.pps(); if (ppii.upto()) { -/* perhaps print on one line */ - if (!pps->print_upto("(") + /* perhaps print on one line */ + if (!pps->print_upto("(...)")) return false; +#ifdef NOT_YET /* TODO: probably use iterators here, when available */ const DList * l = this; while (!l->is_empty()) { obj(l->head_.data()); } +#endif + return true; + } else { + pps->write("(...)"); + return false; } } -#endif } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-object2/utest/X1Collector.test.cpp b/xo-object2/utest/X1Collector.test.cpp index 1174635c..8b37c8ab 100644 --- a/xo-object2/utest/X1Collector.test.cpp +++ b/xo-object2/utest/X1Collector.test.cpp @@ -16,8 +16,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/xo-ratio/utest/CMakeLists.txt b/xo-ratio/utest/CMakeLists.txt index f1ebac58..81379c30 100644 --- a/xo-ratio/utest/CMakeLists.txt +++ b/xo-ratio/utest/CMakeLists.txt @@ -20,6 +20,7 @@ if (ENABLE_TESTING) xo_headeronly_dependency(${SELF_EXE} xo_reflectutil) xo_dependency(${SELF_EXE} randomgen) xo_dependency(${SELF_EXE} indentlog) + xo_dependency(${SELF_EXE} xo_flatstring) xo_external_target_dependency(${SELF_EXE} Catch2 Catch2::Catch2) endif()