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