From: Shi, Steven Date: Fri, 15 Jul 2016 22:16:08 +0000 (+0200) Subject: MdePkg: Enable new MS VA intrinsics for GNUC x86 64bits build X-Git-Tag: edk2-stable201903~6238 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=48d5f9a551a93acb45f272dda879b0ab5a504e36 MdePkg: Enable new MS VA intrinsics for GNUC x86 64bits build Both GCC and LLVM 3.8 64bits support new variable argument (VA) intrinsics for Microsoft ABI, enable these new VA intrinsics for GNUC family 64bits code build. These VA intrinsics are only permitted use in 64bits code, so not use them in 32bits code build. The original 32bits GNU VA intrinsics has the same calling convention as MS, so we don't need change them. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Steven Shi [ardb: update CPP logic so that the change only applies to X64] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Jordan Justen Tested-by: Laszlo Ersek Tested-By: Liming Gao Reviewed-by: Liming Gao --- diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 7dbf9386b6..e03fa82392 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -590,6 +590,30 @@ struct _LIST_ENTRY { #define VA_COPY(Dest, Start) __va_copy (Dest, Start) #elif defined(__GNUC__) && !defined(NO_BUILTIN_VA_FUNCS) + +#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS) +// +// X64 only. Use MS ABI version of GCC built-in macros for variable argument lists. +// +/// +/// Both GCC and LLVM 3.8 for X64 support new variable argument intrinsics for Microsoft ABI +/// + +/// +/// Variable used to traverse the list of arguments. This type can vary by +/// implementation and could be an array or structure. +/// +typedef __builtin_ms_va_list VA_LIST; + +#define VA_START(Marker, Parameter) __builtin_ms_va_start (Marker, Parameter) + +#define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE))) + +#define VA_END(Marker) __builtin_ms_va_end (Marker) + +#define VA_COPY(Dest, Start) __builtin_ms_va_copy (Dest, Start) + +#else // // Use GCC built-in macros for variable argument lists. // @@ -608,6 +632,8 @@ typedef __builtin_va_list VA_LIST; #define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start) +#endif + #else /// /// Variable used to traverse the list of arguments. This type can vary by