public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"mhaeuser@posteo.de" <mhaeuser@posteo.de>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	"Liu, Zhiguang" <zhiguang.liu@intel.com>,
	"Vitaly Cheptsov" <vit9696@protonmail.com>
Subject: Re: [edk2-devel] [PATCH V2 2/3] MdePkg/Base.h: Introduce various alignment-related macros
Date: Mon, 16 Aug 2021 09:42:37 +0000	[thread overview]
Message-ID: <CO1PR11MB4930B865265F96EF826367418CFD9@CO1PR11MB4930.namprd11.prod.outlook.com> (raw)
In-Reply-To: <fb996587a85f7d75052ec4c4fca3caafc7a4894a.1629057790.git.mhaeuser@posteo.de>

Marvin,
So lucky to have you in the edk2 project looking into these fundamentals!

+  #define ALIGNOF(TYPE) OFFSET_OF (struct { CHAR8 C; TYPE A; }, A)

1. Does struct{} inside a macro conform to C standard? How is the compatibility with different compilers?

+#define IS_POW2(Value)  ((Value) != 0U && ((Value) & ((Value) - 1U)) == 
+0U)

2. Good to me. I learned this trick when implementing the MtrrLib.

+#define ALIGN_VALUE_ADDEND(Value, Alignment)  (((Alignment) - (Value)) 
+& ((Alignment) - 1U))

3. Is any other open source project using the same macro for the addend?
This is actually a general question to all new macros.
I would like the macros look familiar to developers from other open source projects.

  reply	other threads:[~2021-08-16  9:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-15 20:11 [PATCH V2 1/3] MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions Marvin Häuser
2021-08-15 20:11 ` [PATCH V2 2/3] MdePkg/Base.h: Introduce various alignment-related macros Marvin Häuser
2021-08-16  9:42   ` Ni, Ray [this message]
2021-08-16 13:10     ` [edk2-devel] " Marvin Häuser
2021-08-17  1:17       ` Ni, Ray
2021-11-23 10:12       ` Marvin Häuser
2021-12-08  9:10         ` mjsbeaton
2021-12-08 10:36           ` Marvin Häuser
2022-03-22 19:06         ` Marvin Häuser
2021-08-15 20:11 ` [PATCH V2 3/3] MdeModulePkg: Consume new " Marvin Häuser
2021-08-20  5:21   ` [edk2-devel] " Wu, Hao A
2021-08-20  5:21 ` [PATCH V2 1/3] MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions Wu, Hao A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB4930B865265F96EF826367418CFD9@CO1PR11MB4930.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox