From 4642216f70dd98134a79f9299b7ca4bc876649c7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 28 Aug 2016 00:36:53 -0700 Subject: *: refactor all the things Long overdue house cleaning. The addition of compositing/monitoring overlays in vwm3 pushed vwm well past what is a reasonable size for a simple thousand line file. This is a first step towards restoring sanity in the code, but no behavioral differences are intended, this is mostly just shuffling around and organizing code. I expect some performance regressions initially, follow-on commits will make more improvements to that end as the dust settles. --- src/libvmon/bitmap.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/libvmon/bitmap.h (limited to 'src/libvmon/bitmap.h') 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 /* 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 -- cgit v1.2.3