2 * Copyright (c) 2003-2015 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
30 * All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
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.
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
53 * $FreeBSD: src/sys/sys/event.h,v 1.5.2.5 2001/12/14 19:21:22 jlemon Exp $
59 #include <machine/types.h>
60 #include <sys/cdefs.h>
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 */
70 #define EVFILT_MACHPORT (-8) /* Mach portsets */
71 #define EVFILT_FS (-9) /* Filesystem events */
72 #define EVFILT_USER (-10) /* User events */
74 #define EVFILT_VM (-12) /* Virtual memory events */
77 #define EVFILT_SOCK (-13) /* Socket events */
78 #define EVFILT_MEMORYSTATUS (-14) /* Memorystatus events */
81 #define EVFILT_SYSCOUNT 14
82 #define EVFILT_THREADMARKER EVFILT_SYSCOUNT /* Internal use only */
87 uintptr_t ident
; /* identifier for this event */
88 int16_t filter
; /* filter for event */
89 uint16_t flags
; /* general flags */
90 uint32_t fflags
; /* filter-specific flags */
91 intptr_t data
; /* filter-specific data */
92 void *udata
; /* opaque user data identifier */
97 struct user64_kevent
{
98 uint64_t ident
; /* identifier for this event */
99 int16_t filter
; /* filter for event */
100 uint16_t flags
; /* general flags */
101 uint32_t fflags
; /* filter-specific flags */
102 int64_t data
; /* filter-specific data */
103 user_addr_t udata
; /* opaque user data identifier */
106 struct user32_kevent
{
107 uint32_t ident
; /* identifier for this event */
108 int16_t filter
; /* filter for event */
109 uint16_t flags
; /* general flags */
110 uint32_t fflags
; /* filter-specific flags */
111 int32_t data
; /* filter-specific data */
112 user32_addr_t udata
; /* opaque user data identifier */
115 struct kevent_internal_s
{
116 uint64_t ident
; /* identifier for this event */
117 int16_t filter
; /* filter for event */
118 uint16_t flags
; /* general flags */
119 uint32_t fflags
; /* filter-specific flags */
120 int64_t data
; /* filter-specific data */
121 uint64_t udata
; /* opaque user data identifier */
122 uint64_t ext
[2]; /* filter-specific extensions */
130 uint64_t ident
; /* identifier for this event */
131 int16_t filter
; /* filter for event */
132 uint16_t flags
; /* general flags */
133 uint32_t fflags
; /* filter-specific flags */
134 int64_t data
; /* filter-specific data */
135 uint64_t udata
; /* opaque user data identifier */
136 uint64_t ext
[2]; /* filter-specific extensions */
140 struct kevent_qos_s
{
141 uint64_t ident
; /* identifier for this event */
142 int16_t filter
; /* filter for event */
143 uint16_t flags
; /* general flags */
144 int32_t qos
; /* quality of service */
145 uint64_t udata
; /* opaque user data identifier */
146 uint32_t fflags
; /* filter-specific flags */
147 uint32_t xflags
; /* extra filter-specific flags */
148 int64_t data
; /* filter-specific data */
149 uint64_t ext
[4]; /* filter-specific extensions */
153 #define EV_SET(kevp, a, b, c, d, e, f) do { \
154 struct kevent *__kevp__ = (kevp); \
155 __kevp__->ident = (a); \
156 __kevp__->filter = (b); \
157 __kevp__->flags = (c); \
158 __kevp__->fflags = (d); \
159 __kevp__->data = (e); \
160 __kevp__->udata = (f); \
163 #define EV_SET64(kevp, a, b, c, d, e, f, g, h) do { \
164 struct kevent64_s *__kevp__ = (kevp); \
165 __kevp__->ident = (a); \
166 __kevp__->filter = (b); \
167 __kevp__->flags = (c); \
168 __kevp__->fflags = (d); \
169 __kevp__->data = (e); \
170 __kevp__->udata = (f); \
171 __kevp__->ext[0] = (g); \
172 __kevp__->ext[1] = (h); \
176 /* kevent system call flags */
177 #define KEVENT_FLAG_NONE 0x00 /* no flag value */
178 #define KEVENT_FLAG_IMMEDIATE 0x01 /* immediate timeout */
179 #define KEVENT_FLAG_ERROR_EVENTS 0x02 /* output events only include change errors */
185 * Rather than provide an EV_SET_QOS macro for kevent_qos_t structure
186 * initialization, we encourage use of named field initialization support
190 #define KEVENT_FLAG_STACK_EVENTS 0x04 /* output events treated as stack (grows down) */
191 #define KEVENT_FLAG_STACK_DATA 0x08 /* output data allocated as stack (grows down) */
192 #define KEVENT_FLAG_WORKQ 0x20 /* interact with the default workq kq */
194 #ifdef XNU_KERNEL_PRIVATE
196 #define KEVENT_FLAG_LEGACY32 0x40 /* event data in legacy 32-bit format */
197 #define KEVENT_FLAG_LEGACY64 0x80 /* event data in legacy 64-bit format */
199 #define KEVENT_FLAG_USER (KEVENT_FLAG_IMMEDIATE | KEVENT_FLAG_ERROR_EVENTS | \
200 KEVENT_FLAG_STACK_EVENTS | KEVENT_FLAG_STACK_DATA | \
202 #endif /* XNU_KERNEL_PRIVATE */
206 #define EV_ADD 0x0001 /* add event to kq (implies enable) */
207 #define EV_DELETE 0x0002 /* delete event from kq */
208 #define EV_ENABLE 0x0004 /* enable event */
209 #define EV_DISABLE 0x0008 /* disable event (not reported) */
212 #define EV_ONESHOT 0x0010 /* only report one occurrence */
213 #define EV_CLEAR 0x0020 /* clear event state after reporting */
214 #define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data == 0 */
215 #define EV_DISPATCH 0x0080 /* disable event after reporting */
217 #define EV_UDATA_SPECIFIC 0x0100 /* unique kevent per udata value */
218 /* ... in combination with EV_DELETE */
219 /* will defer delete until udata-specific */
220 /* event enabled. EINPROGRESS will be */
221 /* returned to indicate the deferral */
223 #define EV_DISPATCH2 (EV_DISPATCH | EV_UDATA_SPECIFIC)
225 #define EV_SYSFLAGS 0xF000 /* reserved by system */
226 #define EV_FLAG0 0x1000 /* filter-specific flag */
227 #define EV_FLAG1 0x2000 /* filter-specific flag */
229 /* returned values */
230 #define EV_EOF 0x8000 /* EOF detected */
231 #define EV_ERROR 0x4000 /* error, data contains errno */
234 * Filter specific flags for EVFILT_READ
236 * The default behavior for EVFILT_READ is to make the "read" determination
237 * relative to the current file descriptor read pointer.
239 * The EV_POLL flag indicates the determination should be made via poll(2)
240 * semantics. These semantics dictate always returning true for regular files,
241 * regardless of the amount of unread data in the file.
243 * On input, EV_OOBAND specifies that filter should actively return in the
244 * presence of OOB on the descriptor. It implies that filter will return
245 * if there is OOB data available to read OR when any other condition
246 * for the read are met (for example number of bytes regular data becomes >=
248 * If EV_OOBAND is not set on input, it implies that the filter should not actively
249 * return for out of band data on the descriptor. The filter will then only return
250 * when some other condition for read is met (ex: when number of regular data bytes
251 * >=low-watermark OR when socket can't receive more data (SS_CANTRCVMORE)).
253 * On output, EV_OOBAND indicates the presence of OOB data on the descriptor.
254 * If it was not specified as an input parameter, then the data count is the
255 * number of bytes before the current OOB marker, else data count is the number
256 * of bytes beyond OOB marker.
258 #define EV_POLL EV_FLAG0
259 #define EV_OOBAND EV_FLAG1
262 * data/hint fflags for EVFILT_USER, shared with userspace
266 * On input, NOTE_TRIGGER causes the event to be triggered for output.
268 #define NOTE_TRIGGER 0x01000000
271 * On input, the top two bits of fflags specifies how the lower twenty four
272 * bits should be applied to the stored value of fflags.
274 * On output, the top two bits will always be set to NOTE_FFNOP and the
275 * remaining twenty four bits will contain the stored fflags value.
277 #define NOTE_FFNOP 0x00000000 /* ignore input fflags */
278 #define NOTE_FFAND 0x40000000 /* and fflags */
279 #define NOTE_FFOR 0x80000000 /* or fflags */
280 #define NOTE_FFCOPY 0xc0000000 /* copy fflags */
281 #define NOTE_FFCTRLMASK 0xc0000000 /* mask for operations */
282 #define NOTE_FFLAGSMASK 0x00ffffff
285 * data/hint fflags for EVFILT_{READ|WRITE}, shared with userspace
287 * The default behavior for EVFILT_READ is to make the determination
288 * realtive to the current file descriptor read pointer.
290 #define NOTE_LOWAT 0x00000001 /* low water mark */
293 * data/hint fflags for EVFILT_VNODE, shared with userspace
295 #define NOTE_DELETE 0x00000001 /* vnode was removed */
296 #define NOTE_WRITE 0x00000002 /* data contents changed */
297 #define NOTE_EXTEND 0x00000004 /* size increased */
298 #define NOTE_ATTRIB 0x00000008 /* attributes changed */
299 #define NOTE_LINK 0x00000010 /* link count changed */
300 #define NOTE_RENAME 0x00000020 /* vnode was renamed */
301 #define NOTE_REVOKE 0x00000040 /* vnode access was revoked */
302 #define NOTE_NONE 0x00000080 /* No specific vnode event: to test for EVFILT_READ activation*/
305 * data/hint fflags for EVFILT_PROC, shared with userspace
307 * Please note that EVFILT_PROC and EVFILT_SIGNAL share the same knote list
308 * that hangs off the proc structure. They also both play games with the hint
309 * passed to KNOTE(). If NOTE_SIGNAL is passed as a hint, then the lower bits
310 * of the hint contain the signal. IF NOTE_FORK is passed, then the lower bits
311 * contain the PID of the child (but the pid does not get passed through in
312 * the actual kevent).
315 eNoteReapDeprecated
__deprecated_enum_msg("This kqueue(2) EVFILT_PROC flag is deprecated") = 0x10000000
318 #define NOTE_EXIT 0x80000000 /* process exited */
319 #define NOTE_FORK 0x40000000 /* process forked */
320 #define NOTE_EXEC 0x20000000 /* process exec'd */
321 #define NOTE_REAP ((unsigned int)eNoteReapDeprecated /* 0x10000000 */) /* process reaped */
322 #define NOTE_SIGNAL 0x08000000 /* shared with EVFILT_SIGNAL */
323 #define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process only */
324 #define NOTE_EXIT_DETAIL 0x02000000 /* provide details on reasons for exit */
326 #define NOTE_PDATAMASK 0x000fffff /* mask for signal & exit status */
327 #define NOTE_PCTRLMASK (~NOTE_PDATAMASK)
330 * If NOTE_EXITSTATUS is present, provide additional info about exiting process.
333 eNoteExitReparentedDeprecated
__deprecated_enum_msg("This kqueue(2) EVFILT_PROC flag is no longer sent") = 0x00080000
335 #define NOTE_EXIT_REPARENTED ((unsigned int)eNoteExitReparentedDeprecated) /* exited while reparented */
338 * If NOTE_EXIT_DETAIL is present, these bits indicate specific reasons for exiting.
340 #define NOTE_EXIT_DETAIL_MASK 0x00070000
341 #define NOTE_EXIT_DECRYPTFAIL 0x00010000
342 #define NOTE_EXIT_MEMORY 0x00020000
343 #define NOTE_EXIT_CSERROR 0x00040000
348 * If NOTE_EXIT_MEMORY is present, these bits indicate specific jetsam condition.
350 #define NOTE_EXIT_MEMORY_DETAIL_MASK 0xfe000000
351 #define NOTE_EXIT_MEMORY_VMPAGESHORTAGE 0x80000000 /* jetsam condition: lowest jetsam priority proc killed due to vm page shortage */
352 #define NOTE_EXIT_MEMORY_VMTHRASHING 0x40000000 /* jetsam condition: lowest jetsam priority proc killed due to vm thrashing */
353 #define NOTE_EXIT_MEMORY_HIWAT 0x20000000 /* jetsam condition: process reached its high water mark */
354 #define NOTE_EXIT_MEMORY_PID 0x10000000 /* jetsam condition: special pid kill requested */
355 #define NOTE_EXIT_MEMORY_IDLE 0x08000000 /* jetsam condition: idle process cleaned up */
356 #define NOTE_EXIT_MEMORY_VNODE 0X04000000 /* jetsam condition: virtual node kill */
357 #define NOTE_EXIT_MEMORY_FCTHRASHING 0x02000000 /* jetsam condition: lowest jetsam priority proc killed due to filecache thrashing */
362 * data/hint fflags for EVFILT_VM, shared with userspace.
364 #define NOTE_VM_PRESSURE 0x80000000 /* will react on memory pressure */
365 #define NOTE_VM_PRESSURE_TERMINATE 0x40000000 /* will quit on memory pressure, possibly after cleaning up dirty state */
366 #define NOTE_VM_PRESSURE_SUDDEN_TERMINATE 0x20000000 /* will quit immediately on memory pressure */
367 #define NOTE_VM_ERROR 0x10000000 /* there was an error */
372 * data/hint fflags for EVFILT_MEMORYSTATUS, shared with userspace.
374 #define NOTE_MEMORYSTATUS_PRESSURE_NORMAL 0x00000001 /* system memory pressure has returned to normal */
375 #define NOTE_MEMORYSTATUS_PRESSURE_WARN 0x00000002 /* system memory pressure has changed to the warning state */
376 #define NOTE_MEMORYSTATUS_PRESSURE_CRITICAL 0x00000004 /* system memory pressure has changed to the critical state */
377 #define NOTE_MEMORYSTATUS_LOW_SWAP 0x00000008 /* system is in a low-swap state */
379 typedef enum vm_pressure_level
{
380 kVMPressureNormal
= 0,
381 kVMPressureWarning
= 1,
382 kVMPressureUrgent
= 2,
383 kVMPressureCritical
= 3,
384 } vm_pressure_level_t
;
389 * data/hint fflags for EVFILT_TIMER, shared with userspace.
390 * The default is a (repeating) interval timer with the data
391 * specifying the timeout interval in milliseconds.
393 * All timeouts are implicitly EV_CLEAR events.
395 #define NOTE_SECONDS 0x00000001 /* data is seconds */
396 #define NOTE_USECONDS 0x00000002 /* data is microseconds */
397 #define NOTE_NSECONDS 0x00000004 /* data is nanoseconds */
398 #define NOTE_ABSOLUTE 0x00000008 /* absolute timeout */
399 /* ... implicit EV_ONESHOT */
400 #define NOTE_LEEWAY 0x00000010 /* ext[1] holds leeway for power aware timers */
401 #define NOTE_CRITICAL 0x00000020 /* system does minimal timer coalescing */
402 #define NOTE_BACKGROUND 0x00000040 /* system does maximum timer coalescing */
405 * data/hint fflags for EVFILT_SOCK, shared with userspace.
408 #define NOTE_CONNRESET 0x00000001 /* Received RST */
409 #define NOTE_READCLOSED 0x00000002 /* Read side is shutdown */
410 #define NOTE_WRITECLOSED 0x00000004 /* Write side is shutdown */
411 #define NOTE_TIMEOUT 0x00000008 /* timeout: rexmt, keep-alive or persist */
412 #define NOTE_NOSRCADDR 0x00000010 /* source address not available */
413 #define NOTE_IFDENIED 0x00000020 /* interface denied connection */
414 #define NOTE_SUSPEND 0x00000040 /* output queue suspended */
415 #define NOTE_RESUME 0x00000080 /* output queue resumed */
416 #define NOTE_KEEPALIVE 0x00000100 /* TCP Keepalive received */
417 #define NOTE_ADAPTIVE_WTIMO 0x00000200 /* TCP adaptive write timeout */
418 #define NOTE_ADAPTIVE_RTIMO 0x00000400 /* TCP adaptive read timeout */
419 #define NOTE_CONNECTED 0x00000800 /* socket is connected */
420 #define NOTE_DISCONNECTED 0x00001000 /* socket is disconnected */
421 #define NOTE_CONNINFO_UPDATED 0x00002000 /* connection info was updated */
423 #define EVFILT_SOCK_LEVEL_TRIGGER_MASK \
424 (NOTE_READCLOSED | NOTE_WRITECLOSED | NOTE_SUSPEND | NOTE_RESUME | NOTE_CONNECTED | NOTE_DISCONNECTED)
426 #define EVFILT_SOCK_ALL_MASK \
427 (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)
432 * data/hint fflags for EVFILT_MACHPORT, shared with userspace.
434 * Only portsets are supported at this time.
436 * The fflags field can optionally contain the MACH_RCV_MSG, MACH_RCV_LARGE,
437 * and related trailer receive options as defined in <mach/message.h>.
438 * The presence of these flags directs the kevent64() call to attempt to receive
439 * the message during kevent delivery, rather than just indicate that a message exists.
440 * On setup, The ext[0] field contains the receive buffer pointer and ext[1] contains
441 * the receive buffer length. Upon event delivery, the actual received message size
442 * is returned in ext[1]. As with mach_msg(), the buffer must be large enough to
443 * receive the message and the requested (or default) message trailers. In addition,
444 * the fflags field contains the return code normally returned by mach_msg().
446 * If MACH_RCV_MSG is specified, and the ext[1] field specifies a zero length, the
447 * system call argument specifying an ouput area (kevent_qos) will be consulted. If
448 * the system call specified an output data area, the user-space address
449 * of the received message is carved from that provided output data area (if enough
450 * space remains there). The address and length of each received message is
451 * returned in the ext[0] and ext[1] fields (respectively) of the corresponding kevent.
453 * IF_MACH_RCV_VOUCHER_CONTENT is specified, the contents of the message voucher is
454 * extracted (as specified in the xflags field) and stored in ext[2] up to ext[3]
455 * length. If the input length is zero, and the system call provided a data area,
456 * the space for the voucher content is carved from the provided space and its
457 * address and length is returned in ext[2] and ext[3] respectively.
459 * If no message receipt options were provided in the fflags field on setup, no
460 * message is received by this call. Instead, on output, the data field simply
461 * contains the name of the actual port detected with a message waiting.
465 * DEPRECATED!!!!!!!!!
466 * NOTE_TRACK, NOTE_TRACKERR, and NOTE_CHILD are no longer supported as of 10.5
468 /* additional flags for EVFILT_PROC */
469 #define NOTE_TRACK 0x00000001 /* follow across forks */
470 #define NOTE_TRACKERR 0x00000002 /* could not track child */
471 #define NOTE_CHILD 0x00000004 /* am a child process */
476 /* Temporay solution for BootX to use inode.h till kqueue moves to vfs layer */
477 #include <sys/queue.h>
479 SLIST_HEAD(klist
, knote
);
484 #ifdef KERNEL_PRIVATE
485 #include <sys/queue.h>
486 #include <kern/kern_types.h>
488 #ifdef MALLOC_DECLARE
489 MALLOC_DECLARE(M_KQUEUE
);
492 TAILQ_HEAD(kqtailq
, knote
); /* a list of "queued" events */
495 int kn_inuse
; /* inuse count */
497 TAILQ_ENTRY(knote
) kn_tqe
; /* linkage for tail queue */
498 struct kqtailq
*kn_tq
; /* pointer to tail queue */
499 struct kqueue
*kn_kq
; /* which kqueue we are on */
500 SLIST_ENTRY(knote
) kn_link
; /* linkage for search list */
501 SLIST_ENTRY(knote
) kn_selnext
; /* klist element chain */
503 struct fileproc
*p_fp
; /* file data pointer */
504 struct proc
*p_proc
; /* proc pointer */
505 struct ipc_pset
*p_pset
; /* pset pointer */
507 struct filterops
*kn_fop
;
508 int kn_status
; /* status bits */
509 int kn_sfflags
; /* saved filter flags */
512 uint64_t kn_hook_data
;
514 int64_t kn_sdata
; /* saved data field */
515 struct kevent_internal_s kn_kevent
;
517 #define KN_ACTIVE 0x01 /* event has been triggered */
518 #define KN_QUEUED 0x02 /* event is on queue */
519 #define KN_DISABLED 0x04 /* event is disabled */
520 #define KN_DROPPING 0x08 /* knote is being dropped */
521 #define KN_USEWAIT 0x10 /* wait for knote use */
522 #define KN_ATTACHING 0x20 /* event is pending attach */
523 #define KN_STAYQUEUED 0x40 /* force event to stay on queue */
524 #define KN_DEFERDROP 0x80 /* defer drop until re-enabled */
525 #define KN_TOUCH 0x100 /* Always call f_touch callback */
527 #define kn_id kn_kevent.ident
528 #define kn_filter kn_kevent.filter
529 #define kn_flags kn_kevent.flags
530 #define kn_qos kn_kevent.qos
531 #define kn_udata kn_kevent.udata
532 #define kn_fflags kn_kevent.fflags
533 #define kn_xflags kn_kevent.xflags
534 #define kn_data kn_kevent.data
535 #define kn_ext kn_kevent.ext
536 #define kn_fp kn_ptr.p_fp
539 /* Hint values for f_touch filter operation */
540 #define EVENT_REGISTER 1
541 #define EVENT_PROCESS 2
544 int f_isfd
; /* true if ident == filedescriptor */
545 int (*f_attach
)(struct knote
*kn
);
546 void (*f_detach
)(struct knote
*kn
);
547 int (*f_event
)(struct knote
*kn
, long hint
);
548 /* Optional f_touch operation, called only if !f_isfd && non-NULL */
549 void (*f_touch
)(struct knote
*kn
, struct kevent_internal_s
*kev
, long type
);
550 /* Optional f_peek operation, called only if KN_STAYQUEUED is set */
551 unsigned (*f_peek
)(struct knote
*kn
);
557 SLIST_HEAD(klist
, knote
);
558 extern void knote_init(void);
559 extern void klist_init(struct klist
*list
);
561 #define KNOTE(list, hint) knote(list, hint)
562 #define KNOTE_ATTACH(list, kn) knote_attach(list, kn)
563 #define KNOTE_DETACH(list, kn) knote_detach(list, kn)
566 extern void knote(struct klist
*list
, long hint
);
567 extern int knote_attach(struct klist
*list
, struct knote
*kn
);
568 extern int knote_detach(struct klist
*list
, struct knote
*kn
);
569 extern int knote_link_waitq(struct knote
*kn
, struct waitq
*wq
, uint64_t *reserved_link
);
570 extern int knote_unlink_waitq(struct knote
*kn
, struct waitq
*wq
);
571 extern void knote_fdclose(struct proc
*p
, int fd
);
572 extern void knote_markstayqueued(struct knote
*kn
);
573 extern void knote_clearstayqueued(struct knote
*kn
);
575 extern int kevent_qos_internal(struct proc
*p
, int fd
,
576 user_addr_t changelist
, int nchanges
,
577 user_addr_t eventlist
, int nevents
,
578 user_addr_t data_out
, user_size_t
*data_available
,
579 unsigned int flags
, int32_t *retval
);
580 #endif /* !KERNEL_PRIVATE */
584 #include <sys/types.h>
591 const struct kevent
*changelist
, int nchanges
,
592 struct kevent
*eventlist
, int nevents
,
593 const struct timespec
*timeout
);
595 const struct kevent64_s
*changelist
, int nchanges
,
596 struct kevent64_s
*eventlist
, int nevents
,
598 const struct timespec
*timeout
);
601 int kevent_qos(int kq
,
602 const struct kevent_qos_s
*changelist
, int nchanges
,
603 struct kevent_qos_s
*eventlist
, int nevents
,
604 void *data_out
, size_t *data_available
,
614 #endif /* !_SYS_EVENT_H_ */