From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Define std::atomic_ref and std::atomic<floating-point> for C++20
Date: Fri, 12 Jul 2019 12:11:00 -0000 [thread overview]
Message-ID: <20190712114906.GM4665@redhat.com> (raw)
In-Reply-To: <20190712112014.GJ4665@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 815 bytes --]
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<floating-point>
>>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<integral> and atomic<pointer> 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.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 6158 bytes --]
commit 654cef2273b3231dd9ab64261183f477a378d795
Author: Jonathan Wakely <jwakely@redhat.com>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
@@ -1276,20 +1278,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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<typename _ITp>
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,
next prev parent reply other threads:[~2019-07-12 11:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 19:45 Jonathan Wakely
2019-07-12 9:30 ` Jonathan Wakely
2019-07-12 11:24 ` Jonathan Wakely
2019-07-12 12:11 ` Jonathan Wakely [this message]
2019-07-12 11:44 ` Jonathan Wakely
2019-07-12 15:56 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190712114906.GM4665@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).