From 420f76ea0014a862dc727e76f5b7c1745259d501 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Fri, 10 Jan 2025 23:21:27 +0800 Subject: [PATCH] macro/align: Fix ALIGN_UP and ALIGN_DOWN Signed-off-by: wangmingrong1 --- include/nuttx/nuttx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nuttx/nuttx.h b/include/nuttx/nuttx.h index 484c66b8bdcf4..cb4ddaca31eba 100644 --- a/include/nuttx/nuttx.h +++ b/include/nuttx/nuttx.h @@ -48,7 +48,7 @@ #endif #ifndef ALIGN_UP -# define ALIGN_UP(x,a) (((x) + ((a) - 1)) & ~((a) - 1)) +# define ALIGN_UP(x,a) ((((x) + (a) - 1) / (a)) * (a)) #endif #ifndef ALIGN_UP_MASK @@ -56,7 +56,7 @@ #endif #ifndef ALIGN_DOWN -# define ALIGN_DOWN(x,a) ((x) & (~((a) - 1))) +# define ALIGN_DOWN(x,a) (((x) / (a)) * (a)) #endif #ifndef ALIGN_DOWN_MASK