mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
hv: lib: add ffz64_ex
Add ffz64_ex to find the first zero bit in a uint64_t array. Note: the API is lockless. Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
538173838d
commit
709cd5749e
@ -129,6 +129,22 @@ static inline uint16_t ffz64(uint64_t value)
|
|||||||
return ffs64(~value);
|
return ffs64(~value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find the first zero bit in a uint64_t array.
|
||||||
|
* @pre: the size must be multiple of 64.
|
||||||
|
*/
|
||||||
|
static inline uint64_t ffz64_ex(const uint64_t *addr, uint64_t size)
|
||||||
|
{
|
||||||
|
uint64_t idx;
|
||||||
|
|
||||||
|
for (idx = 0; (idx << 6U) < size; idx++) {
|
||||||
|
if (addr[idx] != ~0UL)
|
||||||
|
return (idx << 6U) + ffz64(addr[idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Counts leading zeros.
|
* Counts leading zeros.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user