Skip to content

Commit

Permalink
Auto merge of #379 - asomers:evfilt, r=alexcrichton
Browse files Browse the repository at this point in the history
Move kqueue-related definitions from nix to libc

This PR moves, as much as possible, kqueue and kevent related definitions from the nix crate to libc.  There will be a companion PR to the nix repo.
  • Loading branch information
bors authored Sep 9, 2016
2 parents d4f6a19 + 38c4b8b commit b641737
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 65 deletions.
90 changes: 61 additions & 29 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,46 +1001,78 @@ pub const FD_SETSIZE: usize = 1024;

pub const ST_NOSUID: ::c_ulong = 2;

pub const EVFILT_AIO: ::int16_t = 0xfffd;
pub const EVFILT_PROC: ::int16_t = 0xfffb;
pub const EVFILT_READ: ::int16_t = 0xffff;
pub const EVFILT_SIGNAL: ::int16_t = 0xfffa;
pub const EVFILT_SYSCOUNT: ::int16_t = 0xe;
pub const EVFILT_TIMER: ::int16_t = 0xfff9;
pub const EVFILT_VNODE: ::int16_t = 0xfffc;
pub const EVFILT_WRITE: ::int16_t = 0xfffe;
pub const EVFILT_FS: ::int16_t = 0xfff7;
pub const EVFILT_MACHPORT: ::int16_t = 0xfff8;
pub const EVFILT_USER: ::int16_t = 0xfff6;
pub const EVFILT_VM: ::int16_t = 0xfff4;

pub const EVFILT_READ: ::int16_t = -1;
pub const EVFILT_WRITE: ::int16_t = -2;
pub const EVFILT_AIO: ::int16_t = -3;
pub const EVFILT_VNODE: ::int16_t = -4;
pub const EVFILT_PROC: ::int16_t = -5;
pub const EVFILT_SIGNAL: ::int16_t = -6;
pub const EVFILT_TIMER: ::int16_t = -7;
pub const EVFILT_MACHPORT: ::int16_t = -8;
pub const EVFILT_FS: ::int16_t = -9;
pub const EVFILT_USER: ::int16_t = -10;
pub const EVFILT_VM: ::int16_t = -12;

pub const EV_ADD: ::uint16_t = 0x1;
pub const EV_DELETE: ::uint16_t = 0x2;
pub const EV_ENABLE: ::uint16_t = 0x4;
pub const EV_DISABLE: ::uint16_t = 0x8;
pub const EV_ONESHOT: ::uint16_t = 0x10;
pub const EV_CLEAR: ::uint16_t = 0x20;
pub const EV_RECEIPT: ::uint16_t = 0x40;
pub const EV_DISPATCH: ::uint16_t = 0x80;
pub const EV_FLAG0: ::uint16_t = 0x1000;
pub const EV_OOBAND: ::uint16_t = 0x2000;
pub const EV_POLL: ::uint16_t = 0x1000;
pub const EV_RECEIPT: ::uint16_t = 0x40;
pub const EV_FLAG1: ::uint16_t = 0x2000;
pub const EV_OOBAND: ::uint16_t = 0x2000;
pub const EV_ERROR: ::uint16_t = 0x4000;
pub const EV_EOF: ::uint16_t = 0x8000;
pub const EV_SYSFLAGS: ::uint16_t = 0xf000;

