mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
gallium/util: add u_bit_consecutive for generating a consecutive range of bits
There are some undefined behavior subtleties, so having a function to match the u_bit_scan_consecutive_range makes sense. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
504df3a1d7
commit
91fb4bb2e9
1 changed files with 12 additions and 0 deletions
|
|
@ -545,6 +545,18 @@ u_bit_scan_consecutive_range64(uint64_t *mask, int *start, int *count)
|
|||
*mask &= ~(((1llu << *count) - 1) << *start);
|
||||
}
|
||||
|
||||
/* Returns a bitfield in which the first count bits starting at start are
|
||||
* set.
|
||||
*/
|
||||
static inline unsigned
|
||||
u_bit_consecutive(unsigned start, unsigned count)
|
||||
{
|
||||
assert(start + count <= 32);
|
||||
if (count == 32)
|
||||
return ~0;
|
||||
return ((1u << count) - 1) << start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return float bits.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue