public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
@ 2019-11-28  5:56 Alex James
  2019-11-28 13:16 ` [edk2-devel] " Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Alex James @ 2019-11-28  5:56 UTC (permalink / raw)
  To: devel; +Cc: Michael D Kinney, Liming Gao

CLANGPDB does not define __GNUC__, but it does define __clang__. Check
for the __clang__ preprocessor definition to use __builtin_offsetof to
implement the OFFSET_OF macro.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Alex James <theracermaster@gmail.com>
---
 MdePkg/Include/Base.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index 4680e64136..e0bcd0ae67 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
   @return  Offset, in bytes, of field.
 
 **/
-#ifdef __GNUC__
-#if __GNUC__ >= 4
+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
 #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
 #endif
-#endif
 
 #ifndef OFFSET_OF
 #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
-- 
2.24.0


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

end of thread, other threads:[~2019-12-20  6:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-28  5:56 [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Alex James
2019-11-28 13:16 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-11-29  0:23 ` Liming Gao
2019-11-29  6:11 ` Liming Gao
     [not found] ` <15DB8D5B995A93E2.20368@groups.io>
2019-12-10  0:50   ` [edk2-devel] " Liming Gao
     [not found]   ` <15DEDC2D7232490F.29160@groups.io>
2019-12-18  2:06     ` Liming Gao
     [not found]     ` <15E15503EA811A55.14752@groups.io>
2019-12-20  6:10       ` Liming Gao

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