123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef BOOST_ENDIAN_INTRINSIC_HPP
- #define BOOST_ENDIAN_INTRINSIC_HPP
- #ifndef BOOST_ENDIAN_NO_INTRINSICS
- #ifndef __has_builtin
- #define __has_builtin(x) 0
- #endif
- #if defined(_MSC_VER) && ( !defined(__clang__) || defined(__c2__) )
- # define BOOST_ENDIAN_INTRINSIC_MSG "cstdlib _byteswap_ushort, etc."
- # include <cstdlib>
- # 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)
- #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."
- # if (defined(__clang__) && __has_builtin(__builtin_bswap16)) \
- || (defined(__GNUC__) &&(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap16(x)
- # else
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap32((x) << 16)
- # endif
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) __builtin_bswap64(x)
- # define BOOST_ENDIAN_CONSTEXPR_INTRINSICS
- #elif defined(__linux__)
- # define BOOST_ENDIAN_INTRINSIC_MSG "byteswap.h bswap_16, etc."
- # include <byteswap.h>
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) bswap_16(x)
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) bswap_32(x)
- # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) bswap_64(x)
- #else
- # define BOOST_ENDIAN_NO_INTRINSICS
- # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
- #endif
- #elif !defined(BOOST_ENDIAN_INTRINSIC_MSG)
- # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
- #endif
- #endif
|