]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/29_atomics/atomic/requirements/compare_exchange_lowering.cc
df8cd11f59461c539a94b605271be06f6529750f
1 // { dg-do compile { target c++11 } }
3 // Copyright (C) 2013-2019 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 #include <testsuite_common_types.h>
23 #define TEST_ALL_ORDERS() \
25 ORDER_TEST(std::memory_order_relaxed); \
26 ORDER_TEST(std::memory_order_consume); \
27 ORDER_TEST(std::memory_order_acquire); \
28 ORDER_TEST(std::memory_order_release); \
29 ORDER_TEST(std::memory_order_acq_rel); \
30 ORDER_TEST(std::memory_order_seq_cst); \
35 #define ORDER_TEST(ORDER) \
37 __gnu_test::compare_exchange_order_lowering<ORDER> test; \
38 __gnu_cxx::typelist::apply_generator(test, \
39 __gnu_test::integral_types::type()); \
45 #define ORDER_TEST(ORDER) \
47 std::atomic<e> x(a); \
49 x.compare_exchange_strong(expected, b, ORDER); \
50 x.compare_exchange_weak(expected, c, ORDER); \
55 #define ORDER_TEST(ORDER) \
57 std::atomic<void*> x(nullptr); \
58 void* expected = nullptr; \
59 x.compare_exchange_strong(expected, nullptr, ORDER); \
60 x.compare_exchange_weak(expected, nullptr, ORDER); \