summaryrefslogtreecommitdiff
path: root/src/libvmon/bitmap.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2016-09-09 14:20:28 -0700
committerGitHub <noreply@github.com>2016-09-09 14:20:28 -0700
commita1aba8e0fe5c94ebf04258b609666c92b756954f (patch)
treefe9792b77766e31728b1d2d04d2461858ef45443 /src/libvmon/bitmap.h
parente99f5ac1293a0ae1f498bc4c73c4c04e4edb8665 (diff)
parent8ef5fccc1ad2f5acb5530a438de631153e4ad945 (diff)
Merge pull request #6 from vcaputo/clean_house
House cleaning
Diffstat (limited to 'src/libvmon/bitmap.h')
-rw-r--r--src/libvmon/bitmap.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libvmon/bitmap.h b/src/libvmon/bitmap.h
new file mode 100644
index 0000000..eacb97d
--- /dev/null
+++ b/src/libvmon/bitmap.h
@@ -0,0 +1,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