From 6b839b35324dc93ee2e032c2beaa16dbf1e629b5 Mon Sep 17 00:00:00 2001 From: rjones Date: Wed, 15 Oct 2008 10:05:18 +0000 Subject: [PATCH 1/1] Fix endianness test for Windows. --- byteswap.h | 12 ++++++++++++ configure.ac | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/byteswap.h b/byteswap.h index 3509acf..991e85b 100644 --- a/byteswap.h +++ b/byteswap.h @@ -20,6 +20,10 @@ #ifndef _PORTABLEXDR_BYTESWAP_H #define _PORTABLEXDR_BYTESWAP_H 1 +#ifdef HAVE_SYS_PARAM_H +#include +#endif + /* Swap bytes in 16 bit value. */ #define __bswap_constant_16(x) \ ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) @@ -107,6 +111,7 @@ static inline uint32_t htonl (x) uint32_t x; { +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) #if BYTE_ORDER == BIG_ENDIAN return x; #elif BYTE_ORDER == LITTLE_ENDIAN @@ -114,6 +119,9 @@ htonl (x) #else # error "What kind of system is this?" #endif +#else +#error "BYTE_ORDER/BIG_ENDIAN/LITTLE_ENDIAN are not defined" +#endif } #define ntohl htonl @@ -147,6 +155,7 @@ static inline uint16_t htons (x) uint16_t x; { +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) #if BYTE_ORDER == BIG_ENDIAN return x; #elif BYTE_ORDER == LITTLE_ENDIAN @@ -154,6 +163,9 @@ htons (x) #else # error "What kind of system is this?" #endif +#else +#error "BYTE_ORDER/BIG_ENDIAN/LITTLE_ENDIAN are not defined" +#endif } #define ntohs htons diff --git a/configure.ac b/configure.ac index 7b455cd..30bec5e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(portablexdr, 4.0.10) +AC_INIT(portablexdr, 4.0.11) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS([config.h]) @@ -17,7 +17,7 @@ case "$host" in esac AC_SUBST(MINGW_EXTRA_LDFLAGS) -AC_CHECK_HEADERS([arpa/inet.h]) +AC_CHECK_HEADERS([arpa/inet.h sys/param.h]) AC_CHECK_FUNCS([ntohl htonl ntohs htons]) AC_OUTPUT(Makefile) -- 1.8.3.1