[libcxx-commits] [libcxxabi] b0f1a4e - [libc++abi] NFC: Move AtomicInt to cxa_guard_impl.h

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 12 15:27:14 PDT 2020


Author: Louis Dionne
Date: 2020-03-12T18:27:03-04:00
New Revision: b0f1a4e7dffcd41a1ca46c16cefad9545ce159f3

URL: https://github.com/llvm/llvm-project/commit/b0f1a4e7dffcd41a1ca46c16cefad9545ce159f3
DIFF: https://github.com/llvm/llvm-project/commit/b0f1a4e7dffcd41a1ca46c16cefad9545ce159f3.diff

LOG: [libc++abi] NFC: Move AtomicInt to cxa_guard_impl.h

Since the atomic_support.h header of libc++abi is considered technical
debt (since we should use libc++'s), it's better not to add new
definitions to it, which makes it diverge from the original libc++
header even more.

Differential Revision: https://reviews.llvm.org/D75950

Added: 
    

Modified: 
    libcxxabi/src/cxa_guard_impl.h
    libcxxabi/src/include/atomic_support.h

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h
index 6acb8762fd78..dfb26cf687e4 100644
--- a/libcxxabi/src/cxa_guard_impl.h
+++ b/libcxxabi/src/cxa_guard_impl.h
@@ -108,6 +108,32 @@ struct LazyValue {
   bool is_init = false;
 };
 
+template <class IntType>
+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
index 4ff45eb93add..6f9dbf436047 100644
--- a/libcxxabi/src/include/atomic_support.h
+++ b/libcxxabi/src/include/atomic_support.h
@@ -177,34 +177,4 @@ bool __libcpp_atomic_compare_exchange(_ValueType* __val,
 
 _LIBCPP_END_NAMESPACE_STD
 
-namespace {
-
-template <class IntType>
-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


        


More information about the libcxx-commits mailing list