From a6b61b9f8b6576e8159a4e7e6aee88bba7e5d07d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 11 Nov 2015 15:32:28 +0100 Subject: [PATCH] Avoid using non-portable debian.h Instead use autoconf's AC_C_BIGENDIAN --- configure.ac | 1 + src/wrbuf_sha1.c | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 4090a95..8d7e03b 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/wrbuf_sha1.c b/src/wrbuf_sha1.c index 3aee3ca..733d8a2 100644 --- a/src/wrbuf_sha1.c +++ b/src/wrbuf_sha1.c @@ -24,13 +24,11 @@ By Steve Reid 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 -#include 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)) -- 1.7.10.4