diff options
author | Brad King <brad.king@kitware.com> | 2016-11-08 16:32:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-10 13:28:57 (GMT) |
commit | 7189d62c32e6f53dab5637f928917e59055f5e41 (patch) | |
tree | 7c6577498945fea5dadcc239b4d4b7d424766a14 | |
parent | af7ebf8ad3b2b773dfe636a189a82998b1dc63e1 (diff) | |
download | CMake-7189d62c32e6f53dab5637f928917e59055f5e41.zip CMake-7189d62c32e6f53dab5637f928917e59055f5e41.tar.gz CMake-7189d62c32e6f53dab5637f928917e59055f5e41.tar.bz2 |
librhash: Use __builtin_bswap{32,64} on Clang
-rw-r--r-- | Utilities/cmlibrhash/librhash/byte_order.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Utilities/cmlibrhash/librhash/byte_order.h b/Utilities/cmlibrhash/librhash/byte_order.h index 59a6c23..a43906c 100644 --- a/Utilities/cmlibrhash/librhash/byte_order.h +++ b/Utilities/cmlibrhash/librhash/byte_order.h @@ -85,6 +85,10 @@ void rhash_swap_copy_str_to_u64(void* to, int index, const void* from, size_t le void rhash_swap_copy_u64_to_str(void* to, const void* from, size_t length); void rhash_u32_mem_swap(unsigned *p, int length_in_u32); +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + /* define bswap_32 */ #if defined(__GNUC__) && defined(CPU_IA32) && !defined(__i386__) /* for intel x86 CPU */ @@ -95,6 +99,8 @@ static inline uint32_t bswap_32(uint32_t x) { #elif defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) /* for GCC >= 4.3 */ # define bswap_32(x) __builtin_bswap32(x) +#elif defined(__clang__) && __has_builtin(__builtin_bswap32) +# 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__) @@ -110,6 +116,8 @@ static inline uint32_t bswap_32(uint32_t x) { #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) # define bswap_64(x) __builtin_bswap64(x) +#elif defined(__clang__) && __has_builtin(__builtin_bswap64) +# define bswap_64(x) __builtin_bswap64(x) #elif (_MSC_VER > 1300) && (defined(CPU_IA32) || defined(CPU_X64)) /* MS VC */ # define bswap_64(x) _byteswap_uint64((__int64)x) #elif !defined(__STRICT_ANSI__) |