util/hbitmap.c: Use ctpopl rather than reimplementing a local equivalent
PATCH 1/1 util/hbitmap.c: Use ctpopl rather than reimplementing a local equivalent
The function popcountl() in hbitmap.c is effectively a reimplementation of what host-utils.h provides as ctpopl(). Use ctpopl() directly; this fixes a failure to compile on NetBSD (whose strings.h erroneously exposes a system popcountl() which clashes with this one).
---
We haven't compiled on NetBSD for over a year...
util/hbitmap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
util/hbitmap.c +2 -7
@@ -92,11 +92,6 @@ struct HBitmap {unsigned long *levels[HBITMAP_LEVELS ]; }; -static inline int popcountl (unsigned long l) -{ -return BITS_PER_LONG ==32 ?ctpop32 (l) :ctpop64 (l); -} -/* Advance hbi to the next nonzero word and return it. hbi->pos * is updated. Returns zero if we reach the end of the bitmap. */
@@ -200,14 +195,14 @@ static uint64_t hb_count_between(HBitmap *hb, uint64_t start, uint64_t last)if (pos >= (end >>BITS_PER_LEVEL )) {break ; } - count +=popcountl (cur); + count +=ctpopl (cur); }if (pos == (end >>BITS_PER_LEVEL )) {/* Drop bits representing the END-th and subsequent items. */ int bit = end & (BITS_PER_LONG -1 ); cur &= (1UL << bit) -1 ; - count +=popcountl (cur); + count +=ctpopl (cur); }return count;
Signature · 1 line
1.9.2
Il 04/06/2014 01:41, Peter Maydell ha scritto:
Quoted 37 lines
The function
popcountl()inhbitmap.cis effectively a reimplementation of whathost-utils.hprovides asctpopl(). Usectpopl()directly; this fixes a failure to compile on NetBSD (whosestrings.herroneously exposes a systempopcountl()which clashes with this one).Signed-off-by Peter Maydell <[email protected]>Reported-by Martin Husemann <[email protected]>---
We haven't compiled on NetBSD for over a year...util/hbitmap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)util/hbitmap.c +1
-6@@ -92,11 +92,6 @@ struct HBitmap {unsigned long *levels[HBITMAP_LEVELS ]; }; -static inline int popcountl (unsigned long l) -{ -return BITS_PER_LONG ==32 ?ctpop32 (l) :ctpop64 (l); -} -/* Advance hbi to the next nonzero word and return it. hbi->pos * is updated. Returns zero if we reach the end of the bitmap. */ @@ -200,14 +195,14 @@ static uint64_t hb_count_between(HBitmap *hb, uint64_t start, uint64_t last)if (pos >= (end >>BITS_PER_LEVEL )) {break ; } - count +=popcountl (cur); + count +=ctpopl (cur); }
util/hbitmap.c static uint64_t hb_count_between(HBitmap *hb, uint64_t start, uint64_t last) · line 208
Quoted 10 lines
util/hbitmap.c +1
-1if (pos == (end >>BITS_PER_LEVEL )) {/* Drop bits representing the END-th and subsequent items. */ int bit = end & (BITS_PER_LONG -1 ); cur &= (1UL << bit) -1 ; - count +=popcountl (cur); + count +=ctpopl (cur); }return count;