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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 10 10:54:57 PDT 2020


ldionne created this revision.
ldionne added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, jfb, dexonsmith, jkorous.
Herald added a project: libc++.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75950

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


Index: libcxxabi/src/include/atomic_support.h
===================================================================
--- libcxxabi/src/include/atomic_support.h
+++ libcxxabi/src/include/atomic_support.h
@@ -177,34 +177,4 @@
 
 _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
Index: libcxxabi/src/cxa_guard_impl.h
===================================================================
--- libcxxabi/src/cxa_guard_impl.h
+++ libcxxabi/src/cxa_guard_impl.h
@@ -108,6 +108,32 @@
   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
 //===----------------------------------------------------------------------===//


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75950.249454.patch
Type: text/x-patch
Size: 2357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200310/305cf287/attachment-0001.bin>


More information about the libcxx-commits mailing list