This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Define std::atomic_ref and std::atomic<floating-point> for C++20


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.


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,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]