diff options
author | Keith Whitwell <keithw@vmware.com> | 2009-08-21 18:07:35 +0100 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-08-21 18:07:35 +0100 |
commit | b1cc196e6d18494348c2974aad5d85d1b8281ce0 (patch) | |
tree | b344c986ad0a3ea5195bff5fdb417e2eba8a3472 /src/gallium/auxiliary | |
parent | 00c835918259f8d41c3f74eca679a972713b11b2 (diff) |
util: add util_is_power_of_two function
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index d30fa3c2d5..163522d3ef 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -273,6 +273,14 @@ util_fast_pow(float x, float y) return util_fast_exp2(util_fast_log2(x) * y); } +/* Note that this counts zero as a power of two. + */ +static INLINE boolean +util_is_power_of_two( unsigned v ) +{ + return (v & (v-1)) == 0; +} + /** |