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
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.
12 .\" Copyright (c) 2014, Joyent, Inc. All Rights Reserved.
19 .Nd create a file descriptor for event notification
24 .Fa "unsigned int initval"
32 instance that has an associated 64-bit unsigned counter.
33 It returns a file descriptor that can be operated upon via
36 and the facilities that notify of file descriptor activity (e.g.,
39 .Xr epoll_wait 3C Ns ).
40 To dispose of the instance,
42 should be called on the file descriptor.
46 argument specifies the initial value of the 64-bit counter associated with the
48 (Note that this limits the initial value to be a 32-bit quantity despite the
49 fact that the underlying counter is 64-bit.)
51 The \fIflags\fR argument specifies additional parameters for the
52 instance, and can have any of the following values:
56 Instance will be closed upon an
65 Instance will be set to be non-blocking.
70 instance that has been initialized with
74 in lieu of blocking if the count associated with the instance is zero.
78 Provide counting semaphore semantics whereby a
80 will atomically decrement rather than atomically clear the count when it
82 See below for details on
88 The following operations can be performed upon an
94 Atomically reads and modifies the value of the 64-bit counter associated
96 The precise semantics of
98 depend on the disposition of
101 respect to the instance: if
103 was set when the instance was created,
106 .Em atomically decrement
107 the counter if (and when) it is non-zero, copying the value 1 to the eight
108 byte buffer passed to the system call; if
114 the counter if (and when) it is non-zero, copying the former value of the
115 counter to the eight byte buffer passed to the
119 will block if the counter is
122 if the instance was created with
123 .Sy EFD_NONBLOCK Ns ).
124 If the buffer specified to
127 eight bytes in length,
133 Atomically adds the 64-bit value pointed to by the buffer to the 64-bit
134 counter associated with the instance.
135 If the resulting value would overflow, the
137 will block until the value would not overflow
140 EAGAIN if the instance was created with
141 .Sy EFD_NONBLOCK Ns ).
142 If the buffer specified to
144 is less than eight bytes in length,
148 .It Sy poll(2), port_get(3C), epoll_wait(3C)
150 Provide notification when the 64-bit counter associated
151 with the instance is ready for reading or writing, as specified.
152 If the 64-bit value associated with the instance is non-zero,
156 will be set; if the value 1 can be added the value
165 Upon successful completion, a file descriptor associated with the instance
171 is set to indicate the error.
175 function will fail if:
183 .Pf { Sy OPEN_MAX Ns }
184 file descriptors open in the calling process.