summaryrefslogtreecommitdiff
path: root/libvmon/bitmap.h
blob: eacb97def9fa458cf6a750c62e627a619ea61efe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef _BITMAP_H
#define _BITMAP_H

/* simple implementation of general-purpose bitmap macros taken from the comp.lang.c FAQ */

#include <limits.h>	/* for CHAR_BIT */

#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
© All Rights Reserved