15cd1b91peter/*-
2d8596f6pfg * SPDX-License-Identifier: BSD-3-Clause
3d8596f6pfg *
45cd1b91peter * Copyright (c) 1997 Peter Wemm <peter@freebsd.org>
55cd1b91peter * All rights reserved.
65cd1b91peter *
75cd1b91peter * Redistribution and use in source and binary forms, with or without
85cd1b91peter * modification, are permitted provided that the following conditions
95cd1b91peter * are met:
105cd1b91peter * 1. Redistributions of source code must retain the above copyright
115cd1b91peter *    notice, this list of conditions and the following disclaimer.
125cd1b91peter * 2. Redistributions in binary form must reproduce the above copyright
135cd1b91peter *    notice, this list of conditions and the following disclaimer in the
145cd1b91peter *    documentation and/or other materials provided with the distribution.
155cd1b91peter * 3. The name of the author may not be used to endorse or promote products
165cd1b91peter *    derived from this software without specific prior written permission.
175cd1b91peter *
185cd1b91peter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
195cd1b91peter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
205cd1b91peter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
215cd1b91peter * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
225cd1b91peter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
235cd1b91peter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
245cd1b91peter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
255cd1b91peter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
265cd1b91peter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
275cd1b91peter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
285cd1b91peter * SUCH DAMAGE.
295cd1b91peter *
303b842d3peter * $FreeBSD$
315cd1b91peter */
325cd1b91peter
335cd1b91peter#ifndef _SYS_POLL_H_
345cd1b91peter#define	_SYS_POLL_H_
355cd1b91peter
362363974mike#include <sys/cdefs.h>
372363974mike
385cd1b91peter/*
397d76aceasmodai * This file is intended to be compatible with the traditional poll.h.
405cd1b91peter */
415cd1b91peter
422363974miketypedef	unsigned int	nfds_t;
432363974mike
445cd1b91peter/*
4508a4a83bde * This structure is passed as an array to poll(2).
465cd1b91peter */
475cd1b91peterstruct pollfd {
485cd1b91peter	int	fd;		/* which file descriptor to poll */
495cd1b91peter	short	events;		/* events we are interested in */
505cd1b91peter	short	revents;	/* events found on return */
515cd1b91peter};
525cd1b91peter
535cd1b91peter/*
545cd1b91peter * Requestable events.  If poll(2) finds any of these set, they are
555cd1b91peter * copied to revents on return.
565cd1b91peter * XXX Note that FreeBSD doesn't make much distinction between POLLPRI
575cd1b91peter * and POLLRDBAND since none of the file types have distinct priority
585cd1b91peter * bands - and only some have an urgent "mode".
595cd1b91peter * XXX Note POLLIN isn't really supported in true SVSV terms.  Under SYSV
605cd1b91peter * POLLIN includes all of normal, band and urgent data.  Most poll handlers
615cd1b91peter * on FreeBSD only treat it as "normal" data.
625cd1b91peter */
635cd1b91peter#define	POLLIN		0x0001		/* any readable data available */
645cd1b91peter#define	POLLPRI		0x0002		/* OOB/Urgent readable data */
655cd1b91peter#define	POLLOUT		0x0004		/* file descriptor is writeable */
665cd1b91peter#define	POLLRDNORM	0x0040		/* non-OOB/URG data available */
675cd1b91peter#define	POLLWRNORM	POLLOUT		/* no write type differentiation */
685cd1b91peter#define	POLLRDBAND	0x0080		/* OOB/Urgent readable data */
695cd1b91peter#define	POLLWRBAND	0x0100		/* OOB/Urgent data can be written */
705cd1b91peter
712363974mike#if __BSD_VISIBLE
72c96eb5emike/* General FreeBSD extension (currently only supported for sockets): */
731a9ffdbalfred#define	POLLINIGNEOF	0x2000		/* like POLLIN, except ignore EOF */
742363974mike#endif
751a06d88wollman
761a06d88wollman/*
775cd1b91peter * These events are set if they occur regardless of whether they were
785cd1b91peter * requested.
795cd1b91peter */
805cd1b91peter#define	POLLERR		0x0008		/* some poll error occurred */
815cd1b91peter#define	POLLHUP		0x0010		/* file descriptor was "hung up" */
825cd1b91peter#define	POLLNVAL	0x0020		/* requested events "invalid" */
835cd1b91peter
842363974mike#if __BSD_VISIBLE
852363974mike
861a06d88wollman#define	POLLSTANDARD	(POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\
871a06d88wollman			 POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
881a06d88wollman
89fb22d35peter/*
9008a4a83bde * Request that poll() wait forever.
9108a4a83bde * XXX in SYSV, this is defined in stropts.h, which is not included
9208a4a83bde * by poll.h.
93fb22d35peter */
9408a4a83bde#define	INFTIM		(-1)
95fb22d35peter
962363974mike#endif
9708a4a83bde
982363974mike#ifndef _KERNEL
995cd1b91peter
1001620120dchagin#if __BSD_VISIBLE
1011620120dchagin#include <sys/_types.h>
1021620120dchagin
1031620120dchagin#include <sys/_sigset.h>
1041620120dchagin#include <sys/timespec.h>
1051620120dchagin
1061620120dchagin#ifndef _SIGSET_T_DECLARED
1071620120dchagin#define	_SIGSET_T_DECLARED
1081620120dchagintypedef	__sigset_t	sigset_t;
1091620120dchagin#endif
1101620120dchagin
1111620120dchagin#endif
1121620120dchagin
1135cd1b91peter__BEGIN_DECLS
1142363974mikeint	poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
1151620120dchagin#if __BSD_VISIBLE
1161620120dchaginint	ppoll(struct pollfd _pfd[], nfds_t _nfds,
1171620120dchagin	    const struct timespec *__restrict _timeout,
1181620120dchagin	    const sigset_t *__restrict _newsigmask);
1191620120dchagin#endif
1205cd1b91peter__END_DECLS
1215cd1b91peter
12215b9bcbpeter#endif /* !_KERNEL */
12308a4a83bde
1245cd1b91peter#endif /* !_SYS_POLL_H_ */
125