1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: libcpp-has-no-threads
11 // ... assertion fails line 38
17 // atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, T* expc,
19 // memory_order s, memory_order f);
23 // atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, T desr,
24 // memory_order s, memory_order f);
27 #include <type_traits>
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>()();