1 #include "threadimpl.h"
6 * FreeBSD 4 and earlier needs the context functions.
9 makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
13 sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4;
15 memmove(sp, &argc+1, argc*sizeof(int));
16 *--sp = 0; /* return address */
17 ucp->uc_mcontext.mc_eip = (long)func;
18 ucp->uc_mcontext.mc_esp = (int)sp;
21 extern int getmcontext(mcontext_t*);
22 extern int setmcontext(mcontext_t*);
25 getcontext(ucontext_t *uc)
27 return getmcontext(&uc->uc_mcontext);
31 setcontext(ucontext_t *uc)
33 setmcontext(&uc->uc_mcontext);
37 swapcontext(ucontext_t *oucp, ucontext_t *ucp)
39 if(getcontext(oucp) == 0)