summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-08 02:27:46 +0000
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-08 02:27:46 +0000
commit130a2eecc44b762345d5ff704e9d599b25e0f091 (patch)
tree8c83cceac6ead92aa5fe1feb665d30468ca04098 /MdePkg
parent7c9d25ae76f53b3cf20f615ae8902eef1648c5b5 (diff)
downloadedk2-130a2eecc44b762345d5ff704e9d599b25e0f091.tar.gz
edk2-130a2eecc44b762345d5ff704e9d599b25e0f091.tar.bz2
edk2-130a2eecc44b762345d5ff704e9d599b25e0f091.zip
The GCC compiler’s behavior is different than the Microsoft compilers for statically linked vararg functions. The GCC compilers do provide __builtin_ functions for accessing varargs. we should use these intrinsic functions with GCC
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8260 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Base.h15
1 files changed, 15 insertions, 0 deletions
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.