diff options
| author | Yury Norov <ynorov@nvidia.com> | 2026-03-01 20:11:55 -0500 |
|---|---|---|
| committer | Yury Norov <ynorov@nvidia.com> | 2026-04-01 20:03:07 -0400 |
| commit | d57e74f10461b80c77d1678f646720f616fb8553 (patch) | |
| tree | 8b07ccd943130cf5a391cbb65168e3da6acef711 /lib/bitmap.c | |
| parent | 95d324fb1b48434f4c659e4c245c3bdeecdff22c (diff) | |
| download | linux-next-d57e74f10461b80c77d1678f646720f616fb8553.tar.gz linux-next-d57e74f10461b80c77d1678f646720f616fb8553.zip | |
bitmap: introduce bitmap_weighted_xor()
The function helps to XOR bitmaps and calculate Hamming weight of
the result in one pass.
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Yury Norov <ynorov@nvidia.com>
Diffstat (limited to 'lib/bitmap.c')
| -rw-r--r-- | lib/bitmap.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 1b897f94e0ff..b9bfa157e095 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -363,6 +363,13 @@ unsigned int __bitmap_weighted_or(unsigned long *dst, const unsigned long *bitma } EXPORT_SYMBOL(__bitmap_weighted_or); +unsigned int __bitmap_weighted_xor(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, unsigned int bits) +{ + return BITMAP_WEIGHT(({dst[idx] = bitmap1[idx] ^ bitmap2[idx]; dst[idx]; }), bits); +} +EXPORT_SYMBOL(__bitmap_weighted_xor); + void __bitmap_set(unsigned long *map, unsigned int start, int len) { unsigned long *p = map + BIT_WORD(start); |
