1 #include "threadimpl.h"
4 makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
8 sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4;
10 memmove(sp, &argc+1, argc*sizeof(int));
11 *--sp = 0; /* return address */
12 ucp->uc_mcontext.mc_eip = (long)func;
13 ucp->uc_mcontext.mc_esp = (int)sp;
16 extern int getmcontext(mcontext_t*);
17 extern int setmcontext(mcontext_t*);
20 getcontext(ucontext_t *uc)
22 return getmcontext(&uc->uc_mcontext);
26 setcontext(ucontext_t *uc)
28 setmcontext(&uc->uc_mcontext);
32 swapcontext(ucontext_t *oucp, ucontext_t *ucp)
34 if(getcontext(oucp) == 0)