forked from boostorg/type_traits
Added support and tests for MSVC SSE intrinsic types with alignments > long long.
[SVN r43952]
This commit is contained in:
@ -30,6 +30,10 @@ template <typename T> struct alignment_of;
|
||||
// get the alignment of some arbitrary type:
|
||||
namespace detail {
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4324) // structure was padded due to __declspec(align())
|
||||
#endif
|
||||
template <typename T>
|
||||
struct alignment_of_hack
|
||||
{
|
||||
@ -37,7 +41,9 @@ struct alignment_of_hack
|
||||
T t;
|
||||
alignment_of_hack();
|
||||
};
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template <unsigned A, unsigned S>
|
||||
struct alignment_logic
|
||||
|
@ -232,6 +232,29 @@ BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a16,true)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a32,true)
|
||||
}
|
||||
#endif
|
||||
#if defined(BOOST_MSVC) || (defined(BOOST_INTEL) && defined(_MSC_VER))
|
||||
namespace align {
|
||||
struct __declspec(align(8)) a8 { char m[8]; };
|
||||
struct __declspec(align(16)) a16 { char m[16]; };
|
||||
struct __declspec(align(32)) a32 { char m[32]; };
|
||||
struct __declspec(align(64)) a64 { char m[64]; };
|
||||
struct __declspec(align(128)) a128 { char m[128]; };
|
||||
}
|
||||
|
||||
template<> class type_with_alignment<8> { public: typedef align::a8 type; };
|
||||
template<> class type_with_alignment<16> { public: typedef align::a16 type; };
|
||||
template<> class type_with_alignment<32> { public: typedef align::a32 type; };
|
||||
template<> class type_with_alignment<64> { public: typedef align::a64 type; };
|
||||
template<> class type_with_alignment<128> { public: typedef align::a128 type; };
|
||||
|
||||
namespace detail {
|
||||
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a8,true)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a16,true)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a32,true)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a64,true)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a128,true)
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
@ -14,6 +14,17 @@
|
||||
# include <boost/type_traits/is_pod.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC) || (defined(BOOST_INTEL) && defined(_MSC_VER))
|
||||
#if _MSC_VER >= 1400
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
struct __declspec(align(8)) a8 { char m[8]; };
|
||||
struct __declspec(align(16)) a16 { char m[16]; };
|
||||
struct __declspec(align(32)) a32 { char m[32]; };
|
||||
struct __declspec(align(64)) a64 { char m[64]; };
|
||||
struct __declspec(align(128)) a128 { char m[128]; };
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(type_with_alignment)
|
||||
|
||||
BOOST_MESSAGE(typeid(::tt::type_with_alignment<
|
||||
@ -69,6 +80,40 @@ BOOST_CHECK(::tt::alignment_of<
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<__int64>::value);
|
||||
#endif
|
||||
#if defined(BOOST_MSVC) || (defined(BOOST_INTEL) && defined(_MSC_VER))
|
||||
#if _MSC_VER >= 1400
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<__m128>::value
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<__m128>::value);
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<__m64>::value
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<__m64>::value);
|
||||
#endif
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<a8>::value
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<a8>::value);
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<a16>::value
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<a16>::value);
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<a32>::value
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<a32>::value);
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<a64>::value
|
||||
>::type
|
||||
>::value == ::boost::alignment_of<a64>::value);
|
||||
#endif
|
||||
BOOST_CHECK(::tt::alignment_of<
|
||||
::tt::type_with_alignment<
|
||||
::tt::alignment_of<int[4]>::value
|
||||
|
Reference in New Issue
Block a user