From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D00F53858D28 for ; Thu, 10 Feb 2022 13:05:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D00F53858D28 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-jYwboCYnOxi0rAZL_FtyWw-1; Thu, 10 Feb 2022 08:05:58 -0500 X-MC-Unique: jYwboCYnOxi0rAZL_FtyWw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 441A681C9BB; Thu, 10 Feb 2022 13:05:57 +0000 (UTC) Received: from localhost (unknown [10.33.36.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA5D170D20; Thu, 10 Feb 2022 13:05:56 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add atomic_fetch_xor to Date: Thu, 10 Feb 2022 13:05:55 +0000 Message-Id: <20220210130555.3254237-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Feb 2022 13:06:01 -0000 Tested powerpc64le-linux, pushed to trunk. -- >8 -- This function (and the explicit memory over version) are present in both C++ and C , so should be in C++ 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