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=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 6812 invoked from network); 17 May 2023 10:37:52 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 17 May 2023 10:37:52 -0000 Received: (qmail 32009 invoked by uid 550); 17 May 2023 10:37:48 -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 31968 invoked from network); 17 May 2023 10:37:47 -0000 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ayaya.dev; s=key1; t=1684319856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZdL6zgzWoLVwxEzMxW3WrzzMOWEw4rFJLC9A0xtJOZY=; b=Ir3JnyIt7FI24touzIEu3Zkr3jHQ4A+SKbdechDN+pgbY9T9atLOIHdM9yG+qaPN1i77KW nF+mbd1oeDL29w/AEUlmIfJnSJWDfhjaW29FvjkKT9ZQOci9l+DX1BZPwTRA8zPR2w5c5Q 8jb2d/J83dAytxXRkmulRTKj6ZSnqyA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 17 May 2023 12:37:33 +0200 Message-Id: X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "alice" To: References: In-Reply-To: X-Migadu-Flow: FLOW_OUT Subject: =?utf-8?q?Re:_[musl]_Question=EF=BC=9AWhy_musl_call=C2=A0a=5Fbarrier_in_?= =?utf-8?q?=5F=5Fpthread=5Fonce=3F?= On Wed May 17, 2023 at 12:07 PM CEST, =3D?gb18030?B?ODQ3NTY3MTYx?=3D wrote: > Hi, > > Why musl add a_barrier() in if branch here? =20 > What happend if we remove it? Could you give me more details? see commit df37d3960abec482e17fad2274a99b790f6cc08b, removing it would cause issues on weakly-ordered memory models. > > int __pthread_once(pthread_once_t *control, void (*init)(void)) > { > /* Return immediately if init finished before, but ensure that > * effects of the init routine are visible to the caller. */ > if (*(volatile int *)control =3D=3D 2) { > a_barrier(); > return 0; > } > return __pthread_once_full(control, init); > } > > https://gitee.com/openharmony/third_party_musl/blob/master/src/thread/pth= read_once.c#L44 > > > Chuang Yin