]>
Commit | Line | Data |
---|---|---|
5ffa42cb TG |
1 | #pragma once |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2015 Tom Gundersen | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
11c3a366 TA |
22 | #include <stdbool.h> |
23 | ||
cb57dd41 | 24 | #include "hashmap.h" |
71d35b6b | 25 | #include "macro.h" |
5ffa42cb TG |
26 | |
27 | typedef struct Bitmap Bitmap; | |
28 | ||
29 | Bitmap *bitmap_new(void); | |
17c8de63 | 30 | Bitmap *bitmap_copy(Bitmap *b); |
5ffa42cb | 31 | int bitmap_ensure_allocated(Bitmap **b); |
17c8de63 | 32 | void bitmap_free(Bitmap *b); |
5ffa42cb TG |
33 | |
34 | int bitmap_set(Bitmap *b, unsigned n); | |
35 | void bitmap_unset(Bitmap *b, unsigned n); | |
36 | bool bitmap_isset(Bitmap *b, unsigned n); | |
37 | bool bitmap_isclear(Bitmap *b); | |
38 | void bitmap_clear(Bitmap *b); | |
39 | ||
cb57dd41 | 40 | bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n); |
5ffa42cb TG |
41 | |
42 | bool bitmap_equal(Bitmap *a, Bitmap *b); | |
43 | ||
cb57dd41 TG |
44 | #define BITMAP_FOREACH(n, b, i) \ |
45 | for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); ) | |
5ffa42cb TG |
46 | |
47 | DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free); | |
48 | ||
49 | #define _cleanup_bitmap_free_ _cleanup_(bitmap_freep) |