2 * Copyright (c) 2008 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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)) {