]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/bitmap.h
pkgconfig: define variables relative to ${prefix}/${rootprefix}/${sysconfdir}
[thirdparty/systemd.git] / src / basic / bitmap.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "hashmap.h"
7 #include "macro.h"
8
9 typedef struct Bitmap Bitmap;
10
11 Bitmap *bitmap_new(void);
12 Bitmap *bitmap_copy(Bitmap *b);
13 int bitmap_ensure_allocated(Bitmap **b);
14 void bitmap_free(Bitmap *b);
15
16 int bitmap_set(Bitmap *b, unsigned n);
17 void bitmap_unset(Bitmap *b, unsigned n);
18 bool bitmap_isset(Bitmap *b, unsigned n);
19 bool bitmap_isclear(Bitmap *b);
20 void bitmap_clear(Bitmap *b);
21
22 bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
23
24 bool bitmap_equal(Bitmap *a, Bitmap *b);
25
26 #define BITMAP_FOREACH(n, b, i) \
27 for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); )
28
29 DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);
30
31 #define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)