macros: add mask() as a macro to calculate the bit mask

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent fa49f634e4
commit a22b59b2a8
  1. 1
      include/macros.h

@ -21,6 +21,7 @@
#define ROUND_DOWN(x, k) ((x) & ~((k) - 1))
#define ROUND_UP(x, k) (((x) + (k) - 1) & ~((k) - 1))
#define mask(x, k) ((x) & ((1 << (k)) - 1))
#define align(x, k) ((x) & ~((1 << (k)) - 1))
#define align_up(x, k) align(x + ((1 << (k)) - 1), k)
#define is_aligned(x, k) (!((x) & ((1 << (k)) - 1)))

Loading…
Cancel
Save