mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: Bruno Haible <bruno@clisp.org>
Cc: Assaf Gordon <assafgordon@gmail.com>,
	bug-gnulib@gnu.org, musl@lists.openwall.com
Subject: Re: localename: add support for musl libc
Date: Sun, 25 Feb 2018 13:19:04 -0500	[thread overview]
Message-ID: <20180225181904.GN1436@brightrain.aerifal.cx> (raw)
In-Reply-To: <7452235.CQINynMRMO@omega>

On Sun, Feb 25, 2018 at 11:17:08AM +0100, Bruno Haible wrote:
> Hi Assaf,
> 
> > > +#  elif defined __linux__ && HAVE_LANGINFO_H && defined NL_LOCALE_NAME
> > > +        /* musl libc */
> > 
> > A tiny comment about the comment :)
> > 
> > You wrote "musl libc", but what the "elif defined ..." is something like
> > "linux but not glibc, with langinfo.h" - which could (in theory) be
> > something other than musl-libc.
> 
> Yes, that's it. The refusal of the musl people to define a symbol such
> as __MUSL__ [1] makes it hard to write future-proof code. If someone else

The existence of it would not help futureproof and would promote
writing of non-futureproof code by hardcoding specific assumptions
about a specific version of musl rather than configure-time or
preprocessor-time detection of features.

> creates a platform that shares the same superficial characteristics
> (runs on Linux, has <langinfo.h> and NL_LOCALE_NAME) but behaves
> differently, we will accidentally run into the code intended for musl
> on that platform. Whereas the fallback code (return "" in this case)
> would be safer: it would make the unit test fail, but it would not
> lead to a compilation error or to a code dump.
> 
> And if that platform does not have an identifiying macro either, we
> really got a problem how to distinguish the two.

The comment /* musl */ above is wrong and should not have been added.
Really use of NL_LOCALE_NAME should always be preferred if it's
available, since it's a clean public interface for the functionality
desired rather than a hack poking at implementation internals. But if
you really like poking at internals for other implementations, it also
works to leave it as the fallback case after the hardcoded list of
assumptions about particular known platforms. It should just be called
something more reasonable like /* otherwise, use public NL_LOCALE_NAME
interface if the system has it */ instead of /* musl */.

Rich


       reply	other threads:[~2018-02-25 18:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6726776.syxiYx1ubZ@omega>
     [not found] ` <20180225075444.GB1188@tomato>
     [not found]   ` <7452235.CQINynMRMO@omega>
2018-02-25 18:19     ` Rich Felker [this message]
2018-02-25 21:19       ` Bruno Haible
2018-02-25 23:40         ` 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=20180225181904.GN1436@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=assafgordon@gmail.com \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.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).