#include <sys/event.h>

sys/event.h

includes: machine/types.h, sys/cdefs.h, sys/queue.h, stdint.h, sys/types.h
87 macros · 3 structs · 3 functions · 2 enums

macroEVFILT_READ

Filter types
#define EVFILT_READ (-1)

macroEVFILT_WRITE

#define EVFILT_WRITE (-2)

macroEVFILT_AIO

#define EVFILT_AIO (-3)
attached to aio requests

macroEVFILT_VNODE

#define EVFILT_VNODE (-4)
attached to vnodes

macroEVFILT_PROC

#define EVFILT_PROC (-5)
attached to struct proc

macroEVFILT_SIGNAL

#define EVFILT_SIGNAL (-6)
attached to struct proc

macroEVFILT_TIMER

#define EVFILT_TIMER (-7)
timers

macroEVFILT_MACHPORT

#define EVFILT_MACHPORT (-8)
Mach portsets

macroEVFILT_FS

#define EVFILT_FS (-9)
Filesystem events

macroEVFILT_USER

#define EVFILT_USER (-10)
User events

macroEVFILT_VM

#define EVFILT_VM (-12)
Virtual memory events

macroEVFILT_EXCEPT

#define EVFILT_EXCEPT (-15)
Exception events

macroEVFILT_SYSCOUNT

#define EVFILT_SYSCOUNT 18

macroEVFILT_THREADMARKER

#define EVFILT_THREADMARKER EVFILT_SYSCOUNT
Internal use only

structkevent

size 32, align 4
uintptr_tidentidentifier for this event
int16_tfilterfilter for event
uint16_tflagsgeneral flags
uint32_tfflagsfilter-specific flags
intptr_tdatafilter-specific data
void *udataopaque user data identifier

structkevent64_s

size 48, align 8
uint64_tidentidentifier for this event
int16_tfilterfilter for event
uint16_tflagsgeneral flags
uint32_tfflagsfilter-specific flags
int64_tdatafilter-specific data
uint64_tudataopaque user data identifier
uint64_t[2]extfilter-specific extensions

macroEV_SET

#define EV_SET(kevp, a, b, c, d, e, f) do {
	struct kevent *__kevp__ = (kevp);
	__kevp__->ident = (a);
	__kevp__->filter = (b);
	__kevp__->flags = (c);
	__kevp__->fflags = (d);
	__kevp__->data = (e);
	__kevp__->udata = (f);
} while(0)

macroEV_SET64

#define EV_SET64(kevp, a, b, c, d, e, f, g, h) do {
	struct kevent64_s *__kevp__ = (kevp);
	__kevp__->ident = (a);
	__kevp__->filter = (b);
	__kevp__->flags = (c);
	__kevp__->fflags = (d);
	__kevp__->data = (e);
	__kevp__->udata = (f);
	__kevp__->ext[0] = (g);
	__kevp__->ext[1] = (h);
} while(0)

macroKEVENT_FLAG_NONE

kevent system call flags
#define KEVENT_FLAG_NONE 0x000000
no flag value

macroKEVENT_FLAG_IMMEDIATE

#define KEVENT_FLAG_IMMEDIATE 0x000001
immediate timeout

macroKEVENT_FLAG_ERROR_EVENTS

#define KEVENT_FLAG_ERROR_EVENTS 0x000002
output events only include change errors

macroEV_ADD

actions
#define EV_ADD 0x0001
add event to kq (implies enable)

macroEV_DELETE

#define EV_DELETE 0x0002
delete event from kq

macroEV_ENABLE

#define EV_ENABLE 0x0004
enable event

macroEV_DISABLE

#define EV_DISABLE 0x0008
disable event (not reported)

macroEV_ONESHOT

flags
#define EV_ONESHOT 0x0010
only report one occurrence

macroEV_CLEAR

#define EV_CLEAR 0x0020
clear event state after reporting

macroEV_RECEIPT

#define EV_RECEIPT 0x0040
force immediate event output

macroEV_DISPATCH

#define EV_DISPATCH 0x0080
disable event after reporting

macroEV_UDATA_SPECIFIC

#define EV_UDATA_SPECIFIC 0x0100
unique kevent per udata value

macroEV_DISPATCH2

#define EV_DISPATCH2 (EV_DISPATCH | EV_UDATA_SPECIFIC)

macroEV_VANISHED

#define EV_VANISHED 0x0200
report that source has vanished

macroEV_SYSFLAGS

#define EV_SYSFLAGS 0xF000
reserved by system

macroEV_FLAG0

#define EV_FLAG0 0x1000
filter-specific flag

macroEV_FLAG1

#define EV_FLAG1 0x2000
filter-specific flag

macroEV_EOF

returned values
#define EV_EOF 0x8000
EOF detected

macroEV_ERROR

#define EV_ERROR 0x4000
error, data contains errno

