diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-03-27 20:19:57 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-03-27 20:19:57 +0100 |
commit | f1437255f54753366513618ef315a1f50f88b4eb (patch) | |
tree | e64c75238c0748ce014d5b56350fde489083ebe9 /include | |
parent | a09bff4bfc759f23be2e17425bb879d87f6de5d2 (diff) |
Rename bitset macros
Diffstat (limited to 'include')
-rw-r--r-- | include/bitset.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/include/bitset.h b/include/bitset.h index c72985e..5fe91dd 100644 --- a/include/bitset.h +++ b/include/bitset.h @@ -3,15 +3,14 @@ #include <limits.h> -#define __MLIB_BITSLOT(x) ((x) / CHAR_BIT) -#define __MLIB_BITMASK(x) (1 << ((x) % CHAR_BIT)) -#define __MLIB_BITIMPL(bs, x, op) ((bs)[__MLIB_BITSLOT(x)] op __MLIB_BITMASK(x)) +#define __MLIB_BITSLOT(x) ((x) / CHAR_BIT) +#define __MLIB_BITMASK(x) (1 << ((x) % CHAR_BIT)) -#define bitset(name, n) unsigned char name[(n + CHAR_BIT - 1) / CHAR_BIT] +#define BITSET(name, n) unsigned char name[(n + CHAR_BIT - 1) / CHAR_BIT] -#define BITCLR(bs, x) __MLIB_BITIMPL(bs, x, &= ~) -#define BITSET(bs, x) __MLIB_BITIMPL(bs, x, |=) -#define BITTOGL(bs, x) __MLIB_BITIMPL(bs, x, ^=) -#define BITTEST(bs, x) (bool)__MLIB_BITIMPL(bs, x, &) +#define CLRBIT(bs, x) ((bs)[__MLIB_BITSLOT(x)] &= ~__MLIB_BITMASK(x)) +#define SETBIT(bs, x) ((bs)[__MLIB_BITSLOT(x)] |= __MLIB_BITMASK(x)) +#define TOGLBIT(bs, x) ((bs)[__MLIB_BITSLOT(x)] ^= __MLIB_BITMASK(x)) +#define TESTBIT(bs, x) ((bool)((bs)[__MLIB_BITSLOT(x)] & __MLIB_BITMASK(x))) #endif /* !MLIB_BITSET_H */ |