8 #if !defined(__OpenBSD__)
11 #include <sys/utsname.h>
15 #if defined(__FreeBSD__) && __FreeBSD__ < 5
16 extern int getmcontext(mcontext_t*);
17 extern void setmcontext(mcontext_t*);
18 #define setcontext(u) setmcontext(&(u)->uc_mcontext)
19 #define getcontext(u) getmcontext(&(u)->uc_mcontext)
20 extern int swapcontext(ucontext_t*, ucontext_t*);
21 extern void makecontext(ucontext_t*, void(*)(), int, ...);
24 #if defined(__APPLE__)
25 # define mcontext libthread_mcontext
26 # define mcontext_t libthread_mcontext_t
27 # define ucontext libthread_ucontext
28 # define ucontext_t libthread_ucontext_t
29 # if defined(__i386__)
30 # include "386-ucontext.h"
32 # include "power-ucontext.h"
36 #if defined(__OpenBSD__)
37 # define mcontext libthread_mcontext
38 # define mcontext_t libthread_mcontext_t
39 # define ucontext libthread_ucontext
40 # define ucontext_t libthread_ucontext_t
42 # include "386-ucontext.h"
44 # include "power-ucontext.h"
46 extern pid_t rfork_thread(int, void*, int(*)(void*), void*);
50 # define mcontext libthread_mcontext
51 # define mcontext_t libthread_mcontext_t
52 # define ucontext libthread_ucontext
53 # define ucontext_t libthread_ucontext_t
54 # include "sparc-ucontext.h"
58 int getmcontext(mcontext_t*);
59 void setmcontext(const mcontext_t*);
60 #define setcontext(u) setmcontext(&(u)->uc_mcontext)
61 #define getcontext(u) getmcontext(&(u)->uc_mcontext)
65 typedef struct Context Context;
66 typedef struct Execjob Execjob;
67 typedef struct Proc Proc;
68 typedef struct _Procrendez _Procrendez;
70 typedef struct Jmp Jmp;
105 void (*startfn)(void*);
117 #ifdef PLAN9PORT_USING_PTHREADS
124 extern void _procsleep(_Procrendez*);
125 extern void _procwakeup(_Procrendez*);
126 extern void _procwakeupandunlock(_Procrendez*);
133 #ifdef PLAN9PORT_USING_PTHREADS
142 _Threadlist runqueue;
143 _Threadlist idlequeue;
144 _Threadlist allthreads;
148 Context schedcontext;
154 #define proc() _threadproc()
155 #define setproc(p) _threadsetproc(p)
157 extern Proc *_threadprocs;
158 extern Lock _threadprocslock;
159 extern Proc *_threadexecproc;
160 extern Channel *_threadexecchan;
161 extern QLock _threadexeclock;
162 extern Channel *_dowaitchan;
164 extern void _procstart(Proc*, void (*fn)(Proc*));
165 extern _Thread *_threadcreate(Proc*, void(*fn)(void*), void*, uint);
166 extern void _threadexit(void);
167 extern Proc *_threadproc(void);
168 extern void _threadsetproc(Proc*);
169 extern int _threadlock(Lock*, int, ulong);
170 extern void _threadunlock(Lock*, ulong);
171 extern void _pthreadinit(void);
172 extern int _threadspawn(int*, char*, char**);
173 extern int _runthreadspawn(int*, char*, char**);
174 extern void _threadsetupdaemonize(void);
175 extern void _threaddodaemonize(char*);
176 extern void _threadpexit(void);
177 extern void _threaddaemonize(void);