From e55696a4f88b63c622bb3a0360f9114d01253e53 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Sat, 22 May 2021 12:31:47 +0200 Subject: Lib: Indirect bitmap for MPLS label allocator --- lib/bitmap.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/bitmap.h') 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 -- cgit v1.2.3