diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 469161b4b9..2e0d68fa7e 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -907,6 +907,17 @@ STATIC_ASSERT (ALIGNOF (__VERIFY_INT32_ENUM_SIZE) == sizeof (__VERIFY_INT32_ENUM **/ #define IS_POW2(Value) ((Value) != 0U && ((Value) & ((Value) - 1U)) == 0U) +/** + Determines the subtrahend to subtract from a value to round it down to the + previous boundary of a specified alignment. + + @param Value The value to round down. + @param Alignment The alignment boundary used to return the subtrahend. + + @return Subtrahend to round Value down to alignment boundary Alignment. +**/ +#define ALIGN_VALUE_SUBTRAHEND(Value, Alignment) ((Value) & ((Alignment) - 1U)) + /** Checks whether a value is aligned by a specified alignment. @@ -916,7 +927,7 @@ STATIC_ASSERT (ALIGNOF (__VERIFY_INT32_ENUM_SIZE) == sizeof (__VERIFY_INT32_ENUM @retval TRUE Value is aligned by Alignment. @retval FALSE Value is not aligned by Alignment. **/ -#define IS_ALIGNED(Value, Alignment) (((Value) & ((Alignment) - 1U)) == 0U) +#define IS_ALIGNED(Value, Alignment) (ALIGN_VALUE_SUBTRAHEND (Value, Alignment) == 0U) /** Checks whether a pointer or address is aligned by a specified alignment.