1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * include/linux/eventpoll.h ( Efficient event polling implementation ) 4*4882a593Smuzhiyun * Copyright (C) 2001,...,2006 Davide Libenzi 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or modify 7*4882a593Smuzhiyun * it under the terms of the GNU General Public License as published by 8*4882a593Smuzhiyun * the Free Software Foundation; either version 2 of the License, or 9*4882a593Smuzhiyun * (at your option) any later version. 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * Davide Libenzi <davidel@xmailserver.org> 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #ifndef _UAPI_LINUX_EVENTPOLL_H 16*4882a593Smuzhiyun #define _UAPI_LINUX_EVENTPOLL_H 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* For O_CLOEXEC */ 19*4882a593Smuzhiyun #include <linux/fcntl.h> 20*4882a593Smuzhiyun #include <linux/types.h> 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /* Flags for epoll_create1. */ 23*4882a593Smuzhiyun #define EPOLL_CLOEXEC O_CLOEXEC 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* Valid opcodes to issue to sys_epoll_ctl() */ 26*4882a593Smuzhiyun #define EPOLL_CTL_ADD 1 27*4882a593Smuzhiyun #define EPOLL_CTL_DEL 2 28*4882a593Smuzhiyun #define EPOLL_CTL_MOD 3 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun /* Epoll event masks */ 31*4882a593Smuzhiyun #define EPOLLIN (__force __poll_t)0x00000001 32*4882a593Smuzhiyun #define EPOLLPRI (__force __poll_t)0x00000002 33*4882a593Smuzhiyun #define EPOLLOUT (__force __poll_t)0x00000004 34*4882a593Smuzhiyun #define EPOLLERR (__force __poll_t)0x00000008 35*4882a593Smuzhiyun #define EPOLLHUP (__force __poll_t)0x00000010 36*4882a593Smuzhiyun #define EPOLLNVAL (__force __poll_t)0x00000020 37*4882a593Smuzhiyun #define EPOLLRDNORM (__force __poll_t)0x00000040 38*4882a593Smuzhiyun #define EPOLLRDBAND (__force __poll_t)0x00000080 39*4882a593Smuzhiyun #define EPOLLWRNORM (__force __poll_t)0x00000100 40*4882a593Smuzhiyun #define EPOLLWRBAND (__force __poll_t)0x00000200 41*4882a593Smuzhiyun #define EPOLLMSG (__force __poll_t)0x00000400 42*4882a593Smuzhiyun #define EPOLLRDHUP (__force __poll_t)0x00002000 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun /* 45*4882a593Smuzhiyun * Internal flag - wakeup generated by io_uring, used to detect recursion back 46*4882a593Smuzhiyun * into the io_uring poll handler. 47*4882a593Smuzhiyun */ 48*4882a593Smuzhiyun #define EPOLL_URING_WAKE ((__force __poll_t)(1U << 27)) 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /* Set exclusive wakeup mode for the target file descriptor */ 51*4882a593Smuzhiyun #define EPOLLEXCLUSIVE ((__force __poll_t)(1U << 28)) 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* 54*4882a593Smuzhiyun * Request the handling of system wakeup events so as to prevent system suspends 55*4882a593Smuzhiyun * from happening while those events are being processed. 56*4882a593Smuzhiyun * 57*4882a593Smuzhiyun * Assuming neither EPOLLET nor EPOLLONESHOT is set, system suspends will not be 58*4882a593Smuzhiyun * re-allowed until epoll_wait is called again after consuming the wakeup 59*4882a593Smuzhiyun * event(s). 60*4882a593Smuzhiyun * 61*4882a593Smuzhiyun * Requires CAP_BLOCK_SUSPEND 62*4882a593Smuzhiyun */ 63*4882a593Smuzhiyun #define EPOLLWAKEUP ((__force __poll_t)(1U << 29)) 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun /* Set the One Shot behaviour for the target file descriptor */ 66*4882a593Smuzhiyun #define EPOLLONESHOT ((__force __poll_t)(1U << 30)) 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun /* Set the Edge Triggered behaviour for the target file descriptor */ 69*4882a593Smuzhiyun #define EPOLLET ((__force __poll_t)(1U << 31)) 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun /* 72*4882a593Smuzhiyun * On x86-64 make the 64bit structure have the same alignment as the 73*4882a593Smuzhiyun * 32bit structure. This makes 32bit emulation easier. 74*4882a593Smuzhiyun * 75*4882a593Smuzhiyun * UML/x86_64 needs the same packing as x86_64 76*4882a593Smuzhiyun */ 77*4882a593Smuzhiyun #ifdef __x86_64__ 78*4882a593Smuzhiyun #define EPOLL_PACKED __attribute__((packed)) 79*4882a593Smuzhiyun #else 80*4882a593Smuzhiyun #define EPOLL_PACKED 81*4882a593Smuzhiyun #endif 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun struct epoll_event { 84*4882a593Smuzhiyun __poll_t events; 85*4882a593Smuzhiyun __u64 data; 86*4882a593Smuzhiyun } EPOLL_PACKED; 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun #ifdef CONFIG_PM_SLEEP ep_take_care_of_epollwakeup(struct epoll_event * epev)89*4882a593Smuzhiyunstatic inline void ep_take_care_of_epollwakeup(struct epoll_event *epev) 90*4882a593Smuzhiyun { 91*4882a593Smuzhiyun if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND)) 92*4882a593Smuzhiyun epev->events &= ~EPOLLWAKEUP; 93*4882a593Smuzhiyun } 94*4882a593Smuzhiyun #else ep_take_care_of_epollwakeup(struct epoll_event * epev)95*4882a593Smuzhiyunstatic inline void ep_take_care_of_epollwakeup(struct epoll_event *epev) 96*4882a593Smuzhiyun { 97*4882a593Smuzhiyun epev->events &= ~EPOLLWAKEUP; 98*4882a593Smuzhiyun } 99*4882a593Smuzhiyun #endif 100*4882a593Smuzhiyun #endif /* _UAPI_LINUX_EVENTPOLL_H */ 101