|
Message-Id: <CSOHK2KY87QJ.165RWDISH4BH1@sumire> Date: Wed, 17 May 2023 12:37:33 +0200 From: "alice" <alice@...ya.dev> To: <musl@...ts.openwall.com> Subject: Re: Question:Why musl call a_barrier in __pthread_once? On Wed May 17, 2023 at 12:07 PM CEST, =?gb18030?B?ODQ3NTY3MTYx?= wrote: > Hi, > > Why musl add a_barrier() in if branch here? > 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 == 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.