From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31780 invoked from network); 26 May 2023 21:00:16 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 26 May 2023 21:00:16 -0000 Received: (qmail 11866 invoked by uid 550); 26 May 2023 21:00:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11834 invoked from network); 26 May 2023 21:00:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version; bh=eQIGUrW8lR63er4Xj2tRNO/ogFst44VCMbx5v5nXobI=; b=IA3rpY+YcKwoCP9dU71gYO+HmpYgMphp21KH8v/zwbBID+44VYWLXPlM 7yVlxrSyEDPooi2yGJOgizIYAGuuAjYJqrsBF+/YlAlzxoFy/7WLrImo7 B1vK5hoIQ2b8LFndeFlbjxu2WrjpLqn1Bl1LQQL0n81bTkKVucvfeHSKc c=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=jens.gustedt@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.00,195,1681164000"; d="scan'208";a="57139719" Date: Fri, 26 May 2023 23:00:00 +0200 From: =?UTF-8?B?SuKCkeKCmeKCmw==?= Gustedt To: Rich Felker Cc: musl@lists.openwall.com Message-ID: <20230526230000.67b24cd6@inria.fr> In-Reply-To: <20230526203358.GO4163@brightrain.aerifal.cx> References: <20230526203358.GO4163@brightrain.aerifal.cx> Organization: inria.fr X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) X-Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAACRQTFRFERslNjAsLTE9Ok9wUk9TaUs8iWhSrYZkj42Rz6aD3sGZ MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/sDYRnH7HkzJA7DmnIDlFi.f"; protocol="application/pgp-signature"; micalg=pgp-sha1 Subject: Re: [musl] [C23 printf 3/3] C23: implement the wfN length modifiers for printf --Sig_/sDYRnH7HkzJA7DmnIDlFi.f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Rich, on Fri, 26 May 2023 16:33:59 -0400 you (Rich Felker ) wrote: > On Fri, May 26, 2023 at 09:41:04PM +0200, Jens Gustedt wrote: > > Musl only has a difference between fixed-width and fastest-width > > integer types for N =3D=3D 16. And even here all architectures have made > > the same choice, namely mapping to 32 bit types. > > --- > > src/stdio/vfprintf.c | 9 ++++++++- > > src/stdio/vfwprintf.c | 9 ++++++++- > > 2 files changed, 16 insertions(+), 2 deletions(-) > >=20 > > diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c > > index 1a516663..9f02a594 100644 > > --- a/src/stdio/vfprintf.c > > +++ b/src/stdio/vfprintf.c > > @@ -529,9 +529,16 @@ static int printf_core(FILE *f, const char > > *fmt, va_list *ap, union arg *nl_arg, ps=3Dst; > > st=3Dstates[st]S(*s++); > > if (st =3D=3D WPRE) { > > + // See if "fast" is requested. > > Difference is only > > + // relevant for a fast type of > > minimum width 16. > > + int fast16 =3D HPRE; > > + if (*s =3D=3D 'f') { > > + fast16 =3D BARE; > > + ++s; > > + } > > switch (getint(&s)) { > > case 8: st =3D HHPRE; goto wpre; > > - case 16: st =3D HPRE; goto wpre; > > + case 16: st =3D fast16; goto wpre; > > case 32: st =3D BARE; goto wpre; > > #if UINTPTR_MAX >=3D UINT64_MAX > > case 64: st =3D LPRE; goto wpre; > > diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c > > index 4320761a..4e9ce63a 100644 > > --- a/src/stdio/vfwprintf.c > > +++ b/src/stdio/vfwprintf.c > > @@ -244,9 +244,16 @@ static int wprintf_core(FILE *f, const wchar_t > > *fmt, va_list *ap, union arg *nl_ ps=3Dst; > > st=3Dstates[st]S(*s++); > > if (st =3D=3D WPRE) { > > + // See if "fast" is requested. > > Difference is only > > + // relevant for a fast type of > > minimum width 16. > > + int fast16 =3D HPRE; > > + if (*s =3D=3D 'f') { > > + fast16 =3D BARE; > > + ++s; > > + } > > switch (getint(&s)) { > > case 8: st =3D HHPRE; goto wpre; > > - case 16: st =3D HPRE; goto wpre; > > + case 16: st =3D fast16; goto wpre; > > case 32: st =3D BARE; goto wpre; > > #if UINTPTR_MAX >=3D UINT64_MAX > > case 64: st =3D LPRE; goto wpre; > > --=20 > > 2.34.1 =20 >=20 > It may just work to have w8, w16, wf8, and wf16 all resolve to BARE > unconditionally, as the default promitions for variadic functions > force these all to be passed as int. In the current code, for h and hh > prefixes we cast down and discard any high bits, but unless the caller > invoked UB by passing an argument with mismatched type, the cast is > guaranteed not to change the value. This might be a nice simplification, I'd have to think of this. At a first glance this sounds a bit user unfriendly to me. J=E2=82=91=E2=82=99=E2=82=9B --=20 :: ICube :::::::::::::::::::::::::::::: deputy director :: :: Universit=C3=A9 de Strasbourg :::::::::::::::::::::: ICPS :: :: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus :: :: :::::::::::::::::::::::::::::::::::: =E2=98=8E +33 368854536 :: :: https://icube-icps.unistra.fr/index.php/Jens_Gustedt :: --Sig_/sDYRnH7HkzJA7DmnIDlFi.f Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSN9stI2OFN1pLljN0P0+hp2tU34gUCZHEd0AAKCRAP0+hp2tU3 4oOGAJ4r03QBWFviavsiIrVQz3d1OLyhKgCfV6LaCZtM6AzlwfTla/aemqxvZwk= =SjVN -----END PGP SIGNATURE----- --Sig_/sDYRnH7HkzJA7DmnIDlFi.f--