diff options
| author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-02-26 23:46:21 +0000 |
|---|---|---|
| committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-02-26 23:46:21 +0000 |
| commit | df024a617c39097302cc4b5d15fdd908d6bd1c9b (patch) | |
| tree | 1a0f1e32f26cd55c8c7f4b824e26da5915a446aa /libstdc++-v3/include | |
| parent | ed8fbc5553e145aafc874dab11d08850ce52e744 (diff) | |
| download | gcc-df024a617c39097302cc4b5d15fdd908d6bd1c9b.tar.gz | |
PR libstdc++/56012
* include/bits/atomic_base.h (atomic_flag): Fix narrowing conversion.
* testsuite/29_atomics/atomic/operators/56012.cc: New.
PR libstdc++/56011
* include/std/atomic (atomic<bool>::operator=(bool) volatile): Add
missing overload.
* testsuite/29_atomics/atomic/operators/56011.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196296 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
| -rw-r--r-- | libstdc++-v3/include/bits/atomic_base.h | 20 | ||||
| -rw-r--r-- | libstdc++-v3/include/std/atomic | 4 |
2 files changed, 17 insertions, 7 deletions
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index b44e99071af..609fe8b0623 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -239,6 +239,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct atomic<_Tp*>; + /* The target's "set" value for test-and-set may not be exactly 1. */ +#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1 + typedef bool __atomic_flag_data_type; +#else + typedef unsigned char __atomic_flag_data_type; +#endif /** * @brief Base type for atomic_flag. @@ -254,12 +260,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __atomic_flag_base { - /* The target's "set" value for test-and-set may not be exactly 1. */ -#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1 - bool _M_i; -#else - unsigned char _M_i; -#endif + __atomic_flag_data_type _M_i; }; _GLIBCXX_END_EXTERN_C @@ -277,7 +278,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Conversion to ATOMIC_FLAG_INIT. constexpr atomic_flag(bool __i) noexcept - : __atomic_flag_base({ __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0 }) + : __atomic_flag_base{ _S_init(__i) } { } bool @@ -313,6 +314,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __atomic_clear (&_M_i, __m); } + + private: + static constexpr __atomic_flag_data_type + _S_init(bool __i) + { return __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; } }; diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index 8ed53eb0b02..813f5741a10 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -69,6 +69,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator=(bool __i) noexcept { return _M_base.operator=(__i); } + bool + operator=(bool __i) volatile noexcept + { return _M_base.operator=(__i); } + operator bool() const noexcept { return _M_base.load(); } |
