1 ba940ae6 2009-11-18 rsc #include "threadimpl.h"
4 ba940ae6 2009-11-18 rsc makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...)
9 ba940ae6 2009-11-18 rsc sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4;
10 ba940ae6 2009-11-18 rsc va_start(arg, argc);
11 ba940ae6 2009-11-18 rsc for(i=0; i<4 && i<argc; i++)
12 ba940ae6 2009-11-18 rsc uc->uc_mcontext.gregs[i] = va_arg(arg, uint);
14 ba940ae6 2009-11-18 rsc uc->uc_mcontext.gregs[13] = (uint)sp;
15 ba940ae6 2009-11-18 rsc uc->uc_mcontext.gregs[14] = (uint)fn;
19 ba940ae6 2009-11-18 rsc swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
21 ba940ae6 2009-11-18 rsc if(getcontext(oucp) == 0)
22 ba940ae6 2009-11-18 rsc setcontext(ucp);