util: add util_is_power_of_two function

This commit is contained in:
Keith Whitwell 2009-08-21 18:07:35 +01:00
parent 00c8359182
commit b1cc196e6d

View file

@ -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;
}
/**