blob: 5c28246504e15f794db51e3d60100c7bb9bfe031 [file] [log] [blame]
rsc31cf0ab2004-12-28 03:50:11 +00001#include "threadimpl.h"
2
rsccea10002005-05-01 18:38:12 +00003#include "BSD.c"
rsc1d2533d2004-12-28 22:36:24 +00004
rscd54ead72004-12-28 04:20:39 +00005/*
6 * FreeBSD 4 and earlier needs the context functions.
7 */
8void
9makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
10{
11 int *sp;
12
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}
20
rscd54ead72004-12-28 04:20:39 +000021int
22swapcontext(ucontext_t *oucp, ucontext_t *ucp)
23{
24 if(getcontext(oucp) == 0)
25 setcontext(ucp);
26 return 0;
27}
28
rscb20b42b2005-08-10 18:48:31 +000029void
30_pthreadinit(void)
31{
32 __isthreaded = 1;
33 signal(SIGUSR2, sigusr2handler);
34}