#ifndef __MACRO_H
#define __MACRO_H

#define __ALIGN_CONSTANT(x, b, A) (__builtin_constant_p(b) ? ((b) == 1 ? (x) : A(x, b)) : A(x, b))
#define __ALIGN_VALUE_UP(x, b) ((((x) - 1)| ((b) - 1)) + 1)
#define ALIGN_VALUE_UP(x, b) __ALIGN_CONSTANT(x, b, __ALIGN_VALUE_UP)
#define ALIGN_ADDRESS_UP(x, b) ((void*)ALIGN_VALUE_UP((uint32_t)(x), (b)))
#define ALIGN_VALUE_DOWN(x, b) (x == (ALIGN_VALUE_UP(x,b))?x:(ALIGN_VALUE_UP(x,b)-b))

#endif
