xref: /illumos-gate/usr/src/uts/common/sys/eventfd.h (revision 2c5ec7a875dcd76853e6618614e990f1e8cdd56d)
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) 2015 Joyent, Inc.  All rights reserved.
14  */
15 
16 /*
17  * Header file to support for the eventfd facility.  Note that this facility
18  * is designed to be binary compatible with the Linux eventfd facility; values
19  * for constants here should therefore exactly match those found in Linux, and
20  * this facility shouldn't be extended independently of Linux.
21  */
22 
23 #ifndef _SYS_EVENTFD_H
24 #define	_SYS_EVENTFD_H
25 
26 #include <sys/types.h>
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 typedef uint64_t eventfd_t;
33 
34 /*
35  * To assure binary compatibility with Linux, these values are fixed at their
36  * Linux equivalents, not their native ones.
37  */
38 #define	EFD_CLOEXEC		02000000		/* LX_O_CLOEXEC */
39 #define	EFD_NONBLOCK		04000			/* LX_O_NONBLOCK */
40 #define	EFD_SEMAPHORE		1
41 
42 /*
43  * These ioctl values are specific to the native implementation; applications
44  * shouldn't be using them directly, and they should therefore be safe to
45  * change without breaking apps.
46  */
47 #define	EVENTFDIOC		(('e' << 24) | ('f' << 16) | ('d' << 8))
48 #define	EVENTFDIOC_SEMAPHORE	(EVENTFDIOC | 1)	/* toggle sem state */
49 
50 #ifndef _KERNEL
51 
52 extern int eventfd(unsigned int, int);
53 extern int eventfd_read(int, eventfd_t *);
54 extern int eventfd_write(int, eventfd_t);
55 
56 #else
57 
58 #define	EVENTFDMNRN_EVENTFD	0
59 #define	EVENTFDMNRN_CLONE	1
60 #define	EVENTFD_VALMAX		(ULLONG_MAX - 1ULL)
61 
62 #endif /* _KERNEL */
63 
64 #ifdef	__cplusplus
65 }
66 #endif
67 
68 #endif	/* _SYS_EVENTFD_H */
69