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