From a7eb5d7a955a2b90ebfbeb5177c3d01e5c287e30 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 1 Feb 2010 20:19:45 +0100 Subject: common: add some more bit utilities --- src/common.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/common.h') diff --git a/src/common.h b/src/common.h index f9d9f77..b1c3273 100644 --- a/src/common.h +++ b/src/common.h @@ -54,9 +54,11 @@ #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) -#define GETBIT(m, x) ((m>>(x))&1U) -#define SETBIT(m, x) (m|=(1U<<(x))) -#define CLEARBIT(m, x) (m&=~(1U<<(x))) +#define BITMASK(x) (1U << (x)) +#define BITONES(x) (BITMASK(x) - 1U) +#define GETBIT(m, x) (((m) >> (x)) & 1U) +#define SETBIT(m, x) (m |= BITMASK(x)) +#define CLEARBIT(m, x) (m &= ~BITMASK(x)) //////////////////////////////////////////////////////// -- cgit v1.2.3