macroEV_POLL

Filter specific flags for EVFILT_READ The default behavior for EVFILT_READ is to make the "read" determination relative to the current file descriptor read pointer. The EV_POLL flag indicates the determination should be made via poll(2) semantics. These semantics dictate always returning true for regular files, regardless of the amount of unread data in the file. On input, EV_OOBAND specifies that filter should actively return in the presence of OOB on the descriptor. It implies that filter will return if there is OOB data available to read OR when any other condition for the read are met (for example number of bytes regular data becomes >= low-watermark). If EV_OOBAND is not set on input, it implies that the filter should not actively return for out of band data on the descriptor. The filter will then only return when some other condition for read is met (ex: when number of regular data bytes >=low-watermark OR when socket can't receive more data (SS_CANTRCVMORE)). On output, EV_OOBAND indicates the presence of OOB data on the descriptor. If it was not specified as an input parameter, then the data count is the number of bytes before the current OOB marker, else data count is the number of bytes beyond OOB marker.
#define EV_POLL EV_FLAG0

macroEV_OOBAND

#define EV_OOBAND EV_FLAG1

macroNOTE_TRIGGER

On input, NOTE_TRIGGER causes the event to be triggered for output.
#define NOTE_TRIGGER 0x01000000

macroNOTE_FFNOP

On input, the top two bits of fflags specifies how the lower twenty four bits should be applied to the stored value of fflags. On output, the top two bits will always be set to NOTE_FFNOP and the remaining twenty four bits will contain the stored fflags value.
#define NOTE_FFNOP 0x00000000
ignore input fflags

macroNOTE_FFAND

#define NOTE_FFAND 0x40000000
and fflags

macroNOTE_FFOR

#define NOTE_FFOR 0x80000000
or fflags

macroNOTE_FFCOPY

#define NOTE_FFCOPY 0xc0000000
copy fflags

macroNOTE_FFCTRLMASK

#define NOTE_FFCTRLMASK 0xc0000000
mask for operations

macroNOTE_FFLAGSMASK

#define NOTE_FFLAGSMASK 0x00ffffff

macroNOTE_LOWAT

data/hint fflags for EVFILT_{READ|WRITE}, shared with userspace The default behavior for EVFILT_READ is to make the determination realtive to the current file descriptor read pointer.
#define NOTE_LOWAT 0x00000001
low water mark

macroNOTE_OOB

data/hint flags for EVFILT_EXCEPT, shared with userspace
#define NOTE_OOB 0x00000002
OOB data

macroNOTE_DELETE

data/hint fflags for EVFILT_VNODE, shared with userspace
#define NOTE_DELETE 0x00000001
vnode was removed

macroNOTE_WRITE

#define NOTE_WRITE 0x00000002
data contents changed

macroNOTE_EXTEND

#define NOTE_EXTEND 0x00000004
size increased

macroNOTE_ATTRIB

#define NOTE_ATTRIB 0x00000008
attributes changed

macroNOTE_RENAME

#define NOTE_RENAME 0x00000020
vnode was renamed

macroNOTE_REVOKE

#define NOTE_REVOKE 0x00000040
vnode access was revoked

macroNOTE_NONE

#define NOTE_NONE 0x00000080
No specific vnode event: to test for EVFILT_READ activation

macroNOTE_FUNLOCK

#define NOTE_FUNLOCK 0x00000100
vnode was unlocked by flock(2)

macroNOTE_LEASE_DOWNGRADE

#define NOTE_LEASE_DOWNGRADE 0x00000200
lease downgrade requested

macroNOTE_LEASE_RELEASE

#define NOTE_LEASE_RELEASE 0x00000400
lease release requested

enum(anonymous)

data/hint fflags for EVFILT_PROC, shared with userspace Please note that EVFILT_PROC and EVFILT_SIGNAL share the same knote list that hangs off the proc structure. They also both play games with the hint passed to KNOTE(). If NOTE_SIGNAL is passed as a hint, then the lower bits of the hint contain the signal. IF NOTE_FORK is passed, then the lower bits contain the PID of the child (but the pid does not get passed through in the actual kevent).
underlying type unsigned int
eNoteReapDeprecated268435456

macroNOTE_EXIT

#define NOTE_EXIT 0x80000000
process exited

macroNOTE_FORK

#define NOTE_FORK 0x40000000
process forked

macroNOTE_EXEC

#define NOTE_EXEC 0x20000000
process exec'd

macroNOTE_REAP

#define NOTE_REAP ((unsigned int)eNoteReapDeprecated /* 0x10000000 */ )
process reaped

macroNOTE_SIGNAL

#define NOTE_SIGNAL 0x08000000
shared with EVFILT_SIGNAL

macroNOTE_EXITSTATUS

#define NOTE_EXITSTATUS 0x04000000
exit status to be returned, valid for child process or when allowed to signal target pid

macroNOTE_EXIT_DETAIL

#define NOTE_EXIT_DETAIL 0x02000000
provide details on reasons for exit

macroNOTE_PDATAMASK

#define NOTE_PDATAMASK 0x000fffff
mask for signal & exit status

macroNOTE_PCTRLMASK

#define NOTE_PCTRLMASK (~NOTE_PDATAMASK)

enum(anonymous)

If NOTE_EXITSTATUS is present, provide additional info about exiting process.
underlying type unsigned int
eNoteExitReparentedDeprecated524288

macroNOTE_EXIT_REPARENTED

#define NOTE_EXIT_REPARENTED ((unsigned int)eNoteExitReparentedDeprecated)
exited while reparented

macroNOTE_EXIT_DETAIL_MASK

If NOTE_EXIT_DETAIL is present, these bits indicate specific reasons for exiting.
#define NOTE_EXIT_DETAIL_MASK 0x00070000

macroNOTE_EXIT_DECRYPTFAIL

#define NOTE_EXIT_DECRYPTFAIL 0x00010000

macroNOTE_EXIT_MEMORY

#define NOTE_EXIT_MEMORY 0x00020000

macroNOTE_EXIT_CSERROR

#define NOTE_EXIT_CSERROR 0x00040000

macroNOTE_VM_PRESSURE

data/hint fflags for EVFILT_VM, shared with userspace.
#define NOTE_VM_PRESSURE 0x80000000
will react on memory pressure

macroNOTE_VM_PRESSURE_TERMINATE

#define NOTE_VM_PRESSURE_TERMINATE 0x40000000
will quit on memory pressure, possibly after cleaning up dirty state

macroNOTE_VM_PRESSURE_SUDDEN_TERMINATE

#define NOTE_VM_PRESSURE_SUDDEN_TERMINATE 0x20000000
will quit immediately on memory pressure

macroNOTE_VM_ERROR

#define NOTE_VM_ERROR 0x10000000
there was an error

macroNOTE_SECONDS

data/hint fflags for EVFILT_TIMER, shared with userspace. The default is a (repeating) interval timer with the data specifying the timeout interval in milliseconds. All timeouts are implicitly EV_CLEAR events.
#define NOTE_SECONDS 0x00000001
data is seconds

macroNOTE_USECONDS

#define NOTE_USECONDS 0x00000002
data is microseconds

macroNOTE_NSECONDS

#define NOTE_NSECONDS 0x00000004
data is nanoseconds

macroNOTE_ABSOLUTE

#define NOTE_ABSOLUTE 0x00000008
absolute timeout

macroNOTE_LEEWAY

... implicit EV_ONESHOT, timeout uses the gettimeofday epoch
#define NOTE_LEEWAY 0x00000010
ext[1] holds leeway for power aware timers

macroNOTE_CRITICAL

#define NOTE_CRITICAL 0x00000020
system does minimal timer coalescing

macroNOTE_BACKGROUND

#define NOTE_BACKGROUND 0x00000040
system does maximum timer coalescing

macroNOTE_MACH_CONTINUOUS_TIME

#define NOTE_MACH_CONTINUOUS_TIME 0x00000080

macroNOTE_MACHTIME

NOTE_MACH_CONTINUOUS_TIME: with NOTE_ABSOLUTE: causes the timer to continue to tick across sleep, still uses gettimeofday epoch with NOTE_MACHTIME and NOTE_ABSOLUTE: uses mach continuous time epoch without NOTE_ABSOLUTE (interval timer mode): continues to tick across sleep
#define NOTE_MACHTIME 0x00000100
data is mach absolute time units

macroNOTE_TRACK

DEPRECATED!!!!!!!!! NOTE_TRACK, NOTE_TRACKERR, and NOTE_CHILD are no longer supported as of 10.5 additional flags for EVFILT_PROC
#define NOTE_TRACK 0x00000001
follow across forks

macroNOTE_TRACKERR

#define NOTE_TRACKERR 0x00000002
could not track child

macroNOTE_CHILD

#define NOTE_CHILD 0x00000004
am a child process

structklist

size 8, align 8
struct knote *slh_firstfirst element

functionkqueue

int kqueue(void)
man page · October 21, 2008
kqueue(2) — kernel event notification mechanism

functionkevent

int kevent(
	int kq,
	const struct kevent *changelist,
	int nchanges,
	struct kevent *eventlist,
	int nevents,
	const struct timespec *timeout
)
man page · October 21, 2008
kevent(2) — kernel event notification mechanism

functionkevent64

int kevent64(
	int kq,
	const struct kevent64_s *changelist,
	int nchanges,
	struct kevent64_s *eventlist,
	int nevents,
	unsigned int flags,
	const struct timespec *timeout
)
man page · October 21, 2008
kevent64(2) — kernel event notification mechanism