mailing list of musl libc
 help / color / mirror / code / Atom feed
From: ell1e <kittens@wobble.ninja>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Would it to be possible to get strtoll_l?
Date: Wed, 7 Oct 2020 15:44:11 +0200	[thread overview]
Message-ID: <c127ba0d-ced6-a248-7484-6a5e378b102b@wobble.ninja> (raw)
In-Reply-To: <20201001154702.GQ17637@brightrain.aerifal.cx>

Hi Rich,

I admit I have a very biased view. Let me first preface this with saying
that for my program, this issue is now solved. However, I think there
might be some use if I explain further where I am coming from, and what
I think about adding more *_l() functions:

This is how I came to here, asking about strtoll_l():

1. I wouldn't necessarily know that strtoll doesn't really PRACTICALLY
do locale dependent changes, and same might apply to other people. I did
however realize that in general, process-wide setlocale() doesn't seem
to have died out yet, and for some programs written to work with 3rd
party plugins (that may basically do whatever) this is a big problem. As
a result, picking strtoll_l was a best effort decision with limited
knowledge, based on a default careful approach (which has proven useful
writing C over the years) to rather pick non-locale dependent stuff out
of principle, just to be safe. It wasn't because I identified
strtoll_l() in particular to be necessary, or even useful.

2. All platforms including even Windows 10, and macOS, seem to have
realized that locale-dependent basic string formatting is occasionally a
giant annoying headache and a mess, and therefore offer *_l functions
for pretty much everything. And so does glibc. So again it seemed only
natural to me to pick strtoll_l(), as a spontaneous decision. That this
might cause a problem with musl wasn't something that occurred to me at
first.

3. I only then HAPPENED to even check with musl libc. (Since I run it on
my linux phone.) Then I only happened to go as far as to ask here on the
mailing list, instead of not bothering for now and just writing off musl
libc compatibility. Of course the most "proper" way to deal with this
would be feature detection, but for some smaller projects that otherwise
don't rely on much otherwise "arcane" functionality that may seem like
overkill.

4. I then also just happened to have an overmotivated friend who was
bored enough to write a custom str-to-int and contributed it, so that I
no longer depend on either of strtoll/strtoll_l, which is why this is
solved for me now.

However, I think this chain of events still shows that *_l() coverage
would be useful, in general, for a majority of string functions, even in
cases where it might seem technically useless. This is of course from
the angle of app developers and maintainers, who do their best effort
but ultimately not always best-informed decisions picking string
formatting functions, and then possibly run into this *_l() issue on
musl when porting.

But then again, most of these things can be worked around when porting
to musl. But how many people will bother, and how many programs be left
behind as a result and not work on Alpine etc.? Is that some quantity
that will bother anyone? (My plan before I got the helpful contribution
for example was to just skip musl compatibility for a while before I had
some more time to either add feature detection, or revisit this issue in
other ways. But would anyone have cared not being able to run my program
in particular? I honestly can't tell you.)

I don't think I can give you further insight than this. Nevertheless, I
hope that wall of text had something of use for you.

Regards,

ell1e

On 10/1/20 5:47 PM, Rich Felker wrote:
> On Thu, Oct 01, 2020 at 10:08:17AM +0200, Ellie wrote:
>> Hah, sorry for the e-mail spam, I'm only now just realizing I read over
>> your latest remark that strtoll doesn't really change in behavior.
>>
>> Yeah, I have actually be wondering how strtoll even could be
>> locale-specific, but assumed surely there'd be some corner case I don't
>> know about.
>>
>> But if that makes it just an alias of strtoll effectively, would it be
>> possible to add strtoll_l to musl just for the sake of completion? Since
>> it exists for most platforms (glibc, bsd, windows) who knows how this
>> will be changed to behave in the future, I'd rather use the "proper"
>> function and be on the safe side.
>>
>> In any case, thanks for the insightful response!
> 
> A *complete* set of *_l functions (for all operations that are
> locale-dependent) would be rather large, and would include a lot that
> don't really admit such thin implementations e.g. because they'd have
> variadic signatures. It looks like the set chosen for standardization
> mostly covered just the ones where the function itself was expected to
> be so small/fast that setting the thread-local locale around the call
> would be relatively expensive, but some don't fit that pattern, like
> strftime_l. And then on top of that, we seem to have a somewhat
> inconsistent coverage set for non-standardized BSD/GNU extensions --
> wcsftime_l, strtod_l, etc.
> 
> A big part of maintainership, especially for libc, is saying no. In
> this case, it might make sense to add a few more nonstandard ones,
> especially if we already have most but not all of them and there's a
> clear bounded set of what would be supported and they're all things
> that admit ultra-thin wrappers. Would you be interested in
> investigating that and following up?
> 
> Rich
> 

  reply	other threads:[~2020-10-07 13:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01  0:34 ell1e
2020-10-01  2:35 ` Rich Felker
2020-10-01  4:36   ` ell1e
2020-10-01  5:24     ` Ellie
2020-10-01  8:08       ` Ellie
2020-10-01 15:47         ` Rich Felker
2020-10-07 13:44           ` ell1e [this message]
2020-10-07 13:52             ` Ellie
2020-10-07 14:58               ` 罗勇刚(Yonggang Luo)
2020-10-07 15:41             ` Ariadne Conill
2020-10-07 19:37             ` 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=c127ba0d-ced6-a248-7484-6a5e378b102b@wobble.ninja \
    --to=kittens@wobble.ninja \
    --cc=dalias@libc.org \
    --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).