From d8580cf84d3040956bdf8d799b02ad060b144ed9 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Mon, 5 May 2014 21:49:58 +0200 Subject: kern/bitmap: add cmp/and/or/xor operations --- kern/bitmap.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'kern/bitmap.h') 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) { -- cgit v1.2.3