summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-09 16:38:54 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-10 13:29:36 (GMT)
commitfc2cb74feedf2637e4b2cc153ede7b0726b9a7d3 (patch)
tree27c0dbfab4a2246c2ae5b0074461031125b7abf5
parent0bd333bc2eb6590f939ccabb7caf102f13443600 (diff)
downloadCMake-fc2cb74feedf2637e4b2cc153ede7b0726b9a7d3.zip
CMake-fc2cb74feedf2637e4b2cc153ede7b0726b9a7d3.tar.gz
CMake-fc2cb74feedf2637e4b2cc153ede7b0726b9a7d3.tar.bz2
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.
-rw-r--r--Utilities/cmlibrhash/librhash/byte_order.h7
1 files 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)