aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-05-28 16:27:51 +0000
committerJonathan Wakely <jwakely@redhat.com>2015-05-28 16:27:51 +0000
commitce2a30e74ffb132a0d7abaf3125958e9f8ffb3cb (patch)
treebfda761c9e487536a4380e5249f8ae59e426e7b6
parentfdbefd1167532061b19f570501a12699603ce79b (diff)
Backport from mainline
2015-01-20 Jonathan Wakely <jwakely@redhat.com> * testsuite/29_atomics/atomic/64658.cc: Test stored value. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@223841 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/std/atomic6
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/64658.cc30
3 files changed, 41 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 4c34eb21cbc..1dfea0e3edb 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,6 +1,13 @@
2015-05-28 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
+ 2015-01-20 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/64658
+ * include/std/atomic (atomic_init): Define.
+ * testsuite/29_atomics/atomic/64658.cc: New.
+
+ Backport from mainline
2014-12-22 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/37522
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index ece75a4e4ba..d7ab751d221 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -815,11 +815,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ITp>
inline void
- atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept;
+ atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept
+ { __a->store(__i, memory_order_relaxed); }
template<typename _ITp>
inline void
- atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept;
+ atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept
+ { __a->store(__i, memory_order_relaxed); }
template<typename _ITp>
inline void
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc b/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc
new file mode 100644
index 00000000000..0b2ff43ff19
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc
@@ -0,0 +1,30 @@
+// 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-require-atomic-builtins "" }
+// { dg-options "-std=gnu++11" }
+
+#include <atomic>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ std::atomic<int> i;
+ atomic_init(&i, 5);
+ VERIFY( i == 5 );
+}