| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $ */ | | 1 | /* $NetBSD: pthread_cancelstub.c,v 1.22 2008/10/08 08:27:07 ad Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Nathan J. Williams and Andrew Doran. | | 8 | * by Nathan J. Williams and Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __RCSID("$NetBSD: pthread_cancelstub.c,v 1.21 2008/09/29 08:48:15 ad Exp $"); | | 33 | __RCSID("$NetBSD: pthread_cancelstub.c,v 1.22 2008/10/08 08:27:07 ad Exp $"); |
34 | | | 34 | |
35 | #ifndef lint | | 35 | #ifndef lint |
36 | | | 36 | |
37 | | | 37 | |
38 | /* | | 38 | /* |
39 | * This is necessary because the names are always weak (they are not | | 39 | * This is necessary because the names are always weak (they are not |
40 | * POSIX functions). | | 40 | * POSIX functions). |
41 | */ | | 41 | */ |
42 | #define fsync_range _fsync_range | | 42 | #define fsync_range _fsync_range |
43 | #define pollts _pollts | | 43 | #define pollts _pollts |
44 | | | 44 | |
45 | /* | | 45 | /* |
46 | * XXX this is necessary to get the prototypes for the __sigsuspend14 | | 46 | * XXX this is necessary to get the prototypes for the __sigsuspend14 |
| @@ -121,26 +121,41 @@ accept(int s, struct sockaddr *addr, soc | | | @@ -121,26 +121,41 @@ accept(int s, struct sockaddr *addr, soc |
121 | { | | 121 | { |
122 | int retval; | | 122 | int retval; |
123 | pthread_t self; | | 123 | pthread_t self; |
124 | | | 124 | |
125 | self = pthread__self(); | | 125 | self = pthread__self(); |
126 | TESTCANCEL(self); | | 126 | TESTCANCEL(self); |
127 | retval = _sys_accept(s, addr, addrlen); | | 127 | retval = _sys_accept(s, addr, addrlen); |
128 | TESTCANCEL(self); | | 128 | TESTCANCEL(self); |
129 | | | 129 | |
130 | return retval; | | 130 | return retval; |
131 | } | | 131 | } |
132 | | | 132 | |
133 | int | | 133 | int |
| | | 134 | aio_suspend(const struct aiocb * const list[], int nent, |
| | | 135 | const struct timespec *timeout) |
| | | 136 | { |
| | | 137 | int retval; |
| | | 138 | pthread_t self; |
| | | 139 | |
| | | 140 | self = pthread__self(); |
| | | 141 | TESTCANCEL(self); |
| | | 142 | retval = _sys_aio_suspend(list, nent, timeout); |
| | | 143 | TESTCANCEL(self); |
| | | 144 | |
| | | 145 | return retval; |
| | | 146 | } |
| | | 147 | |
| | | 148 | int |
134 | close(int d) | | 149 | close(int d) |
135 | { | | 150 | { |
136 | int retval; | | 151 | int retval; |
137 | pthread_t self; | | 152 | pthread_t self; |
138 | | | 153 | |
139 | self = pthread__self(); | | 154 | self = pthread__self(); |
140 | TESTCANCEL(self); | | 155 | TESTCANCEL(self); |
141 | retval = _sys_close(d); | | 156 | retval = _sys_close(d); |
142 | TESTCANCEL(self); | | 157 | TESTCANCEL(self); |
143 | | | 158 | |
144 | return retval; | | 159 | return retval; |
145 | } | | 160 | } |
146 | | | 161 | |
| @@ -207,26 +222,84 @@ int | | | @@ -207,26 +222,84 @@ int |
207 | fsync_range(int d, int f, off_t s, off_t e) | | 222 | fsync_range(int d, int f, off_t s, off_t e) |
208 | { | | 223 | { |
209 | int retval; | | 224 | int retval; |
210 | pthread_t self; | | 225 | pthread_t self; |
211 | | | 226 | |
212 | self = pthread__self(); | | 227 | self = pthread__self(); |
213 | TESTCANCEL(self); | | 228 | TESTCANCEL(self); |
214 | retval = _sys_fsync_range(d, f, s, e); | | 229 | retval = _sys_fsync_range(d, f, s, e); |
215 | TESTCANCEL(self); | | 230 | TESTCANCEL(self); |
216 | | | 231 | |
217 | return retval; | | 232 | return retval; |
218 | } | | 233 | } |
219 | | | 234 | |
| | | 235 | int |
| | | 236 | mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) |
| | | 237 | { |
| | | 238 | int retval; |
| | | 239 | pthread_t self; |
| | | 240 | |
| | | 241 | self = pthread__self(); |
| | | 242 | TESTCANCEL(self); |
| | | 243 | retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio); |
| | | 244 | TESTCANCEL(self); |
| | | 245 | |
| | | 246 | return retval; |
| | | 247 | } |
| | | 248 | |
| | | 249 | ssize_t |
| | | 250 | mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio) |
| | | 251 | { |
| | | 252 | ssize_t retval; |
| | | 253 | pthread_t self; |
| | | 254 | |
| | | 255 | self = pthread__self(); |
| | | 256 | TESTCANCEL(self); |
| | | 257 | retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio); |
| | | 258 | TESTCANCEL(self); |
| | | 259 | |
| | | 260 | return retval; |
| | | 261 | } |
| | | 262 | |
| | | 263 | int |
| | | 264 | mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, |
| | | 265 | unsigned msg_prio, const struct timespec *abst) |
| | | 266 | { |
| | | 267 | int retval; |
| | | 268 | pthread_t self; |
| | | 269 | |
| | | 270 | self = pthread__self(); |
| | | 271 | TESTCANCEL(self); |
| | | 272 | retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst); |
| | | 273 | TESTCANCEL(self); |
| | | 274 | |
| | | 275 | return retval; |
| | | 276 | } |
| | | 277 | |
| | | 278 | ssize_t |
| | | 279 | mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, |
| | | 280 | const struct timespec *abst) |
| | | 281 | { |
| | | 282 | ssize_t retval; |
| | | 283 | pthread_t self; |
| | | 284 | |
| | | 285 | self = pthread__self(); |
| | | 286 | TESTCANCEL(self); |
| | | 287 | retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst); |
| | | 288 | TESTCANCEL(self); |
| | | 289 | |
| | | 290 | return retval; |
| | | 291 | } |
| | | 292 | |
220 | ssize_t | | 293 | ssize_t |
221 | msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg) | | 294 | msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg) |
222 | { | | 295 | { |
223 | ssize_t retval; | | 296 | ssize_t retval; |
224 | pthread_t self; | | 297 | pthread_t self; |
225 | | | 298 | |
226 | self = pthread__self(); | | 299 | self = pthread__self(); |
227 | TESTCANCEL(self); | | 300 | TESTCANCEL(self); |
228 | retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg); | | 301 | retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg); |
229 | TESTCANCEL(self); | | 302 | TESTCANCEL(self); |
230 | | | 303 | |
231 | return retval; | | 304 | return retval; |
232 | } | | 305 | } |
| @@ -457,116 +530,40 @@ sigtimedwait(const sigset_t * __restrict | | | @@ -457,116 +530,40 @@ sigtimedwait(const sigset_t * __restrict |
457 | const struct timespec * __restrict timeout) | | 530 | const struct timespec * __restrict timeout) |
458 | { | | 531 | { |
459 | pthread_t self; | | 532 | pthread_t self; |
460 | int retval; | | 533 | int retval; |
461 | | | 534 | |
462 | self = pthread__self(); | | 535 | self = pthread__self(); |
463 | TESTCANCEL(self); | | 536 | TESTCANCEL(self); |
464 | retval = _sigtimedwait(set, info, timeout); | | 537 | retval = _sigtimedwait(set, info, timeout); |
465 | TESTCANCEL(self); | | 538 | TESTCANCEL(self); |
466 | | | 539 | |
467 | return retval; | | 540 | return retval; |
468 | } | | 541 | } |
469 | | | 542 | |
| | | 543 | __strong_alias(_aio_suspend, aio_suspend) |
470 | __strong_alias(_close, close) | | 544 | __strong_alias(_close, close) |
471 | __strong_alias(_fcntl, fcntl) | | 545 | __strong_alias(_fcntl, fcntl) |
472 | __strong_alias(_fdatasync, fdatasync) | | 546 | __strong_alias(_fdatasync, fdatasync) |
473 | __strong_alias(_fsync, fsync) | | 547 | __strong_alias(_fsync, fsync) |
474 | __weak_alias(fsync_range, _fsync_range) | | 548 | __weak_alias(fsync_range, _fsync_range) |
| | | 549 | __strong_alias(_mq_send, mq_send) |
| | | 550 | __strong_alias(_mq_receive, mq_receive) |
| | | 551 | __strong_alias(_mq_timedsend, mq_timedsend) |
| | | 552 | __strong_alias(_mq_timedreceive, mq_timedreceive) |
475 | __strong_alias(_msgrcv, msgrcv) | | 553 | __strong_alias(_msgrcv, msgrcv) |
476 | __strong_alias(_msgsnd, msgsnd) | | 554 | __strong_alias(_msgsnd, msgsnd) |
477 | __strong_alias(___msync13, __msync13) | | 555 | __strong_alias(___msync13, __msync13) |
478 | __strong_alias(_open, open) | | 556 | __strong_alias(_open, open) |
479 | __strong_alias(_poll, poll) | | 557 | __strong_alias(_poll, poll) |
480 | __weak_alias(pollts, _pollts) | | 558 | __weak_alias(pollts, _pollts) |
481 | __strong_alias(_pread, pread) | | 559 | __strong_alias(_pread, pread) |
482 | __strong_alias(_pselect, pselect) | | 560 | __strong_alias(_pselect, pselect) |
483 | __strong_alias(_pwrite, pwrite) | | 561 | __strong_alias(_pwrite, pwrite) |
484 | __strong_alias(_read, read) | | 562 | __strong_alias(_read, read) |
485 | __strong_alias(_readv, readv) | | 563 | __strong_alias(_readv, readv) |
486 | __strong_alias(_select, select) | | 564 | __strong_alias(_select, select) |
487 | __strong_alias(_wait4, wait4) | | 565 | __strong_alias(_wait4, wait4) |
488 | __strong_alias(_write, write) | | 566 | __strong_alias(_write, write) |
489 | __strong_alias(_writev, writev) | | 567 | __strong_alias(_writev, writev) |
490 | | | 568 | |
491 | #ifndef PTHREAD__COMPAT | | | |
492 | int | | | |
493 | aio_suspend(const struct aiocb * const list[], int nent, | | | |
494 | const struct timespec *timeout) | | | |
495 | { | | | |
496 | int retval; | | | |
497 | pthread_t self; | | | |
498 | | | | |
499 | self = pthread__self(); | | | |
500 | TESTCANCEL(self); | | | |
501 | retval = _sys_aio_suspend(list, nent, timeout); | | | |
502 | TESTCANCEL(self); | | | |
503 | | | | |
504 | return retval; | | | |
505 | } | | | |
506 | | | | |
507 | int | | | |
508 | mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) | | | |
509 | { | | | |
510 | int retval; | | | |
511 | pthread_t self; | | | |
512 | | | | |
513 | self = pthread__self(); | | | |
514 | TESTCANCEL(self); | | | |
515 | retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio); | | | |
516 | TESTCANCEL(self); | | | |
517 | | | | |
518 | return retval; | | | |
519 | } | | | |
520 | | | | |
521 | ssize_t | | | |
522 | mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio) | | | |
523 | { | | | |
524 | ssize_t retval; | | | |
525 | pthread_t self; | | | |
526 | | | | |
527 | self = pthread__self(); | | | |
528 | TESTCANCEL(self); | | | |
529 | retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio); | | | |
530 | TESTCANCEL(self); | | | |
531 | | | | |
532 | return retval; | | | |
533 | } | | | |
534 | | | | |
535 | int | | | |
536 | mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, | | | |
537 | unsigned msg_prio, const struct timespec *abst) | | | |
538 | { | | | |
539 | int retval; | | | |
540 | pthread_t self; | | | |
541 | | | | |
542 | self = pthread__self(); | | | |
543 | TESTCANCEL(self); | | | |
544 | retval = _sys_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abst); | | | |
545 | TESTCANCEL(self); | | | |
546 | | | | |
547 | return retval; | | | |
548 | } | | | |
549 | | | | |
550 | ssize_t | | | |
551 | mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, | | | |
552 | const struct timespec *abst) | | | |
553 | { | | | |
554 | ssize_t retval; | | | |
555 | pthread_t self; | | | |
556 | | | | |
557 | self = pthread__self(); | | | |
558 | TESTCANCEL(self); | | | |
559 | retval = _sys_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abst); | | | |
560 | TESTCANCEL(self); | | | |
561 | | | | |
562 | return retval; | | | |
563 | } | | | |
564 | | | | |
565 | __strong_alias(_aio_suspend, aio_suspend) | | | |
566 | __strong_alias(_mq_send, mq_send) | | | |
567 | __strong_alias(_mq_receive, mq_receive) | | | |
568 | __strong_alias(_mq_timedsend, mq_timedsend) | | | |
569 | __strong_alias(_mq_timedreceive, mq_timedreceive) | | | |
570 | #endif /* !PTHREAD__COMPAT */ | | | |
571 | | | | |
572 | #endif /* !lint */ | | 569 | #endif /* !lint */ |