order.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
  2. #define BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
  3. // Copyright 2019 Peter Dimov
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. #include <boost/core/scoped_enum.hpp>
  8. #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  9. # define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
  10. #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  11. # define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER big
  12. #elif defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
  13. # error The Boost.Endian library does not support platforms with PDP endianness.
  14. #elif defined(__LITTLE_ENDIAN__)
  15. # define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
  16. #elif defined(__BIG_ENDIAN__)
  17. # define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER big
  18. #elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__)
  19. # define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
  20. #else
  21. # error The Boost.Endian library could not determine the endianness of this platform.
  22. #endif
  23. namespace boost
  24. {
  25. namespace endian
  26. {
  27. BOOST_SCOPED_ENUM_START(order)
  28. {
  29. big,
  30. little,
  31. native = BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
  32. }; BOOST_SCOPED_ENUM_END
  33. } // namespace endian
  34. } // namespace boost
  35. #undef BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
  36. #endif // BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED