diff --git a/sbitmap.c b/sbitmap.c index e8ebd62fe01c..fbded9089134 100644 --- a/sbitmap.c +++ b/sbitmap.c @@ -89,7 +89,6 @@ static unsigned int __sbitmap_weight(const struct sbitmap_context *sc, bool set) { const ulong sbitmap_word_size = SIZE(sbitmap_word); const ulong w_word_off = OFFSET(sbitmap_word_word); - const ulong w_cleared_off = OFFSET(sbitmap_word_cleared); unsigned int weight = 0; ulong addr = sc->map_addr; @@ -111,7 +110,10 @@ static unsigned int __sbitmap_weight(const struct sbitmap_context *sc, bool set) word = ULONG(sbitmap_word_buf + w_word_off); weight += bitmap_weight(word, depth); } else { - cleared = ULONG(sbitmap_word_buf + w_cleared_off); + if (VALID_MEMBER(sbitmap_word_cleared)) + cleared = ULONG(sbitmap_word_buf + OFFSET(sbitmap_word_cleared)); + else + cleared = 0; weight += bitmap_weight(cleared, depth); } @@ -130,7 +132,10 @@ static unsigned int sbitmap_weight(const struct sbitmap_context *sc) static unsigned int sbitmap_cleared(const struct sbitmap_context *sc) { - return __sbitmap_weight(sc, false); + if (VALID_MEMBER(sbitmap_word_cleared)) /* 5.0 and later */ + return __sbitmap_weight(sc, false); + else + return 0; } static void sbitmap_emit_byte(unsigned int offset, uint8_t byte) @@ -149,7 +154,6 @@ static void sbitmap_bitmap_show(const struct sbitmap_context *sc) { const ulong sbitmap_word_size = SIZE(sbitmap_word); const ulong w_word_off = OFFSET(sbitmap_word_word); - const ulong w_cleared_off = OFFSET(sbitmap_word_cleared); uint8_t byte = 0; unsigned int byte_bits = 0; @@ -169,7 +173,10 @@ static void sbitmap_bitmap_show(const struct sbitmap_context *sc) } word = ULONG(sbitmap_word_buf + w_word_off); - cleared = ULONG(sbitmap_word_buf + w_cleared_off); + if (VALID_MEMBER(sbitmap_word_cleared)) + cleared = ULONG(sbitmap_word_buf + OFFSET(sbitmap_word_cleared)); + else + cleared = 0; word_bits = __map_depth(sc, i); word &= ~cleared; @@ -219,7 +226,6 @@ static void __sbitmap_for_each_set(const struct sbitmap_context *sc, { const ulong sbitmap_word_size = SIZE(sbitmap_word); const ulong w_word_off = OFFSET(sbitmap_word_word); - const ulong w_cleared_off = OFFSET(sbitmap_word_cleared); unsigned int index; unsigned int nr; @@ -245,7 +251,10 @@ static void __sbitmap_for_each_set(const struct sbitmap_context *sc, } w_word = ULONG(sbitmap_word_buf + w_word_off); - w_cleared = ULONG(sbitmap_word_buf + w_cleared_off); + if (VALID_MEMBER(sbitmap_word_cleared)) + w_cleared = ULONG(sbitmap_word_buf + OFFSET(sbitmap_word_cleared)); + else + w_cleared = 0; depth = min(__map_depth(sc, index) - nr, sc->depth - scanned); @@ -297,7 +306,8 @@ static void sbitmap_queue_show(const struct sbitmap_queue_context *sqc, fprintf(fp, "depth = %u\n", sc->depth); fprintf(fp, "busy = %u\n", sbitmap_weight(sc) - sbitmap_cleared(sc)); - fprintf(fp, "cleared = %u\n", sbitmap_cleared(sc)); + if (VALID_MEMBER(sbitmap_word_cleared)) /* 5.0 and later */ + fprintf(fp, "cleared = %u\n", sbitmap_cleared(sc)); fprintf(fp, "bits_per_word = %u\n", 1U << sc->shift); fprintf(fp, "map_nr = %u\n", sc->map_nr); -- 2.27.0