diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-12-31 11:29:38 +0800 |
---|---|---|
committer | Lv Zheng <lv.zheng@intel.com> | 2016-11-09 04:05:05 +0800 |
commit | adaead47de2dd98ee556de911fd798371ba4c378 (patch) | |
tree | cf615de2c5a56cee9881c07eeee84a9d7a4d72d4 | |
parent | b138a24ae1b5301cbf07b9f79bf26806052e5fbd (diff) | |
download | acpica-adaead47de2dd98ee556de911fd798371ba4c378.tar.gz |
Utilities: Add ACPI_IS_POWER_OF_TWO()
This patch adds a macro ACPI_IS_POWER_OF_TWO, which can be used to
detect if a number is a power of two. Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
-rw-r--r-- | source/include/acmacros.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/include/acmacros.h b/source/include/acmacros.h index a805a32ce..b451cbbbd 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -336,6 +336,11 @@ #define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) +/* Generic (power-of-two) rounding */ + +#define ACPI_IS_ALIGNED(a, s) (((a) & ((s) - 1)) == 0) +#define ACPI_IS_POWER_OF_TWO(a) ACPI_IS_ALIGNED(a, a) + /* * Bitmask creation * Bit positions start at zero. |