Skip to content

Commit

Permalink
Utilities: Add ACPI_IS_POWER_OF_TWO()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lv Zheng committed Mar 15, 2016
1 parent e81ceda commit cbcb775
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/include/acmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@

#define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1))

/* Generic (power-of-two) rounding */

#define ACPI_IS_POWER_OF_TWO(a) (((a) & ((a) - 1)) == 0)

/*
* Bitmask creation
* Bit positions start at zero.
Expand Down

0 comments on commit cbcb775

Please sign in to comment.