pthread_cancelstub.c revision 1.21 1 1.21 ad /* $NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $ */
2 1.2 thorpej
3 1.2 thorpej /*-
4 1.14 ad * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5 1.2 thorpej * All rights reserved.
6 1.2 thorpej *
7 1.2 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.14 ad * by Nathan J. Williams and Andrew Doran.
9 1.2 thorpej *
10 1.2 thorpej * Redistribution and use in source and binary forms, with or without
11 1.2 thorpej * modification, are permitted provided that the following conditions
12 1.2 thorpej * are met:
13 1.2 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.2 thorpej * notice, this list of conditions and the following disclaimer.
15 1.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.2 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.2 thorpej * documentation and/or other materials provided with the distribution.
18 1.2 thorpej *
19 1.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
30 1.2 thorpej */
31 1.5 lukem
32 1.5 lukem #include <sys/cdefs.h>
33 1.21 ad __RCSID("$NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $");
34 1.20 ad
35 1.20 ad #ifndef lint
36 1.20 ad
37 1.6 thorpej
38 1.6 thorpej /*
39 1.11 kleink * This is necessary because the names are always weak (they are not
40 1.11 kleink * POSIX functions).
41 1.6 thorpej */
42 1.6 thorpej #define fsync_range _fsync_range
43 1.11 kleink #define pollts _pollts
44 1.2 thorpej
45 1.10 kleink /*
46 1.10 kleink * XXX this is necessary to get the prototypes for the __sigsuspend14
47 1.10 kleink * XXX and __msync13 internal names, instead of the application-visible
48 1.10 kleink * XXX sigsuspend and msync names. It's kind of gross, but we're pretty
49 1.10 kleink * XXX intimate with libc already.
50 1.10 kleink */
51 1.10 kleink #define __LIBC12_SOURCE__
52 1.10 kleink
53 1.2 thorpej #include <sys/msg.h>
54 1.2 thorpej #include <sys/types.h>
55 1.2 thorpej #include <sys/uio.h>
56 1.2 thorpej #include <sys/wait.h>
57 1.15 rmind #include <aio.h>
58 1.2 thorpej #include <fcntl.h>
59 1.15 rmind #include <mqueue.h>
60 1.2 thorpej #include <poll.h>
61 1.2 thorpej #include <stdarg.h>
62 1.2 thorpej #include <unistd.h>
63 1.2 thorpej
64 1.2 thorpej #include <signal.h>
65 1.2 thorpej #include <sys/mman.h>
66 1.12 kleink #include <sys/select.h>
67 1.3 nathanw #include <sys/socket.h>
68 1.2 thorpej
69 1.13 christos #include <compat/sys/mman.h>
70 1.13 christos
71 1.2 thorpej #include "pthread.h"
72 1.2 thorpej #include "pthread_int.h"
73 1.2 thorpej
74 1.10 kleink int pthread__cancel_stub_binder;
75 1.10 kleink
76 1.3 nathanw int _sys_accept(int, struct sockaddr *, socklen_t *);
77 1.15 rmind int _sys_aio_suspend(const struct aiocb * const [], int,
78 1.15 rmind const struct timespec *);
79 1.2 thorpej int _sys_close(int);
80 1.3 nathanw int _sys_connect(int, const struct sockaddr *, socklen_t);
81 1.2 thorpej int _sys_fcntl(int, int, ...);
82 1.9 kleink int _sys_fdatasync(int);
83 1.2 thorpej int _sys_fsync(int);
84 1.6 thorpej int _sys_fsync_range(int, int, off_t, off_t);
85 1.15 rmind int _sys_mq_send(mqd_t, const char *, size_t, unsigned);
86 1.15 rmind ssize_t _sys_mq_receive(mqd_t, char *, size_t, unsigned *);
87 1.15 rmind int _sys_mq_timedsend(mqd_t, const char *, size_t, unsigned,
88 1.15 rmind const struct timespec *);
89 1.15 rmind ssize_t _sys_mq_timedreceive(mqd_t, char *, size_t, unsigned *,
90 1.15 rmind const struct timespec *);
91 1.2 thorpej ssize_t _sys_msgrcv(int, void *, size_t, long, int);
92 1.2 thorpej int _sys_msgsnd(int, const void *, size_t, int);
93 1.2 thorpej int _sys___msync13(void *, size_t, int);
94 1.2 thorpej int _sys_open(const char *, int, ...);
95 1.2 thorpej int _sys_poll(struct pollfd *, nfds_t, int);
96 1.11 kleink int _sys_pollts(struct pollfd *, nfds_t, const struct timespec *,
97 1.11 kleink const sigset_t *);
98 1.2 thorpej ssize_t _sys_pread(int, void *, size_t, off_t);
99 1.11 kleink int _sys_pselect(int, fd_set *, fd_set *, fd_set *,
100 1.11 kleink const struct timespec *, const sigset_t *);
101 1.2 thorpej ssize_t _sys_pwrite(int, const void *, size_t, off_t);
102 1.2 thorpej ssize_t _sys_read(int, void *, size_t);
103 1.2 thorpej ssize_t _sys_readv(int, const struct iovec *, int);
104 1.2 thorpej int _sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
105 1.2 thorpej int _sys_wait4(pid_t, int *, int, struct rusage *);
106 1.2 thorpej ssize_t _sys_write(int, const void *, size_t);
107 1.2 thorpej ssize_t _sys_writev(int, const struct iovec *, int);
108 1.14 ad int _sys___sigsuspend14(const sigset_t *);
109 1.14 ad int _sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict,
110 1.14 ad const struct timespec * __restrict);
111 1.14 ad int __sigsuspend14(const sigset_t *);
112 1.2 thorpej
113 1.7 nathanw #define TESTCANCEL(id) do { \
114 1.7 nathanw if (__predict_false((id)->pt_cancel)) \
115 1.17 ad pthread__cancelled(); \
116 1.8 cl } while (/*CONSTCOND*/0)
117 1.7 nathanw
118 1.2 thorpej
119 1.2 thorpej int
120 1.3 nathanw accept(int s, struct sockaddr *addr, socklen_t *addrlen)
121 1.3 nathanw {
122 1.3 nathanw int retval;
123 1.3 nathanw pthread_t self;
124 1.3 nathanw
125 1.3 nathanw self = pthread__self();
126 1.7 nathanw TESTCANCEL(self);
127 1.3 nathanw retval = _sys_accept(s, addr, addrlen);
128 1.7 nathanw TESTCANCEL(self);
129 1.3 nathanw
130 1.3 nathanw return retval;
131 1.3 nathanw }
132 1.3 nathanw
133 1.3 nathanw int
134 1.2 thorpej close(int d)
135 1.2 thorpej {
136 1.2 thorpej int retval;
137 1.2 thorpej pthread_t self;
138 1.2 thorpej
139 1.2 thorpej self = pthread__self();
140 1.7 nathanw TESTCANCEL(self);
141 1.2 thorpej retval = _sys_close(d);
142 1.7 nathanw TESTCANCEL(self);
143 1.3 nathanw
144 1.3 nathanw return retval;
145 1.3 nathanw }
146 1.3 nathanw
147 1.3 nathanw int
148 1.3 nathanw connect(int s, const struct sockaddr *addr, socklen_t namelen)
149 1.3 nathanw {
150 1.3 nathanw int retval;
151 1.3 nathanw pthread_t self;
152 1.3 nathanw
153 1.3 nathanw self = pthread__self();
154 1.7 nathanw TESTCANCEL(self);
155 1.3 nathanw retval = _sys_connect(s, addr, namelen);
156 1.7 nathanw TESTCANCEL(self);
157 1.2 thorpej
158 1.2 thorpej return retval;
159 1.2 thorpej }
160 1.2 thorpej
161 1.2 thorpej int
162 1.2 thorpej fcntl(int fd, int cmd, ...)
163 1.2 thorpej {
164 1.2 thorpej int retval;
165 1.2 thorpej pthread_t self;
166 1.2 thorpej va_list ap;
167 1.2 thorpej
168 1.2 thorpej self = pthread__self();
169 1.7 nathanw TESTCANCEL(self);
170 1.2 thorpej va_start(ap, cmd);
171 1.2 thorpej retval = _sys_fcntl(fd, cmd, va_arg(ap, void *));
172 1.2 thorpej va_end(ap);
173 1.7 nathanw TESTCANCEL(self);
174 1.2 thorpej
175 1.2 thorpej return retval;
176 1.2 thorpej }
177 1.2 thorpej
178 1.2 thorpej int
179 1.9 kleink fdatasync(int d)
180 1.9 kleink {
181 1.9 kleink int retval;
182 1.9 kleink pthread_t self;
183 1.9 kleink
184 1.9 kleink self = pthread__self();
185 1.9 kleink TESTCANCEL(self);
186 1.9 kleink retval = _sys_fdatasync(d);
187 1.9 kleink TESTCANCEL(self);
188 1.9 kleink
189 1.9 kleink return retval;
190 1.9 kleink }
191 1.9 kleink
192 1.9 kleink int
193 1.2 thorpej fsync(int d)
194 1.2 thorpej {
195 1.2 thorpej int retval;
196 1.2 thorpej pthread_t self;
197 1.2 thorpej
198 1.2 thorpej self = pthread__self();
199 1.7 nathanw TESTCANCEL(self);
200 1.2 thorpej retval = _sys_fsync(d);
201 1.7 nathanw TESTCANCEL(self);
202 1.2 thorpej
203 1.2 thorpej return retval;
204 1.2 thorpej }
205 1.2 thorpej
206 1.6 thorpej int
207 1.6 thorpej fsync_range(int d, int f, off_t s, off_t e)
208 1.6 thorpej {
209 1.6 thorpej int retval;
210 1.6 thorpej pthread_t self;
211 1.6 thorpej
212 1.6 thorpej self = pthread__self();
213 1.7 nathanw TESTCANCEL(self);
214 1.6 thorpej retval = _sys_fsync_range(d, f, s, e);
215 1.7 nathanw TESTCANCEL(self);
216 1.6 thorpej
217 1.6 thorpej return retval;
218 1.6 thorpej }
219 1.6 thorpej
220 1.2 thorpej ssize_t
221 1.2 thorpej msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
222 1.2 thorpej {
223 1.2 thorpej ssize_t retval;
224 1.2 thorpej pthread_t self;
225 1.2 thorpej
226 1.2 thorpej self = pthread__self();
227 1.7 nathanw TESTCANCEL(self);
228 1.2 thorpej retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg);
229 1.7 nathanw TESTCANCEL(self);
230 1.2 thorpej
231 1.2 thorpej return retval;
232 1.2 thorpej }
233 1.2 thorpej
234 1.2 thorpej int
235 1.2 thorpej msgsnd(int msgid, const void *msgp, size_t msgsz, int msgflg)
236 1.2 thorpej {
237 1.2 thorpej int retval;
238 1.2 thorpej pthread_t self;
239 1.2 thorpej
240 1.2 thorpej self = pthread__self();
241 1.7 nathanw TESTCANCEL(self);
242 1.2 thorpej retval = _sys_msgsnd(msgid, msgp, msgsz, msgflg);
243 1.7 nathanw TESTCANCEL(self);
244 1.2 thorpej
245 1.2 thorpej return retval;
246 1.2 thorpej }
247 1.2 thorpej
248 1.2 thorpej int
249 1.2 thorpej __msync13(void *addr, size_t len, int flags)
250 1.2 thorpej {
251 1.2 thorpej int retval;
252 1.2 thorpej pthread_t self;
253 1.2 thorpej
254 1.2 thorpej self = pthread__self();
255 1.7 nathanw TESTCANCEL(self);
256 1.2 thorpej retval = _sys___msync13(addr, len, flags);
257 1.7 nathanw TESTCANCEL(self);
258 1.2 thorpej
259 1.2 thorpej return retval;
260 1.2 thorpej }
261 1.2 thorpej
262 1.2 thorpej int
263 1.2 thorpej open(const char *path, int flags, ...)
264 1.2 thorpej {
265 1.2 thorpej int retval;
266 1.2 thorpej pthread_t self;
267 1.2 thorpej va_list ap;
268 1.2 thorpej
269 1.2 thorpej self = pthread__self();
270 1.7 nathanw TESTCANCEL(self);
271 1.2 thorpej va_start(ap, flags);
272 1.2 thorpej retval = _sys_open(path, flags, va_arg(ap, mode_t));
273 1.2 thorpej va_end(ap);
274 1.7 nathanw TESTCANCEL(self);
275 1.2 thorpej
276 1.2 thorpej return retval;
277 1.2 thorpej }
278 1.2 thorpej
279 1.2 thorpej int
280 1.2 thorpej poll(struct pollfd *fds, nfds_t nfds, int timeout)
281 1.2 thorpej {
282 1.2 thorpej int retval;
283 1.2 thorpej pthread_t self;
284 1.2 thorpej
285 1.2 thorpej self = pthread__self();
286 1.7 nathanw TESTCANCEL(self);
287 1.2 thorpej retval = _sys_poll(fds, nfds, timeout);
288 1.7 nathanw TESTCANCEL(self);
289 1.2 thorpej
290 1.2 thorpej return retval;
291 1.2 thorpej }
292 1.2 thorpej
293 1.11 kleink int
294 1.11 kleink pollts(struct pollfd *fds, nfds_t nfds, const struct timespec *ts,
295 1.11 kleink const sigset_t *sigmask)
296 1.11 kleink {
297 1.11 kleink int retval;
298 1.11 kleink pthread_t self;
299 1.11 kleink
300 1.11 kleink self = pthread__self();
301 1.11 kleink TESTCANCEL(self);
302 1.11 kleink retval = _sys_pollts(fds, nfds, ts, sigmask);
303 1.11 kleink TESTCANCEL(self);
304 1.11 kleink
305 1.11 kleink return retval;
306 1.11 kleink }
307 1.11 kleink
308 1.2 thorpej ssize_t
309 1.2 thorpej pread(int d, void *buf, size_t nbytes, off_t offset)
310 1.2 thorpej {
311 1.2 thorpej ssize_t retval;
312 1.2 thorpej pthread_t self;
313 1.2 thorpej
314 1.2 thorpej self = pthread__self();
315 1.7 nathanw TESTCANCEL(self);
316 1.2 thorpej retval = _sys_pread(d, buf, nbytes, offset);
317 1.7 nathanw TESTCANCEL(self);
318 1.2 thorpej
319 1.2 thorpej return retval;
320 1.2 thorpej }
321 1.2 thorpej
322 1.11 kleink int
323 1.11 kleink pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
324 1.11 kleink const struct timespec *timeout, const sigset_t *sigmask)
325 1.11 kleink {
326 1.11 kleink int retval;
327 1.11 kleink pthread_t self;
328 1.11 kleink
329 1.11 kleink self = pthread__self();
330 1.11 kleink TESTCANCEL(self);
331 1.11 kleink retval = _sys_pselect(nfds, readfds, writefds, exceptfds, timeout,
332 1.11 kleink sigmask);
333 1.11 kleink TESTCANCEL(self);
334 1.11 kleink
335 1.11 kleink return retval;
336 1.11 kleink }
337 1.11 kleink
338 1.2 thorpej ssize_t
339 1.2 thorpej pwrite(int d, const void *buf, size_t nbytes, off_t offset)
340 1.2 thorpej {
341 1.2 thorpej ssize_t retval;
342 1.2 thorpej pthread_t self;
343 1.2 thorpej
344 1.2 thorpej self = pthread__self();
345 1.7 nathanw TESTCANCEL(self);
346 1.2 thorpej retval = _sys_pwrite(d, buf, nbytes, offset);
347 1.7 nathanw TESTCANCEL(self);
348 1.2 thorpej
349 1.2 thorpej return retval;
350 1.2 thorpej }
351 1.2 thorpej
352 1.18 christos #ifdef _FORTIFY_SOURCE
353 1.18 christos #undef read
354 1.18 christos #endif
355 1.18 christos
356 1.2 thorpej ssize_t
357 1.2 thorpej read(int d, void *buf, size_t nbytes)
358 1.2 thorpej {
359 1.2 thorpej ssize_t retval;
360 1.2 thorpej pthread_t self;
361 1.2 thorpej
362 1.2 thorpej self = pthread__self();
363 1.7 nathanw TESTCANCEL(self);
364 1.2 thorpej retval = _sys_read(d, buf, nbytes);
365 1.7 nathanw TESTCANCEL(self);
366 1.2 thorpej
367 1.2 thorpej return retval;
368 1.2 thorpej }
369 1.2 thorpej
370 1.2 thorpej ssize_t
371 1.2 thorpej readv(int d, const struct iovec *iov, int iovcnt)
372 1.2 thorpej {
373 1.2 thorpej ssize_t retval;
374 1.2 thorpej pthread_t self;
375 1.2 thorpej
376 1.2 thorpej self = pthread__self();
377 1.7 nathanw TESTCANCEL(self);
378 1.2 thorpej retval = _sys_readv(d, iov, iovcnt);
379 1.7 nathanw TESTCANCEL(self);
380 1.2 thorpej
381 1.2 thorpej return retval;
382 1.2 thorpej }
383 1.2 thorpej
384 1.2 thorpej int
385 1.2 thorpej select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
386 1.2 thorpej struct timeval *timeout)
387 1.2 thorpej {
388 1.2 thorpej int retval;
389 1.2 thorpej pthread_t self;
390 1.2 thorpej
391 1.2 thorpej self = pthread__self();
392 1.7 nathanw TESTCANCEL(self);
393 1.2 thorpej retval = _sys_select(nfds, readfds, writefds, exceptfds, timeout);
394 1.7 nathanw TESTCANCEL(self);
395 1.2 thorpej
396 1.2 thorpej return retval;
397 1.2 thorpej }
398 1.2 thorpej
399 1.2 thorpej pid_t
400 1.2 thorpej wait4(pid_t wpid, int *status, int options, struct rusage *rusage)
401 1.2 thorpej {
402 1.2 thorpej pid_t retval;
403 1.2 thorpej pthread_t self;
404 1.2 thorpej
405 1.2 thorpej self = pthread__self();
406 1.7 nathanw TESTCANCEL(self);
407 1.2 thorpej retval = _sys_wait4(wpid, status, options, rusage);
408 1.7 nathanw TESTCANCEL(self);
409 1.2 thorpej
410 1.2 thorpej return retval;
411 1.2 thorpej }
412 1.2 thorpej
413 1.2 thorpej ssize_t
414 1.2 thorpej write(int d, const void *buf, size_t nbytes)
415 1.2 thorpej {
416 1.2 thorpej ssize_t retval;
417 1.2 thorpej pthread_t self;
418 1.2 thorpej
419 1.2 thorpej self = pthread__self();
420 1.7 nathanw TESTCANCEL(self);
421 1.2 thorpej retval = _sys_write(d, buf, nbytes);
422 1.7 nathanw TESTCANCEL(self);
423 1.2 thorpej
424 1.2 thorpej return retval;
425 1.2 thorpej }
426 1.2 thorpej
427 1.2 thorpej ssize_t
428 1.2 thorpej writev(int d, const struct iovec *iov, int iovcnt)
429 1.2 thorpej {
430 1.2 thorpej ssize_t retval;
431 1.2 thorpej pthread_t self;
432 1.2 thorpej
433 1.2 thorpej self = pthread__self();
434 1.7 nathanw TESTCANCEL(self);
435 1.2 thorpej retval = _sys_writev(d, iov, iovcnt);
436 1.7 nathanw TESTCANCEL(self);
437 1.2 thorpej
438 1.2 thorpej return retval;
439 1.2 thorpej }
440 1.2 thorpej
441 1.14 ad int
442 1.14 ad __sigsuspend14(const sigset_t *sigmask)
443 1.14 ad {
444 1.14 ad pthread_t self;
445 1.14 ad int retval;
446 1.14 ad
447 1.14 ad self = pthread__self();
448 1.14 ad TESTCANCEL(self);
449 1.14 ad retval = _sys___sigsuspend14(sigmask);
450 1.14 ad TESTCANCEL(self);
451 1.14 ad
452 1.14 ad return retval;
453 1.14 ad }
454 1.14 ad
455 1.14 ad int
456 1.14 ad sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info,
457 1.14 ad const struct timespec * __restrict timeout)
458 1.14 ad {
459 1.14 ad pthread_t self;
460 1.14 ad int retval;
461 1.14 ad
462 1.14 ad self = pthread__self();
463 1.14 ad TESTCANCEL(self);
464 1.14 ad retval = _sigtimedwait(set, info, timeout);
465 1.14 ad TESTCANCEL(self);
466 1.14 ad
467 1.14 ad return retval;
468 1.14 ad }
469 1.2 thorpej
470 1.2 thorpej __strong_alias(_close, close)
471 1.2 thorpej __strong_alias(_fcntl, fcntl)
472 1.9 kleink __strong_alias(_fdatasync, fdatasync)
473 1.2 thorpej __strong_alias(_fsync, fsync)
474 1.6 thorpej __weak_alias(fsync_range, _fsync_range)
475 1.2 thorpej __strong_alias(_msgrcv, msgrcv)
476 1.2 thorpej __strong_alias(_msgsnd, msgsnd)
477 1.2 thorpej __strong_alias(___msync13, __msync13)
478 1.2 thorpej __strong_alias(_open, open)
479 1.2 thorpej __strong_alias(_poll, poll)
480 1.11 kleink __weak_alias(pollts, _pollts)
481 1.2 thorpej __strong_alias(_pread, pread)
482 1.11 kleink __strong_alias(_pselect, pselect)
483 1.2 thorpej __strong_alias(_pwrite, pwrite)
484 1.2 thorpej __strong_alias(_read, read)
485 1.2 thorpej __strong_alias(_readv, readv)
486 1.2 thorpej __strong_alias(_select, select)
487 1.2 thorpej __strong_alias(_wait4, wait4)
488 1.2 thorpej __strong_alias(_write, write)
489 1.2 thorpej __strong_alias(_writev, writev)
490 1.20 ad
491 1.21 ad #ifndef PTHREAD__COMPAT
492 1.21 ad int
493 1.21 ad aio_suspend(const struct aiocb * const list[], int nent,
494 1.21 ad const struct timespec *timeout)
495 1.21 ad {
496 1.21 ad int retval;
497 1.21 ad pthread_t self;
498 1.21 ad
499 1.21 ad self = pthread__self();
500 1.21 ad TESTCANCEL(self);
501 1.21 ad retval = _sys_aio_suspend(list, nent, timeout);
502 1.21 ad TESTCANCEL(self);
503 1.21 ad
504 1.21 ad return retval;
505 1.21 ad }
506 1.21 ad
507 1.21 ad int
508 1.21 ad mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
509 1.21 ad {
510 1.21 ad int retval;
511 1.21 ad pthread_t self;
512 1.21 ad
513 1.21 ad self = pthread__self();
514 1.21 ad TESTCANCEL(self);
515 1.21 ad retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
516 1.21 ad TESTCANCEL(self);
517 1.21 ad
518 1.21 ad return retval;
519 1.21 ad }
520 1.21 ad
521 1.21 ad ssize_t
522 1.21 ad mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
523 1.21 ad {
524 1.21 ad ssize_t retval;
525 1.21 ad pthread_t self;
526 1.21 ad
527 1.21 ad self = pthread__self();
528 1.21 ad TESTCANCEL(self);
529 1.21 ad retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
530 1.21 ad TESTCANCEL(self);
531 1.21 ad
532 1.21 ad return retval;
533 1.21 ad }
534 1.21 ad
535 1.21 ad int
536 1.21 ad mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
537 1.21 ad unsigned msg_prio, const struct timespec *abst)
538 1.21 ad {
539 1.21 ad int retval;
540 1.21 ad pthread_t self;
541 1.21 ad
542 1.21 ad self = pthread__self();
543 1.21 ad TESTCANCEL(self);
544 1.21 ad retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst);
545 1.21 ad TESTCANCEL(self);
546 1.21 ad
547 1.21 ad return retval;
548 1.21 ad }
549 1.21 ad
550 1.21 ad ssize_t
551 1.21 ad mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio,
552 1.21 ad const struct timespec *abst)
553 1.21 ad {
554 1.21 ad ssize_t retval;
555 1.21 ad pthread_t self;
556 1.21 ad
557 1.21 ad self = pthread__self();
558 1.21 ad TESTCANCEL(self);
559 1.21 ad retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst);
560 1.21 ad TESTCANCEL(self);
561 1.21 ad
562 1.21 ad return retval;
563 1.21 ad }
564 1.21 ad
565 1.21 ad __strong_alias(_aio_suspend, aio_suspend)
566 1.21 ad __strong_alias(_mq_send, mq_send)
567 1.21 ad __strong_alias(_mq_receive, mq_receive)
568 1.21 ad __strong_alias(_mq_timedsend, mq_timedsend)
569 1.21 ad __strong_alias(_mq_timedreceive, mq_timedreceive)
570 1.21 ad #endif /* !PTHREAD__COMPAT */
571 1.21 ad
572 1.20 ad #endif /* !lint */
573