* [PATCH] MdePkg/BasePrintLib: Add %z specifier
@ 2022-07-05 0:03 Pedro Falcato
2022-07-05 1:01 ` 回复: " gaoliming
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Falcato @ 2022-07-05 0:03 UTC (permalink / raw)
To: devel; +Cc: Michael D Kinney, Liming Gao, Zhiguang Liu
%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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* 回复: [PATCH] MdePkg/BasePrintLib: Add %z specifier
2022-07-05 0:03 [PATCH] MdePkg/BasePrintLib: Add %z specifier Pedro Falcato
@ 2022-07-05 1:01 ` gaoliming
2022-07-05 1:17 ` [edk2-devel] " Pedro Falcato
0 siblings, 1 reply; 3+ messages in thread
From: gaoliming @ 2022-07-05 1:01 UTC (permalink / raw)
To: 'Pedro Falcato', devel
Cc: 'Michael D Kinney', 'Zhiguang Liu'
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [edk2-devel] 回复: [PATCH] MdePkg/BasePrintLib: Add %z specifier
2022-07-05 1:01 ` 回复: " gaoliming
@ 2022-07-05 1:17 ` Pedro Falcato
0 siblings, 0 replies; 3+ messages in thread
From: Pedro Falcato @ 2022-07-05 1:17 UTC (permalink / raw)
To: edk2-devel-groups-io, Liming Gao; +Cc: Michael D Kinney, Zhiguang Liu
[-- Attachment #1: Type: text/plain, Size: 3027 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 4595 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-05 1:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-05 0:03 [PATCH] MdePkg/BasePrintLib: Add %z specifier Pedro Falcato
2022-07-05 1:01 ` 回复: " gaoliming
2022-07-05 1:17 ` [edk2-devel] " Pedro Falcato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox