From: Andrew Cooper Date: Fri, 26 Feb 2016 18:30:44 +0000 (+0000) Subject: Introduce IS_ALIGNED() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=98f75c856b87e067205101322e55a34669e137d3;p=people%2Froyger%2Fxen-test-framework.git Introduce IS_ALIGNED() 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 --- diff --git a/include/xtf/numbers.h b/include/xtf/numbers.h index c237900..ef28488 100644 --- a/include/xtf/numbers.h +++ b/include/xtf/numbers.h @@ -14,16 +14,37 @@ # 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 */ /*