129347Speter/*-
229347Speter * Copyright (c) 1997 Peter Wemm <peter@freebsd.org>
329347Speter * All rights reserved.
429347Speter *
529347Speter * Redistribution and use in source and binary forms, with or without
629347Speter * modification, are permitted provided that the following conditions
729347Speter * are met:
829347Speter * 1. Redistributions of source code must retain the above copyright
929347Speter *    notice, this list of conditions and the following disclaimer.
1029347Speter * 2. Redistributions in binary form must reproduce the above copyright
1129347Speter *    notice, this list of conditions and the following disclaimer in the
1229347Speter *    documentation and/or other materials provided with the distribution.
1329347Speter * 3. The name of the author may not be used to endorse or promote products
1429347Speter *    derived from this software without specific prior written permission.
1529347Speter *
1629347Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1729347Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1829347Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1929347Speter * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2029347Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2129347Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2229347Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2329347Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2429347Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2529347Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2629347Speter * SUCH DAMAGE.
2729347Speter *
2850477Speter * $FreeBSD$
2929347Speter */
3029347Speter
3129347Speter#ifndef _SYS_POLL_H_
3229347Speter#define	_SYS_POLL_H_
3329347Speter
3499593Smike#include <sys/cdefs.h>
3599593Smike
3629347Speter/*
3772093Sasmodai * This file is intended to be compatible with the traditional poll.h.
3829347Speter */
3929347Speter
4099593Smiketypedef	unsigned int	nfds_t;
4199593Smike
4229347Speter/*
4333059Sbde * This structure is passed as an array to poll(2).
4429347Speter */
4529347Speterstruct pollfd {
4629347Speter	int	fd;		/* which file descriptor to poll */
4729347Speter	short	events;		/* events we are interested in */
4829347Speter	short	revents;	/* events found on return */
4929347Speter};
5029347Speter
5129347Speter/*
5229347Speter * Requestable events.  If poll(2) finds any of these set, they are
5329347Speter * copied to revents on return.
5429347Speter * XXX Note that FreeBSD doesn't make much distinction between POLLPRI
5529347Speter * and POLLRDBAND since none of the file types have distinct priority
5629347Speter * bands - and only some have an urgent "mode".
5729347Speter * XXX Note POLLIN isn't really supported in true SVSV terms.  Under SYSV
5829347Speter * POLLIN includes all of normal, band and urgent data.  Most poll handlers
5929347Speter * on FreeBSD only treat it as "normal" data.
6029347Speter */
6129347Speter#define	POLLIN		0x0001		/* any readable data available */
6229347Speter#define	POLLPRI		0x0002		/* OOB/Urgent readable data */
6329347Speter#define	POLLOUT		0x0004		/* file descriptor is writeable */
6429347Speter#define	POLLRDNORM	0x0040		/* non-OOB/URG data available */
6529347Speter#define	POLLWRNORM	POLLOUT		/* no write type differentiation */
6629347Speter#define	POLLRDBAND	0x0080		/* OOB/Urgent readable data */
6729347Speter#define	POLLWRBAND	0x0100		/* OOB/Urgent data can be written */
6829347Speter
6999710Smike#if __BSD_VISIBLE
7094997Salfred/* General FreeBSD extension (currently only supported for sockets): */
7194997Salfred#define	POLLINIGNEOF	0x2000		/* like POLLIN, except ignore EOF */
7299593Smike#endif
7331727Swollman
7431727Swollman/*
7529347Speter * These events are set if they occur regardless of whether they were
7629347Speter * requested.
7729347Speter */
7829347Speter#define	POLLERR		0x0008		/* some poll error occurred */
7929347Speter#define	POLLHUP		0x0010		/* file descriptor was "hung up" */
8029347Speter#define	POLLNVAL	0x0020		/* requested events "invalid" */
8129347Speter
8299593Smike#if __BSD_VISIBLE
8399593Smike
8431727Swollman#define	POLLSTANDARD	(POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\
8531727Swollman			 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
8631727Swollman
8729373Speter/*
8833059Sbde * Request that poll() wait forever.
8933059Sbde * XXX in SYSV, this is defined in stropts.h, which is not included
9033059Sbde * by poll.h.
9129373Speter */
9233059Sbde#define	INFTIM		(-1)
9329373Speter
9499593Smike#endif
9599593Smike
9655205Speter#ifndef _KERNEL
9733059Sbde
9829347Speter__BEGIN_DECLS
9999593Smikeint	poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
10029347Speter__END_DECLS
10129347Speter
10255205Speter#endif /* !_KERNEL */
10333059Sbde
10429347Speter#endif /* !_SYS_POLL_H_ */
105