diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-09-07 14:21:51 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2009-09-07 15:02:06 +0100 |
commit | 6b129a82223c674d3e11472aa8abe07fd741764a (patch) | |
tree | 3a977315162055d02478faaf3f7adcd0d67332a8 /src/gallium | |
parent | 8be72bb7646d430e66cb36e09c13c13bee030d53 (diff) | |
download | external_mesa3d-6b129a82223c674d3e11472aa8abe07fd741764a.zip external_mesa3d-6b129a82223c674d3e11472aa8abe07fd741764a.tar.gz external_mesa3d-6b129a82223c674d3e11472aa8abe07fd741764a.tar.bz2 |
util: Utility function to check if a number is a power of two.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 4c6c2bc..b12c97d 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -341,6 +341,16 @@ util_is_inf_or_nan(float x) /** + * Test whether x is a power of two. + */ +static INLINE boolean +util_is_pot(unsigned x) +{ + return (x & (x - 1)) == 0; +} + + +/** * Find first bit set in word. Least significant bit is 1. * Return 0 if no bits set. */ |