]> git.saurik.com Git - redis.git/commitdiff
Fixed sha1.c compilation on Linux, due to endianess detection lameness
authorantirez <antirez@metal.(none)>
Fri, 14 May 2010 17:21:30 +0000 (19:21 +0200)
committerantirez <antirez@metal.(none)>
Fri, 14 May 2010 17:21:30 +0000 (19:21 +0200)
sha1.c

diff --git a/sha1.c b/sha1.c
index a768a7a7f85e77afa476bd7de57f63617b0c8546..a4f54c9e601c48effe596d16df62cc081f425f9b 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -21,6 +21,8 @@ A million repetitions of "a"
 
 #define SHA1HANDSOFF
 
+#include <endian.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h> /* for u_int*_t */
@@ -56,6 +58,14 @@ A million repetitions of "a"
 #endif /* BSD */
 #endif /* BYTE_ORDER */
 
+#if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+#define BYTE_ORDER LITTLE_ENDIAN
+#else
+#define BYTE_ORDER BIG_ENDIAN
+#endif
+#endif
+
 #if !defined(BYTE_ORDER) || \
     (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
     BYTE_ORDER != PDP_ENDIAN)
@@ -64,7 +74,7 @@ A million repetitions of "a"
         * which will force your compiles to bomb until you fix
         * the above macros.
         */
-  error "Undefined or invalid BYTE_ORDER";
+#error "Undefined or invalid BYTE_ORDER"
 #endif
 
 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))