]>
Commit | Line | Data |
---|---|---|
55e303ae | 1 | /* |
39037602 | 2 | * Copyright (c) 2003-2016 Apple Inc. All rights reserved. |
55e303ae | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
55e303ae | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
55e303ae A |
27 | */ |
28 | /*- | |
29 | * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> | |
30 | * All rights reserved. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
35 | * 1. Redistributions of source code must retain the above copyright | |
36 | * notice, this list of conditions and the following disclaimer. | |
37 | * 2. Redistributions in binary form must reproduce the above copyright | |
38 | * notice, this list of conditions and the following disclaimer in the | |
39 | * documentation and/or other materials provided with the distribution. | |
40 | * | |
41 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | |
52 | * | |
53 | * $FreeBSD: src/sys/sys/event.h,v 1.5.2.5 2001/12/14 19:21:22 jlemon Exp $ | |
54 | */ | |
55 | ||
56 | #ifndef _SYS_EVENT_H_ | |
57 | #define _SYS_EVENT_H_ | |
58 | ||
91447636 A |
59 | #include <machine/types.h> |
60 | #include <sys/cdefs.h> | |
61 | #include <stdint.h> | |
62 | ||
55e303ae A |
63 | #define EVFILT_READ (-1) |
64 | #define EVFILT_WRITE (-2) | |
65 | #define EVFILT_AIO (-3) /* attached to aio requests */ | |
66 | #define EVFILT_VNODE (-4) /* attached to vnodes */ | |
67 | #define EVFILT_PROC (-5) /* attached to struct proc */ | |
68 | #define EVFILT_SIGNAL (-6) /* attached to struct proc */ | |
69 | #define EVFILT_TIMER (-7) /* timers */ | |
b0d623f7 | 70 | #define EVFILT_MACHPORT (-8) /* Mach portsets */ |
55e303ae | 71 | #define EVFILT_FS (-9) /* Filesystem events */ |
b0d623f7 | 72 | #define EVFILT_USER (-10) /* User events */ |
6d2010ae A |
73 | /* (-11) unused */ |
74 | #define EVFILT_VM (-12) /* Virtual memory events */ | |
55e303ae | 75 | |
316670eb A |
76 | #ifdef PRIVATE |
77 | #define EVFILT_SOCK (-13) /* Socket events */ | |
39236c6e | 78 | #define EVFILT_MEMORYSTATUS (-14) /* Memorystatus events */ |
316670eb | 79 | #endif /* PRIVATE */ |
39037602 | 80 | #define EVFILT_EXCEPT (-15) /* Exception events */ |
316670eb | 81 | |
39037602 | 82 | #define EVFILT_SYSCOUNT 15 |
91447636 A |
83 | #define EVFILT_THREADMARKER EVFILT_SYSCOUNT /* Internal use only */ |
84 | ||
0c530ab8 | 85 | #pragma pack(4) |
55e303ae A |
86 | |
87 | struct kevent { | |
88 | uintptr_t ident; /* identifier for this event */ | |
b0d623f7 A |
89 | int16_t filter; /* filter for event */ |
90 | uint16_t flags; /* general flags */ | |
91 | uint32_t fflags; /* filter-specific flags */ | |
91447636 | 92 | intptr_t data; /* filter-specific data */ |
55e303ae | 93 | void *udata; /* opaque user data identifier */ |
91447636 A |
94 | }; |
95 | ||
96 | #ifdef KERNEL_PRIVATE | |
97 | ||
b0d623f7 | 98 | struct user64_kevent { |
91447636 | 99 | uint64_t ident; /* identifier for this event */ |
b0d623f7 A |
100 | int16_t filter; /* filter for event */ |
101 | uint16_t flags; /* general flags */ | |
102 | uint32_t fflags; /* filter-specific flags */ | |
91447636 A |
103 | int64_t data; /* filter-specific data */ |
104 | user_addr_t udata; /* opaque user data identifier */ | |
55e303ae A |
105 | }; |
106 | ||
b0d623f7 A |
107 | struct user32_kevent { |
108 | uint32_t ident; /* identifier for this event */ | |
109 | int16_t filter; /* filter for event */ | |
110 | uint16_t flags; /* general flags */ | |
111 | uint32_t fflags; /* filter-specific flags */ | |
112 | int32_t data; /* filter-specific data */ | |
39037602 | 113 | user32_addr_t udata; /* opaque user data identifier */ |
b0d623f7 A |
114 | }; |
115 | ||
3e170ce0 | 116 | struct kevent_internal_s { |
39037602 A |
117 | uint64_t ident; /* identifier for this event */ |
118 | int16_t filter; /* filter for event */ | |
119 | uint16_t flags; /* general flags */ | |
120 | int32_t qos; /* quality of service */ | |
121 | uint32_t fflags; /* filter-specific flags */ | |
122 | // uint32_t xflags; /* extra filter-specific flags */ | |
123 | int64_t data; /* filter-specific data */ | |
124 | uint64_t udata; /* opaque user data identifier */ | |
125 | uint64_t ext[4]; /* filter-specific extensions */ | |
3e170ce0 A |
126 | }; |
127 | ||
91447636 A |
128 | #endif |
129 | ||
0c530ab8 | 130 | #pragma pack() |
91447636 | 131 | |
b0d623f7 A |
132 | struct kevent64_s { |
133 | uint64_t ident; /* identifier for this event */ | |
134 | int16_t filter; /* filter for event */ | |
135 | uint16_t flags; /* general flags */ | |
136 | uint32_t fflags; /* filter-specific flags */ | |
137 | int64_t data; /* filter-specific data */ | |
138 | uint64_t udata; /* opaque user data identifier */ | |
139 | uint64_t ext[2]; /* filter-specific extensions */ | |
140 | }; | |
141 | ||
3e170ce0 A |
142 | #ifdef PRIVATE |
143 | struct kevent_qos_s { | |
144 | uint64_t ident; /* identifier for this event */ | |
145 | int16_t filter; /* filter for event */ | |
146 | uint16_t flags; /* general flags */ | |
147 | int32_t qos; /* quality of service */ | |
148 | uint64_t udata; /* opaque user data identifier */ | |
149 | uint32_t fflags; /* filter-specific flags */ | |
150 | uint32_t xflags; /* extra filter-specific flags */ | |
151 | int64_t data; /* filter-specific data */ | |
152 | uint64_t ext[4]; /* filter-specific extensions */ | |
153 | }; | |
154 | #endif /* PRIVATE */ | |
155 | ||
55e303ae A |
156 | #define EV_SET(kevp, a, b, c, d, e, f) do { \ |
157 | struct kevent *__kevp__ = (kevp); \ | |
158 | __kevp__->ident = (a); \ | |
159 | __kevp__->filter = (b); \ | |
160 | __kevp__->flags = (c); \ | |
161 | __kevp__->fflags = (d); \ | |
162 | __kevp__->data = (e); \ | |
163 | __kevp__->udata = (f); \ | |
164 | } while(0) | |
165 | ||
b0d623f7 A |
166 | #define EV_SET64(kevp, a, b, c, d, e, f, g, h) do { \ |
167 | struct kevent64_s *__kevp__ = (kevp); \ | |
168 | __kevp__->ident = (a); \ | |
169 | __kevp__->filter = (b); \ | |
170 | __kevp__->flags = (c); \ | |
171 | __kevp__->fflags = (d); \ | |
172 | __kevp__->data = (e); \ | |
173 | __kevp__->udata = (f); \ | |
174 | __kevp__->ext[0] = (g); \ | |
175 | __kevp__->ext[1] = (h); \ | |
176 | } while(0) | |
177 | ||
3e170ce0 A |
178 | |
179 | /* kevent system call flags */ | |
39037602 A |
180 | #define KEVENT_FLAG_NONE 0x000 /* no flag value */ |
181 | #define KEVENT_FLAG_IMMEDIATE 0x001 /* immediate timeout */ | |
182 | #define KEVENT_FLAG_ERROR_EVENTS 0x002 /* output events only include change errors */ | |
3e170ce0 A |
183 | |
184 | #ifdef PRIVATE | |
185 | ||
3e170ce0 A |
186 | /* |
187 | * Rather than provide an EV_SET_QOS macro for kevent_qos_t structure | |
188 | * initialization, we encourage use of named field initialization support | |
189 | * instead. | |
190 | */ | |
191 | ||
39037602 A |
192 | #define KEVENT_FLAG_STACK_EVENTS 0x004 /* output events treated as stack (grows down) */ |
193 | #define KEVENT_FLAG_STACK_DATA 0x008 /* output data allocated as stack (grows down) */ | |
194 | #define KEVENT_FLAG_WORKQ 0x020 /* interact with the default workq kq */ | |
195 | #define KEVENT_FLAG_WORKQ_MANAGER 0x200 /* current thread is the workq manager */ | |
3e170ce0 A |
196 | |
197 | #ifdef XNU_KERNEL_PRIVATE | |
198 | ||
39037602 A |
199 | #define KEVENT_FLAG_LEGACY32 0x040 /* event data in legacy 32-bit format */ |
200 | #define KEVENT_FLAG_LEGACY64 0x080 /* event data in legacy 64-bit format */ | |
201 | #define KEVENT_FLAG_KERNEL 0x100 /* caller is in-kernel */ | |
3e170ce0 | 202 | #define KEVENT_FLAG_USER (KEVENT_FLAG_IMMEDIATE | KEVENT_FLAG_ERROR_EVENTS | \ |
39037602 A |
203 | KEVENT_FLAG_STACK_EVENTS | KEVENT_FLAG_STACK_DATA | \ |
204 | KEVENT_FLAG_WORKQ) | |
205 | ||
206 | /* | |
207 | * Since some filter ops are not part of the standard sysfilt_ops, we | |
208 | * use kn_filtid starting from EVFILT_SYSCOUNT to identify these cases. | |
209 | * This is to let kn_fops() get the correct fops for all cases. | |
210 | */ | |
211 | #define EVFILTID_KQREAD (EVFILT_SYSCOUNT) | |
212 | #define EVFILTID_PIPE_R (EVFILT_SYSCOUNT + 1) | |
213 | #define EVFILTID_PIPE_W (EVFILT_SYSCOUNT + 2) | |
214 | #define EVFILTID_PTSD (EVFILT_SYSCOUNT + 3) | |
215 | #define EVFILTID_SOREAD (EVFILT_SYSCOUNT + 4) | |
216 | #define EVFILTID_SOWRITE (EVFILT_SYSCOUNT + 5) | |
217 | #define EVFILTID_SCK (EVFILT_SYSCOUNT + 6) | |
218 | #define EVFILTID_SOEXCEPT (EVFILT_SYSCOUNT + 7) | |
219 | #define EVFILTID_SPEC (EVFILT_SYSCOUNT + 8) | |
220 | #define EVFILTID_BPFREAD (EVFILT_SYSCOUNT + 9) | |
221 | #define EVFILTID_NECP_FD (EVFILT_SYSCOUNT + 10) | |
222 | #define EVFILTID_FSEVENT (EVFILT_SYSCOUNT + 13) | |
223 | #define EVFILTID_VN (EVFILT_SYSCOUNT + 14) | |
224 | ||
225 | #define EVFILTID_MAX (EVFILT_SYSCOUNT + 15) | |
226 | ||
3e170ce0 | 227 | #endif /* XNU_KERNEL_PRIVATE */ |
39037602 A |
228 | |
229 | #define EV_SET_QOS 0 | |
230 | ||
3e170ce0 A |
231 | #endif /* PRIVATE */ |
232 | ||
55e303ae | 233 | /* actions */ |
39037602 A |
234 | #define EV_ADD 0x0001 /* add event to kq (implies enable) */ |
235 | #define EV_DELETE 0x0002 /* delete event from kq */ | |
236 | #define EV_ENABLE 0x0004 /* enable event */ | |
237 | #define EV_DISABLE 0x0008 /* disable event (not reported) */ | |
55e303ae A |
238 | |
239 | /* flags */ | |
39037602 A |
240 | #define EV_ONESHOT 0x0010 /* only report one occurrence */ |
241 | #define EV_CLEAR 0x0020 /* clear event state after reporting */ | |
242 | #define EV_RECEIPT 0x0040 /* force immediate event output */ | |
243 | /* ... with or without EV_ERROR */ | |
244 | /* ... use KEVENT_FLAG_ERROR_EVENTS */ | |
245 | /* on syscalls supporting flags */ | |
246 | ||
247 | #define EV_DISPATCH 0x0080 /* disable event after reporting */ | |
248 | #define EV_UDATA_SPECIFIC 0x0100 /* unique kevent per udata value */ | |
3e170ce0 | 249 | |
39037602 A |
250 | #define EV_DISPATCH2 (EV_DISPATCH | EV_UDATA_SPECIFIC) |
251 | /* ... in combination with EV_DELETE */ | |
252 | /* will defer delete until udata-specific */ | |
253 | /* event enabled. EINPROGRESS will be */ | |
254 | /* returned to indicate the deferral */ | |
55e303ae | 255 | |
39037602 A |
256 | #define EV_VANISHED 0x0200 /* report that source has vanished */ |
257 | /* ... only valid with EV_DISPATCH2 */ | |
3e170ce0 | 258 | |
39037602 A |
259 | #define EV_SYSFLAGS 0xF000 /* reserved by system */ |
260 | #define EV_FLAG0 0x1000 /* filter-specific flag */ | |
261 | #define EV_FLAG1 0x2000 /* filter-specific flag */ | |
55e303ae A |
262 | |
263 | /* returned values */ | |
39037602 A |
264 | #define EV_EOF 0x8000 /* EOF detected */ |
265 | #define EV_ERROR 0x4000 /* error, data contains errno */ | |
55e303ae A |
266 | |
267 | /* | |
91447636 A |
268 | * Filter specific flags for EVFILT_READ |
269 | * | |
270 | * The default behavior for EVFILT_READ is to make the "read" determination | |
3e170ce0 A |
271 | * relative to the current file descriptor read pointer. |
272 | * | |
273 | * The EV_POLL flag indicates the determination should be made via poll(2) | |
274 | * semantics. These semantics dictate always returning true for regular files, | |
275 | * regardless of the amount of unread data in the file. | |
91447636 | 276 | * |
04b8595b A |
277 | * On input, EV_OOBAND specifies that filter should actively return in the |
278 | * presence of OOB on the descriptor. It implies that filter will return | |
279 | * if there is OOB data available to read OR when any other condition | |
280 | * for the read are met (for example number of bytes regular data becomes >= | |
281 | * low-watermark). | |
282 | * If EV_OOBAND is not set on input, it implies that the filter should not actively | |
283 | * return for out of band data on the descriptor. The filter will then only return | |
284 | * when some other condition for read is met (ex: when number of regular data bytes | |
285 | * >=low-watermark OR when socket can't receive more data (SS_CANTRCVMORE)). | |
91447636 | 286 | * |
04b8595b | 287 | * On output, EV_OOBAND indicates the presence of OOB data on the descriptor. |
91447636 | 288 | * If it was not specified as an input parameter, then the data count is the |
04b8595b A |
289 | * number of bytes before the current OOB marker, else data count is the number |
290 | * of bytes beyond OOB marker. | |
55e303ae | 291 | */ |
3e170ce0 | 292 | #define EV_POLL EV_FLAG0 |
91447636 | 293 | #define EV_OOBAND EV_FLAG1 |
55e303ae | 294 | |
b0d623f7 A |
295 | /* |
296 | * data/hint fflags for EVFILT_USER, shared with userspace | |
297 | */ | |
298 | ||
299 | /* | |
300 | * On input, NOTE_TRIGGER causes the event to be triggered for output. | |
301 | */ | |
302 | #define NOTE_TRIGGER 0x01000000 | |
b0d623f7 A |
303 | |
304 | /* | |
305 | * On input, the top two bits of fflags specifies how the lower twenty four | |
306 | * bits should be applied to the stored value of fflags. | |
307 | * | |
308 | * On output, the top two bits will always be set to NOTE_FFNOP and the | |
309 | * remaining twenty four bits will contain the stored fflags value. | |
310 | */ | |
311 | #define NOTE_FFNOP 0x00000000 /* ignore input fflags */ | |
312 | #define NOTE_FFAND 0x40000000 /* and fflags */ | |
313 | #define NOTE_FFOR 0x80000000 /* or fflags */ | |
314 | #define NOTE_FFCOPY 0xc0000000 /* copy fflags */ | |
315 | #define NOTE_FFCTRLMASK 0xc0000000 /* mask for operations */ | |
316 | #define NOTE_FFLAGSMASK 0x00ffffff | |
317 | ||
55e303ae | 318 | /* |
91447636 A |
319 | * data/hint fflags for EVFILT_{READ|WRITE}, shared with userspace |
320 | * | |
321 | * The default behavior for EVFILT_READ is to make the determination | |
322 | * realtive to the current file descriptor read pointer. | |
323 | */ | |
324 | #define NOTE_LOWAT 0x00000001 /* low water mark */ | |
3e170ce0 | 325 | |
39037602 A |
326 | /* data/hint flags for EVFILT_EXCEPT, shared with userspace */ |
327 | #define NOTE_OOB 0x00000002 /* OOB data */ | |
328 | ||
91447636 A |
329 | /* |
330 | * data/hint fflags for EVFILT_VNODE, shared with userspace | |
55e303ae | 331 | */ |
91447636 A |
332 | #define NOTE_DELETE 0x00000001 /* vnode was removed */ |
333 | #define NOTE_WRITE 0x00000002 /* data contents changed */ | |
334 | #define NOTE_EXTEND 0x00000004 /* size increased */ | |
335 | #define NOTE_ATTRIB 0x00000008 /* attributes changed */ | |
336 | #define NOTE_LINK 0x00000010 /* link count changed */ | |
337 | #define NOTE_RENAME 0x00000020 /* vnode was renamed */ | |
338 | #define NOTE_REVOKE 0x00000040 /* vnode access was revoked */ | |
b0d623f7 | 339 | #define NOTE_NONE 0x00000080 /* No specific vnode event: to test for EVFILT_READ activation*/ |
39037602 | 340 | #define NOTE_FUNLOCK 0x00000100 /* vnode was unlocked by flock(2) */ |
55e303ae A |
341 | |
342 | /* | |
91447636 | 343 | * data/hint fflags for EVFILT_PROC, shared with userspace |
2d21ac55 A |
344 | * |
345 | * Please note that EVFILT_PROC and EVFILT_SIGNAL share the same knote list | |
346 | * that hangs off the proc structure. They also both play games with the hint | |
347 | * passed to KNOTE(). If NOTE_SIGNAL is passed as a hint, then the lower bits | |
348 | * of the hint contain the signal. IF NOTE_FORK is passed, then the lower bits | |
39236c6e A |
349 | * contain the PID of the child (but the pid does not get passed through in |
350 | * the actual kevent). | |
55e303ae | 351 | */ |
39236c6e A |
352 | enum { |
353 | eNoteReapDeprecated __deprecated_enum_msg("This kqueue(2) EVFILT_PROC flag is deprecated") = 0x10000000 | |
354 | }; | |
355 | ||
356 | #define NOTE_EXIT 0x80000000 /* process exited */ | |
357 | #define NOTE_FORK 0x40000000 /* process forked */ | |
358 | #define NOTE_EXEC 0x20000000 /* process exec'd */ | |
359 | #define NOTE_REAP ((unsigned int)eNoteReapDeprecated /* 0x10000000 */) /* process reaped */ | |
360 | #define NOTE_SIGNAL 0x08000000 /* shared with EVFILT_SIGNAL */ | |
361 | #define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process only */ | |
362 | #define NOTE_EXIT_DETAIL 0x02000000 /* provide details on reasons for exit */ | |
363 | ||
39236c6e | 364 | #define NOTE_PDATAMASK 0x000fffff /* mask for signal & exit status */ |
2d21ac55 | 365 | #define NOTE_PCTRLMASK (~NOTE_PDATAMASK) |
55e303ae | 366 | |
99c3a104 A |
367 | /* |
368 | * If NOTE_EXITSTATUS is present, provide additional info about exiting process. | |
369 | */ | |
39236c6e A |
370 | enum { |
371 | eNoteExitReparentedDeprecated __deprecated_enum_msg("This kqueue(2) EVFILT_PROC flag is no longer sent") = 0x00080000 | |
372 | }; | |
373 | #define NOTE_EXIT_REPARENTED ((unsigned int)eNoteExitReparentedDeprecated) /* exited while reparented */ | |
374 | ||
375 | /* | |
376 | * If NOTE_EXIT_DETAIL is present, these bits indicate specific reasons for exiting. | |
377 | */ | |
378 | #define NOTE_EXIT_DETAIL_MASK 0x00070000 | |
379 | #define NOTE_EXIT_DECRYPTFAIL 0x00010000 | |
380 | #define NOTE_EXIT_MEMORY 0x00020000 | |
381 | #define NOTE_EXIT_CSERROR 0x00040000 | |
382 | ||
383 | #ifdef PRIVATE | |
384 | ||
385 | /* | |
386 | * If NOTE_EXIT_MEMORY is present, these bits indicate specific jetsam condition. | |
387 | */ | |
fe8ab488 | 388 | #define NOTE_EXIT_MEMORY_DETAIL_MASK 0xfe000000 |
39236c6e A |
389 | #define NOTE_EXIT_MEMORY_VMPAGESHORTAGE 0x80000000 /* jetsam condition: lowest jetsam priority proc killed due to vm page shortage */ |
390 | #define NOTE_EXIT_MEMORY_VMTHRASHING 0x40000000 /* jetsam condition: lowest jetsam priority proc killed due to vm thrashing */ | |
391 | #define NOTE_EXIT_MEMORY_HIWAT 0x20000000 /* jetsam condition: process reached its high water mark */ | |
392 | #define NOTE_EXIT_MEMORY_PID 0x10000000 /* jetsam condition: special pid kill requested */ | |
393 | #define NOTE_EXIT_MEMORY_IDLE 0x08000000 /* jetsam condition: idle process cleaned up */ | |
394 | #define NOTE_EXIT_MEMORY_VNODE 0X04000000 /* jetsam condition: virtual node kill */ | |
fe8ab488 | 395 | #define NOTE_EXIT_MEMORY_FCTHRASHING 0x02000000 /* jetsam condition: lowest jetsam priority proc killed due to filecache thrashing */ |
39236c6e A |
396 | |
397 | #endif | |
99c3a104 | 398 | |
6d2010ae A |
399 | /* |
400 | * data/hint fflags for EVFILT_VM, shared with userspace. | |
401 | */ | |
402 | #define NOTE_VM_PRESSURE 0x80000000 /* will react on memory pressure */ | |
403 | #define NOTE_VM_PRESSURE_TERMINATE 0x40000000 /* will quit on memory pressure, possibly after cleaning up dirty state */ | |
404 | #define NOTE_VM_PRESSURE_SUDDEN_TERMINATE 0x20000000 /* will quit immediately on memory pressure */ | |
405 | #define NOTE_VM_ERROR 0x10000000 /* there was an error */ | |
406 | ||
39236c6e A |
407 | #ifdef PRIVATE |
408 | ||
409 | /* | |
410 | * data/hint fflags for EVFILT_MEMORYSTATUS, shared with userspace. | |
411 | */ | |
412 | #define NOTE_MEMORYSTATUS_PRESSURE_NORMAL 0x00000001 /* system memory pressure has returned to normal */ | |
413 | #define NOTE_MEMORYSTATUS_PRESSURE_WARN 0x00000002 /* system memory pressure has changed to the warning state */ | |
414 | #define NOTE_MEMORYSTATUS_PRESSURE_CRITICAL 0x00000004 /* system memory pressure has changed to the critical state */ | |
fe8ab488 | 415 | #define NOTE_MEMORYSTATUS_LOW_SWAP 0x00000008 /* system is in a low-swap state */ |
39037602 A |
416 | #define NOTE_MEMORYSTATUS_PROC_LIMIT_WARN 0x00000010 /* process memory limit has hit a warning state */ |
417 | #define NOTE_MEMORYSTATUS_PROC_LIMIT_CRITICAL 0x00000020 /* process memory limit has hit a critical state - soft limit */ | |
39236c6e | 418 | |
813fb2f6 A |
419 | #ifdef KERNEL_PRIVATE |
420 | /* | |
421 | * data/hint fflags for EVFILT_MEMORYSTATUS, but not shared with userspace. | |
422 | */ | |
423 | #define NOTE_MEMORYSTATUS_PROC_LIMIT_WARN_ACTIVE 0x00000040 /* Used to restrict sending a warn event only once, per active limit, soft limits only */ | |
424 | #define NOTE_MEMORYSTATUS_PROC_LIMIT_WARN_INACTIVE 0x00000080 /* Used to restrict sending a warn event only once, per inactive limit, soft limit only */ | |
425 | #define NOTE_MEMORYSTATUS_PROC_LIMIT_CRITICAL_ACTIVE 0x00000100 /* Used to restrict sending a critical event only once per active limit, soft limit only */ | |
426 | #define NOTE_MEMORYSTATUS_PROC_LIMIT_CRITICAL_INACTIVE 0x00000200 /* Used to restrict sending a critical event only once per inactive limit, soft limit only */ | |
427 | ||
428 | /* | |
429 | * Use this mask to protect the kernel private flags. | |
430 | */ | |
431 | #define EVFILT_MEMORYSTATUS_ALL_MASK \ | |
432 | (NOTE_MEMORYSTATUS_PRESSURE_NORMAL | NOTE_MEMORYSTATUS_PRESSURE_WARN | NOTE_MEMORYSTATUS_PRESSURE_CRITICAL | NOTE_MEMORYSTATUS_LOW_SWAP | NOTE_MEMORYSTATUS_PROC_LIMIT_WARN | NOTE_MEMORYSTATUS_PROC_LIMIT_CRITICAL) | |
433 | ||
434 | #endif /* KERNEL_PRIVATE */ | |
435 | ||
39236c6e A |
436 | typedef enum vm_pressure_level { |
437 | kVMPressureNormal = 0, | |
438 | kVMPressureWarning = 1, | |
439 | kVMPressureUrgent = 2, | |
440 | kVMPressureCritical = 3, | |
441 | } vm_pressure_level_t; | |
442 | ||
813fb2f6 | 443 | #endif /* PRIVATE */ |
39236c6e | 444 | |
91447636 A |
445 | /* |
446 | * data/hint fflags for EVFILT_TIMER, shared with userspace. | |
447 | * The default is a (repeating) interval timer with the data | |
448 | * specifying the timeout interval in milliseconds. | |
449 | * | |
450 | * All timeouts are implicitly EV_CLEAR events. | |
451 | */ | |
452 | #define NOTE_SECONDS 0x00000001 /* data is seconds */ | |
453 | #define NOTE_USECONDS 0x00000002 /* data is microseconds */ | |
454 | #define NOTE_NSECONDS 0x00000004 /* data is nanoseconds */ | |
455 | #define NOTE_ABSOLUTE 0x00000008 /* absolute timeout */ | |
456 | /* ... implicit EV_ONESHOT */ | |
39236c6e A |
457 | #define NOTE_LEEWAY 0x00000010 /* ext[1] holds leeway for power aware timers */ |
458 | #define NOTE_CRITICAL 0x00000020 /* system does minimal timer coalescing */ | |
459 | #define NOTE_BACKGROUND 0x00000040 /* system does maximum timer coalescing */ | |
39037602 | 460 | #define NOTE_MACH_CONTINUOUS_TIME 0x00000080 /* use continuous time base */ |
316670eb A |
461 | #ifdef PRIVATE |
462 | /* | |
463 | * data/hint fflags for EVFILT_SOCK, shared with userspace. | |
464 | * | |
465 | */ | |
466 | #define NOTE_CONNRESET 0x00000001 /* Received RST */ | |
467 | #define NOTE_READCLOSED 0x00000002 /* Read side is shutdown */ | |
468 | #define NOTE_WRITECLOSED 0x00000004 /* Write side is shutdown */ | |
469 | #define NOTE_TIMEOUT 0x00000008 /* timeout: rexmt, keep-alive or persist */ | |
470 | #define NOTE_NOSRCADDR 0x00000010 /* source address not available */ | |
471 | #define NOTE_IFDENIED 0x00000020 /* interface denied connection */ | |
472 | #define NOTE_SUSPEND 0x00000040 /* output queue suspended */ | |
473 | #define NOTE_RESUME 0x00000080 /* output queue resumed */ | |
474 | #define NOTE_KEEPALIVE 0x00000100 /* TCP Keepalive received */ | |
39236c6e A |
475 | #define NOTE_ADAPTIVE_WTIMO 0x00000200 /* TCP adaptive write timeout */ |
476 | #define NOTE_ADAPTIVE_RTIMO 0x00000400 /* TCP adaptive read timeout */ | |
477 | #define NOTE_CONNECTED 0x00000800 /* socket is connected */ | |
478 | #define NOTE_DISCONNECTED 0x00001000 /* socket is disconnected */ | |
479 | #define NOTE_CONNINFO_UPDATED 0x00002000 /* connection info was updated */ | |
39037602 | 480 | #define NOTE_NOTIFY_ACK 0x00004000 /* notify acknowledgement */ |
316670eb | 481 | |
3e170ce0 A |
482 | #define EVFILT_SOCK_LEVEL_TRIGGER_MASK \ |
483 | (NOTE_READCLOSED | NOTE_WRITECLOSED | NOTE_SUSPEND | NOTE_RESUME | NOTE_CONNECTED | NOTE_DISCONNECTED) | |
484 | ||
485 | #define EVFILT_SOCK_ALL_MASK \ | |
39037602 | 486 | (NOTE_CONNRESET | NOTE_READCLOSED | NOTE_WRITECLOSED | NOTE_TIMEOUT | NOTE_NOSRCADDR | NOTE_IFDENIED | NOTE_SUSPEND | NOTE_RESUME | NOTE_KEEPALIVE | NOTE_ADAPTIVE_WTIMO | NOTE_ADAPTIVE_RTIMO | NOTE_CONNECTED | NOTE_DISCONNECTED | NOTE_CONNINFO_UPDATED | NOTE_NOTIFY_ACK) |
3e170ce0 | 487 | |
316670eb A |
488 | #endif /* PRIVATE */ |
489 | ||
b0d623f7 A |
490 | /* |
491 | * data/hint fflags for EVFILT_MACHPORT, shared with userspace. | |
492 | * | |
6d2010ae | 493 | * Only portsets are supported at this time. |
b0d623f7 A |
494 | * |
495 | * The fflags field can optionally contain the MACH_RCV_MSG, MACH_RCV_LARGE, | |
496 | * and related trailer receive options as defined in <mach/message.h>. | |
497 | * The presence of these flags directs the kevent64() call to attempt to receive | |
498 | * the message during kevent delivery, rather than just indicate that a message exists. | |
499 | * On setup, The ext[0] field contains the receive buffer pointer and ext[1] contains | |
500 | * the receive buffer length. Upon event delivery, the actual received message size | |
501 | * is returned in ext[1]. As with mach_msg(), the buffer must be large enough to | |
502 | * receive the message and the requested (or default) message trailers. In addition, | |
503 | * the fflags field contains the return code normally returned by mach_msg(). | |
504 | * | |
3e170ce0 A |
505 | * If MACH_RCV_MSG is specified, and the ext[1] field specifies a zero length, the |
506 | * system call argument specifying an ouput area (kevent_qos) will be consulted. If | |
507 | * the system call specified an output data area, the user-space address | |
508 | * of the received message is carved from that provided output data area (if enough | |
509 | * space remains there). The address and length of each received message is | |
510 | * returned in the ext[0] and ext[1] fields (respectively) of the corresponding kevent. | |
511 | * | |
512 | * IF_MACH_RCV_VOUCHER_CONTENT is specified, the contents of the message voucher is | |
513 | * extracted (as specified in the xflags field) and stored in ext[2] up to ext[3] | |
514 | * length. If the input length is zero, and the system call provided a data area, | |
515 | * the space for the voucher content is carved from the provided space and its | |
516 | * address and length is returned in ext[2] and ext[3] respectively. | |
517 | * | |
b0d623f7 A |
518 | * If no message receipt options were provided in the fflags field on setup, no |
519 | * message is received by this call. Instead, on output, the data field simply | |
520 | * contains the name of the actual port detected with a message waiting. | |
521 | */ | |
522 | ||
2d21ac55 A |
523 | /* |
524 | * DEPRECATED!!!!!!!!! | |
525 | * NOTE_TRACK, NOTE_TRACKERR, and NOTE_CHILD are no longer supported as of 10.5 | |
526 | */ | |
55e303ae A |
527 | /* additional flags for EVFILT_PROC */ |
528 | #define NOTE_TRACK 0x00000001 /* follow across forks */ | |
529 | #define NOTE_TRACKERR 0x00000002 /* could not track child */ | |
530 | #define NOTE_CHILD 0x00000004 /* am a child process */ | |
531 | ||
532 | ||
55e303ae | 533 | |
91447636 A |
534 | #ifndef KERNEL |
535 | /* Temporay solution for BootX to use inode.h till kqueue moves to vfs layer */ | |
536 | #include <sys/queue.h> | |
537 | struct knote; | |
538 | SLIST_HEAD(klist, knote); | |
539 | #endif | |
540 | ||
541 | #ifdef KERNEL | |
542 | ||
39037602 | 543 | #ifdef XNU_KERNEL_PRIVATE |
55e303ae | 544 | #include <sys/queue.h> |
39236c6e | 545 | #include <kern/kern_types.h> |
55e303ae A |
546 | |
547 | #ifdef MALLOC_DECLARE | |
548 | MALLOC_DECLARE(M_KQUEUE); | |
549 | #endif | |
550 | ||
91447636 A |
551 | TAILQ_HEAD(kqtailq, knote); /* a list of "queued" events */ |
552 | ||
39037602 A |
553 | /* Bit size for packed field within knote */ |
554 | #define KNOTE_KQ_BITSIZE 40 | |
555 | ||
556 | ||
557 | /* index into various kq queues */ | |
558 | typedef uint8_t kq_index_t; | |
559 | typedef uint16_t kn_status_t; | |
560 | ||
561 | #define KN_ACTIVE 0x0001 /* event has been triggered */ | |
562 | #define KN_QUEUED 0x0002 /* event is on queue */ | |
563 | #define KN_DISABLED 0x0004 /* event is disabled */ | |
564 | #define KN_DROPPING 0x0008 /* knote is being dropped */ | |
565 | #define KN_USEWAIT 0x0010 /* wait for knote use */ | |
566 | #define KN_ATTACHING 0x0020 /* event is pending attach */ | |
567 | #define KN_STAYACTIVE 0x0040 /* force event to stay active */ | |
568 | #define KN_DEFERDELETE 0x0080 /* defer delete until re-enabled */ | |
569 | #define KN_ATTACHED 0x0100 /* currently attached to source */ | |
570 | #define KN_DISPATCH 0x0200 /* disables as part of deliver */ | |
571 | #define KN_UDATA_SPECIFIC 0x0400 /* udata is part of matching */ | |
572 | #define KN_SUPPRESSED 0x0800 /* event is suppressed during delivery */ | |
573 | #define KN_STOLENDROP 0x1000 /* someone stole the drop privilege */ | |
574 | #define KN_REQVANISH 0x2000 /* requested EV_VANISH */ | |
575 | #define KN_VANISHED 0x4000 /* has vanished */ | |
576 | ||
577 | #define KN_DISPATCH2 (KN_DISPATCH | KN_UDATA_SPECIFIC) | |
578 | /* combination defines deferred-delete mode enabled */ | |
579 | ||
813fb2f6 | 580 | struct knote { |
39037602 A |
581 | TAILQ_ENTRY(knote) kn_tqe; /* linkage for tail queue */ |
582 | SLIST_ENTRY(knote) kn_link; /* linkage for search list */ | |
583 | SLIST_ENTRY(knote) kn_selnext; /* klist element chain */ | |
55e303ae | 584 | union { |
39037602 A |
585 | struct fileproc *p_fp; /* file data pointer */ |
586 | struct proc *p_proc; /* proc pointer */ | |
587 | struct ipc_mqueue *p_mqueue; /* pset pointer */ | |
55e303ae | 588 | } kn_ptr; |
39037602 A |
589 | uint64_t kn_req_index:4, /* requested qos index */ |
590 | kn_qos_index:4, /* in-use qos index */ | |
591 | kn_qos_override:4, /* qos override index */ | |
592 | kn_reserved:4, /* reserved bits */ | |
593 | kn_filtid:8, /* filter id to index filter ops */ | |
594 | kn_kq_packed:KNOTE_KQ_BITSIZE; /* packed pointer for kq */ | |
595 | ||
3e170ce0 | 596 | union { |
39037602 | 597 | void *kn_hook; |
813fb2f6 | 598 | uint64_t kn_hook_data; |
3e170ce0 | 599 | }; |
39037602 A |
600 | int64_t kn_sdata; /* saved data field */ |
601 | struct kevent_internal_s kn_kevent; | |
813fb2f6 A |
602 | int kn_sfflags; /* saved filter flags */ |
603 | int kn_hookid; | |
604 | uint16_t kn_inuse; /* inuse count */ | |
605 | kn_status_t kn_status; /* status bits */ | |
55e303ae A |
606 | |
607 | #define kn_id kn_kevent.ident | |
608 | #define kn_filter kn_kevent.filter | |
609 | #define kn_flags kn_kevent.flags | |
3e170ce0 A |
610 | #define kn_qos kn_kevent.qos |
611 | #define kn_udata kn_kevent.udata | |
55e303ae | 612 | #define kn_fflags kn_kevent.fflags |
3e170ce0 | 613 | #define kn_xflags kn_kevent.xflags |
55e303ae | 614 | #define kn_data kn_kevent.data |
b0d623f7 | 615 | #define kn_ext kn_kevent.ext |
55e303ae A |
616 | #define kn_fp kn_ptr.p_fp |
617 | }; | |
618 | ||
39037602 A |
619 | static inline struct kqueue *knote_get_kq(struct knote *kn) |
620 | { | |
621 | if (!(kn->kn_kq_packed)) | |
622 | return 0; | |
623 | else | |
624 | return (struct kqueue *)((uintptr_t)(kn->kn_kq_packed) + (uintptr_t)VM_MIN_KERNEL_AND_KEXT_ADDRESS); | |
625 | } | |
626 | ||
627 | static inline void knote_set_kq(struct knote *kn, void *kq) | |
628 | { | |
629 | if (!kq) | |
630 | kn->kn_kq_packed = 0; | |
631 | else { | |
632 | uint64_t offset = ((uintptr_t)kq - (uintptr_t)VM_MIN_KERNEL_AND_KEXT_ADDRESS); | |
633 | kn->kn_kq_packed = offset; | |
634 | } | |
635 | } | |
636 | ||
637 | struct filt_process_s { | |
638 | int fp_fd; | |
639 | unsigned int fp_flags; | |
640 | user_addr_t fp_data_out; | |
641 | user_size_t fp_data_size; | |
642 | user_size_t fp_data_resid; | |
643 | }; | |
644 | typedef struct filt_process_s *filt_process_data_t; | |
645 | ||
646 | /* | |
647 | * Filter operators | |
648 | * | |
649 | * These routines, provided by each filter, are called to attach, detach, deliver events, | |
650 | * change/update filter registration and process/deliver events. They are called with the | |
651 | * with a use-count referenced knote, with the kq unlocked. Here are more details: | |
652 | * | |
653 | * f_isfd - | |
654 | * identifies if the "ident" field in the kevent structure is a file-descriptor. | |
655 | * | |
656 | * If so, the knote is associated with the file descriptor prior to attach and | |
657 | * auto-removed when the file descriptor is closed (this latter behavior may change | |
658 | * for EV_DISPATCH2 kevent types to allow delivery of events identifying unintended | |
659 | * closes). | |
660 | * | |
661 | * Otherwise the knote is hashed by the ident and has no auto-close behavior. | |
662 | * | |
663 | * f_attach - | |
664 | * called to attach the knote to the underlying object that will be delivering events | |
665 | * through it when EV_ADD is supplied and no existing matching event is found | |
666 | * | |
667 | * provided a knote that is pre-attached to the fd or hashed (see above) but is | |
668 | * specially marked to avoid concurrent access until the attach is complete. The | |
669 | * kevent structure embedded in this knote has been filled in with a sanitized | |
670 | * version of the user-supplied kevent data. However, the user-supplied filter-specific | |
671 | * flags (fflags) and data fields have been moved into the knote's kn_sfflags and kn_sdata | |
672 | * fields respectively. These are usually interpretted as a set of "interest" flags and | |
673 | * data by each filter - to be matched against delivered events. | |
674 | * | |
675 | * The attach operator indicated errors by setting the EV_ERROR flog in the flags field | |
676 | * embedded in the knote's kevent structure - with the specific error indicated in the | |
677 | * corresponding data field. | |
678 | * | |
679 | * The return value indicates if the knote should already be considered "activated" at | |
680 | * the time of attach (one or more of the interest events has already occured). | |
681 | * | |
682 | * f_detach - | |
683 | * called to disassociate the knote from the underlying object delivering events | |
684 | * the filter should not attempt to deliver events through this knote after this | |
685 | * operation returns control to the kq system. | |
686 | * | |
687 | * f_event - | |
688 | * if the knote() function (or KNOTE() macro) is called against a list of knotes, | |
689 | * this operator will be called on each knote in the list. | |
690 | * | |
691 | * The "hint" parameter is completely filter-specific, but usually indicates an | |
692 | * event or set of events that have occured against the source object associated | |
693 | * with the list. | |
694 | * | |
695 | * The return value indicates if the knote should already be considered "activated" at | |
696 | * the time of attach (one or more of the interest events has already occured). | |
697 | * | |
698 | * f_process - | |
699 | * called when attempting to deliver triggered events to user-space. | |
700 | * | |
701 | * If the knote was previously activated, this operator will be called when a | |
702 | * thread is trying to deliver events to user-space. The filter gets one last | |
703 | * chance to determine if the event/events are still interesting for this knote | |
704 | * (are the conditions still right to deliver an event). If so, the filter | |
705 | * fills in the output kevent structure with the information to be delivered. | |
706 | * | |
707 | * The input context/data parameter is used during event delivery. Some | |
708 | * filters allow additional data delivery as part of event delivery. This | |
709 | * context field indicates if space was made available for these additional | |
710 | * items and how that space is to be allocated/carved-out. | |
711 | * | |
712 | * The filter may set EV_CLEAR or EV_ONESHOT in the output flags field to indicate | |
713 | * special post-delivery dispositions for the knote. | |
714 | * | |
715 | * EV_CLEAR - indicates that all matching events have been delivered. Even | |
716 | * though there were events to deliver now, there will not be any | |
717 | * more until some additional events are delivered to the knote | |
718 | * via the f_event operator, or the interest set is changed via | |
719 | * the f_touch operator. The knote can remain deactivated after | |
720 | * processing this event delivery. | |
721 | * | |
722 | * EV_ONESHOT - indicates that this is the last event to be delivered via | |
723 | * this knote. It will automatically be deleted upon delivery | |
724 | * (or if in dispatch-mode, upon re-enablement after this delivery). | |
725 | * | |
726 | * The return value indicates if the knote has delivered an output event. | |
727 | * Unless one of the special output flags was set in the output kevent, a non- | |
728 | * zero return value ALSO indicates that the knote should be re-activated | |
729 | * for future event processing (in case it delivers level-based or a multi-edge | |
730 | * type events like message queues that already exist). | |
731 | * | |
732 | * NOTE: In the future, the boolean may change to an enum that allows more | |
733 | * explicit indication of just delivering a current event vs delivering | |
734 | * an event with more events still pending. | |
735 | * | |
736 | * f_peek - | |
737 | * For knotes marked KN_STAYACTIVE, indicate if the knote is truly active at | |
738 | * the moment (not used for event delivery, but for status checks). | |
739 | */ | |
b0d623f7 | 740 | |
55e303ae A |
741 | struct filterops { |
742 | int f_isfd; /* true if ident == filedescriptor */ | |
91447636 A |
743 | int (*f_attach)(struct knote *kn); |
744 | void (*f_detach)(struct knote *kn); | |
745 | int (*f_event)(struct knote *kn, long hint); | |
39037602 A |
746 | int (*f_touch)(struct knote *kn, struct kevent_internal_s *kev); |
747 | int (*f_process)(struct knote *kn, struct filt_process_s *data, struct kevent_internal_s *kev); | |
6d2010ae | 748 | unsigned (*f_peek)(struct knote *kn); |
55e303ae A |
749 | }; |
750 | ||
751 | struct proc; | |
3e170ce0 | 752 | struct waitq; |
55e303ae A |
753 | |
754 | SLIST_HEAD(klist, knote); | |
39236c6e | 755 | extern void knote_init(void); |
55e303ae A |
756 | extern void klist_init(struct klist *list); |
757 | ||
758 | #define KNOTE(list, hint) knote(list, hint) | |
759 | #define KNOTE_ATTACH(list, kn) knote_attach(list, kn) | |
760 | #define KNOTE_DETACH(list, kn) knote_detach(list, kn) | |
761 | ||
762 | ||
763 | extern void knote(struct klist *list, long hint); | |
764 | extern int knote_attach(struct klist *list, struct knote *kn); | |
765 | extern int knote_detach(struct klist *list, struct knote *kn); | |
39037602 | 766 | extern void knote_vanish(struct klist *list); |
3e170ce0 A |
767 | extern int knote_link_waitq(struct knote *kn, struct waitq *wq, uint64_t *reserved_link); |
768 | extern int knote_unlink_waitq(struct knote *kn, struct waitq *wq); | |
39037602 A |
769 | extern void knote_fdclose(struct proc *p, int fd, int force); |
770 | extern void knote_markstayactive(struct knote *kn); | |
771 | extern void knote_clearstayactive(struct knote *kn); | |
772 | extern void knote_adjust_qos(struct knote *kn, int qos, int override); | |
773 | extern struct filterops *knote_fops(struct knote *kn); | |
3e170ce0 | 774 | |
39037602 A |
775 | #elif defined(KERNEL_PRIVATE) /* !XNU_KERNEL_PRIVATE: kexts still need a klist structure definition */ |
776 | ||
777 | #include <sys/queue.h> | |
778 | struct proc; | |
779 | struct knote; | |
780 | SLIST_HEAD(klist, knote); | |
781 | ||
782 | #endif /* !XNU_KERNEL_PRIVATE && KERNEL_PRIVATE */ | |
783 | ||
784 | #ifdef KERNEL_PRIVATE | |
785 | #ifdef PRIVATE | |
786 | ||
787 | /* make these private functions available to the pthread kext */ | |
3e170ce0 A |
788 | extern int kevent_qos_internal(struct proc *p, int fd, |
789 | user_addr_t changelist, int nchanges, | |
790 | user_addr_t eventlist, int nevents, | |
791 | user_addr_t data_out, user_size_t *data_available, | |
792 | unsigned int flags, int32_t *retval); | |
39037602 A |
793 | |
794 | extern int kevent_qos_internal_bind(struct proc *p, | |
795 | int fd, thread_t thread, unsigned int flags); | |
796 | extern int kevent_qos_internal_unbind(struct proc *p, | |
797 | int fd, thread_t thread, unsigned int flags); | |
798 | ||
799 | #endif /* PRIVATE */ | |
800 | #endif /* KERNEL_PRIVATE */ | |
91447636 A |
801 | |
802 | #else /* KERNEL */ | |
55e303ae | 803 | |
3e170ce0 | 804 | #include <sys/types.h> |
55e303ae | 805 | |
55e303ae A |
806 | struct timespec; |
807 | ||
808 | __BEGIN_DECLS | |
91447636 | 809 | int kqueue(void); |
3e170ce0 A |
810 | int kevent(int kq, |
811 | const struct kevent *changelist, int nchanges, | |
812 | struct kevent *eventlist, int nevents, | |
813 | const struct timespec *timeout); | |
814 | int kevent64(int kq, | |
815 | const struct kevent64_s *changelist, int nchanges, | |
816 | struct kevent64_s *eventlist, int nevents, | |
817 | unsigned int flags, | |
818 | const struct timespec *timeout); | |
819 | ||
820 | #ifdef PRIVATE | |
821 | int kevent_qos(int kq, | |
822 | const struct kevent_qos_s *changelist, int nchanges, | |
823 | struct kevent_qos_s *eventlist, int nevents, | |
824 | void *data_out, size_t *data_available, | |
825 | unsigned int flags); | |
826 | #endif /* PRIVATE */ | |
827 | ||
55e303ae A |
828 | __END_DECLS |
829 | ||
55e303ae | 830 | |
91447636 | 831 | #endif /* KERNEL */ |
55e303ae | 832 | |
55e303ae A |
833 | |
834 | #endif /* !_SYS_EVENT_H_ */ |