mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Nicholas Fraser <nick@ludocode.com>
To: musl@lists.openwall.com
Subject: Re: [musl] Detect qsort_r() support with preprocessor
Date: Tue, 19 Apr 2022 19:10:23 -0400	[thread overview]
Message-ID: <9eef4922-b71b-e0cf-1a11-d014a0f024af@ludocode.com> (raw)
In-Reply-To: <20220419065954.GA1933@voyager>

Thanks for the replies. I'm a bit surprised to hear you agree that, given my
requirements, I should ignore your features and re-implement them myself.
Beyond that it looks like we won't find common ground.

I'll just take the opportunity to clarify a few things:

On 2022-04-19 02:59, Markus Wichmann wrote:
 > Since Windows/MSVC is on the list of platforms you wish to
 > support, that means C89. And ONLY C89. Good luck with that.

You may be interested to learn that Microsoft has had full C99 support (minus
those features made optional in C11) since VS 2015. This is the oldest version
of the VS tools still supported. More recently, VS 2019 supports nearly all
of C11 (including a conforming preprocessor.)

Even before that, it was easy to make well-written C99 compile as C++ to work
under Microsoft's compiler. Compiling as C++ is a virtual necessity for a
header-only library anyway.

 > I'm pretty sure it won't work on OS-9. That would be a restriction.

I think this is the main source of our disagreement. You seem very concerned
that my strategy won't work on platforms I've never heard of, and that if it's
not perfect, it's useless.

I do provide my users the option to manually override whatever I detect in case
it's wrong. I'm just trying to detect as much as I can to make it easier for
them. It's okay if it only works 90% of the time, and the remaining 10%
requires manual configuration. I believe it will be more like >99% though, and
I had hoped musl would want to be part of that >99%.

 > So you
 > would need __MUSL_VERSION__ or something.  But then Alpine went ahead
 > and backported it to earlier versions. So there are versions of musl
 > 1.2.2 out there with qsort_r() and those without it. So again, the macro
 > you are begging for would not tell you what you want to know.

For the record I didn't ask for __MUSL_VERSION__. I asked for __HAS_QSORT_R.

I asked this for exactly this reason, because I've been testing on Alpine and
noticed they backported it. I only brought up __MUSL__ in comparison to what
works for me on other platforms. We all agree that a standard macro like
__HAS_QSORT_R would be a better solution but it will take a decade for this to
get standardized.

In any case, even if a version macro doesn't detect backported features, that's
not a big deal. It's a temporary problem that will solve itself. This is
another case of perfect being the enemy of good.

 > So what you would want is __MUSL_HAS_QSORT_R__, which for a growing list
 > of standard extensions is obviously untennable.

This isn't obvious at all. I can't imagine what is so untenable about putting
a simple #define next to each extension function you support.

 From my perspective, I think what is obvious is that you want to hide the fact
that the implementation is musl, and you are opposed to macros like this simply
because they could be used to reveal that you're musl.

On 2022-04-19 09:32, Rich Felker wrote:
 > You cannot #define _GNU_SOURCE or __STDC_WANT_LIB_EXT1__ after any
 > standard header has already been included.

Yes, I know that of course (give me a little credit here.) Maybe I was unclear.
I'm not defining _GNU_SOURCE or whatever. I'm declaring the actual libc
function I want to link against within the scope of my wrapper function that
calls it. That's what the snippet of code I showed does. Ultimately I'm
targeting the ABI, not the headers, which is why I make it work regardless of
_GNU_SOURCE and such.

Nick


  reply	other threads:[~2022-04-19 23:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16  8:13 Nicholas Fraser
2022-04-16 12:01 ` Markus Wichmann
2022-04-16 14:16   ` Quentin Rameau
2022-04-16 17:50     ` Nicholas Fraser
2022-04-16 18:42       ` Quentin Rameau
2022-04-16 23:59         ` Nicholas Fraser
2022-04-17  2:04       ` Rich Felker
2022-04-19  3:38         ` Nicholas Fraser
2022-04-19  6:59           ` Markus Wichmann
2022-04-19 23:10             ` Nicholas Fraser [this message]
2022-04-19 13:32           ` 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=9eef4922-b71b-e0cf-1a11-d014a0f024af@ludocode.com \
    --to=nick@ludocode.com \
    --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).