xref: /linux/include/uapi/linux/eventpoll.h (revision 7e040726850a106587485c21bdacc0bfc8a0cbed)
1607ca46eSDavid Howells /*
2607ca46eSDavid Howells  *  include/linux/eventpoll.h ( Efficient event polling implementation )
3607ca46eSDavid Howells  *  Copyright (C) 2001,...,2006	 Davide Libenzi
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  *  This program is free software; you can redistribute it and/or modify
6607ca46eSDavid Howells  *  it under the terms of the GNU General Public License as published by
7607ca46eSDavid Howells  *  the Free Software Foundation; either version 2 of the License, or
8607ca46eSDavid Howells  *  (at your option) any later version.
9607ca46eSDavid Howells  *
10607ca46eSDavid Howells  *  Davide Libenzi <davidel@xmailserver.org>
11607ca46eSDavid Howells  *
12607ca46eSDavid Howells  */
13607ca46eSDavid Howells 
14607ca46eSDavid Howells #ifndef _UAPI_LINUX_EVENTPOLL_H
15607ca46eSDavid Howells #define _UAPI_LINUX_EVENTPOLL_H
16607ca46eSDavid Howells 
17607ca46eSDavid Howells /* For O_CLOEXEC */
18607ca46eSDavid Howells #include <linux/fcntl.h>
19607ca46eSDavid Howells #include <linux/types.h>
20607ca46eSDavid Howells 
21607ca46eSDavid Howells /* Flags for epoll_create1.  */
22607ca46eSDavid Howells #define EPOLL_CLOEXEC O_CLOEXEC
23607ca46eSDavid Howells 
24607ca46eSDavid Howells /* Valid opcodes to issue to sys_epoll_ctl() */
25607ca46eSDavid Howells #define EPOLL_CTL_ADD 1
26607ca46eSDavid Howells #define EPOLL_CTL_DEL 2
27607ca46eSDavid Howells #define EPOLL_CTL_MOD 3
28607ca46eSDavid Howells 
29*7e040726SGreg KH /* Epoll event masks */
30*7e040726SGreg KH #define EPOLLIN		0x00000001
31*7e040726SGreg KH #define EPOLLPRI	0x00000002
32*7e040726SGreg KH #define EPOLLOUT	0x00000004
33*7e040726SGreg KH #define EPOLLERR	0x00000008
34*7e040726SGreg KH #define EPOLLHUP	0x00000010
35*7e040726SGreg KH #define EPOLLRDNORM	0x00000040
36*7e040726SGreg KH #define EPOLLRDBAND	0x00000080
37*7e040726SGreg KH #define EPOLLWRNORM	0x00000100
38*7e040726SGreg KH #define EPOLLWRBAND	0x00000200
39*7e040726SGreg KH #define EPOLLMSG	0x00000400
40*7e040726SGreg KH #define EPOLLRDHUP	0x00002000
41*7e040726SGreg KH 
42df0108c5SJason Baron /* Set exclusive wakeup mode for the target file descriptor */
436f051e4aSGreg KH #define EPOLLEXCLUSIVE (1U << 28)
44df0108c5SJason Baron 
45607ca46eSDavid Howells /*
46607ca46eSDavid Howells  * Request the handling of system wakeup events so as to prevent system suspends
47607ca46eSDavid Howells  * from happening while those events are being processed.
48607ca46eSDavid Howells  *
49607ca46eSDavid Howells  * Assuming neither EPOLLET nor EPOLLONESHOT is set, system suspends will not be
50607ca46eSDavid Howells  * re-allowed until epoll_wait is called again after consuming the wakeup
51607ca46eSDavid Howells  * event(s).
52607ca46eSDavid Howells  *
53607ca46eSDavid Howells  * Requires CAP_BLOCK_SUSPEND
54607ca46eSDavid Howells  */
556f051e4aSGreg KH #define EPOLLWAKEUP (1U << 29)
56607ca46eSDavid Howells 
57607ca46eSDavid Howells /* Set the One Shot behaviour for the target file descriptor */
586f051e4aSGreg KH #define EPOLLONESHOT (1U << 30)
59607ca46eSDavid Howells 
60607ca46eSDavid Howells /* Set the Edge Triggered behaviour for the target file descriptor */
616f051e4aSGreg KH #define EPOLLET (1U << 31)
62607ca46eSDavid Howells 
63607ca46eSDavid Howells /*
64607ca46eSDavid Howells  * On x86-64 make the 64bit structure have the same alignment as the
65607ca46eSDavid Howells  * 32bit structure. This makes 32bit emulation easier.
66607ca46eSDavid Howells  *
67607ca46eSDavid Howells  * UML/x86_64 needs the same packing as x86_64
68607ca46eSDavid Howells  */
69607ca46eSDavid Howells #ifdef __x86_64__
70607ca46eSDavid Howells #define EPOLL_PACKED __attribute__((packed))
71607ca46eSDavid Howells #else
72607ca46eSDavid Howells #define EPOLL_PACKED
73607ca46eSDavid Howells #endif
74607ca46eSDavid Howells 
75607ca46eSDavid Howells struct epoll_event {
76607ca46eSDavid Howells 	__u32 events;
77607ca46eSDavid Howells 	__u64 data;
78607ca46eSDavid Howells } EPOLL_PACKED;
79607ca46eSDavid Howells 
8095f19f65SAmit Pundir #ifdef CONFIG_PM_SLEEP
8195f19f65SAmit Pundir static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
8295f19f65SAmit Pundir {
8395f19f65SAmit Pundir 	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
8495f19f65SAmit Pundir 		epev->events &= ~EPOLLWAKEUP;
8595f19f65SAmit Pundir }
8695f19f65SAmit Pundir #else
8795f19f65SAmit Pundir static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
8895f19f65SAmit Pundir {
8995f19f65SAmit Pundir 	epev->events &= ~EPOLLWAKEUP;
9095f19f65SAmit Pundir }
9195f19f65SAmit Pundir #endif
92607ca46eSDavid Howells #endif /* _UAPI_LINUX_EVENTPOLL_H */
93