Skip to content
Snippets Groups Projects
Commit 7189d62c authored by Brad King's avatar Brad King
Browse files

librhash: Use __builtin_bswap{32,64} on Clang

parent af7ebf8a
No related branches found
No related tags found
No related merge requests found
......@@ -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__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment