diff --git a/src/snmalloc/ds_core/helpers.h b/src/snmalloc/ds_core/helpers.h index aedb72f..73a8729 100644 --- a/src/snmalloc/ds_core/helpers.h +++ b/src/snmalloc/ds_core/helpers.h @@ -134,86 +134,6 @@ namespace snmalloc UNUSED(t); } - /** - * Sometimes we need atomics with trivial initializer. Unfortunately, this - * became harder to accomplish in C++20. Fortunately, our rules for accessing - * these are at least as strong as those required by C++20's atomic_ref: - * - * * The objects outlive any references to them - * - * * We always access the objects through references (though we'd be allowed - * to access them without if we knew there weren't other references) - * - * * We don't access sub-objects at all, much less concurrently through - * other references. - */ - template - class TrivialInitAtomic - { - static_assert( - std::is_trivially_default_constructible_v, - "TrivialInitAtomic should not attempt to call nontrivial constructors"); - -#ifdef __cpp_lib_atomic_ref - using Val = T; - using Ref = std::atomic_ref; -#else - using Val = std::atomic; - using Ref = std::atomic&; -#endif - Val v; - - public: - /** - * Construct a reference to this value; use .load and .store to manipulate - * the value. - */ - SNMALLOC_FAST_PATH Ref ref() - { -#ifdef __cpp_lib_atomic_ref - return std::atomic_ref(this->v); -#else - return this->v; -#endif - } - - SNMALLOC_FAST_PATH T - load(std::memory_order mo = std::memory_order_seq_cst) noexcept - { - return this->ref().load(mo); - } - - SNMALLOC_FAST_PATH void - store(T n, std::memory_order mo = std::memory_order_seq_cst) noexcept - { - return this->ref().store(n, mo); - } - - SNMALLOC_FAST_PATH bool compare_exchange_strong( - T& exp, T des, std::memory_order mo = std::memory_order_seq_cst) noexcept - { - return this->ref().compare_exchange_strong(exp, des, mo); - } - - SNMALLOC_FAST_PATH T - exchange(T des, std::memory_order mo = std::memory_order_seq_cst) noexcept - { - return this->ref().exchange(des, mo); - } - - template - SNMALLOC_FAST_PATH - typename std::enable_if::value, Q>::type - fetch_add( - Q arg, std::memory_order mo = std::memory_order_seq_cst) noexcept - { - return this->ref().fetch_add(arg, mo); - } - }; - - static_assert(sizeof(TrivialInitAtomic) == sizeof(char)); - static_assert(alignof(TrivialInitAtomic) == alignof(char)); - /** * Helper class for building fatal errors. Used by `report_fatal_error` to * build an on-stack buffer containing the formatted string.