3 #if defined(__cplusplus)
10 * basic procs and threads
12 int proccreate(void (*f)(void *arg), void *arg, unsigned int stacksize);
13 int threadcreate(void (*f)(void *arg), void *arg, unsigned int stacksize);
14 void threadexits(char *);
15 void threadexitsall(char *);
16 void threadsetname(char*, ...);
17 void threadsetstate(char*, ...);
18 int threadyield(void);
19 void _threadready(_Thread*);
20 void _threadswitch(void);
21 void _threadsetsysproc(void);
22 void _threadsleep(Rendez*);
23 _Thread *_threadwakeup(Rendez*);
24 #define yield threadyield
27 * I am tired of making this mistake.
29 #define exits do_not_call_exits_in_threaded_programs
30 #define _exits do_not_call__exits_in_threaded_programs
37 void threadnotify(int(*f)(void*,char*), int);
42 void threaddaemonize(void);
46 * per proc and thread data
48 void **procdata(void);
51 * supplied by user instead of main.
52 * mainstacksize is size of stack allocated to run threadmain
54 void threadmain(int argc, char *argv[]);
55 extern int mainstacksize;
58 * channel communication
60 typedef struct Alt Alt;
61 typedef struct _Altarray _Altarray;
62 typedef struct Channel Channel;
101 /* [Edit .+1,./^$/ |cfn -h $PLAN9/src/libthread/channel.c] */
102 int chanalt(Alt *alts);
103 Channel* chancreate(int elemsize, int elemcnt);
104 void chanfree(Channel *c);
105 int chaninit(Channel *c, int elemsize, int elemcnt);
106 int channbrecv(Channel *c, void *v);
107 void* channbrecvp(Channel *c);
108 ulong channbrecvul(Channel *c);
109 int channbsend(Channel *c, void *v);
110 int channbsendp(Channel *c, void *v);
111 int channbsendul(Channel *c, ulong v);
112 int chanrecv(Channel *c, void *v);
113 void* chanrecvp(Channel *c);
114 ulong chanrecvul(Channel *c);
115 int chansend(Channel *c, void *v);
116 int chansendp(Channel *c, void *v);
117 int chansendul(Channel *c, ulong v);
118 void chansetname(Channel *c, char *fmt, ...);
121 #define nbrecv channbrecv
122 #define nbrecvp channbrecvp
123 #define nvrecvul channbrecvul
124 #define nbsend channbsend
125 #define nbsendp channbsendp
126 #define nbsendul channbsendul
127 #define recv chanrecv
128 #define recvp chanrecvp
129 #define recvul chanrecvul
130 #define send chansend
131 #define sendp chansendp
132 #define sendul chansendul
137 typedef struct Ref Ref;
148 * slave i/o processes
150 typedef struct Ioproc Ioproc;
152 /* [Edit .+1,/^$/ |cfn -h $PLAN9/src/libthread/io*.c] */
153 void closeioproc(Ioproc *io);
154 long iocall(Ioproc *io, long (*op)(va_list*), ...);
155 int ioclose(Ioproc *io, int fd);
156 int iodial(Ioproc *io, char *addr, char *local, char *dir, int *cdfp);
157 void iointerrupt(Ioproc *io);
158 int ioopen(Ioproc *io, char *path, int mode);
159 Ioproc* ioproc(void);
160 long ioread(Ioproc *io, int fd, void *a, long n);
161 int ioread9pmsg(Ioproc*, int, void*, int);
162 long ioreadn(Ioproc *io, int fd, void *a, long n);
163 int iorecvfd(Ioproc *, int);
164 int iosendfd(Ioproc*, int, int);
165 int iosleep(Ioproc *io, long n);
166 long iowrite(Ioproc *io, int fd, void *a, long n);
169 * exec external programs
171 void threadexec(Channel*, int[3], char*, char *[]);
172 void threadexecl(Channel*, int[3], char*, ...);
173 int threadspawn(int[3], char*, char*[]);
174 Channel* threadwaitchan(void);
176 #if defined(__cplusplus)
179 #endif /* _THREADH_ */