Home | History | Annotate | Line # | Download | only in libpthread
pthread_cancelstub.c revision 1.34
      1  1.34     joerg /*	$NetBSD: pthread_cancelstub.c,v 1.34 2011/04/21 13:38:14 joerg 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.34     joerg /* Disable namespace mangling, Fortification is useless here anyway. */
     33  1.34     joerg #undef _FORTIFY_SOURCE
     34  1.34     joerg 
     35   1.5     lukem #include <sys/cdefs.h>
     36  1.34     joerg __RCSID("$NetBSD: pthread_cancelstub.c,v 1.34 2011/04/21 13:38:14 joerg Exp $");
     37  1.20        ad 
     38  1.20        ad #ifndef lint
     39  1.20        ad 
     40   1.6   thorpej 
     41   1.6   thorpej /*
     42  1.11    kleink  * This is necessary because the names are always weak (they are not
     43  1.11    kleink  * POSIX functions).
     44   1.6   thorpej  */
     45   1.6   thorpej #define	fsync_range	_fsync_range
     46  1.11    kleink #define	pollts		_pollts
     47   1.2   thorpej 
     48  1.10    kleink /*
     49  1.10    kleink  * XXX this is necessary to get the prototypes for the __sigsuspend14
     50  1.10    kleink  * XXX and __msync13 internal names, instead of the application-visible
     51  1.10    kleink  * XXX sigsuspend and msync names. It's kind of gross, but we're pretty
     52  1.10    kleink  * XXX intimate with libc already.
     53  1.10    kleink  */
     54  1.10    kleink #define __LIBC12_SOURCE__
     55  1.10    kleink 
     56   1.2   thorpej #include <sys/msg.h>
     57   1.2   thorpej #include <sys/types.h>
     58   1.2   thorpej #include <sys/uio.h>
     59   1.2   thorpej #include <sys/wait.h>
     60  1.15     rmind #include <aio.h>
     61   1.2   thorpej #include <fcntl.h>
     62  1.15     rmind #include <mqueue.h>
     63   1.2   thorpej #include <poll.h>
     64   1.2   thorpej #include <stdarg.h>
     65   1.2   thorpej #include <unistd.h>
     66   1.2   thorpej 
     67   1.2   thorpej #include <signal.h>
     68   1.2   thorpej #include <sys/mman.h>
     69  1.12    kleink #include <sys/select.h>
     70   1.3   nathanw #include <sys/socket.h>
     71  1.28  christos #include <sys/event.h>
     72   1.2   thorpej 
     73  1.13  christos #include <compat/sys/mman.h>
     74  1.25  christos #include <compat/sys/poll.h>
     75  1.25  christos #include <compat/sys/select.h>
     76  1.28  christos #include <compat/sys/event.h>
     77  1.25  christos #include <compat/sys/wait.h>
     78  1.25  christos #include <compat/include/mqueue.h>
     79  1.25  christos #include <compat/include/signal.h>
     80  1.13  christos 
     81   1.2   thorpej #include "pthread.h"
     82   1.2   thorpej #include "pthread_int.h"
     83   1.2   thorpej 
     84  1.10    kleink int	pthread__cancel_stub_binder;
     85  1.10    kleink 
     86   1.3   nathanw int	_sys_accept(int, struct sockaddr *, socklen_t *);
     87  1.25  christos int	_sys___aio_suspend50(const struct aiocb * const [], int,
     88  1.25  christos 	    const struct timespec *);
     89  1.25  christos int	__aio_suspend50(const struct aiocb * const [], int,
     90  1.15     rmind 	    const struct timespec *);
     91   1.2   thorpej int	_sys_close(int);
     92   1.3   nathanw int	_sys_connect(int, const struct sockaddr *, socklen_t);
     93   1.2   thorpej int	_sys_fcntl(int, int, ...);
     94   1.9    kleink int	_sys_fdatasync(int);
     95   1.2   thorpej int	_sys_fsync(int);
     96   1.6   thorpej int	_sys_fsync_range(int, int, off_t, off_t);
     97  1.28  christos int	_sys___kevent50(int, const struct kevent *, size_t, struct kevent *,
     98  1.28  christos 	    size_t, const struct timespec *);
     99  1.15     rmind int	_sys_mq_send(mqd_t, const char *, size_t, unsigned);
    100  1.15     rmind ssize_t	_sys_mq_receive(mqd_t, char *, size_t, unsigned *);
    101  1.25  christos int	_sys___mq_timedsend50(mqd_t, const char *, size_t, unsigned,
    102  1.15     rmind 	    const struct timespec *);
    103  1.25  christos ssize_t	_sys___mq_timedreceive50(mqd_t, char *, size_t, unsigned *,
    104  1.15     rmind 	    const struct timespec *);
    105   1.2   thorpej ssize_t	_sys_msgrcv(int, void *, size_t, long, int);
    106   1.2   thorpej int	_sys_msgsnd(int, const void *, size_t, int);
    107   1.2   thorpej int	_sys___msync13(void *, size_t, int);
    108  1.27     enami int	_sys___nanosleep50(const struct timespec *, struct timespec *);
    109  1.27     enami int	__nanosleep50(const struct timespec *, struct timespec *);
    110   1.2   thorpej int	_sys_open(const char *, int, ...);
    111   1.2   thorpej int	_sys_poll(struct pollfd *, nfds_t, int);
    112  1.25  christos int	_sys___pollts50(struct pollfd *, nfds_t, const struct timespec *,
    113  1.11    kleink 	    const sigset_t *);
    114   1.2   thorpej ssize_t	_sys_pread(int, void *, size_t, off_t);
    115  1.25  christos int	_sys___pselect50(int, fd_set *, fd_set *, fd_set *,
    116  1.11    kleink 	    const struct timespec *, const sigset_t *);
    117   1.2   thorpej ssize_t	_sys_pwrite(int, const void *, size_t, off_t);
    118   1.2   thorpej ssize_t	_sys_read(int, void *, size_t);
    119   1.2   thorpej ssize_t	_sys_readv(int, const struct iovec *, int);
    120  1.25  christos int	_sys___select50(int, fd_set *, fd_set *, fd_set *, struct timeval *);
    121  1.25  christos int	_sys___wait450(pid_t, int *, int, struct rusage *);
    122   1.2   thorpej ssize_t	_sys_write(int, const void *, size_t);
    123   1.2   thorpej ssize_t	_sys_writev(int, const struct iovec *, int);
    124  1.14        ad int	_sys___sigsuspend14(const sigset_t *);
    125  1.26  christos int	____sigtimedwait50(const sigset_t * __restrict, siginfo_t * __restrict,
    126  1.26  christos 	    struct timespec * __restrict);
    127  1.14        ad int	__sigsuspend14(const sigset_t *);
    128   1.2   thorpej 
    129   1.7   nathanw #define TESTCANCEL(id) 	do {						\
    130   1.7   nathanw 	if (__predict_false((id)->pt_cancel))				\
    131  1.17        ad 		pthread__cancelled();					\
    132   1.8        cl 	} while (/*CONSTCOND*/0)
    133   1.7   nathanw 
    134   1.2   thorpej 
    135   1.2   thorpej int
    136   1.3   nathanw accept(int s, struct sockaddr *addr, socklen_t *addrlen)
    137   1.3   nathanw {
    138   1.3   nathanw 	int retval;
    139   1.3   nathanw 	pthread_t self;
    140   1.3   nathanw 
    141   1.3   nathanw 	self = pthread__self();
    142   1.7   nathanw 	TESTCANCEL(self);
    143   1.3   nathanw 	retval = _sys_accept(s, addr, addrlen);
    144   1.7   nathanw 	TESTCANCEL(self);
    145   1.3   nathanw 
    146   1.3   nathanw 	return retval;
    147   1.3   nathanw }
    148   1.3   nathanw 
    149   1.3   nathanw int
    150  1.25  christos __aio_suspend50(const struct aiocb * const list[], int nent,
    151  1.22        ad     const struct timespec *timeout)
    152  1.22        ad {
    153  1.22        ad 	int retval;
    154  1.22        ad 	pthread_t self;
    155  1.22        ad 
    156  1.22        ad 	self = pthread__self();
    157  1.22        ad 	TESTCANCEL(self);
    158  1.25  christos 	retval = _sys___aio_suspend50(list, nent, timeout);
    159  1.22        ad 	TESTCANCEL(self);
    160  1.22        ad 
    161  1.22        ad 	return retval;
    162  1.22        ad }
    163  1.22        ad 
    164  1.22        ad int
    165  1.28  christos __kevent50(int fd, const struct kevent *ev, size_t nev, struct kevent *rev,
    166  1.28  christos     size_t nrev, const struct timespec *ts)
    167  1.28  christos {
    168  1.28  christos 	int retval;
    169  1.28  christos 	pthread_t self;
    170  1.28  christos 
    171  1.28  christos 	self = pthread__self();
    172  1.28  christos 	TESTCANCEL(self);
    173  1.28  christos 	retval = _sys___kevent50(fd, ev, nev, rev, nrev, ts);
    174  1.28  christos 	TESTCANCEL(self);
    175  1.28  christos 
    176  1.28  christos 	return retval;
    177  1.28  christos }
    178  1.28  christos 
    179  1.28  christos int
    180   1.2   thorpej close(int d)
    181   1.2   thorpej {
    182   1.2   thorpej 	int retval;
    183   1.2   thorpej 	pthread_t self;
    184   1.2   thorpej 
    185   1.2   thorpej 	self = pthread__self();
    186   1.7   nathanw 	TESTCANCEL(self);
    187   1.2   thorpej 	retval = _sys_close(d);
    188   1.7   nathanw 	TESTCANCEL(self);
    189   1.3   nathanw 
    190   1.3   nathanw 	return retval;
    191   1.3   nathanw }
    192   1.3   nathanw 
    193   1.3   nathanw int
    194   1.3   nathanw connect(int s, const struct sockaddr *addr, socklen_t namelen)
    195   1.3   nathanw {
    196   1.3   nathanw 	int retval;
    197   1.3   nathanw 	pthread_t self;
    198   1.3   nathanw 
    199   1.3   nathanw 	self = pthread__self();
    200   1.7   nathanw 	TESTCANCEL(self);
    201   1.3   nathanw 	retval = _sys_connect(s, addr, namelen);
    202   1.7   nathanw 	TESTCANCEL(self);
    203   1.2   thorpej 
    204   1.2   thorpej 	return retval;
    205   1.2   thorpej }
    206   1.2   thorpej 
    207   1.2   thorpej int
    208   1.2   thorpej fcntl(int fd, int cmd, ...)
    209   1.2   thorpej {
    210   1.2   thorpej 	int retval;
    211   1.2   thorpej 	pthread_t self;
    212   1.2   thorpej 	va_list ap;
    213   1.2   thorpej 
    214   1.2   thorpej 	self = pthread__self();
    215   1.7   nathanw 	TESTCANCEL(self);
    216   1.2   thorpej 	va_start(ap, cmd);
    217   1.2   thorpej 	retval = _sys_fcntl(fd, cmd, va_arg(ap, void *));
    218   1.2   thorpej 	va_end(ap);
    219   1.7   nathanw 	TESTCANCEL(self);
    220   1.2   thorpej 
    221   1.2   thorpej 	return retval;
    222   1.2   thorpej }
    223   1.2   thorpej 
    224   1.2   thorpej int
    225   1.9    kleink fdatasync(int d)
    226   1.9    kleink {
    227   1.9    kleink 	int retval;
    228   1.9    kleink 	pthread_t self;
    229   1.9    kleink 
    230   1.9    kleink 	self = pthread__self();
    231   1.9    kleink 	TESTCANCEL(self);
    232   1.9    kleink 	retval = _sys_fdatasync(d);
    233   1.9    kleink 	TESTCANCEL(self);
    234   1.9    kleink 
    235   1.9    kleink 	return retval;
    236   1.9    kleink }
    237   1.9    kleink 
    238   1.9    kleink int
    239   1.2   thorpej fsync(int d)
    240   1.2   thorpej {
    241   1.2   thorpej 	int retval;
    242   1.2   thorpej 	pthread_t self;
    243   1.2   thorpej 
    244   1.2   thorpej 	self = pthread__self();
    245   1.7   nathanw 	TESTCANCEL(self);
    246   1.2   thorpej 	retval = _sys_fsync(d);
    247   1.7   nathanw 	TESTCANCEL(self);
    248   1.2   thorpej 
    249   1.2   thorpej 	return retval;
    250   1.2   thorpej }
    251   1.2   thorpej 
    252   1.6   thorpej int
    253   1.6   thorpej fsync_range(int d, int f, off_t s, off_t e)
    254   1.6   thorpej {
    255   1.6   thorpej 	int retval;
    256   1.6   thorpej 	pthread_t self;
    257   1.6   thorpej 
    258   1.6   thorpej 	self = pthread__self();
    259   1.7   nathanw 	TESTCANCEL(self);
    260   1.6   thorpej 	retval = _sys_fsync_range(d, f, s, e);
    261   1.7   nathanw 	TESTCANCEL(self);
    262   1.6   thorpej 
    263   1.6   thorpej 	return retval;
    264   1.6   thorpej }
    265   1.6   thorpej 
    266  1.22        ad int
    267  1.22        ad mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
    268  1.22        ad {
    269  1.22        ad 	int retval;
    270  1.22        ad 	pthread_t self;
    271  1.22        ad 
    272  1.22        ad 	self = pthread__self();
    273  1.22        ad 	TESTCANCEL(self);
    274  1.22        ad 	retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
    275  1.22        ad 	TESTCANCEL(self);
    276  1.22        ad 
    277  1.22        ad 	return retval;
    278  1.22        ad }
    279  1.22        ad 
    280  1.22        ad ssize_t
    281  1.22        ad mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
    282  1.22        ad {
    283  1.22        ad 	ssize_t retval;
    284  1.22        ad 	pthread_t self;
    285  1.22        ad 
    286  1.22        ad 	self = pthread__self();
    287  1.22        ad 	TESTCANCEL(self);
    288  1.22        ad 	retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
    289  1.22        ad 	TESTCANCEL(self);
    290  1.22        ad 
    291  1.22        ad 	return retval;
    292  1.22        ad }
    293  1.22        ad 
    294  1.22        ad int
    295  1.25  christos __mq_timedsend50(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
    296  1.22        ad     unsigned msg_prio, const struct timespec *abst)
    297  1.22        ad {
    298  1.22        ad 	int retval;
    299  1.22        ad 	pthread_t self;
    300  1.22        ad 
    301  1.22        ad 	self = pthread__self();
    302  1.22        ad 	TESTCANCEL(self);
    303  1.25  christos 	retval = _sys___mq_timedsend50(mqdes, msg_ptr, msg_len, msg_prio, abst);
    304  1.22        ad 	TESTCANCEL(self);
    305  1.22        ad 
    306  1.22        ad 	return retval;
    307  1.22        ad }
    308  1.22        ad 
    309  1.22        ad ssize_t
    310  1.25  christos __mq_timedreceive50(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio,
    311  1.22        ad     const struct timespec *abst)
    312  1.22        ad {
    313  1.22        ad 	ssize_t retval;
    314  1.22        ad 	pthread_t self;
    315  1.22        ad 
    316  1.22        ad 	self = pthread__self();
    317  1.22        ad 	TESTCANCEL(self);
    318  1.25  christos 	retval = _sys___mq_timedreceive50(mqdes, msg_ptr, msg_len, msg_prio, abst);
    319  1.22        ad 	TESTCANCEL(self);
    320  1.22        ad 
    321  1.22        ad 	return retval;
    322  1.22        ad }
    323  1.22        ad 
    324   1.2   thorpej ssize_t
    325   1.2   thorpej msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
    326   1.2   thorpej {
    327   1.2   thorpej 	ssize_t retval;
    328   1.2   thorpej 	pthread_t self;
    329   1.2   thorpej 
    330   1.2   thorpej 	self = pthread__self();
    331   1.7   nathanw 	TESTCANCEL(self);
    332   1.2   thorpej 	retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg);
    333   1.7   nathanw 	TESTCANCEL(self);
    334   1.2   thorpej 
    335   1.2   thorpej 	return retval;
    336   1.2   thorpej }
    337   1.2   thorpej 
    338   1.2   thorpej int
    339   1.2   thorpej msgsnd(int msgid, const void *msgp, size_t msgsz, int msgflg)
    340   1.2   thorpej {
    341   1.2   thorpej 	int 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_msgsnd(msgid, msgp, msgsz, msgflg);
    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.2   thorpej int
    353   1.2   thorpej __msync13(void *addr, size_t len, int flags)
    354   1.2   thorpej {
    355   1.2   thorpej 	int retval;
    356   1.2   thorpej 	pthread_t self;
    357   1.2   thorpej 
    358   1.2   thorpej 	self = pthread__self();
    359   1.7   nathanw 	TESTCANCEL(self);
    360   1.2   thorpej 	retval = _sys___msync13(addr, len, flags);
    361   1.7   nathanw 	TESTCANCEL(self);
    362   1.2   thorpej 
    363   1.2   thorpej 	return retval;
    364   1.2   thorpej }
    365   1.2   thorpej 
    366   1.2   thorpej int
    367   1.2   thorpej open(const char *path, int flags, ...)
    368   1.2   thorpej {
    369   1.2   thorpej 	int retval;
    370   1.2   thorpej 	pthread_t self;
    371   1.2   thorpej 	va_list ap;
    372   1.2   thorpej 
    373   1.2   thorpej 	self = pthread__self();
    374   1.7   nathanw 	TESTCANCEL(self);
    375   1.2   thorpej 	va_start(ap, flags);
    376   1.2   thorpej 	retval = _sys_open(path, flags, va_arg(ap, mode_t));
    377   1.2   thorpej 	va_end(ap);
    378   1.7   nathanw 	TESTCANCEL(self);
    379   1.2   thorpej 
    380   1.2   thorpej 	return retval;
    381   1.2   thorpej }
    382   1.2   thorpej 
    383   1.2   thorpej int
    384  1.27     enami __nanosleep50(const struct timespec *rqtp, struct timespec *rmtp)
    385  1.27     enami {
    386  1.27     enami 	int retval;
    387  1.27     enami 	pthread_t self;
    388  1.27     enami 
    389  1.27     enami 	self = pthread__self();
    390  1.27     enami 	TESTCANCEL(self);
    391  1.27     enami 	/*
    392  1.27     enami 	 * For now, just nanosleep.  In the future, maybe pass a ucontext_t
    393  1.27     enami 	 * to _lwp_nanosleep() and allow it to recycle our kernel stack.
    394  1.27     enami 	 */
    395  1.27     enami 	retval = _sys___nanosleep50(rqtp, rmtp);
    396  1.27     enami 	TESTCANCEL(self);
    397  1.27     enami 
    398  1.27     enami 	return retval;
    399  1.27     enami }
    400  1.27     enami 
    401  1.27     enami int
    402   1.2   thorpej poll(struct pollfd *fds, nfds_t nfds, int timeout)
    403   1.2   thorpej {
    404   1.2   thorpej 	int retval;
    405   1.2   thorpej 	pthread_t self;
    406   1.2   thorpej 
    407   1.2   thorpej 	self = pthread__self();
    408   1.7   nathanw 	TESTCANCEL(self);
    409   1.2   thorpej 	retval = _sys_poll(fds, nfds, timeout);
    410   1.7   nathanw 	TESTCANCEL(self);
    411   1.2   thorpej 
    412   1.2   thorpej 	return retval;
    413   1.2   thorpej }
    414   1.2   thorpej 
    415  1.11    kleink int
    416  1.25  christos __pollts50(struct pollfd *fds, nfds_t nfds, const struct timespec *ts,
    417  1.11    kleink     const sigset_t *sigmask)
    418  1.11    kleink {
    419  1.11    kleink 	int retval;
    420  1.11    kleink 	pthread_t self;
    421  1.11    kleink 
    422  1.11    kleink 	self = pthread__self();
    423  1.11    kleink 	TESTCANCEL(self);
    424  1.25  christos 	retval = _sys___pollts50(fds, nfds, ts, sigmask);
    425  1.11    kleink 	TESTCANCEL(self);
    426  1.11    kleink 
    427  1.11    kleink 	return retval;
    428  1.11    kleink }
    429  1.11    kleink 
    430   1.2   thorpej ssize_t
    431   1.2   thorpej pread(int d, void *buf, size_t nbytes, off_t offset)
    432   1.2   thorpej {
    433   1.2   thorpej 	ssize_t retval;
    434   1.2   thorpej 	pthread_t self;
    435   1.2   thorpej 
    436   1.2   thorpej 	self = pthread__self();
    437   1.7   nathanw 	TESTCANCEL(self);
    438   1.2   thorpej 	retval = _sys_pread(d, buf, nbytes, offset);
    439   1.7   nathanw 	TESTCANCEL(self);
    440   1.2   thorpej 
    441   1.2   thorpej 	return retval;
    442   1.2   thorpej }
    443   1.2   thorpej 
    444  1.11    kleink int
    445  1.25  christos __pselect50(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
    446  1.11    kleink     const struct timespec *timeout, const sigset_t *sigmask)
    447  1.11    kleink {
    448  1.11    kleink 	int retval;
    449  1.11    kleink 	pthread_t self;
    450  1.11    kleink 
    451  1.11    kleink 	self = pthread__self();
    452  1.11    kleink 	TESTCANCEL(self);
    453  1.25  christos 	retval = _sys___pselect50(nfds, readfds, writefds, exceptfds, timeout,
    454  1.11    kleink 	    sigmask);
    455  1.11    kleink 	TESTCANCEL(self);
    456  1.11    kleink 
    457  1.11    kleink 	return retval;
    458  1.11    kleink }
    459  1.11    kleink 
    460   1.2   thorpej ssize_t
    461   1.2   thorpej pwrite(int d, const void *buf, size_t nbytes, off_t offset)
    462   1.2   thorpej {
    463   1.2   thorpej 	ssize_t retval;
    464   1.2   thorpej 	pthread_t self;
    465   1.2   thorpej 
    466   1.2   thorpej 	self = pthread__self();
    467   1.7   nathanw 	TESTCANCEL(self);
    468   1.2   thorpej 	retval = _sys_pwrite(d, buf, nbytes, offset);
    469   1.7   nathanw 	TESTCANCEL(self);
    470   1.2   thorpej 
    471   1.2   thorpej 	return retval;
    472   1.2   thorpej }
    473   1.2   thorpej 
    474   1.2   thorpej ssize_t
    475   1.2   thorpej readv(int d, const struct iovec *iov, int iovcnt)
    476   1.2   thorpej {
    477   1.2   thorpej 	ssize_t retval;
    478   1.2   thorpej 	pthread_t self;
    479   1.2   thorpej 
    480   1.2   thorpej 	self = pthread__self();
    481   1.7   nathanw 	TESTCANCEL(self);
    482   1.2   thorpej 	retval = _sys_readv(d, iov, iovcnt);
    483   1.7   nathanw 	TESTCANCEL(self);
    484   1.2   thorpej 
    485   1.2   thorpej 	return retval;
    486   1.2   thorpej }
    487   1.2   thorpej 
    488   1.2   thorpej int
    489  1.25  christos __select50(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
    490   1.2   thorpej     struct timeval *timeout)
    491   1.2   thorpej {
    492   1.2   thorpej 	int retval;
    493   1.2   thorpej 	pthread_t self;
    494   1.2   thorpej 
    495   1.2   thorpej 	self = pthread__self();
    496   1.7   nathanw 	TESTCANCEL(self);
    497  1.25  christos 	retval = _sys___select50(nfds, readfds, writefds, exceptfds, timeout);
    498   1.7   nathanw 	TESTCANCEL(self);
    499   1.2   thorpej 
    500   1.2   thorpej 	return retval;
    501   1.2   thorpej }
    502   1.2   thorpej 
    503   1.2   thorpej pid_t
    504  1.25  christos __wait450(pid_t wpid, int *status, int options, struct rusage *rusage)
    505   1.2   thorpej {
    506   1.2   thorpej 	pid_t retval;
    507   1.2   thorpej 	pthread_t self;
    508   1.2   thorpej 
    509   1.2   thorpej 	self = pthread__self();
    510   1.7   nathanw 	TESTCANCEL(self);
    511  1.25  christos 	retval = _sys___wait450(wpid, status, options, rusage);
    512   1.7   nathanw 	TESTCANCEL(self);
    513   1.2   thorpej 
    514   1.2   thorpej 	return retval;
    515   1.2   thorpej }
    516   1.2   thorpej 
    517   1.2   thorpej ssize_t
    518   1.2   thorpej write(int d, const void *buf, size_t nbytes)
    519   1.2   thorpej {
    520   1.2   thorpej 	ssize_t retval;
    521   1.2   thorpej 	pthread_t self;
    522   1.2   thorpej 
    523   1.2   thorpej 	self = pthread__self();
    524   1.7   nathanw 	TESTCANCEL(self);
    525   1.2   thorpej 	retval = _sys_write(d, buf, nbytes);
    526   1.7   nathanw 	TESTCANCEL(self);
    527   1.2   thorpej 
    528   1.2   thorpej 	return retval;
    529   1.2   thorpej }
    530   1.2   thorpej 
    531   1.2   thorpej ssize_t
    532   1.2   thorpej writev(int d, const struct iovec *iov, int iovcnt)
    533   1.2   thorpej {
    534   1.2   thorpej 	ssize_t retval;
    535   1.2   thorpej 	pthread_t self;
    536   1.2   thorpej 
    537   1.2   thorpej 	self = pthread__self();
    538   1.7   nathanw 	TESTCANCEL(self);
    539   1.2   thorpej 	retval = _sys_writev(d, iov, iovcnt);
    540   1.7   nathanw 	TESTCANCEL(self);
    541   1.2   thorpej 
    542   1.2   thorpej 	return retval;
    543   1.2   thorpej }
    544   1.2   thorpej 
    545  1.14        ad int
    546  1.14        ad __sigsuspend14(const sigset_t *sigmask)
    547  1.14        ad {
    548  1.14        ad 	pthread_t self;
    549  1.14        ad 	int retval;
    550  1.14        ad 
    551  1.14        ad 	self = pthread__self();
    552  1.14        ad 	TESTCANCEL(self);
    553  1.14        ad 	retval = _sys___sigsuspend14(sigmask);
    554  1.14        ad 	TESTCANCEL(self);
    555  1.14        ad 
    556  1.14        ad 	return retval;
    557  1.14        ad }
    558  1.14        ad 
    559  1.14        ad int
    560  1.25  christos __sigtimedwait50(const sigset_t * __restrict set, siginfo_t * __restrict info,
    561  1.25  christos     const struct timespec * __restrict timeout)
    562  1.14        ad {
    563  1.14        ad 	pthread_t self;
    564  1.14        ad 	int retval;
    565  1.26  christos 	struct timespec tout, *tp;
    566  1.26  christos 	if (timeout) {
    567  1.26  christos 		tout = *timeout;
    568  1.26  christos 		tp = &tout;
    569  1.26  christos 	} else
    570  1.26  christos 		tp = NULL;
    571  1.14        ad 
    572  1.14        ad 	self = pthread__self();
    573  1.14        ad 	TESTCANCEL(self);
    574  1.26  christos 	retval = ____sigtimedwait50(set, info, tp);
    575  1.14        ad 	TESTCANCEL(self);
    576  1.14        ad 
    577  1.14        ad 	return retval;
    578  1.14        ad }
    579   1.2   thorpej 
    580   1.2   thorpej __strong_alias(_close, close)
    581   1.2   thorpej __strong_alias(_fcntl, fcntl)
    582   1.9    kleink __strong_alias(_fdatasync, fdatasync)
    583   1.2   thorpej __strong_alias(_fsync, fsync)
    584   1.6   thorpej __weak_alias(fsync_range, _fsync_range)
    585  1.22        ad __strong_alias(_mq_send, mq_send)
    586  1.22        ad __strong_alias(_mq_receive, mq_receive)
    587   1.2   thorpej __strong_alias(_msgrcv, msgrcv)
    588   1.2   thorpej __strong_alias(_msgsnd, msgsnd)
    589   1.2   thorpej __strong_alias(___msync13, __msync13)
    590  1.27     enami __strong_alias(___nanosleep50, __nanosleep50)
    591   1.2   thorpej __strong_alias(_open, open)
    592   1.2   thorpej __strong_alias(_poll, poll)
    593   1.2   thorpej __strong_alias(_pread, pread)
    594   1.2   thorpej __strong_alias(_pwrite, pwrite)
    595   1.2   thorpej __strong_alias(_read, read)
    596   1.2   thorpej __strong_alias(_readv, readv)
    597   1.2   thorpej __strong_alias(_write, write)
    598   1.2   thorpej __strong_alias(_writev, writev)
    599  1.20        ad 
    600  1.20        ad #endif	/* !lint */
    601