From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25245 invoked by alias); 12 Jul 2019 11:49:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25194 invoked by uid 89); 12 Jul 2019 11:49:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,KAM_SHORT,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=UD:link, wg21link, UD:wg21.link, wg21.link X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Jul 2019 11:49:08 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9716830820C9; Fri, 12 Jul 2019 11:49:07 +0000 (UTC) Received: from localhost (unknown [10.33.36.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48BAF19C4F; Fri, 12 Jul 2019 11:49:07 +0000 (UTC) Date: Fri, 12 Jul 2019 12:11:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Define std::atomic_ref and std::atomic for C++20 Message-ID: <20190712114906.GM4665@redhat.com> References: <20190711194500.GA27493@redhat.com> <20190712112014.GJ4665@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="p8PhoBjPxaQXD0vg" Content-Disposition: inline In-Reply-To: <20190712112014.GJ4665@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.11.3 (2019-02-01) X-SW-Source: 2019-07/txt/msg00971.txt.bz2 --p8PhoBjPxaQXD0vg Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 815 On 12/07/19 12:20 +0100, Jonathan Wakely wrote: >On 11/07/19 20:45 +0100, Jonathan Wakely wrote: >>This adds the new atomic types from C++2a, as proposed by P0019 and >>P0020. To reduce duplication the calls to the compiler's atomic >>built-ins are wrapped in new functions in the __atomic_impl namespace. >>These functions are currently only used by std::atomic >>and std::atomic_ref but could also be used for all other specializations >>of std::atomic. > >Here's a patch to reuse the new __atomic_impl functions in the >existing atomic and atomic specializations (and >apply some general tidying up). > >I don't plan to commit this yet, but I might do so at some point. And here's a patch for https://wg21.link/lwg3220 which I won't apply until that open issue is resolved. --p8PhoBjPxaQXD0vg Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 6158 commit 654cef2273b3231dd9ab64261183f477a378d795 Author: Jonathan Wakely Date: Fri Jul 12 12:46:42 2019 +0100 LWG 3220 diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index 686ecc9114e..e1f1bbc488c 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -1183,13 +1183,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline void - atomic_store_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + atomic_store_explicit(atomic<_ITp>* __a, __type_identity_t<_ITp> __i, memory_order __m) noexcept { __a->store(__i, __m); } template inline void - atomic_store_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + atomic_store_explicit(volatile atomic<_ITp>* __a, + __type_identity_t<_ITp> __i, memory_order __m) noexcept { __a->store(__i, __m); } @@ -1206,22 +1207,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline _ITp - atomic_exchange_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + atomic_exchange_explicit(atomic<_ITp>* __a, __type_identity_t<_ITp> __i, memory_order __m) noexcept { return __a->exchange(__i, __m); } template inline _ITp atomic_exchange_explicit(volatile atomic<_ITp>* __a, - __atomic_val_t<_ITp> __i, + __type_identity_t<_ITp> __i, memory_order __m) noexcept { return __a->exchange(__i, __m); } template inline bool atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2, + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } @@ -1229,8 +1230,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline bool atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2, + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } @@ -1238,8 +1239,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline bool atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2, + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } @@ -1247,8 +1248,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline bool atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2, + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } @@ -1256,12 +1257,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline void - atomic_store(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + atomic_store(atomic<_ITp>* __a, __type_identity_t<_ITp> __i) noexcept { atomic_store_explicit(__a, __i, memory_order_seq_cst); } template inline void - atomic_store(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + atomic_store(volatile atomic<_ITp>* __a, + __type_identity_t<_ITp> __i) noexcept { atomic_store_explicit(__a, __i, memory_order_seq_cst); } template @@ -1276,20 +1278,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline _ITp - atomic_exchange(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + atomic_exchange(atomic<_ITp>* __a, __type_identity_t<_ITp> __i) noexcept { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } template inline _ITp atomic_exchange(volatile atomic<_ITp>* __a, - __atomic_val_t<_ITp> __i) noexcept + __type_identity_t<_ITp> __i) noexcept { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } template inline bool atomic_compare_exchange_weak(atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2) noexcept + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2) noexcept { return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, memory_order_seq_cst, @@ -1299,8 +1301,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline bool atomic_compare_exchange_weak(volatile atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2) noexcept + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2) noexcept { return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, memory_order_seq_cst, @@ -1310,8 +1312,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline bool atomic_compare_exchange_strong(atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2) noexcept + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2) noexcept { return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, memory_order_seq_cst, @@ -1321,8 +1323,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline bool atomic_compare_exchange_strong(volatile atomic<_ITp>* __a, - __atomic_val_t<_ITp>* __i1, - __atomic_val_t<_ITp> __i2) noexcept + __type_identity_t<_ITp>* __i1, + __type_identity_t<_ITp> __i2) noexcept { return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, memory_order_seq_cst, --p8PhoBjPxaQXD0vg--