mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Ram Nalamothu (QUIC)" <quic_vnalamot@quicinc.com>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: Re: [musl] Integer only print functions support in MUSL
Date: Wed, 12 Jun 2024 21:06:55 -0400	[thread overview]
Message-ID: <20240613010654.GV10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <DM5PR02MB36398389F609351B6E37F0E3F0C02@DM5PR02MB3639.namprd02.prod.outlook.com>

On Wed, Jun 12, 2024 at 05:29:59PM +0000, Ram Nalamothu (QUIC) wrote:
> Hi,
> 
> On the subject line topic, is there a plan for integer only print
> functions support in MUSL upstream?
> 
> The newlib seems to support the same since 2004 [1] and one
> immediate scenario using this capability is assert function [2] in
> the C library itself which needs to print only the non-float types.
> 
> Applications that use integer only print functions can benefit from
> this capability in terms of reduced code size by avoiding floating
> point support implementation in the linked print functions.
> 
> I tried a quick search on the mailing list but couldn't find any
> previous discussions on this topic.
> Would it make sense to have the similar support in MUSL as well?
> Would the community be open to accept patches supporting integer
> only print functions?

My leaning is no. There is no major precedent for this, no hard *need*
(it's only an optimization hint to make up for other failed
optimizations), and to do it completely and consistently it's a
combinatoric explosion (doubling the number of printf-family
functions). At the very least you'd need (and this would be
application-unfriendly to have just these) i versions of vfprintf and
vsnprintf; everything else can be built on them.

But to get back to the point, on archs that are hard-float and don't
have an oversized soft-only long double, the size of the floating
point code in printf is around 6k. Only the most extreme environments
would warrant exploding complexity like that to save 6k. A better way
to meet their needs would probably be to provide a way to dummy-out
float support at link-time, by putting fmt_fp in its own TU and having
some trick to keep it from getting linked if you use the right
LDFLAGS. But unless there is a really good documented widespread need
for this, I can't see it making sense to do hacks like that upstream
in musl.

Rich

  parent reply	other threads:[~2024-06-13  1:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 17:29 Ram Nalamothu (QUIC)
2024-06-12 18:56 ` Markus Wichmann
2024-06-12 19:21   ` James Y Knight
2024-06-13  1:06 ` Rich Felker [this message]
2024-06-13 16:03   ` James Y Knight
2024-06-27  6:15     ` Ram Nalamothu (QUIC)

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=20240613010654.GV10433@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=quic_vnalamot@quicinc.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).