From nobody Fri May 17 09:38:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+91055+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91055+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1656983787; cv=none; d=zohomail.com; s=zohoarc; b=WjsJ2q1OcSknLHsH7r08vPa3iU0cvxDivFsXA5Zx4dpjmzafRcvbMtAB2JRm+mdjnjED3eeq3ReR8ZBVe3mDXkKf6Ly6LIf/KdIsxmnqPbqczreAySRJRAVpXhl3rNARD6CLnX1RF9OSfeql6VqS/+zgJQOsrnhYlS7/q2L3MUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656983787; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Ydk6UDRAB9nEozIKcDKM5IxGqpqSvmBRbT14uwihsQU=; b=A4SyxqGiue9iNSnADW1ZlNUzHt8ywTbZHPAjE5Um4Jg2lapH+TDJYdRLgE4TcK+Och51xjt89eWVVbX0SMkSilhm16KnNIqoLMRreJlroFGLaXOskYGJLbBU5ZjNZWSfXf8muS26y2/yCeoP+9dxVt5/LKGxjNoe/PdrpRYrCb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91055+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1656983787533311.4208547979614; Mon, 4 Jul 2022 18:16:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id niQBYY1788612xTPiZfufDqm; Mon, 04 Jul 2022 18:16:26 -0700 X-Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mx.groups.io with SMTP id smtpd.web09.79753.1656983785871800897 for ; Mon, 04 Jul 2022 18:16:26 -0700 X-Received: by mail-wm1-f41.google.com with SMTP id v67-20020a1cac46000000b003a1888b9d36so6409431wme.0 for ; Mon, 04 Jul 2022 18:16:25 -0700 (PDT) X-Gm-Message-State: pqWB0mLRZ5kNa8hKKSoVK04ix1787277AA= X-Google-Smtp-Source: AGRyM1sU2K8Zo114kJQIJHKl59HZ8axw9y345wzsT3bAiVPagl/6WE1JcbgmWR6bmIrBvaEcPxMlxA== X-Received: by 2002:a1c:7918:0:b0:3a0:4c75:87af with SMTP id l24-20020a1c7918000000b003a04c7587afmr35067687wme.194.1656983783967; Mon, 04 Jul 2022 18:16:23 -0700 (PDT) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id bg28-20020a05600c3c9c00b003a175bc9c17sm17534261wmb.42.2022.07.04.18.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 18:16:23 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH v2] MdePkg/BasePrintLib: Add %z specifier Date: Tue, 5 Jul 2022 02:16:22 +0100 Message-Id: <20220705011622.351454-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1656983786; bh=WVSYy86LL5V53tvVxHlxYDl6bLTO+uKX0W1y6SCLvSw=; h=Cc:Date:From:Reply-To:Subject:To; b=LFikcyto0de+vG37Kic0HpMyW+D3gki+raW/4AiyIhTI6V14hYTt9ZeJDzXzaPD3f+b DAqmRQqVmu4a3VgulYk0cqqP1m2SP7DtfszPOvMAzSXFATsPOssYCGWznF2joxaS/Ee12 MCmqlOmsupICRWeuKwjWQYeruaW8jE+RZnI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1656983788357100001 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3977 %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 Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Pedro Falcato --- MdePkg/Include/Library/PrintLib.h | 13 ++++++++----- MdePkg/Library/BasePrintLib/PrintLibInternal.c | 9 +++++++++ MdePkg/Library/BasePrintLib/PrintLibInternal.h | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/MdePkg/Include/Library/PrintLib.h b/MdePkg/Include/Library/Pri= ntLib.h index 8d523cac52..0d67f62d3f 100644 --- a/MdePkg/Include/Library/PrintLib.h +++ b/MdePkg/Include/Library/PrintLib.h @@ -42,6 +42,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - L, l - The number being printed is size UINT64. Only valid for types X, = x, and d. If this flag is not specified, then the number being printed is si= ze int. + - z + - The number being printed is of size UINTN. Only valid for types X,= x and d. + If this flag is not specified, then the number being printed is si= ze int. - NOTE: All invalid flags are ignored. =20 [width]: @@ -73,18 +76,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent using this type too by making sure bits 8..15 of the argument are = set to 0. - x - The argument is an unsigned hexadecimal number. The characters us= ed are 0..9 and - A..F. If the flag 'L' is not specified, then the argument is assu= med + A..F. If the flags 'L', 'z' are not specified, then the argument = is assumed to be size int. This does not follow ANSI C. - X - The argument is an unsigned hexadecimal number and the number is p= added with - zeros. This is equivalent to a format string of "0x". If the flag - 'L' is not specified, then the argument is assumed to be size int. + zeros. This is equivalent to a format string of "0x". If the flags + 'L', 'z' are not specified, then the argument is assumed to be siz= e int. This does not follow ANSI C. - d - - The argument is a signed decimal number. If the flag 'L' is not s= pecified, + - The argument is a signed decimal number. If the flags 'L', 'z' ar= e not specified, then the argument is assumed to be size int. - u - - The argument is a unsigned decimal number. If the flag 'L' is not= specified, + - The argument is a unsigned decimal number. If the flags 'L'. 'z' = are not specified, then the argument is assumed to be size int. - p - The argument is a pointer that is a (VOID *), and it is printed as= an diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Librar= y/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 |=3D LONG_TYPE; break; + case 'z': + Flags |=3D SIZET_TYPE; + break; case '*': if ((Flags & PRECISION) =3D=3D 0) { Flags |=3D PAD_TO_WIDTH; @@ -833,6 +836,12 @@ BasePrintLibSPrintMarker ( } else { Value =3D BASE_ARG (BaseListMarker, int); } + } else if ((Flags & SIZET_TYPE) !=3D 0) { + if (BaseListMarker =3D=3D NULL) { + Value =3D VA_ARG (VaListMarker, UINTN); + } else { + Value =3D BASE_ARG (BaseListMarker, UINTN); + } } else { if (BaseListMarker =3D=3D NULL) { Value =3D VA_ARG (VaListMarker, INT64); diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Librar= y/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 =20 // // Record date and time information --=20 2.37.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91055): https://edk2.groups.io/g/devel/message/91055 Mute This Topic: https://groups.io/mt/92177290/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-