summaryrefslogtreecommitdiffstats
path: root/src/lisiblestd/bitset.h
blob: 3e8cb706f307845cb1680d6ed3765c742eede522 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef LSTD_BITSET_H
#define LSTD_BITSET_H

#include <limits.h>

#define BITMASK(b) (1 << ((b) % CHAR_BIT))
#define BITSLOT(b) ((b) / CHAR_BIT)
#define BITSET(a, b) ((a)[BITSLOT(b)] |= BITMASK(b))
#define BITCLEAR(a, b) ((a)[BITSLOT(b)] &= ~BITMASK(b))
#define BITTEST(a, b) ((a)[BITSLOT(b)] & BITMASK(b))
#define BITNSLOTS(nb) ((nb + CHAR_BIT - 1) / CHAR_BIT)

#endif // LSTD_BITSET_H
Go back to lisible.xyz