From 7eb42cc5384ef42062f53f732b2a927dd9b68f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 6 Sep 2014 04:03:20 +0200 Subject: [PATCH] fix UC_ROUND_UP() --- include/ucore/utils.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/ucore/utils.h b/include/ucore/utils.h index 70e5ca9..4a3e199 100644 --- a/include/ucore/utils.h +++ b/include/ucore/utils.h @@ -95,20 +95,24 @@ const typeof( ((const type *)0)->member ) *__mptr = (ptr); \ #define UC_DIV_ROUND_UP(x, y) (((x) + ((y) - 1))/(y)) /** - * Round x down to nearest multiple of y + * Round x up to nearest multiple of y + * e.g. UC_ROUND_UP(30,48) == 48 + * e.g. UC_ROUND_UP(49,48) == 96 * * @param x numerator, must be positive * @param y denominator - * @return x rounded to nearest multiple of y + * @return x rounded up to nearest multiple of y */ -#define UC_ROUND_UP(x, y) (((x) / (y)) * (y)) +#define UC_ROUND_UP(x, y) (UC_DIV_ROUND_UP(x, y) * (y)) /** * Round x down to nearest multiple of y + * e.g. UC_ROUND_UP(30,48) == 0 + * e.g. UC_ROUND_UP(49,48) == 48 * * @param x numerator, must be positive * @param y denominator - * @return x rounded to nearest multiple of y + * @return x rounded down nearest multiple of y */ #define UC_ROUND_DOWN(x, y) ((x) / (y) * (y))