mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Jₑₙₛ Gustedt" <jens.gustedt@inria.fr>
Cc: musl@lists.openwall.com, 847567161 <847567161@qq.com>
Subject: Re: [musl] Question:Why musl call a_barrier in __pthread_once?
Date: Thu, 18 May 2023 10:08:37 -0400	[thread overview]
Message-ID: <20230518140837.GQ4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20230518160118.231a1585@inria.fr>

On Thu, May 18, 2023 at 04:01:18PM +0200, Jₑₙₛ Gustedt wrote:
> Rich,
> 
> on Thu, 18 May 2023 09:29:05 -0400 you (Rich Felker <dalias@libc.org>)
> wrote:
> 
> > Of course call_once is exempt from any such requirements
> 
> it was, but isn't anymore. In C23, now we have
> 
>     Completion of an effective call to the `call_once` function
>     synchronizes with all subsequent calls to the `call_once` function
>     with the same value of `flag`.

That's fine because it's for the same value of flag. The old POSIX
requirement is independent of the value of flag (just like
"synchronizes memory" for mutex lock is independent of which mutex
it's called with, etc.). This is why POSIX (as written) requires full
seq_cst for everything.

> POSIX (for which the ISO 9945 instantiation is currently at NB ballot)
> also has updated all of this
> 
>       The pthread_once() and call_once() functions shall synchronize
>       memory for the first successful call in each thread for a given
>       pthread_once_t or once_flag object, respectively. If the
>       init_routine called by pthread_once() or call_once() is a
>       cancellation point and is canceled, a successful call to
>       pthread_once() for the same pthread_once_t object or to
>       call_once() for the same once_flag object, made from a
>       cancellation cleanup handler shall also synchronize memory.
> 
> If I understand this correctly, the C11 interfaces become mandatory if
> the platform supports threads.

Looks like POSIX is fixing it then, by making it specific to the
object, just like C11. So all should be good.

Rich

  reply	other threads:[~2023-05-18 14:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18  2:49 =?gb18030?B?UmU6IFJlOiBbbXVzbF0gUXVlc3Rpb26juldoeSBtdXNsIGNhbGwgYV9iYXJyaWVyIGluIF9fcHRocmVhZF9vbmNlPw==?= =?gb18030?B?ODQ3NTY3MTYx?=
2023-05-18 12:23 ` Re: [musl] Question:Why musl call a_barrier in __pthread_once? Szabolcs Nagy
2023-05-18 13:29   ` Rich Felker
2023-05-18 14:01     ` Jₑₙₛ Gustedt
2023-05-18 14:08       ` Rich Felker [this message]
2023-05-18 14:15     ` Jeffrey Walton
2023-05-18 14:20       ` Rich Felker
  -- strict thread matches above, loose matches on Subject: below --
2023-05-17 10:07 [musl] =?gb18030?B?UXVlc3Rpb26juldoeSBtdXNsIGNhbGyBMIQyYV9iYXJyaWVyIGluIF9fcHRocmVhZF9vbmNlPw==?= =?gb18030?B?ODQ3NTY3MTYx?=
2023-05-17 10:37 ` [musl] Question:Why musl call a_barrier in __pthread_once? alice
2023-05-17 11:17 ` NRK
2023-05-17 13:12   ` 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=20230518140837.GQ4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=847567161@qq.com \
    --cc=jens.gustedt@inria.fr \
    --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).