aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2015-03-26 11:31:11 -0700
committerRichard Henderson <rth@gcc.gnu.org>2015-03-26 11:31:11 -0700
commit8be568519bf08098e056567d57a75c3f38416ac2 (patch)
treecfeb96ebc205c54e8e802c9284eb6658d380533e /libstdc++-v3
parent41b38772ccd584a384945c7b1fdd61f4712d9792 (diff)
downloadgcc-8be568519bf08098e056567d57a75c3f38416ac2.zip
gcc-8be568519bf08098e056567d57a75c3f38416ac2.tar.gz
gcc-8be568519bf08098e056567d57a75c3f38416ac2.tar.bz2
re PR libstdc++/65033 (C++11 atomics: is_lock_free result does not always match the real lock-free property)
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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/atomic_base.h24
-rw-r--r--libstdc++-v3/include/std/atomic12
3 files changed, 38 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 6793e9d..cd4640a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index fe6524f..8104c98 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -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,
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 1a17427..cc4b5f1 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -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