diff options
author | Tom Stellard <[email protected]> | 2014-02-19 14:17:33 -0800 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2014-02-24 12:56:27 -0800 |
commit | a9f88e2ae8632189b08f01e8a4166020df8d0d38 (patch) | |
tree | ec2bf597b4aeedecbe9de077228d6c0e8a46b536 /src | |
parent | f8ba0f55d32274eb2fe0e0060658dc2284569dd4 (diff) |
util: Add util_bswap64() v3
v2:
- Use __builtin_bswap64()
- Remove unnecessary mask
- Add util_le64_to_cpu() helper
v3:
- Remove unnecessary AC_SUBST
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index b0f0e3dbb8e..0f498bc1531 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -717,9 +717,11 @@ util_bitcount(unsigned n) */ #ifdef PIPE_ARCH_BIG_ENDIAN +#define util_le64_to_cpu(x) util_bswap64(x) #define util_le32_to_cpu(x) util_bswap32(x) #define util_le16_to_cpu(x) util_bswap16(x) #else +#define util_le64_to_cpu(x) (x) #define util_le32_to_cpu(x) (x) #define util_le16_to_cpu(x) (x) #endif @@ -742,6 +744,20 @@ util_bswap32(uint32_t n) #endif } +/** + * Reverse byte order of a 64bit word. + */ +static INLINE uint64_t +util_bswap64(uint64_t n) +{ +#if defined(HAVE___BUILTIN_BSWAP64) + return __builtin_bswap64(n); +#else + return ((uint64_t)util_bswap32(n) << 32) | + util_bswap32((n >> 32)); +#endif +} + /** * Reverse byte order of a 16 bit word. |