2 * Copyright (c) 2008 Nicira Networks.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 /* Sets 'count' consecutive bits in 'bitmap', starting at bit offset 'start',
24 bitmap_set_multiple(unsigned long *bitmap, size_t start, size_t count,
27 for (; count && start % BITMAP_ULONG_BITS; count--) {
28 bitmap_set(bitmap, start++, value);
30 for (; count >= BITMAP_ULONG_BITS; count -= BITMAP_ULONG_BITS) {
31 *bitmap_unit__(bitmap, start) = -(unsigned long) value;
32 start += BITMAP_ULONG_BITS;
34 for (; count; count--) {
35 bitmap_set(bitmap, start++, value);
39 /* Compares the 'n' bits in bitmaps 'a' and 'b'. Returns true if all bits are
40 * equal, false otherwise. */
42 bitmap_equal(const unsigned long *a, const unsigned long *b, size_t n)
46 if (memcmp(a, b, n / BITMAP_ULONG_BITS * sizeof(unsigned long))) {
49 for (i = ROUND_DOWN(n, BITMAP_ULONG_BITS); i < n; i++) {
50 if (bitmap_is_set(a, i) != bitmap_is_set(b, i)) {