macros: add align() macro

This commit is contained in:
S.J.R. van Schaik 2017-05-19 18:29:17 +02:00
parent c684a57e24
commit efa91ba5c3

View file

@ -21,6 +21,7 @@
#define ROUND_DOWN(x, k) ((x) & ~((k) - 1))
#define ROUND_UP(x, k) (((x) + (k) - 1) & ~((k) - 1))
#define align(x, k) ((x) & ~((1 << (k)) - 1))
#define is_aligned(x, k) (!((x) & ((1 << (k)) - 1)))
#define align_eq(x, y, k) (!(((x) ^ (y)) >> k))