X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fthread%2Fpthread_once.c;h=a8f8aeb17a03995cba0ac62d75cd2d97d09ff0dc;hb=53cd8c5a29b57ef3776ce152e00544752f3ce790;hp=7c47385ccc8fe70e24df960e97aa520c30146bd6;hpb=00548408398ced546c540dab773ea66cea4fe1c2;p=musl diff --git a/src/thread/pthread_once.c b/src/thread/pthread_once.c index 7c47385c..a8f8aeb1 100644 --- a/src/thread/pthread_once.c +++ b/src/thread/pthread_once.c @@ -8,15 +8,8 @@ static void undo(void *control) __wake(control, -1, 1); } -int __pthread_once(pthread_once_t *control, void (*init)(void)) +int __pthread_once_full(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 (*control == 2) { - a_barrier(); - return 0; - } - /* Try to enter initializing state. Four possibilities: * 0 - we're the first or the other cancelled; run init * 1 - another thread is running init; wait @@ -43,4 +36,15 @@ int __pthread_once(pthread_once_t *control, void (*init)(void)) } } +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); +} + weak_alias(__pthread_once, pthread_once);