mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-22 01:00:47 +02:00
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:
parent
3fc727b346
commit
3aa929ca46
1 changed files with 11 additions and 0 deletions
|
|
@ -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:
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue