Commit 1bbfcb95ab

Andrew Kelley <andrew@ziglang.org>
2021-08-25 02:21:53
std: reorganize std.c to eliminate `usingnamespace`
Behavior tests pass on x86_64-linux with -lc
1 parent 3deda15
lib/std/c/darwin.zig
@@ -3,6 +3,7 @@ const assert = std.debug.assert;
 const builtin = @import("builtin");
 const macho = std.macho;
 const native_arch = builtin.target.cpu.arch;
+const maxInt = std.math.maxInt;
 
 extern "c" fn __error() *c_int;
 pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
@@ -21,20 +22,25 @@ pub const copyfile_state_t = *opaque {};
 pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int;
 
 pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
+pub const realpath = @"realpath$DARWIN_EXTSN";
 
 pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize;
 
-extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
-/// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to force 64bit version.
-/// Note that this is fixed on aarch64 and no longer necessary.
-extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *libc_stat) c_int;
-pub const _fstat = if (native_arch == .aarch64) fstat else @"fstat$INODE64";
+const private = struct {
+    extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
+    /// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to
+    /// force 64bit version.
+    /// Note that this is fixed on aarch64 and no longer necessary.
+    extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;
 
-extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
-/// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to force 64bit version.
-/// Note that this is fixed on aarch64 and no longer necessary.
-extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *libc_stat, flags: u32) c_int;
-pub const _fstatat = if (native_arch == .aarch64) fstatat else @"fstatat$INODE64";
+    extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
+    /// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to
+    /// force 64bit version.
+    /// Note that this is fixed on aarch64 and no longer necessary.
+    extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *Stat, flags: u32) c_int;
+};
+pub const fstat = if (native_arch == .aarch64) private.fstat else private.@"fstat$INODE64";
+pub const fstatat = if (native_arch == .aarch64) private.fstatat else private.@"fstatat$INODE64";
 
 pub extern "c" fn mach_absolute_time() u64;
 pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
@@ -254,3 +260,1799 @@ pub extern "c" fn os_unfair_lock_unlock(o: os_unfair_lock_t) void;
 pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool;
 pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void;
 pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void;
+
+// XXX: close -> close$NOCANCEL
+// XXX: getdirentries -> _getdirentries64
+pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
+pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub extern "c" fn sched_yield() c_int;
+pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
+pub extern "c" fn sigfillset(set: ?*sigset_t) void;
+pub extern "c" fn alarm(seconds: c_uint) c_uint;
+pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
+
+// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
+// TODO: audit mode_t/pid_t, should likely be u16/i32
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+pub const mode_t = c_uint;
+pub const uid_t = u32;
+pub const gid_t = u32;
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+pub const socklen_t = u32;
+pub const sockaddr = extern struct {
+    len: u8,
+    family: sa_family_t,
+    data: [14]u8,
+};
+pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+pub const sockaddr_in = extern struct {
+    len: u8 = @sizeOf(sockaddr_in),
+    family: sa_family_t = AF_INET,
+    port: in_port_t,
+    addr: u32,
+    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+};
+pub const sockaddr_in6 = extern struct {
+    len: u8 = @sizeOf(sockaddr_in6),
+    family: sa_family_t = AF_INET6,
+    port: in_port_t,
+    flowinfo: u32,
+    addr: [16]u8,
+    scope_id: u32,
+};
+
+/// UNIX domain socket
+pub const sockaddr_un = extern struct {
+    len: u8 = @sizeOf(sockaddr_un),
+    family: sa_family_t = AF_UNIX,
+    path: [104]u8,
+};
+
+pub const timeval = extern struct {
+    tv_sec: c_long,
+    tv_usec: i32,
+};
+
+pub const timezone = extern struct {
+    tz_minuteswest: i32,
+    tz_dsttime: i32,
+};
+
+pub const mach_timebase_info_data = extern struct {
+    numer: u32,
+    denom: u32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+
+pub const Flock = extern struct {
+    l_start: off_t,
+    l_len: off_t,
+    l_pid: pid_t,
+    l_type: i16,
+    l_whence: i16,
+};
+
+pub const Stat = extern struct {
+    dev: i32,
+    mode: u16,
+    nlink: u16,
+    ino: ino_t,
+    uid: uid_t,
+    gid: gid_t,
+    rdev: i32,
+    atimesec: isize,
+    atimensec: isize,
+    mtimesec: isize,
+    mtimensec: isize,
+    ctimesec: isize,
+    ctimensec: isize,
+    birthtimesec: isize,
+    birthtimensec: isize,
+    size: off_t,
+    blocks: i64,
+    blksize: i32,
+    flags: u32,
+    gen: u32,
+    lspare: i32,
+    qspare: [2]i64,
+
+    pub fn atime(self: @This()) timespec {
+        return timespec{
+            .tv_sec = self.atimesec,
+            .tv_nsec = self.atimensec,
+        };
+    }
+
+    pub fn mtime(self: @This()) timespec {
+        return timespec{
+            .tv_sec = self.mtimesec,
+            .tv_nsec = self.mtimensec,
+        };
+    }
+
+    pub fn ctime(self: @This()) timespec {
+        return timespec{
+            .tv_sec = self.ctimesec,
+            .tv_nsec = self.ctimensec,
+        };
+    }
+};
+
+pub const timespec = extern struct {
+    tv_sec: isize,
+    tv_nsec: isize,
+};
+
+pub const sigset_t = u32;
+pub const empty_sigset: sigset_t = 0;
+
+pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
+
+pub const siginfo_t = extern struct {
+    signo: c_int,
+    errno: c_int,
+    code: c_int,
+    pid: pid_t,
+    uid: uid_t,
+    status: c_int,
+    addr: *c_void,
+    value: extern union {
+        int: c_int,
+        ptr: *c_void,
+    },
+    si_band: c_long,
+    _pad: [7]c_ulong,
+};
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
+pub const Sigaction = extern struct {
+    pub const handler_fn = fn (c_int) callconv(.C) void;
+    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+    handler: extern union {
+        handler: ?handler_fn,
+        sigaction: ?sigaction_fn,
+    },
+    mask: sigset_t,
+    flags: c_uint,
+};
+
+pub const dirent = extern struct {
+    d_ino: usize,
+    d_seekoff: usize,
+    d_reclen: u16,
+    d_namlen: u16,
+    d_type: u8,
+    d_name: u8, // field address is address of first byte of name
+
+    pub fn reclen(self: dirent) u16 {
+        return self.d_reclen;
+    }
+};
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+    ident: usize,
+    filter: i16,
+    flags: u16,
+    fflags: u32,
+    data: isize,
+    udata: usize,
+};
+
+// sys/types.h on macos uses #pragma pack(4) so these checks are
+// to make sure the struct is laid out the same. These values were
+// produced from C code using the offsetof macro.
+comptime {
+    assert(@offsetOf(Kevent, "ident") == 0);
+    assert(@offsetOf(Kevent, "filter") == 8);
+    assert(@offsetOf(Kevent, "flags") == 10);
+    assert(@offsetOf(Kevent, "fflags") == 12);
+    assert(@offsetOf(Kevent, "data") == 16);
+    assert(@offsetOf(Kevent, "udata") == 24);
+}
+
+pub const kevent64_s = extern struct {
+    ident: u64,
+    filter: i16,
+    flags: u16,
+    fflags: u32,
+    data: i64,
+    udata: u64,
+    ext: [2]u64,
+};
+
+// sys/types.h on macos uses #pragma pack() so these checks are
+// to make sure the struct is laid out the same. These values were
+// produced from C code using the offsetof macro.
+comptime {
+    assert(@offsetOf(kevent64_s, "ident") == 0);
+    assert(@offsetOf(kevent64_s, "filter") == 8);
+    assert(@offsetOf(kevent64_s, "flags") == 10);
+    assert(@offsetOf(kevent64_s, "fflags") == 12);
+    assert(@offsetOf(kevent64_s, "data") == 16);
+    assert(@offsetOf(kevent64_s, "udata") == 24);
+    assert(@offsetOf(kevent64_s, "ext") == 32);
+}
+
+pub const mach_port_t = c_uint;
+pub const clock_serv_t = mach_port_t;
+pub const clock_res_t = c_int;
+pub const mach_port_name_t = natural_t;
+pub const natural_t = c_uint;
+pub const mach_timespec_t = extern struct {
+    tv_sec: c_uint,
+    tv_nsec: clock_res_t,
+};
+pub const kern_return_t = c_int;
+pub const host_t = mach_port_t;
+pub const CALENDAR_CLOCK = 1;
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = 16;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+/// [MC2] no permissions
+pub const PROT_NONE = 0x00;
+
+/// [MC2] pages can be read
+pub const PROT_READ = 0x01;
+
+/// [MC2] pages can be written
+pub const PROT_WRITE = 0x02;
+
+/// [MC2] pages can be executed
+pub const PROT_EXEC = 0x04;
+
+/// allocated from memory, swap space
+pub const MAP_ANONYMOUS = 0x1000;
+
+/// map from file (default)
+pub const MAP_FILE = 0x0000;
+
+/// interpret addr exactly
+pub const MAP_FIXED = 0x0010;
+
+/// region may contain semaphores
+pub const MAP_HASSEMAPHORE = 0x0200;
+
+/// changes are private
+pub const MAP_PRIVATE = 0x0002;
+
+/// share changes
+pub const MAP_SHARED = 0x0001;
+
+/// don't cache pages for this mapping
+pub const MAP_NOCACHE = 0x0400;
+
+/// don't reserve needed swap area
+pub const MAP_NORESERVE = 0x0040;
+pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+
+/// [XSI] no hang in wait/no child to reap
+pub const WNOHANG = 0x00000001;
+
+/// [XSI] notify on stop, untraced child
+pub const WUNTRACED = 0x00000002;
+
+/// take signal on signal stack
+pub const SA_ONSTACK = 0x0001;
+
+/// restart system on signal return
+pub const SA_RESTART = 0x0002;
+
+/// reset to SIG_DFL when taking signal
+pub const SA_RESETHAND = 0x0004;
+
+/// do not generate SIGCHLD on child stop
+pub const SA_NOCLDSTOP = 0x0008;
+
+/// don't mask the signal we're delivering
+pub const SA_NODEFER = 0x0010;
+
+/// don't keep zombies around
+pub const SA_NOCLDWAIT = 0x0020;
+
+/// signal handler with SA_SIGINFO args
+pub const SA_SIGINFO = 0x0040;
+
+/// do not bounce off kernel's sigtramp
+pub const SA_USERTRAMP = 0x0100;
+
+/// signal handler with SA_SIGINFO args with 64bit   regs information
+pub const SA_64REGSET = 0x0200;
+
+pub const O_PATH = 0x0000;
+
+pub const F_OK = 0;
+pub const X_OK = 1;
+pub const W_OK = 2;
+pub const R_OK = 4;
+
+/// open for reading only
+pub const O_RDONLY = 0x0000;
+
+/// open for writing only
+pub const O_WRONLY = 0x0001;
+
+/// open for reading and writing
+pub const O_RDWR = 0x0002;
+
+/// do not block on open or for data to become available
+pub const O_NONBLOCK = 0x0004;
+
+/// append on each write
+pub const O_APPEND = 0x0008;
+
+/// create file if it does not exist
+pub const O_CREAT = 0x0200;
+
+/// truncate size to 0
+pub const O_TRUNC = 0x0400;
+
+/// error if O_CREAT and the file exists
+pub const O_EXCL = 0x0800;
+
+/// atomically obtain a shared lock
+pub const O_SHLOCK = 0x0010;
+
+/// atomically obtain an exclusive lock
+pub const O_EXLOCK = 0x0020;
+
+/// do not follow symlinks
+pub const O_NOFOLLOW = 0x0100;
+
+/// allow open of symlinks
+pub const O_SYMLINK = 0x200000;
+
+/// descriptor requested for event notifications only
+pub const O_EVTONLY = 0x8000;
+
+/// mark as close-on-exec
+pub const O_CLOEXEC = 0x1000000;
+
+pub const O_ACCMODE = 3;
+pub const O_ALERT = 536870912;
+pub const O_ASYNC = 64;
+pub const O_DIRECTORY = 1048576;
+pub const O_DP_GETRAWENCRYPTED = 1;
+pub const O_DP_GETRAWUNENCRYPTED = 2;
+pub const O_DSYNC = 4194304;
+pub const O_FSYNC = O_SYNC;
+pub const O_NOCTTY = 131072;
+pub const O_POPUP = 2147483648;
+pub const O_SYNC = 128;
+
+pub const SEEK_SET = 0x0;
+pub const SEEK_CUR = 0x1;
+pub const SEEK_END = 0x2;
+
+pub const DT_UNKNOWN = 0;
+pub const DT_FIFO = 1;
+pub const DT_CHR = 2;
+pub const DT_DIR = 4;
+pub const DT_BLK = 6;
+pub const DT_REG = 8;
+pub const DT_LNK = 10;
+pub const DT_SOCK = 12;
+pub const DT_WHT = 14;
+
+/// block specified signal set
+pub const SIG_BLOCK = 1;
+
+/// unblock specified signal set
+pub const SIG_UNBLOCK = 2;
+
+/// set specified signal set
+pub const SIG_SETMASK = 3;
+
+/// hangup
+pub const SIGHUP = 1;
+
+/// interrupt
+pub const SIGINT = 2;
+
+/// quit
+pub const SIGQUIT = 3;
+
+/// illegal instruction (not reset when caught)
+pub const SIGILL = 4;
+
+/// trace trap (not reset when caught)
+pub const SIGTRAP = 5;
+
+/// abort()
+pub const SIGABRT = 6;
+
+/// pollable event ([XSR] generated, not supported)
+pub const SIGPOLL = 7;
+
+/// compatibility
+pub const SIGIOT = SIGABRT;
+
+/// EMT instruction
+pub const SIGEMT = 7;
+
+/// floating point exception
+pub const SIGFPE = 8;
+
+/// kill (cannot be caught or ignored)
+pub const SIGKILL = 9;
+
+/// bus error
+pub const SIGBUS = 10;
+
+/// segmentation violation
+pub const SIGSEGV = 11;
+
+/// bad argument to system call
+pub const SIGSYS = 12;
+
+/// write on a pipe with no one to read it
+pub const SIGPIPE = 13;
+
+/// alarm clock
+pub const SIGALRM = 14;
+
+/// software termination signal from kill
+pub const SIGTERM = 15;
+
+/// urgent condition on IO channel
+pub const SIGURG = 16;
+
+/// sendable stop signal not from tty
+pub const SIGSTOP = 17;
+
+/// stop signal from tty
+pub const SIGTSTP = 18;
+
+/// continue a stopped process
+pub const SIGCONT = 19;
+
+/// to parent on child stop or exit
+pub const SIGCHLD = 20;
+
+/// to readers pgrp upon background tty read
+pub const SIGTTIN = 21;
+
+/// like TTIN for output if (tp->t_local&LTOSTOP)
+pub const SIGTTOU = 22;
+
+/// input/output possible signal
+pub const SIGIO = 23;
+
+/// exceeded CPU time limit
+pub const SIGXCPU = 24;
+
+/// exceeded file size limit
+pub const SIGXFSZ = 25;
+
+/// virtual time alarm
+pub const SIGVTALRM = 26;
+
+/// profiling time alarm
+pub const SIGPROF = 27;
+
+/// window size changes
+pub const SIGWINCH = 28;
+
+/// information request
+pub const SIGINFO = 29;
+
+/// user defined signal 1
+pub const SIGUSR1 = 30;
+
+/// user defined signal 2
+pub const SIGUSR2 = 31;
+
+/// no flag value
+pub const KEVENT_FLAG_NONE = 0x000;
+
+/// immediate timeout
+pub const KEVENT_FLAG_IMMEDIATE = 0x001;
+
+/// 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
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+///     on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// 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
+/// event enabled. EINPROGRESS will be
+/// returned to indicate the deferral
+pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
+
+/// report that source has vanished
+/// ... only valid with EV_DISPATCH2
+pub const EV_VANISHED = 0x0200;
+
+/// 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;
+
+/// 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;
+
+/// 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;
+
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// OOB data
+pub const NOTE_OOB = 0x00000002;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// 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;
+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;
+
+/// will quit on memory       pressure, possibly after cleaning up dirty state
+pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
+
+/// will quit immediately on      memory pressure
+pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
+
+/// 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;
+
+/// data is mach absolute time units
+pub const NOTE_MACHTIME = 0x00000100;
+
+pub const AF_UNSPEC = 0;
+pub const AF_LOCAL = 1;
+pub const AF_UNIX = AF_LOCAL;
+pub const AF_INET = 2;
+pub const AF_SYS_CONTROL = 2;
+pub const AF_IMPLINK = 3;
+pub const AF_PUP = 4;
+pub const AF_CHAOS = 5;
+pub const AF_NS = 6;
+pub const AF_ISO = 7;
+pub const AF_OSI = AF_ISO;
+pub const AF_ECMA = 8;
+pub const AF_DATAKIT = 9;
+pub const AF_CCITT = 10;
+pub const AF_SNA = 11;
+pub const AF_DECnet = 12;
+pub const AF_DLI = 13;
+pub const AF_LAT = 14;
+pub const AF_HYLINK = 15;
+pub const AF_APPLETALK = 16;
+pub const AF_ROUTE = 17;
+pub const AF_LINK = 18;
+pub const AF_XTP = 19;
+pub const AF_COIP = 20;
+pub const AF_CNT = 21;
+pub const AF_RTIP = 22;
+pub const AF_IPX = 23;
+pub const AF_SIP = 24;
+pub const AF_PIP = 25;
+pub const AF_ISDN = 28;
+pub const AF_E164 = AF_ISDN;
+pub const AF_KEY = 29;
+pub const AF_INET6 = 30;
+pub const AF_NATM = 31;
+pub const AF_SYSTEM = 32;
+pub const AF_NETBIOS = 33;
+pub const AF_PPP = 34;
+pub const AF_MAX = 40;
+
+pub const PF_UNSPEC = AF_UNSPEC;
+pub const PF_LOCAL = AF_LOCAL;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_INET = AF_INET;
+pub const PF_IMPLINK = AF_IMPLINK;
+pub const PF_PUP = AF_PUP;
+pub const PF_CHAOS = AF_CHAOS;
+pub const PF_NS = AF_NS;
+pub const PF_ISO = AF_ISO;
+pub const PF_OSI = AF_ISO;
+pub const PF_ECMA = AF_ECMA;
+pub const PF_DATAKIT = AF_DATAKIT;
+pub const PF_CCITT = AF_CCITT;
+pub const PF_SNA = AF_SNA;
+pub const PF_DECnet = AF_DECnet;
+pub const PF_DLI = AF_DLI;
+pub const PF_LAT = AF_LAT;
+pub const PF_HYLINK = AF_HYLINK;
+pub const PF_APPLETALK = AF_APPLETALK;
+pub const PF_ROUTE = AF_ROUTE;
+pub const PF_LINK = AF_LINK;
+pub const PF_XTP = AF_XTP;
+pub const PF_COIP = AF_COIP;
+pub const PF_CNT = AF_CNT;
+pub const PF_SIP = AF_SIP;
+pub const PF_IPX = AF_IPX;
+pub const PF_RTIP = AF_RTIP;
+pub const PF_PIP = AF_PIP;
+pub const PF_ISDN = AF_ISDN;
+pub const PF_KEY = AF_KEY;
+pub const PF_INET6 = AF_INET6;
+pub const PF_NATM = AF_NATM;
+pub const PF_SYSTEM = AF_SYSTEM;
+pub const PF_NETBIOS = AF_NETBIOS;
+pub const PF_PPP = AF_PPP;
+pub const PF_MAX = AF_MAX;
+
+pub const SYSPROTO_EVENT = 1;
+pub const SYSPROTO_CONTROL = 2;
+
+pub const SOCK_STREAM = 1;
+pub const SOCK_DGRAM = 2;
+pub const SOCK_RAW = 3;
+pub const SOCK_RDM = 4;
+pub const SOCK_SEQPACKET = 5;
+pub const SOCK_MAXADDRLEN = 255;
+
+/// Not actually supported by Darwin, but Zig supplies a shim.
+/// This numerical value is not ABI-stable. It need only not conflict
+/// with any other "SOCK_" bits.
+pub const SOCK_CLOEXEC = 1 << 15;
+/// Not actually supported by Darwin, but Zig supplies a shim.
+/// This numerical value is not ABI-stable. It need only not conflict
+/// with any other "SOCK_" bits.
+pub const SOCK_NONBLOCK = 1 << 16;
+
+pub const IPPROTO_ICMP = 1;
+pub const IPPROTO_ICMPV6 = 58;
+pub const IPPROTO_TCP = 6;
+pub const IPPROTO_UDP = 17;
+pub const IPPROTO_IP = 0;
+pub const IPPROTO_IPV6 = 41;
+
+pub const SOL_SOCKET = 0xffff;
+
+pub const SO_DEBUG = 0x0001;
+pub const SO_ACCEPTCONN = 0x0002;
+pub const SO_REUSEADDR = 0x0004;
+pub const SO_KEEPALIVE = 0x0008;
+pub const SO_DONTROUTE = 0x0010;
+pub const SO_BROADCAST = 0x0020;
+pub const SO_USELOOPBACK = 0x0040;
+pub const SO_LINGER = 0x1080;
+pub const SO_OOBINLINE = 0x0100;
+pub const SO_REUSEPORT = 0x0200;
+pub const SO_ACCEPTFILTER = 0x1000;
+pub const SO_SNDBUF = 0x1001;
+pub const SO_RCVBUF = 0x1002;
+pub const SO_SNDLOWAT = 0x1003;
+pub const SO_RCVLOWAT = 0x1004;
+pub const SO_SNDTIMEO = 0x1005;
+pub const SO_RCVTIMEO = 0x1006;
+pub const SO_ERROR = 0x1007;
+pub const SO_TYPE = 0x1008;
+
+pub const SO_NREAD = 0x1020;
+pub const SO_NKE = 0x1021;
+pub const SO_NOSIGPIPE = 0x1022;
+pub const SO_NOADDRERR = 0x1023;
+pub const SO_NWRITE = 0x1024;
+pub const SO_REUSESHAREUID = 0x1025;
+
+fn wstatus(x: u32) u32 {
+    return x & 0o177;
+}
+const wstopped = 0o177;
+pub fn WEXITSTATUS(x: u32) u8 {
+    return @intCast(u8, x >> 8);
+}
+pub fn WTERMSIG(x: u32) u32 {
+    return wstatus(x);
+}
+pub fn WSTOPSIG(x: u32) u32 {
+    return x >> 8;
+}
+pub fn WIFEXITED(x: u32) bool {
+    return wstatus(x) == 0;
+}
+pub fn WIFSTOPPED(x: u32) bool {
+    return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
+}
+pub fn WIFSIGNALED(x: u32) bool {
+    return wstatus(x) != wstopped and wstatus(x) != 0;
+}
+
+pub const E = enum(u16) {
+    /// No error occurred.
+    SUCCESS = 0,
+
+    /// Operation not permitted
+    PERM = 1,
+
+    /// No such file or directory
+    NOENT = 2,
+
+    /// No such process
+    SRCH = 3,
+
+    /// Interrupted system call
+    INTR = 4,
+
+    /// Input/output error
+    IO = 5,
+
+    /// Device not configured
+    NXIO = 6,
+
+    /// Argument list too long
+    @"2BIG" = 7,
+
+    /// Exec format error
+    NOEXEC = 8,
+
+    /// Bad file descriptor
+    BADF = 9,
+
+    /// No child processes
+    CHILD = 10,
+
+    /// Resource deadlock avoided
+    DEADLK = 11,
+
+    /// Cannot allocate memory
+    NOMEM = 12,
+
+    /// Permission denied
+    ACCES = 13,
+
+    /// Bad address
+    FAULT = 14,
+
+    /// Block device required
+    NOTBLK = 15,
+
+    /// Device / Resource busy
+    BUSY = 16,
+
+    /// File exists
+    EXIST = 17,
+
+    /// Cross-device link
+    XDEV = 18,
+
+    /// Operation not supported by device
+    NODEV = 19,
+
+    /// Not a directory
+    NOTDIR = 20,
+
+    /// Is a directory
+    ISDIR = 21,
+
+    /// Invalid argument
+    INVAL = 22,
+
+    /// Too many open files in system
+    NFILE = 23,
+
+    /// Too many open files
+    MFILE = 24,
+
+    /// Inappropriate ioctl for device
+    NOTTY = 25,
+
+    /// Text file busy
+    TXTBSY = 26,
+
+    /// File too large
+    FBIG = 27,
+
+    /// No space left on device
+    NOSPC = 28,
+
+    /// Illegal seek
+    SPIPE = 29,
+
+    /// Read-only file system
+    ROFS = 30,
+
+    /// Too many links
+    MLINK = 31,
+
+    /// Broken pipe
+    PIPE = 32,
+
+    // math software
+
+    /// Numerical argument out of domain
+    DOM = 33,
+
+    /// Result too large
+    RANGE = 34,
+
+    // non-blocking and interrupt i/o
+
+    /// Resource temporarily unavailable
+    /// This is the same code used for `WOULDBLOCK`.
+    AGAIN = 35,
+
+    /// Operation now in progress
+    INPROGRESS = 36,
+
+    /// Operation already in progress
+    ALREADY = 37,
+
+    // ipc/network software -- argument errors
+
+    /// Socket operation on non-socket
+    NOTSOCK = 38,
+
+    /// Destination address required
+    DESTADDRREQ = 39,
+
+    /// Message too long
+    MSGSIZE = 40,
+
+    /// Protocol wrong type for socket
+    PROTOTYPE = 41,
+
+    /// Protocol not available
+    NOPROTOOPT = 42,
+
+    /// Protocol not supported
+    PROTONOSUPPORT = 43,
+
+    /// Socket type not supported
+    SOCKTNOSUPPORT = 44,
+
+    /// Operation not supported
+    /// The same code is used for `NOTSUP`.
+    OPNOTSUPP = 45,
+
+    /// Protocol family not supported
+    PFNOSUPPORT = 46,
+
+    /// Address family not supported by protocol family
+    AFNOSUPPORT = 47,
+
+    /// Address already in use
+    ADDRINUSE = 48,
+    /// Can't assign requested address
+
+    // ipc/network software -- operational errors
+    ADDRNOTAVAIL = 49,
+
+    /// Network is down
+    NETDOWN = 50,
+
+    /// Network is unreachable
+    NETUNREACH = 51,
+
+    /// Network dropped connection on reset
+    NETRESET = 52,
+
+    /// Software caused connection abort
+    CONNABORTED = 53,
+
+    /// Connection reset by peer
+    CONNRESET = 54,
+
+    /// No buffer space available
+    NOBUFS = 55,
+
+    /// Socket is already connected
+    ISCONN = 56,
+
+    /// Socket is not connected
+    NOTCONN = 57,
+
+    /// Can't send after socket shutdown
+    SHUTDOWN = 58,
+
+    /// Too many references: can't splice
+    TOOMANYREFS = 59,
+
+    /// Operation timed out
+    TIMEDOUT = 60,
+
+    /// Connection refused
+    CONNREFUSED = 61,
+
+    /// Too many levels of symbolic links
+    LOOP = 62,
+
+    /// File name too long
+    NAMETOOLONG = 63,
+
+    /// Host is down
+    HOSTDOWN = 64,
+
+    /// No route to host
+    HOSTUNREACH = 65,
+    /// Directory not empty
+
+    // quotas & mush
+    NOTEMPTY = 66,
+
+    /// Too many processes
+    PROCLIM = 67,
+
+    /// Too many users
+    USERS = 68,
+    /// Disc quota exceeded
+
+    // Network File System
+    DQUOT = 69,
+
+    /// Stale NFS file handle
+    STALE = 70,
+
+    /// Too many levels of remote in path
+    REMOTE = 71,
+
+    /// RPC struct is bad
+    BADRPC = 72,
+
+    /// RPC version wrong
+    RPCMISMATCH = 73,
+
+    /// RPC prog. not avail
+    PROGUNAVAIL = 74,
+
+    /// Program version wrong
+    PROGMISMATCH = 75,
+
+    /// Bad procedure for program
+    PROCUNAVAIL = 76,
+
+    /// No locks available
+    NOLCK = 77,
+
+    /// Function not implemented
+    NOSYS = 78,
+
+    /// Inappropriate file type or format
+    FTYPE = 79,
+
+    /// Authentication error
+    AUTH = 80,
+
+    /// Need authenticator
+    NEEDAUTH = 81,
+
+    // Intelligent device errors
+
+    /// Device power is off
+    PWROFF = 82,
+
+    /// Device error, e.g. paper out
+    DEVERR = 83,
+
+    /// Value too large to be stored in data type
+    OVERFLOW = 84,
+
+    // Program loading errors
+
+    /// Bad executable
+    BADEXEC = 85,
+
+    /// Bad CPU type in executable
+    BADARCH = 86,
+
+    /// Shared library version mismatch
+    SHLIBVERS = 87,
+
+    /// Malformed Macho file
+    BADMACHO = 88,
+
+    /// Operation canceled
+    CANCELED = 89,
+
+    /// Identifier removed
+    IDRM = 90,
+
+    /// No message of desired type
+    NOMSG = 91,
+
+    /// Illegal byte sequence
+    ILSEQ = 92,
+
+    /// Attribute not found
+    NOATTR = 93,
+
+    /// Bad message
+    BADMSG = 94,
+
+    /// Reserved
+    MULTIHOP = 95,
+
+    /// No message available on STREAM
+    NODATA = 96,
+
+    /// Reserved
+    NOLINK = 97,
+
+    /// No STREAM resources
+    NOSR = 98,
+
+    /// Not a STREAM
+    NOSTR = 99,
+
+    /// Protocol error
+    PROTO = 100,
+
+    /// STREAM ioctl timeout
+    TIME = 101,
+
+    /// No such policy registered
+    NOPOLICY = 103,
+
+    /// State not recoverable
+    NOTRECOVERABLE = 104,
+
+    /// Previous owner died
+    OWNERDEAD = 105,
+
+    /// Interface output queue is full
+    QFULL = 106,
+
+    _,
+};
+
+pub const SIGSTKSZ = 131072;
+pub const MINSIGSTKSZ = 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+    ss_sp: [*]u8,
+    ss_size: isize,
+    ss_flags: i32,
+};
+
+pub const S_IFMT = 0o170000;
+
+pub const S_IFIFO = 0o010000;
+pub const S_IFCHR = 0o020000;
+pub const S_IFDIR = 0o040000;
+pub const S_IFBLK = 0o060000;
+pub const S_IFREG = 0o100000;
+pub const S_IFLNK = 0o120000;
+pub const S_IFSOCK = 0o140000;
+pub const S_IFWHT = 0o160000;
+
+pub const S_ISUID = 0o4000;
+pub const S_ISGID = 0o2000;
+pub const S_ISVTX = 0o1000;
+pub const S_IRWXU = 0o700;
+pub const S_IRUSR = 0o400;
+pub const S_IWUSR = 0o200;
+pub const S_IXUSR = 0o100;
+pub const S_IRWXG = 0o070;
+pub const S_IRGRP = 0o040;
+pub const S_IWGRP = 0o020;
+pub const S_IXGRP = 0o010;
+pub const S_IRWXO = 0o007;
+pub const S_IROTH = 0o004;
+pub const S_IWOTH = 0o002;
+pub const S_IXOTH = 0o001;
+
+pub fn S_ISFIFO(m: u32) bool {
+    return m & S_IFMT == S_IFIFO;
+}
+
+pub fn S_ISCHR(m: u32) bool {
+    return m & S_IFMT == S_IFCHR;
+}
+
+pub fn S_ISDIR(m: u32) bool {
+    return m & S_IFMT == S_IFDIR;
+}
+
+pub fn S_ISBLK(m: u32) bool {
+    return m & S_IFMT == S_IFBLK;
+}
+
+pub fn S_ISREG(m: u32) bool {
+    return m & S_IFMT == S_IFREG;
+}
+
+pub fn S_ISLNK(m: u32) bool {
+    return m & S_IFMT == S_IFLNK;
+}
+
+pub fn S_ISSOCK(m: u32) bool {
+    return m & S_IFMT == S_IFSOCK;
+}
+
+pub fn S_IWHT(m: u32) bool {
+    return m & S_IFMT == S_IFWHT;
+}
+
+pub const HOST_NAME_MAX = 72;
+
+pub const AT_FDCWD = -2;
+
+/// Use effective ids in access check
+pub const AT_EACCESS = 0x0010;
+
+/// Act on the symlink itself not the target
+pub const AT_SYMLINK_NOFOLLOW = 0x0020;
+
+/// Act on target of symlink
+pub const AT_SYMLINK_FOLLOW = 0x0040;
+
+/// Path refers to directory
+pub const AT_REMOVEDIR = 0x0080;
+
+pub const addrinfo = extern struct {
+    flags: i32,
+    family: i32,
+    socktype: i32,
+    protocol: i32,
+    addrlen: socklen_t,
+    canonname: ?[*:0]u8,
+    addr: ?*sockaddr,
+    next: ?*addrinfo,
+};
+
+pub const RTLD_LAZY = 0x1;
+pub const RTLD_NOW = 0x2;
+pub const RTLD_LOCAL = 0x4;
+pub const RTLD_GLOBAL = 0x8;
+pub const RTLD_NOLOAD = 0x10;
+pub const RTLD_NODELETE = 0x80;
+pub const RTLD_FIRST = 0x100;
+
+pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
+pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
+pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
+pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
+
+/// duplicate file descriptor
+pub const F_DUPFD = 0;
+
+/// get file descriptor flags
+pub const F_GETFD = 1;
+
+/// set file descriptor flags
+pub const F_SETFD = 2;
+
+/// get file status flags
+pub const F_GETFL = 3;
+
+/// set file status flags
+pub const F_SETFL = 4;
+
+/// get SIGIO/SIGURG proc/pgrp
+pub const F_GETOWN = 5;
+
+/// set SIGIO/SIGURG proc/pgrp
+pub const F_SETOWN = 6;
+
+/// get record locking information
+pub const F_GETLK = 7;
+
+/// set record locking information
+pub const F_SETLK = 8;
+
+/// F_SETLK; wait if blocked
+pub const F_SETLKW = 9;
+
+/// F_SETLK; wait if blocked, return on timeout
+pub const F_SETLKWTIMEOUT = 10;
+pub const F_FLUSH_DATA = 40;
+
+/// Used for regression test
+pub const F_CHKCLEAN = 41;
+
+/// Preallocate storage
+pub const F_PREALLOCATE = 42;
+
+/// Truncate a file without zeroing space
+pub const F_SETSIZE = 43;
+
+/// Issue an advisory read async with no copy to user
+pub const F_RDADVISE = 44;
+
+/// turn read ahead off/on for this fd
+pub const F_RDAHEAD = 45;
+
+/// turn data caching off/on for this fd
+pub const F_NOCACHE = 48;
+
+/// file offset to device offset
+pub const F_LOG2PHYS = 49;
+
+/// return the full path of the fd
+pub const F_GETPATH = 50;
+
+/// fsync + ask the drive to flush to the media
+pub const F_FULLFSYNC = 51;
+
+/// find which component (if any) is a package
+pub const F_PATHPKG_CHECK = 52;
+
+/// "freeze" all fs operations
+pub const F_FREEZE_FS = 53;
+
+/// "thaw" all fs operations
+pub const F_THAW_FS = 54;
+
+/// turn data caching off/on (globally) for this file
+pub const F_GLOBAL_NOCACHE = 55;
+
+/// add detached signatures
+pub const F_ADDSIGS = 59;
+
+/// add signature from same file (used by dyld for shared libs)
+pub const F_ADDFILESIGS = 61;
+
+/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes
+/// should not be used (i.e. its ok to temporaily create cached pages)
+pub const F_NODIRECT = 62;
+
+///Get the protection class of a file from the EA, returns int
+pub const F_GETPROTECTIONCLASS = 63;
+
+///Set the protection class of a file for the EA, requires int
+pub const F_SETPROTECTIONCLASS = 64;
+
+///file offset to device offset, extended
+pub const F_LOG2PHYS_EXT = 65;
+
+///get record locking information, per-process
+pub const F_GETLKPID = 66;
+
+///Mark the file as being the backing store for another filesystem
+pub const F_SETBACKINGSTORE = 70;
+
+///return the full path of the FD, but error in specific mtmd circumstances
+pub const F_GETPATH_MTMINFO = 71;
+
+///Returns the code directory, with associated hashes, to the caller
+pub const F_GETCODEDIR = 72;
+
+///No SIGPIPE generated on EPIPE
+pub const F_SETNOSIGPIPE = 73;
+
+///Status of SIGPIPE for this fd
+pub const F_GETNOSIGPIPE = 74;
+
+///For some cases, we need to rewrap the key for AKS/MKB
+pub const F_TRANSCODEKEY = 75;
+
+///file being written to a by single writer... if throttling enabled, writes
+///may be broken into smaller chunks with throttling in between
+pub const F_SINGLE_WRITER = 76;
+
+///Get the protection version number for this filesystem
+pub const F_GETPROTECTIONLEVEL = 77;
+
+///Add detached code signatures (used by dyld for shared libs)
+pub const F_FINDSIGS = 78;
+
+///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
+pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83;
+
+///fsync + issue barrier to drive
+pub const F_BARRIERFSYNC = 85;
+
+///Add signature from same file, return end offset in structure on success
+pub const F_ADDFILESIGS_RETURN = 97;
+
+///Check if Library Validation allows this Mach-O file to be mapped into the calling process
+pub const F_CHECK_LV = 98;
+
+///Deallocate a range of the file
+pub const F_PUNCHHOLE = 99;
+
+///Trim an active file
+pub const F_TRIM_ACTIVE_FILE = 100;
+
+pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
+
+///mark the dup with FD_CLOEXEC
+pub const F_DUPFD_CLOEXEC = 67;
+
+///close-on-exec flag
+pub const FD_CLOEXEC = 1;
+
+/// shared or read lock
+pub const F_RDLCK = 1;
+
+/// unlock
+pub const F_UNLCK = 2;
+
+/// exclusive or write lock
+pub const F_WRLCK = 3;
+
+pub const LOCK_SH = 1;
+pub const LOCK_EX = 2;
+pub const LOCK_UN = 8;
+pub const LOCK_NB = 4;
+
+pub const nfds_t = u32;
+pub const pollfd = extern struct {
+    fd: fd_t,
+    events: i16,
+    revents: i16,
+};
+
+pub const POLLIN = 0x001;
+pub const POLLPRI = 0x002;
+pub const POLLOUT = 0x004;
+pub const POLLRDNORM = 0x040;
+pub const POLLWRNORM = POLLOUT;
+pub const POLLRDBAND = 0x080;
+pub const POLLWRBAND = 0x100;
+
+pub const POLLEXTEND = 0x0200;
+pub const POLLATTRIB = 0x0400;
+pub const POLLNLINK = 0x0800;
+pub const POLLWRITE = 0x1000;
+
+pub const POLLERR = 0x008;
+pub const POLLHUP = 0x010;
+pub const POLLNVAL = 0x020;
+
+pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
+
+pub const CLOCK_REALTIME = 0;
+pub const CLOCK_MONOTONIC = 6;
+pub const CLOCK_MONOTONIC_RAW = 4;
+pub const CLOCK_MONOTONIC_RAW_APPROX = 5;
+pub const CLOCK_UPTIME_RAW = 8;
+pub const CLOCK_UPTIME_RAW_APPROX = 9;
+pub const CLOCK_PROCESS_CPUTIME_ID = 12;
+pub const CLOCK_THREAD_CPUTIME_ID = 16;
+
+/// Max open files per process
+/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html
+pub const OPEN_MAX = 10240;
+pub const RUSAGE_SELF = 0;
+pub const RUSAGE_CHILDREN = -1;
+
+pub const rusage = extern struct {
+    utime: timeval,
+    stime: timeval,
+    maxrss: isize,
+    ixrss: isize,
+    idrss: isize,
+    isrss: isize,
+    minflt: isize,
+    majflt: isize,
+    nswap: isize,
+    inblock: isize,
+    oublock: isize,
+    msgsnd: isize,
+    msgrcv: isize,
+    nsignals: isize,
+    nvcsw: isize,
+    nivcsw: isize,
+};
+
+pub const rlimit_resource = enum(c_int) {
+    CPU = 0,
+    FSIZE = 1,
+    DATA = 2,
+    STACK = 3,
+    CORE = 4,
+    RSS = 5,
+    MEMLOCK = 6,
+    NPROC = 7,
+    NOFILE = 8,
+    _,
+
+    pub const AS: rlimit_resource = .RSS;
+};
+
+pub const rlim_t = u64;
+
+/// No limit
+pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
+
+pub const RLIM_SAVED_MAX = RLIM_INFINITY;
+pub const RLIM_SAVED_CUR = RLIM_INFINITY;
+
+pub const rlimit = extern struct {
+    /// Soft limit
+    cur: rlim_t,
+    /// Hard limit
+    max: rlim_t,
+};
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 2;
+
+// Term
+pub const VEOF = 0;
+pub const VEOL = 1;
+pub const VEOL2 = 2;
+pub const VERASE = 3;
+pub const VWERASE = 4;
+pub const VKILL = 5;
+pub const VREPRINT = 6;
+pub const VINTR = 8;
+pub const VQUIT = 9;
+pub const VSUSP = 10;
+pub const VDSUSP = 11;
+pub const VSTART = 12;
+pub const VSTOP = 13;
+pub const VLNEXT = 14;
+pub const VDISCARD = 15;
+pub const VMIN = 16;
+pub const VTIME = 17;
+pub const VSTATUS = 18;
+pub const NCCS = 20; // 2 spares (7, 19)
+
+pub const IGNBRK = 0x00000001; // ignore BREAK condition
+pub const BRKINT = 0x00000002; // map BREAK to SIGINTR
+pub const IGNPAR = 0x00000004; // ignore (discard) parity errors
+pub const PARMRK = 0x00000008; // mark parity and framing errors
+pub const INPCK = 0x00000010; // enable checking of parity errors
+pub const ISTRIP = 0x00000020; // strip 8th bit off chars
+pub const INLCR = 0x00000040; // map NL into CR
+pub const IGNCR = 0x00000080; // ignore CR
+pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD)
+pub const IXON = 0x00000200; // enable output flow control
+pub const IXOFF = 0x00000400; // enable input flow control
+pub const IXANY = 0x00000800; // any char will restart after stop
+pub const IMAXBEL = 0x00002000; // ring bell on input queue full
+pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE
+
+pub const OPOST = 0x00000001; //enable following output processing
+pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD)
+pub const OXTABS = 0x00000004; // expand tabs to spaces
+pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output)
+
+pub const OCRNL = 0x00000010; // map CR to NL on output
+pub const ONOCR = 0x00000020; // no CR output at column 0
+pub const ONLRET = 0x00000040; // NL performs CR function
+pub const OFILL = 0x00000080; // use fill characters for delay
+pub const NLDLY = 0x00000300; // \n delay
+pub const TABDLY = 0x00000c04; // horizontal tab delay
+pub const CRDLY = 0x00003000; // \r delay
+pub const FFDLY = 0x00004000; // form feed delay
+pub const BSDLY = 0x00008000; // \b delay
+pub const VTDLY = 0x00010000; // vertical tab delay
+pub const OFDEL = 0x00020000; // fill is DEL, else NUL
+
+pub const NL0 = 0x00000000;
+pub const NL1 = 0x00000100;
+pub const NL2 = 0x00000200;
+pub const NL3 = 0x00000300;
+pub const TAB0 = 0x00000000;
+pub const TAB1 = 0x00000400;
+pub const TAB2 = 0x00000800;
+pub const TAB3 = 0x00000004;
+pub const CR0 = 0x00000000;
+pub const CR1 = 0x00001000;
+pub const CR2 = 0x00002000;
+pub const CR3 = 0x00003000;
+pub const FF0 = 0x00000000;
+pub const FF1 = 0x00004000;
+pub const BS0 = 0x00000000;
+pub const BS1 = 0x00008000;
+pub const VT0 = 0x00000000;
+pub const VT1 = 0x00010000;
+
+pub const CIGNORE = 0x00000001; // ignore control flags
+pub const CSIZE = 0x00000300; // character size mask
+pub const CS5 = 0x00000000; //    5 bits (pseudo)
+pub const CS6 = 0x00000100; //    6 bits
+pub const CS7 = 0x00000200; //    7 bits
+pub const CS8 = 0x00000300; //    8 bits
+pub const CSTOPB = 0x0000040; // send 2 stop bits
+pub const CREAD = 0x00000800; // enable receiver
+pub const PARENB = 0x00001000; // parity enable
+pub const PARODD = 0x00002000; // odd parity, else even
+pub const HUPCL = 0x00004000; // hang up on last close
+pub const CLOCAL = 0x00008000; // ignore modem status lines
+pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output
+pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW);
+pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input
+pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input
+pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output
+pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output
+pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW
+
+pub const ECHOKE = 0x00000001; // visual erase for line kill
+pub const ECHOE = 0x00000002; // visually erase chars
+pub const ECHOK = 0x00000004; // echo NL after line kill
+pub const ECHO = 0x00000008; // enable echoing
+pub const ECHONL = 0x00000010; // echo NL even if ECHO is off
+pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy
+pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char)
+pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP
+pub const ICANON = 0x00000100; // canonicalize input lines
+pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm
+pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT
+pub const EXTPROC = 0x00000800; // external processing
+pub const TOSTOP = 0x00400000; // stop background jobs from output
+pub const FLUSHO = 0x00800000; // output being flushed (state)
+pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS
+pub const PENDIN = 0x20000000; // XXX retype pending input (state)
+pub const NOFLSH = 0x80000000; // don't flush after interrupt
+
+pub const TCSANOW = 0; // make change immediate
+pub const TCSADRAIN = 1; // drain output, then change
+pub const TCSAFLUSH = 2; // drain output, flush input
+pub const TCSASOFT = 0x10; // flag - don't alter h.w. state
+pub const TCSA = enum(c_uint) {
+    NOW,
+    DRAIN,
+    FLUSH,
+    _,
+};
+
+pub const B0 = 0;
+pub const B50 = 50;
+pub const B75 = 75;
+pub const B110 = 110;
+pub const B134 = 134;
+pub const B150 = 150;
+pub const B200 = 200;
+pub const B300 = 300;
+pub const B600 = 600;
+pub const B1200 = 1200;
+pub const B1800 = 1800;
+pub const B2400 = 2400;
+pub const B4800 = 4800;
+pub const B9600 = 9600;
+pub const B19200 = 19200;
+pub const B38400 = 38400;
+pub const B7200 = 7200;
+pub const B14400 = 14400;
+pub const B28800 = 28800;
+pub const B57600 = 57600;
+pub const B76800 = 76800;
+pub const B115200 = 115200;
+pub const B230400 = 230400;
+pub const EXTA = 19200;
+pub const EXTB = 38400;
+
+pub const TCIFLUSH = 1;
+pub const TCOFLUSH = 2;
+pub const TCIOFLUSH = 3;
+pub const TCOOFF = 1;
+pub const TCOON = 2;
+pub const TCIOFF = 3;
+pub const TCION = 4;
+
+pub const cc_t = u8;
+pub const speed_t = u64;
+pub const tcflag_t = u64;
+
+pub const termios = extern struct {
+    iflag: tcflag_t, // input flags
+    oflag: tcflag_t, // output flags
+    cflag: tcflag_t, // control flags
+    lflag: tcflag_t, // local flags
+    cc: [NCCS]cc_t, // control chars
+    ispeed: speed_t align(8), // input speed
+    ospeed: speed_t, // output speed
+};
+
+pub const winsize = extern struct {
+    ws_row: u16,
+    ws_col: u16,
+    ws_xpixel: u16,
+    ws_ypixel: u16,
+};
+
+pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
+pub const IOCPARM_MASK = 0x1fff;
+
+fn ior(inout: u32, group: usize, num: usize, len: usize) usize {
+    return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num));
+}
+
+// CPU families mapping
+pub const CPUFAMILY = enum(u32) {
+    UNKNOWN = 0,
+    POWERPC_G3 = 0xcee41549,
+    POWERPC_G4 = 0x77c184ae,
+    POWERPC_G5 = 0xed76d8aa,
+    INTEL_6_13 = 0xaa33392b,
+    INTEL_PENRYN = 0x78ea4fbc,
+    INTEL_NEHALEM = 0x6b5a4cd2,
+    INTEL_WESTMERE = 0x573b5eec,
+    INTEL_SANDYBRIDGE = 0x5490b78c,
+    INTEL_IVYBRIDGE = 0x1f65e835,
+    INTEL_HASWELL = 0x10b282dc,
+    INTEL_BROADWELL = 0x582ed09c,
+    INTEL_SKYLAKE = 0x37fc219f,
+    INTEL_KABYLAKE = 0x0f817246,
+    ARM_9 = 0xe73283ae,
+    ARM_11 = 0x8ff620d8,
+    ARM_XSCALE = 0x53b005f5,
+    ARM_12 = 0xbd1b0ae9,
+    ARM_13 = 0x0cc90e64,
+    ARM_14 = 0x96077ef1,
+    ARM_15 = 0xa8511bca,
+    ARM_SWIFT = 0x1e2d6381,
+    ARM_CYCLONE = 0x37a09642,
+    ARM_TYPHOON = 0x2c91a47e,
+    ARM_TWISTER = 0x92fb37c8,
+    ARM_HURRICANE = 0x67ceee93,
+    ARM_MONSOON_MISTRAL = 0xe81e7ef6,
+    ARM_VORTEX_TEMPEST = 0x07d34b9f,
+    ARM_LIGHTNING_THUNDER = 0x462504d2,
+    ARM_FIRESTORM_ICESTORM = 0x1b588bb3,
+    _,
+};
lib/std/c/dragonfly.zig
@@ -1,5 +1,6 @@
 const std = @import("../std.zig");
-usingnamespace std.c;
+const maxInt = std.math.maxInt;
+
 extern "c" threadlocal var errno: c_int;
 pub fn _errno() *c_int {
     return &errno;
@@ -30,3 +31,1032 @@ pub const pthread_attr_t = extern struct { // copied from freebsd
 };
 
 pub const sem_t = ?*opaque {};
+
+pub fn S_ISCHR(m: u32) bool {
+    return m & S_IFMT == S_IFCHR;
+}
+
+// See:
+// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
+// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h
+// TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+pub const off_t = c_long;
+pub const mode_t = c_uint;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const time_t = isize;
+pub const suseconds_t = c_long;
+
+pub const E = enum(u16) {
+    /// No error occurred.
+    SUCCESS = 0,
+
+    PERM = 1,
+    NOENT = 2,
+    SRCH = 3,
+    INTR = 4,
+    IO = 5,
+    NXIO = 6,
+    @"2BIG" = 7,
+    NOEXEC = 8,
+    BADF = 9,
+    CHILD = 10,
+    DEADLK = 11,
+    NOMEM = 12,
+    ACCES = 13,
+    FAULT = 14,
+    NOTBLK = 15,
+    BUSY = 16,
+    EXIST = 17,
+    XDEV = 18,
+    NODEV = 19,
+    NOTDIR = 20,
+    ISDIR = 21,
+    INVAL = 22,
+    NFILE = 23,
+    MFILE = 24,
+    NOTTY = 25,
+    TXTBSY = 26,
+    FBIG = 27,
+    NOSPC = 28,
+    SPIPE = 29,
+    ROFS = 30,
+    MLINK = 31,
+    PIPE = 32,
+    DOM = 33,
+    RANGE = 34,
+    /// This code is also used for `WOULDBLOCK`.
+    AGAIN = 35,
+    INPROGRESS = 36,
+    ALREADY = 37,
+    NOTSOCK = 38,
+    DESTADDRREQ = 39,
+    MSGSIZE = 40,
+    PROTOTYPE = 41,
+    NOPROTOOPT = 42,
+    PROTONOSUPPORT = 43,
+    SOCKTNOSUPPORT = 44,
+    /// This code is also used for `NOTSUP`.
+    OPNOTSUPP = 45,
+    PFNOSUPPORT = 46,
+    AFNOSUPPORT = 47,
+    ADDRINUSE = 48,
+    ADDRNOTAVAIL = 49,
+    NETDOWN = 50,
+    NETUNREACH = 51,
+    NETRESET = 52,
+    CONNABORTED = 53,
+    CONNRESET = 54,
+    NOBUFS = 55,
+    ISCONN = 56,
+    NOTCONN = 57,
+    SHUTDOWN = 58,
+    TOOMANYREFS = 59,
+    TIMEDOUT = 60,
+    CONNREFUSED = 61,
+    LOOP = 62,
+    NAMETOOLONG = 63,
+    HOSTDOWN = 64,
+    HOSTUNREACH = 65,
+    NOTEMPTY = 66,
+    PROCLIM = 67,
+    USERS = 68,
+    DQUOT = 69,
+    STALE = 70,
+    REMOTE = 71,
+    BADRPC = 72,
+    RPCMISMATCH = 73,
+    PROGUNAVAIL = 74,
+    PROGMISMATCH = 75,
+    PROCUNAVAIL = 76,
+    NOLCK = 77,
+    NOSYS = 78,
+    FTYPE = 79,
+    AUTH = 80,
+    NEEDAUTH = 81,
+    IDRM = 82,
+    NOMSG = 83,
+    OVERFLOW = 84,
+    CANCELED = 85,
+    ILSEQ = 86,
+    NOATTR = 87,
+    DOOFUS = 88,
+    BADMSG = 89,
+    MULTIHOP = 90,
+    NOLINK = 91,
+    PROTO = 92,
+    NOMEDIUM = 93,
+    ASYNC = 99,
+    _,
+};
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT_NONE = 0;
+pub const PROT_READ = 1;
+pub const PROT_WRITE = 2;
+pub const PROT_EXEC = 4;
+
+pub const MAP_FILE = 0;
+pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+pub const MAP_ANONYMOUS = MAP_ANON;
+pub const MAP_COPY = MAP_PRIVATE;
+pub const MAP_SHARED = 1;
+pub const MAP_PRIVATE = 2;
+pub const MAP_FIXED = 16;
+pub const MAP_RENAME = 32;
+pub const MAP_NORESERVE = 64;
+pub const MAP_INHERIT = 128;
+pub const MAP_NOEXTEND = 256;
+pub const MAP_HASSEMAPHORE = 512;
+pub const MAP_STACK = 1024;
+pub const MAP_NOSYNC = 2048;
+pub const MAP_ANON = 4096;
+pub const MAP_VPAGETABLE = 8192;
+pub const MAP_TRYFIXED = 65536;
+pub const MAP_NOCORE = 131072;
+pub const MAP_SIZEALIGN = 262144;
+
+pub const WNOHANG = 0x0001;
+pub const WUNTRACED = 0x0002;
+pub const WCONTINUED = 0x0004;
+pub const WSTOPPED = WUNTRACED;
+pub const WNOWAIT = 0x0008;
+pub const WEXITED = 0x0010;
+pub const WTRAPPED = 0x0020;
+
+pub const SA_ONSTACK = 0x0001;
+pub const SA_RESTART = 0x0002;
+pub const SA_RESETHAND = 0x0004;
+pub const SA_NODEFER = 0x0010;
+pub const SA_NOCLDWAIT = 0x0020;
+pub const SA_SIGINFO = 0x0040;
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = KERN_IOV_MAX;
+
+pub const ino_t = c_ulong;
+
+pub const Stat = extern struct {
+    ino: ino_t,
+    nlink: c_uint,
+    dev: c_uint,
+    mode: c_ushort,
+    padding1: u16,
+    uid: uid_t,
+    gid: gid_t,
+    rdev: c_uint,
+    atim: timespec,
+    mtim: timespec,
+    ctim: timespec,
+    size: c_ulong,
+    blocks: i64,
+    blksize: u32,
+    flags: u32,
+    gen: u32,
+    lspare: i32,
+    qspare1: i64,
+    qspare2: i64,
+    pub fn atime(self: @This()) timespec {
+        return self.atim;
+    }
+
+    pub fn mtime(self: @This()) timespec {
+        return self.mtim;
+    }
+
+    pub fn ctime(self: @This()) timespec {
+        return self.ctim;
+    }
+};
+
+pub const timespec = extern struct {
+    tv_sec: c_long,
+    tv_nsec: c_long,
+};
+
+pub const timeval = extern struct {
+    /// seconds
+    tv_sec: time_t,
+    /// microseconds
+    tv_usec: suseconds_t,
+};
+
+pub const CTL_UNSPEC = 0;
+pub const CTL_KERN = 1;
+pub const CTL_VM = 2;
+pub const CTL_VFS = 3;
+pub const CTL_NET = 4;
+pub const CTL_DEBUG = 5;
+pub const CTL_HW = 6;
+pub const CTL_MACHDEP = 7;
+pub const CTL_USER = 8;
+pub const CTL_LWKT = 10;
+pub const CTL_MAXID = 11;
+pub const CTL_MAXNAME = 12;
+
+pub const KERN_PROC_ALL = 0;
+pub const KERN_OSTYPE = 1;
+pub const KERN_PROC_PID = 1;
+pub const KERN_OSRELEASE = 2;
+pub const KERN_PROC_PGRP = 2;
+pub const KERN_OSREV = 3;
+pub const KERN_PROC_SESSION = 3;
+pub const KERN_VERSION = 4;
+pub const KERN_PROC_TTY = 4;
+pub const KERN_MAXVNODES = 5;
+pub const KERN_PROC_UID = 5;
+pub const KERN_MAXPROC = 6;
+pub const KERN_PROC_RUID = 6;
+pub const KERN_MAXFILES = 7;
+pub const KERN_PROC_ARGS = 7;
+pub const KERN_ARGMAX = 8;
+pub const KERN_PROC_CWD = 8;
+pub const KERN_PROC_PATHNAME = 9;
+pub const KERN_SECURELVL = 9;
+pub const KERN_PROC_SIGTRAMP = 10;
+pub const KERN_HOSTNAME = 10;
+pub const KERN_HOSTID = 11;
+pub const KERN_CLOCKRATE = 12;
+pub const KERN_VNODE = 13;
+pub const KERN_PROC = 14;
+pub const KERN_FILE = 15;
+pub const KERN_PROC_FLAGMASK = 16;
+pub const KERN_PROF = 16;
+pub const KERN_PROC_FLAG_LWP = 16;
+pub const KERN_POSIX1 = 17;
+pub const KERN_NGROUPS = 18;
+pub const KERN_JOB_CONTROL = 19;
+pub const KERN_SAVED_IDS = 20;
+pub const KERN_BOOTTIME = 21;
+pub const KERN_NISDOMAINNAME = 22;
+pub const KERN_UPDATEINTERVAL = 23;
+pub const KERN_OSRELDATE = 24;
+pub const KERN_NTP_PLL = 25;
+pub const KERN_BOOTFILE = 26;
+pub const KERN_MAXFILESPERPROC = 27;
+pub const KERN_MAXPROCPERUID = 28;
+pub const KERN_DUMPDEV = 29;
+pub const KERN_IPC = 30;
+pub const KERN_DUMMY = 31;
+pub const KERN_PS_STRINGS = 32;
+pub const KERN_USRSTACK = 33;
+pub const KERN_LOGSIGEXIT = 34;
+pub const KERN_IOV_MAX = 35;
+pub const KERN_MAXPOSIXLOCKSPERUID = 36;
+pub const KERN_MAXID = 37;
+
+pub const HOST_NAME_MAX = 255;
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O_RDONLY = 0;
+pub const O_NDELAY = O_NONBLOCK;
+pub const O_WRONLY = 1;
+pub const O_RDWR = 2;
+pub const O_ACCMODE = 3;
+pub const O_NONBLOCK = 4;
+pub const O_APPEND = 8;
+pub const O_SHLOCK = 16;
+pub const O_EXLOCK = 32;
+pub const O_ASYNC = 64;
+pub const O_FSYNC = 128;
+pub const O_SYNC = 128;
+pub const O_NOFOLLOW = 256;
+pub const O_CREAT = 512;
+pub const O_TRUNC = 1024;
+pub const O_EXCL = 2048;
+pub const O_NOCTTY = 32768;
+pub const O_DIRECT = 65536;
+pub const O_CLOEXEC = 131072;
+pub const O_FBLOCKING = 262144;
+pub const O_FNONBLOCKING = 524288;
+pub const O_FAPPEND = 1048576;
+pub const O_FOFFSET = 2097152;
+pub const O_FSYNCWRITE = 4194304;
+pub const O_FASYNCWRITE = 8388608;
+pub const O_DIRECTORY = 134217728;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+pub const SEEK_DATA = 3;
+pub const SEEK_HOLE = 4;
+
+pub const F_ULOCK = 0;
+pub const F_LOCK = 1;
+pub const F_TLOCK = 2;
+pub const F_TEST = 3;
+
+pub const FD_CLOEXEC = 1;
+
+pub const AT_FDCWD = -328243;
+pub const AT_SYMLINK_NOFOLLOW = 1;
+pub const AT_REMOVEDIR = 2;
+pub const AT_EACCESS = 4;
+pub const AT_SYMLINK_FOLLOW = 8;
+
+pub fn WEXITSTATUS(s: u32) u8 {
+    return @intCast(u8, (s & 0xff00) >> 8);
+}
+pub fn WTERMSIG(s: u32) u32 {
+    return s & 0x7f;
+}
+pub fn WSTOPSIG(s: u32) u32 {
+    return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: u32) bool {
+    return WTERMSIG(s) == 0;
+}
+pub fn WIFSTOPPED(s: u32) bool {
+    return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
+}
+pub fn WIFSIGNALED(s: u32) bool {
+    return (s & 0xffff) -% 1 < 0xff;
+}
+
+pub const dirent = extern struct {
+    d_fileno: c_ulong,
+    d_namlen: u16,
+    d_type: u8,
+    d_unused1: u8,
+    d_unused2: u32,
+    d_name: [256]u8,
+
+    pub fn reclen(self: dirent) u16 {
+        return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7);
+    }
+};
+
+pub const DT_UNKNOWN = 0;
+pub const DT_FIFO = 1;
+pub const DT_CHR = 2;
+pub const DT_DIR = 4;
+pub const DT_BLK = 6;
+pub const DT_REG = 8;
+pub const DT_LNK = 10;
+pub const DT_SOCK = 12;
+pub const DT_WHT = 14;
+pub const DT_DBF = 15;
+
+pub const CLOCK_REALTIME = 0;
+pub const CLOCK_VIRTUAL = 1;
+pub const CLOCK_PROF = 2;
+pub const CLOCK_MONOTONIC = 4;
+pub const CLOCK_UPTIME = 5;
+pub const CLOCK_UPTIME_PRECISE = 7;
+pub const CLOCK_UPTIME_FAST = 8;
+pub const CLOCK_REALTIME_PRECISE = 9;
+pub const CLOCK_REALTIME_FAST = 10;
+pub const CLOCK_MONOTONIC_PRECISE = 11;
+pub const CLOCK_MONOTONIC_FAST = 12;
+pub const CLOCK_SECOND = 13;
+pub const CLOCK_THREAD_CPUTIME_ID = 14;
+pub const CLOCK_PROCESS_CPUTIME_ID = 15;
+
+pub const sockaddr = extern struct {
+    len: u8,
+    family: u8,
+    data: [14]u8,
+};
+
+pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+
+pub const Kevent = extern struct {
+    ident: usize,
+    filter: c_short,
+    flags: c_ushort,
+    fflags: c_uint,
+    data: isize,
+    udata: usize,
+};
+
+pub const EVFILT_FS = -10;
+pub const EVFILT_USER = -9;
+pub const EVFILT_EXCEPT = -8;
+pub const EVFILT_TIMER = -7;
+pub const EVFILT_SIGNAL = -6;
+pub const EVFILT_PROC = -5;
+pub const EVFILT_VNODE = -4;
+pub const EVFILT_AIO = -3;
+pub const EVFILT_WRITE = -2;
+pub const EVFILT_READ = -1;
+pub const EVFILT_SYSCOUNT = 10;
+pub const EVFILT_MARKER = 15;
+
+pub const EV_ADD = 1;
+pub const EV_DELETE = 2;
+pub const EV_ENABLE = 4;
+pub const EV_DISABLE = 8;
+pub const EV_ONESHOT = 16;
+pub const EV_CLEAR = 32;
+pub const EV_RECEIPT = 64;
+pub const EV_DISPATCH = 128;
+pub const EV_NODATA = 4096;
+pub const EV_FLAG1 = 8192;
+pub const EV_ERROR = 16384;
+pub const EV_EOF = 32768;
+pub const EV_SYSFLAGS = 61440;
+
+pub const NOTE_FFNOP = 0;
+pub const NOTE_TRACK = 1;
+pub const NOTE_DELETE = 1;
+pub const NOTE_LOWAT = 1;
+pub const NOTE_TRACKERR = 2;
+pub const NOTE_OOB = 2;
+pub const NOTE_WRITE = 2;
+pub const NOTE_EXTEND = 4;
+pub const NOTE_CHILD = 4;
+pub const NOTE_ATTRIB = 8;
+pub const NOTE_LINK = 16;
+pub const NOTE_RENAME = 32;
+pub const NOTE_REVOKE = 64;
+pub const NOTE_PDATAMASK = 1048575;
+pub const NOTE_FFLAGSMASK = 16777215;
+pub const NOTE_TRIGGER = 16777216;
+pub const NOTE_EXEC = 536870912;
+pub const NOTE_FFAND = 1073741824;
+pub const NOTE_FORK = 1073741824;
+pub const NOTE_EXIT = 2147483648;
+pub const NOTE_FFOR = 2147483648;
+pub const NOTE_FFCTRLMASK = 3221225472;
+pub const NOTE_FFCOPY = 3221225472;
+pub const NOTE_PCTRLMASK = 4026531840;
+
+pub const stack_t = extern struct {
+    ss_sp: [*]u8,
+    ss_size: isize,
+    ss_flags: i32,
+};
+
+pub const S_IREAD = S_IRUSR;
+pub const S_IEXEC = S_IXUSR;
+pub const S_IWRITE = S_IWUSR;
+pub const S_IXOTH = 1;
+pub const S_IWOTH = 2;
+pub const S_IROTH = 4;
+pub const S_IRWXO = 7;
+pub const S_IXGRP = 8;
+pub const S_IWGRP = 16;
+pub const S_IRGRP = 32;
+pub const S_IRWXG = 56;
+pub const S_IXUSR = 64;
+pub const S_IWUSR = 128;
+pub const S_IRUSR = 256;
+pub const S_IRWXU = 448;
+pub const S_ISTXT = 512;
+pub const S_BLKSIZE = 512;
+pub const S_ISVTX = 512;
+pub const S_ISGID = 1024;
+pub const S_ISUID = 2048;
+pub const S_IFIFO = 4096;
+pub const S_IFCHR = 8192;
+pub const S_IFDIR = 16384;
+pub const S_IFBLK = 24576;
+pub const S_IFREG = 32768;
+pub const S_IFDB = 36864;
+pub const S_IFLNK = 40960;
+pub const S_IFSOCK = 49152;
+pub const S_IFWHT = 57344;
+pub const S_IFMT = 61440;
+
+pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+pub const BADSIG = SIG_ERR;
+
+pub const SIG_BLOCK = 1;
+pub const SIG_UNBLOCK = 2;
+pub const SIG_SETMASK = 3;
+
+pub const SIGIOT = SIGABRT;
+pub const SIGHUP = 1;
+pub const SIGINT = 2;
+pub const SIGQUIT = 3;
+pub const SIGILL = 4;
+pub const SIGTRAP = 5;
+pub const SIGABRT = 6;
+pub const SIGEMT = 7;
+pub const SIGFPE = 8;
+pub const SIGKILL = 9;
+pub const SIGBUS = 10;
+pub const SIGSEGV = 11;
+pub const SIGSYS = 12;
+pub const SIGPIPE = 13;
+pub const SIGALRM = 14;
+pub const SIGTERM = 15;
+pub const SIGURG = 16;
+pub const SIGSTOP = 17;
+pub const SIGTSTP = 18;
+pub const SIGCONT = 19;
+pub const SIGCHLD = 20;
+pub const SIGTTIN = 21;
+pub const SIGTTOU = 22;
+pub const SIGIO = 23;
+pub const SIGXCPU = 24;
+pub const SIGXFSZ = 25;
+pub const SIGVTALRM = 26;
+pub const SIGPROF = 27;
+pub const SIGWINCH = 28;
+pub const SIGINFO = 29;
+pub const SIGUSR1 = 30;
+pub const SIGUSR2 = 31;
+pub const SIGTHR = 32;
+pub const SIGCKPT = 33;
+pub const SIGCKPTEXIT = 34;
+
+pub const siginfo_t = extern struct {
+    signo: c_int,
+    errno: c_int,
+    code: c_int,
+    pid: c_int,
+    uid: uid_t,
+    status: c_int,
+    addr: ?*c_void,
+    value: sigval,
+    band: c_long,
+    __spare__: [7]c_int,
+};
+
+pub const sigval = extern union {
+    sival_int: c_int,
+    sival_ptr: ?*c_void,
+};
+
+pub const _SIG_WORDS = 4;
+
+pub const sigset_t = extern struct {
+    __bits: [_SIG_WORDS]c_uint,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS };
+
+pub const sig_atomic_t = c_int;
+
+pub const Sigaction = extern struct {
+    pub const handler_fn = fn (c_int) callconv(.C) void;
+    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+    /// signal handler
+    handler: extern union {
+        handler: ?handler_fn,
+        sigaction: ?sigaction_fn,
+    },
+    flags: c_uint,
+    mask: sigset_t,
+};
+
+pub const sig_t = [*c]fn (c_int) callconv(.C) void;
+
+pub const SOCK_STREAM = 1;
+pub const SOCK_DGRAM = 2;
+pub const SOCK_RAW = 3;
+pub const SOCK_RDM = 4;
+pub const SOCK_SEQPACKET = 5;
+pub const SOCK_MAXADDRLEN = 255;
+pub const SOCK_CLOEXEC = 0x10000000;
+pub const SOCK_NONBLOCK = 0x20000000;
+
+pub const SO_DEBUG = 0x0001;
+pub const SO_ACCEPTCONN = 0x0002;
+pub const SO_REUSEADDR = 0x0004;
+pub const SO_KEEPALIVE = 0x0008;
+pub const SO_DONTROUTE = 0x0010;
+pub const SO_BROADCAST = 0x0020;
+pub const SO_USELOOPBACK = 0x0040;
+pub const SO_LINGER = 0x0080;
+pub const SO_OOBINLINE = 0x0100;
+pub const SO_REUSEPORT = 0x0200;
+pub const SO_TIMESTAMP = 0x0400;
+pub const SO_NOSIGPIPE = 0x0800;
+pub const SO_ACCEPTFILTER = 0x1000;
+pub const SO_RERROR = 0x2000;
+pub const SO_PASSCRED = 0x4000;
+
+pub const SO_SNDBUF = 0x1001;
+pub const SO_RCVBUF = 0x1002;
+pub const SO_SNDLOWAT = 0x1003;
+pub const SO_RCVLOWAT = 0x1004;
+pub const SO_SNDTIMEO = 0x1005;
+pub const SO_RCVTIMEO = 0x1006;
+pub const SO_ERROR = 0x1007;
+pub const SO_TYPE = 0x1008;
+pub const SO_SNDSPACE = 0x100a;
+pub const SO_CPUHINT = 0x1030;
+
+pub const SOL_SOCKET = 0xffff;
+
+pub const PF_INET6 = AF_INET6;
+pub const PF_IMPLINK = AF_IMPLINK;
+pub const PF_ROUTE = AF_ROUTE;
+pub const PF_ISO = AF_ISO;
+pub const PF_PIP = pseudo_AF_PIP;
+pub const PF_CHAOS = AF_CHAOS;
+pub const PF_DATAKIT = AF_DATAKIT;
+pub const PF_INET = AF_INET;
+pub const PF_APPLETALK = AF_APPLETALK;
+pub const PF_SIP = AF_SIP;
+pub const PF_OSI = AF_ISO;
+pub const PF_CNT = AF_CNT;
+pub const PF_LINK = AF_LINK;
+pub const PF_HYLINK = AF_HYLINK;
+pub const PF_MAX = AF_MAX;
+pub const PF_KEY = pseudo_AF_KEY;
+pub const PF_PUP = AF_PUP;
+pub const PF_COIP = AF_COIP;
+pub const PF_SNA = AF_SNA;
+pub const PF_LOCAL = AF_LOCAL;
+pub const PF_NETBIOS = AF_NETBIOS;
+pub const PF_NATM = AF_NATM;
+pub const PF_BLUETOOTH = AF_BLUETOOTH;
+pub const PF_UNSPEC = AF_UNSPEC;
+pub const PF_NETGRAPH = AF_NETGRAPH;
+pub const PF_ECMA = AF_ECMA;
+pub const PF_IPX = AF_IPX;
+pub const PF_DLI = AF_DLI;
+pub const PF_ATM = AF_ATM;
+pub const PF_CCITT = AF_CCITT;
+pub const PF_ISDN = AF_ISDN;
+pub const PF_RTIP = pseudo_AF_RTIP;
+pub const PF_LAT = AF_LAT;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_XTP = pseudo_AF_XTP;
+pub const PF_DECnet = AF_DECnet;
+
+pub const AF_UNSPEC = 0;
+pub const AF_OSI = AF_ISO;
+pub const AF_UNIX = AF_LOCAL;
+pub const AF_LOCAL = 1;
+pub const AF_INET = 2;
+pub const AF_IMPLINK = 3;
+pub const AF_PUP = 4;
+pub const AF_CHAOS = 5;
+pub const AF_NETBIOS = 6;
+pub const AF_ISO = 7;
+pub const AF_ECMA = 8;
+pub const AF_DATAKIT = 9;
+pub const AF_CCITT = 10;
+pub const AF_SNA = 11;
+pub const AF_DLI = 13;
+pub const AF_LAT = 14;
+pub const AF_HYLINK = 15;
+pub const AF_APPLETALK = 16;
+pub const AF_ROUTE = 17;
+pub const AF_LINK = 18;
+pub const AF_COIP = 20;
+pub const AF_CNT = 21;
+pub const AF_IPX = 23;
+pub const AF_SIP = 24;
+pub const AF_ISDN = 26;
+pub const AF_INET6 = 28;
+pub const AF_NATM = 29;
+pub const AF_ATM = 30;
+pub const AF_NETGRAPH = 32;
+pub const AF_BLUETOOTH = 33;
+pub const AF_MPLS = 34;
+pub const AF_MAX = 36;
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+pub const socklen_t = u32;
+
+pub const sockaddr_in = extern struct {
+    len: u8 = @sizeOf(sockaddr_in),
+    family: sa_family_t = AF_INET,
+    port: in_port_t,
+    addr: u32,
+    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+};
+
+pub const sockaddr_in6 = extern struct {
+    len: u8 = @sizeOf(sockaddr_in6),
+    family: sa_family_t = AF_INET6,
+    port: in_port_t,
+    flowinfo: u32,
+    addr: [16]u8,
+    scope_id: u32,
+};
+
+pub const EAI = enum(c_int) {
+    ADDRFAMILY = 1,
+    AGAIN = 2,
+    BADFLAGS = 3,
+    FAIL = 4,
+    FAMILY = 5,
+    MEMORY = 6,
+    NODATA = 7,
+    NONAME = 8,
+    SERVICE = 9,
+    SOCKTYPE = 10,
+    SYSTEM = 11,
+    BADHINTS = 12,
+    PROTOCOL = 13,
+    OVERFLOW = 14,
+    _,
+};
+
+pub const AI_PASSIVE = 0x00000001;
+pub const AI_CANONNAME = 0x00000002;
+pub const AI_NUMERICHOST = 0x00000004;
+pub const AI_NUMERICSERV = 0x00000008;
+pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG;
+pub const AI_ALL = 0x00000100;
+pub const AI_V4MAPPED_CFG = 0x00000200;
+pub const AI_ADDRCONFIG = 0x00000400;
+pub const AI_V4MAPPED = 0x00000800;
+pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
+
+pub const RTLD_LAZY = 1;
+pub const RTLD_NOW = 2;
+pub const RTLD_MODEMASK = 0x3;
+pub const RTLD_GLOBAL = 0x100;
+pub const RTLD_LOCAL = 0;
+pub const RTLD_TRACE = 0x200;
+pub const RTLD_NODELETE = 0x01000;
+pub const RTLD_NOLOAD = 0x02000;
+
+pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
+pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
+pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
+pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));
+
+pub const dl_phdr_info = extern struct {
+    dlpi_addr: usize,
+    dlpi_name: ?[*:0]const u8,
+    dlpi_phdr: [*]std.elf.Phdr,
+    dlpi_phnum: u16,
+};
+pub const cmsghdr = extern struct {
+    cmsg_len: socklen_t,
+    cmsg_level: c_int,
+    cmsg_type: c_int,
+};
+pub const msghdr = extern struct {
+    msg_name: ?*c_void,
+    msg_namelen: socklen_t,
+    msg_iov: [*c]iovec,
+    msg_iovlen: c_int,
+    msg_control: ?*c_void,
+    msg_controllen: socklen_t,
+    msg_flags: c_int,
+};
+pub const cmsgcred = extern struct {
+    cmcred_pid: pid_t,
+    cmcred_uid: uid_t,
+    cmcred_euid: uid_t,
+    cmcred_gid: gid_t,
+    cmcred_ngroups: c_short,
+    cmcred_groups: [16]gid_t,
+};
+pub const sf_hdtr = extern struct {
+    headers: [*c]iovec,
+    hdr_cnt: c_int,
+    trailers: [*c]iovec,
+    trl_cnt: c_int,
+};
+
+pub const MS_SYNC = 0;
+pub const MS_ASYNC = 1;
+pub const MS_INVALIDATE = 2;
+
+pub const POSIX_MADV_SEQUENTIAL = 2;
+pub const POSIX_MADV_RANDOM = 1;
+pub const POSIX_MADV_DONTNEED = 4;
+pub const POSIX_MADV_NORMAL = 0;
+pub const POSIX_MADV_WILLNEED = 3;
+
+pub const MADV_SEQUENTIAL = 2;
+pub const MADV_CONTROL_END = MADV_SETMAP;
+pub const MADV_DONTNEED = 4;
+pub const MADV_RANDOM = 1;
+pub const MADV_WILLNEED = 3;
+pub const MADV_NORMAL = 0;
+pub const MADV_CONTROL_START = MADV_INVAL;
+pub const MADV_FREE = 5;
+pub const MADV_NOSYNC = 6;
+pub const MADV_AUTOSYNC = 7;
+pub const MADV_NOCORE = 8;
+pub const MADV_CORE = 9;
+pub const MADV_INVAL = 10;
+pub const MADV_SETMAP = 11;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_RDLCK = 1;
+pub const F_SETFD = 2;
+pub const F_UNLCK = 2;
+pub const F_WRLCK = 3;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+pub const F_GETOWN = 5;
+pub const F_SETOWN = 6;
+pub const F_GETLK = 7;
+pub const F_SETLK = 8;
+pub const F_SETLKW = 9;
+pub const F_DUP2FD = 10;
+pub const F_DUPFD_CLOEXEC = 17;
+pub const F_DUP2FD_CLOEXEC = 18;
+
+pub const LOCK_SH = 1;
+pub const LOCK_EX = 2;
+pub const LOCK_UN = 8;
+pub const LOCK_NB = 4;
+
+pub const Flock = extern struct {
+    l_start: off_t,
+    l_len: off_t,
+    l_pid: pid_t,
+    l_type: c_short,
+    l_whence: c_short,
+};
+
+pub const addrinfo = extern struct {
+    flags: i32,
+    family: i32,
+    socktype: i32,
+    protocol: i32,
+    addrlen: socklen_t,
+    canonname: ?[*:0]u8,
+    addr: ?*sockaddr,
+    next: ?*addrinfo,
+};
+
+pub const IPPROTO_IP = 0;
+pub const IPPROTO_ICMP = 1;
+pub const IPPROTO_TCP = 6;
+pub const IPPROTO_UDP = 17;
+pub const IPPROTO_IPV6 = 41;
+pub const IPPROTO_RAW = 255;
+pub const IPPROTO_HOPOPTS = 0;
+pub const IPPROTO_IGMP = 2;
+pub const IPPROTO_GGP = 3;
+pub const IPPROTO_IPV4 = 4;
+pub const IPPROTO_IPIP = IPPROTO_IPV4;
+pub const IPPROTO_ST = 7;
+pub const IPPROTO_EGP = 8;
+pub const IPPROTO_PIGP = 9;
+pub const IPPROTO_RCCMON = 10;
+pub const IPPROTO_NVPII = 11;
+pub const IPPROTO_PUP = 12;
+pub const IPPROTO_ARGUS = 13;
+pub const IPPROTO_EMCON = 14;
+pub const IPPROTO_XNET = 15;
+pub const IPPROTO_CHAOS = 16;
+pub const IPPROTO_MUX = 18;
+pub const IPPROTO_MEAS = 19;
+pub const IPPROTO_HMP = 20;
+pub const IPPROTO_PRM = 21;
+pub const IPPROTO_IDP = 22;
+pub const IPPROTO_TRUNK1 = 23;
+pub const IPPROTO_TRUNK2 = 24;
+pub const IPPROTO_LEAF1 = 25;
+pub const IPPROTO_LEAF2 = 26;
+pub const IPPROTO_RDP = 27;
+pub const IPPROTO_IRTP = 28;
+pub const IPPROTO_TP = 29;
+pub const IPPROTO_BLT = 30;
+pub const IPPROTO_NSP = 31;
+pub const IPPROTO_INP = 32;
+pub const IPPROTO_SEP = 33;
+pub const IPPROTO_3PC = 34;
+pub const IPPROTO_IDPR = 35;
+pub const IPPROTO_XTP = 36;
+pub const IPPROTO_DDP = 37;
+pub const IPPROTO_CMTP = 38;
+pub const IPPROTO_TPXX = 39;
+pub const IPPROTO_IL = 40;
+pub const IPPROTO_SDRP = 42;
+pub const IPPROTO_ROUTING = 43;
+pub const IPPROTO_FRAGMENT = 44;
+pub const IPPROTO_IDRP = 45;
+pub const IPPROTO_RSVP = 46;
+pub const IPPROTO_GRE = 47;
+pub const IPPROTO_MHRP = 48;
+pub const IPPROTO_BHA = 49;
+pub const IPPROTO_ESP = 50;
+pub const IPPROTO_AH = 51;
+pub const IPPROTO_INLSP = 52;
+pub const IPPROTO_SWIPE = 53;
+pub const IPPROTO_NHRP = 54;
+pub const IPPROTO_MOBILE = 55;
+pub const IPPROTO_TLSP = 56;
+pub const IPPROTO_SKIP = 57;
+pub const IPPROTO_ICMPV6 = 58;
+pub const IPPROTO_NONE = 59;
+pub const IPPROTO_DSTOPTS = 60;
+pub const IPPROTO_AHIP = 61;
+pub const IPPROTO_CFTP = 62;
+pub const IPPROTO_HELLO = 63;
+pub const IPPROTO_SATEXPAK = 64;
+pub const IPPROTO_KRYPTOLAN = 65;
+pub const IPPROTO_RVD = 66;
+pub const IPPROTO_IPPC = 67;
+pub const IPPROTO_ADFS = 68;
+pub const IPPROTO_SATMON = 69;
+pub const IPPROTO_VISA = 70;
+pub const IPPROTO_IPCV = 71;
+pub const IPPROTO_CPNX = 72;
+pub const IPPROTO_CPHB = 73;
+pub const IPPROTO_WSN = 74;
+pub const IPPROTO_PVP = 75;
+pub const IPPROTO_BRSATMON = 76;
+pub const IPPROTO_ND = 77;
+pub const IPPROTO_WBMON = 78;
+pub const IPPROTO_WBEXPAK = 79;
+pub const IPPROTO_EON = 80;
+pub const IPPROTO_VMTP = 81;
+pub const IPPROTO_SVMTP = 82;
+pub const IPPROTO_VINES = 83;
+pub const IPPROTO_TTP = 84;
+pub const IPPROTO_IGP = 85;
+pub const IPPROTO_DGP = 86;
+pub const IPPROTO_TCF = 87;
+pub const IPPROTO_IGRP = 88;
+pub const IPPROTO_OSPFIGP = 89;
+pub const IPPROTO_SRPC = 90;
+pub const IPPROTO_LARP = 91;
+pub const IPPROTO_MTP = 92;
+pub const IPPROTO_AX25 = 93;
+pub const IPPROTO_IPEIP = 94;
+pub const IPPROTO_MICP = 95;
+pub const IPPROTO_SCCSP = 96;
+pub const IPPROTO_ETHERIP = 97;
+pub const IPPROTO_ENCAP = 98;
+pub const IPPROTO_APES = 99;
+pub const IPPROTO_GMTP = 100;
+pub const IPPROTO_IPCOMP = 108;
+pub const IPPROTO_PIM = 103;
+pub const IPPROTO_CARP = 112;
+pub const IPPROTO_PGM = 113;
+pub const IPPROTO_PFSYNC = 240;
+pub const IPPROTO_DIVERT = 254;
+pub const IPPROTO_MAX = 256;
+pub const IPPROTO_DONE = 257;
+pub const IPPROTO_UNKNOWN = 258;
+
+pub const rlimit_resource = enum(c_int) {
+    CPU = 0,
+    FSIZE = 1,
+    DATA = 2,
+    STACK = 3,
+    CORE = 4,
+    RSS = 5,
+    MEMLOCK = 6,
+    NPROC = 7,
+    NOFILE = 8,
+    SBSIZE = 9,
+    VMEM = 10,
+    POSIXLOCKS = 11,
+    _,
+
+    pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = i64;
+
+/// No limit
+pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
+
+pub const RLIM_SAVED_MAX = RLIM_INFINITY;
+pub const RLIM_SAVED_CUR = RLIM_INFINITY;
+
+pub const rlimit = extern struct {
+    /// Soft limit
+    cur: rlim_t,
+    /// Hard limit
+    max: rlim_t,
+};
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 2;
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+    fd: fd_t,
+    events: i16,
+    revents: i16,
+};
+
+/// Requestable events.
+pub const POLLIN = 0x0001;
+pub const POLLPRI = 0x0002;
+pub const POLLOUT = 0x0004;
+pub const POLLRDNORM = 0x0040;
+pub const POLLWRNORM = POLLOUT;
+pub const POLLRDBAND = 0x0080;
+pub const POLLWRBAND = 0x0100;
+
+/// These events are set if they occur regardless of whether they were requested.
+pub const POLLERR = 0x0008;
+pub const POLLHUP = 0x0010;
+pub const POLLNVAL = 0x0020;
lib/std/c/freebsd.zig
@@ -1,5 +1,5 @@
 const std = @import("../std.zig");
-usingnamespace std.c;
+const maxInt = std.math.maxInt;
 
 extern "c" fn __error() *c_int;
 pub const _errno = __error;
@@ -136,3 +136,1540 @@ pub const AI_V4MAPPED = 0x00000800;
 
 /// special recommended flags for getipnodebyname
 pub const AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG);
+
+pub const blksize_t = i32;
+pub const blkcnt_t = i64;
+pub const clockid_t = i32;
+pub const fsblkcnt_t = u64;
+pub const fsfilcnt_t = u64;
+pub const nlink_t = u64;
+pub const fd_t = i32;
+pub const pid_t = i32;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const mode_t = u16;
+pub const off_t = i64;
+pub const ino_t = u64;
+pub const dev_t = u64;
+pub const time_t = i64;
+// The signedness is not constant across different architectures.
+pub const clock_t = isize;
+
+pub const socklen_t = u32;
+pub const suseconds_t = c_long;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+    ident: usize,
+    filter: i16,
+    flags: u16,
+    fflags: u32,
+    data: i64,
+    udata: usize,
+    // TODO ext
+};
+
+// Modes and flags for dlopen()
+// include/dlfcn.h
+
+/// Bind function calls lazily.
+pub const RTLD_LAZY = 1;
+
+/// Bind function calls immediately.
+pub const RTLD_NOW = 2;
+
+pub const RTLD_MODEMASK = 0x3;
+
+/// Make symbols globally available.
+pub const RTLD_GLOBAL = 0x100;
+
+/// Opposite of RTLD_GLOBAL, and the default.
+pub const RTLD_LOCAL = 0;
+
+/// Trace loaded objects and exit.
+pub const RTLD_TRACE = 0x200;
+
+/// Do not remove members.
+pub const RTLD_NODELETE = 0x01000;
+
+/// Do not load if not already loaded.
+pub const RTLD_NOLOAD = 0x02000;
+
+pub const dl_phdr_info = extern struct {
+    dlpi_addr: usize,
+    dlpi_name: ?[*:0]const u8,
+    dlpi_phdr: [*]std.elf.Phdr,
+    dlpi_phnum: u16,
+};
+
+pub const Flock = extern struct {
+    l_start: off_t,
+    l_len: off_t,
+    l_pid: pid_t,
+    l_type: i16,
+    l_whence: i16,
+    l_sysid: i32,
+    __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+    /// optional address
+    msg_name: ?*sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec,
+
+    /// # elements in msg_iov
+    msg_iovlen: i32,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+    /// optional address
+    msg_name: ?*const sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec_const,
+
+    /// # elements in msg_iov
+    msg_iovlen: i32,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: i32,
+};
+
+pub const Stat = extern struct {
+    dev: dev_t,
+    ino: ino_t,
+    nlink: nlink_t,
+
+    mode: mode_t,
+    __pad0: u16,
+    uid: uid_t,
+    gid: gid_t,
+    __pad1: u32,
+    rdev: dev_t,
+
+    atim: timespec,
+    mtim: timespec,
+    ctim: timespec,
+    birthtim: timespec,
+
+    size: off_t,
+    blocks: i64,
+    blksize: isize,
+    flags: u32,
+    gen: u64,
+    __spare: [10]u64,
+
+    pub fn atime(self: @This()) timespec {
+        return self.atim;
+    }
+
+    pub fn mtime(self: @This()) timespec {
+        return self.mtim;
+    }
+
+    pub fn ctime(self: @This()) timespec {
+        return self.ctim;
+    }
+};
+
+pub const timespec = extern struct {
+    tv_sec: isize,
+    tv_nsec: isize,
+};
+
+pub const timeval = extern struct {
+    /// seconds
+    tv_sec: time_t,
+    /// microseconds
+    tv_usec: suseconds_t,
+};
+
+pub const dirent = extern struct {
+    d_fileno: usize,
+    d_off: i64,
+    d_reclen: u16,
+    d_type: u8,
+    d_pad0: u8,
+    d_namlen: u16,
+    d_pad1: u16,
+    d_name: [256]u8,
+
+    pub fn reclen(self: dirent) u16 {
+        return self.d_reclen;
+    }
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+    /// total length
+    len: u8,
+
+    /// address family
+    family: sa_family_t,
+
+    /// actually longer; address value
+    data: [14]u8,
+};
+
+pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+
+pub const sockaddr_in = extern struct {
+    len: u8 = @sizeOf(sockaddr_in),
+    family: sa_family_t = AF_INET,
+    port: in_port_t,
+    addr: u32,
+    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+};
+
+pub const sockaddr_in6 = extern struct {
+    len: u8 = @sizeOf(sockaddr_in6),
+    family: sa_family_t = AF_INET6,
+    port: in_port_t,
+    flowinfo: u32,
+    addr: [16]u8,
+    scope_id: u32,
+};
+
+pub const sockaddr_un = extern struct {
+    len: u8 = @sizeOf(sockaddr_un),
+    family: sa_family_t = AF_UNIX,
+    path: [104]u8,
+};
+
+pub const CTL_KERN = 1;
+pub const CTL_DEBUG = 5;
+
+pub const KERN_PROC = 14; // struct: process entries
+pub const KERN_PROC_PATHNAME = 12; // path to executable
+pub const KERN_IOV_MAX = 35;
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = KERN_IOV_MAX;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT_NONE = 0;
+pub const PROT_READ = 1;
+pub const PROT_WRITE = 2;
+pub const PROT_EXEC = 4;
+
+pub const CLOCK_REALTIME = 0;
+pub const CLOCK_VIRTUAL = 1;
+pub const CLOCK_PROF = 2;
+pub const CLOCK_MONOTONIC = 4;
+pub const CLOCK_UPTIME = 5;
+pub const CLOCK_UPTIME_PRECISE = 7;
+pub const CLOCK_UPTIME_FAST = 8;
+pub const CLOCK_REALTIME_PRECISE = 9;
+pub const CLOCK_REALTIME_FAST = 10;
+pub const CLOCK_MONOTONIC_PRECISE = 11;
+pub const CLOCK_MONOTONIC_FAST = 12;
+pub const CLOCK_SECOND = 13;
+pub const CLOCK_THREAD_CPUTIME_ID = 14;
+pub const CLOCK_PROCESS_CPUTIME_ID = 15;
+
+pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+pub const MAP_SHARED = 0x0001;
+pub const MAP_PRIVATE = 0x0002;
+pub const MAP_FIXED = 0x0010;
+pub const MAP_STACK = 0x0400;
+pub const MAP_NOSYNC = 0x0800;
+pub const MAP_ANON = 0x1000;
+pub const MAP_ANONYMOUS = MAP_ANON;
+pub const MAP_FILE = 0;
+
+pub const MAP_GUARD = 0x00002000;
+pub const MAP_EXCL = 0x00004000;
+pub const MAP_NOCORE = 0x00020000;
+pub const MAP_PREFAULT_READ = 0x00040000;
+pub const MAP_32BIT = 0x00080000;
+
+pub const WNOHANG = 1;
+pub const WUNTRACED = 2;
+pub const WSTOPPED = WUNTRACED;
+pub const WCONTINUED = 4;
+pub const WNOWAIT = 8;
+pub const WEXITED = 16;
+pub const WTRAPPED = 32;
+
+pub const SA_ONSTACK = 0x0001;
+pub const SA_RESTART = 0x0002;
+pub const SA_RESETHAND = 0x0004;
+pub const SA_NOCLDSTOP = 0x0008;
+pub const SA_NODEFER = 0x0010;
+pub const SA_NOCLDWAIT = 0x0020;
+pub const SA_SIGINFO = 0x0040;
+
+pub const SIGHUP = 1;
+pub const SIGINT = 2;
+pub const SIGQUIT = 3;
+pub const SIGILL = 4;
+pub const SIGTRAP = 5;
+pub const SIGABRT = 6;
+pub const SIGIOT = SIGABRT;
+pub const SIGEMT = 7;
+pub const SIGFPE = 8;
+pub const SIGKILL = 9;
+pub const SIGBUS = 10;
+pub const SIGSEGV = 11;
+pub const SIGSYS = 12;
+pub const SIGPIPE = 13;
+pub const SIGALRM = 14;
+pub const SIGTERM = 15;
+pub const SIGURG = 16;
+pub const SIGSTOP = 17;
+pub const SIGTSTP = 18;
+pub const SIGCONT = 19;
+pub const SIGCHLD = 20;
+pub const SIGTTIN = 21;
+pub const SIGTTOU = 22;
+pub const SIGIO = 23;
+pub const SIGXCPU = 24;
+pub const SIGXFSZ = 25;
+pub const SIGVTALRM = 26;
+pub const SIGPROF = 27;
+pub const SIGWINCH = 28;
+pub const SIGINFO = 29;
+pub const SIGUSR1 = 30;
+pub const SIGUSR2 = 31;
+pub const SIGTHR = 32;
+pub const SIGLWP = SIGTHR;
+pub const SIGLIBRT = 33;
+
+pub const SIGRTMIN = 65;
+pub const SIGRTMAX = 126;
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O_RDONLY = 0x0000;
+pub const O_WRONLY = 0x0001;
+pub const O_RDWR = 0x0002;
+pub const O_ACCMODE = 0x0003;
+
+pub const O_SHLOCK = 0x0010;
+pub const O_EXLOCK = 0x0020;
+
+pub const O_CREAT = 0x0200;
+pub const O_EXCL = 0x0800;
+pub const O_NOCTTY = 0x8000;
+pub const O_TRUNC = 0x0400;
+pub const O_APPEND = 0x0008;
+pub const O_NONBLOCK = 0x0004;
+pub const O_DSYNC = 0o10000;
+pub const O_SYNC = 0x0080;
+pub const O_RSYNC = 0o4010000;
+pub const O_DIRECTORY = 0x20000;
+pub const O_NOFOLLOW = 0x0100;
+pub const O_CLOEXEC = 0x00100000;
+
+pub const O_ASYNC = 0x0040;
+pub const O_DIRECT = 0x00010000;
+pub const O_NOATIME = 0o1000000;
+pub const O_PATH = 0o10000000;
+pub const O_TMPFILE = 0o20200000;
+pub const O_NDELAY = O_NONBLOCK;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_SETFD = 2;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+
+pub const F_GETOWN = 5;
+pub const F_SETOWN = 6;
+
+pub const F_GETLK = 11;
+pub const F_SETLK = 12;
+pub const F_SETLKW = 13;
+
+pub const F_RDLCK = 1;
+pub const F_WRLCK = 3;
+pub const F_UNLCK = 2;
+
+pub const LOCK_SH = 1;
+pub const LOCK_EX = 2;
+pub const LOCK_UN = 8;
+pub const LOCK_NB = 4;
+
+pub const F_SETOWN_EX = 15;
+pub const F_GETOWN_EX = 16;
+
+pub const F_GETOWNER_UIDS = 17;
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+
+pub const SIG_BLOCK = 1;
+pub const SIG_UNBLOCK = 2;
+pub const SIG_SETMASK = 3;
+
+pub const SOCK_STREAM = 1;
+pub const SOCK_DGRAM = 2;
+pub const SOCK_RAW = 3;
+pub const SOCK_RDM = 4;
+pub const SOCK_SEQPACKET = 5;
+
+pub const SOCK_CLOEXEC = 0x10000000;
+pub const SOCK_NONBLOCK = 0x20000000;
+
+pub const SO_DEBUG = 0x00000001;
+pub const SO_ACCEPTCONN = 0x00000002;
+pub const SO_REUSEADDR = 0x00000004;
+pub const SO_KEEPALIVE = 0x00000008;
+pub const SO_DONTROUTE = 0x00000010;
+pub const SO_BROADCAST = 0x00000020;
+pub const SO_USELOOPBACK = 0x00000040;
+pub const SO_LINGER = 0x00000080;
+pub const SO_OOBINLINE = 0x00000100;
+pub const SO_REUSEPORT = 0x00000200;
+pub const SO_TIMESTAMP = 0x00000400;
+pub const SO_NOSIGPIPE = 0x00000800;
+pub const SO_ACCEPTFILTER = 0x00001000;
+pub const SO_BINTIME = 0x00002000;
+pub const SO_NO_OFFLOAD = 0x00004000;
+pub const SO_NO_DDP = 0x00008000;
+pub const SO_REUSEPORT_LB = 0x00010000;
+
+pub const SO_SNDBUF = 0x1001;
+pub const SO_RCVBUF = 0x1002;
+pub const SO_SNDLOWAT = 0x1003;
+pub const SO_RCVLOWAT = 0x1004;
+pub const SO_SNDTIMEO = 0x1005;
+pub const SO_RCVTIMEO = 0x1006;
+pub const SO_ERROR = 0x1007;
+pub const SO_TYPE = 0x1008;
+pub const SO_LABEL = 0x1009;
+pub const SO_PEERLABEL = 0x1010;
+pub const SO_LISTENQLIMIT = 0x1011;
+pub const SO_LISTENQLEN = 0x1012;
+pub const SO_LISTENINCQLEN = 0x1013;
+pub const SO_SETFIB = 0x1014;
+pub const SO_USER_COOKIE = 0x1015;
+pub const SO_PROTOCOL = 0x1016;
+pub const SO_PROTOTYPE = SO_PROTOCOL;
+pub const SO_TS_CLOCK = 0x1017;
+pub const SO_MAX_PACING_RATE = 0x1018;
+pub const SO_DOMAIN = 0x1019;
+
+pub const SOL_SOCKET = 0xffff;
+
+pub const PF_UNSPEC = AF_UNSPEC;
+pub const PF_LOCAL = AF_LOCAL;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_INET = AF_INET;
+pub const PF_IMPLINK = AF_IMPLINK;
+pub const PF_PUP = AF_PUP;
+pub const PF_CHAOS = AF_CHAOS;
+pub const PF_NETBIOS = AF_NETBIOS;
+pub const PF_ISO = AF_ISO;
+pub const PF_OSI = AF_ISO;
+pub const PF_ECMA = AF_ECMA;
+pub const PF_DATAKIT = AF_DATAKIT;
+pub const PF_CCITT = AF_CCITT;
+pub const PF_DECnet = AF_DECnet;
+pub const PF_DLI = AF_DLI;
+pub const PF_LAT = AF_LAT;
+pub const PF_HYLINK = AF_HYLINK;
+pub const PF_APPLETALK = AF_APPLETALK;
+pub const PF_ROUTE = AF_ROUTE;
+pub const PF_LINK = AF_LINK;
+pub const PF_XTP = pseudo_AF_XTP;
+pub const PF_COIP = AF_COIP;
+pub const PF_CNT = AF_CNT;
+pub const PF_SIP = AF_SIP;
+pub const PF_IPX = AF_IPX;
+pub const PF_RTIP = pseudo_AF_RTIP;
+pub const PF_PIP = psuedo_AF_PIP;
+pub const PF_ISDN = AF_ISDN;
+pub const PF_KEY = pseudo_AF_KEY;
+pub const PF_INET6 = pseudo_AF_INET6;
+pub const PF_NATM = AF_NATM;
+pub const PF_ATM = AF_ATM;
+pub const PF_NETGRAPH = AF_NETGRAPH;
+pub const PF_SLOW = AF_SLOW;
+pub const PF_SCLUSTER = AF_SCLUSTER;
+pub const PF_ARP = AF_ARP;
+pub const PF_BLUETOOTH = AF_BLUETOOTH;
+pub const PF_IEEE80211 = AF_IEEE80211;
+pub const PF_INET_SDP = AF_INET_SDP;
+pub const PF_INET6_SDP = AF_INET6_SDP;
+pub const PF_MAX = AF_MAX;
+
+pub const AF_UNSPEC = 0;
+pub const AF_UNIX = 1;
+pub const AF_LOCAL = AF_UNIX;
+pub const AF_FILE = AF_LOCAL;
+pub const AF_INET = 2;
+pub const AF_IMPLINK = 3;
+pub const AF_PUP = 4;
+pub const AF_CHAOS = 5;
+pub const AF_NETBIOS = 6;
+pub const AF_ISO = 7;
+pub const AF_OSI = AF_ISO;
+pub const AF_ECMA = 8;
+pub const AF_DATAKIT = 9;
+pub const AF_CCITT = 10;
+pub const AF_SNA = 11;
+pub const AF_DECnet = 12;
+pub const AF_DLI = 13;
+pub const AF_LAT = 14;
+pub const AF_HYLINK = 15;
+pub const AF_APPLETALK = 16;
+pub const AF_ROUTE = 17;
+pub const AF_LINK = 18;
+pub const pseudo_AF_XTP = 19;
+pub const AF_COIP = 20;
+pub const AF_CNT = 21;
+pub const pseudo_AF_RTIP = 22;
+pub const AF_IPX = 23;
+pub const AF_SIP = 24;
+pub const pseudo_AF_PIP = 25;
+pub const AF_ISDN = 26;
+pub const AF_E164 = AF_ISDN;
+pub const pseudo_AF_KEY = 27;
+pub const AF_INET6 = 28;
+pub const AF_NATM = 29;
+pub const AF_ATM = 30;
+pub const pseudo_AF_HDRCMPLT = 31;
+pub const AF_NETGRAPH = 32;
+pub const AF_SLOW = 33;
+pub const AF_SCLUSTER = 34;
+pub const AF_ARP = 35;
+pub const AF_BLUETOOTH = 36;
+pub const AF_IEEE80211 = 37;
+pub const AF_INET_SDP = 40;
+pub const AF_INET6_SDP = 42;
+pub const AF_MAX = 42;
+
+pub const DT_UNKNOWN = 0;
+pub const DT_FIFO = 1;
+pub const DT_CHR = 2;
+pub const DT_DIR = 4;
+pub const DT_BLK = 6;
+pub const DT_REG = 8;
+pub const DT_LNK = 10;
+pub const DT_SOCK = 12;
+pub const DT_WHT = 14;
+
+/// 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;
+
+/// error, event data contains errno
+pub const EV_ERROR = 0x4000;
+
+/// force immediate event output
+/// ... with or without EV_ERROR
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+///     on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
+
+/// 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;
+
+/// Process descriptors
+pub const EVFILT_PROCDESC = -8;
+
+/// Filesystem events
+pub const EVFILT_FS = -9;
+
+pub const EVFILT_LIO = -10;
+
+/// User events
+pub const EVFILT_USER = -11;
+
+/// Sendfile events
+pub const EVFILT_SENDFILE = -12;
+
+pub const EVFILT_EMPTY = -13;
+
+/// On input, NOTE_TRIGGER causes the event to be triggered for output.
+pub const NOTE_TRIGGER = 0x01000000;
+
+/// 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;
+
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// behave like poll()
+pub const NOTE_FILE_POLL = 0x00000002;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// 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;
+
+/// vnode was opened
+pub const NOTE_OPEN = 0x00000080;
+
+/// file closed, fd did not allow write
+pub const NOTE_CLOSE = 0x00000100;
+
+/// file closed, fd did allow write
+pub const NOTE_CLOSE_WRITE = 0x00000200;
+
+/// file was read
+pub const NOTE_READ = 0x00000400;
+
+/// process exited
+pub const NOTE_EXIT = 0x80000000;
+
+/// process forked
+pub const NOTE_FORK = 0x40000000;
+
+/// process exec'd
+pub const NOTE_EXEC = 0x20000000;
+
+/// mask for signal & exit status
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
+
+/// data is seconds
+pub const NOTE_SECONDS = 0x00000001;
+
+/// data is milliseconds
+pub const NOTE_MSECONDS = 0x00000002;
+
+/// data is microseconds
+pub const NOTE_USECONDS = 0x00000004;
+
+/// data is nanoseconds
+pub const NOTE_NSECONDS = 0x00000008;
+
+/// timeout is absolute
+pub const NOTE_ABSTIME = 0x00000010;
+
+pub const TIOCEXCL = 0x2000740d;
+pub const TIOCNXCL = 0x2000740e;
+pub const TIOCSCTTY = 0x20007461;
+pub const TIOCGPGRP = 0x40047477;
+pub const TIOCSPGRP = 0x80047476;
+pub const TIOCOUTQ = 0x40047473;
+pub const TIOCSTI = 0x80017472;
+pub const TIOCGWINSZ = 0x40087468;
+pub const TIOCSWINSZ = 0x80087467;
+pub const TIOCMGET = 0x4004746a;
+pub const TIOCMBIS = 0x8004746c;
+pub const TIOCMBIC = 0x8004746b;
+pub const TIOCMSET = 0x8004746d;
+pub const FIONREAD = 0x4004667f;
+pub const TIOCCONS = 0x80047462;
+pub const TIOCPKT = 0x80047470;
+pub const FIONBIO = 0x8004667e;
+pub const TIOCNOTTY = 0x20007471;
+pub const TIOCSETD = 0x8004741b;
+pub const TIOCGETD = 0x4004741a;
+pub const TIOCSBRK = 0x2000747b;
+pub const TIOCCBRK = 0x2000747a;
+pub const TIOCGSID = 0x40047463;
+pub const TIOCGPTN = 0x4004740f;
+pub const TIOCSIG = 0x2004745f;
+
+pub fn WEXITSTATUS(s: u32) u8 {
+    return @intCast(u8, (s & 0xff00) >> 8);
+}
+pub fn WTERMSIG(s: u32) u32 {
+    return s & 0x7f;
+}
+pub fn WSTOPSIG(s: u32) u32 {
+    return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: u32) bool {
+    return WTERMSIG(s) == 0;
+}
+pub fn WIFSTOPPED(s: u32) bool {
+    return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
+}
+pub fn WIFSIGNALED(s: u32) bool {
+    return (s & 0xffff) -% 1 < 0xff;
+}
+
+pub const winsize = extern struct {
+    ws_row: u16,
+    ws_col: u16,
+    ws_xpixel: u16,
+    ws_ypixel: u16,
+};
+
+const NSIG = 32;
+
+pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+    pub const handler_fn = fn (c_int) callconv(.C) void;
+    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+    /// signal handler
+    handler: extern union {
+        handler: ?handler_fn,
+        sigaction: ?sigaction_fn,
+    },
+
+    /// see signal options
+    flags: c_uint,
+
+    /// signal mask to apply
+    mask: sigset_t,
+};
+
+pub const siginfo_t = extern struct {
+    signo: c_int,
+    errno: c_int,
+    code: c_int,
+    pid: pid_t,
+    uid: uid_t,
+    status: c_int,
+    addr: ?*c_void,
+    value: sigval,
+    reason: extern union {
+        fault: extern struct {
+            trapno: c_int,
+        },
+        timer: extern struct {
+            timerid: c_int,
+            overrun: c_int,
+        },
+        mesgq: extern struct {
+            mqd: c_int,
+        },
+        poll: extern struct {
+            band: c_long,
+        },
+        spare: extern struct {
+            spare1: c_long,
+            spare2: [7]c_int,
+        },
+    },
+};
+
+pub const sigval = extern union {
+    int: c_int,
+    ptr: ?*c_void,
+};
+
+pub const _SIG_WORDS = 4;
+pub const _SIG_MAXSIG = 128;
+
+pub inline fn _SIG_IDX(sig: usize) usize {
+    return sig - 1;
+}
+pub inline fn _SIG_WORD(sig: usize) usize {
+    return_SIG_IDX(sig) >> 5;
+}
+pub inline fn _SIG_BIT(sig: usize) usize {
+    return 1 << (_SIG_IDX(sig) & 31);
+}
+pub inline fn _SIG_VALID(sig: usize) usize {
+    return sig <= _SIG_MAXSIG and sig > 0;
+}
+
+pub const sigset_t = extern struct {
+    __bits: [_SIG_WORDS]u32,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
+
+pub usingnamespace switch (builtin.cpu.arch) {
+    .x86_64 => struct {
+        pub const ucontext_t = extern struct {
+            sigmask: sigset_t,
+            mcontext: mcontext_t,
+            link: ?*ucontext_t,
+            stack: stack_t,
+            flags: c_int,
+            __spare__: [4]c_int,
+        };
+
+        /// XXX x86_64 specific
+        pub const mcontext_t = extern struct {
+            onstack: u64,
+            rdi: u64,
+            rsi: u64,
+            rdx: u64,
+            rcx: u64,
+            r8: u64,
+            r9: u64,
+            rax: u64,
+            rbx: u64,
+            rbp: u64,
+            r10: u64,
+            r11: u64,
+            r12: u64,
+            r13: u64,
+            r14: u64,
+            r15: u64,
+            trapno: u32,
+            fs: u16,
+            gs: u16,
+            addr: u64,
+            flags: u32,
+            es: u16,
+            ds: u16,
+            err: u64,
+            rip: u64,
+            cs: u64,
+            rflags: u64,
+            rsp: u64,
+            ss: u64,
+        };
+    },
+    else => struct {},
+};
+
+pub const E = enum(u16) {
+    /// No error occurred.
+    SUCCESS = 0,
+
+    PERM = 1, // Operation not permitted
+    NOENT = 2, // No such file or directory
+    SRCH = 3, // No such process
+    INTR = 4, // Interrupted system call
+    IO = 5, // Input/output error
+    NXIO = 6, // Device not configured
+    @"2BIG" = 7, // Argument list too long
+    NOEXEC = 8, // Exec format error
+    BADF = 9, // Bad file descriptor
+    CHILD = 10, // No child processes
+    DEADLK = 11, // Resource deadlock avoided
+    // 11 was AGAIN
+    NOMEM = 12, // Cannot allocate memory
+    ACCES = 13, // Permission denied
+    FAULT = 14, // Bad address
+    NOTBLK = 15, // Block device required
+    BUSY = 16, // Device busy
+    EXIST = 17, // File exists
+    XDEV = 18, // Cross-device link
+    NODEV = 19, // Operation not supported by device
+    NOTDIR = 20, // Not a directory
+    ISDIR = 21, // Is a directory
+    INVAL = 22, // Invalid argument
+    NFILE = 23, // Too many open files in system
+    MFILE = 24, // Too many open files
+    NOTTY = 25, // Inappropriate ioctl for device
+    TXTBSY = 26, // Text file busy
+    FBIG = 27, // File too large
+    NOSPC = 28, // No space left on device
+    SPIPE = 29, // Illegal seek
+    ROFS = 30, // Read-only filesystem
+    MLINK = 31, // Too many links
+    PIPE = 32, // Broken pipe
+
+    // math software
+    DOM = 33, // Numerical argument out of domain
+    RANGE = 34, // Result too large
+
+    // non-blocking and interrupt i/o
+
+    /// Resource temporarily unavailable
+    /// This code is also used for `WOULDBLOCK`: operation would block.
+    AGAIN = 35,
+    INPROGRESS = 36, // Operation now in progress
+    ALREADY = 37, // Operation already in progress
+
+    // ipc/network software -- argument errors
+    NOTSOCK = 38, // Socket operation on non-socket
+    DESTADDRREQ = 39, // Destination address required
+    MSGSIZE = 40, // Message too long
+    PROTOTYPE = 41, // Protocol wrong type for socket
+    NOPROTOOPT = 42, // Protocol not available
+    PROTONOSUPPORT = 43, // Protocol not supported
+    SOCKTNOSUPPORT = 44, // Socket type not supported
+    /// Operation not supported
+    /// This code is also used for `NOTSUP`.
+    OPNOTSUPP = 45,
+    PFNOSUPPORT = 46, // Protocol family not supported
+    AFNOSUPPORT = 47, // Address family not supported by protocol family
+    ADDRINUSE = 48, // Address already in use
+    ADDRNOTAVAIL = 49, // Can't assign requested address
+
+    // ipc/network software -- operational errors
+    NETDOWN = 50, // Network is down
+    NETUNREACH = 51, // Network is unreachable
+    NETRESET = 52, // Network dropped connection on reset
+    CONNABORTED = 53, // Software caused connection abort
+    CONNRESET = 54, // Connection reset by peer
+    NOBUFS = 55, // No buffer space available
+    ISCONN = 56, // Socket is already connected
+    NOTCONN = 57, // Socket is not connected
+    SHUTDOWN = 58, // Can't send after socket shutdown
+    TOOMANYREFS = 59, // Too many references: can't splice
+    TIMEDOUT = 60, // Operation timed out
+    CONNREFUSED = 61, // Connection refused
+
+    LOOP = 62, // Too many levels of symbolic links
+    NAMETOOLONG = 63, // File name too long
+
+    // should be rearranged
+    HOSTDOWN = 64, // Host is down
+    HOSTUNREACH = 65, // No route to host
+    NOTEMPTY = 66, // Directory not empty
+
+    // quotas & mush
+    PROCLIM = 67, // Too many processes
+    USERS = 68, // Too many users
+    DQUOT = 69, // Disc quota exceeded
+
+    // Network File System
+    STALE = 70, // Stale NFS file handle
+    REMOTE = 71, // Too many levels of remote in path
+    BADRPC = 72, // RPC struct is bad
+    RPCMISMATCH = 73, // RPC version wrong
+    PROGUNAVAIL = 74, // RPC prog. not avail
+    PROGMISMATCH = 75, // Program version wrong
+    PROCUNAVAIL = 76, // Bad procedure for program
+
+    NOLCK = 77, // No locks available
+    NOSYS = 78, // Function not implemented
+
+    FTYPE = 79, // Inappropriate file type or format
+    AUTH = 80, // Authentication error
+    NEEDAUTH = 81, // Need authenticator
+    IDRM = 82, // Identifier removed
+    NOMSG = 83, // No message of desired type
+    OVERFLOW = 84, // Value too large to be stored in data type
+    CANCELED = 85, // Operation canceled
+    ILSEQ = 86, // Illegal byte sequence
+    NOATTR = 87, // Attribute not found
+
+    DOOFUS = 88, // Programming error
+
+    BADMSG = 89, // Bad message
+    MULTIHOP = 90, // Multihop attempted
+    NOLINK = 91, // Link has been severed
+    PROTO = 92, // Protocol error
+
+    NOTCAPABLE = 93, // Capabilities insufficient
+    CAPMODE = 94, // Not permitted in capability mode
+    NOTRECOVERABLE = 95, // State not recoverable
+    OWNERDEAD = 96, // Previous owner died
+    _,
+};
+
+pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
+    .i386, .x86_64 => 2048,
+    .arm, .aarch64 => 4096,
+    else => @compileError("MINSIGSTKSZ not defined for this architecture"),
+};
+pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+    ss_sp: [*]u8,
+    ss_size: isize,
+    ss_flags: i32,
+};
+
+pub const S_IFMT = 0o170000;
+
+pub const S_IFIFO = 0o010000;
+pub const S_IFCHR = 0o020000;
+pub const S_IFDIR = 0o040000;
+pub const S_IFBLK = 0o060000;
+pub const S_IFREG = 0o100000;
+pub const S_IFLNK = 0o120000;
+pub const S_IFSOCK = 0o140000;
+pub const S_IFWHT = 0o160000;
+
+pub const S_ISUID = 0o4000;
+pub const S_ISGID = 0o2000;
+pub const S_ISVTX = 0o1000;
+pub const S_IRWXU = 0o700;
+pub const S_IRUSR = 0o400;
+pub const S_IWUSR = 0o200;
+pub const S_IXUSR = 0o100;
+pub const S_IRWXG = 0o070;
+pub const S_IRGRP = 0o040;
+pub const S_IWGRP = 0o020;
+pub const S_IXGRP = 0o010;
+pub const S_IRWXO = 0o007;
+pub const S_IROTH = 0o004;
+pub const S_IWOTH = 0o002;
+pub const S_IXOTH = 0o001;
+
+pub fn S_ISFIFO(m: u32) bool {
+    return m & S_IFMT == S_IFIFO;
+}
+
+pub fn S_ISCHR(m: u32) bool {
+    return m & S_IFMT == S_IFCHR;
+}
+
+pub fn S_ISDIR(m: u32) bool {
+    return m & S_IFMT == S_IFDIR;
+}
+
+pub fn S_ISBLK(m: u32) bool {
+    return m & S_IFMT == S_IFBLK;
+}
+
+pub fn S_ISREG(m: u32) bool {
+    return m & S_IFMT == S_IFREG;
+}
+
+pub fn S_ISLNK(m: u32) bool {
+    return m & S_IFMT == S_IFLNK;
+}
+
+pub fn S_ISSOCK(m: u32) bool {
+    return m & S_IFMT == S_IFSOCK;
+}
+
+pub fn S_IWHT(m: u32) bool {
+    return m & S_IFMT == S_IFWHT;
+}
+
+pub const HOST_NAME_MAX = 255;
+
+/// Magic value that specify the use of the current working directory
+/// to determine the target of relative file paths in the openat() and
+/// similar syscalls.
+pub const AT_FDCWD = -100;
+
+/// Check access using effective user and group ID
+pub const AT_EACCESS = 0x0100;
+
+/// Do not follow symbolic links
+pub const AT_SYMLINK_NOFOLLOW = 0x0200;
+
+/// Follow symbolic link
+pub const AT_SYMLINK_FOLLOW = 0x0400;
+
+/// Remove directory instead of file
+pub const AT_REMOVEDIR = 0x0800;
+
+pub const addrinfo = extern struct {
+    flags: i32,
+    family: i32,
+    socktype: i32,
+    protocol: i32,
+    addrlen: socklen_t,
+    canonname: ?[*:0]u8,
+    addr: ?*sockaddr,
+    next: ?*addrinfo,
+};
+
+/// Fail if not under dirfd
+pub const AT_BENEATH = 0x1000;
+
+/// dummy for IP
+pub const IPPROTO_IP = 0;
+
+/// control message protocol
+pub const IPPROTO_ICMP = 1;
+
+/// tcp
+pub const IPPROTO_TCP = 6;
+
+/// user datagram protocol
+pub const IPPROTO_UDP = 17;
+
+/// IP6 header
+pub const IPPROTO_IPV6 = 41;
+
+/// raw IP packet
+pub const IPPROTO_RAW = 255;
+
+/// IP6 hop-by-hop options
+pub const IPPROTO_HOPOPTS = 0;
+
+/// group mgmt protocol
+pub const IPPROTO_IGMP = 2;
+
+/// gateway^2 (deprecated)
+pub const IPPROTO_GGP = 3;
+
+/// IPv4 encapsulation
+pub const IPPROTO_IPV4 = 4;
+
+/// for compatibility
+pub const IPPROTO_IPIP = IPPROTO_IPV4;
+
+/// Stream protocol II
+pub const IPPROTO_ST = 7;
+
+/// exterior gateway protocol
+pub const IPPROTO_EGP = 8;
+
+/// private interior gateway
+pub const IPPROTO_PIGP = 9;
+
+/// BBN RCC Monitoring
+pub const IPPROTO_RCCMON = 10;
+
+/// network voice protocol
+pub const IPPROTO_NVPII = 11;
+
+/// pup
+pub const IPPROTO_PUP = 12;
+
+/// Argus
+pub const IPPROTO_ARGUS = 13;
+
+/// EMCON
+pub const IPPROTO_EMCON = 14;
+
+/// Cross Net Debugger
+pub const IPPROTO_XNET = 15;
+
+/// Chaos
+pub const IPPROTO_CHAOS = 16;
+
+/// Multiplexing
+pub const IPPROTO_MUX = 18;
+
+/// DCN Measurement Subsystems
+pub const IPPROTO_MEAS = 19;
+
+/// Host Monitoring
+pub const IPPROTO_HMP = 20;
+
+/// Packet Radio Measurement
+pub const IPPROTO_PRM = 21;
+
+/// xns idp
+pub const IPPROTO_IDP = 22;
+
+/// Trunk-1
+pub const IPPROTO_TRUNK1 = 23;
+
+/// Trunk-2
+pub const IPPROTO_TRUNK2 = 24;
+
+/// Leaf-1
+pub const IPPROTO_LEAF1 = 25;
+
+/// Leaf-2
+pub const IPPROTO_LEAF2 = 26;
+
+/// Reliable Data
+pub const IPPROTO_RDP = 27;
+
+/// Reliable Transaction
+pub const IPPROTO_IRTP = 28;
+
+/// tp-4 w/ class negotiation
+pub const IPPROTO_TP = 29;
+
+/// Bulk Data Transfer
+pub const IPPROTO_BLT = 30;
+
+/// Network Services
+pub const IPPROTO_NSP = 31;
+
+/// Merit Internodal
+pub const IPPROTO_INP = 32;
+
+/// Datagram Congestion Control Protocol
+pub const IPPROTO_DCCP = 33;
+
+/// Third Party Connect
+pub const IPPROTO_3PC = 34;
+
+/// InterDomain Policy Routing
+pub const IPPROTO_IDPR = 35;
+
+/// XTP
+pub const IPPROTO_XTP = 36;
+
+/// Datagram Delivery
+pub const IPPROTO_DDP = 37;
+
+/// Control Message Transport
+pub const IPPROTO_CMTP = 38;
+
+/// TP++ Transport
+pub const IPPROTO_TPXX = 39;
+
+/// IL transport protocol
+pub const IPPROTO_IL = 40;
+
+/// Source Demand Routing
+pub const IPPROTO_SDRP = 42;
+
+/// IP6 routing header
+pub const IPPROTO_ROUTING = 43;
+
+/// IP6 fragmentation header
+pub const IPPROTO_FRAGMENT = 44;
+
+/// InterDomain Routing
+pub const IPPROTO_IDRP = 45;
+
+/// resource reservation
+pub const IPPROTO_RSVP = 46;
+
+/// General Routing Encap.
+pub const IPPROTO_GRE = 47;
+
+/// Mobile Host Routing
+pub const IPPROTO_MHRP = 48;
+
+/// BHA
+pub const IPPROTO_BHA = 49;
+
+/// IP6 Encap Sec. Payload
+pub const IPPROTO_ESP = 50;
+
+/// IP6 Auth Header
+pub const IPPROTO_AH = 51;
+
+/// Integ. Net Layer Security
+pub const IPPROTO_INLSP = 52;
+
+/// IP with encryption
+pub const IPPROTO_SWIPE = 53;
+
+/// Next Hop Resolution
+pub const IPPROTO_NHRP = 54;
+
+/// IP Mobility
+pub const IPPROTO_MOBILE = 55;
+
+/// Transport Layer Security
+pub const IPPROTO_TLSP = 56;
+
+/// SKIP
+pub const IPPROTO_SKIP = 57;
+
+/// ICMP6
+pub const IPPROTO_ICMPV6 = 58;
+
+/// IP6 no next header
+pub const IPPROTO_NONE = 59;
+
+/// IP6 destination option
+pub const IPPROTO_DSTOPTS = 60;
+
+/// any host internal protocol
+pub const IPPROTO_AHIP = 61;
+
+/// CFTP
+pub const IPPROTO_CFTP = 62;
+
+/// "hello" routing protocol
+pub const IPPROTO_HELLO = 63;
+
+/// SATNET/Backroom EXPAK
+pub const IPPROTO_SATEXPAK = 64;
+
+/// Kryptolan
+pub const IPPROTO_KRYPTOLAN = 65;
+
+/// Remote Virtual Disk
+pub const IPPROTO_RVD = 66;
+
+/// Pluribus Packet Core
+pub const IPPROTO_IPPC = 67;
+
+/// Any distributed FS
+pub const IPPROTO_ADFS = 68;
+
+/// Satnet Monitoring
+pub const IPPROTO_SATMON = 69;
+
+/// VISA Protocol
+pub const IPPROTO_VISA = 70;
+
+/// Packet Core Utility
+pub const IPPROTO_IPCV = 71;
+
+/// Comp. Prot. Net. Executive
+pub const IPPROTO_CPNX = 72;
+
+/// Comp. Prot. HeartBeat
+pub const IPPROTO_CPHB = 73;
+
+/// Wang Span Network
+pub const IPPROTO_WSN = 74;
+
+/// Packet Video Protocol
+pub const IPPROTO_PVP = 75;
+
+/// BackRoom SATNET Monitoring
+pub const IPPROTO_BRSATMON = 76;
+
+/// Sun net disk proto (temp.)
+pub const IPPROTO_ND = 77;
+
+/// WIDEBAND Monitoring
+pub const IPPROTO_WBMON = 78;
+
+/// WIDEBAND EXPAK
+pub const IPPROTO_WBEXPAK = 79;
+
+/// ISO cnlp
+pub const IPPROTO_EON = 80;
+
+/// VMTP
+pub const IPPROTO_VMTP = 81;
+
+/// Secure VMTP
+pub const IPPROTO_SVMTP = 82;
+
+/// Banyon VINES
+pub const IPPROTO_VINES = 83;
+
+/// TTP
+pub const IPPROTO_TTP = 84;
+
+/// NSFNET-IGP
+pub const IPPROTO_IGP = 85;
+
+/// dissimilar gateway prot.
+pub const IPPROTO_DGP = 86;
+
+/// TCF
+pub const IPPROTO_TCF = 87;
+
+/// Cisco/GXS IGRP
+pub const IPPROTO_IGRP = 88;
+
+/// OSPFIGP
+pub const IPPROTO_OSPFIGP = 89;
+
+/// Strite RPC protocol
+pub const IPPROTO_SRPC = 90;
+
+/// Locus Address Resoloution
+pub const IPPROTO_LARP = 91;
+
+/// Multicast Transport
+pub const IPPROTO_MTP = 92;
+
+/// AX.25 Frames
+pub const IPPROTO_AX25 = 93;
+
+/// IP encapsulated in IP
+pub const IPPROTO_IPEIP = 94;
+
+/// Mobile Int.ing control
+pub const IPPROTO_MICP = 95;
+
+/// Semaphore Comm. security
+pub const IPPROTO_SCCSP = 96;
+
+/// Ethernet IP encapsulation
+pub const IPPROTO_ETHERIP = 97;
+
+/// encapsulation header
+pub const IPPROTO_ENCAP = 98;
+
+/// any private encr. scheme
+pub const IPPROTO_APES = 99;
+
+/// GMTP
+pub const IPPROTO_GMTP = 100;
+
+/// payload compression (IPComp)
+pub const IPPROTO_IPCOMP = 108;
+
+/// SCTP
+pub const IPPROTO_SCTP = 132;
+
+/// IPv6 Mobility Header
+pub const IPPROTO_MH = 135;
+
+/// UDP-Lite
+pub const IPPROTO_UDPLITE = 136;
+
+/// IP6 Host Identity Protocol
+pub const IPPROTO_HIP = 139;
+
+/// IP6 Shim6 Protocol
+pub const IPPROTO_SHIM6 = 140;
+
+/// Protocol Independent Mcast
+pub const IPPROTO_PIM = 103;
+
+/// CARP
+pub const IPPROTO_CARP = 112;
+
+/// PGM
+pub const IPPROTO_PGM = 113;
+
+/// MPLS-in-IP
+pub const IPPROTO_MPLS = 137;
+
+/// PFSYNC
+pub const IPPROTO_PFSYNC = 240;
+
+/// Reserved
+pub const IPPROTO_RESERVED_253 = 253;
+
+/// Reserved
+pub const IPPROTO_RESERVED_254 = 254;
+
+pub const rlimit_resource = enum(c_int) {
+    CPU = 0,
+    FSIZE = 1,
+    DATA = 2,
+    STACK = 3,
+    CORE = 4,
+    RSS = 5,
+    MEMLOCK = 6,
+    NPROC = 7,
+    NOFILE = 8,
+    SBSIZE = 9,
+    VMEM = 10,
+    NPTS = 11,
+    SWAP = 12,
+    KQUEUES = 13,
+    UMTXP = 14,
+    _,
+
+    pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = i64;
+
+/// No limit
+pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
+
+pub const RLIM_SAVED_MAX = RLIM_INFINITY;
+pub const RLIM_SAVED_CUR = RLIM_INFINITY;
+
+pub const rlimit = extern struct {
+    /// Soft limit
+    cur: rlim_t,
+    /// Hard limit
+    max: rlim_t,
+};
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 2;
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+    fd: fd_t,
+    events: i16,
+    revents: i16,
+};
+
+/// any readable data available.
+pub const POLLIN = 0x0001;
+/// OOB/Urgent readable data.
+pub const POLLPRI = 0x0002;
+/// file descriptor is writeable.
+pub const POLLOUT = 0x0004;
+/// non-OOB/URG data available.
+pub const POLLRDNORM = 0x0040;
+/// no write type differentiation.
+pub const POLLWRNORM = POLLOUT;
+/// OOB/Urgent readable data.
+pub const POLLRDBAND = 0x0080;
+/// OOB/Urgent data can be written.
+pub const POLLWRBAND = 0x0100;
+/// like POLLIN, except ignore EOF.
+pub const POLLINIGNEOF = 0x2000;
+/// some poll error occurred.
+pub const POLLERR = 0x0008;
+/// file descriptor was "hung up".
+pub const POLLHUP = 0x0010;
+/// requested events "invalid".
+pub const POLLNVAL = 0x0020;
+
+pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND |
+    POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
lib/std/c/generic.zig
@@ -0,0 +1,22 @@
+const std = @import("../std.zig");
+const Stat = std.c.Stat;
+const timespec = std.c.timespec;
+const Sigaction = std.c.Sigaction;
+const sigset_t = std.c.sigset_t;
+
+pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
+pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
+pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
+pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
+pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub extern "c" fn sched_yield() c_int;
+pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
+pub extern "c" fn sigfillset(set: ?*sigset_t) void;
+pub extern "c" fn alarm(seconds: c_uint) c_uint;
+pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
lib/std/c/haiku.zig
@@ -1,6 +1,5 @@
-//
 const std = @import("../std.zig");
-const builtin = std.builtin;
+const maxInt = std.math.maxInt;
 
 usingnamespace std.c;
 
@@ -19,7 +18,7 @@ pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *i
 
 pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize;
 
-pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, libc_stat: *libc_stat, stat_size: i32) usize;
+pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, st: *Stat, stat_size: i32) usize;
 
 pub extern "c" fn _kern_get_current_team() i32;
 
@@ -111,3 +110,1374 @@ pub const EAI = enum(c_int) {
 };
 
 pub const EAI_MAX = 15;
+
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+pub const uid_t = u32;
+pub const gid_t = u32;
+pub const mode_t = c_uint;
+
+pub const socklen_t = u32;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+    ident: usize,
+    filter: i16,
+    flags: u16,
+    fflags: u32,
+    data: i64,
+    udata: usize,
+    // TODO ext
+};
+
+// Modes and flags for dlopen()
+// include/dlfcn.h
+
+pub const POLLIN = 0x0001;
+pub const POLLERR = 0x0004;
+pub const POLLNVAL = 0x1000;
+pub const POLLHUP = 0x0080;
+
+/// Bind function calls lazily.
+pub const RTLD_LAZY = 1;
+
+/// Bind function calls immediately.
+pub const RTLD_NOW = 2;
+
+pub const RTLD_MODEMASK = 0x3;
+
+/// Make symbols globally available.
+pub const RTLD_GLOBAL = 0x100;
+
+/// Opposite of RTLD_GLOBAL, and the default.
+pub const RTLD_LOCAL = 0;
+
+/// Trace loaded objects and exit.
+pub const RTLD_TRACE = 0x200;
+
+/// Do not remove members.
+pub const RTLD_NODELETE = 0x01000;
+
+/// Do not load if not already loaded.
+pub const RTLD_NOLOAD = 0x02000;
+
+pub const dl_phdr_info = extern struct {
+    dlpi_addr: usize,
+    dlpi_name: ?[*:0]const u8,
+    dlpi_phdr: [*]std.elf.Phdr,
+    dlpi_phnum: u16,
+};
+
+pub const Flock = extern struct {
+    l_start: off_t,
+    l_len: off_t,
+    l_pid: pid_t,
+    l_type: i16,
+    l_whence: i16,
+    l_sysid: i32,
+    __unused: [4]u8,
+};
+
+pub const msghdr = extern struct {
+    /// optional address
+    msg_name: ?*sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec,
+
+    /// # elements in msg_iov
+    msg_iovlen: i32,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+    /// optional address
+    msg_name: ?*const sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec_const,
+
+    /// # elements in msg_iov
+    msg_iovlen: i32,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: i32,
+};
+
+pub const off_t = i64;
+pub const ino_t = u64;
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+    fd: i32,
+    events: i16,
+    revents: i16,
+};
+
+pub const Stat = extern struct {
+    dev: i32,
+    ino: u64,
+    mode: u32,
+    nlink: i32,
+    uid: i32,
+    gid: i32,
+    size: i64,
+    rdev: i32,
+    blksize: i32,
+    atim: timespec,
+    mtim: timespec,
+    ctim: timespec,
+    crtim: timespec,
+    st_type: u32,
+    blocks: i64,
+
+    pub fn atime(self: @This()) timespec {
+        return self.atim;
+    }
+    pub fn mtime(self: @This()) timespec {
+        return self.mtim;
+    }
+    pub fn ctime(self: @This()) timespec {
+        return self.ctim;
+    }
+    pub fn crtime(self: @This()) timespec {
+        return self.crtim;
+    }
+};
+
+pub const timespec = extern struct {
+    tv_sec: isize,
+    tv_nsec: isize,
+};
+
+pub const dirent = extern struct {
+    d_dev: i32,
+    d_pdev: i32,
+    d_ino: i64,
+    d_pino: i64,
+    d_reclen: u16,
+    d_name: [256]u8,
+
+    pub fn reclen(self: dirent) u16 {
+        return self.d_reclen;
+    }
+};
+
+pub const image_info = extern struct {
+    id: u32,
+    type: u32,
+    sequence: i32,
+    init_order: i32,
+    init_routine: *c_void,
+    term_routine: *c_void,
+    device: i32,
+    node: i32,
+    name: [1024]u8,
+    text: *c_void,
+    data: *c_void,
+    text_size: i32,
+    data_size: i32,
+    api_version: i32,
+    abi: i32,
+};
+
+pub const system_info = extern struct {
+    boot_time: i64,
+    cpu_count: u32,
+    max_pages: u64,
+    used_pages: u64,
+    cached_pages: u64,
+    block_cache_pages: u64,
+    ignored_pages: u64,
+    needed_memory: u64,
+    free_memory: u64,
+    max_swap_pages: u64,
+    free_swap_pages: u64,
+    page_faults: u32,
+    max_sems: u32,
+    used_sems: u32,
+    max_ports: u32,
+    used_ports: u32,
+    max_threads: u32,
+    used_threads: u32,
+    max_teams: u32,
+    used_teams: u32,
+    kernel_name: [256]u8,
+    kernel_build_date: [32]u8,
+    kernel_build_time: [32]u8,
+    kernel_version: i64,
+    abi: u32,
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+    /// total length
+    len: u8,
+
+    /// address family
+    family: sa_family_t,
+
+    /// actually longer; address value
+    data: [14]u8,
+};
+
+pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+
+pub const sockaddr_in = extern struct {
+    len: u8 = @sizeOf(sockaddr_in),
+    family: sa_family_t = AF_INET,
+    port: in_port_t,
+    addr: u32,
+    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+};
+
+pub const sockaddr_in6 = extern struct {
+    len: u8 = @sizeOf(sockaddr_in6),
+    family: sa_family_t = AF_INET6,
+    port: in_port_t,
+    flowinfo: u32,
+    addr: [16]u8,
+    scope_id: u32,
+};
+
+pub const sockaddr_un = extern struct {
+    len: u8 = @sizeOf(sockaddr_un),
+    family: sa_family_t = AF_UNIX,
+    path: [104]u8,
+};
+
+pub const CTL_KERN = 1;
+pub const CTL_DEBUG = 5;
+
+pub const KERN_PROC = 14; // struct: process entries
+pub const KERN_PROC_PATHNAME = 12; // path to executable
+
+pub const PATH_MAX = 1024;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT_NONE = 0;
+pub const PROT_READ = 1;
+pub const PROT_WRITE = 2;
+pub const PROT_EXEC = 4;
+
+pub const CLOCK_MONOTONIC = 0;
+pub const CLOCK_REALTIME = -1;
+pub const CLOCK_PROCESS_CPUTIME_ID = -2;
+pub const CLOCK_THREAD_CPUTIME_ID = -3;
+
+pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+pub const MAP_SHARED = 0x0001;
+pub const MAP_PRIVATE = 0x0002;
+pub const MAP_FIXED = 0x0010;
+pub const MAP_STACK = 0x0400;
+pub const MAP_NOSYNC = 0x0800;
+pub const MAP_ANON = 0x1000;
+pub const MAP_ANONYMOUS = MAP_ANON;
+pub const MAP_FILE = 0;
+
+pub const MAP_GUARD = 0x00002000;
+pub const MAP_EXCL = 0x00004000;
+pub const MAP_NOCORE = 0x00020000;
+pub const MAP_PREFAULT_READ = 0x00040000;
+pub const MAP_32BIT = 0x00080000;
+
+pub const WNOHANG = 0x1;
+pub const WUNTRACED = 0x2;
+pub const WSTOPPED = 0x10;
+pub const WCONTINUED = 0x4;
+pub const WNOWAIT = 0x20;
+pub const WEXITED = 0x08;
+
+pub const SA_ONSTACK = 0x20;
+pub const SA_RESTART = 0x10;
+pub const SA_RESETHAND = 0x04;
+pub const SA_NOCLDSTOP = 0x01;
+pub const SA_NODEFER = 0x08;
+pub const SA_NOCLDWAIT = 0x02;
+pub const SA_SIGINFO = 0x40;
+pub const SA_NOMASK = SA_NODEFER;
+pub const SA_STACK = SA_ONSTACK;
+pub const SA_ONESHOT = SA_RESETHAND;
+
+pub const SIGHUP = 1;
+pub const SIGINT = 2;
+pub const SIGQUIT = 3;
+pub const SIGILL = 4;
+pub const SIGCHLD = 5;
+pub const SIGABRT = 6;
+pub const SIGIOT = SIGABRT;
+pub const SIGPIPE = 7;
+pub const SIGFPE = 8;
+pub const SIGKILL = 9;
+pub const SIGSTOP = 10;
+pub const SIGSEGV = 11;
+pub const SIGCONT = 12;
+pub const SIGTSTP = 13;
+pub const SIGALRM = 14;
+pub const SIGTERM = 15;
+pub const SIGTTIN = 16;
+pub const SIGTTOU = 17;
+pub const SIGUSR1 = 18;
+pub const SIGUSR2 = 19;
+pub const SIGWINCH = 20;
+pub const SIGKILLTHR = 21;
+pub const SIGTRAP = 22;
+pub const SIGPOLL = 23;
+pub const SIGPROF = 24;
+pub const SIGSYS = 25;
+pub const SIGURG = 26;
+pub const SIGVTALRM = 27;
+pub const SIGXCPU = 28;
+pub const SIGXFSZ = 29;
+pub const SIGBUS = 30;
+pub const SIGRESERVED1 = 31;
+pub const SIGRESERVED2 = 32;
+
+// TODO: check
+pub const SIGRTMIN = 65;
+pub const SIGRTMAX = 126;
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+pub const O_RDONLY = 0x0000;
+pub const O_WRONLY = 0x0001;
+pub const O_RDWR = 0x0002;
+pub const O_ACCMODE = 0x0003;
+
+pub const O_SHLOCK = 0x0010;
+pub const O_EXLOCK = 0x0020;
+
+pub const O_CREAT = 0x0200;
+pub const O_EXCL = 0x0800;
+pub const O_NOCTTY = 0x8000;
+pub const O_TRUNC = 0x0400;
+pub const O_APPEND = 0x0008;
+pub const O_NONBLOCK = 0x0004;
+pub const O_DSYNC = 0o10000;
+pub const O_SYNC = 0x0080;
+pub const O_RSYNC = 0o4010000;
+pub const O_DIRECTORY = 0x20000;
+pub const O_NOFOLLOW = 0x0100;
+pub const O_CLOEXEC = 0x00100000;
+
+pub const O_ASYNC = 0x0040;
+pub const O_DIRECT = 0x00010000;
+pub const O_NOATIME = 0o1000000;
+pub const O_PATH = 0o10000000;
+pub const O_TMPFILE = 0o20200000;
+pub const O_NDELAY = O_NONBLOCK;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_SETFD = 2;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+
+pub const F_GETOWN = 5;
+pub const F_SETOWN = 6;
+
+pub const F_GETLK = 11;
+pub const F_SETLK = 12;
+pub const F_SETLKW = 13;
+
+pub const F_RDLCK = 1;
+pub const F_WRLCK = 3;
+pub const F_UNLCK = 2;
+
+pub const LOCK_SH = 1;
+pub const LOCK_EX = 2;
+pub const LOCK_UN = 8;
+pub const LOCK_NB = 4;
+
+pub const F_SETOWN_EX = 15;
+pub const F_GETOWN_EX = 16;
+
+pub const F_GETOWNER_UIDS = 17;
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+
+pub const SIG_BLOCK = 1;
+pub const SIG_UNBLOCK = 2;
+pub const SIG_SETMASK = 3;
+
+pub const SOCK_STREAM = 1;
+pub const SOCK_DGRAM = 2;
+pub const SOCK_RAW = 3;
+pub const SOCK_RDM = 4;
+pub const SOCK_SEQPACKET = 5;
+
+pub const SOCK_CLOEXEC = 0x10000000;
+pub const SOCK_NONBLOCK = 0x20000000;
+
+pub const SO_DEBUG = 0x00000001;
+pub const SO_ACCEPTCONN = 0x00000002;
+pub const SO_REUSEADDR = 0x00000004;
+pub const SO_KEEPALIVE = 0x00000008;
+pub const SO_DONTROUTE = 0x00000010;
+pub const SO_BROADCAST = 0x00000020;
+pub const SO_USELOOPBACK = 0x00000040;
+pub const SO_LINGER = 0x00000080;
+pub const SO_OOBINLINE = 0x00000100;
+pub const SO_REUSEPORT = 0x00000200;
+pub const SO_TIMESTAMP = 0x00000400;
+pub const SO_NOSIGPIPE = 0x00000800;
+pub const SO_ACCEPTFILTER = 0x00001000;
+pub const SO_BINTIME = 0x00002000;
+pub const SO_NO_OFFLOAD = 0x00004000;
+pub const SO_NO_DDP = 0x00008000;
+pub const SO_REUSEPORT_LB = 0x00010000;
+
+pub const SO_SNDBUF = 0x1001;
+pub const SO_RCVBUF = 0x1002;
+pub const SO_SNDLOWAT = 0x1003;
+pub const SO_RCVLOWAT = 0x1004;
+pub const SO_SNDTIMEO = 0x1005;
+pub const SO_RCVTIMEO = 0x1006;
+pub const SO_ERROR = 0x1007;
+pub const SO_TYPE = 0x1008;
+pub const SO_LABEL = 0x1009;
+pub const SO_PEERLABEL = 0x1010;
+pub const SO_LISTENQLIMIT = 0x1011;
+pub const SO_LISTENQLEN = 0x1012;
+pub const SO_LISTENINCQLEN = 0x1013;
+pub const SO_SETFIB = 0x1014;
+pub const SO_USER_COOKIE = 0x1015;
+pub const SO_PROTOCOL = 0x1016;
+pub const SO_PROTOTYPE = SO_PROTOCOL;
+pub const SO_TS_CLOCK = 0x1017;
+pub const SO_MAX_PACING_RATE = 0x1018;
+pub const SO_DOMAIN = 0x1019;
+
+pub const SOL_SOCKET = 0xffff;
+
+pub const PF_UNSPEC = AF_UNSPEC;
+pub const PF_LOCAL = AF_LOCAL;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_INET = AF_INET;
+pub const PF_IMPLINK = AF_IMPLINK;
+pub const PF_PUP = AF_PUP;
+pub const PF_CHAOS = AF_CHAOS;
+pub const PF_NETBIOS = AF_NETBIOS;
+pub const PF_ISO = AF_ISO;
+pub const PF_OSI = AF_ISO;
+pub const PF_ECMA = AF_ECMA;
+pub const PF_DATAKIT = AF_DATAKIT;
+pub const PF_CCITT = AF_CCITT;
+pub const PF_DECnet = AF_DECnet;
+pub const PF_DLI = AF_DLI;
+pub const PF_LAT = AF_LAT;
+pub const PF_HYLINK = AF_HYLINK;
+pub const PF_APPLETALK = AF_APPLETALK;
+pub const PF_ROUTE = AF_ROUTE;
+pub const PF_LINK = AF_LINK;
+pub const PF_XTP = pseudo_AF_XTP;
+pub const PF_COIP = AF_COIP;
+pub const PF_CNT = AF_CNT;
+pub const PF_SIP = AF_SIP;
+pub const PF_IPX = AF_IPX;
+pub const PF_RTIP = pseudo_AF_RTIP;
+pub const PF_PIP = psuedo_AF_PIP;
+pub const PF_ISDN = AF_ISDN;
+pub const PF_KEY = pseudo_AF_KEY;
+pub const PF_INET6 = pseudo_AF_INET6;
+pub const PF_NATM = AF_NATM;
+pub const PF_ATM = AF_ATM;
+pub const PF_NETGRAPH = AF_NETGRAPH;
+pub const PF_SLOW = AF_SLOW;
+pub const PF_SCLUSTER = AF_SCLUSTER;
+pub const PF_ARP = AF_ARP;
+pub const PF_BLUETOOTH = AF_BLUETOOTH;
+pub const PF_IEEE80211 = AF_IEEE80211;
+pub const PF_INET_SDP = AF_INET_SDP;
+pub const PF_INET6_SDP = AF_INET6_SDP;
+pub const PF_MAX = AF_MAX;
+
+pub const AF_UNSPEC = 0;
+pub const AF_UNIX = 1;
+pub const AF_LOCAL = AF_UNIX;
+pub const AF_FILE = AF_LOCAL;
+pub const AF_INET = 2;
+pub const AF_IMPLINK = 3;
+pub const AF_PUP = 4;
+pub const AF_CHAOS = 5;
+pub const AF_NETBIOS = 6;
+pub const AF_ISO = 7;
+pub const AF_OSI = AF_ISO;
+pub const AF_ECMA = 8;
+pub const AF_DATAKIT = 9;
+pub const AF_CCITT = 10;
+pub const AF_SNA = 11;
+pub const AF_DECnet = 12;
+pub const AF_DLI = 13;
+pub const AF_LAT = 14;
+pub const AF_HYLINK = 15;
+pub const AF_APPLETALK = 16;
+pub const AF_ROUTE = 17;
+pub const AF_LINK = 18;
+pub const pseudo_AF_XTP = 19;
+pub const AF_COIP = 20;
+pub const AF_CNT = 21;
+pub const pseudo_AF_RTIP = 22;
+pub const AF_IPX = 23;
+pub const AF_SIP = 24;
+pub const pseudo_AF_PIP = 25;
+pub const AF_ISDN = 26;
+pub const AF_E164 = AF_ISDN;
+pub const pseudo_AF_KEY = 27;
+pub const AF_INET6 = 28;
+pub const AF_NATM = 29;
+pub const AF_ATM = 30;
+pub const pseudo_AF_HDRCMPLT = 31;
+pub const AF_NETGRAPH = 32;
+pub const AF_SLOW = 33;
+pub const AF_SCLUSTER = 34;
+pub const AF_ARP = 35;
+pub const AF_BLUETOOTH = 36;
+pub const AF_IEEE80211 = 37;
+pub const AF_INET_SDP = 40;
+pub const AF_INET6_SDP = 42;
+pub const AF_MAX = 42;
+
+pub const DT_UNKNOWN = 0;
+pub const DT_FIFO = 1;
+pub const DT_CHR = 2;
+pub const DT_DIR = 4;
+pub const DT_BLK = 6;
+pub const DT_REG = 8;
+pub const DT_LNK = 10;
+pub const DT_SOCK = 12;
+pub const DT_WHT = 14;
+
+/// 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
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+///     on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
+
+/// 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;
+
+/// Process descriptors
+pub const EVFILT_PROCDESC = -8;
+
+/// Filesystem events
+pub const EVFILT_FS = -9;
+
+pub const EVFILT_LIO = -10;
+
+/// User events
+pub const EVFILT_USER = -11;
+
+/// Sendfile events
+pub const EVFILT_SENDFILE = -12;
+
+pub const EVFILT_EMPTY = -13;
+
+pub const TCGETA = 0x8000;
+pub const TCSETA = 0x8001;
+pub const TCSETAW = 0x8004;
+pub const TCSETAF = 0x8003;
+pub const TCSBRK = 08005;
+pub const TCXONC = 0x8007;
+pub const TCFLSH = 0x8006;
+
+pub const TIOCSCTTY = 0x8017;
+pub const TIOCGPGRP = 0x8015;
+pub const TIOCSPGRP = 0x8016;
+pub const TIOCGWINSZ = 0x8012;
+pub const TIOCSWINSZ = 0x8013;
+pub const TIOCMGET = 0x8018;
+pub const TIOCMBIS = 0x8022;
+pub const TIOCMBIC = 0x8023;
+pub const TIOCMSET = 0x8019;
+pub const FIONREAD = 0xbe000001;
+pub const FIONBIO = 0xbe000000;
+pub const TIOCSBRK = 0x8020;
+pub const TIOCCBRK = 0x8021;
+pub const TIOCGSID = 0x8024;
+
+pub fn WEXITSTATUS(s: u32) u8 {
+    return @intCast(u8, s & 0xff);
+}
+
+pub fn WTERMSIG(s: u32) u32 {
+    return (s >> 8) & 0xff;
+}
+
+pub fn WSTOPSIG(s: u32) u32 {
+    return WEXITSTATUS(s);
+}
+
+pub fn WIFEXITED(s: u32) bool {
+    return WTERMSIG(s) == 0;
+}
+
+pub fn WIFSTOPPED(s: u32) bool {
+    return ((s >> 16) & 0xff) != 0;
+}
+
+pub fn WIFSIGNALED(s: u32) bool {
+    return ((s >> 8) & 0xff) != 0;
+}
+
+pub const winsize = extern struct {
+    ws_row: u16,
+    ws_col: u16,
+    ws_xpixel: u16,
+    ws_ypixel: u16,
+};
+
+const NSIG = 32;
+
+pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
+pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
+pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+    /// signal handler
+    __sigaction_u: extern union {
+        __sa_handler: fn (i32) callconv(.C) void,
+        __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
+    },
+
+    /// see signal options
+    sa_flags: u32,
+
+    /// signal mask to apply
+    sa_mask: sigset_t,
+};
+
+pub const _SIG_WORDS = 4;
+pub const _SIG_MAXSIG = 128;
+pub inline fn _SIG_IDX(sig: usize) usize {
+    return sig - 1;
+}
+pub inline fn _SIG_WORD(sig: usize) usize {
+    return_SIG_IDX(sig) >> 5;
+}
+pub inline fn _SIG_BIT(sig: usize) usize {
+    return 1 << (_SIG_IDX(sig) & 31);
+}
+pub inline fn _SIG_VALID(sig: usize) usize {
+    return sig <= _SIG_MAXSIG and sig > 0;
+}
+
+pub const sigset_t = extern struct {
+    __bits: [_SIG_WORDS]u32,
+};
+
+pub const E = enum(i32) {
+    /// No error occurred.
+    SUCCESS = 0,
+    PERM = -0x7ffffff1, // Operation not permitted
+    NOENT = -0x7fff9ffd, // No such file or directory
+    SRCH = -0x7fff8ff3, // No such process
+    INTR = -0x7ffffff6, // Interrupted system call
+    IO = -0x7fffffff, // Input/output error
+    NXIO = -0x7fff8ff5, // Device not configured
+    @"2BIG" = -0x7fff8fff, // Argument list too long
+    NOEXEC = -0x7fffecfe, // Exec format error
+    CHILD = -0x7fff8ffe, // No child processes
+    DEADLK = -0x7fff8ffd, // Resource deadlock avoided
+    NOMEM = -0x80000000, // Cannot allocate memory
+    ACCES = -0x7ffffffe, // Permission denied
+    FAULT = -0x7fffecff, // Bad address
+    BUSY = -0x7ffffff2, // Device busy
+    EXIST = -0x7fff9ffe, // File exists
+    XDEV = -0x7fff9ff5, // Cross-device link
+    NODEV = -0x7fff8ff9, // Operation not supported by device
+    NOTDIR = -0x7fff9ffb, // Not a directory
+    ISDIR = -0x7fff9ff7, // Is a directory
+    INVAL = -0x7ffffffb, // Invalid argument
+    NFILE = -0x7fff8ffa, // Too many open files in system
+    MFILE = -0x7fff9ff6, // Too many open files
+    NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device
+    TXTBSY = -0x7fff8fc5, // Text file busy
+    FBIG = -0x7fff8ffc, // File too large
+    NOSPC = -0x7fff9ff9, // No space left on device
+    SPIPE = -0x7fff8ff4, // Illegal seek
+    ROFS = -0x7fff9ff8, // Read-only filesystem
+    MLINK = -0x7fff8ffb, // Too many links
+    PIPE = -0x7fff9ff3, // Broken pipe
+    BADF = -0x7fffa000, // Bad file descriptor
+
+    // math software
+    DOM = 33, // Numerical argument out of domain
+    RANGE = 34, // Result too large
+
+    // non-blocking and interrupt i/o
+
+    /// Also used for `WOULDBLOCK`.
+    AGAIN = -0x7ffffff5,
+    INPROGRESS = -0x7fff8fdc,
+    ALREADY = -0x7fff8fdb,
+
+    // ipc/network software -- argument errors
+    NOTSOCK = 38, // Socket operation on non-socket
+    DESTADDRREQ = 39, // Destination address required
+    MSGSIZE = 40, // Message too long
+    PROTOTYPE = 41, // Protocol wrong type for socket
+    NOPROTOOPT = 42, // Protocol not available
+    PROTONOSUPPORT = 43, // Protocol not supported
+    SOCKTNOSUPPORT = 44, // Socket type not supported
+    /// Also used for `NOTSUP`.
+    OPNOTSUPP = 45, // Operation not supported
+    PFNOSUPPORT = 46, // Protocol family not supported
+    AFNOSUPPORT = 47, // Address family not supported by protocol family
+    ADDRINUSE = 48, // Address already in use
+    ADDRNOTAVAIL = 49, // Can't assign requested address
+
+    // ipc/network software -- operational errors
+    NETDOWN = 50, // Network is down
+    NETUNREACH = 51, // Network is unreachable
+    NETRESET = 52, // Network dropped connection on reset
+    CONNABORTED = 53, // Software caused connection abort
+    CONNRESET = 54, // Connection reset by peer
+    NOBUFS = 55, // No buffer space available
+    ISCONN = 56, // Socket is already connected
+    NOTCONN = 57, // Socket is not connected
+    SHUTDOWN = 58, // Can't send after socket shutdown
+    TOOMANYREFS = 59, // Too many references: can't splice
+    TIMEDOUT = 60, // Operation timed out
+    CONNREFUSED = 61, // Connection refused
+
+    LOOP = 62, // Too many levels of symbolic links
+    NAMETOOLONG = 63, // File name too long
+
+    // should be rearranged
+    HOSTDOWN = 64, // Host is down
+    HOSTUNREACH = 65, // No route to host
+    NOTEMPTY = 66, // Directory not empty
+
+    // quotas & mush
+    PROCLIM = 67, // Too many processes
+    USERS = 68, // Too many users
+    DQUOT = 69, // Disc quota exceeded
+
+    // Network File System
+    STALE = 70, // Stale NFS file handle
+    REMOTE = 71, // Too many levels of remote in path
+    BADRPC = 72, // RPC struct is bad
+    RPCMISMATCH = 73, // RPC version wrong
+    PROGUNAVAIL = 74, // RPC prog. not avail
+    PROGMISMATCH = 75, // Program version wrong
+    PROCUNAVAIL = 76, // Bad procedure for program
+
+    NOLCK = 77, // No locks available
+    NOSYS = 78, // Function not implemented
+
+    FTYPE = 79, // Inappropriate file type or format
+    AUTH = 80, // Authentication error
+    NEEDAUTH = 81, // Need authenticator
+    IDRM = 82, // Identifier removed
+    NOMSG = 83, // No message of desired type
+    OVERFLOW = 84, // Value too large to be stored in data type
+    CANCELED = 85, // Operation canceled
+    ILSEQ = 86, // Illegal byte sequence
+    NOATTR = 87, // Attribute not found
+
+    DOOFUS = 88, // Programming error
+
+    BADMSG = 89, // Bad message
+    MULTIHOP = 90, // Multihop attempted
+    NOLINK = 91, // Link has been severed
+    PROTO = 92, // Protocol error
+
+    NOTCAPABLE = 93, // Capabilities insufficient
+    CAPMODE = 94, // Not permitted in capability mode
+    NOTRECOVERABLE = 95, // State not recoverable
+    OWNERDEAD = 96, // Previous owner died
+
+    _,
+};
+
+pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
+    .i386, .x86_64 => 2048,
+    .arm, .aarch64 => 4096,
+    else => @compileError("MINSIGSTKSZ not defined for this architecture"),
+};
+pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+    ss_sp: [*]u8,
+    ss_size: isize,
+    ss_flags: i32,
+};
+
+pub const S_IFMT = 0o170000;
+
+pub const S_IFIFO = 0o010000;
+pub const S_IFCHR = 0o020000;
+pub const S_IFDIR = 0o040000;
+pub const S_IFBLK = 0o060000;
+pub const S_IFREG = 0o100000;
+pub const S_IFLNK = 0o120000;
+pub const S_IFSOCK = 0o140000;
+pub const S_IFWHT = 0o160000;
+
+pub const S_ISUID = 0o4000;
+pub const S_ISGID = 0o2000;
+pub const S_ISVTX = 0o1000;
+pub const S_IRWXU = 0o700;
+pub const S_IRUSR = 0o400;
+pub const S_IWUSR = 0o200;
+pub const S_IXUSR = 0o100;
+pub const S_IRWXG = 0o070;
+pub const S_IRGRP = 0o040;
+pub const S_IWGRP = 0o020;
+pub const S_IXGRP = 0o010;
+pub const S_IRWXO = 0o007;
+pub const S_IROTH = 0o004;
+pub const S_IWOTH = 0o002;
+pub const S_IXOTH = 0o001;
+
+pub fn S_ISFIFO(m: u32) bool {
+    return m & S_IFMT == S_IFIFO;
+}
+
+pub fn S_ISCHR(m: u32) bool {
+    return m & S_IFMT == S_IFCHR;
+}
+
+pub fn S_ISDIR(m: u32) bool {
+    return m & S_IFMT == S_IFDIR;
+}
+
+pub fn S_ISBLK(m: u32) bool {
+    return m & S_IFMT == S_IFBLK;
+}
+
+pub fn S_ISREG(m: u32) bool {
+    return m & S_IFMT == S_IFREG;
+}
+
+pub fn S_ISLNK(m: u32) bool {
+    return m & S_IFMT == S_IFLNK;
+}
+
+pub fn S_ISSOCK(m: u32) bool {
+    return m & S_IFMT == S_IFSOCK;
+}
+
+pub fn S_IWHT(m: u32) bool {
+    return m & S_IFMT == S_IFWHT;
+}
+
+pub const HOST_NAME_MAX = 255;
+
+/// Magic value that specify the use of the current working directory
+/// to determine the target of relative file paths in the openat() and
+/// similar syscalls.
+pub const AT_FDCWD = -100;
+
+/// Check access using effective user and group ID
+pub const AT_EACCESS = 0x0100;
+
+/// Do not follow symbolic links
+pub const AT_SYMLINK_NOFOLLOW = 0x0200;
+
+/// Follow symbolic link
+pub const AT_SYMLINK_FOLLOW = 0x0400;
+
+/// Remove directory instead of file
+pub const AT_REMOVEDIR = 0x0800;
+
+pub const addrinfo = extern struct {
+    flags: i32,
+    family: i32,
+    socktype: i32,
+    protocol: i32,
+    addrlen: socklen_t,
+    canonname: ?[*:0]u8,
+    addr: ?*sockaddr,
+    next: ?*addrinfo,
+};
+
+/// Fail if not under dirfd
+pub const AT_BENEATH = 0x1000;
+
+/// dummy for IP
+pub const IPPROTO_IP = 0;
+
+/// control message protocol
+pub const IPPROTO_ICMP = 1;
+
+/// tcp
+pub const IPPROTO_TCP = 6;
+
+/// user datagram protocol
+pub const IPPROTO_UDP = 17;
+
+/// IP6 header
+pub const IPPROTO_IPV6 = 41;
+
+/// raw IP packet
+pub const IPPROTO_RAW = 255;
+
+/// IP6 hop-by-hop options
+pub const IPPROTO_HOPOPTS = 0;
+
+/// group mgmt protocol
+pub const IPPROTO_IGMP = 2;
+
+/// gateway^2 (deprecated)
+pub const IPPROTO_GGP = 3;
+
+/// IPv4 encapsulation
+pub const IPPROTO_IPV4 = 4;
+
+/// for compatibility
+pub const IPPROTO_IPIP = IPPROTO_IPV4;
+
+/// Stream protocol II
+pub const IPPROTO_ST = 7;
+
+/// exterior gateway protocol
+pub const IPPROTO_EGP = 8;
+
+/// private interior gateway
+pub const IPPROTO_PIGP = 9;
+
+/// BBN RCC Monitoring
+pub const IPPROTO_RCCMON = 10;
+
+/// network voice protocol
+pub const IPPROTO_NVPII = 11;
+
+/// pup
+pub const IPPROTO_PUP = 12;
+
+/// Argus
+pub const IPPROTO_ARGUS = 13;
+
+/// EMCON
+pub const IPPROTO_EMCON = 14;
+
+/// Cross Net Debugger
+pub const IPPROTO_XNET = 15;
+
+/// Chaos
+pub const IPPROTO_CHAOS = 16;
+
+/// Multiplexing
+pub const IPPROTO_MUX = 18;
+
+/// DCN Measurement Subsystems
+pub const IPPROTO_MEAS = 19;
+
+/// Host Monitoring
+pub const IPPROTO_HMP = 20;
+
+/// Packet Radio Measurement
+pub const IPPROTO_PRM = 21;
+
+/// xns idp
+pub const IPPROTO_IDP = 22;
+
+/// Trunk-1
+pub const IPPROTO_TRUNK1 = 23;
+
+/// Trunk-2
+pub const IPPROTO_TRUNK2 = 24;
+
+/// Leaf-1
+pub const IPPROTO_LEAF1 = 25;
+
+/// Leaf-2
+pub const IPPROTO_LEAF2 = 26;
+
+/// Reliable Data
+pub const IPPROTO_RDP = 27;
+
+/// Reliable Transaction
+pub const IPPROTO_IRTP = 28;
+
+/// tp-4 w/ class negotiation
+pub const IPPROTO_TP = 29;
+
+/// Bulk Data Transfer
+pub const IPPROTO_BLT = 30;
+
+/// Network Services
+pub const IPPROTO_NSP = 31;
+
+/// Merit Internodal
+pub const IPPROTO_INP = 32;
+
+/// Datagram Congestion Control Protocol
+pub const IPPROTO_DCCP = 33;
+
+/// Third Party Connect
+pub const IPPROTO_3PC = 34;
+
+/// InterDomain Policy Routing
+pub const IPPROTO_IDPR = 35;
+
+/// XTP
+pub const IPPROTO_XTP = 36;
+
+/// Datagram Delivery
+pub const IPPROTO_DDP = 37;
+
+/// Control Message Transport
+pub const IPPROTO_CMTP = 38;
+
+/// TP++ Transport
+pub const IPPROTO_TPXX = 39;
+
+/// IL transport protocol
+pub const IPPROTO_IL = 40;
+
+/// Source Demand Routing
+pub const IPPROTO_SDRP = 42;
+
+/// IP6 routing header
+pub const IPPROTO_ROUTING = 43;
+
+/// IP6 fragmentation header
+pub const IPPROTO_FRAGMENT = 44;
+
+/// InterDomain Routing
+pub const IPPROTO_IDRP = 45;
+
+/// resource reservation
+pub const IPPROTO_RSVP = 46;
+
+/// General Routing Encap.
+pub const IPPROTO_GRE = 47;
+
+/// Mobile Host Routing
+pub const IPPROTO_MHRP = 48;
+
+/// BHA
+pub const IPPROTO_BHA = 49;
+
+/// IP6 Encap Sec. Payload
+pub const IPPROTO_ESP = 50;
+
+/// IP6 Auth Header
+pub const IPPROTO_AH = 51;
+
+/// Integ. Net Layer Security
+pub const IPPROTO_INLSP = 52;
+
+/// IP with encryption
+pub const IPPROTO_SWIPE = 53;
+
+/// Next Hop Resolution
+pub const IPPROTO_NHRP = 54;
+
+/// IP Mobility
+pub const IPPROTO_MOBILE = 55;
+
+/// Transport Layer Security
+pub const IPPROTO_TLSP = 56;
+
+/// SKIP
+pub const IPPROTO_SKIP = 57;
+
+/// ICMP6
+pub const IPPROTO_ICMPV6 = 58;
+
+/// IP6 no next header
+pub const IPPROTO_NONE = 59;
+
+/// IP6 destination option
+pub const IPPROTO_DSTOPTS = 60;
+
+/// any host internal protocol
+pub const IPPROTO_AHIP = 61;
+
+/// CFTP
+pub const IPPROTO_CFTP = 62;
+
+/// "hello" routing protocol
+pub const IPPROTO_HELLO = 63;
+
+/// SATNET/Backroom EXPAK
+pub const IPPROTO_SATEXPAK = 64;
+
+/// Kryptolan
+pub const IPPROTO_KRYPTOLAN = 65;
+
+/// Remote Virtual Disk
+pub const IPPROTO_RVD = 66;
+
+/// Pluribus Packet Core
+pub const IPPROTO_IPPC = 67;
+
+/// Any distributed FS
+pub const IPPROTO_ADFS = 68;
+
+/// Satnet Monitoring
+pub const IPPROTO_SATMON = 69;
+
+/// VISA Protocol
+pub const IPPROTO_VISA = 70;
+
+/// Packet Core Utility
+pub const IPPROTO_IPCV = 71;
+
+/// Comp. Prot. Net. Executive
+pub const IPPROTO_CPNX = 72;
+
+/// Comp. Prot. HeartBeat
+pub const IPPROTO_CPHB = 73;
+
+/// Wang Span Network
+pub const IPPROTO_WSN = 74;
+
+/// Packet Video Protocol
+pub const IPPROTO_PVP = 75;
+
+/// BackRoom SATNET Monitoring
+pub const IPPROTO_BRSATMON = 76;
+
+/// Sun net disk proto (temp.)
+pub const IPPROTO_ND = 77;
+
+/// WIDEBAND Monitoring
+pub const IPPROTO_WBMON = 78;
+
+/// WIDEBAND EXPAK
+pub const IPPROTO_WBEXPAK = 79;
+
+/// ISO cnlp
+pub const IPPROTO_EON = 80;
+
+/// VMTP
+pub const IPPROTO_VMTP = 81;
+
+/// Secure VMTP
+pub const IPPROTO_SVMTP = 82;
+
+/// Banyon VINES
+pub const IPPROTO_VINES = 83;
+
+/// TTP
+pub const IPPROTO_TTP = 84;
+
+/// NSFNET-IGP
+pub const IPPROTO_IGP = 85;
+
+/// dissimilar gateway prot.
+pub const IPPROTO_DGP = 86;
+
+/// TCF
+pub const IPPROTO_TCF = 87;
+
+/// Cisco/GXS IGRP
+pub const IPPROTO_IGRP = 88;
+
+/// OSPFIGP
+pub const IPPROTO_OSPFIGP = 89;
+
+/// Strite RPC protocol
+pub const IPPROTO_SRPC = 90;
+
+/// Locus Address Resoloution
+pub const IPPROTO_LARP = 91;
+
+/// Multicast Transport
+pub const IPPROTO_MTP = 92;
+
+/// AX.25 Frames
+pub const IPPROTO_AX25 = 93;
+
+/// IP encapsulated in IP
+pub const IPPROTO_IPEIP = 94;
+
+/// Mobile Int.ing control
+pub const IPPROTO_MICP = 95;
+
+/// Semaphore Comm. security
+pub const IPPROTO_SCCSP = 96;
+
+/// Ethernet IP encapsulation
+pub const IPPROTO_ETHERIP = 97;
+
+/// encapsulation header
+pub const IPPROTO_ENCAP = 98;
+
+/// any private encr. scheme
+pub const IPPROTO_APES = 99;
+
+/// GMTP
+pub const IPPROTO_GMTP = 100;
+
+/// payload compression (IPComp)
+pub const IPPROTO_IPCOMP = 108;
+
+/// SCTP
+pub const IPPROTO_SCTP = 132;
+
+/// IPv6 Mobility Header
+pub const IPPROTO_MH = 135;
+
+/// UDP-Lite
+pub const IPPROTO_UDPLITE = 136;
+
+/// IP6 Host Identity Protocol
+pub const IPPROTO_HIP = 139;
+
+/// IP6 Shim6 Protocol
+pub const IPPROTO_SHIM6 = 140;
+
+/// Protocol Independent Mcast
+pub const IPPROTO_PIM = 103;
+
+/// CARP
+pub const IPPROTO_CARP = 112;
+
+/// PGM
+pub const IPPROTO_PGM = 113;
+
+/// MPLS-in-IP
+pub const IPPROTO_MPLS = 137;
+
+/// PFSYNC
+pub const IPPROTO_PFSYNC = 240;
+
+/// Reserved
+pub const IPPROTO_RESERVED_253 = 253;
+
+/// Reserved
+pub const IPPROTO_RESERVED_254 = 254;
+
+pub const rlimit_resource = enum(c_int) {
+    CPU = 0,
+    FSIZE = 1,
+    DATA = 2,
+    STACK = 3,
+    CORE = 4,
+    RSS = 5,
+    MEMLOCK = 6,
+    NPROC = 7,
+    NOFILE = 8,
+    SBSIZE = 9,
+    VMEM = 10,
+    NPTS = 11,
+    SWAP = 12,
+    KQUEUES = 13,
+    UMTXP = 14,
+    _,
+
+    pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = i64;
+
+/// No limit
+pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
+
+pub const RLIM_SAVED_MAX = RLIM_INFINITY;
+pub const RLIM_SAVED_CUR = RLIM_INFINITY;
+
+pub const rlimit = extern struct {
+    /// Soft limit
+    cur: rlim_t,
+    /// Hard limit
+    max: rlim_t,
+};
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 2;
+
+// TODO fill out if needed
+pub const directory_which = enum(c_int) {
+    B_USER_SETTINGS_DIRECTORY = 0xbbe,
+
+    _,
+};
+
+pub const cc_t = u8;
+pub const speed_t = u8;
+pub const tcflag_t = u32;
+
+pub const NCCS = 32;
+
+pub const termios = extern struct {
+    c_iflag: tcflag_t,
+    c_oflag: tcflag_t,
+    c_cflag: tcflag_t,
+    c_lflag: tcflag_t,
+    c_line: cc_t,
+    c_ispeed: speed_t,
+    c_ospeed: speed_t,
+    cc_t: [NCCS]cc_t,
+};
lib/std/c/linux.zig
@@ -1,11 +1,66 @@
 const std = @import("../std.zig");
+const builtin = @import("builtin");
 const maxInt = std.math.maxInt;
-const abi = std.Target.current.abi;
-const arch = std.Target.current.cpu.arch;
-const os_tag = std.Target.current.os.tag;
-usingnamespace std.c;
+const native_abi = builtin.abi;
+const native_arch = builtin.cpu.arch;
+const linux = std.os.linux;
 
-pub const _errno = switch (abi) {
+pub const E = linux.E;
+pub const Sigaction = linux.Sigaction;
+pub const dl_phdr_info = linux.dl_phdr_info;
+pub const fd_t = linux.fd_t;
+pub const rlimit = linux.rlimit;
+pub const rlimit_resource = linux.rlimit_resource;
+pub const timespec = linux.timespec;
+pub const NAME_MAX = linux.NAME_MAX;
+pub const PATH_MAX = linux.PATH_MAX;
+pub const IOV_MAX = linux.IOV_MAX;
+pub const STDIN_FILENO = linux.STDIN_FILENO;
+pub const STDOUT_FILENO = linux.STDIN_FILENO;
+pub const STDERR_FILENO = linux.STDIN_FILENO;
+pub const AT = linux.AT;
+pub const PROT = linux.PROT;
+pub const CLOCK = linux.CLOCK;
+pub const SIG = linux.SIG;
+pub const empty_sigset = linux.empty_sigset;
+pub const S = linux.S;
+pub const siginfo_t = linux.siginfo_t;
+pub const SA = linux.SA;
+pub const pollfd = linux.pollfd;
+pub const sigset_t = linux.sigset_t;
+pub const ARCH = linux.ARCH;
+pub const Elf_Symndx = linux.Elf_Symndx;
+pub const F = linux.F;
+pub const Flock = linux.Flock;
+pub const LOCK = linux.LOCK;
+pub const MAP = linux.MAP;
+pub const MMAP2_UNIT = linux.MMAP2_UNIT;
+pub const O = linux.O;
+pub const REG = linux.REG;
+pub const SC = linux.SC;
+pub const SYS = linux.SYS;
+pub const VDSO = linux.VDSO;
+pub const blkcnt_t = linux.blkcnt_t;
+pub const blksize_t = linux.blksize_t;
+pub const dev_t = linux.dev_t;
+pub const ino_t = linux.ino_t;
+pub const mcontext_t = linux.mcontext_t;
+pub const mode_t = linux.mode_t;
+pub const msghdr = linux.msghdr;
+pub const msghdr_const = linux.msghdr_const;
+pub const nlink_t = linux.nlink_t;
+pub const off_t = linux.off_t;
+pub const time_t = linux.time_t;
+pub const timeval = linux.timeval;
+pub const timezone = linux.timezone;
+pub const ucontext_t = linux.ucontext_t;
+pub const user_desc = linux.user_desc;
+pub const pid_t = linux.pid_t;
+pub const uid_t = linux.uid_t;
+pub const gid_t = linux.gid_t;
+pub const clock_t = linux.clock_t;
+
+pub const _errno = switch (native_abi) {
     .android => struct {
         extern "c" var __errno: c_int;
         fn getErrno() *c_int {
@@ -17,22 +72,94 @@ pub const _errno = switch (abi) {
     }.__errno_location,
 };
 
+pub const Stat = switch (native_arch) {
+    .sparcv9 => extern struct {
+        dev: u64,
+        ino: ino_t,
+        mode: u32,
+        nlink: usize,
+
+        uid: u32,
+        gid: u32,
+        rdev: u64,
+        __pad0: u32,
+
+        size: off_t,
+        blksize: isize,
+        blocks: i64,
+
+        atim: timespec,
+        mtim: timespec,
+        ctim: timespec,
+        __unused: [2]isize,
+
+        pub fn atime(self: @This()) timespec {
+            return self.atim;
+        }
+
+        pub fn mtime(self: @This()) timespec {
+            return self.mtim;
+        }
+
+        pub fn ctime(self: @This()) timespec {
+            return self.ctim;
+        }
+    },
+    .mips, .mipsel => extern struct {
+        dev: dev_t,
+        __pad0: [2]u32,
+        ino: ino_t,
+        mode: mode_t,
+        nlink: nlink_t,
+        uid: uid_t,
+        gid: gid_t,
+        rdev: dev_t,
+        __pad1: [2]u32,
+        size: off_t,
+        atim: timespec,
+        mtim: timespec,
+        ctim: timespec,
+        blksize: blksize_t,
+        __pad3: u32,
+        blocks: blkcnt_t,
+        __pad4: [14]u32,
+
+        pub fn atime(self: @This()) timespec {
+            return self.atim;
+        }
+
+        pub fn mtime(self: @This()) timespec {
+            return self.mtim;
+        }
+
+        pub fn ctime(self: @This()) timespec {
+            return self.ctim;
+        }
+    },
+
+    else => std.os.linux.Stat, // libc stat is the same as kernel stat.
+};
+
 pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
 
-pub const AI_PASSIVE = 0x01;
-pub const AI_CANONNAME = 0x02;
-pub const AI_NUMERICHOST = 0x04;
-pub const AI_V4MAPPED = 0x08;
-pub const AI_ALL = 0x10;
-pub const AI_ADDRCONFIG = 0x20;
-pub const AI_NUMERICSERV = 0x400;
-
-pub const NI_NUMERICHOST = 0x01;
-pub const NI_NUMERICSERV = 0x02;
-pub const NI_NOFQDN = 0x04;
-pub const NI_NAMEREQD = 0x08;
-pub const NI_DGRAM = 0x10;
-pub const NI_NUMERICSCOPE = 0x100;
+pub const AI = struct {
+    pub const PASSIVE = 0x01;
+    pub const CANONNAME = 0x02;
+    pub const NUMERICHOST = 0x04;
+    pub const V4MAPPED = 0x08;
+    pub const ALL = 0x10;
+    pub const ADDRCONFIG = 0x20;
+    pub const NUMERICSERV = 0x400;
+};
+
+pub const NI = struct {
+    pub const NUMERICHOST = 0x01;
+    pub const NUMERICSERV = 0x02;
+    pub const NOFQDN = 0x04;
+    pub const NAMEREQD = 0x08;
+    pub const DGRAM = 0x10;
+    pub const NUMERICSCOPE = 0x100;
+};
 
 pub const EAI = enum(c_int) {
     BADFLAGS = -1,
@@ -60,8 +187,8 @@ pub const EAI = enum(c_int) {
 
 pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int;
 pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
-pub extern "c" fn fstat64(fd: fd_t, buf: *libc_stat) c_int;
-pub extern "c" fn fstatat64(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
+pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int;
+pub extern "c" fn fstatat64(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
 pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int;
 pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int;
 pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64;
@@ -137,7 +264,7 @@ pub const pthread_mutex_t = extern struct {
 pub const pthread_cond_t = extern struct {
     size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T,
 };
-pub const pthread_rwlock_t = switch (abi) {
+pub const pthread_rwlock_t = switch (native_abi) {
     .android => switch (@sizeOf(usize)) {
         4 => extern struct {
             lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER,
@@ -168,11 +295,11 @@ pub const sem_t = extern struct {
 };
 
 const __SIZEOF_PTHREAD_COND_T = 48;
-const __SIZEOF_PTHREAD_MUTEX_T = if (os_tag == .fuchsia) 40 else switch (abi) {
+const __SIZEOF_PTHREAD_MUTEX_T = switch (native_abi) {
     .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24,
-    .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (arch) {
+    .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) {
         .aarch64 => 48,
-        .x86_64 => if (abi == .gnux32) 40 else 32,
+        .x86_64 => if (native_abi == .gnux32) 40 else 32,
         .mips64, .powerpc64, .powerpc64le, .sparcv9 => 40,
         else => if (@sizeOf(usize) == 8) 40 else 24,
     },
@@ -184,9 +311,11 @@ const __SIZEOF_SEM_T = 4 * @sizeOf(usize);
 pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E;
 pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
 
-pub const RTLD_LAZY = 1;
-pub const RTLD_NOW = 2;
-pub const RTLD_NOLOAD = 4;
-pub const RTLD_NODELETE = 4096;
-pub const RTLD_GLOBAL = 256;
-pub const RTLD_LOCAL = 0;
+pub const RTLD = struct {
+    pub const LAZY = 1;
+    pub const NOW = 2;
+    pub const NOLOAD = 4;
+    pub const NODELETE = 4096;
+    pub const GLOBAL = 256;
+    pub const LOCAL = 0;
+};
lib/std/c/netbsd.zig
@@ -1,5 +1,6 @@
 const std = @import("../std.zig");
-const builtin = std.builtin;
+const builtin = @import("builtin");
+const maxInt = std.math.maxInt;
 
 usingnamespace std.c;
 
@@ -13,8 +14,8 @@ pub extern "c" fn _lwp_self() lwpid_t;
 
 pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
 pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
-pub extern "c" fn __fstat50(fd: fd_t, buf: *libc_stat) c_int;
-pub extern "c" fn __stat50(path: [*:0]const u8, buf: *libc_stat) c_int;
+pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
+pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
 pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
 pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
 pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
@@ -51,7 +52,7 @@ pub const pthread_cond_t = extern struct {
 
 pub const pthread_rwlock_t = extern struct {
     ptr_magic: c_uint = 0x99990009,
-    ptr_interlock: switch (std.builtin.cpu.arch) {
+    ptr_interlock: switch (builtin.cpu.arch) {
         .aarch64, .sparc, .x86_64, .i386 => u8,
         .arm, .powerpc => c_int,
         else => unreachable,
@@ -92,3 +93,1341 @@ pub const sem_t = ?*opaque {};
 
 pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E;
 pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
+
+pub const clock_getres = __clock_getres50;
+pub const clock_gettime = __clock_gettime50;
+pub const fstat = __fstat50;
+pub const getdents = __getdents30;
+pub const getrusage = __getrusage50;
+pub const gettimeofday = __gettimeofday50;
+pub const nanosleep = __nanosleep50;
+pub const sched_yield = __libc_thr_yield;
+pub const sigaction = __sigaction14;
+pub const sigaltstack = __sigaltstack14;
+pub const sigprocmask = __sigprocmask14;
+pub const socket = __socket30;
+pub const stat = __stat50;
+
+pub const blkcnt_t = i64;
+pub const blksize_t = i32;
+pub const clock_t = u32;
+pub const dev_t = u64;
+pub const fd_t = i32;
+pub const gid_t = u32;
+pub const ino_t = u64;
+pub const mode_t = u32;
+pub const nlink_t = u32;
+pub const off_t = i64;
+pub const pid_t = i32;
+pub const socklen_t = u32;
+pub const time_t = i64;
+pub const uid_t = u32;
+pub const lwpid_t = i32;
+pub const suseconds_t = c_int;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+    ident: usize,
+    filter: i32,
+    flags: u32,
+    fflags: u32,
+    data: i64,
+    udata: usize,
+};
+
+pub const RTLD_LAZY = 1;
+pub const RTLD_NOW = 2;
+pub const RTLD_GLOBAL = 0x100;
+pub const RTLD_LOCAL = 0x200;
+pub const RTLD_NODELETE = 0x01000;
+pub const RTLD_NOLOAD = 0x02000;
+
+pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
+pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
+pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
+
+pub const dl_phdr_info = extern struct {
+    dlpi_addr: usize,
+    dlpi_name: ?[*:0]const u8,
+    dlpi_phdr: [*]std.elf.Phdr,
+    dlpi_phnum: u16,
+};
+
+pub const Flock = extern struct {
+    l_start: off_t,
+    l_len: off_t,
+    l_pid: pid_t,
+    l_type: i16,
+    l_whence: i16,
+};
+
+pub const addrinfo = extern struct {
+    flags: i32,
+    family: i32,
+    socktype: i32,
+    protocol: i32,
+    addrlen: socklen_t,
+    canonname: ?[*:0]u8,
+    addr: ?*sockaddr,
+    next: ?*addrinfo,
+};
+
+pub const EAI = enum(c_int) {
+    /// address family for hostname not supported
+    ADDRFAMILY = 1,
+
+    /// name could not be resolved at this time
+    AGAIN = 2,
+
+    /// flags parameter had an invalid value
+    BADFLAGS = 3,
+
+    /// non-recoverable failure in name resolution
+    FAIL = 4,
+
+    /// address family not recognized
+    FAMILY = 5,
+
+    /// memory allocation failure
+    MEMORY = 6,
+
+    /// no address associated with hostname
+    NODATA = 7,
+
+    /// name does not resolve
+    NONAME = 8,
+
+    /// service not recognized for socket type
+    SERVICE = 9,
+
+    /// intended socket type was not recognized
+    SOCKTYPE = 10,
+
+    /// system error returned in errno
+    SYSTEM = 11,
+
+    /// invalid value for hints
+    BADHINTS = 12,
+
+    /// resolved protocol is unknown
+    PROTOCOL = 13,
+
+    /// argument buffer overflow
+    OVERFLOW = 14,
+
+    _,
+};
+
+pub const EAI_MAX = 15;
+
+pub const msghdr = extern struct {
+    /// optional address
+    msg_name: ?*sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec,
+
+    /// # elements in msg_iov
+    msg_iovlen: i32,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: i32,
+};
+
+pub const msghdr_const = extern struct {
+    /// optional address
+    msg_name: ?*const sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec_const,
+
+    /// # elements in msg_iov
+    msg_iovlen: i32,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: i32,
+};
+
+/// The stat structure used by libc.
+pub const Stat = extern struct {
+    dev: dev_t,
+    mode: mode_t,
+    ino: ino_t,
+    nlink: nlink_t,
+    uid: uid_t,
+    gid: gid_t,
+    rdev: dev_t,
+    atim: timespec,
+    mtim: timespec,
+    ctim: timespec,
+    birthtim: timespec,
+    size: off_t,
+    blocks: blkcnt_t,
+    blksize: blksize_t,
+    flags: u32,
+    gen: u32,
+    __spare: [2]u32,
+
+    pub fn atime(self: @This()) timespec {
+        return self.atim;
+    }
+
+    pub fn mtime(self: @This()) timespec {
+        return self.mtim;
+    }
+
+    pub fn ctime(self: @This()) timespec {
+        return self.ctim;
+    }
+};
+
+pub const timespec = extern struct {
+    tv_sec: i64,
+    tv_nsec: isize,
+};
+
+pub const timeval = extern struct {
+    /// seconds
+    tv_sec: time_t,
+    /// microseconds
+    tv_usec: suseconds_t,
+};
+
+pub const MAXNAMLEN = 511;
+
+pub const dirent = extern struct {
+    d_fileno: ino_t,
+    d_reclen: u16,
+    d_namlen: u16,
+    d_type: u8,
+    d_name: [MAXNAMLEN:0]u8,
+
+    pub fn reclen(self: dirent) u16 {
+        return self.d_reclen;
+    }
+};
+
+pub const SOCK_STREAM = 1;
+pub const SOCK_DGRAM = 2;
+pub const SOCK_RAW = 3;
+pub const SOCK_RDM = 4;
+pub const SOCK_SEQPACKET = 5;
+pub const SOCK_CONN_DGRAM = 6;
+pub const SOCK_DCCP = SOCK_CONN_DGRAM;
+
+pub const SOCK_CLOEXEC = 0x10000000;
+pub const SOCK_NONBLOCK = 0x20000000;
+pub const SOCK_NOSIGPIPE = 0x40000000;
+pub const SOCK_FLAGS_MASK = 0xf0000000;
+
+pub const SO_DEBUG = 0x0001;
+pub const SO_ACCEPTCONN = 0x0002;
+pub const SO_REUSEADDR = 0x0004;
+pub const SO_KEEPALIVE = 0x0008;
+pub const SO_DONTROUTE = 0x0010;
+pub const SO_BROADCAST = 0x0020;
+pub const SO_USELOOPBACK = 0x0040;
+pub const SO_LINGER = 0x0080;
+pub const SO_OOBINLINE = 0x0100;
+pub const SO_REUSEPORT = 0x0200;
+pub const SO_NOSIGPIPE = 0x0800;
+pub const SO_ACCEPTFILTER = 0x1000;
+pub const SO_TIMESTAMP = 0x2000;
+pub const SO_RERROR = 0x4000;
+
+pub const SO_SNDBUF = 0x1001;
+pub const SO_RCVBUF = 0x1002;
+pub const SO_SNDLOWAT = 0x1003;
+pub const SO_RCVLOWAT = 0x1004;
+pub const SO_ERROR = 0x1007;
+pub const SO_TYPE = 0x1008;
+pub const SO_OVERFLOWED = 0x1009;
+
+pub const SO_NOHEADER = 0x100a;
+pub const SO_SNDTIMEO = 0x100b;
+pub const SO_RCVTIMEO = 0x100c;
+
+pub const SOL_SOCKET = 0xffff;
+
+pub const PF_UNSPEC = AF_UNSPEC;
+pub const PF_LOCAL = AF_LOCAL;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_INET = AF_INET;
+pub const PF_IMPLINK = AF_IMPLINK;
+pub const PF_PUP = AF_PUP;
+pub const PF_CHAOS = AF_CHAOS;
+pub const PF_NS = AF_NS;
+pub const PF_ISO = AF_ISO;
+pub const PF_OSI = AF_ISO;
+pub const PF_ECMA = AF_ECMA;
+pub const PF_DATAKIT = AF_DATAKIT;
+pub const PF_CCITT = AF_CCITT;
+pub const PF_SNA = AF_SNA;
+pub const PF_DECnet = AF_DECnet;
+pub const PF_DLI = AF_DLI;
+pub const PF_LAT = AF_LAT;
+pub const PF_HYLINK = AF_HYLINK;
+pub const PF_APPLETALK = AF_APPLETALK;
+pub const PF_OROUTE = AF_OROUTE;
+pub const PF_LINK = AF_LINK;
+pub const PF_COIP = AF_COIP;
+pub const PF_CNT = AF_CNT;
+pub const PF_INET6 = AF_INET6;
+pub const PF_IPX = AF_IPX;
+pub const PF_ISDN = AF_ISDN;
+pub const PF_E164 = AF_E164;
+pub const PF_NATM = AF_NATM;
+pub const PF_ARP = AF_ARP;
+pub const PF_BLUETOOTH = AF_BLUETOOTH;
+pub const PF_MPLS = AF_MPLS;
+pub const PF_ROUTE = AF_ROUTE;
+pub const PF_CAN = AF_CAN;
+pub const PF_ETHER = AF_ETHER;
+pub const PF_MAX = AF_MAX;
+
+pub const AF_UNSPEC = 0;
+pub const AF_LOCAL = 1;
+pub const AF_UNIX = AF_LOCAL;
+pub const AF_INET = 2;
+pub const AF_IMPLINK = 3;
+pub const AF_PUP = 4;
+pub const AF_CHAOS = 5;
+pub const AF_NS = 6;
+pub const AF_ISO = 7;
+pub const AF_OSI = AF_ISO;
+pub const AF_ECMA = 8;
+pub const AF_DATAKIT = 9;
+pub const AF_CCITT = 10;
+pub const AF_SNA = 11;
+pub const AF_DECnet = 12;
+pub const AF_DLI = 13;
+pub const AF_LAT = 14;
+pub const AF_HYLINK = 15;
+pub const AF_APPLETALK = 16;
+pub const AF_OROUTE = 17;
+pub const AF_LINK = 18;
+pub const AF_COIP = 20;
+pub const AF_CNT = 21;
+pub const AF_IPX = 23;
+pub const AF_INET6 = 24;
+pub const AF_ISDN = 26;
+pub const AF_E164 = AF_ISDN;
+pub const AF_NATM = 27;
+pub const AF_ARP = 28;
+pub const AF_BLUETOOTH = 31;
+pub const AF_IEEE80211 = 32;
+pub const AF_MPLS = 33;
+pub const AF_ROUTE = 34;
+pub const AF_CAN = 35;
+pub const AF_ETHER = 36;
+pub const AF_MAX = 37;
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+    /// total length
+    len: u8,
+
+    /// address family
+    family: sa_family_t,
+
+    /// actually longer; address value
+    data: [14]u8,
+};
+
+pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+
+pub const sockaddr_in = extern struct {
+    len: u8 = @sizeOf(sockaddr_in),
+    family: sa_family_t = AF_INET,
+    port: in_port_t,
+    addr: u32,
+    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+};
+
+pub const sockaddr_in6 = extern struct {
+    len: u8 = @sizeOf(sockaddr_in6),
+    family: sa_family_t = AF_INET6,
+    port: in_port_t,
+    flowinfo: u32,
+    addr: [16]u8,
+    scope_id: u32,
+};
+
+/// Definitions for UNIX IPC domain.
+pub const sockaddr_un = extern struct {
+    /// total sockaddr length
+    len: u8 = @sizeOf(sockaddr_un),
+
+    /// AF_LOCAL
+    family: sa_family_t = AF_LOCAL,
+
+    /// path name
+    path: [104]u8,
+};
+
+/// get address to use bind()
+pub const AI_PASSIVE = 0x00000001;
+
+/// fill ai_canonname
+pub const AI_CANONNAME = 0x00000002;
+
+/// prevent host name resolution
+pub const AI_NUMERICHOST = 0x00000004;
+
+/// prevent service name resolution
+pub const AI_NUMERICSERV = 0x00000008;
+
+/// only if any address is assigned
+pub const AI_ADDRCONFIG = 0x00000400;
+
+pub const CTL_KERN = 1;
+pub const CTL_DEBUG = 5;
+
+pub const KERN_PROC_ARGS = 48; // struct: process argv/env
+pub const KERN_PROC_PATHNAME = 5; // path to executable
+pub const KERN_IOV_MAX = 38;
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = KERN_IOV_MAX;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT_NONE = 0;
+pub const PROT_READ = 1;
+pub const PROT_WRITE = 2;
+pub const PROT_EXEC = 4;
+
+pub const CLOCK_REALTIME = 0;
+pub const CLOCK_VIRTUAL = 1;
+pub const CLOCK_PROF = 2;
+pub const CLOCK_MONOTONIC = 3;
+pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;
+pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;
+
+pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+pub const MAP_SHARED = 0x0001;
+pub const MAP_PRIVATE = 0x0002;
+pub const MAP_REMAPDUP = 0x0004;
+pub const MAP_FIXED = 0x0010;
+pub const MAP_RENAME = 0x0020;
+pub const MAP_NORESERVE = 0x0040;
+pub const MAP_INHERIT = 0x0080;
+pub const MAP_HASSEMAPHORE = 0x0200;
+pub const MAP_TRYFIXED = 0x0400;
+pub const MAP_WIRED = 0x0800;
+
+pub const MAP_FILE = 0x0000;
+pub const MAP_NOSYNC = 0x0800;
+pub const MAP_ANON = 0x1000;
+pub const MAP_ANONYMOUS = MAP_ANON;
+pub const MAP_STACK = 0x2000;
+
+pub const WNOHANG = 0x00000001;
+pub const WUNTRACED = 0x00000002;
+pub const WSTOPPED = WUNTRACED;
+pub const WCONTINUED = 0x00000010;
+pub const WNOWAIT = 0x00010000;
+pub const WEXITED = 0x00000020;
+pub const WTRAPPED = 0x00000040;
+
+pub const SA_ONSTACK = 0x0001;
+pub const SA_RESTART = 0x0002;
+pub const SA_RESETHAND = 0x0004;
+pub const SA_NOCLDSTOP = 0x0008;
+pub const SA_NODEFER = 0x0010;
+pub const SA_NOCLDWAIT = 0x0020;
+pub const SA_SIGINFO = 0x0040;
+
+pub const SIGHUP = 1;
+pub const SIGINT = 2;
+pub const SIGQUIT = 3;
+pub const SIGILL = 4;
+pub const SIGTRAP = 5;
+pub const SIGABRT = 6;
+pub const SIGIOT = SIGABRT;
+pub const SIGEMT = 7;
+pub const SIGFPE = 8;
+pub const SIGKILL = 9;
+pub const SIGBUS = 10;
+pub const SIGSEGV = 11;
+pub const SIGSYS = 12;
+pub const SIGPIPE = 13;
+pub const SIGALRM = 14;
+pub const SIGTERM = 15;
+pub const SIGURG = 16;
+pub const SIGSTOP = 17;
+pub const SIGTSTP = 18;
+pub const SIGCONT = 19;
+pub const SIGCHLD = 20;
+pub const SIGTTIN = 21;
+pub const SIGTTOU = 22;
+pub const SIGIO = 23;
+pub const SIGXCPU = 24;
+pub const SIGXFSZ = 25;
+pub const SIGVTALRM = 26;
+pub const SIGPROF = 27;
+pub const SIGWINCH = 28;
+pub const SIGINFO = 29;
+pub const SIGUSR1 = 30;
+pub const SIGUSR2 = 31;
+pub const SIGPWR = 32;
+
+pub const SIGRTMIN = 33;
+pub const SIGRTMAX = 63;
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+/// open for reading only
+pub const O_RDONLY = 0x00000000;
+
+/// open for writing only
+pub const O_WRONLY = 0x00000001;
+
+/// open for reading and writing
+pub const O_RDWR = 0x00000002;
+
+/// mask for above modes
+pub const O_ACCMODE = 0x00000003;
+
+/// no delay
+pub const O_NONBLOCK = 0x00000004;
+
+/// set append mode
+pub const O_APPEND = 0x00000008;
+
+/// open with shared file lock
+pub const O_SHLOCK = 0x00000010;
+
+/// open with exclusive file lock
+pub const O_EXLOCK = 0x00000020;
+
+/// signal pgrp when data ready
+pub const O_ASYNC = 0x00000040;
+
+/// synchronous writes
+pub const O_SYNC = 0x00000080;
+
+/// don't follow symlinks on the last
+pub const O_NOFOLLOW = 0x00000100;
+
+/// create if nonexistent
+pub const O_CREAT = 0x00000200;
+
+/// truncate to zero length
+pub const O_TRUNC = 0x00000400;
+
+/// error if already exists
+pub const O_EXCL = 0x00000800;
+
+/// don't assign controlling terminal
+pub const O_NOCTTY = 0x00008000;
+
+/// write: I/O data completion
+pub const O_DSYNC = 0x00010000;
+
+/// read: I/O completion as for write
+pub const O_RSYNC = 0x00020000;
+
+/// use alternate i/o semantics
+pub const O_ALT_IO = 0x00040000;
+
+/// direct I/O hint
+pub const O_DIRECT = 0x00080000;
+
+/// fail if not a directory
+pub const O_DIRECTORY = 0x00200000;
+
+/// set close on exec
+pub const O_CLOEXEC = 0x00400000;
+
+/// skip search permission checks
+pub const O_SEARCH = 0x00800000;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_SETFD = 2;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+
+pub const F_GETOWN = 5;
+pub const F_SETOWN = 6;
+
+pub const F_GETLK = 7;
+pub const F_SETLK = 8;
+pub const F_SETLKW = 9;
+
+pub const F_RDLCK = 1;
+pub const F_WRLCK = 3;
+pub const F_UNLCK = 2;
+
+pub const LOCK_SH = 1;
+pub const LOCK_EX = 2;
+pub const LOCK_UN = 8;
+pub const LOCK_NB = 4;
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+
+pub const SIG_BLOCK = 1;
+pub const SIG_UNBLOCK = 2;
+pub const SIG_SETMASK = 3;
+
+pub const DT_UNKNOWN = 0;
+pub const DT_FIFO = 1;
+pub const DT_CHR = 2;
+pub const DT_DIR = 4;
+pub const DT_BLK = 6;
+pub const DT_REG = 8;
+pub const DT_LNK = 10;
+pub const DT_SOCK = 12;
+pub const DT_WHT = 14;
+
+/// 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
+/// ... use KEVENT_FLAG_ERROR_EVENTS
+///     on syscalls supporting flags
+pub const EV_RECEIPT = 0x0040;
+
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+pub const EVFILT_READ = 0;
+pub const EVFILT_WRITE = 1;
+
+/// attached to aio requests
+pub const EVFILT_AIO = 2;
+
+/// attached to vnodes
+pub const EVFILT_VNODE = 3;
+
+/// attached to struct proc
+pub const EVFILT_PROC = 4;
+
+/// attached to struct proc
+pub const EVFILT_SIGNAL = 5;
+
+/// timers
+pub const EVFILT_TIMER = 6;
+
+/// Filesystem events
+pub const EVFILT_FS = 7;
+
+/// On input, NOTE_TRIGGER causes the event to be triggered for output.
+pub const NOTE_TRIGGER = 0x08000000;
+
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// 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;
+
+/// process exited
+pub const NOTE_EXIT = 0x80000000;
+
+/// process forked
+pub const NOTE_FORK = 0x40000000;
+
+/// process exec'd
+pub const NOTE_EXEC = 0x20000000;
+
+/// mask for signal & exit status
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = 0xf0000000;
+
+pub const TIOCCBRK = 0x2000747a;
+pub const TIOCCDTR = 0x20007478;
+pub const TIOCCONS = 0x80047462;
+pub const TIOCDCDTIMESTAMP = 0x40107458;
+pub const TIOCDRAIN = 0x2000745e;
+pub const TIOCEXCL = 0x2000740d;
+pub const TIOCEXT = 0x80047460;
+pub const TIOCFLAG_CDTRCTS = 0x10;
+pub const TIOCFLAG_CLOCAL = 0x2;
+pub const TIOCFLAG_CRTSCTS = 0x4;
+pub const TIOCFLAG_MDMBUF = 0x8;
+pub const TIOCFLAG_SOFTCAR = 0x1;
+pub const TIOCFLUSH = 0x80047410;
+pub const TIOCGETA = 0x402c7413;
+pub const TIOCGETD = 0x4004741a;
+pub const TIOCGFLAGS = 0x4004745d;
+pub const TIOCGLINED = 0x40207442;
+pub const TIOCGPGRP = 0x40047477;
+pub const TIOCGQSIZE = 0x40047481;
+pub const TIOCGRANTPT = 0x20007447;
+pub const TIOCGSID = 0x40047463;
+pub const TIOCGSIZE = 0x40087468;
+pub const TIOCGWINSZ = 0x40087468;
+pub const TIOCMBIC = 0x8004746b;
+pub const TIOCMBIS = 0x8004746c;
+pub const TIOCMGET = 0x4004746a;
+pub const TIOCMSET = 0x8004746d;
+pub const TIOCM_CAR = 0x40;
+pub const TIOCM_CD = 0x40;
+pub const TIOCM_CTS = 0x20;
+pub const TIOCM_DSR = 0x100;
+pub const TIOCM_DTR = 0x2;
+pub const TIOCM_LE = 0x1;
+pub const TIOCM_RI = 0x80;
+pub const TIOCM_RNG = 0x80;
+pub const TIOCM_RTS = 0x4;
+pub const TIOCM_SR = 0x10;
+pub const TIOCM_ST = 0x8;
+pub const TIOCNOTTY = 0x20007471;
+pub const TIOCNXCL = 0x2000740e;
+pub const TIOCOUTQ = 0x40047473;
+pub const TIOCPKT = 0x80047470;
+pub const TIOCPKT_DATA = 0x0;
+pub const TIOCPKT_DOSTOP = 0x20;
+pub const TIOCPKT_FLUSHREAD = 0x1;
+pub const TIOCPKT_FLUSHWRITE = 0x2;
+pub const TIOCPKT_IOCTL = 0x40;
+pub const TIOCPKT_NOSTOP = 0x10;
+pub const TIOCPKT_START = 0x8;
+pub const TIOCPKT_STOP = 0x4;
+pub const TIOCPTMGET = 0x40287446;
+pub const TIOCPTSNAME = 0x40287448;
+pub const TIOCRCVFRAME = 0x80087445;
+pub const TIOCREMOTE = 0x80047469;
+pub const TIOCSBRK = 0x2000747b;
+pub const TIOCSCTTY = 0x20007461;
+pub const TIOCSDTR = 0x20007479;
+pub const TIOCSETA = 0x802c7414;
+pub const TIOCSETAF = 0x802c7416;
+pub const TIOCSETAW = 0x802c7415;
+pub const TIOCSETD = 0x8004741b;
+pub const TIOCSFLAGS = 0x8004745c;
+pub const TIOCSIG = 0x2000745f;
+pub const TIOCSLINED = 0x80207443;
+pub const TIOCSPGRP = 0x80047476;
+pub const TIOCSQSIZE = 0x80047480;
+pub const TIOCSSIZE = 0x80087467;
+pub const TIOCSTART = 0x2000746e;
+pub const TIOCSTAT = 0x80047465;
+pub const TIOCSTI = 0x80017472;
+pub const TIOCSTOP = 0x2000746f;
+pub const TIOCSWINSZ = 0x80087467;
+pub const TIOCUCNTL = 0x80047466;
+pub const TIOCXMTFRAME = 0x80087444;
+
+pub fn WEXITSTATUS(s: u32) u8 {
+    return @intCast(u8, (s >> 8) & 0xff);
+}
+pub fn WTERMSIG(s: u32) u32 {
+    return s & 0x7f;
+}
+pub fn WSTOPSIG(s: u32) u32 {
+    return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: u32) bool {
+    return WTERMSIG(s) == 0;
+}
+
+pub fn WIFCONTINUED(s: u32) bool {
+    return ((s & 0x7f) == 0xffff);
+}
+
+pub fn WIFSTOPPED(s: u32) bool {
+    return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
+}
+
+pub fn WIFSIGNALED(s: u32) bool {
+    return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s);
+}
+
+pub const winsize = extern struct {
+    ws_row: u16,
+    ws_col: u16,
+    ws_xpixel: u16,
+    ws_ypixel: u16,
+};
+
+const NSIG = 32;
+
+pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+    pub const handler_fn = fn (c_int) callconv(.C) void;
+    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+    /// signal handler
+    handler: extern union {
+        handler: ?handler_fn,
+        sigaction: ?sigaction_fn,
+    },
+    /// signal mask to apply
+    mask: sigset_t,
+    /// signal options
+    flags: c_uint,
+};
+
+pub const sigval_t = extern union {
+    int: i32,
+    ptr: ?*c_void,
+};
+
+pub const siginfo_t = extern union {
+    pad: [128]u8,
+    info: _ksiginfo,
+};
+
+pub const _ksiginfo = extern struct {
+    signo: i32,
+    code: i32,
+    errno: i32,
+    // 64bit architectures insert 4bytes of padding here, this is done by
+    // correctly aligning the reason field
+    reason: extern union {
+        rt: extern struct {
+            pid: pid_t,
+            uid: uid_t,
+            value: sigval_t,
+        },
+        child: extern struct {
+            pid: pid_t,
+            uid: uid_t,
+            status: i32,
+            utime: clock_t,
+            stime: clock_t,
+        },
+        fault: extern struct {
+            addr: ?*c_void,
+            trap: i32,
+            trap2: i32,
+            trap3: i32,
+        },
+        poll: extern struct {
+            band: i32,
+            fd: i32,
+        },
+        syscall: extern struct {
+            sysnum: i32,
+            retval: [2]i32,
+            @"error": i32,
+            args: [8]u64,
+        },
+        ptrace_state: extern struct {
+            pe_report_event: i32,
+            option: extern union {
+                pe_other_pid: pid_t,
+                pe_lwp: lwpid_t,
+            },
+        },
+    } align(@sizeOf(usize)),
+};
+
+pub const _SIG_WORDS = 4;
+pub const _SIG_MAXSIG = 128;
+
+pub inline fn _SIG_IDX(sig: usize) usize {
+    return sig - 1;
+}
+pub inline fn _SIG_WORD(sig: usize) usize {
+    return_SIG_IDX(sig) >> 5;
+}
+pub inline fn _SIG_BIT(sig: usize) usize {
+    return 1 << (_SIG_IDX(sig) & 31);
+}
+pub inline fn _SIG_VALID(sig: usize) usize {
+    return sig <= _SIG_MAXSIG and sig > 0;
+}
+
+pub const sigset_t = extern struct {
+    __bits: [_SIG_WORDS]u32,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
+
+// XXX x86_64 specific
+pub const mcontext_t = extern struct {
+    gregs: [26]u64,
+    mc_tlsbase: u64,
+    fpregs: [512]u8 align(8),
+};
+
+pub const REG_RBP = 12;
+pub const REG_RIP = 21;
+pub const REG_RSP = 24;
+
+pub const ucontext_t = extern struct {
+    flags: u32,
+    link: ?*ucontext_t,
+    sigmask: sigset_t,
+    stack: stack_t,
+    mcontext: mcontext_t,
+    __pad: [
+        switch (builtin.cpu.arch) {
+            .i386 => 4,
+            .mips, .mipsel, .mips64, .mips64el => 14,
+            .arm, .armeb, .thumb, .thumbeb => 1,
+            .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8,
+            else => 0,
+        }
+    ]u32,
+};
+
+pub const E = enum(u16) {
+    /// No error occurred.
+    SUCCESS = 0,
+    PERM = 1, // Operation not permitted
+    NOENT = 2, // No such file or directory
+    SRCH = 3, // No such process
+    INTR = 4, // Interrupted system call
+    IO = 5, // Input/output error
+    NXIO = 6, // Device not configured
+    @"2BIG" = 7, // Argument list too long
+    NOEXEC = 8, // Exec format error
+    BADF = 9, // Bad file descriptor
+    CHILD = 10, // No child processes
+    DEADLK = 11, // Resource deadlock avoided
+    // 11 was AGAIN
+    NOMEM = 12, // Cannot allocate memory
+    ACCES = 13, // Permission denied
+    FAULT = 14, // Bad address
+    NOTBLK = 15, // Block device required
+    BUSY = 16, // Device busy
+    EXIST = 17, // File exists
+    XDEV = 18, // Cross-device link
+    NODEV = 19, // Operation not supported by device
+    NOTDIR = 20, // Not a directory
+    ISDIR = 21, // Is a directory
+    INVAL = 22, // Invalid argument
+    NFILE = 23, // Too many open files in system
+    MFILE = 24, // Too many open files
+    NOTTY = 25, // Inappropriate ioctl for device
+    TXTBSY = 26, // Text file busy
+    FBIG = 27, // File too large
+    NOSPC = 28, // No space left on device
+    SPIPE = 29, // Illegal seek
+    ROFS = 30, // Read-only file system
+    MLINK = 31, // Too many links
+    PIPE = 32, // Broken pipe
+
+    // math software
+    DOM = 33, // Numerical argument out of domain
+    RANGE = 34, // Result too large or too small
+
+    // non-blocking and interrupt i/o
+    // also: WOULDBLOCK: operation would block
+    AGAIN = 35, // Resource temporarily unavailable
+    INPROGRESS = 36, // Operation now in progress
+    ALREADY = 37, // Operation already in progress
+
+    // ipc/network software -- argument errors
+    NOTSOCK = 38, // Socket operation on non-socket
+    DESTADDRREQ = 39, // Destination address required
+    MSGSIZE = 40, // Message too long
+    PROTOTYPE = 41, // Protocol wrong type for socket
+    NOPROTOOPT = 42, // Protocol option not available
+    PROTONOSUPPORT = 43, // Protocol not supported
+    SOCKTNOSUPPORT = 44, // Socket type not supported
+    OPNOTSUPP = 45, // Operation not supported
+    PFNOSUPPORT = 46, // Protocol family not supported
+    AFNOSUPPORT = 47, // Address family not supported by protocol family
+    ADDRINUSE = 48, // Address already in use
+    ADDRNOTAVAIL = 49, // Can't assign requested address
+
+    // ipc/network software -- operational errors
+    NETDOWN = 50, // Network is down
+    NETUNREACH = 51, // Network is unreachable
+    NETRESET = 52, // Network dropped connection on reset
+    CONNABORTED = 53, // Software caused connection abort
+    CONNRESET = 54, // Connection reset by peer
+    NOBUFS = 55, // No buffer space available
+    ISCONN = 56, // Socket is already connected
+    NOTCONN = 57, // Socket is not connected
+    SHUTDOWN = 58, // Can't send after socket shutdown
+    TOOMANYREFS = 59, // Too many references: can't splice
+    TIMEDOUT = 60, // Operation timed out
+    CONNREFUSED = 61, // Connection refused
+
+    LOOP = 62, // Too many levels of symbolic links
+    NAMETOOLONG = 63, // File name too long
+
+    // should be rearranged
+    HOSTDOWN = 64, // Host is down
+    HOSTUNREACH = 65, // No route to host
+    NOTEMPTY = 66, // Directory not empty
+
+    // quotas & mush
+    PROCLIM = 67, // Too many processes
+    USERS = 68, // Too many users
+    DQUOT = 69, // Disc quota exceeded
+
+    // Network File System
+    STALE = 70, // Stale NFS file handle
+    REMOTE = 71, // Too many levels of remote in path
+    BADRPC = 72, // RPC struct is bad
+    RPCMISMATCH = 73, // RPC version wrong
+    PROGUNAVAIL = 74, // RPC prog. not avail
+    PROGMISMATCH = 75, // Program version wrong
+    PROCUNAVAIL = 76, // Bad procedure for program
+
+    NOLCK = 77, // No locks available
+    NOSYS = 78, // Function not implemented
+
+    FTYPE = 79, // Inappropriate file type or format
+    AUTH = 80, // Authentication error
+    NEEDAUTH = 81, // Need authenticator
+
+    // SystemV IPC
+    IDRM = 82, // Identifier removed
+    NOMSG = 83, // No message of desired type
+    OVERFLOW = 84, // Value too large to be stored in data type
+
+    // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
+    ILSEQ = 85, // Illegal byte sequence
+
+    // From IEEE Std 1003.1-2001
+    // Base, Realtime, Threads or Thread Priority Scheduling option errors
+    NOTSUP = 86, // Not supported
+
+    // Realtime option errors
+    CANCELED = 87, // Operation canceled
+
+    // Realtime, XSI STREAMS option errors
+    BADMSG = 88, // Bad or Corrupt message
+
+    // XSI STREAMS option errors
+    NODATA = 89, // No message available
+    NOSR = 90, // No STREAM resources
+    NOSTR = 91, // Not a STREAM
+    TIME = 92, // STREAM ioctl timeout
+
+    // File system extended attribute errors
+    NOATTR = 93, // Attribute not found
+
+    // Realtime, XSI STREAMS option errors
+    MULTIHOP = 94, // Multihop attempted
+    NOLINK = 95, // Link has been severed
+    PROTO = 96, // Protocol error
+
+    _,
+};
+
+pub const MINSIGSTKSZ = 8192;
+pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
+
+pub const SS_ONSTACK = 1;
+pub const SS_DISABLE = 4;
+
+pub const stack_t = extern struct {
+    ss_sp: [*]u8,
+    ss_size: isize,
+    ss_flags: i32,
+};
+
+pub const S_IFMT = 0o170000;
+
+pub const S_IFIFO = 0o010000;
+pub const S_IFCHR = 0o020000;
+pub const S_IFDIR = 0o040000;
+pub const S_IFBLK = 0o060000;
+pub const S_IFREG = 0o100000;
+pub const S_IFLNK = 0o120000;
+pub const S_IFSOCK = 0o140000;
+pub const S_IFWHT = 0o160000;
+
+pub const S_ISUID = 0o4000;
+pub const S_ISGID = 0o2000;
+pub const S_ISVTX = 0o1000;
+pub const S_IRWXU = 0o700;
+pub const S_IRUSR = 0o400;
+pub const S_IWUSR = 0o200;
+pub const S_IXUSR = 0o100;
+pub const S_IRWXG = 0o070;
+pub const S_IRGRP = 0o040;
+pub const S_IWGRP = 0o020;
+pub const S_IXGRP = 0o010;
+pub const S_IRWXO = 0o007;
+pub const S_IROTH = 0o004;
+pub const S_IWOTH = 0o002;
+pub const S_IXOTH = 0o001;
+
+pub fn S_ISFIFO(m: u32) bool {
+    return m & S_IFMT == S_IFIFO;
+}
+
+pub fn S_ISCHR(m: u32) bool {
+    return m & S_IFMT == S_IFCHR;
+}
+
+pub fn S_ISDIR(m: u32) bool {
+    return m & S_IFMT == S_IFDIR;
+}
+
+pub fn S_ISBLK(m: u32) bool {
+    return m & S_IFMT == S_IFBLK;
+}
+
+pub fn S_ISREG(m: u32) bool {
+    return m & S_IFMT == S_IFREG;
+}
+
+pub fn S_ISLNK(m: u32) bool {
+    return m & S_IFMT == S_IFLNK;
+}
+
+pub fn S_ISSOCK(m: u32) bool {
+    return m & S_IFMT == S_IFSOCK;
+}
+
+pub fn S_IWHT(m: u32) bool {
+    return m & S_IFMT == S_IFWHT;
+}
+
+/// Magic value that specify the use of the current working directory
+/// to determine the target of relative file paths in the openat() and
+/// similar syscalls.
+pub const AT_FDCWD = -100;
+
+/// Check access using effective user and group ID
+pub const AT_EACCESS = 0x0100;
+
+/// Do not follow symbolic links
+pub const AT_SYMLINK_NOFOLLOW = 0x0200;
+
+/// Follow symbolic link
+pub const AT_SYMLINK_FOLLOW = 0x0400;
+
+/// Remove directory instead of file
+pub const AT_REMOVEDIR = 0x0800;
+
+pub const HOST_NAME_MAX = 255;
+
+/// dummy for IP
+pub const IPPROTO_IP = 0;
+
+/// IP6 hop-by-hop options
+pub const IPPROTO_HOPOPTS = 0;
+
+/// control message protocol
+pub const IPPROTO_ICMP = 1;
+
+/// group mgmt protocol
+pub const IPPROTO_IGMP = 2;
+
+/// gateway^2 (deprecated)
+pub const IPPROTO_GGP = 3;
+
+/// IP header
+pub const IPPROTO_IPV4 = 4;
+
+/// IP inside IP
+pub const IPPROTO_IPIP = 4;
+
+/// tcp
+pub const IPPROTO_TCP = 6;
+
+/// exterior gateway protocol
+pub const IPPROTO_EGP = 8;
+
+/// pup
+pub const IPPROTO_PUP = 12;
+
+/// user datagram protocol
+pub const IPPROTO_UDP = 17;
+
+/// xns idp
+pub const IPPROTO_IDP = 22;
+
+/// tp-4 w/ class negotiation
+pub const IPPROTO_TP = 29;
+
+/// DCCP
+pub const IPPROTO_DCCP = 33;
+
+/// IP6 header
+pub const IPPROTO_IPV6 = 41;
+
+/// IP6 routing header
+pub const IPPROTO_ROUTING = 43;
+
+/// IP6 fragmentation header
+pub const IPPROTO_FRAGMENT = 44;
+
+/// resource reservation
+pub const IPPROTO_RSVP = 46;
+
+/// GRE encaps RFC 1701
+pub const IPPROTO_GRE = 47;
+
+/// encap. security payload
+pub const IPPROTO_ESP = 50;
+
+/// authentication header
+pub const IPPROTO_AH = 51;
+
+/// IP Mobility RFC 2004
+pub const IPPROTO_MOBILE = 55;
+
+/// IPv6 ICMP
+pub const IPPROTO_IPV6_ICMP = 58;
+
+/// ICMP6
+pub const IPPROTO_ICMPV6 = 58;
+
+/// IP6 no next header
+pub const IPPROTO_NONE = 59;
+
+/// IP6 destination option
+pub const IPPROTO_DSTOPTS = 60;
+
+/// ISO cnlp
+pub const IPPROTO_EON = 80;
+
+/// Ethernet-in-IP
+pub const IPPROTO_ETHERIP = 97;
+
+/// encapsulation header
+pub const IPPROTO_ENCAP = 98;
+
+/// Protocol indep. multicast
+pub const IPPROTO_PIM = 103;
+
+/// IP Payload Comp. Protocol
+pub const IPPROTO_IPCOMP = 108;
+
+/// VRRP RFC 2338
+pub const IPPROTO_VRRP = 112;
+
+/// Common Address Resolution Protocol
+pub const IPPROTO_CARP = 112;
+
+/// L2TPv3
+pub const IPPROTO_L2TP = 115;
+
+/// SCTP
+pub const IPPROTO_SCTP = 132;
+
+/// PFSYNC
+pub const IPPROTO_PFSYNC = 240;
+
+/// raw IP packet
+pub const IPPROTO_RAW = 255;
+
+pub const rlimit_resource = enum(c_int) {
+    CPU = 0,
+    FSIZE = 1,
+    DATA = 2,
+    STACK = 3,
+    CORE = 4,
+    RSS = 5,
+    MEMLOCK = 6,
+    NPROC = 7,
+    NOFILE = 8,
+    SBSIZE = 9,
+    VMEM = 10,
+    NTHR = 11,
+    _,
+
+    pub const AS: rlimit_resource = .VMEM;
+};
+
+pub const rlim_t = u64;
+
+/// No limit
+pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
+
+pub const RLIM_SAVED_MAX = RLIM_INFINITY;
+pub const RLIM_SAVED_CUR = RLIM_INFINITY;
+
+pub const rlimit = extern struct {
+    /// Soft limit
+    cur: rlim_t,
+    /// Hard limit
+    max: rlim_t,
+};
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 2;
+
+pub const nfds_t = u32;
+
+pub const pollfd = extern struct {
+    fd: fd_t,
+    events: i16,
+    revents: i16,
+};
+
+/// Testable events (may be specified in events field).
+pub const POLLIN = 0x0001;
+pub const POLLPRI = 0x0002;
+pub const POLLOUT = 0x0004;
+pub const POLLRDNORM = 0x0040;
+pub const POLLWRNORM = POLLOUT;
+pub const POLLRDBAND = 0x0080;
+pub const POLLWRBAND = 0x0100;
+
+/// Non-testable events (may not be specified in events field).
+pub const POLLERR = 0x0008;
+pub const POLLHUP = 0x0010;
+pub const POLLNVAL = 0x0020;
lib/std/c/openbsd.zig
@@ -1,7 +1,6 @@
 const std = @import("../std.zig");
-const builtin = std.builtin;
-
-usingnamespace std.c;
+const maxInt = std.math.maxInt;
+const builtin = @import("builtin");
 
 extern "c" fn __errno() *c_int;
 pub const _errno = __errno;
@@ -43,3 +42,1328 @@ pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_in
 
 pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void;
 pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void;
+
+pub const blkcnt_t = i64;
+pub const blksize_t = i32;
+pub const clock_t = i64;
+pub const dev_t = i32;
+pub const fd_t = c_int;
+pub const gid_t = u32;
+pub const ino_t = u64;
+pub const mode_t = u32;
+pub const nlink_t = u32;
+pub const off_t = i64;
+pub const pid_t = i32;
+pub const socklen_t = u32;
+pub const time_t = i64;
+pub const uid_t = u32;
+
+/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
+pub const Kevent = extern struct {
+    ident: usize,
+    filter: c_short,
+    flags: u16,
+    fflags: c_uint,
+    data: i64,
+    udata: usize,
+};
+
+// Modes and flags for dlopen()
+// include/dlfcn.h
+
+/// Bind function calls lazily.
+pub const RTLD_LAZY = 1;
+
+/// Bind function calls immediately.
+pub const RTLD_NOW = 2;
+
+/// Make symbols globally available.
+pub const RTLD_GLOBAL = 0x100;
+
+/// Opposite of RTLD_GLOBAL, and the default.
+pub const RTLD_LOCAL = 0x000;
+
+/// Trace loaded objects and exit.
+pub const RTLD_TRACE = 0x200;
+
+pub const dl_phdr_info = extern struct {
+    dlpi_addr: std.elf.Addr,
+    dlpi_name: ?[*:0]const u8,
+    dlpi_phdr: [*]std.elf.Phdr,
+    dlpi_phnum: std.elf.Half,
+};
+
+pub const Flock = extern struct {
+    l_start: off_t,
+    l_len: off_t,
+    l_pid: pid_t,
+    l_type: c_short,
+    l_whence: c_short,
+};
+
+pub const addrinfo = extern struct {
+    flags: c_int,
+    family: c_int,
+    socktype: c_int,
+    protocol: c_int,
+    addrlen: socklen_t,
+    addr: ?*sockaddr,
+    canonname: ?[*:0]u8,
+    next: ?*addrinfo,
+};
+
+pub const EAI = enum(c_int) {
+    /// address family for hostname not supported
+    ADDRFAMILY = -9,
+
+    /// name could not be resolved at this time
+    AGAIN = -3,
+
+    /// flags parameter had an invalid value
+    BADFLAGS = -1,
+
+    /// non-recoverable failure in name resolution
+    FAIL = -4,
+
+    /// address family not recognized
+    FAMILY = -6,
+
+    /// memory allocation failure
+    MEMORY = -10,
+
+    /// no address associated with hostname
+    NODATA = -5,
+
+    /// name does not resolve
+    NONAME = -2,
+
+    /// service not recognized for socket type
+    SERVICE = -8,
+
+    /// intended socket type was not recognized
+    SOCKTYPE = -7,
+
+    /// system error returned in errno
+    SYSTEM = -11,
+
+    /// invalid value for hints
+    BADHINTS = -12,
+
+    /// resolved protocol is unknown
+    PROTOCOL = -13,
+
+    /// argument buffer overflow
+    OVERFLOW = -14,
+
+    _,
+};
+
+pub const EAI_MAX = 15;
+
+pub const msghdr = extern struct {
+    /// optional address
+    msg_name: ?*sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec,
+
+    /// # elements in msg_iov
+    msg_iovlen: c_uint,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: c_int,
+};
+
+pub const msghdr_const = extern struct {
+    /// optional address
+    msg_name: ?*const sockaddr,
+
+    /// size of address
+    msg_namelen: socklen_t,
+
+    /// scatter/gather array
+    msg_iov: [*]iovec_const,
+
+    /// # elements in msg_iov
+    msg_iovlen: c_uint,
+
+    /// ancillary data
+    msg_control: ?*c_void,
+
+    /// ancillary data buffer len
+    msg_controllen: socklen_t,
+
+    /// flags on received message
+    msg_flags: c_int,
+};
+
+pub const Stat = extern struct {
+    mode: mode_t,
+    dev: dev_t,
+    ino: ino_t,
+    nlink: nlink_t,
+    uid: uid_t,
+    gid: gid_t,
+    rdev: dev_t,
+    atim: timespec,
+    mtim: timespec,
+    ctim: timespec,
+    size: off_t,
+    blocks: blkcnt_t,
+    blksize: blksize_t,
+    flags: u32,
+    gen: u32,
+    birthtim: timespec,
+
+    pub fn atime(self: @This()) timespec {
+        return self.atim;
+    }
+
+    pub fn mtime(self: @This()) timespec {
+        return self.mtim;
+    }
+
+    pub fn ctime(self: @This()) timespec {
+        return self.ctim;
+    }
+};
+
+pub const timespec = extern struct {
+    tv_sec: time_t,
+    tv_nsec: c_long,
+};
+
+pub const timeval = extern struct {
+    tv_sec: time_t,
+    tv_usec: c_long,
+};
+
+pub const timezone = extern struct {
+    tz_minuteswest: c_int,
+    tz_dsttime: c_int,
+};
+
+pub const MAXNAMLEN = 255;
+
+pub const dirent = extern struct {
+    d_fileno: ino_t,
+    d_off: off_t,
+    d_reclen: u16,
+    d_type: u8,
+    d_namlen: u8,
+    __d_padding: [4]u8,
+    d_name: [MAXNAMLEN + 1]u8,
+
+    pub fn reclen(self: dirent) u16 {
+        return self.d_reclen;
+    }
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern struct {
+    /// total length
+    len: u8,
+
+    /// address family
+    family: sa_family_t,
+
+    /// actually longer; address value
+    data: [14]u8,
+};
+
+pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
+
+pub const sockaddr_in = extern struct {
+    len: u8 = @sizeOf(sockaddr_in),
+    family: sa_family_t = AF_INET,
+    port: in_port_t,
+    addr: u32,
+    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+};
+
+pub const sockaddr_in6 = extern struct {
+    len: u8 = @sizeOf(sockaddr_in6),
+    family: sa_family_t = AF_INET6,
+    port: in_port_t,
+    flowinfo: u32,
+    addr: [16]u8,
+    scope_id: u32,
+};
+
+/// Definitions for UNIX IPC domain.
+pub const sockaddr_un = extern struct {
+    /// total sockaddr length
+    len: u8 = @sizeOf(sockaddr_un),
+
+    /// AF_LOCAL
+    family: sa_family_t = AF_LOCAL,
+
+    /// path name
+    path: [104]u8,
+};
+
+/// get address to use bind()
+pub const AI_PASSIVE = 1;
+
+/// fill ai_canonname
+pub const AI_CANONNAME = 2;
+
+/// prevent host name resolution
+pub const AI_NUMERICHOST = 4;
+
+/// prevent service name resolution
+pub const AI_NUMERICSERV = 16;
+
+/// only if any address is assigned
+pub const AI_ADDRCONFIG = 64;
+
+pub const PATH_MAX = 1024;
+pub const IOV_MAX = 1024;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const PROT_NONE = 0;
+pub const PROT_READ = 1;
+pub const PROT_WRITE = 2;
+pub const PROT_EXEC = 4;
+
+pub const CLOCK_REALTIME = 0;
+pub const CLOCK_PROCESS_CPUTIME_ID = 2;
+pub const CLOCK_MONOTONIC = 3;
+pub const CLOCK_THREAD_CPUTIME_ID = 4;
+
+pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
+pub const MAP_SHARED = 0x0001;
+pub const MAP_PRIVATE = 0x0002;
+pub const MAP_FIXED = 0x0010;
+pub const MAP_RENAME = 0;
+pub const MAP_NORESERVE = 0;
+pub const MAP_INHERIT = 0;
+pub const MAP_HASSEMAPHORE = 0;
+pub const MAP_TRYFIXED = 0;
+
+pub const MAP_FILE = 0;
+pub const MAP_ANON = 0x1000;
+pub const MAP_ANONYMOUS = MAP_ANON;
+pub const MAP_STACK = 0x4000;
+pub const MAP_CONCEAL = 0x8000;
+
+pub const WNOHANG = 1;
+pub const WUNTRACED = 2;
+pub const WCONTINUED = 8;
+
+pub const SA_ONSTACK = 0x0001;
+pub const SA_RESTART = 0x0002;
+pub const SA_RESETHAND = 0x0004;
+pub const SA_NOCLDSTOP = 0x0008;
+pub const SA_NODEFER = 0x0010;
+pub const SA_NOCLDWAIT = 0x0020;
+pub const SA_SIGINFO = 0x0040;
+
+pub const SIGHUP = 1;
+pub const SIGINT = 2;
+pub const SIGQUIT = 3;
+pub const SIGILL = 4;
+pub const SIGTRAP = 5;
+pub const SIGABRT = 6;
+pub const SIGIOT = SIGABRT;
+pub const SIGEMT = 7;
+pub const SIGFPE = 8;
+pub const SIGKILL = 9;
+pub const SIGBUS = 10;
+pub const SIGSEGV = 11;
+pub const SIGSYS = 12;
+pub const SIGPIPE = 13;
+pub const SIGALRM = 14;
+pub const SIGTERM = 15;
+pub const SIGURG = 16;
+pub const SIGSTOP = 17;
+pub const SIGTSTP = 18;
+pub const SIGCONT = 19;
+pub const SIGCHLD = 20;
+pub const SIGTTIN = 21;
+pub const SIGTTOU = 22;
+pub const SIGIO = 23;
+pub const SIGXCPU = 24;
+pub const SIGXFSZ = 25;
+pub const SIGVTALRM = 26;
+pub const SIGPROF = 27;
+pub const SIGWINCH = 28;
+pub const SIGINFO = 29;
+pub const SIGUSR1 = 30;
+pub const SIGUSR2 = 31;
+pub const SIGPWR = 32;
+
+// access function
+pub const F_OK = 0; // test for existence of file
+pub const X_OK = 1; // test for execute or search permission
+pub const W_OK = 2; // test for write permission
+pub const R_OK = 4; // test for read permission
+
+/// open for reading only
+pub const O_RDONLY = 0x00000000;
+
+/// open for writing only
+pub const O_WRONLY = 0x00000001;
+
+/// open for reading and writing
+pub const O_RDWR = 0x00000002;
+
+/// mask for above modes
+pub const O_ACCMODE = 0x00000003;
+
+/// no delay
+pub const O_NONBLOCK = 0x00000004;
+
+/// set append mode
+pub const O_APPEND = 0x00000008;
+
+/// open with shared file lock
+pub const O_SHLOCK = 0x00000010;
+
+/// open with exclusive file lock
+pub const O_EXLOCK = 0x00000020;
+
+/// signal pgrp when data ready
+pub const O_ASYNC = 0x00000040;
+
+/// synchronous writes
+pub const O_SYNC = 0x00000080;
+
+/// don't follow symlinks on the last
+pub const O_NOFOLLOW = 0x00000100;
+
+/// create if nonexistent
+pub const O_CREAT = 0x00000200;
+
+/// truncate to zero length
+pub const O_TRUNC = 0x00000400;
+
+/// error if already exists
+pub const O_EXCL = 0x00000800;
+
+/// don't assign controlling terminal
+pub const O_NOCTTY = 0x00008000;
+
+/// write: I/O data completion
+pub const O_DSYNC = O_SYNC;
+
+/// read: I/O completion as for write
+pub const O_RSYNC = O_SYNC;
+
+/// fail if not a directory
+pub const O_DIRECTORY = 0x20000;
+
+/// set close on exec
+pub const O_CLOEXEC = 0x10000;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_SETFD = 2;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+
+pub const F_GETOWN = 5;
+pub const F_SETOWN = 6;
+
+pub const F_GETLK = 7;
+pub const F_SETLK = 8;
+pub const F_SETLKW = 9;
+
+pub const F_RDLCK = 1;
+pub const F_UNLCK = 2;
+pub const F_WRLCK = 3;
+
+pub const LOCK_SH = 0x01;
+pub const LOCK_EX = 0x02;
+pub const LOCK_NB = 0x04;
+pub const LOCK_UN = 0x08;
+
+pub const FD_CLOEXEC = 1;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+
+pub const SIG_BLOCK = 1;
+pub const SIG_UNBLOCK = 2;
+pub const SIG_SETMASK = 3;
+
+pub const SOCK_STREAM = 1;
+pub const SOCK_DGRAM = 2;
+pub const SOCK_RAW = 3;
+pub const SOCK_RDM = 4;
+pub const SOCK_SEQPACKET = 5;
+
+pub const SOCK_CLOEXEC = 0x8000;
+pub const SOCK_NONBLOCK = 0x4000;
+
+pub const SO_DEBUG = 0x0001;
+pub const SO_ACCEPTCONN = 0x0002;
+pub const SO_REUSEADDR = 0x0004;
+pub const SO_KEEPALIVE = 0x0008;
+pub const SO_DONTROUTE = 0x0010;
+pub const SO_BROADCAST = 0x0020;
+pub const SO_USELOOPBACK = 0x0040;
+pub const SO_LINGER = 0x0080;
+pub const SO_OOBINLINE = 0x0100;
+pub const SO_REUSEPORT = 0x0200;
+pub const SO_TIMESTAMP = 0x0800;
+pub const SO_BINDANY = 0x1000;
+pub const SO_ZEROIZE = 0x2000;
+pub const SO_SNDBUF = 0x1001;
+pub const SO_RCVBUF = 0x1002;
+pub const SO_SNDLOWAT = 0x1003;
+pub const SO_RCVLOWAT = 0x1004;
+pub const SO_SNDTIMEO = 0x1005;
+pub const SO_RCVTIMEO = 0x1006;
+pub const SO_ERROR = 0x1007;
+pub const SO_TYPE = 0x1008;
+pub const SO_NETPROC = 0x1020;
+pub const SO_RTABLE = 0x1021;
+pub const SO_PEERCRED = 0x1022;
+pub const SO_SPLICE = 0x1023;
+pub const SO_DOMAIN = 0x1024;
+pub const SO_PROTOCOL = 0x1025;
+
+pub const SOL_SOCKET = 0xffff;
+
+pub const PF_UNSPEC = AF_UNSPEC;
+pub const PF_LOCAL = AF_LOCAL;
+pub const PF_UNIX = AF_UNIX;
+pub const PF_INET = AF_INET;
+pub const PF_APPLETALK = AF_APPLETALK;
+pub const PF_INET6 = AF_INET6;
+pub const PF_DECnet = AF_DECnet;
+pub const PF_KEY = AF_KEY;
+pub const PF_ROUTE = AF_ROUTE;
+pub const PF_SNA = AF_SNA;
+pub const PF_MPLS = AF_MPLS;
+pub const PF_BLUETOOTH = AF_BLUETOOTH;
+pub const PF_ISDN = AF_ISDN;
+pub const PF_MAX = AF_MAX;
+
+pub const AF_UNSPEC = 0;
+pub const AF_UNIX = 1;
+pub const AF_LOCAL = AF_UNIX;
+pub const AF_INET = 2;
+pub const AF_APPLETALK = 16;
+pub const AF_INET6 = 24;
+pub const AF_KEY = 30;
+pub const AF_ROUTE = 17;
+pub const AF_SNA = 11;
+pub const AF_MPLS = 33;
+pub const AF_BLUETOOTH = 32;
+pub const AF_ISDN = 26;
+pub const AF_MAX = 36;
+
+pub const DT_UNKNOWN = 0;
+pub const DT_FIFO = 1;
+pub const DT_CHR = 2;
+pub const DT_DIR = 4;
+pub const DT_BLK = 6;
+pub const DT_REG = 8;
+pub const DT_LNK = 10;
+pub const DT_SOCK = 12;
+pub const DT_WHT = 14; // XXX
+
+pub const EV_ADD = 0x0001;
+pub const EV_DELETE = 0x0002;
+pub const EV_ENABLE = 0x0004;
+pub const EV_DISABLE = 0x0008;
+pub const EV_ONESHOT = 0x0010;
+pub const EV_CLEAR = 0x0020;
+pub const EV_RECEIPT = 0x0040;
+pub const EV_DISPATCH = 0x0080;
+pub const EV_FLAG1 = 0x2000;
+pub const EV_ERROR = 0x4000;
+pub const EV_EOF = 0x8000;
+
+pub const EVFILT_READ = -1;
+pub const EVFILT_WRITE = -2;
+pub const EVFILT_AIO = -3;
+pub const EVFILT_VNODE = -4;
+pub const EVFILT_PROC = -5;
+pub const EVFILT_SIGNAL = -6;
+pub const EVFILT_TIMER = -7;
+pub const EVFILT_EXCEPT = -9;
+
+// data/hint flags for EVFILT_{READ|WRITE}
+pub const NOTE_LOWAT = 0x0001;
+pub const NOTE_EOF = 0x0002;
+
+// data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE}
+pub const NOTE_OOB = 0x0004;
+
+// data/hint flags for EVFILT_VNODE
+pub const NOTE_DELETE = 0x0001;
+pub const NOTE_WRITE = 0x0002;
+pub const NOTE_EXTEND = 0x0004;
+pub const NOTE_ATTRIB = 0x0008;
+pub const NOTE_LINK = 0x0010;
+pub const NOTE_RENAME = 0x0020;
+pub const NOTE_REVOKE = 0x0040;
+pub const NOTE_TRUNCATE = 0x0080;
+
+// data/hint flags for EVFILT_PROC
+pub const NOTE_EXIT = 0x80000000;
+pub const NOTE_FORK = 0x40000000;
+pub const NOTE_EXEC = 0x20000000;
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = 0xf0000000;
+pub const NOTE_TRACK = 0x00000001;
+pub const NOTE_TRACKERR = 0x00000002;
+pub const NOTE_CHILD = 0x00000004;
+
+// data/hint flags for EVFILT_DEVICE
+pub const NOTE_CHANGE = 0x00000001;
+
+pub const TIOCCBRK = 0x2000747a;
+pub const TIOCCDTR = 0x20007478;
+pub const TIOCCONS = 0x80047462;
+pub const TIOCDCDTIMESTAMP = 0x40107458;
+pub const TIOCDRAIN = 0x2000745e;
+pub const TIOCEXCL = 0x2000740d;
+pub const TIOCEXT = 0x80047460;
+pub const TIOCFLAG_CDTRCTS = 0x10;
+pub const TIOCFLAG_CLOCAL = 0x2;
+pub const TIOCFLAG_CRTSCTS = 0x4;
+pub const TIOCFLAG_MDMBUF = 0x8;
+pub const TIOCFLAG_SOFTCAR = 0x1;
+pub const TIOCFLUSH = 0x80047410;
+pub const TIOCGETA = 0x402c7413;
+pub const TIOCGETD = 0x4004741a;
+pub const TIOCGFLAGS = 0x4004745d;
+pub const TIOCGLINED = 0x40207442;
+pub const TIOCGPGRP = 0x40047477;
+pub const TIOCGQSIZE = 0x40047481;
+pub const TIOCGRANTPT = 0x20007447;
+pub const TIOCGSID = 0x40047463;
+pub const TIOCGSIZE = 0x40087468;
+pub const TIOCGWINSZ = 0x40087468;
+pub const TIOCMBIC = 0x8004746b;
+pub const TIOCMBIS = 0x8004746c;
+pub const TIOCMGET = 0x4004746a;
+pub const TIOCMSET = 0x8004746d;
+pub const TIOCM_CAR = 0x40;
+pub const TIOCM_CD = 0x40;
+pub const TIOCM_CTS = 0x20;
+pub const TIOCM_DSR = 0x100;
+pub const TIOCM_DTR = 0x2;
+pub const TIOCM_LE = 0x1;
+pub const TIOCM_RI = 0x80;
+pub const TIOCM_RNG = 0x80;
+pub const TIOCM_RTS = 0x4;
+pub const TIOCM_SR = 0x10;
+pub const TIOCM_ST = 0x8;
+pub const TIOCNOTTY = 0x20007471;
+pub const TIOCNXCL = 0x2000740e;
+pub const TIOCOUTQ = 0x40047473;
+pub const TIOCPKT = 0x80047470;
+pub const TIOCPKT_DATA = 0x0;
+pub const TIOCPKT_DOSTOP = 0x20;
+pub const TIOCPKT_FLUSHREAD = 0x1;
+pub const TIOCPKT_FLUSHWRITE = 0x2;
+pub const TIOCPKT_IOCTL = 0x40;
+pub const TIOCPKT_NOSTOP = 0x10;
+pub const TIOCPKT_START = 0x8;
+pub const TIOCPKT_STOP = 0x4;
+pub const TIOCPTMGET = 0x40287446;
+pub const TIOCPTSNAME = 0x40287448;
+pub const TIOCRCVFRAME = 0x80087445;
+pub const TIOCREMOTE = 0x80047469;
+pub const TIOCSBRK = 0x2000747b;
+pub const TIOCSCTTY = 0x20007461;
+pub const TIOCSDTR = 0x20007479;
+pub const TIOCSETA = 0x802c7414;
+pub const TIOCSETAF = 0x802c7416;
+pub const TIOCSETAW = 0x802c7415;
+pub const TIOCSETD = 0x8004741b;
+pub const TIOCSFLAGS = 0x8004745c;
+pub const TIOCSIG = 0x2000745f;
+pub const TIOCSLINED = 0x80207443;
+pub const TIOCSPGRP = 0x80047476;
+pub const TIOCSQSIZE = 0x80047480;
+pub const TIOCSSIZE = 0x80087467;
+pub const TIOCSTART = 0x2000746e;
+pub const TIOCSTAT = 0x80047465;
+pub const TIOCSTI = 0x80017472;
+pub const TIOCSTOP = 0x2000746f;
+pub const TIOCSWINSZ = 0x80087467;
+pub const TIOCUCNTL = 0x80047466;
+pub const TIOCXMTFRAME = 0x80087444;
+
+pub fn WEXITSTATUS(s: u32) u8 {
+    return @intCast(u8, (s >> 8) & 0xff);
+}
+pub fn WTERMSIG(s: u32) u32 {
+    return (s & 0x7f);
+}
+pub fn WSTOPSIG(s: u32) u32 {
+    return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: u32) bool {
+    return WTERMSIG(s) == 0;
+}
+
+pub fn WIFCONTINUED(s: u32) bool {
+    return ((s & 0o177777) == 0o177777);
+}
+
+pub fn WIFSTOPPED(s: u32) bool {
+    return (s & 0xff == 0o177);
+}
+
+pub fn WIFSIGNALED(s: u32) bool {
+    return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0);
+}
+
+pub const winsize = extern struct {
+    ws_row: c_ushort,
+    ws_col: c_ushort,
+    ws_xpixel: c_ushort,
+    ws_ypixel: c_ushort,
+};
+
+const NSIG = 33;
+
+pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
+pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = extern struct {
+    pub const handler_fn = fn (c_int) callconv(.C) void;
+    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
+
+    /// signal handler
+    handler: extern union {
+        handler: ?handler_fn,
+        sigaction: ?sigaction_fn,
+    },
+    /// signal mask to apply
+    mask: sigset_t,
+    /// signal options
+    flags: c_uint,
+};
+
+pub const sigval = extern union {
+    int: c_int,
+    ptr: ?*c_void,
+};
+
+pub const siginfo_t = extern struct {
+    signo: c_int,
+    code: c_int,
+    errno: c_int,
+    data: extern union {
+        proc: extern struct {
+            pid: pid_t,
+            pdata: extern union {
+                kill: extern struct {
+                    uid: uid_t,
+                    value: sigval,
+                },
+                cld: extern struct {
+                    utime: clock_t,
+                    stime: clock_t,
+                    status: c_int,
+                },
+            },
+        },
+        fault: extern struct {
+            addr: ?*c_void,
+            trapno: c_int,
+        },
+        __pad: [128 - 3 * @sizeOf(c_int)]u8,
+    },
+};
+
+comptime {
+    if (@sizeOf(usize) == 4)
+        std.debug.assert(@sizeOf(siginfo_t) == 128)
+    else
+        // Take into account the padding between errno and data fields.
+        std.debug.assert(@sizeOf(siginfo_t) == 136);
+}
+
+pub usingnamespace switch (builtin.cpu.arch) {
+    .x86_64 => struct {
+        pub const ucontext_t = extern struct {
+            sc_rdi: c_long,
+            sc_rsi: c_long,
+            sc_rdx: c_long,
+            sc_rcx: c_long,
+            sc_r8: c_long,
+            sc_r9: c_long,
+            sc_r10: c_long,
+            sc_r11: c_long,
+            sc_r12: c_long,
+            sc_r13: c_long,
+            sc_r14: c_long,
+            sc_r15: c_long,
+            sc_rbp: c_long,
+            sc_rbx: c_long,
+            sc_rax: c_long,
+            sc_gs: c_long,
+            sc_fs: c_long,
+            sc_es: c_long,
+            sc_ds: c_long,
+            sc_trapno: c_long,
+            sc_err: c_long,
+            sc_rip: c_long,
+            sc_cs: c_long,
+            sc_rflags: c_long,
+            sc_rsp: c_long,
+            sc_ss: c_long,
+
+            sc_fpstate: fxsave64,
+            __sc_unused: c_int,
+            sc_mask: c_int,
+            sc_cookie: c_long,
+        };
+
+        pub const fxsave64 = packed struct {
+            fx_fcw: u16,
+            fx_fsw: u16,
+            fx_ftw: u8,
+            fx_unused1: u8,
+            fx_fop: u16,
+            fx_rip: u64,
+            fx_rdp: u64,
+            fx_mxcsr: u32,
+            fx_mxcsr_mask: u32,
+            fx_st: [8][2]u64,
+            fx_xmm: [16][2]u64,
+            fx_unused3: [96]u8,
+        };
+    },
+    else => struct {},
+};
+
+pub const sigset_t = c_uint;
+pub const empty_sigset: sigset_t = 0;
+
+pub const E = enum(u16) {
+    /// No error occurred.
+    SUCCESS = 0,
+    PERM = 1, // Operation not permitted
+    NOENT = 2, // No such file or directory
+    SRCH = 3, // No such process
+    INTR = 4, // Interrupted system call
+    IO = 5, // Input/output error
+    NXIO = 6, // Device not configured
+    @"2BIG" = 7, // Argument list too long
+    NOEXEC = 8, // Exec format error
+    BADF = 9, // Bad file descriptor
+    CHILD = 10, // No child processes
+    DEADLK = 11, // Resource deadlock avoided
+    // 11 was AGAIN
+    NOMEM = 12, // Cannot allocate memory
+    ACCES = 13, // Permission denied
+    FAULT = 14, // Bad address
+    NOTBLK = 15, // Block device required
+    BUSY = 16, // Device busy
+    EXIST = 17, // File exists
+    XDEV = 18, // Cross-device link
+    NODEV = 19, // Operation not supported by device
+    NOTDIR = 20, // Not a directory
+    ISDIR = 21, // Is a directory
+    INVAL = 22, // Invalid argument
+    NFILE = 23, // Too many open files in system
+    MFILE = 24, // Too many open files
+    NOTTY = 25, // Inappropriate ioctl for device
+    TXTBSY = 26, // Text file busy
+    FBIG = 27, // File too large
+    NOSPC = 28, // No space left on device
+    SPIPE = 29, // Illegal seek
+    ROFS = 30, // Read-only file system
+    MLINK = 31, // Too many links
+    PIPE = 32, // Broken pipe
+
+    // math software
+    DOM = 33, // Numerical argument out of domain
+    RANGE = 34, // Result too large or too small
+
+    // non-blocking and interrupt i/o
+    // also: WOULDBLOCK: operation would block
+    AGAIN = 35, // Resource temporarily unavailable
+    INPROGRESS = 36, // Operation now in progress
+    ALREADY = 37, // Operation already in progress
+
+    // ipc/network software -- argument errors
+    NOTSOCK = 38, // Socket operation on non-socket
+    DESTADDRREQ = 39, // Destination address required
+    MSGSIZE = 40, // Message too long
+    PROTOTYPE = 41, // Protocol wrong type for socket
+    NOPROTOOPT = 42, // Protocol option not available
+    PROTONOSUPPORT = 43, // Protocol not supported
+    SOCKTNOSUPPORT = 44, // Socket type not supported
+    OPNOTSUPP = 45, // Operation not supported
+    PFNOSUPPORT = 46, // Protocol family not supported
+    AFNOSUPPORT = 47, // Address family not supported by protocol family
+    ADDRINUSE = 48, // Address already in use
+    ADDRNOTAVAIL = 49, // Can't assign requested address
+
+    // ipc/network software -- operational errors
+    NETDOWN = 50, // Network is down
+    NETUNREACH = 51, // Network is unreachable
+    NETRESET = 52, // Network dropped connection on reset
+    CONNABORTED = 53, // Software caused connection abort
+    CONNRESET = 54, // Connection reset by peer
+    NOBUFS = 55, // No buffer space available
+    ISCONN = 56, // Socket is already connected
+    NOTCONN = 57, // Socket is not connected
+    SHUTDOWN = 58, // Can't send after socket shutdown
+    TOOMANYREFS = 59, // Too many references: can't splice
+    TIMEDOUT = 60, // Operation timed out
+    CONNREFUSED = 61, // Connection refused
+
+    LOOP = 62, // Too many levels of symbolic links
+    NAMETOOLONG = 63, // File name too long
+
+    // should be rearranged
+    HOSTDOWN = 64, // Host is down
+    HOSTUNREACH = 65, // No route to host
+    NOTEMPTY = 66, // Directory not empty
+
+    // quotas & mush
+    PROCLIM = 67, // Too many processes
+    USERS = 68, // Too many users
+    DQUOT = 69, // Disc quota exceeded
+
+    // Network File System
+    STALE = 70, // Stale NFS file handle
+    REMOTE = 71, // Too many levels of remote in path
+    BADRPC = 72, // RPC struct is bad
+    RPCMISMATCH = 73, // RPC version wrong
+    PROGUNAVAIL = 74, // RPC prog. not avail
+    PROGMISMATCH = 75, // Program version wrong
+    PROCUNAVAIL = 76, // Bad procedure for program
+
+    NOLCK = 77, // No locks available
+    NOSYS = 78, // Function not implemented
+
+    FTYPE = 79, // Inappropriate file type or format
+    AUTH = 80, // Authentication error
+    NEEDAUTH = 81, // Need authenticator
+    IPSEC = 82, // IPsec processing failure
+    NOATTR = 83, // Attribute not found
+
+    // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
+    ILSEQ = 84, // Illegal byte sequence
+
+    NOMEDIUM = 85, // No medium found
+    MEDIUMTYPE = 86, // Wrong medium type
+    OVERFLOW = 87, // Value too large to be stored in data type
+    CANCELED = 88, // Operation canceled
+    IDRM = 89, // Identifier removed
+    NOMSG = 90, // No message of desired type
+    NOTSUP = 91, // Not supported
+    BADMSG = 92, // Bad or Corrupt message
+    NOTRECOVERABLE = 93, // State not recoverable
+    OWNERDEAD = 94, // Previous owner died
+    PROTO = 95, // Protocol error
+
+    _,
+};
+
+const _MAX_PAGE_SHIFT = switch (builtin.cpu.arch) {
+    .i386 => 12,
+    .sparcv9 => 13,
+};
+pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT;
+pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4;
+
+pub const SS_ONSTACK = 0x0001;
+pub const SS_DISABLE = 0x0004;
+
+pub const stack_t = extern struct {
+    ss_sp: [*]u8,
+    ss_size: usize,
+    ss_flags: c_int,
+};
+
+pub const S_IFMT = 0o170000;
+
+pub const S_IFIFO = 0o010000;
+pub const S_IFCHR = 0o020000;
+pub const S_IFDIR = 0o040000;
+pub const S_IFBLK = 0o060000;
+pub const S_IFREG = 0o100000;
+pub const S_IFLNK = 0o120000;
+pub const S_IFSOCK = 0o140000;
+
+pub const S_ISUID = 0o4000;
+pub const S_ISGID = 0o2000;
+pub const S_ISVTX = 0o1000;
+pub const S_IRWXU = 0o700;
+pub const S_IRUSR = 0o400;
+pub const S_IWUSR = 0o200;
+pub const S_IXUSR = 0o100;
+pub const S_IRWXG = 0o070;
+pub const S_IRGRP = 0o040;
+pub const S_IWGRP = 0o020;
+pub const S_IXGRP = 0o010;
+pub const S_IRWXO = 0o007;
+pub const S_IROTH = 0o004;
+pub const S_IWOTH = 0o002;
+pub const S_IXOTH = 0o001;
+
+pub fn S_ISFIFO(m: u32) bool {
+    return m & S_IFMT == S_IFIFO;
+}
+
+pub fn S_ISCHR(m: u32) bool {
+    return m & S_IFMT == S_IFCHR;
+}
+
+pub fn S_ISDIR(m: u32) bool {
+    return m & S_IFMT == S_IFDIR;
+}
+
+pub fn S_ISBLK(m: u32) bool {
+    return m & S_IFMT == S_IFBLK;
+}
+
+pub fn S_ISREG(m: u32) bool {
+    return m & S_IFMT == S_IFREG;
+}
+
+pub fn S_ISLNK(m: u32) bool {
+    return m & S_IFMT == S_IFLNK;
+}
+
+pub fn S_ISSOCK(m: u32) bool {
+    return m & S_IFMT == S_IFSOCK;
+}
+
+/// Magic value that specify the use of the current working directory
+/// to determine the target of relative file paths in the openat() and
+/// similar syscalls.
+pub const AT_FDCWD = -100;
+
+/// Check access using effective user and group ID
+pub const AT_EACCESS = 0x01;
+
+/// Do not follow symbolic links
+pub const AT_SYMLINK_NOFOLLOW = 0x02;
+
+/// Follow symbolic link
+pub const AT_SYMLINK_FOLLOW = 0x04;
+
+/// Remove directory instead of file
+pub const AT_REMOVEDIR = 0x08;
+
+pub const HOST_NAME_MAX = 255;
+
+/// dummy for IP
+pub const IPPROTO_IP = 0;
+
+/// IP6 hop-by-hop options
+pub const IPPROTO_HOPOPTS = IPPROTO_IP;
+
+/// control message protocol
+pub const IPPROTO_ICMP = 1;
+
+/// group mgmt protocol
+pub const IPPROTO_IGMP = 2;
+
+/// gateway^2 (deprecated)
+pub const IPPROTO_GGP = 3;
+
+/// IP header
+pub const IPPROTO_IPV4 = IPPROTO_IPIP;
+
+/// IP inside IP
+pub const IPPROTO_IPIP = 4;
+
+/// tcp
+pub const IPPROTO_TCP = 6;
+
+/// exterior gateway protocol
+pub const IPPROTO_EGP = 8;
+
+/// pup
+pub const IPPROTO_PUP = 12;
+
+/// user datagram protocol
+pub const IPPROTO_UDP = 17;
+
+/// xns idp
+pub const IPPROTO_IDP = 22;
+
+/// tp-4 w/ class negotiation
+pub const IPPROTO_TP = 29;
+
+/// IP6 header
+pub const IPPROTO_IPV6 = 41;
+
+/// IP6 routing header
+pub const IPPROTO_ROUTING = 43;
+
+/// IP6 fragmentation header
+pub const IPPROTO_FRAGMENT = 44;
+
+/// resource reservation
+pub const IPPROTO_RSVP = 46;
+
+/// GRE encaps RFC 1701
+pub const IPPROTO_GRE = 47;
+
+/// encap. security payload
+pub const IPPROTO_ESP = 50;
+
+/// authentication header
+pub const IPPROTO_AH = 51;
+
+/// IP Mobility RFC 2004
+pub const IPPROTO_MOBILE = 55;
+
+/// IPv6 ICMP
+pub const IPPROTO_IPV6_ICMP = 58;
+
+/// ICMP6
+pub const IPPROTO_ICMPV6 = 58;
+
+/// IP6 no next header
+pub const IPPROTO_NONE = 59;
+
+/// IP6 destination option
+pub const IPPROTO_DSTOPTS = 60;
+
+/// ISO cnlp
+pub const IPPROTO_EON = 80;
+
+/// Ethernet-in-IP
+pub const IPPROTO_ETHERIP = 97;
+
+/// encapsulation header
+pub const IPPROTO_ENCAP = 98;
+
+/// Protocol indep. multicast
+pub const IPPROTO_PIM = 103;
+
+/// IP Payload Comp. Protocol
+pub const IPPROTO_IPCOMP = 108;
+
+/// VRRP RFC 2338
+pub const IPPROTO_VRRP = 112;
+
+/// Common Address Resolution Protocol
+pub const IPPROTO_CARP = 112;
+
+/// PFSYNC
+pub const IPPROTO_PFSYNC = 240;
+
+/// raw IP packet
+pub const IPPROTO_RAW = 255;
+
+pub const rlimit_resource = enum(c_int) {
+    CPU,
+    FSIZE,
+    DATA,
+    STACK,
+    CORE,
+    RSS,
+    MEMLOCK,
+    NPROC,
+    NOFILE,
+
+    _,
+};
+
+pub const rlim_t = u64;
+
+/// No limit
+pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
+
+pub const RLIM_SAVED_MAX = RLIM_INFINITY;
+pub const RLIM_SAVED_CUR = RLIM_INFINITY;
+
+pub const rlimit = extern struct {
+    /// Soft limit
+    cur: rlim_t,
+    /// Hard limit
+    max: rlim_t,
+};
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 2;
+
+pub const nfds_t = c_uint;
+
+pub const pollfd = extern struct {
+    fd: fd_t,
+    events: c_short,
+    revents: c_short,
+};
+
+pub const POLLIN = 0x0001;
+pub const POLLPRI = 0x0002;
+pub const POLLOUT = 0x0004;
+pub const POLLERR = 0x0008;
+pub const POLLHUP = 0x0010;
+pub const POLLNVAL = 0x0020;
+pub const POLLRDNORM = 0x0040;
+pub const POLLNORM = POLLRDNORM;
+pub const POLLWRNORM = POLLOUT;
+pub const POLLRDBAND = 0x0080;
+pub const POLLWRBAND = 0x0100;
+
+// sysctl mib
+pub const CTL_UNSPEC = 0;
+pub const CTL_KERN = 1;
+pub const CTL_VM = 2;
+pub const CTL_FS = 3;
+pub const CTL_NET = 4;
+pub const CTL_DEBUG = 5;
+pub const CTL_HW = 6;
+pub const CTL_MACHDEP = 7;
+
+pub const CTL_DDB = 9;
+pub const CTL_VFS = 10;
+
+pub const KERN_OSTYPE = 1;
+pub const KERN_OSRELEASE = 2;
+pub const KERN_OSREV = 3;
+pub const KERN_VERSION = 4;
+pub const KERN_MAXVNODES = 5;
+pub const KERN_MAXPROC = 6;
+pub const KERN_MAXFILES = 7;
+pub const KERN_ARGMAX = 8;
+pub const KERN_SECURELVL = 9;
+pub const KERN_HOSTNAME = 10;
+pub const KERN_HOSTID = 11;
+pub const KERN_CLOCKRATE = 12;
+
+pub const KERN_PROF = 16;
+pub const KERN_POSIX1 = 17;
+pub const KERN_NGROUPS = 18;
+pub const KERN_JOB_CONTROL = 19;
+pub const KERN_SAVED_IDS = 20;
+pub const KERN_BOOTTIME = 21;
+pub const KERN_DOMAINNAME = 22;
+pub const KERN_MAXPARTITIONS = 23;
+pub const KERN_RAWPARTITION = 24;
+pub const KERN_MAXTHREAD = 25;
+pub const KERN_NTHREADS = 26;
+pub const KERN_OSVERSION = 27;
+pub const KERN_SOMAXCONN = 28;
+pub const KERN_SOMINCONN = 29;
+
+pub const KERN_NOSUIDCOREDUMP = 32;
+pub const KERN_FSYNC = 33;
+pub const KERN_SYSVMSG = 34;
+pub const KERN_SYSVSEM = 35;
+pub const KERN_SYSVSHM = 36;
+
+pub const KERN_MSGBUFSIZE = 38;
+pub const KERN_MALLOCSTATS = 39;
+pub const KERN_CPTIME = 40;
+pub const KERN_NCHSTATS = 41;
+pub const KERN_FORKSTAT = 42;
+pub const KERN_NSELCOLL = 43;
+pub const KERN_TTY = 44;
+pub const KERN_CCPU = 45;
+pub const KERN_FSCALE = 46;
+pub const KERN_NPROCS = 47;
+pub const KERN_MSGBUF = 48;
+pub const KERN_POOL = 49;
+pub const KERN_STACKGAPRANDOM = 50;
+pub const KERN_SYSVIPC_INFO = 51;
+pub const KERN_ALLOWKMEM = 52;
+pub const KERN_WITNESSWATCH = 53;
+pub const KERN_SPLASSERT = 54;
+pub const KERN_PROC_ARGS = 55;
+pub const KERN_NFILES = 56;
+pub const KERN_TTYCOUNT = 57;
+pub const KERN_NUMVNODES = 58;
+pub const KERN_MBSTAT = 59;
+pub const KERN_WITNESS = 60;
+pub const KERN_SEMINFO = 61;
+pub const KERN_SHMINFO = 62;
+pub const KERN_INTRCNT = 63;
+pub const KERN_WATCHDOG = 64;
+pub const KERN_ALLOWDT = 65;
+pub const KERN_PROC = 66;
+pub const KERN_MAXCLUSTERS = 67;
+pub const KERN_EVCOUNT = 68;
+pub const KERN_TIMECOUNTER = 69;
+pub const KERN_MAXLOCKSPERUID = 70;
+pub const KERN_CPTIME2 = 71;
+pub const KERN_CACHEPCT = 72;
+pub const KERN_FILE = 73;
+pub const KERN_WXABORT = 74;
+pub const KERN_CONSDEV = 75;
+pub const KERN_NETLIVELOCKS = 76;
+pub const KERN_POOL_DEBUG = 77;
+pub const KERN_PROC_CWD = 78;
+pub const KERN_PROC_NOBROADCASTKILL = 79;
+pub const KERN_PROC_VMMAP = 80;
+pub const KERN_GLOBAL_PTRACE = 81;
+pub const KERN_CONSBUFSIZE = 82;
+pub const KERN_CONSBUF = 83;
+pub const KERN_AUDIO = 84;
+pub const KERN_CPUSTATS = 85;
+pub const KERN_PFSTATUS = 86;
+pub const KERN_TIMEOUT_STATS = 87;
+pub const KERN_UTC_OFFSET = 88;
+pub const KERN_VIDEO = 89;
+
+pub const HW_MACHINE = 1;
+pub const HW_MODEL = 2;
+pub const HW_NCPU = 3;
+pub const HW_BYTEORDER = 4;
+pub const HW_PHYSMEM = 5;
+pub const HW_USERMEM = 6;
+pub const HW_PAGESIZE = 7;
+pub const HW_DISKNAMES = 8;
+pub const HW_DISKSTATS = 9;
+pub const HW_DISKCOUNT = 10;
+pub const HW_SENSORS = 11;
+pub const HW_CPUSPEED = 12;
+pub const HW_SETPERF = 13;
+pub const HW_VENDOR = 14;
+pub const HW_PRODUCT = 15;
+pub const HW_VERSION = 16;
+pub const HW_SERIALNO = 17;
+pub const HW_UUID = 18;
+pub const HW_PHYSMEM64 = 19;
+pub const HW_USERMEM64 = 20;
+pub const HW_NCPUFOUND = 21;
+pub const HW_ALLOWPOWERDOWN = 22;
+pub const HW_PERFPOLICY = 23;
+pub const HW_SMT = 24;
+pub const HW_NCPUONLINE = 25;
+
+pub const KERN_PROC_ALL = 0;
+pub const KERN_PROC_PID = 1;
+pub const KERN_PROC_PGRP = 2;
+pub const KERN_PROC_SESSION = 3;
+pub const KERN_PROC_TTY = 4;
+pub const KERN_PROC_UID = 5;
+pub const KERN_PROC_RUID = 6;
+pub const KERN_PROC_KTHREAD = 7;
+pub const KERN_PROC_SHOW_THREADS = 0x40000000;
+
+pub const KERN_PROC_ARGV = 1;
+pub const KERN_PROC_NARGV = 2;
+pub const KERN_PROC_ENV = 3;
+pub const KERN_PROC_NENV = 4;
lib/std/c/wasi.zig
@@ -4,12 +4,13 @@ pub fn _errno() *c_int {
     return &errno;
 }
 
+pub const fd_t = c_int;
 pub const pid_t = c_int;
 pub const uid_t = u32;
 pub const gid_t = u32;
 pub const off_t = i64;
 
-pub const libc_stat = extern struct {
+pub const Stat = extern struct {
     dev: i32,
     ino: ino_t,
     nlink: u64,
@@ -51,3 +52,27 @@ pub const libc_stat = extern struct {
         };
     }
 };
+
+/// Derived from
+/// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
+pub const O = struct {
+    pub const ACCMODE = (EXEC | RDWR | SEARCH);
+    pub const APPEND = FDFLAG_APPEND;
+    pub const CLOEXEC = (0);
+    pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
+    pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
+    pub const DSYNC = FDFLAG_DSYNC;
+    pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
+    pub const EXEC = (0x02000000);
+    pub const NOCTTY = (0);
+    pub const NOFOLLOW = (0x01000000);
+    pub const NONBLOCK = (1 << FDFLAG_NONBLOCK);
+    pub const RDONLY = (0x04000000);
+    pub const RDWR = (RDONLY | WRONLY);
+    pub const RSYNC = (1 << FDFLAG_RSYNC);
+    pub const SEARCH = (0x08000000);
+    pub const SYNC = (1 << FDFLAG_SYNC);
+    pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
+    pub const TTY_INIT = (0);
+    pub const WRONLY = (0x10000000);
+};
lib/std/c/windows.zig
@@ -1,3 +1,343 @@
+//! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
+
+const ws2_32 = @import("../os/windows/ws2_32.zig");
+
 pub extern "c" fn _errno() *c_int;
 
 pub extern "c" fn _msize(memblock: ?*c_void) usize;
+
+// TODO: copied the else case and removed the socket function (because its in ws2_32)
+//       need to verify which of these is actually supported on windows
+pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
+pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
+pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
+pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub extern "c" fn sched_yield() c_int;
+pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
+pub extern "c" fn sigfillset(set: ?*sigset_t) void;
+pub extern "c" fn alarm(seconds: c_uint) c_uint;
+pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
+
+pub const fd_t = HANDLE;
+pub const ino_t = LARGE_INTEGER;
+pub const pid_t = HANDLE;
+pub const mode_t = u0;
+
+pub const PATH_MAX = 260;
+
+pub const time_t = c_longlong;
+
+pub const timespec = extern struct {
+    tv_sec: time_t,
+    tv_nsec: c_long,
+};
+
+pub const timeval = extern struct {
+    tv_sec: c_long,
+    tv_usec: c_long,
+};
+
+pub const sig_atomic_t = c_int;
+
+/// maximum signal number + 1
+pub const NSIG = 23;
+
+// Signal types
+
+/// interrupt
+pub const SIGINT = 2;
+
+/// illegal instruction - invalid function image
+pub const SIGILL = 4;
+
+/// floating point exception
+pub const SIGFPE = 8;
+
+/// segment violation
+pub const SIGSEGV = 11;
+
+/// Software termination signal from kill
+pub const SIGTERM = 15;
+
+/// Ctrl-Break sequence
+pub const SIGBREAK = 21;
+
+/// abnormal termination triggered by abort call
+pub const SIGABRT = 22;
+
+/// SIGABRT compatible with other platforms, same as SIGABRT
+pub const SIGABRT_COMPAT = 6;
+
+// Signal action codes
+
+/// default signal action
+pub const SIG_DFL = 0;
+
+/// ignore signal
+pub const SIG_IGN = 1;
+
+/// return current value
+pub const SIG_GET = 2;
+
+/// signal gets error
+pub const SIG_SGE = 3;
+
+/// acknowledge
+pub const SIG_ACK = 4;
+
+/// Signal error value (returned by signal call on error)
+pub const SIG_ERR = -1;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+
+pub const E = enum(u16) {
+    /// No error occurred.
+    SUCCESS = 0,
+    PERM = 1,
+    NOENT = 2,
+    SRCH = 3,
+    INTR = 4,
+    IO = 5,
+    NXIO = 6,
+    @"2BIG" = 7,
+    NOEXEC = 8,
+    BADF = 9,
+    CHILD = 10,
+    AGAIN = 11,
+    NOMEM = 12,
+    ACCES = 13,
+    FAULT = 14,
+    BUSY = 16,
+    EXIST = 17,
+    XDEV = 18,
+    NODEV = 19,
+    NOTDIR = 20,
+    ISDIR = 21,
+    NFILE = 23,
+    MFILE = 24,
+    NOTTY = 25,
+    FBIG = 27,
+    NOSPC = 28,
+    SPIPE = 29,
+    ROFS = 30,
+    MLINK = 31,
+    PIPE = 32,
+    DOM = 33,
+    /// Also means `DEADLOCK`.
+    DEADLK = 36,
+    NAMETOOLONG = 38,
+    NOLCK = 39,
+    NOSYS = 40,
+    NOTEMPTY = 41,
+
+    INVAL = 22,
+    RANGE = 34,
+    ILSEQ = 42,
+
+    // POSIX Supplement
+    ADDRINUSE = 100,
+    ADDRNOTAVAIL = 101,
+    AFNOSUPPORT = 102,
+    ALREADY = 103,
+    BADMSG = 104,
+    CANCELED = 105,
+    CONNABORTED = 106,
+    CONNREFUSED = 107,
+    CONNRESET = 108,
+    DESTADDRREQ = 109,
+    HOSTUNREACH = 110,
+    IDRM = 111,
+    INPROGRESS = 112,
+    ISCONN = 113,
+    LOOP = 114,
+    MSGSIZE = 115,
+    NETDOWN = 116,
+    NETRESET = 117,
+    NETUNREACH = 118,
+    NOBUFS = 119,
+    NODATA = 120,
+    NOLINK = 121,
+    NOMSG = 122,
+    NOPROTOOPT = 123,
+    NOSR = 124,
+    NOSTR = 125,
+    NOTCONN = 126,
+    NOTRECOVERABLE = 127,
+    NOTSOCK = 128,
+    NOTSUP = 129,
+    OPNOTSUPP = 130,
+    OTHER = 131,
+    OVERFLOW = 132,
+    OWNERDEAD = 133,
+    PROTO = 134,
+    PROTONOSUPPORT = 135,
+    PROTOTYPE = 136,
+    TIME = 137,
+    TIMEDOUT = 138,
+    TXTBSY = 139,
+    WOULDBLOCK = 140,
+    DQUOT = 10069,
+    _,
+};
+
+pub const STRUNCATE = 80;
+
+pub const F_OK = 0;
+
+/// Remove directory instead of unlinking file
+pub const AT_REMOVEDIR = 0x200;
+
+pub const in_port_t = u16;
+pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
+pub const socklen_t = ws2_32.socklen_t;
+
+pub const sockaddr = ws2_32.sockaddr;
+pub const sockaddr_in = ws2_32.sockaddr_in;
+pub const sockaddr_in6 = ws2_32.sockaddr_in6;
+pub const sockaddr_un = ws2_32.sockaddr_un;
+
+pub const in6_addr = [16]u8;
+pub const in_addr = u32;
+
+pub const addrinfo = ws2_32.addrinfo;
+
+pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
+pub const AF_UNIX = ws2_32.AF_UNIX;
+pub const AF_INET = ws2_32.AF_INET;
+pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
+pub const AF_PUP = ws2_32.AF_PUP;
+pub const AF_CHAOS = ws2_32.AF_CHAOS;
+pub const AF_NS = ws2_32.AF_NS;
+pub const AF_IPX = ws2_32.AF_IPX;
+pub const AF_ISO = ws2_32.AF_ISO;
+pub const AF_OSI = ws2_32.AF_OSI;
+pub const AF_ECMA = ws2_32.AF_ECMA;
+pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
+pub const AF_CCITT = ws2_32.AF_CCITT;
+pub const AF_SNA = ws2_32.AF_SNA;
+pub const AF_DECnet = ws2_32.AF_DECnet;
+pub const AF_DLI = ws2_32.AF_DLI;
+pub const AF_LAT = ws2_32.AF_LAT;
+pub const AF_HYLINK = ws2_32.AF_HYLINK;
+pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
+pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
+pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
+pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
+pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
+pub const AF_BAN = ws2_32.AF_BAN;
+pub const AF_ATM = ws2_32.AF_ATM;
+pub const AF_INET6 = ws2_32.AF_INET6;
+pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
+pub const AF_12844 = ws2_32.AF_12844;
+pub const AF_IRDA = ws2_32.AF_IRDA;
+pub const AF_NETDES = ws2_32.AF_NETDES;
+pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
+pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
+pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
+pub const AF_BTH = ws2_32.AF_BTH;
+pub const AF_MAX = ws2_32.AF_MAX;
+
+pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
+pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
+pub const SOCK_RAW = ws2_32.SOCK_RAW;
+pub const SOCK_RDM = ws2_32.SOCK_RDM;
+pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
+
+/// WARNING: this flag is not supported by windows socket functions directly,
+///          it is only supported by std.os.socket. Be sure that this value does
+///          not share any bits with any of the SOCK_* values.
+pub const SOCK_CLOEXEC = 0x10000;
+/// WARNING: this flag is not supported by windows socket functions directly,
+///          it is only supported by std.os.socket. Be sure that this value does
+///          not share any bits with any of the SOCK_* values.
+pub const SOCK_NONBLOCK = 0x20000;
+
+pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
+pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
+pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
+pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
+pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
+pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
+pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
+
+pub const nfds_t = c_ulong;
+pub const pollfd = ws2_32.pollfd;
+
+pub const POLLRDNORM = ws2_32.POLLRDNORM;
+pub const POLLRDBAND = ws2_32.POLLRDBAND;
+pub const POLLIN = ws2_32.POLLIN;
+pub const POLLPRI = ws2_32.POLLPRI;
+pub const POLLWRNORM = ws2_32.POLLWRNORM;
+pub const POLLOUT = ws2_32.POLLOUT;
+pub const POLLWRBAND = ws2_32.POLLWRBAND;
+pub const POLLERR = ws2_32.POLLERR;
+pub const POLLHUP = ws2_32.POLLHUP;
+pub const POLLNVAL = ws2_32.POLLNVAL;
+
+pub const SOL_SOCKET = ws2_32.SOL_SOCKET;
+
+pub const SO_DEBUG = ws2_32.SO_DEBUG;
+pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN;
+pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR;
+pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE;
+pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE;
+pub const SO_BROADCAST = ws2_32.SO_BROADCAST;
+pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK;
+pub const SO_LINGER = ws2_32.SO_LINGER;
+pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE;
+
+pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER;
+pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE;
+
+pub const SO_SNDBUF = ws2_32.SO_SNDBUF;
+pub const SO_RCVBUF = ws2_32.SO_RCVBUF;
+pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT;
+pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT;
+pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO;
+pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO;
+pub const SO_ERROR = ws2_32.SO_ERROR;
+pub const SO_TYPE = ws2_32.SO_TYPE;
+
+pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID;
+pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY;
+pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE;
+pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA;
+pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW;
+
+pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
+pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT;
+
+pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
+
+pub const O_RDONLY = 0o0;
+pub const O_WRONLY = 0o1;
+pub const O_RDWR = 0o2;
+
+pub const O_CREAT = 0o100;
+pub const O_EXCL = 0o200;
+pub const O_NOCTTY = 0o400;
+pub const O_TRUNC = 0o1000;
+pub const O_APPEND = 0o2000;
+pub const O_NONBLOCK = 0o4000;
+pub const O_DSYNC = 0o10000;
+pub const O_SYNC = 0o4010000;
+pub const O_RSYNC = 0o4010000;
+pub const O_DIRECTORY = 0o200000;
+pub const O_NOFOLLOW = 0o400000;
+pub const O_CLOEXEC = 0o2000000;
+
+pub const O_ASYNC = 0o20000;
+pub const O_DIRECT = 0o40000;
+pub const O_LARGEFILE = 0;
+pub const O_NOATIME = 0o1000000;
+pub const O_PATH = 0o10000000;
+pub const O_TMPFILE = 0o20200000;
+pub const O_NDELAY = O_NONBLOCK;
+
+pub const IFNAMESIZE = 30;
lib/std/os/bits/linux/arm-eabi.zig
@@ -551,7 +551,7 @@ pub const dev_t = u64;
 pub const blkcnt_t = i64;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     __dev_padding: u32,
     __ino_truncated: u32,
@@ -582,9 +582,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const timespec = extern struct {
     tv_sec: i32,
     tv_nsec: i32,
lib/std/os/bits/linux/arm64.zig
@@ -424,7 +424,7 @@ pub const dev_t = usize;
 pub const blkcnt_t = isize;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     ino: ino_t,
     mode: mode_t,
@@ -455,9 +455,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const timespec = extern struct {
     tv_sec: time_t,
     tv_nsec: isize,
lib/std/os/bits/linux/i386.zig
@@ -599,7 +599,7 @@ pub const dev_t = u64;
 pub const blkcnt_t = i64;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     __dev_padding: u32,
     __ino_truncated: u32,
@@ -630,9 +630,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const timespec = extern struct {
     tv_sec: i32,
     tv_nsec: i32,
lib/std/os/bits/linux/mips.zig
@@ -540,7 +540,7 @@ pub const dev_t = u64;
 pub const blkcnt_t = i64;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: u32,
     __pad0: [3]u32, // Reserved for st_dev expansion
     ino: ino_t,
@@ -572,38 +572,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-pub const libc_stat = extern struct {
-    dev: dev_t,
-    __pad0: [2]u32,
-    ino: ino_t,
-    mode: mode_t,
-    nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
-    rdev: dev_t,
-    __pad1: [2]u32,
-    size: off_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    blksize: blksize_t,
-    __pad3: u32,
-    blocks: blkcnt_t,
-    __pad4: [14]u32,
-
-    pub fn atime(self: @This()) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: @This()) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: @This()) timespec {
-        return self.ctim;
-    }
-};
-
 pub const timespec = extern struct {
     tv_sec: isize,
     tv_nsec: isize,
lib/std/os/bits/linux/powerpc.zig
@@ -539,7 +539,7 @@ pub const dev_t = u64;
 pub const blkcnt_t = i64;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     ino: ino_t,
     mode: mode_t,
@@ -569,9 +569,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const timespec = extern struct {
     tv_sec: time_t,
     tv_nsec: isize,
lib/std/os/bits/linux/powerpc64.zig
@@ -515,7 +515,7 @@ pub const dev_t = u64;
 pub const blkcnt_t = i64;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     ino: ino_t,
     nlink: nlink_t,
@@ -544,9 +544,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const timespec = extern struct {
     tv_sec: time_t,
     tv_nsec: isize,
lib/std/os/bits/linux/riscv64.zig
@@ -386,7 +386,7 @@ pub const Flock = extern struct {
 };
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     ino: ino_t,
     mode: mode_t,
@@ -417,7 +417,4 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const Elf_Symndx = u32;
lib/std/os/bits/linux/sparc64.zig
@@ -489,42 +489,8 @@ pub const off_t = i64;
 pub const ino_t = u64;
 pub const mode_t = u32;
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = extern struct {
-    dev: u64,
-    ino: ino_t,
-    mode: u32,
-    nlink: usize,
-
-    uid: u32,
-    gid: u32,
-    rdev: u64,
-    __pad0: u32,
-
-    size: off_t,
-    blksize: isize,
-    blocks: i64,
-
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    __unused: [2]isize,
-
-    pub fn atime(self: libc_stat) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: libc_stat) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: libc_stat) timespec {
-        return self.ctim;
-    }
-};
-
 // The `stat64` definition used by the kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: u64,
     ino: u64,
     nlink: u64,
lib/std/os/bits/darwin.zig
@@ -1,1783 +0,0 @@
-const std = @import("../../std.zig");
-const assert = std.debug.assert;
-const maxInt = std.math.maxInt;
-
-// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
-// TODO: audit mode_t/pid_t, should likely be u16/i32
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const mode_t = c_uint;
-pub const uid_t = u32;
-pub const gid_t = u32;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-pub const socklen_t = u32;
-pub const sockaddr = extern struct {
-    len: u8,
-    family: sa_family_t,
-    data: [14]u8,
-};
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-pub const sockaddr_in = extern struct {
-    len: u8 = @sizeOf(sockaddr_in),
-    family: sa_family_t = AF_INET,
-    port: in_port_t,
-    addr: u32,
-    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-pub const sockaddr_in6 = extern struct {
-    len: u8 = @sizeOf(sockaddr_in6),
-    family: sa_family_t = AF_INET6,
-    port: in_port_t,
-    flowinfo: u32,
-    addr: [16]u8,
-    scope_id: u32,
-};
-
-/// UNIX domain socket
-pub const sockaddr_un = extern struct {
-    len: u8 = @sizeOf(sockaddr_un),
-    family: sa_family_t = AF_UNIX,
-    path: [104]u8,
-};
-
-pub const timeval = extern struct {
-    tv_sec: c_long,
-    tv_usec: i32,
-};
-
-pub const timezone = extern struct {
-    tz_minuteswest: i32,
-    tz_dsttime: i32,
-};
-
-pub const mach_timebase_info_data = extern struct {
-    numer: u32,
-    denom: u32,
-};
-
-pub const off_t = i64;
-pub const ino_t = u64;
-
-pub const Flock = extern struct {
-    l_start: off_t,
-    l_len: off_t,
-    l_pid: pid_t,
-    l_type: i16,
-    l_whence: i16,
-};
-
-pub const libc_stat = extern struct {
-    dev: i32,
-    mode: u16,
-    nlink: u16,
-    ino: ino_t,
-    uid: uid_t,
-    gid: gid_t,
-    rdev: i32,
-    atimesec: isize,
-    atimensec: isize,
-    mtimesec: isize,
-    mtimensec: isize,
-    ctimesec: isize,
-    ctimensec: isize,
-    birthtimesec: isize,
-    birthtimensec: isize,
-    size: off_t,
-    blocks: i64,
-    blksize: i32,
-    flags: u32,
-    gen: u32,
-    lspare: i32,
-    qspare: [2]i64,
-
-    pub fn atime(self: @This()) timespec {
-        return timespec{
-            .tv_sec = self.atimesec,
-            .tv_nsec = self.atimensec,
-        };
-    }
-
-    pub fn mtime(self: @This()) timespec {
-        return timespec{
-            .tv_sec = self.mtimesec,
-            .tv_nsec = self.mtimensec,
-        };
-    }
-
-    pub fn ctime(self: @This()) timespec {
-        return timespec{
-            .tv_sec = self.ctimesec,
-            .tv_nsec = self.ctimensec,
-        };
-    }
-};
-
-pub const timespec = extern struct {
-    tv_sec: isize,
-    tv_nsec: isize,
-};
-
-pub const sigset_t = u32;
-pub const empty_sigset: sigset_t = 0;
-
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
-
-pub const siginfo_t = extern struct {
-    signo: c_int,
-    errno: c_int,
-    code: c_int,
-    pid: pid_t,
-    uid: uid_t,
-    status: c_int,
-    addr: *c_void,
-    value: extern union {
-        int: c_int,
-        ptr: *c_void,
-    },
-    si_band: c_long,
-    _pad: [7]c_ulong,
-};
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
-pub const Sigaction = extern struct {
-    pub const handler_fn = fn (c_int) callconv(.C) void;
-    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
-    handler: extern union {
-        handler: ?handler_fn,
-        sigaction: ?sigaction_fn,
-    },
-    mask: sigset_t,
-    flags: c_uint,
-};
-
-pub const dirent = extern struct {
-    d_ino: usize,
-    d_seekoff: usize,
-    d_reclen: u16,
-    d_namlen: u16,
-    d_type: u8,
-    d_name: u8, // field address is address of first byte of name
-
-    pub fn reclen(self: dirent) u16 {
-        return self.d_reclen;
-    }
-};
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
-    ident: usize,
-    filter: i16,
-    flags: u16,
-    fflags: u32,
-    data: isize,
-    udata: usize,
-};
-
-// sys/types.h on macos uses #pragma pack(4) so these checks are
-// to make sure the struct is laid out the same. These values were
-// produced from C code using the offsetof macro.
-comptime {
-    assert(@offsetOf(Kevent, "ident") == 0);
-    assert(@offsetOf(Kevent, "filter") == 8);
-    assert(@offsetOf(Kevent, "flags") == 10);
-    assert(@offsetOf(Kevent, "fflags") == 12);
-    assert(@offsetOf(Kevent, "data") == 16);
-    assert(@offsetOf(Kevent, "udata") == 24);
-}
-
-pub const kevent64_s = extern struct {
-    ident: u64,
-    filter: i16,
-    flags: u16,
-    fflags: u32,
-    data: i64,
-    udata: u64,
-    ext: [2]u64,
-};
-
-// sys/types.h on macos uses #pragma pack() so these checks are
-// to make sure the struct is laid out the same. These values were
-// produced from C code using the offsetof macro.
-comptime {
-    assert(@offsetOf(kevent64_s, "ident") == 0);
-    assert(@offsetOf(kevent64_s, "filter") == 8);
-    assert(@offsetOf(kevent64_s, "flags") == 10);
-    assert(@offsetOf(kevent64_s, "fflags") == 12);
-    assert(@offsetOf(kevent64_s, "data") == 16);
-    assert(@offsetOf(kevent64_s, "udata") == 24);
-    assert(@offsetOf(kevent64_s, "ext") == 32);
-}
-
-pub const mach_port_t = c_uint;
-pub const clock_serv_t = mach_port_t;
-pub const clock_res_t = c_int;
-pub const mach_port_name_t = natural_t;
-pub const natural_t = c_uint;
-pub const mach_timespec_t = extern struct {
-    tv_sec: c_uint,
-    tv_nsec: clock_res_t,
-};
-pub const kern_return_t = c_int;
-pub const host_t = mach_port_t;
-pub const CALENDAR_CLOCK = 1;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = 16;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-/// [MC2] no permissions
-pub const PROT_NONE = 0x00;
-
-/// [MC2] pages can be read
-pub const PROT_READ = 0x01;
-
-/// [MC2] pages can be written
-pub const PROT_WRITE = 0x02;
-
-/// [MC2] pages can be executed
-pub const PROT_EXEC = 0x04;
-
-/// allocated from memory, swap space
-pub const MAP_ANONYMOUS = 0x1000;
-
-/// map from file (default)
-pub const MAP_FILE = 0x0000;
-
-/// interpret addr exactly
-pub const MAP_FIXED = 0x0010;
-
-/// region may contain semaphores
-pub const MAP_HASSEMAPHORE = 0x0200;
-
-/// changes are private
-pub const MAP_PRIVATE = 0x0002;
-
-/// share changes
-pub const MAP_SHARED = 0x0001;
-
-/// don't cache pages for this mapping
-pub const MAP_NOCACHE = 0x0400;
-
-/// don't reserve needed swap area
-pub const MAP_NORESERVE = 0x0040;
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-
-/// [XSI] no hang in wait/no child to reap
-pub const WNOHANG = 0x00000001;
-
-/// [XSI] notify on stop, untraced child
-pub const WUNTRACED = 0x00000002;
-
-/// take signal on signal stack
-pub const SA_ONSTACK = 0x0001;
-
-/// restart system on signal return
-pub const SA_RESTART = 0x0002;
-
-/// reset to SIG_DFL when taking signal
-pub const SA_RESETHAND = 0x0004;
-
-/// do not generate SIGCHLD on child stop
-pub const SA_NOCLDSTOP = 0x0008;
-
-/// don't mask the signal we're delivering
-pub const SA_NODEFER = 0x0010;
-
-/// don't keep zombies around
-pub const SA_NOCLDWAIT = 0x0020;
-
-/// signal handler with SA_SIGINFO args
-pub const SA_SIGINFO = 0x0040;
-
-/// do not bounce off kernel's sigtramp
-pub const SA_USERTRAMP = 0x0100;
-
-/// signal handler with SA_SIGINFO args with 64bit   regs information
-pub const SA_64REGSET = 0x0200;
-
-pub const O_PATH = 0x0000;
-
-pub const F_OK = 0;
-pub const X_OK = 1;
-pub const W_OK = 2;
-pub const R_OK = 4;
-
-/// open for reading only
-pub const O_RDONLY = 0x0000;
-
-/// open for writing only
-pub const O_WRONLY = 0x0001;
-
-/// open for reading and writing
-pub const O_RDWR = 0x0002;
-
-/// do not block on open or for data to become available
-pub const O_NONBLOCK = 0x0004;
-
-/// append on each write
-pub const O_APPEND = 0x0008;
-
-/// create file if it does not exist
-pub const O_CREAT = 0x0200;
-
-/// truncate size to 0
-pub const O_TRUNC = 0x0400;
-
-/// error if O_CREAT and the file exists
-pub const O_EXCL = 0x0800;
-
-/// atomically obtain a shared lock
-pub const O_SHLOCK = 0x0010;
-
-/// atomically obtain an exclusive lock
-pub const O_EXLOCK = 0x0020;
-
-/// do not follow symlinks
-pub const O_NOFOLLOW = 0x0100;
-
-/// allow open of symlinks
-pub const O_SYMLINK = 0x200000;
-
-/// descriptor requested for event notifications only
-pub const O_EVTONLY = 0x8000;
-
-/// mark as close-on-exec
-pub const O_CLOEXEC = 0x1000000;
-
-pub const O_ACCMODE = 3;
-pub const O_ALERT = 536870912;
-pub const O_ASYNC = 64;
-pub const O_DIRECTORY = 1048576;
-pub const O_DP_GETRAWENCRYPTED = 1;
-pub const O_DP_GETRAWUNENCRYPTED = 2;
-pub const O_DSYNC = 4194304;
-pub const O_FSYNC = O_SYNC;
-pub const O_NOCTTY = 131072;
-pub const O_POPUP = 2147483648;
-pub const O_SYNC = 128;
-
-pub const SEEK_SET = 0x0;
-pub const SEEK_CUR = 0x1;
-pub const SEEK_END = 0x2;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// block specified signal set
-pub const SIG_BLOCK = 1;
-
-/// unblock specified signal set
-pub const SIG_UNBLOCK = 2;
-
-/// set specified signal set
-pub const SIG_SETMASK = 3;
-
-/// hangup
-pub const SIGHUP = 1;
-
-/// interrupt
-pub const SIGINT = 2;
-
-/// quit
-pub const SIGQUIT = 3;
-
-/// illegal instruction (not reset when caught)
-pub const SIGILL = 4;
-
-/// trace trap (not reset when caught)
-pub const SIGTRAP = 5;
-
-/// abort()
-pub const SIGABRT = 6;
-
-/// pollable event ([XSR] generated, not supported)
-pub const SIGPOLL = 7;
-
-/// compatibility
-pub const SIGIOT = SIGABRT;
-
-/// EMT instruction
-pub const SIGEMT = 7;
-
-/// floating point exception
-pub const SIGFPE = 8;
-
-/// kill (cannot be caught or ignored)
-pub const SIGKILL = 9;
-
-/// bus error
-pub const SIGBUS = 10;
-
-/// segmentation violation
-pub const SIGSEGV = 11;
-
-/// bad argument to system call
-pub const SIGSYS = 12;
-
-/// write on a pipe with no one to read it
-pub const SIGPIPE = 13;
-
-/// alarm clock
-pub const SIGALRM = 14;
-
-/// software termination signal from kill
-pub const SIGTERM = 15;
-
-/// urgent condition on IO channel
-pub const SIGURG = 16;
-
-/// sendable stop signal not from tty
-pub const SIGSTOP = 17;
-
-/// stop signal from tty
-pub const SIGTSTP = 18;
-
-/// continue a stopped process
-pub const SIGCONT = 19;
-
-/// to parent on child stop or exit
-pub const SIGCHLD = 20;
-
-/// to readers pgrp upon background tty read
-pub const SIGTTIN = 21;
-
-/// like TTIN for output if (tp->t_local&LTOSTOP)
-pub const SIGTTOU = 22;
-
-/// input/output possible signal
-pub const SIGIO = 23;
-
-/// exceeded CPU time limit
-pub const SIGXCPU = 24;
-
-/// exceeded file size limit
-pub const SIGXFSZ = 25;
-
-/// virtual time alarm
-pub const SIGVTALRM = 26;
-
-/// profiling time alarm
-pub const SIGPROF = 27;
-
-/// window size changes
-pub const SIGWINCH = 28;
-
-/// information request
-pub const SIGINFO = 29;
-
-/// user defined signal 1
-pub const SIGUSR1 = 30;
-
-/// user defined signal 2
-pub const SIGUSR2 = 31;
-
-/// no flag value
-pub const KEVENT_FLAG_NONE = 0x000;
-
-/// immediate timeout
-pub const KEVENT_FLAG_IMMEDIATE = 0x001;
-
-/// 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
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-///     on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// 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
-/// event enabled. EINPROGRESS will be
-/// returned to indicate the deferral
-pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
-
-/// report that source has vanished
-/// ... only valid with EV_DISPATCH2
-pub const EV_VANISHED = 0x0200;
-
-/// 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;
-
-/// 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;
-
-/// 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;
-
-/// low water mark
-pub const NOTE_LOWAT = 0x00000001;
-
-/// OOB data
-pub const NOTE_OOB = 0x00000002;
-
-/// vnode was removed
-pub const NOTE_DELETE = 0x00000001;
-
-/// data contents changed
-pub const NOTE_WRITE = 0x00000002;
-
-/// 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;
-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;
-
-/// will quit on memory       pressure, possibly after cleaning up dirty state
-pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
-
-/// will quit immediately on      memory pressure
-pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
-
-/// 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;
-
-/// data is mach absolute time units
-pub const NOTE_MACHTIME = 0x00000100;
-
-pub const AF_UNSPEC = 0;
-pub const AF_LOCAL = 1;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_SYS_CONTROL = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const AF_XTP = 19;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const AF_RTIP = 22;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const AF_PIP = 25;
-pub const AF_ISDN = 28;
-pub const AF_E164 = AF_ISDN;
-pub const AF_KEY = 29;
-pub const AF_INET6 = 30;
-pub const AF_NATM = 31;
-pub const AF_SYSTEM = 32;
-pub const AF_NETBIOS = 33;
-pub const AF_PPP = 34;
-pub const AF_MAX = 40;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NS = AF_NS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_SNA = AF_SNA;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_XTP = AF_XTP;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_SIP = AF_SIP;
-pub const PF_IPX = AF_IPX;
-pub const PF_RTIP = AF_RTIP;
-pub const PF_PIP = AF_PIP;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_KEY = AF_KEY;
-pub const PF_INET6 = AF_INET6;
-pub const PF_NATM = AF_NATM;
-pub const PF_SYSTEM = AF_SYSTEM;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_PPP = AF_PPP;
-pub const PF_MAX = AF_MAX;
-
-pub const SYSPROTO_EVENT = 1;
-pub const SYSPROTO_CONTROL = 2;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_MAXADDRLEN = 255;
-
-/// Not actually supported by Darwin, but Zig supplies a shim.
-/// This numerical value is not ABI-stable. It need only not conflict
-/// with any other "SOCK_" bits.
-pub const SOCK_CLOEXEC = 1 << 15;
-/// Not actually supported by Darwin, but Zig supplies a shim.
-/// This numerical value is not ABI-stable. It need only not conflict
-/// with any other "SOCK_" bits.
-pub const SOCK_NONBLOCK = 1 << 16;
-
-pub const IPPROTO_ICMP = 1;
-pub const IPPROTO_ICMPV6 = 58;
-pub const IPPROTO_TCP = 6;
-pub const IPPROTO_UDP = 17;
-pub const IPPROTO_IP = 0;
-pub const IPPROTO_IPV6 = 41;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x1080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_ACCEPTFILTER = 0x1000;
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-
-pub const SO_NREAD = 0x1020;
-pub const SO_NKE = 0x1021;
-pub const SO_NOSIGPIPE = 0x1022;
-pub const SO_NOADDRERR = 0x1023;
-pub const SO_NWRITE = 0x1024;
-pub const SO_REUSESHAREUID = 0x1025;
-
-fn wstatus(x: u32) u32 {
-    return x & 0o177;
-}
-const wstopped = 0o177;
-pub fn WEXITSTATUS(x: u32) u8 {
-    return @intCast(u8, x >> 8);
-}
-pub fn WTERMSIG(x: u32) u32 {
-    return wstatus(x);
-}
-pub fn WSTOPSIG(x: u32) u32 {
-    return x >> 8;
-}
-pub fn WIFEXITED(x: u32) bool {
-    return wstatus(x) == 0;
-}
-pub fn WIFSTOPPED(x: u32) bool {
-    return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
-}
-pub fn WIFSIGNALED(x: u32) bool {
-    return wstatus(x) != wstopped and wstatus(x) != 0;
-}
-
-pub const E = enum(u16) {
-    /// No error occurred.
-    SUCCESS = 0,
-
-    /// Operation not permitted
-    PERM = 1,
-
-    /// No such file or directory
-    NOENT = 2,
-
-    /// No such process
-    SRCH = 3,
-
-    /// Interrupted system call
-    INTR = 4,
-
-    /// Input/output error
-    IO = 5,
-
-    /// Device not configured
-    NXIO = 6,
-
-    /// Argument list too long
-    @"2BIG" = 7,
-
-    /// Exec format error
-    NOEXEC = 8,
-
-    /// Bad file descriptor
-    BADF = 9,
-
-    /// No child processes
-    CHILD = 10,
-
-    /// Resource deadlock avoided
-    DEADLK = 11,
-
-    /// Cannot allocate memory
-    NOMEM = 12,
-
-    /// Permission denied
-    ACCES = 13,
-
-    /// Bad address
-    FAULT = 14,
-
-    /// Block device required
-    NOTBLK = 15,
-
-    /// Device / Resource busy
-    BUSY = 16,
-
-    /// File exists
-    EXIST = 17,
-
-    /// Cross-device link
-    XDEV = 18,
-
-    /// Operation not supported by device
-    NODEV = 19,
-
-    /// Not a directory
-    NOTDIR = 20,
-
-    /// Is a directory
-    ISDIR = 21,
-
-    /// Invalid argument
-    INVAL = 22,
-
-    /// Too many open files in system
-    NFILE = 23,
-
-    /// Too many open files
-    MFILE = 24,
-
-    /// Inappropriate ioctl for device
-    NOTTY = 25,
-
-    /// Text file busy
-    TXTBSY = 26,
-
-    /// File too large
-    FBIG = 27,
-
-    /// No space left on device
-    NOSPC = 28,
-
-    /// Illegal seek
-    SPIPE = 29,
-
-    /// Read-only file system
-    ROFS = 30,
-
-    /// Too many links
-    MLINK = 31,
-
-    /// Broken pipe
-    PIPE = 32,
-
-    // math software
-
-    /// Numerical argument out of domain
-    DOM = 33,
-
-    /// Result too large
-    RANGE = 34,
-
-    // non-blocking and interrupt i/o
-
-    /// Resource temporarily unavailable
-    /// This is the same code used for `WOULDBLOCK`.
-    AGAIN = 35,
-
-    /// Operation now in progress
-    INPROGRESS = 36,
-
-    /// Operation already in progress
-    ALREADY = 37,
-
-    // ipc/network software -- argument errors
-
-    /// Socket operation on non-socket
-    NOTSOCK = 38,
-
-    /// Destination address required
-    DESTADDRREQ = 39,
-
-    /// Message too long
-    MSGSIZE = 40,
-
-    /// Protocol wrong type for socket
-    PROTOTYPE = 41,
-
-    /// Protocol not available
-    NOPROTOOPT = 42,
-
-    /// Protocol not supported
-    PROTONOSUPPORT = 43,
-
-    /// Socket type not supported
-    SOCKTNOSUPPORT = 44,
-
-    /// Operation not supported
-    /// The same code is used for `NOTSUP`.
-    OPNOTSUPP = 45,
-
-    /// Protocol family not supported
-    PFNOSUPPORT = 46,
-
-    /// Address family not supported by protocol family
-    AFNOSUPPORT = 47,
-
-    /// Address already in use
-    ADDRINUSE = 48,
-    /// Can't assign requested address
-
-    // ipc/network software -- operational errors
-    ADDRNOTAVAIL = 49,
-
-    /// Network is down
-    NETDOWN = 50,
-
-    /// Network is unreachable
-    NETUNREACH = 51,
-
-    /// Network dropped connection on reset
-    NETRESET = 52,
-
-    /// Software caused connection abort
-    CONNABORTED = 53,
-
-    /// Connection reset by peer
-    CONNRESET = 54,
-
-    /// No buffer space available
-    NOBUFS = 55,
-
-    /// Socket is already connected
-    ISCONN = 56,
-
-    /// Socket is not connected
-    NOTCONN = 57,
-
-    /// Can't send after socket shutdown
-    SHUTDOWN = 58,
-
-    /// Too many references: can't splice
-    TOOMANYREFS = 59,
-
-    /// Operation timed out
-    TIMEDOUT = 60,
-
-    /// Connection refused
-    CONNREFUSED = 61,
-
-    /// Too many levels of symbolic links
-    LOOP = 62,
-
-    /// File name too long
-    NAMETOOLONG = 63,
-
-    /// Host is down
-    HOSTDOWN = 64,
-
-    /// No route to host
-    HOSTUNREACH = 65,
-    /// Directory not empty
-
-    // quotas & mush
-    NOTEMPTY = 66,
-
-    /// Too many processes
-    PROCLIM = 67,
-
-    /// Too many users
-    USERS = 68,
-    /// Disc quota exceeded
-
-    // Network File System
-    DQUOT = 69,
-
-    /// Stale NFS file handle
-    STALE = 70,
-
-    /// Too many levels of remote in path
-    REMOTE = 71,
-
-    /// RPC struct is bad
-    BADRPC = 72,
-
-    /// RPC version wrong
-    RPCMISMATCH = 73,
-
-    /// RPC prog. not avail
-    PROGUNAVAIL = 74,
-
-    /// Program version wrong
-    PROGMISMATCH = 75,
-
-    /// Bad procedure for program
-    PROCUNAVAIL = 76,
-
-    /// No locks available
-    NOLCK = 77,
-
-    /// Function not implemented
-    NOSYS = 78,
-
-    /// Inappropriate file type or format
-    FTYPE = 79,
-
-    /// Authentication error
-    AUTH = 80,
-
-    /// Need authenticator
-    NEEDAUTH = 81,
-
-    // Intelligent device errors
-
-    /// Device power is off
-    PWROFF = 82,
-
-    /// Device error, e.g. paper out
-    DEVERR = 83,
-
-    /// Value too large to be stored in data type
-    OVERFLOW = 84,
-
-    // Program loading errors
-
-    /// Bad executable
-    BADEXEC = 85,
-
-    /// Bad CPU type in executable
-    BADARCH = 86,
-
-    /// Shared library version mismatch
-    SHLIBVERS = 87,
-
-    /// Malformed Macho file
-    BADMACHO = 88,
-
-    /// Operation canceled
-    CANCELED = 89,
-
-    /// Identifier removed
-    IDRM = 90,
-
-    /// No message of desired type
-    NOMSG = 91,
-
-    /// Illegal byte sequence
-    ILSEQ = 92,
-
-    /// Attribute not found
-    NOATTR = 93,
-
-    /// Bad message
-    BADMSG = 94,
-
-    /// Reserved
-    MULTIHOP = 95,
-
-    /// No message available on STREAM
-    NODATA = 96,
-
-    /// Reserved
-    NOLINK = 97,
-
-    /// No STREAM resources
-    NOSR = 98,
-
-    /// Not a STREAM
-    NOSTR = 99,
-
-    /// Protocol error
-    PROTO = 100,
-
-    /// STREAM ioctl timeout
-    TIME = 101,
-
-    /// No such policy registered
-    NOPOLICY = 103,
-
-    /// State not recoverable
-    NOTRECOVERABLE = 104,
-
-    /// Previous owner died
-    OWNERDEAD = 105,
-
-    /// Interface output queue is full
-    QFULL = 106,
-
-    _,
-};
-
-pub const SIGSTKSZ = 131072;
-pub const MINSIGSTKSZ = 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
-    ss_sp: [*]u8,
-    ss_size: isize,
-    ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
-    return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
-    return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
-    return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
-    return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
-    return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
-    return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
-    return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
-    return m & S_IFMT == S_IFWHT;
-}
-
-pub const HOST_NAME_MAX = 72;
-
-pub const AT_FDCWD = -2;
-
-/// Use effective ids in access check
-pub const AT_EACCESS = 0x0010;
-
-/// Act on the symlink itself not the target
-pub const AT_SYMLINK_NOFOLLOW = 0x0020;
-
-/// Act on target of symlink
-pub const AT_SYMLINK_FOLLOW = 0x0040;
-
-/// Path refers to directory
-pub const AT_REMOVEDIR = 0x0080;
-
-pub const addrinfo = extern struct {
-    flags: i32,
-    family: i32,
-    socktype: i32,
-    protocol: i32,
-    addrlen: socklen_t,
-    canonname: ?[*:0]u8,
-    addr: ?*sockaddr,
-    next: ?*addrinfo,
-};
-
-pub const RTLD_LAZY = 0x1;
-pub const RTLD_NOW = 0x2;
-pub const RTLD_LOCAL = 0x4;
-pub const RTLD_GLOBAL = 0x8;
-pub const RTLD_NOLOAD = 0x10;
-pub const RTLD_NODELETE = 0x80;
-pub const RTLD_FIRST = 0x100;
-
-pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
-pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
-pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
-pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
-
-/// duplicate file descriptor
-pub const F_DUPFD = 0;
-
-/// get file descriptor flags
-pub const F_GETFD = 1;
-
-/// set file descriptor flags
-pub const F_SETFD = 2;
-
-/// get file status flags
-pub const F_GETFL = 3;
-
-/// set file status flags
-pub const F_SETFL = 4;
-
-/// get SIGIO/SIGURG proc/pgrp
-pub const F_GETOWN = 5;
-
-/// set SIGIO/SIGURG proc/pgrp
-pub const F_SETOWN = 6;
-
-/// get record locking information
-pub const F_GETLK = 7;
-
-/// set record locking information
-pub const F_SETLK = 8;
-
-/// F_SETLK; wait if blocked
-pub const F_SETLKW = 9;
-
-/// F_SETLK; wait if blocked, return on timeout
-pub const F_SETLKWTIMEOUT = 10;
-pub const F_FLUSH_DATA = 40;
-
-/// Used for regression test
-pub const F_CHKCLEAN = 41;
-
-/// Preallocate storage
-pub const F_PREALLOCATE = 42;
-
-/// Truncate a file without zeroing space
-pub const F_SETSIZE = 43;
-
-/// Issue an advisory read async with no copy to user
-pub const F_RDADVISE = 44;
-
-/// turn read ahead off/on for this fd
-pub const F_RDAHEAD = 45;
-
-/// turn data caching off/on for this fd
-pub const F_NOCACHE = 48;
-
-/// file offset to device offset
-pub const F_LOG2PHYS = 49;
-
-/// return the full path of the fd
-pub const F_GETPATH = 50;
-
-/// fsync + ask the drive to flush to the media
-pub const F_FULLFSYNC = 51;
-
-/// find which component (if any) is a package
-pub const F_PATHPKG_CHECK = 52;
-
-/// "freeze" all fs operations
-pub const F_FREEZE_FS = 53;
-
-/// "thaw" all fs operations
-pub const F_THAW_FS = 54;
-
-/// turn data caching off/on (globally) for this file
-pub const F_GLOBAL_NOCACHE = 55;
-
-/// add detached signatures
-pub const F_ADDSIGS = 59;
-
-/// add signature from same file (used by dyld for shared libs)
-pub const F_ADDFILESIGS = 61;
-
-/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes
-/// should not be used (i.e. its ok to temporaily create cached pages)
-pub const F_NODIRECT = 62;
-
-///Get the protection class of a file from the EA, returns int
-pub const F_GETPROTECTIONCLASS = 63;
-
-///Set the protection class of a file for the EA, requires int
-pub const F_SETPROTECTIONCLASS = 64;
-
-///file offset to device offset, extended
-pub const F_LOG2PHYS_EXT = 65;
-
-///get record locking information, per-process
-pub const F_GETLKPID = 66;
-
-///Mark the file as being the backing store for another filesystem
-pub const F_SETBACKINGSTORE = 70;
-
-///return the full path of the FD, but error in specific mtmd circumstances
-pub const F_GETPATH_MTMINFO = 71;
-
-///Returns the code directory, with associated hashes, to the caller
-pub const F_GETCODEDIR = 72;
-
-///No SIGPIPE generated on EPIPE
-pub const F_SETNOSIGPIPE = 73;
-
-///Status of SIGPIPE for this fd
-pub const F_GETNOSIGPIPE = 74;
-
-///For some cases, we need to rewrap the key for AKS/MKB
-pub const F_TRANSCODEKEY = 75;
-
-///file being written to a by single writer... if throttling enabled, writes
-///may be broken into smaller chunks with throttling in between
-pub const F_SINGLE_WRITER = 76;
-
-///Get the protection version number for this filesystem
-pub const F_GETPROTECTIONLEVEL = 77;
-
-///Add detached code signatures (used by dyld for shared libs)
-pub const F_FINDSIGS = 78;
-
-///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
-pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83;
-
-///fsync + issue barrier to drive
-pub const F_BARRIERFSYNC = 85;
-
-///Add signature from same file, return end offset in structure on success
-pub const F_ADDFILESIGS_RETURN = 97;
-
-///Check if Library Validation allows this Mach-O file to be mapped into the calling process
-pub const F_CHECK_LV = 98;
-
-///Deallocate a range of the file
-pub const F_PUNCHHOLE = 99;
-
-///Trim an active file
-pub const F_TRIM_ACTIVE_FILE = 100;
-
-pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
-
-///mark the dup with FD_CLOEXEC
-pub const F_DUPFD_CLOEXEC = 67;
-
-///close-on-exec flag
-pub const FD_CLOEXEC = 1;
-
-/// shared or read lock
-pub const F_RDLCK = 1;
-
-/// unlock
-pub const F_UNLCK = 2;
-
-/// exclusive or write lock
-pub const F_WRLCK = 3;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const nfds_t = u32;
-pub const pollfd = extern struct {
-    fd: fd_t,
-    events: i16,
-    revents: i16,
-};
-
-pub const POLLIN = 0x001;
-pub const POLLPRI = 0x002;
-pub const POLLOUT = 0x004;
-pub const POLLRDNORM = 0x040;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x080;
-pub const POLLWRBAND = 0x100;
-
-pub const POLLEXTEND = 0x0200;
-pub const POLLATTRIB = 0x0400;
-pub const POLLNLINK = 0x0800;
-pub const POLLWRITE = 0x1000;
-
-pub const POLLERR = 0x008;
-pub const POLLHUP = 0x010;
-pub const POLLNVAL = 0x020;
-
-pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_MONOTONIC = 6;
-pub const CLOCK_MONOTONIC_RAW = 4;
-pub const CLOCK_MONOTONIC_RAW_APPROX = 5;
-pub const CLOCK_UPTIME_RAW = 8;
-pub const CLOCK_UPTIME_RAW_APPROX = 9;
-pub const CLOCK_PROCESS_CPUTIME_ID = 12;
-pub const CLOCK_THREAD_CPUTIME_ID = 16;
-
-/// Max open files per process
-/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html
-pub const OPEN_MAX = 10240;
-pub const RUSAGE_SELF = 0;
-pub const RUSAGE_CHILDREN = -1;
-
-pub const rusage = extern struct {
-    utime: timeval,
-    stime: timeval,
-    maxrss: isize,
-    ixrss: isize,
-    idrss: isize,
-    isrss: isize,
-    minflt: isize,
-    majflt: isize,
-    nswap: isize,
-    inblock: isize,
-    oublock: isize,
-    msgsnd: isize,
-    msgrcv: isize,
-    nsignals: isize,
-    nvcsw: isize,
-    nivcsw: isize,
-};
-
-pub const rlimit_resource = enum(c_int) {
-    CPU = 0,
-    FSIZE = 1,
-    DATA = 2,
-    STACK = 3,
-    CORE = 4,
-    RSS = 5,
-    MEMLOCK = 6,
-    NPROC = 7,
-    NOFILE = 8,
-    _,
-
-    pub const AS: rlimit_resource = .RSS;
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
-    /// Soft limit
-    cur: rlim_t,
-    /// Hard limit
-    max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-// Term
-pub const VEOF = 0;
-pub const VEOL = 1;
-pub const VEOL2 = 2;
-pub const VERASE = 3;
-pub const VWERASE = 4;
-pub const VKILL = 5;
-pub const VREPRINT = 6;
-pub const VINTR = 8;
-pub const VQUIT = 9;
-pub const VSUSP = 10;
-pub const VDSUSP = 11;
-pub const VSTART = 12;
-pub const VSTOP = 13;
-pub const VLNEXT = 14;
-pub const VDISCARD = 15;
-pub const VMIN = 16;
-pub const VTIME = 17;
-pub const VSTATUS = 18;
-pub const NCCS = 20; // 2 spares (7, 19)
-
-pub const IGNBRK = 0x00000001; // ignore BREAK condition
-pub const BRKINT = 0x00000002; // map BREAK to SIGINTR
-pub const IGNPAR = 0x00000004; // ignore (discard) parity errors
-pub const PARMRK = 0x00000008; // mark parity and framing errors
-pub const INPCK = 0x00000010; // enable checking of parity errors
-pub const ISTRIP = 0x00000020; // strip 8th bit off chars
-pub const INLCR = 0x00000040; // map NL into CR
-pub const IGNCR = 0x00000080; // ignore CR
-pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD)
-pub const IXON = 0x00000200; // enable output flow control
-pub const IXOFF = 0x00000400; // enable input flow control
-pub const IXANY = 0x00000800; // any char will restart after stop
-pub const IMAXBEL = 0x00002000; // ring bell on input queue full
-pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE
-
-pub const OPOST = 0x00000001; //enable following output processing
-pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD)
-pub const OXTABS = 0x00000004; // expand tabs to spaces
-pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output)
-
-pub const OCRNL = 0x00000010; // map CR to NL on output
-pub const ONOCR = 0x00000020; // no CR output at column 0
-pub const ONLRET = 0x00000040; // NL performs CR function
-pub const OFILL = 0x00000080; // use fill characters for delay
-pub const NLDLY = 0x00000300; // \n delay
-pub const TABDLY = 0x00000c04; // horizontal tab delay
-pub const CRDLY = 0x00003000; // \r delay
-pub const FFDLY = 0x00004000; // form feed delay
-pub const BSDLY = 0x00008000; // \b delay
-pub const VTDLY = 0x00010000; // vertical tab delay
-pub const OFDEL = 0x00020000; // fill is DEL, else NUL
-
-pub const NL0 = 0x00000000;
-pub const NL1 = 0x00000100;
-pub const NL2 = 0x00000200;
-pub const NL3 = 0x00000300;
-pub const TAB0 = 0x00000000;
-pub const TAB1 = 0x00000400;
-pub const TAB2 = 0x00000800;
-pub const TAB3 = 0x00000004;
-pub const CR0 = 0x00000000;
-pub const CR1 = 0x00001000;
-pub const CR2 = 0x00002000;
-pub const CR3 = 0x00003000;
-pub const FF0 = 0x00000000;
-pub const FF1 = 0x00004000;
-pub const BS0 = 0x00000000;
-pub const BS1 = 0x00008000;
-pub const VT0 = 0x00000000;
-pub const VT1 = 0x00010000;
-
-pub const CIGNORE = 0x00000001; // ignore control flags
-pub const CSIZE = 0x00000300; // character size mask
-pub const CS5 = 0x00000000; //    5 bits (pseudo)
-pub const CS6 = 0x00000100; //    6 bits
-pub const CS7 = 0x00000200; //    7 bits
-pub const CS8 = 0x00000300; //    8 bits
-pub const CSTOPB = 0x0000040; // send 2 stop bits
-pub const CREAD = 0x00000800; // enable receiver
-pub const PARENB = 0x00001000; // parity enable
-pub const PARODD = 0x00002000; // odd parity, else even
-pub const HUPCL = 0x00004000; // hang up on last close
-pub const CLOCAL = 0x00008000; // ignore modem status lines
-pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output
-pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW);
-pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input
-pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input
-pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output
-pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output
-pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW
-
-pub const ECHOKE = 0x00000001; // visual erase for line kill
-pub const ECHOE = 0x00000002; // visually erase chars
-pub const ECHOK = 0x00000004; // echo NL after line kill
-pub const ECHO = 0x00000008; // enable echoing
-pub const ECHONL = 0x00000010; // echo NL even if ECHO is off
-pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy
-pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char)
-pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP
-pub const ICANON = 0x00000100; // canonicalize input lines
-pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm
-pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT
-pub const EXTPROC = 0x00000800; // external processing
-pub const TOSTOP = 0x00400000; // stop background jobs from output
-pub const FLUSHO = 0x00800000; // output being flushed (state)
-pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS
-pub const PENDIN = 0x20000000; // XXX retype pending input (state)
-pub const NOFLSH = 0x80000000; // don't flush after interrupt
-
-pub const TCSANOW = 0; // make change immediate
-pub const TCSADRAIN = 1; // drain output, then change
-pub const TCSAFLUSH = 2; // drain output, flush input
-pub const TCSASOFT = 0x10; // flag - don't alter h.w. state
-pub const TCSA = enum(c_uint) {
-    NOW,
-    DRAIN,
-    FLUSH,
-    _,
-};
-
-pub const B0 = 0;
-pub const B50 = 50;
-pub const B75 = 75;
-pub const B110 = 110;
-pub const B134 = 134;
-pub const B150 = 150;
-pub const B200 = 200;
-pub const B300 = 300;
-pub const B600 = 600;
-pub const B1200 = 1200;
-pub const B1800 = 1800;
-pub const B2400 = 2400;
-pub const B4800 = 4800;
-pub const B9600 = 9600;
-pub const B19200 = 19200;
-pub const B38400 = 38400;
-pub const B7200 = 7200;
-pub const B14400 = 14400;
-pub const B28800 = 28800;
-pub const B57600 = 57600;
-pub const B76800 = 76800;
-pub const B115200 = 115200;
-pub const B230400 = 230400;
-pub const EXTA = 19200;
-pub const EXTB = 38400;
-
-pub const TCIFLUSH = 1;
-pub const TCOFLUSH = 2;
-pub const TCIOFLUSH = 3;
-pub const TCOOFF = 1;
-pub const TCOON = 2;
-pub const TCIOFF = 3;
-pub const TCION = 4;
-
-pub const cc_t = u8;
-pub const speed_t = u64;
-pub const tcflag_t = u64;
-
-pub const termios = extern struct {
-    iflag: tcflag_t, // input flags
-    oflag: tcflag_t, // output flags
-    cflag: tcflag_t, // control flags
-    lflag: tcflag_t, // local flags
-    cc: [NCCS]cc_t, // control chars
-    ispeed: speed_t align(8), // input speed
-    ospeed: speed_t, // output speed
-};
-
-pub const winsize = extern struct {
-    ws_row: u16,
-    ws_col: u16,
-    ws_xpixel: u16,
-    ws_ypixel: u16,
-};
-
-pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
-pub const IOCPARM_MASK = 0x1fff;
-
-fn ior(inout: u32, group: usize, num: usize, len: usize) usize {
-    return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num));
-}
-
-// CPU families mapping
-pub const CPUFAMILY = enum(u32) {
-    UNKNOWN = 0,
-    POWERPC_G3 = 0xcee41549,
-    POWERPC_G4 = 0x77c184ae,
-    POWERPC_G5 = 0xed76d8aa,
-    INTEL_6_13 = 0xaa33392b,
-    INTEL_PENRYN = 0x78ea4fbc,
-    INTEL_NEHALEM = 0x6b5a4cd2,
-    INTEL_WESTMERE = 0x573b5eec,
-    INTEL_SANDYBRIDGE = 0x5490b78c,
-    INTEL_IVYBRIDGE = 0x1f65e835,
-    INTEL_HASWELL = 0x10b282dc,
-    INTEL_BROADWELL = 0x582ed09c,
-    INTEL_SKYLAKE = 0x37fc219f,
-    INTEL_KABYLAKE = 0x0f817246,
-    ARM_9 = 0xe73283ae,
-    ARM_11 = 0x8ff620d8,
-    ARM_XSCALE = 0x53b005f5,
-    ARM_12 = 0xbd1b0ae9,
-    ARM_13 = 0x0cc90e64,
-    ARM_14 = 0x96077ef1,
-    ARM_15 = 0xa8511bca,
-    ARM_SWIFT = 0x1e2d6381,
-    ARM_CYCLONE = 0x37a09642,
-    ARM_TYPHOON = 0x2c91a47e,
-    ARM_TWISTER = 0x92fb37c8,
-    ARM_HURRICANE = 0x67ceee93,
-    ARM_MONSOON_MISTRAL = 0xe81e7ef6,
-    ARM_VORTEX_TEMPEST = 0x07d34b9f,
-    ARM_LIGHTNING_THUNDER = 0x462504d2,
-    ARM_FIRESTORM_ICESTORM = 0x1b588bb3,
-    _,
-};
lib/std/os/bits/dragonfly.zig
@@ -1,1031 +0,0 @@
-const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-
-pub fn S_ISCHR(m: u32) bool {
-    return m & S_IFMT == S_IFCHR;
-}
-
-// See:
-// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
-// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h
-// TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const off_t = c_long;
-pub const mode_t = c_uint;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const time_t = isize;
-pub const suseconds_t = c_long;
-
-pub const E = enum(u16) {
-    /// No error occurred.
-    SUCCESS = 0,
-
-    PERM = 1,
-    NOENT = 2,
-    SRCH = 3,
-    INTR = 4,
-    IO = 5,
-    NXIO = 6,
-    @"2BIG" = 7,
-    NOEXEC = 8,
-    BADF = 9,
-    CHILD = 10,
-    DEADLK = 11,
-    NOMEM = 12,
-    ACCES = 13,
-    FAULT = 14,
-    NOTBLK = 15,
-    BUSY = 16,
-    EXIST = 17,
-    XDEV = 18,
-    NODEV = 19,
-    NOTDIR = 20,
-    ISDIR = 21,
-    INVAL = 22,
-    NFILE = 23,
-    MFILE = 24,
-    NOTTY = 25,
-    TXTBSY = 26,
-    FBIG = 27,
-    NOSPC = 28,
-    SPIPE = 29,
-    ROFS = 30,
-    MLINK = 31,
-    PIPE = 32,
-    DOM = 33,
-    RANGE = 34,
-    /// This code is also used for `WOULDBLOCK`.
-    AGAIN = 35,
-    INPROGRESS = 36,
-    ALREADY = 37,
-    NOTSOCK = 38,
-    DESTADDRREQ = 39,
-    MSGSIZE = 40,
-    PROTOTYPE = 41,
-    NOPROTOOPT = 42,
-    PROTONOSUPPORT = 43,
-    SOCKTNOSUPPORT = 44,
-    /// This code is also used for `NOTSUP`.
-    OPNOTSUPP = 45,
-    PFNOSUPPORT = 46,
-    AFNOSUPPORT = 47,
-    ADDRINUSE = 48,
-    ADDRNOTAVAIL = 49,
-    NETDOWN = 50,
-    NETUNREACH = 51,
-    NETRESET = 52,
-    CONNABORTED = 53,
-    CONNRESET = 54,
-    NOBUFS = 55,
-    ISCONN = 56,
-    NOTCONN = 57,
-    SHUTDOWN = 58,
-    TOOMANYREFS = 59,
-    TIMEDOUT = 60,
-    CONNREFUSED = 61,
-    LOOP = 62,
-    NAMETOOLONG = 63,
-    HOSTDOWN = 64,
-    HOSTUNREACH = 65,
-    NOTEMPTY = 66,
-    PROCLIM = 67,
-    USERS = 68,
-    DQUOT = 69,
-    STALE = 70,
-    REMOTE = 71,
-    BADRPC = 72,
-    RPCMISMATCH = 73,
-    PROGUNAVAIL = 74,
-    PROGMISMATCH = 75,
-    PROCUNAVAIL = 76,
-    NOLCK = 77,
-    NOSYS = 78,
-    FTYPE = 79,
-    AUTH = 80,
-    NEEDAUTH = 81,
-    IDRM = 82,
-    NOMSG = 83,
-    OVERFLOW = 84,
-    CANCELED = 85,
-    ILSEQ = 86,
-    NOATTR = 87,
-    DOOFUS = 88,
-    BADMSG = 89,
-    MULTIHOP = 90,
-    NOLINK = 91,
-    PROTO = 92,
-    NOMEDIUM = 93,
-    ASYNC = 99,
-    _,
-};
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const MAP_FILE = 0;
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_COPY = MAP_PRIVATE;
-pub const MAP_SHARED = 1;
-pub const MAP_PRIVATE = 2;
-pub const MAP_FIXED = 16;
-pub const MAP_RENAME = 32;
-pub const MAP_NORESERVE = 64;
-pub const MAP_INHERIT = 128;
-pub const MAP_NOEXTEND = 256;
-pub const MAP_HASSEMAPHORE = 512;
-pub const MAP_STACK = 1024;
-pub const MAP_NOSYNC = 2048;
-pub const MAP_ANON = 4096;
-pub const MAP_VPAGETABLE = 8192;
-pub const MAP_TRYFIXED = 65536;
-pub const MAP_NOCORE = 131072;
-pub const MAP_SIZEALIGN = 262144;
-
-pub const WNOHANG = 0x0001;
-pub const WUNTRACED = 0x0002;
-pub const WCONTINUED = 0x0004;
-pub const WSTOPPED = WUNTRACED;
-pub const WNOWAIT = 0x0008;
-pub const WEXITED = 0x0010;
-pub const WTRAPPED = 0x0020;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = KERN_IOV_MAX;
-
-pub const ino_t = c_ulong;
-
-pub const libc_stat = extern struct {
-    ino: ino_t,
-    nlink: c_uint,
-    dev: c_uint,
-    mode: c_ushort,
-    padding1: u16,
-    uid: uid_t,
-    gid: gid_t,
-    rdev: c_uint,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    size: c_ulong,
-    blocks: i64,
-    blksize: u32,
-    flags: u32,
-    gen: u32,
-    lspare: i32,
-    qspare1: i64,
-    qspare2: i64,
-    pub fn atime(self: @This()) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: @This()) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: @This()) timespec {
-        return self.ctim;
-    }
-};
-
-pub const timespec = extern struct {
-    tv_sec: c_long,
-    tv_nsec: c_long,
-};
-
-pub const timeval = extern struct {
-    /// seconds
-    tv_sec: time_t,
-    /// microseconds
-    tv_usec: suseconds_t,
-};
-
-pub const CTL_UNSPEC = 0;
-pub const CTL_KERN = 1;
-pub const CTL_VM = 2;
-pub const CTL_VFS = 3;
-pub const CTL_NET = 4;
-pub const CTL_DEBUG = 5;
-pub const CTL_HW = 6;
-pub const CTL_MACHDEP = 7;
-pub const CTL_USER = 8;
-pub const CTL_LWKT = 10;
-pub const CTL_MAXID = 11;
-pub const CTL_MAXNAME = 12;
-
-pub const KERN_PROC_ALL = 0;
-pub const KERN_OSTYPE = 1;
-pub const KERN_PROC_PID = 1;
-pub const KERN_OSRELEASE = 2;
-pub const KERN_PROC_PGRP = 2;
-pub const KERN_OSREV = 3;
-pub const KERN_PROC_SESSION = 3;
-pub const KERN_VERSION = 4;
-pub const KERN_PROC_TTY = 4;
-pub const KERN_MAXVNODES = 5;
-pub const KERN_PROC_UID = 5;
-pub const KERN_MAXPROC = 6;
-pub const KERN_PROC_RUID = 6;
-pub const KERN_MAXFILES = 7;
-pub const KERN_PROC_ARGS = 7;
-pub const KERN_ARGMAX = 8;
-pub const KERN_PROC_CWD = 8;
-pub const KERN_PROC_PATHNAME = 9;
-pub const KERN_SECURELVL = 9;
-pub const KERN_PROC_SIGTRAMP = 10;
-pub const KERN_HOSTNAME = 10;
-pub const KERN_HOSTID = 11;
-pub const KERN_CLOCKRATE = 12;
-pub const KERN_VNODE = 13;
-pub const KERN_PROC = 14;
-pub const KERN_FILE = 15;
-pub const KERN_PROC_FLAGMASK = 16;
-pub const KERN_PROF = 16;
-pub const KERN_PROC_FLAG_LWP = 16;
-pub const KERN_POSIX1 = 17;
-pub const KERN_NGROUPS = 18;
-pub const KERN_JOB_CONTROL = 19;
-pub const KERN_SAVED_IDS = 20;
-pub const KERN_BOOTTIME = 21;
-pub const KERN_NISDOMAINNAME = 22;
-pub const KERN_UPDATEINTERVAL = 23;
-pub const KERN_OSRELDATE = 24;
-pub const KERN_NTP_PLL = 25;
-pub const KERN_BOOTFILE = 26;
-pub const KERN_MAXFILESPERPROC = 27;
-pub const KERN_MAXPROCPERUID = 28;
-pub const KERN_DUMPDEV = 29;
-pub const KERN_IPC = 30;
-pub const KERN_DUMMY = 31;
-pub const KERN_PS_STRINGS = 32;
-pub const KERN_USRSTACK = 33;
-pub const KERN_LOGSIGEXIT = 34;
-pub const KERN_IOV_MAX = 35;
-pub const KERN_MAXPOSIXLOCKSPERUID = 36;
-pub const KERN_MAXID = 37;
-
-pub const HOST_NAME_MAX = 255;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-pub const O_RDONLY = 0;
-pub const O_NDELAY = O_NONBLOCK;
-pub const O_WRONLY = 1;
-pub const O_RDWR = 2;
-pub const O_ACCMODE = 3;
-pub const O_NONBLOCK = 4;
-pub const O_APPEND = 8;
-pub const O_SHLOCK = 16;
-pub const O_EXLOCK = 32;
-pub const O_ASYNC = 64;
-pub const O_FSYNC = 128;
-pub const O_SYNC = 128;
-pub const O_NOFOLLOW = 256;
-pub const O_CREAT = 512;
-pub const O_TRUNC = 1024;
-pub const O_EXCL = 2048;
-pub const O_NOCTTY = 32768;
-pub const O_DIRECT = 65536;
-pub const O_CLOEXEC = 131072;
-pub const O_FBLOCKING = 262144;
-pub const O_FNONBLOCKING = 524288;
-pub const O_FAPPEND = 1048576;
-pub const O_FOFFSET = 2097152;
-pub const O_FSYNCWRITE = 4194304;
-pub const O_FASYNCWRITE = 8388608;
-pub const O_DIRECTORY = 134217728;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-pub const SEEK_DATA = 3;
-pub const SEEK_HOLE = 4;
-
-pub const F_ULOCK = 0;
-pub const F_LOCK = 1;
-pub const F_TLOCK = 2;
-pub const F_TEST = 3;
-
-pub const FD_CLOEXEC = 1;
-
-pub const AT_FDCWD = -328243;
-pub const AT_SYMLINK_NOFOLLOW = 1;
-pub const AT_REMOVEDIR = 2;
-pub const AT_EACCESS = 4;
-pub const AT_SYMLINK_FOLLOW = 8;
-
-pub fn WEXITSTATUS(s: u32) u8 {
-    return @intCast(u8, (s & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: u32) u32 {
-    return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
-    return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
-    return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: u32) bool {
-    return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: u32) bool {
-    return (s & 0xffff) -% 1 < 0xff;
-}
-
-pub const dirent = extern struct {
-    d_fileno: c_ulong,
-    d_namlen: u16,
-    d_type: u8,
-    d_unused1: u8,
-    d_unused2: u32,
-    d_name: [256]u8,
-
-    pub fn reclen(self: dirent) u16 {
-        return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7);
-    }
-};
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-pub const DT_DBF = 15;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_VIRTUAL = 1;
-pub const CLOCK_PROF = 2;
-pub const CLOCK_MONOTONIC = 4;
-pub const CLOCK_UPTIME = 5;
-pub const CLOCK_UPTIME_PRECISE = 7;
-pub const CLOCK_UPTIME_FAST = 8;
-pub const CLOCK_REALTIME_PRECISE = 9;
-pub const CLOCK_REALTIME_FAST = 10;
-pub const CLOCK_MONOTONIC_PRECISE = 11;
-pub const CLOCK_MONOTONIC_FAST = 12;
-pub const CLOCK_SECOND = 13;
-pub const CLOCK_THREAD_CPUTIME_ID = 14;
-pub const CLOCK_PROCESS_CPUTIME_ID = 15;
-
-pub const sockaddr = extern struct {
-    len: u8,
-    family: u8,
-    data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const Kevent = extern struct {
-    ident: usize,
-    filter: c_short,
-    flags: c_ushort,
-    fflags: c_uint,
-    data: isize,
-    udata: usize,
-};
-
-pub const EVFILT_FS = -10;
-pub const EVFILT_USER = -9;
-pub const EVFILT_EXCEPT = -8;
-pub const EVFILT_TIMER = -7;
-pub const EVFILT_SIGNAL = -6;
-pub const EVFILT_PROC = -5;
-pub const EVFILT_VNODE = -4;
-pub const EVFILT_AIO = -3;
-pub const EVFILT_WRITE = -2;
-pub const EVFILT_READ = -1;
-pub const EVFILT_SYSCOUNT = 10;
-pub const EVFILT_MARKER = 15;
-
-pub const EV_ADD = 1;
-pub const EV_DELETE = 2;
-pub const EV_ENABLE = 4;
-pub const EV_DISABLE = 8;
-pub const EV_ONESHOT = 16;
-pub const EV_CLEAR = 32;
-pub const EV_RECEIPT = 64;
-pub const EV_DISPATCH = 128;
-pub const EV_NODATA = 4096;
-pub const EV_FLAG1 = 8192;
-pub const EV_ERROR = 16384;
-pub const EV_EOF = 32768;
-pub const EV_SYSFLAGS = 61440;
-
-pub const NOTE_FFNOP = 0;
-pub const NOTE_TRACK = 1;
-pub const NOTE_DELETE = 1;
-pub const NOTE_LOWAT = 1;
-pub const NOTE_TRACKERR = 2;
-pub const NOTE_OOB = 2;
-pub const NOTE_WRITE = 2;
-pub const NOTE_EXTEND = 4;
-pub const NOTE_CHILD = 4;
-pub const NOTE_ATTRIB = 8;
-pub const NOTE_LINK = 16;
-pub const NOTE_RENAME = 32;
-pub const NOTE_REVOKE = 64;
-pub const NOTE_PDATAMASK = 1048575;
-pub const NOTE_FFLAGSMASK = 16777215;
-pub const NOTE_TRIGGER = 16777216;
-pub const NOTE_EXEC = 536870912;
-pub const NOTE_FFAND = 1073741824;
-pub const NOTE_FORK = 1073741824;
-pub const NOTE_EXIT = 2147483648;
-pub const NOTE_FFOR = 2147483648;
-pub const NOTE_FFCTRLMASK = 3221225472;
-pub const NOTE_FFCOPY = 3221225472;
-pub const NOTE_PCTRLMASK = 4026531840;
-
-pub const stack_t = extern struct {
-    ss_sp: [*]u8,
-    ss_size: isize,
-    ss_flags: i32,
-};
-
-pub const S_IREAD = S_IRUSR;
-pub const S_IEXEC = S_IXUSR;
-pub const S_IWRITE = S_IWUSR;
-pub const S_IXOTH = 1;
-pub const S_IWOTH = 2;
-pub const S_IROTH = 4;
-pub const S_IRWXO = 7;
-pub const S_IXGRP = 8;
-pub const S_IWGRP = 16;
-pub const S_IRGRP = 32;
-pub const S_IRWXG = 56;
-pub const S_IXUSR = 64;
-pub const S_IWUSR = 128;
-pub const S_IRUSR = 256;
-pub const S_IRWXU = 448;
-pub const S_ISTXT = 512;
-pub const S_BLKSIZE = 512;
-pub const S_ISVTX = 512;
-pub const S_ISGID = 1024;
-pub const S_ISUID = 2048;
-pub const S_IFIFO = 4096;
-pub const S_IFCHR = 8192;
-pub const S_IFDIR = 16384;
-pub const S_IFBLK = 24576;
-pub const S_IFREG = 32768;
-pub const S_IFDB = 36864;
-pub const S_IFLNK = 40960;
-pub const S_IFSOCK = 49152;
-pub const S_IFWHT = 57344;
-pub const S_IFMT = 61440;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const BADSIG = SIG_ERR;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SIGIOT = SIGABRT;
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGTHR = 32;
-pub const SIGCKPT = 33;
-pub const SIGCKPTEXIT = 34;
-
-pub const siginfo_t = extern struct {
-    signo: c_int,
-    errno: c_int,
-    code: c_int,
-    pid: c_int,
-    uid: uid_t,
-    status: c_int,
-    addr: ?*c_void,
-    value: sigval,
-    band: c_long,
-    __spare__: [7]c_int,
-};
-
-pub const sigval = extern union {
-    sival_int: c_int,
-    sival_ptr: ?*c_void,
-};
-
-pub const _SIG_WORDS = 4;
-
-pub const sigset_t = extern struct {
-    __bits: [_SIG_WORDS]c_uint,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS };
-
-pub const sig_atomic_t = c_int;
-
-pub const Sigaction = extern struct {
-    pub const handler_fn = fn (c_int) callconv(.C) void;
-    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
-    /// signal handler
-    handler: extern union {
-        handler: ?handler_fn,
-        sigaction: ?sigaction_fn,
-    },
-    flags: c_uint,
-    mask: sigset_t,
-};
-
-pub const sig_t = [*c]fn (c_int) callconv(.C) void;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_MAXADDRLEN = 255;
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_TIMESTAMP = 0x0400;
-pub const SO_NOSIGPIPE = 0x0800;
-pub const SO_ACCEPTFILTER = 0x1000;
-pub const SO_RERROR = 0x2000;
-pub const SO_PASSCRED = 0x4000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_SNDSPACE = 0x100a;
-pub const SO_CPUHINT = 0x1030;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_INET6 = AF_INET6;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_ISO = AF_ISO;
-pub const PF_PIP = pseudo_AF_PIP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_INET = AF_INET;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_SIP = AF_SIP;
-pub const PF_OSI = AF_ISO;
-pub const PF_CNT = AF_CNT;
-pub const PF_LINK = AF_LINK;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_MAX = AF_MAX;
-pub const PF_KEY = pseudo_AF_KEY;
-pub const PF_PUP = AF_PUP;
-pub const PF_COIP = AF_COIP;
-pub const PF_SNA = AF_SNA;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_NATM = AF_NATM;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_NETGRAPH = AF_NETGRAPH;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_IPX = AF_IPX;
-pub const PF_DLI = AF_DLI;
-pub const PF_ATM = AF_ATM;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_RTIP = pseudo_AF_RTIP;
-pub const PF_LAT = AF_LAT;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_XTP = pseudo_AF_XTP;
-pub const PF_DECnet = AF_DECnet;
-
-pub const AF_UNSPEC = 0;
-pub const AF_OSI = AF_ISO;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_LOCAL = 1;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NETBIOS = 6;
-pub const AF_ISO = 7;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const AF_ISDN = 26;
-pub const AF_INET6 = 28;
-pub const AF_NATM = 29;
-pub const AF_ATM = 30;
-pub const AF_NETGRAPH = 32;
-pub const AF_BLUETOOTH = 33;
-pub const AF_MPLS = 34;
-pub const AF_MAX = 36;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-pub const socklen_t = u32;
-
-pub const sockaddr_in = extern struct {
-    len: u8 = @sizeOf(sockaddr_in),
-    family: sa_family_t = AF_INET,
-    port: in_port_t,
-    addr: u32,
-    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
-    len: u8 = @sizeOf(sockaddr_in6),
-    family: sa_family_t = AF_INET6,
-    port: in_port_t,
-    flowinfo: u32,
-    addr: [16]u8,
-    scope_id: u32,
-};
-
-pub const EAI = enum(c_int) {
-    ADDRFAMILY = 1,
-    AGAIN = 2,
-    BADFLAGS = 3,
-    FAIL = 4,
-    FAMILY = 5,
-    MEMORY = 6,
-    NODATA = 7,
-    NONAME = 8,
-    SERVICE = 9,
-    SOCKTYPE = 10,
-    SYSTEM = 11,
-    BADHINTS = 12,
-    PROTOCOL = 13,
-    OVERFLOW = 14,
-    _,
-};
-
-pub const AI_PASSIVE = 0x00000001;
-pub const AI_CANONNAME = 0x00000002;
-pub const AI_NUMERICHOST = 0x00000004;
-pub const AI_NUMERICSERV = 0x00000008;
-pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG;
-pub const AI_ALL = 0x00000100;
-pub const AI_V4MAPPED_CFG = 0x00000200;
-pub const AI_ADDRCONFIG = 0x00000400;
-pub const AI_V4MAPPED = 0x00000800;
-pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
-
-pub const RTLD_LAZY = 1;
-pub const RTLD_NOW = 2;
-pub const RTLD_MODEMASK = 0x3;
-pub const RTLD_GLOBAL = 0x100;
-pub const RTLD_LOCAL = 0;
-pub const RTLD_TRACE = 0x200;
-pub const RTLD_NODELETE = 0x01000;
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
-pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
-pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
-pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4)));
-
-pub const dl_phdr_info = extern struct {
-    dlpi_addr: usize,
-    dlpi_name: ?[*:0]const u8,
-    dlpi_phdr: [*]std.elf.Phdr,
-    dlpi_phnum: u16,
-};
-pub const cmsghdr = extern struct {
-    cmsg_len: socklen_t,
-    cmsg_level: c_int,
-    cmsg_type: c_int,
-};
-pub const msghdr = extern struct {
-    msg_name: ?*c_void,
-    msg_namelen: socklen_t,
-    msg_iov: [*c]iovec,
-    msg_iovlen: c_int,
-    msg_control: ?*c_void,
-    msg_controllen: socklen_t,
-    msg_flags: c_int,
-};
-pub const cmsgcred = extern struct {
-    cmcred_pid: pid_t,
-    cmcred_uid: uid_t,
-    cmcred_euid: uid_t,
-    cmcred_gid: gid_t,
-    cmcred_ngroups: c_short,
-    cmcred_groups: [16]gid_t,
-};
-pub const sf_hdtr = extern struct {
-    headers: [*c]iovec,
-    hdr_cnt: c_int,
-    trailers: [*c]iovec,
-    trl_cnt: c_int,
-};
-
-pub const MS_SYNC = 0;
-pub const MS_ASYNC = 1;
-pub const MS_INVALIDATE = 2;
-
-pub const POSIX_MADV_SEQUENTIAL = 2;
-pub const POSIX_MADV_RANDOM = 1;
-pub const POSIX_MADV_DONTNEED = 4;
-pub const POSIX_MADV_NORMAL = 0;
-pub const POSIX_MADV_WILLNEED = 3;
-
-pub const MADV_SEQUENTIAL = 2;
-pub const MADV_CONTROL_END = MADV_SETMAP;
-pub const MADV_DONTNEED = 4;
-pub const MADV_RANDOM = 1;
-pub const MADV_WILLNEED = 3;
-pub const MADV_NORMAL = 0;
-pub const MADV_CONTROL_START = MADV_INVAL;
-pub const MADV_FREE = 5;
-pub const MADV_NOSYNC = 6;
-pub const MADV_AUTOSYNC = 7;
-pub const MADV_NOCORE = 8;
-pub const MADV_CORE = 9;
-pub const MADV_INVAL = 10;
-pub const MADV_SETMAP = 11;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_RDLCK = 1;
-pub const F_SETFD = 2;
-pub const F_UNLCK = 2;
-pub const F_WRLCK = 3;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-pub const F_DUP2FD = 10;
-pub const F_DUPFD_CLOEXEC = 17;
-pub const F_DUP2FD_CLOEXEC = 18;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const Flock = extern struct {
-    l_start: off_t,
-    l_len: off_t,
-    l_pid: pid_t,
-    l_type: c_short,
-    l_whence: c_short,
-};
-
-pub const addrinfo = extern struct {
-    flags: i32,
-    family: i32,
-    socktype: i32,
-    protocol: i32,
-    addrlen: socklen_t,
-    canonname: ?[*:0]u8,
-    addr: ?*sockaddr,
-    next: ?*addrinfo,
-};
-
-pub const IPPROTO_IP = 0;
-pub const IPPROTO_ICMP = 1;
-pub const IPPROTO_TCP = 6;
-pub const IPPROTO_UDP = 17;
-pub const IPPROTO_IPV6 = 41;
-pub const IPPROTO_RAW = 255;
-pub const IPPROTO_HOPOPTS = 0;
-pub const IPPROTO_IGMP = 2;
-pub const IPPROTO_GGP = 3;
-pub const IPPROTO_IPV4 = 4;
-pub const IPPROTO_IPIP = IPPROTO_IPV4;
-pub const IPPROTO_ST = 7;
-pub const IPPROTO_EGP = 8;
-pub const IPPROTO_PIGP = 9;
-pub const IPPROTO_RCCMON = 10;
-pub const IPPROTO_NVPII = 11;
-pub const IPPROTO_PUP = 12;
-pub const IPPROTO_ARGUS = 13;
-pub const IPPROTO_EMCON = 14;
-pub const IPPROTO_XNET = 15;
-pub const IPPROTO_CHAOS = 16;
-pub const IPPROTO_MUX = 18;
-pub const IPPROTO_MEAS = 19;
-pub const IPPROTO_HMP = 20;
-pub const IPPROTO_PRM = 21;
-pub const IPPROTO_IDP = 22;
-pub const IPPROTO_TRUNK1 = 23;
-pub const IPPROTO_TRUNK2 = 24;
-pub const IPPROTO_LEAF1 = 25;
-pub const IPPROTO_LEAF2 = 26;
-pub const IPPROTO_RDP = 27;
-pub const IPPROTO_IRTP = 28;
-pub const IPPROTO_TP = 29;
-pub const IPPROTO_BLT = 30;
-pub const IPPROTO_NSP = 31;
-pub const IPPROTO_INP = 32;
-pub const IPPROTO_SEP = 33;
-pub const IPPROTO_3PC = 34;
-pub const IPPROTO_IDPR = 35;
-pub const IPPROTO_XTP = 36;
-pub const IPPROTO_DDP = 37;
-pub const IPPROTO_CMTP = 38;
-pub const IPPROTO_TPXX = 39;
-pub const IPPROTO_IL = 40;
-pub const IPPROTO_SDRP = 42;
-pub const IPPROTO_ROUTING = 43;
-pub const IPPROTO_FRAGMENT = 44;
-pub const IPPROTO_IDRP = 45;
-pub const IPPROTO_RSVP = 46;
-pub const IPPROTO_GRE = 47;
-pub const IPPROTO_MHRP = 48;
-pub const IPPROTO_BHA = 49;
-pub const IPPROTO_ESP = 50;
-pub const IPPROTO_AH = 51;
-pub const IPPROTO_INLSP = 52;
-pub const IPPROTO_SWIPE = 53;
-pub const IPPROTO_NHRP = 54;
-pub const IPPROTO_MOBILE = 55;
-pub const IPPROTO_TLSP = 56;
-pub const IPPROTO_SKIP = 57;
-pub const IPPROTO_ICMPV6 = 58;
-pub const IPPROTO_NONE = 59;
-pub const IPPROTO_DSTOPTS = 60;
-pub const IPPROTO_AHIP = 61;
-pub const IPPROTO_CFTP = 62;
-pub const IPPROTO_HELLO = 63;
-pub const IPPROTO_SATEXPAK = 64;
-pub const IPPROTO_KRYPTOLAN = 65;
-pub const IPPROTO_RVD = 66;
-pub const IPPROTO_IPPC = 67;
-pub const IPPROTO_ADFS = 68;
-pub const IPPROTO_SATMON = 69;
-pub const IPPROTO_VISA = 70;
-pub const IPPROTO_IPCV = 71;
-pub const IPPROTO_CPNX = 72;
-pub const IPPROTO_CPHB = 73;
-pub const IPPROTO_WSN = 74;
-pub const IPPROTO_PVP = 75;
-pub const IPPROTO_BRSATMON = 76;
-pub const IPPROTO_ND = 77;
-pub const IPPROTO_WBMON = 78;
-pub const IPPROTO_WBEXPAK = 79;
-pub const IPPROTO_EON = 80;
-pub const IPPROTO_VMTP = 81;
-pub const IPPROTO_SVMTP = 82;
-pub const IPPROTO_VINES = 83;
-pub const IPPROTO_TTP = 84;
-pub const IPPROTO_IGP = 85;
-pub const IPPROTO_DGP = 86;
-pub const IPPROTO_TCF = 87;
-pub const IPPROTO_IGRP = 88;
-pub const IPPROTO_OSPFIGP = 89;
-pub const IPPROTO_SRPC = 90;
-pub const IPPROTO_LARP = 91;
-pub const IPPROTO_MTP = 92;
-pub const IPPROTO_AX25 = 93;
-pub const IPPROTO_IPEIP = 94;
-pub const IPPROTO_MICP = 95;
-pub const IPPROTO_SCCSP = 96;
-pub const IPPROTO_ETHERIP = 97;
-pub const IPPROTO_ENCAP = 98;
-pub const IPPROTO_APES = 99;
-pub const IPPROTO_GMTP = 100;
-pub const IPPROTO_IPCOMP = 108;
-pub const IPPROTO_PIM = 103;
-pub const IPPROTO_CARP = 112;
-pub const IPPROTO_PGM = 113;
-pub const IPPROTO_PFSYNC = 240;
-pub const IPPROTO_DIVERT = 254;
-pub const IPPROTO_MAX = 256;
-pub const IPPROTO_DONE = 257;
-pub const IPPROTO_UNKNOWN = 258;
-
-pub const rlimit_resource = enum(c_int) {
-    CPU = 0,
-    FSIZE = 1,
-    DATA = 2,
-    STACK = 3,
-    CORE = 4,
-    RSS = 5,
-    MEMLOCK = 6,
-    NPROC = 7,
-    NOFILE = 8,
-    SBSIZE = 9,
-    VMEM = 10,
-    POSIXLOCKS = 11,
-    _,
-
-    pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = i64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
-    /// Soft limit
-    cur: rlim_t,
-    /// Hard limit
-    max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
-    fd: fd_t,
-    events: i16,
-    revents: i16,
-};
-
-/// Requestable events.
-pub const POLLIN = 0x0001;
-pub const POLLPRI = 0x0002;
-pub const POLLOUT = 0x0004;
-pub const POLLRDNORM = 0x0040;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x0080;
-pub const POLLWRBAND = 0x0100;
-
-/// These events are set if they occur regardless of whether they were requested.
-pub const POLLERR = 0x0008;
-pub const POLLHUP = 0x0010;
-pub const POLLNVAL = 0x0020;
lib/std/os/bits/freebsd.zig
@@ -1,1540 +0,0 @@
-const std = @import("../../std.zig");
-const builtin = @import("builtin");
-const maxInt = std.math.maxInt;
-
-pub const blksize_t = i32;
-pub const blkcnt_t = i64;
-pub const clockid_t = i32;
-pub const fsblkcnt_t = u64;
-pub const fsfilcnt_t = u64;
-pub const nlink_t = u64;
-pub const fd_t = i32;
-pub const pid_t = i32;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const mode_t = u16;
-pub const off_t = i64;
-pub const ino_t = u64;
-pub const dev_t = u64;
-pub const time_t = i64;
-// The signedness is not constant across different architectures.
-pub const clock_t = isize;
-
-pub const socklen_t = u32;
-pub const suseconds_t = c_long;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
-    ident: usize,
-    filter: i16,
-    flags: u16,
-    fflags: u32,
-    data: i64,
-    udata: usize,
-    // TODO ext
-};
-
-// Modes and flags for dlopen()
-// include/dlfcn.h
-
-/// Bind function calls lazily.
-pub const RTLD_LAZY = 1;
-
-/// Bind function calls immediately.
-pub const RTLD_NOW = 2;
-
-pub const RTLD_MODEMASK = 0x3;
-
-/// Make symbols globally available.
-pub const RTLD_GLOBAL = 0x100;
-
-/// Opposite of RTLD_GLOBAL, and the default.
-pub const RTLD_LOCAL = 0;
-
-/// Trace loaded objects and exit.
-pub const RTLD_TRACE = 0x200;
-
-/// Do not remove members.
-pub const RTLD_NODELETE = 0x01000;
-
-/// Do not load if not already loaded.
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const dl_phdr_info = extern struct {
-    dlpi_addr: usize,
-    dlpi_name: ?[*:0]const u8,
-    dlpi_phdr: [*]std.elf.Phdr,
-    dlpi_phnum: u16,
-};
-
-pub const Flock = extern struct {
-    l_start: off_t,
-    l_len: off_t,
-    l_pid: pid_t,
-    l_type: i16,
-    l_whence: i16,
-    l_sysid: i32,
-    __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
-    /// optional address
-    msg_name: ?*sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec,
-
-    /// # elements in msg_iov
-    msg_iovlen: i32,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
-    /// optional address
-    msg_name: ?*const sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec_const,
-
-    /// # elements in msg_iov
-    msg_iovlen: i32,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: i32,
-};
-
-pub const libc_stat = extern struct {
-    dev: dev_t,
-    ino: ino_t,
-    nlink: nlink_t,
-
-    mode: mode_t,
-    __pad0: u16,
-    uid: uid_t,
-    gid: gid_t,
-    __pad1: u32,
-    rdev: dev_t,
-
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    birthtim: timespec,
-
-    size: off_t,
-    blocks: i64,
-    blksize: isize,
-    flags: u32,
-    gen: u64,
-    __spare: [10]u64,
-
-    pub fn atime(self: @This()) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: @This()) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: @This()) timespec {
-        return self.ctim;
-    }
-};
-
-pub const timespec = extern struct {
-    tv_sec: isize,
-    tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
-    /// seconds
-    tv_sec: time_t,
-    /// microseconds
-    tv_usec: suseconds_t,
-};
-
-pub const dirent = extern struct {
-    d_fileno: usize,
-    d_off: i64,
-    d_reclen: u16,
-    d_type: u8,
-    d_pad0: u8,
-    d_namlen: u16,
-    d_pad1: u16,
-    d_name: [256]u8,
-
-    pub fn reclen(self: dirent) u16 {
-        return self.d_reclen;
-    }
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
-    /// total length
-    len: u8,
-
-    /// address family
-    family: sa_family_t,
-
-    /// actually longer; address value
-    data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
-    len: u8 = @sizeOf(sockaddr_in),
-    family: sa_family_t = AF_INET,
-    port: in_port_t,
-    addr: u32,
-    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
-    len: u8 = @sizeOf(sockaddr_in6),
-    family: sa_family_t = AF_INET6,
-    port: in_port_t,
-    flowinfo: u32,
-    addr: [16]u8,
-    scope_id: u32,
-};
-
-pub const sockaddr_un = extern struct {
-    len: u8 = @sizeOf(sockaddr_un),
-    family: sa_family_t = AF_UNIX,
-    path: [104]u8,
-};
-
-pub const CTL_KERN = 1;
-pub const CTL_DEBUG = 5;
-
-pub const KERN_PROC = 14; // struct: process entries
-pub const KERN_PROC_PATHNAME = 12; // path to executable
-pub const KERN_IOV_MAX = 35;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = KERN_IOV_MAX;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_VIRTUAL = 1;
-pub const CLOCK_PROF = 2;
-pub const CLOCK_MONOTONIC = 4;
-pub const CLOCK_UPTIME = 5;
-pub const CLOCK_UPTIME_PRECISE = 7;
-pub const CLOCK_UPTIME_FAST = 8;
-pub const CLOCK_REALTIME_PRECISE = 9;
-pub const CLOCK_REALTIME_FAST = 10;
-pub const CLOCK_MONOTONIC_PRECISE = 11;
-pub const CLOCK_MONOTONIC_FAST = 12;
-pub const CLOCK_SECOND = 13;
-pub const CLOCK_THREAD_CPUTIME_ID = 14;
-pub const CLOCK_PROCESS_CPUTIME_ID = 15;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_STACK = 0x0400;
-pub const MAP_NOSYNC = 0x0800;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_FILE = 0;
-
-pub const MAP_GUARD = 0x00002000;
-pub const MAP_EXCL = 0x00004000;
-pub const MAP_NOCORE = 0x00020000;
-pub const MAP_PREFAULT_READ = 0x00040000;
-pub const MAP_32BIT = 0x00080000;
-
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WSTOPPED = WUNTRACED;
-pub const WCONTINUED = 4;
-pub const WNOWAIT = 8;
-pub const WEXITED = 16;
-pub const WTRAPPED = 32;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NOCLDSTOP = 0x0008;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGTHR = 32;
-pub const SIGLWP = SIGTHR;
-pub const SIGLIBRT = 33;
-
-pub const SIGRTMIN = 65;
-pub const SIGRTMAX = 126;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-pub const O_RDONLY = 0x0000;
-pub const O_WRONLY = 0x0001;
-pub const O_RDWR = 0x0002;
-pub const O_ACCMODE = 0x0003;
-
-pub const O_SHLOCK = 0x0010;
-pub const O_EXLOCK = 0x0020;
-
-pub const O_CREAT = 0x0200;
-pub const O_EXCL = 0x0800;
-pub const O_NOCTTY = 0x8000;
-pub const O_TRUNC = 0x0400;
-pub const O_APPEND = 0x0008;
-pub const O_NONBLOCK = 0x0004;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0x0080;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0x20000;
-pub const O_NOFOLLOW = 0x0100;
-pub const O_CLOEXEC = 0x00100000;
-
-pub const O_ASYNC = 0x0040;
-pub const O_DIRECT = 0x00010000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 11;
-pub const F_SETLK = 12;
-pub const F_SETLKW = 13;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-
-pub const SO_DEBUG = 0x00000001;
-pub const SO_ACCEPTCONN = 0x00000002;
-pub const SO_REUSEADDR = 0x00000004;
-pub const SO_KEEPALIVE = 0x00000008;
-pub const SO_DONTROUTE = 0x00000010;
-pub const SO_BROADCAST = 0x00000020;
-pub const SO_USELOOPBACK = 0x00000040;
-pub const SO_LINGER = 0x00000080;
-pub const SO_OOBINLINE = 0x00000100;
-pub const SO_REUSEPORT = 0x00000200;
-pub const SO_TIMESTAMP = 0x00000400;
-pub const SO_NOSIGPIPE = 0x00000800;
-pub const SO_ACCEPTFILTER = 0x00001000;
-pub const SO_BINTIME = 0x00002000;
-pub const SO_NO_OFFLOAD = 0x00004000;
-pub const SO_NO_DDP = 0x00008000;
-pub const SO_REUSEPORT_LB = 0x00010000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_LABEL = 0x1009;
-pub const SO_PEERLABEL = 0x1010;
-pub const SO_LISTENQLIMIT = 0x1011;
-pub const SO_LISTENQLEN = 0x1012;
-pub const SO_LISTENINCQLEN = 0x1013;
-pub const SO_SETFIB = 0x1014;
-pub const SO_USER_COOKIE = 0x1015;
-pub const SO_PROTOCOL = 0x1016;
-pub const SO_PROTOTYPE = SO_PROTOCOL;
-pub const SO_TS_CLOCK = 0x1017;
-pub const SO_MAX_PACING_RATE = 0x1018;
-pub const SO_DOMAIN = 0x1019;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_XTP = pseudo_AF_XTP;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_SIP = AF_SIP;
-pub const PF_IPX = AF_IPX;
-pub const PF_RTIP = pseudo_AF_RTIP;
-pub const PF_PIP = psuedo_AF_PIP;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_KEY = pseudo_AF_KEY;
-pub const PF_INET6 = pseudo_AF_INET6;
-pub const PF_NATM = AF_NATM;
-pub const PF_ATM = AF_ATM;
-pub const PF_NETGRAPH = AF_NETGRAPH;
-pub const PF_SLOW = AF_SLOW;
-pub const PF_SCLUSTER = AF_SCLUSTER;
-pub const PF_ARP = AF_ARP;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_IEEE80211 = AF_IEEE80211;
-pub const PF_INET_SDP = AF_INET_SDP;
-pub const PF_INET6_SDP = AF_INET6_SDP;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_LOCAL = AF_UNIX;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NETBIOS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const pseudo_AF_XTP = 19;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const pseudo_AF_RTIP = 22;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const pseudo_AF_PIP = 25;
-pub const AF_ISDN = 26;
-pub const AF_E164 = AF_ISDN;
-pub const pseudo_AF_KEY = 27;
-pub const AF_INET6 = 28;
-pub const AF_NATM = 29;
-pub const AF_ATM = 30;
-pub const pseudo_AF_HDRCMPLT = 31;
-pub const AF_NETGRAPH = 32;
-pub const AF_SLOW = 33;
-pub const AF_SCLUSTER = 34;
-pub const AF_ARP = 35;
-pub const AF_BLUETOOTH = 36;
-pub const AF_IEEE80211 = 37;
-pub const AF_INET_SDP = 40;
-pub const AF_INET6_SDP = 42;
-pub const AF_MAX = 42;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// 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;
-
-/// error, event data contains errno
-pub const EV_ERROR = 0x4000;
-
-/// force immediate event output
-/// ... with or without EV_ERROR
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-///     on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-
-/// 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;
-
-/// Process descriptors
-pub const EVFILT_PROCDESC = -8;
-
-/// Filesystem events
-pub const EVFILT_FS = -9;
-
-pub const EVFILT_LIO = -10;
-
-/// User events
-pub const EVFILT_USER = -11;
-
-/// Sendfile events
-pub const EVFILT_SENDFILE = -12;
-
-pub const EVFILT_EMPTY = -13;
-
-/// On input, NOTE_TRIGGER causes the event to be triggered for output.
-pub const NOTE_TRIGGER = 0x01000000;
-
-/// 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;
-
-/// low water mark
-pub const NOTE_LOWAT = 0x00000001;
-
-/// behave like poll()
-pub const NOTE_FILE_POLL = 0x00000002;
-
-/// vnode was removed
-pub const NOTE_DELETE = 0x00000001;
-
-/// data contents changed
-pub const NOTE_WRITE = 0x00000002;
-
-/// 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;
-
-/// vnode was opened
-pub const NOTE_OPEN = 0x00000080;
-
-/// file closed, fd did not allow write
-pub const NOTE_CLOSE = 0x00000100;
-
-/// file closed, fd did allow write
-pub const NOTE_CLOSE_WRITE = 0x00000200;
-
-/// file was read
-pub const NOTE_READ = 0x00000400;
-
-/// process exited
-pub const NOTE_EXIT = 0x80000000;
-
-/// process forked
-pub const NOTE_FORK = 0x40000000;
-
-/// process exec'd
-pub const NOTE_EXEC = 0x20000000;
-
-/// mask for signal & exit status
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
-
-/// data is seconds
-pub const NOTE_SECONDS = 0x00000001;
-
-/// data is milliseconds
-pub const NOTE_MSECONDS = 0x00000002;
-
-/// data is microseconds
-pub const NOTE_USECONDS = 0x00000004;
-
-/// data is nanoseconds
-pub const NOTE_NSECONDS = 0x00000008;
-
-/// timeout is absolute
-pub const NOTE_ABSTIME = 0x00000010;
-
-pub const TIOCEXCL = 0x2000740d;
-pub const TIOCNXCL = 0x2000740e;
-pub const TIOCSCTTY = 0x20007461;
-pub const TIOCGPGRP = 0x40047477;
-pub const TIOCSPGRP = 0x80047476;
-pub const TIOCOUTQ = 0x40047473;
-pub const TIOCSTI = 0x80017472;
-pub const TIOCGWINSZ = 0x40087468;
-pub const TIOCSWINSZ = 0x80087467;
-pub const TIOCMGET = 0x4004746a;
-pub const TIOCMBIS = 0x8004746c;
-pub const TIOCMBIC = 0x8004746b;
-pub const TIOCMSET = 0x8004746d;
-pub const FIONREAD = 0x4004667f;
-pub const TIOCCONS = 0x80047462;
-pub const TIOCPKT = 0x80047470;
-pub const FIONBIO = 0x8004667e;
-pub const TIOCNOTTY = 0x20007471;
-pub const TIOCSETD = 0x8004741b;
-pub const TIOCGETD = 0x4004741a;
-pub const TIOCSBRK = 0x2000747b;
-pub const TIOCCBRK = 0x2000747a;
-pub const TIOCGSID = 0x40047463;
-pub const TIOCGPTN = 0x4004740f;
-pub const TIOCSIG = 0x2004745f;
-
-pub fn WEXITSTATUS(s: u32) u8 {
-    return @intCast(u8, (s & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: u32) u32 {
-    return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
-    return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
-    return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: u32) bool {
-    return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: u32) bool {
-    return (s & 0xffff) -% 1 < 0xff;
-}
-
-pub const winsize = extern struct {
-    ws_row: u16,
-    ws_col: u16,
-    ws_xpixel: u16,
-    ws_ypixel: u16,
-};
-
-const NSIG = 32;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
-    pub const handler_fn = fn (c_int) callconv(.C) void;
-    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
-    /// signal handler
-    handler: extern union {
-        handler: ?handler_fn,
-        sigaction: ?sigaction_fn,
-    },
-
-    /// see signal options
-    flags: c_uint,
-
-    /// signal mask to apply
-    mask: sigset_t,
-};
-
-pub const siginfo_t = extern struct {
-    signo: c_int,
-    errno: c_int,
-    code: c_int,
-    pid: pid_t,
-    uid: uid_t,
-    status: c_int,
-    addr: ?*c_void,
-    value: sigval,
-    reason: extern union {
-        fault: extern struct {
-            trapno: c_int,
-        },
-        timer: extern struct {
-            timerid: c_int,
-            overrun: c_int,
-        },
-        mesgq: extern struct {
-            mqd: c_int,
-        },
-        poll: extern struct {
-            band: c_long,
-        },
-        spare: extern struct {
-            spare1: c_long,
-            spare2: [7]c_int,
-        },
-    },
-};
-
-pub const sigval = extern union {
-    int: c_int,
-    ptr: ?*c_void,
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-
-pub inline fn _SIG_IDX(sig: usize) usize {
-    return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
-    return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
-    return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
-    return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
-    __bits: [_SIG_WORDS]u32,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
-
-pub usingnamespace switch (builtin.target.cpu.arch) {
-    .x86_64 => struct {
-        pub const ucontext_t = extern struct {
-            sigmask: sigset_t,
-            mcontext: mcontext_t,
-            link: ?*ucontext_t,
-            stack: stack_t,
-            flags: c_int,
-            __spare__: [4]c_int,
-        };
-
-        /// XXX x86_64 specific
-        pub const mcontext_t = extern struct {
-            onstack: u64,
-            rdi: u64,
-            rsi: u64,
-            rdx: u64,
-            rcx: u64,
-            r8: u64,
-            r9: u64,
-            rax: u64,
-            rbx: u64,
-            rbp: u64,
-            r10: u64,
-            r11: u64,
-            r12: u64,
-            r13: u64,
-            r14: u64,
-            r15: u64,
-            trapno: u32,
-            fs: u16,
-            gs: u16,
-            addr: u64,
-            flags: u32,
-            es: u16,
-            ds: u16,
-            err: u64,
-            rip: u64,
-            cs: u64,
-            rflags: u64,
-            rsp: u64,
-            ss: u64,
-        };
-    },
-    else => struct {},
-};
-
-pub const E = enum(u16) {
-    /// No error occurred.
-    SUCCESS = 0,
-
-    PERM = 1, // Operation not permitted
-    NOENT = 2, // No such file or directory
-    SRCH = 3, // No such process
-    INTR = 4, // Interrupted system call
-    IO = 5, // Input/output error
-    NXIO = 6, // Device not configured
-    @"2BIG" = 7, // Argument list too long
-    NOEXEC = 8, // Exec format error
-    BADF = 9, // Bad file descriptor
-    CHILD = 10, // No child processes
-    DEADLK = 11, // Resource deadlock avoided
-    // 11 was AGAIN
-    NOMEM = 12, // Cannot allocate memory
-    ACCES = 13, // Permission denied
-    FAULT = 14, // Bad address
-    NOTBLK = 15, // Block device required
-    BUSY = 16, // Device busy
-    EXIST = 17, // File exists
-    XDEV = 18, // Cross-device link
-    NODEV = 19, // Operation not supported by device
-    NOTDIR = 20, // Not a directory
-    ISDIR = 21, // Is a directory
-    INVAL = 22, // Invalid argument
-    NFILE = 23, // Too many open files in system
-    MFILE = 24, // Too many open files
-    NOTTY = 25, // Inappropriate ioctl for device
-    TXTBSY = 26, // Text file busy
-    FBIG = 27, // File too large
-    NOSPC = 28, // No space left on device
-    SPIPE = 29, // Illegal seek
-    ROFS = 30, // Read-only filesystem
-    MLINK = 31, // Too many links
-    PIPE = 32, // Broken pipe
-
-    // math software
-    DOM = 33, // Numerical argument out of domain
-    RANGE = 34, // Result too large
-
-    // non-blocking and interrupt i/o
-
-    /// Resource temporarily unavailable
-    /// This code is also used for `WOULDBLOCK`: operation would block.
-    AGAIN = 35,
-    INPROGRESS = 36, // Operation now in progress
-    ALREADY = 37, // Operation already in progress
-
-    // ipc/network software -- argument errors
-    NOTSOCK = 38, // Socket operation on non-socket
-    DESTADDRREQ = 39, // Destination address required
-    MSGSIZE = 40, // Message too long
-    PROTOTYPE = 41, // Protocol wrong type for socket
-    NOPROTOOPT = 42, // Protocol not available
-    PROTONOSUPPORT = 43, // Protocol not supported
-    SOCKTNOSUPPORT = 44, // Socket type not supported
-    /// Operation not supported
-    /// This code is also used for `NOTSUP`.
-    OPNOTSUPP = 45,
-    PFNOSUPPORT = 46, // Protocol family not supported
-    AFNOSUPPORT = 47, // Address family not supported by protocol family
-    ADDRINUSE = 48, // Address already in use
-    ADDRNOTAVAIL = 49, // Can't assign requested address
-
-    // ipc/network software -- operational errors
-    NETDOWN = 50, // Network is down
-    NETUNREACH = 51, // Network is unreachable
-    NETRESET = 52, // Network dropped connection on reset
-    CONNABORTED = 53, // Software caused connection abort
-    CONNRESET = 54, // Connection reset by peer
-    NOBUFS = 55, // No buffer space available
-    ISCONN = 56, // Socket is already connected
-    NOTCONN = 57, // Socket is not connected
-    SHUTDOWN = 58, // Can't send after socket shutdown
-    TOOMANYREFS = 59, // Too many references: can't splice
-    TIMEDOUT = 60, // Operation timed out
-    CONNREFUSED = 61, // Connection refused
-
-    LOOP = 62, // Too many levels of symbolic links
-    NAMETOOLONG = 63, // File name too long
-
-    // should be rearranged
-    HOSTDOWN = 64, // Host is down
-    HOSTUNREACH = 65, // No route to host
-    NOTEMPTY = 66, // Directory not empty
-
-    // quotas & mush
-    PROCLIM = 67, // Too many processes
-    USERS = 68, // Too many users
-    DQUOT = 69, // Disc quota exceeded
-
-    // Network File System
-    STALE = 70, // Stale NFS file handle
-    REMOTE = 71, // Too many levels of remote in path
-    BADRPC = 72, // RPC struct is bad
-    RPCMISMATCH = 73, // RPC version wrong
-    PROGUNAVAIL = 74, // RPC prog. not avail
-    PROGMISMATCH = 75, // Program version wrong
-    PROCUNAVAIL = 76, // Bad procedure for program
-
-    NOLCK = 77, // No locks available
-    NOSYS = 78, // Function not implemented
-
-    FTYPE = 79, // Inappropriate file type or format
-    AUTH = 80, // Authentication error
-    NEEDAUTH = 81, // Need authenticator
-    IDRM = 82, // Identifier removed
-    NOMSG = 83, // No message of desired type
-    OVERFLOW = 84, // Value too large to be stored in data type
-    CANCELED = 85, // Operation canceled
-    ILSEQ = 86, // Illegal byte sequence
-    NOATTR = 87, // Attribute not found
-
-    DOOFUS = 88, // Programming error
-
-    BADMSG = 89, // Bad message
-    MULTIHOP = 90, // Multihop attempted
-    NOLINK = 91, // Link has been severed
-    PROTO = 92, // Protocol error
-
-    NOTCAPABLE = 93, // Capabilities insufficient
-    CAPMODE = 94, // Not permitted in capability mode
-    NOTRECOVERABLE = 95, // State not recoverable
-    OWNERDEAD = 96, // Previous owner died
-    _,
-};
-
-pub const MINSIGSTKSZ = switch (builtin.target.cpu.arch) {
-    .i386, .x86_64 => 2048,
-    .arm, .aarch64 => 4096,
-    else => @compileError("MINSIGSTKSZ not defined for this architecture"),
-};
-pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
-    ss_sp: [*]u8,
-    ss_size: isize,
-    ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
-    return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
-    return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
-    return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
-    return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
-    return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
-    return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
-    return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
-    return m & S_IFMT == S_IFWHT;
-}
-
-pub const HOST_NAME_MAX = 255;
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
-
-pub const addrinfo = extern struct {
-    flags: i32,
-    family: i32,
-    socktype: i32,
-    protocol: i32,
-    addrlen: socklen_t,
-    canonname: ?[*:0]u8,
-    addr: ?*sockaddr,
-    next: ?*addrinfo,
-};
-
-/// Fail if not under dirfd
-pub const AT_BENEATH = 0x1000;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = 0;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IPv4 encapsulation
-pub const IPPROTO_IPV4 = 4;
-
-/// for compatibility
-pub const IPPROTO_IPIP = IPPROTO_IPV4;
-
-/// Stream protocol II
-pub const IPPROTO_ST = 7;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// private interior gateway
-pub const IPPROTO_PIGP = 9;
-
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON = 10;
-
-/// network voice protocol
-pub const IPPROTO_NVPII = 11;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// Argus
-pub const IPPROTO_ARGUS = 13;
-
-/// EMCON
-pub const IPPROTO_EMCON = 14;
-
-/// Cross Net Debugger
-pub const IPPROTO_XNET = 15;
-
-/// Chaos
-pub const IPPROTO_CHAOS = 16;
-
-/// Multiplexing
-pub const IPPROTO_MUX = 18;
-
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS = 19;
-
-/// Host Monitoring
-pub const IPPROTO_HMP = 20;
-
-/// Packet Radio Measurement
-pub const IPPROTO_PRM = 21;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// Trunk-1
-pub const IPPROTO_TRUNK1 = 23;
-
-/// Trunk-2
-pub const IPPROTO_TRUNK2 = 24;
-
-/// Leaf-1
-pub const IPPROTO_LEAF1 = 25;
-
-/// Leaf-2
-pub const IPPROTO_LEAF2 = 26;
-
-/// Reliable Data
-pub const IPPROTO_RDP = 27;
-
-/// Reliable Transaction
-pub const IPPROTO_IRTP = 28;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// Bulk Data Transfer
-pub const IPPROTO_BLT = 30;
-
-/// Network Services
-pub const IPPROTO_NSP = 31;
-
-/// Merit Internodal
-pub const IPPROTO_INP = 32;
-
-/// Datagram Congestion Control Protocol
-pub const IPPROTO_DCCP = 33;
-
-/// Third Party Connect
-pub const IPPROTO_3PC = 34;
-
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR = 35;
-
-/// XTP
-pub const IPPROTO_XTP = 36;
-
-/// Datagram Delivery
-pub const IPPROTO_DDP = 37;
-
-/// Control Message Transport
-pub const IPPROTO_CMTP = 38;
-
-/// TP++ Transport
-pub const IPPROTO_TPXX = 39;
-
-/// IL transport protocol
-pub const IPPROTO_IL = 40;
-
-/// Source Demand Routing
-pub const IPPROTO_SDRP = 42;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// InterDomain Routing
-pub const IPPROTO_IDRP = 45;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// General Routing Encap.
-pub const IPPROTO_GRE = 47;
-
-/// Mobile Host Routing
-pub const IPPROTO_MHRP = 48;
-
-/// BHA
-pub const IPPROTO_BHA = 49;
-
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP = 50;
-
-/// IP6 Auth Header
-pub const IPPROTO_AH = 51;
-
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP = 52;
-
-/// IP with encryption
-pub const IPPROTO_SWIPE = 53;
-
-/// Next Hop Resolution
-pub const IPPROTO_NHRP = 54;
-
-/// IP Mobility
-pub const IPPROTO_MOBILE = 55;
-
-/// Transport Layer Security
-pub const IPPROTO_TLSP = 56;
-
-/// SKIP
-pub const IPPROTO_SKIP = 57;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// any host internal protocol
-pub const IPPROTO_AHIP = 61;
-
-/// CFTP
-pub const IPPROTO_CFTP = 62;
-
-/// "hello" routing protocol
-pub const IPPROTO_HELLO = 63;
-
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK = 64;
-
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN = 65;
-
-/// Remote Virtual Disk
-pub const IPPROTO_RVD = 66;
-
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC = 67;
-
-/// Any distributed FS
-pub const IPPROTO_ADFS = 68;
-
-/// Satnet Monitoring
-pub const IPPROTO_SATMON = 69;
-
-/// VISA Protocol
-pub const IPPROTO_VISA = 70;
-
-/// Packet Core Utility
-pub const IPPROTO_IPCV = 71;
-
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX = 72;
-
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB = 73;
-
-/// Wang Span Network
-pub const IPPROTO_WSN = 74;
-
-/// Packet Video Protocol
-pub const IPPROTO_PVP = 75;
-
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON = 76;
-
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND = 77;
-
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON = 78;
-
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK = 79;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// VMTP
-pub const IPPROTO_VMTP = 81;
-
-/// Secure VMTP
-pub const IPPROTO_SVMTP = 82;
-
-/// Banyon VINES
-pub const IPPROTO_VINES = 83;
-
-/// TTP
-pub const IPPROTO_TTP = 84;
-
-/// NSFNET-IGP
-pub const IPPROTO_IGP = 85;
-
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP = 86;
-
-/// TCF
-pub const IPPROTO_TCF = 87;
-
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP = 88;
-
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP = 89;
-
-/// Strite RPC protocol
-pub const IPPROTO_SRPC = 90;
-
-/// Locus Address Resoloution
-pub const IPPROTO_LARP = 91;
-
-/// Multicast Transport
-pub const IPPROTO_MTP = 92;
-
-/// AX.25 Frames
-pub const IPPROTO_AX25 = 93;
-
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP = 94;
-
-/// Mobile Int.ing control
-pub const IPPROTO_MICP = 95;
-
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP = 96;
-
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// any private encr. scheme
-pub const IPPROTO_APES = 99;
-
-/// GMTP
-pub const IPPROTO_GMTP = 100;
-
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP = 108;
-
-/// SCTP
-pub const IPPROTO_SCTP = 132;
-
-/// IPv6 Mobility Header
-pub const IPPROTO_MH = 135;
-
-/// UDP-Lite
-pub const IPPROTO_UDPLITE = 136;
-
-/// IP6 Host Identity Protocol
-pub const IPPROTO_HIP = 139;
-
-/// IP6 Shim6 Protocol
-pub const IPPROTO_SHIM6 = 140;
-
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM = 103;
-
-/// CARP
-pub const IPPROTO_CARP = 112;
-
-/// PGM
-pub const IPPROTO_PGM = 113;
-
-/// MPLS-in-IP
-pub const IPPROTO_MPLS = 137;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// Reserved
-pub const IPPROTO_RESERVED_253 = 253;
-
-/// Reserved
-pub const IPPROTO_RESERVED_254 = 254;
-
-pub const rlimit_resource = enum(c_int) {
-    CPU = 0,
-    FSIZE = 1,
-    DATA = 2,
-    STACK = 3,
-    CORE = 4,
-    RSS = 5,
-    MEMLOCK = 6,
-    NPROC = 7,
-    NOFILE = 8,
-    SBSIZE = 9,
-    VMEM = 10,
-    NPTS = 11,
-    SWAP = 12,
-    KQUEUES = 13,
-    UMTXP = 14,
-    _,
-
-    pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = i64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
-    /// Soft limit
-    cur: rlim_t,
-    /// Hard limit
-    max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
-    fd: fd_t,
-    events: i16,
-    revents: i16,
-};
-
-/// any readable data available.
-pub const POLLIN = 0x0001;
-/// OOB/Urgent readable data.
-pub const POLLPRI = 0x0002;
-/// file descriptor is writeable.
-pub const POLLOUT = 0x0004;
-/// non-OOB/URG data available.
-pub const POLLRDNORM = 0x0040;
-/// no write type differentiation.
-pub const POLLWRNORM = POLLOUT;
-/// OOB/Urgent readable data.
-pub const POLLRDBAND = 0x0080;
-/// OOB/Urgent data can be written.
-pub const POLLWRBAND = 0x0100;
-/// like POLLIN, except ignore EOF.
-pub const POLLINIGNEOF = 0x2000;
-/// some poll error occurred.
-pub const POLLERR = 0x0008;
-/// file descriptor was "hung up".
-pub const POLLHUP = 0x0010;
-/// requested events "invalid".
-pub const POLLNVAL = 0x0020;
-
-pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND |
-    POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
lib/std/os/bits/haiku.zig
@@ -1,1373 +0,0 @@
-const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const uid_t = u32;
-pub const gid_t = u32;
-pub const mode_t = c_uint;
-
-pub const socklen_t = u32;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
-    ident: usize,
-    filter: i16,
-    flags: u16,
-    fflags: u32,
-    data: i64,
-    udata: usize,
-    // TODO ext
-};
-
-// Modes and flags for dlopen()
-// include/dlfcn.h
-
-pub const POLLIN = 0x0001;
-pub const POLLERR = 0x0004;
-pub const POLLNVAL = 0x1000;
-pub const POLLHUP = 0x0080;
-
-/// Bind function calls lazily.
-pub const RTLD_LAZY = 1;
-
-/// Bind function calls immediately.
-pub const RTLD_NOW = 2;
-
-pub const RTLD_MODEMASK = 0x3;
-
-/// Make symbols globally available.
-pub const RTLD_GLOBAL = 0x100;
-
-/// Opposite of RTLD_GLOBAL, and the default.
-pub const RTLD_LOCAL = 0;
-
-/// Trace loaded objects and exit.
-pub const RTLD_TRACE = 0x200;
-
-/// Do not remove members.
-pub const RTLD_NODELETE = 0x01000;
-
-/// Do not load if not already loaded.
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const dl_phdr_info = extern struct {
-    dlpi_addr: usize,
-    dlpi_name: ?[*:0]const u8,
-    dlpi_phdr: [*]std.elf.Phdr,
-    dlpi_phnum: u16,
-};
-
-pub const Flock = extern struct {
-    l_start: off_t,
-    l_len: off_t,
-    l_pid: pid_t,
-    l_type: i16,
-    l_whence: i16,
-    l_sysid: i32,
-    __unused: [4]u8,
-};
-
-pub const msghdr = extern struct {
-    /// optional address
-    msg_name: ?*sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec,
-
-    /// # elements in msg_iov
-    msg_iovlen: i32,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
-    /// optional address
-    msg_name: ?*const sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec_const,
-
-    /// # elements in msg_iov
-    msg_iovlen: i32,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: i32,
-};
-
-pub const off_t = i64;
-pub const ino_t = u64;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
-    fd: i32,
-    events: i16,
-    revents: i16,
-};
-
-pub const libc_stat = extern struct {
-    dev: i32,
-    ino: u64,
-    mode: u32,
-    nlink: i32,
-    uid: i32,
-    gid: i32,
-    size: i64,
-    rdev: i32,
-    blksize: i32,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    crtim: timespec,
-    st_type: u32,
-    blocks: i64,
-
-    pub fn atime(self: @This()) timespec {
-        return self.atim;
-    }
-    pub fn mtime(self: @This()) timespec {
-        return self.mtim;
-    }
-    pub fn ctime(self: @This()) timespec {
-        return self.ctim;
-    }
-    pub fn crtime(self: @This()) timespec {
-        return self.crtim;
-    }
-};
-
-pub const timespec = extern struct {
-    tv_sec: isize,
-    tv_nsec: isize,
-};
-
-pub const dirent = extern struct {
-    d_dev: i32,
-    d_pdev: i32,
-    d_ino: i64,
-    d_pino: i64,
-    d_reclen: u16,
-    d_name: [256]u8,
-
-    pub fn reclen(self: dirent) u16 {
-        return self.d_reclen;
-    }
-};
-
-pub const image_info = extern struct {
-    id: u32,
-    type: u32,
-    sequence: i32,
-    init_order: i32,
-    init_routine: *c_void,
-    term_routine: *c_void,
-    device: i32,
-    node: i32,
-    name: [1024]u8,
-    text: *c_void,
-    data: *c_void,
-    text_size: i32,
-    data_size: i32,
-    api_version: i32,
-    abi: i32,
-};
-
-pub const system_info = extern struct {
-    boot_time: i64,
-    cpu_count: u32,
-    max_pages: u64,
-    used_pages: u64,
-    cached_pages: u64,
-    block_cache_pages: u64,
-    ignored_pages: u64,
-    needed_memory: u64,
-    free_memory: u64,
-    max_swap_pages: u64,
-    free_swap_pages: u64,
-    page_faults: u32,
-    max_sems: u32,
-    used_sems: u32,
-    max_ports: u32,
-    used_ports: u32,
-    max_threads: u32,
-    used_threads: u32,
-    max_teams: u32,
-    used_teams: u32,
-    kernel_name: [256]u8,
-    kernel_build_date: [32]u8,
-    kernel_build_time: [32]u8,
-    kernel_version: i64,
-    abi: u32,
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
-    /// total length
-    len: u8,
-
-    /// address family
-    family: sa_family_t,
-
-    /// actually longer; address value
-    data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
-    len: u8 = @sizeOf(sockaddr_in),
-    family: sa_family_t = AF_INET,
-    port: in_port_t,
-    addr: u32,
-    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
-    len: u8 = @sizeOf(sockaddr_in6),
-    family: sa_family_t = AF_INET6,
-    port: in_port_t,
-    flowinfo: u32,
-    addr: [16]u8,
-    scope_id: u32,
-};
-
-pub const sockaddr_un = extern struct {
-    len: u8 = @sizeOf(sockaddr_un),
-    family: sa_family_t = AF_UNIX,
-    path: [104]u8,
-};
-
-pub const CTL_KERN = 1;
-pub const CTL_DEBUG = 5;
-
-pub const KERN_PROC = 14; // struct: process entries
-pub const KERN_PROC_PATHNAME = 12; // path to executable
-
-pub const PATH_MAX = 1024;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_MONOTONIC = 0;
-pub const CLOCK_REALTIME = -1;
-pub const CLOCK_PROCESS_CPUTIME_ID = -2;
-pub const CLOCK_THREAD_CPUTIME_ID = -3;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_STACK = 0x0400;
-pub const MAP_NOSYNC = 0x0800;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_FILE = 0;
-
-pub const MAP_GUARD = 0x00002000;
-pub const MAP_EXCL = 0x00004000;
-pub const MAP_NOCORE = 0x00020000;
-pub const MAP_PREFAULT_READ = 0x00040000;
-pub const MAP_32BIT = 0x00080000;
-
-pub const WNOHANG = 0x1;
-pub const WUNTRACED = 0x2;
-pub const WSTOPPED = 0x10;
-pub const WCONTINUED = 0x4;
-pub const WNOWAIT = 0x20;
-pub const WEXITED = 0x08;
-
-pub const SA_ONSTACK = 0x20;
-pub const SA_RESTART = 0x10;
-pub const SA_RESETHAND = 0x04;
-pub const SA_NOCLDSTOP = 0x01;
-pub const SA_NODEFER = 0x08;
-pub const SA_NOCLDWAIT = 0x02;
-pub const SA_SIGINFO = 0x40;
-pub const SA_NOMASK = SA_NODEFER;
-pub const SA_STACK = SA_ONSTACK;
-pub const SA_ONESHOT = SA_RESETHAND;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGCHLD = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGPIPE = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGSTOP = 10;
-pub const SIGSEGV = 11;
-pub const SIGCONT = 12;
-pub const SIGTSTP = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGTTIN = 16;
-pub const SIGTTOU = 17;
-pub const SIGUSR1 = 18;
-pub const SIGUSR2 = 19;
-pub const SIGWINCH = 20;
-pub const SIGKILLTHR = 21;
-pub const SIGTRAP = 22;
-pub const SIGPOLL = 23;
-pub const SIGPROF = 24;
-pub const SIGSYS = 25;
-pub const SIGURG = 26;
-pub const SIGVTALRM = 27;
-pub const SIGXCPU = 28;
-pub const SIGXFSZ = 29;
-pub const SIGBUS = 30;
-pub const SIGRESERVED1 = 31;
-pub const SIGRESERVED2 = 32;
-
-// TODO: check
-pub const SIGRTMIN = 65;
-pub const SIGRTMAX = 126;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-pub const O_RDONLY = 0x0000;
-pub const O_WRONLY = 0x0001;
-pub const O_RDWR = 0x0002;
-pub const O_ACCMODE = 0x0003;
-
-pub const O_SHLOCK = 0x0010;
-pub const O_EXLOCK = 0x0020;
-
-pub const O_CREAT = 0x0200;
-pub const O_EXCL = 0x0800;
-pub const O_NOCTTY = 0x8000;
-pub const O_TRUNC = 0x0400;
-pub const O_APPEND = 0x0008;
-pub const O_NONBLOCK = 0x0004;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0x0080;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0x20000;
-pub const O_NOFOLLOW = 0x0100;
-pub const O_CLOEXEC = 0x00100000;
-
-pub const O_ASYNC = 0x0040;
-pub const O_DIRECT = 0x00010000;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 11;
-pub const F_SETLK = 12;
-pub const F_SETLKW = 13;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-
-pub const SO_DEBUG = 0x00000001;
-pub const SO_ACCEPTCONN = 0x00000002;
-pub const SO_REUSEADDR = 0x00000004;
-pub const SO_KEEPALIVE = 0x00000008;
-pub const SO_DONTROUTE = 0x00000010;
-pub const SO_BROADCAST = 0x00000020;
-pub const SO_USELOOPBACK = 0x00000040;
-pub const SO_LINGER = 0x00000080;
-pub const SO_OOBINLINE = 0x00000100;
-pub const SO_REUSEPORT = 0x00000200;
-pub const SO_TIMESTAMP = 0x00000400;
-pub const SO_NOSIGPIPE = 0x00000800;
-pub const SO_ACCEPTFILTER = 0x00001000;
-pub const SO_BINTIME = 0x00002000;
-pub const SO_NO_OFFLOAD = 0x00004000;
-pub const SO_NO_DDP = 0x00008000;
-pub const SO_REUSEPORT_LB = 0x00010000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_LABEL = 0x1009;
-pub const SO_PEERLABEL = 0x1010;
-pub const SO_LISTENQLIMIT = 0x1011;
-pub const SO_LISTENQLEN = 0x1012;
-pub const SO_LISTENINCQLEN = 0x1013;
-pub const SO_SETFIB = 0x1014;
-pub const SO_USER_COOKIE = 0x1015;
-pub const SO_PROTOCOL = 0x1016;
-pub const SO_PROTOTYPE = SO_PROTOCOL;
-pub const SO_TS_CLOCK = 0x1017;
-pub const SO_MAX_PACING_RATE = 0x1018;
-pub const SO_DOMAIN = 0x1019;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NETBIOS = AF_NETBIOS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_XTP = pseudo_AF_XTP;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_SIP = AF_SIP;
-pub const PF_IPX = AF_IPX;
-pub const PF_RTIP = pseudo_AF_RTIP;
-pub const PF_PIP = psuedo_AF_PIP;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_KEY = pseudo_AF_KEY;
-pub const PF_INET6 = pseudo_AF_INET6;
-pub const PF_NATM = AF_NATM;
-pub const PF_ATM = AF_ATM;
-pub const PF_NETGRAPH = AF_NETGRAPH;
-pub const PF_SLOW = AF_SLOW;
-pub const PF_SCLUSTER = AF_SCLUSTER;
-pub const PF_ARP = AF_ARP;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_IEEE80211 = AF_IEEE80211;
-pub const PF_INET_SDP = AF_INET_SDP;
-pub const PF_INET6_SDP = AF_INET6_SDP;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_LOCAL = AF_UNIX;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NETBIOS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_ROUTE = 17;
-pub const AF_LINK = 18;
-pub const pseudo_AF_XTP = 19;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const pseudo_AF_RTIP = 22;
-pub const AF_IPX = 23;
-pub const AF_SIP = 24;
-pub const pseudo_AF_PIP = 25;
-pub const AF_ISDN = 26;
-pub const AF_E164 = AF_ISDN;
-pub const pseudo_AF_KEY = 27;
-pub const AF_INET6 = 28;
-pub const AF_NATM = 29;
-pub const AF_ATM = 30;
-pub const pseudo_AF_HDRCMPLT = 31;
-pub const AF_NETGRAPH = 32;
-pub const AF_SLOW = 33;
-pub const AF_SCLUSTER = 34;
-pub const AF_ARP = 35;
-pub const AF_BLUETOOTH = 36;
-pub const AF_IEEE80211 = 37;
-pub const AF_INET_SDP = 40;
-pub const AF_INET6_SDP = 42;
-pub const AF_MAX = 42;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// 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
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-///     on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-
-/// 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;
-
-/// Process descriptors
-pub const EVFILT_PROCDESC = -8;
-
-/// Filesystem events
-pub const EVFILT_FS = -9;
-
-pub const EVFILT_LIO = -10;
-
-/// User events
-pub const EVFILT_USER = -11;
-
-/// Sendfile events
-pub const EVFILT_SENDFILE = -12;
-
-pub const EVFILT_EMPTY = -13;
-
-pub const TCGETA = 0x8000;
-pub const TCSETA = 0x8001;
-pub const TCSETAW = 0x8004;
-pub const TCSETAF = 0x8003;
-pub const TCSBRK = 08005;
-pub const TCXONC = 0x8007;
-pub const TCFLSH = 0x8006;
-
-pub const TIOCSCTTY = 0x8017;
-pub const TIOCGPGRP = 0x8015;
-pub const TIOCSPGRP = 0x8016;
-pub const TIOCGWINSZ = 0x8012;
-pub const TIOCSWINSZ = 0x8013;
-pub const TIOCMGET = 0x8018;
-pub const TIOCMBIS = 0x8022;
-pub const TIOCMBIC = 0x8023;
-pub const TIOCMSET = 0x8019;
-pub const FIONREAD = 0xbe000001;
-pub const FIONBIO = 0xbe000000;
-pub const TIOCSBRK = 0x8020;
-pub const TIOCCBRK = 0x8021;
-pub const TIOCGSID = 0x8024;
-
-pub fn WEXITSTATUS(s: u32) u8 {
-    return @intCast(u8, s & 0xff);
-}
-
-pub fn WTERMSIG(s: u32) u32 {
-    return (s >> 8) & 0xff;
-}
-
-pub fn WSTOPSIG(s: u32) u32 {
-    return WEXITSTATUS(s);
-}
-
-pub fn WIFEXITED(s: u32) bool {
-    return WTERMSIG(s) == 0;
-}
-
-pub fn WIFSTOPPED(s: u32) bool {
-    return ((s >> 16) & 0xff) != 0;
-}
-
-pub fn WIFSIGNALED(s: u32) bool {
-    return ((s >> 8) & 0xff) != 0;
-}
-
-pub const winsize = extern struct {
-    ws_row: u16,
-    ws_col: u16,
-    ws_xpixel: u16,
-    ws_ypixel: u16,
-};
-
-const NSIG = 32;
-
-pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize));
-pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0);
-pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1);
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
-    /// signal handler
-    __sigaction_u: extern union {
-        __sa_handler: fn (i32) callconv(.C) void,
-        __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
-    },
-
-    /// see signal options
-    sa_flags: u32,
-
-    /// signal mask to apply
-    sa_mask: sigset_t,
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-pub inline fn _SIG_IDX(sig: usize) usize {
-    return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
-    return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
-    return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
-    return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
-    __bits: [_SIG_WORDS]u32,
-};
-
-pub const E = enum(i32) {
-    /// No error occurred.
-    SUCCESS = 0,
-    PERM = -0x7ffffff1, // Operation not permitted
-    NOENT = -0x7fff9ffd, // No such file or directory
-    SRCH = -0x7fff8ff3, // No such process
-    INTR = -0x7ffffff6, // Interrupted system call
-    IO = -0x7fffffff, // Input/output error
-    NXIO = -0x7fff8ff5, // Device not configured
-    @"2BIG" = -0x7fff8fff, // Argument list too long
-    NOEXEC = -0x7fffecfe, // Exec format error
-    CHILD = -0x7fff8ffe, // No child processes
-    DEADLK = -0x7fff8ffd, // Resource deadlock avoided
-    NOMEM = -0x80000000, // Cannot allocate memory
-    ACCES = -0x7ffffffe, // Permission denied
-    FAULT = -0x7fffecff, // Bad address
-    BUSY = -0x7ffffff2, // Device busy
-    EXIST = -0x7fff9ffe, // File exists
-    XDEV = -0x7fff9ff5, // Cross-device link
-    NODEV = -0x7fff8ff9, // Operation not supported by device
-    NOTDIR = -0x7fff9ffb, // Not a directory
-    ISDIR = -0x7fff9ff7, // Is a directory
-    INVAL = -0x7ffffffb, // Invalid argument
-    NFILE = -0x7fff8ffa, // Too many open files in system
-    MFILE = -0x7fff9ff6, // Too many open files
-    NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device
-    TXTBSY = -0x7fff8fc5, // Text file busy
-    FBIG = -0x7fff8ffc, // File too large
-    NOSPC = -0x7fff9ff9, // No space left on device
-    SPIPE = -0x7fff8ff4, // Illegal seek
-    ROFS = -0x7fff9ff8, // Read-only filesystem
-    MLINK = -0x7fff8ffb, // Too many links
-    PIPE = -0x7fff9ff3, // Broken pipe
-    BADF = -0x7fffa000, // Bad file descriptor
-
-    // math software
-    DOM = 33, // Numerical argument out of domain
-    RANGE = 34, // Result too large
-
-    // non-blocking and interrupt i/o
-
-    /// Also used for `WOULDBLOCK`.
-    AGAIN = -0x7ffffff5,
-    INPROGRESS = -0x7fff8fdc,
-    ALREADY = -0x7fff8fdb,
-
-    // ipc/network software -- argument errors
-    NOTSOCK = 38, // Socket operation on non-socket
-    DESTADDRREQ = 39, // Destination address required
-    MSGSIZE = 40, // Message too long
-    PROTOTYPE = 41, // Protocol wrong type for socket
-    NOPROTOOPT = 42, // Protocol not available
-    PROTONOSUPPORT = 43, // Protocol not supported
-    SOCKTNOSUPPORT = 44, // Socket type not supported
-    /// Also used for `NOTSUP`.
-    OPNOTSUPP = 45, // Operation not supported
-    PFNOSUPPORT = 46, // Protocol family not supported
-    AFNOSUPPORT = 47, // Address family not supported by protocol family
-    ADDRINUSE = 48, // Address already in use
-    ADDRNOTAVAIL = 49, // Can't assign requested address
-
-    // ipc/network software -- operational errors
-    NETDOWN = 50, // Network is down
-    NETUNREACH = 51, // Network is unreachable
-    NETRESET = 52, // Network dropped connection on reset
-    CONNABORTED = 53, // Software caused connection abort
-    CONNRESET = 54, // Connection reset by peer
-    NOBUFS = 55, // No buffer space available
-    ISCONN = 56, // Socket is already connected
-    NOTCONN = 57, // Socket is not connected
-    SHUTDOWN = 58, // Can't send after socket shutdown
-    TOOMANYREFS = 59, // Too many references: can't splice
-    TIMEDOUT = 60, // Operation timed out
-    CONNREFUSED = 61, // Connection refused
-
-    LOOP = 62, // Too many levels of symbolic links
-    NAMETOOLONG = 63, // File name too long
-
-    // should be rearranged
-    HOSTDOWN = 64, // Host is down
-    HOSTUNREACH = 65, // No route to host
-    NOTEMPTY = 66, // Directory not empty
-
-    // quotas & mush
-    PROCLIM = 67, // Too many processes
-    USERS = 68, // Too many users
-    DQUOT = 69, // Disc quota exceeded
-
-    // Network File System
-    STALE = 70, // Stale NFS file handle
-    REMOTE = 71, // Too many levels of remote in path
-    BADRPC = 72, // RPC struct is bad
-    RPCMISMATCH = 73, // RPC version wrong
-    PROGUNAVAIL = 74, // RPC prog. not avail
-    PROGMISMATCH = 75, // Program version wrong
-    PROCUNAVAIL = 76, // Bad procedure for program
-
-    NOLCK = 77, // No locks available
-    NOSYS = 78, // Function not implemented
-
-    FTYPE = 79, // Inappropriate file type or format
-    AUTH = 80, // Authentication error
-    NEEDAUTH = 81, // Need authenticator
-    IDRM = 82, // Identifier removed
-    NOMSG = 83, // No message of desired type
-    OVERFLOW = 84, // Value too large to be stored in data type
-    CANCELED = 85, // Operation canceled
-    ILSEQ = 86, // Illegal byte sequence
-    NOATTR = 87, // Attribute not found
-
-    DOOFUS = 88, // Programming error
-
-    BADMSG = 89, // Bad message
-    MULTIHOP = 90, // Multihop attempted
-    NOLINK = 91, // Link has been severed
-    PROTO = 92, // Protocol error
-
-    NOTCAPABLE = 93, // Capabilities insufficient
-    CAPMODE = 94, // Not permitted in capability mode
-    NOTRECOVERABLE = 95, // State not recoverable
-    OWNERDEAD = 96, // Previous owner died
-
-    _,
-};
-
-pub const MINSIGSTKSZ = switch (builtin.cpu.arch) {
-    .i386, .x86_64 => 2048,
-    .arm, .aarch64 => 4096,
-    else => @compileError("MINSIGSTKSZ not defined for this architecture"),
-};
-pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
-    ss_sp: [*]u8,
-    ss_size: isize,
-    ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
-    return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
-    return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
-    return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
-    return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
-    return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
-    return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
-    return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
-    return m & S_IFMT == S_IFWHT;
-}
-
-pub const HOST_NAME_MAX = 255;
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
-
-pub const addrinfo = extern struct {
-    flags: i32,
-    family: i32,
-    socktype: i32,
-    protocol: i32,
-    addrlen: socklen_t,
-    canonname: ?[*:0]u8,
-    addr: ?*sockaddr,
-    next: ?*addrinfo,
-};
-
-/// Fail if not under dirfd
-pub const AT_BENEATH = 0x1000;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = 0;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IPv4 encapsulation
-pub const IPPROTO_IPV4 = 4;
-
-/// for compatibility
-pub const IPPROTO_IPIP = IPPROTO_IPV4;
-
-/// Stream protocol II
-pub const IPPROTO_ST = 7;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// private interior gateway
-pub const IPPROTO_PIGP = 9;
-
-/// BBN RCC Monitoring
-pub const IPPROTO_RCCMON = 10;
-
-/// network voice protocol
-pub const IPPROTO_NVPII = 11;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// Argus
-pub const IPPROTO_ARGUS = 13;
-
-/// EMCON
-pub const IPPROTO_EMCON = 14;
-
-/// Cross Net Debugger
-pub const IPPROTO_XNET = 15;
-
-/// Chaos
-pub const IPPROTO_CHAOS = 16;
-
-/// Multiplexing
-pub const IPPROTO_MUX = 18;
-
-/// DCN Measurement Subsystems
-pub const IPPROTO_MEAS = 19;
-
-/// Host Monitoring
-pub const IPPROTO_HMP = 20;
-
-/// Packet Radio Measurement
-pub const IPPROTO_PRM = 21;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// Trunk-1
-pub const IPPROTO_TRUNK1 = 23;
-
-/// Trunk-2
-pub const IPPROTO_TRUNK2 = 24;
-
-/// Leaf-1
-pub const IPPROTO_LEAF1 = 25;
-
-/// Leaf-2
-pub const IPPROTO_LEAF2 = 26;
-
-/// Reliable Data
-pub const IPPROTO_RDP = 27;
-
-/// Reliable Transaction
-pub const IPPROTO_IRTP = 28;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// Bulk Data Transfer
-pub const IPPROTO_BLT = 30;
-
-/// Network Services
-pub const IPPROTO_NSP = 31;
-
-/// Merit Internodal
-pub const IPPROTO_INP = 32;
-
-/// Datagram Congestion Control Protocol
-pub const IPPROTO_DCCP = 33;
-
-/// Third Party Connect
-pub const IPPROTO_3PC = 34;
-
-/// InterDomain Policy Routing
-pub const IPPROTO_IDPR = 35;
-
-/// XTP
-pub const IPPROTO_XTP = 36;
-
-/// Datagram Delivery
-pub const IPPROTO_DDP = 37;
-
-/// Control Message Transport
-pub const IPPROTO_CMTP = 38;
-
-/// TP++ Transport
-pub const IPPROTO_TPXX = 39;
-
-/// IL transport protocol
-pub const IPPROTO_IL = 40;
-
-/// Source Demand Routing
-pub const IPPROTO_SDRP = 42;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// InterDomain Routing
-pub const IPPROTO_IDRP = 45;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// General Routing Encap.
-pub const IPPROTO_GRE = 47;
-
-/// Mobile Host Routing
-pub const IPPROTO_MHRP = 48;
-
-/// BHA
-pub const IPPROTO_BHA = 49;
-
-/// IP6 Encap Sec. Payload
-pub const IPPROTO_ESP = 50;
-
-/// IP6 Auth Header
-pub const IPPROTO_AH = 51;
-
-/// Integ. Net Layer Security
-pub const IPPROTO_INLSP = 52;
-
-/// IP with encryption
-pub const IPPROTO_SWIPE = 53;
-
-/// Next Hop Resolution
-pub const IPPROTO_NHRP = 54;
-
-/// IP Mobility
-pub const IPPROTO_MOBILE = 55;
-
-/// Transport Layer Security
-pub const IPPROTO_TLSP = 56;
-
-/// SKIP
-pub const IPPROTO_SKIP = 57;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// any host internal protocol
-pub const IPPROTO_AHIP = 61;
-
-/// CFTP
-pub const IPPROTO_CFTP = 62;
-
-/// "hello" routing protocol
-pub const IPPROTO_HELLO = 63;
-
-/// SATNET/Backroom EXPAK
-pub const IPPROTO_SATEXPAK = 64;
-
-/// Kryptolan
-pub const IPPROTO_KRYPTOLAN = 65;
-
-/// Remote Virtual Disk
-pub const IPPROTO_RVD = 66;
-
-/// Pluribus Packet Core
-pub const IPPROTO_IPPC = 67;
-
-/// Any distributed FS
-pub const IPPROTO_ADFS = 68;
-
-/// Satnet Monitoring
-pub const IPPROTO_SATMON = 69;
-
-/// VISA Protocol
-pub const IPPROTO_VISA = 70;
-
-/// Packet Core Utility
-pub const IPPROTO_IPCV = 71;
-
-/// Comp. Prot. Net. Executive
-pub const IPPROTO_CPNX = 72;
-
-/// Comp. Prot. HeartBeat
-pub const IPPROTO_CPHB = 73;
-
-/// Wang Span Network
-pub const IPPROTO_WSN = 74;
-
-/// Packet Video Protocol
-pub const IPPROTO_PVP = 75;
-
-/// BackRoom SATNET Monitoring
-pub const IPPROTO_BRSATMON = 76;
-
-/// Sun net disk proto (temp.)
-pub const IPPROTO_ND = 77;
-
-/// WIDEBAND Monitoring
-pub const IPPROTO_WBMON = 78;
-
-/// WIDEBAND EXPAK
-pub const IPPROTO_WBEXPAK = 79;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// VMTP
-pub const IPPROTO_VMTP = 81;
-
-/// Secure VMTP
-pub const IPPROTO_SVMTP = 82;
-
-/// Banyon VINES
-pub const IPPROTO_VINES = 83;
-
-/// TTP
-pub const IPPROTO_TTP = 84;
-
-/// NSFNET-IGP
-pub const IPPROTO_IGP = 85;
-
-/// dissimilar gateway prot.
-pub const IPPROTO_DGP = 86;
-
-/// TCF
-pub const IPPROTO_TCF = 87;
-
-/// Cisco/GXS IGRP
-pub const IPPROTO_IGRP = 88;
-
-/// OSPFIGP
-pub const IPPROTO_OSPFIGP = 89;
-
-/// Strite RPC protocol
-pub const IPPROTO_SRPC = 90;
-
-/// Locus Address Resoloution
-pub const IPPROTO_LARP = 91;
-
-/// Multicast Transport
-pub const IPPROTO_MTP = 92;
-
-/// AX.25 Frames
-pub const IPPROTO_AX25 = 93;
-
-/// IP encapsulated in IP
-pub const IPPROTO_IPEIP = 94;
-
-/// Mobile Int.ing control
-pub const IPPROTO_MICP = 95;
-
-/// Semaphore Comm. security
-pub const IPPROTO_SCCSP = 96;
-
-/// Ethernet IP encapsulation
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// any private encr. scheme
-pub const IPPROTO_APES = 99;
-
-/// GMTP
-pub const IPPROTO_GMTP = 100;
-
-/// payload compression (IPComp)
-pub const IPPROTO_IPCOMP = 108;
-
-/// SCTP
-pub const IPPROTO_SCTP = 132;
-
-/// IPv6 Mobility Header
-pub const IPPROTO_MH = 135;
-
-/// UDP-Lite
-pub const IPPROTO_UDPLITE = 136;
-
-/// IP6 Host Identity Protocol
-pub const IPPROTO_HIP = 139;
-
-/// IP6 Shim6 Protocol
-pub const IPPROTO_SHIM6 = 140;
-
-/// Protocol Independent Mcast
-pub const IPPROTO_PIM = 103;
-
-/// CARP
-pub const IPPROTO_CARP = 112;
-
-/// PGM
-pub const IPPROTO_PGM = 113;
-
-/// MPLS-in-IP
-pub const IPPROTO_MPLS = 137;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// Reserved
-pub const IPPROTO_RESERVED_253 = 253;
-
-/// Reserved
-pub const IPPROTO_RESERVED_254 = 254;
-
-pub const rlimit_resource = enum(c_int) {
-    CPU = 0,
-    FSIZE = 1,
-    DATA = 2,
-    STACK = 3,
-    CORE = 4,
-    RSS = 5,
-    MEMLOCK = 6,
-    NPROC = 7,
-    NOFILE = 8,
-    SBSIZE = 9,
-    VMEM = 10,
-    NPTS = 11,
-    SWAP = 12,
-    KQUEUES = 13,
-    UMTXP = 14,
-    _,
-
-    pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = i64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
-    /// Soft limit
-    cur: rlim_t,
-    /// Hard limit
-    max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-// TODO fill out if needed
-pub const directory_which = enum(c_int) {
-    B_USER_SETTINGS_DIRECTORY = 0xbbe,
-
-    _,
-};
-
-pub const cc_t = u8;
-pub const speed_t = u8;
-pub const tcflag_t = u32;
-
-pub const NCCS = 32;
-
-pub const termios = extern struct {
-    c_iflag: tcflag_t,
-    c_oflag: tcflag_t,
-    c_cflag: tcflag_t,
-    c_lflag: tcflag_t,
-    c_line: cc_t,
-    c_ispeed: speed_t,
-    c_ospeed: speed_t,
-    cc_t: [NCCS]cc_t,
-};
lib/std/os/bits/netbsd.zig
@@ -1,1326 +0,0 @@
-const std = @import("../../std.zig");
-const builtin = std.builtin;
-const maxInt = std.math.maxInt;
-
-pub const blkcnt_t = i64;
-pub const blksize_t = i32;
-pub const clock_t = u32;
-pub const dev_t = u64;
-pub const fd_t = i32;
-pub const gid_t = u32;
-pub const ino_t = u64;
-pub const mode_t = u32;
-pub const nlink_t = u32;
-pub const off_t = i64;
-pub const pid_t = i32;
-pub const socklen_t = u32;
-pub const time_t = i64;
-pub const uid_t = u32;
-pub const lwpid_t = i32;
-pub const suseconds_t = c_int;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
-    ident: usize,
-    filter: i32,
-    flags: u32,
-    fflags: u32,
-    data: i64,
-    udata: usize,
-};
-
-pub const RTLD_LAZY = 1;
-pub const RTLD_NOW = 2;
-pub const RTLD_GLOBAL = 0x100;
-pub const RTLD_LOCAL = 0x200;
-pub const RTLD_NODELETE = 0x01000;
-pub const RTLD_NOLOAD = 0x02000;
-
-pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
-pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
-pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
-
-pub const dl_phdr_info = extern struct {
-    dlpi_addr: usize,
-    dlpi_name: ?[*:0]const u8,
-    dlpi_phdr: [*]std.elf.Phdr,
-    dlpi_phnum: u16,
-};
-
-pub const Flock = extern struct {
-    l_start: off_t,
-    l_len: off_t,
-    l_pid: pid_t,
-    l_type: i16,
-    l_whence: i16,
-};
-
-pub const addrinfo = extern struct {
-    flags: i32,
-    family: i32,
-    socktype: i32,
-    protocol: i32,
-    addrlen: socklen_t,
-    canonname: ?[*:0]u8,
-    addr: ?*sockaddr,
-    next: ?*addrinfo,
-};
-
-pub const EAI = enum(c_int) {
-    /// address family for hostname not supported
-    ADDRFAMILY = 1,
-
-    /// name could not be resolved at this time
-    AGAIN = 2,
-
-    /// flags parameter had an invalid value
-    BADFLAGS = 3,
-
-    /// non-recoverable failure in name resolution
-    FAIL = 4,
-
-    /// address family not recognized
-    FAMILY = 5,
-
-    /// memory allocation failure
-    MEMORY = 6,
-
-    /// no address associated with hostname
-    NODATA = 7,
-
-    /// name does not resolve
-    NONAME = 8,
-
-    /// service not recognized for socket type
-    SERVICE = 9,
-
-    /// intended socket type was not recognized
-    SOCKTYPE = 10,
-
-    /// system error returned in errno
-    SYSTEM = 11,
-
-    /// invalid value for hints
-    BADHINTS = 12,
-
-    /// resolved protocol is unknown
-    PROTOCOL = 13,
-
-    /// argument buffer overflow
-    OVERFLOW = 14,
-
-    _,
-};
-
-pub const EAI_MAX = 15;
-
-pub const msghdr = extern struct {
-    /// optional address
-    msg_name: ?*sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec,
-
-    /// # elements in msg_iov
-    msg_iovlen: i32,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: i32,
-};
-
-pub const msghdr_const = extern struct {
-    /// optional address
-    msg_name: ?*const sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec_const,
-
-    /// # elements in msg_iov
-    msg_iovlen: i32,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: i32,
-};
-
-pub const libc_stat = extern struct {
-    dev: dev_t,
-    mode: mode_t,
-    ino: ino_t,
-    nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
-    rdev: dev_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    birthtim: timespec,
-    size: off_t,
-    blocks: blkcnt_t,
-    blksize: blksize_t,
-    flags: u32,
-    gen: u32,
-    __spare: [2]u32,
-
-    pub fn atime(self: @This()) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: @This()) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: @This()) timespec {
-        return self.ctim;
-    }
-};
-
-pub const timespec = extern struct {
-    tv_sec: i64,
-    tv_nsec: isize,
-};
-
-pub const timeval = extern struct {
-    /// seconds
-    tv_sec: time_t,
-    /// microseconds
-    tv_usec: suseconds_t,
-};
-
-pub const MAXNAMLEN = 511;
-
-pub const dirent = extern struct {
-    d_fileno: ino_t,
-    d_reclen: u16,
-    d_namlen: u16,
-    d_type: u8,
-    d_name: [MAXNAMLEN:0]u8,
-
-    pub fn reclen(self: dirent) u16 {
-        return self.d_reclen;
-    }
-};
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-pub const SOCK_CONN_DGRAM = 6;
-pub const SOCK_DCCP = SOCK_CONN_DGRAM;
-
-pub const SOCK_CLOEXEC = 0x10000000;
-pub const SOCK_NONBLOCK = 0x20000000;
-pub const SOCK_NOSIGPIPE = 0x40000000;
-pub const SOCK_FLAGS_MASK = 0xf0000000;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_NOSIGPIPE = 0x0800;
-pub const SO_ACCEPTFILTER = 0x1000;
-pub const SO_TIMESTAMP = 0x2000;
-pub const SO_RERROR = 0x4000;
-
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_OVERFLOWED = 0x1009;
-
-pub const SO_NOHEADER = 0x100a;
-pub const SO_SNDTIMEO = 0x100b;
-pub const SO_RCVTIMEO = 0x100c;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_INET = AF_INET;
-pub const PF_IMPLINK = AF_IMPLINK;
-pub const PF_PUP = AF_PUP;
-pub const PF_CHAOS = AF_CHAOS;
-pub const PF_NS = AF_NS;
-pub const PF_ISO = AF_ISO;
-pub const PF_OSI = AF_ISO;
-pub const PF_ECMA = AF_ECMA;
-pub const PF_DATAKIT = AF_DATAKIT;
-pub const PF_CCITT = AF_CCITT;
-pub const PF_SNA = AF_SNA;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_DLI = AF_DLI;
-pub const PF_LAT = AF_LAT;
-pub const PF_HYLINK = AF_HYLINK;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_OROUTE = AF_OROUTE;
-pub const PF_LINK = AF_LINK;
-pub const PF_COIP = AF_COIP;
-pub const PF_CNT = AF_CNT;
-pub const PF_INET6 = AF_INET6;
-pub const PF_IPX = AF_IPX;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_E164 = AF_E164;
-pub const PF_NATM = AF_NATM;
-pub const PF_ARP = AF_ARP;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_MPLS = AF_MPLS;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_CAN = AF_CAN;
-pub const PF_ETHER = AF_ETHER;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_LOCAL = 1;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_INET = 2;
-pub const AF_IMPLINK = 3;
-pub const AF_PUP = 4;
-pub const AF_CHAOS = 5;
-pub const AF_NS = 6;
-pub const AF_ISO = 7;
-pub const AF_OSI = AF_ISO;
-pub const AF_ECMA = 8;
-pub const AF_DATAKIT = 9;
-pub const AF_CCITT = 10;
-pub const AF_SNA = 11;
-pub const AF_DECnet = 12;
-pub const AF_DLI = 13;
-pub const AF_LAT = 14;
-pub const AF_HYLINK = 15;
-pub const AF_APPLETALK = 16;
-pub const AF_OROUTE = 17;
-pub const AF_LINK = 18;
-pub const AF_COIP = 20;
-pub const AF_CNT = 21;
-pub const AF_IPX = 23;
-pub const AF_INET6 = 24;
-pub const AF_ISDN = 26;
-pub const AF_E164 = AF_ISDN;
-pub const AF_NATM = 27;
-pub const AF_ARP = 28;
-pub const AF_BLUETOOTH = 31;
-pub const AF_IEEE80211 = 32;
-pub const AF_MPLS = 33;
-pub const AF_ROUTE = 34;
-pub const AF_CAN = 35;
-pub const AF_ETHER = 36;
-pub const AF_MAX = 37;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
-    /// total length
-    len: u8,
-
-    /// address family
-    family: sa_family_t,
-
-    /// actually longer; address value
-    data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
-    len: u8 = @sizeOf(sockaddr_in),
-    family: sa_family_t = AF_INET,
-    port: in_port_t,
-    addr: u32,
-    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
-    len: u8 = @sizeOf(sockaddr_in6),
-    family: sa_family_t = AF_INET6,
-    port: in_port_t,
-    flowinfo: u32,
-    addr: [16]u8,
-    scope_id: u32,
-};
-
-/// Definitions for UNIX IPC domain.
-pub const sockaddr_un = extern struct {
-    /// total sockaddr length
-    len: u8 = @sizeOf(sockaddr_un),
-
-    /// AF_LOCAL
-    family: sa_family_t = AF_LOCAL,
-
-    /// path name
-    path: [104]u8,
-};
-
-/// get address to use bind()
-pub const AI_PASSIVE = 0x00000001;
-
-/// fill ai_canonname
-pub const AI_CANONNAME = 0x00000002;
-
-/// prevent host name resolution
-pub const AI_NUMERICHOST = 0x00000004;
-
-/// prevent service name resolution
-pub const AI_NUMERICSERV = 0x00000008;
-
-/// only if any address is assigned
-pub const AI_ADDRCONFIG = 0x00000400;
-
-pub const CTL_KERN = 1;
-pub const CTL_DEBUG = 5;
-
-pub const KERN_PROC_ARGS = 48; // struct: process argv/env
-pub const KERN_PROC_PATHNAME = 5; // path to executable
-pub const KERN_IOV_MAX = 38;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = KERN_IOV_MAX;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_VIRTUAL = 1;
-pub const CLOCK_PROF = 2;
-pub const CLOCK_MONOTONIC = 3;
-pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000;
-pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_REMAPDUP = 0x0004;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_RENAME = 0x0020;
-pub const MAP_NORESERVE = 0x0040;
-pub const MAP_INHERIT = 0x0080;
-pub const MAP_HASSEMAPHORE = 0x0200;
-pub const MAP_TRYFIXED = 0x0400;
-pub const MAP_WIRED = 0x0800;
-
-pub const MAP_FILE = 0x0000;
-pub const MAP_NOSYNC = 0x0800;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_STACK = 0x2000;
-
-pub const WNOHANG = 0x00000001;
-pub const WUNTRACED = 0x00000002;
-pub const WSTOPPED = WUNTRACED;
-pub const WCONTINUED = 0x00000010;
-pub const WNOWAIT = 0x00010000;
-pub const WEXITED = 0x00000020;
-pub const WTRAPPED = 0x00000040;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NOCLDSTOP = 0x0008;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGPWR = 32;
-
-pub const SIGRTMIN = 33;
-pub const SIGRTMAX = 63;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-/// open for reading only
-pub const O_RDONLY = 0x00000000;
-
-/// open for writing only
-pub const O_WRONLY = 0x00000001;
-
-/// open for reading and writing
-pub const O_RDWR = 0x00000002;
-
-/// mask for above modes
-pub const O_ACCMODE = 0x00000003;
-
-/// no delay
-pub const O_NONBLOCK = 0x00000004;
-
-/// set append mode
-pub const O_APPEND = 0x00000008;
-
-/// open with shared file lock
-pub const O_SHLOCK = 0x00000010;
-
-/// open with exclusive file lock
-pub const O_EXLOCK = 0x00000020;
-
-/// signal pgrp when data ready
-pub const O_ASYNC = 0x00000040;
-
-/// synchronous writes
-pub const O_SYNC = 0x00000080;
-
-/// don't follow symlinks on the last
-pub const O_NOFOLLOW = 0x00000100;
-
-/// create if nonexistent
-pub const O_CREAT = 0x00000200;
-
-/// truncate to zero length
-pub const O_TRUNC = 0x00000400;
-
-/// error if already exists
-pub const O_EXCL = 0x00000800;
-
-/// don't assign controlling terminal
-pub const O_NOCTTY = 0x00008000;
-
-/// write: I/O data completion
-pub const O_DSYNC = 0x00010000;
-
-/// read: I/O completion as for write
-pub const O_RSYNC = 0x00020000;
-
-/// use alternate i/o semantics
-pub const O_ALT_IO = 0x00040000;
-
-/// direct I/O hint
-pub const O_DIRECT = 0x00080000;
-
-/// fail if not a directory
-pub const O_DIRECTORY = 0x00200000;
-
-/// set close on exec
-pub const O_CLOEXEC = 0x00400000;
-
-/// skip search permission checks
-pub const O_SEARCH = 0x00800000;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
-
-pub const LOCK_SH = 1;
-pub const LOCK_EX = 2;
-pub const LOCK_UN = 8;
-pub const LOCK_NB = 4;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14;
-
-/// 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
-/// ... use KEVENT_FLAG_ERROR_EVENTS
-///     on syscalls supporting flags
-pub const EV_RECEIPT = 0x0040;
-
-/// disable event after reporting
-pub const EV_DISPATCH = 0x0080;
-
-pub const EVFILT_READ = 0;
-pub const EVFILT_WRITE = 1;
-
-/// attached to aio requests
-pub const EVFILT_AIO = 2;
-
-/// attached to vnodes
-pub const EVFILT_VNODE = 3;
-
-/// attached to struct proc
-pub const EVFILT_PROC = 4;
-
-/// attached to struct proc
-pub const EVFILT_SIGNAL = 5;
-
-/// timers
-pub const EVFILT_TIMER = 6;
-
-/// Filesystem events
-pub const EVFILT_FS = 7;
-
-/// On input, NOTE_TRIGGER causes the event to be triggered for output.
-pub const NOTE_TRIGGER = 0x08000000;
-
-/// low water mark
-pub const NOTE_LOWAT = 0x00000001;
-
-/// vnode was removed
-pub const NOTE_DELETE = 0x00000001;
-
-/// data contents changed
-pub const NOTE_WRITE = 0x00000002;
-
-/// 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;
-
-/// process exited
-pub const NOTE_EXIT = 0x80000000;
-
-/// process forked
-pub const NOTE_FORK = 0x40000000;
-
-/// process exec'd
-pub const NOTE_EXEC = 0x20000000;
-
-/// mask for signal & exit status
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = 0xf0000000;
-
-pub const TIOCCBRK = 0x2000747a;
-pub const TIOCCDTR = 0x20007478;
-pub const TIOCCONS = 0x80047462;
-pub const TIOCDCDTIMESTAMP = 0x40107458;
-pub const TIOCDRAIN = 0x2000745e;
-pub const TIOCEXCL = 0x2000740d;
-pub const TIOCEXT = 0x80047460;
-pub const TIOCFLAG_CDTRCTS = 0x10;
-pub const TIOCFLAG_CLOCAL = 0x2;
-pub const TIOCFLAG_CRTSCTS = 0x4;
-pub const TIOCFLAG_MDMBUF = 0x8;
-pub const TIOCFLAG_SOFTCAR = 0x1;
-pub const TIOCFLUSH = 0x80047410;
-pub const TIOCGETA = 0x402c7413;
-pub const TIOCGETD = 0x4004741a;
-pub const TIOCGFLAGS = 0x4004745d;
-pub const TIOCGLINED = 0x40207442;
-pub const TIOCGPGRP = 0x40047477;
-pub const TIOCGQSIZE = 0x40047481;
-pub const TIOCGRANTPT = 0x20007447;
-pub const TIOCGSID = 0x40047463;
-pub const TIOCGSIZE = 0x40087468;
-pub const TIOCGWINSZ = 0x40087468;
-pub const TIOCMBIC = 0x8004746b;
-pub const TIOCMBIS = 0x8004746c;
-pub const TIOCMGET = 0x4004746a;
-pub const TIOCMSET = 0x8004746d;
-pub const TIOCM_CAR = 0x40;
-pub const TIOCM_CD = 0x40;
-pub const TIOCM_CTS = 0x20;
-pub const TIOCM_DSR = 0x100;
-pub const TIOCM_DTR = 0x2;
-pub const TIOCM_LE = 0x1;
-pub const TIOCM_RI = 0x80;
-pub const TIOCM_RNG = 0x80;
-pub const TIOCM_RTS = 0x4;
-pub const TIOCM_SR = 0x10;
-pub const TIOCM_ST = 0x8;
-pub const TIOCNOTTY = 0x20007471;
-pub const TIOCNXCL = 0x2000740e;
-pub const TIOCOUTQ = 0x40047473;
-pub const TIOCPKT = 0x80047470;
-pub const TIOCPKT_DATA = 0x0;
-pub const TIOCPKT_DOSTOP = 0x20;
-pub const TIOCPKT_FLUSHREAD = 0x1;
-pub const TIOCPKT_FLUSHWRITE = 0x2;
-pub const TIOCPKT_IOCTL = 0x40;
-pub const TIOCPKT_NOSTOP = 0x10;
-pub const TIOCPKT_START = 0x8;
-pub const TIOCPKT_STOP = 0x4;
-pub const TIOCPTMGET = 0x40287446;
-pub const TIOCPTSNAME = 0x40287448;
-pub const TIOCRCVFRAME = 0x80087445;
-pub const TIOCREMOTE = 0x80047469;
-pub const TIOCSBRK = 0x2000747b;
-pub const TIOCSCTTY = 0x20007461;
-pub const TIOCSDTR = 0x20007479;
-pub const TIOCSETA = 0x802c7414;
-pub const TIOCSETAF = 0x802c7416;
-pub const TIOCSETAW = 0x802c7415;
-pub const TIOCSETD = 0x8004741b;
-pub const TIOCSFLAGS = 0x8004745c;
-pub const TIOCSIG = 0x2000745f;
-pub const TIOCSLINED = 0x80207443;
-pub const TIOCSPGRP = 0x80047476;
-pub const TIOCSQSIZE = 0x80047480;
-pub const TIOCSSIZE = 0x80087467;
-pub const TIOCSTART = 0x2000746e;
-pub const TIOCSTAT = 0x80047465;
-pub const TIOCSTI = 0x80017472;
-pub const TIOCSTOP = 0x2000746f;
-pub const TIOCSWINSZ = 0x80087467;
-pub const TIOCUCNTL = 0x80047466;
-pub const TIOCXMTFRAME = 0x80087444;
-
-pub fn WEXITSTATUS(s: u32) u8 {
-    return @intCast(u8, (s >> 8) & 0xff);
-}
-pub fn WTERMSIG(s: u32) u32 {
-    return s & 0x7f;
-}
-pub fn WSTOPSIG(s: u32) u32 {
-    return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
-    return WTERMSIG(s) == 0;
-}
-
-pub fn WIFCONTINUED(s: u32) bool {
-    return ((s & 0x7f) == 0xffff);
-}
-
-pub fn WIFSTOPPED(s: u32) bool {
-    return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
-}
-
-pub fn WIFSIGNALED(s: u32) bool {
-    return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s);
-}
-
-pub const winsize = extern struct {
-    ws_row: u16,
-    ws_col: u16,
-    ws_xpixel: u16,
-    ws_ypixel: u16,
-};
-
-const NSIG = 32;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
-    pub const handler_fn = fn (c_int) callconv(.C) void;
-    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
-    /// signal handler
-    handler: extern union {
-        handler: ?handler_fn,
-        sigaction: ?sigaction_fn,
-    },
-    /// signal mask to apply
-    mask: sigset_t,
-    /// signal options
-    flags: c_uint,
-};
-
-pub const sigval_t = extern union {
-    int: i32,
-    ptr: ?*c_void,
-};
-
-pub const siginfo_t = extern union {
-    pad: [128]u8,
-    info: _ksiginfo,
-};
-
-pub const _ksiginfo = extern struct {
-    signo: i32,
-    code: i32,
-    errno: i32,
-    // 64bit architectures insert 4bytes of padding here, this is done by
-    // correctly aligning the reason field
-    reason: extern union {
-        rt: extern struct {
-            pid: pid_t,
-            uid: uid_t,
-            value: sigval_t,
-        },
-        child: extern struct {
-            pid: pid_t,
-            uid: uid_t,
-            status: i32,
-            utime: clock_t,
-            stime: clock_t,
-        },
-        fault: extern struct {
-            addr: ?*c_void,
-            trap: i32,
-            trap2: i32,
-            trap3: i32,
-        },
-        poll: extern struct {
-            band: i32,
-            fd: i32,
-        },
-        syscall: extern struct {
-            sysnum: i32,
-            retval: [2]i32,
-            @"error": i32,
-            args: [8]u64,
-        },
-        ptrace_state: extern struct {
-            pe_report_event: i32,
-            option: extern union {
-                pe_other_pid: pid_t,
-                pe_lwp: lwpid_t,
-            },
-        },
-    } align(@sizeOf(usize)),
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-
-pub inline fn _SIG_IDX(sig: usize) usize {
-    return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
-    return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
-    return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
-    return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
-    __bits: [_SIG_WORDS]u32,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
-
-// XXX x86_64 specific
-pub const mcontext_t = extern struct {
-    gregs: [26]u64,
-    mc_tlsbase: u64,
-    fpregs: [512]u8 align(8),
-};
-
-pub const REG_RBP = 12;
-pub const REG_RIP = 21;
-pub const REG_RSP = 24;
-
-pub const ucontext_t = extern struct {
-    flags: u32,
-    link: ?*ucontext_t,
-    sigmask: sigset_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    __pad: [
-        switch (builtin.cpu.arch) {
-            .i386 => 4,
-            .mips, .mipsel, .mips64, .mips64el => 14,
-            .arm, .armeb, .thumb, .thumbeb => 1,
-            .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8,
-            else => 0,
-        }
-    ]u32,
-};
-
-pub const E = enum(u16) {
-    /// No error occurred.
-    SUCCESS = 0,
-    PERM = 1, // Operation not permitted
-    NOENT = 2, // No such file or directory
-    SRCH = 3, // No such process
-    INTR = 4, // Interrupted system call
-    IO = 5, // Input/output error
-    NXIO = 6, // Device not configured
-    @"2BIG" = 7, // Argument list too long
-    NOEXEC = 8, // Exec format error
-    BADF = 9, // Bad file descriptor
-    CHILD = 10, // No child processes
-    DEADLK = 11, // Resource deadlock avoided
-    // 11 was AGAIN
-    NOMEM = 12, // Cannot allocate memory
-    ACCES = 13, // Permission denied
-    FAULT = 14, // Bad address
-    NOTBLK = 15, // Block device required
-    BUSY = 16, // Device busy
-    EXIST = 17, // File exists
-    XDEV = 18, // Cross-device link
-    NODEV = 19, // Operation not supported by device
-    NOTDIR = 20, // Not a directory
-    ISDIR = 21, // Is a directory
-    INVAL = 22, // Invalid argument
-    NFILE = 23, // Too many open files in system
-    MFILE = 24, // Too many open files
-    NOTTY = 25, // Inappropriate ioctl for device
-    TXTBSY = 26, // Text file busy
-    FBIG = 27, // File too large
-    NOSPC = 28, // No space left on device
-    SPIPE = 29, // Illegal seek
-    ROFS = 30, // Read-only file system
-    MLINK = 31, // Too many links
-    PIPE = 32, // Broken pipe
-
-    // math software
-    DOM = 33, // Numerical argument out of domain
-    RANGE = 34, // Result too large or too small
-
-    // non-blocking and interrupt i/o
-    // also: WOULDBLOCK: operation would block
-    AGAIN = 35, // Resource temporarily unavailable
-    INPROGRESS = 36, // Operation now in progress
-    ALREADY = 37, // Operation already in progress
-
-    // ipc/network software -- argument errors
-    NOTSOCK = 38, // Socket operation on non-socket
-    DESTADDRREQ = 39, // Destination address required
-    MSGSIZE = 40, // Message too long
-    PROTOTYPE = 41, // Protocol wrong type for socket
-    NOPROTOOPT = 42, // Protocol option not available
-    PROTONOSUPPORT = 43, // Protocol not supported
-    SOCKTNOSUPPORT = 44, // Socket type not supported
-    OPNOTSUPP = 45, // Operation not supported
-    PFNOSUPPORT = 46, // Protocol family not supported
-    AFNOSUPPORT = 47, // Address family not supported by protocol family
-    ADDRINUSE = 48, // Address already in use
-    ADDRNOTAVAIL = 49, // Can't assign requested address
-
-    // ipc/network software -- operational errors
-    NETDOWN = 50, // Network is down
-    NETUNREACH = 51, // Network is unreachable
-    NETRESET = 52, // Network dropped connection on reset
-    CONNABORTED = 53, // Software caused connection abort
-    CONNRESET = 54, // Connection reset by peer
-    NOBUFS = 55, // No buffer space available
-    ISCONN = 56, // Socket is already connected
-    NOTCONN = 57, // Socket is not connected
-    SHUTDOWN = 58, // Can't send after socket shutdown
-    TOOMANYREFS = 59, // Too many references: can't splice
-    TIMEDOUT = 60, // Operation timed out
-    CONNREFUSED = 61, // Connection refused
-
-    LOOP = 62, // Too many levels of symbolic links
-    NAMETOOLONG = 63, // File name too long
-
-    // should be rearranged
-    HOSTDOWN = 64, // Host is down
-    HOSTUNREACH = 65, // No route to host
-    NOTEMPTY = 66, // Directory not empty
-
-    // quotas & mush
-    PROCLIM = 67, // Too many processes
-    USERS = 68, // Too many users
-    DQUOT = 69, // Disc quota exceeded
-
-    // Network File System
-    STALE = 70, // Stale NFS file handle
-    REMOTE = 71, // Too many levels of remote in path
-    BADRPC = 72, // RPC struct is bad
-    RPCMISMATCH = 73, // RPC version wrong
-    PROGUNAVAIL = 74, // RPC prog. not avail
-    PROGMISMATCH = 75, // Program version wrong
-    PROCUNAVAIL = 76, // Bad procedure for program
-
-    NOLCK = 77, // No locks available
-    NOSYS = 78, // Function not implemented
-
-    FTYPE = 79, // Inappropriate file type or format
-    AUTH = 80, // Authentication error
-    NEEDAUTH = 81, // Need authenticator
-
-    // SystemV IPC
-    IDRM = 82, // Identifier removed
-    NOMSG = 83, // No message of desired type
-    OVERFLOW = 84, // Value too large to be stored in data type
-
-    // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
-    ILSEQ = 85, // Illegal byte sequence
-
-    // From IEEE Std 1003.1-2001
-    // Base, Realtime, Threads or Thread Priority Scheduling option errors
-    NOTSUP = 86, // Not supported
-
-    // Realtime option errors
-    CANCELED = 87, // Operation canceled
-
-    // Realtime, XSI STREAMS option errors
-    BADMSG = 88, // Bad or Corrupt message
-
-    // XSI STREAMS option errors
-    NODATA = 89, // No message available
-    NOSR = 90, // No STREAM resources
-    NOSTR = 91, // Not a STREAM
-    TIME = 92, // STREAM ioctl timeout
-
-    // File system extended attribute errors
-    NOATTR = 93, // Attribute not found
-
-    // Realtime, XSI STREAMS option errors
-    MULTIHOP = 94, // Multihop attempted
-    NOLINK = 95, // Link has been severed
-    PROTO = 96, // Protocol error
-
-    _,
-};
-
-pub const MINSIGSTKSZ = 8192;
-pub const SIGSTKSZ = MINSIGSTKSZ + 32768;
-
-pub const SS_ONSTACK = 1;
-pub const SS_DISABLE = 4;
-
-pub const stack_t = extern struct {
-    ss_sp: [*]u8,
-    ss_size: isize,
-    ss_flags: i32,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-pub const S_IFWHT = 0o160000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
-    return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
-    return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
-    return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
-    return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
-    return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
-    return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
-    return m & S_IFMT == S_IFSOCK;
-}
-
-pub fn S_IWHT(m: u32) bool {
-    return m & S_IFMT == S_IFWHT;
-}
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
-
-pub const HOST_NAME_MAX = 255;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = 0;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IP header
-pub const IPPROTO_IPV4 = 4;
-
-/// IP inside IP
-pub const IPPROTO_IPIP = 4;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// DCCP
-pub const IPPROTO_DCCP = 33;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// GRE encaps RFC 1701
-pub const IPPROTO_GRE = 47;
-
-/// encap. security payload
-pub const IPPROTO_ESP = 50;
-
-/// authentication header
-pub const IPPROTO_AH = 51;
-
-/// IP Mobility RFC 2004
-pub const IPPROTO_MOBILE = 55;
-
-/// IPv6 ICMP
-pub const IPPROTO_IPV6_ICMP = 58;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// Ethernet-in-IP
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// Protocol indep. multicast
-pub const IPPROTO_PIM = 103;
-
-/// IP Payload Comp. Protocol
-pub const IPPROTO_IPCOMP = 108;
-
-/// VRRP RFC 2338
-pub const IPPROTO_VRRP = 112;
-
-/// Common Address Resolution Protocol
-pub const IPPROTO_CARP = 112;
-
-/// L2TPv3
-pub const IPPROTO_L2TP = 115;
-
-/// SCTP
-pub const IPPROTO_SCTP = 132;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-pub const rlimit_resource = enum(c_int) {
-    CPU = 0,
-    FSIZE = 1,
-    DATA = 2,
-    STACK = 3,
-    CORE = 4,
-    RSS = 5,
-    MEMLOCK = 6,
-    NPROC = 7,
-    NOFILE = 8,
-    SBSIZE = 9,
-    VMEM = 10,
-    NTHR = 11,
-    _,
-
-    pub const AS: rlimit_resource = .VMEM;
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
-    /// Soft limit
-    cur: rlim_t,
-    /// Hard limit
-    max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = u32;
-
-pub const pollfd = extern struct {
-    fd: fd_t,
-    events: i16,
-    revents: i16,
-};
-
-/// Testable events (may be specified in events field).
-pub const POLLIN = 0x0001;
-pub const POLLPRI = 0x0002;
-pub const POLLOUT = 0x0004;
-pub const POLLRDNORM = 0x0040;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x0080;
-pub const POLLWRBAND = 0x0100;
-
-/// Non-testable events (may not be specified in events field).
-pub const POLLERR = 0x0008;
-pub const POLLHUP = 0x0010;
-pub const POLLNVAL = 0x0020;
lib/std/os/bits/openbsd.zig
@@ -1,1328 +0,0 @@
-const std = @import("../../std.zig");
-const builtin = std.builtin;
-const maxInt = std.math.maxInt;
-
-pub const blkcnt_t = i64;
-pub const blksize_t = i32;
-pub const clock_t = i64;
-pub const dev_t = i32;
-pub const fd_t = c_int;
-pub const gid_t = u32;
-pub const ino_t = u64;
-pub const mode_t = u32;
-pub const nlink_t = u32;
-pub const off_t = i64;
-pub const pid_t = i32;
-pub const socklen_t = u32;
-pub const time_t = i64;
-pub const uid_t = u32;
-
-/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
-pub const Kevent = extern struct {
-    ident: usize,
-    filter: c_short,
-    flags: u16,
-    fflags: c_uint,
-    data: i64,
-    udata: usize,
-};
-
-// Modes and flags for dlopen()
-// include/dlfcn.h
-
-/// Bind function calls lazily.
-pub const RTLD_LAZY = 1;
-
-/// Bind function calls immediately.
-pub const RTLD_NOW = 2;
-
-/// Make symbols globally available.
-pub const RTLD_GLOBAL = 0x100;
-
-/// Opposite of RTLD_GLOBAL, and the default.
-pub const RTLD_LOCAL = 0x000;
-
-/// Trace loaded objects and exit.
-pub const RTLD_TRACE = 0x200;
-
-pub const dl_phdr_info = extern struct {
-    dlpi_addr: std.elf.Addr,
-    dlpi_name: ?[*:0]const u8,
-    dlpi_phdr: [*]std.elf.Phdr,
-    dlpi_phnum: std.elf.Half,
-};
-
-pub const Flock = extern struct {
-    l_start: off_t,
-    l_len: off_t,
-    l_pid: pid_t,
-    l_type: c_short,
-    l_whence: c_short,
-};
-
-pub const addrinfo = extern struct {
-    flags: c_int,
-    family: c_int,
-    socktype: c_int,
-    protocol: c_int,
-    addrlen: socklen_t,
-    addr: ?*sockaddr,
-    canonname: ?[*:0]u8,
-    next: ?*addrinfo,
-};
-
-pub const EAI = enum(c_int) {
-    /// address family for hostname not supported
-    ADDRFAMILY = -9,
-
-    /// name could not be resolved at this time
-    AGAIN = -3,
-
-    /// flags parameter had an invalid value
-    BADFLAGS = -1,
-
-    /// non-recoverable failure in name resolution
-    FAIL = -4,
-
-    /// address family not recognized
-    FAMILY = -6,
-
-    /// memory allocation failure
-    MEMORY = -10,
-
-    /// no address associated with hostname
-    NODATA = -5,
-
-    /// name does not resolve
-    NONAME = -2,
-
-    /// service not recognized for socket type
-    SERVICE = -8,
-
-    /// intended socket type was not recognized
-    SOCKTYPE = -7,
-
-    /// system error returned in errno
-    SYSTEM = -11,
-
-    /// invalid value for hints
-    BADHINTS = -12,
-
-    /// resolved protocol is unknown
-    PROTOCOL = -13,
-
-    /// argument buffer overflow
-    OVERFLOW = -14,
-
-    _,
-};
-
-pub const EAI_MAX = 15;
-
-pub const msghdr = extern struct {
-    /// optional address
-    msg_name: ?*sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec,
-
-    /// # elements in msg_iov
-    msg_iovlen: c_uint,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: c_int,
-};
-
-pub const msghdr_const = extern struct {
-    /// optional address
-    msg_name: ?*const sockaddr,
-
-    /// size of address
-    msg_namelen: socklen_t,
-
-    /// scatter/gather array
-    msg_iov: [*]iovec_const,
-
-    /// # elements in msg_iov
-    msg_iovlen: c_uint,
-
-    /// ancillary data
-    msg_control: ?*c_void,
-
-    /// ancillary data buffer len
-    msg_controllen: socklen_t,
-
-    /// flags on received message
-    msg_flags: c_int,
-};
-
-pub const libc_stat = extern struct {
-    mode: mode_t,
-    dev: dev_t,
-    ino: ino_t,
-    nlink: nlink_t,
-    uid: uid_t,
-    gid: gid_t,
-    rdev: dev_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-    size: off_t,
-    blocks: blkcnt_t,
-    blksize: blksize_t,
-    flags: u32,
-    gen: u32,
-    birthtim: timespec,
-
-    pub fn atime(self: @This()) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: @This()) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: @This()) timespec {
-        return self.ctim;
-    }
-};
-
-pub const timespec = extern struct {
-    tv_sec: time_t,
-    tv_nsec: c_long,
-};
-
-pub const timeval = extern struct {
-    tv_sec: time_t,
-    tv_usec: c_long,
-};
-
-pub const timezone = extern struct {
-    tz_minuteswest: c_int,
-    tz_dsttime: c_int,
-};
-
-pub const MAXNAMLEN = 255;
-
-pub const dirent = extern struct {
-    d_fileno: ino_t,
-    d_off: off_t,
-    d_reclen: u16,
-    d_type: u8,
-    d_namlen: u8,
-    __d_padding: [4]u8,
-    d_name: [MAXNAMLEN + 1]u8,
-
-    pub fn reclen(self: dirent) u16 {
-        return self.d_reclen;
-    }
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern struct {
-    /// total length
-    len: u8,
-
-    /// address family
-    family: sa_family_t,
-
-    /// actually longer; address value
-    data: [14]u8,
-};
-
-pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage;
-
-pub const sockaddr_in = extern struct {
-    len: u8 = @sizeOf(sockaddr_in),
-    family: sa_family_t = AF_INET,
-    port: in_port_t,
-    addr: u32,
-    zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
-};
-
-pub const sockaddr_in6 = extern struct {
-    len: u8 = @sizeOf(sockaddr_in6),
-    family: sa_family_t = AF_INET6,
-    port: in_port_t,
-    flowinfo: u32,
-    addr: [16]u8,
-    scope_id: u32,
-};
-
-/// Definitions for UNIX IPC domain.
-pub const sockaddr_un = extern struct {
-    /// total sockaddr length
-    len: u8 = @sizeOf(sockaddr_un),
-
-    /// AF_LOCAL
-    family: sa_family_t = AF_LOCAL,
-
-    /// path name
-    path: [104]u8,
-};
-
-/// get address to use bind()
-pub const AI_PASSIVE = 1;
-
-/// fill ai_canonname
-pub const AI_CANONNAME = 2;
-
-/// prevent host name resolution
-pub const AI_NUMERICHOST = 4;
-
-/// prevent service name resolution
-pub const AI_NUMERICSERV = 16;
-
-/// only if any address is assigned
-pub const AI_ADDRCONFIG = 64;
-
-pub const PATH_MAX = 1024;
-pub const IOV_MAX = 1024;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_PROCESS_CPUTIME_ID = 2;
-pub const CLOCK_MONOTONIC = 3;
-pub const CLOCK_THREAD_CPUTIME_ID = 4;
-
-pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
-pub const MAP_SHARED = 0x0001;
-pub const MAP_PRIVATE = 0x0002;
-pub const MAP_FIXED = 0x0010;
-pub const MAP_RENAME = 0;
-pub const MAP_NORESERVE = 0;
-pub const MAP_INHERIT = 0;
-pub const MAP_HASSEMAPHORE = 0;
-pub const MAP_TRYFIXED = 0;
-
-pub const MAP_FILE = 0;
-pub const MAP_ANON = 0x1000;
-pub const MAP_ANONYMOUS = MAP_ANON;
-pub const MAP_STACK = 0x4000;
-pub const MAP_CONCEAL = 0x8000;
-
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WCONTINUED = 8;
-
-pub const SA_ONSTACK = 0x0001;
-pub const SA_RESTART = 0x0002;
-pub const SA_RESETHAND = 0x0004;
-pub const SA_NOCLDSTOP = 0x0008;
-pub const SA_NODEFER = 0x0010;
-pub const SA_NOCLDWAIT = 0x0020;
-pub const SA_SIGINFO = 0x0040;
-
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGTRAP = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGEMT = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGBUS = 10;
-pub const SIGSEGV = 11;
-pub const SIGSYS = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGURG = 16;
-pub const SIGSTOP = 17;
-pub const SIGTSTP = 18;
-pub const SIGCONT = 19;
-pub const SIGCHLD = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGIO = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGINFO = 29;
-pub const SIGUSR1 = 30;
-pub const SIGUSR2 = 31;
-pub const SIGPWR = 32;
-
-// access function
-pub const F_OK = 0; // test for existence of file
-pub const X_OK = 1; // test for execute or search permission
-pub const W_OK = 2; // test for write permission
-pub const R_OK = 4; // test for read permission
-
-/// open for reading only
-pub const O_RDONLY = 0x00000000;
-
-/// open for writing only
-pub const O_WRONLY = 0x00000001;
-
-/// open for reading and writing
-pub const O_RDWR = 0x00000002;
-
-/// mask for above modes
-pub const O_ACCMODE = 0x00000003;
-
-/// no delay
-pub const O_NONBLOCK = 0x00000004;
-
-/// set append mode
-pub const O_APPEND = 0x00000008;
-
-/// open with shared file lock
-pub const O_SHLOCK = 0x00000010;
-
-/// open with exclusive file lock
-pub const O_EXLOCK = 0x00000020;
-
-/// signal pgrp when data ready
-pub const O_ASYNC = 0x00000040;
-
-/// synchronous writes
-pub const O_SYNC = 0x00000080;
-
-/// don't follow symlinks on the last
-pub const O_NOFOLLOW = 0x00000100;
-
-/// create if nonexistent
-pub const O_CREAT = 0x00000200;
-
-/// truncate to zero length
-pub const O_TRUNC = 0x00000400;
-
-/// error if already exists
-pub const O_EXCL = 0x00000800;
-
-/// don't assign controlling terminal
-pub const O_NOCTTY = 0x00008000;
-
-/// write: I/O data completion
-pub const O_DSYNC = O_SYNC;
-
-/// read: I/O completion as for write
-pub const O_RSYNC = O_SYNC;
-
-/// fail if not a directory
-pub const O_DIRECTORY = 0x20000;
-
-/// set close on exec
-pub const O_CLOEXEC = 0x10000;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
-
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-pub const F_RDLCK = 1;
-pub const F_UNLCK = 2;
-pub const F_WRLCK = 3;
-
-pub const LOCK_SH = 0x01;
-pub const LOCK_EX = 0x02;
-pub const LOCK_NB = 0x04;
-pub const LOCK_UN = 0x08;
-
-pub const FD_CLOEXEC = 1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 1;
-pub const SIG_UNBLOCK = 2;
-pub const SIG_SETMASK = 3;
-
-pub const SOCK_STREAM = 1;
-pub const SOCK_DGRAM = 2;
-pub const SOCK_RAW = 3;
-pub const SOCK_RDM = 4;
-pub const SOCK_SEQPACKET = 5;
-
-pub const SOCK_CLOEXEC = 0x8000;
-pub const SOCK_NONBLOCK = 0x4000;
-
-pub const SO_DEBUG = 0x0001;
-pub const SO_ACCEPTCONN = 0x0002;
-pub const SO_REUSEADDR = 0x0004;
-pub const SO_KEEPALIVE = 0x0008;
-pub const SO_DONTROUTE = 0x0010;
-pub const SO_BROADCAST = 0x0020;
-pub const SO_USELOOPBACK = 0x0040;
-pub const SO_LINGER = 0x0080;
-pub const SO_OOBINLINE = 0x0100;
-pub const SO_REUSEPORT = 0x0200;
-pub const SO_TIMESTAMP = 0x0800;
-pub const SO_BINDANY = 0x1000;
-pub const SO_ZEROIZE = 0x2000;
-pub const SO_SNDBUF = 0x1001;
-pub const SO_RCVBUF = 0x1002;
-pub const SO_SNDLOWAT = 0x1003;
-pub const SO_RCVLOWAT = 0x1004;
-pub const SO_SNDTIMEO = 0x1005;
-pub const SO_RCVTIMEO = 0x1006;
-pub const SO_ERROR = 0x1007;
-pub const SO_TYPE = 0x1008;
-pub const SO_NETPROC = 0x1020;
-pub const SO_RTABLE = 0x1021;
-pub const SO_PEERCRED = 0x1022;
-pub const SO_SPLICE = 0x1023;
-pub const SO_DOMAIN = 0x1024;
-pub const SO_PROTOCOL = 0x1025;
-
-pub const SOL_SOCKET = 0xffff;
-
-pub const PF_UNSPEC = AF_UNSPEC;
-pub const PF_LOCAL = AF_LOCAL;
-pub const PF_UNIX = AF_UNIX;
-pub const PF_INET = AF_INET;
-pub const PF_APPLETALK = AF_APPLETALK;
-pub const PF_INET6 = AF_INET6;
-pub const PF_DECnet = AF_DECnet;
-pub const PF_KEY = AF_KEY;
-pub const PF_ROUTE = AF_ROUTE;
-pub const PF_SNA = AF_SNA;
-pub const PF_MPLS = AF_MPLS;
-pub const PF_BLUETOOTH = AF_BLUETOOTH;
-pub const PF_ISDN = AF_ISDN;
-pub const PF_MAX = AF_MAX;
-
-pub const AF_UNSPEC = 0;
-pub const AF_UNIX = 1;
-pub const AF_LOCAL = AF_UNIX;
-pub const AF_INET = 2;
-pub const AF_APPLETALK = 16;
-pub const AF_INET6 = 24;
-pub const AF_KEY = 30;
-pub const AF_ROUTE = 17;
-pub const AF_SNA = 11;
-pub const AF_MPLS = 33;
-pub const AF_BLUETOOTH = 32;
-pub const AF_ISDN = 26;
-pub const AF_MAX = 36;
-
-pub const DT_UNKNOWN = 0;
-pub const DT_FIFO = 1;
-pub const DT_CHR = 2;
-pub const DT_DIR = 4;
-pub const DT_BLK = 6;
-pub const DT_REG = 8;
-pub const DT_LNK = 10;
-pub const DT_SOCK = 12;
-pub const DT_WHT = 14; // XXX
-
-pub const EV_ADD = 0x0001;
-pub const EV_DELETE = 0x0002;
-pub const EV_ENABLE = 0x0004;
-pub const EV_DISABLE = 0x0008;
-pub const EV_ONESHOT = 0x0010;
-pub const EV_CLEAR = 0x0020;
-pub const EV_RECEIPT = 0x0040;
-pub const EV_DISPATCH = 0x0080;
-pub const EV_FLAG1 = 0x2000;
-pub const EV_ERROR = 0x4000;
-pub const EV_EOF = 0x8000;
-
-pub const EVFILT_READ = -1;
-pub const EVFILT_WRITE = -2;
-pub const EVFILT_AIO = -3;
-pub const EVFILT_VNODE = -4;
-pub const EVFILT_PROC = -5;
-pub const EVFILT_SIGNAL = -6;
-pub const EVFILT_TIMER = -7;
-pub const EVFILT_EXCEPT = -9;
-
-// data/hint flags for EVFILT_{READ|WRITE}
-pub const NOTE_LOWAT = 0x0001;
-pub const NOTE_EOF = 0x0002;
-
-// data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE}
-pub const NOTE_OOB = 0x0004;
-
-// data/hint flags for EVFILT_VNODE
-pub const NOTE_DELETE = 0x0001;
-pub const NOTE_WRITE = 0x0002;
-pub const NOTE_EXTEND = 0x0004;
-pub const NOTE_ATTRIB = 0x0008;
-pub const NOTE_LINK = 0x0010;
-pub const NOTE_RENAME = 0x0020;
-pub const NOTE_REVOKE = 0x0040;
-pub const NOTE_TRUNCATE = 0x0080;
-
-// data/hint flags for EVFILT_PROC
-pub const NOTE_EXIT = 0x80000000;
-pub const NOTE_FORK = 0x40000000;
-pub const NOTE_EXEC = 0x20000000;
-pub const NOTE_PDATAMASK = 0x000fffff;
-pub const NOTE_PCTRLMASK = 0xf0000000;
-pub const NOTE_TRACK = 0x00000001;
-pub const NOTE_TRACKERR = 0x00000002;
-pub const NOTE_CHILD = 0x00000004;
-
-// data/hint flags for EVFILT_DEVICE
-pub const NOTE_CHANGE = 0x00000001;
-
-pub const TIOCCBRK = 0x2000747a;
-pub const TIOCCDTR = 0x20007478;
-pub const TIOCCONS = 0x80047462;
-pub const TIOCDCDTIMESTAMP = 0x40107458;
-pub const TIOCDRAIN = 0x2000745e;
-pub const TIOCEXCL = 0x2000740d;
-pub const TIOCEXT = 0x80047460;
-pub const TIOCFLAG_CDTRCTS = 0x10;
-pub const TIOCFLAG_CLOCAL = 0x2;
-pub const TIOCFLAG_CRTSCTS = 0x4;
-pub const TIOCFLAG_MDMBUF = 0x8;
-pub const TIOCFLAG_SOFTCAR = 0x1;
-pub const TIOCFLUSH = 0x80047410;
-pub const TIOCGETA = 0x402c7413;
-pub const TIOCGETD = 0x4004741a;
-pub const TIOCGFLAGS = 0x4004745d;
-pub const TIOCGLINED = 0x40207442;
-pub const TIOCGPGRP = 0x40047477;
-pub const TIOCGQSIZE = 0x40047481;
-pub const TIOCGRANTPT = 0x20007447;
-pub const TIOCGSID = 0x40047463;
-pub const TIOCGSIZE = 0x40087468;
-pub const TIOCGWINSZ = 0x40087468;
-pub const TIOCMBIC = 0x8004746b;
-pub const TIOCMBIS = 0x8004746c;
-pub const TIOCMGET = 0x4004746a;
-pub const TIOCMSET = 0x8004746d;
-pub const TIOCM_CAR = 0x40;
-pub const TIOCM_CD = 0x40;
-pub const TIOCM_CTS = 0x20;
-pub const TIOCM_DSR = 0x100;
-pub const TIOCM_DTR = 0x2;
-pub const TIOCM_LE = 0x1;
-pub const TIOCM_RI = 0x80;
-pub const TIOCM_RNG = 0x80;
-pub const TIOCM_RTS = 0x4;
-pub const TIOCM_SR = 0x10;
-pub const TIOCM_ST = 0x8;
-pub const TIOCNOTTY = 0x20007471;
-pub const TIOCNXCL = 0x2000740e;
-pub const TIOCOUTQ = 0x40047473;
-pub const TIOCPKT = 0x80047470;
-pub const TIOCPKT_DATA = 0x0;
-pub const TIOCPKT_DOSTOP = 0x20;
-pub const TIOCPKT_FLUSHREAD = 0x1;
-pub const TIOCPKT_FLUSHWRITE = 0x2;
-pub const TIOCPKT_IOCTL = 0x40;
-pub const TIOCPKT_NOSTOP = 0x10;
-pub const TIOCPKT_START = 0x8;
-pub const TIOCPKT_STOP = 0x4;
-pub const TIOCPTMGET = 0x40287446;
-pub const TIOCPTSNAME = 0x40287448;
-pub const TIOCRCVFRAME = 0x80087445;
-pub const TIOCREMOTE = 0x80047469;
-pub const TIOCSBRK = 0x2000747b;
-pub const TIOCSCTTY = 0x20007461;
-pub const TIOCSDTR = 0x20007479;
-pub const TIOCSETA = 0x802c7414;
-pub const TIOCSETAF = 0x802c7416;
-pub const TIOCSETAW = 0x802c7415;
-pub const TIOCSETD = 0x8004741b;
-pub const TIOCSFLAGS = 0x8004745c;
-pub const TIOCSIG = 0x2000745f;
-pub const TIOCSLINED = 0x80207443;
-pub const TIOCSPGRP = 0x80047476;
-pub const TIOCSQSIZE = 0x80047480;
-pub const TIOCSSIZE = 0x80087467;
-pub const TIOCSTART = 0x2000746e;
-pub const TIOCSTAT = 0x80047465;
-pub const TIOCSTI = 0x80017472;
-pub const TIOCSTOP = 0x2000746f;
-pub const TIOCSWINSZ = 0x80087467;
-pub const TIOCUCNTL = 0x80047466;
-pub const TIOCXMTFRAME = 0x80087444;
-
-pub fn WEXITSTATUS(s: u32) u8 {
-    return @intCast(u8, (s >> 8) & 0xff);
-}
-pub fn WTERMSIG(s: u32) u32 {
-    return (s & 0x7f);
-}
-pub fn WSTOPSIG(s: u32) u32 {
-    return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: u32) bool {
-    return WTERMSIG(s) == 0;
-}
-
-pub fn WIFCONTINUED(s: u32) bool {
-    return ((s & 0o177777) == 0o177777);
-}
-
-pub fn WIFSTOPPED(s: u32) bool {
-    return (s & 0xff == 0o177);
-}
-
-pub fn WIFSIGNALED(s: u32) bool {
-    return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0);
-}
-
-pub const winsize = extern struct {
-    ws_row: c_ushort,
-    ws_col: c_ushort,
-    ws_xpixel: c_ushort,
-    ws_ypixel: c_ushort,
-};
-
-const NSIG = 33;
-
-pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
-pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
-pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
-pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
-pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = extern struct {
-    pub const handler_fn = fn (c_int) callconv(.C) void;
-    pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
-
-    /// signal handler
-    handler: extern union {
-        handler: ?handler_fn,
-        sigaction: ?sigaction_fn,
-    },
-    /// signal mask to apply
-    mask: sigset_t,
-    /// signal options
-    flags: c_uint,
-};
-
-pub const sigval = extern union {
-    int: c_int,
-    ptr: ?*c_void,
-};
-
-pub const siginfo_t = extern struct {
-    signo: c_int,
-    code: c_int,
-    errno: c_int,
-    data: extern union {
-        proc: extern struct {
-            pid: pid_t,
-            pdata: extern union {
-                kill: extern struct {
-                    uid: uid_t,
-                    value: sigval,
-                },
-                cld: extern struct {
-                    utime: clock_t,
-                    stime: clock_t,
-                    status: c_int,
-                },
-            },
-        },
-        fault: extern struct {
-            addr: ?*c_void,
-            trapno: c_int,
-        },
-        __pad: [128 - 3 * @sizeOf(c_int)]u8,
-    },
-};
-
-comptime {
-    if (@sizeOf(usize) == 4)
-        std.debug.assert(@sizeOf(siginfo_t) == 128)
-    else
-        // Take into account the padding between errno and data fields.
-        std.debug.assert(@sizeOf(siginfo_t) == 136);
-}
-
-pub usingnamespace switch (builtin.target.cpu.arch) {
-    .x86_64 => struct {
-        pub const ucontext_t = extern struct {
-            sc_rdi: c_long,
-            sc_rsi: c_long,
-            sc_rdx: c_long,
-            sc_rcx: c_long,
-            sc_r8: c_long,
-            sc_r9: c_long,
-            sc_r10: c_long,
-            sc_r11: c_long,
-            sc_r12: c_long,
-            sc_r13: c_long,
-            sc_r14: c_long,
-            sc_r15: c_long,
-            sc_rbp: c_long,
-            sc_rbx: c_long,
-            sc_rax: c_long,
-            sc_gs: c_long,
-            sc_fs: c_long,
-            sc_es: c_long,
-            sc_ds: c_long,
-            sc_trapno: c_long,
-            sc_err: c_long,
-            sc_rip: c_long,
-            sc_cs: c_long,
-            sc_rflags: c_long,
-            sc_rsp: c_long,
-            sc_ss: c_long,
-
-            sc_fpstate: fxsave64,
-            __sc_unused: c_int,
-            sc_mask: c_int,
-            sc_cookie: c_long,
-        };
-
-        pub const fxsave64 = packed struct {
-            fx_fcw: u16,
-            fx_fsw: u16,
-            fx_ftw: u8,
-            fx_unused1: u8,
-            fx_fop: u16,
-            fx_rip: u64,
-            fx_rdp: u64,
-            fx_mxcsr: u32,
-            fx_mxcsr_mask: u32,
-            fx_st: [8][2]u64,
-            fx_xmm: [16][2]u64,
-            fx_unused3: [96]u8,
-        };
-    },
-    else => struct {},
-};
-
-pub const sigset_t = c_uint;
-pub const empty_sigset: sigset_t = 0;
-
-pub const E = enum(u16) {
-    /// No error occurred.
-    SUCCESS = 0,
-    PERM = 1, // Operation not permitted
-    NOENT = 2, // No such file or directory
-    SRCH = 3, // No such process
-    INTR = 4, // Interrupted system call
-    IO = 5, // Input/output error
-    NXIO = 6, // Device not configured
-    @"2BIG" = 7, // Argument list too long
-    NOEXEC = 8, // Exec format error
-    BADF = 9, // Bad file descriptor
-    CHILD = 10, // No child processes
-    DEADLK = 11, // Resource deadlock avoided
-    // 11 was AGAIN
-    NOMEM = 12, // Cannot allocate memory
-    ACCES = 13, // Permission denied
-    FAULT = 14, // Bad address
-    NOTBLK = 15, // Block device required
-    BUSY = 16, // Device busy
-    EXIST = 17, // File exists
-    XDEV = 18, // Cross-device link
-    NODEV = 19, // Operation not supported by device
-    NOTDIR = 20, // Not a directory
-    ISDIR = 21, // Is a directory
-    INVAL = 22, // Invalid argument
-    NFILE = 23, // Too many open files in system
-    MFILE = 24, // Too many open files
-    NOTTY = 25, // Inappropriate ioctl for device
-    TXTBSY = 26, // Text file busy
-    FBIG = 27, // File too large
-    NOSPC = 28, // No space left on device
-    SPIPE = 29, // Illegal seek
-    ROFS = 30, // Read-only file system
-    MLINK = 31, // Too many links
-    PIPE = 32, // Broken pipe
-
-    // math software
-    DOM = 33, // Numerical argument out of domain
-    RANGE = 34, // Result too large or too small
-
-    // non-blocking and interrupt i/o
-    // also: WOULDBLOCK: operation would block
-    AGAIN = 35, // Resource temporarily unavailable
-    INPROGRESS = 36, // Operation now in progress
-    ALREADY = 37, // Operation already in progress
-
-    // ipc/network software -- argument errors
-    NOTSOCK = 38, // Socket operation on non-socket
-    DESTADDRREQ = 39, // Destination address required
-    MSGSIZE = 40, // Message too long
-    PROTOTYPE = 41, // Protocol wrong type for socket
-    NOPROTOOPT = 42, // Protocol option not available
-    PROTONOSUPPORT = 43, // Protocol not supported
-    SOCKTNOSUPPORT = 44, // Socket type not supported
-    OPNOTSUPP = 45, // Operation not supported
-    PFNOSUPPORT = 46, // Protocol family not supported
-    AFNOSUPPORT = 47, // Address family not supported by protocol family
-    ADDRINUSE = 48, // Address already in use
-    ADDRNOTAVAIL = 49, // Can't assign requested address
-
-    // ipc/network software -- operational errors
-    NETDOWN = 50, // Network is down
-    NETUNREACH = 51, // Network is unreachable
-    NETRESET = 52, // Network dropped connection on reset
-    CONNABORTED = 53, // Software caused connection abort
-    CONNRESET = 54, // Connection reset by peer
-    NOBUFS = 55, // No buffer space available
-    ISCONN = 56, // Socket is already connected
-    NOTCONN = 57, // Socket is not connected
-    SHUTDOWN = 58, // Can't send after socket shutdown
-    TOOMANYREFS = 59, // Too many references: can't splice
-    TIMEDOUT = 60, // Operation timed out
-    CONNREFUSED = 61, // Connection refused
-
-    LOOP = 62, // Too many levels of symbolic links
-    NAMETOOLONG = 63, // File name too long
-
-    // should be rearranged
-    HOSTDOWN = 64, // Host is down
-    HOSTUNREACH = 65, // No route to host
-    NOTEMPTY = 66, // Directory not empty
-
-    // quotas & mush
-    PROCLIM = 67, // Too many processes
-    USERS = 68, // Too many users
-    DQUOT = 69, // Disc quota exceeded
-
-    // Network File System
-    STALE = 70, // Stale NFS file handle
-    REMOTE = 71, // Too many levels of remote in path
-    BADRPC = 72, // RPC struct is bad
-    RPCMISMATCH = 73, // RPC version wrong
-    PROGUNAVAIL = 74, // RPC prog. not avail
-    PROGMISMATCH = 75, // Program version wrong
-    PROCUNAVAIL = 76, // Bad procedure for program
-
-    NOLCK = 77, // No locks available
-    NOSYS = 78, // Function not implemented
-
-    FTYPE = 79, // Inappropriate file type or format
-    AUTH = 80, // Authentication error
-    NEEDAUTH = 81, // Need authenticator
-    IPSEC = 82, // IPsec processing failure
-    NOATTR = 83, // Attribute not found
-
-    // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
-    ILSEQ = 84, // Illegal byte sequence
-
-    NOMEDIUM = 85, // No medium found
-    MEDIUMTYPE = 86, // Wrong medium type
-    OVERFLOW = 87, // Value too large to be stored in data type
-    CANCELED = 88, // Operation canceled
-    IDRM = 89, // Identifier removed
-    NOMSG = 90, // No message of desired type
-    NOTSUP = 91, // Not supported
-    BADMSG = 92, // Bad or Corrupt message
-    NOTRECOVERABLE = 93, // State not recoverable
-    OWNERDEAD = 94, // Previous owner died
-    PROTO = 95, // Protocol error
-
-    _,
-};
-
-const _MAX_PAGE_SHIFT = switch (builtin.target.cpu.arch) {
-    .i386 => 12,
-    .sparcv9 => 13,
-};
-pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT;
-pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4;
-
-pub const SS_ONSTACK = 0x0001;
-pub const SS_DISABLE = 0x0004;
-
-pub const stack_t = extern struct {
-    ss_sp: [*]u8,
-    ss_size: usize,
-    ss_flags: c_int,
-};
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFIFO = 0o010000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFDIR = 0o040000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFLNK = 0o120000;
-pub const S_IFSOCK = 0o140000;
-
-pub const S_ISUID = 0o4000;
-pub const S_ISGID = 0o2000;
-pub const S_ISVTX = 0o1000;
-pub const S_IRWXU = 0o700;
-pub const S_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXG = 0o070;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXO = 0o007;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-
-pub fn S_ISFIFO(m: u32) bool {
-    return m & S_IFMT == S_IFIFO;
-}
-
-pub fn S_ISCHR(m: u32) bool {
-    return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISDIR(m: u32) bool {
-    return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
-    return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISREG(m: u32) bool {
-    return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISLNK(m: u32) bool {
-    return m & S_IFMT == S_IFLNK;
-}
-
-pub fn S_ISSOCK(m: u32) bool {
-    return m & S_IFMT == S_IFSOCK;
-}
-
-/// Magic value that specify the use of the current working directory
-/// to determine the target of relative file paths in the openat() and
-/// similar syscalls.
-pub const AT_FDCWD = -100;
-
-/// Check access using effective user and group ID
-pub const AT_EACCESS = 0x01;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x02;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x04;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x08;
-
-pub const HOST_NAME_MAX = 255;
-
-/// dummy for IP
-pub const IPPROTO_IP = 0;
-
-/// IP6 hop-by-hop options
-pub const IPPROTO_HOPOPTS = IPPROTO_IP;
-
-/// control message protocol
-pub const IPPROTO_ICMP = 1;
-
-/// group mgmt protocol
-pub const IPPROTO_IGMP = 2;
-
-/// gateway^2 (deprecated)
-pub const IPPROTO_GGP = 3;
-
-/// IP header
-pub const IPPROTO_IPV4 = IPPROTO_IPIP;
-
-/// IP inside IP
-pub const IPPROTO_IPIP = 4;
-
-/// tcp
-pub const IPPROTO_TCP = 6;
-
-/// exterior gateway protocol
-pub const IPPROTO_EGP = 8;
-
-/// pup
-pub const IPPROTO_PUP = 12;
-
-/// user datagram protocol
-pub const IPPROTO_UDP = 17;
-
-/// xns idp
-pub const IPPROTO_IDP = 22;
-
-/// tp-4 w/ class negotiation
-pub const IPPROTO_TP = 29;
-
-/// IP6 header
-pub const IPPROTO_IPV6 = 41;
-
-/// IP6 routing header
-pub const IPPROTO_ROUTING = 43;
-
-/// IP6 fragmentation header
-pub const IPPROTO_FRAGMENT = 44;
-
-/// resource reservation
-pub const IPPROTO_RSVP = 46;
-
-/// GRE encaps RFC 1701
-pub const IPPROTO_GRE = 47;
-
-/// encap. security payload
-pub const IPPROTO_ESP = 50;
-
-/// authentication header
-pub const IPPROTO_AH = 51;
-
-/// IP Mobility RFC 2004
-pub const IPPROTO_MOBILE = 55;
-
-/// IPv6 ICMP
-pub const IPPROTO_IPV6_ICMP = 58;
-
-/// ICMP6
-pub const IPPROTO_ICMPV6 = 58;
-
-/// IP6 no next header
-pub const IPPROTO_NONE = 59;
-
-/// IP6 destination option
-pub const IPPROTO_DSTOPTS = 60;
-
-/// ISO cnlp
-pub const IPPROTO_EON = 80;
-
-/// Ethernet-in-IP
-pub const IPPROTO_ETHERIP = 97;
-
-/// encapsulation header
-pub const IPPROTO_ENCAP = 98;
-
-/// Protocol indep. multicast
-pub const IPPROTO_PIM = 103;
-
-/// IP Payload Comp. Protocol
-pub const IPPROTO_IPCOMP = 108;
-
-/// VRRP RFC 2338
-pub const IPPROTO_VRRP = 112;
-
-/// Common Address Resolution Protocol
-pub const IPPROTO_CARP = 112;
-
-/// PFSYNC
-pub const IPPROTO_PFSYNC = 240;
-
-/// raw IP packet
-pub const IPPROTO_RAW = 255;
-
-pub const rlimit_resource = enum(c_int) {
-    CPU,
-    FSIZE,
-    DATA,
-    STACK,
-    CORE,
-    RSS,
-    MEMLOCK,
-    NPROC,
-    NOFILE,
-
-    _,
-};
-
-pub const rlim_t = u64;
-
-/// No limit
-pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1;
-
-pub const RLIM_SAVED_MAX = RLIM_INFINITY;
-pub const RLIM_SAVED_CUR = RLIM_INFINITY;
-
-pub const rlimit = extern struct {
-    /// Soft limit
-    cur: rlim_t,
-    /// Hard limit
-    max: rlim_t,
-};
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 2;
-
-pub const nfds_t = c_uint;
-
-pub const pollfd = extern struct {
-    fd: fd_t,
-    events: c_short,
-    revents: c_short,
-};
-
-pub const POLLIN = 0x0001;
-pub const POLLPRI = 0x0002;
-pub const POLLOUT = 0x0004;
-pub const POLLERR = 0x0008;
-pub const POLLHUP = 0x0010;
-pub const POLLNVAL = 0x0020;
-pub const POLLRDNORM = 0x0040;
-pub const POLLNORM = POLLRDNORM;
-pub const POLLWRNORM = POLLOUT;
-pub const POLLRDBAND = 0x0080;
-pub const POLLWRBAND = 0x0100;
-
-// sysctl mib
-pub const CTL_UNSPEC = 0;
-pub const CTL_KERN = 1;
-pub const CTL_VM = 2;
-pub const CTL_FS = 3;
-pub const CTL_NET = 4;
-pub const CTL_DEBUG = 5;
-pub const CTL_HW = 6;
-pub const CTL_MACHDEP = 7;
-
-pub const CTL_DDB = 9;
-pub const CTL_VFS = 10;
-
-pub const KERN_OSTYPE = 1;
-pub const KERN_OSRELEASE = 2;
-pub const KERN_OSREV = 3;
-pub const KERN_VERSION = 4;
-pub const KERN_MAXVNODES = 5;
-pub const KERN_MAXPROC = 6;
-pub const KERN_MAXFILES = 7;
-pub const KERN_ARGMAX = 8;
-pub const KERN_SECURELVL = 9;
-pub const KERN_HOSTNAME = 10;
-pub const KERN_HOSTID = 11;
-pub const KERN_CLOCKRATE = 12;
-
-pub const KERN_PROF = 16;
-pub const KERN_POSIX1 = 17;
-pub const KERN_NGROUPS = 18;
-pub const KERN_JOB_CONTROL = 19;
-pub const KERN_SAVED_IDS = 20;
-pub const KERN_BOOTTIME = 21;
-pub const KERN_DOMAINNAME = 22;
-pub const KERN_MAXPARTITIONS = 23;
-pub const KERN_RAWPARTITION = 24;
-pub const KERN_MAXTHREAD = 25;
-pub const KERN_NTHREADS = 26;
-pub const KERN_OSVERSION = 27;
-pub const KERN_SOMAXCONN = 28;
-pub const KERN_SOMINCONN = 29;
-
-pub const KERN_NOSUIDCOREDUMP = 32;
-pub const KERN_FSYNC = 33;
-pub const KERN_SYSVMSG = 34;
-pub const KERN_SYSVSEM = 35;
-pub const KERN_SYSVSHM = 36;
-
-pub const KERN_MSGBUFSIZE = 38;
-pub const KERN_MALLOCSTATS = 39;
-pub const KERN_CPTIME = 40;
-pub const KERN_NCHSTATS = 41;
-pub const KERN_FORKSTAT = 42;
-pub const KERN_NSELCOLL = 43;
-pub const KERN_TTY = 44;
-pub const KERN_CCPU = 45;
-pub const KERN_FSCALE = 46;
-pub const KERN_NPROCS = 47;
-pub const KERN_MSGBUF = 48;
-pub const KERN_POOL = 49;
-pub const KERN_STACKGAPRANDOM = 50;
-pub const KERN_SYSVIPC_INFO = 51;
-pub const KERN_ALLOWKMEM = 52;
-pub const KERN_WITNESSWATCH = 53;
-pub const KERN_SPLASSERT = 54;
-pub const KERN_PROC_ARGS = 55;
-pub const KERN_NFILES = 56;
-pub const KERN_TTYCOUNT = 57;
-pub const KERN_NUMVNODES = 58;
-pub const KERN_MBSTAT = 59;
-pub const KERN_WITNESS = 60;
-pub const KERN_SEMINFO = 61;
-pub const KERN_SHMINFO = 62;
-pub const KERN_INTRCNT = 63;
-pub const KERN_WATCHDOG = 64;
-pub const KERN_ALLOWDT = 65;
-pub const KERN_PROC = 66;
-pub const KERN_MAXCLUSTERS = 67;
-pub const KERN_EVCOUNT = 68;
-pub const KERN_TIMECOUNTER = 69;
-pub const KERN_MAXLOCKSPERUID = 70;
-pub const KERN_CPTIME2 = 71;
-pub const KERN_CACHEPCT = 72;
-pub const KERN_FILE = 73;
-pub const KERN_WXABORT = 74;
-pub const KERN_CONSDEV = 75;
-pub const KERN_NETLIVELOCKS = 76;
-pub const KERN_POOL_DEBUG = 77;
-pub const KERN_PROC_CWD = 78;
-pub const KERN_PROC_NOBROADCASTKILL = 79;
-pub const KERN_PROC_VMMAP = 80;
-pub const KERN_GLOBAL_PTRACE = 81;
-pub const KERN_CONSBUFSIZE = 82;
-pub const KERN_CONSBUF = 83;
-pub const KERN_AUDIO = 84;
-pub const KERN_CPUSTATS = 85;
-pub const KERN_PFSTATUS = 86;
-pub const KERN_TIMEOUT_STATS = 87;
-pub const KERN_UTC_OFFSET = 88;
-pub const KERN_VIDEO = 89;
-
-pub const HW_MACHINE = 1;
-pub const HW_MODEL = 2;
-pub const HW_NCPU = 3;
-pub const HW_BYTEORDER = 4;
-pub const HW_PHYSMEM = 5;
-pub const HW_USERMEM = 6;
-pub const HW_PAGESIZE = 7;
-pub const HW_DISKNAMES = 8;
-pub const HW_DISKSTATS = 9;
-pub const HW_DISKCOUNT = 10;
-pub const HW_SENSORS = 11;
-pub const HW_CPUSPEED = 12;
-pub const HW_SETPERF = 13;
-pub const HW_VENDOR = 14;
-pub const HW_PRODUCT = 15;
-pub const HW_VERSION = 16;
-pub const HW_SERIALNO = 17;
-pub const HW_UUID = 18;
-pub const HW_PHYSMEM64 = 19;
-pub const HW_USERMEM64 = 20;
-pub const HW_NCPUFOUND = 21;
-pub const HW_ALLOWPOWERDOWN = 22;
-pub const HW_PERFPOLICY = 23;
-pub const HW_SMT = 24;
-pub const HW_NCPUONLINE = 25;
-
-pub const KERN_PROC_ALL = 0;
-pub const KERN_PROC_PID = 1;
-pub const KERN_PROC_PGRP = 2;
-pub const KERN_PROC_SESSION = 3;
-pub const KERN_PROC_TTY = 4;
-pub const KERN_PROC_UID = 5;
-pub const KERN_PROC_RUID = 6;
-pub const KERN_PROC_KTHREAD = 7;
-pub const KERN_PROC_SHOW_THREADS = 0x40000000;
-
-pub const KERN_PROC_ARGV = 1;
-pub const KERN_PROC_NARGV = 2;
-pub const KERN_PROC_ENV = 3;
-pub const KERN_PROC_NENV = 4;
lib/std/os/bits/wasi.zig
@@ -1,491 +0,0 @@
-// Convenience types and consts used by std.os module
-const builtin = @import("builtin");
-pub const iovec = posix.iovec;
-pub const iovec_const = posix.iovec_const;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const mode_t = u32;
-
-pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
-
-pub const timespec = struct {
-    tv_sec: time_t,
-    tv_nsec: isize,
-
-    pub fn fromTimestamp(tm: timestamp_t) timespec {
-        const tv_sec: timestamp_t = tm / 1_000_000_000;
-        const tv_nsec = tm - tv_sec * 1_000_000_000;
-        return timespec{
-            .tv_sec = @intCast(time_t, tv_sec),
-            .tv_nsec = @intCast(isize, tv_nsec),
-        };
-    }
-
-    pub fn toTimestamp(ts: timespec) timestamp_t {
-        const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec);
-        return tm;
-    }
-};
-
-pub const kernel_stat = struct {
-    dev: device_t,
-    ino: inode_t,
-    mode: mode_t,
-    filetype: filetype_t,
-    nlink: linkcount_t,
-    size: filesize_t,
-    atim: timespec,
-    mtim: timespec,
-    ctim: timespec,
-
-    const Self = @This();
-
-    pub fn fromFilestat(stat: filestat_t) Self {
-        return Self{
-            .dev = stat.dev,
-            .ino = stat.ino,
-            .mode = 0,
-            .filetype = stat.filetype,
-            .nlink = stat.nlink,
-            .size = stat.size,
-            .atim = stat.atime(),
-            .mtim = stat.mtime(),
-            .ctim = stat.ctime(),
-        };
-    }
-
-    pub fn atime(self: Self) timespec {
-        return self.atim;
-    }
-
-    pub fn mtime(self: Self) timespec {
-        return self.mtim;
-    }
-
-    pub fn ctime(self: Self) timespec {
-        return self.ctim;
-    }
-};
-
-pub const IOV_MAX = 1024;
-
-pub const AT_REMOVEDIR: u32 = 0x4;
-pub const AT_FDCWD: fd_t = -2;
-
-// As defined in the wasi_snapshot_preview1 spec file:
-// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
-pub const advice_t = u8;
-pub const ADVICE_NORMAL: advice_t = 0;
-pub const ADVICE_SEQUENTIAL: advice_t = 1;
-pub const ADVICE_RANDOM: advice_t = 2;
-pub const ADVICE_WILLNEED: advice_t = 3;
-pub const ADVICE_DONTNEED: advice_t = 4;
-pub const ADVICE_NOREUSE: advice_t = 5;
-
-pub const clockid_t = u32;
-pub const CLOCK = struct {
-    pub const REALTIME: clockid_t = 0;
-    pub const MONOTONIC: clockid_t = 1;
-    pub const PROCESS_CPUTIME_ID: clockid_t = 2;
-    pub const THREAD_CPUTIME_ID: clockid_t = 3;
-};
-
-pub const device_t = u64;
-
-pub const dircookie_t = u64;
-pub const DIRCOOKIE_START: dircookie_t = 0;
-
-pub const dirnamlen_t = u32;
-
-pub const dirent_t = extern struct {
-    d_next: dircookie_t,
-    d_ino: inode_t,
-    d_namlen: dirnamlen_t,
-    d_type: filetype_t,
-};
-
-pub const errno_t = enum(u16) {
-    SUCCESS = 0,
-    @"2BIG" = 1,
-    ACCES = 2,
-    ADDRINUSE = 3,
-    ADDRNOTAVAIL = 4,
-    AFNOSUPPORT = 5,
-    /// This is also the error code used for `WOULDBLOCK`.
-    AGAIN = 6,
-    ALREADY = 7,
-    BADF = 8,
-    BADMSG = 9,
-    BUSY = 10,
-    CANCELED = 11,
-    CHILD = 12,
-    CONNABORTED = 13,
-    CONNREFUSED = 14,
-    CONNRESET = 15,
-    DEADLK = 16,
-    DESTADDRREQ = 17,
-    DOM = 18,
-    DQUOT = 19,
-    EXIST = 20,
-    FAULT = 21,
-    FBIG = 22,
-    HOSTUNREACH = 23,
-    IDRM = 24,
-    ILSEQ = 25,
-    INPROGRESS = 26,
-    INTR = 27,
-    INVAL = 28,
-    IO = 29,
-    ISCONN = 30,
-    ISDIR = 31,
-    LOOP = 32,
-    MFILE = 33,
-    MLINK = 34,
-    MSGSIZE = 35,
-    MULTIHOP = 36,
-    NAMETOOLONG = 37,
-    NETDOWN = 38,
-    NETRESET = 39,
-    NETUNREACH = 40,
-    NFILE = 41,
-    NOBUFS = 42,
-    NODEV = 43,
-    NOENT = 44,
-    NOEXEC = 45,
-    NOLCK = 46,
-    NOLINK = 47,
-    NOMEM = 48,
-    NOMSG = 49,
-    NOPROTOOPT = 50,
-    NOSPC = 51,
-    NOSYS = 52,
-    NOTCONN = 53,
-    NOTDIR = 54,
-    NOTEMPTY = 55,
-    NOTRECOVERABLE = 56,
-    NOTSOCK = 57,
-    /// This is also the code used for `NOTSUP`.
-    OPNOTSUPP = 58,
-    NOTTY = 59,
-    NXIO = 60,
-    OVERFLOW = 61,
-    OWNERDEAD = 62,
-    PERM = 63,
-    PIPE = 64,
-    PROTO = 65,
-    PROTONOSUPPORT = 66,
-    PROTOTYPE = 67,
-    RANGE = 68,
-    ROFS = 69,
-    SPIPE = 70,
-    SRCH = 71,
-    STALE = 72,
-    TIMEDOUT = 73,
-    TXTBSY = 74,
-    XDEV = 75,
-    NOTCAPABLE = 76,
-    _,
-};
-pub const E = errno_t;
-
-pub const event_t = extern struct {
-    userdata: userdata_t,
-    @"error": errno_t,
-    @"type": eventtype_t,
-    fd_readwrite: eventfdreadwrite_t,
-};
-
-pub const eventfdreadwrite_t = extern struct {
-    nbytes: filesize_t,
-    flags: eventrwflags_t,
-};
-
-pub const eventrwflags_t = u16;
-pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
-
-pub const eventtype_t = u8;
-pub const EVENTTYPE_CLOCK: eventtype_t = 0;
-pub const EVENTTYPE_FD_READ: eventtype_t = 1;
-pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
-
-pub const exitcode_t = u32;
-
-pub const fd_t = if (builtin.link_libc) c_int else u32;
-
-pub const fdflags_t = u16;
-pub const FDFLAG_APPEND: fdflags_t = 0x0001;
-pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
-pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
-pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
-pub const FDFLAG_SYNC: fdflags_t = 0x0010;
-
-pub const fdstat_t = extern struct {
-    fs_filetype: filetype_t,
-    fs_flags: fdflags_t,
-    fs_rights_base: rights_t,
-    fs_rights_inheriting: rights_t,
-};
-
-pub const filedelta_t = i64;
-
-pub const filesize_t = u64;
-
-pub const filestat_t = extern struct {
-    dev: device_t,
-    ino: inode_t,
-    filetype: filetype_t,
-    nlink: linkcount_t,
-    size: filesize_t,
-    atim: timestamp_t,
-    mtim: timestamp_t,
-    ctim: timestamp_t,
-
-    pub fn atime(self: filestat_t) timespec {
-        return timespec.fromTimestamp(self.atim);
-    }
-
-    pub fn mtime(self: filestat_t) timespec {
-        return timespec.fromTimestamp(self.mtim);
-    }
-
-    pub fn ctime(self: filestat_t) timespec {
-        return timespec.fromTimestamp(self.ctim);
-    }
-};
-
-pub const filetype_t = u8;
-pub const FILETYPE_UNKNOWN: filetype_t = 0;
-pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
-pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
-pub const FILETYPE_DIRECTORY: filetype_t = 3;
-pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
-pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
-pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
-pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
-
-pub const fstflags_t = u16;
-pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
-pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
-pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
-pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
-
-pub const inode_t = u64;
-pub const ino_t = inode_t;
-
-pub const linkcount_t = u64;
-
-pub const lookupflags_t = u32;
-pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
-
-pub usingnamespace if (builtin.link_libc) struct {
-    // Derived from https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
-    pub const O_ACCMODE = (O_EXEC | O_RDWR | O_SEARCH);
-    pub const O_APPEND = FDFLAG_APPEND;
-    pub const O_CLOEXEC = (0);
-    pub const O_CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
-    pub const O_DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
-    pub const O_DSYNC = FDFLAG_DSYNC;
-    pub const O_EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
-    pub const O_EXEC = (0x02000000);
-    pub const O_NOCTTY = (0);
-    pub const O_NOFOLLOW = (0x01000000);
-    pub const O_NONBLOCK = (1 << FDFLAG_NONBLOCK);
-    pub const O_RDONLY = (0x04000000);
-    pub const O_RDWR = (O_RDONLY | O_WRONLY);
-    pub const O_RSYNC = (1 << FDFLAG_RSYNC);
-    pub const O_SEARCH = (0x08000000);
-    pub const O_SYNC = (1 << FDFLAG_SYNC);
-    pub const O_TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
-    pub const O_TTY_INIT = (0);
-    pub const O_WRONLY = (0x10000000);
-} else struct {
-    pub const oflags_t = u16;
-    pub const O_CREAT: oflags_t = 0x0001;
-    pub const O_DIRECTORY: oflags_t = 0x0002;
-    pub const O_EXCL: oflags_t = 0x0004;
-    pub const O_TRUNC: oflags_t = 0x0008;
-};
-
-pub const preopentype_t = u8;
-pub const PREOPENTYPE_DIR: preopentype_t = 0;
-
-pub const prestat_t = extern struct {
-    pr_type: preopentype_t,
-    u: prestat_u_t,
-};
-
-pub const prestat_dir_t = extern struct {
-    pr_name_len: usize,
-};
-
-pub const prestat_u_t = extern union {
-    dir: prestat_dir_t,
-};
-
-pub const riflags_t = u16;
-pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
-pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
-
-pub const rights_t = u64;
-pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
-pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
-pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
-pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
-pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
-pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
-pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
-pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
-pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
-pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
-pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
-pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
-pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
-pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
-pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
-pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
-pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
-pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
-pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
-pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
-pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
-pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
-pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
-pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
-pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
-pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
-pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
-pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
-pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
-pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
-    RIGHT_FD_READ |
-    RIGHT_FD_SEEK |
-    RIGHT_FD_FDSTAT_SET_FLAGS |
-    RIGHT_FD_SYNC |
-    RIGHT_FD_TELL |
-    RIGHT_FD_WRITE |
-    RIGHT_FD_ADVISE |
-    RIGHT_FD_ALLOCATE |
-    RIGHT_PATH_CREATE_DIRECTORY |
-    RIGHT_PATH_CREATE_FILE |
-    RIGHT_PATH_LINK_SOURCE |
-    RIGHT_PATH_LINK_TARGET |
-    RIGHT_PATH_OPEN |
-    RIGHT_FD_READDIR |
-    RIGHT_PATH_READLINK |
-    RIGHT_PATH_RENAME_SOURCE |
-    RIGHT_PATH_RENAME_TARGET |
-    RIGHT_PATH_FILESTAT_GET |
-    RIGHT_PATH_FILESTAT_SET_SIZE |
-    RIGHT_PATH_FILESTAT_SET_TIMES |
-    RIGHT_FD_FILESTAT_GET |
-    RIGHT_FD_FILESTAT_SET_SIZE |
-    RIGHT_FD_FILESTAT_SET_TIMES |
-    RIGHT_PATH_SYMLINK |
-    RIGHT_PATH_REMOVE_DIRECTORY |
-    RIGHT_PATH_UNLINK_FILE |
-    RIGHT_POLL_FD_READWRITE |
-    RIGHT_SOCK_SHUTDOWN;
-
-pub const roflags_t = u16;
-pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
-
-pub const sdflags_t = u8;
-pub const SHUT_RD: sdflags_t = 0x01;
-pub const SHUT_WR: sdflags_t = 0x02;
-
-pub const siflags_t = u16;
-
-pub const signal_t = u8;
-pub const SIGNONE: signal_t = 0;
-pub const SIGHUP: signal_t = 1;
-pub const SIGINT: signal_t = 2;
-pub const SIGQUIT: signal_t = 3;
-pub const SIGILL: signal_t = 4;
-pub const SIGTRAP: signal_t = 5;
-pub const SIGABRT: signal_t = 6;
-pub const SIGBUS: signal_t = 7;
-pub const SIGFPE: signal_t = 8;
-pub const SIGKILL: signal_t = 9;
-pub const SIGUSR1: signal_t = 10;
-pub const SIGSEGV: signal_t = 11;
-pub const SIGUSR2: signal_t = 12;
-pub const SIGPIPE: signal_t = 13;
-pub const SIGALRM: signal_t = 14;
-pub const SIGTERM: signal_t = 15;
-pub const SIGCHLD: signal_t = 16;
-pub const SIGCONT: signal_t = 17;
-pub const SIGSTOP: signal_t = 18;
-pub const SIGTSTP: signal_t = 19;
-pub const SIGTTIN: signal_t = 20;
-pub const SIGTTOU: signal_t = 21;
-pub const SIGURG: signal_t = 22;
-pub const SIGXCPU: signal_t = 23;
-pub const SIGXFSZ: signal_t = 24;
-pub const SIGVTALRM: signal_t = 25;
-pub const SIGPROF: signal_t = 26;
-pub const SIGWINCH: signal_t = 27;
-pub const SIGPOLL: signal_t = 28;
-pub const SIGPWR: signal_t = 29;
-pub const SIGSYS: signal_t = 30;
-
-pub const subclockflags_t = u16;
-pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
-
-pub const subscription_t = extern struct {
-    userdata: userdata_t,
-    u: subscription_u_t,
-};
-
-pub const subscription_clock_t = extern struct {
-    id: clockid_t,
-    timeout: timestamp_t,
-    precision: timestamp_t,
-    flags: subclockflags_t,
-};
-
-pub const subscription_fd_readwrite_t = extern struct {
-    fd: fd_t,
-};
-
-pub const subscription_u_t = extern struct {
-    tag: eventtype_t,
-    u: subscription_u_u_t,
-};
-
-pub const subscription_u_u_t = extern union {
-    clock: subscription_clock_t,
-    fd_read: subscription_fd_readwrite_t,
-    fd_write: subscription_fd_readwrite_t,
-};
-
-pub const timestamp_t = u64;
-
-pub const userdata_t = u64;
-
-pub const whence_t = u8;
-pub const WHENCE_SET: whence_t = 0;
-pub const WHENCE_CUR: whence_t = 1;
-pub const WHENCE_END: whence_t = 2;
-
-pub const S_IEXEC = S_IXUSR;
-pub const S_IFBLK = 0x6000;
-pub const S_IFCHR = 0x2000;
-pub const S_IFDIR = 0x4000;
-pub const S_IFIFO = 0xc000;
-pub const S_IFLNK = 0xa000;
-pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK;
-pub const S_IFREG = 0x8000;
-// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
-pub const S_IFSOCK = 0x1;
-
-pub const SEEK_SET = WHENCE_SET;
-pub const SEEK_CUR = WHENCE_CUR;
-pub const SEEK_END = WHENCE_END;
-
-pub const LOCK_SH = 0x1;
-pub const LOCK_EX = 0x2;
-pub const LOCK_NB = 0x4;
-pub const LOCK_UN = 0x8;
lib/std/os/bits/windows.zig
@@ -1,324 +0,0 @@
-// The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
-
-usingnamespace @import("../windows/bits.zig");
-const ws2_32 = @import("../windows/ws2_32.zig");
-
-pub const fd_t = HANDLE;
-pub const ino_t = LARGE_INTEGER;
-pub const pid_t = HANDLE;
-pub const mode_t = u0;
-
-pub const PATH_MAX = 260;
-
-pub const time_t = c_longlong;
-
-pub const timespec = extern struct {
-    tv_sec: time_t,
-    tv_nsec: c_long,
-};
-
-pub const timeval = extern struct {
-    tv_sec: c_long,
-    tv_usec: c_long,
-};
-
-pub const sig_atomic_t = c_int;
-
-/// maximum signal number + 1
-pub const NSIG = 23;
-
-// Signal types
-
-/// interrupt
-pub const SIGINT = 2;
-
-/// illegal instruction - invalid function image
-pub const SIGILL = 4;
-
-/// floating point exception
-pub const SIGFPE = 8;
-
-/// segment violation
-pub const SIGSEGV = 11;
-
-/// Software termination signal from kill
-pub const SIGTERM = 15;
-
-/// Ctrl-Break sequence
-pub const SIGBREAK = 21;
-
-/// abnormal termination triggered by abort call
-pub const SIGABRT = 22;
-
-/// SIGABRT compatible with other platforms, same as SIGABRT
-pub const SIGABRT_COMPAT = 6;
-
-// Signal action codes
-
-/// default signal action
-pub const SIG_DFL = 0;
-
-/// ignore signal
-pub const SIG_IGN = 1;
-
-/// return current value
-pub const SIG_GET = 2;
-
-/// signal gets error
-pub const SIG_SGE = 3;
-
-/// acknowledge
-pub const SIG_ACK = 4;
-
-/// Signal error value (returned by signal call on error)
-pub const SIG_ERR = -1;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const E = enum(u16) {
-    /// No error occurred.
-    SUCCESS = 0,
-    PERM = 1,
-    NOENT = 2,
-    SRCH = 3,
-    INTR = 4,
-    IO = 5,
-    NXIO = 6,
-    @"2BIG" = 7,
-    NOEXEC = 8,
-    BADF = 9,
-    CHILD = 10,
-    AGAIN = 11,
-    NOMEM = 12,
-    ACCES = 13,
-    FAULT = 14,
-    BUSY = 16,
-    EXIST = 17,
-    XDEV = 18,
-    NODEV = 19,
-    NOTDIR = 20,
-    ISDIR = 21,
-    NFILE = 23,
-    MFILE = 24,
-    NOTTY = 25,
-    FBIG = 27,
-    NOSPC = 28,
-    SPIPE = 29,
-    ROFS = 30,
-    MLINK = 31,
-    PIPE = 32,
-    DOM = 33,
-    /// Also means `DEADLOCK`.
-    DEADLK = 36,
-    NAMETOOLONG = 38,
-    NOLCK = 39,
-    NOSYS = 40,
-    NOTEMPTY = 41,
-
-    INVAL = 22,
-    RANGE = 34,
-    ILSEQ = 42,
-
-    // POSIX Supplement
-    ADDRINUSE = 100,
-    ADDRNOTAVAIL = 101,
-    AFNOSUPPORT = 102,
-    ALREADY = 103,
-    BADMSG = 104,
-    CANCELED = 105,
-    CONNABORTED = 106,
-    CONNREFUSED = 107,
-    CONNRESET = 108,
-    DESTADDRREQ = 109,
-    HOSTUNREACH = 110,
-    IDRM = 111,
-    INPROGRESS = 112,
-    ISCONN = 113,
-    LOOP = 114,
-    MSGSIZE = 115,
-    NETDOWN = 116,
-    NETRESET = 117,
-    NETUNREACH = 118,
-    NOBUFS = 119,
-    NODATA = 120,
-    NOLINK = 121,
-    NOMSG = 122,
-    NOPROTOOPT = 123,
-    NOSR = 124,
-    NOSTR = 125,
-    NOTCONN = 126,
-    NOTRECOVERABLE = 127,
-    NOTSOCK = 128,
-    NOTSUP = 129,
-    OPNOTSUPP = 130,
-    OTHER = 131,
-    OVERFLOW = 132,
-    OWNERDEAD = 133,
-    PROTO = 134,
-    PROTONOSUPPORT = 135,
-    PROTOTYPE = 136,
-    TIME = 137,
-    TIMEDOUT = 138,
-    TXTBSY = 139,
-    WOULDBLOCK = 140,
-    DQUOT = 10069,
-    _,
-};
-
-pub const STRUNCATE = 80;
-
-pub const F_OK = 0;
-
-/// Remove directory instead of unlinking file
-pub const AT_REMOVEDIR = 0x200;
-
-pub const in_port_t = u16;
-pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
-pub const socklen_t = ws2_32.socklen_t;
-
-pub const sockaddr = ws2_32.sockaddr;
-pub const sockaddr_in = ws2_32.sockaddr_in;
-pub const sockaddr_in6 = ws2_32.sockaddr_in6;
-pub const sockaddr_un = ws2_32.sockaddr_un;
-
-pub const in6_addr = [16]u8;
-pub const in_addr = u32;
-
-pub const addrinfo = ws2_32.addrinfo;
-
-pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
-pub const AF_UNIX = ws2_32.AF_UNIX;
-pub const AF_INET = ws2_32.AF_INET;
-pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
-pub const AF_PUP = ws2_32.AF_PUP;
-pub const AF_CHAOS = ws2_32.AF_CHAOS;
-pub const AF_NS = ws2_32.AF_NS;
-pub const AF_IPX = ws2_32.AF_IPX;
-pub const AF_ISO = ws2_32.AF_ISO;
-pub const AF_OSI = ws2_32.AF_OSI;
-pub const AF_ECMA = ws2_32.AF_ECMA;
-pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
-pub const AF_CCITT = ws2_32.AF_CCITT;
-pub const AF_SNA = ws2_32.AF_SNA;
-pub const AF_DECnet = ws2_32.AF_DECnet;
-pub const AF_DLI = ws2_32.AF_DLI;
-pub const AF_LAT = ws2_32.AF_LAT;
-pub const AF_HYLINK = ws2_32.AF_HYLINK;
-pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
-pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
-pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
-pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
-pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
-pub const AF_BAN = ws2_32.AF_BAN;
-pub const AF_ATM = ws2_32.AF_ATM;
-pub const AF_INET6 = ws2_32.AF_INET6;
-pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
-pub const AF_12844 = ws2_32.AF_12844;
-pub const AF_IRDA = ws2_32.AF_IRDA;
-pub const AF_NETDES = ws2_32.AF_NETDES;
-pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
-pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
-pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
-pub const AF_BTH = ws2_32.AF_BTH;
-pub const AF_MAX = ws2_32.AF_MAX;
-
-pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
-pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
-pub const SOCK_RAW = ws2_32.SOCK_RAW;
-pub const SOCK_RDM = ws2_32.SOCK_RDM;
-pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
-
-/// WARNING: this flag is not supported by windows socket functions directly,
-///          it is only supported by std.os.socket. Be sure that this value does
-///          not share any bits with any of the SOCK_* values.
-pub const SOCK_CLOEXEC = 0x10000;
-/// WARNING: this flag is not supported by windows socket functions directly,
-///          it is only supported by std.os.socket. Be sure that this value does
-///          not share any bits with any of the SOCK_* values.
-pub const SOCK_NONBLOCK = 0x20000;
-
-pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
-pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
-pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
-pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
-pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
-pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
-pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
-
-pub const nfds_t = c_ulong;
-pub const pollfd = ws2_32.pollfd;
-
-pub const POLLRDNORM = ws2_32.POLLRDNORM;
-pub const POLLRDBAND = ws2_32.POLLRDBAND;
-pub const POLLIN = ws2_32.POLLIN;
-pub const POLLPRI = ws2_32.POLLPRI;
-pub const POLLWRNORM = ws2_32.POLLWRNORM;
-pub const POLLOUT = ws2_32.POLLOUT;
-pub const POLLWRBAND = ws2_32.POLLWRBAND;
-pub const POLLERR = ws2_32.POLLERR;
-pub const POLLHUP = ws2_32.POLLHUP;
-pub const POLLNVAL = ws2_32.POLLNVAL;
-
-pub const SOL_SOCKET = ws2_32.SOL_SOCKET;
-
-pub const SO_DEBUG = ws2_32.SO_DEBUG;
-pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN;
-pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR;
-pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE;
-pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE;
-pub const SO_BROADCAST = ws2_32.SO_BROADCAST;
-pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK;
-pub const SO_LINGER = ws2_32.SO_LINGER;
-pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE;
-
-pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER;
-pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE;
-
-pub const SO_SNDBUF = ws2_32.SO_SNDBUF;
-pub const SO_RCVBUF = ws2_32.SO_RCVBUF;
-pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT;
-pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT;
-pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO;
-pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO;
-pub const SO_ERROR = ws2_32.SO_ERROR;
-pub const SO_TYPE = ws2_32.SO_TYPE;
-
-pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID;
-pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY;
-pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE;
-pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA;
-pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW;
-
-pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
-pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT;
-
-pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
-
-pub const O_RDONLY = 0o0;
-pub const O_WRONLY = 0o1;
-pub const O_RDWR = 0o2;
-
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o200000;
-pub const O_NOFOLLOW = 0o400000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o40000;
-pub const O_LARGEFILE = 0;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const IFNAMESIZE = 30;
lib/std/os/linux/test.zig
@@ -82,7 +82,7 @@ test "statx" {
         else => unreachable,
     }
 
-    var stat_buf: linux.kernel_stat = undefined;
+    var stat_buf: linux.Stat = undefined;
     switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) {
         .SUCCESS => {},
         else => unreachable,
lib/std/os/linux/x86_64.zig
@@ -112,6 +112,9 @@ pub fn restore_rt() callconv(.Naked) void {
 
 pub const mode_t = usize;
 pub const time_t = isize;
+pub const nlink_t = usize;
+pub const blksize_t = isize;
+pub const blkcnt_t = isize;
 
 pub const SYS = enum(usize) {
     read = 0,
@@ -664,7 +667,7 @@ pub const ino_t = u64;
 pub const dev_t = u64;
 
 // The `stat` definition used by the Linux kernel.
-pub const kernel_stat = extern struct {
+pub const Stat = extern struct {
     dev: dev_t,
     ino: ino_t,
     nlink: usize,
@@ -696,9 +699,6 @@ pub const kernel_stat = extern struct {
     }
 };
 
-// The `stat64` definition used by the libc.
-pub const libc_stat = kernel_stat;
-
 pub const timespec = extern struct {
     tv_sec: isize,
     tv_nsec: isize,
lib/std/os/windows/ws2_32.zig
@@ -1,5 +1,4 @@
 const std = @import("../../std.zig");
-usingnamespace @import("bits.zig");
 
 pub const SOCKET = *opaque {};
 pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
lib/std/os/linux.zig
@@ -1,10 +1,10 @@
-// This file provides the system interface functions for Linux matching those
-// that are provided by libc, whether or not libc is linked. The following
-// abstractions are made:
-// * Work around kernel bugs and limitations. For example, see sendmmsg.
-// * Implement all the syscalls in the same way that libc functions will
-//   provide `rename` when only the `renameat` syscall exists.
-// * Does not support POSIX thread cancellation.
+//! This file provides the system interface functions for Linux matching those
+//! that are provided by libc, whether or not libc is linked. The following
+//! abstractions are made:
+//! * Work around kernel bugs and limitations. For example, see sendmmsg.
+//! * Implement all the syscalls in the same way that libc functions will
+//!   provide `rename` when only the `renameat` syscall exists.
+//! * Does not support POSIX thread cancellation.
 const std = @import("../std.zig");
 const assert = std.debug.assert;
 const maxInt = std.math.maxInt;
@@ -63,8 +63,7 @@ pub const blkcnt_t = arch_bits.blkcnt_t;
 pub const blksize_t = arch_bits.blksize_t;
 pub const dev_t = arch_bits.dev_t;
 pub const ino_t = arch_bits.ino_t;
-pub const kernel_stat = arch_bits.kernel_stat;
-pub const libc_stat = arch_bits.libc_stat;
+pub const Stat = arch_bits.Stat;
 pub const mcontext_t = arch_bits.mcontext_t;
 pub const mode_t = arch_bits.mode_t;
 pub const msghdr = arch_bits.msghdr;
@@ -81,7 +80,30 @@ pub const user_desc = arch_bits.user_desc;
 pub const tls = @import("linux/tls.zig");
 pub const pie = @import("linux/start_pie.zig");
 pub const BPF = @import("linux/bpf.zig");
-pub usingnamespace @import("linux/io_uring.zig");
+
+const io_uring = @import("linux/io_uring.zig");
+pub const IO_Uring = io_uring.IO_Uring;
+pub const SubmissionQueue = io_uring.SubmissionQueue;
+pub const CompletionQueue = io_uring.CompletionQueue;
+pub const io_uring_prep_nop = io_uring.io_uring_prep_nop;
+pub const io_uring_prep_fsync = io_uring.io_uring_prep_fsync;
+pub const io_uring_prep_rw = io_uring.io_uring_prep_rw;
+pub const io_uring_prep_read = io_uring.io_uring_prep_read;
+pub const io_uring_prep_write = io_uring.io_uring_prep_write;
+pub const io_uring_prep_readv = io_uring.io_uring_prep_readv;
+pub const io_uring_prep_writev = io_uring.io_uring_prep_writev;
+pub const io_uring_prep_accept = io_uring.io_uring_prep_accept;
+pub const io_uring_prep_connect = io_uring.io_uring_prep_connect;
+pub const io_uring_prep_epoll_ctl = io_uring.io_uring_prep_epoll_ctl;
+pub const io_uring_prep_recv = io_uring.io_uring_prep_recv;
+pub const io_uring_prep_send = io_uring.io_uring_prep_send;
+pub const io_uring_prep_openat = io_uring.io_uring_prep_openat;
+pub const io_uring_prep_close = io_uring.io_uring_prep_close;
+pub const io_uring_prep_timeout = io_uring.io_uring_prep_timeout;
+pub const io_uring_prep_timeout_remove = io_uring.io_uring_prep_timeout_remove;
+pub const io_uring_prep_poll_add = io_uring.io_uring_prep_poll_add;
+pub const io_uring_prep_poll_remove = io_uring.io_uring_prep_poll_remove;
+pub const io_uring_prep_fallocate = io_uring.io_uring_prep_fallocate;
 
 /// Set by startup code, used by `getauxval`.
 pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
@@ -1205,7 +1227,7 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag
     return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
 }
 
-pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize {
+pub fn fstat(fd: i32, stat_buf: *Stat) usize {
     if (@hasField(SYS, "fstat64")) {
         return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
     } else {
@@ -1213,7 +1235,7 @@ pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize {
     }
 }
 
-pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
+pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
     if (@hasField(SYS, "stat64")) {
         return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
     } else {
@@ -1221,7 +1243,7 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
     }
 }
 
-pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
+pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
     if (@hasField(SYS, "lstat64")) {
         return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
     } else {
@@ -1229,7 +1251,7 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize {
     }
 }
 
-pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *kernel_stat, flags: u32) usize {
+pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {
     if (@hasField(SYS, "fstatat64")) {
         return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
     } else {
lib/std/os/wasi.zig
@@ -15,8 +15,8 @@ comptime {
     // assert(@alignOf(u64) == 8);
 }
 
-pub const iovec_t = iovec;
-pub const ciovec_t = iovec_const;
+pub const iovec_t = std.os.iovec;
+pub const ciovec_t = std.os.iovec_const;
 
 pub extern "wasi_snapshot_preview1" fn args_get(argv: [*][*:0]u8, argv_buf: [*]u8) errno_t;
 pub extern "wasi_snapshot_preview1" fn args_sizes_get(argc: *usize, argv_buf_size: *usize) errno_t;
@@ -79,3 +79,469 @@ pub extern "wasi_snapshot_preview1" fn sock_shutdown(sock: fd_t, how: sdflags_t)
 pub fn getErrno(r: errno_t) errno_t {
     return r;
 }
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const mode_t = u32;
+
+pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
+
+pub const timespec = struct {
+    tv_sec: time_t,
+    tv_nsec: isize,
+
+    pub fn fromTimestamp(tm: timestamp_t) timespec {
+        const tv_sec: timestamp_t = tm / 1_000_000_000;
+        const tv_nsec = tm - tv_sec * 1_000_000_000;
+        return timespec{
+            .tv_sec = @intCast(time_t, tv_sec),
+            .tv_nsec = @intCast(isize, tv_nsec),
+        };
+    }
+
+    pub fn toTimestamp(ts: timespec) timestamp_t {
+        const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec);
+        return tm;
+    }
+};
+
+pub const Stat = struct {
+    dev: device_t,
+    ino: inode_t,
+    mode: mode_t,
+    filetype: filetype_t,
+    nlink: linkcount_t,
+    size: filesize_t,
+    atim: timespec,
+    mtim: timespec,
+    ctim: timespec,
+
+    const Self = @This();
+
+    pub fn fromFilestat(stat: filestat_t) Self {
+        return Self{
+            .dev = stat.dev,
+            .ino = stat.ino,
+            .mode = 0,
+            .filetype = stat.filetype,
+            .nlink = stat.nlink,
+            .size = stat.size,
+            .atim = stat.atime(),
+            .mtim = stat.mtime(),
+            .ctim = stat.ctime(),
+        };
+    }
+
+    pub fn atime(self: Self) timespec {
+        return self.atim;
+    }
+
+    pub fn mtime(self: Self) timespec {
+        return self.mtim;
+    }
+
+    pub fn ctime(self: Self) timespec {
+        return self.ctim;
+    }
+};
+
+pub const IOV_MAX = 1024;
+
+pub const AT_REMOVEDIR: u32 = 0x4;
+pub const AT_FDCWD: fd_t = -2;
+
+// As defined in the wasi_snapshot_preview1 spec file:
+// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
+pub const advice_t = u8;
+pub const ADVICE_NORMAL: advice_t = 0;
+pub const ADVICE_SEQUENTIAL: advice_t = 1;
+pub const ADVICE_RANDOM: advice_t = 2;
+pub const ADVICE_WILLNEED: advice_t = 3;
+pub const ADVICE_DONTNEED: advice_t = 4;
+pub const ADVICE_NOREUSE: advice_t = 5;
+
+pub const clockid_t = u32;
+pub const CLOCK = struct {
+    pub const REALTIME: clockid_t = 0;
+    pub const MONOTONIC: clockid_t = 1;
+    pub const PROCESS_CPUTIME_ID: clockid_t = 2;
+    pub const THREAD_CPUTIME_ID: clockid_t = 3;
+};
+
+pub const device_t = u64;
+
+pub const dircookie_t = u64;
+pub const DIRCOOKIE_START: dircookie_t = 0;
+
+pub const dirnamlen_t = u32;
+
+pub const dirent_t = extern struct {
+    d_next: dircookie_t,
+    d_ino: inode_t,
+    d_namlen: dirnamlen_t,
+    d_type: filetype_t,
+};
+
+pub const errno_t = enum(u16) {
+    SUCCESS = 0,
+    @"2BIG" = 1,
+    ACCES = 2,
+    ADDRINUSE = 3,
+    ADDRNOTAVAIL = 4,
+    AFNOSUPPORT = 5,
+    /// This is also the error code used for `WOULDBLOCK`.
+    AGAIN = 6,
+    ALREADY = 7,
+    BADF = 8,
+    BADMSG = 9,
+    BUSY = 10,
+    CANCELED = 11,
+    CHILD = 12,
+    CONNABORTED = 13,
+    CONNREFUSED = 14,
+    CONNRESET = 15,
+    DEADLK = 16,
+    DESTADDRREQ = 17,
+    DOM = 18,
+    DQUOT = 19,
+    EXIST = 20,
+    FAULT = 21,
+    FBIG = 22,
+    HOSTUNREACH = 23,
+    IDRM = 24,
+    ILSEQ = 25,
+    INPROGRESS = 26,
+    INTR = 27,
+    INVAL = 28,
+    IO = 29,
+    ISCONN = 30,
+    ISDIR = 31,
+    LOOP = 32,
+    MFILE = 33,
+    MLINK = 34,
+    MSGSIZE = 35,
+    MULTIHOP = 36,
+    NAMETOOLONG = 37,
+    NETDOWN = 38,
+    NETRESET = 39,
+    NETUNREACH = 40,
+    NFILE = 41,
+    NOBUFS = 42,
+    NODEV = 43,
+    NOENT = 44,
+    NOEXEC = 45,
+    NOLCK = 46,
+    NOLINK = 47,
+    NOMEM = 48,
+    NOMSG = 49,
+    NOPROTOOPT = 50,
+    NOSPC = 51,
+    NOSYS = 52,
+    NOTCONN = 53,
+    NOTDIR = 54,
+    NOTEMPTY = 55,
+    NOTRECOVERABLE = 56,
+    NOTSOCK = 57,
+    /// This is also the code used for `NOTSUP`.
+    OPNOTSUPP = 58,
+    NOTTY = 59,
+    NXIO = 60,
+    OVERFLOW = 61,
+    OWNERDEAD = 62,
+    PERM = 63,
+    PIPE = 64,
+    PROTO = 65,
+    PROTONOSUPPORT = 66,
+    PROTOTYPE = 67,
+    RANGE = 68,
+    ROFS = 69,
+    SPIPE = 70,
+    SRCH = 71,
+    STALE = 72,
+    TIMEDOUT = 73,
+    TXTBSY = 74,
+    XDEV = 75,
+    NOTCAPABLE = 76,
+    _,
+};
+pub const E = errno_t;
+
+pub const event_t = extern struct {
+    userdata: userdata_t,
+    @"error": errno_t,
+    @"type": eventtype_t,
+    fd_readwrite: eventfdreadwrite_t,
+};
+
+pub const eventfdreadwrite_t = extern struct {
+    nbytes: filesize_t,
+    flags: eventrwflags_t,
+};
+
+pub const eventrwflags_t = u16;
+pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
+
+pub const eventtype_t = u8;
+pub const EVENTTYPE_CLOCK: eventtype_t = 0;
+pub const EVENTTYPE_FD_READ: eventtype_t = 1;
+pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
+
+pub const exitcode_t = u32;
+
+pub const fd_t = u32;
+
+pub const fdflags_t = u16;
+pub const FDFLAG_APPEND: fdflags_t = 0x0001;
+pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
+pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
+pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
+pub const FDFLAG_SYNC: fdflags_t = 0x0010;
+
+pub const fdstat_t = extern struct {
+    fs_filetype: filetype_t,
+    fs_flags: fdflags_t,
+    fs_rights_base: rights_t,
+    fs_rights_inheriting: rights_t,
+};
+
+pub const filedelta_t = i64;
+
+pub const filesize_t = u64;
+
+pub const filestat_t = extern struct {
+    dev: device_t,
+    ino: inode_t,
+    filetype: filetype_t,
+    nlink: linkcount_t,
+    size: filesize_t,
+    atim: timestamp_t,
+    mtim: timestamp_t,
+    ctim: timestamp_t,
+
+    pub fn atime(self: filestat_t) timespec {
+        return timespec.fromTimestamp(self.atim);
+    }
+
+    pub fn mtime(self: filestat_t) timespec {
+        return timespec.fromTimestamp(self.mtim);
+    }
+
+    pub fn ctime(self: filestat_t) timespec {
+        return timespec.fromTimestamp(self.ctim);
+    }
+};
+
+pub const filetype_t = u8;
+pub const FILETYPE_UNKNOWN: filetype_t = 0;
+pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
+pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
+pub const FILETYPE_DIRECTORY: filetype_t = 3;
+pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
+pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
+pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
+pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
+
+pub const fstflags_t = u16;
+pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
+pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
+pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
+pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
+
+pub const inode_t = u64;
+pub const ino_t = inode_t;
+
+pub const linkcount_t = u64;
+
+pub const lookupflags_t = u32;
+pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
+
+pub const oflags_t = u16;
+pub const O = struct {
+    pub const CREAT: oflags_t = 0x0001;
+    pub const DIRECTORY: oflags_t = 0x0002;
+    pub const EXCL: oflags_t = 0x0004;
+    pub const TRUNC: oflags_t = 0x0008;
+};
+
+pub const preopentype_t = u8;
+pub const PREOPENTYPE_DIR: preopentype_t = 0;
+
+pub const prestat_t = extern struct {
+    pr_type: preopentype_t,
+    u: prestat_u_t,
+};
+
+pub const prestat_dir_t = extern struct {
+    pr_name_len: usize,
+};
+
+pub const prestat_u_t = extern union {
+    dir: prestat_dir_t,
+};
+
+pub const riflags_t = u16;
+pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
+pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
+
+pub const rights_t = u64;
+pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
+pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
+pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
+pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
+pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
+pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
+pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
+pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
+pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
+pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
+pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
+pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
+pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
+pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
+pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
+pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
+pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
+pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
+pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
+pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
+pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
+pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
+pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
+pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
+pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
+pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
+pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
+pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
+pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
+pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
+    RIGHT_FD_READ |
+    RIGHT_FD_SEEK |
+    RIGHT_FD_FDSTAT_SET_FLAGS |
+    RIGHT_FD_SYNC |
+    RIGHT_FD_TELL |
+    RIGHT_FD_WRITE |
+    RIGHT_FD_ADVISE |
+    RIGHT_FD_ALLOCATE |
+    RIGHT_PATH_CREATE_DIRECTORY |
+    RIGHT_PATH_CREATE_FILE |
+    RIGHT_PATH_LINK_SOURCE |
+    RIGHT_PATH_LINK_TARGET |
+    RIGHT_PATH_OPEN |
+    RIGHT_FD_READDIR |
+    RIGHT_PATH_READLINK |
+    RIGHT_PATH_RENAME_SOURCE |
+    RIGHT_PATH_RENAME_TARGET |
+    RIGHT_PATH_FILESTAT_GET |
+    RIGHT_PATH_FILESTAT_SET_SIZE |
+    RIGHT_PATH_FILESTAT_SET_TIMES |
+    RIGHT_FD_FILESTAT_GET |
+    RIGHT_FD_FILESTAT_SET_SIZE |
+    RIGHT_FD_FILESTAT_SET_TIMES |
+    RIGHT_PATH_SYMLINK |
+    RIGHT_PATH_REMOVE_DIRECTORY |
+    RIGHT_PATH_UNLINK_FILE |
+    RIGHT_POLL_FD_READWRITE |
+    RIGHT_SOCK_SHUTDOWN;
+
+pub const roflags_t = u16;
+pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
+
+pub const sdflags_t = u8;
+pub const SHUT_RD: sdflags_t = 0x01;
+pub const SHUT_WR: sdflags_t = 0x02;
+
+pub const siflags_t = u16;
+
+pub const signal_t = u8;
+pub const SIGNONE: signal_t = 0;
+pub const SIGHUP: signal_t = 1;
+pub const SIGINT: signal_t = 2;
+pub const SIGQUIT: signal_t = 3;
+pub const SIGILL: signal_t = 4;
+pub const SIGTRAP: signal_t = 5;
+pub const SIGABRT: signal_t = 6;
+pub const SIGBUS: signal_t = 7;
+pub const SIGFPE: signal_t = 8;
+pub const SIGKILL: signal_t = 9;
+pub const SIGUSR1: signal_t = 10;
+pub const SIGSEGV: signal_t = 11;
+pub const SIGUSR2: signal_t = 12;
+pub const SIGPIPE: signal_t = 13;
+pub const SIGALRM: signal_t = 14;
+pub const SIGTERM: signal_t = 15;
+pub const SIGCHLD: signal_t = 16;
+pub const SIGCONT: signal_t = 17;
+pub const SIGSTOP: signal_t = 18;
+pub const SIGTSTP: signal_t = 19;
+pub const SIGTTIN: signal_t = 20;
+pub const SIGTTOU: signal_t = 21;
+pub const SIGURG: signal_t = 22;
+pub const SIGXCPU: signal_t = 23;
+pub const SIGXFSZ: signal_t = 24;
+pub const SIGVTALRM: signal_t = 25;
+pub const SIGPROF: signal_t = 26;
+pub const SIGWINCH: signal_t = 27;
+pub const SIGPOLL: signal_t = 28;
+pub const SIGPWR: signal_t = 29;
+pub const SIGSYS: signal_t = 30;
+
+pub const subclockflags_t = u16;
+pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
+
+pub const subscription_t = extern struct {
+    userdata: userdata_t,
+    u: subscription_u_t,
+};
+
+pub const subscription_clock_t = extern struct {
+    id: clockid_t,
+    timeout: timestamp_t,
+    precision: timestamp_t,
+    flags: subclockflags_t,
+};
+
+pub const subscription_fd_readwrite_t = extern struct {
+    fd: fd_t,
+};
+
+pub const subscription_u_t = extern struct {
+    tag: eventtype_t,
+    u: subscription_u_u_t,
+};
+
+pub const subscription_u_u_t = extern union {
+    clock: subscription_clock_t,
+    fd_read: subscription_fd_readwrite_t,
+    fd_write: subscription_fd_readwrite_t,
+};
+
+pub const timestamp_t = u64;
+
+pub const userdata_t = u64;
+
+pub const whence_t = u8;
+pub const WHENCE_SET: whence_t = 0;
+pub const WHENCE_CUR: whence_t = 1;
+pub const WHENCE_END: whence_t = 2;
+
+pub const S_IEXEC = S_IXUSR;
+pub const S_IFBLK = 0x6000;
+pub const S_IFCHR = 0x2000;
+pub const S_IFDIR = 0x4000;
+pub const S_IFIFO = 0xc000;
+pub const S_IFLNK = 0xa000;
+pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK;
+pub const S_IFREG = 0x8000;
+// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
+pub const S_IFSOCK = 0x1;
+
+pub const SEEK_SET = WHENCE_SET;
+pub const SEEK_CUR = WHENCE_CUR;
+pub const SEEK_END = WHENCE_END;
+
+pub const LOCK_SH = 0x1;
+pub const LOCK_EX = 0x2;
+pub const LOCK_NB = 0x4;
+pub const LOCK_UN = 0x8;
lib/std/c.zig
@@ -10,7 +10,8 @@ test {
     _ = tokenizer;
 }
 
-pub usingnamespace switch (std.Target.current.os.tag) {
+const generic = @import("c/generic.zig");
+const system = switch (builtin.os.tag) {
     .linux => @import("c/linux.zig"),
     .windows => @import("c/windows.zig"),
     .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
@@ -27,6 +28,109 @@ pub usingnamespace switch (std.Target.current.os.tag) {
     .wasi => @import("c/wasi.zig"),
     else => struct {},
 };
+pub const E = system.E;
+pub const _errno = system._errno;
+pub const MAP_FAILED = system.MAP_FAILED;
+pub const AI = system.AI;
+pub const NI = system.NI;
+pub const EAI = system.EAI;
+pub const timespec = system.timespec;
+pub const Sigaction = system.Sigaction;
+pub const fallocate64 = system.fallocate64;
+pub const fopen64 = system.fopen64;
+pub const fstat64 = system.fstat64;
+pub const fstatat64 = system.fstatat64;
+pub const ftruncate64 = system.ftruncate64;
+pub const getrlimit64 = system.getrlimit64;
+pub const lseek64 = system.lseek64;
+pub const mmap64 = system.mmap64;
+pub const open64 = system.open64;
+pub const openat64 = system.openat64;
+pub const pread64 = system.pread64;
+pub const preadv64 = system.preadv64;
+pub const pwrite64 = system.pwrite64;
+pub const pwritev64 = system.pwritev64;
+pub const sendfile64 = system.sendfile64;
+pub const setrlimit64 = system.setrlimit64;
+
+pub const AT = system.AT;
+pub const CLOCK = system.CLOCK;
+pub const IOV_MAX = system.IOV_MAX;
+pub const NAME_MAX = system.NAME_MAX;
+pub const PATH_MAX = system.PATH_MAX;
+pub const PROT = system.PROT;
+pub const RTLD = system.RTLD;
+pub const S = system.S;
+pub const SA = system.SA;
+pub const SIG = system.SIG;
+pub const STDERR_FILENO = system.STDIN_FILENO;
+pub const STDIN_FILENO = system.STDIN_FILENO;
+pub const STDOUT_FILENO = system.STDIN_FILENO;
+pub const Stat = system.Stat;
+pub const copy_file_range = system.copy_file_range;
+pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback;
+pub const dl_phdr_info = system.dl_phdr_info;
+pub const empty_sigset = system.empty_sigset;
+pub const epoll_create1 = system.epoll_create1;
+pub const epoll_ctl = system.epoll_ctl;
+pub const epoll_pwait = system.epoll_pwait;
+pub const epoll_wait = system.epoll_wait;
+pub const eventfd = system.eventfd;
+pub const fallocate = system.fallocate;
+pub const fd_t = system.fd_t;
+pub const getauxval = system.getauxval;
+pub const getdents = system.getdents;
+pub const getrandom = system.getrandom;
+pub const inotify_add_watch = system.inotify_add_watch;
+pub const inotify_init1 = system.inotify_init1;
+pub const inotify_rm_watch = system.inotify_rm_watch;
+pub const madvise = system.madvise;
+pub const malloc_usable_size = system.malloc_usable_size;
+pub const memfd_create = system.memfd_create;
+pub const pipe2 = system.pipe2;
+pub const pollfd = system.pollfd;
+pub const posix_memalign = system.posix_memalign;
+pub const prlimit = system.prlimit;
+pub const pthread_attr_t = system.pthread_attr_t;
+pub const pthread_cond_t = system.pthread_cond_t;
+pub const pthread_getname_np = system.pthread_getname_np;
+pub const pthread_mutex_t = system.pthread_mutex_t;
+pub const pthread_rwlock_t = system.pthread_rwlock_t;
+pub const pthread_setname_np = system.pthread_setname_np;
+pub const rlimit = system.rlimit;
+pub const rlimit_resource = system.rlimit_resource;
+pub const sched_getaffinity = system.sched_getaffinity;
+pub const sem_t = system.sem_t;
+pub const sendfile = system.sendfile;
+pub const sigaltstack = system.sigaltstack;
+pub const siginfo_t = system.siginfo_t;
+pub const signalfd = system.signalfd;
+pub const sigset_t = system.sigset_t;
+pub const MAP = system.MAP;
+pub const LOCK = system.LOCK;
+pub const REG = system.REG;
+pub const dl_iterate_phdr = system.dl_iterate_phdr;
+pub const ino_t = system.ino_t;
+pub const mode_t = system.mode_t;
+pub const ucontext_t = system.ucontext_t;
+pub const O = system.O;
+
+pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm;
+pub const clock_getres = if (@hasDecl(system, "clock_getres")) system.clock_getres else generic.clock_getres;
+pub const clock_gettime = if (@hasDecl(system, "clock_gettime")) system.clock_gettime else generic.clock_gettime;
+pub const fstat = if (@hasDecl(system, "fstat")) system.fstat else generic.fstat;
+pub const fstatat = if (@hasDecl(system, "fstatat")) system.fstatat else generic.fstatat;
+pub const getrusage = if (@hasDecl(system, "getrusage")) system.getrusage else generic.getrusage;
+pub const gettimeofday = if (@hasDecl(system, "gettimeofday")) system.gettimeofday else generic.gettimeofday;
+pub const nanosleep = if (@hasDecl(system, "nanosleep")) system.nanosleep else generic.nanosleep;
+pub const realpath = if (@hasDecl(system, "realpath")) system.realpath else generic.realpath;
+pub const sched_yield = if (@hasDecl(system, "sched_yield")) system.sched_yield else generic.sched_yield;
+pub const sigaction = if (@hasDecl(system, "sigaction")) system.sigaction else generic.sigaction;
+pub const sigfillset = if (@hasDecl(system, "sigfillset")) system.sigfillset else generic.sigfillset;
+pub const sigprocmask = if (@hasDecl(system, "sigprocmask")) system.sigprocmask else generic.sigprocmask;
+pub const sigwait = if (@hasDecl(system, "sigwait")) system.sigwait else generic.sigwait;
+pub const socket = if (@hasDecl(system, "socket")) system.socket else generic.socket;
+pub const stat = if (@hasDecl(system, "stat")) system.stat else generic.stat;
 
 pub fn getErrno(rc: anytype) E {
     if (rc == -1) {
@@ -47,9 +151,9 @@ pub fn versionCheck(glibc_version: builtin.Version) type {
     return struct {
         pub const ok = blk: {
             if (!builtin.link_libc) break :blk false;
-            if (std.Target.current.abi.isMusl()) break :blk true;
-            if (std.Target.current.isGnuLibC()) {
-                const ver = std.Target.current.os.version_range.linux.glibc;
+            if (builtin.abi.isMusl()) break :blk true;
+            if (builtin.target.isGnuLibC()) {
+                const ver = builtin.os.version_range.linux.glibc;
                 const order = ver.order(glibc_version);
                 break :blk switch (order) {
                     .gt, .eq => true,
@@ -115,17 +219,6 @@ pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int;
 pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
 pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
 
-pub usingnamespace switch (builtin.os.tag) {
-    .macos, .ios, .watchos, .tvos => struct {
-        pub const realpath = @"realpath$DARWIN_EXTSN";
-        pub const fstatat = _fstatat;
-    },
-    else => struct {
-        pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
-        pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int;
-    },
-};
-
 pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
 pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
 pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
@@ -172,75 +265,6 @@ pub extern "c" fn recvfrom(
 ) isize;
 pub extern "c" fn recvmsg(sockfd: fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;
 
-pub usingnamespace switch (builtin.os.tag) {
-    .netbsd => struct {
-        pub const clock_getres = __clock_getres50;
-        pub const clock_gettime = __clock_gettime50;
-        pub const fstat = __fstat50;
-        pub const getdents = __getdents30;
-        pub const getrusage = __getrusage50;
-        pub const gettimeofday = __gettimeofday50;
-        pub const nanosleep = __nanosleep50;
-        pub const sched_yield = __libc_thr_yield;
-        pub const sigaction = __sigaction14;
-        pub const sigaltstack = __sigaltstack14;
-        pub const sigprocmask = __sigprocmask14;
-        pub const socket = __socket30;
-        pub const stat = __stat50;
-    },
-    .macos, .ios, .watchos, .tvos => struct {
-        // XXX: close -> close$NOCANCEL
-        // XXX: getdirentries -> _getdirentries64
-        pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
-        pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
-        pub const fstat = _fstat;
-        pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
-        pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
-        pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
-        pub extern "c" fn sched_yield() c_int;
-        pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
-        pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
-        pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
-        pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int;
-        pub extern "c" fn sigfillset(set: ?*sigset_t) void;
-        pub extern "c" fn alarm(seconds: c_uint) c_uint;
-        pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
-    },
-    .windows => struct {
-        // TODO: copied the else case and removed the socket function (because its in ws2_32)
-        //       need to verify which of these is actually supported on windows
-        pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
-        pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
-        pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
-        pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
-        pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
-        pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
-        pub extern "c" fn sched_yield() c_int;
-        pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
-        pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
-        pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int;
-        pub extern "c" fn sigfillset(set: ?*sigset_t) void;
-        pub extern "c" fn alarm(seconds: c_uint) c_uint;
-        pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
-    },
-    else => struct {
-        pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
-        pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
-        pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int;
-        pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
-        pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
-        pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
-        pub extern "c" fn sched_yield() c_int;
-        pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
-        pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
-        pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
-        pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int;
-        pub extern "c" fn sigfillset(set: ?*sigset_t) void;
-        pub extern "c" fn alarm(seconds: c_uint) c_uint;
-        pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
-    },
-};
-
 pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int;
 pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
 
@@ -375,9 +399,9 @@ pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int)
 pub extern "c" fn closelog() void;
 pub extern "c" fn setlogmask(maskpri: c_int) c_int;
 
-pub const max_align_t = if (std.Target.current.abi == .msvc)
+pub const max_align_t = if (builtin.abi == .msvc)
     f64
-else if (std.Target.current.isDarwin())
+else if (builtin.target.isDarwin())
     c_longdouble
 else
     extern struct {
lib/std/fs.zig
@@ -471,7 +471,7 @@ pub const Dir = struct {
                         continue :start_over;
                     }
 
-                    var stat_info: os.libc_stat = undefined;
+                    var stat_info: os.Stat = undefined;
                     _ = os.system._kern_read_stat(
                         self.dir.fd,
                         &haiku_entry.d_name,
lib/std/os.zig
@@ -40,15 +40,10 @@ comptime {
 }
 
 test {
-    _ = darwin;
-    _ = freebsd;
     _ = linux;
-    _ = netbsd;
-    _ = openbsd;
     _ = uefi;
     _ = wasi;
     _ = windows;
-    _ = haiku;
 
     _ = @import("os/test.zig");
 }
@@ -61,85 +56,68 @@ pub const system = if (@hasDecl(root, "os") and root.os != @This())
 else if (builtin.link_libc)
     std.c
 else switch (builtin.os.tag) {
-    .macos, .ios, .watchos, .tvos => darwin,
-    .freebsd => freebsd,
-    .haiku => haiku,
     .linux => linux,
-    .netbsd => netbsd,
-    .openbsd => openbsd,
-    .dragonfly => dragonfly,
     .wasi => wasi,
     .windows => windows,
+    .uefi => uefi,
     else => struct {},
 };
-
-const bits = switch (builtin.os.tag) {
-    .macos, .ios, .tvos, .watchos => std.c,
-    .dragonfly => @import("os/bits/dragonfly.zig"),
-    .freebsd => @import("os/bits/freebsd.zig"),
-    .haiku => @import("os/bits/haiku.zig"),
-    .linux => linux,
-    .netbsd => @import("os/bits/netbsd.zig"),
-    .openbsd => @import("os/bits/openbsd.zig"),
-    .wasi => @import("os/bits/wasi.zig"),
-    .windows => @import("os/bits/windows.zig"),
-    else => struct {},
-};
-pub const E = bits.E;
-pub const ARCH = bits.ARCH;
-pub const Elf_Symndx = bits.Elf_Symndx;
-pub const F = bits.F;
-pub const Flock = bits.Flock;
-pub const LOCK = bits.LOCK;
-pub const MAP = bits.MAP;
-pub const MMAP2_UNIT = bits.MMAP2_UNIT;
-pub const O = bits.O;
-pub const REG = bits.REG;
-pub const SC = bits.SC;
-pub const SYS = bits.SYS;
-pub const VDSO = bits.VDSO;
-pub const blkcnt_t = bits.blkcnt_t;
-pub const blksize_t = bits.blksize_t;
-pub const dev_t = bits.dev_t;
-pub const ino_t = bits.ino_t;
-pub const kernel_stat = bits.kernel_stat;
-pub const libc_stat = bits.libc_stat;
-pub const mcontext_t = bits.mcontext_t;
-pub const mode_t = bits.mode_t;
-pub const msghdr = bits.msghdr;
-pub const msghdr_const = bits.msghdr_const;
-pub const nlink_t = bits.nlink_t;
-pub const off_t = bits.off_t;
-pub const time_t = bits.time_t;
-pub const timespec = bits.timespec;
-pub const timeval = bits.timeval;
-pub const timezone = bits.timezone;
-pub const ucontext_t = bits.ucontext_t;
-pub const user_desc = bits.user_desc;
-pub const pid_t = bits.pid_t;
-pub const fd_t = bits.fd_t;
-pub const uid_t = bits.uid_t;
-pub const gid_t = bits.gid_t;
-pub const clock_t = bits.clock_t;
-pub const NAME_MAX = bits.NAME_MAX;
-pub const PATH_MAX = bits.PATH_MAX;
-pub const IOV_MAX = bits.IOV_MAX;
-pub const MAX_ADDR_LEN = bits.MAX_ADDR_LEN;
-pub const STDIN_FILENO = bits.STDIN_FILENO;
-pub const STDOUT_FILENO = bits.STDIN_FILENO;
-pub const STDERR_FILENO = bits.STDIN_FILENO;
-pub const AT = bits.AT;
-pub const PROT = bits.PROT;
-pub const CLOCK = bits.CLOCK;
-pub const dl_phdr_info = bits.dl_phdr_info;
-pub const Sigaction = bits.Sigaction;
-pub const rlimit_resource = bits.rlimit_resource;
-pub const SIG = bits.SIG;
-pub const rlimit = bits.rlimit;
-pub const empty_sigset = bits.empty_sigset;
-pub const S = bits.S;
-pub const siginfo_t = bits.siginfo_t;
-pub const SA = bits.SA;
+pub const ARCH = system.ARCH;
+pub const AT = system.AT;
+pub const CLOCK = system.CLOCK;
+pub const E = system.E;
+pub const Elf_Symndx = system.Elf_Symndx;
+pub const F = system.F;
+pub const Flock = system.Flock;
+pub const IOV_MAX = system.IOV_MAX;
+pub const LOCK = system.LOCK;
+pub const MAP = system.MAP;
+pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN;
+pub const MMAP2_UNIT = system.MMAP2_UNIT;
+pub const NAME_MAX = system.NAME_MAX;
+pub const O = system.O;
+pub const PATH_MAX = system.PATH_MAX;
+pub const PROT = system.PROT;
+pub const REG = system.REG;
+pub const S = system.S;
+pub const SA = system.SA;
+pub const SC = system.SC;
+pub const SIG = system.SIG;
+pub const STDERR_FILENO = system.STDIN_FILENO;
+pub const STDIN_FILENO = system.STDIN_FILENO;
+pub const STDOUT_FILENO = system.STDIN_FILENO;
+pub const SYS = system.SYS;
+pub const Sigaction = system.Sigaction;
+pub const Stat = system.Stat;
+pub const VDSO = system.VDSO;
+pub const blkcnt_t = system.blkcnt_t;
+pub const blksize_t = system.blksize_t;
+pub const clock_t = system.clock_t;
+pub const dev_t = system.dev_t;
+pub const dl_phdr_info = system.dl_phdr_info;
+pub const empty_sigset = system.empty_sigset;
+pub const fd_t = system.fd_t;
+pub const gid_t = system.gid_t;
+pub const ino_t = system.ino_t;
+pub const mcontext_t = system.mcontext_t;
+pub const mode_t = system.mode_t;
+pub const msghdr = system.msghdr;
+pub const msghdr_const = system.msghdr_const;
+pub const nlink_t = system.nlink_t;
+pub const off_t = system.off_t;
+pub const pid_t = system.pid_t;
+pub const pollfd = system.pollfd;
+pub const rlimit = system.rlimit;
+pub const rlimit_resource = system.rlimit_resource;
+pub const siginfo_t = system.siginfo_t;
+pub const sigset_t = system.sigset_t;
+pub const time_t = system.time_t;
+pub const timespec = system.timespec;
+pub const timeval = system.timeval;
+pub const timezone = system.timezone;
+pub const ucontext_t = system.ucontext_t;
+pub const uid_t = system.uid_t;
+pub const user_desc = system.user_desc;
 
 pub const iovec = extern struct {
     iov_base: [*]u8,
@@ -334,7 +312,7 @@ pub fn raise(sig: u8) RaiseError!void {
     }
 
     if (builtin.os.tag == .linux) {
-        var set: bits.sigset_t = undefined;
+        var set: sigset_t = undefined;
         // block application signals
         _ = linux.sigprocmask(SIG.BLOCK, &linux.app_mask, &set);
 
@@ -3558,11 +3536,6 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult {
     }
 }
 
-pub const Stat = if (builtin.link_libc)
-    system.libc_stat
-else
-    system.kernel_stat;
-
 pub const FStatError = error{
     SystemResources,