mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] __MUSL__ macro
Date: Fri, 7 Jul 2023 16:19:14 +0200	[thread overview]
Message-ID: <ZKge4q4QjB7j0ooB@voyager> (raw)
In-Reply-To: <054B1907-817E-496D-9F83-7FBE7AB0111A@apple.com>

Am Fri, Jul 07, 2023 at 02:14:30PM +0100 schrieb Alastair Houghton:
> This is a somewhat irrelevant distraction and I rather wish I hadn’t
> mentioned that as an example of odd behaviour.  I’m well aware that
> you cannot copy or assign `pthread_mutex_t` values in general (and I
> understand the reasons why).
>
> Please can we instead focus on the issue of whether or not musl should
> have `__MUSL__` and `__MUSL_MINOR__`.
>

The counter-examples are not irrelevant. That is precisely the point.
Nobody advocating for implementation identification macros has so far
given a valid reason to do so. Every single one so far has turned out to
be spurious. Well, I tell a lie, there is one case with a shadow of
reason behind it: Header-only libraries. But maybe the problem with
those is trying to be a header-only library.

If you have different implementations with different runtime behavior,
check whether the behavior is acceptable from the specification. If it
is, write code that can accept the behavior. If it is not, write a bug
report.

Very often I am astonished that the problem presented is claimed to have
the __MUSL__ macro as a solution. I am reminded of a Stack Overflow
question where someone wanted to identify musl, because musl doesn't
have a trustworthy vfork(). Pressed on what exactly he meant, the poster
said that depending on version and architecture, calling vfork() with
musl actually results in it calling fork(). OK, that was his concern.
His solution? If he found he was running on Apple or musl, he wanted to
call fork() instead of vfork(). Why he would not just always call
vfork() if the claimed untrustworthy behavior was also his remedy is a
question the guy skillfully avoided an answer to.

In your case, apparently there is a way to deal with failing dladdr().
So why don't you put the code for that in the failure path for the call,
instead of into "#ifdef __MUSL__"? That way, even unknown
implementations would be supported.

For header-only libraries, the customer could configure them at build
time. I have so far not figured out why people that write programs for a
living cannot be expected to fill out a config.h template. There was a
person here before who wanted a macro to identify that qsort_r() is
available, and I told him much the same thing, and never got a
satisfactory answer to the above query. Also, he already had his own
fallback sorting algorithm, so the portable solution was just to call
that, and then the whole need evaporated.

I remain in staunch opposition to identification macros, because those
have so far always - no matter how benevolent they might have seemed at
the beginning - lead to #ifdef hell of levels Dante couldn't dream of.
They lead to people writing bad code and making bad assumptions.

None of this matters one bit, because Rich is God as far as musl is
concerned, and he has not weighed in yet. However, in the past he has
spoken out against these macros, and I doubt your arguments have
convinced him. They haven't convinced me, at any rate.

Ciao,
Markus

  reply	other threads:[~2023-07-07 14:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 10:48 Alastair Houghton
2023-07-06 12:17 ` Alex Xu
2023-07-06 16:26   ` Szabolcs Nagy
2023-07-07  7:14   ` Alastair Houghton
2023-07-07  7:30     ` A. Wilcox
2023-07-07  8:24       ` Alastair Houghton
2023-07-07 11:20     ` Laurent Bercot
2023-07-07 11:45     ` Jeffrey Walton
2023-07-07 13:53     ` Rich Felker
2023-07-07 14:18       ` Alastair Houghton
2023-07-07 12:47 ` Rich Felker
2023-07-07 13:14   ` Alastair Houghton
2023-07-07 14:19     ` Markus Wichmann [this message]
2023-07-07 14:26       ` Markus Wichmann
2023-07-07 14:46       ` Alastair Houghton
2023-07-07 15:02       ` Andrew Bell
2023-07-07 15:19         ` Markus Wichmann
2023-07-07 15:24           ` Andrew Bell
2023-07-07 15:34           ` Alastair Houghton
2023-07-07 15:45             ` Rich Felker
2023-07-07 15:58               ` Alastair Houghton
2023-07-07 15:05     ` i262jq

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=ZKge4q4QjB7j0ooB@voyager \
    --to=nullplan@gmx.net \
    --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).