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>
This commit is contained in:
Alex James 2019-11-28 13:56:45 +08:00 committed by mergify[bot]
parent 665afccc52
commit 796b380ca7
1 changed files with 1 additions and 3 deletions

View File

@ -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))