]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Introduce IS_ALIGNED()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 26 Feb 2016 18:30:44 +0000 (18:30 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 24 Mar 2016 12:23:58 +0000 (12:23 +0000)
While at it comment the entities in this file, and guard _p() to avoid it
accidentally being used in assembly code.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/xtf/numbers.h

index c237900b075629056565ed5bbf17ce18c11da285..ef28488b29c2d4e9c8024eb0c2bcbb0b82345f82 100644 (file)
 # define _AC(num, suf) num
 #else
 # define _AC(num, suf) __tok(num, suf)
+/** @cond */
 # define __tok(a, b)   (a ## b)
+/** @endcond */
 #endif
 
+/** Express @p num in Kilobytes. */
 #define KB(num) (_AC(num, ULL) << 10)
+
+/** Express @p num in Megabytes. */
 #define MB(num) (_AC(num, ULL) << 20)
+
+/** Express @p num in Gigabytes. */
 #define GB(num) (_AC(num, ULL) << 30)
+
+/** Express @p num in Terabytes. */
 #define TB(num) (_AC(num, ULL) << 40)
 
+/**
+ * Return a boolean indicating whether @p val is aligned on @p align.  @p
+ * align is required to be exact power of two.
+ */
+#define IS_ALIGNED(val, align) (((val) & ((align) - 1)) == 0)
+
+#ifndef __ASSEMBLY__
+
+/**
+ * Express an abitrary integer @p v as void *.
+ */
 #define _p(v) ((void*)(unsigned long)(v))
 
+#endif /* !__ASSEMBLY__ */
 #endif /* XTF_NUMBERS_H */
 
 /*