diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h --- a/libcxxabi/src/cxa_guard_impl.h +++ b/libcxxabi/src/cxa_guard_impl.h @@ -108,6 +108,32 @@ bool is_init = false; }; +template +class AtomicInt { +public: + using MemoryOrder = std::__libcpp_atomic_order; + + explicit AtomicInt(IntType *b) : b(b) {} + AtomicInt(AtomicInt const&) = delete; + AtomicInt& operator=(AtomicInt const&) = delete; + + IntType load(MemoryOrder ord) { + return std::__libcpp_atomic_load(b, ord); + } + void store(IntType val, MemoryOrder ord) { + std::__libcpp_atomic_store(b, val, ord); + } + IntType exchange(IntType new_val, MemoryOrder ord) { + return std::__libcpp_atomic_exchange(b, new_val, ord); + } + bool compare_exchange(IntType *expected, IntType desired, MemoryOrder ord_success, MemoryOrder ord_failure) { + return std::__libcpp_atomic_compare_exchange(b, expected, desired, ord_success, ord_failure); + } + +private: + IntType *b; +}; + //===----------------------------------------------------------------------===// // PlatformGetThreadID //===----------------------------------------------------------------------===// diff --git a/libcxxabi/src/include/atomic_support.h b/libcxxabi/src/include/atomic_support.h --- a/libcxxabi/src/include/atomic_support.h +++ b/libcxxabi/src/include/atomic_support.h @@ -177,34 +177,4 @@ _LIBCPP_END_NAMESPACE_STD -namespace { - -template -class AtomicInt { -public: - using MemoryOrder = std::__libcpp_atomic_order; - - explicit AtomicInt(IntType *b) : b(b) {} - AtomicInt(AtomicInt const&) = delete; - AtomicInt& operator=(AtomicInt const&) = delete; - - IntType load(MemoryOrder ord) { - return std::__libcpp_atomic_load(b, ord); - } - void store(IntType val, MemoryOrder ord) { - std::__libcpp_atomic_store(b, val, ord); - } - IntType exchange(IntType new_val, MemoryOrder ord) { - return std::__libcpp_atomic_exchange(b, new_val, ord); - } - bool compare_exchange(IntType *expected, IntType desired, MemoryOrder ord_success, MemoryOrder ord_failure) { - return std::__libcpp_atomic_compare_exchange(b, expected, desired, ord_success, ord_failure); - } - -private: - IntType *b; -}; - -} // end namespace - #endif // ATOMIC_SUPPORT_H