mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
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>
This commit is contained in:
parent
0c21e07354
commit
d1d32d6255
4 changed files with 16 additions and 40 deletions
|
@ -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);
|
||||
g_assert(ov1);
|
||||
g_assert(ov2);
|
||||
|
||||
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);
|
||||
bitmap_andnot(tmp, ov1->bitmap, ov2->bitmap, OV_MAXBITS);
|
||||
result = bitmap_empty(tmp, OV_MAXBITS);
|
||||
|
||||
if (!bitmap_empty(removed_bits, OV_MAXBITS)) {
|
||||
bits_were_removed = true;
|
||||
}
|
||||
g_free(tmp);
|
||||
|
||||
g_free(change_mask);
|
||||
g_free(removed_bits);
|
||||
|
||||
return bits_were_removed;
|
||||
return result;
|
||||
}
|
||||
|
||||
void spapr_ovec_cleanup(SpaprOptionVector *ov)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue