mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Jₑₙₛ Gustedt" <jens.gustedt@inria.fr>
Cc: musl@lists.openwall.com, jens.gustedt@posteo.eu
Subject: Re: [musl] [C23 printf 2/3] C23: implement the wN length specifiers for printf
Date: Fri, 2 Jun 2023 11:16:40 -0400	[thread overview]
Message-ID: <20230602151639.GS4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20230602170926.41dca6e7@inria.fr>

On Fri, Jun 02, 2023 at 05:09:26PM +0200, Jₑₙₛ Gustedt wrote:
> Rich,
> 
> on Fri, 2 Jun 2023 10:38:00 -0400 you (Rich Felker <dalias@libc.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 ;-)

Well, in musl we generally want the code to have well-defined behavior
even if it's inlined via LTO, where the types would mismatch. Note
that this is kinda a problem for scanf where va_arg is used with
void*, except that POSIX, conveniently, explicitly requires the C
(compiler) implementation accept mismatched va_arg types when both
types are pointers. This is a big hammer but it seems to be a
necessary assumption to admit implementing the %n$ form of scanf,
which POSIX requires.

Rich

  reply	other threads:[~2023-06-02 15:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1685429467.git.Jens.Gustedt@inria.fr>
2023-05-30  6:55 ` [musl] [C23 printf 1/3] C23: implement the b and B printf specifiers Jens Gustedt
2023-05-30  6:55 ` [musl] [C23 printf 2/3] C23: implement the wN length specifiers for printf Jens Gustedt
2023-06-02 14:38   ` Rich Felker
2023-06-02 15:09     ` Jₑₙₛ Gustedt
2023-06-02 15:16       ` Rich Felker [this message]
2023-06-02 15:37         ` Jₑₙₛ Gustedt
2023-05-30  6:55 ` [musl] [C23 printf 3/3] C23: implement the wfN length modifiers " Jens Gustedt
2023-05-31 14:04 [musl] [C23 printf 0/3] to be replaced Jens Gustedt
2023-05-31 14:04 ` [musl] [C23 printf 2/3] C23: implement the wN length specifiers for printf Jens Gustedt
  -- strict thread matches above, loose matches on Subject: below --
2023-05-26 19:41 [musl] [C23 printf 0/3] Jens Gustedt
2023-05-26 19:41 ` [musl] [C23 printf 2/3] C23: implement the wN length specifiers for printf Jens Gustedt
2023-05-26 20:31   ` Rich Felker
2023-05-26 20:51     ` Jₑₙₛ Gustedt
2023-05-26 21:03       ` Rich Felker
2023-05-29  7:14         ` Jₑₙₛ Gustedt
2023-05-29 15:46           ` Rich Felker
2023-05-29 19:21             ` Jₑₙₛ Gustedt
2023-05-30  1:48               ` Rich Felker
2023-05-30  6:46                 ` Jₑₙₛ Gustedt
2023-05-30 17:28                   ` Rich Felker
2023-05-30 18:00                     ` Rich Felker
2023-05-31  7:59                     ` Jₑₙₛ Gustedt
2023-06-02 14:29                 ` Rich Felker
2023-06-02 14:55                   ` Jₑₙₛ Gustedt
2023-06-02 15:07                     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230602151639.GS4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=jens.gustedt@inria.fr \
    --cc=jens.gustedt@posteo.eu \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).