util: Utility function to check if a number is a power of two.
This commit is contained in:
@@ -340,6 +340,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.
|
||||
|
||||
Reference in New Issue
Block a user