17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright (c) 1998 by Sun Microsystems, Inc. 247c478bd9Sstevel@tonic-gate * All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27a5eb7107SBryan Cantrill /* 28*f3bb54f3SPatrick Mooney * Copyright 2015, Joyent, Inc. 29a5eb7107SBryan Cantrill */ 30a5eb7107SBryan Cantrill 317c478bd9Sstevel@tonic-gate #ifndef _SYS_DEVPOLL_H 327c478bd9Sstevel@tonic-gate #define _SYS_DEVPOLL_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/poll_impl.h> 357c478bd9Sstevel@tonic-gate #include <sys/types32.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* /dev/poll ioctl */ 437c478bd9Sstevel@tonic-gate #define DPIOC (0xD0 << 8) 44a5eb7107SBryan Cantrill #define DP_POLL (DPIOC | 1) /* poll on fds cached via /dev/poll */ 457c478bd9Sstevel@tonic-gate #define DP_ISPOLLED (DPIOC | 2) /* is this fd cached in /dev/poll */ 46a5eb7107SBryan Cantrill #define DP_PPOLL (DPIOC | 3) /* ppoll on fds cached via /dev/poll */ 47a5eb7107SBryan Cantrill #define DP_EPOLLCOMPAT (DPIOC | 4) /* turn on epoll compatibility */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define DEVPOLLSIZE 1000 /* /dev/poll table size increment */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * /dev/poll DP_POLL ioctl format 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate typedef struct dvpoll { 557c478bd9Sstevel@tonic-gate pollfd_t *dp_fds; /* pollfd array */ 567c478bd9Sstevel@tonic-gate nfds_t dp_nfds; /* num of pollfd's in dp_fds[] */ 577c478bd9Sstevel@tonic-gate int dp_timeout; /* time out in milisec */ 58a5eb7107SBryan Cantrill sigset_t *dp_setp; /* sigset, if any */ 597c478bd9Sstevel@tonic-gate } dvpoll_t; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate typedef struct dvpoll32 { 627c478bd9Sstevel@tonic-gate caddr32_t dp_fds; /* pollfd array */ 637c478bd9Sstevel@tonic-gate uint32_t dp_nfds; /* num of pollfd's in dp_fds[] */ 647c478bd9Sstevel@tonic-gate int32_t dp_timeout; /* time out in milisec */ 65a5eb7107SBryan Cantrill caddr32_t dp_setp; /* sigset, if any */ 667c478bd9Sstevel@tonic-gate } dvpoll32_t; 677c478bd9Sstevel@tonic-gate 68a5eb7107SBryan Cantrill typedef struct dvpoll_epollfd { 69a5eb7107SBryan Cantrill pollfd_t dpep_pollfd; /* must be first member */ 70a5eb7107SBryan Cantrill uint64_t dpep_data; /* data payload */ 71a5eb7107SBryan Cantrill } dvpoll_epollfd_t; 72a5eb7107SBryan Cantrill 737c478bd9Sstevel@tonic-gate #ifdef _KERNEL 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate typedef struct dp_entry { 767c478bd9Sstevel@tonic-gate kmutex_t dpe_lock; /* protect a devpoll entry */ 777c478bd9Sstevel@tonic-gate pollcache_t *dpe_pcache; /* a ptr to pollcache */ 787c478bd9Sstevel@tonic-gate int dpe_refcnt; /* no. of ioctl lwp on the dpe */ 797c478bd9Sstevel@tonic-gate int dpe_writerwait; /* no. of waits on write */ 807c478bd9Sstevel@tonic-gate int dpe_flag; /* see below */ 817c478bd9Sstevel@tonic-gate kcondvar_t dpe_cv; 827c478bd9Sstevel@tonic-gate } dp_entry_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate #define DP_WRITER_PRESENT 0x1 /* a write is in progress */ 85a5eb7107SBryan Cantrill #define DP_ISEPOLLCOMPAT 0x2 /* epoll compatibility mode */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #define DP_REFRELE(dpep) { \ 887c478bd9Sstevel@tonic-gate mutex_enter(&(dpep)->dpe_lock); \ 897c478bd9Sstevel@tonic-gate ASSERT((dpep)->dpe_refcnt > 0); \ 907c478bd9Sstevel@tonic-gate (dpep)->dpe_refcnt--; \ 917c478bd9Sstevel@tonic-gate mutex_exit(&(dpep)->dpe_lock); \ 927c478bd9Sstevel@tonic-gate } 937c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #ifdef __cplusplus 967c478bd9Sstevel@tonic-gate } 977c478bd9Sstevel@tonic-gate #endif 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #endif /* _SYS_DEVPOLL_H */ 100