From 130a2eecc44b762345d5ff704e9d599b25e0f091 Mon Sep 17 00:00:00 2001 From: eric_tian Date: Fri, 8 May 2009 02:27:46 +0000 Subject: [PATCH] =?UTF-8?q?The=20GCC=20compiler=E2=80=99s=20behavior=20is?= =?UTF-8?q?=20different=20than=20the=20Microsoft=20compilers=20for=20stati?= =?UTF-8?q?cally=20linked=20vararg=20functions.=20The=20GCC=20compilers=20?= =?UTF-8?q?do=20provide=20=5F=5Fbuiltin=5F=20functions=20for=20accessing?= =?UTF-8?q?=20varargs.=20we=20should=20use=20these=20intrinsic=20functions?= =?UTF-8?q?=20with=20GCC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8260 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Base.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 00cce609f5..69ebba345e 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -332,7 +332,20 @@ struct _LIST_ENTRY { // return Result // } // +#if defined(__GNUC__) +// +// In GCC compiler, its behavior for statically linked varargs is different with MSFT tool chain. +// Should use __builtin_* intrinsic functions provided by GCC compiler to access varargs. +// +typedef __builtin_va_list VA_LIST; +#define VA_START(Marker, Parameter) __builtin_va_start(Marker, Parameter) + +#define VA_ARG(Marker, TYPE) __builtin_va_arg(Marker, TYPE) + +#define VA_END(Marker) __builtin_va_end(Marker) + +#else /** Return the size of argument that has been aligned to sizeof (UINTN). @@ -394,6 +407,8 @@ typedef CHAR8 *VA_LIST; **/ #define VA_END(Marker) (Marker = (VA_LIST) 0) +#endif + /** Macro that returns the byte offset of a field in a data structure.