]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/bitmap.h
Merge pull request #653 from dvdhrm/bus-gold
[thirdparty/systemd.git] / src / basic / bitmap.h
CommitLineData
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
27typedef struct Bitmap Bitmap;
28
29Bitmap *bitmap_new(void);
17c8de63 30Bitmap *bitmap_copy(Bitmap *b);
5ffa42cb 31int bitmap_ensure_allocated(Bitmap **b);
17c8de63 32void bitmap_free(Bitmap *b);
5ffa42cb
TG
33
34int bitmap_set(Bitmap *b, unsigned n);
35void bitmap_unset(Bitmap *b, unsigned n);
36bool bitmap_isset(Bitmap *b, unsigned n);
37bool bitmap_isclear(Bitmap *b);
38void bitmap_clear(Bitmap *b);
39
cb57dd41 40bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
5ffa42cb
TG
41
42bool 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
47DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);
48
49#define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)