OSDN Git Service

* include/bits/atomic_base.h (__calculate_memory_order): Rename to...
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2011 09:44:57 +0000 (09:44 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2011 09:44:57 +0000 (09:44 +0000)
(__cmpexch_failure_order): This, and rewrite as constexpr function.
(compare_exchange_strong, compare_exchange_weak): Use it.
* include/std/atomic (compare_exchange_strong, compare_exchange_weak):
Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182105 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/atomic_base.h
libstdc++-v3/include/std/atomic

index d8707d8..bf5224e 100644 (file)
@@ -1,3 +1,11 @@
+2011-12-08  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       * include/bits/atomic_base.h (__calculate_memory_order): Rename to...
+       (__cmpexch_failure_order): This, and rewrite as constexpr function.
+       (compare_exchange_strong, compare_exchange_weak): Use it.
+       * include/std/atomic (compare_exchange_strong, compare_exchange_weak):
+       Likewise.
+
 2011-12-07  Fran├žois Dumont <fdumont@gcc.gnu.org>
 
        PR libstdc++/51386
index 3f00cda..ef17b7e 100644 (file)
@@ -59,14 +59,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       memory_order_seq_cst
     } memory_order;
 
-  inline memory_order
-  __calculate_memory_order(memory_order __m) noexcept
+  // Drop release ordering as per [atomics.types.operations.req]/21
+  constexpr memory_order
+  __cmpexch_failure_order(memory_order __m) noexcept
   {
-    const bool __cond1 = __m == memory_order_release;
-    const bool __cond2 = __m == memory_order_acq_rel;
-    memory_order __mo1(__cond1 ? memory_order_relaxed : __m);
-    memory_order __mo2(__cond2 ? memory_order_acquire : __mo1);
-    return __mo2;
+    return __m == memory_order_acq_rel ? memory_order_acquire
+      : __m == memory_order_release ? memory_order_relaxed : __m;
   }
 
   inline void
@@ -505,7 +503,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                            memory_order __m = memory_order_seq_cst) noexcept
       {
        return compare_exchange_weak(__i1, __i2, __m,
-                                    __calculate_memory_order(__m));
+                                    __cmpexch_failure_order(__m));
       }
 
       bool
@@ -513,7 +511,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                   memory_order __m = memory_order_seq_cst) volatile noexcept
       {
        return compare_exchange_weak(__i1, __i2, __m,
-                                    __calculate_memory_order(__m));
+                                    __cmpexch_failure_order(__m));
       }
 
       bool
@@ -544,7 +542,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                              memory_order __m = memory_order_seq_cst) noexcept
       {
        return compare_exchange_strong(__i1, __i2, __m,
-                                      __calculate_memory_order(__m));
+                                      __cmpexch_failure_order(__m));
       }
 
       bool
@@ -552,7 +550,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                 memory_order __m = memory_order_seq_cst) volatile noexcept
       {
        return compare_exchange_strong(__i1, __i2, __m,
-                                      __calculate_memory_order(__m));
+                                      __cmpexch_failure_order(__m));
       }
 
       __int_type
index 70f613f..31673e9 100644 (file)
@@ -408,7 +408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                            memory_order __m = memory_order_seq_cst) noexcept
       {
        return compare_exchange_weak(__p1, __p2, __m,
-                                    __calculate_memory_order(__m));
+                                    __cmpexch_failure_order(__m));
       }
 
       bool
@@ -416,7 +416,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                    memory_order __m = memory_order_seq_cst) volatile noexcept
       {
        return compare_exchange_weak(__p1, __p2, __m,
-                                    __calculate_memory_order(__m));
+                                    __cmpexch_failure_order(__m));
       }
 
       bool
@@ -435,7 +435,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                              memory_order __m = memory_order_seq_cst) noexcept
       {
        return _M_b.compare_exchange_strong(__p1, __p2, __m,
-                                           __calculate_memory_order(__m));
+                                           __cmpexch_failure_order(__m));
       }
 
       bool
@@ -443,7 +443,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                    memory_order __m = memory_order_seq_cst) volatile noexcept
       {
        return _M_b.compare_exchange_strong(__p1, __p2, __m,
-                                           __calculate_memory_order(__m));
+                                           __cmpexch_failure_order(__m));
       }
 
       __pointer_type