public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3 0/1] MdePkg: Add STATIC_ASSERT macro
@ 2019-08-16 23:28 Vitaly Cheptsov
  2019-08-16 23:28 ` [PATCH v3 1/1] " Vitaly Cheptsov
  0 siblings, 1 reply; 7+ messages in thread
From: Vitaly Cheptsov @ 2019-08-16 23:28 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

Implements https://bugzilla.tianocore.org/show_bug.cgi?id=3D2048.

Things to note:
- _Static_assert is a standard C11 keyword and thus is available
on every modern compiler (including Apple Clang, Clang, and GCC).
See: https://en.cppreference.com/w/c/keyword/_Static_assert
- static_assert is a hack to support MSVC, which implements static
assertions with this vendor-specific keyword starting from at least
VS 2010 to date.
- V3 of the patch addresses the confusion with doxygen, which I
expected to not be able to handle @param for a macro with no arguments.
- The replacement of VERIFY_SIZE_OF will be submitted in a separate
patch series, and I request the colleagues to test this on their setups.
As for myself I can report that it works for me with CLANG38, GCC5,
VS2017, and XCODE5. 


Vitaly Cheptsov (1):
  MdePkg: Add STATIC_ASSERT macro

 MdePkg/Include/Base.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

-- 
2.20.1 (Apple Git-117)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
  2019-08-16 23:28 [PATCH v3 0/1] MdePkg: Add STATIC_ASSERT macro Vitaly Cheptsov
@ 2019-08-16 23:28 ` Vitaly Cheptsov
  2019-09-07 16:31   ` [edk2-devel] " Vitaly Cheptsov
  2019-09-10  6:30   ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 7+ messages in thread
From: Vitaly Cheptsov @ 2019-08-16 23:28 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2048

Provide a macro for compile time assertions.
Equivalent to C11 static_assert macro from assert.h.

Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
---
 MdePkg/Include/Base.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index ce20b5f01d..ec096133ba 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -843,6 +843,20 @@ typedef UINTN  *BASE_LIST;
 #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
 #endif
 
+/**
+  Portable definition for compile time assertions.
+  Equivalent to C11 static_assert macro from assert.h.
+
+  @param  Expression  Boolean expression.
+  @param  Message     Raised compiler diagnostic message when expression is false.
+
+**/
+#ifdef _MSC_EXTENSIONS
+  #define STATIC_ASSERT static_assert
+#else
+  #define STATIC_ASSERT _Static_assert
+#endif
+
 /**
   Macro that returns a pointer to the data structure that contains a specified field of
   that data structure.  This is a lightweight method to hide information by placing a
-- 
2.20.1 (Apple Git-117)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
  2019-08-16 23:28 ` [PATCH v3 1/1] " Vitaly Cheptsov
@ 2019-09-07 16:31   ` Vitaly Cheptsov
  2019-09-09  7:57     ` Liming Gao
  2019-09-10  6:30   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 7+ messages in thread
From: Vitaly Cheptsov @ 2019-09-07 16:31 UTC (permalink / raw)
  To: vit9696, devel

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Hello,

Given that new EDK II stable has already landed, and it was suggested to merge this right afterwards, it seems to me about the time to merge this patch.

Best wishes,
Vitaly

