]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - src/basic/bitmap.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / basic / bitmap.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: LGPL-2.1+ */
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
23#include <stdbool.h>
24
25#include "hashmap.h"
26#include "macro.h"
27
28typedef struct Bitmap Bitmap;
29
30Bitmap *bitmap_new(void);
31Bitmap *bitmap_copy(Bitmap *b);
32int bitmap_ensure_allocated(Bitmap **b);
33void bitmap_free(Bitmap *b);
34
35int bitmap_set(Bitmap *b, unsigned n);
36void bitmap_unset(Bitmap *b, unsigned n);
37bool bitmap_isset(Bitmap *b, unsigned n);
38bool bitmap_isclear(Bitmap *b);
39void bitmap_clear(Bitmap *b);
40
41bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
42
43bool 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
48DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);
49
50#define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)