2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2015-07-13 19:47:26 +02:00
|
|
|
#pragma once
|
|
|
|
|
2015-11-30 21:43:37 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2015-07-16 14:06:11 +02:00
|
|
|
#include "hashmap.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "macro.h"
|
2015-07-13 19:47:26 +02:00
|
|
|
|
|
|
|
typedef struct Bitmap Bitmap;
|
|
|
|
|
|
|
|
Bitmap *bitmap_new(void);
|
2016-06-20 21:24:46 +02:00
|
|
|
Bitmap *bitmap_copy(Bitmap *b);
|
2015-07-13 19:47:26 +02:00
|
|
|
int bitmap_ensure_allocated(Bitmap **b);
|
2016-06-20 21:24:46 +02:00
|
|
|
void bitmap_free(Bitmap *b);
|
2015-07-13 19:47:26 +02:00
|
|
|
|
|
|
|
int bitmap_set(Bitmap *b, unsigned n);
|
|
|
|
void bitmap_unset(Bitmap *b, unsigned n);
|
|
|
|
bool bitmap_isset(Bitmap *b, unsigned n);
|
|
|
|
bool bitmap_isclear(Bitmap *b);
|
|
|
|
void bitmap_clear(Bitmap *b);
|
|
|
|
|
2015-07-16 14:06:11 +02:00
|
|
|
bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
|
2015-07-13 19:47:26 +02:00
|
|
|
|
|
|
|
bool bitmap_equal(Bitmap *a, Bitmap *b);
|
|
|
|
|
2015-07-16 14:06:11 +02:00
|
|
|
#define BITMAP_FOREACH(n, b, i) \
|
|
|
|
for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); )
|
2015-07-13 19:47:26 +02:00
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free);
|
|
|
|
|
|
|
|
#define _cleanup_bitmap_free_ _cleanup_(bitmap_freep)
|