summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-09-17 15:46:04 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-09-17 15:46:04 +0000
commit4ca99588b4d09a693b138b0373e896cdb9f9c05a (patch)
tree1f0c51ea5f77e0d267433e5aeeec1b8ac770b3b8 /libstdc++-v3
parentb422b023f07d868c72624ad4e3a0116cbd92d409 (diff)
downloadgcc-4ca99588b4d09a693b138b0373e896cdb9f9c05a.tar.gz
Handle alignment in __atomic_is_lock_free
gcc: 2015-09-17 Richard Henderson <rth@redhat.com> PR libstdc++/65913 * builtins.c (fold_builtin_atomic_always_lock_free): Handle fake pointers that encode the alignment of the object. libstdc++-v3: 2015-09-17 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/65913 * include/bits/atomic_base.h (__atomic_base<_TTp>::is_lock_free(), __atomic_base<_PTp*>::is_lock_free()): Call the built-in with the immediate pointer value, not a variable. * include/std/atomic (atomic<T>::is_lock_free()): Likewise. * testsuite/29_atomics/atomic/65913.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227878 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/atomic_base.h20
-rw-r--r--libstdc++-v3/include/std/atomic8
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/65913.cc39
4 files changed, 60 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index fd1ed22cb93..a1b0c3545f8 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,12 @@
2015-09-17 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/65913
+ * include/bits/atomic_base.h (__atomic_base<_TTp>::is_lock_free(),
+ __atomic_base<_PTp*>::is_lock_free()): Call the built-in with the
+ immediate pointer value, not a variable.
+ * include/std/atomic (atomic<T>::is_lock_free()): Likewise.
+ * testsuite/29_atomics/atomic/65913.cc: New.
+
* testsuite/experimental/filesystem/operations/canonical.cc: Remove
non-deterministic part of the test.
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 79769cf46d8..75a7ca7731a 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -350,17 +350,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
is_lock_free() const noexcept
{
- // Produce a fake, minimally aligned pointer.
- void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
- return __atomic_is_lock_free(sizeof(_M_i), __a);
+ // Use a fake, minimally aligned pointer.
+ return __atomic_is_lock_free(sizeof(_M_i),
+ reinterpret_cast<void *>(-__alignof(_M_i)));
}
bool
is_lock_free() const volatile noexcept
{
- // Produce a fake, minimally aligned pointer.
- void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
- return __atomic_is_lock_free(sizeof(_M_i), __a);
+ // Use a fake, minimally aligned pointer.
+ return __atomic_is_lock_free(sizeof(_M_i),
+ reinterpret_cast<void *>(-__alignof(_M_i)));
}
_GLIBCXX_ALWAYS_INLINE void
@@ -666,16 +666,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_lock_free() const noexcept
{
// Produce a fake, minimally aligned pointer.
- void *__a = reinterpret_cast<void *>(-__alignof(_M_p));
- return __atomic_is_lock_free(sizeof(_M_p), __a);
+ return __atomic_is_lock_free(sizeof(_M_p),
+ reinterpret_cast<void *>(-__alignof(_M_p)));
}
bool
is_lock_free() const volatile noexcept
{
// Produce a fake, minimally aligned pointer.
- void *__a = reinterpret_cast<void *>(-__alignof(_M_p));
- return __atomic_is_lock_free(sizeof(_M_p), __a);
+ return __atomic_is_lock_free(sizeof(_M_p),
+ reinterpret_cast<void *>(-__alignof(_M_p)));
}
_GLIBCXX_ALWAYS_INLINE void
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 125e37a2838..cdd1f0b992d 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -208,16 +208,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
is_lock_free() const noexcept
{
// Produce a fake, minimally aligned pointer.
- void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
- return __atomic_is_lock_free(sizeof(_M_i), __a);
+ return __atomic_is_lock_free(sizeof(_M_i),
+ reinterpret_cast<void *>(-__alignof(_M_i)));
}
bool
is_lock_free() const volatile noexcept
{
// Produce a fake, minimally aligned pointer.
- void *__a = reinterpret_cast<void *>(-__alignof(_M_i));
- return __atomic_is_lock_free(sizeof(_M_i), __a);
+ return __atomic_is_lock_free(sizeof(_M_i),
+ reinterpret_cast<void *>(-__alignof(_M_i)));
}
void
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/65913.cc b/libstdc++-v3/testsuite/29_atomics/atomic/65913.cc
new file mode 100644
index 00000000000..dbdd9cf7db6
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/65913.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target x86_64-*-linux* powerpc*-*-linux* } }
+// { dg-options "-std=gnu++11 -O0" }
+
+#include <atomic>
+#include <testsuite_hooks.h>
+
+// PR libstdc++/65913
+
+void
+test01()
+{
+ struct Int { int i; };
+ VERIFY( std::atomic<Int>{}.is_lock_free() );
+ VERIFY( std::atomic<int>{}.is_lock_free() );
+ VERIFY( std::atomic<int*>{}.is_lock_free() );
+}
+
+int
+main()
+{
+ test01();
+}