]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/bitmap.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 typedef struct Bitmap
{
12 size_t bitmaps_allocated
;
15 Bitmap
*bitmap_new(void);
16 Bitmap
*bitmap_copy(Bitmap
*b
);
17 int bitmap_ensure_allocated(Bitmap
**b
);
18 void bitmap_free(Bitmap
*b
);
20 int bitmap_set(Bitmap
*b
, unsigned n
);
21 void bitmap_unset(Bitmap
*b
, unsigned n
);
22 bool bitmap_isset(const Bitmap
*b
, unsigned n
);
23 bool bitmap_isclear(const Bitmap
*b
);
24 void bitmap_clear(Bitmap
*b
);
26 bool bitmap_iterate(const Bitmap
*b
, Iterator
*i
, unsigned *n
);
28 bool bitmap_equal(const Bitmap
*a
, const Bitmap
*b
);
30 #define _BITMAP_FOREACH(n, b, i) \
31 for (Iterator i = {}; bitmap_iterate((b), &i, (unsigned*)&(n)); )
32 #define BITMAP_FOREACH(n, b) \
33 _BITMAP_FOREACH(n, b, UNIQ_T(i, UNIQ))
35 DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap
*, bitmap_free
);
37 #define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)