diff options
| author | rsc <devnull@localhost> | 2004-09-21 01:11:28 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-09-21 01:11:28 +0000 |
| commit | c6687d4591964cb13df87f55ec4770e778a4a55c (patch) | |
| tree | ee669a419904e929ae8ae54fd04c2bb41b5a57b1 /src/libthread/ucontext.c | |
| parent | 3d5e34e146b5ba5c973230abb624ce9126024569 (diff) | |
| download | plan9port-c6687d4591964cb13df87f55ec4770e778a4a55c.tar.gz plan9port-c6687d4591964cb13df87f55ec4770e778a4a55c.zip | |
Continue the pthreads torture.
Diffstat (limited to 'src/libthread/ucontext.c')
| -rw-r--r-- | src/libthread/ucontext.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libthread/ucontext.c b/src/libthread/ucontext.c new file mode 100644 index 00000000..60f803d3 --- /dev/null +++ b/src/libthread/ucontext.c @@ -0,0 +1,41 @@ +#include "threadimpl.h" + +void +_threadinitstack(Thread *t, void (*f)(void*), void *arg) +{ + sigset_t zero; + + /* do a reasonable initialization */ + memset(&t->sched.uc, 0, sizeof t->sched.uc); + sigemptyset(&zero); + sigprocmask(SIG_BLOCK, &zero, &t->sched.uc.uc_sigmask); + + /* call getcontext, because on Linux makecontext neglects floating point */ + getcontext(&t->sched.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); +} + +void +_threadinswitch(int enter) +{ + USED(enter); +} + +void +_threadstacklimit(void *bottom, void *top) +{ + USED(bottom); + USED(top); +} + +void +_swaplabel(Label *old, Label *new) +{ + if(swapcontext(&old->uc, &new->uc) < 0) + sysfatal("swapcontext: %r"); +} + |
