File indexing completed on 2025-12-16 09:45:24
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_ENDIAN_INTRINSIC_HPP
0010 #define BOOST_ENDIAN_INTRINSIC_HPP
0011
0012
0013
0014
0015 #ifndef BOOST_ENDIAN_NO_INTRINSICS
0016
0017 #ifndef __has_builtin
0018 #define __has_builtin(x) 0
0019 #endif
0020
0021 #if defined(_MSC_VER) && ( !defined(__clang__) || defined(__c2__) )
0022
0023
0024
0025
0026 # define BOOST_ENDIAN_INTRINSIC_MSG "cstdlib _byteswap_ushort, etc."
0027 # include <cstdlib>
0028 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) _byteswap_ushort(x)
0029 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) _byteswap_ulong(x)
0030 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) _byteswap_uint64(x)
0031
0032
0033 #elif (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \
0034 || (defined(__GNUC__ ) && \
0035 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
0036 # define BOOST_ENDIAN_INTRINSIC_MSG "__builtin_bswap16, etc."
0037
0038
0039
0040 # if (defined(__clang__) && __has_builtin(__builtin_bswap16)) \
0041 || (defined(__GNUC__) &&(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
0042 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap16(x)
0043 # else
0044 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap32((x) << 16)
0045 # endif
0046 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
0047 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) __builtin_bswap64(x)
0048
0049 # define BOOST_ENDIAN_CONSTEXPR_INTRINSICS
0050
0051
0052 #elif defined(__linux__)
0053
0054
0055 # define BOOST_ENDIAN_INTRINSIC_MSG "byteswap.h bswap_16, etc."
0056 # include <byteswap.h>
0057 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) bswap_16(x)
0058 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) bswap_32(x)
0059 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) bswap_64(x)
0060
0061 #else
0062 # define BOOST_ENDIAN_NO_INTRINSICS
0063 # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
0064 #endif
0065
0066 #elif !defined(BOOST_ENDIAN_INTRINSIC_MSG)
0067 # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
0068 #endif
0069 #endif