From 114676622f4ed3e7aaa7e8e8a21e789b76446dc2 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 4 Jan 2013 18:58:50 +0000 Subject: [PATCH] atomic_bool was missing (just a typedef to atomic). llvm-svn: 171498 --- libcxx/include/atomic | 2 + .../atomics/atomics.types.generic/bool.pass.cpp | 57 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/libcxx/include/atomic b/libcxx/include/atomic index 6dffdb2..4731e4f 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -472,6 +472,7 @@ template // Atomics for standard typedef types +typedef atomic atomic_bool; typedef atomic atomic_char; typedef atomic atomic_schar; typedef atomic atomic_uchar; @@ -1454,6 +1455,7 @@ atomic_signal_fence(memory_order __m) _NOEXCEPT // Atomics for standard typedef types +typedef atomic atomic_bool; typedef atomic atomic_char; typedef atomic atomic_schar; typedef atomic atomic_uchar; diff --git a/libcxx/test/atomics/atomics.types.generic/bool.pass.cpp b/libcxx/test/atomics/atomics.types.generic/bool.pass.cpp index a9002ea..f6379dc 100644 --- a/libcxx/test/atomics/atomics.types.generic/bool.pass.cpp +++ b/libcxx/test/atomics/atomics.types.generic/bool.pass.cpp @@ -46,6 +46,8 @@ // T operator=(T) volatile; // T operator=(T); // }; +// +// typedef atomic atomic_bool; #include #include @@ -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); + } } -- 2.7.4