mask to represent a boolean value using only 1 bit
This commit is contained in:
parent
955d4ad8fd
commit
4dda0a3b62
2
src/bitbool.c
Normal file
2
src/bitbool.c
Normal 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
9
src/bitbool.h
Normal 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
|
Loading…
Reference in New Issue
Block a user