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