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