diff options
author | Arran Cudbard-Bell <a.cudbardb@freeradius.org> | 2014-03-02 21:51:39 +0000 |
---|---|---|
committer | Arran Cudbard-Bell <a.cudbardb@freeradius.org> | 2014-03-02 21:51:39 +0000 |
commit | 8a5052072cdeec3ca23350befbc0903001bea52c (patch) | |
tree | 9715c022b85063d923cc324ac3eb4345e386c623 | |
parent | 5d827a1f40373f41d2bce6b59719b930bcd646bd (diff) | |
download | libpam-radius-auth-8a5052072cdeec3ca23350befbc0903001bea52c.tar.gz libpam-radius-auth-8a5052072cdeec3ca23350befbc0903001bea52c.zip |
Use a combination of endian macros
-rw-r--r-- | md5.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -42,15 +42,28 @@ #include <string.h> #include "md5.h" -#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define HIGHFIRST -#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN -# define HIGHFIRST -#elif defined(__sparc) || defined(__mips) -# define HIGHFIRST +/* + * Try and determine endianness of the target system. + * + * Other projects seem to use endian.h and variants, but these are + * in non standard locations, and may mess up cross compiling. + * + * Here at least the endianess can be set explicitly with + * -DLITTLE_ENDIAN or -DBIG_ENDIAN. + */ +#if !defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN) +# if defined(__LITTLE_ENDIAN__) || \ + (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) +# define LITTLE_ENDIAN 1 +# elif defined(__BIG_ENDIAN__) || \ + (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) +# define BIG_ENDIAN 1 +# else +# error Failed determining endianness of system +# endif #endif -#ifndef HIGHFIRST +#ifdef LITTLE_ENDIAN # define byteReverse(buf, len) /* Nothing */ #else void byteReverse(unsigned char *buf, unsigned longs); |