From: Bart Van Assche Date: Mon, 14 Apr 2008 16:10:01 +0000 (+0000) Subject: Added bm_compare(). X-Git-Tag: svn/VALGRIND_3_4_0~735 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16610d7ddbc329d86b350f44cd48067dd718e061;p=thirdparty%2Fvalgrind.git Added bm_compare(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7872 --- diff --git a/exp-drd/drd_bitmap.c b/exp-drd/drd_bitmap.c index fed709187a..e89cb2367d 100644 --- a/exp-drd/drd_bitmap.c +++ b/exp-drd/drd_bitmap.c @@ -745,6 +745,52 @@ Bool bm_store_has_conflict_with(const struct bitmap* const bm, return bm_has_conflict_with(bm, a1, a2, eStore); } +/** Return true if the two bitmaps *lhs and *rhs are identical, and false + * if not. + */ +Bool bm_compare(struct bitmap* const lhs, + const struct bitmap* const rhs) +{ + struct bitmap2* bm2l; + struct bitmap2ref* bm2l_ref; + struct bitmap2* bm2r; + const struct bitmap2ref* bm2r_ref; + + VG_(OSetGen_ResetIter)(lhs->oset); + VG_(OSetGen_ResetIter)(rhs->oset); + + for ( ; (bm2l_ref = VG_(OSetGen_Next)(lhs->oset)) != 0; ) + { + bm2l = bm2l_ref->bm2; + tl_assert(bm2l); + tl_assert(bm_has_any_access(lhs, + bm2l->addr << ADDR0_BITS, + (bm2l->addr + 1) << ADDR0_BITS)); + bm2r_ref = VG_(OSetGen_Next)(rhs->oset); + if (bm2r_ref == 0) + return False; + bm2r = bm2r_ref->bm2; + tl_assert(bm2r); + tl_assert(bm_has_any_access(rhs, + bm2r->addr << ADDR0_BITS, + (bm2r->addr + 1) << ADDR0_BITS)); + if (bm2l->addr != bm2r->addr + || VG_(memcmp)(&bm2l->bm1, &bm2r->bm1, sizeof(bm2l->bm1)) != 0) + { + return False; + } + bm2r = VG_(OSetGen_Next)(rhs->oset); + if (bm2r) + { + tl_assert(bm_has_any_access(rhs, + bm2r->addr << ADDR0_BITS, + (bm2r->addr + 1) << ADDR0_BITS)); + return False; + } + } + return True; +} + void bm_swap(struct bitmap* const bm1, struct bitmap* const bm2) { OSet* const tmp = bm1->oset; diff --git a/exp-drd/pub_drd_bitmap.h b/exp-drd/pub_drd_bitmap.h index d8324e0e84..27e7bf9df1 100644 --- a/exp-drd/pub_drd_bitmap.h +++ b/exp-drd/pub_drd_bitmap.h @@ -102,6 +102,8 @@ Bool bm_store_4_has_conflict_with(const struct bitmap* const bm,const Addr a1); Bool bm_store_8_has_conflict_with(const struct bitmap* const bm,const Addr a1); Bool bm_store_has_conflict_with(const struct bitmap* const bm, const Addr a1, const Addr a2); +Bool bm_compare(struct bitmap* const lhs, + const struct bitmap* const rhs); void bm_swap(struct bitmap* const bm1, struct bitmap* const bm2); void bm_merge2(struct bitmap* const lhs, const struct bitmap* const rhs);