Skip to content

Commit 9522ef8

Browse files
committed
[rtdef] add RT_IS_ALIGN macro
1 parent 7c3f5c3 commit 9522ef8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/rtdef.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,16 @@ typedef int (*init_fn_t)(void);
386386

387387
/**@}*/
388388

389+
/**
390+
* @ingroup BasicDef
391+
*
392+
* @def RT_IS_ALIGN(addr, align)
393+
* Return true(1) or false(0).
394+
* RT_IS_ALIGN(128, 4) is judging whether 128 aligns with 4.
395+
* The result is 1, which means 128 aligns with 4.
396+
*/
397+
#define RT_IS_ALIGN(addr, align) (!(addr & (align - 1)))
398+
389399
/**
390400
* @ingroup BasicDef
391401
*

0 commit comments

Comments
 (0)