1 #include "pthread_impl.h"
10 static void (*callback)(void *), *context;
12 static sem_t chainlock, chaindone;
14 static void handler(int sig, siginfo_t *si, void *ctx)
17 pthread_t self = __pthread_self();
18 int old_errno = errno;
20 if (chainlen == libc.threads_minus_1) return;
22 sigqueue(self->pid, SIGSYNCCALL, (union sigval){0});
24 sem_init(&ch.sem, 0, 0);
25 sem_init(&ch.sem2, 0, 0);
27 while (sem_wait(&chainlock));
30 if (++chainlen == libc.threads_minus_1) sem_post(&chaindone);
33 while (sem_wait(&ch.sem));
36 while (sem_wait(&ch.sem));
41 void __synccall(void (*func)(void *), void *ctx)
48 if (!libc.threads_minus_1) {
55 __syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGALL_SET,
58 sem_init(&chaindone, 0, 0);
59 sem_init(&chainlock, 0, 1);
64 sa.sa_flags = SA_SIGINFO | SA_RESTART;
65 sa.sa_sigaction = handler;
66 sigfillset(&sa.sa_mask);
67 __libc_sigaction(SIGSYNCCALL, &sa, 0);
69 self = __pthread_self();
70 sigqueue(self->pid, SIGSYNCCALL, (union sigval){0});
71 while (sem_wait(&chaindone));
73 for (cur=head; cur; cur=cur->next) {
75 while (sem_wait(&cur->sem2));
79 for (cur=head; cur; cur=next) {
85 sa.sa_handler = SIG_IGN;
86 __libc_sigaction(SIGSYNCCALL, &sa, 0);
88 __syscall(SYS_rt_sigprocmask, SIG_SETMASK,
89 &oldmask, 0, _NSIG/8);