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