[-- Attachment #2: Type: text/html, Size: 208 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
  2019-09-07 16:31   ` [edk2-devel] " Vitaly Cheptsov
@ 2019-09-09  7:57     ` Liming Gao
  2019-09-09 23:04       ` Vitaly Cheptsov
  0 siblings, 1 reply; 7+ messages in thread
From: Liming Gao @ 2019-09-09  7:57 UTC (permalink / raw)
  To: devel@edk2.groups.io, vit9696@protonmail.com

[-- Attachment #1: Type: text/plain, Size: 672 bytes --]

Vitaly:
  I see https://edk2.groups.io/g/devel/message/45743 and https://edk2.groups.io/g/devel/message/45691 gives RB.

  If no other comments, I will push this change this week.

Thanks
Liming
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Vitaly Cheptsov via Groups.Io
Sent: Sunday, September 08, 2019 12:31 AM
To: vit9696 <vit9696@protonmail.com>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro

Hello,

Given that new EDK II stable has already landed, and it was suggested to merge this right afterwards, it seems to me about the time to merge this patch.

Best wishes,
Vitaly


[-- Attachment #2: Type: text/html, Size: 4451 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
  2019-09-09  7:57     ` Liming Gao
@ 2019-09-09 23:04       ` Vitaly Cheptsov
  0 siblings, 0 replies; 7+ messages in thread
From: Vitaly Cheptsov @ 2019-09-09 23:04 UTC (permalink / raw)
  To: Gao, Liming; +Cc: devel@edk2.groups.io


[-- Attachment #1.1: Type: text/plain, Size: 1056 bytes --]

Liming, sounds great, thank you.

> 9 сент. 2019 г., в 10:57, Gao, Liming <liming.gao@intel.com> написал(а):
> 
> Vitaly:
>   I see https://edk2.groups.io/g/devel/message/45743 <https://edk2.groups.io/g/devel/message/45743> and https://edk2.groups.io/g/devel/message/45691 <https://edk2.groups.io/g/devel/message/45691> gives RB.
>
>   If no other comments, I will push this change this week.
>
> Thanks
> Liming
> From: devel@edk2.groups.io <mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io <mailto:devel@edk2.groups.io>] On Behalf Of Vitaly Cheptsov via Groups.Io
> Sent: Sunday, September 08, 2019 12:31 AM
> To: vit9696 <vit9696@protonmail.com <mailto:vit9696@protonmail.com>>; devel@edk2.groups.io <mailto:devel@edk2.groups.io>
> Subject: Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
>
> Hello,
> 
> Given that new EDK II stable has already landed, and it was suggested to merge this right afterwards, it seems to me about the time to merge this patch.
> 
> Best wishes,
> Vitaly 
> 


[-- Attachment #1.2: Type: text/html, Size: 5800 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
  2019-08-16 23:28 ` [PATCH v3 1/1] " Vitaly Cheptsov
  2019-09-07 16:31   ` [edk2-devel] " Vitaly Cheptsov
@ 2019-09-10  6:30   ` Philippe Mathieu-Daudé
  2019-09-12  1:21     ` Liming Gao
  1 sibling, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-10  6:30 UTC (permalink / raw)
  To: devel, vit9696

On 8/17/19 1:28 AM, Vitaly Cheptsov via Groups.Io wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2048
> 
> Provide a macro for compile time assertions.
> Equivalent to C11 static_assert macro from assert.h.
> 
> Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
> ---
>  MdePkg/Include/Base.h | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> index ce20b5f01d..ec096133ba 100644
> --- a/MdePkg/Include/Base.h
> +++ b/MdePkg/Include/Base.h
> @@ -843,6 +843,20 @@ typedef UINTN  *BASE_LIST;
>  #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>  #endif
>  
> +/**
> +  Portable definition for compile time assertions.
> +  Equivalent to C11 static_assert macro from assert.h.
> +
> +  @param  Expression  Boolean expression.
> +  @param  Message     Raised compiler diagnostic message when expression is false.
> +
> +**/
> +#ifdef _MSC_EXTENSIONS
> +  #define STATIC_ASSERT static_assert
> +#else
> +  #define STATIC_ASSERT _Static_assert
> +#endif
> +
>  /**
>    Macro that returns a pointer to the data structure that contains a specified field of
>    that data structure.  This is a lightweight method to hide information by placing a
> 

Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
  2019-09-10  6:30   ` Philippe Mathieu-Daudé
@ 2019-09-12  1:21     ` Liming Gao
  0 siblings, 0 replies; 7+ messages in thread
From: Liming Gao @ 2019-09-12  1:21 UTC (permalink / raw)
  To: devel@edk2.groups.io, philmd@redhat.com, vit9696@protonmail.com

Push @204ae9da230ecbf0910c21acac7aa5d5e8cbb8d0

>-----Original Message-----
>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>Philippe Mathieu-Daudé
>Sent: Tuesday, September 10, 2019 2:30 PM
>To: devel@edk2.groups.io; vit9696@protonmail.com
>Subject: Re: [edk2-devel] [PATCH v3 1/1] MdePkg: Add STATIC_ASSERT macro
>
>On 8/17/19 1:28 AM, Vitaly Cheptsov via Groups.Io wrote:
>> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2048
>>
>> Provide a macro for compile time assertions.
>> Equivalent to C11 static_assert macro from assert.h.
>>
>> Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
>> ---
>>  MdePkg/Include/Base.h | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>> index ce20b5f01d..ec096133ba 100644
>> --- a/MdePkg/Include/Base.h
>> +++ b/MdePkg/Include/Base.h
>> @@ -843,6 +843,20 @@ typedef UINTN  *BASE_LIST;
>>  #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>>  #endif
>>
>> +/**
>> +  Portable definition for compile time assertions.
>> +  Equivalent to C11 static_assert macro from assert.h.
>> +
>> +  @param  Expression  Boolean expression.
>> +  @param  Message     Raised compiler diagnostic message when
>expression is false.
>> +
>> +**/
>> +#ifdef _MSC_EXTENSIONS
>> +  #define STATIC_ASSERT static_assert
>> +#else
>> +  #define STATIC_ASSERT _Static_assert
>> +#endif
>> +
>>  /**
>>    Macro that returns a pointer to the data structure that contains a specified
>field of
>>    that data structure.  This is a lightweight method to hide information by
>placing a
>>
>
>Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
>
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-12  1:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-16 23:28 [PATCH v3 0/1] MdePkg: Add STATIC_ASSERT macro Vitaly Cheptsov
2019-08-16 23:28 ` [PATCH v3 1/1] " Vitaly Cheptsov
2019-09-07 16:31   ` [edk2-devel] " Vitaly Cheptsov
2019-09-09  7:57     ` Liming Gao
2019-09-09 23:04       ` Vitaly Cheptsov
2019-09-10  6:30   ` Philippe Mathieu-Daudé
2019-09-12  1:21     ` Liming Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox