diff --git a/include/macros.h b/include/macros.h index a987cbf..abb6b26 100644 --- a/include/macros.h +++ b/include/macros.h @@ -35,3 +35,4 @@ #define BIT_SIZE(t) (CHAR_BIT * sizeof(t)) #define BIT(n) (1 << (n)) #define BITS(_start, _end) ((BIT(_end) - BIT(_start)) + BIT(_end)) +#define BIT_MASK(x, k) ((x) & ((1 << (k)) - 1))