[edk2-devel] [PATCH V2 2/3] MdePkg/Base.h: Introduce various alignment-related macros
Ni, Ray
ray.ni at intel.com
Mon Aug 16 09:42:37 UTC 2021
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.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79344): https://edk2.groups.io/g/devel/message/79344
Mute This Topic: https://groups.io/mt/84909448/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