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