Lines 1-9
Link Here
|
1 |
/* |
1 |
/* |
|
|
2 |
* Copyright (c) 2014 The FreeBSD Foundation. |
2 |
* Copyright (C) 2005 David Xu <davidxu@freebsd.org>. |
3 |
* Copyright (C) 2005 David Xu <davidxu@freebsd.org>. |
3 |
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>. |
4 |
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>. |
4 |
* Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. |
5 |
* Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. |
5 |
* All rights reserved. |
6 |
* All rights reserved. |
6 |
* |
7 |
* |
|
|
8 |
* Portions of this software were developed by Konstantin Belousov |
9 |
* under sponsorship from the FreeBSD Foundation. |
10 |
* |
7 |
* Redistribution and use in source and binary forms, with or without |
11 |
* Redistribution and use in source and binary forms, with or without |
8 |
* modification, are permitted provided that the following conditions |
12 |
* modification, are permitted provided that the following conditions |
9 |
* are met: |
13 |
* are met: |
Lines 27-34
Link Here
|
27 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
31 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
28 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
32 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
29 |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 |
* |
|
|
31 |
* $FreeBSD$ |
32 |
*/ |
34 |
*/ |
33 |
|
35 |
|
34 |
/* |
36 |
/* |
Lines 61-66
Link Here
|
61 |
* |
63 |
* |
62 |
*/ |
64 |
*/ |
63 |
|
65 |
|
|
|
66 |
#include <sys/cdefs.h> |
67 |
__FBSDID("$FreeBSD$"); |
68 |
|
64 |
#include "namespace.h" |
69 |
#include "namespace.h" |
65 |
#include <sys/types.h> |
70 |
#include <sys/types.h> |
66 |
#include <sys/mman.h> |
71 |
#include <sys/mman.h> |
Lines 87-171
Link Here
|
87 |
#include <pthread.h> |
92 |
#include <pthread.h> |
88 |
#include "un-namespace.h" |
93 |
#include "un-namespace.h" |
89 |
|
94 |
|
|
|
95 |
#include "libc_private.h" |
90 |
#include "thr_private.h" |
96 |
#include "thr_private.h" |
91 |
|
97 |
|
92 |
extern int __creat(const char *, mode_t); |
|
|
93 |
extern int __pselect(int, fd_set *, fd_set *, fd_set *, |
94 |
const struct timespec *, const sigset_t *); |
95 |
extern unsigned __sleep(unsigned int); |
96 |
extern int __system(const char *); |
97 |
extern int __tcdrain(int); |
98 |
extern int __usleep(useconds_t); |
99 |
extern pid_t __wait(int *); |
100 |
extern pid_t __waitpid(pid_t, int *, int); |
101 |
extern int __sys_aio_suspend(const struct aiocb * const[], int, |
102 |
const struct timespec *); |
103 |
extern int __sys_accept(int, struct sockaddr *, socklen_t *); |
104 |
extern int __sys_accept4(int, struct sockaddr *, socklen_t *, int); |
105 |
extern int __sys_connect(int, const struct sockaddr *, socklen_t); |
106 |
extern int __sys_fsync(int); |
107 |
extern int __sys_msync(void *, size_t, int); |
108 |
extern int __sys_pselect(int, fd_set *, fd_set *, fd_set *, |
109 |
const struct timespec *, const sigset_t *); |
110 |
extern int __sys_poll(struct pollfd *, unsigned, int); |
111 |
extern ssize_t __sys_recv(int, void *, size_t, int); |
112 |
extern ssize_t __sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *); |
113 |
extern ssize_t __sys_recvmsg(int, struct msghdr *, int); |
114 |
extern int __sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); |
115 |
extern int __sys_sendfile(int, int, off_t, size_t, struct sf_hdtr *, |
116 |
off_t *, int); |
117 |
extern ssize_t __sys_sendmsg(int, const struct msghdr *, int); |
118 |
extern ssize_t __sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t); |
119 |
extern ssize_t __sys_readv(int, const struct iovec *, int); |
120 |
extern pid_t __sys_wait4(pid_t, int *, int, struct rusage *); |
121 |
extern ssize_t __sys_writev(int, const struct iovec *, int); |
122 |
|
123 |
int ___creat(const char *, mode_t); |
124 |
int ___pselect(int, fd_set *, fd_set *, fd_set *, |
125 |
const struct timespec *, const sigset_t *); |
126 |
unsigned ___sleep(unsigned); |
127 |
int ___system(const char *); |
128 |
int ___tcdrain(int); |
129 |
int ___usleep(useconds_t useconds); |
130 |
pid_t ___wait(int *); |
131 |
pid_t ___waitpid(pid_t, int *, int); |
132 |
int __accept(int, struct sockaddr *, socklen_t *); |
133 |
int __accept4(int, struct sockaddr *, socklen_t *, int); |
134 |
int __aio_suspend(const struct aiocb * const iocbs[], int, |
135 |
const struct timespec *); |
136 |
int __close(int); |
137 |
int __connect(int, const struct sockaddr *, socklen_t); |
138 |
int __fcntl(int, int,...); |
139 |
#ifdef SYSCALL_COMPAT |
98 |
#ifdef SYSCALL_COMPAT |
140 |
extern int __fcntl_compat(int, int,...); |
99 |
extern int __fcntl_compat(int, int, ...); |
141 |
#endif |
100 |
#endif |
142 |
int __fsync(int); |
|
|
143 |
int __msync(void *, size_t, int); |
144 |
int __nanosleep(const struct timespec *, struct timespec *); |
145 |
int __open(const char *, int,...); |
146 |
int __openat(int, const char *, int,...); |
147 |
int __poll(struct pollfd *, unsigned int, int); |
148 |
ssize_t __read(int, void *buf, size_t); |
149 |
ssize_t __readv(int, const struct iovec *, int); |
150 |
ssize_t __recvfrom(int, void *, size_t, int f, struct sockaddr *, socklen_t *); |
151 |
ssize_t __recvmsg(int, struct msghdr *, int); |
152 |
int __select(int, fd_set *, fd_set *, fd_set *, struct timeval *); |
153 |
ssize_t __sendmsg(int, const struct msghdr *, int); |
154 |
ssize_t __sendto(int, const void *, size_t, int, |
155 |
const struct sockaddr *, socklen_t); |
156 |
pid_t __wait3(int *, int, struct rusage *); |
157 |
pid_t __wait4(pid_t, int *, int, struct rusage *); |
158 |
ssize_t __write(int, const void *, size_t); |
159 |
ssize_t __writev(int, const struct iovec *, int); |
160 |
|
161 |
__weak_reference(__accept, accept); |
162 |
|
101 |
|
163 |
/* |
102 |
/* |
164 |
* Cancellation behavior: |
103 |
* Cancellation behavior: |
165 |
* If thread is canceled, no socket is created. |
104 |
* If thread is canceled, no socket is created. |
166 |
*/ |
105 |
*/ |
167 |
int |
106 |
static int |
168 |
__accept(int s, struct sockaddr *addr, socklen_t *addrlen) |
107 |
__thr_accept(int s, struct sockaddr *addr, socklen_t *addrlen) |
169 |
{ |
108 |
{ |
170 |
struct pthread *curthread; |
109 |
struct pthread *curthread; |
171 |
int ret; |
110 |
int ret; |
Lines 178-191
__accept(int s, struct sockaddr *addr, socklen_t *addrlen)
Link Here
|
178 |
return (ret); |
117 |
return (ret); |
179 |
} |
118 |
} |
180 |
|
119 |
|
181 |
__weak_reference(__accept4, accept4); |
|
|
182 |
|
183 |
/* |
120 |
/* |
184 |
* Cancellation behavior: |
121 |
* Cancellation behavior: |
185 |
* If thread is canceled, no socket is created. |
122 |
* If thread is canceled, no socket is created. |
186 |
*/ |
123 |
*/ |
187 |
int |
124 |
static int |
188 |
__accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) |
125 |
__thr_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) |
189 |
{ |
126 |
{ |
190 |
struct pthread *curthread; |
127 |
struct pthread *curthread; |
191 |
int ret; |
128 |
int ret; |
Lines 198-212
__accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
Link Here
|
198 |
return (ret); |
135 |
return (ret); |
199 |
} |
136 |
} |
200 |
|
137 |
|
201 |
__weak_reference(__aio_suspend, aio_suspend); |
138 |
static int |
202 |
|
139 |
__thr_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct |
203 |
int |
|
|
204 |
__aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct |
205 |
timespec *timeout) |
140 |
timespec *timeout) |
206 |
{ |
141 |
{ |
207 |
struct pthread *curthread = _get_curthread(); |
142 |
struct pthread *curthread; |
208 |
int ret; |
143 |
int ret; |
209 |
|
144 |
|
|
|
145 |
curthread = _get_curthread(); |
210 |
_thr_cancel_enter(curthread); |
146 |
_thr_cancel_enter(curthread); |
211 |
ret = __sys_aio_suspend(iocbs, niocb, timeout); |
147 |
ret = __sys_aio_suspend(iocbs, niocb, timeout); |
212 |
_thr_cancel_leave(curthread, 1); |
148 |
_thr_cancel_leave(curthread, 1); |
Lines 214-221
__aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
Link Here
|
214 |
return (ret); |
150 |
return (ret); |
215 |
} |
151 |
} |
216 |
|
152 |
|
217 |
__weak_reference(__close, close); |
|
|
218 |
|
219 |
/* |
153 |
/* |
220 |
* Cancellation behavior: |
154 |
* Cancellation behavior: |
221 |
* According to manual of close(), the file descriptor is always deleted. |
155 |
* According to manual of close(), the file descriptor is always deleted. |
Lines 223-234
__weak_reference(__close, close);
Link Here
|
223 |
* descriptor is always deleted despite whether the thread is canceled |
157 |
* descriptor is always deleted despite whether the thread is canceled |
224 |
* or not. |
158 |
* or not. |
225 |
*/ |
159 |
*/ |
226 |
int |
160 |
static int |
227 |
__close(int fd) |
161 |
__thr_close(int fd) |
228 |
{ |
162 |
{ |
229 |
struct pthread *curthread = _get_curthread(); |
163 |
struct pthread *curthread; |
230 |
int ret; |
164 |
int ret; |
231 |
|
165 |
|
|
|
166 |
curthread = _get_curthread(); |
232 |
_thr_cancel_enter2(curthread, 0); |
167 |
_thr_cancel_enter2(curthread, 0); |
233 |
ret = __sys_close(fd); |
168 |
ret = __sys_close(fd); |
234 |
_thr_cancel_leave(curthread, 1); |
169 |
_thr_cancel_leave(curthread, 1); |
Lines 236-253
__close(int fd)
Link Here
|
236 |
return (ret); |
171 |
return (ret); |
237 |
} |
172 |
} |
238 |
|
173 |
|
239 |
__weak_reference(__connect, connect); |
|
|
240 |
|
241 |
/* |
174 |
/* |
242 |
* Cancellation behavior: |
175 |
* Cancellation behavior: |
243 |
* If the thread is canceled, connection is not made. |
176 |
* If the thread is canceled, connection is not made. |
244 |
*/ |
177 |
*/ |
245 |
int |
178 |
static int |
246 |
__connect(int fd, const struct sockaddr *name, socklen_t namelen) |
179 |
__thr_connect(int fd, const struct sockaddr *name, socklen_t namelen) |
247 |
{ |
180 |
{ |
248 |
struct pthread *curthread = _get_curthread(); |
181 |
struct pthread *curthread; |
249 |
int ret; |
182 |
int ret; |
250 |
|
183 |
|
|
|
184 |
curthread = _get_curthread(); |
251 |
_thr_cancel_enter(curthread); |
185 |
_thr_cancel_enter(curthread); |
252 |
ret = __sys_connect(fd, name, namelen); |
186 |
ret = __sys_connect(fd, name, namelen); |
253 |
_thr_cancel_leave(curthread, ret == -1); |
187 |
_thr_cancel_leave(curthread, ret == -1); |
Lines 255-281
__connect(int fd, const struct sockaddr *name, socklen_t namelen)
Link Here
|
255 |
return (ret); |
189 |
return (ret); |
256 |
} |
190 |
} |
257 |
|
191 |
|
258 |
__weak_reference(___creat, creat); |
|
|
259 |
|
192 |
|
260 |
/* |
193 |
/* |
261 |
* Cancellation behavior: |
194 |
* Cancellation behavior: |
262 |
* If thread is canceled, file is not created. |
195 |
* If thread is canceled, file is not created. |
263 |
*/ |
196 |
*/ |
264 |
int |
197 |
static int |
265 |
___creat(const char *path, mode_t mode) |
198 |
__thr_creat(const char *path, mode_t mode) |
266 |
{ |
199 |
{ |
267 |
struct pthread *curthread = _get_curthread(); |
200 |
struct pthread *curthread; |
268 |
int ret; |
201 |
int ret; |
269 |
|
202 |
|
|
|
203 |
curthread = _get_curthread(); |
270 |
_thr_cancel_enter(curthread); |
204 |
_thr_cancel_enter(curthread); |
271 |
ret = __creat(path, mode); |
205 |
ret = __libc_creat(path, mode); |
272 |
_thr_cancel_leave(curthread, ret == -1); |
206 |
_thr_cancel_leave(curthread, ret == -1); |
273 |
|
207 |
|
274 |
return ret; |
208 |
return (ret); |
275 |
} |
209 |
} |
276 |
|
210 |
|
277 |
__weak_reference(__fcntl, fcntl); |
|
|
278 |
|
279 |
/* |
211 |
/* |
280 |
* Cancellation behavior: |
212 |
* Cancellation behavior: |
281 |
* According to specification, only F_SETLKW is a cancellation point. |
213 |
* According to specification, only F_SETLKW is a cancellation point. |
Lines 283-295
__weak_reference(__fcntl, fcntl);
Link Here
|
283 |
* is failure, this means the function does not generate side effect |
215 |
* is failure, this means the function does not generate side effect |
284 |
* if it is canceled. |
216 |
* if it is canceled. |
285 |
*/ |
217 |
*/ |
286 |
int |
218 |
static int |
287 |
__fcntl(int fd, int cmd,...) |
219 |
__thr_fcntl(int fd, int cmd, ...) |
288 |
{ |
220 |
{ |
289 |
struct pthread *curthread = _get_curthread(); |
221 |
struct pthread *curthread; |
290 |
int ret; |
222 |
int ret; |
291 |
va_list ap; |
223 |
va_list ap; |
292 |
|
224 |
|
|
|
225 |
curthread = _get_curthread(); |
293 |
va_start(ap, cmd); |
226 |
va_start(ap, cmd); |
294 |
if (cmd == F_OSETLKW || cmd == F_SETLKW) { |
227 |
if (cmd == F_OSETLKW || cmd == F_SETLKW) { |
295 |
_thr_cancel_enter(curthread); |
228 |
_thr_cancel_enter(curthread); |
Lines 311-328
__fcntl(int fd, int cmd,...)
Link Here
|
311 |
return (ret); |
244 |
return (ret); |
312 |
} |
245 |
} |
313 |
|
246 |
|
314 |
__weak_reference(__fsync, fsync); |
|
|
315 |
|
316 |
/* |
247 |
/* |
317 |
* Cancellation behavior: |
248 |
* Cancellation behavior: |
318 |
* Thread may be canceled after system call. |
249 |
* Thread may be canceled after system call. |
319 |
*/ |
250 |
*/ |
320 |
int |
251 |
static int |
321 |
__fsync(int fd) |
252 |
__thr_fsync(int fd) |
322 |
{ |
253 |
{ |
323 |
struct pthread *curthread = _get_curthread(); |
254 |
struct pthread *curthread; |
324 |
int ret; |
255 |
int ret; |
325 |
|
256 |
|
|
|
257 |
curthread = _get_curthread(); |
326 |
_thr_cancel_enter2(curthread, 0); |
258 |
_thr_cancel_enter2(curthread, 0); |
327 |
ret = __sys_fsync(fd); |
259 |
ret = __sys_fsync(fd); |
328 |
_thr_cancel_leave(curthread, 1); |
260 |
_thr_cancel_leave(curthread, 1); |
Lines 330-363
__fsync(int fd)
Link Here
|
330 |
return (ret); |
262 |
return (ret); |
331 |
} |
263 |
} |
332 |
|
264 |
|
333 |
__weak_reference(__msync, msync); |
|
|
334 |
|
335 |
/* |
265 |
/* |
336 |
* Cancellation behavior: |
266 |
* Cancellation behavior: |
337 |
* Thread may be canceled after system call. |
267 |
* Thread may be canceled after system call. |
338 |
*/ |
268 |
*/ |
339 |
int |
269 |
static int |
340 |
__msync(void *addr, size_t len, int flags) |
270 |
__thr_msync(void *addr, size_t len, int flags) |
341 |
{ |
271 |
{ |
342 |
struct pthread *curthread = _get_curthread(); |
272 |
struct pthread *curthread; |
343 |
int ret; |
273 |
int ret; |
344 |
|
274 |
|
|
|
275 |
curthread = _get_curthread(); |
345 |
_thr_cancel_enter2(curthread, 0); |
276 |
_thr_cancel_enter2(curthread, 0); |
346 |
ret = __sys_msync(addr, len, flags); |
277 |
ret = __sys_msync(addr, len, flags); |
347 |
_thr_cancel_leave(curthread, 1); |
278 |
_thr_cancel_leave(curthread, 1); |
348 |
|
279 |
|
349 |
return ret; |
280 |
return (ret); |
350 |
} |
281 |
} |
351 |
|
282 |
|
352 |
__weak_reference(__nanosleep, nanosleep); |
283 |
static int |
353 |
|
284 |
__thr_nanosleep(const struct timespec *time_to_sleep, |
354 |
int |
|
|
355 |
__nanosleep(const struct timespec *time_to_sleep, |
356 |
struct timespec *time_remaining) |
285 |
struct timespec *time_remaining) |
357 |
{ |
286 |
{ |
358 |
struct pthread *curthread = _get_curthread(); |
287 |
struct pthread *curthread; |
359 |
int ret; |
288 |
int ret; |
360 |
|
289 |
|
|
|
290 |
curthread = _get_curthread(); |
361 |
_thr_cancel_enter(curthread); |
291 |
_thr_cancel_enter(curthread); |
362 |
ret = __sys_nanosleep(time_to_sleep, time_remaining); |
292 |
ret = __sys_nanosleep(time_to_sleep, time_remaining); |
363 |
_thr_cancel_leave(curthread, 1); |
293 |
_thr_cancel_leave(curthread, 1); |
Lines 365-463
__nanosleep(const struct timespec *time_to_sleep,
Link Here
|
365 |
return (ret); |
295 |
return (ret); |
366 |
} |
296 |
} |
367 |
|
297 |
|
368 |
__weak_reference(__open, open); |
|
|
369 |
|
370 |
/* |
298 |
/* |
371 |
* Cancellation behavior: |
299 |
* Cancellation behavior: |
372 |
* If the thread is canceled, file is not opened. |
300 |
* If the thread is canceled, file is not opened. |
373 |
*/ |
301 |
*/ |
374 |
int |
302 |
static int |
375 |
__open(const char *path, int flags,...) |
303 |
__thr_open(const char *path, int flags,...) |
376 |
{ |
304 |
{ |
377 |
struct pthread *curthread = _get_curthread(); |
305 |
struct pthread *curthread; |
378 |
int ret; |
306 |
int mode, ret; |
379 |
int mode = 0; |
|
|
380 |
va_list ap; |
307 |
va_list ap; |
381 |
|
308 |
|
382 |
/* Check if the file is being created: */ |
309 |
/* Check if the file is being created: */ |
383 |
if (flags & O_CREAT) { |
310 |
if ((flags & O_CREAT) != 0) { |
384 |
/* Get the creation mode: */ |
311 |
/* Get the creation mode: */ |
385 |
va_start(ap, flags); |
312 |
va_start(ap, flags); |
386 |
mode = va_arg(ap, int); |
313 |
mode = va_arg(ap, int); |
387 |
va_end(ap); |
314 |
va_end(ap); |
|
|
315 |
} else { |
316 |
mode = 0; |
388 |
} |
317 |
} |
389 |
|
318 |
|
|
|
319 |
curthread = _get_curthread(); |
390 |
_thr_cancel_enter(curthread); |
320 |
_thr_cancel_enter(curthread); |
391 |
ret = __sys_open(path, flags, mode); |
321 |
ret = __sys_open(path, flags, mode); |
392 |
_thr_cancel_leave(curthread, ret == -1); |
322 |
_thr_cancel_leave(curthread, ret == -1); |
393 |
|
323 |
|
394 |
return ret; |
324 |
return (ret); |
395 |
} |
325 |
} |
396 |
|
326 |
|
397 |
__weak_reference(__openat, openat); |
|
|
398 |
|
399 |
/* |
327 |
/* |
400 |
* Cancellation behavior: |
328 |
* Cancellation behavior: |
401 |
* If the thread is canceled, file is not opened. |
329 |
* If the thread is canceled, file is not opened. |
402 |
*/ |
330 |
*/ |
403 |
int |
331 |
static int |
404 |
__openat(int fd, const char *path, int flags, ...) |
332 |
__thr_openat(int fd, const char *path, int flags, ...) |
405 |
{ |
333 |
{ |
406 |
struct pthread *curthread = _get_curthread(); |
334 |
struct pthread *curthread; |
407 |
int ret; |
335 |
int mode, ret; |
408 |
int mode = 0; |
|
|
409 |
va_list ap; |
336 |
va_list ap; |
410 |
|
337 |
|
411 |
|
338 |
|
412 |
/* Check if the file is being created: */ |
339 |
/* Check if the file is being created: */ |
413 |
if (flags & O_CREAT) { |
340 |
if ((flags & O_CREAT) != 0) { |
414 |
/* Get the creation mode: */ |
341 |
/* Get the creation mode: */ |
415 |
va_start(ap, flags); |
342 |
va_start(ap, flags); |
416 |
mode = va_arg(ap, int); |
343 |
mode = va_arg(ap, int); |
417 |
va_end(ap); |
344 |
va_end(ap); |
|
|
345 |
} else { |
346 |
mode = 0; |
418 |
} |
347 |
} |
419 |
|
348 |
|
|
|
349 |
curthread = _get_curthread(); |
420 |
_thr_cancel_enter(curthread); |
350 |
_thr_cancel_enter(curthread); |
421 |
ret = __sys_openat(fd, path, flags, mode); |
351 |
ret = __sys_openat(fd, path, flags, mode); |
422 |
_thr_cancel_leave(curthread, ret == -1); |
352 |
_thr_cancel_leave(curthread, ret == -1); |
423 |
|
353 |
|
424 |
return ret; |
354 |
return (ret); |
425 |
} |
355 |
} |
426 |
|
356 |
|
427 |
__weak_reference(__poll, poll); |
|
|
428 |
|
429 |
/* |
357 |
/* |
430 |
* Cancellation behavior: |
358 |
* Cancellation behavior: |
431 |
* Thread may be canceled at start, but if the system call returns something, |
359 |
* Thread may be canceled at start, but if the system call returns something, |
432 |
* the thread is not canceled. |
360 |
* the thread is not canceled. |
433 |
*/ |
361 |
*/ |
434 |
int |
362 |
static int |
435 |
__poll(struct pollfd *fds, unsigned int nfds, int timeout) |
363 |
__thr_poll(struct pollfd *fds, unsigned int nfds, int timeout) |
436 |
{ |
364 |
{ |
437 |
struct pthread *curthread = _get_curthread(); |
365 |
struct pthread *curthread; |
438 |
int ret; |
366 |
int ret; |
439 |
|
367 |
|
|
|
368 |
curthread = _get_curthread(); |
440 |
_thr_cancel_enter(curthread); |
369 |
_thr_cancel_enter(curthread); |
441 |
ret = __sys_poll(fds, nfds, timeout); |
370 |
ret = __sys_poll(fds, nfds, timeout); |
442 |
_thr_cancel_leave(curthread, ret == -1); |
371 |
_thr_cancel_leave(curthread, ret == -1); |
443 |
|
372 |
|
444 |
return ret; |
373 |
return (ret); |
445 |
} |
374 |
} |
446 |
|
375 |
|
447 |
__weak_reference(___pselect, pselect); |
|
|
448 |
|
449 |
/* |
376 |
/* |
450 |
* Cancellation behavior: |
377 |
* Cancellation behavior: |
451 |
* Thread may be canceled at start, but if the system call returns something, |
378 |
* Thread may be canceled at start, but if the system call returns something, |
452 |
* the thread is not canceled. |
379 |
* the thread is not canceled. |
453 |
*/ |
380 |
*/ |
454 |
int |
381 |
static int |
455 |
___pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, |
382 |
__thr_pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, |
456 |
const struct timespec *timo, const sigset_t *mask) |
383 |
const struct timespec *timo, const sigset_t *mask) |
457 |
{ |
384 |
{ |
458 |
struct pthread *curthread = _get_curthread(); |
385 |
struct pthread *curthread; |
459 |
int ret; |
386 |
int ret; |
460 |
|
387 |
|
|
|
388 |
curthread = _get_curthread(); |
461 |
_thr_cancel_enter(curthread); |
389 |
_thr_cancel_enter(curthread); |
462 |
ret = __sys_pselect(count, rfds, wfds, efds, timo, mask); |
390 |
ret = __sys_pselect(count, rfds, wfds, efds, timo, mask); |
463 |
_thr_cancel_leave(curthread, ret == -1); |
391 |
_thr_cancel_leave(curthread, ret == -1); |
Lines 465-785
___pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
Link Here
|
465 |
return (ret); |
393 |
return (ret); |
466 |
} |
394 |
} |
467 |
|
395 |
|
468 |
__weak_reference(__read, read); |
|
|
469 |
|
470 |
/* |
396 |
/* |
471 |
* Cancellation behavior: |
397 |
* Cancellation behavior: |
472 |
* Thread may be canceled at start, but if the system call got some data, |
398 |
* Thread may be canceled at start, but if the system call got some data, |
473 |
* the thread is not canceled. |
399 |
* the thread is not canceled. |
474 |
*/ |
400 |
*/ |
475 |
ssize_t |
401 |
static ssize_t |
476 |
__read(int fd, void *buf, size_t nbytes) |
402 |
__thr_read(int fd, void *buf, size_t nbytes) |
477 |
{ |
403 |
{ |
478 |
struct pthread *curthread = _get_curthread(); |
404 |
struct pthread *curthread; |
479 |
ssize_t ret; |
405 |
ssize_t ret; |
480 |
|
406 |
|
|
|
407 |
curthread = _get_curthread(); |
481 |
_thr_cancel_enter(curthread); |
408 |
_thr_cancel_enter(curthread); |
482 |
ret = __sys_read(fd, buf, nbytes); |
409 |
ret = __sys_read(fd, buf, nbytes); |
483 |
_thr_cancel_leave(curthread, ret == -1); |
410 |
_thr_cancel_leave(curthread, ret == -1); |
484 |
|
411 |
|
485 |
return ret; |
412 |
return (ret); |
486 |
} |
413 |
} |
487 |
|
414 |
|
488 |
__weak_reference(__readv, readv); |
|
|
489 |
|
490 |
/* |
415 |
/* |
491 |
* Cancellation behavior: |
416 |
* Cancellation behavior: |
492 |
* Thread may be canceled at start, but if the system call got some data, |
417 |
* Thread may be canceled at start, but if the system call got some data, |
493 |
* the thread is not canceled. |
418 |
* the thread is not canceled. |
494 |
*/ |
419 |
*/ |
495 |
ssize_t |
420 |
static ssize_t |
496 |
__readv(int fd, const struct iovec *iov, int iovcnt) |
421 |
__thr_readv(int fd, const struct iovec *iov, int iovcnt) |
497 |
{ |
422 |
{ |
498 |
struct pthread *curthread = _get_curthread(); |
423 |
struct pthread *curthread; |
499 |
ssize_t ret; |
424 |
ssize_t ret; |
500 |
|
425 |
|
|
|
426 |
curthread = _get_curthread(); |
501 |
_thr_cancel_enter(curthread); |
427 |
_thr_cancel_enter(curthread); |
502 |
ret = __sys_readv(fd, iov, iovcnt); |
428 |
ret = __sys_readv(fd, iov, iovcnt); |
503 |
_thr_cancel_leave(curthread, ret == -1); |
429 |
_thr_cancel_leave(curthread, ret == -1); |
504 |
return ret; |
430 |
return (ret); |
505 |
} |
431 |
} |
506 |
|
432 |
|
507 |
__weak_reference(__recvfrom, recvfrom); |
|
|
508 |
|
509 |
/* |
433 |
/* |
510 |
* Cancellation behavior: |
434 |
* Cancellation behavior: |
511 |
* Thread may be canceled at start, but if the system call got some data, |
435 |
* Thread may be canceled at start, but if the system call got some data, |
512 |
* the thread is not canceled. |
436 |
* the thread is not canceled. |
513 |
*/ |
437 |
*/ |
514 |
ssize_t |
438 |
static ssize_t |
515 |
__recvfrom(int s, void *b, size_t l, int f, struct sockaddr *from, |
439 |
__thr_recvfrom(int s, void *b, size_t l, int f, struct sockaddr *from, |
516 |
socklen_t *fl) |
440 |
socklen_t *fl) |
517 |
{ |
441 |
{ |
518 |
struct pthread *curthread = _get_curthread(); |
442 |
struct pthread *curthread; |
519 |
ssize_t ret; |
443 |
ssize_t ret; |
520 |
|
444 |
|
|
|
445 |
curthread = _get_curthread(); |
521 |
_thr_cancel_enter(curthread); |
446 |
_thr_cancel_enter(curthread); |
522 |
ret = __sys_recvfrom(s, b, l, f, from, fl); |
447 |
ret = __sys_recvfrom(s, b, l, f, from, fl); |
523 |
_thr_cancel_leave(curthread, ret == -1); |
448 |
_thr_cancel_leave(curthread, ret == -1); |
524 |
return (ret); |
449 |
return (ret); |
525 |
} |
450 |
} |
526 |
|
451 |
|
527 |
__weak_reference(__recvmsg, recvmsg); |
|
|
528 |
|
529 |
/* |
452 |
/* |
530 |
* Cancellation behavior: |
453 |
* Cancellation behavior: |
531 |
* Thread may be canceled at start, but if the system call got some data, |
454 |
* Thread may be canceled at start, but if the system call got some data, |
532 |
* the thread is not canceled. |
455 |
* the thread is not canceled. |
533 |
*/ |
456 |
*/ |
534 |
ssize_t |
457 |
static ssize_t |
535 |
__recvmsg(int s, struct msghdr *m, int f) |
458 |
__thr_recvmsg(int s, struct msghdr *m, int f) |
536 |
{ |
459 |
{ |
537 |
struct pthread *curthread = _get_curthread(); |
460 |
struct pthread *curthread; |
538 |
ssize_t ret; |
461 |
ssize_t ret; |
539 |
|
462 |
|
|
|
463 |
curthread = _get_curthread(); |
540 |
_thr_cancel_enter(curthread); |
464 |
_thr_cancel_enter(curthread); |
541 |
ret = __sys_recvmsg(s, m, f); |
465 |
ret = __sys_recvmsg(s, m, f); |
542 |
_thr_cancel_leave(curthread, ret == -1); |
466 |
_thr_cancel_leave(curthread, ret == -1); |
543 |
return (ret); |
467 |
return (ret); |
544 |
} |
468 |
} |
545 |
|
469 |
|
546 |
__weak_reference(__select, select); |
|
|
547 |
|
548 |
/* |
470 |
/* |
549 |
* Cancellation behavior: |
471 |
* Cancellation behavior: |
550 |
* Thread may be canceled at start, but if the system call returns something, |
472 |
* Thread may be canceled at start, but if the system call returns something, |
551 |
* the thread is not canceled. |
473 |
* the thread is not canceled. |
552 |
*/ |
474 |
*/ |
553 |
int |
475 |
static int |
554 |
__select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
476 |
__thr_select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
555 |
struct timeval *timeout) |
477 |
struct timeval *timeout) |
556 |
{ |
478 |
{ |
557 |
struct pthread *curthread = _get_curthread(); |
479 |
struct pthread *curthread; |
558 |
int ret; |
480 |
int ret; |
559 |
|
481 |
|
|
|
482 |
curthread = _get_curthread(); |
560 |
_thr_cancel_enter(curthread); |
483 |
_thr_cancel_enter(curthread); |
561 |
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); |
484 |
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); |
562 |
_thr_cancel_leave(curthread, ret == -1); |
485 |
_thr_cancel_leave(curthread, ret == -1); |
563 |
return ret; |
486 |
return (ret); |
564 |
} |
487 |
} |
565 |
|
488 |
|
566 |
__weak_reference(__sendmsg, sendmsg); |
|
|
567 |
|
568 |
/* |
489 |
/* |
569 |
* Cancellation behavior: |
490 |
* Cancellation behavior: |
570 |
* Thread may be canceled at start, but if the system call sent |
491 |
* Thread may be canceled at start, but if the system call sent |
571 |
* data, the thread is not canceled. |
492 |
* data, the thread is not canceled. |
572 |
*/ |
493 |
*/ |
573 |
ssize_t |
494 |
static ssize_t |
574 |
__sendmsg(int s, const struct msghdr *m, int f) |
495 |
__thr_sendmsg(int s, const struct msghdr *m, int f) |
575 |
{ |
496 |
{ |
576 |
struct pthread *curthread = _get_curthread(); |
497 |
struct pthread *curthread; |
577 |
ssize_t ret; |
498 |
ssize_t ret; |
578 |
|
499 |
|
|
|
500 |
curthread = _get_curthread(); |
579 |
_thr_cancel_enter(curthread); |
501 |
_thr_cancel_enter(curthread); |
580 |
ret = __sys_sendmsg(s, m, f); |
502 |
ret = __sys_sendmsg(s, m, f); |
581 |
_thr_cancel_leave(curthread, ret <= 0); |
503 |
_thr_cancel_leave(curthread, ret <= 0); |
582 |
return (ret); |
504 |
return (ret); |
583 |
} |
505 |
} |
584 |
|
506 |
|
585 |
__weak_reference(__sendto, sendto); |
|
|
586 |
|
587 |
/* |
507 |
/* |
588 |
* Cancellation behavior: |
508 |
* Cancellation behavior: |
589 |
* Thread may be canceled at start, but if the system call sent some |
509 |
* Thread may be canceled at start, but if the system call sent some |
590 |
* data, the thread is not canceled. |
510 |
* data, the thread is not canceled. |
591 |
*/ |
511 |
*/ |
592 |
ssize_t |
512 |
static ssize_t |
593 |
__sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t, |
513 |
__thr_sendto(int s, const void *m, size_t l, int f, const struct sockaddr *t, |
594 |
socklen_t tl) |
514 |
socklen_t tl) |
595 |
{ |
515 |
{ |
596 |
struct pthread *curthread = _get_curthread(); |
516 |
struct pthread *curthread; |
597 |
ssize_t ret; |
517 |
ssize_t ret; |
598 |
|
518 |
|
|
|
519 |
curthread = _get_curthread(); |
599 |
_thr_cancel_enter(curthread); |
520 |
_thr_cancel_enter(curthread); |
600 |
ret = __sys_sendto(s, m, l, f, t, tl); |
521 |
ret = __sys_sendto(s, m, l, f, t, tl); |
601 |
_thr_cancel_leave(curthread, ret <= 0); |
522 |
_thr_cancel_leave(curthread, ret <= 0); |
602 |
return (ret); |
523 |
return (ret); |
603 |
} |
524 |
} |
604 |
|
525 |
|
605 |
__weak_reference(___sleep, sleep); |
526 |
static unsigned int |
606 |
|
527 |
__thr_sleep(unsigned int seconds) |
607 |
unsigned int |
|
|
608 |
___sleep(unsigned int seconds) |
609 |
{ |
528 |
{ |
610 |
struct pthread *curthread = _get_curthread(); |
529 |
struct pthread *curthread; |
611 |
unsigned int ret; |
530 |
unsigned int ret; |
612 |
|
531 |
|
|
|
532 |
curthread = _get_curthread(); |
613 |
_thr_cancel_enter(curthread); |
533 |
_thr_cancel_enter(curthread); |
614 |
ret = __sleep(seconds); |
534 |
ret = __libc_sleep(seconds); |
615 |
_thr_cancel_leave(curthread, 1); |
535 |
_thr_cancel_leave(curthread, 1); |
616 |
|
|
|
617 |
return (ret); |
536 |
return (ret); |
618 |
} |
537 |
} |
619 |
|
538 |
|
620 |
__weak_reference(___system, system); |
539 |
static int |
621 |
|
540 |
__thr_system(const char *string) |
622 |
int |
|
|
623 |
___system(const char *string) |
624 |
{ |
541 |
{ |
625 |
struct pthread *curthread = _get_curthread(); |
542 |
struct pthread *curthread; |
626 |
int ret; |
543 |
int ret; |
627 |
|
544 |
|
|
|
545 |
curthread = _get_curthread(); |
628 |
_thr_cancel_enter(curthread); |
546 |
_thr_cancel_enter(curthread); |
629 |
ret = __system(string); |
547 |
ret = __libc_system(string); |
630 |
_thr_cancel_leave(curthread, 1); |
548 |
_thr_cancel_leave(curthread, 1); |
631 |
|
549 |
return (ret); |
632 |
return ret; |
|
|
633 |
} |
550 |
} |
634 |
|
551 |
|
635 |
__weak_reference(___tcdrain, tcdrain); |
|
|
636 |
|
637 |
/* |
552 |
/* |
638 |
* Cancellation behavior: |
553 |
* Cancellation behavior: |
639 |
* If thread is canceled, the system call is not completed, |
554 |
* If thread is canceled, the system call is not completed, |
640 |
* this means not all bytes were drained. |
555 |
* this means not all bytes were drained. |
641 |
*/ |
556 |
*/ |
642 |
int |
557 |
static int |
643 |
___tcdrain(int fd) |
558 |
__thr_tcdrain(int fd) |
644 |
{ |
559 |
{ |
645 |
struct pthread *curthread = _get_curthread(); |
560 |
struct pthread *curthread; |
646 |
int ret; |
561 |
int ret; |
647 |
|
562 |
|
|
|
563 |
curthread = _get_curthread(); |
648 |
_thr_cancel_enter(curthread); |
564 |
_thr_cancel_enter(curthread); |
649 |
ret = __tcdrain(fd); |
565 |
ret = __libc_tcdrain(fd); |
650 |
_thr_cancel_leave(curthread, ret == -1); |
566 |
_thr_cancel_leave(curthread, ret == -1); |
651 |
return (ret); |
567 |
return (ret); |
652 |
} |
568 |
} |
653 |
|
569 |
|
654 |
__weak_reference(___usleep, usleep); |
570 |
static int |
655 |
|
571 |
__thr_usleep(useconds_t useconds) |
656 |
int |
|
|
657 |
___usleep(useconds_t useconds) |
658 |
{ |
572 |
{ |
659 |
struct pthread *curthread = _get_curthread(); |
573 |
struct pthread *curthread; |
660 |
int ret; |
574 |
int ret; |
661 |
|
575 |
|
|
|
576 |
curthread = _get_curthread(); |
662 |
_thr_cancel_enter(curthread); |
577 |
_thr_cancel_enter(curthread); |
663 |
ret = __usleep(useconds); |
578 |
ret = __libc_usleep(useconds); |
664 |
_thr_cancel_leave(curthread, 1); |
579 |
_thr_cancel_leave(curthread, 1); |
665 |
|
|
|
666 |
return (ret); |
580 |
return (ret); |
667 |
} |
581 |
} |
668 |
|
582 |
|
669 |
__weak_reference(___wait, wait); |
|
|
670 |
|
671 |
/* |
583 |
/* |
672 |
* Cancellation behavior: |
584 |
* Cancellation behavior: |
673 |
* Thread may be canceled at start, but if the system call returns |
585 |
* Thread may be canceled at start, but if the system call returns |
674 |
* a child pid, the thread is not canceled. |
586 |
* a child pid, the thread is not canceled. |
675 |
*/ |
587 |
*/ |
676 |
pid_t |
588 |
static pid_t |
677 |
___wait(int *istat) |
589 |
__thr_wait(int *istat) |
678 |
{ |
590 |
{ |
679 |
struct pthread *curthread = _get_curthread(); |
591 |
struct pthread *curthread; |
680 |
pid_t ret; |
592 |
pid_t ret; |
681 |
|
593 |
|
|
|
594 |
curthread = _get_curthread(); |
682 |
_thr_cancel_enter(curthread); |
595 |
_thr_cancel_enter(curthread); |
683 |
ret = __wait(istat); |
596 |
ret = __libc_wait(istat); |
684 |
_thr_cancel_leave(curthread, ret <= 0); |
597 |
_thr_cancel_leave(curthread, ret <= 0); |
685 |
|
598 |
return (ret); |
686 |
return ret; |
|
|
687 |
} |
599 |
} |
688 |
|
600 |
|
689 |
__weak_reference(__wait3, wait3); |
|
|
690 |
|
691 |
/* |
601 |
/* |
692 |
* Cancellation behavior: |
602 |
* Cancellation behavior: |
693 |
* Thread may be canceled at start, but if the system call returns |
603 |
* Thread may be canceled at start, but if the system call returns |
694 |
* a child pid, the thread is not canceled. |
604 |
* a child pid, the thread is not canceled. |
695 |
*/ |
605 |
*/ |
696 |
pid_t |
606 |
static pid_t |
697 |
__wait3(int *status, int options, struct rusage *rusage) |
607 |
__thr_wait3(int *status, int options, struct rusage *rusage) |
698 |
{ |
608 |
{ |
699 |
struct pthread *curthread = _get_curthread(); |
609 |
struct pthread *curthread; |
700 |
pid_t ret; |
610 |
pid_t ret; |
701 |
|
611 |
|
|
|
612 |
curthread = _get_curthread(); |
702 |
_thr_cancel_enter(curthread); |
613 |
_thr_cancel_enter(curthread); |
703 |
ret = _wait4(WAIT_ANY, status, options, rusage); |
614 |
ret = __libc_wait3(status, options, rusage); |
704 |
_thr_cancel_leave(curthread, ret <= 0); |
615 |
_thr_cancel_leave(curthread, ret <= 0); |
705 |
|
|
|
706 |
return (ret); |
616 |
return (ret); |
707 |
} |
617 |
} |
708 |
|
618 |
|
709 |
__weak_reference(__wait4, wait4); |
|
|
710 |
|
711 |
/* |
619 |
/* |
712 |
* Cancellation behavior: |
620 |
* Cancellation behavior: |
713 |
* Thread may be canceled at start, but if the system call returns |
621 |
* Thread may be canceled at start, but if the system call returns |
714 |
* a child pid, the thread is not canceled. |
622 |
* a child pid, the thread is not canceled. |
715 |
*/ |
623 |
*/ |
716 |
pid_t |
624 |
static pid_t |
717 |
__wait4(pid_t pid, int *status, int options, struct rusage *rusage) |
625 |
__thr_wait4(pid_t pid, int *status, int options, struct rusage *rusage) |
718 |
{ |
626 |
{ |
719 |
struct pthread *curthread = _get_curthread(); |
627 |
struct pthread *curthread; |
720 |
pid_t ret; |
628 |
pid_t ret; |
721 |
|
629 |
|
|
|
630 |
curthread = _get_curthread(); |
722 |
_thr_cancel_enter(curthread); |
631 |
_thr_cancel_enter(curthread); |
723 |
ret = __sys_wait4(pid, status, options, rusage); |
632 |
ret = __sys_wait4(pid, status, options, rusage); |
724 |
_thr_cancel_leave(curthread, ret <= 0); |
633 |
_thr_cancel_leave(curthread, ret <= 0); |
725 |
|
634 |
return (ret); |
726 |
return ret; |
|
|
727 |
} |
635 |
} |
728 |
|
636 |
|
729 |
__weak_reference(___waitpid, waitpid); |
|
|
730 |
|
731 |
/* |
637 |
/* |
732 |
* Cancellation behavior: |
638 |
* Cancellation behavior: |
733 |
* Thread may be canceled at start, but if the system call returns |
639 |
* Thread may be canceled at start, but if the system call returns |
734 |
* a child pid, the thread is not canceled. |
640 |
* a child pid, the thread is not canceled. |
735 |
*/ |
641 |
*/ |
736 |
pid_t |
642 |
static pid_t |
737 |
___waitpid(pid_t wpid, int *status, int options) |
643 |
__thr_waitpid(pid_t wpid, int *status, int options) |
738 |
{ |
644 |
{ |
739 |
struct pthread *curthread = _get_curthread(); |
645 |
struct pthread *curthread; |
740 |
pid_t ret; |
646 |
pid_t ret; |
741 |
|
647 |
|
|
|
648 |
curthread = _get_curthread(); |
742 |
_thr_cancel_enter(curthread); |
649 |
_thr_cancel_enter(curthread); |
743 |
ret = __waitpid(wpid, status, options); |
650 |
ret = __libc_waitpid(wpid, status, options); |
744 |
_thr_cancel_leave(curthread, ret <= 0); |
651 |
_thr_cancel_leave(curthread, ret <= 0); |
745 |
|
652 |
return (ret); |
746 |
return ret; |
|
|
747 |
} |
653 |
} |
748 |
|
654 |
|
749 |
__weak_reference(__write, write); |
|
|
750 |
|
751 |
/* |
655 |
/* |
752 |
* Cancellation behavior: |
656 |
* Cancellation behavior: |
753 |
* Thread may be canceled at start, but if the thread wrote some data, |
657 |
* Thread may be canceled at start, but if the thread wrote some data, |
754 |
* it is not canceled. |
658 |
* it is not canceled. |
755 |
*/ |
659 |
*/ |
756 |
ssize_t |
660 |
static ssize_t |
757 |
__write(int fd, const void *buf, size_t nbytes) |
661 |
__thr_write(int fd, const void *buf, size_t nbytes) |
758 |
{ |
662 |
{ |
759 |
struct pthread *curthread = _get_curthread(); |
663 |
struct pthread *curthread; |
760 |
ssize_t ret; |
664 |
ssize_t ret; |
761 |
|
665 |
|
|
|
666 |
curthread = _get_curthread(); |
762 |
_thr_cancel_enter(curthread); |
667 |
_thr_cancel_enter(curthread); |
763 |
ret = __sys_write(fd, buf, nbytes); |
668 |
ret = __sys_write(fd, buf, nbytes); |
764 |
_thr_cancel_leave(curthread, (ret <= 0)); |
669 |
_thr_cancel_leave(curthread, (ret <= 0)); |
765 |
return ret; |
670 |
return (ret); |
766 |
} |
671 |
} |
767 |
|
672 |
|
768 |
__weak_reference(__writev, writev); |
|
|
769 |
|
770 |
/* |
673 |
/* |
771 |
* Cancellation behavior: |
674 |
* Cancellation behavior: |
772 |
* Thread may be canceled at start, but if the thread wrote some data, |
675 |
* Thread may be canceled at start, but if the thread wrote some data, |
773 |
* it is not canceled. |
676 |
* it is not canceled. |
774 |
*/ |
677 |
*/ |
775 |
ssize_t |
678 |
static ssize_t |
776 |
__writev(int fd, const struct iovec *iov, int iovcnt) |
679 |
__thr_writev(int fd, const struct iovec *iov, int iovcnt) |
777 |
{ |
680 |
{ |
778 |
struct pthread *curthread = _get_curthread(); |
681 |
struct pthread *curthread; |
779 |
ssize_t ret; |
682 |
ssize_t ret; |
780 |
|
683 |
|
|
|
684 |
curthread = _get_curthread(); |
781 |
_thr_cancel_enter(curthread); |
685 |
_thr_cancel_enter(curthread); |
782 |
ret = __sys_writev(fd, iov, iovcnt); |
686 |
ret = __sys_writev(fd, iov, iovcnt); |
783 |
_thr_cancel_leave(curthread, (ret <= 0)); |
687 |
_thr_cancel_leave(curthread, (ret <= 0)); |
784 |
return ret; |
688 |
return (ret); |
|
|
689 |
} |
690 |
|
691 |
void |
692 |
__thr_interpose_libc(void) |
693 |
{ |
694 |
|
695 |
__error_selector = __error_threaded; |
696 |
#define SLOT(name) \ |
697 |
*(__libc_interposing_slot(INTERPOS_##name)) = \ |
698 |
(interpos_func_t)__thr_##name; |
699 |
SLOT(accept); |
700 |
SLOT(accept4); |
701 |
SLOT(aio_suspend); |
702 |
SLOT(close); |
703 |
SLOT(connect); |
704 |
SLOT(creat); |
705 |
SLOT(fcntl); |
706 |
SLOT(fsync); |
707 |
SLOT(msync); |
708 |
SLOT(nanosleep); |
709 |
SLOT(open); |
710 |
SLOT(openat); |
711 |
SLOT(poll); |
712 |
SLOT(pselect); |
713 |
SLOT(raise); |
714 |
SLOT(read); |
715 |
SLOT(readv); |
716 |
SLOT(recvfrom); |
717 |
SLOT(recvmsg); |
718 |
SLOT(select); |
719 |
SLOT(sendmsg); |
720 |
SLOT(sendto); |
721 |
SLOT(setcontext); |
722 |
SLOT(sigaction); |
723 |
SLOT(sigprocmask); |
724 |
SLOT(sigsuspend); |
725 |
SLOT(sigwait); |
726 |
SLOT(sigtimedwait); |
727 |
SLOT(sigwaitinfo); |
728 |
SLOT(swapcontext); |
729 |
SLOT(system); |
730 |
SLOT(sleep); |
731 |
SLOT(tcdrain); |
732 |
SLOT(usleep); |
733 |
SLOT(pause); |
734 |
SLOT(wait); |
735 |
SLOT(wait3); |
736 |
SLOT(wait4); |
737 |
SLOT(waitpid); |
738 |
SLOT(write); |
739 |
SLOT(writev); |
740 |
#undef SLOT |
741 |
*(__libc_interposing_slot( |
742 |
INTERPOS__pthread_mutex_init_calloc_cb)) = |
743 |
(interpos_func_t)_pthread_mutex_init_calloc_cb; |
785 |
} |
744 |
} |