mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
gallium/util: added util_bswap32()
This commit is contained in:
parent
7fa1bcc05a
commit
e65258abf5
1 changed files with 17 additions and 0 deletions
|
|
@ -510,6 +510,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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue