Avoid using non-portable debian.h
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 11 Nov 2015 14:32:28 +0000 (15:32 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 11 Nov 2015 14:32:28 +0000 (15:32 +0100)
Instead use autoconf's AC_C_BIGENDIAN

configure.ac
src/wrbuf_sha1.c

index 4090a95..8d7e03b 100644 (file)
@@ -27,6 +27,7 @@ dnl
 YAZ_DOC
 dnl
 dnl
+AC_C_BIGENDIAN
 AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h sys/prctl.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h execinfo.h],[],[],[])
 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
  #if HAVE_SYS_TYPES_H
index 3aee3ca..733d8a2 100644 (file)
@@ -24,13 +24,11 @@ By Steve Reid <steve@edmweb.com>
 100% Public Domain
 */
 
-/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */
 /* #define SHA1HANDSOFF * Copies data before messing with it. */
 
 #define SHA1HANDSOFF
 
 #include <stdint.h>
-#include <endian.h>
 
 typedef struct {
     uint32_t state[5];
@@ -42,13 +40,11 @@ typedef struct {
 
 /* blk0() and blk() perform the initial expand. */
 /* I got the idea of expanding during the round function from SSLeay */
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
-    |(rol(block->l[i],8)&0x00FF00FF))
-#elif BYTE_ORDER == BIG_ENDIAN
+#if WORDS_BIGENDIAN
 #define blk0(i) block->l[i]
 #else
-#error "Endianness not defined!"
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+    |(rol(block->l[i],8)&0x00FF00FF))
 #endif
 #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
     ^block->l[(i+2)&15]^block->l[i&15],1))