silk.platform.native.kqueue.
The Darwin kqueue system calls and their C types, shared by the native providers that use them.
When to use#
Use these declarations to build a native provider on Darwin, such as silk.system.subprocess
or silk.system.signal_watch. Application code uses those modules instead.
Details#
A program has one declaration of each C symbol, so every module that calls kevent imports it
from here. The functions are the C functions with no wrapping: a negative result means failure,
and the error code is in errno.
Gotchas#
The module is empty on targets other than Darwin on x86_64 or aarch64.
Import as KernelEvent with import silk.platform.native.kqueue { KernelEvent }.
Public declarations: 19.
KernelEvent#
pub extern "C" struct KernelEventThe C struct kevent of 64-bit Darwin: one filter change, or one event of a kqueue.
Details#
ident names what the filter watches, such as a descriptor, a process ID, or a signal number.
filter is one of the FILTER_ constants, and flags a set of the flag constants such as
ADD. fflags and data are specific to the filter. udata comes back unchanged with each
event of the filter.
Field ident#
pub ident: usizeWhat the filter watches.
Field filter#
pub filter: i16The kind of filter, such as FILTER_READ.
Field flags#
pub flags: u16The action and the state flags, such as ADD.
Field fflags#
pub fflags: u32Flags specific to the filter, such as NOTE_EXIT.
Field data#
pub data: isizeData specific to the filter, such as the error code of a change with ERROR.
Field udata#
pub udata: usizeThe value of the caller, returned with each event.
Implementation Copy for KernelEvent#
impl Copy for KernelEventImplementation KernelEvent#
impl KernelEventAssociated function make#
pub fn make(ident: usize, filter: i16, flags: u16, fflags: u32, udata: usize) -> KernelEventReturns a filter change or an event buffer entry, with data 0.
TimeSpec#
pub extern "C" struct TimeSpecThe C struct timespec of 64-bit Darwin, for the timeout of kevent.
Field seconds#
pub seconds: i64Whole seconds.
Field nanoseconds#
pub nanoseconds: i64Nanoseconds, from 0 to 999999999.
Implementation Copy for TimeSpec#
impl Copy for TimeSpeckqueue#
pub unsafe extern "C" fn kqueue() -> i32The C kqueue function: opens a new kernel queue, or returns -1.
Gotchas#
The descriptor is not close-on-exec; set FD_CLOEXEC with fcntl.
kevent#
@foreign(noCapture: .("changes", "events", "timeout"))
pub unsafe extern "C" fn kevent(queue: i32, changes: ?[*]const KernelEvent, changeCount: i32, events: ?[*]mut KernelEvent, eventCount: i32, timeout: ?*const TimeSpec) -> i32The C kevent function: applies changeCount changes, then waits up to timeout (forever
when null) for at most eventCount events. Returns the number of events, or -1.
Gotchas#
changes must hold changeCount entries and events must have room for eventCount entries
during the call.
FILTER_READ#
pub const FILTER_READ: i16EVFILT_READ: the descriptor has data to read.
FILTER_WRITE#
pub const FILTER_WRITE: i16EVFILT_WRITE: a write to the descriptor would not block.
FILTER_PROC#
pub const FILTER_PROC: i16EVFILT_PROC: the process ident had an event of fflags, such as NOTE_EXIT.
FILTER_SIGNAL#
pub const FILTER_SIGNAL: i16EVFILT_SIGNAL: the signal ident was sent to the process; data counts the arrivals.
FILTER_USER#
pub const FILTER_USER: i16EVFILT_USER: an event that the caller triggers with NOTE_TRIGGER.
ADD#
pub const ADD: u16EV_ADD: adds the filter, or changes it.
DELETE#
pub const DELETE: u16EV_DELETE: removes the filter.
ENABLE#
pub const ENABLE: u16EV_ENABLE: reports the events of the filter.
ONESHOT#
pub const ONESHOT: u16EV_ONESHOT: removes the filter after its first event.
CLEAR#
pub const CLEAR: u16EV_CLEAR: resets the state of the filter after each event.
RECEIPT#
pub const RECEIPT: u16EV_RECEIPT: reports each change as an event with ERROR and its result in data.
ERROR#
pub const ERROR: u16EV_ERROR: the event reports the result of a change in data.
END#
pub const END: u16EV_EOF: the descriptor reached its end, or its peer closed.
NOTE_EXIT#
pub const NOTE_EXIT: u32NOTE_EXIT: the process exited, for FILTER_PROC.
NOTE_TRIGGER#
pub const NOTE_TRIGGER: u32NOTE_TRIGGER: triggers a FILTER_USER event.
Category: Native platform.
Profiles: aarch64-apple-darwin.