Add C++20 ownership and allocation core

Header-only primitives for the no-heap-after-startup design:
Result/Status, Region, ObjectPool with PoolPtr (std::unique_ptr with a
pool deleter), generation-checked Handle and asynchronous close support,
intrusive RefPtr, FixedBuffer, MonotonicArena, FixedHashMap and FixedLru,
IntrusiveList, and a bounded FixedHeap for third-party allocator hooks.

Unit tests cover each primitive (test_core_*). scripts/check_no_heap.py
rejects heap allocation in C++ sources under src/ and runs as a ctest.
clang-tidy now also analyses C++ sources and the core headers.
This commit is contained in:
Max Lv
2026-10-14 12:51:47 +08:00
parent 0799d3a9aa
commit f90cfe9034
20 changed files with 2789 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef SS_TEST_HELPERS_HPP
#define SS_TEST_HELPERS_HPP
// Minimal harness for the C++ unit tests. Tests are built without
// exceptions, so a failed check reports its location and aborts.
#include <cstdio>
#include <cstdlib>
#define SS_CHECK(...) \
do { \
if (!(__VA_ARGS__)) { \
std::fprintf(stderr, "%s:%d: check failed: %s\n", __FILE__, \
__LINE__, #__VA_ARGS__); \
std::abort(); \
} \
} while (0)
#define SS_RUN(test) \
do { \
test(); \
std::printf("ok %s\n", #test); \
} while (0)
#endif