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