148046Sjb/*
248046Sjb * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com>
348046Sjb * All rights reserved.
448046Sjb *
548046Sjb * Redistribution and use in source and binary forms, with or without
648046Sjb * modification, are permitted provided that the following conditions
748046Sjb * are met:
848046Sjb * 1. Redistributions of source code must retain the above copyright
948046Sjb *    notice, this list of conditions and the following disclaimer.
1048046Sjb * 2. Redistributions in binary form must reproduce the above copyright
1148046Sjb *    notice, this list of conditions and the following disclaimer in the
1248046Sjb *    documentation and/or other materials provided with the distribution.
1348046Sjb * 3. All advertising materials mentioning features or use of this software
1448046Sjb *    must display the following acknowledgement:
1548046Sjb *	This product includes software developed by Daniel Eischen.
1648046Sjb * 4. Neither the name of the author nor the names of any co-contributors
1748046Sjb *    may be used to endorse or promote products derived from this software
1848046Sjb *    without specific prior written permission.
1948046Sjb *
2048046Sjb * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND
2148046Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2248046Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2348046Sjb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2448046Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2548046Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2648046Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2748046Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2848046Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2948046Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3048046Sjb * SUCH DAMAGE.
3148046Sjb *
3250476Speter * $FreeBSD$
3348046Sjb */
34174112Sdeischen
35174112Sdeischen#include "namespace.h"
3648046Sjb#include <unistd.h>
3748046Sjb#include <errno.h>
3848046Sjb#include <string.h>
3948046Sjb#include <poll.h>
4048046Sjb#include <sys/types.h>
4148046Sjb#include <sys/time.h>
4248046Sjb#include <sys/fcntl.h>
4348046Sjb#include <pthread.h>
44174112Sdeischen#include "un-namespace.h"
45103388Smini#include "thr_private.h"
4648046Sjb
47174112Sdeischenint __poll(struct pollfd *fds, unsigned int nfds, int timeout);
48174112Sdeischen
4995948Sarchie__weak_reference(__poll, poll);
5048046Sjb
5195948Sarchieint
5295948Sarchie__poll(struct pollfd *fds, unsigned int nfds, int timeout)
5395948Sarchie{
54113658Sdeischen	struct pthread *curthread = _get_curthread();
5595948Sarchie	int ret;
5695948Sarchie
57123312Sdavidxu	_thr_cancel_enter(curthread);
58103419Smini	ret = __sys_poll(fds, nfds, timeout);
59123312Sdavidxu	_thr_cancel_leave(curthread, 1);
6095948Sarchie
6195948Sarchie	return ret;
6295948Sarchie}
63