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