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