diff options
author | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-22 02:39:57 +0000 |
---|---|---|
committer | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-22 02:39:57 +0000 |
commit | 265fa9fa399225509fe2f9b5b24c3619e30aa411 (patch) | |
tree | 00258ce3ea353ce62e9ed1d4b92ae1af058700f2 | |
parent | 53c31c516489d4cd46d20d59a3705720be3443f1 (diff) | |
download | edk2-platforms-265fa9fa399225509fe2f9b5b24c3619e30aa411.tar.xz |
MdePkg: Add a new macro VA_COPY for variable argument support. Fix a bug in the UefiLib instance that there is a non portable assumption that Marker is copied when passed to a function.
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
-rw-r--r-- | MdePkg/Include/Base.h | 20 | ||||
-rw-r--r-- | MdePkg/Library/UefiLib/UefiLibPrint.c | 5 |
2 files changed, 23 insertions, 2 deletions
diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 4fcc3a1bf6..66fc5d271b 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -6,7 +6,7 @@ environment. There are a set of base libraries in the Mde Package that can
be used to implement base modules.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -393,6 +393,7 @@ struct _LIST_ENTRY { // VA_END (VA_LIST Marker) - Clear Marker
// VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argument from
// the ... list. You must know the size and pass it in this macro.
+// VA_COPY (VA_LIST Dest, VA_LIST Start) - Initialize Dest as a copy of Start.
//
// example:
//
@@ -454,6 +455,8 @@ struct _LIST_ENTRY { #define VA_END(Marker) ((void)0)
+#define VA_COPY(Dest, Start) __va_copy (Dest, Start)
+
#elif defined(__GNUC__) && !defined(NO_BUILTIN_VA_FUNCS)
//
// Use GCC built-in macros for variable argument lists.
@@ -471,6 +474,8 @@ typedef __builtin_va_list VA_LIST; #define VA_END(Marker) __builtin_va_end (Marker)
+#define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)
+
#else
///
/// Variable used to traverse the list of arguments. This type can vary by
@@ -526,6 +531,19 @@ typedef CHAR8 *VA_LIST; **/
#define VA_END(Marker) (Marker = (VA_LIST) 0)
+/**
+ Initializes a VA_LIST as a copy of an existing VA_LIST.
+
+ This macro initializes Dest as a copy of Start, as if the VA_START macro had been applied to Dest
+ followed by the same sequence of uses of the VA_ARG macro as had previously been used to reach
+ the present state of Start.
+
+ @param Dest VA_LIST used to traverse the list of arguments.
+ @param Start VA_LIST used to traverse the list of arguments.
+
+**/
+#define VA_COPY(Dest, Start) ((void)((Dest) = (Start)))
+
#endif
///
diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c index 6eadc120c8..1bf6d26821 100644 --- a/MdePkg/Library/UefiLib/UefiLibPrint.c +++ b/MdePkg/Library/UefiLib/UefiLibPrint.c @@ -742,8 +742,11 @@ CatVSPrint ( UINTN CharactersRequired;
UINTN SizeRequired;
CHAR16 *BufferToReturn;
+ VA_LIST ExtraMarker;
- CharactersRequired = SPrintLength(FormatString, Marker);
+ VA_COPY (ExtraMarker, Marker);
+ CharactersRequired = SPrintLength(FormatString, ExtraMarker);
+ VA_END (ExtraMarker);
if (String != NULL) {
SizeRequired = StrSize(String) + (CharactersRequired * sizeof(CHAR16));
|