diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/internal/libc.h | 1 | ||||
-rw-r--r-- | src/thread/forkall.c | 68 | ||||
-rw-r--r-- | src/thread/synccall.c | 8 |
3 files changed, 0 insertions, 77 deletions
diff --git a/src/internal/libc.h b/src/internal/libc.h index 78fca47f..0ec3691e 100644 --- a/src/internal/libc.h +++ b/src/internal/libc.h @@ -52,7 +52,6 @@ void __unlockfile(FILE *); #define UNLOCK(x) (libc.threads_minus_1 ? (__unlock(x),1) : ((void)(x),1)) void __synccall(void (*)(void *), void *); -void __synccall_wait(void); int __setxid(int, int, int, int); extern char **__environ; diff --git a/src/thread/forkall.c b/src/thread/forkall.c deleted file mode 100644 index 6810ea50..00000000 --- a/src/thread/forkall.c +++ /dev/null @@ -1,68 +0,0 @@ -#if 0 -#include "pthread_impl.h" -#include <setjmp.h> - -struct thread { - struct thread *next; - pthread_t td; - jmp_buf jb; - void *tmp, *stack; -}; - -struct ctx { - struct thread *list; - pthread_t caller; - pid_t pid; - size_t cnt; - pthread_barrier_t barrier; -}; - -static void restart_thread(pthread_t self) -{ - struct thread *t = self->start_arg; - self->start_arg = t->tmp; - self->pid = getpid(); - longjmp(t->jb, 1); -} - -static void do_forkall(void *p) -{ - struct ctx *c = p, *volatile cv = c; - char tmpstack[2048]; - struct thread *tp, t = { - .td = __pthread_self(), - .next = c->list, - .stack = tmpstack+1024 - }; - - if (t.td != c->caller) { - c->cnt++; - t.tmp = t.td->start_arg; - t.td->start_arg = &t; - if (setjmp(t.jb)) { - c = cv; - if (c->pid) return; - pthread_barrier_wait(&c->barrier); - return; - } - c->list = &t; - __synccall_wait(); - return; - } - c->pid = syscall(SYS_fork); - if (c->pid) return; - - pthread_barrier_init(&c->barrier, 0, c->cnt); - for (tp=c->list; tp; tp=tp->next) - if (__uniclone(tp->stack, restart_thread, tp->td) < 0) - _exit(127); - pthread_barrier_wait(&c->barrier); -} - -pid_t forkall() -{ - struct ctx c = { .caller = pthread_self() }; - __synccall(do_forkall, &c); - return c.pid; -} -#endif diff --git a/src/thread/synccall.c b/src/thread/synccall.c index 2cd25e4b..1520b3b4 100644 --- a/src/thread/synccall.c +++ b/src/thread/synccall.c @@ -47,14 +47,6 @@ 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; |