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