X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fsynccall.c;h=2cd25e4bb2b84315ca4adb9c562d4592eebcb55a;hb=5a2e18093725c3965486641f0ad0b61a44f7ed68;hp=7c4f92bfdb77307338778a27adca3e9dd5ca07ad;hpb=acb04806628990ad2430e04261dd20f23babde5e;p=musl diff --git a/src/thread/synccall.c b/src/thread/synccall.c index 7c4f92bf..2cd25e4b 100644 --- a/src/thread/synccall.c +++ b/src/thread/synccall.c @@ -4,7 +4,7 @@ static struct chain { struct chain *next; sem_t sem, sem2; -} *head; +} *head, *cur; static void (*callback)(void *), *context; static int chainlen; @@ -47,22 +47,30 @@ static void handler(int sig, siginfo_t *si, void *ctx) errno = old_errno; } +void __synccall_wait() +{ + struct chain *ch = cur; + sem_post(&ch->sem2); + while (sem_wait(&ch->sem)); + sem_post(&ch->sem); +} + void __synccall(void (*func)(void *), void *ctx) { pthread_t self; struct sigaction sa; - struct chain *cur, *next; + struct chain *next; uint64_t oldmask; - pthread_rwlock_wrlock(&lock); - - __syscall(SYS_rt_sigprocmask, SIG_BLOCK, (uint64_t[]){-1}, &oldmask, 8); - if (!libc.threads_minus_1) { func(ctx); return; } + pthread_rwlock_wrlock(&lock); + + __syscall(SYS_rt_sigprocmask, SIG_BLOCK, (uint64_t[]){-1}, &oldmask, 8); + sem_init(&chaindone, 0, 0); sem_init(&chainlock, 0, 1); chainlen = 0;