From cba26286807ebe6b31c31d165677271de0417def Mon Sep 17 00:00:00 2001 From: batt Date: Fri, 2 Apr 2010 09:56:44 +0000 Subject: [PATCH] DIV_ROUNDUP: new macro. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3379 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cfg/macros.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bertos/cfg/macros.h b/bertos/cfg/macros.h index 4f77b21e..caa2340f 100644 --- a/bertos/cfg/macros.h +++ b/bertos/cfg/macros.h @@ -182,6 +182,13 @@ */ #define DIV_ROUND(dividend, divisor) (((dividend) + (divisor) / 2) / (divisor)) +/** + * Perform an integer division rounding the result to the upper int value. + * \note \a divisor should preferibly be a costant, otherwise this macro generates + * 2 division. Also divisor is evaluated twice. + */ +#define DIV_ROUNDUP(dividend, divisor) (((dividend) + (divisor) - 1) / (divisor)) + /** Round up \a x to an even multiple of the 2's power \a pad. */ #define ROUND_UP2(x, pad) (((x) + ((pad) - 1)) & ~((pad) - 1)) -- 2.25.1