From 2045959d176e3584849c9bd67728317922604265 Mon Sep 17 00:00:00 2001 From: arighi Date: Thu, 30 Sep 2010 14:15:13 +0000 Subject: [PATCH] Introduce ALIGN_UP() macro Add a generic macro to align a value to the next alignment boundary. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4386 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cfg/macros.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bertos/cfg/macros.h b/bertos/cfg/macros.h index d0ccf433..3ec6b277 100644 --- a/bertos/cfg/macros.h +++ b/bertos/cfg/macros.h @@ -94,6 +94,11 @@ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif /* !(COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF) */ +/** Align \p value to the next \p align boundary */ +#define ALIGN_UP(value, align) (((value) & ((align) - 1)) ? \ + (((value) + ((align) - 1)) & ~((align) - 1)) : \ + (value)) + /** Bound \a x between \a min and \a max. */ #define MINMAX(min,x,max) (MIN(MAX(min, x), max)) -- 2.25.1