From fc2cb74feedf2637e4b2cc153ede7b0726b9a7d3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Nov 2016 11:38:54 -0500 Subject: librhash: Implement bswap_32 as a function even in strict C90 mode We cannot fall back to the macro implementation because some call sites may call it with an argument like `*ptr++` that has side effects. --- Utilities/cmlibrhash/librhash/byte_order.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Utilities/cmlibrhash/librhash/byte_order.h b/Utilities/cmlibrhash/librhash/byte_order.h index 6ed8668..f8330e1 100644 --- a/Utilities/cmlibrhash/librhash/byte_order.h +++ b/Utilities/cmlibrhash/librhash/byte_order.h @@ -103,15 +103,12 @@ static inline uint32_t bswap_32(uint32_t x) { # define bswap_32(x) __builtin_bswap32(x) #elif (_MSC_VER > 1300) && (defined(CPU_IA32) || defined(CPU_X64)) /* MS VC */ # define bswap_32(x) _byteswap_ulong((unsigned long)x) -#elif !defined(__STRICT_ANSI__) +#else /* general bswap_32 definition */ -static inline uint32_t bswap_32(uint32_t x) { +static uint32_t bswap_32(uint32_t x) { x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0x00FF00FF); return (x >> 16) | (x << 16); } -#else -#define bswap_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) #endif /* bswap_32 */ #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) -- cgit v0.12