annotate DEPENDENCIES/generic/include/boost/endian/detail/intrinsic.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // endian/detail/intrinsic.hpp -------------------------------------------------------//
Chris@102 2
Chris@102 3 // Copyright (C) 2012 David Stone
Chris@102 4 // Copyright Beman Dawes 2013
Chris@102 5
Chris@102 6 // Distributed under the Boost Software License, Version 1.0.
Chris@102 7 // http://www.boost.org/LICENSE_1_0.txt
Chris@102 8
Chris@102 9 #ifndef BOOST_ENDIAN_INTRINSIC_HPP
Chris@102 10 #define BOOST_ENDIAN_INTRINSIC_HPP
Chris@102 11
Chris@102 12 // Allow user to force BOOST_ENDIAN_NO_INTRINSICS in case they aren't available for a
Chris@102 13 // particular platform/compiler combination. Please report such platform/compiler
Chris@102 14 // combinations to the Boost mailing list.
Chris@102 15 #ifndef BOOST_ENDIAN_NO_INTRINSICS
Chris@102 16
Chris@102 17 #ifndef __has_builtin // Optional of course
Chris@102 18 #define __has_builtin(x) 0 // Compatibility with non-clang compilers
Chris@102 19 #endif
Chris@102 20
Chris@102 21 // GCC and Clang recent versions provide intrinsic byte swaps via builtins
Chris@102 22 #if (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \
Chris@102 23 || (defined(__GNUC__ ) && \
Chris@102 24 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
Chris@102 25 # define BOOST_ENDIAN_INTRINSIC_MSG "__builtin_bswap16, etc."
Chris@102 26 // prior to 4.8, gcc did not provide __builtin_bswap16 on some platforms so we emulate it
Chris@102 27 // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
Chris@102 28 // Clang has a similar problem, but their feature test macros make it easier to detect
Chris@102 29 # if (defined(__clang__) && __has_builtin(__builtin_bswap16)) \
Chris@102 30 || (defined(__GNUC__) &&(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
Chris@102 31 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap16(x)
Chris@102 32 # else
Chris@102 33 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap32((x) << 16)
Chris@102 34 # endif
Chris@102 35 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
Chris@102 36 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) __builtin_bswap64(x)
Chris@102 37
Chris@102 38 // Linux systems provide the byteswap.h header, with
Chris@102 39 #elif defined(__linux__)
Chris@102 40 // don't check for obsolete forms defined(linux) and defined(__linux) on the theory that
Chris@102 41 // compilers that predefine only these are so old that byteswap.h probably isn't present.
Chris@102 42 # define BOOST_ENDIAN_INTRINSIC_MSG "byteswap.h bswap_16, etc."
Chris@102 43 # include <byteswap.h>
Chris@102 44 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) bswap_16(x)
Chris@102 45 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) bswap_32(x)
Chris@102 46 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) bswap_64(x)
Chris@102 47
Chris@102 48 #elif defined(_MSC_VER)
Chris@102 49 // Microsoft documents these as being compatible since Windows 95 and specificly
Chris@102 50 // lists runtime library support since Visual Studio 2003 (aka 7.1).
Chris@102 51 # define BOOST_ENDIAN_INTRINSIC_MSG "cstdlib _byteswap_ushort, etc."
Chris@102 52 # include <cstdlib>
Chris@102 53 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) _byteswap_ushort(x)
Chris@102 54 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) _byteswap_ulong(x)
Chris@102 55 # define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) _byteswap_uint64(x)
Chris@102 56 #else
Chris@102 57 # define BOOST_ENDIAN_NO_INTRINSICS
Chris@102 58 # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
Chris@102 59 #endif
Chris@102 60
Chris@102 61 #elif !defined(BOOST_ENDIAN_INTRINSIC_MSG)
Chris@102 62 # define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
Chris@102 63 #endif // BOOST_ENDIAN_NO_INTRINSICS
Chris@102 64 #endif // BOOST_ENDIAN_INTRINSIC_HPP