8 #if !defined(__OpenBSD__)
9 # if defined(__APPLE__)
10 # define _XOPEN_SOURCE /* for Snow Leopard */
13 #include <sys/utsname.h>
17 typedef struct Execjob Execjob;
18 typedef struct Proc Proc;
19 typedef struct _Procrendez _Procrendez;
21 typedef struct Jmp Jmp;
54 void (*startfn)(void*);
67 _Procrendez schedrend;
70 extern void _procsleep(_Procrendez*);
71 extern void _procwakeup(_Procrendez*);
72 extern void _procwakeupandunlock(_Procrendez*);
86 _Threadlist idlequeue;
87 _Threadlist allthreads;
97 #define proc() _threadproc()
99 extern Proc *_threadprocs;
100 extern Lock _threadprocslock;
101 extern Proc *_threadexecproc;
102 extern Channel *_threadexecchan;
103 extern QLock _threadexeclock;
104 extern Channel *_dowaitchan;
106 extern void _procstart(Proc*, void (*fn)(Proc*));
107 extern _Thread *_threadcreate(Proc*, void(*fn)(void*), void*, uint);
108 extern void _procexit(void);
109 extern Proc *_threadproc(void);
110 extern void _threadsetproc(Proc*);
111 extern int _threadlock(Lock*, int, ulong);
112 extern void _threadunlock(Lock*, ulong);
113 extern void _pthreadinit(void);
114 extern int _threadspawn(int*, char*, char**, char*);
115 extern int _runthreadspawn(int*, char*, char**, char*);
116 extern void _threadsetupdaemonize(void);
117 extern void _threaddodaemonize(char*);
118 extern void _threadpexit(void);
119 extern void _threaddaemonize(void);
120 extern void *_threadstkalloc(int);
121 extern void _threadstkfree(void*, int);
122 extern void _threadpthreadmain(Proc*, _Thread*);
123 extern void _threadpthreadstart(Proc*, _Thread*);
125 #define USPALIGN(ucp, align) \
126 (void*)((((uintptr)(ucp)->uc_stack.ss_sp+(ucp)->uc_stack.ss_size)-(align))&~((align)-1))