mailing list of musl libc
 help / color / mirror / code / Atom feed
From: William Ahern <william@25thandClement.com>
To: musl@lists.openwall.com
Subject: MUSL Feature Detection
Date: Wed, 4 Mar 2015 12:54:58 -0800	[thread overview]
Message-ID: <20150304205458.GA14554@wilbur.25thandClement.com> (raw)

I'm familiar with the policy that MUSL is not interested in adding version
macros, etc. I mostly agree with the policy, however there are some corner
cases where it's problematic.

I maintain a Lua bindings library to Unix APIs

	http://25thandclement.com/~william/projects/lunix.html

Unlike the most commonly used module, luaposix, my module tries to be as
thread-safe as possible. (It also supports "portable" but non-POSIX
interfaces.) That means using all the re-entrant versions of functions if
available. But some functions don't have re-entrant versions, such as
strsignal. In those cases I try to synthesize a safe version if possible and
practical, such as using sys_siglist if available.

Knowing whether an interface is thread-safe requires me inspecting the code
and basically documenting my findings inside the source code with
conditionals. I could _also_ do run-time checks, but that's more susceptible
to false negatives, and so I think it would only make sense to do that as a
back-stop. (Compile-time checks won't work for cross-compiling).

The vast majority of people don't pay attention to obscure thread-safety
issues, especially because the most popular platforms like Linux/glibc and
Solaris do a pretty decent job of implementing APIs in a thread-safe manner
(e.g. getenv, strsignal). This lack of interest is especially true in the
context of a library, and doubly so of a scripting module, where people just
assume the mode and the dependencies do the right thing, assuming they
bother worrying about it in the first place.

So you can see I'm stuck between a rock and a hard place. MUSL is probably
safe in most regards. It doesn't even do localization, so strsignal is safe.
But I have no easy way to _know_ that I'm building against MUSL without the
person compiling the module knowingly and explicitly changing the build
configuration.

So, is there any sort of sanctioned way to detect MUSL at all, version or no
version? Is there any interest in supporting any kind of feature detection,
such as an API that communicates implementation choices wrt unspecified and
undefined behavior.



             reply	other threads:[~2015-03-04 20:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 20:54 William Ahern [this message]
2015-03-05  4:23 ` Rich Felker
2015-03-05  8:33 ` u-wsnj
2015-03-05  8:58   ` u-wsnj
2015-03-05 15:34     ` stephen Turner
2015-03-05 21:02       ` William Ahern
2015-03-05 21:38         ` 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=20150304205458.GA14554@wilbur.25thandClement.com \
    --to=william@25thandclement.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).