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_weak_explicit(volatile atomic<T>* obj, T* expc,
18 // memory_order s, memory_order f);
22 // atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
23 // memory_order s, memory_order f);
26 #include <type_traits>
29 #include <cmpxchg_loop.h>
31 #include "test_macros.h"
32 #include "atomic_helpers.h"
36 void operator()() const {
38 typedef std::atomic<T> A;
41 std::atomic_init(&a, t);
42 assert(c_cmpxchg_weak_loop(&a, &t, T(2),
43 std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
46 assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
47 std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
52 typedef std::atomic<T> A;
55 std::atomic_init(&a, t);
56 assert(c_cmpxchg_weak_loop(&a, &t, T(2),
57 std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
60 assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
61 std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
70 TestEachAtomicType<TestFn>()();