[edk2-devel] [PATCH edk2-platforms 1/2] Platform/Intel/WhiskeylakeOpenBoardPkg: Fix ALIGN16 macro

Pedro Falcato pedro.falcato at gmail.com
Mon May 15 13:22:36 UTC 2023


On Mon, May 15, 2023 at 6:43 AM Rebecca Cran <rebecca at bsdio.com> wrote:
>
> The IS_ALIGNED macro defined in PlatformBoardConfig.h conflicts with the
> definition from MdePkg/Include/Base.h. Delete it, and switch to
> ADDRESS_IS_ALIGNED.
>
> Signed-off-by: Rebecca Cran <rebecca at bsdio.com>
> ---
>  Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
> index 44b4059f8ebf..4872a0afc65a 100644
> --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
> +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
> @@ -15,8 +15,7 @@
>  #include <GpioConfig.h>
>  #include <TbtBoardInfo.h>
>
> -#define IS_ALIGNED(addr, size) (((addr) & (size - 1)) ? 0 : 1)
> -#define ALIGN16(size)          (IS_ALIGNED(size, 16) ? size : ((size + 16) & 0xFFF0))
> +#define ALIGN16(size)          (ADDRESS_IS_ALIGNED(size, 16) ? size : ((size + 16) & 0xFFF0))

As I mentioned on Discord, ALIGN16 should not need a branch like this.
I propose switching ALIGN16 to use ALIGN_VALUE, or if you need compat
with older edk2s, even:

#define ALIGN16(size)         (((size) + 15) & -16)

Which is a common enough pattern that it hopefully is self-explanatory.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104871): https://edk2.groups.io/g/devel/message/104871
Mute This Topic: https://groups.io/mt/98897866/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list