From dd16b7d98d89f282b9effc40e519e0a9855395f2 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 28 May 2015 17:27:51 +0100 Subject: [PATCH] backport: 64658.cc: Test stored value. Backport from mainline 2015-01-20 Jonathan Wakely * testsuite/29_atomics/atomic/64658.cc: Test stored value. From-SVN: r223841 --- libstdc++-v3/ChangeLog | 7 +++++ libstdc++-v3/include/std/atomic | 6 ++-- .../testsuite/29_atomics/atomic/64658.cc | 30 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/64658.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4c34eb21cbc3..1dfea0e3edbb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2015-05-28 Jonathan Wakely + Backport from mainline + 2015-01-20 Jonathan Wakely + + PR libstdc++/64658 + * include/std/atomic (atomic_init): Define. + * testsuite/29_atomics/atomic/64658.cc: New. + Backport from mainline 2014-12-22 Jonathan Wakely diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index ece75a4e4ba3..d7ab751d2219 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -815,11 +815,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template 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 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 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 000000000000..0b2ff43ff197 --- /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 +// . + +// { dg-require-atomic-builtins "" } +// { dg-options "-std=gnu++11" } + +#include +#include + +int +main() +{ + std::atomic i; + atomic_init(&i, 5); + VERIFY( i == 5 ); +} -- 2.47.2