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:
Shuo A Liu 2019-05-23 13:27:40 +08:00 committed by ACRN System Integration
parent f4ce9cc4a2
commit d588703976
1 changed files with 5 additions and 0 deletions

View File

@ -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*/