]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/29_atomics/atomic_integral/is_always_lock_free.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 29_atomics / atomic_integral / is_always_lock_free.cc
CommitLineData
a945c346 1// Copyright (C) 2016-2024 Free Software Foundation, Inc.
387edf83
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
6458742a 18// { dg-do compile { target c++17 } }
387edf83
JW
19
20#include <atomic>
21
22using std::atomic;
23
24template<typename T>
25constexpr bool check(int macro)
26{
27 return std::atomic<T>::is_always_lock_free == (macro == 2);
28}
29
30static_assert( check<bool>(ATOMIC_BOOL_LOCK_FREE) );
31static_assert( check<char>(ATOMIC_CHAR_LOCK_FREE) );
32static_assert( check<signed char>(ATOMIC_CHAR_LOCK_FREE) );
33static_assert( check<unsigned char>(ATOMIC_CHAR_LOCK_FREE) );
34static_assert( check<int>(ATOMIC_INT_LOCK_FREE) );
35static_assert( check<unsigned int>(ATOMIC_INT_LOCK_FREE) );
36static_assert( check<long>(ATOMIC_LONG_LOCK_FREE) );
37static_assert( check<unsigned long>(ATOMIC_LONG_LOCK_FREE) );
38static_assert( check<long long>(ATOMIC_LLONG_LOCK_FREE) );
39static_assert( check<unsigned long long>(ATOMIC_LLONG_LOCK_FREE) );
40static_assert( check<wchar_t>(ATOMIC_WCHAR_T_LOCK_FREE) );
59019b42
TH
41#ifdef _GLIBCXX_USE_CHAR8_T
42static_assert( check<char8_t>(ATOMIC_CHAR8_T_LOCK_FREE) );
43#endif
387edf83
JW
44static_assert( check<char16_t>(ATOMIC_CHAR16_T_LOCK_FREE) );
45static_assert( check<char32_t>(ATOMIC_CHAR32_T_LOCK_FREE) );