diff options
author | Christoph Bumiller <[email protected]> | 2009-11-26 16:58:59 +0100 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2009-11-27 21:28:56 +0100 |
commit | e65258abf52bd1923a547f76bd7346bf5ed1c5c6 (patch) | |
tree | a6b5ef73c22bbfb1e79455c009562b135bca88bf /src/gallium | |
parent | 7fa1bcc05a237365e5ea09512453f29a91c7a141 (diff) |
gallium/util: added util_bswap32()
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index b7fc0586f39..7e75702701d 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -511,6 +511,23 @@ util_bitcount(unsigned n) /** + * Reverse byte order of a 32 bit word. + */ +static INLINE uint32_t +util_bswap32(uint32_t n) +{ +#if defined(PIPE_CC_GCC) + return __builtin_bswap32(n); +#else + return (n >> 24) | + ((n >> 8) & 0x0000ff00) | + ((n << 8) & 0x00ff0000) | + (n << 24); +#endif +} + + +/** * Clamp X to [MIN, MAX]. * This is a macro to allow float, int, uint, etc. types. */ |