mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
gallium/util: add u_bit_scan_consecutive_range
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Acked-by: Christian König <christian.koenig@amd.com>
This commit is contained in:
parent
d38a560106
commit
fc292b5821
1 changed files with 20 additions and 0 deletions
|
|
@ -483,6 +483,26 @@ u_bit_scan64(uint64_t *mask)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* For looping over a bitmask when you want to loop over consecutive bits
|
||||
* manually, for example:
|
||||
*
|
||||
* while (mask) {
|
||||
* int start, count, i;
|
||||
*
|
||||
* u_bit_scan_consecutive_range(&mask, &start, &count);
|
||||
*
|
||||
* for (i = 0; i < count; i++)
|
||||
* ... process element (start+i)
|
||||
* }
|
||||
*/
|
||||
static inline void
|
||||
u_bit_scan_consecutive_range(unsigned *mask, int *start, int *count)
|
||||
{
|
||||
*start = ffs(*mask) - 1;
|
||||
*count = ffs(~(*mask >> *start)) - 1;
|
||||
*mask &= ~(((1 << *count) - 1) << *start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return float bits.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue