Blob


1 #include "threadimpl.h"
3 #include "BSD.c"
5 /*
6 * FreeBSD 4 and earlier needs the context functions.
7 */
8 void
9 makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
10 {
11 int *sp;
13 sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4;
14 sp -= argc;
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;
19 }
21 int
22 swapcontext(ucontext_t *oucp, ucontext_t *ucp)
23 {
24 if(getcontext(oucp) == 0)
25 setcontext(ucp);
26 return 0;
27 }
29 void
30 _pthreadinit(void)
31 {
32 __isthreaded = 1;
33 signal(SIGUSR2, sigusr2handler);
34 }