]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add a new macro VA_COPY for variable argument support. Fix a bug in the UefiL...
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 22 Feb 2012 02:39:57 +0000 (02:39 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 22 Feb 2012 02:39:57 +0000 (02:39 +0000)
Signed-off-by: rsun3
Reviewed-by: mdkinney
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13025 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Base.h
MdePkg/Library/UefiLib/UefiLibPrint.c

index 4fcc3a1bf651ecca2d22a7d981fcb23eaebab3c1..66fc5d271b23e01b9ebacc305bd9eb8135d8e11e 100644 (file)
@@ -6,7 +6,7 @@
   environment. There are a set of base libraries in the Mde Package that can\r
   be used to implement base modules.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -393,6 +393,7 @@ struct _LIST_ENTRY {
 //  VA_END (VA_LIST Marker) - Clear Marker\r
 //  VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argument from\r
 //    the ... list. You must know the size and pass it in this macro.\r
+//  VA_COPY (VA_LIST Dest, VA_LIST Start) - Initialize Dest as a copy of Start.\r
 //\r
 //  example:\r
 //\r
@@ -454,6 +455,8 @@ struct _LIST_ENTRY {
 \r
 #define VA_END(Marker)                ((void)0)\r
 \r
+#define VA_COPY(Dest, Start)          __va_copy (Dest, Start)\r
+\r
 #elif defined(__GNUC__) && !defined(NO_BUILTIN_VA_FUNCS)\r
 //\r
 // Use GCC built-in macros for variable argument lists.\r
@@ -471,6 +474,8 @@ typedef __builtin_va_list VA_LIST;
 \r
 #define VA_END(Marker)               __builtin_va_end (Marker)\r
 \r
+#define VA_COPY(Dest, Start)         __builtin_va_copy (Dest, Start)\r
+\r
 #else\r
 ///\r
 /// Variable used to traverse the list of arguments. This type can vary by\r
@@ -526,6 +531,19 @@ typedef CHAR8 *VA_LIST;
 **/\r
 #define VA_END(Marker)      (Marker = (VA_LIST) 0)\r
 \r
+/**\r
+  Initializes a VA_LIST as a copy of an existing VA_LIST.\r
+\r
+  This macro initializes Dest as a copy of Start, as if the VA_START macro had been applied to Dest\r
+  followed by the same sequence of uses of the VA_ARG macro as had previously been used to reach\r
+  the present state of Start. \r
+\r
+  @param   Dest   VA_LIST used to traverse the list of arguments.\r
+  @param   Start  VA_LIST used to traverse the list of arguments.\r
+\r
+**/\r
+#define VA_COPY(Dest, Start)  ((void)((Dest) = (Start)))\r
+\r
 #endif\r
 \r
 ///\r
index 6eadc120c82021ad95d01ab11f0d17fbe9fc4752..1bf6d26821e32bf5ab67e9e6ed1ba93d5c0c375b 100644 (file)
@@ -742,8 +742,11 @@ CatVSPrint (
   UINTN   CharactersRequired;\r
   UINTN   SizeRequired;\r
   CHAR16  *BufferToReturn;\r
+  VA_LIST ExtraMarker;\r
 \r
-  CharactersRequired = SPrintLength(FormatString, Marker);\r
+  VA_COPY (ExtraMarker, Marker);\r
+  CharactersRequired = SPrintLength(FormatString, ExtraMarker);\r
+  VA_END (ExtraMarker);\r
 \r
   if (String != NULL) {\r
     SizeRequired = StrSize(String) + (CharactersRequired * sizeof(CHAR16));\r