xref: /titanic_51/usr/src/uts/common/sys/eventfd.h (revision 1767006bb066ef500b90b432fba79d63d0d09b36)
1*1767006bSBryan Cantrill /*
2*1767006bSBryan Cantrill  * This file and its contents are supplied under the terms of the
3*1767006bSBryan Cantrill  * Common Development and Distribution License ("CDDL"), version 1.0.
4*1767006bSBryan Cantrill  * You may only use this file in accordance with the terms of version
5*1767006bSBryan Cantrill  * 1.0 of the CDDL.
6*1767006bSBryan Cantrill  *
7*1767006bSBryan Cantrill  * A full copy of the text of the CDDL should have accompanied this
8*1767006bSBryan Cantrill  * source.  A copy of the CDDL is also available via the Internet at
9*1767006bSBryan Cantrill  * http://www.illumos.org/license/CDDL.
10*1767006bSBryan Cantrill  */
11*1767006bSBryan Cantrill 
12*1767006bSBryan Cantrill /*
13*1767006bSBryan Cantrill  * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
14*1767006bSBryan Cantrill  */
15*1767006bSBryan Cantrill 
16*1767006bSBryan Cantrill /*
17*1767006bSBryan Cantrill  * Header file to support for the eventfd facility.  Note that this facility
18*1767006bSBryan Cantrill  * is designed to be binary compatible with the Linux eventfd facility; values
19*1767006bSBryan Cantrill  * for constants here should therefore exactly match those found in Linux, and
20*1767006bSBryan Cantrill  * this facility shouldn't be extended independently of Linux.
21*1767006bSBryan Cantrill  */
22*1767006bSBryan Cantrill 
23*1767006bSBryan Cantrill #ifndef _SYS_EVENTFD_H
24*1767006bSBryan Cantrill #define	_SYS_EVENTFD_H
25*1767006bSBryan Cantrill 
26*1767006bSBryan Cantrill #include <sys/types.h>
27*1767006bSBryan Cantrill 
28*1767006bSBryan Cantrill #ifdef	__cplusplus
29*1767006bSBryan Cantrill extern "C" {
30*1767006bSBryan Cantrill #endif
31*1767006bSBryan Cantrill 
32*1767006bSBryan Cantrill typedef uint64_t eventfd_t;
33*1767006bSBryan Cantrill 
34*1767006bSBryan Cantrill /*
35*1767006bSBryan Cantrill  * To assure binary compatibility with Linux, these values are fixed at their
36*1767006bSBryan Cantrill  * Linux equivalents, not their native ones.
37*1767006bSBryan Cantrill  */
38*1767006bSBryan Cantrill #define	EFD_CLOEXEC		02000000		/* LX_O_CLOEXEC */
39*1767006bSBryan Cantrill #define	EFD_NONBLOCK		04000			/* LX_O_NONBLOCK */
40*1767006bSBryan Cantrill #define	EFD_SEMAPHORE		1
41*1767006bSBryan Cantrill 
42*1767006bSBryan Cantrill /*
43*1767006bSBryan Cantrill  * These ioctl values are specific to the native implementation; applications
44*1767006bSBryan Cantrill  * shouldn't be using them directly, and they should therefore be safe to
45*1767006bSBryan Cantrill  * change without breaking apps.
46*1767006bSBryan Cantrill  */
47*1767006bSBryan Cantrill #define	EVENTFDIOC		(('e' << 24) | ('f' << 16) | ('d' << 8))
48*1767006bSBryan Cantrill #define	EVENTFDIOC_SEMAPHORE	(EVENTFDIOC | 1)	/* toggle sem state */
49*1767006bSBryan Cantrill 
50*1767006bSBryan Cantrill #ifndef _KERNEL
51*1767006bSBryan Cantrill 
52*1767006bSBryan Cantrill extern int eventfd(unsigned int, int);
53*1767006bSBryan Cantrill extern int eventfd_read(int, eventfd_t *);
54*1767006bSBryan Cantrill extern int eventfd_write(int, eventfd_t);
55*1767006bSBryan Cantrill 
56*1767006bSBryan Cantrill #else
57*1767006bSBryan Cantrill 
58*1767006bSBryan Cantrill #define	EVENTFDMNRN_EVENTFD	0
59*1767006bSBryan Cantrill #define	EVENTFDMNRN_CLONE	1
60*1767006bSBryan Cantrill #define	EVENTFD_VALMAX		(ULLONG_MAX - 1ULL)
61*1767006bSBryan Cantrill 
62*1767006bSBryan Cantrill #endif /* _KERNEL */
63*1767006bSBryan Cantrill 
64*1767006bSBryan Cantrill #ifdef	__cplusplus
65*1767006bSBryan Cantrill }
66*1767006bSBryan Cantrill #endif
67*1767006bSBryan Cantrill 
68*1767006bSBryan Cantrill #endif	/* _SYS_EVENTFD_H */
69