| 1 |
// Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 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 |
|
| 18 |
// { dg-do run { target c++11 } } |
| 19 |
// { dg-require-gthreads "" } |
| 20 |
// { dg-require-effective-target hosted } |
| 21 |
// { dg-additional-options "-Wno-deprecated" { target c++20 } } |
| 22 |
|
| 23 |
#include <memory> |
| 24 |
|
| 25 |
int main() |
| 26 |
{ |
| 27 |
using test_type = std::__shared_ptr<int, std::_S_single>; |
| 28 |
bool test __attribute__ ((unused)) = false; |
| 29 |
constexpr auto mo = std::memory_order_seq_cst; |
| 30 |
const test_type p; |
| 31 |
test = std::atomic_is_lock_free(&p); |
| 32 |
test_type p2 = std::atomic_load(&p); |
| 33 |
test_type p3 = std::atomic_load_explicit(&p, mo); |
| 34 |
std::atomic_store(&p2, p); |
| 35 |
std::atomic_store_explicit(&p2, p, mo); |
| 36 |
test_type p4 = std::atomic_exchange(&p2, p); |
| 37 |
p4 = std::atomic_exchange_explicit(&p2, p, mo); |
| 38 |
test = std::atomic_compare_exchange_weak(&p2, &p3, p); |
| 39 |
test = std::atomic_compare_exchange_strong(&p2, &p3, p); |
| 40 |
test = std::atomic_compare_exchange_weak_explicit(&p2, &p3, p, mo, mo); |
| 41 |
test = std::atomic_compare_exchange_strong_explicit(&p2, &p3, p, mo, mo); |
| 42 |
} |