forked from boostorg/config
Correct usage of std::memory_order in test case.
Otherwise it fails in C++20.
This commit is contained in:
@ -21,72 +21,78 @@
|
|||||||
|
|
||||||
namespace boost_no_cxx11_hdr_atomic {
|
namespace boost_no_cxx11_hdr_atomic {
|
||||||
|
|
||||||
int test()
|
void consume(std::memory_order)
|
||||||
{
|
{}
|
||||||
std::memory_order m = static_cast<std::memory_order>(std::memory_order_relaxed | std::memory_order_consume | std::memory_order_acquire | std::memory_order_release
|
|
||||||
| std::memory_order_acq_rel | std::memory_order_seq_cst);
|
|
||||||
(void)m;
|
|
||||||
|
|
||||||
std::atomic<int> a1;
|
int test()
|
||||||
std::atomic<unsigned> a2;
|
{
|
||||||
std::atomic<int*> a3;
|
consume(std::memory_order_relaxed);
|
||||||
a1.is_lock_free();
|
consume(std::memory_order_consume);
|
||||||
a1.store(1);
|
consume(std::memory_order_acquire);
|
||||||
a1.load();
|
consume(std::memory_order_release);
|
||||||
a1.exchange(2);
|
consume(std::memory_order_acq_rel);
|
||||||
int v;
|
consume(std::memory_order_seq_cst);
|
||||||
a1.compare_exchange_weak(v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
|
||||||
a1.compare_exchange_strong(v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
|
||||||
a1.fetch_add(2);
|
|
||||||
a1.fetch_sub(3);
|
|
||||||
a1.fetch_and(3);
|
|
||||||
a1.fetch_or(1);
|
|
||||||
a1.fetch_xor(1);
|
|
||||||
a1++;
|
|
||||||
++a1;
|
|
||||||
a1--;
|
|
||||||
--a1;
|
|
||||||
a1 += 2;
|
|
||||||
a1 -= 2;
|
|
||||||
a1 &= 1;
|
|
||||||
a1 |= 2;
|
|
||||||
a1 ^= 3;
|
|
||||||
|
|
||||||
a2 = 0u;
|
std::atomic<int> a1;
|
||||||
|
std::atomic<unsigned> a2;
|
||||||
|
std::atomic<int*> a3;
|
||||||
|
a1.is_lock_free();
|
||||||
|
a1.store(1);
|
||||||
|
a1.load();
|
||||||
|
a1.exchange(2);
|
||||||
|
int v;
|
||||||
|
a1.compare_exchange_weak(v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
||||||
|
a1.compare_exchange_strong(v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
||||||
|
a1.fetch_add(2);
|
||||||
|
a1.fetch_sub(3);
|
||||||
|
a1.fetch_and(3);
|
||||||
|
a1.fetch_or(1);
|
||||||
|
a1.fetch_xor(1);
|
||||||
|
a1++;
|
||||||
|
++a1;
|
||||||
|
a1--;
|
||||||
|
--a1;
|
||||||
|
a1 += 2;
|
||||||
|
a1 -= 2;
|
||||||
|
a1 &= 1;
|
||||||
|
a1 |= 2;
|
||||||
|
a1 ^= 3;
|
||||||
|
|
||||||
a3.store(&v);
|
a2 = 0u;
|
||||||
a3.fetch_add(1);
|
|
||||||
a3.fetch_sub(1);
|
|
||||||
++a3;
|
|
||||||
--a3;
|
|
||||||
a3++;
|
|
||||||
a3--;
|
|
||||||
a3 += 1;
|
|
||||||
a3 -= 1;
|
|
||||||
|
|
||||||
std::atomic_is_lock_free(&a1);
|
a3.store(&v);
|
||||||
// This produces linker errors on Mingw32 for some reason, probably not required anyway for most uses??
|
a3.fetch_add(1);
|
||||||
//std::atomic_init(&a1, 2);
|
a3.fetch_sub(1);
|
||||||
std::atomic_store(&a1, 3);
|
++a3;
|
||||||
std::atomic_store_explicit(&a1, 3, std::memory_order_relaxed);
|
--a3;
|
||||||
std::atomic_load(&a1);
|
a3++;
|
||||||
std::atomic_load_explicit(&a1, std::memory_order_relaxed);
|
a3--;
|
||||||
std::atomic_exchange(&a1, 3);
|
a3 += 1;
|
||||||
std::atomic_compare_exchange_weak(&a1, &v, 2);
|
a3 -= 1;
|
||||||
std::atomic_compare_exchange_strong(&a1, &v, 2);
|
|
||||||
std::atomic_compare_exchange_weak_explicit(&a1, &v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
|
||||||
std::atomic_compare_exchange_strong_explicit(&a1, &v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
|
||||||
|
|
||||||
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
std::atomic_is_lock_free(&a1);
|
||||||
f.test_and_set(std::memory_order_relaxed);
|
// This produces linker errors on Mingw32 for some reason, probably not required anyway for most uses??
|
||||||
f.test_and_set();
|
//std::atomic_init(&a1, 2);
|
||||||
f.clear(std::memory_order_relaxed);
|
std::atomic_store(&a1, 3);
|
||||||
f.clear();
|
std::atomic_store_explicit(&a1, 3, std::memory_order_relaxed);
|
||||||
|
std::atomic_load(&a1);
|
||||||
|
std::atomic_load_explicit(&a1, std::memory_order_relaxed);
|
||||||
|
std::atomic_exchange(&a1, 3);
|
||||||
|
std::atomic_compare_exchange_weak(&a1, &v, 2);
|
||||||
|
std::atomic_compare_exchange_strong(&a1, &v, 2);
|
||||||
|
std::atomic_compare_exchange_weak_explicit(&a1, &v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
||||||
|
std::atomic_compare_exchange_strong_explicit(&a1, &v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
|
||||||
|
|
||||||
std::atomic_thread_fence(std::memory_order_relaxed);
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
std::atomic_signal_fence(std::memory_order_relaxed);
|
f.test_and_set(std::memory_order_relaxed);
|
||||||
|
f.test_and_set();
|
||||||
|
f.clear(std::memory_order_relaxed);
|
||||||
|
f.clear();
|
||||||
|
|
||||||
return 0;
|
std::atomic_thread_fence(std::memory_order_relaxed);
|
||||||
}
|
std::atomic_signal_fence(std::memory_order_relaxed);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user