summaryrefslogtreecommitdiff
path: root/src/thread/forkall.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-05-22 22:43:27 -0400
committerRich Felker <dalias@aerifal.cx>2012-05-22 22:43:27 -0400
commit0c29adfe427ab6ed98cb73644f8f52a76045245c (patch)
tree5703af4273b5341688b84472cdcef2c63b5c84b0 /src/thread/forkall.c
parentaf3330d7648627816fbc82aa3247419e8a528230 (diff)
downloadmusl-0c29adfe427ab6ed98cb73644f8f52a76045245c.tar.gz
musl-0c29adfe427ab6ed98cb73644f8f52a76045245c.tar.bz2
musl-0c29adfe427ab6ed98cb73644f8f52a76045245c.tar.xz
musl-0c29adfe427ab6ed98cb73644f8f52a76045245c.zip
remove everything related to forkall
i made a best attempt, but the intended semantics of this function are fundamentally contradictory. there is no consistent way to handle ownership of locks when forking a multi-threaded process. the code could have worked by accident for programs that only used normal mutexes and nothing else (since they don't actually store or care about their owner), but that's about it. broken-by-design interfaces that aren't even in glibc (only solaris) don't belong in musl.
Diffstat (limited to 'src/thread/forkall.c')
-rw-r--r--src/thread/forkall.c68
1 files changed, 0 insertions, 68 deletions
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