Skip to content

Commit

Permalink
[rtdef] RT_IS_ALIGN marco add a null address exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
wdfk-prog authored and mysterywolf committed Jun 11, 2023
1 parent e36b97f commit 780806f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/rtdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,9 @@ typedef int (*init_fn_t)(void);
* 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.
* @note If the address is NULL, false(0) will be returned
*/
#define RT_IS_ALIGN(addr, align) (!(addr & (align - 1)))
#define RT_IS_ALIGN(addr, align) ((!(addr & (align - 1))) && (addr != RT_NULL))

/**
* @ingroup BasicDef
Expand Down

0 comments on commit 780806f

Please sign in to comment.