mirror of
https://github.com/boostorg/core.git
synced 2025-05-11 05:07:39 +00:00
Added support for __builtin_bswap16.
This commit is contained in:
parent
7cbbb08e7b
commit
db0fd77af1
@ -47,12 +47,19 @@
|
|||||||
# if __has_builtin(__builtin_bit_cast)
|
# if __has_builtin(__builtin_bit_cast)
|
||||||
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
||||||
# endif
|
# endif
|
||||||
|
# if __has_builtin(__builtin_bswap16)
|
||||||
|
# define BOOST_CORE_HAS_BUILTIN_BSWAP16
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1926
|
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1926
|
||||||
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOST_CORE_HAS_BUILTIN_BSWAP16) && (defined(BOOST_GCC_VERSION) && BOOST_GCC_VERSION >= 40800)
|
||||||
|
# define BOOST_CORE_HAS_BUILTIN_BSWAP16
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace core
|
namespace core
|
||||||
@ -825,11 +832,22 @@ BOOST_CONSTEXPR inline boost::uint8_t byteswap_impl( boost::uint8_t x ) BOOST_NO
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_CORE_HAS_BUILTIN_BSWAP16)
|
||||||
|
|
||||||
|
BOOST_CONSTEXPR inline boost::uint16_t byteswap_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return __builtin_bswap16( x );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
BOOST_CONSTEXPR inline boost::uint16_t byteswap_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
BOOST_CONSTEXPR inline boost::uint16_t byteswap_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return static_cast<boost::uint16_t>( x << 8 | x >> 8 );
|
return static_cast<boost::uint16_t>( x << 8 | x >> 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
|
||||||
BOOST_CXX14_CONSTEXPR inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
BOOST_CXX14_CONSTEXPR inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user