summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-06-08 05:37:31 +0000
committershenshushi <shenshushi@Edk2>2015-06-08 05:37:31 +0000
commit9ade4339658e962c067d01f12ff83f1c2dab13ab (patch)
tree84609daa43b6d72ee791542fe1c633876603758a /MdePkg/Library
parent796fecd84b740f24c26f0791a6cde122517fa2df (diff)
downloadedk2-9ade4339658e962c067d01f12ff83f1c2dab13ab.tar.gz
edk2-9ade4339658e962c067d01f12ff83f1c2dab13ab.tar.bz2
edk2-9ade4339658e962c067d01f12ff83f1c2dab13ab.zip
MdePkg: Add %u and %lu support for PrintLib and DebugLib.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17571 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.c26
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.h3
2 files changed, 24 insertions, 5 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
index 8dc5ec7381..a114bde13a 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
@@ -1,7 +1,7 @@
/** @file
Print Library internal worker functions.
- Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -547,10 +547,18 @@ BasePrintLibSPrintMarker (
//
// break skipped on purpose
//
+ case 'u':
+ if ((Flags & RADIX_HEX) == 0) {
+ Flags &= ~((UINTN) (PREFIX_SIGN));
+ Flags |= UNSIGNED_TYPE;
+ }
+ //
+ // break skipped on purpose
+ //
case 'd':
if ((Flags & LONG_TYPE) == 0) {
//
- // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
// This assumption is made so the format string definition is compatible with the ANSI C
// Specification for formatted strings. It is recommended that the Base Types be used
// everywhere, but in this one case, compliance with ANSI C is more important, and
@@ -584,17 +592,27 @@ BasePrintLibSPrintMarker (
Flags &= ~((UINTN) PREFIX_ZERO);
Precision = 1;
}
- if (Value < 0) {
+ if (Value < 0 && (Flags & UNSIGNED_TYPE) == 0) {
Flags |= PREFIX_SIGN;
Prefix = '-';
Value = -Value;
+ } else if ((Flags & UNSIGNED_TYPE) != 0 && (Flags & LONG_TYPE) == 0) {
+ //
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // This assumption is made so the format string definition is compatible with the ANSI C
+ // Specification for formatted strings. It is recommended that the Base Types be used
+ // everywhere, but in this one case, compliance with ANSI C is more important, and
+ // provides an implementation that is compatible with that largest possible set of CPU
+ // architectures. This is why the type "unsigned int" is used in this one case.
+ //
+ Value = (unsigned int)Value;
}
} else {
Radix = 16;
Comma = FALSE;
if ((Flags & LONG_TYPE) == 0 && Value < 0) {
//
- // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
// This assumption is made so the format string definition is compatible with the ANSI C
// Specification for formatted strings. It is recommended that the Base Types be used
// everywhere, but in this one case, compliance with ANSI C is more important, and
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
index 32a21266c8..05f2e1bc99 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
@@ -1,7 +1,7 @@
/** @file
Base Print Library instance Internal Functions definition.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -34,6 +34,7 @@
#define PRECISION BIT11
#define ARGUMENT_REVERSED BIT12
#define COUNT_ONLY_NO_PRINT BIT13
+#define UNSIGNED_TYPE BIT14
//
// Record date and time information