From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> The bitmap_diff_nonzero() checks if the 'self' bitmap contains any bits that are not on in the 'other' bitmap. Also, delete the declaration of bitmap_is_subset() as it is not used or implemented. Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> Signed-off-by: Taylor Blau <me@xxxxxxxxxxxx> --- ewah/bitmap.c | 24 ++++++++++++++++++++++++ ewah/ewok.h | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ewah/bitmap.c b/ewah/bitmap.c index eb7e2539be..e2ebeac0e5 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -200,6 +200,30 @@ int bitmap_equals(struct bitmap *self, struct bitmap *other) return 1; } +int bitmap_diff_nonzero(struct bitmap *self, struct bitmap *other) +{ + struct bitmap *small; + size_t i; + + if (self->word_alloc < other->word_alloc) { + small = self; + } else { + small = other; + + for (i = other->word_alloc; i < self->word_alloc; i++) { + if (self->words[i] != 0) + return 1; + } + } + + for (i = 0; i < small->word_alloc; i++) { + if ((self->words[i] & ~other->words[i])) + return 1; + } + + return 0; +} + void bitmap_reset(struct bitmap *bitmap) { memset(bitmap->words, 0x0, bitmap->word_alloc * sizeof(eword_t)); diff --git a/ewah/ewok.h b/ewah/ewok.h index 1fc555e672..156c71d06d 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -180,7 +180,7 @@ int bitmap_get(struct bitmap *self, size_t pos); void bitmap_reset(struct bitmap *self); void bitmap_free(struct bitmap *self); int bitmap_equals(struct bitmap *self, struct bitmap *other); -int bitmap_is_subset(struct bitmap *self, struct bitmap *super); +int bitmap_diff_nonzero(struct bitmap *self, struct bitmap *other); struct ewah_bitmap * bitmap_to_ewah(struct bitmap *bitmap); struct bitmap *ewah_to_bitmap(struct ewah_bitmap *ewah); -- 2.29.2.312.gabc4d358d8