From 83b2c84a3c031beec3f039c587ad20bf3eff4e67 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Mon, 19 Dec 2011 11:44:20 +0000 Subject: [PATCH] Some fixes to operations to explicitly use atomic types and operations. The integral types now work with clang trunk (if you remove the guard), although we're still missing an intrinsic for initialising atomics (needed for C1x too). Howard: Please review. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@146865 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/atomic | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/atomic b/include/atomic index 244f42d0a..f2e428a26 100644 --- a/include/atomic +++ b/include/atomic @@ -555,7 +555,7 @@ kill_dependency(_Tp __y) template ::value && !is_same<_Tp, bool>::value> struct __atomic_base // false { - _Tp __a_; + _Atomic(_Tp) __a_; _LIBCPP_INLINE_VISIBILITY bool is_lock_free() const volatile @@ -621,7 +621,7 @@ struct __atomic_base // false _LIBCPP_INLINE_VISIBILITY __atomic_base() {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) : __a_(__d) {} + /*constexpr*/ __atomic_base(_Tp __d) { __atomic_store(&__a_, __d, memory_order_seq_cst); } #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __atomic_base(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete; @@ -820,7 +820,7 @@ inline _LIBCPP_INLINE_VISIBILITY void atomic_init(volatile atomic<_Tp>* __o, _Tp __d) { - __o->__a_ = __d; + __atomic_store(&__o->__a_, __d, memory_order_seq_cst); } template @@ -828,7 +828,7 @@ inline _LIBCPP_INLINE_VISIBILITY void atomic_init(atomic<_Tp>* __o, _Tp __d) { - __o->__a_ = __d; + __atomic_store(&__o->__a_, __d, memory_order_seq_cst); } // atomic_store @@ -1348,7 +1348,7 @@ atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) typedef struct atomic_flag { - bool __a_; + _Atomic(bool) __a_; _LIBCPP_INLINE_VISIBILITY bool test_and_set(memory_order __m = memory_order_seq_cst) volatile @@ -1366,7 +1366,7 @@ typedef struct atomic_flag _LIBCPP_INLINE_VISIBILITY atomic_flag() {} // = default; _LIBCPP_INLINE_VISIBILITY - atomic_flag(bool __b) : __a_(__b) {} + atomic_flag(bool __b) { __atomic_store(&__a_, __b, memory_order_seq_cst); } #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS atomic_flag(const atomic_flag&) = delete;