pub const NOTE_ABSOLUTE: ::uint32_t = 0x8;
pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000;
pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000;
pub const NOTE_TRIGGER: ::uint32_t = 0x01000000;
pub const NOTE_FFNOP: ::uint32_t = 0x00000000;
pub const NOTE_FFAND: ::uint32_t = 0x40000000;
pub const NOTE_FFOR: ::uint32_t = 0x80000000;
pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000;
pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000;
pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff;
pub const NOTE_FFNOP: ::uint32_t = 0x0;
pub const NOTE_FFOR: ::uint32_t = 0x80000000;
pub const NOTE_NONE: ::uint32_t = 0x80;
pub const NOTE_NSECONDS: ::uint32_t = 0x4;
pub const NOTE_LOWAT: ::uint32_t = 0x00000001;
pub const NOTE_DELETE: ::uint32_t = 0x00000001;
pub const NOTE_WRITE: ::uint32_t = 0x00000002;
pub const NOTE_EXTEND: ::uint32_t = 0x00000004;
pub const NOTE_ATTRIB: ::uint32_t = 0x00000008;
pub const NOTE_LINK: ::uint32_t = 0x00000010;
pub const NOTE_RENAME: ::uint32_t = 0x00000020;
pub const NOTE_REVOKE: ::uint32_t = 0x00000040;
pub const NOTE_NONE: ::uint32_t = 0x00000080;
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
pub const NOTE_FORK: ::uint32_t = 0x40000000;
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
pub const NOTE_REAP: ::uint32_t = 0x10000000;
pub const NOTE_SECONDS: ::uint32_t = 0x1;
pub const NOTE_SIGNAL: ::uint32_t = 0x8000000;
pub const NOTE_TRIGGER: ::uint32_t = 0x01000000;
pub const NOTE_USECONDS: ::uint32_t = 0x2;
pub const NOTE_VM_ERROR: ::uint32_t = 0x10000000;
pub const NOTE_SIGNAL: ::uint32_t = 0x08000000;
pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000;
pub const NOTE_EXIT_DETAIL: ::uint32_t = 0x02000000;
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000;
pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000;
pub const NOTE_EXIT_DETAIL_MASK: ::uint32_t = 0x00070000;
pub const NOTE_EXIT_DECRYPTFAIL: ::uint32_t = 0x00010000;
pub const NOTE_EXIT_MEMORY: ::uint32_t = 0x00020000;
pub const NOTE_EXIT_CSERROR: ::uint32_t = 0x00040000;
pub const NOTE_VM_PRESSURE: ::uint32_t = 0x80000000;
pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: ::uint32_t = 0x20000000;
pub const NOTE_VM_PRESSURE_TERMINATE: ::uint32_t = 0x40000000;
pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000;
pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: ::uint32_t = 0x20000000;
pub const NOTE_VM_ERROR: ::uint32_t = 0x10000000;
pub const NOTE_SECONDS: ::uint32_t = 0x00000001;
pub const NOTE_USECONDS: ::uint32_t = 0x00000002;
pub const NOTE_NSECONDS: ::uint32_t = 0x00000004;
pub const NOTE_ABSOLUTE: ::uint32_t = 0x00000008;
pub const NOTE_LEEWAY: ::uint32_t = 0x00000010;
pub const NOTE_CRITICAL: ::uint32_t = 0x00000020;
pub const NOTE_BACKGROUND: ::uint32_t = 0x00000040;
pub const NOTE_TRACK: ::uint32_t = 0x00000001;
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
pub const NOTE_CHILD: ::uint32_t = 0x00000004;

pub const NL0: ::c_int = 0x00000000;
pub const NL1: ::c_int = 0x00000100;
Expand Down
50 changes: 50 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,56 @@ pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24;
pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25;
pub const CTL_P1003_1B_MAXID: ::c_int = 26;

pub const EVFILT_READ: ::int16_t = -1;
pub const EVFILT_WRITE: ::int16_t = -2;
pub const EVFILT_AIO: ::int16_t = -3;
pub const EVFILT_VNODE: ::int16_t = -4;
pub const EVFILT_PROC: ::int16_t = -5;
pub const EVFILT_SIGNAL: ::int16_t = -6;
pub const EVFILT_TIMER: ::int16_t = -7;
pub const EVFILT_PROCDESC: ::int16_t = -8;
pub const EVFILT_USER: ::int16_t = -9;
pub const EVFILT_FS: ::int16_t = -10;

pub const EV_ADD: ::uint16_t = 0x1;
pub const EV_DELETE: ::uint16_t = 0x2;
pub const EV_ENABLE: ::uint16_t = 0x4;
pub const EV_DISABLE: ::uint16_t = 0x8;
pub const EV_ONESHOT: ::uint16_t = 0x10;
pub const EV_CLEAR: ::uint16_t = 0x20;
pub const EV_RECEIPT: ::uint16_t = 0x40;
pub const EV_DISPATCH: ::uint16_t = 0x80;
pub const EV_NODATA: ::uint16_t = 0x1000;
pub const EV_FLAG1: ::uint16_t = 0x2000;
pub const EV_ERROR: ::uint16_t = 0x4000;
pub const EV_EOF: ::uint16_t = 0x8000;
pub const EV_SYSFLAGS: ::uint16_t = 0xf000;

pub const NOTE_TRIGGER: ::uint32_t = 0x01000000;
pub const NOTE_FFNOP: ::uint32_t = 0x00000000;
pub const NOTE_FFAND: ::uint32_t = 0x40000000;
pub const NOTE_FFOR: ::uint32_t = 0x80000000;
pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000;
pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000;
pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff;
pub const NOTE_LOWAT: ::uint32_t = 0x00000001;
pub const NOTE_OOB: ::uint32_t = 0x00000002;
pub const NOTE_DELETE: ::uint32_t = 0x00000001;
pub const NOTE_WRITE: ::uint32_t = 0x00000002;
pub const NOTE_EXTEND: ::uint32_t = 0x00000004;
pub const NOTE_ATTRIB: ::uint32_t = 0x00000008;
pub const NOTE_LINK: ::uint32_t = 0x00000010;
pub const NOTE_RENAME: ::uint32_t = 0x00000020;
pub const NOTE_REVOKE: ::uint32_t = 0x00000040;
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
pub const NOTE_FORK: ::uint32_t = 0x40000000;
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000;
pub const NOTE_TRACK: ::uint32_t = 0x00000001;
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
pub const NOTE_CHILD: ::uint32_t = 0x00000004;

