MdePkg/Library/BasePrintLib/PrintLibInternal.c | 9 +++++++++ MdePkg/Library/BasePrintLib/PrintLibInternal.h | 1 + 2 files changed, 10 insertions(+)
%z is used in standard C99 as the printf specifier for size_t types.
Add support for it so we can portably print UINTN.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
---
MdePkg/Library/BasePrintLib/PrintLibInternal.c | 9 +++++++++
MdePkg/Library/BasePrintLib/PrintLibInternal.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
index 42b598a432..1cd99b2213 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
@@ -720,6 +720,9 @@ BasePrintLibSPrintMarker (
case 'l':
Flags |= LONG_TYPE;
break;
+ case 'z':
+ Flags |= SIZET_TYPE;
+ break;
case '*':
if ((Flags & PRECISION) == 0) {
Flags |= PAD_TO_WIDTH;
@@ -833,6 +836,12 @@ BasePrintLibSPrintMarker (
} else {
Value = BASE_ARG (BaseListMarker, int);
}
+ } else if ((Flags & SIZET_TYPE) != 0) {
+ if (BaseListMarker == NULL) {
+ Value = VA_ARG (VaListMarker, UINTN);
+ } else {
+ Value = BASE_ARG (BaseListMarker, UINTN);
+ }
} else {
if (BaseListMarker == NULL) {
Value = VA_ARG (VaListMarker, INT64);
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
index 34d591c6fc..9193e6192b 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
@@ -29,6 +29,7 @@
#define ARGUMENT_REVERSED BIT12
#define COUNT_ONLY_NO_PRINT BIT13
#define UNSIGNED_TYPE BIT14
+#define SIZET_TYPE BIT15
//
// Record date and time information
--
2.37.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91051): https://edk2.groups.io/g/devel/message/91051
Mute This Topic: https://groups.io/mt/92176193/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Pedro: Please also add %z description in Edk2\MdePkg\Include\Library\PrintLib.h. And, please also submit one BZ for this change. This is a new feature. Thanks Liming > -----邮件原件----- > 发件人: Pedro Falcato <pedro.falcato@gmail.com> > 发送时间: 2022年7月5日 8:04 > 收件人: devel@edk2.groups.io > 抄送: Michael D Kinney <michael.d.kinney@intel.com>; Liming Gao > <gaoliming@byosoft.com.cn>; Zhiguang Liu <zhiguang.liu@intel.com> > 主题: [PATCH] MdePkg/BasePrintLib: Add %z specifier > > %z is used in standard C99 as the printf specifier for size_t types. > Add support for it so we can portably print UINTN. > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> > --- > MdePkg/Library/BasePrintLib/PrintLibInternal.c | 9 +++++++++ > MdePkg/Library/BasePrintLib/PrintLibInternal.h | 1 + > 2 files changed, 10 insertions(+) > > diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c > b/MdePkg/Library/BasePrintLib/PrintLibInternal.c > index 42b598a432..1cd99b2213 100644 > --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c > +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c > @@ -720,6 +720,9 @@ BasePrintLibSPrintMarker ( > case 'l': > Flags |= LONG_TYPE; > break; > + case 'z': > + Flags |= SIZET_TYPE; > + break; > case '*': > if ((Flags & PRECISION) == 0) { > Flags |= PAD_TO_WIDTH; > @@ -833,6 +836,12 @@ BasePrintLibSPrintMarker ( > } else { > Value = BASE_ARG (BaseListMarker, int); > } > + } else if ((Flags & SIZET_TYPE) != 0) { > + if (BaseListMarker == NULL) { > + Value = VA_ARG (VaListMarker, UINTN); > + } else { > + Value = BASE_ARG (BaseListMarker, UINTN); > + } > } else { > if (BaseListMarker == NULL) { > Value = VA_ARG (VaListMarker, INT64); > diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h > b/MdePkg/Library/BasePrintLib/PrintLibInternal.h > index 34d591c6fc..9193e6192b 100644 > --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h > +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h > @@ -29,6 +29,7 @@ > #define ARGUMENT_REVERSED BIT12 > #define COUNT_ONLY_NO_PRINT BIT13 > #define UNSIGNED_TYPE BIT14 > +#define SIZET_TYPE BIT15 > > // > // Record date and time information > -- > 2.37.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91054): https://edk2.groups.io/g/devel/message/91054 Mute This Topic: https://groups.io/mt/92177026/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Fixed in v2. On Tue, Jul 5, 2022 at 2:01 AM gaoliming via groups.io <gaoliming= byosoft.com.cn@groups.io> wrote: > Pedro: > Please also add %z description in > Edk2\MdePkg\Include\Library\PrintLib.h. > > And, please also submit one BZ for this change. This is a new feature. > > Thanks > Liming > > > -----邮件原件----- > > 发件人: Pedro Falcato <pedro.falcato@gmail.com> > > 发送时间: 2022年7月5日 8:04 > > 收件人: devel@edk2.groups.io > > 抄送: Michael D Kinney <michael.d.kinney@intel.com>; Liming Gao > > <gaoliming@byosoft.com.cn>; Zhiguang Liu <zhiguang.liu@intel.com> > > 主题: [PATCH] MdePkg/BasePrintLib: Add %z specifier > > > > %z is used in standard C99 as the printf specifier for size_t types. > > Add support for it so we can portably print UINTN. > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > > Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> > > --- > > MdePkg/Library/BasePrintLib/PrintLibInternal.c | 9 +++++++++ > > MdePkg/Library/BasePrintLib/PrintLibInternal.h | 1 + > > 2 files changed, 10 insertions(+) > > > > diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c > > b/MdePkg/Library/BasePrintLib/PrintLibInternal.c > > index 42b598a432..1cd99b2213 100644 > > --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c > > +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c > > @@ -720,6 +720,9 @@ BasePrintLibSPrintMarker ( > > case 'l': > > Flags |= LONG_TYPE; > > break; > > + case 'z': > > + Flags |= SIZET_TYPE; > > + break; > > case '*': > > if ((Flags & PRECISION) == 0) { > > Flags |= PAD_TO_WIDTH; > > @@ -833,6 +836,12 @@ BasePrintLibSPrintMarker ( > > } else { > > Value = BASE_ARG (BaseListMarker, int); > > } > > + } else if ((Flags & SIZET_TYPE) != 0) { > > + if (BaseListMarker == NULL) { > > + Value = VA_ARG (VaListMarker, UINTN); > > + } else { > > + Value = BASE_ARG (BaseListMarker, UINTN); > > + } > > } else { > > if (BaseListMarker == NULL) { > > Value = VA_ARG (VaListMarker, INT64); > > diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h > > b/MdePkg/Library/BasePrintLib/PrintLibInternal.h > > index 34d591c6fc..9193e6192b 100644 > > --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h > > +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h > > @@ -29,6 +29,7 @@ > > #define ARGUMENT_REVERSED BIT12 > > #define COUNT_ONLY_NO_PRINT BIT13 > > #define UNSIGNED_TYPE BIT14 > > +#define SIZET_TYPE BIT15 > > > > // > > // Record date and time information > > -- > > 2.37.0 > > > > > > > > > -- Pedro Falcato -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91056): https://edk2.groups.io/g/devel/message/91056 Mute This Topic: https://groups.io/mt/92177026/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.