[general] Endianity detection for ARM

Hello All, Something in Boost.Test started using detail/endian.hpp internally between 1.43 and 1.50. Since at work I build Boost.Test-based tests for several mobile platforms, all of which use ARM, I needed to fix it. It is easy for all platforms built with either gcc or clang (Android, iOS and Bada). Gcc defines __ARMEB__ for big-endian ARM and __ARMEL__ for little-endian ARM. Windows CE is however another issue. Microsoft usually defines rather characteristic _M_<arch> macros, but _M_ARM is *not* defined in Windows CE, though it appears to be defined for Windows 8 ARM (I don't work with those yet). The WinCE projects define ARM and _ARM_, but those may appear on big-endian ARM platforms too. However since there are no big-endian Win32 platforms and they are unlikely to be created, I suggest just hardcoding little endian for anything that defines _WIN32 (the _M_* macros could then possibly be removed, but they don't cause any problems there). I therefore propose this patch: --- a/boost/detail/endian.hpp +++ b/boost/detail/endian.hpp @@ -57,7 +57,7 @@ || defined(_POWER) || defined(__powerpc__) \ || defined(__ppc__) || defined(__hpux) || defined(__hppa) \ || defined(_MIPSEB) || defined(_POWER) \ - || defined(__s390__) + || defined(__s390__) || defined(__ARMEB__) # define BOOST_BIG_ENDIAN # define BOOST_BYTE_ORDER 4321 #elif defined(__i386__) || defined(__alpha__) \ @@ -66,7 +66,9 @@ || defined(_M_ALPHA) || defined(__amd64) \ || defined(__amd64__) || defined(_M_AMD64) \ || defined(__x86_64) || defined(__x86_64__) \ - || defined(_M_X64) || defined(__bfin__) + || defined(_M_X64) || defined(__bfin__) \ + || defined(__ARMEL__) \ + || defined(_WIN32) // ARM Windows CE don't define __ARMEL__ nor _M_ARM, but there are no big-endian Windows versions # define BOOST_LITTLE_ENDIAN # define BOOST_BYTE_ORDER 1234 -- Jan 'Bulb' Hudec <bulb@ucw.cz>
participants (1)
-
Jan Hudec