From f1437255f54753366513618ef315a1f50f88b4eb Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 27 Mar 2024 20:19:57 +0100 Subject: Rename bitset macros --- include/bitset.h | 15 +++++++-------- 1 file 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 -#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 */ -- cgit v1.2.3