]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - lib/bitmap.c
Merge tag 'for-linus-5.4-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / lib / bitmap.c
index bbe2589e8497d147447d3528f2787e8ac748bdcc..f9e834841e941826392ebc6ccf5650186bf657fd 100644 (file)
@@ -59,6 +59,26 @@ int __bitmap_equal(const unsigned long *bitmap1,
 }
 EXPORT_SYMBOL(__bitmap_equal);
 
+bool __bitmap_or_equal(const unsigned long *bitmap1,
+                      const unsigned long *bitmap2,
+                      const unsigned long *bitmap3,
+                      unsigned int bits)
+{
+       unsigned int k, lim = bits / BITS_PER_LONG;
+       unsigned long tmp;
+
+       for (k = 0; k < lim; ++k) {
+               if ((bitmap1[k] | bitmap2[k]) != bitmap3[k])
+                       return false;
+       }
+
+       if (!(bits % BITS_PER_LONG))
+               return true;
+
+       tmp = (bitmap1[k] | bitmap2[k]) ^ bitmap3[k];
+       return (tmp & BITMAP_LAST_WORD_MASK(bits)) == 0;
+}
+
 void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits)
 {
        unsigned int k, lim = BITS_TO_LONGS(bits);