diff --git a/libratbox/configure.ac b/libratbox/configure.ac index b2b33f3..d50095c 100644 --- a/libratbox/configure.ac +++ b/libratbox/configure.ac @@ -40,6 +40,7 @@ AM_MAINTAINER_MODE AC_ISC_POSIX AC_C_INLINE AC_C_CONST +AC_C_BIGENDIAN AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PATH_PROG(AUTOMAKE, automake) diff --git a/libratbox/include/libratbox_config.h.in b/libratbox/include/libratbox_config.h.in index 1055efd..4e585c1 100644 --- a/libratbox/include/libratbox_config.h.in +++ b/libratbox/include/libratbox_config.h.in @@ -1,5 +1,8 @@ /* include/libratbox_config.h.in. Generated from configure.ac by autoheader. */ +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -229,9 +232,6 @@ /* Define this to disable debugging support. */ #undef NDEBUG -/* Define if your system needs crypt. */ -#undef NEED_CRYPT - /* Define to 1 if you wish to disable the block allocator. */ #undef NOBALLOC @@ -310,6 +310,18 @@ /* This is a Windows system */ #undef WINDOWS +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + /* Define to 1 if on MINIX. */ #undef _MINIX diff --git a/libratbox/src/crypt.c b/libratbox/src/crypt.c index 7bb27c2..3741e0b 100644 --- a/libratbox/src/crypt.c +++ b/libratbox/src/crypt.c @@ -779,7 +779,7 @@ static void MD5Init (MD5_CTX *); static void MD5Update (MD5_CTX *, const void *, unsigned int); static void MD5Final (unsigned char [16], MD5_CTX *); -#if (BYTE_ORDER == LITTLE_ENDIAN) +#ifndef WORDS_BIGENDIAN #define Encode memcpy #define Decode memcpy #else @@ -1196,7 +1196,7 @@ struct sha256_ctx char buffer[128]; /* NB: always correctly aligned for uint32_t. */ }; -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifndef WORDS_BIGENDIAN # define SHA256_SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else @@ -1738,7 +1738,7 @@ struct sha512_ctx }; -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifndef WORDS_BIGENDIAN # define SHA512_SWAP(n) \ (((n) << 56) \ | (((n) & 0xff00) << 40) \