util/u_math: Implement a logbase2 function for unsigned long

v2 (Karol Herbst <kherbst@redhat.com>):
* removed unneeded ll
* ll -> ull

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
Pierre Moreau
2017-05-06 17:52:59 +02:00
committed by Karol Herbst
parent 539aa604a0
commit 03f592a164
2 changed files with 66 additions and 0 deletions
+11
View File
@@ -123,6 +123,17 @@ util_is_power_of_two_or_zero(unsigned v)
return (v & (v - 1)) == 0;
}
/* Determine if an uint64_t value is a power of two.
*
* \note
* Zero is treated as a power of two.
*/
static inline bool
util_is_power_of_two_or_zero64(uint64_t v)
{
return (v & (v - 1)) == 0;
}
/* Determine if an unsigned value is a power of two.
*
* \note