1 /* 2 * CDDL HEADER START 3 * 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 7 * with the License. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1998 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 /* 28 * Copyright (c) 2014, Joyent, Inc. All rights reserved. 29 */ 30 31 #ifndef _SYS_DEVPOLL_H 32 #define _SYS_DEVPOLL_H 33 34 #include <sys/poll_impl.h> 35 #include <sys/types32.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 42 /* /dev/poll ioctl */ 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 */ 48 49 #define DEVPOLLSIZE 1000 /* /dev/poll table size increment */ 50 51 /* 52 * /dev/poll DP_POLL ioctl format 53 */ 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 */ 59 } dvpoll_t; 60 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 */ 66 } dvpoll32_t; 67 68 typedef struct dvpoll_epollfd { 69 pollfd_t dpep_pollfd; /* must be first member */ 70 uint64_t dpep_data; /* data payload */ 71 } dvpoll_epollfd_t; 72 73 #ifdef _KERNEL 74 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 */ 81 kcondvar_t dpe_cv; 82 } dp_entry_t; 83 84 #define DP_WRITER_PRESENT 0x1 /* a write is in progress */ 85 #define DP_ISEPOLLCOMPAT 0x2 /* epoll compatibility mode */ 86 87 #define DP_REFRELE(dpep) { \ 88 mutex_enter(&(dpep)->dpe_lock); \ 89 ASSERT((dpep)->dpe_refcnt > 0); \ 90 (dpep)->dpe_refcnt--; \ 91 if ((dpep)->dpe_refcnt == 0) { \ 92 cv_broadcast(&(dpep)->dpe_cv); \ 93 } \ 94 mutex_exit(&(dpep)->dpe_lock); \ 95 } 96 #endif /* _KERNEL */ 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif /* _SYS_DEVPOLL_H */ 103