From 9522ef8486922b4f93124e38811b79b9844ef64f Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 8 Jun 2023 17:41:57 -0400 Subject: [PATCH] [rtdef] add RT_IS_ALIGN macro --- include/rtdef.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/rtdef.h b/include/rtdef.h index e70a9cac98..eb5f047f1b 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -386,6 +386,16 @@ typedef int (*init_fn_t)(void); /**@}*/ +/** + * @ingroup BasicDef + * + * @def RT_IS_ALIGN(addr, align) + * Return true(1) or false(0). + * RT_IS_ALIGN(128, 4) is judging whether 128 aligns with 4. + * The result is 1, which means 128 aligns with 4. + */ +#define RT_IS_ALIGN(addr, align) (!(addr & (align - 1))) + /** * @ingroup BasicDef *