extern {
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
Expand Down
53 changes: 53 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,59 @@ pub const POSIX_FADV_WILLNEED: ::c_int = 3;
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
pub const POSIX_FADV_NOREUSE: ::c_int = 5;

pub const EVFILT_READ: ::int16_t = -1;
pub const EVFILT_WRITE: ::int16_t = -2;
pub const EVFILT_AIO: ::int16_t = -3;
pub const EVFILT_VNODE: ::int16_t = -4;
pub const EVFILT_PROC: ::int16_t = -5;
pub const EVFILT_SIGNAL: ::int16_t = -6;
pub const EVFILT_TIMER: ::int16_t = -7;
pub const EVFILT_FS: ::int16_t = -9;
pub const EVFILT_LIO: ::int16_t = -10;
pub const EVFILT_USER: ::int16_t = -11;

pub const EV_ADD: ::uint16_t = 0x1;
pub const EV_DELETE: ::uint16_t = 0x2;
pub const EV_ENABLE: ::uint16_t = 0x4;
pub const EV_DISABLE: ::uint16_t = 0x8;
pub const EV_ONESHOT: ::uint16_t = 0x10;
pub const EV_CLEAR: ::uint16_t = 0x20;
pub const EV_RECEIPT: ::uint16_t = 0x40;
pub const EV_DISPATCH: ::uint16_t = 0x80;
pub const EV_DROP: ::uint16_t = 0x1000;
pub const EV_FLAG1: ::uint16_t = 0x2000;
pub const EV_ERROR: ::uint16_t = 0x4000;
pub const EV_EOF: ::uint16_t = 0x8000;
pub const EV_SYSFLAGS: ::uint16_t = 0xf000;

pub const NOTE_TRIGGER: ::uint32_t = 0x01000000;
pub const NOTE_FFNOP: ::uint32_t = 0x00000000;
pub const NOTE_FFAND: ::uint32_t = 0x40000000;
pub const NOTE_FFOR: ::uint32_t = 0x80000000;
pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000;
pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000;
pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff;
pub const NOTE_LOWAT: ::uint32_t = 0x00000001;
pub const NOTE_DELETE: ::uint32_t = 0x00000001;
pub const NOTE_WRITE: ::uint32_t = 0x00000002;
pub const NOTE_EXTEND: ::uint32_t = 0x00000004;
pub const NOTE_ATTRIB: ::uint32_t = 0x00000008;
pub const NOTE_LINK: ::uint32_t = 0x00000010;
pub const NOTE_RENAME: ::uint32_t = 0x00000020;
pub const NOTE_REVOKE: ::uint32_t = 0x00000040;
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
pub const NOTE_FORK: ::uint32_t = 0x40000000;
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000;
pub const NOTE_TRACK: ::uint32_t = 0x00000001;
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
pub const NOTE_CHILD: ::uint32_t = 0x00000004;
pub const NOTE_SECONDS: ::uint32_t = 0x00000001;
pub const NOTE_MSECONDS: ::uint32_t = 0x00000002;
pub const NOTE_USECONDS: ::uint32_t = 0x00000004;
pub const NOTE_NSECONDS: ::uint32_t = 0x00000008;

pub const MADV_PROTECT: ::c_int = 10;
pub const RUSAGE_THREAD: ::c_int = 1;

Expand Down
15 changes: 15 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ s! {
__unused8: *mut ::c_void,
}

pub struct kevent {
pub ident: ::uintptr_t,
pub filter: ::c_short,
pub flags: ::c_ushort,
pub fflags: ::c_uint,
pub data: ::intptr_t,
pub udata: *mut ::c_void,
}

pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: ::sa_family_t,
Expand Down Expand Up @@ -743,6 +752,12 @@ extern {
serv: *mut ::c_char,
servlen: ::size_t,
flags: ::c_int) -> ::c_int;
pub fn kevent(kq: ::c_int,
changelist: *const ::kevent,
nchanges: ::c_int,
eventlist: *mut ::kevent,
nevents: ::c_int,
timeout: *const ::timespec) -> ::c_int;
pub fn mincore(addr: *const ::c_void, len: ::size_t,
vec: *mut ::c_char) -> ::c_int;
pub fn sysctlnametomib(name: *const ::c_char,
Expand Down
27 changes: 0 additions & 27 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,33 +179,6 @@ pub const IPV6_V6ONLY: ::c_int = 27;

pub const ST_RDONLY: ::c_ulong = 1;

pub const EV_ADD: ::uint16_t = 0x1;
pub const EV_CLEAR: ::uint16_t = 0x20;
pub const EV_DELETE: ::uint16_t = 0x2;
pub const EV_DISABLE: ::uint16_t = 0x8;
pub const EV_ENABLE: ::uint16_t = 0x4;
pub const EV_EOF: ::uint16_t = 0x8000;
pub const EV_ERROR: ::uint16_t = 0x4000;
pub const EV_FLAG1: ::uint16_t = 0x2000;
pub const EV_ONESHOT: ::uint16_t = 0x10;
pub const EV_SYSFLAGS: ::uint16_t = 0xf000;

pub const NOTE_ATTRIB: ::uint32_t = 0x8;
pub const NOTE_CHILD: ::uint32_t = 0x4;
pub const NOTE_DELETE: ::uint32_t = 0x1;
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
pub const NOTE_EXTEND: ::uint32_t = 0x4;
pub const NOTE_FORK: ::uint32_t = 0x40000000;
pub const NOTE_LINK: ::uint32_t = 0x10;
pub const NOTE_LOWAT: ::uint32_t = 0x1;
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
pub const NOTE_RENAME: ::uint32_t = 0x20;
pub const NOTE_REVOKE: ::uint32_t = 0x40;
pub const NOTE_TRACK: ::uint32_t = 0x1;
pub const NOTE_TRACKERR: ::uint32_t = 0x2;
pub const NOTE_WRITE: ::uint32_t = 0x2;

pub const NCCS: usize = 20;

pub const O_ASYNC: ::c_int = 0x40;
Expand Down
53 changes: 53 additions & 0 deletions src/unix/bsd/openbsdlike/bitrig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ s! {
__unused7: *mut ::c_void,
}

pub struct kevent {
pub ident: ::uintptr_t,
pub filter: ::c_short,
pub flags: ::c_ushort,
pub fflags: ::c_uint,
pub data: ::int64_t,
pub udata: *mut ::c_void,
}

pub struct stat {
pub st_mode: ::mode_t,
pub st_dev: ::dev_t,
Expand Down Expand Up @@ -278,6 +287,44 @@ pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4;
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP;

pub const EVFILT_AIO: ::int16_t = -3;
pub const EVFILT_PROC: ::int16_t = -5;
pub const EVFILT_READ: ::int16_t = -1;
pub const EVFILT_SIGNAL: ::int16_t = -6;
pub const EVFILT_TIMER: ::int16_t = -7;
pub const EVFILT_VNODE: ::int16_t = -4;
pub const EVFILT_WRITE: ::int16_t = -2;

pub const EV_ADD: ::uint16_t = 0x1;
pub const EV_DELETE: ::uint16_t = 0x2;
pub const EV_ENABLE: ::uint16_t = 0x4;
pub const EV_DISABLE: ::uint16_t = 0x8;
pub const EV_ONESHOT: ::uint16_t = 0x10;
pub const EV_CLEAR: ::uint16_t = 0x20;
pub const EV_FLAG1: ::uint16_t = 0x2000;
pub const EV_ERROR: ::uint16_t = 0x4000;
pub const EV_EOF: ::uint16_t = 0x8000;
pub const EV_SYSFLAGS: ::uint16_t = 0xf000;

pub const NOTE_LOWAT: ::uint32_t = 0x00000001;
pub const NOTE_EOF: ::uint32_t = 0x00000002;
pub const NOTE_DELETE: ::uint32_t = 0x00000001;
pub const NOTE_WRITE: ::uint32_t = 0x00000002;
pub const NOTE_EXTEND: ::uint32_t = 0x00000004;
pub const NOTE_ATTRIB: ::uint32_t = 0x00000008;
pub const NOTE_LINK: ::uint32_t = 0x00000010;
pub const NOTE_RENAME: ::uint32_t = 0x00000020;
pub const NOTE_REVOKE: ::uint32_t = 0x00000040;
pub const NOTE_TRUNCATE: ::uint32_t = 0x00000080;
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
pub const NOTE_FORK: ::uint32_t = 0x40000000;
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000;
pub const NOTE_TRACK: ::uint32_t = 0x00000001;
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
pub const NOTE_CHILD: ::uint32_t = 0x00000004;

pub const TMP_MAX : ::c_uint = 0x7fffffff;

pub const NI_MAXHOST: ::size_t = 256;
Expand Down Expand Up @@ -407,6 +454,12 @@ extern {
serv: *mut ::c_char,
servlen: ::size_t,
flags: ::c_int) -> ::c_int;
pub fn kevent(kq: ::c_int,
changelist: *const ::kevent,
nchanges: ::c_int,
eventlist: *mut ::kevent,
nevents: ::c_int,
timeout: *const ::timespec) -> ::c_int;
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn pthread_main_np() -> ::c_int;
Expand Down
Loading

0 comments on commit b641737

Please sign in to comment.