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