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 34
16 // atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr);
20 // atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr);
23 #include <type_traits>
26 #include "test_macros.h"
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>()();