]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: 64658.cc: Test stored value.
authorJonathan Wakely <jwakely@redhat.com>
Thu, 28 May 2015 16:27:51 +0000 (17:27 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 28 May 2015 16:27:51 +0000 (17:27 +0100)
Backport from mainline
2015-01-20  Jonathan Wakely  <jwakely@redhat.com>

* testsuite/29_atomics/atomic/64658.cc: Test stored value.

From-SVN: r223841

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/atomic
libstdc++-v3/testsuite/29_atomics/atomic/64658.cc [new file with mode: 0644]

index 4c34eb21cbc387046c95836f005c5f41ccc07ad1..1dfea0e3edbb82b297647e66c549ac719eedc56e 100644 (file)
@@ -1,5 +1,12 @@
 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>
 
index ece75a4e4ba3c5cad72841ab3cb970953cc653b5..d7ab751d2219591cd871cbf590cee6ce2779f8c1 100644 (file)
@@ -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 (file)
index 0000000..0b2ff43
--- /dev/null
@@ -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 );
+}