浏览代码

[rtdef] add RT_IS_ALIGN macro

Meco Man 1 年之前
父节点
当前提交
9522ef8486
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      include/rtdef.h

+ 10 - 0
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
  * @ingroup BasicDef
  *
  *