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 //===----------------------------------------------------------------------===//
12 bool cmpxchg_weak_loop(A
& atomic
, typename
A::value_type
& expected
, typename
A::value_type desired
) {
13 for (int i
= 0; i
< 10; i
++) {
14 if (atomic
.compare_exchange_weak(expected
, desired
) == true) {
23 bool cmpxchg_weak_loop(A
& atomic
, typename
A::value_type
& expected
, typename
A::value_type desired
,
24 std::memory_order success
,
25 std::memory_order failure
) {
26 for (int i
= 0; i
< 10; i
++) {
27 if (atomic
.compare_exchange_weak(expected
, desired
, success
,
37 bool c_cmpxchg_weak_loop(A
* atomic
, typename
A::value_type
* expected
, typename
A::value_type desired
) {
38 for (int i
= 0; i
< 10; i
++) {
39 if (std::atomic_compare_exchange_weak(atomic
, expected
, desired
) == true) {
48 bool c_cmpxchg_weak_loop(A
* atomic
, typename
A::value_type
* expected
, typename
A::value_type desired
,
49 std::memory_order success
,
50 std::memory_order failure
) {
51 for (int i
= 0; i
< 10; i
++) {
52 if (std::atomic_compare_exchange_weak_explicit(atomic
, expected
, desired
,
53 success
, failure
) == true) {