mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] =?gb18030?B?UXVlc3Rpb26juldoeSBtdXNsIGNhbGyBMIQyYV9iYXJyaWVyIGluIF9fcHRocmVhZF9vbmNlPw==?=
@ 2023-05-17 10:07 =?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
  0 siblings, 2 replies; 5+ messages in thread
From: =?gb18030?B?ODQ3NTY3MTYx?= @ 2023-05-17 10:07 UTC (permalink / raw)
  To: =?gb18030?B?bXVzbA==?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 527 bytes --]

Hi,

Why musl add a_barrier() in if branch here?  
What happend if we remove it? Could you give me more details?

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 == 2) {
		a_barrier();
		return 0;
	}
	return __pthread_once_full(control, init);
}

https://gitee.com/openharmony/third_party_musl/blob/master/src/thread/pthread_once.c#L44


Chuang Yin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-17 13:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 12:11   ` =?gb18030?B?UmU6IFttdXNsXSBRdWVzdGlvbqO6V2h5IG11c2wgY2FsbIEwhDJhX2JhcnJpZXIgaW4gX19wdGhyZWFkX29uY2U/?= =?gb18030?B?ODQ3NTY3MTYx?=
2023-05-17 13:12   ` [musl] Question:Why musl call a_barrier in __pthread_once? Rich Felker

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).