From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10846 invoked from network); 18 May 2023 14:08:52 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 18 May 2023 14:08:52 -0000 Received: (qmail 17787 invoked by uid 550); 18 May 2023 14:08:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 17750 invoked from network); 18 May 2023 14:08:49 -0000 Date: Thu, 18 May 2023 10:08:37 -0400 From: Rich Felker To: =?utf-8?B?SuKCkeKCmeKCmw==?= Gustedt Cc: musl@lists.openwall.com, 847567161 <847567161@qq.com> Message-ID: <20230518140837.GQ4163@brightrain.aerifal.cx> References: <20230518122306.GU3630668@port70.net> <20230518132905.GP4163@brightrain.aerifal.cx> <20230518160118.231a1585@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230518160118.231a1585@inria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] =?utf-8?Q?Question=EF=BC=9AWh?= =?utf-8?Q?y?= musl call a_barrier in __pthread_once? 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 ) > 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