mirror of
https://github.com/boostorg/atomic.git
synced 2026-02-02 20:32:09 +00:00
Added a workaround for gcc 4.8 not supporting alignas with a constant expression
gcc 4.8 requires that the argument of alignas is a literal constant and does not accept a constant expression. This workaround is temporary, until Boost.Config updates BOOST_NO_CXX11_ALIGNAS: https://github.com/boostorg/config/pull/324
This commit is contained in:
@@ -45,7 +45,7 @@ struct atomic_flag
|
||||
typedef atomics::detail::operations< 1u, false > operations;
|
||||
typedef operations::storage_type storage_type;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALIGNAS)
|
||||
#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
|
||||
alignas(operations::storage_alignment) storage_type m_storage;
|
||||
#else
|
||||
// Note: Some compilers cannot use constant expressions in alignment attributes, so we have to use the union trick
|
||||
|
||||
@@ -76,7 +76,7 @@ protected:
|
||||
static BOOST_CONSTEXPR_OR_CONST std::size_t storage_alignment = atomics::detail::alignment_of< value_type >::value <= operations::storage_alignment ? operations::storage_alignment : atomics::detail::alignment_of< value_type >::value;
|
||||
|
||||
protected:
|
||||
#if !defined(BOOST_NO_CXX11_ALIGNAS)
|
||||
#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
|
||||
alignas(storage_alignment) storage_type m_storage;
|
||||
#else
|
||||
// Note: Some compilers cannot use constant expressions in alignment attributes, so we have to use the union trick
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
#endif
|
||||
#endif // defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALIGNAS) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40900)
|
||||
// This macro indicates that the compiler doesn't support alignas with a constant expression as an argument
|
||||
#define BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
@@ -42,7 +42,7 @@ BOOST_FORCEINLINE void non_atomic_load(T const volatile& from, T& to) BOOST_NOEX
|
||||
template< std::size_t Size, std::size_t Alignment = 1u >
|
||||
struct BOOST_ATOMIC_DETAIL_MAY_ALIAS buffer_storage
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_ALIGNAS)
|
||||
#if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
|
||||
alignas(Alignment) unsigned char data[Size];
|
||||
#else
|
||||
union
|
||||
|
||||
Reference in New Issue
Block a user