@@ -233,10 +233,9 @@ bitmap_set(
return res;
}
-#if 0 /* Unused, provided for completeness. */
/* Clear a region of bits. */
-int
-bitmap_clear(
+static int
+__bitmap_clear(
struct bitmap *bmap,
uint64_t start,
uint64_t len)
@@ -251,8 +250,8 @@ bitmap_clear(
uint64_t new_length;
struct avl64node *node;
int stat;
+ int ret = 0;
- pthread_mutex_lock(&bmap->bt_lock);
/* Find any existing nodes over that range. */
avl64_findranges(bmap->bt_tree, start, start + len, &firstn, &lastn);
@@ -312,10 +311,24 @@ bitmap_clear(
}
out:
- pthread_mutex_unlock(&bmap->bt_lock);
return ret;
}
-#endif
+
+/* Clear a region of bits. */
+int
+bitmap_clear(
+ struct bitmap *bmap,
+ uint64_t start,
+ uint64_t length)
+{
+ int res;
+
+ pthread_mutex_lock(&bmap->bt_lock);
+ res = __bitmap_clear(bmap, start, length);
+ pthread_mutex_unlock(&bmap->bt_lock);
+
+ return res;
+}
/* Iterate the set regions of this bitmap. */
int
@@ -14,6 +14,7 @@ struct bitmap {
int bitmap_alloc(struct bitmap **bmap);
void bitmap_free(struct bitmap **bmap);
int bitmap_set(struct bitmap *bmap, uint64_t start, uint64_t length);
+int bitmap_clear(struct bitmap *bmap, uint64_t start, uint64_t length);
int bitmap_iterate(struct bitmap *bmap, int (*fn)(uint64_t, uint64_t, void *),
void *arg);
int bitmap_iterate_range(struct bitmap *bmap, uint64_t start, uint64_t length,