mirror of
https://github.com/boostorg/core.git
synced 2025-05-09 23:03:54 +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)
|
||||
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
||||
# endif
|
||||
# if __has_builtin(__builtin_bswap16)
|
||||
# define BOOST_CORE_HAS_BUILTIN_BSWAP16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1926
|
||||
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
||||
#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 core
|
||||
@ -825,11 +832,22 @@ BOOST_CONSTEXPR inline boost::uint8_t byteswap_impl( boost::uint8_t x ) BOOST_NO
|
||||
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
|
||||
{
|
||||
return static_cast<boost::uint16_t>( x << 8 | x >> 8 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
|
Loading…
x
Reference in New Issue
Block a user