]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/shared_ptr/atomic/2.cc
libstdc++: Disable hosted-only tests [PR103626]
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / shared_ptr / atomic / 2.cc
CommitLineData
7adcbafe 1// Copyright (C) 2014-2022 Free Software Foundation, Inc.
be8de894
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
52066eae 18// { dg-do run { target c++11 } }
be8de894 19// { dg-require-gthreads "" }
7cc9022f 20// { dg-require-effective-target hosted }
be8de894
JW
21
22#include <memory>
23
24int main()
25{
26 using test_type = std::__shared_ptr<int, std::_S_single>;
27 bool test __attribute__ ((unused)) = false;
28 constexpr auto mo = std::memory_order_seq_cst;
29 const test_type p;
30 test = std::atomic_is_lock_free(&p);
31 test_type p2 = std::atomic_load(&p);
32 test_type p3 = std::atomic_load_explicit(&p, mo);
33 std::atomic_store(&p2, p);
34 std::atomic_store_explicit(&p2, p, mo);
35 test_type p4 = std::atomic_exchange(&p2, p);
36 p4 = std::atomic_exchange_explicit(&p2, p, mo);
37 test = std::atomic_compare_exchange_weak(&p2, &p3, p);
38 test = std::atomic_compare_exchange_strong(&p2, &p3, p);
39 test = std::atomic_compare_exchange_weak_explicit(&p2, &p3, p, mo, mo);
40 test = std::atomic_compare_exchange_strong_explicit(&p2, &p3, p, mo, mo);
41}