]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add %u and %lu support for PrintLib and DebugLib.
authorQiu Shumin <shumin.qiu@intel.com>
Mon, 8 Jun 2015 05:37:31 +0000 (05:37 +0000)
committershenshushi <shenshushi@Edk2>
Mon, 8 Jun 2015 05:37:31 +0000 (05:37 +0000)
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

MdePkg/Include/Library/PrintLib.h
MdePkg/Library/BasePrintLib/PrintLibInternal.c
MdePkg/Library/BasePrintLib/PrintLibInternal.h

index 908c93b3c802a04b779528c35d1310d22dc4bc66..fcaacde6522a763893eda0bfd299557790c2f96a 100644 (file)
@@ -2,7 +2,7 @@
   Provides services to print a formatted string to a buffer. All combinations of\r
   Unicode and ASCII strings are supported.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -89,6 +89,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     - d\r
       - The argument is a signed decimal number.  If the flag 'L' is not specified, \r
         then the argument is assumed to be size int.  \r
+    - u\r
+      - The argument is a unsigned decimal number.  If the flag 'L' is not specified, \r
+        then the argument is assumed to be size int.\r
     - p\r
       - The argument is a pointer that is a (VOID *), and it is printed as an \r
         unsigned hexadecimal number  The characters used are 0..9 and A..F.\r
index 8dc5ec73814886b153048d7d002531efe8bda68b..a114bde13a9b7d9120cc08423faff61f9a4db4a4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Print Library internal worker functions.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, Intel Corporation. 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
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -547,10 +547,18 @@ BasePrintLibSPrintMarker (
         //\r
         // break skipped on purpose\r
         //\r
+      case 'u':\r
+        if ((Flags & RADIX_HEX) == 0) {\r
+          Flags &= ~((UINTN) (PREFIX_SIGN));\r
+          Flags |= UNSIGNED_TYPE;\r
+        }\r
+        //\r
+        // break skipped on purpose\r
+        //\r
       case 'd':\r
         if ((Flags & LONG_TYPE) == 0) {\r
           //\r
-          // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
+          // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
           // This assumption is made so the format string definition is compatible with the ANSI C\r
           // Specification for formatted strings.  It is recommended that the Base Types be used \r
           // everywhere, but in this one case, compliance with ANSI C is more important, and \r
@@ -584,17 +592,27 @@ BasePrintLibSPrintMarker (
             Flags &= ~((UINTN) PREFIX_ZERO);\r
             Precision = 1;\r
           }\r
-          if (Value < 0) {\r
+          if (Value < 0 && (Flags & UNSIGNED_TYPE) == 0) {\r
             Flags |= PREFIX_SIGN;\r
             Prefix = '-';\r
             Value = -Value;\r
+          } else if ((Flags & UNSIGNED_TYPE) != 0 && (Flags & LONG_TYPE) == 0) {\r
+            //\r
+            // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
+            // This assumption is made so the format string definition is compatible with the ANSI C\r
+            // Specification for formatted strings.  It is recommended that the Base Types be used \r
+            // everywhere, but in this one case, compliance with ANSI C is more important, and \r
+            // provides an implementation that is compatible with that largest possible set of CPU \r
+            // architectures.  This is why the type "unsigned int" is used in this one case.\r
+            //\r
+            Value = (unsigned int)Value;\r
           }\r
         } else {\r
           Radix = 16;\r
           Comma = FALSE;\r
           if ((Flags & LONG_TYPE) == 0 && Value < 0) {\r
             //\r
-            // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
+            // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
             // This assumption is made so the format string definition is compatible with the ANSI C\r
             // Specification for formatted strings.  It is recommended that the Base Types be used \r
             // everywhere, but in this one case, compliance with ANSI C is more important, and \r
index 32a21266c82b26c035851141eb890e57a7ba46bb..05f2e1bc99b509d10f78fe351adc806067bdc525 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Base Print Library instance Internal Functions definition.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, Intel Corporation. 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
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -34,6 +34,7 @@
 #define PRECISION             BIT11\r
 #define ARGUMENT_REVERSED     BIT12\r
 #define COUNT_ONLY_NO_PRINT   BIT13\r
+#define UNSIGNED_TYPE         BIT14\r
 \r
 //\r
 // Record date and time information\r