Continue fighting pthreads.
Clean up thread library a bit too.
This commit is contained in:
@@ -6,17 +6,18 @@ _threadinitstack(Thread *t, void (*f)(void*), void *arg)
|
||||
sigset_t zero;
|
||||
|
||||
/* do a reasonable initialization */
|
||||
memset(&t->sched.uc, 0, sizeof t->sched.uc);
|
||||
memset(&t->context.uc, 0, sizeof t->context.uc);
|
||||
sigemptyset(&zero);
|
||||
sigprocmask(SIG_BLOCK, &zero, &t->sched.uc.uc_sigmask);
|
||||
sigprocmask(SIG_BLOCK, &zero, &t->context.uc.uc_sigmask);
|
||||
|
||||
/* call getcontext, because on Linux makecontext neglects floating point */
|
||||
getcontext(&t->sched.uc);
|
||||
getcontext(&t->context.uc);
|
||||
|
||||
/* call makecontext to do the real work. */
|
||||
t->sched.uc.uc_stack.ss_sp = t->stk;
|
||||
t->sched.uc.uc_stack.ss_size = t->stksize;
|
||||
makecontext(&t->sched.uc, (void(*)())f, 1, arg);
|
||||
/* leave a few words open on both ends */
|
||||
t->context.uc.uc_stack.ss_sp = t->stk+8;
|
||||
t->context.uc.uc_stack.ss_size = t->stksize-16;
|
||||
makecontext(&t->context.uc, (void(*)())f, 1, arg);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user