|
Boost-Commit : |
From: john_at_[hidden]
Date: 2008-03-30 13:25:24
Author: johnmaddock
Date: 2008-03-30 13:25:24 EDT (Sun, 30 Mar 2008)
New Revision: 43952
URL: http://svn.boost.org/trac/boost/changeset/43952
Log:
Added support and tests for MSVC SSE intrinsic types with alignments > long long.
Text files modified:
trunk/boost/type_traits/alignment_of.hpp | 8 ++++++
trunk/boost/type_traits/type_with_alignment.hpp | 23 ++++++++++++++++++++
trunk/libs/type_traits/test/type_with_alignment_test.cpp | 45 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 1 deletions(-)
Modified: trunk/boost/type_traits/alignment_of.hpp
==============================================================================
--- trunk/boost/type_traits/alignment_of.hpp (original)
+++ trunk/boost/type_traits/alignment_of.hpp 2008-03-30 13:25:24 EDT (Sun, 30 Mar 2008)
@@ -30,6 +30,10 @@
// 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 @@
T t;
alignment_of_hack();
};
-
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
template <unsigned A, unsigned S>
struct alignment_logic
Modified: trunk/boost/type_traits/type_with_alignment.hpp
==============================================================================
--- trunk/boost/type_traits/type_with_alignment.hpp (original)
+++ trunk/boost/type_traits/type_with_alignment.hpp 2008-03-30 13:25:24 EDT (Sun, 30 Mar 2008)
@@ -232,6 +232,29 @@
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
Modified: trunk/libs/type_traits/test/type_with_alignment_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/type_with_alignment_test.cpp (original)
+++ trunk/libs/type_traits/test/type_with_alignment_test.cpp 2008-03-30 13:25:24 EDT (Sun, 30 Mar 2008)
@@ -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 @@
>::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
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk