summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorAlex James <theracermaster@gmail.com>2019-11-28 13:56:45 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2019-12-20 05:54:06 +0000
commit796b380ca7d263ca504b82fe5317a78d3546d537 (patch)
treef9764a2d9aebdd3edc774f82c6984a8470f2e597 /MdePkg
parent665afccc52e1a02ee329147e02f04b8e9cf1d571 (diff)
downloadedk2-796b380ca7d263ca504b82fe5317a78d3546d537.tar.gz
edk2-796b380ca7d263ca504b82fe5317a78d3546d537.tar.bz2
edk2-796b380ca7d263ca504b82fe5317a78d3546d537.zip
MdePkg: Use __builtin_offset with CLANGPDB toolchain
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2393 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> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Base.h4
1 files changed, 1 insertions, 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))