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:
Li, Fei1 2018-08-16 23:31:23 +08:00 committed by lijinxia
parent 538173838d
commit 709cd5749e

View File

@ -129,6 +129,22 @@ static inline uint16_t ffz64(uint64_t 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.
*