summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nsd/bitset.h
blob: 85ed3bfb16f87002bb9ab85cd0469665752a10e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * bitset.h -- Dynamic bitset.
 *
 * Copyright (c) 2001-2020, NLnet Labs. All rights reserved.
 *
 * See LICENSE for the license.
 *
 */
#ifndef _BITSET_H_
#define _BITSET_H_

#include <assert.h>
#include <limits.h>
#include <string.h>

typedef struct nsd_bitset nsd_bitset_type;

struct nsd_bitset {
	size_t size; /** Number of available bits in the set */
	unsigned char bits[];
};

size_t nsd_bitset_size(size_t bits);

void nsd_bitset_zero(struct nsd_bitset *bset);

void nsd_bitset_init(struct nsd_bitset *bset, size_t bits);

int nsd_bitset_isset(struct nsd_bitset *bset, size_t bit);

void nsd_bitset_set(struct nsd_bitset *bset, size_t bit);

void nsd_bitset_unset(struct nsd_bitset *bset, size_t bit);

void nsd_bitset_or(
	struct nsd_bitset *destset,
	struct nsd_bitset *srcset1,
	struct nsd_bitset *srcset2);

#endif /* _BITSET_H_ */