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 34
17 // atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr);
21 // atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr);
24 #include <type_traits>
27 #include "atomic_helpers.h"
31 void operator()() const {
33 typedef std::atomic<T> A;
36 std::atomic_init(&a, t);
37 assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
40 assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
45 typedef std::atomic<T> A;
48 std::atomic_init(&a, t);
49 assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
52 assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
61 TestEachAtomicType<TestFn>()();