util: Add function util_is_power_of_two_nonzero64 in bitscan.h

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23732>
This commit is contained in:
Yonggang Luo 2023-06-20 09:48:26 +08:00 committed by Marge Bot
parent 3fc727b346
commit 3aa929ca46

View file

@ -168,6 +168,17 @@ util_is_power_of_two_nonzero(unsigned v)
#endif
}
/* Determine if an uint64_t value is a power of two.
*
* \note
* Zero is \b not treated as a power of two.
*/
static inline bool
util_is_power_of_two_nonzero64(uint64_t v)
{
return v != 0 && IS_POT(v);
}
/* For looping over a bitmask when you want to loop over consecutive bits
* manually, for example:
*