aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/iorw.c
blob: b69f9ec42b4c68a897c0f8a6656372f0f8ec5466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <u.h>
#include <unistd.h>
#include <fcntl.h>
#include <libc.h>
#include <fcall.h>
#include <thread.h>
#include "ioproc.h"

static long
_ioclose(va_list *arg)
{
	int fd;

	fd = va_arg(*arg, int);
	return close(fd);
}
int
ioclose(Ioproc *io, int fd)
{
	return iocall(io, _ioclose, fd);
}

static long
_iodial(va_list *arg)
{
	char *addr, *local, *dir;
	int *cdfp, fd;

	addr = va_arg(*arg, char*);
	local = va_arg(*arg, char*);
	dir = va_arg(*arg, char*);
	cdfp = va_arg(*arg, int*);

	fd = dial(addr, local, dir, cdfp);
	return fd;
}
int
iodial(Ioproc *io, char *addr, char *local, char *dir, int *cdfp)
{
	return iocall(io, _iodial, addr, local, dir, cdfp);
}

static long
_ioopen(va_list *arg)
{
	char *path;
	int mode;

	path = va_arg(*arg, char*);
	mode = va_arg(*arg, int);
	return open(path, mode);
}
int
ioopen(Ioproc *io, char *path, int mode)
{
	return iocall(io, _ioopen, path, mode);
}

static long
_ioread(va_list *arg)
{
	int fd;
	void *a;
	long n;

	fd = va_arg(*arg, int);
	a = va_arg(*arg, void*);
	n = va_arg(*arg, long);
	return read(fd, a, n);
}
long
ioread(Ioproc *io, int fd, void *a, long n)
{
	return iocall(io, _ioread, fd, a, n);
}

static long
_ioreadn(va_list *arg)
{
	int fd;
	void *a;
	long n;

	fd = va_arg(*arg, int);
	a = va_arg(*arg, void*);
	n = va_arg(*arg, long);
	n = readn(fd, a, n);
	return n;
}
long
ioreadn(Ioproc *io, int fd, void *a, long n)
{
	return iocall(io, _ioreadn, fd, a, n);
}

static long
_iosleep(va_list *arg)
{
	long n;

	n = va_arg(*arg, long);
	return sleep(n);
}
int
iosleep(Ioproc *io, long n)
{
	return iocall(io, _iosleep, n);
}

static long
_iowrite(va_list *arg)
{
	int fd;
	void *a;
	long n, nn;

	fd = va_arg(*arg, int);
	a = va_arg(*arg, void*);
	n = va_arg(*arg, long);
	nn = write(fd, a, n);
	return nn;
}
long
iowrite(Ioproc *io, int fd, void *a, long n)
{
	n = iocall(io, _iowrite, fd, a, n);
	return n;
}

static long
_iosendfd(va_list *arg)
{
	int n, fd, fd2;

	fd = va_arg(*arg, int);
	fd2 = va_arg(*arg, int);
	n = sendfd(fd, fd2);
	return n;
}
int
iosendfd(Ioproc *io, int fd, int fd2)
{
	return iocall(io, _iosendfd, fd, fd2);
}

static long
_iorecvfd(va_list *arg)
{
	int n, fd;

	fd = va_arg(*arg, int);
	n = recvfd(fd);
	return n;
}
int
iorecvfd(Ioproc *io, int fd)
{
	return iocall(io, _iorecvfd, fd);
}

static long
_ioread9pmsg(va_list *arg)
{
	int fd;
	void *a;
	int n;

	fd = va_arg(*arg, int);
	a = va_arg(*arg, void*);
	n = va_arg(*arg, int);
	read9pmsg(fd, a, n);
	return n;
}
int
ioread9pmsg(Ioproc *io, int fd, void *a, int n)
{
	return iocall(io, _ioread9pmsg, fd, a, n);
}