diff options
| author | Meco Man <[email protected]> | 2023-06-08 17:41:57 -0400 |
|---|---|---|
| committer | Man, Jianting (Meco) <[email protected]> | 2023-06-09 22:48:22 -0400 |
| commit | 9522ef8486922b4f93124e38811b79b9844ef64f (patch) | |
| tree | 70e5dba716b73ebf63b6ceb908c72301b2ac3062 | |
| parent | 7c3f5c3879a05ceeb524f546a1d7a9a4cd48cf96 (diff) | |
[rtdef] add RT_IS_ALIGN macro
| -rw-r--r-- | include/rtdef.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/rtdef.h b/include/rtdef.h index e70a9cac98..eb5f047f1b 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -389,6 +389,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 + * * @def RT_ALIGN(size, align) * Return the most contiguous size aligned at specified width. RT_ALIGN(13, 4) * would return 16. |
