From a7669183ad01cf2999a1d2001d867ea5d23aa0ed Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 11 Aug 2010 16:10:09 +0200 Subject: [PATCH] Use HAVE_LITTLE_ENDIAN in crc32 code --- bacula/src/lib/crc32.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bacula/src/lib/crc32.c b/bacula/src/lib/crc32.c index 74bd8a14cc..efd3075013 100644 --- a/bacula/src/lib/crc32.c +++ b/bacula/src/lib/crc32.c @@ -69,21 +69,20 @@ main() #include "bacula.h" -#ifndef __BYTE_ORDER -#error __BYTE_ORDER not defined! +#if !defined(HAVE_LITTLE_ENDIAN) && !defined(HAVE_BIG_ENDIAN) +#error Either HAVE_LITTLE_ENDIAN or HAVE_BIG_ENDIAN must be defined! #endif -#define bswab32(x) \ - ((uint32_t)( \ - (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ - (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ - (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24) )) - /* tole == To Little Endian */ -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define tole(x) x +#ifdef HAVE_BIG_ENDIAN +#define tole(x) \ + ((uint32_t)( \ + (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24) )) + #else -#define tole(x) bswab32(x) +#define tole(x) x #endif /* -- 2.39.5