diff --git a/configure.ac b/configure.ac index d9f51b89d..9122f469c 100644 --- a/configure.ac +++ b/configure.ac @@ -202,6 +202,8 @@ AC_PROG_CXX_C_O AM_PROG_AS +AC_C_BIGENDIAN + # Check for other compiler toolchain tools. AC_CHECK_TOOL(AR, ar) diff --git a/src/core/common/encoding.hpp b/src/core/common/encoding.hpp index 0d4ba72cb..8f2858406 100644 --- a/src/core/common/encoding.hpp +++ b/src/core/common/encoding.hpp @@ -37,8 +37,13 @@ #include "openthread-core-config.h" #ifndef BYTE_ORDER_BIG_ENDIAN +#if defined(WORDS_BIGENDIAN) || \ + defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define BYTE_ORDER_BIG_ENDIAN 1 +#else #define BYTE_ORDER_BIG_ENDIAN 0 #endif +#endif #include #include