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