4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1998 by Sun Microsystems, Inc.
24 * All rights reserved.
28 * Copyright 2015, Joyent, Inc.
31 #ifndef _SYS_DEVPOLL_H
32 #define _SYS_DEVPOLL_H
34 #include <sys/poll_impl.h>
35 #include <sys/types32.h>
43 #define DPIOC (0xD0 << 8)
44 #define DP_POLL (DPIOC | 1) /* poll on fds cached via /dev/poll */
45 #define DP_ISPOLLED (DPIOC | 2) /* is this fd cached in /dev/poll */
46 #define DP_PPOLL (DPIOC | 3) /* ppoll on fds cached via /dev/poll */
47 #define DP_EPOLLCOMPAT (DPIOC | 4) /* turn on epoll compatibility */
49 #define DEVPOLLSIZE 1000 /* /dev/poll table size increment */
52 * /dev/poll DP_POLL ioctl format
54 typedef struct dvpoll
{
55 pollfd_t
*dp_fds
; /* pollfd array */
56 nfds_t dp_nfds
; /* num of pollfd's in dp_fds[] */
57 int dp_timeout
; /* time out in milisec */
58 sigset_t
*dp_setp
; /* sigset, if any */
61 typedef struct dvpoll32
{
62 caddr32_t dp_fds
; /* pollfd array */
63 uint32_t dp_nfds
; /* num of pollfd's in dp_fds[] */
64 int32_t dp_timeout
; /* time out in milisec */
65 caddr32_t dp_setp
; /* sigset, if any */
68 typedef struct dvpoll_epollfd
{
69 pollfd_t dpep_pollfd
; /* must be first member */
70 uint64_t dpep_data
; /* data payload */
75 typedef struct dp_entry
{
76 kmutex_t dpe_lock
; /* protect a devpoll entry */
77 pollcache_t
*dpe_pcache
; /* a ptr to pollcache */
78 int dpe_refcnt
; /* no. of ioctl lwp on the dpe */
79 int dpe_writerwait
; /* no. of waits on write */
80 int dpe_flag
; /* see below */
84 #define DP_WRITER_PRESENT 0x1 /* a write is in progress */
85 #define DP_ISEPOLLCOMPAT 0x2 /* epoll compatibility mode */
87 #define DP_REFRELE(dpep) { \
88 mutex_enter(&(dpep)->dpe_lock); \
89 ASSERT((dpep)->dpe_refcnt > 0); \
90 (dpep)->dpe_refcnt--; \
91 mutex_exit(&(dpep)->dpe_lock); \
99 #endif /* _SYS_DEVPOLL_H */