diff options
Diffstat (limited to 'boost/atomic')
23 files changed, 473 insertions, 376 deletions
diff --git a/boost/atomic/detail/atomic_template.hpp b/boost/atomic/detail/atomic_template.hpp index dd3c741506..7bbc1fffad 100644 --- a/boost/atomic/detail/atomic_template.hpp +++ b/boost/atomic/detail/atomic_template.hpp @@ -19,11 +19,13 @@ #include <cstddef> #include <boost/cstdint.hpp> #include <boost/assert.hpp> -#include <boost/type_traits/is_signed.hpp> -#include <boost/type_traits/is_integral.hpp> #include <boost/atomic/detail/config.hpp> #include <boost/atomic/detail/bitwise_cast.hpp> #include <boost/atomic/detail/operations_fwd.hpp> +#include <boost/atomic/detail/type_traits/is_signed.hpp> +#include <boost/atomic/detail/type_traits/is_integral.hpp> +#include <boost/atomic/detail/type_traits/is_function.hpp> +#include <boost/atomic/detail/type_traits/conditional.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -56,7 +58,19 @@ BOOST_FORCEINLINE BOOST_CONSTEXPR bool cas_failure_order_must_not_be_stronger_th return (failure_order & 15u) <= (success_order & 15u); } -template< typename T, bool IsInt = boost::is_integral< T >::value > +template< typename T, bool IsFunction = boost::atomics::detail::is_function< T >::value > +struct classify_pointer +{ + typedef void* type; +}; + +template< typename T > +struct classify_pointer< T, true > +{ + typedef void type; +}; + +template< typename T, bool IsInt = boost::atomics::detail::is_integral< T >::value > struct classify { typedef void type; @@ -66,21 +80,157 @@ template< typename T > struct classify< T, true > { typedef int type; }; template< typename T > -struct classify< T*, false > { typedef void* type; }; +struct classify< T*, false > { typedef typename classify_pointer< T >::type type; }; + +template< > +struct classify< void*, false > { typedef void type; }; + +template< > +struct classify< const void*, false > { typedef void type; }; + +template< > +struct classify< volatile void*, false > { typedef void type; }; + +template< > +struct classify< const volatile void*, false > { typedef void type; }; + +template< typename T, typename U > +struct classify< T U::*, false > { typedef void type; }; + +template< bool > +struct boolean_constant {}; +typedef boolean_constant< true > true_constant; +typedef boolean_constant< false > false_constant; + template< typename T, typename Kind > class base_atomic; +//! General template. Implementation for user-defined types, such as structs and enums, and pointers to non-object types +template< typename T > +class base_atomic< T, void > +{ +public: + typedef T value_type; + +protected: + typedef atomics::detail::operations< storage_size_of< value_type >::value, false > operations; + typedef typename boost::atomics::detail::conditional< sizeof(value_type) <= sizeof(void*), value_type, value_type const& >::type value_arg_type; + +public: + typedef typename operations::storage_type storage_type; + +private: + typedef boolean_constant< sizeof(value_type) == sizeof(storage_type) > value_matches_storage; + +protected: + typename operations::aligned_storage_type m_storage; + +public: + BOOST_FORCEINLINE explicit base_atomic(value_arg_type v = value_type()) BOOST_NOEXCEPT : m_storage(atomics::detail::bitwise_cast< storage_type >(v)) + { + } + + BOOST_FORCEINLINE void store(value_arg_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT + { + BOOST_ASSERT(order != memory_order_consume); + BOOST_ASSERT(order != memory_order_acquire); + BOOST_ASSERT(order != memory_order_acq_rel); + + operations::store(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order); + } + + BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT + { + BOOST_ASSERT(order != memory_order_release); + BOOST_ASSERT(order != memory_order_acq_rel); + + return atomics::detail::bitwise_cast< value_type >(operations::load(m_storage.value, order)); + } + + BOOST_FORCEINLINE value_type exchange(value_arg_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT + { + return atomics::detail::bitwise_cast< value_type >(operations::exchange(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order)); + } + + BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_arg_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT + { + BOOST_ASSERT(failure_order != memory_order_release); + BOOST_ASSERT(failure_order != memory_order_acq_rel); + BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); + + return compare_exchange_strong_impl(expected, desired, success_order, failure_order, value_matches_storage()); + } + + BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_arg_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT + { + return compare_exchange_strong(expected, desired, order, atomics::detail::deduce_failure_order(order)); + } + + BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_arg_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT + { + BOOST_ASSERT(failure_order != memory_order_release); + BOOST_ASSERT(failure_order != memory_order_acq_rel); + BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); + + return compare_exchange_weak_impl(expected, desired, success_order, failure_order, value_matches_storage()); + } + + BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_arg_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT + { + return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order)); + } + + BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&)) + BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&)) + +private: + BOOST_FORCEINLINE bool compare_exchange_strong_impl(value_type& expected, value_arg_type desired, memory_order success_order, memory_order failure_order, true_constant) volatile BOOST_NOEXCEPT + { +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_strong(m_storage.value, reinterpret_cast< storage_type& >(expected), atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); +#else + return compare_exchange_strong_impl(expected, desired, success_order, failure_order, false_constant()); +#endif + } + + BOOST_FORCEINLINE bool compare_exchange_strong_impl(value_type& expected, value_arg_type desired, memory_order success_order, memory_order failure_order, false_constant) volatile BOOST_NOEXCEPT + { + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); + return res; + } + + BOOST_FORCEINLINE bool compare_exchange_weak_impl(value_type& expected, value_arg_type desired, memory_order success_order, memory_order failure_order, true_constant) volatile BOOST_NOEXCEPT + { +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_weak(m_storage.value, reinterpret_cast< storage_type& >(expected), atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); +#else + return compare_exchange_weak_impl(expected, desired, success_order, failure_order, false_constant()); +#endif + } + + BOOST_FORCEINLINE bool compare_exchange_weak_impl(value_type& expected, value_arg_type desired, memory_order success_order, memory_order failure_order, false_constant) volatile BOOST_NOEXCEPT + { + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); + return res; + } +}; + + //! Implementation for integers template< typename T > class base_atomic< T, int > { -private: +public: typedef T value_type; typedef T difference_type; protected: - typedef atomics::detail::operations< storage_size_of< value_type >::value, boost::is_signed< T >::value > operations; + typedef atomics::detail::operations< storage_size_of< value_type >::value, boost::atomics::detail::is_signed< T >::value > operations; typedef value_type value_arg_type; public: @@ -131,10 +281,14 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_strong(m_storage.value, reinterpret_cast< storage_type& >(expected), static_cast< storage_type >(desired), success_order, failure_order); +#else storage_type old_value = static_cast< storage_type >(expected); const bool res = operations::compare_exchange_strong(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = static_cast< value_type >(old_value); return res; +#endif } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT @@ -148,10 +302,14 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_weak(m_storage.value, reinterpret_cast< storage_type& >(expected), static_cast< storage_type >(desired), success_order, failure_order); +#else storage_type old_value = static_cast< storage_type >(expected); const bool res = operations::compare_exchange_weak(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = static_cast< value_type >(old_value); return res; +#endif } BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT @@ -174,11 +332,6 @@ public: return static_cast< value_type >(operations::fetch_xor(m_storage.value, static_cast< storage_type >(v), order)); } - BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT - { - return operations::is_lock_free(m_storage.value); - } - BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT { return fetch_add(1); @@ -232,7 +385,7 @@ public: template< > class base_atomic< bool, int > { -private: +public: typedef bool value_type; protected: @@ -277,10 +430,14 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_strong(m_storage.value, reinterpret_cast< storage_type& >(expected), static_cast< storage_type >(desired), success_order, failure_order); +#else storage_type old_value = static_cast< storage_type >(expected); const bool res = operations::compare_exchange_strong(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = !!old_value; return res; +#endif } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT @@ -294,10 +451,14 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_weak(m_storage.value, reinterpret_cast< storage_type& >(expected), static_cast< storage_type >(desired), success_order, failure_order); +#else storage_type old_value = static_cast< storage_type >(expected); const bool res = operations::compare_exchange_weak(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = !!old_value; return res; +#endif } BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT @@ -305,109 +466,16 @@ public: return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order)); } - BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT - { - return operations::is_lock_free(m_storage.value); - } - - BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&)) - BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&)) -}; - - -//! Implementation for user-defined types, such as structs and enums -template< typename T > -class base_atomic< T, void > -{ -private: - typedef T value_type; - -protected: - typedef atomics::detail::operations< storage_size_of< value_type >::value, false > operations; - typedef value_type const& value_arg_type; - -public: - typedef typename operations::storage_type storage_type; - -protected: - typename operations::aligned_storage_type m_storage; - -public: - BOOST_FORCEINLINE explicit base_atomic(value_type const& v = value_type()) BOOST_NOEXCEPT : m_storage(atomics::detail::bitwise_cast< storage_type >(v)) - { - } - - BOOST_FORCEINLINE void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(order != memory_order_consume); - BOOST_ASSERT(order != memory_order_acquire); - BOOST_ASSERT(order != memory_order_acq_rel); - - operations::store(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order); - } - - BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(order != memory_order_release); - BOOST_ASSERT(order != memory_order_acq_rel); - - return atomics::detail::bitwise_cast< value_type >(operations::load(m_storage.value, order)); - } - - BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return atomics::detail::bitwise_cast< value_type >(operations::exchange(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order)); - } - - BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(failure_order != memory_order_release); - BOOST_ASSERT(failure_order != memory_order_acq_rel); - BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - - storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::bitwise_cast< value_type >(old_value); - return res; - } - - BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return compare_exchange_strong(expected, desired, order, atomics::detail::deduce_failure_order(order)); - } - - BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(failure_order != memory_order_release); - BOOST_ASSERT(failure_order != memory_order_acq_rel); - BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - - storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::bitwise_cast< value_type >(old_value); - return res; - } - - BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order)); - } - - BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT - { - return operations::is_lock_free(m_storage.value); - } - BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&)) BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&)) }; -//! Implementation for pointers +//! Implementation for pointers to object types template< typename T > class base_atomic< T*, void* > { -private: +public: typedef T* value_type; typedef std::ptrdiff_t difference_type; @@ -465,10 +533,14 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_strong(m_storage.value, reinterpret_cast< storage_type& >(expected), atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); +#else storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; +#endif } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT @@ -482,10 +554,14 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); +#if defined(BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS) + return operations::compare_exchange_weak(m_storage.value, reinterpret_cast< storage_type& >(expected), atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); +#else storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; +#endif } BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT @@ -493,11 +569,6 @@ public: return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order)); } - BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT - { - return operations::is_lock_free(m_storage.value); - } - BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT { return fetch_add(1); @@ -532,136 +603,6 @@ public: BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&)) }; - -//! Implementation for void pointers -template< > -class base_atomic< void*, void* > -{ -private: - typedef void* value_type; - typedef std::ptrdiff_t difference_type; - -protected: - typedef atomics::detail::operations< storage_size_of< value_type >::value, false > operations; - typedef value_type value_arg_type; - -public: - typedef operations::storage_type storage_type; - -protected: - operations::aligned_storage_type m_storage; - -public: - BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) - BOOST_FORCEINLINE explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : m_storage(atomics::detail::bitwise_cast< storage_type >(v)) - { - } - - BOOST_FORCEINLINE void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(order != memory_order_consume); - BOOST_ASSERT(order != memory_order_acquire); - BOOST_ASSERT(order != memory_order_acq_rel); - - operations::store(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order); - } - - BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(order != memory_order_release); - BOOST_ASSERT(order != memory_order_acq_rel); - - return atomics::detail::bitwise_cast< value_type >(operations::load(m_storage.value, order)); - } - - BOOST_FORCEINLINE value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return atomics::detail::bitwise_cast< value_type >(operations::fetch_add(m_storage.value, static_cast< storage_type >(v), order)); - } - - BOOST_FORCEINLINE value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return atomics::detail::bitwise_cast< value_type >(operations::fetch_sub(m_storage.value, static_cast< storage_type >(v), order)); - } - - BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return atomics::detail::bitwise_cast< value_type >(operations::exchange(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order)); - } - - BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(failure_order != memory_order_release); - BOOST_ASSERT(failure_order != memory_order_acq_rel); - BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - - storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::bitwise_cast< value_type >(old_value); - return res; - } - - BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return compare_exchange_strong(expected, desired, order, atomics::detail::deduce_failure_order(order)); - } - - BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT - { - BOOST_ASSERT(failure_order != memory_order_release); - BOOST_ASSERT(failure_order != memory_order_acq_rel); - BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - - storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::bitwise_cast< value_type >(old_value); - return res; - } - - BOOST_FORCEINLINE bool compare_exchange_weak(value_type& expected, value_type desired, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT - { - return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order)); - } - - BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT - { - return operations::is_lock_free(m_storage.value); - } - - BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT - { - return fetch_add(1); - } - - BOOST_FORCEINLINE value_type operator++() volatile BOOST_NOEXCEPT - { - return (char*)fetch_add(1) + 1; - } - - BOOST_FORCEINLINE value_type operator--(int) volatile BOOST_NOEXCEPT - { - return fetch_sub(1); - } - - BOOST_FORCEINLINE value_type operator--() volatile BOOST_NOEXCEPT - { - return (char*)fetch_sub(1) - 1; - } - - BOOST_FORCEINLINE value_type operator+=(difference_type v) volatile BOOST_NOEXCEPT - { - return (char*)fetch_add(v) + v; - } - - BOOST_FORCEINLINE value_type operator-=(difference_type v) volatile BOOST_NOEXCEPT - { - return (char*)fetch_sub(v) - v; - } - - BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&)) - BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&)) -}; - } // namespace detail template< typename T > @@ -669,11 +610,11 @@ class atomic : public atomics::detail::base_atomic< T, typename atomics::detail::classify< T >::type > { private: - typedef T value_type; typedef atomics::detail::base_atomic< T, typename atomics::detail::classify< T >::type > base_type; typedef typename base_type::value_arg_type value_arg_type; public: + typedef typename base_type::value_type value_type; typedef typename base_type::storage_type storage_type; public: @@ -694,11 +635,17 @@ public: return v; } - BOOST_FORCEINLINE operator value_type() volatile const BOOST_NOEXCEPT + BOOST_FORCEINLINE operator value_type() const volatile BOOST_NOEXCEPT { return this->load(); } + BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT + { + // C++17 requires all instances of atomic<> return a value consistent with is_always_lock_free here + return is_always_lock_free; + } + BOOST_FORCEINLINE storage_type& storage() BOOST_NOEXCEPT { return this->m_storage.value; } BOOST_FORCEINLINE storage_type volatile& storage() volatile BOOST_NOEXCEPT { return this->m_storage.value; } BOOST_FORCEINLINE storage_type const& storage() const BOOST_NOEXCEPT { return this->m_storage.value; } diff --git a/boost/atomic/detail/bitwise_cast.hpp b/boost/atomic/detail/bitwise_cast.hpp index 1405a25d6a..4a285ecab2 100644 --- a/boost/atomic/detail/bitwise_cast.hpp +++ b/boost/atomic/detail/bitwise_cast.hpp @@ -25,6 +25,12 @@ #pragma once #endif +#if defined(BOOST_GCC) && (BOOST_GCC+0) >= 40600 +#pragma GCC diagnostic push +// missing initializer for member var +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + namespace boost { namespace atomics { namespace detail { @@ -34,7 +40,7 @@ BOOST_FORCEINLINE T* addressof(T& value) BOOST_NOEXCEPT { // Note: The point of using a local struct as the intermediate type instead of char is to avoid gcc warnings // if T is a const volatile char*: - // warning: casting ‘const volatile char* const’ to ‘const volatile char&’ does not dereference pointer + // warning: casting 'const volatile char* const' to 'const volatile char&' does not dereference pointer // The local struct makes sure T is not related to the cast target type. struct opaque_type; return reinterpret_cast< T* >(&const_cast< opaque_type& >(reinterpret_cast< const volatile opaque_type& >(value))); @@ -61,4 +67,8 @@ BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT } // namespace atomics } // namespace boost +#if defined(BOOST_GCC) && (BOOST_GCC+0) >= 40600 +#pragma GCC diagnostic pop +#endif + #endif // BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_ diff --git a/boost/atomic/detail/config.hpp b/boost/atomic/detail/config.hpp index 00f7bff696..7a43e23cbc 100644 --- a/boost/atomic/detail/config.hpp +++ b/boost/atomic/detail/config.hpp @@ -73,4 +73,30 @@ #define BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS #endif +#if defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) +#if !(defined(BOOST_LIBSTDCXX11) && (BOOST_LIBSTDCXX_VERSION+0) >= 40700) /* libstdc++ from gcc >= 4.7 in C++11 mode */ +// This macro indicates that there is no <type_traits> standard header that is sufficient for Boost.Atomic needs. +#define BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS +#endif +#endif // defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) + +// Enable pointer/reference casts between storage and value when possible. +// Note: Despite that MSVC does not employ strict aliasing rules for optimizations +// and does not require an explicit markup for types that may alias, we still don't +// enable the optimization for this compiler because at least MSVC-8 and 9 are known +// to generate broken code sometimes when casts are used. +#if defined(__GNUC__) && (!defined(BOOST_INTEL_CXX_VERSION) || (BOOST_INTEL_CXX_VERSION+0) >= 1300) +#define BOOST_ATOMIC_DETAIL_MAY_ALIAS __attribute__((__may_alias__)) +#define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS +#elif defined(__has_attribute) +#if __has_attribute(__may_alias__) +#define BOOST_ATOMIC_DETAIL_MAY_ALIAS __attribute__((__may_alias__)) +#define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS +#endif +#endif + +#if !defined(BOOST_ATOMIC_DETAIL_MAY_ALIAS) +#define BOOST_ATOMIC_DETAIL_MAY_ALIAS +#endif + #endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ diff --git a/boost/atomic/detail/ops_emulated.hpp b/boost/atomic/detail/ops_emulated.hpp index a21128ec69..e15f37a680 100644 --- a/boost/atomic/detail/ops_emulated.hpp +++ b/boost/atomic/detail/ops_emulated.hpp @@ -142,11 +142,6 @@ struct emulated_operations { store(storage, (storage_type)0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return false; - } }; template< std::size_t Size, bool Signed > diff --git a/boost/atomic/detail/ops_gcc_alpha.hpp b/boost/atomic/detail/ops_gcc_alpha.hpp index 15118f58a2..5a9deb42ea 100644 --- a/boost/atomic/detail/ops_gcc_alpha.hpp +++ b/boost/atomic/detail/ops_gcc_alpha.hpp @@ -339,11 +339,6 @@ struct operations< 4u, Signed > : { store(storage, 0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; @@ -851,11 +846,6 @@ struct operations< 8u, Signed > : { store(storage, 0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; diff --git a/boost/atomic/detail/ops_gcc_arm.hpp b/boost/atomic/detail/ops_gcc_arm.hpp index e181b16853..86a75f5b25 100644 --- a/boost/atomic/detail/ops_gcc_arm.hpp +++ b/boost/atomic/detail/ops_gcc_arm.hpp @@ -404,11 +404,6 @@ struct operations< 4u, Signed > : { store(storage, 0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; @@ -946,11 +941,6 @@ struct operations< 8u, Signed > : { store(storage, 0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; #endif // defined(BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD) diff --git a/boost/atomic/detail/ops_gcc_atomic.hpp b/boost/atomic/detail/ops_gcc_atomic.hpp index 0a34c01f16..4e1adae86a 100644 --- a/boost/atomic/detail/ops_gcc_atomic.hpp +++ b/boost/atomic/detail/ops_gcc_atomic.hpp @@ -161,11 +161,6 @@ struct gcc_atomic_operations { __atomic_clear(const_cast< storage_type* >(&storage), atomics::detail::convert_memory_order_to_gcc(order)); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile& storage) BOOST_NOEXCEPT - { - return __atomic_is_lock_free(sizeof(storage_type), &storage); - } }; #if BOOST_ATOMIC_INT128_LOCK_FREE > 0 diff --git a/boost/atomic/detail/ops_gcc_ppc.hpp b/boost/atomic/detail/ops_gcc_ppc.hpp index 4183bc0485..76eae4e232 100644 --- a/boost/atomic/detail/ops_gcc_ppc.hpp +++ b/boost/atomic/detail/ops_gcc_ppc.hpp @@ -331,11 +331,6 @@ struct operations< 4u, Signed > : { store(storage, 0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; @@ -758,11 +753,6 @@ struct operations< 8u, Signed > : { store(storage, 0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; #endif // defined(__powerpc64__) || defined(__PPC64__) diff --git a/boost/atomic/detail/ops_gcc_sparc.hpp b/boost/atomic/detail/ops_gcc_sparc.hpp index fd42fa8095..08492ac69a 100644 --- a/boost/atomic/detail/ops_gcc_sparc.hpp +++ b/boost/atomic/detail/ops_gcc_sparc.hpp @@ -120,11 +120,6 @@ struct gcc_sparc_cas32 : fence_after(order); return v; } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > @@ -192,11 +187,6 @@ struct gcc_sparc_cas64 : { return compare_exchange_strong(storage, expected, desired, success_order, failure_order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > diff --git a/boost/atomic/detail/ops_gcc_sync.hpp b/boost/atomic/detail/ops_gcc_sync.hpp index 2f41aff279..a9a9ae2f72 100644 --- a/boost/atomic/detail/ops_gcc_sync.hpp +++ b/boost/atomic/detail/ops_gcc_sync.hpp @@ -145,11 +145,6 @@ struct gcc_sync_operations : if (order == memory_order_seq_cst) __sync_synchronize(); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; #if BOOST_ATOMIC_INT8_LOCK_FREE > 0 diff --git a/boost/atomic/detail/ops_gcc_x86.hpp b/boost/atomic/detail/ops_gcc_x86.hpp index 98dcdc064e..74e45c1f61 100644 --- a/boost/atomic/detail/ops_gcc_x86.hpp +++ b/boost/atomic/detail/ops_gcc_x86.hpp @@ -104,11 +104,6 @@ struct gcc_x86_operations : { store(storage, (storage_type)0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > diff --git a/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/boost/atomic/detail/ops_gcc_x86_dcas.hpp index e356e8cfbd..7f3962199a 100644 --- a/boost/atomic/detail/ops_gcc_x86_dcas.hpp +++ b/boost/atomic/detail/ops_gcc_x86_dcas.hpp @@ -354,11 +354,6 @@ struct gcc_dcas_x86 #endif // defined(__PIC__) #endif } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; #endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) @@ -611,11 +606,6 @@ struct gcc_dcas_x86_64 return v; #endif } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; #endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) diff --git a/boost/atomic/detail/ops_linux_arm.hpp b/boost/atomic/detail/ops_linux_arm.hpp index 01894b63ee..c26bc2c07b 100644 --- a/boost/atomic/detail/ops_linux_arm.hpp +++ b/boost/atomic/detail/ops_linux_arm.hpp @@ -136,11 +136,6 @@ struct linux_arm_cas : return false; } } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > diff --git a/boost/atomic/detail/ops_msvc_arm.hpp b/boost/atomic/detail/ops_msvc_arm.hpp index fd07f093fb..e0a709c991 100644 --- a/boost/atomic/detail/ops_msvc_arm.hpp +++ b/boost/atomic/detail/ops_msvc_arm.hpp @@ -18,11 +18,11 @@ #include <intrin.h> #include <boost/memory_order.hpp> -#include <boost/type_traits/make_signed.hpp> #include <boost/atomic/detail/config.hpp> #include <boost/atomic/detail/interlocked.hpp> #include <boost/atomic/detail/storage_type.hpp> #include <boost/atomic/detail/operations_fwd.hpp> +#include <boost/atomic/detail/type_traits/make_signed.hpp> #include <boost/atomic/capabilities.hpp> #include <boost/atomic/detail/ops_msvc_common.hpp> @@ -105,7 +105,7 @@ struct msvc_arm_operations : static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - typedef typename make_signed< storage_type >::type signed_storage_type; + typedef typename boost::atomics::detail::make_signed< storage_type >::type signed_storage_type; return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); } @@ -124,11 +124,6 @@ struct msvc_arm_operations : { Derived::store(storage, (storage_type)0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > diff --git a/boost/atomic/detail/ops_msvc_x86.hpp b/boost/atomic/detail/ops_msvc_x86.hpp index 24824214dd..623662468d 100644 --- a/boost/atomic/detail/ops_msvc_x86.hpp +++ b/boost/atomic/detail/ops_msvc_x86.hpp @@ -17,11 +17,11 @@ #define BOOST_ATOMIC_DETAIL_OPS_MSVC_X86_HPP_INCLUDED_ #include <boost/memory_order.hpp> -#include <boost/type_traits/make_signed.hpp> #include <boost/atomic/detail/config.hpp> #include <boost/atomic/detail/interlocked.hpp> #include <boost/atomic/detail/storage_type.hpp> #include <boost/atomic/detail/operations_fwd.hpp> +#include <boost/atomic/detail/type_traits/make_signed.hpp> #include <boost/atomic/capabilities.hpp> #if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) #include <boost/cstdint.hpp> @@ -135,7 +135,7 @@ struct msvc_x86_operations : static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - typedef typename make_signed< storage_type >::type signed_storage_type; + typedef typename boost::atomics::detail::make_signed< storage_type >::type signed_storage_type; return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); } @@ -154,11 +154,6 @@ struct msvc_x86_operations : { store(storage, (storage_type)0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > @@ -799,11 +794,6 @@ struct msvc_dcas_x86 return v; } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > @@ -893,11 +883,6 @@ struct msvc_dcas_x86_64 { return compare_exchange_strong(storage, expected, desired, success_order, failure_order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > diff --git a/boost/atomic/detail/ops_windows.hpp b/boost/atomic/detail/ops_windows.hpp index 867f1c6113..50d951dabf 100644 --- a/boost/atomic/detail/ops_windows.hpp +++ b/boost/atomic/detail/ops_windows.hpp @@ -24,11 +24,11 @@ #define BOOST_ATOMIC_DETAIL_OPS_WINDOWS_HPP_INCLUDED_ #include <boost/memory_order.hpp> -#include <boost/type_traits/make_signed.hpp> #include <boost/atomic/detail/config.hpp> #include <boost/atomic/detail/interlocked.hpp> #include <boost/atomic/detail/storage_type.hpp> #include <boost/atomic/detail/operations_fwd.hpp> +#include <boost/atomic/detail/type_traits/make_signed.hpp> #include <boost/atomic/capabilities.hpp> #include <boost/atomic/detail/ops_msvc_common.hpp> #include <boost/atomic/detail/ops_extending_cas_based.hpp> @@ -80,7 +80,7 @@ struct windows_operations : static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - typedef typename make_signed< storage_type >::type signed_storage_type; + typedef typename boost::atomics::detail::make_signed< storage_type >::type signed_storage_type; return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); } @@ -99,11 +99,6 @@ struct windows_operations : { store(storage, (storage_type)0, order); } - - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } }; template< bool Signed > diff --git a/boost/atomic/detail/platform.hpp b/boost/atomic/detail/platform.hpp index cc3cf1b67a..786b1f1971 100644 --- a/boost/atomic/detail/platform.hpp +++ b/boost/atomic/detail/platform.hpp @@ -60,7 +60,8 @@ defined(__ARM_ARCH_6ZK__) ||\ defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) ||\ defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) ||\ - defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__)\ + defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__) ||\ + defined(__ARM_ARCH_8A__)\ ) #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_arm diff --git a/boost/atomic/detail/storage_type.hpp b/boost/atomic/detail/storage_type.hpp index 63a7cef581..59e6901c26 100644 --- a/boost/atomic/detail/storage_type.hpp +++ b/boost/atomic/detail/storage_type.hpp @@ -38,7 +38,7 @@ BOOST_FORCEINLINE void non_atomic_load(T const volatile& from, T& to) BOOST_NOEX } template< std::size_t Size > -struct buffer_storage +struct BOOST_ATOMIC_DETAIL_MAY_ALIAS buffer_storage { BOOST_ALIGNMENT(16) unsigned char data[Size]; @@ -69,7 +69,7 @@ struct make_storage_type { typedef buffer_storage< Size > type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { type value; @@ -81,9 +81,9 @@ struct make_storage_type template< > struct make_storage_type< 1u, false > { - typedef boost::uint8_t type; + typedef boost::uint8_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { type value; @@ -95,9 +95,9 @@ struct make_storage_type< 1u, false > template< > struct make_storage_type< 1u, true > { - typedef boost::int8_t type; + typedef boost::int8_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { type value; @@ -109,9 +109,9 @@ struct make_storage_type< 1u, true > template< > struct make_storage_type< 2u, false > { - typedef boost::uint16_t type; + typedef boost::uint16_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(2) type value; @@ -123,9 +123,9 @@ struct make_storage_type< 2u, false > template< > struct make_storage_type< 2u, true > { - typedef boost::int16_t type; + typedef boost::int16_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(2) type value; @@ -137,9 +137,9 @@ struct make_storage_type< 2u, true > template< > struct make_storage_type< 4u, false > { - typedef boost::uint32_t type; + typedef boost::uint32_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(4) type value; @@ -151,9 +151,9 @@ struct make_storage_type< 4u, false > template< > struct make_storage_type< 4u, true > { - typedef boost::int32_t type; + typedef boost::int32_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(4) type value; @@ -165,9 +165,9 @@ struct make_storage_type< 4u, true > template< > struct make_storage_type< 8u, false > { - typedef boost::uint64_t type; + typedef boost::uint64_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(8) type value; @@ -179,9 +179,9 @@ struct make_storage_type< 8u, false > template< > struct make_storage_type< 8u, true > { - typedef boost::int64_t type; + typedef boost::int64_t BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(8) type value; @@ -195,9 +195,9 @@ struct make_storage_type< 8u, true > template< > struct make_storage_type< 16u, false > { - typedef boost::uint128_type type; + typedef boost::uint128_type BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(16) type value; @@ -209,9 +209,9 @@ struct make_storage_type< 16u, false > template< > struct make_storage_type< 16u, true > { - typedef boost::int128_type type; + typedef boost::int128_type BOOST_ATOMIC_DETAIL_MAY_ALIAS type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(16) type value; @@ -222,7 +222,7 @@ struct make_storage_type< 16u, true > #elif !defined(BOOST_NO_ALIGNMENT) -struct storage128_t +struct BOOST_ATOMIC_DETAIL_MAY_ALIAS storage128_t { boost::uint64_t data[2]; @@ -252,7 +252,7 @@ struct make_storage_type< 16u, Signed > { typedef storage128_t type; - struct aligned + struct BOOST_ATOMIC_DETAIL_MAY_ALIAS aligned { BOOST_ALIGNMENT(16) type value; diff --git a/boost/atomic/detail/type_traits/conditional.hpp b/boost/atomic/detail/type_traits/conditional.hpp new file mode 100644 index 0000000000..71397ab154 --- /dev/null +++ b/boost/atomic/detail/type_traits/conditional.hpp @@ -0,0 +1,42 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2017 Andrey Semashev + */ +/*! + * \file atomic/detail/type_traits/conditional.hpp + * + * This header defines \c conditional type trait + */ + +#ifndef BOOST_ATOMIC_DETAIL_TYPE_TRAITS_CONDITIONAL_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_TYPE_TRAITS_CONDITIONAL_HPP_INCLUDED_ + +#include <boost/atomic/detail/config.hpp> +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) +#include <type_traits> +#else +#include <boost/type_traits/conditional.hpp> +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace atomics { +namespace detail { + +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) +using std::conditional; +#else +using boost::conditional; +#endif + +} // namespace detail +} // namespace atomics +} // namespace boost + +#endif // BOOST_ATOMIC_DETAIL_TYPE_TRAITS_CONDITIONAL_HPP_INCLUDED_ diff --git a/boost/atomic/detail/type_traits/is_function.hpp b/boost/atomic/detail/type_traits/is_function.hpp new file mode 100644 index 0000000000..7b82840f5e --- /dev/null +++ b/boost/atomic/detail/type_traits/is_function.hpp @@ -0,0 +1,42 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2017 Andrey Semashev + */ +/*! + * \file atomic/detail/type_traits/is_function.hpp + * + * This header defines \c is_function type trait + */ + +#ifndef BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_FUNCTION_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_FUNCTION_HPP_INCLUDED_ + +#include <boost/atomic/detail/config.hpp> +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) +#include <type_traits> +#else +#include <boost/type_traits/is_function.hpp> +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace atomics { +namespace detail { + +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) +using std::is_function; +#else +using boost::is_function; +#endif + +} // namespace detail +} // namespace atomics +} // namespace boost + +#endif // BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_FUNCTION_HPP_INCLUDED_ diff --git a/boost/atomic/detail/type_traits/is_integral.hpp b/boost/atomic/detail/type_traits/is_integral.hpp new file mode 100644 index 0000000000..5deb12034c --- /dev/null +++ b/boost/atomic/detail/type_traits/is_integral.hpp @@ -0,0 +1,43 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2017 Andrey Semashev + */ +/*! + * \file atomic/detail/type_traits/is_integral.hpp + * + * This header defines \c is_integral type trait + */ + +#ifndef BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_INTEGRAL_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_INTEGRAL_HPP_INCLUDED_ + +#include <boost/atomic/detail/config.hpp> +// Some versions of libstdc++ don't consider __int128 an integral type. Use Boost.TypeTraits because of that. +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_HAS_INT128) +#include <type_traits> +#else +#include <boost/type_traits/is_integral.hpp> +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace atomics { +namespace detail { + +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_HAS_INT128) +using std::is_integral; +#else +using boost::is_integral; +#endif + +} // namespace detail +} // namespace atomics +} // namespace boost + +#endif // BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_INTEGRAL_HPP_INCLUDED_ diff --git a/boost/atomic/detail/type_traits/is_signed.hpp b/boost/atomic/detail/type_traits/is_signed.hpp new file mode 100644 index 0000000000..bf95163828 --- /dev/null +++ b/boost/atomic/detail/type_traits/is_signed.hpp @@ -0,0 +1,43 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2017 Andrey Semashev + */ +/*! + * \file atomic/detail/type_traits/is_signed.hpp + * + * This header defines \c is_signed type trait + */ + +#ifndef BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_SIGNED_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_SIGNED_HPP_INCLUDED_ + +#include <boost/atomic/detail/config.hpp> +// Some versions of libstdc++ don't consider __int128 an integral type. Use Boost.TypeTraits because of that. +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_HAS_INT128) +#include <type_traits> +#else +#include <boost/type_traits/is_signed.hpp> +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace atomics { +namespace detail { + +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_HAS_INT128) +using std::is_signed; +#else +using boost::is_signed; +#endif + +} // namespace detail +} // namespace atomics +} // namespace boost + +#endif // BOOST_ATOMIC_DETAIL_TYPE_TRAITS_IS_SIGNED_HPP_INCLUDED_ diff --git a/boost/atomic/detail/type_traits/make_signed.hpp b/boost/atomic/detail/type_traits/make_signed.hpp new file mode 100644 index 0000000000..831efdc391 --- /dev/null +++ b/boost/atomic/detail/type_traits/make_signed.hpp @@ -0,0 +1,43 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2017 Andrey Semashev + */ +/*! + * \file atomic/detail/type_traits/make_signed.hpp + * + * This header defines \c make_signed type trait + */ + +#ifndef BOOST_ATOMIC_DETAIL_TYPE_TRAITS_MAKE_SIGNED_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_TYPE_TRAITS_MAKE_SIGNED_HPP_INCLUDED_ + +#include <boost/atomic/detail/config.hpp> +// Some versions of libstdc++ don't consider __int128 an integral type. Use Boost.TypeTraits because of that. +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_HAS_INT128) +#include <type_traits> +#else +#include <boost/type_traits/make_signed.hpp> +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace atomics { +namespace detail { + +#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS) && !defined(BOOST_HAS_INT128) +using std::make_signed; +#else +using boost::make_signed; +#endif + +} // namespace detail +} // namespace atomics +} // namespace boost + +#endif // BOOST_ATOMIC_DETAIL_TYPE_TRAITS_MAKE_SIGNED_HPP_INCLUDED_ |