1*a5eb7107SBryan Cantrill /* 2*a5eb7107SBryan Cantrill * This file and its contents are supplied under the terms of the 3*a5eb7107SBryan Cantrill * Common Development and Distribution License ("CDDL"), version 1.0. 4*a5eb7107SBryan Cantrill * You may only use this file in accordance with the terms of version 5*a5eb7107SBryan Cantrill * 1.0 of the CDDL. 6*a5eb7107SBryan Cantrill * 7*a5eb7107SBryan Cantrill * A full copy of the text of the CDDL should have accompanied this 8*a5eb7107SBryan Cantrill * source. A copy of the CDDL is also available via the Internet at 9*a5eb7107SBryan Cantrill * http://www.illumos.org/license/CDDL. 10*a5eb7107SBryan Cantrill */ 11*a5eb7107SBryan Cantrill 12*a5eb7107SBryan Cantrill /* 13*a5eb7107SBryan Cantrill * Copyright (c) 2014, Joyent, Inc. All rights reserved. 14*a5eb7107SBryan Cantrill */ 15*a5eb7107SBryan Cantrill 16*a5eb7107SBryan Cantrill #ifndef _SYS_EPOLL_H 17*a5eb7107SBryan Cantrill #define _SYS_EPOLL_H 18*a5eb7107SBryan Cantrill 19*a5eb7107SBryan Cantrill #include <sys/types.h> 20*a5eb7107SBryan Cantrill #include <sys/poll.h> 21*a5eb7107SBryan Cantrill 22*a5eb7107SBryan Cantrill #ifdef __cplusplus 23*a5eb7107SBryan Cantrill extern "C" { 24*a5eb7107SBryan Cantrill #endif 25*a5eb7107SBryan Cantrill 26*a5eb7107SBryan Cantrill typedef union epoll_data { 27*a5eb7107SBryan Cantrill void *ptr; 28*a5eb7107SBryan Cantrill int fd; 29*a5eb7107SBryan Cantrill uint32_t u32; 30*a5eb7107SBryan Cantrill uint64_t u64; 31*a5eb7107SBryan Cantrill } epoll_data_t; 32*a5eb7107SBryan Cantrill 33*a5eb7107SBryan Cantrill #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 34*a5eb7107SBryan Cantrill #pragma pack(4) 35*a5eb7107SBryan Cantrill #endif 36*a5eb7107SBryan Cantrill 37*a5eb7107SBryan Cantrill typedef struct epoll_event { 38*a5eb7107SBryan Cantrill uint32_t events; /* events */ 39*a5eb7107SBryan Cantrill epoll_data_t data; /* user-specified data */ 40*a5eb7107SBryan Cantrill } epoll_event_t; 41*a5eb7107SBryan Cantrill 42*a5eb7107SBryan Cantrill #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 43*a5eb7107SBryan Cantrill #pragma pack() 44*a5eb7107SBryan Cantrill #endif 45*a5eb7107SBryan Cantrill 46*a5eb7107SBryan Cantrill /* 47*a5eb7107SBryan Cantrill * Define the EPOLL* constants in terms of their poll(2)/poll(7) equivalents. 48*a5eb7107SBryan Cantrill * Note that the values match the equivalents in Linux to allow for any binary 49*a5eb7107SBryan Cantrill * compatibility layers to not need to translate them. 50*a5eb7107SBryan Cantrill */ 51*a5eb7107SBryan Cantrill #define EPOLLIN 0x0001 52*a5eb7107SBryan Cantrill #define EPOLLPRI 0x0002 53*a5eb7107SBryan Cantrill #define EPOLLOUT 0x0004 54*a5eb7107SBryan Cantrill #define EPOLLRDNORM 0x0040 55*a5eb7107SBryan Cantrill #define EPOLLRDBAND 0x0080 56*a5eb7107SBryan Cantrill #define EPOLLWRNORM 0x0100 57*a5eb7107SBryan Cantrill #define EPOLLWRBAND 0x0200 58*a5eb7107SBryan Cantrill #define EPOLLMSG 0x0400 /* not used */ 59*a5eb7107SBryan Cantrill #define EPOLLERR 0x0008 60*a5eb7107SBryan Cantrill #define EPOLLHUP 0x0010 61*a5eb7107SBryan Cantrill #define EPOLLRDHUP 0x2000 62*a5eb7107SBryan Cantrill 63*a5eb7107SBryan Cantrill #define EPOLLWAKEUP (1UL << 29) /* no meaning; silently ignored */ 64*a5eb7107SBryan Cantrill #define EPOLLONESHOT (1UL << 30) /* translated to POLLONESHOT */ 65*a5eb7107SBryan Cantrill #define EPOLLET (1UL << 31) /* translated to POLLET */ 66*a5eb7107SBryan Cantrill 67*a5eb7107SBryan Cantrill #define EPOLL_CTL_ADD 1 68*a5eb7107SBryan Cantrill #define EPOLL_CTL_DEL 2 69*a5eb7107SBryan Cantrill #define EPOLL_CTL_MOD 3 70*a5eb7107SBryan Cantrill 71*a5eb7107SBryan Cantrill #define EPOLL_CLOEXEC 02000000 72*a5eb7107SBryan Cantrill 73*a5eb7107SBryan Cantrill #if !defined(_KERNEL) 74*a5eb7107SBryan Cantrill 75*a5eb7107SBryan Cantrill extern int epoll_create(int size); 76*a5eb7107SBryan Cantrill extern int epoll_create1(int flags); 77*a5eb7107SBryan Cantrill extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); 78*a5eb7107SBryan Cantrill extern int epoll_wait(int epfd, struct epoll_event *events, 79*a5eb7107SBryan Cantrill int maxevents, int timeout); 80*a5eb7107SBryan Cantrill extern int epoll_pwait(int epfd, struct epoll_event *events, 81*a5eb7107SBryan Cantrill int maxevents, int timeout, const sigset_t *sigmask); 82*a5eb7107SBryan Cantrill 83*a5eb7107SBryan Cantrill #endif /* !_KERNEL */ 84*a5eb7107SBryan Cantrill 85*a5eb7107SBryan Cantrill #ifdef __cplusplus 86*a5eb7107SBryan Cantrill } 87*a5eb7107SBryan Cantrill #endif 88*a5eb7107SBryan Cantrill 89*a5eb7107SBryan Cantrill #endif /* _SYS_EPOLL_H */ 90