public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Add atomic_fetch_xor to <stdatomic.h>
@ 2022-02-10 13:05 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-02-10 13:05 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested powerpc64le-linux, pushed to trunk.

-- >8 --

This function (and the explicit memory over version) are present in both
C++ <atomic> and C <stdatomic.h>, so should be in C++ <stdatomic.h> too.
There is a library issue incoming for this, but the resolution is
obvious.

libstdc++-v3/ChangeLog:

	* include/c_compatibility/stdatomic.h (atomic_fetch_xor): Add
	using-declaration.
	(atomic_fetch_xor_explicit): Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: Check
	arithmetic and logical operations for atomic_int.
---
 libstdc++-v3/include/c_compatibility/stdatomic.h      |  2 ++
 .../29_atomics/headers/stdatomic.h/c_compat.cc        | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/libstdc++-v3/include/c_compatibility/stdatomic.h b/libstdc++-v3/include/c_compatibility/stdatomic.h
index 95c72615b4e..c97cbac984e 100644
--- a/libstdc++-v3/include/c_compatibility/stdatomic.h
+++ b/libstdc++-v3/include/c_compatibility/stdatomic.h
@@ -111,6 +111,8 @@ using std::atomic_fetch_sub;
 using std::atomic_fetch_sub_explicit;
 using std::atomic_fetch_or;
 using std::atomic_fetch_or_explicit;
+using std::atomic_fetch_xor;
+using std::atomic_fetch_xor_explicit;
 using std::atomic_fetch_and;
 using std::atomic_fetch_and_explicit;
 using std::atomic_flag_test_and_set;
diff --git a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc
index 80d2e150647..6dd4f5b00ca 100644
--- a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc
+++ b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc
@@ -116,6 +116,17 @@ static_assert( requires (::atomic_int* i, int* e) {
   ::atomic_compare_exchange_weak_explicit(i, e, 3,
 					  memory_order_acq_rel,
 					  memory_order_relaxed);
+
+  ::atomic_fetch_add(i, 1);
+  ::atomic_fetch_add_explicit(i, 1, memory_order_relaxed);
+  ::atomic_fetch_sub(i, 1);
+  ::atomic_fetch_sub_explicit(i, 1, memory_order_relaxed);
+  ::atomic_fetch_and(i, 1);
+  ::atomic_fetch_and_explicit(i, 1, memory_order_relaxed);
+  ::atomic_fetch_or(i, 1);
+  ::atomic_fetch_or_explicit(i, 1, memory_order_relaxed);
+  ::atomic_fetch_xor(i, 1);
+  ::atomic_fetch_xor_explicit(i, 1, memory_order_relaxed);
 } );
 
 static_assert( requires (::atomic_flag* f) {
-- 
2.34.1


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

only message in thread, other threads:[~2022-02-10 13:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 13:05 [committed] libstdc++: Add atomic_fetch_xor to <stdatomic.h> Jonathan Wakely

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).