aboutsummaryrefslogtreecommitdiff
path: root/hw/ppc/spapr_ovec.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2019-11-29 16:23:21 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2019-12-17 10:39:48 +1100
commitd1d32d6255a395eb071c10aeffb932a3485bdfcd (patch)
tree8f913032bd9385a5c578fd2bf6416e3f35471694 /hw/ppc/spapr_ovec.c
parent0c21e073541cc093b4cb8744640e24f130e6f8ba (diff)
downloadqemu-d1d32d6255a395eb071c10aeffb932a3485bdfcd.zip
qemu-d1d32d6255a395eb071c10aeffb932a3485bdfcd.tar.gz
qemu-d1d32d6255a395eb071c10aeffb932a3485bdfcd.tar.bz2
spapr: Simplify ovec diff
spapr_ovec_diff(ov, old, new) has somewhat complex semantics. ov is set to those bits which are in new but not old, and it returns as a boolean whether or not there are any bits in old but not new. It turns out that both callers only care about the second, not the first. This is basically equivalent to a bitmap subset operation, which is easier to understand and implement. So replace spapr_ovec_diff() with spapr_ovec_subset(). Cc: Mike Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Cedric Le Goater <clg@fr.ibm.com>
Diffstat (limited to 'hw/ppc/spapr_ovec.c')
-rw-r--r--hw/ppc/spapr_ovec.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/hw/ppc/spapr_ovec.c b/hw/ppc/spapr_ovec.c
index 811fadf..0ff6d1a 100644
--- a/hw/ppc/spapr_ovec.c
+++ b/hw/ppc/spapr_ovec.c
@@ -76,31 +76,21 @@ void spapr_ovec_intersect(SpaprOptionVector *ov,
bitmap_and(ov->bitmap, ov1->bitmap, ov2->bitmap, OV_MAXBITS);
}
-/* returns true if options bits were removed, false otherwise */
-bool spapr_ovec_diff(SpaprOptionVector *ov,
- SpaprOptionVector *ov_old,
- SpaprOptionVector *ov_new)
+/* returns true if ov1 has a subset of bits in ov2 */
+bool spapr_ovec_subset(SpaprOptionVector *ov1, SpaprOptionVector *ov2)
{
- unsigned long *change_mask = bitmap_new(OV_MAXBITS);
- unsigned long *removed_bits = bitmap_new(OV_MAXBITS);
- bool bits_were_removed = false;
+ unsigned long *tmp = bitmap_new(OV_MAXBITS);
+ bool result;
- g_assert(ov);
- g_assert(ov_old);
- g_assert(ov_new);
-
- bitmap_xor(change_mask, ov_old->bitmap, ov_new->bitmap, OV_MAXBITS);
- bitmap_and(ov->bitmap, ov_new->bitmap, change_mask, OV_MAXBITS);
- bitmap_and(removed_bits, ov_old->bitmap, change_mask, OV_MAXBITS);
+ g_assert(ov1);
+ g_assert(ov2);
- if (!bitmap_empty(removed_bits, OV_MAXBITS)) {
- bits_were_removed = true;
- }
+ bitmap_andnot(tmp, ov1->bitmap, ov2->bitmap, OV_MAXBITS);
+ result = bitmap_empty(tmp, OV_MAXBITS);
- g_free(change_mask);
- g_free(removed_bits);
+ g_free(tmp);
- return bits_were_removed;
+ return result;
}
void spapr_ovec_cleanup(SpaprOptionVector *ov)