From 156e30a60d2d73bb796b290d336662302cc588fb Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 8 Jun 2016 22:32:37 +0200 Subject: [PATCH] added address alignment macros for 'struct pool' --- include/utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/utils.h b/include/utils.h index a2bc29521..cdb3adf85 100644 --- a/include/utils.h +++ b/include/utils.h @@ -43,6 +43,12 @@ #define XSTR(x) STR(x) #define STR(x) #x +#define ALIGN(x, a) ALIGN_MASK(x, (uintptr_t) (a) - 1) +#define ALIGN_MASK(x, m) (((uintptr_t) (x) + (m)) & ~(m)) +#define IS_ALIGNED(x, a) (ALIGN(x, a) == (uintptr_t) x) + +#define CEIL(x, y) ((x + y - 1) / y) + /** Calculate the number of elements in an array. */ #define ARRAY_LEN(a) ( sizeof (a) / sizeof (a)[0] )