[libcxx-commits] [libcxx] hxie/mingw3 (PR #231590)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 13 10:06:48 PDT 2026


https://github.com/huixie90 created https://github.com/llvm/llvm-project/pull/231590

- **test debug**
- **try**
- **2**
- **simple**


>From 5696cd259c07a180acebe16b51d5c64f425e6369 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Tue, 13 Oct 2026 12:22:01 +0100
Subject: [PATCH 1/4] test debug

---
 libcxx/test/std/atomics/debug.pass.cpp | 78 ++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 libcxx/test/std/atomics/debug.pass.cpp

diff --git a/libcxx/test/std/atomics/debug.pass.cpp b/libcxx/test/std/atomics/debug.pass.cpp
new file mode 100644
index 00000000000000..b207605e79b089
--- /dev/null
+++ b/libcxx/test/std/atomics/debug.pass.cpp
@@ -0,0 +1,78 @@
+//
+// UNSUPPORTED: no-threads
+// REQUIRES: std-at-least-c++20
+// XFAIL: !has-128-bit-atomics
+
+#include <atomic>
+#include <cassert>
+
+#include "test_macros.h"
+
+struct Node {
+  int i = 0;
+};
+
+struct Entry {
+  Node* x = nullptr;
+  Node* y = nullptr;
+};
+
+struct A {
+  int64_t x = 0;
+  int64_t y = 0;
+};
+
+int main() {
+  // test number
+  {
+    std::atomic<A> a{};
+    auto r0 = a.load(std::memory_order_relaxed);
+    assert(r0.x == 0);
+    assert(r0.y == 0);
+
+    auto expected = a.load(std::memory_order_relaxed);
+    while (true) {
+      if (a.compare_exchange_weak(expected, A{1, 2}, std::memory_order_acq_rel, std::memory_order_relaxed))
+        break;
+    }
+    auto r1 = a.load(std::memory_order_relaxed);
+    assert(r1.x == 1);
+    assert(r1.y == 2);
+
+    auto r2 = a.exchange(A{0, 0}, std::memory_order_relaxed);
+    assert(r2.x == 1);
+    assert(r2.y == 2);
+
+    auto r3 = a.load(std::memory_order_relaxed);
+    assert(r3.x == 0);
+    assert(r3.y == 0);
+  }
+
+  // test ptr
+  {
+    Node n1{1}, n2{2};
+    std::atomic<Entry> a{};
+
+    auto r0 = a.load(std::memory_order_relaxed);
+    assert(r0.x == nullptr);
+    assert(r0.y == nullptr);
+
+    auto expected = a.load(std::memory_order_relaxed);
+    while (true) {
+      if (a.compare_exchange_weak(expected, Entry{&n1, &n2}, std::memory_order_acq_rel, std::memory_order_relaxed))
+        break;
+    }
+
+    auto r1 = a.load(std::memory_order_relaxed);
+    assert(r1.x == &n1);
+    assert(r1.y == &n2);
+
+    auto r2 = a.exchange(Entry{nullptr, nullptr}, std::memory_order_relaxed);
+    assert(r2.x == &n1);
+    assert(r2.y == &n2);
+
+    auto r3 = a.load(std::memory_order_relaxed);
+    assert(r3.x == nullptr);
+    assert(r3.y == nullptr);
+  }
+}

>From cf161641d34a5af6001e9b3b0fa37cc32c787bc5 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Tue, 13 Oct 2026 13:43:01 +0100
Subject: [PATCH 2/4] try

---
 libcxx/test/std/atomics/debug.pass.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/test/std/atomics/debug.pass.cpp b/libcxx/test/std/atomics/debug.pass.cpp
index b207605e79b089..df1168d9920547 100644
--- a/libcxx/test/std/atomics/debug.pass.cpp
+++ b/libcxx/test/std/atomics/debug.pass.cpp
@@ -5,6 +5,7 @@
 
 #include <atomic>
 #include <cassert>
+#include <cstdint>
 
 #include "test_macros.h"
 

>From 5c4c3c390d1480d81c51da99a4ae778693f4ef12 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Tue, 13 Oct 2026 15:16:10 +0100
Subject: [PATCH 3/4] 2

---
 libcxx/test/std/atomics/debug.pass.cpp | 39 +-------------------------
 1 file changed, 1 insertion(+), 38 deletions(-)

diff --git a/libcxx/test/std/atomics/debug.pass.cpp b/libcxx/test/std/atomics/debug.pass.cpp
index df1168d9920547..6df263edd1b11c 100644
--- a/libcxx/test/std/atomics/debug.pass.cpp
+++ b/libcxx/test/std/atomics/debug.pass.cpp
@@ -9,15 +9,6 @@
 
 #include "test_macros.h"
 
-struct Node {
-  int i = 0;
-};
-
-struct Entry {
-  Node* x = nullptr;
-  Node* y = nullptr;
-};
-
 struct A {
   int64_t x = 0;
   int64_t y = 0;
@@ -26,7 +17,7 @@ struct A {
 int main() {
   // test number
   {
-    std::atomic<A> a{};
+    std::atomic<A> a{A{0, 0}};
     auto r0 = a.load(std::memory_order_relaxed);
     assert(r0.x == 0);
     assert(r0.y == 0);
@@ -48,32 +39,4 @@ int main() {
     assert(r3.x == 0);
     assert(r3.y == 0);
   }
-
-  // test ptr
-  {
-    Node n1{1}, n2{2};
-    std::atomic<Entry> a{};
-
-    auto r0 = a.load(std::memory_order_relaxed);
-    assert(r0.x == nullptr);
-    assert(r0.y == nullptr);
-
-    auto expected = a.load(std::memory_order_relaxed);
-    while (true) {
-      if (a.compare_exchange_weak(expected, Entry{&n1, &n2}, std::memory_order_acq_rel, std::memory_order_relaxed))
-        break;
-    }
-
-    auto r1 = a.load(std::memory_order_relaxed);
-    assert(r1.x == &n1);
-    assert(r1.y == &n2);
-
-    auto r2 = a.exchange(Entry{nullptr, nullptr}, std::memory_order_relaxed);
-    assert(r2.x == &n1);
-    assert(r2.y == &n2);
-
-    auto r3 = a.load(std::memory_order_relaxed);
-    assert(r3.x == nullptr);
-    assert(r3.y == nullptr);
-  }
 }

>From f6e8c91f866fcded5f17fd134dcd6c12803fae90 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Tue, 13 Oct 2026 18:06:16 +0100
Subject: [PATCH 4/4] simple

---
 libcxx/test/std/atomics/debug.pass.cpp | 28 ++++----------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/libcxx/test/std/atomics/debug.pass.cpp b/libcxx/test/std/atomics/debug.pass.cpp
index 6df263edd1b11c..767117d1093096 100644
--- a/libcxx/test/std/atomics/debug.pass.cpp
+++ b/libcxx/test/std/atomics/debug.pass.cpp
@@ -15,28 +15,8 @@ struct A {
 };
 
 int main() {
-  // test number
-  {
-    std::atomic<A> a{A{0, 0}};
-    auto r0 = a.load(std::memory_order_relaxed);
-    assert(r0.x == 0);
-    assert(r0.y == 0);
-
-    auto expected = a.load(std::memory_order_relaxed);
-    while (true) {
-      if (a.compare_exchange_weak(expected, A{1, 2}, std::memory_order_acq_rel, std::memory_order_relaxed))
-        break;
-    }
-    auto r1 = a.load(std::memory_order_relaxed);
-    assert(r1.x == 1);
-    assert(r1.y == 2);
-
-    auto r2 = a.exchange(A{0, 0}, std::memory_order_relaxed);
-    assert(r2.x == 1);
-    assert(r2.y == 2);
-
-    auto r3 = a.load(std::memory_order_relaxed);
-    assert(r3.x == 0);
-    assert(r3.y == 0);
-  }
+  std::atomic<A> a{A{0, 0}};
+  auto r0 = a.load(std::memory_order_relaxed);
+  assert(r0.x == 0);
+  assert(r0.y == 0);
 }



More information about the libcxx-commits mailing list