summaryrefslogtreecommitdiff
path: root/kern/bitmap.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2014-05-05 21:49:58 +0200
committerRichard Braun <rbraun@sceen.net>2014-05-05 21:49:58 +0200
commitd8580cf84d3040956bdf8d799b02ad060b144ed9 (patch)
treed6c32f02a56a99617f5b98a99165076cc3dcc4f3 /kern/bitmap.h
parenta67386802e26cd9ea613bf5bdf385f5b3d3645ea (diff)
kern/bitmap: add cmp/and/or/xor operations
Diffstat (limited to 'kern/bitmap.h')
-rw-r--r--kern/bitmap.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/kern/bitmap.h b/kern/bitmap.h
index 28e51c35..8c5980a1 100644
--- a/kern/bitmap.h
+++ b/kern/bitmap.h
@@ -31,6 +31,8 @@
#define BITMAP_DECLARE(name, nr_bits) unsigned long name[BITMAP_LONGS(nr_bits)]
+int bitmap_cmp(const unsigned long *a, const unsigned long *b, int nr_bits);
+
static inline void
bitmap_zero(unsigned long *bm, int nr_bits)
{
@@ -103,6 +105,39 @@ bitmap_test(const unsigned long *bm, int bit)
return ((*bm & bitmap_mask(bit)) != 0);
}
+static inline void
+bitmap_and(unsigned long *a, const unsigned long *b, int nr_bits)
+{
+ int i, n;
+
+ n = BITMAP_LONGS(nr_bits);
+
+ for (i = 0; i < n; i++)
+ a[i] &= b[i];
+}
+
+static inline void
+bitmap_or(unsigned long *a, const unsigned long *b, int nr_bits)
+{
+ int i, n;
+
+ n = BITMAP_LONGS(nr_bits);
+
+ for (i = 0; i < n; i++)
+ a[i] |= b[i];
+}
+
+static inline void
+bitmap_xor(unsigned long *a, const unsigned long *b, int nr_bits)
+{
+ int i, n;
+
+ n = BITMAP_LONGS(nr_bits);
+
+ for (i = 0; i < n; i++)
+ a[i] ^= b[i];
+}
+
static inline int
bitmap_find_next(const unsigned long *bm, int nr_bits, int bit)
{