endian.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. ////////////////////////////////////////////////////////////////
  2. // Copyright 2021 Matt Borland. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_MP_DETAIL_ENDIAN_HPP
  6. #define BOOST_MP_DETAIL_ENDIAN_HPP
  7. #include <boost/multiprecision/detail/standalone_config.hpp>
  8. #ifndef BOOST_MP_STANDALONE
  9. # include <boost/predef/other/endian.h>
  10. # define BOOST_MP_ENDIAN_BIG_BYTE BOOST_ENDIAN_BIG_BYTE
  11. # define BOOST_MP_ENDIAN_LITTLE_BYTE BOOST_ENDIAN_LITTLE_BYTE
  12. #elif defined(_WIN32)
  13. # define BOOST_MP_ENDIAN_BIG_BYTE 0
  14. # define BOOST_MP_ENDIAN_LITTLE_BYTE 1
  15. #elif defined(__BYTE_ORDER__)
  16. # define BOOST_MP_ENDIAN_BIG_BYTE (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  17. # define BOOST_MP_ENDIAN_LITTLE_BYTE (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  18. #else
  19. # error Could not determine endian type. Please disable standalone mode, and file an issue at https://github.com/boostorg/multiprecision
  20. #endif // Determine endianness
  21. static_assert((BOOST_MP_ENDIAN_BIG_BYTE || BOOST_MP_ENDIAN_LITTLE_BYTE)
  22. && !(BOOST_MP_ENDIAN_BIG_BYTE && BOOST_MP_ENDIAN_LITTLE_BYTE),
  23. "Inconsistent endianness detected. Please disable standalone mode, and file an issue at https://github.com/boostorg/multiprecision");
  24. #endif // BOOST_MP_DETAIL_ENDIAN_HPP