Home | History | Annotate | Line # | Download | only in libpthread
pthread_cancelstub.c revision 1.36
      1  1.36       agc /*	$NetBSD: pthread_cancelstub.c,v 1.36 2012/04/04 06:29:16 agc Exp $	*/
      2   1.2   thorpej 
      3   1.2   thorpej /*-
      4  1.14        ad  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
      5   1.2   thorpej  * All rights reserved.
      6   1.2   thorpej  *
      7   1.2   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.14        ad  * by Nathan J. Williams and Andrew Doran.
      9   1.2   thorpej  *
     10   1.2   thorpej  * Redistribution and use in source and binary forms, with or without
     11   1.2   thorpej  * modification, are permitted provided that the following conditions
     12   1.2   thorpej  * are met:
     13   1.2   thorpej  * 1. Redistributions of source code must retain the above copyright
     14   1.2   thorpej  *    notice, this list of conditions and the following disclaimer.
     15   1.2   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.2   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17   1.2   thorpej  *    documentation and/or other materials provided with the distribution.
     18   1.2   thorpej  *
     19   1.2   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.2   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.2   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.2   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.2   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.2   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.2   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.2   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.2   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.2   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.2   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30   1.2   thorpej  */
     31   1.5     lukem 
     32  1.34     joerg /* Disable namespace mangling, Fortification is useless here anyway. */
     33  1.34     joerg #undef _FORTIFY_SOURCE
     34  1.34     joerg 
     35   1.5     lukem #include <sys/cdefs.h>
     36  1.36       agc __RCSID("$NetBSD: pthread_cancelstub.c,v 1.36 2012/04/04 06:29:16 agc Exp $");
     37  1.20        ad 
     38  1.20        ad #ifndef lint
     39  1.20        ad 
     40   1.6   thorpej 
     41   1.6   thorpej /*
     42  1.11    kleink  * This is necessary because the names are always weak (they are not
     43  1.11    kleink  * POSIX functions).
     44   1.6   thorpej  */
     45   1.6   thorpej #define	fsync_range	_fsync_range
     46  1.11    kleink #define	pollts		_pollts
     47   1.2   thorpej 
     48  1.10    kleink /*
     49  1.10    kleink  * XXX this is necessary to get the prototypes for the __sigsuspend14
     50  1.10    kleink  * XXX and __msync13 internal names, instead of the application-visible
     51  1.10    kleink  * XXX sigsuspend and msync names. It's kind of gross, but we're pretty
     52  1.10    kleink  * XXX intimate with libc already.
     53  1.10    kleink  */
     54  1.10    kleink #define __LIBC12_SOURCE__
     55  1.10    kleink 
     56   1.2   thorpej #include <sys/msg.h>
     57   1.2   thorpej #include <sys/types.h>
     58   1.2   thorpej #include <sys/uio.h>
     59   1.2   thorpej #include <sys/wait.h>
     60  1.15     rmind #include <aio.h>
     61  1.36       agc #include <errno.h>
     62   1.2   thorpej #include <fcntl.h>
     63  1.15     rmind #include <mqueue.h>
     64   1.2   thorpej #include <poll.h>
     65   1.2   thorpej #include <stdarg.h>
     66   1.2   thorpej #include <unistd.h>
     67   1.2   thorpej 
     68   1.2   thorpej #include <signal.h>
     69   1.2   thorpej #include <sys/mman.h>
     70  1.12    kleink #include <sys/select.h>
     71   1.3   nathanw #include <sys/socket.h>
     72  1.28  christos #include <sys/event.h>
     73   1.2   thorpej 
     74  1.13  christos #include <compat/sys/mman.h>
     75  1.25  christos #include <compat/sys/poll.h>
     76  1.25  christos #include <compat/sys/select.h>
     77  1.28  christos #include <compat/sys/event.h>
     78  1.25  christos #include <compat/sys/wait.h>
     79  1.25  christos #include <compat/include/mqueue.h>
     80  1.25  christos #include <compat/include/signal.h>
     81  1.13  christos 
     82   1.2   thorpej #include "pthread.h"
     83   1.2   thorpej #include "pthread_int.h"
     84   1.2   thorpej 
     85  1.10    kleink int	pthread__cancel_stub_binder;
     86  1.10    kleink 
     87   1.3   nathanw int	_sys_accept(int, struct sockaddr *, socklen_t *);
     88  1.25  christos int	_sys___aio_suspend50(const struct aiocb * const [], int,
     89  1.25  christos 	    const struct timespec *);
     90  1.25  christos int	__aio_suspend50(const struct aiocb * const [], int,
     91  1.15     rmind 	    const struct timespec *);
     92   1.2   thorpej int	_sys_close(int);
     93   1.3   nathanw int	_sys_connect(int, const struct sockaddr *, socklen_t);
     94   1.2   thorpej int	_sys_fcntl(int, int, ...);
     95   1.9    kleink int	_sys_fdatasync(int);
     96   1.2   thorpej int	_sys_fsync(int);
     97   1.6   thorpej int	_sys_fsync_range(int, int, off_t, off_t);
     98  1.28  christos int	_sys___kevent50(int, const struct kevent *, size_t, struct kevent *,
     99  1.28  christos 	    size_t, const struct timespec *);
    100  1.15     rmind int	_sys_mq_send(mqd_t, const char *, size_t, unsigned);
    101  1.15     rmind ssize_t	_sys_mq_receive(mqd_t, char *, size_t, unsigned *);
    102  1.25  christos int	_sys___mq_timedsend50(mqd_t, const char *, size_t, unsigned,
    103  1.15     rmind 	    const struct timespec *);
    104  1.25  christos ssize_t	_sys___mq_timedreceive50(mqd_t, char *, size_t, unsigned *,
    105  1.15     rmind 	    const struct timespec *);
    106   1.2   thorpej ssize_t	_sys_msgrcv(int, void *, size_t, long, int);
    107   1.2   thorpej int	_sys_msgsnd(int, const void *, size_t, int);
    108   1.2   thorpej int	_sys___msync13(void *, size_t, int);
    109  1.27     enami int	_sys___nanosleep50(const struct timespec *, struct timespec *);
    110  1.27     enami int	__nanosleep50(const struct timespec *, struct timespec *);
    111   1.2   thorpej int	_sys_open(const char *, int, ...);
    112   1.2   thorpej int	_sys_poll(struct pollfd *, nfds_t, int);
    113  1.25  christos int	_sys___pollts50(struct pollfd *, nfds_t, const struct timespec *,
    114  1.11    kleink 	    const sigset_t *);
    115   1.2   thorpej ssize_t	_sys_pread(int, void *, size_t, off_t);
    116  1.25  christos int	_sys___pselect50(int, fd_set *, fd_set *, fd_set *,
    117  1.11    kleink 	    const struct timespec *, const sigset_t *);
    118   1.2   thorpej ssize_t	_sys_pwrite(int, const void *, size_t, off_t);
    119   1.2   thorpej ssize_t	_sys_read(int, void *, size_t);
    120   1.2   thorpej ssize_t	_sys_readv(int, const struct iovec *, int);
    121  1.25  christos int	_sys___select50(int, fd_set *, fd_set *, fd_set *, struct timeval *);
    122  1.25  christos int	_sys___wait450(pid_t, int *, int, struct rusage *);
    123   1.2   thorpej ssize_t	_sys_write(int, const void *, size_t);
    124   1.2   thorpej ssize_t	_sys_writev(int, const struct iovec *, int);
    125  1.14        ad int	_sys___sigsuspend14(const sigset_t *);
    126  1.26  christos int	____sigtimedwait50(const sigset_t * __restrict, siginfo_t * __restrict,
    127  1.26  christos 	    struct timespec * __restrict);
    128  1.14        ad int	__sigsuspend14(const sigset_t *);
    129   1.2   thorpej 
    130   1.7   nathanw #define TESTCANCEL(id) 	do {						\
    131   1.7   nathanw 	if (__predict_false((id)->pt_cancel))				\
    132  1.17        ad 		pthread__cancelled();					\
    133   1.8        cl 	} while (/*CONSTCOND*/0)
    134   1.7   nathanw 
    135   1.2   thorpej 
    136   1.2   thorpej int
    137   1.3   nathanw accept(int s, struct sockaddr *addr, socklen_t *addrlen)
    138   1.3   nathanw {
    139   1.3   nathanw 	int retval;
    140   1.3   nathanw 	pthread_t self;
    141   1.3   nathanw 
    142   1.3   nathanw 	self = pthread__self();
    143   1.7   nathanw 	TESTCANCEL(self);
    144   1.3   nathanw 	retval = _sys_accept(s, addr, addrlen);
    145   1.7   nathanw 	TESTCANCEL(self);
    146   1.3   nathanw 
    147   1.3   nathanw 	return retval;
    148   1.3   nathanw }
    149   1.3   nathanw 
    150   1.3   nathanw int
    151  1.25  christos __aio_suspend50(const struct aiocb * const list[], int nent,
    152  1.22        ad     const struct timespec *timeout)
    153  1.22        ad {
    154  1.22        ad 	int retval;
    155  1.22        ad 	pthread_t self;
    156  1.22        ad 
    157  1.22        ad 	self = pthread__self();
    158  1.22        ad 	TESTCANCEL(self);
    159  1.25  christos 	retval = _sys___aio_suspend50(list, nent, timeout);
    160  1.22        ad 	TESTCANCEL(self);
    161  1.22        ad 
    162  1.22        ad 	return retval;
    163  1.22        ad }
    164  1.22        ad 
    165  1.22        ad int
    166  1.28  christos __kevent50(int fd, const struct kevent *ev, size_t nev, struct kevent *rev,
    167  1.28  christos     size_t nrev, const struct timespec *ts)
    168  1.28  christos {
    169  1.28  christos 	int retval;
    170  1.28  christos 	pthread_t self;
    171  1.28  christos 
    172  1.28  christos 	self = pthread__self();
    173  1.28  christos 	TESTCANCEL(self);
    174  1.28  christos 	retval = _sys___kevent50(fd, ev, nev, rev, nrev, ts);
    175  1.28  christos 	TESTCANCEL(self);
    176  1.28  christos 
    177  1.28  christos 	return retval;
    178  1.28  christos }
    179  1.28  christos 
    180  1.28  christos int
    181   1.2   thorpej close(int d)
    182   1.2   thorpej {
    183   1.2   thorpej 	int retval;
    184   1.2   thorpej 	pthread_t self;
    185   1.2   thorpej 
    186   1.2   thorpej 	self = pthread__self();
    187   1.7   nathanw 	TESTCANCEL(self);
    188   1.2   thorpej 	retval = _sys_close(d);
    189   1.7   nathanw 	TESTCANCEL(self);
    190   1.3   nathanw 
    191   1.3   nathanw 	return retval;
    192   1.3   nathanw }
    193   1.3   nathanw 
    194   1.3   nathanw int
    195   1.3   nathanw connect(int s, const struct sockaddr *addr, socklen_t namelen)
    196   1.3   nathanw {
    197   1.3   nathanw 	int retval;
    198   1.3   nathanw 	pthread_t self;
    199   1.3   nathanw 
    200   1.3   nathanw 	self = pthread__self();
    201   1.7   nathanw 	TESTCANCEL(self);
    202   1.3   nathanw 	retval = _sys_connect(s, addr, namelen);
    203   1.7   nathanw 	TESTCANCEL(self);
    204   1.2   thorpej 
    205   1.2   thorpej 	return retval;
    206   1.2   thorpej }
    207   1.2   thorpej 
    208   1.2   thorpej int
    209   1.2   thorpej fcntl(int fd, int cmd, ...)
    210   1.2   thorpej {
    211   1.2   thorpej 	int retval;
    212   1.2   thorpej 	pthread_t self;
    213   1.2   thorpej 	va_list ap;
    214   1.2   thorpej 
    215   1.2   thorpej 	self = pthread__self();
    216   1.7   nathanw 	TESTCANCEL(self);
    217   1.2   thorpej 	va_start(ap, cmd);
    218   1.2   thorpej 	retval = _sys_fcntl(fd, cmd, va_arg(ap, void *));
    219   1.2   thorpej 	va_end(ap);
    220   1.7   nathanw 	TESTCANCEL(self);
    221   1.2   thorpej 
    222   1.2   thorpej 	return retval;
    223   1.2   thorpej }
    224   1.2   thorpej 
    225   1.2   thorpej int
    226   1.9    kleink fdatasync(int d)
    227   1.9    kleink {
    228   1.9    kleink 	int retval;
    229   1.9    kleink 	pthread_t self;
    230   1.9    kleink 
    231   1.9    kleink 	self = pthread__self();
    232   1.9    kleink 	TESTCANCEL(self);
    233   1.9    kleink 	retval = _sys_fdatasync(d);
    234   1.9    kleink 	TESTCANCEL(self);
    235   1.9    kleink 
    236   1.9    kleink 	return retval;
    237   1.9    kleink }
    238   1.9    kleink 
    239   1.9    kleink int
    240   1.2   thorpej fsync(int d)
    241   1.2   thorpej {
    242   1.2   thorpej 	int retval;
    243   1.2   thorpej 	pthread_t self;
    244   1.2   thorpej 
    245   1.2   thorpej 	self = pthread__self();
    246   1.7   nathanw 	TESTCANCEL(self);
    247   1.2   thorpej 	retval = _sys_fsync(d);
    248   1.7   nathanw 	TESTCANCEL(self);
    249   1.2   thorpej 
    250   1.2   thorpej 	return retval;
    251   1.2   thorpej }
    252   1.2   thorpej 
    253   1.6   thorpej int
    254   1.6   thorpej fsync_range(int d, int f, off_t s, off_t e)
    255   1.6   thorpej {
    256   1.6   thorpej 	int retval;
    257   1.6   thorpej 	pthread_t self;
    258   1.6   thorpej 
    259   1.6   thorpej 	self = pthread__self();
    260   1.7   nathanw 	TESTCANCEL(self);
    261   1.6   thorpej 	retval = _sys_fsync_range(d, f, s, e);
    262   1.7   nathanw 	TESTCANCEL(self);
    263   1.6   thorpej 
    264   1.6   thorpej 	return retval;
    265   1.6   thorpej }
    266   1.6   thorpej 
    267  1.22        ad int
    268  1.22        ad mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
    269  1.22        ad {
    270  1.22        ad 	int retval;
    271  1.22        ad 	pthread_t self;
    272  1.22        ad 
    273  1.22        ad 	self = pthread__self();
    274  1.22        ad 	TESTCANCEL(self);
    275  1.22        ad 	retval = _sys_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
    276  1.22        ad 	TESTCANCEL(self);
    277  1.22        ad 
    278  1.22        ad 	return retval;
    279  1.22        ad }
    280  1.22        ad 
    281  1.22        ad ssize_t
    282  1.22        ad mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
    283  1.22        ad {
    284  1.22        ad 	ssize_t retval;
    285  1.22        ad 	pthread_t self;
    286  1.22        ad 
    287  1.22        ad 	self = pthread__self();
    288  1.22        ad 	TESTCANCEL(self);
    289  1.22        ad 	retval = _sys_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
    290  1.22        ad 	TESTCANCEL(self);
    291  1.22        ad 
    292  1.22        ad 	return retval;
    293  1.22        ad }
    294  1.22        ad 
    295  1.22        ad int
    296  1.25  christos __mq_timedsend50(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
    297  1.22        ad     unsigned msg_prio, const struct timespec *abst)
    298  1.22        ad {
    299  1.22        ad 	int retval;
    300  1.22        ad 	pthread_t self;
    301  1.22        ad 
    302  1.22        ad 	self = pthread__self();
    303  1.22        ad 	TESTCANCEL(self);
    304  1.25  christos 	retval = _sys___mq_timedsend50(mqdes, msg_ptr, msg_len, msg_prio, abst);
    305  1.22        ad 	TESTCANCEL(self);
    306  1.22        ad 
    307  1.22        ad 	return retval;
    308  1.22        ad }
    309  1.22        ad 
    310  1.22        ad ssize_t
    311  1.25  christos __mq_timedreceive50(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio,
    312  1.22        ad     const struct timespec *abst)
    313  1.22        ad {
    314  1.22        ad 	ssize_t retval;
    315  1.22        ad 	pthread_t self;
    316  1.22        ad 
    317  1.22        ad 	self = pthread__self();
    318  1.22        ad 	TESTCANCEL(self);
    319  1.25  christos 	retval = _sys___mq_timedreceive50(mqdes, msg_ptr, msg_len, msg_prio, abst);
    320  1.22        ad 	TESTCANCEL(self);
    321  1.22        ad 
    322  1.22        ad 	return retval;
    323  1.22        ad }
    324  1.22        ad 
    325   1.2   thorpej ssize_t
    326   1.2   thorpej msgrcv(int msgid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
    327   1.2   thorpej {
    328   1.2   thorpej 	ssize_t retval;
    329   1.2   thorpej 	pthread_t self;
    330   1.2   thorpej 
    331   1.2   thorpej 	self = pthread__self();
    332   1.7   nathanw 	TESTCANCEL(self);
    333   1.2   thorpej 	retval = _sys_msgrcv(msgid, msgp, msgsz, msgtyp, msgflg);
    334   1.7   nathanw 	TESTCANCEL(self);
    335   1.2   thorpej 
    336   1.2   thorpej 	return retval;
    337   1.2   thorpej }
    338   1.2   thorpej 
    339   1.2   thorpej int
    340   1.2   thorpej msgsnd(int msgid, const void *msgp, size_t msgsz, int msgflg)
    341   1.2   thorpej {
    342   1.2   thorpej 	int retval;
    343   1.2   thorpej 	pthread_t self;
    344   1.2   thorpej 
    345   1.2   thorpej 	self = pthread__self();
    346   1.7   nathanw 	TESTCANCEL(self);
    347   1.2   thorpej 	retval = _sys_msgsnd(msgid, msgp, msgsz, msgflg);
    348   1.7   nathanw 	TESTCANCEL(self);
    349   1.2   thorpej 
    350   1.2   thorpej 	return retval;
    351   1.2   thorpej }
    352   1.2   thorpej 
    353   1.2   thorpej int
    354   1.2   thorpej __msync13(void *addr, size_t len, int flags)
    355   1.2   thorpej {
    356   1.2   thorpej 	int retval;
    357   1.2   thorpej 	pthread_t self;
    358   1.2   thorpej 
    359   1.2   thorpej 	self = pthread__self();
    360   1.7   nathanw 	TESTCANCEL(self);
    361   1.2   thorpej 	retval = _sys___msync13(addr, len, flags);
    362   1.7   nathanw 	TESTCANCEL(self);
    363   1.2   thorpej 
    364   1.2   thorpej 	return retval;
    365   1.2   thorpej }
    366   1.2   thorpej 
    367   1.2   thorpej int
    368   1.2   thorpej open(const char *path, int flags, ...)
    369   1.2   thorpej {
    370   1.2   thorpej 	int retval;
    371   1.2   thorpej 	pthread_t self;
    372   1.2   thorpej 	va_list ap;
    373   1.2   thorpej 
    374   1.2   thorpej 	self = pthread__self();
    375   1.7   nathanw 	TESTCANCEL(self);
    376   1.2   thorpej 	va_start(ap, flags);
    377   1.2   thorpej 	retval = _sys_open(path, flags, va_arg(ap, mode_t));
    378   1.2   thorpej 	va_end(ap);
    379   1.7   nathanw 	TESTCANCEL(self);
    380   1.2   thorpej 
    381   1.2   thorpej 	return retval;
    382   1.2   thorpej }
    383   1.2   thorpej 
    384   1.2   thorpej int
    385  1.27     enami __nanosleep50(const struct timespec *rqtp, struct timespec *rmtp)
    386  1.27     enami {
    387  1.27     enami 	int retval;
    388  1.27     enami 	pthread_t self;
    389  1.27     enami 
    390  1.27     enami 	self = pthread__self();
    391  1.27     enami 	TESTCANCEL(self);
    392  1.27     enami 	/*
    393  1.27     enami 	 * For now, just nanosleep.  In the future, maybe pass a ucontext_t
    394  1.27     enami 	 * to _lwp_nanosleep() and allow it to recycle our kernel stack.
    395  1.27     enami 	 */
    396  1.27     enami 	retval = _sys___nanosleep50(rqtp, rmtp);
    397  1.27     enami 	TESTCANCEL(self);
    398  1.27     enami 
    399  1.27     enami 	return retval;
    400  1.27     enami }
    401  1.27     enami 
    402  1.27     enami int
    403   1.2   thorpej poll(struct pollfd *fds, nfds_t nfds, int timeout)
    404   1.2   thorpej {
    405   1.2   thorpej 	int retval;
    406   1.2   thorpej 	pthread_t self;
    407   1.2   thorpej 
    408   1.2   thorpej 	self = pthread__self();
    409   1.7   nathanw 	TESTCANCEL(self);
    410   1.2   thorpej 	retval = _sys_poll(fds, nfds, timeout);
    411   1.7   nathanw 	TESTCANCEL(self);
    412   1.2   thorpej 
    413   1.2   thorpej 	return retval;
    414   1.2   thorpej }
    415   1.2   thorpej 
    416  1.11    kleink int
    417  1.25  christos __pollts50(struct pollfd *fds, nfds_t nfds, const struct timespec *ts,
    418  1.11    kleink     const sigset_t *sigmask)
    419  1.11    kleink {
    420  1.11    kleink 	int retval;
    421  1.11    kleink 	pthread_t self;
    422  1.11    kleink 
    423  1.11    kleink 	self = pthread__self();
    424  1.11    kleink 	TESTCANCEL(self);
    425  1.25  christos 	retval = _sys___pollts50(fds, nfds, ts, sigmask);
    426  1.11    kleink 	TESTCANCEL(self);
    427  1.11    kleink 
    428  1.11    kleink 	return retval;
    429  1.11    kleink }
    430  1.11    kleink 
    431   1.2   thorpej ssize_t
    432   1.2   thorpej pread(int d, void *buf, size_t nbytes, off_t offset)
    433   1.2   thorpej {
    434   1.2   thorpej 	ssize_t retval;
    435   1.2   thorpej 	pthread_t self;
    436   1.2   thorpej 
    437   1.2   thorpej 	self = pthread__self();
    438   1.7   nathanw 	TESTCANCEL(self);
    439   1.2   thorpej 	retval = _sys_pread(d, buf, nbytes, offset);
    440   1.7   nathanw 	TESTCANCEL(self);
    441   1.2   thorpej 
    442   1.2   thorpej 	return retval;
    443   1.2   thorpej }
    444   1.2   thorpej 
    445  1.11    kleink int
    446  1.25  christos __pselect50(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
    447  1.11    kleink     const struct timespec *timeout, const sigset_t *sigmask)
    448  1.11    kleink {
    449  1.11    kleink 	int retval;
    450  1.11    kleink 	pthread_t self;
    451  1.11    kleink 
    452  1.11    kleink 	self = pthread__self();
    453  1.11    kleink 	TESTCANCEL(self);
    454  1.25  christos 	retval = _sys___pselect50(nfds, readfds, writefds, exceptfds, timeout,
    455  1.11    kleink 	    sigmask);
    456  1.11    kleink 	TESTCANCEL(self);
    457  1.11    kleink 
    458  1.11    kleink 	return retval;
    459  1.11    kleink }
    460  1.11    kleink 
    461   1.2   thorpej ssize_t
    462   1.2   thorpej pwrite(int d, const void *buf, size_t nbytes, off_t offset)
    463   1.2   thorpej {
    464   1.2   thorpej 	ssize_t retval;
    465   1.2   thorpej 	pthread_t self;
    466   1.2   thorpej 
    467   1.2   thorpej 	self = pthread__self();
    468   1.7   nathanw 	TESTCANCEL(self);
    469   1.2   thorpej 	retval = _sys_pwrite(d, buf, nbytes, offset);
    470   1.7   nathanw 	TESTCANCEL(self);
    471   1.2   thorpej 
    472   1.2   thorpej 	return retval;
    473   1.2   thorpej }
    474   1.2   thorpej 
    475   1.2   thorpej ssize_t
    476  1.35     joerg read(int d, void *buf, size_t nbytes)
    477  1.35     joerg {
    478  1.35     joerg 	ssize_t retval;
    479  1.35     joerg 	pthread_t self;
    480  1.35     joerg 
    481  1.35     joerg 	self = pthread__self();
    482  1.35     joerg 	TESTCANCEL(self);
    483  1.35     joerg 	retval = _sys_read(d, buf, nbytes);
    484  1.35     joerg 	TESTCANCEL(self);
    485  1.35     joerg 
    486  1.35     joerg 	return retval;
    487  1.35     joerg }
    488  1.35     joerg 
    489  1.35     joerg 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.36       agc 
    582  1.26  christos 	if (timeout) {
    583  1.26  christos 		tout = *timeout;
    584  1.26  christos 		tp = &tout;
    585  1.26  christos 	} else
    586  1.26  christos 		tp = NULL;
    587  1.14        ad 
    588  1.14        ad 	self = pthread__self();
    589  1.14        ad 	TESTCANCEL(self);
    590  1.26  christos 	retval = ____sigtimedwait50(set, info, tp);
    591  1.14        ad 	TESTCANCEL(self);
    592  1.14        ad 
    593  1.14        ad 	return retval;
    594  1.14        ad }
    595   1.2   thorpej 
    596  1.36       agc int
    597  1.36       agc sigwait(const sigset_t * __restrict set, int * __restrict sig)
    598  1.36       agc {
    599  1.36       agc 	pthread_t	self;
    600  1.36       agc 	int		saved_errno;
    601  1.36       agc 	int		new_errno;
    602  1.36       agc 	int		retval;
    603  1.36       agc 
    604  1.36       agc 	self = pthread__self();
    605  1.36       agc 	saved_errno = errno;
    606  1.36       agc 	TESTCANCEL(self);
    607  1.36       agc 	retval = ____sigtimedwait50(set, NULL, NULL);
    608  1.36       agc 	TESTCANCEL(self);
    609  1.36       agc 	new_errno = errno;
    610  1.36       agc 	errno = saved_errno;
    611  1.36       agc 	if (retval < 0) {
    612  1.36       agc 		return new_errno;
    613  1.36       agc 	}
    614  1.36       agc 	*sig = retval;
    615  1.36       agc 	return 0;
    616  1.36       agc }
    617  1.36       agc 
    618   1.2   thorpej __strong_alias(_close, close)
    619   1.2   thorpej __strong_alias(_fcntl, fcntl)
    620   1.9    kleink __strong_alias(_fdatasync, fdatasync)
    621   1.2   thorpej __strong_alias(_fsync, fsync)
    622   1.6   thorpej __weak_alias(fsync_range, _fsync_range)
    623  1.22        ad __strong_alias(_mq_send, mq_send)
    624  1.22        ad __strong_alias(_mq_receive, mq_receive)
    625   1.2   thorpej __strong_alias(_msgrcv, msgrcv)
    626   1.2   thorpej __strong_alias(_msgsnd, msgsnd)
    627   1.2   thorpej __strong_alias(___msync13, __msync13)
    628  1.27     enami __strong_alias(___nanosleep50, __nanosleep50)
    629   1.2   thorpej __strong_alias(_open, open)
    630   1.2   thorpej __strong_alias(_poll, poll)
    631   1.2   thorpej __strong_alias(_pread, pread)
    632   1.2   thorpej __strong_alias(_pwrite, pwrite)
    633   1.2   thorpej __strong_alias(_read, read)
    634   1.2   thorpej __strong_alias(_readv, readv)
    635  1.36       agc __strong_alias(_sigwait, sigwait)
    636   1.2   thorpej __strong_alias(_write, write)
    637   1.2   thorpej __strong_alias(_writev, writev)
    638  1.20        ad 
    639  1.20        ad #endif	/* !lint */
    640