zig fmt
This commit is contained in:
parent
3ba451778f
commit
a0c564d762
@ -7,11 +7,24 @@ pub extern "c" fn mach_absolute_time() u64;
|
||||
pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
|
||||
|
||||
pub extern "c" fn kqueue() c_int;
|
||||
pub extern "c" fn kevent(kq: c_int, changelist: [*]const Kevent, nchanges: c_int,
|
||||
eventlist: [*]Kevent, nevents: c_int, timeout: ?*const timespec) c_int;
|
||||
pub extern "c" fn kevent(
|
||||
kq: c_int,
|
||||
changelist: [*]const Kevent,
|
||||
nchanges: c_int,
|
||||
eventlist: [*]Kevent,
|
||||
nevents: c_int,
|
||||
timeout: ?*const timespec,
|
||||
) c_int;
|
||||
|
||||
pub extern "c" fn kevent64(kq: c_int, changelist: [*]const kevent64_s, nchanges: c_int,
|
||||
eventlist: [*]kevent64_s, nevents: c_int, flags: c_uint, timeout: ?*const timespec) c_int;
|
||||
pub extern "c" fn kevent64(
|
||||
kq: c_int,
|
||||
changelist: [*]const kevent64_s,
|
||||
nchanges: c_int,
|
||||
eventlist: [*]kevent64_s,
|
||||
nevents: c_int,
|
||||
flags: c_uint,
|
||||
timeout: ?*const timespec,
|
||||
) c_int;
|
||||
|
||||
pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
|
||||
pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
|
||||
@ -145,4 +158,3 @@ comptime {
|
||||
assert(@offsetOf(kevent64_s, "udata") == 24);
|
||||
assert(@offsetOf(kevent64_s, "ext") == 32);
|
||||
}
|
||||
|
||||
|
@ -264,17 +264,32 @@ pub const SIGUSR1 = 30;
|
||||
/// user defined signal 2
|
||||
pub const SIGUSR2 = 31;
|
||||
|
||||
pub const KEVENT_FLAG_NONE = 0x000; /// no flag value
|
||||
pub const KEVENT_FLAG_IMMEDIATE = 0x001; /// immediate timeout
|
||||
pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; /// output events only include change
|
||||
/// no flag value
|
||||
pub const KEVENT_FLAG_NONE = 0x000;
|
||||
|
||||
pub const EV_ADD = 0x0001; /// add event to kq (implies enable)
|
||||
pub const EV_DELETE = 0x0002; /// delete event from kq
|
||||
pub const EV_ENABLE = 0x0004; /// enable event
|
||||
pub const EV_DISABLE = 0x0008; /// disable event (not reported)
|
||||
/// immediate timeout
|
||||
pub const KEVENT_FLAG_IMMEDIATE = 0x001;
|
||||
|
||||
pub const EV_ONESHOT = 0x0010; /// only report one occurrence
|
||||
pub const EV_CLEAR = 0x0020; /// clear event state after reporting
|
||||
/// output events only include change
|
||||
pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
|
||||
|
||||
/// add event to kq (implies enable)
|
||||
pub const EV_ADD = 0x0001;
|
||||
|
||||
/// delete event from kq
|
||||
pub const EV_DELETE = 0x0002;
|
||||
|
||||
/// enable event
|
||||
pub const EV_ENABLE = 0x0004;
|
||||
|
||||
/// disable event (not reported)
|
||||
pub const EV_DISABLE = 0x0008;
|
||||
|
||||
/// only report one occurrence
|
||||
pub const EV_ONESHOT = 0x0010;
|
||||
|
||||
/// clear event state after reporting
|
||||
pub const EV_CLEAR = 0x0020;
|
||||
|
||||
/// force immediate event output
|
||||
/// ... with or without EV_ERROR
|
||||
@ -282,8 +297,11 @@ pub const EV_CLEAR = 0x0020; /// clear event state after reporting
|
||||
/// on syscalls supporting flags
|
||||
pub const EV_RECEIPT = 0x0040;
|
||||
|
||||
pub const EV_DISPATCH = 0x0080; /// disable event after reporting
|
||||
pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value
|
||||
/// disable event after reporting
|
||||
pub const EV_DISPATCH = 0x0080;
|
||||
|
||||
/// unique kevent per udata value
|
||||
pub const EV_UDATA_SPECIFIC = 0x0100;
|
||||
|
||||
/// ... in combination with EV_DELETE
|
||||
/// will defer delete until udata-specific
|
||||
@ -295,63 +313,131 @@ pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
|
||||
/// ... only valid with EV_DISPATCH2
|
||||
pub const EV_VANISHED = 0x0200;
|
||||
|
||||
pub const EV_SYSFLAGS = 0xF000; /// reserved by system
|
||||
pub const EV_FLAG0 = 0x1000; /// filter-specific flag
|
||||
pub const EV_FLAG1 = 0x2000; /// filter-specific flag
|
||||
pub const EV_EOF = 0x8000; /// EOF detected
|
||||
pub const EV_ERROR = 0x4000; /// error, data contains errno
|
||||
/// reserved by system
|
||||
pub const EV_SYSFLAGS = 0xF000;
|
||||
|
||||
/// filter-specific flag
|
||||
pub const EV_FLAG0 = 0x1000;
|
||||
|
||||
/// filter-specific flag
|
||||
pub const EV_FLAG1 = 0x2000;
|
||||
|
||||
/// EOF detected
|
||||
pub const EV_EOF = 0x8000;
|
||||
|
||||
/// error, data contains errno
|
||||
pub const EV_ERROR = 0x4000;
|
||||
|
||||
pub const EV_POLL = EV_FLAG0;
|
||||
pub const EV_OOBAND = EV_FLAG1;
|
||||
|
||||
pub const EVFILT_READ = -1;
|
||||
pub const EVFILT_WRITE = -2;
|
||||
pub const EVFILT_AIO = -3; /// attached to aio requests
|
||||
pub const EVFILT_VNODE = -4; /// attached to vnodes
|
||||
pub const EVFILT_PROC = -5; /// attached to struct proc
|
||||
pub const EVFILT_SIGNAL = -6; /// attached to struct proc
|
||||
pub const EVFILT_TIMER = -7; /// timers
|
||||
pub const EVFILT_MACHPORT = -8; /// Mach portsets
|
||||
pub const EVFILT_FS = -9; /// Filesystem events
|
||||
pub const EVFILT_USER = -10; /// User events
|
||||
pub const EVFILT_VM = -12; /// Virtual memory events
|
||||
|
||||
pub const EVFILT_EXCEPT = -15; /// Exception events
|
||||
/// attached to aio requests
|
||||
pub const EVFILT_AIO = -3;
|
||||
|
||||
/// attached to vnodes
|
||||
pub const EVFILT_VNODE = -4;
|
||||
|
||||
/// attached to struct proc
|
||||
pub const EVFILT_PROC = -5;
|
||||
|
||||
/// attached to struct proc
|
||||
pub const EVFILT_SIGNAL = -6;
|
||||
|
||||
/// timers
|
||||
pub const EVFILT_TIMER = -7;
|
||||
|
||||
/// Mach portsets
|
||||
pub const EVFILT_MACHPORT = -8;
|
||||
|
||||
/// Filesystem events
|
||||
pub const EVFILT_FS = -9;
|
||||
|
||||
/// User events
|
||||
pub const EVFILT_USER = -10;
|
||||
|
||||
/// Virtual memory events
|
||||
pub const EVFILT_VM = -12;
|
||||
|
||||
/// Exception events
|
||||
pub const EVFILT_EXCEPT = -15;
|
||||
|
||||
pub const EVFILT_SYSCOUNT = 17;
|
||||
|
||||
/// On input, NOTE_TRIGGER causes the event to be triggered for output.
|
||||
pub const NOTE_TRIGGER = 0x01000000;
|
||||
|
||||
pub const NOTE_FFNOP = 0x00000000; /// ignore input fflags
|
||||
pub const NOTE_FFAND = 0x40000000; /// and fflags
|
||||
pub const NOTE_FFOR = 0x80000000; /// or fflags
|
||||
pub const NOTE_FFCOPY = 0xc0000000; /// copy fflags
|
||||
pub const NOTE_FFCTRLMASK = 0xc0000000; /// mask for operations
|
||||
/// ignore input fflags
|
||||
pub const NOTE_FFNOP = 0x00000000;
|
||||
|
||||
/// and fflags
|
||||
pub const NOTE_FFAND = 0x40000000;
|
||||
|
||||
/// or fflags
|
||||
pub const NOTE_FFOR = 0x80000000;
|
||||
|
||||
/// copy fflags
|
||||
pub const NOTE_FFCOPY = 0xc0000000;
|
||||
|
||||
/// mask for operations
|
||||
pub const NOTE_FFCTRLMASK = 0xc0000000;
|
||||
pub const NOTE_FFLAGSMASK = 0x00ffffff;
|
||||
|
||||
pub const NOTE_LOWAT = 0x00000001; /// low water mark
|
||||
/// low water mark
|
||||
pub const NOTE_LOWAT = 0x00000001;
|
||||
|
||||
pub const NOTE_OOB = 0x00000002; /// OOB data
|
||||
/// OOB data
|
||||
pub const NOTE_OOB = 0x00000002;
|
||||
|
||||
pub const NOTE_DELETE = 0x00000001; /// vnode was removed
|
||||
pub const NOTE_WRITE = 0x00000002; /// data contents changed
|
||||
pub const NOTE_EXTEND = 0x00000004; /// size increased
|
||||
pub const NOTE_ATTRIB = 0x00000008; /// attributes changed
|
||||
pub const NOTE_LINK = 0x00000010; /// link count changed
|
||||
pub const NOTE_RENAME = 0x00000020; /// vnode was renamed
|
||||
pub const NOTE_REVOKE = 0x00000040; /// vnode access was revoked
|
||||
pub const NOTE_NONE = 0x00000080; /// No specific vnode event: to test for EVFILT_READ activation
|
||||
pub const NOTE_FUNLOCK = 0x00000100; /// vnode was unlocked by flock(2)
|
||||
/// vnode was removed
|
||||
pub const NOTE_DELETE = 0x00000001;
|
||||
|
||||
pub const NOTE_EXIT = 0x80000000; /// process exited
|
||||
pub const NOTE_FORK = 0x40000000; /// process forked
|
||||
pub const NOTE_EXEC = 0x20000000; /// process exec'd
|
||||
pub const NOTE_SIGNAL = 0x08000000; /// shared with EVFILT_SIGNAL
|
||||
pub const NOTE_EXITSTATUS = 0x04000000; /// exit status to be returned, valid for child process only
|
||||
pub const NOTE_EXIT_DETAIL = 0x02000000; /// provide details on reasons for exit
|
||||
/// data contents changed
|
||||
pub const NOTE_WRITE = 0x00000002;
|
||||
|
||||
pub const NOTE_PDATAMASK = 0x000fffff; /// mask for signal & exit status
|
||||
/// size increased
|
||||
pub const NOTE_EXTEND = 0x00000004;
|
||||
|
||||
/// attributes changed
|
||||
pub const NOTE_ATTRIB = 0x00000008;
|
||||
|
||||
/// link count changed
|
||||
pub const NOTE_LINK = 0x00000010;
|
||||
|
||||
/// vnode was renamed
|
||||
pub const NOTE_RENAME = 0x00000020;
|
||||
|
||||
/// vnode access was revoked
|
||||
pub const NOTE_REVOKE = 0x00000040;
|
||||
|
||||
/// No specific vnode event: to test for EVFILT_READ activation
|
||||
pub const NOTE_NONE = 0x00000080;
|
||||
|
||||
/// vnode was unlocked by flock(2)
|
||||
pub const NOTE_FUNLOCK = 0x00000100;
|
||||
|
||||
/// process exited
|
||||
pub const NOTE_EXIT = 0x80000000;
|
||||
|
||||
/// process forked
|
||||
pub const NOTE_FORK = 0x40000000;
|
||||
|
||||
/// process exec'd
|
||||
pub const NOTE_EXEC = 0x20000000;
|
||||
|
||||
/// shared with EVFILT_SIGNAL
|
||||
pub const NOTE_SIGNAL = 0x08000000;
|
||||
|
||||
/// exit status to be returned, valid for child process only
|
||||
pub const NOTE_EXITSTATUS = 0x04000000;
|
||||
|
||||
/// provide details on reasons for exit
|
||||
pub const NOTE_EXIT_DETAIL = 0x02000000;
|
||||
|
||||
/// mask for signal & exit status
|
||||
pub const NOTE_PDATAMASK = 0x000fffff;
|
||||
pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
|
||||
|
||||
pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
|
||||
@ -359,23 +445,42 @@ pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
|
||||
pub const NOTE_EXIT_MEMORY = 0x00020000;
|
||||
pub const NOTE_EXIT_CSERROR = 0x00040000;
|
||||
|
||||
/// will react on memory pressure
|
||||
pub const NOTE_VM_PRESSURE = 0x80000000;
|
||||
|
||||
pub const NOTE_VM_PRESSURE = 0x80000000; /// will react on memory pressure
|
||||
pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; /// will quit on memory pressure, possibly after cleaning up dirty state
|
||||
pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; /// will quit immediately on memory pressure
|
||||
pub const NOTE_VM_ERROR = 0x10000000; /// there was an error
|
||||
/// will quit on memory pressure, possibly after cleaning up dirty state
|
||||
pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
|
||||
|
||||
pub const NOTE_SECONDS = 0x00000001; /// data is seconds
|
||||
pub const NOTE_USECONDS = 0x00000002; /// data is microseconds
|
||||
pub const NOTE_NSECONDS = 0x00000004; /// data is nanoseconds
|
||||
pub const NOTE_ABSOLUTE = 0x00000008; /// absolute timeout
|
||||
/// will quit immediately on memory pressure
|
||||
pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
|
||||
|
||||
pub const NOTE_LEEWAY = 0x00000010; /// ext[1] holds leeway for power aware timers
|
||||
pub const NOTE_CRITICAL = 0x00000020; /// system does minimal timer coalescing
|
||||
pub const NOTE_BACKGROUND = 0x00000040; /// system does maximum timer coalescing
|
||||
/// there was an error
|
||||
pub const NOTE_VM_ERROR = 0x10000000;
|
||||
|
||||
/// data is seconds
|
||||
pub const NOTE_SECONDS = 0x00000001;
|
||||
|
||||
/// data is microseconds
|
||||
pub const NOTE_USECONDS = 0x00000002;
|
||||
|
||||
/// data is nanoseconds
|
||||
pub const NOTE_NSECONDS = 0x00000004;
|
||||
|
||||
/// absolute timeout
|
||||
pub const NOTE_ABSOLUTE = 0x00000008;
|
||||
|
||||
/// ext[1] holds leeway for power aware timers
|
||||
pub const NOTE_LEEWAY = 0x00000010;
|
||||
|
||||
/// system does minimal timer coalescing
|
||||
pub const NOTE_CRITICAL = 0x00000020;
|
||||
|
||||
/// system does maximum timer coalescing
|
||||
pub const NOTE_BACKGROUND = 0x00000040;
|
||||
pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
|
||||
pub const NOTE_MACHTIME = 0x00000100; /// data is mach absolute time units
|
||||
|
||||
/// data is mach absolute time units
|
||||
pub const NOTE_MACHTIME = 0x00000100;
|
||||
|
||||
fn wstatus(x: i32) i32 {
|
||||
return x & 0o177;
|
||||
@ -503,12 +608,23 @@ pub fn kqueue() usize {
|
||||
}
|
||||
|
||||
pub fn kevent(kq: i32, changelist: []const Kevent, eventlist: []Kevent, timeout: ?*const timespec) usize {
|
||||
return errnoWrap(c.kevent(kq, changelist.ptr, @intCast(c_int, changelist.len), eventlist.ptr, @intCast(c_int, eventlist.len), timeout,));
|
||||
return errnoWrap(c.kevent(
|
||||
kq,
|
||||
changelist.ptr,
|
||||
@intCast(c_int, changelist.len),
|
||||
eventlist.ptr,
|
||||
@intCast(c_int, eventlist.len),
|
||||
timeout,
|
||||
));
|
||||
}
|
||||
|
||||
pub fn kevent64(kq: i32, changelist: []const kevent64_s, eventlist: []kevent64_s, flags: u32,
|
||||
timeout: ?*const timespec) usize
|
||||
{
|
||||
pub fn kevent64(
|
||||
kq: i32,
|
||||
changelist: []const kevent64_s,
|
||||
eventlist: []kevent64_s,
|
||||
flags: u32,
|
||||
timeout: ?*const timespec,
|
||||
) usize {
|
||||
return errnoWrap(c.kevent64(kq, changelist.ptr, changelist.len, eventlist.ptr, eventlist.len, flags, timeout));
|
||||
}
|
||||
|
||||
|
@ -2845,9 +2845,12 @@ pub const BsdKEventError = error {
|
||||
ProcessNotFound,
|
||||
};
|
||||
|
||||
pub fn bsdKEvent(kq: i32, changelist: []const posix.Kevent, eventlist: []posix.Kevent,
|
||||
timeout: ?*const posix.timespec) BsdKEventError!usize
|
||||
{
|
||||
pub fn bsdKEvent(
|
||||
kq: i32,
|
||||
changelist: []const posix.Kevent,
|
||||
eventlist: []posix.Kevent,
|
||||
timeout: ?*const posix.timespec,
|
||||
) BsdKEventError!usize {
|
||||
while (true) {
|
||||
const rc = posix.kevent(kq, changelist, eventlist, timeout);
|
||||
const err = posix.getErrno(rc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user