summaryrefslogtreecommitdiff
path: root/lib/bitmap.h
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2021-05-22 12:31:47 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-10-04 13:01:21 +0200
commite55696a4f88b63c622bb3a0360f9114d01253e53 (patch)
tree78625ec44c68fd52d46b50de63ff6501cea59e42 /lib/bitmap.h
parent21213be523baa7f2cbf0feaa617f265c55e9b17a (diff)
Lib: Indirect bitmap for MPLS label allocator
Diffstat (limited to 'lib/bitmap.h')
-rw-r--r--lib/bitmap.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/bitmap.h b/lib/bitmap.h
index 0093cd18..4d2dc2a8 100644
--- a/lib/bitmap.h
+++ b/lib/bitmap.h
@@ -60,4 +60,25 @@ void hmap_clear(struct hmap *b, uint n);
u32 hmap_first_zero(struct hmap *b);
void hmap_check(struct hmap *b);
+
+struct lmap
+{
+ slab *slab;
+ uint size;
+ u32 **data;
+ u32 *root;
+};
+
+static inline uint lmap_max(struct lmap *b)
+{ return b->size << 10; }
+
+void lmap_init(struct lmap *b, pool *p);
+void lmap_free(struct lmap *b);
+int lmap_test(struct lmap *b, uint n);
+void lmap_set(struct lmap *b, uint n);
+void lmap_clear(struct lmap *b, uint n);
+uint lmap_first_zero(struct lmap *b);
+uint lmap_first_zero_in_range(struct lmap *b, uint lo, uint hi);
+void lmap_check(struct lmap *b);
+
#endif