[cfe-commits] [libcxx] r171498 - in /libcxx/trunk: include/atomic test/atomics/atomics.types.generic/bool.pass.cpp
Howard Hinnant
hhinnant at apple.com
Fri Jan 4 10:58:50 PST 2013
Author: hhinnant
Date: Fri Jan 4 12:58:50 2013
New Revision: 171498
URL: http://llvm.org/viewvc/llvm-project?rev=171498&view=rev
Log:
atomic_bool was missing (just a typedef to atomic<bool>).
Modified:
libcxx/trunk/include/atomic
libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp
Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=171498&r1=171497&r2=171498&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Fri Jan 4 12:58:50 2013
@@ -472,6 +472,7 @@
// 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 @@
// 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;
Modified: libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp?rev=171498&r1=171497&r2=171498&view=diff
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp Fri Jan 4 12:58:50 2013
@@ -46,6 +46,8 @@
// T operator=(T) volatile;
// T operator=(T);
// };
+//
+// typedef atomic<bool> atomic_bool;
#include <atomic>
#include <cassert>
@@ -162,4 +164,59 @@
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);
+ }
}
More information about the cfe-commits
mailing list