Author: hselasky
Date: Fri Jul 10 12:06:18 2020
New Revision: 363078
URL: https://svnweb.freebsd.org/changeset/base/363078

Log:
  Implement the bitmap_subset() function in the LinuxKPI. This function
  checks if the bitmap pointed to by the first argument is a subset of
  the bitmap pointed to by the second argument. The function returns one
  on success and zero on failure.
  
  MFC after:            1 week
  Sponsored by:         Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/bitmap.h

Modified: head/sys/compat/linuxkpi/common/include/linux/bitmap.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/bitmap.h      Fri Jul 10 
11:27:54 2020        (r363077)
+++ head/sys/compat/linuxkpi/common/include/linux/bitmap.h      Fri Jul 10 
12:06:18 2020        (r363078)
@@ -244,6 +244,28 @@ bitmap_equal(const unsigned long *pa,
        return (1);
 }
 
+static inline int
+bitmap_subset(const unsigned long *pa,
+    const unsigned long *pb, unsigned size)
+{
+       const unsigned end = BIT_WORD(size);
+       const unsigned tail = size & (BITS_PER_LONG - 1);
+       unsigned i;
+
+       for (i = 0; i != end; i++) {
+               if (pa[i] & ~pb[i])
+                       return (0);
+       }
+
+       if (tail) {
+               const unsigned long mask = BITMAP_LAST_WORD_MASK(tail);
+
+               if (pa[end] & ~pb[end] & mask)
+                       return (0);
+       }
+       return (1);
+}
+
 static inline void
 bitmap_complement(unsigned long *dst, const unsigned long *src,
     const unsigned int size)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to