re PR libstdc++/65033 (C++11 atomics: is_lock_free result does not always match the...
authorRichard Henderson <rth@redhat.com>
Thu, 26 Mar 2015 18:31:11 +0000 (11:31 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 26 Mar 2015 18:31:11 +0000 (11:31 -0700)
PR libstdc++/65033

 * include/bits/atomic_base.h (__atomic_base<T>::is_lock_free): Build
 a fake pointer indicating type alignment.
 (__atomic_base<T *>::is_lock_free): Likewise.
 * include/std/atomic (atomic<T>::is_lock_free): Likewise.

From-SVN: r221701

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

index 6793e9d39d6d19ce8e6bcfd3d52f72b191cec7aa..cd4640a39e30947dd812dba90655c66fdd29d902 100644 (file)
@@ -1,3 +1,11 @@
+2015-03-26  Richard Henderson  <rth@redhat.com>
+
+       PR libstdc++/65033
+       * include/bits/atomic_base.h (__atomic_base<T>::is_lock_free): Build
+       a fake pointer indicating type alignment.
+       (__atomic_base<T *>::is_lock_free): Likewise.
+       * include/std/atomic (atomic<T>::is_lock_free): Likewise.
+
 2015-03-25  Alan Lawrence  <alan.lawrence@arm.com>
 
        PR libstdc++/33394
index fe6524f41b7374d4ecf07cd734a11b23bef81e8d..8104c986b5298c3abe6b7983e8099a2e080630e8 100644 (file)
@@ -346,11 +346,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       bool
       is_lock_free() const noexcept
-      { return __atomic_is_lock_free(sizeof(_M_i), nullptr); }
+      {
+       // Produce a fake, minimally aligned pointer.
+       void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
+       return __atomic_is_lock_free(sizeof(_M_i), __a);
+      }
 
       bool
       is_lock_free() const volatile noexcept
-      { return __atomic_is_lock_free(sizeof(_M_i), nullptr); }
+      {
+       // Produce a fake, minimally aligned pointer.
+       void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
+       return __atomic_is_lock_free(sizeof(_M_i), __a);
+      }
 
       _GLIBCXX_ALWAYS_INLINE void
       store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept
@@ -653,11 +661,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       bool
       is_lock_free() const noexcept
-      { return __atomic_is_lock_free(sizeof(__pointer_type), nullptr); }
+      {
+       // Produce a fake, minimally aligned pointer.
+       void *__a = reinterpret_cast<void *>(-__alignof(_M_p));
+       return __atomic_is_lock_free(sizeof(_M_p), __a);
+      }
 
       bool
       is_lock_free() const volatile noexcept
-      { return __atomic_is_lock_free(sizeof(__pointer_type), nullptr); }
+      {
+       // Produce a fake, minimally aligned pointer.
+       void *__a = reinterpret_cast<void *>(-__alignof(_M_p));
+       return __atomic_is_lock_free(sizeof(_M_p), __a);
+      }
 
       _GLIBCXX_ALWAYS_INLINE void
       store(__pointer_type __p,
index 1a17427e2313b7c825ba736c2e74978e5f57c23d..cc4b5f1a94c04869bee7401b62c0e1f71be90c01 100644 (file)
@@ -198,11 +198,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       bool
       is_lock_free() const noexcept
-      { return __atomic_is_lock_free(sizeof(_M_i), nullptr); }
+      {
+       // Produce a fake, minimally aligned pointer.
+       void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
+       return __atomic_is_lock_free(sizeof(_M_i), __a);
+      }
 
       bool
       is_lock_free() const volatile noexcept
-      { return __atomic_is_lock_free(sizeof(_M_i), nullptr); }
+      {
+       // Produce a fake, minimally aligned pointer.
+       void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
+       return __atomic_is_lock_free(sizeof(_M_i), __a);
+      }
 
       void
       store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept