atomic_bool was missing (just a typedef to atomic<bool>).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@171498 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8226d0b7c5
commit
6ae47055f9
@ -472,6 +472,7 @@ template <class T>
|
||||
|
||||
// Atomics for standard typedef types
|
||||
|
||||
typedef atomic<bool> atomic_bool;
|
||||
typedef atomic<char> atomic_char;
|
||||
typedef atomic<signed char> atomic_schar;
|
||||
typedef atomic<unsigned char> atomic_uchar;
|
||||
@ -1454,6 +1455,7 @@ atomic_signal_fence(memory_order __m) _NOEXCEPT
|
||||
|
||||
// Atomics for standard typedef types
|
||||
|
||||
typedef atomic<bool> atomic_bool;
|
||||
typedef atomic<char> atomic_char;
|
||||
typedef atomic<signed char> atomic_schar;
|
||||
typedef atomic<unsigned char> atomic_uchar;
|
||||
|
@ -46,6 +46,8 @@
|
||||
// T operator=(T) volatile;
|
||||
// T operator=(T);
|
||||
// };
|
||||
//
|
||||
// typedef atomic<bool> atomic_bool;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
@ -162,4 +164,59 @@ int main()
|
||||
assert((obj = true) == true);
|
||||
assert(obj == true);
|
||||
}
|
||||
{
|
||||
std::atomic_bool _;
|
||||
std::atomic_bool obj(true);
|
||||
assert(obj == true);
|
||||
std::atomic_init(&obj, false);
|
||||
assert(obj == false);
|
||||
std::atomic_init(&obj, true);
|
||||
assert(obj == true);
|
||||
bool b0 = obj.is_lock_free();
|
||||
obj.store(false);
|
||||
assert(obj == false);
|
||||
obj.store(true, std::memory_order_release);
|
||||
assert(obj == true);
|
||||
assert(obj.load() == true);
|
||||
assert(obj.load(std::memory_order_acquire) == true);
|
||||
assert(obj.exchange(false) == true);
|
||||
assert(obj == false);
|
||||
assert(obj.exchange(true, std::memory_order_relaxed) == false);
|
||||
assert(obj == true);
|
||||
bool x = obj;
|
||||
assert(obj.compare_exchange_weak(x, false) == true);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert(obj.compare_exchange_weak(x, true,
|
||||
std::memory_order_seq_cst) == false);
|
||||
assert(obj == false);
|
||||
assert(x == false);
|
||||
obj.store(true);
|
||||
x = true;
|
||||
assert(obj.compare_exchange_weak(x, false,
|
||||
std::memory_order_seq_cst,
|
||||
std::memory_order_seq_cst) == true);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
x = true;
|
||||
obj.store(true);
|
||||
assert(obj.compare_exchange_strong(x, false) == true);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert(obj.compare_exchange_strong(x, true,
|
||||
std::memory_order_seq_cst) == false);
|
||||
assert(obj == false);
|
||||
assert(x == false);
|
||||
x = true;
|
||||
obj.store(true);
|
||||
assert(obj.compare_exchange_strong(x, false,
|
||||
std::memory_order_seq_cst,
|
||||
std::memory_order_seq_cst) == true);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert((obj = false) == false);
|
||||
assert(obj == false);
|
||||
assert((obj = true) == true);
|
||||
assert(obj == true);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user