1 /* 2 * bitset.h -- Dynamic bitset. 3 * 4 * Copyright (c) 2001-2020, NLnet Labs. All rights reserved. 5 * 6 * See LICENSE for the license. 7 * 8 */ 9 #ifndef BITSET_H 10 #define BITSET_H 11 12 #include <assert.h> 13 #include <limits.h> 14 #include <string.h> 15 16 typedef struct nsd_bitset nsd_bitset_type; 17 18 struct nsd_bitset { 19 size_t size; /** Number of available bits in the set */ 20 unsigned char bits[]; 21 }; 22 23 size_t nsd_bitset_size(size_t bits); 24 25 void nsd_bitset_zero(struct nsd_bitset *bset); 26 27 void nsd_bitset_init(struct nsd_bitset *bset, size_t bits); 28 29 int nsd_bitset_isset(struct nsd_bitset *bset, size_t bit); 30 31 void nsd_bitset_set(struct nsd_bitset *bset, size_t bit); 32 33 void nsd_bitset_unset(struct nsd_bitset *bset, size_t bit); 34 35 void nsd_bitset_or( 36 struct nsd_bitset *destset, 37 struct nsd_bitset *srcset1, 38 struct nsd_bitset *srcset2); 39 40 #endif /* BITSET_H */ 41