mask to represent a boolean value using only 1 bit

This commit is contained in:
fc_botelho 2005-01-21 20:30:23 +00:00
parent 955d4ad8fd
commit 4dda0a3b62
2 changed files with 11 additions and 0 deletions

2
src/bitbool.c Normal file
View File

@ -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 };

9
src/bitbool.h Normal file
View File

@ -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