mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Alastair Houghton <ahoughton@apple.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] __MUSL__ macro
Date: Fri, 7 Jul 2023 08:47:23 -0400	[thread overview]
Message-ID: <20230707124722.GE4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <309EDCC9-2402-46B5-BDBD-B96677E470DD@apple.com>

On Thu, Jul 06, 2023 at 11:48:04AM +0100, Alastair Houghton wrote:
> Hi all,
> 
> Before I start, I’m aware of
> 
>   <https://www.openwall.com/lists/musl/2013/03/29/13>
> 
> but I *still* want to add __MUSL__ (see attached patch).
> 
> Let me explain what we’re doing, why we want it and why we think
> musl *should* have it. We’re trying to add support for musl to Swift
> <https://swift.org <https://swiftlang.org/>> and its attendant core
> libraries, and there are a number of things about musl that
> presently differ from other platforms/C libraries we support.
> 
> Examples include the use of `union`s in `pthread_mutex_t` et al
> (which means that we can’t write a C++ `constexpr` function that
> returns one, even if all it does is return
> `PTHREAD_MUTEX_INITIALIZER`), the fact that it doesn’t have the
> `d_namlen` member of `struct dirent`, or the fact that `dladdr()` is
> a no-op when statically linked.

This has nothing to do with being on musl. This has to do with writing
semantically incorrect code that does not meet the requirements of the
specification.

pthread_mutex_t is not a value type. It's an object. You cannot
initialize a pthread_mutex_t in one context and copy/assign/return it
to be used somewhere else as a value. Only the actual object
initialized may be used. For example, it may even contain references
to its own address. Whatever implementations you think this works on
on probably to not have a contract to make it work; you're writing to
something that you observed working on your system. And in that case,
once you've read the relevant source, you need to hard-code the unsafe
code to be used *only on that specific implementation and version of
it*, not assume musl is the one doing something odd/different because
you hack doesn't work here.

Rich

  parent reply	other threads:[~2023-07-07 14:08 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 [this message]
2023-07-07 13:14   ` Alastair Houghton
2023-07-07 14:19     ` Markus Wichmann
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=20230707124722.GE4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=ahoughton@apple.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).