]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/bitmap.h
nspawn-oci: use SYNTHETIC_ERRNO
[thirdparty/systemd.git] / src / shared / bitmap.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
5ffa42cb
TG
2#pragma once
3
11c3a366
TA
4#include <stdbool.h>
5
cb57dd41 6#include "hashmap.h"
71d35b6b 7#include "macro.h"
5ffa42cb
TG
8
9typedef struct Bitmap Bitmap;
10
11Bitmap *bitmap_new(void);
17c8de63 12Bitmap *bitmap_copy(Bitmap *b);
5ffa42cb 13int bitmap_ensure_allocated(Bitmap **b);
17c8de63 14void bitmap_free(Bitmap *b);
5ffa42cb
TG
15
16int bitmap_set(Bitmap *b, unsigned n);
17void bitmap_unset(Bitmap *b, unsigned n);
18bool bitmap_isset(Bitmap *b, unsigned n);
19bool bitmap_isclear(Bitmap *b);
20void bitmap_clear(Bitmap *b);
21
cb57dd41 22bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
5ffa42cb
TG
23
24bool bitmap_equal(Bitmap *a, Bitmap *b);
25
cb57dd41
TG
26#define BITMAP_FOREACH(n, b, i) \
27 for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); )
5ffa42cb
TG
28
29DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);
30
31#define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)