1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: libcpp-has-no-threads
10 // ... assertion fails line 38
16 // atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, T* expc,
18 // memory_order s, memory_order f);
22 // atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, T desr,
23 // memory_order s, memory_order f);
26 #include <type_traits>
29 #include "test_macros.h"
30 #include "atomic_helpers.h"
34 void operator()() const {
36 typedef std::atomic<T> A;
39 std::atomic_init(&a, t);
40 assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
41 std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
44 assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
45 std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
50 typedef std::atomic<T> A;
53 std::atomic_init(&a, t);
54 assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
55 std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
58 assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
59 std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
68 TestEachAtomicType<TestFn>()();