From 1b0a41e6cba74f55954b8cb481cb346e5cce39c1 Mon Sep 17 00:00:00 2001 From: Beman Date: Fri, 11 Dec 2015 08:15:25 -0500 Subject: [PATCH] Add Clang/c2 solution with conversion_test_clang project. Clang/c2 uses the Microsoft rather than GCC intrinsics, so check for defined(_MSC_VER) before defined(__clang__) --- include/boost/endian/detail/intrinsic.hpp | 21 ++- test/msvc/common.props | 1 + .../conversion_test_clang.vcxproj | 156 ++++++++++++++++++ test/msvc/endian-clang-c2.sln | 28 ++++ 4 files changed, 197 insertions(+), 9 deletions(-) create mode 100644 test/msvc/conversion_test_clang/conversion_test_clang.vcxproj create mode 100644 test/msvc/endian-clang-c2.sln diff --git a/include/boost/endian/detail/intrinsic.hpp b/include/boost/endian/detail/intrinsic.hpp index 6ead681..0abd0ad 100644 --- a/include/boost/endian/detail/intrinsic.hpp +++ b/include/boost/endian/detail/intrinsic.hpp @@ -18,8 +18,19 @@ #define __has_builtin(x) 0 // Compatibility with non-clang compilers #endif +#if defined(_MSC_VER) +// Microsoft documents these as being compatible since Windows 95 and specifically +// lists runtime library support since Visual Studio 2003 (aka 7.1). +// Clang/c2 uses the Microsoft rather than GCC intrinsics, so we check for +// defined(_MSC_VER) before defined(__clang__) +# define BOOST_ENDIAN_INTRINSIC_MSG "cstdlib _byteswap_ushort, etc." +# include +# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) _byteswap_ushort(x) +# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) _byteswap_ulong(x) +# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) _byteswap_uint64(x) + // GCC and Clang recent versions provide intrinsic byte swaps via builtins -#if (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \ +#elif (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \ || (defined(__GNUC__ ) && \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) # define BOOST_ENDIAN_INTRINSIC_MSG "__builtin_bswap16, etc." @@ -45,14 +56,6 @@ # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) bswap_32(x) # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) bswap_64(x) -#elif defined(_MSC_VER) -// Microsoft documents these as being compatible since Windows 95 and specificly -// lists runtime library support since Visual Studio 2003 (aka 7.1). -# define BOOST_ENDIAN_INTRINSIC_MSG "cstdlib _byteswap_ushort, etc." -# include -# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) _byteswap_ushort(x) -# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) _byteswap_ulong(x) -# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) _byteswap_uint64(x) #else # define BOOST_ENDIAN_NO_INTRINSICS # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics" diff --git a/test/msvc/common.props b/test/msvc/common.props index 8b8b2f0..78c3093 100644 --- a/test/msvc/common.props +++ b/test/msvc/common.props @@ -11,6 +11,7 @@ ..\..\..\..\..;%(AdditionalIncludeDirectories) EnableAllWarnings BOOST_LIGHTWEIGHT_TEST_OSTREAM=std::cout;BOOST_ALL_DYN_LINK;_UNICODE;UNICODE;%(PreprocessorDefinitions) + true Executing test $(TargetName).exe... diff --git a/test/msvc/conversion_test_clang/conversion_test_clang.vcxproj b/test/msvc/conversion_test_clang/conversion_test_clang.vcxproj new file mode 100644 index 0000000..ddf310d --- /dev/null +++ b/test/msvc/conversion_test_clang/conversion_test_clang.vcxproj @@ -0,0 +1,156 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {0DA4B909-1E3D-43A2-A248-3FE73E499726} + Win32Proj + conversion_test_clang + + + + Application + true + v140_clang_3_7 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140_Clang_3_7 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + EnableAllWarnings + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Enabled + ../../../../../ + true + + + Console + true + + + "$(TargetDir)\$(TargetName).exe" + + + + + NotUsing + Disabled + true + Enabled + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/test/msvc/endian-clang-c2.sln b/test/msvc/endian-clang-c2.sln new file mode 100644 index 0000000..376a15f --- /dev/null +++ b/test/msvc/endian-clang-c2.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "conversion_test_clang", "conversion_test_clang\conversion_test_clang.vcxproj", "{0DA4B909-1E3D-43A2-A248-3FE73E499726}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x64.ActiveCfg = Debug|x64 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x64.Build.0 = Debug|x64 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x86.ActiveCfg = Debug|Win32 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x86.Build.0 = Debug|Win32 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x64.ActiveCfg = Release|x64 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x64.Build.0 = Release|x64 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x86.ActiveCfg = Release|Win32 + {0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal