From 49ada7a2c3f664aa2c3e17e2adf4abaf2a04d17d Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 20 Apr 2010 13:58:22 +0000 Subject: [PATCH] Add dm_bitset_equal to libdevmapper. --- WHATS_NEW_DM | 2 +- libdm/.exported_symbols | 1 + libdm/datastruct/bitset.c | 11 +++++++++++ libdm/libdevmapper.h | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 657847728..60725a8a4 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,6 +1,6 @@ Version 1.02.47 - ================================= - Add dm_bit_and. + Add dm_bit_and and dm_bitset_equal to libdevmapper. Simplify dm_bitset_create. Speed up dm_bit_get_next with ffs(). diff --git a/libdm/.exported_symbols b/libdm/.exported_symbols index 67962aeea..73ee5bd7d 100644 --- a/libdm/.exported_symbols +++ b/libdm/.exported_symbols @@ -109,6 +109,7 @@ dm_pool_strndup dm_pool_zalloc dm_bitset_create dm_bitset_destroy +dm_bitset_equal dm_bit_and dm_bit_union dm_bit_get_first diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c index 6dd5952a6..9b8aff933 100644 --- a/libdm/datastruct/bitset.c +++ b/libdm/datastruct/bitset.c @@ -42,6 +42,17 @@ void dm_bitset_destroy(dm_bitset_t bs) dm_free(bs); } +int dm_bitset_equal(dm_bitset_t in1, dm_bitset_t in2) +{ + int i; + + for (i = (in1[0] / DM_BITS_PER_INT) + 1; i; i--) + if (in1[i] != in2[i]) + return 0; + + return 1; +} + void dm_bit_and(dm_bitset_t out, dm_bitset_t in1, dm_bitset_t in2) { int i; diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 243577421..0ee23fbb5 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -600,6 +600,8 @@ typedef uint32_t *dm_bitset_t; dm_bitset_t dm_bitset_create(struct dm_pool *mem, unsigned num_bits); void dm_bitset_destroy(dm_bitset_t bs); +int dm_bitset_equal(dm_bitset_t in1, dm_bitset_t in2); + void dm_bit_and(dm_bitset_t out, dm_bitset_t in1, dm_bitset_t in2); void dm_bit_union(dm_bitset_t out, dm_bitset_t in1, dm_bitset_t in2); int dm_bit_get_first(dm_bitset_t bs);