hv: Add a helper to account bitmap weight
Sometimes we need know the number of 1 in one bitmap. This patch provide a inline function bitmap_weight for it. Tracked-On: #3663 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Signed-off-by: Yu Wang <yu1.wang@intel.com> Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
f4ce9cc4a2
commit
d588703976
|
@ -291,4 +291,9 @@ build_bitmap_testandclear(bitmap_test_and_clear_lock, "q", uint64_t, BUS_LOCK)
|
|||
build_bitmap_testandclear(bitmap32_test_and_clear_nolock, "l", uint32_t, "")
|
||||
build_bitmap_testandclear(bitmap32_test_and_clear_lock, "l", uint32_t, BUS_LOCK)
|
||||
|
||||
static inline uint16_t bitmap_weight(uint64_t bits)
|
||||
{
|
||||
return __builtin_popcountl(bits);
|
||||
}
|
||||
|
||||
#endif /* BITS_H*/
|
||||
|
|
Loading…
Reference in New Issue