diff options
author | Pierre Moreau <[email protected]> | 2017-05-06 17:52:59 +0200 |
---|---|---|
committer | Karol Herbst <[email protected]> | 2018-05-29 13:37:45 +0200 |
commit | 03f592a164fa95abbc839dc9820d2ef9fdd21edd (patch) | |
tree | 02a0c0afa36ef2dfa7bb923216fb81392ebfb072 /src/util | |
parent | 539aa604a0bc565481d1d38b327879a294feeec6 (diff) |
util/u_math: Implement a logbase2 function for unsigned long
v2 (Karol Herbst <[email protected]>):
* removed unneeded ll
* ll -> ull
Signed-off-by: Karol Herbst <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/bitscan.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/bitscan.h b/src/util/bitscan.h index 5cc75f0beba..dc89ac93f28 100644 --- a/src/util/bitscan.h +++ b/src/util/bitscan.h @@ -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 |