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*);
49 /* THIS DOES NOT WORK! Don't do this!
50 (At least, not on Solaris. Maybe this is right for Linux,
51 in which case it should say if defined(__linux__) && defined(__sun__),
52 but surely the latter would be defined(__sparc__).
55 # define mcontext libthread_mcontext
56 # define mcontext_t libthread_mcontext_t
57 # define ucontext libthread_ucontext
58 # define ucontext_t libthread_ucontext_t
59 # include "sparc-ucontext.h"
64 int getmcontext(mcontext_t*);
65 void setmcontext(const mcontext_t*);
66 #define setcontext(u) setmcontext(&(u)->uc_mcontext)
67 #define getcontext(u) getmcontext(&(u)->uc_mcontext)
71 typedef struct Context Context;
72 typedef struct Execjob Execjob;
73 typedef struct Proc Proc;
74 typedef struct _Procrendez _Procrendez;
76 typedef struct Jmp Jmp;
111 void (*startfn)(void*);
124 #ifdef PLAN9PORT_USING_PTHREADS
131 extern void _procsleep(_Procrendez*);
132 extern void _procwakeup(_Procrendez*);
133 extern void _procwakeupandunlock(_Procrendez*);
140 #ifdef PLAN9PORT_USING_PTHREADS
149 _Threadlist runqueue;
150 _Threadlist idlequeue;
151 _Threadlist allthreads;
155 Context schedcontext;
161 #define proc() _threadproc()
162 #define setproc(p) _threadsetproc(p)
164 extern Proc *_threadprocs;
165 extern Lock _threadprocslock;
166 extern Proc *_threadexecproc;
167 extern Channel *_threadexecchan;
168 extern QLock _threadexeclock;
169 extern Channel *_dowaitchan;
171 extern void _procstart(Proc*, void (*fn)(Proc*));
172 extern _Thread *_threadcreate(Proc*, void(*fn)(void*), void*, uint);
173 extern void _threadexit(void);
174 extern Proc *_threadproc(void);
175 extern void _threadsetproc(Proc*);
176 extern int _threadlock(Lock*, int, ulong);
177 extern void _threadunlock(Lock*, ulong);
178 extern void _pthreadinit(void);
179 extern int _threadspawn(int*, char*, char**);
180 extern int _runthreadspawn(int*, char*, char**);
181 extern void _threadsetupdaemonize(void);
182 extern void _threaddodaemonize(char*);
183 extern void _threadpexit(void);
184 extern void _threaddaemonize(void);