public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Only support atomic_ref::wait tests which are always lockfree
@ 2021-06-09 20:52 Thomas Rodgers
  0 siblings, 0 replies; only message in thread
From: Thomas Rodgers @ 2021-06-09 20:52 UTC (permalink / raw)
  To: gcc-patches, libstdc++; +Cc: trodgers, Thomas Rodgers

Fixes a regression on arm32 targets.

libstdc++/ChangeLog:
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Guard
	test logic with constexpr check for is_always_lock_free.

As discussed on IRC.

Tested x86_64-pc-linux-gnu, committed to master, backported to
releases/gcc-11.
---
 .../29_atomics/atomic_ref/wait_notify.cc      | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
index 2500dddf884..c21c3a11ab5 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
@@ -30,17 +30,20 @@ template<typename S>
   void
   test (S va, S vb)
   {
-    S aa{ va };
-    S bb{ vb };
-    std::atomic_ref<S> a{ aa };
-    a.wait(bb);
-    std::thread t([&]
+    if constexpr (std::atomic_ref<S>::is_always_lock_free)
       {
-        a.store(bb);
-        a.notify_one();
-      });
-    a.wait(aa);
-    t.join();
+        S aa{ va };
+        S bb{ vb };
+        std::atomic_ref<S> a{ aa };
+        a.wait(bb);
+        std::thread t([&]
+          {
+            a.store(bb);
+            a.notify_one();
+          });
+        a.wait(aa);
+        t.join();
+      }
   }
 
 int
-- 
2.26.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-09 20:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 20:52 [committed] libstdc++: Only support atomic_ref::wait tests which are always lockfree Thomas Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).