From a050a62857e73092f2f6bcdca767a50d8880371e Mon Sep 17 00:00:00 2001 From: fc_botelho Date: Fri, 21 Jan 2005 20:30:23 +0000 Subject: [PATCH] mask to represent a boolean value using only 1 bit --- src/bitbool.c | 2 ++ src/bitbool.h | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/bitbool.c create mode 100644 src/bitbool.h diff --git a/src/bitbool.c b/src/bitbool.c new file mode 100644 index 0000000..07279e4 --- /dev/null +++ b/src/bitbool.c @@ -0,0 +1,2 @@ +#include "bitbool.h" +const cmph_uint8 bitmask[] = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 }; diff --git a/src/bitbool.h b/src/bitbool.h new file mode 100644 index 0000000..5428919 --- /dev/null +++ b/src/bitbool.h @@ -0,0 +1,9 @@ +#ifndef _CMPH_BITBOOL_H__ +#define _CMPH_BITBOOL_H__ +#include "cmph_types.h" +extern const cmph_uint8 bitmask[]; +#define GETBIT(array, i) (array[(i) / 8] & bitmask[(i) % 8]) +#define SETBIT(array, i) (array[(i) / 8] |= bitmask[(i) % 8]) +#define UNSETBIT(array, i) (array[(i) / 8] &= (~(bitmask[(i) % 8]))) + +#endif