197952Sdougb/*-
297952Sdougb * Copyright (c) 1997 Peter Wemm <peter@freebsd.org>
397952Sdougb * All rights reserved.
497952Sdougb *
597952Sdougb * Redistribution and use in source and binary forms, with or without
697952Sdougb * modification, are permitted provided that the following conditions
797952Sdougb * are met:
897952Sdougb * 1. Redistributions of source code must retain the above copyright
997952Sdougb *    notice, this list of conditions and the following disclaimer.
1097952Sdougb * 2. Redistributions in binary form must reproduce the above copyright
1197952Sdougb *    notice, this list of conditions and the following disclaimer in the
1297952Sdougb *    documentation and/or other materials provided with the distribution.
1397952Sdougb * 3. The name of the author may not be used to endorse or promote products
1497952Sdougb *    derived from this software without specific prior written permission.
1597952Sdougb *
1697952Sdougb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1797952Sdougb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1897952Sdougb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1997952Sdougb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2097952Sdougb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2197952Sdougb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2297952Sdougb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2397952Sdougb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2497952Sdougb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2597952Sdougb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2697952Sdougb * SUCH DAMAGE.
2797952Sdougb *
2897952Sdougb * $FreeBSD: releng/10.3/sys/sys/poll.h 275986 2014-12-21 07:58:28Z dchagin $
2997952Sdougb */
3097952Sdougb
3197952Sdougb#ifndef _SYS_POLL_H_
3297952Sdougb#define	_SYS_POLL_H_
3397952Sdougb
3497952Sdougb#include <sys/cdefs.h>
3597952Sdougb
3697952Sdougb/*
37114924Sdougb * This file is intended to be compatible with the traditional poll.h.
38101773Sdougb */
3997952Sdougb
40120836Sdougbtypedef	unsigned int	nfds_t;
4197952Sdougb
42101773Sdougb/*
4397952Sdougb * This structure is passed as an array to poll(2).
44101773Sdougb */
45101773Sdougbstruct pollfd {
46120836Sdougb	int	fd;		/* which file descriptor to poll */
47120836Sdougb	short	events;		/* events we are interested in */
48120836Sdougb	short	revents;	/* events found on return */
49120836Sdougb};
50120836Sdougb
51120836Sdougb/*
52120836Sdougb * Requestable events.  If poll(2) finds any of these set, they are
53120836Sdougb * copied to revents on return.
54120836Sdougb * XXX Note that FreeBSD doesn't make much distinction between POLLPRI
55120836Sdougb * and POLLRDBAND since none of the file types have distinct priority
56101897Sdougb * bands - and only some have an urgent "mode".
5797952Sdougb * XXX Note POLLIN isn't really supported in true SVSV terms.  Under SYSV
58101773Sdougb * POLLIN includes all of normal, band and urgent data.  Most poll handlers
59101773Sdougb * on FreeBSD only treat it as "normal" data.
6097952Sdougb */
61101773Sdougb#define	POLLIN		0x0001		/* any readable data available */
62101897Sdougb#define	POLLPRI		0x0002		/* OOB/Urgent readable data */
63101773Sdougb#define	POLLOUT		0x0004		/* file descriptor is writeable */
6497952Sdougb#define	POLLRDNORM	0x0040		/* non-OOB/URG data available */
6597952Sdougb#define	POLLWRNORM	POLLOUT		/* no write type differentiation */
66101773Sdougb#define	POLLRDBAND	0x0080		/* OOB/Urgent readable data */
67101773Sdougb#define	POLLWRBAND	0x0100		/* OOB/Urgent data can be written */
68101773Sdougb
6997952Sdougb#if __BSD_VISIBLE
70120836Sdougb/* General FreeBSD extension (currently only supported for sockets): */
71120836Sdougb#define	POLLINIGNEOF	0x2000		/* like POLLIN, except ignore EOF */
72120836Sdougb#endif
73120836Sdougb
74120836Sdougb/*
75120836Sdougb * These events are set if they occur regardless of whether they were
76120836Sdougb * requested.
77120836Sdougb */
78120836Sdougb#define	POLLERR		0x0008		/* some poll error occurred */
79120836Sdougb#define	POLLHUP		0x0010		/* file descriptor was "hung up" */
80120836Sdougb#define	POLLNVAL	0x0020		/* requested events "invalid" */
81120836Sdougb
82120836Sdougb#if __BSD_VISIBLE
83120836Sdougb
84120836Sdougb#define	POLLSTANDARD	(POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\
85120836Sdougb			 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
86120836Sdougb
87120836Sdougb/*
88120836Sdougb * Request that poll() wait forever.
89120836Sdougb * XXX in SYSV, this is defined in stropts.h, which is not included
90120836Sdougb * by poll.h.
91120836Sdougb */
92120836Sdougb#define	INFTIM		(-1)
93120836Sdougb
94120836Sdougb#endif
95120836Sdougb
9697952Sdougb#ifndef _KERNEL
97120836Sdougb
98120836Sdougb#if __BSD_VISIBLE
99120836Sdougb#include <sys/_types.h>
100120836Sdougb
10197952Sdougb#include <sys/_sigset.h>
10297952Sdougb#include <sys/timespec.h>
10397952Sdougb
10497952Sdougb#ifndef _SIGSET_T_DECLARED
10597952Sdougb#define	_SIGSET_T_DECLARED
106120836Sdougbtypedef	__sigset_t	sigset_t;
107120836Sdougb#endif
10897952Sdougb
10997952Sdougb#endif
11097952Sdougb
111188481Smaxim__BEGIN_DECLS
11297952Sdougbint	poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
11397952Sdougb#if __BSD_VISIBLE
11497952Sdougbint	ppoll(struct pollfd _pfd[], nfds_t _nfds,
11597952Sdougb	    const struct timespec *__restrict _timeout,
11697952Sdougb	    const sigset_t *__restrict _newsigmask);
11797952Sdougb#endif
11897952Sdougb__END_DECLS
11997952Sdougb
12097952Sdougb#endif /* !_KERNEL */
12197952Sdougb
12297952Sdougb#endif /* !_SYS_POLL_H_ */
12397952Sdougb