Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 2 Jun 2023 17:09:26 +0200
From: Jₑₙₛ Gustedt <jens.gustedt@...ia.fr>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com, jens.gustedt@...teo.eu
Subject: Re: [C23 printf 2/3] C23: implement the wN length specifiers
 for printf

Rich,

on Fri, 2 Jun 2023 10:38:00 -0400 you (Rich Felker <dalias@...c.org>)
wrote:

> The logic here for whether w64 is LPRE or LLPRE is wrong. The
> condition for whether [u]int64_t is long or long long is not whether
> uintptr_t or long long would be too wide (they never are, in our ABIs)
> but whether long is long enough. All our [u]intN_t are the lowest-rank
> type of the desired size, and this seems to be consistent with what
> other implementations like glibc do.

I probably copied that logic wrong from somewhere. Yes, right thing is
probably just to compare to the new `ULONG_WIDTH` macro or so.

One thing to think about could be to always map 64 to `long long`,
just for this function here. This would always have the right size and
representation. And since this is an implementation of the C library,
we make the rules ;-)

> Short of a compelling reason not to, though, I plan to just go with
> the fix-up of my v2 patch for this functionality. Its ordering avoids
> duplication of logic (the ?: branches in the cases above) and the need
> for maintaining extra side state (the width variable) thru the state
> machine.

I thought a bit of having the state only in the width variable, but
since we also need to track signedness and the extra cases for FP,
this becomes quickly quite messy.

So yes, looks good (with some minor remarks in up-thread).

Thanks
Jₑₙₛ

-- 
:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.