[Mesa-dev] [PATCH 1/3] util: Add util_bswap64()

Michel Dänzer michel at daenzer.net
Wed Feb 19 18:33:12 PST 2014


On Mit, 2014-02-19 at 15:09 -0800, Tom Stellard wrote:
> ---
>  src/gallium/auxiliary/util/u_math.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
> index b5e0663..49f8bda 100644
> --- a/src/gallium/auxiliary/util/u_math.h
> +++ b/src/gallium/auxiliary/util/u_math.h
> @@ -741,6 +741,16 @@ util_bswap32(uint32_t n)
>  #endif
>  }
>  
> +/**
> + * Reverse byte order of a 64bit word.
> + */
> +static INLINE uint64_t
> +util_bswap64(uint64_t n)
> +{

Please use __builtin_bswap64() when available, as per util_bswap32().


> +   return ((uint64_t)util_bswap32(n & 0xffffffff) << 32) |

There is no need for & 0xffffffff.


> +          util_bswap32((n >> 32));
> +}


-- 
Earthling Michel Dänzer            |                  http://www.amd.com
Libre software enthusiast          |                Mesa and X developer



More information about the mesa-dev mailing list