From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@protonmail.com header.s=default header.b=ZgV2KK3v; spf=pass (domain: protonmail.com, ip: 185.70.40.22, mailfrom: vit9696@protonmail.com) Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by groups.io with SMTP; Fri, 16 Aug 2019 16:58:21 -0700 Date: Fri, 16 Aug 2019 23:58:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1565999898; bh=Fm43OdGw8l2X9/8McbHrXE4m6PKq5+AdH2n5jEHJaIw=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:Feedback-ID: From; b=ZgV2KK3vQ7NMayGhLqzLw4eZU9SHnLtP+1NmJf5lgi57xYQJl7ou2PK7yG2gwiVmo TmamGgNXrXpe51OmmFuRSCG3YzKBSN+TvpIA9XvjXf7aHqD2UpqNJ00JQGW6MKxuAD 1NV9RJBMzHc7D0VHL2/pSffGofaBB7P5r4E9DKSk= To: devel@edk2.groups.io From: "Vitaly Cheptsov" Reply-To: Vitaly Cheptsov Subject: [PATCH v1 2/3] MdePkg: Use STATIC_ASSERT macro Message-ID: <20190816235808.16019-3-vit9696@protonmail.com> In-Reply-To: <20190816235808.16019-1-vit9696@protonmail.com> References: <20190816235808.16019-1-vit9696@protonmail.com> Feedback-ID: p9QuX-L1wMgUm6nrSvNrf8juLupNs0VSnzXGVXuYDxlEahFdWtaedWDMB9zpwGDklGt7kzs1-RBc0cqz327Gcg==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=-0.7 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch X-Groupsio-MsgNum: 45873 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha256; boundary="---------------------f617766d256b96f9b676844d65bc2e7e"; charset=UTF-8 -----------------------f617766d256b96f9b676844d65bc2e7e Content-Transfer-Encoding: quoted-printable Date: Sat, 17 Aug 2019 02:58:07 +0300 From: Vitaly Cheptsov In-Reply-To: <20190816235808.16019-1-vit9696@protonmail.com> Message-Id: <20190816235808.16019-3-vit9696@protonmail.com> Mime-Version: 1.0 References: <20190816235808.16019-1-vit9696@protonmail.com> Subject: [PATCH v1 2/3] MdePkg: Use STATIC_ASSERT macro To: devel@edk2.groups.io X-Mailer: git-send-email 2.20.1 (Apple Git-117) REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2048 Use new STATIC_ASSERT macro instead of VERIFY_SIZE_OF. Signed-off-by: Vitaly Cheptsov --- MdePkg/Include/Base.h | 79 ++++++++++---------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index ec096133ba..d871422cd6 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -41,45 +41,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[(sizeo= f(TYPE) =3D=3D (Size)) / (sizeof(TYPE) =3D=3D (Size))] =20 -// -// Verify that ProcessorBind.h produced UEFI Data Types that are compliant= with -// Section 2.3.1 of the UEFI 2.3 Specification. -// -VERIFY_SIZE_OF (BOOLEAN, 1); -VERIFY_SIZE_OF (INT8, 1); -VERIFY_SIZE_OF (UINT8, 1); -VERIFY_SIZE_OF (INT16, 2); -VERIFY_SIZE_OF (UINT16, 2); -VERIFY_SIZE_OF (INT32, 4); -VERIFY_SIZE_OF (UINT32, 4); -VERIFY_SIZE_OF (INT64, 8); -VERIFY_SIZE_OF (UINT64, 8); -VERIFY_SIZE_OF (CHAR8, 1); -VERIFY_SIZE_OF (CHAR16, 2); - -// -// The following three enum types are used to verify that the compiler -// configuration for enum types is compliant with Section 2.3.1 of the -// UEFI 2.3 Specification. These enum types and enum values are not -// intended to be used. A prefix of '__' is used avoid conflicts with -// other types. -// -typedef enum { - __VerifyUint8EnumValue =3D 0xff -} __VERIFY_UINT8_ENUM_SIZE; - -typedef enum { - __VerifyUint16EnumValue =3D 0xffff -} __VERIFY_UINT16_ENUM_SIZE; - -typedef enum { - __VerifyUint32EnumValue =3D 0xffffffff -} __VERIFY_UINT32_ENUM_SIZE; - -VERIFY_SIZE_OF (__VERIFY_UINT8_ENUM_SIZE, 4); -VERIFY_SIZE_OF (__VERIFY_UINT16_ENUM_SIZE, 4); -VERIFY_SIZE_OF (__VERIFY_UINT32_ENUM_SIZE, 4); - // // The Microsoft* C compiler can removed references to unreferenced data i= tems // if the /OPT:REF linker option is used. We defined a macro as this is a @@ -857,6 +818,46 @@ typedef UINTN *BASE_LIST; #define STATIC_ASSERT _Static_assert #endif =20 +// +// Verify that ProcessorBind.h produced UEFI Data Types that are compliant= with +// Section 2.3.1 of the UEFI 2.3 Specification. +// + +STATIC_ASSERT (sizeof (BOOLEAN) =3D=3D 1, "sizeof (BOOLEAN) does not meet = UEFI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (INT8) =3D=3D 1, "sizeof (INT8) does not meet UEF= I Specification Data Type requirements"); +STATIC_ASSERT (sizeof (UINT8) =3D=3D 1, "sizeof (UINT8) does not meet UE= FI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (INT16) =3D=3D 2, "sizeof (INT16) does not meet UE= FI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (UINT16) =3D=3D 2, "sizeof (UINT16) does not meet U= EFI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (INT32) =3D=3D 4, "sizeof (INT32) does not meet UE= FI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (UINT32) =3D=3D 4, "sizeof (UINT32) does not meet U= EFI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (INT64) =3D=3D 8, "sizeof (INT64) does not meet UE= FI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (UINT64) =3D=3D 8, "sizeof (UINT64) does not meet U= EFI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (CHAR8) =3D=3D 1, "sizeof (CHAR8) does not meet UE= FI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (CHAR16) =3D=3D 2, "sizeof (CHAR16) does not meet U= EFI Specification Data Type requirements"); + +// +// The following three enum types are used to verify that the compiler +// configuration for enum types is compliant with Section 2.3.1 of the +// UEFI 2.3 Specification. These enum types and enum values are not +// intended to be used. A prefix of '__' is used avoid conflicts with +// other types. +// +typedef enum { + __VerifyUint8EnumValue =3D 0xff +} __VERIFY_UINT8_ENUM_SIZE; + +typedef enum { + __VerifyUint16EnumValue =3D 0xffff +} __VERIFY_UINT16_ENUM_SIZE; + +typedef enum { + __VerifyUint32EnumValue =3D 0xffffffff +} __VERIFY_UINT32_ENUM_SIZE; + +STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) =3D=3D 4, "Size of enum d= oes not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) =3D=3D 4, "Size of enum = does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) =3D=3D 4, "Size of enum = does not meet UEFI Specification Data Type requirements"); + /** Macro that returns a pointer to the data structure that contains a speci= fied field of that data structure. This is a lightweight method to hide information b= y placing a --=20 2.20.1 (Apple Git-117) -----------------------f617766d256b96f9b676844d65bc2e7e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wsBmBAEBCAAQBQJdV0MTCRBPsoxt7Hy0xQAKCRBPsoxt7Hy0xQR7CAAKg0n/ 1jFpuLN1D8415hynlou9rOAt0nMwC+hnchr+hFwA4gvQdgazN/tjwP1yBws2 dWRdkm2jfyO1CWChjqhZVF2yqiCXTFfY8kpiiRo/WQYkitAQYfS0tCM+h75p zNr0f5YF9Xt9hzivm/RVwoIHB7/eR8u5fqb1i8A3VOC94gQJ9F0NXcvBbBTx YMLL34t2if48+8YXLtmgRu5sL55/ryYSGuCwTXAdcn/4y45vBMH4EPigsthD qzsHMnDYGSM98GxvqdspiNjXeiphFZmsREJuGUoH8W8I4H0etTQndHDcKCQi quhoaIfVVtyBiot0NceyI0yH8C0uMqn/dUh4 =+uJ5 -----END PGP SIGNATURE----- -----------------------f617766d256b96f9b676844d65bc2e7e--