commit 3d61e4228298dcb973c13d8d6eba0bff36acf1ca (tree)
parent 17b0166e004e81d9c433576f4c642e743fc527b7
Author: Andrew Kelley <andrew@ziglang.org>
Date: Fri, 24 May 2019 19:36:09 -0400
rename "posix" to "bits"
Diffstat:
26 files changed, 3762 insertions(+), 3759 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -474,10 +474,7 @@ set(ZIG_STD_FILES
"c/linux.zig"
"c/netbsd.zig"
"c/windows.zig"
- "c/posix.zig"
- "c/posix/darwin.zig"
- "c/posix/freebsd.zig"
- "c/posix/windows.zig"
+ "child_process.zig"
"coff.zig"
"crypto.zig"
"crypto/blake2.zig"
@@ -491,8 +488,8 @@ set(ZIG_STD_FILES
"crypto/x25519.zig"
"cstr.zig"
"debug.zig"
- "debug/leb128.zig"
"debug/failing_allocator.zig"
+ "debug/leb128.zig"
"dwarf.zig"
"dynamic_library.zig"
"elf.zig"
@@ -513,6 +510,10 @@ set(ZIG_STD_FILES
"fmt/errol/enum3.zig"
"fmt/errol/lookup.zig"
"fmt/parse_float.zig"
+ "fs.zig"
+ "fs/file.zig"
+ "fs/get_app_data_dir.zig"
+ "fs/path.zig"
"hash.zig"
"hash/adler.zig"
"hash/crc.zig"
@@ -521,8 +522,8 @@ set(ZIG_STD_FILES
"hash_map.zig"
"heap.zig"
"io.zig"
- "io/seekable_stream.zig"
"io/c_out_stream.zig"
+ "io/seekable_stream.zig"
"json.zig"
"lazy_init.zig"
"linked_list.zig"
@@ -604,46 +605,40 @@ set(ZIG_STD_FILES
"mutex.zig"
"net.zig"
"os.zig"
- "os/child_process.zig"
+ "os/bits.zig"
+ "os/bits/darwin.zig"
+ "os/bits/freebsd.zig"
+ "os/bits/linux.zig"
+ "os/bits/linux/arm64.zig"
+ "os/bits/linux/errno.zig"
+ "os/bits/linux/x86_64.zig"
+ "os/bits/netbsd.zig"
+ "os/bits/wasi.zig"
+ "os/bits/windows.zig"
"os/darwin.zig"
- "os/darwin/errno.zig"
"os/epoch.zig"
- "os/file.zig"
"os/freebsd.zig"
- "os/freebsd/errno.zig"
- "os/get_app_data_dir.zig"
- "os/get_user_id.zig"
"os/linux.zig"
"os/linux/arm64.zig"
- "os/linux/errno.zig"
- "os/linux/posix.zig"
- "os/linux/posix/arm64.zig"
- "os/linux/posix/x86_64.zig"
"os/linux/sys.zig"
"os/linux/tls.zig"
"os/linux/vdso.zig"
"os/linux/x86_64.zig"
"os/netbsd.zig"
- "os/netbsd/errno.zig"
- "os/path.zig"
- "os/posix.zig"
- "os/time.zig"
"os/uefi.zig"
"os/wasi.zig"
- "os/wasi/posix.zig"
"os/windows.zig"
"os/windows/advapi32.zig"
- "os/windows/errno.zig"
"os/windows/error.zig"
"os/windows/kernel32.zig"
"os/windows/ntdll.zig"
"os/windows/ole32.zig"
"os/windows/shell32.zig"
- "os/windows/util.zig"
"os/zen.zig"
"packed_int_array.zig"
"pdb.zig"
"priority_queue.zig"
+ "process.zig"
"rand.zig"
"rand/ziggurat.zig"
"rb.zig"
@@ -655,17 +650,18 @@ set(ZIG_STD_FILES
"special/build_runner.zig"
"special/c.zig"
"special/compiler_rt.zig"
- "special/compiler_rt/stack_probe.zig"
- "special/compiler_rt/arm/aeabi_fcmp.zig"
- "special/compiler_rt/arm/aeabi_dcmp.zig"
"special/compiler_rt/addXf3.zig"
+ "special/compiler_rt/arm/aeabi_dcmp.zig"
+ "special/compiler_rt/arm/aeabi_fcmp.zig"
+ "special/compiler_rt/ashlti3.zig"
+ "special/compiler_rt/ashrti3.zig"
"special/compiler_rt/aulldiv.zig"
"special/compiler_rt/aullrem.zig"
- "special/compiler_rt/comparetf2.zig"
"special/compiler_rt/comparedf2.zig"
"special/compiler_rt/comparesf2.zig"
- "special/compiler_rt/divsf3.zig"
+ "special/compiler_rt/comparetf2.zig"
"special/compiler_rt/divdf3.zig"
+ "special/compiler_rt/divsf3.zig"
"special/compiler_rt/divti3.zig"
"special/compiler_rt/extendXfYf2.zig"
"special/compiler_rt/fixdfdi.zig"
@@ -690,26 +686,25 @@ set(ZIG_STD_FILES
"special/compiler_rt/fixunstfti.zig"
"special/compiler_rt/floatdidf.zig"
"special/compiler_rt/floatsiXf.zig"
- "special/compiler_rt/floatunsidf.zig"
"special/compiler_rt/floattidf.zig"
"special/compiler_rt/floattisf.zig"
"special/compiler_rt/floattitf.zig"
"special/compiler_rt/floatundidf.zig"
"special/compiler_rt/floatunditf.zig"
+ "special/compiler_rt/floatunsidf.zig"
"special/compiler_rt/floatunsitf.zig"
"special/compiler_rt/floatuntidf.zig"
"special/compiler_rt/floatuntisf.zig"
"special/compiler_rt/floatuntitf.zig"
+ "special/compiler_rt/lshrti3.zig"
"special/compiler_rt/modti3.zig"
"special/compiler_rt/mulXf3.zig"
- "special/compiler_rt/muloti4.zig"
"special/compiler_rt/mulodi4.zig"
+ "special/compiler_rt/muloti4.zig"
"special/compiler_rt/multi3.zig"
- "special/compiler_rt/ashlti3.zig"
- "special/compiler_rt/ashrti3.zig"
- "special/compiler_rt/lshrti3.zig"
"special/compiler_rt/negXf2.zig"
"special/compiler_rt/popcountdi2.zig"
+ "special/compiler_rt/stack_probe.zig"
"special/compiler_rt/truncXfYf2.zig"
"special/compiler_rt/udivmod.zig"
"special/compiler_rt/udivmoddi4.zig"
@@ -726,6 +721,8 @@ set(ZIG_STD_FILES
"statically_initialized_mutex.zig"
"std.zig"
"testing.zig"
+ "thread.zig"
+ "time.zig"
"unicode.zig"
"valgrind.zig"
"valgrind/callgrind.zig"
diff --git a/std/c.zig b/std/c.zig
@@ -1,10 +1,9 @@
const builtin = @import("builtin");
-pub const posix = @import("c/posix.zig");
-pub use posix;
+pub use @import("os/bits.zig");
pub use switch (builtin.os) {
- .linux => @import("os/linux/posix.zig"),
+ .linux => @import("c/linux.zig"),
.windows => @import("c/windows.zig"),
.macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"),
.freebsd => @import("c/freebsd.zig"),
diff --git a/std/c/linux.zig b/std/c/linux.zig
@@ -1,17 +1,12 @@
-const linux = @import("../os/linux.zig");
-pub use @import("../os/linux/errno.zig");
+const std = @import("../std.zig");
+use std.c;
pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) c_int;
extern "c" fn __errno_location() *c_int;
pub const _errno = __errno_location;
-pub const pthread_attr_t = extern struct {
- __size: [56]u8,
- __align: c_long,
-};
-
/// See std.elf for constants for this
pub extern fn getauxval(__type: c_ulong) c_ulong;
-pub const dl_iterate_phdr_callback = extern fn (info: *linux.dl_phdr_info, size: usize, data: ?*c_void) c_int;
+pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
pub extern fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
diff --git a/std/c/posix.zig b/std/c/posix.zig
@@ -1,26 +0,0 @@
-// Declarations that are intended to be imported into the POSIX namespace.
-
-const builtin = @import("builtin");
-
-pub use switch (builtin.os) {
- .windows => @import("posix/windows.zig"),
- .macosx, .ios, .tvos, .watchos => @import("posix/darwin.zig"),
- .freebsd => @import("posix/freebsd.zig"),
- .netbsd => @import("posix/netbsd.zig"),
- else => struct {},
-};
-
-pub const fd_t = c_int;
-pub const pid_t = c_int;
-pub const pthread_t = *@OpaqueType();
-pub const FILE = @OpaqueType();
-
-pub const iovec = extern struct {
- iov_base: [*]u8,
- iov_len: usize,
-};
-
-pub const iovec_const = extern struct {
- iov_base: [*]const u8,
- iov_len: usize,
-};
diff --git a/std/c/posix/darwin.zig b/std/c/posix/darwin.zig
@@ -1,1099 +0,0 @@
-const std = @import("../std.zig");
-const assert = std.debug.assert;
-
-pub fn sigaction(sig: u5, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
- assert(sig != SIGKILL);
- assert(sig != SIGSTOP);
- var cact = c.Sigaction{
- .handler = @ptrCast(extern fn (c_int) void, act.handler),
- .sa_flags = @bitCast(c_int, act.flags),
- .sa_mask = act.mask,
- };
- var coact: c.Sigaction = undefined;
- const result = errnoWrap(c.sigaction(sig, &cact, &coact));
- if (result != 0) {
- return result;
- }
- if (oact) |old| {
- old.* = Sigaction{
- .handler = @ptrCast(extern fn (i32) void, coact.handler),
- .flags = @bitCast(u32, coact.sa_flags),
- .mask = coact.sa_mask,
- };
- }
- return result;
-}
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-pub const socklen_t = u32;
-pub const sockaddr = extern union {
- in: sockaddr_in,
- in6: sockaddr_in6,
-};
-pub const sockaddr_in = extern struct {
- len: u8,
- family: sa_family_t,
- port: in_port_t,
- addr: u32,
- zero: [8]u8,
-};
-pub const sockaddr_in6 = extern struct {
- len: u8,
- family: sa_family_t,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-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,
-};
-
-/// Renamed to Stat to not conflict with the stat function.
-pub const Stat = extern struct {
- dev: i32,
- mode: u16,
- nlink: u16,
- ino: u64,
- uid: u32,
- gid: u32,
- rdev: i32,
- atime: usize,
- atimensec: usize,
- mtime: usize,
- mtimensec: usize,
- ctime: usize,
- ctimensec: usize,
- birthtime: usize,
- birthtimensec: usize,
- size: i64,
- blocks: i64,
- blksize: i32,
- flags: u32,
- gen: u32,
- lspare: i32,
- qspare: [2]i64,
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-pub const sigset_t = u32;
-pub const empty_sigset = sigset_t(0);
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
-pub const Sigaction = extern struct {
- handler: extern fn (c_int) void,
- sa_mask: sigset_t,
- sa_flags: c_int,
-};
-
-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 const pthread_attr_t = extern struct {
- __sig: c_long,
- __opaque: [56]u8,
-};
-
-/// 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(@byteOffsetOf(Kevent, "ident") == 0);
- assert(@byteOffsetOf(Kevent, "filter") == 8);
- assert(@byteOffsetOf(Kevent, "flags") == 10);
- assert(@byteOffsetOf(Kevent, "fflags") == 12);
- assert(@byteOffsetOf(Kevent, "data") == 16);
- assert(@byteOffsetOf(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(@byteOffsetOf(kevent64_s, "ident") == 0);
- assert(@byteOffsetOf(kevent64_s, "filter") == 8);
- assert(@byteOffsetOf(kevent64_s, "flags") == 10);
- assert(@byteOffsetOf(kevent64_s, "fflags") == 12);
- assert(@byteOffsetOf(kevent64_s, "data") == 16);
- assert(@byteOffsetOf(kevent64_s, "udata") == 24);
- assert(@byteOffsetOf(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 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 = 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_LARGEFILE = 0x0000;
-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<OSTOP)
-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;
-
-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;
-
-fn wstatus(x: i32) i32 {
- return x & 0o177;
-}
-const wstopped = 0o177;
-pub fn WEXITSTATUS(x: i32) i32 {
- return x >> 8;
-}
-pub fn WTERMSIG(x: i32) i32 {
- return wstatus(x);
-}
-pub fn WSTOPSIG(x: i32) i32 {
- return x >> 8;
-}
-pub fn WIFEXITED(x: i32) bool {
- return wstatus(x) == 0;
-}
-pub fn WIFSTOPPED(x: i32) bool {
- return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
-}
-pub fn WIFSIGNALED(x: i32) bool {
- return wstatus(x) != wstopped and wstatus(x) != 0;
-}
-
-/// Operation not permitted
-pub const EPERM = 1;
-
-/// No such file or directory
-pub const ENOENT = 2;
-
-/// No such process
-pub const ESRCH = 3;
-
-/// Interrupted system call
-pub const EINTR = 4;
-
-/// Input/output error
-pub const EIO = 5;
-
-/// Device not configured
-pub const ENXIO = 6;
-
-/// Argument list too long
-pub const E2BIG = 7;
-
-/// Exec format error
-pub const ENOEXEC = 8;
-
-/// Bad file descriptor
-pub const EBADF = 9;
-
-/// No child processes
-pub const ECHILD = 10;
-
-/// Resource deadlock avoided
-pub const EDEADLK = 11;
-
-/// Cannot allocate memory
-pub const ENOMEM = 12;
-
-/// Permission denied
-pub const EACCES = 13;
-
-/// Bad address
-pub const EFAULT = 14;
-
-/// Block device required
-pub const ENOTBLK = 15;
-
-/// Device / Resource busy
-pub const EBUSY = 16;
-
-/// File exists
-pub const EEXIST = 17;
-
-/// Cross-device link
-pub const EXDEV = 18;
-
-/// Operation not supported by device
-pub const ENODEV = 19;
-
-/// Not a directory
-pub const ENOTDIR = 20;
-
-/// Is a directory
-pub const EISDIR = 21;
-
-/// Invalid argument
-pub const EINVAL = 22;
-
-/// Too many open files in system
-pub const ENFILE = 23;
-
-/// Too many open files
-pub const EMFILE = 24;
-
-/// Inappropriate ioctl for device
-pub const ENOTTY = 25;
-
-/// Text file busy
-pub const ETXTBSY = 26;
-
-/// File too large
-pub const EFBIG = 27;
-
-/// No space left on device
-pub const ENOSPC = 28;
-
-/// Illegal seek
-pub const ESPIPE = 29;
-
-/// Read-only file system
-pub const EROFS = 30;
-
-/// Too many links
-pub const EMLINK = 31;
-/// Broken pipe
-
-// math software
-pub const EPIPE = 32;
-
-/// Numerical argument out of domain
-pub const EDOM = 33;
-/// Result too large
-
-// non-blocking and interrupt i/o
-pub const ERANGE = 34;
-
-/// Resource temporarily unavailable
-pub const EAGAIN = 35;
-
-/// Operation would block
-pub const EWOULDBLOCK = EAGAIN;
-
-/// Operation now in progress
-pub const EINPROGRESS = 36;
-/// Operation already in progress
-
-// ipc/network software -- argument errors
-pub const EALREADY = 37;
-
-/// Socket operation on non-socket
-pub const ENOTSOCK = 38;
-
-/// Destination address required
-pub const EDESTADDRREQ = 39;
-
-/// Message too long
-pub const EMSGSIZE = 40;
-
-/// Protocol wrong type for socket
-pub const EPROTOTYPE = 41;
-
-/// Protocol not available
-pub const ENOPROTOOPT = 42;
-
-/// Protocol not supported
-pub const EPROTONOSUPPORT = 43;
-
-/// Socket type not supported
-pub const ESOCKTNOSUPPORT = 44;
-
-/// Operation not supported
-pub const ENOTSUP = 45;
-
-/// Protocol family not supported
-pub const EPFNOSUPPORT = 46;
-
-/// Address family not supported by protocol family
-pub const EAFNOSUPPORT = 47;
-
-/// Address already in use
-pub const EADDRINUSE = 48;
-/// Can't assign requested address
-
-// ipc/network software -- operational errors
-pub const EADDRNOTAVAIL = 49;
-
-/// Network is down
-pub const ENETDOWN = 50;
-
-/// Network is unreachable
-pub const ENETUNREACH = 51;
-
-/// Network dropped connection on reset
-pub const ENETRESET = 52;
-
-/// Software caused connection abort
-pub const ECONNABORTED = 53;
-
-/// Connection reset by peer
-pub const ECONNRESET = 54;
-
-/// No buffer space available
-pub const ENOBUFS = 55;
-
-/// Socket is already connected
-pub const EISCONN = 56;
-
-/// Socket is not connected
-pub const ENOTCONN = 57;
-
-/// Can't send after socket shutdown
-pub const ESHUTDOWN = 58;
-
-/// Too many references: can't splice
-pub const ETOOMANYREFS = 59;
-
-/// Operation timed out
-pub const ETIMEDOUT = 60;
-
-/// Connection refused
-pub const ECONNREFUSED = 61;
-
-/// Too many levels of symbolic links
-pub const ELOOP = 62;
-
-/// File name too long
-pub const ENAMETOOLONG = 63;
-
-/// Host is down
-pub const EHOSTDOWN = 64;
-
-/// No route to host
-pub const EHOSTUNREACH = 65;
-/// Directory not empty
-
-// quotas & mush
-pub const ENOTEMPTY = 66;
-
-/// Too many processes
-pub const EPROCLIM = 67;
-
-/// Too many users
-pub const EUSERS = 68;
-/// Disc quota exceeded
-
-// Network File System
-pub const EDQUOT = 69;
-
-/// Stale NFS file handle
-pub const ESTALE = 70;
-
-/// Too many levels of remote in path
-pub const EREMOTE = 71;
-
-/// RPC struct is bad
-pub const EBADRPC = 72;
-
-/// RPC version wrong
-pub const ERPCMISMATCH = 73;
-
-/// RPC prog. not avail
-pub const EPROGUNAVAIL = 74;
-
-/// Program version wrong
-pub const EPROGMISMATCH = 75;
-
-/// Bad procedure for program
-pub const EPROCUNAVAIL = 76;
-
-/// No locks available
-pub const ENOLCK = 77;
-
-/// Function not implemented
-pub const ENOSYS = 78;
-
-/// Inappropriate file type or format
-pub const EFTYPE = 79;
-
-/// Authentication error
-pub const EAUTH = 80;
-/// Need authenticator
-
-// Intelligent device errors
-pub const ENEEDAUTH = 81;
-
-/// Device power is off
-pub const EPWROFF = 82;
-
-/// Device error, e.g. paper out
-pub const EDEVERR = 83;
-/// Value too large to be stored in data type
-
-// Program loading errors
-pub const EOVERFLOW = 84;
-
-/// Bad executable
-pub const EBADEXEC = 85;
-
-/// Bad CPU type in executable
-pub const EBADARCH = 86;
-
-/// Shared library version mismatch
-pub const ESHLIBVERS = 87;
-
-/// Malformed Macho file
-pub const EBADMACHO = 88;
-
-/// Operation canceled
-pub const ECANCELED = 89;
-
-/// Identifier removed
-pub const EIDRM = 90;
-
-/// No message of desired type
-pub const ENOMSG = 91;
-
-/// Illegal byte sequence
-pub const EILSEQ = 92;
-
-/// Attribute not found
-pub const ENOATTR = 93;
-
-/// Bad message
-pub const EBADMSG = 94;
-
-/// Reserved
-pub const EMULTIHOP = 95;
-
-/// No message available on STREAM
-pub const ENODATA = 96;
-
-/// Reserved
-pub const ENOLINK = 97;
-
-/// No STREAM resources
-pub const ENOSR = 98;
-
-/// Not a STREAM
-pub const ENOSTR = 99;
-
-/// Protocol error
-pub const EPROTO = 100;
-
-/// STREAM ioctl timeout
-pub const ETIME = 101;
-
-/// No such policy registered
-pub const ENOPOLICY = 103;
-
-/// State not recoverable
-pub const ENOTRECOVERABLE = 104;
-
-/// Previous owner died
-pub const EOWNERDEAD = 105;
-
-/// Interface output queue is full
-pub const EQFULL = 106;
-
-/// Must be equal largest errno
-pub const ELAST = 106;
diff --git a/std/c/posix/freebsd.zig b/std/c/posix/freebsd.zig
@@ -1,839 +0,0 @@
-const std = @import("../std.zig");
-
-/// 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
-};
-
-pub const pthread_attr_t = extern struct {
- __size: [56]u8,
- __align: c_long,
-};
-
-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: u64,
- ino: u64,
- nlink: usize,
-
- mode: u16,
- __pad0: u16,
- uid: u32,
- gid: u32,
- __pad1: u32,
- rdev: u64,
-
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- birthtim: timespec,
-
- size: i64,
- blocks: i64,
- blksize: isize,
- flags: u32,
- gen: u64,
- __spare: [10]u64,
-};
-
-pub const timespec = extern struct {
- tv_sec: isize,
- tv_nsec: isize,
-};
-
-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 const in_port_t = u16;
-pub const sa_family_t = u16;
-
-pub const sockaddr = extern union {
- in: sockaddr_in,
- in6: sockaddr_in6,
-};
-
-pub const sockaddr_in = extern struct {
- len: u8,
- family: sa_family_t,
- port: in_port_t,
- addr: [16]u8,
- zero: [8]u8,
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8,
- family: sa_family_t,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-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_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 = 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_NORESERVE = 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_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 = 0o200000;
-pub const O_NOFOLLOW = 0x0100;
-pub const O_CLOEXEC = 0x00100000;
-
-pub const O_ASYNC = 0x0040;
-pub const O_DIRECT = 0x00010000;
-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 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_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-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 PROTO_ip = 0o000;
-pub const PROTO_icmp = 0o001;
-pub const PROTO_igmp = 0o002;
-pub const PROTO_ggp = 0o003;
-pub const PROTO_ipencap = 0o004;
-pub const PROTO_st = 0o005;
-pub const PROTO_tcp = 0o006;
-pub const PROTO_egp = 0o010;
-pub const PROTO_pup = 0o014;
-pub const PROTO_udp = 0o021;
-pub const PROTO_hmp = 0o024;
-pub const PROTO_xns_idp = 0o026;
-pub const PROTO_rdp = 0o033;
-pub const PROTO_iso_tp4 = 0o035;
-pub const PROTO_xtp = 0o044;
-pub const PROTO_ddp = 0o045;
-pub const PROTO_idpr_cmtp = 0o046;
-pub const PROTO_ipv6 = 0o051;
-pub const PROTO_ipv6_route = 0o053;
-pub const PROTO_ipv6_frag = 0o054;
-pub const PROTO_idrp = 0o055;
-pub const PROTO_rsvp = 0o056;
-pub const PROTO_gre = 0o057;
-pub const PROTO_esp = 0o062;
-pub const PROTO_ah = 0o063;
-pub const PROTO_skip = 0o071;
-pub const PROTO_ipv6_icmp = 0o072;
-pub const PROTO_ipv6_nonxt = 0o073;
-pub const PROTO_ipv6_opts = 0o074;
-pub const PROTO_rspf = 0o111;
-pub const PROTO_vmtp = 0o121;
-pub const PROTO_ospf = 0o131;
-pub const PROTO_ipip = 0o136;
-pub const PROTO_encap = 0o142;
-pub const PROTO_pim = 0o147;
-pub const PROTO_raw = 0o377;
-
-pub const PF_UNSPEC = 0;
-pub const PF_LOCAL = 1;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_FILE = PF_LOCAL;
-pub const PF_INET = 2;
-pub const PF_AX25 = 3;
-pub const PF_IPX = 4;
-pub const PF_APPLETALK = 5;
-pub const PF_NETROM = 6;
-pub const PF_BRIDGE = 7;
-pub const PF_ATMPVC = 8;
-pub const PF_X25 = 9;
-pub const PF_INET6 = 10;
-pub const PF_ROSE = 11;
-pub const PF_DECnet = 12;
-pub const PF_NETBEUI = 13;
-pub const PF_SECURITY = 14;
-pub const PF_KEY = 15;
-pub const PF_NETLINK = 16;
-pub const PF_ROUTE = PF_NETLINK;
-pub const PF_PACKET = 17;
-pub const PF_ASH = 18;
-pub const PF_ECONET = 19;
-pub const PF_ATMSVC = 20;
-pub const PF_RDS = 21;
-pub const PF_SNA = 22;
-pub const PF_IRDA = 23;
-pub const PF_PPPOX = 24;
-pub const PF_WANPIPE = 25;
-pub const PF_LLC = 26;
-pub const PF_IB = 27;
-pub const PF_MPLS = 28;
-pub const PF_CAN = 29;
-pub const PF_TIPC = 30;
-pub const PF_BLUETOOTH = 31;
-pub const PF_IUCV = 32;
-pub const PF_RXRPC = 33;
-pub const PF_ISDN = 34;
-pub const PF_PHONET = 35;
-pub const PF_IEEE802154 = 36;
-pub const PF_CAIF = 37;
-pub const PF_ALG = 38;
-pub const PF_NFC = 39;
-pub const PF_VSOCK = 40;
-pub const PF_MAX = 41;
-
-pub const AF_UNSPEC = PF_UNSPEC;
-pub const AF_LOCAL = PF_LOCAL;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = PF_INET;
-pub const AF_AX25 = PF_AX25;
-pub const AF_IPX = PF_IPX;
-pub const AF_APPLETALK = PF_APPLETALK;
-pub const AF_NETROM = PF_NETROM;
-pub const AF_BRIDGE = PF_BRIDGE;
-pub const AF_ATMPVC = PF_ATMPVC;
-pub const AF_X25 = PF_X25;
-pub const AF_INET6 = PF_INET6;
-pub const AF_ROSE = PF_ROSE;
-pub const AF_DECnet = PF_DECnet;
-pub const AF_NETBEUI = PF_NETBEUI;
-pub const AF_SECURITY = PF_SECURITY;
-pub const AF_KEY = PF_KEY;
-pub const AF_NETLINK = PF_NETLINK;
-pub const AF_ROUTE = PF_ROUTE;
-pub const AF_PACKET = PF_PACKET;
-pub const AF_ASH = PF_ASH;
-pub const AF_ECONET = PF_ECONET;
-pub const AF_ATMSVC = PF_ATMSVC;
-pub const AF_RDS = PF_RDS;
-pub const AF_SNA = PF_SNA;
-pub const AF_IRDA = PF_IRDA;
-pub const AF_PPPOX = PF_PPPOX;
-pub const AF_WANPIPE = PF_WANPIPE;
-pub const AF_LLC = PF_LLC;
-pub const AF_IB = PF_IB;
-pub const AF_MPLS = PF_MPLS;
-pub const AF_CAN = PF_CAN;
-pub const AF_TIPC = PF_TIPC;
-pub const AF_BLUETOOTH = PF_BLUETOOTH;
-pub const AF_IUCV = PF_IUCV;
-pub const AF_RXRPC = PF_RXRPC;
-pub const AF_ISDN = PF_ISDN;
-pub const AF_PHONET = PF_PHONET;
-pub const AF_IEEE802154 = PF_IEEE802154;
-pub const AF_CAIF = PF_CAIF;
-pub const AF_ALG = PF_ALG;
-pub const AF_NFC = PF_NFC;
-pub const AF_VSOCK = PF_VSOCK;
-pub const AF_MAX = PF_MAX;
-
-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;
-
-/// 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 TCGETS = 0x5401;
-pub const TCSETS = 0x5402;
-pub const TCSETSW = 0x5403;
-pub const TCSETSF = 0x5404;
-pub const TCGETA = 0x5405;
-pub const TCSETA = 0x5406;
-pub const TCSETAW = 0x5407;
-pub const TCSETAF = 0x5408;
-pub const TCSBRK = 0x5409;
-pub const TCXONC = 0x540A;
-pub const TCFLSH = 0x540B;
-pub const TIOCEXCL = 0x540C;
-pub const TIOCNXCL = 0x540D;
-pub const TIOCSCTTY = 0x540E;
-pub const TIOCGPGRP = 0x540F;
-pub const TIOCSPGRP = 0x5410;
-pub const TIOCOUTQ = 0x5411;
-pub const TIOCSTI = 0x5412;
-pub const TIOCGWINSZ = 0x5413;
-pub const TIOCSWINSZ = 0x5414;
-pub const TIOCMGET = 0x5415;
-pub const TIOCMBIS = 0x5416;
-pub const TIOCMBIC = 0x5417;
-pub const TIOCMSET = 0x5418;
-pub const TIOCGSOFTCAR = 0x5419;
-pub const TIOCSSOFTCAR = 0x541A;
-pub const FIONREAD = 0x541B;
-pub const TIOCINQ = FIONREAD;
-pub const TIOCLINUX = 0x541C;
-pub const TIOCCONS = 0x541D;
-pub const TIOCGSERIAL = 0x541E;
-pub const TIOCSSERIAL = 0x541F;
-pub const TIOCPKT = 0x5420;
-pub const FIONBIO = 0x5421;
-pub const TIOCNOTTY = 0x5422;
-pub const TIOCSETD = 0x5423;
-pub const TIOCGETD = 0x5424;
-pub const TCSBRKP = 0x5425;
-pub const TIOCSBRK = 0x5427;
-pub const TIOCCBRK = 0x5428;
-pub const TIOCGSID = 0x5429;
-pub const TIOCGRS485 = 0x542E;
-pub const TIOCSRS485 = 0x542F;
-pub const TIOCGPTN = 0x80045430;
-pub const TIOCSPTLCK = 0x40045431;
-pub const TIOCGDEV = 0x80045432;
-pub const TCGETX = 0x5432;
-pub const TCSETX = 0x5433;
-pub const TCSETXF = 0x5434;
-pub const TCSETXW = 0x5435;
-pub const TIOCSIG = 0x40045436;
-pub const TIOCVHANGUP = 0x5437;
-pub const TIOCGPKT = 0x80045438;
-pub const TIOCGPTLCK = 0x80045439;
-pub const TIOCGEXCL = 0x80045440;
-
-fn unsigned(s: i32) u32 {
- return @bitCast(u32, s);
-}
-fn signed(s: u32) i32 {
- return @bitCast(i32, s);
-}
-pub fn WEXITSTATUS(s: i32) i32 {
- return signed((unsigned(s) & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: i32) i32 {
- return signed(unsigned(s) & 0x7f);
-}
-pub fn WSTOPSIG(s: i32) i32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: i32) bool {
- return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: i32) bool {
- return @intCast(u16, (((unsigned(s) & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: i32) bool {
- return (unsigned(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_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
-pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
-pub const SIG_IGN = @intToPtr(extern fn (i32) 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: extern fn (i32) void,
- __sa_sigaction: extern fn (i32, *__siginfo, usize) 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 EPERM = 1; // Operation not permitted
-pub const ENOENT = 2; // No such file or directory
-pub const ESRCH = 3; // No such process
-pub const EINTR = 4; // Interrupted system call
-pub const EIO = 5; // Input/output error
-pub const ENXIO = 6; // Device not configured
-pub const E2BIG = 7; // Argument list too long
-pub const ENOEXEC = 8; // Exec format error
-pub const EBADF = 9; // Bad file descriptor
-pub const ECHILD = 10; // No child processes
-pub const EDEADLK = 11; // Resource deadlock avoided
-// 11 was EAGAIN
-pub const ENOMEM = 12; // Cannot allocate memory
-pub const EACCES = 13; // Permission denied
-pub const EFAULT = 14; // Bad address
-pub const ENOTBLK = 15; // Block device required
-pub const EBUSY = 16; // Device busy
-pub const EEXIST = 17; // File exists
-pub const EXDEV = 18; // Cross-device link
-pub const ENODEV = 19; // Operation not supported by device
-pub const ENOTDIR = 20; // Not a directory
-pub const EISDIR = 21; // Is a directory
-pub const EINVAL = 22; // Invalid argument
-pub const ENFILE = 23; // Too many open files in system
-pub const EMFILE = 24; // Too many open files
-pub const ENOTTY = 25; // Inappropriate ioctl for device
-pub const ETXTBSY = 26; // Text file busy
-pub const EFBIG = 27; // File too large
-pub const ENOSPC = 28; // No space left on device
-pub const ESPIPE = 29; // Illegal seek
-pub const EROFS = 30; // Read-only filesystem
-pub const EMLINK = 31; // Too many links
-pub const EPIPE = 32; // Broken pipe
-
-// math software
-pub const EDOM = 33; // Numerical argument out of domain
-pub const ERANGE = 34; // Result too large
-
-// non-blocking and interrupt i/o
-pub const EAGAIN = 35; // Resource temporarily unavailable
-pub const EWOULDBLOCK = EAGAIN; // Operation would block
-pub const EINPROGRESS = 36; // Operation now in progress
-pub const EALREADY = 37; // Operation already in progress
-
-// ipc/network software -- argument errors
-pub const ENOTSOCK = 38; // Socket operation on non-socket
-pub const EDESTADDRREQ = 39; // Destination address required
-pub const EMSGSIZE = 40; // Message too long
-pub const EPROTOTYPE = 41; // Protocol wrong type for socket
-pub const ENOPROTOOPT = 42; // Protocol not available
-pub const EPROTONOSUPPORT = 43; // Protocol not supported
-pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
-pub const EOPNOTSUPP = 45; // Operation not supported
-pub const ENOTSUP = EOPNOTSUPP; // Operation not supported
-pub const EPFNOSUPPORT = 46; // Protocol family not supported
-pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
-pub const EADDRINUSE = 48; // Address already in use
-pub const EADDRNOTAVAIL = 49; // Can't assign requested address
-
-// ipc/network software -- operational errors
-pub const ENETDOWN = 50; // Network is down
-pub const ENETUNREACH = 51; // Network is unreachable
-pub const ENETRESET = 52; // Network dropped connection on reset
-pub const ECONNABORTED = 53; // Software caused connection abort
-pub const ECONNRESET = 54; // Connection reset by peer
-pub const ENOBUFS = 55; // No buffer space available
-pub const EISCONN = 56; // Socket is already connected
-pub const ENOTCONN = 57; // Socket is not connected
-pub const ESHUTDOWN = 58; // Can't send after socket shutdown
-pub const ETOOMANYREFS = 59; // Too many references: can't splice
-pub const ETIMEDOUT = 60; // Operation timed out
-pub const ECONNREFUSED = 61; // Connection refused
-
-pub const ELOOP = 62; // Too many levels of symbolic links
-pub const ENAMETOOLONG = 63; // File name too long
-
-// should be rearranged
-pub const EHOSTDOWN = 64; // Host is down
-pub const EHOSTUNREACH = 65; // No route to host
-pub const ENOTEMPTY = 66; // Directory not empty
-
-// quotas & mush
-pub const EPROCLIM = 67; // Too many processes
-pub const EUSERS = 68; // Too many users
-pub const EDQUOT = 69; // Disc quota exceeded
-
-// Network File System
-pub const ESTALE = 70; // Stale NFS file handle
-pub const EREMOTE = 71; // Too many levels of remote in path
-pub const EBADRPC = 72; // RPC struct is bad
-pub const ERPCMISMATCH = 73; // RPC version wrong
-pub const EPROGUNAVAIL = 74; // RPC prog. not avail
-pub const EPROGMISMATCH = 75; // Program version wrong
-pub const EPROCUNAVAIL = 76; // Bad procedure for program
-
-pub const ENOLCK = 77; // No locks available
-pub const ENOSYS = 78; // Function not implemented
-
-pub const EFTYPE = 79; // Inappropriate file type or format
-pub const EAUTH = 80; // Authentication error
-pub const ENEEDAUTH = 81; // Need authenticator
-pub const EIDRM = 82; // Identifier removed
-pub const ENOMSG = 83; // No message of desired type
-pub const EOVERFLOW = 84; // Value too large to be stored in data type
-pub const ECANCELED = 85; // Operation canceled
-pub const EILSEQ = 86; // Illegal byte sequence
-pub const ENOATTR = 87; // Attribute not found
-
-pub const EDOOFUS = 88; // Programming error
-
-pub const EBADMSG = 89; // Bad message
-pub const EMULTIHOP = 90; // Multihop attempted
-pub const ENOLINK = 91; // Link has been severed
-pub const EPROTO = 92; // Protocol error
-
-pub const ENOTCAPABLE = 93; // Capabilities insufficient
-pub const ECAPMODE = 94; // Not permitted in capability mode
-pub const ENOTRECOVERABLE = 95; // State not recoverable
-pub const EOWNERDEAD = 96; // Previous owner died
-
-pub const ELAST = 96; // Must be equal largest errno
diff --git a/std/c/posix/netbsd.zig b/std/c/posix/netbsd.zig
@@ -1,728 +0,0 @@
-const std = @import("../../std.zig");
-const maxInt = std.math.maxInt;
-
-/// 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 pthread_attr_t = extern struct {
- pta_magic: u32,
- pta_flags: c_int,
- pta_private: *c_void,
-};
-
-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: u64,
- mode: u32,
- ino: u64,
- nlink: usize,
-
- uid: u32,
- gid: u32,
- rdev: u64,
-
- atim: timespec,
- mtim: timespec,
- ctim: timespec,
- birthtim: timespec,
-
- size: i64,
- blocks: i64,
- blksize: isize,
- flags: u32,
- gen: u32,
- __spare: [2]u32,
-};
-
-pub const timespec = extern struct {
- tv_sec: i64,
- tv_nsec: isize,
-};
-
-pub const dirent = extern struct {
- d_fileno: u64,
- d_reclen: u16,
- d_namlen: u16,
- d_type: u8,
- d_off: i64,
- d_name: [512]u8,
-};
-
-pub const in_port_t = u16;
-pub const sa_family_t = u8;
-
-pub const sockaddr = extern union {
- in: sockaddr_in,
- in6: sockaddr_in6,
-};
-
-pub const sockaddr_in = extern struct {
- len: u8,
- family: sa_family_t,
- port: in_port_t,
- addr: u32,
- zero: [8]u8,
-};
-
-pub const sockaddr_in6 = extern struct {
- len: u8,
- family: sa_family_t,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-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 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_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 = 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
-
-pub const O_RDONLY = 0x0000;
-pub const O_WRONLY = 0x0001;
-pub const O_RDWR = 0x0002;
-pub const O_ACCMODE = 0x0003;
-
-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 = 0x00010000;
-pub const O_SYNC = 0x0080;
-pub const O_RSYNC = 0x00020000;
-pub const O_DIRECTORY = 0x00080000;
-pub const O_NOFOLLOW = 0x00000100;
-pub const O_CLOEXEC = 0x00400000;
-
-pub const O_ASYNC = 0x0040;
-pub const O_DIRECT = 0x00080000;
-pub const O_LARGEFILE = 0;
-pub const O_NOATIME = 0;
-pub const O_PATH = 0;
-pub const O_TMPFILE = 0;
-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 = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-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 PROTO_ip = 0;
-pub const PROTO_icmp = 1;
-pub const PROTO_igmp = 2;
-pub const PROTO_ggp = 3;
-pub const PROTO_ipencap = 4;
-pub const PROTO_tcp = 6;
-pub const PROTO_egp = 8;
-pub const PROTO_pup = 12;
-pub const PROTO_udp = 17;
-pub const PROTO_xns_idp = 22;
-pub const PROTO_iso_tp4 = 29;
-pub const PROTO_ipv6 = 41;
-pub const PROTO_ipv6_route = 43;
-pub const PROTO_ipv6_frag = 44;
-pub const PROTO_rsvp = 46;
-pub const PROTO_gre = 47;
-pub const PROTO_esp = 50;
-pub const PROTO_ah = 51;
-pub const PROTO_ipv6_icmp = 58;
-pub const PROTO_ipv6_nonxt = 59;
-pub const PROTO_ipv6_opts = 60;
-pub const PROTO_encap = 98;
-pub const PROTO_pim = 103;
-pub const PROTO_raw = 255;
-
-pub const PF_UNSPEC = 0;
-pub const PF_LOCAL = 1;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_FILE = PF_LOCAL;
-pub const PF_INET = 2;
-pub const PF_APPLETALK = 16;
-pub const PF_INET6 = 24;
-pub const PF_DECnet = 12;
-pub const PF_KEY = 29;
-pub const PF_ROUTE = 34;
-pub const PF_SNA = 11;
-pub const PF_MPLS = 33;
-pub const PF_CAN = 35;
-pub const PF_BLUETOOTH = 31;
-pub const PF_ISDN = 26;
-pub const PF_MAX = 37;
-
-pub const AF_UNSPEC = PF_UNSPEC;
-pub const AF_LOCAL = PF_LOCAL;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = PF_INET;
-pub const AF_APPLETALK = PF_APPLETALK;
-pub const AF_INET6 = PF_INET6;
-pub const AF_KEY = PF_KEY;
-pub const AF_ROUTE = PF_ROUTE;
-pub const AF_SNA = PF_SNA;
-pub const AF_MPLS = PF_MPLS;
-pub const AF_CAN = PF_CAN;
-pub const AF_BLUETOOTH = PF_BLUETOOTH;
-pub const AF_ISDN = PF_ISDN;
-pub const AF_MAX = PF_MAX;
-
-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;
-
-fn unsigned(s: i32) u32 {
- return @bitCast(u32, s);
-}
-fn signed(s: u32) i32 {
- return @bitCast(i32, s);
-}
-pub fn WEXITSTATUS(s: i32) i32 {
- return signed((unsigned(s) >> 8) & 0xff);
-}
-pub fn WTERMSIG(s: i32) i32 {
- return signed(unsigned(s) & 0x7f);
-}
-pub fn WSTOPSIG(s: i32) i32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: i32) bool {
- return WTERMSIG(s) == 0;
-}
-
-pub fn WIFCONTINUED(s: i32) bool {
- return ((s & 0x7f) == 0xffff);
-}
-
-pub fn WIFSTOPPED(s: i32) bool {
- return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
-}
-
-pub fn WIFSIGNALED(s: i32) 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_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
-pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
-pub const SIG_IGN = @intToPtr(extern fn (i32) 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: extern fn (i32) void,
- __sa_sigaction: extern fn (i32, *__siginfo, usize) 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 EPERM = 1; // Operation not permitted
-pub const ENOENT = 2; // No such file or directory
-pub const ESRCH = 3; // No such process
-pub const EINTR = 4; // Interrupted system call
-pub const EIO = 5; // Input/output error
-pub const ENXIO = 6; // Device not configured
-pub const E2BIG = 7; // Argument list too long
-pub const ENOEXEC = 8; // Exec format error
-pub const EBADF = 9; // Bad file descriptor
-pub const ECHILD = 10; // No child processes
-pub const EDEADLK = 11; // Resource deadlock avoided
-// 11 was EAGAIN
-pub const ENOMEM = 12; // Cannot allocate memory
-pub const EACCES = 13; // Permission denied
-pub const EFAULT = 14; // Bad address
-pub const ENOTBLK = 15; // Block device required
-pub const EBUSY = 16; // Device busy
-pub const EEXIST = 17; // File exists
-pub const EXDEV = 18; // Cross-device link
-pub const ENODEV = 19; // Operation not supported by device
-pub const ENOTDIR = 20; // Not a directory
-pub const EISDIR = 21; // Is a directory
-pub const EINVAL = 22; // Invalid argument
-pub const ENFILE = 23; // Too many open files in system
-pub const EMFILE = 24; // Too many open files
-pub const ENOTTY = 25; // Inappropriate ioctl for device
-pub const ETXTBSY = 26; // Text file busy
-pub const EFBIG = 27; // File too large
-pub const ENOSPC = 28; // No space left on device
-pub const ESPIPE = 29; // Illegal seek
-pub const EROFS = 30; // Read-only file system
-pub const EMLINK = 31; // Too many links
-pub const EPIPE = 32; // Broken pipe
-
-// math software
-pub const EDOM = 33; // Numerical argument out of domain
-pub const ERANGE = 34; // Result too large or too small
-
-// non-blocking and interrupt i/o
-pub const EAGAIN = 35; // Resource temporarily unavailable
-pub const EWOULDBLOCK = EAGAIN; // Operation would block
-pub const EINPROGRESS = 36; // Operation now in progress
-pub const EALREADY = 37; // Operation already in progress
-
-// ipc/network software -- argument errors
-pub const ENOTSOCK = 38; // Socket operation on non-socket
-pub const EDESTADDRREQ = 39; // Destination address required
-pub const EMSGSIZE = 40; // Message too long
-pub const EPROTOTYPE = 41; // Protocol wrong type for socket
-pub const ENOPROTOOPT = 42; // Protocol option not available
-pub const EPROTONOSUPPORT = 43; // Protocol not supported
-pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
-pub const EOPNOTSUPP = 45; // Operation not supported
-pub const EPFNOSUPPORT = 46; // Protocol family not supported
-pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
-pub const EADDRINUSE = 48; // Address already in use
-pub const EADDRNOTAVAIL = 49; // Can't assign requested address
-
-// ipc/network software -- operational errors
-pub const ENETDOWN = 50; // Network is down
-pub const ENETUNREACH = 51; // Network is unreachable
-pub const ENETRESET = 52; // Network dropped connection on reset
-pub const ECONNABORTED = 53; // Software caused connection abort
-pub const ECONNRESET = 54; // Connection reset by peer
-pub const ENOBUFS = 55; // No buffer space available
-pub const EISCONN = 56; // Socket is already connected
-pub const ENOTCONN = 57; // Socket is not connected
-pub const ESHUTDOWN = 58; // Can't send after socket shutdown
-pub const ETOOMANYREFS = 59; // Too many references: can't splice
-pub const ETIMEDOUT = 60; // Operation timed out
-pub const ECONNREFUSED = 61; // Connection refused
-
-pub const ELOOP = 62; // Too many levels of symbolic links
-pub const ENAMETOOLONG = 63; // File name too long
-
-// should be rearranged
-pub const EHOSTDOWN = 64; // Host is down
-pub const EHOSTUNREACH = 65; // No route to host
-pub const ENOTEMPTY = 66; // Directory not empty
-
-// quotas & mush
-pub const EPROCLIM = 67; // Too many processes
-pub const EUSERS = 68; // Too many users
-pub const EDQUOT = 69; // Disc quota exceeded
-
-// Network File System
-pub const ESTALE = 70; // Stale NFS file handle
-pub const EREMOTE = 71; // Too many levels of remote in path
-pub const EBADRPC = 72; // RPC struct is bad
-pub const ERPCMISMATCH = 73; // RPC version wrong
-pub const EPROGUNAVAIL = 74; // RPC prog. not avail
-pub const EPROGMISMATCH = 75; // Program version wrong
-pub const EPROCUNAVAIL = 76; // Bad procedure for program
-
-pub const ENOLCK = 77; // No locks available
-pub const ENOSYS = 78; // Function not implemented
-
-pub const EFTYPE = 79; // Inappropriate file type or format
-pub const EAUTH = 80; // Authentication error
-pub const ENEEDAUTH = 81; // Need authenticator
-
-// SystemV IPC
-pub const EIDRM = 82; // Identifier removed
-pub const ENOMSG = 83; // No message of desired type
-pub const EOVERFLOW = 84; // Value too large to be stored in data type
-
-// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
-pub const EILSEQ = 85; // Illegal byte sequence
-
-// From IEEE Std 1003.1-2001
-// Base, Realtime, Threads or Thread Priority Scheduling option errors
-pub const ENOTSUP = 86; // Not supported
-
-// Realtime option errors
-pub const ECANCELED = 87; // Operation canceled
-
-// Realtime, XSI STREAMS option errors
-pub const EBADMSG = 88; // Bad or Corrupt message
-
-// XSI STREAMS option errors
-pub const ENODATA = 89; // No message available
-pub const ENOSR = 90; // No STREAM resources
-pub const ENOSTR = 91; // Not a STREAM
-pub const ETIME = 92; // STREAM ioctl timeout
-
-// File system extended attribute errors
-pub const ENOATTR = 93; // Attribute not found
-
-// Realtime, XSI STREAMS option errors
-pub const EMULTIHOP = 94; // Multihop attempted
-pub const ENOLINK = 95; // Link has been severed
-pub const EPROTO = 96; // Protocol error
-
-pub const ELAST = 96; // Must equal largest errno
diff --git a/std/c/posix/windows.zig b/std/c/posix/windows.zig
@@ -1,86 +0,0 @@
-pub const EPERM = 1;
-pub const ENOENT = 2;
-pub const ESRCH = 3;
-pub const EINTR = 4;
-pub const EIO = 5;
-pub const ENXIO = 6;
-pub const E2BIG = 7;
-pub const ENOEXEC = 8;
-pub const EBADF = 9;
-pub const ECHILD = 10;
-pub const EAGAIN = 11;
-pub const ENOMEM = 12;
-pub const EACCES = 13;
-pub const EFAULT = 14;
-pub const EBUSY = 16;
-pub const EEXIST = 17;
-pub const EXDEV = 18;
-pub const ENODEV = 19;
-pub const ENOTDIR = 20;
-pub const EISDIR = 21;
-pub const ENFILE = 23;
-pub const EMFILE = 24;
-pub const ENOTTY = 25;
-pub const EFBIG = 27;
-pub const ENOSPC = 28;
-pub const ESPIPE = 29;
-pub const EROFS = 30;
-pub const EMLINK = 31;
-pub const EPIPE = 32;
-pub const EDOM = 33;
-pub const EDEADLK = 36;
-pub const ENAMETOOLONG = 38;
-pub const ENOLCK = 39;
-pub const ENOSYS = 40;
-pub const ENOTEMPTY = 41;
-
-pub const EINVAL = 22;
-pub const ERANGE = 34;
-pub const EILSEQ = 42;
-pub const STRUNCATE = 80;
-
-// Support EDEADLOCK for compatibility with older Microsoft C versions
-pub const EDEADLOCK = EDEADLK;
-
-// POSIX Supplement
-pub const EADDRINUSE = 100;
-pub const EADDRNOTAVAIL = 101;
-pub const EAFNOSUPPORT = 102;
-pub const EALREADY = 103;
-pub const EBADMSG = 104;
-pub const ECANCELED = 105;
-pub const ECONNABORTED = 106;
-pub const ECONNREFUSED = 107;
-pub const ECONNRESET = 108;
-pub const EDESTADDRREQ = 109;
-pub const EHOSTUNREACH = 110;
-pub const EIDRM = 111;
-pub const EINPROGRESS = 112;
-pub const EISCONN = 113;
-pub const ELOOP = 114;
-pub const EMSGSIZE = 115;
-pub const ENETDOWN = 116;
-pub const ENETRESET = 117;
-pub const ENETUNREACH = 118;
-pub const ENOBUFS = 119;
-pub const ENODATA = 120;
-pub const ENOLINK = 121;
-pub const ENOMSG = 122;
-pub const ENOPROTOOPT = 123;
-pub const ENOSR = 124;
-pub const ENOSTR = 125;
-pub const ENOTCONN = 126;
-pub const ENOTRECOVERABLE = 127;
-pub const ENOTSOCK = 128;
-pub const ENOTSUP = 129;
-pub const EOPNOTSUPP = 130;
-pub const EOTHER = 131;
-pub const EOVERFLOW = 132;
-pub const EOWNERDEAD = 133;
-pub const EPROTO = 134;
-pub const EPROTONOSUPPORT = 135;
-pub const EPROTOTYPE = 136;
-pub const ETIME = 137;
-pub const ETIMEDOUT = 138;
-pub const ETXTBSY = 139;
-pub const EWOULDBLOCK = 140;
diff --git a/std/os.zig b/std/os.zig
@@ -19,7 +19,7 @@ const builtin = @import("builtin");
const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES;
comptime {
- assert(@import("std") == std); // You have to run the std lib tests with --override-std-dir
+ assert(@import("std") == std); // std lib tests require --override-std-dir
}
pub const darwin = @import("os/darwin.zig");
@@ -43,6 +43,8 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) {
else => struct {},
};
+pub use @import("os/bits.zig");
+
/// See also `getenv`.
pub var environ: [][*]u8 = undefined;
diff --git a/std/os/bits.zig b/std/os/bits.zig
@@ -0,0 +1,27 @@
+// Platform-dependent types and values that are used along with OS-specific APIs.
+// These are imported into `std.c`, `std.os`, and `std.os.linux`.
+
+const builtin = @import("builtin");
+
+pub use switch (builtin.os) {
+ .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"),
+ .freebsd => @import("bits/freebsd.zig"),
+ .linux => @import("bits/linux.zig"),
+ .netbsd => @import("bits/netbsd.zig"),
+ .wasi => @import("bits/wasi.zig"),
+ .windows => @import("bits/windows.zig"),
+ else => struct {},
+};
+
+pub const pthread_t = *@OpaqueType();
+pub const FILE = @OpaqueType();
+
+pub const iovec = extern struct {
+ iov_base: [*]u8,
+ iov_len: usize,
+};
+
+pub const iovec_const = extern struct {
+ iov_base: [*]const u8,
+ iov_len: usize,
+};
diff --git a/std/os/bits/darwin.zig b/std/os/bits/darwin.zig
@@ -0,0 +1,1102 @@
+const std = @import("../../std.zig");
+const assert = std.debug.assert;
+
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+
+pub fn sigaction(sig: u5, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
+ assert(sig != SIGKILL);
+ assert(sig != SIGSTOP);
+ var cact = c.Sigaction{
+ .handler = @ptrCast(extern fn (c_int) void, act.handler),
+ .sa_flags = @bitCast(c_int, act.flags),
+ .sa_mask = act.mask,
+ };
+ var coact: c.Sigaction = undefined;
+ const result = errnoWrap(c.sigaction(sig, &cact, &coact));
+ if (result != 0) {
+ return result;
+ }
+ if (oact) |old| {
+ old.* = Sigaction{
+ .handler = @ptrCast(extern fn (i32) void, coact.handler),
+ .flags = @bitCast(u32, coact.sa_flags),
+ .mask = coact.sa_mask,
+ };
+ }
+ return result;
+}
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+pub const socklen_t = u32;
+pub const sockaddr = extern union {
+ in: sockaddr_in,
+ in6: sockaddr_in6,
+};
+pub const sockaddr_in = extern struct {
+ len: u8,
+ family: sa_family_t,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8,
+};
+pub const sockaddr_in6 = extern struct {
+ len: u8,
+ family: sa_family_t,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+};
+
+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,
+};
+
+/// Renamed to Stat to not conflict with the stat function.
+pub const Stat = extern struct {
+ dev: i32,
+ mode: u16,
+ nlink: u16,
+ ino: u64,
+ uid: u32,
+ gid: u32,
+ rdev: i32,
+ atime: usize,
+ atimensec: usize,
+ mtime: usize,
+ mtimensec: usize,
+ ctime: usize,
+ ctimensec: usize,
+ birthtime: usize,
+ birthtimensec: usize,
+ size: i64,
+ blocks: i64,
+ blksize: i32,
+ flags: u32,
+ gen: u32,
+ lspare: i32,
+ qspare: [2]i64,
+};
+
+pub const timespec = extern struct {
+ tv_sec: isize,
+ tv_nsec: isize,
+};
+
+pub const sigset_t = u32;
+pub const empty_sigset = sigset_t(0);
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
+pub const Sigaction = extern struct {
+ handler: extern fn (c_int) void,
+ sa_mask: sigset_t,
+ sa_flags: c_int,
+};
+
+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 const pthread_attr_t = extern struct {
+ __sig: c_long,
+ __opaque: [56]u8,
+};
+
+/// 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(@byteOffsetOf(Kevent, "ident") == 0);
+ assert(@byteOffsetOf(Kevent, "filter") == 8);
+ assert(@byteOffsetOf(Kevent, "flags") == 10);
+ assert(@byteOffsetOf(Kevent, "fflags") == 12);
+ assert(@byteOffsetOf(Kevent, "data") == 16);
+ assert(@byteOffsetOf(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(@byteOffsetOf(kevent64_s, "ident") == 0);
+ assert(@byteOffsetOf(kevent64_s, "filter") == 8);
+ assert(@byteOffsetOf(kevent64_s, "flags") == 10);
+ assert(@byteOffsetOf(kevent64_s, "fflags") == 12);
+ assert(@byteOffsetOf(kevent64_s, "data") == 16);
+ assert(@byteOffsetOf(kevent64_s, "udata") == 24);
+ assert(@byteOffsetOf(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 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 = 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_LARGEFILE = 0x0000;
+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<OSTOP)
+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;
+
+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;
+
+fn wstatus(x: i32) i32 {
+ return x & 0o177;
+}
+const wstopped = 0o177;
+pub fn WEXITSTATUS(x: i32) i32 {
+ return x >> 8;
+}
+pub fn WTERMSIG(x: i32) i32 {
+ return wstatus(x);
+}
+pub fn WSTOPSIG(x: i32) i32 {
+ return x >> 8;
+}
+pub fn WIFEXITED(x: i32) bool {
+ return wstatus(x) == 0;
+}
+pub fn WIFSTOPPED(x: i32) bool {
+ return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13;
+}
+pub fn WIFSIGNALED(x: i32) bool {
+ return wstatus(x) != wstopped and wstatus(x) != 0;
+}
+
+/// Operation not permitted
+pub const EPERM = 1;
+
+/// No such file or directory
+pub const ENOENT = 2;
+
+/// No such process
+pub const ESRCH = 3;
+
+/// Interrupted system call
+pub const EINTR = 4;
+
+/// Input/output error
+pub const EIO = 5;
+
+/// Device not configured
+pub const ENXIO = 6;
+
+/// Argument list too long
+pub const E2BIG = 7;
+
+/// Exec format error
+pub const ENOEXEC = 8;
+
+/// Bad file descriptor
+pub const EBADF = 9;
+
+/// No child processes
+pub const ECHILD = 10;
+
+/// Resource deadlock avoided
+pub const EDEADLK = 11;
+
+/// Cannot allocate memory
+pub const ENOMEM = 12;
+
+/// Permission denied
+pub const EACCES = 13;
+
+/// Bad address
+pub const EFAULT = 14;
+
+/// Block device required
+pub const ENOTBLK = 15;
+
+/// Device / Resource busy
+pub const EBUSY = 16;
+
+/// File exists
+pub const EEXIST = 17;
+
+/// Cross-device link
+pub const EXDEV = 18;
+
+/// Operation not supported by device
+pub const ENODEV = 19;
+
+/// Not a directory
+pub const ENOTDIR = 20;
+
+/// Is a directory
+pub const EISDIR = 21;
+
+/// Invalid argument
+pub const EINVAL = 22;
+
+/// Too many open files in system
+pub const ENFILE = 23;
+
+/// Too many open files
+pub const EMFILE = 24;
+
+/// Inappropriate ioctl for device
+pub const ENOTTY = 25;
+
+/// Text file busy
+pub const ETXTBSY = 26;
+
+/// File too large
+pub const EFBIG = 27;
+
+/// No space left on device
+pub const ENOSPC = 28;
+
+/// Illegal seek
+pub const ESPIPE = 29;
+
+/// Read-only file system
+pub const EROFS = 30;
+
+/// Too many links
+pub const EMLINK = 31;
+/// Broken pipe
+
+// math software
+pub const EPIPE = 32;
+
+/// Numerical argument out of domain
+pub const EDOM = 33;
+/// Result too large
+
+// non-blocking and interrupt i/o
+pub const ERANGE = 34;
+
+/// Resource temporarily unavailable
+pub const EAGAIN = 35;
+
+/// Operation would block
+pub const EWOULDBLOCK = EAGAIN;
+
+/// Operation now in progress
+pub const EINPROGRESS = 36;
+/// Operation already in progress
+
+// ipc/network software -- argument errors
+pub const EALREADY = 37;
+
+/// Socket operation on non-socket
+pub const ENOTSOCK = 38;
+
+/// Destination address required
+pub const EDESTADDRREQ = 39;
+
+/// Message too long
+pub const EMSGSIZE = 40;
+
+/// Protocol wrong type for socket
+pub const EPROTOTYPE = 41;
+
+/// Protocol not available
+pub const ENOPROTOOPT = 42;
+
+/// Protocol not supported
+pub const EPROTONOSUPPORT = 43;
+
+/// Socket type not supported
+pub const ESOCKTNOSUPPORT = 44;
+
+/// Operation not supported
+pub const ENOTSUP = 45;
+
+/// Protocol family not supported
+pub const EPFNOSUPPORT = 46;
+
+/// Address family not supported by protocol family
+pub const EAFNOSUPPORT = 47;
+
+/// Address already in use
+pub const EADDRINUSE = 48;
+/// Can't assign requested address
+
+// ipc/network software -- operational errors
+pub const EADDRNOTAVAIL = 49;
+
+/// Network is down
+pub const ENETDOWN = 50;
+
+/// Network is unreachable
+pub const ENETUNREACH = 51;
+
+/// Network dropped connection on reset
+pub const ENETRESET = 52;
+
+/// Software caused connection abort
+pub const ECONNABORTED = 53;
+
+/// Connection reset by peer
+pub const ECONNRESET = 54;
+
+/// No buffer space available
+pub const ENOBUFS = 55;
+
+/// Socket is already connected
+pub const EISCONN = 56;
+
+/// Socket is not connected
+pub const ENOTCONN = 57;
+
+/// Can't send after socket shutdown
+pub const ESHUTDOWN = 58;
+
+/// Too many references: can't splice
+pub const ETOOMANYREFS = 59;
+
+/// Operation timed out
+pub const ETIMEDOUT = 60;
+
+/// Connection refused
+pub const ECONNREFUSED = 61;
+
+/// Too many levels of symbolic links
+pub const ELOOP = 62;
+
+/// File name too long
+pub const ENAMETOOLONG = 63;
+
+/// Host is down
+pub const EHOSTDOWN = 64;
+
+/// No route to host
+pub const EHOSTUNREACH = 65;
+/// Directory not empty
+
+// quotas & mush
+pub const ENOTEMPTY = 66;
+
+/// Too many processes
+pub const EPROCLIM = 67;
+
+/// Too many users
+pub const EUSERS = 68;
+/// Disc quota exceeded
+
+// Network File System
+pub const EDQUOT = 69;
+
+/// Stale NFS file handle
+pub const ESTALE = 70;
+
+/// Too many levels of remote in path
+pub const EREMOTE = 71;
+
+/// RPC struct is bad
+pub const EBADRPC = 72;
+
+/// RPC version wrong
+pub const ERPCMISMATCH = 73;
+
+/// RPC prog. not avail
+pub const EPROGUNAVAIL = 74;
+
+/// Program version wrong
+pub const EPROGMISMATCH = 75;
+
+/// Bad procedure for program
+pub const EPROCUNAVAIL = 76;
+
+/// No locks available
+pub const ENOLCK = 77;
+
+/// Function not implemented
+pub const ENOSYS = 78;
+
+/// Inappropriate file type or format
+pub const EFTYPE = 79;
+
+/// Authentication error
+pub const EAUTH = 80;
+/// Need authenticator
+
+// Intelligent device errors
+pub const ENEEDAUTH = 81;
+
+/// Device power is off
+pub const EPWROFF = 82;
+
+/// Device error, e.g. paper out
+pub const EDEVERR = 83;
+/// Value too large to be stored in data type
+
+// Program loading errors
+pub const EOVERFLOW = 84;
+
+/// Bad executable
+pub const EBADEXEC = 85;
+
+/// Bad CPU type in executable
+pub const EBADARCH = 86;
+
+/// Shared library version mismatch
+pub const ESHLIBVERS = 87;
+
+/// Malformed Macho file
+pub const EBADMACHO = 88;
+
+/// Operation canceled
+pub const ECANCELED = 89;
+
+/// Identifier removed
+pub const EIDRM = 90;
+
+/// No message of desired type
+pub const ENOMSG = 91;
+
+/// Illegal byte sequence
+pub const EILSEQ = 92;
+
+/// Attribute not found
+pub const ENOATTR = 93;
+
+/// Bad message
+pub const EBADMSG = 94;
+
+/// Reserved
+pub const EMULTIHOP = 95;
+
+/// No message available on STREAM
+pub const ENODATA = 96;
+
+/// Reserved
+pub const ENOLINK = 97;
+
+/// No STREAM resources
+pub const ENOSR = 98;
+
+/// Not a STREAM
+pub const ENOSTR = 99;
+
+/// Protocol error
+pub const EPROTO = 100;
+
+/// STREAM ioctl timeout
+pub const ETIME = 101;
+
+/// No such policy registered
+pub const ENOPOLICY = 103;
+
+/// State not recoverable
+pub const ENOTRECOVERABLE = 104;
+
+/// Previous owner died
+pub const EOWNERDEAD = 105;
+
+/// Interface output queue is full
+pub const EQFULL = 106;
+
+/// Must be equal largest errno
+pub const ELAST = 106;
diff --git a/std/os/bits/freebsd.zig b/std/os/bits/freebsd.zig
@@ -0,0 +1,840 @@
+pub const fd_t = c_int;
+pub const pid_t = c_int;
+
+/// 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
+};
+
+pub const pthread_attr_t = extern struct {
+ __size: [56]u8,
+ __align: c_long,
+};
+
+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: u64,
+ ino: u64,
+ nlink: usize,
+
+ mode: u16,
+ __pad0: u16,
+ uid: u32,
+ gid: u32,
+ __pad1: u32,
+ rdev: u64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ birthtim: timespec,
+
+ size: i64,
+ blocks: i64,
+ blksize: isize,
+ flags: u32,
+ gen: u64,
+ __spare: [10]u64,
+};
+
+pub const timespec = extern struct {
+ tv_sec: isize,
+ tv_nsec: isize,
+};
+
+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 const in_port_t = u16;
+pub const sa_family_t = u16;
+
+pub const sockaddr = extern union {
+ in: sockaddr_in,
+ in6: sockaddr_in6,
+};
+
+pub const sockaddr_in = extern struct {
+ len: u8,
+ family: sa_family_t,
+ port: in_port_t,
+ addr: [16]u8,
+ zero: [8]u8,
+};
+
+pub const sockaddr_in6 = extern struct {
+ len: u8,
+ family: sa_family_t,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+};
+
+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_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 = 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_NORESERVE = 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_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 = 0o200000;
+pub const O_NOFOLLOW = 0x0100;
+pub const O_CLOEXEC = 0x00100000;
+
+pub const O_ASYNC = 0x0040;
+pub const O_DIRECT = 0x00010000;
+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 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_SETOWN = 8;
+pub const F_GETOWN = 9;
+pub const F_SETSIG = 10;
+pub const F_GETSIG = 11;
+
+pub const F_GETLK = 5;
+pub const F_SETLK = 6;
+pub const F_SETLKW = 7;
+
+pub const F_SETOWN_EX = 15;
+pub const F_GETOWN_EX = 16;
+
+pub const F_GETOWNER_UIDS = 17;
+
+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 PROTO_ip = 0o000;
+pub const PROTO_icmp = 0o001;
+pub const PROTO_igmp = 0o002;
+pub const PROTO_ggp = 0o003;
+pub const PROTO_ipencap = 0o004;
+pub const PROTO_st = 0o005;
+pub const PROTO_tcp = 0o006;
+pub const PROTO_egp = 0o010;
+pub const PROTO_pup = 0o014;
+pub const PROTO_udp = 0o021;
+pub const PROTO_hmp = 0o024;
+pub const PROTO_xns_idp = 0o026;
+pub const PROTO_rdp = 0o033;
+pub const PROTO_iso_tp4 = 0o035;
+pub const PROTO_xtp = 0o044;
+pub const PROTO_ddp = 0o045;
+pub const PROTO_idpr_cmtp = 0o046;
+pub const PROTO_ipv6 = 0o051;
+pub const PROTO_ipv6_route = 0o053;
+pub const PROTO_ipv6_frag = 0o054;
+pub const PROTO_idrp = 0o055;
+pub const PROTO_rsvp = 0o056;
+pub const PROTO_gre = 0o057;
+pub const PROTO_esp = 0o062;
+pub const PROTO_ah = 0o063;
+pub const PROTO_skip = 0o071;
+pub const PROTO_ipv6_icmp = 0o072;
+pub const PROTO_ipv6_nonxt = 0o073;
+pub const PROTO_ipv6_opts = 0o074;
+pub const PROTO_rspf = 0o111;
+pub const PROTO_vmtp = 0o121;
+pub const PROTO_ospf = 0o131;
+pub const PROTO_ipip = 0o136;
+pub const PROTO_encap = 0o142;
+pub const PROTO_pim = 0o147;
+pub const PROTO_raw = 0o377;
+
+pub const PF_UNSPEC = 0;
+pub const PF_LOCAL = 1;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_FILE = PF_LOCAL;
+pub const PF_INET = 2;
+pub const PF_AX25 = 3;
+pub const PF_IPX = 4;
+pub const PF_APPLETALK = 5;
+pub const PF_NETROM = 6;
+pub const PF_BRIDGE = 7;
+pub const PF_ATMPVC = 8;
+pub const PF_X25 = 9;
+pub const PF_INET6 = 10;
+pub const PF_ROSE = 11;
+pub const PF_DECnet = 12;
+pub const PF_NETBEUI = 13;
+pub const PF_SECURITY = 14;
+pub const PF_KEY = 15;
+pub const PF_NETLINK = 16;
+pub const PF_ROUTE = PF_NETLINK;
+pub const PF_PACKET = 17;
+pub const PF_ASH = 18;
+pub const PF_ECONET = 19;
+pub const PF_ATMSVC = 20;
+pub const PF_RDS = 21;
+pub const PF_SNA = 22;
+pub const PF_IRDA = 23;
+pub const PF_PPPOX = 24;
+pub const PF_WANPIPE = 25;
+pub const PF_LLC = 26;
+pub const PF_IB = 27;
+pub const PF_MPLS = 28;
+pub const PF_CAN = 29;
+pub const PF_TIPC = 30;
+pub const PF_BLUETOOTH = 31;
+pub const PF_IUCV = 32;
+pub const PF_RXRPC = 33;
+pub const PF_ISDN = 34;
+pub const PF_PHONET = 35;
+pub const PF_IEEE802154 = 36;
+pub const PF_CAIF = 37;
+pub const PF_ALG = 38;
+pub const PF_NFC = 39;
+pub const PF_VSOCK = 40;
+pub const PF_MAX = 41;
+
+pub const AF_UNSPEC = PF_UNSPEC;
+pub const AF_LOCAL = PF_LOCAL;
+pub const AF_UNIX = AF_LOCAL;
+pub const AF_FILE = AF_LOCAL;
+pub const AF_INET = PF_INET;
+pub const AF_AX25 = PF_AX25;
+pub const AF_IPX = PF_IPX;
+pub const AF_APPLETALK = PF_APPLETALK;
+pub const AF_NETROM = PF_NETROM;
+pub const AF_BRIDGE = PF_BRIDGE;
+pub const AF_ATMPVC = PF_ATMPVC;
+pub const AF_X25 = PF_X25;
+pub const AF_INET6 = PF_INET6;
+pub const AF_ROSE = PF_ROSE;
+pub const AF_DECnet = PF_DECnet;
+pub const AF_NETBEUI = PF_NETBEUI;
+pub const AF_SECURITY = PF_SECURITY;
+pub const AF_KEY = PF_KEY;
+pub const AF_NETLINK = PF_NETLINK;
+pub const AF_ROUTE = PF_ROUTE;
+pub const AF_PACKET = PF_PACKET;
+pub const AF_ASH = PF_ASH;
+pub const AF_ECONET = PF_ECONET;
+pub const AF_ATMSVC = PF_ATMSVC;
+pub const AF_RDS = PF_RDS;
+pub const AF_SNA = PF_SNA;
+pub const AF_IRDA = PF_IRDA;
+pub const AF_PPPOX = PF_PPPOX;
+pub const AF_WANPIPE = PF_WANPIPE;
+pub const AF_LLC = PF_LLC;
+pub const AF_IB = PF_IB;
+pub const AF_MPLS = PF_MPLS;
+pub const AF_CAN = PF_CAN;
+pub const AF_TIPC = PF_TIPC;
+pub const AF_BLUETOOTH = PF_BLUETOOTH;
+pub const AF_IUCV = PF_IUCV;
+pub const AF_RXRPC = PF_RXRPC;
+pub const AF_ISDN = PF_ISDN;
+pub const AF_PHONET = PF_PHONET;
+pub const AF_IEEE802154 = PF_IEEE802154;
+pub const AF_CAIF = PF_CAIF;
+pub const AF_ALG = PF_ALG;
+pub const AF_NFC = PF_NFC;
+pub const AF_VSOCK = PF_VSOCK;
+pub const AF_MAX = PF_MAX;
+
+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;
+
+/// 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 TCGETS = 0x5401;
+pub const TCSETS = 0x5402;
+pub const TCSETSW = 0x5403;
+pub const TCSETSF = 0x5404;
+pub const TCGETA = 0x5405;
+pub const TCSETA = 0x5406;
+pub const TCSETAW = 0x5407;
+pub const TCSETAF = 0x5408;
+pub const TCSBRK = 0x5409;
+pub const TCXONC = 0x540A;
+pub const TCFLSH = 0x540B;
+pub const TIOCEXCL = 0x540C;
+pub const TIOCNXCL = 0x540D;
+pub const TIOCSCTTY = 0x540E;
+pub const TIOCGPGRP = 0x540F;
+pub const TIOCSPGRP = 0x5410;
+pub const TIOCOUTQ = 0x5411;
+pub const TIOCSTI = 0x5412;
+pub const TIOCGWINSZ = 0x5413;
+pub const TIOCSWINSZ = 0x5414;
+pub const TIOCMGET = 0x5415;
+pub const TIOCMBIS = 0x5416;
+pub const TIOCMBIC = 0x5417;
+pub const TIOCMSET = 0x5418;
+pub const TIOCGSOFTCAR = 0x5419;
+pub const TIOCSSOFTCAR = 0x541A;
+pub const FIONREAD = 0x541B;
+pub const TIOCINQ = FIONREAD;
+pub const TIOCLINUX = 0x541C;
+pub const TIOCCONS = 0x541D;
+pub const TIOCGSERIAL = 0x541E;
+pub const TIOCSSERIAL = 0x541F;
+pub const TIOCPKT = 0x5420;
+pub const FIONBIO = 0x5421;
+pub const TIOCNOTTY = 0x5422;
+pub const TIOCSETD = 0x5423;
+pub const TIOCGETD = 0x5424;
+pub const TCSBRKP = 0x5425;
+pub const TIOCSBRK = 0x5427;
+pub const TIOCCBRK = 0x5428;
+pub const TIOCGSID = 0x5429;
+pub const TIOCGRS485 = 0x542E;
+pub const TIOCSRS485 = 0x542F;
+pub const TIOCGPTN = 0x80045430;
+pub const TIOCSPTLCK = 0x40045431;
+pub const TIOCGDEV = 0x80045432;
+pub const TCGETX = 0x5432;
+pub const TCSETX = 0x5433;
+pub const TCSETXF = 0x5434;
+pub const TCSETXW = 0x5435;
+pub const TIOCSIG = 0x40045436;
+pub const TIOCVHANGUP = 0x5437;
+pub const TIOCGPKT = 0x80045438;
+pub const TIOCGPTLCK = 0x80045439;
+pub const TIOCGEXCL = 0x80045440;
+
+fn unsigned(s: i32) u32 {
+ return @bitCast(u32, s);
+}
+fn signed(s: u32) i32 {
+ return @bitCast(i32, s);
+}
+pub fn WEXITSTATUS(s: i32) i32 {
+ return signed((unsigned(s) & 0xff00) >> 8);
+}
+pub fn WTERMSIG(s: i32) i32 {
+ return signed(unsigned(s) & 0x7f);
+}
+pub fn WSTOPSIG(s: i32) i32 {
+ return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: i32) bool {
+ return WTERMSIG(s) == 0;
+}
+pub fn WIFSTOPPED(s: i32) bool {
+ return @intCast(u16, (((unsigned(s) & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
+}
+pub fn WIFSIGNALED(s: i32) bool {
+ return (unsigned(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_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
+pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
+pub const SIG_IGN = @intToPtr(extern fn (i32) 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: extern fn (i32) void,
+ __sa_sigaction: extern fn (i32, *__siginfo, usize) 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 EPERM = 1; // Operation not permitted
+pub const ENOENT = 2; // No such file or directory
+pub const ESRCH = 3; // No such process
+pub const EINTR = 4; // Interrupted system call
+pub const EIO = 5; // Input/output error
+pub const ENXIO = 6; // Device not configured
+pub const E2BIG = 7; // Argument list too long
+pub const ENOEXEC = 8; // Exec format error
+pub const EBADF = 9; // Bad file descriptor
+pub const ECHILD = 10; // No child processes
+pub const EDEADLK = 11; // Resource deadlock avoided
+// 11 was EAGAIN
+pub const ENOMEM = 12; // Cannot allocate memory
+pub const EACCES = 13; // Permission denied
+pub const EFAULT = 14; // Bad address
+pub const ENOTBLK = 15; // Block device required
+pub const EBUSY = 16; // Device busy
+pub const EEXIST = 17; // File exists
+pub const EXDEV = 18; // Cross-device link
+pub const ENODEV = 19; // Operation not supported by device
+pub const ENOTDIR = 20; // Not a directory
+pub const EISDIR = 21; // Is a directory
+pub const EINVAL = 22; // Invalid argument
+pub const ENFILE = 23; // Too many open files in system
+pub const EMFILE = 24; // Too many open files
+pub const ENOTTY = 25; // Inappropriate ioctl for device
+pub const ETXTBSY = 26; // Text file busy
+pub const EFBIG = 27; // File too large
+pub const ENOSPC = 28; // No space left on device
+pub const ESPIPE = 29; // Illegal seek
+pub const EROFS = 30; // Read-only filesystem
+pub const EMLINK = 31; // Too many links
+pub const EPIPE = 32; // Broken pipe
+
+// math software
+pub const EDOM = 33; // Numerical argument out of domain
+pub const ERANGE = 34; // Result too large
+
+// non-blocking and interrupt i/o
+pub const EAGAIN = 35; // Resource temporarily unavailable
+pub const EWOULDBLOCK = EAGAIN; // Operation would block
+pub const EINPROGRESS = 36; // Operation now in progress
+pub const EALREADY = 37; // Operation already in progress
+
+// ipc/network software -- argument errors
+pub const ENOTSOCK = 38; // Socket operation on non-socket
+pub const EDESTADDRREQ = 39; // Destination address required
+pub const EMSGSIZE = 40; // Message too long
+pub const EPROTOTYPE = 41; // Protocol wrong type for socket
+pub const ENOPROTOOPT = 42; // Protocol not available
+pub const EPROTONOSUPPORT = 43; // Protocol not supported
+pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
+pub const EOPNOTSUPP = 45; // Operation not supported
+pub const ENOTSUP = EOPNOTSUPP; // Operation not supported
+pub const EPFNOSUPPORT = 46; // Protocol family not supported
+pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
+pub const EADDRINUSE = 48; // Address already in use
+pub const EADDRNOTAVAIL = 49; // Can't assign requested address
+
+// ipc/network software -- operational errors
+pub const ENETDOWN = 50; // Network is down
+pub const ENETUNREACH = 51; // Network is unreachable
+pub const ENETRESET = 52; // Network dropped connection on reset
+pub const ECONNABORTED = 53; // Software caused connection abort
+pub const ECONNRESET = 54; // Connection reset by peer
+pub const ENOBUFS = 55; // No buffer space available
+pub const EISCONN = 56; // Socket is already connected
+pub const ENOTCONN = 57; // Socket is not connected
+pub const ESHUTDOWN = 58; // Can't send after socket shutdown
+pub const ETOOMANYREFS = 59; // Too many references: can't splice
+pub const ETIMEDOUT = 60; // Operation timed out
+pub const ECONNREFUSED = 61; // Connection refused
+
+pub const ELOOP = 62; // Too many levels of symbolic links
+pub const ENAMETOOLONG = 63; // File name too long
+
+// should be rearranged
+pub const EHOSTDOWN = 64; // Host is down
+pub const EHOSTUNREACH = 65; // No route to host
+pub const ENOTEMPTY = 66; // Directory not empty
+
+// quotas & mush
+pub const EPROCLIM = 67; // Too many processes
+pub const EUSERS = 68; // Too many users
+pub const EDQUOT = 69; // Disc quota exceeded
+
+// Network File System
+pub const ESTALE = 70; // Stale NFS file handle
+pub const EREMOTE = 71; // Too many levels of remote in path
+pub const EBADRPC = 72; // RPC struct is bad
+pub const ERPCMISMATCH = 73; // RPC version wrong
+pub const EPROGUNAVAIL = 74; // RPC prog. not avail
+pub const EPROGMISMATCH = 75; // Program version wrong
+pub const EPROCUNAVAIL = 76; // Bad procedure for program
+
+pub const ENOLCK = 77; // No locks available
+pub const ENOSYS = 78; // Function not implemented
+
+pub const EFTYPE = 79; // Inappropriate file type or format
+pub const EAUTH = 80; // Authentication error
+pub const ENEEDAUTH = 81; // Need authenticator
+pub const EIDRM = 82; // Identifier removed
+pub const ENOMSG = 83; // No message of desired type
+pub const EOVERFLOW = 84; // Value too large to be stored in data type
+pub const ECANCELED = 85; // Operation canceled
+pub const EILSEQ = 86; // Illegal byte sequence
+pub const ENOATTR = 87; // Attribute not found
+
+pub const EDOOFUS = 88; // Programming error
+
+pub const EBADMSG = 89; // Bad message
+pub const EMULTIHOP = 90; // Multihop attempted
+pub const ENOLINK = 91; // Link has been severed
+pub const EPROTO = 92; // Protocol error
+
+pub const ENOTCAPABLE = 93; // Capabilities insufficient
+pub const ECAPMODE = 94; // Not permitted in capability mode
+pub const ENOTRECOVERABLE = 95; // State not recoverable
+pub const EOWNERDEAD = 96; // Previous owner died
+
+pub const ELAST = 96; // Must be equal largest errno
diff --git a/std/os/bits/linux.zig b/std/os/bits/linux.zig
@@ -0,0 +1,919 @@
+pub use @import("errno.zig");
+pub use switch (builtin.arch) {
+ .x86_64 => @import("linux/x86_64.zig"),
+ .aarch64 => @import("linux/arm64.zig"),
+ else => struct {},
+};
+
+pub const pid_t = i32;
+pub const fd_t = i32;
+
+pub const PATH_MAX = 4096;
+pub const IOV_MAX = 1024;
+
+pub const STDIN_FILENO = 0;
+pub const STDOUT_FILENO = 1;
+pub const STDERR_FILENO = 2;
+
+pub const FUTEX_WAIT = 0;
+pub const FUTEX_WAKE = 1;
+pub const FUTEX_FD = 2;
+pub const FUTEX_REQUEUE = 3;
+pub const FUTEX_CMP_REQUEUE = 4;
+pub const FUTEX_WAKE_OP = 5;
+pub const FUTEX_LOCK_PI = 6;
+pub const FUTEX_UNLOCK_PI = 7;
+pub const FUTEX_TRYLOCK_PI = 8;
+pub const FUTEX_WAIT_BITSET = 9;
+
+pub const FUTEX_PRIVATE_FLAG = 128;
+
+pub const FUTEX_CLOCK_REALTIME = 256;
+
+pub const PROT_NONE = 0;
+pub const PROT_READ = 1;
+pub const PROT_WRITE = 2;
+pub const PROT_EXEC = 4;
+pub const PROT_GROWSDOWN = 0x01000000;
+pub const PROT_GROWSUP = 0x02000000;
+
+pub const MAP_FAILED = maxInt(usize);
+pub const MAP_SHARED = 0x01;
+pub const MAP_PRIVATE = 0x02;
+pub const MAP_TYPE = 0x0f;
+pub const MAP_FIXED = 0x10;
+pub const MAP_ANONYMOUS = 0x20;
+pub const MAP_NORESERVE = 0x4000;
+pub const MAP_GROWSDOWN = 0x0100;
+pub const MAP_DENYWRITE = 0x0800;
+pub const MAP_EXECUTABLE = 0x1000;
+pub const MAP_LOCKED = 0x2000;
+pub const MAP_POPULATE = 0x8000;
+pub const MAP_NONBLOCK = 0x10000;
+pub const MAP_STACK = 0x20000;
+pub const MAP_HUGETLB = 0x40000;
+pub const MAP_FILE = 0;
+
+pub const F_OK = 0;
+pub const X_OK = 1;
+pub const W_OK = 2;
+pub const R_OK = 4;
+
+pub const WNOHANG = 1;
+pub const WUNTRACED = 2;
+pub const WSTOPPED = 2;
+pub const WEXITED = 4;
+pub const WCONTINUED = 8;
+pub const WNOWAIT = 0x1000000;
+
+pub const SA_NOCLDSTOP = 1;
+pub const SA_NOCLDWAIT = 2;
+pub const SA_SIGINFO = 4;
+pub const SA_ONSTACK = 0x08000000;
+pub const SA_RESTART = 0x10000000;
+pub const SA_NODEFER = 0x40000000;
+pub const SA_RESETHAND = 0x80000000;
+pub const SA_RESTORER = 0x04000000;
+
+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 SIGBUS = 7;
+pub const SIGFPE = 8;
+pub const SIGKILL = 9;
+pub const SIGUSR1 = 10;
+pub const SIGSEGV = 11;
+pub const SIGUSR2 = 12;
+pub const SIGPIPE = 13;
+pub const SIGALRM = 14;
+pub const SIGTERM = 15;
+pub const SIGSTKFLT = 16;
+pub const SIGCHLD = 17;
+pub const SIGCONT = 18;
+pub const SIGSTOP = 19;
+pub const SIGTSTP = 20;
+pub const SIGTTIN = 21;
+pub const SIGTTOU = 22;
+pub const SIGURG = 23;
+pub const SIGXCPU = 24;
+pub const SIGXFSZ = 25;
+pub const SIGVTALRM = 26;
+pub const SIGPROF = 27;
+pub const SIGWINCH = 28;
+pub const SIGIO = 29;
+pub const SIGPOLL = 29;
+pub const SIGPWR = 30;
+pub const SIGSYS = 31;
+pub const SIGUNUSED = SIGSYS;
+
+pub const O_RDONLY = 0o0;
+pub const O_WRONLY = 0o1;
+pub const O_RDWR = 0o2;
+
+pub const SEEK_SET = 0;
+pub const SEEK_CUR = 1;
+pub const SEEK_END = 2;
+
+pub const SIG_BLOCK = 0;
+pub const SIG_UNBLOCK = 1;
+pub const SIG_SETMASK = 2;
+
+pub const PROTO_ip = 0o000;
+pub const PROTO_icmp = 0o001;
+pub const PROTO_igmp = 0o002;
+pub const PROTO_ggp = 0o003;
+pub const PROTO_ipencap = 0o004;
+pub const PROTO_st = 0o005;
+pub const PROTO_tcp = 0o006;
+pub const PROTO_egp = 0o010;
+pub const PROTO_pup = 0o014;
+pub const PROTO_udp = 0o021;
+pub const PROTO_hmp = 0o024;
+pub const PROTO_xns_idp = 0o026;
+pub const PROTO_rdp = 0o033;
+pub const PROTO_iso_tp4 = 0o035;
+pub const PROTO_xtp = 0o044;
+pub const PROTO_ddp = 0o045;
+pub const PROTO_idpr_cmtp = 0o046;
+pub const PROTO_ipv6 = 0o051;
+pub const PROTO_ipv6_route = 0o053;
+pub const PROTO_ipv6_frag = 0o054;
+pub const PROTO_idrp = 0o055;
+pub const PROTO_rsvp = 0o056;
+pub const PROTO_gre = 0o057;
+pub const PROTO_esp = 0o062;
+pub const PROTO_ah = 0o063;
+pub const PROTO_skip = 0o071;
+pub const PROTO_ipv6_icmp = 0o072;
+pub const PROTO_ipv6_nonxt = 0o073;
+pub const PROTO_ipv6_opts = 0o074;
+pub const PROTO_rspf = 0o111;
+pub const PROTO_vmtp = 0o121;
+pub const PROTO_ospf = 0o131;
+pub const PROTO_ipip = 0o136;
+pub const PROTO_encap = 0o142;
+pub const PROTO_pim = 0o147;
+pub const PROTO_raw = 0o377;
+
+pub const SHUT_RD = 0;
+pub const SHUT_WR = 1;
+pub const SHUT_RDWR = 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_DCCP = 6;
+pub const SOCK_PACKET = 10;
+pub const SOCK_CLOEXEC = 0o2000000;
+pub const SOCK_NONBLOCK = 0o4000;
+
+pub const PF_UNSPEC = 0;
+pub const PF_LOCAL = 1;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_FILE = PF_LOCAL;
+pub const PF_INET = 2;
+pub const PF_AX25 = 3;
+pub const PF_IPX = 4;
+pub const PF_APPLETALK = 5;
+pub const PF_NETROM = 6;
+pub const PF_BRIDGE = 7;
+pub const PF_ATMPVC = 8;
+pub const PF_X25 = 9;
+pub const PF_INET6 = 10;
+pub const PF_ROSE = 11;
+pub const PF_DECnet = 12;
+pub const PF_NETBEUI = 13;
+pub const PF_SECURITY = 14;
+pub const PF_KEY = 15;
+pub const PF_NETLINK = 16;
+pub const PF_ROUTE = PF_NETLINK;
+pub const PF_PACKET = 17;
+pub const PF_ASH = 18;
+pub const PF_ECONET = 19;
+pub const PF_ATMSVC = 20;
+pub const PF_RDS = 21;
+pub const PF_SNA = 22;
+pub const PF_IRDA = 23;
+pub const PF_PPPOX = 24;
+pub const PF_WANPIPE = 25;
+pub const PF_LLC = 26;
+pub const PF_IB = 27;
+pub const PF_MPLS = 28;
+pub const PF_CAN = 29;
+pub const PF_TIPC = 30;
+pub const PF_BLUETOOTH = 31;
+pub const PF_IUCV = 32;
+pub const PF_RXRPC = 33;
+pub const PF_ISDN = 34;
+pub const PF_PHONET = 35;
+pub const PF_IEEE802154 = 36;
+pub const PF_CAIF = 37;
+pub const PF_ALG = 38;
+pub const PF_NFC = 39;
+pub const PF_VSOCK = 40;
+pub const PF_KCM = 41;
+pub const PF_QIPCRTR = 42;
+pub const PF_SMC = 43;
+pub const PF_MAX = 44;
+
+pub const AF_UNSPEC = PF_UNSPEC;
+pub const AF_LOCAL = PF_LOCAL;
+pub const AF_UNIX = AF_LOCAL;
+pub const AF_FILE = AF_LOCAL;
+pub const AF_INET = PF_INET;
+pub const AF_AX25 = PF_AX25;
+pub const AF_IPX = PF_IPX;
+pub const AF_APPLETALK = PF_APPLETALK;
+pub const AF_NETROM = PF_NETROM;
+pub const AF_BRIDGE = PF_BRIDGE;
+pub const AF_ATMPVC = PF_ATMPVC;
+pub const AF_X25 = PF_X25;
+pub const AF_INET6 = PF_INET6;
+pub const AF_ROSE = PF_ROSE;
+pub const AF_DECnet = PF_DECnet;
+pub const AF_NETBEUI = PF_NETBEUI;
+pub const AF_SECURITY = PF_SECURITY;
+pub const AF_KEY = PF_KEY;
+pub const AF_NETLINK = PF_NETLINK;
+pub const AF_ROUTE = PF_ROUTE;
+pub const AF_PACKET = PF_PACKET;
+pub const AF_ASH = PF_ASH;
+pub const AF_ECONET = PF_ECONET;
+pub const AF_ATMSVC = PF_ATMSVC;
+pub const AF_RDS = PF_RDS;
+pub const AF_SNA = PF_SNA;
+pub const AF_IRDA = PF_IRDA;
+pub const AF_PPPOX = PF_PPPOX;
+pub const AF_WANPIPE = PF_WANPIPE;
+pub const AF_LLC = PF_LLC;
+pub const AF_IB = PF_IB;
+pub const AF_MPLS = PF_MPLS;
+pub const AF_CAN = PF_CAN;
+pub const AF_TIPC = PF_TIPC;
+pub const AF_BLUETOOTH = PF_BLUETOOTH;
+pub const AF_IUCV = PF_IUCV;
+pub const AF_RXRPC = PF_RXRPC;
+pub const AF_ISDN = PF_ISDN;
+pub const AF_PHONET = PF_PHONET;
+pub const AF_IEEE802154 = PF_IEEE802154;
+pub const AF_CAIF = PF_CAIF;
+pub const AF_ALG = PF_ALG;
+pub const AF_NFC = PF_NFC;
+pub const AF_VSOCK = PF_VSOCK;
+pub const AF_KCM = PF_KCM;
+pub const AF_QIPCRTR = PF_QIPCRTR;
+pub const AF_SMC = PF_SMC;
+pub const AF_MAX = PF_MAX;
+
+pub const SO_DEBUG = 1;
+pub const SO_REUSEADDR = 2;
+pub const SO_TYPE = 3;
+pub const SO_ERROR = 4;
+pub const SO_DONTROUTE = 5;
+pub const SO_BROADCAST = 6;
+pub const SO_SNDBUF = 7;
+pub const SO_RCVBUF = 8;
+pub const SO_KEEPALIVE = 9;
+pub const SO_OOBINLINE = 10;
+pub const SO_NO_CHECK = 11;
+pub const SO_PRIORITY = 12;
+pub const SO_LINGER = 13;
+pub const SO_BSDCOMPAT = 14;
+pub const SO_REUSEPORT = 15;
+pub const SO_PASSCRED = 16;
+pub const SO_PEERCRED = 17;
+pub const SO_RCVLOWAT = 18;
+pub const SO_SNDLOWAT = 19;
+pub const SO_RCVTIMEO = 20;
+pub const SO_SNDTIMEO = 21;
+pub const SO_ACCEPTCONN = 30;
+pub const SO_SNDBUFFORCE = 32;
+pub const SO_RCVBUFFORCE = 33;
+pub const SO_PROTOCOL = 38;
+pub const SO_DOMAIN = 39;
+
+pub const SO_SECURITY_AUTHENTICATION = 22;
+pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;
+pub const SO_SECURITY_ENCRYPTION_NETWORK = 24;
+
+pub const SO_BINDTODEVICE = 25;
+
+pub const SO_ATTACH_FILTER = 26;
+pub const SO_DETACH_FILTER = 27;
+pub const SO_GET_FILTER = SO_ATTACH_FILTER;
+
+pub const SO_PEERNAME = 28;
+pub const SO_TIMESTAMP = 29;
+pub const SCM_TIMESTAMP = SO_TIMESTAMP;
+
+pub const SO_PEERSEC = 31;
+pub const SO_PASSSEC = 34;
+pub const SO_TIMESTAMPNS = 35;
+pub const SCM_TIMESTAMPNS = SO_TIMESTAMPNS;
+pub const SO_MARK = 36;
+pub const SO_TIMESTAMPING = 37;
+pub const SCM_TIMESTAMPING = SO_TIMESTAMPING;
+pub const SO_RXQ_OVFL = 40;
+pub const SO_WIFI_STATUS = 41;
+pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;
+pub const SO_PEEK_OFF = 42;
+pub const SO_NOFCS = 43;
+pub const SO_LOCK_FILTER = 44;
+pub const SO_SELECT_ERR_QUEUE = 45;
+pub const SO_BUSY_POLL = 46;
+pub const SO_MAX_PACING_RATE = 47;
+pub const SO_BPF_EXTENSIONS = 48;
+pub const SO_INCOMING_CPU = 49;
+pub const SO_ATTACH_BPF = 50;
+pub const SO_DETACH_BPF = SO_DETACH_FILTER;
+pub const SO_ATTACH_REUSEPORT_CBPF = 51;
+pub const SO_ATTACH_REUSEPORT_EBPF = 52;
+pub const SO_CNX_ADVICE = 53;
+pub const SCM_TIMESTAMPING_OPT_STATS = 54;
+pub const SO_MEMINFO = 55;
+pub const SO_INCOMING_NAPI_ID = 56;
+pub const SO_COOKIE = 57;
+pub const SCM_TIMESTAMPING_PKTINFO = 58;
+pub const SO_PEERGROUPS = 59;
+pub const SO_ZEROCOPY = 60;
+
+pub const SOL_SOCKET = 1;
+
+pub const SOL_IP = 0;
+pub const SOL_IPV6 = 41;
+pub const SOL_ICMPV6 = 58;
+
+pub const SOL_RAW = 255;
+pub const SOL_DECNET = 261;
+pub const SOL_X25 = 262;
+pub const SOL_PACKET = 263;
+pub const SOL_ATM = 264;
+pub const SOL_AAL = 265;
+pub const SOL_IRDA = 266;
+pub const SOL_NETBEUI = 267;
+pub const SOL_LLC = 268;
+pub const SOL_DCCP = 269;
+pub const SOL_NETLINK = 270;
+pub const SOL_TIPC = 271;
+pub const SOL_RXRPC = 272;
+pub const SOL_PPPOL2TP = 273;
+pub const SOL_BLUETOOTH = 274;
+pub const SOL_PNPIPE = 275;
+pub const SOL_RDS = 276;
+pub const SOL_IUCV = 277;
+pub const SOL_CAIF = 278;
+pub const SOL_ALG = 279;
+pub const SOL_NFC = 280;
+pub const SOL_KCM = 281;
+pub const SOL_TLS = 282;
+
+pub const SOMAXCONN = 128;
+
+pub const MSG_OOB = 0x0001;
+pub const MSG_PEEK = 0x0002;
+pub const MSG_DONTROUTE = 0x0004;
+pub const MSG_CTRUNC = 0x0008;
+pub const MSG_PROXY = 0x0010;
+pub const MSG_TRUNC = 0x0020;
+pub const MSG_DONTWAIT = 0x0040;
+pub const MSG_EOR = 0x0080;
+pub const MSG_WAITALL = 0x0100;
+pub const MSG_FIN = 0x0200;
+pub const MSG_SYN = 0x0400;
+pub const MSG_CONFIRM = 0x0800;
+pub const MSG_RST = 0x1000;
+pub const MSG_ERRQUEUE = 0x2000;
+pub const MSG_NOSIGNAL = 0x4000;
+pub const MSG_MORE = 0x8000;
+pub const MSG_WAITFORONE = 0x10000;
+pub const MSG_BATCH = 0x40000;
+pub const MSG_ZEROCOPY = 0x4000000;
+pub const MSG_FASTOPEN = 0x20000000;
+pub const MSG_CMSG_CLOEXEC = 0x40000000;
+
+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 TCGETS = 0x5401;
+pub const TCSETS = 0x5402;
+pub const TCSETSW = 0x5403;
+pub const TCSETSF = 0x5404;
+pub const TCGETA = 0x5405;
+pub const TCSETA = 0x5406;
+pub const TCSETAW = 0x5407;
+pub const TCSETAF = 0x5408;
+pub const TCSBRK = 0x5409;
+pub const TCXONC = 0x540A;
+pub const TCFLSH = 0x540B;
+pub const TIOCEXCL = 0x540C;
+pub const TIOCNXCL = 0x540D;
+pub const TIOCSCTTY = 0x540E;
+pub const TIOCGPGRP = 0x540F;
+pub const TIOCSPGRP = 0x5410;
+pub const TIOCOUTQ = 0x5411;
+pub const TIOCSTI = 0x5412;
+pub const TIOCGWINSZ = 0x5413;
+pub const TIOCSWINSZ = 0x5414;
+pub const TIOCMGET = 0x5415;
+pub const TIOCMBIS = 0x5416;
+pub const TIOCMBIC = 0x5417;
+pub const TIOCMSET = 0x5418;
+pub const TIOCGSOFTCAR = 0x5419;
+pub const TIOCSSOFTCAR = 0x541A;
+pub const FIONREAD = 0x541B;
+pub const TIOCINQ = FIONREAD;
+pub const TIOCLINUX = 0x541C;
+pub const TIOCCONS = 0x541D;
+pub const TIOCGSERIAL = 0x541E;
+pub const TIOCSSERIAL = 0x541F;
+pub const TIOCPKT = 0x5420;
+pub const FIONBIO = 0x5421;
+pub const TIOCNOTTY = 0x5422;
+pub const TIOCSETD = 0x5423;
+pub const TIOCGETD = 0x5424;
+pub const TCSBRKP = 0x5425;
+pub const TIOCSBRK = 0x5427;
+pub const TIOCCBRK = 0x5428;
+pub const TIOCGSID = 0x5429;
+pub const TIOCGRS485 = 0x542E;
+pub const TIOCSRS485 = 0x542F;
+pub const TIOCGPTN = 0x80045430;
+pub const TIOCSPTLCK = 0x40045431;
+pub const TIOCGDEV = 0x80045432;
+pub const TCGETX = 0x5432;
+pub const TCSETX = 0x5433;
+pub const TCSETXF = 0x5434;
+pub const TCSETXW = 0x5435;
+pub const TIOCSIG = 0x40045436;
+pub const TIOCVHANGUP = 0x5437;
+pub const TIOCGPKT = 0x80045438;
+pub const TIOCGPTLCK = 0x80045439;
+pub const TIOCGEXCL = 0x80045440;
+
+pub const EPOLL_CLOEXEC = O_CLOEXEC;
+
+pub const EPOLL_CTL_ADD = 1;
+pub const EPOLL_CTL_DEL = 2;
+pub const EPOLL_CTL_MOD = 3;
+
+pub const EPOLLIN = 0x001;
+pub const EPOLLPRI = 0x002;
+pub const EPOLLOUT = 0x004;
+pub const EPOLLRDNORM = 0x040;
+pub const EPOLLRDBAND = 0x080;
+pub const EPOLLWRNORM = 0x100;
+pub const EPOLLWRBAND = 0x200;
+pub const EPOLLMSG = 0x400;
+pub const EPOLLERR = 0x008;
+pub const EPOLLHUP = 0x010;
+pub const EPOLLRDHUP = 0x2000;
+pub const EPOLLEXCLUSIVE = (u32(1) << 28);
+pub const EPOLLWAKEUP = (u32(1) << 29);
+pub const EPOLLONESHOT = (u32(1) << 30);
+pub const EPOLLET = (u32(1) << 31);
+
+pub const CLOCK_REALTIME = 0;
+pub const CLOCK_MONOTONIC = 1;
+pub const CLOCK_PROCESS_CPUTIME_ID = 2;
+pub const CLOCK_THREAD_CPUTIME_ID = 3;
+pub const CLOCK_MONOTONIC_RAW = 4;
+pub const CLOCK_REALTIME_COARSE = 5;
+pub const CLOCK_MONOTONIC_COARSE = 6;
+pub const CLOCK_BOOTTIME = 7;
+pub const CLOCK_REALTIME_ALARM = 8;
+pub const CLOCK_BOOTTIME_ALARM = 9;
+pub const CLOCK_SGI_CYCLE = 10;
+pub const CLOCK_TAI = 11;
+
+pub const CSIGNAL = 0x000000ff;
+pub const CLONE_VM = 0x00000100;
+pub const CLONE_FS = 0x00000200;
+pub const CLONE_FILES = 0x00000400;
+pub const CLONE_SIGHAND = 0x00000800;
+pub const CLONE_PTRACE = 0x00002000;
+pub const CLONE_VFORK = 0x00004000;
+pub const CLONE_PARENT = 0x00008000;
+pub const CLONE_THREAD = 0x00010000;
+pub const CLONE_NEWNS = 0x00020000;
+pub const CLONE_SYSVSEM = 0x00040000;
+pub const CLONE_SETTLS = 0x00080000;
+pub const CLONE_PARENT_SETTID = 0x00100000;
+pub const CLONE_CHILD_CLEARTID = 0x00200000;
+pub const CLONE_DETACHED = 0x00400000;
+pub const CLONE_UNTRACED = 0x00800000;
+pub const CLONE_CHILD_SETTID = 0x01000000;
+pub const CLONE_NEWCGROUP = 0x02000000;
+pub const CLONE_NEWUTS = 0x04000000;
+pub const CLONE_NEWIPC = 0x08000000;
+pub const CLONE_NEWUSER = 0x10000000;
+pub const CLONE_NEWPID = 0x20000000;
+pub const CLONE_NEWNET = 0x40000000;
+pub const CLONE_IO = 0x80000000;
+
+pub const EFD_SEMAPHORE = 1;
+pub const EFD_CLOEXEC = O_CLOEXEC;
+pub const EFD_NONBLOCK = O_NONBLOCK;
+
+pub const MS_RDONLY = 1;
+pub const MS_NOSUID = 2;
+pub const MS_NODEV = 4;
+pub const MS_NOEXEC = 8;
+pub const MS_SYNCHRONOUS = 16;
+pub const MS_REMOUNT = 32;
+pub const MS_MANDLOCK = 64;
+pub const MS_DIRSYNC = 128;
+pub const MS_NOATIME = 1024;
+pub const MS_NODIRATIME = 2048;
+pub const MS_BIND = 4096;
+pub const MS_MOVE = 8192;
+pub const MS_REC = 16384;
+pub const MS_SILENT = 32768;
+pub const MS_POSIXACL = (1 << 16);
+pub const MS_UNBINDABLE = (1 << 17);
+pub const MS_PRIVATE = (1 << 18);
+pub const MS_SLAVE = (1 << 19);
+pub const MS_SHARED = (1 << 20);
+pub const MS_RELATIME = (1 << 21);
+pub const MS_KERNMOUNT = (1 << 22);
+pub const MS_I_VERSION = (1 << 23);
+pub const MS_STRICTATIME = (1 << 24);
+pub const MS_LAZYTIME = (1 << 25);
+pub const MS_NOREMOTELOCK = (1 << 27);
+pub const MS_NOSEC = (1 << 28);
+pub const MS_BORN = (1 << 29);
+pub const MS_ACTIVE = (1 << 30);
+pub const MS_NOUSER = (1 << 31);
+
+pub const MS_RMT_MASK = (MS_RDONLY | MS_SYNCHRONOUS | MS_MANDLOCK | MS_I_VERSION | MS_LAZYTIME);
+
+pub const MS_MGC_VAL = 0xc0ed0000;
+pub const MS_MGC_MSK = 0xffff0000;
+
+pub const MNT_FORCE = 1;
+pub const MNT_DETACH = 2;
+pub const MNT_EXPIRE = 4;
+pub const UMOUNT_NOFOLLOW = 8;
+
+pub const IN_CLOEXEC = O_CLOEXEC;
+pub const IN_NONBLOCK = O_NONBLOCK;
+
+pub const IN_ACCESS = 0x00000001;
+pub const IN_MODIFY = 0x00000002;
+pub const IN_ATTRIB = 0x00000004;
+pub const IN_CLOSE_WRITE = 0x00000008;
+pub const IN_CLOSE_NOWRITE = 0x00000010;
+pub const IN_CLOSE = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
+pub const IN_OPEN = 0x00000020;
+pub const IN_MOVED_FROM = 0x00000040;
+pub const IN_MOVED_TO = 0x00000080;
+pub const IN_MOVE = IN_MOVED_FROM | IN_MOVED_TO;
+pub const IN_CREATE = 0x00000100;
+pub const IN_DELETE = 0x00000200;
+pub const IN_DELETE_SELF = 0x00000400;
+pub const IN_MOVE_SELF = 0x00000800;
+pub const IN_ALL_EVENTS = 0x00000fff;
+
+pub const IN_UNMOUNT = 0x00002000;
+pub const IN_Q_OVERFLOW = 0x00004000;
+pub const IN_IGNORED = 0x00008000;
+
+pub const IN_ONLYDIR = 0x01000000;
+pub const IN_DONT_FOLLOW = 0x02000000;
+pub const IN_EXCL_UNLINK = 0x04000000;
+pub const IN_MASK_ADD = 0x20000000;
+
+pub const IN_ISDIR = 0x40000000;
+pub const IN_ONESHOT = 0x80000000;
+
+pub const S_IFMT = 0o170000;
+
+pub const S_IFDIR = 0o040000;
+pub const S_IFCHR = 0o020000;
+pub const S_IFBLK = 0o060000;
+pub const S_IFREG = 0o100000;
+pub const S_IFIFO = 0o010000;
+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_IRUSR = 0o400;
+pub const S_IWUSR = 0o200;
+pub const S_IXUSR = 0o100;
+pub const S_IRWXU = 0o700;
+pub const S_IRGRP = 0o040;
+pub const S_IWGRP = 0o020;
+pub const S_IXGRP = 0o010;
+pub const S_IRWXG = 0o070;
+pub const S_IROTH = 0o004;
+pub const S_IWOTH = 0o002;
+pub const S_IXOTH = 0o001;
+pub const S_IRWXO = 0o007;
+
+pub fn S_ISREG(m: u32) bool {
+ return m & S_IFMT == S_IFREG;
+}
+
+pub fn S_ISDIR(m: u32) bool {
+ return m & S_IFMT == S_IFDIR;
+}
+
+pub fn S_ISCHR(m: u32) bool {
+ return m & S_IFMT == S_IFCHR;
+}
+
+pub fn S_ISBLK(m: u32) bool {
+ return m & S_IFMT == S_IFBLK;
+}
+
+pub fn S_ISFIFO(m: u32) bool {
+ return m & S_IFMT == S_IFIFO;
+}
+
+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 const TFD_NONBLOCK = O_NONBLOCK;
+pub const TFD_CLOEXEC = O_CLOEXEC;
+
+pub const TFD_TIMER_ABSTIME = 1;
+pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
+
+fn unsigned(s: i32) u32 {
+ return @bitCast(u32, s);
+}
+fn signed(s: u32) i32 {
+ return @bitCast(i32, s);
+}
+pub fn WEXITSTATUS(s: i32) i32 {
+ return signed((unsigned(s) & 0xff00) >> 8);
+}
+pub fn WTERMSIG(s: i32) i32 {
+ return signed(unsigned(s) & 0x7f);
+}
+pub fn WSTOPSIG(s: i32) i32 {
+ return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: i32) bool {
+ return WTERMSIG(s) == 0;
+}
+pub fn WIFSTOPPED(s: i32) bool {
+ return @intCast(u16, ((unsigned(s) & 0xffff) *% 0x10001) >> 8) > 0x7f00;
+}
+pub fn WIFSIGNALED(s: i32) bool {
+ return (unsigned(s) & 0xffff) -% 1 < 0xff;
+}
+
+pub const winsize = extern struct {
+ ws_row: u16,
+ ws_col: u16,
+ ws_xpixel: u16,
+ ws_ypixel: u16,
+};
+
+const NSIG = 65;
+const sigset_t = [128 / @sizeOf(usize)]usize;
+const all_mask = []u32{ 0xffffffff, 0xffffffff };
+const app_mask = []u32{ 0xfffffffc, 0x7fffffff };
+
+const k_sigaction = extern struct {
+ handler: extern fn (i32) void,
+ flags: usize,
+ restorer: extern fn () void,
+ mask: [2]u32,
+};
+
+/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
+pub const Sigaction = struct {
+ handler: extern fn (i32) void,
+ mask: sigset_t,
+ flags: u32,
+};
+
+pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
+pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
+pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
+pub const empty_sigset = []usize{0} ** sigset_t.len;
+
+pub const in_port_t = u16;
+pub const sa_family_t = u16;
+pub const socklen_t = u32;
+
+/// This intentionally only has ip4 and ip6
+pub const sockaddr = extern union {
+ in: sockaddr_in,
+ in6: sockaddr_in6,
+};
+
+pub const sockaddr_in = extern struct {
+ family: sa_family_t,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8,
+};
+
+pub const sockaddr_in6 = extern struct {
+ family: sa_family_t,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+};
+
+pub const sockaddr_un = extern struct {
+ family: sa_family_t,
+ path: [108]u8,
+};
+
+pub const iovec = extern struct {
+ iov_base: [*]u8,
+ iov_len: usize,
+};
+
+pub const iovec_const = extern struct {
+ iov_base: [*]const u8,
+ iov_len: usize,
+};
+
+pub const mmsghdr = extern struct {
+ msg_hdr: msghdr,
+ msg_len: u32,
+};
+
+pub const mmsghdr_const = extern struct {
+ msg_hdr: msghdr_const,
+ msg_len: u32,
+};
+
+pub const epoll_data = extern union {
+ ptr: usize,
+ fd: i32,
+ @"u32": u32,
+ @"u64": u64,
+};
+
+// On x86_64 the structure is packed so that it matches the definition of its
+// 32bit counterpart
+pub const epoll_event = if (builtin.arch != .x86_64)
+ extern struct {
+ events: u32,
+ data: epoll_data,
+ }
+else
+ packed struct {
+ events: u32,
+ data: epoll_data,
+ };
+
+pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
+pub const _LINUX_CAPABILITY_U32S_1 = 1;
+
+pub const _LINUX_CAPABILITY_VERSION_2 = 0x20071026;
+pub const _LINUX_CAPABILITY_U32S_2 = 2;
+
+pub const _LINUX_CAPABILITY_VERSION_3 = 0x20080522;
+pub const _LINUX_CAPABILITY_U32S_3 = 2;
+
+pub const VFS_CAP_REVISION_MASK = 0xFF000000;
+pub const VFS_CAP_REVISION_SHIFT = 24;
+pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK;
+pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;
+
+pub const VFS_CAP_REVISION_1 = 0x01000000;
+pub const VFS_CAP_U32_1 = 1;
+pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);
+
+pub const VFS_CAP_REVISION_2 = 0x02000000;
+pub const VFS_CAP_U32_2 = 2;
+pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);
+
+pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
+pub const VFS_CAP_U32 = VFS_CAP_U32_2;
+pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;
+
+pub const vfs_cap_data = extern struct {
+ //all of these are mandated as little endian
+ //when on disk.
+ const Data = struct {
+ permitted: u32,
+ inheritable: u32,
+ };
+
+ magic_etc: u32,
+ data: [VFS_CAP_U32]Data,
+};
+
+pub const CAP_CHOWN = 0;
+pub const CAP_DAC_OVERRIDE = 1;
+pub const CAP_DAC_READ_SEARCH = 2;
+pub const CAP_FOWNER = 3;
+pub const CAP_FSETID = 4;
+pub const CAP_KILL = 5;
+pub const CAP_SETGID = 6;
+pub const CAP_SETUID = 7;
+pub const CAP_SETPCAP = 8;
+pub const CAP_LINUX_IMMUTABLE = 9;
+pub const CAP_NET_BIND_SERVICE = 10;
+pub const CAP_NET_BROADCAST = 11;
+pub const CAP_NET_ADMIN = 12;
+pub const CAP_NET_RAW = 13;
+pub const CAP_IPC_LOCK = 14;
+pub const CAP_IPC_OWNER = 15;
+pub const CAP_SYS_MODULE = 16;
+pub const CAP_SYS_RAWIO = 17;
+pub const CAP_SYS_CHROOT = 18;
+pub const CAP_SYS_PTRACE = 19;
+pub const CAP_SYS_PACCT = 20;
+pub const CAP_SYS_ADMIN = 21;
+pub const CAP_SYS_BOOT = 22;
+pub const CAP_SYS_NICE = 23;
+pub const CAP_SYS_RESOURCE = 24;
+pub const CAP_SYS_TIME = 25;
+pub const CAP_SYS_TTY_CONFIG = 26;
+pub const CAP_MKNOD = 27;
+pub const CAP_LEASE = 28;
+pub const CAP_AUDIT_WRITE = 29;
+pub const CAP_AUDIT_CONTROL = 30;
+pub const CAP_SETFCAP = 31;
+pub const CAP_MAC_OVERRIDE = 32;
+pub const CAP_MAC_ADMIN = 33;
+pub const CAP_SYSLOG = 34;
+pub const CAP_WAKE_ALARM = 35;
+pub const CAP_BLOCK_SUSPEND = 36;
+pub const CAP_AUDIT_READ = 37;
+pub const CAP_LAST_CAP = CAP_AUDIT_READ;
+
+pub fn cap_valid(u8: x) bool {
+ return x >= 0 and x <= CAP_LAST_CAP;
+}
+
+pub fn CAP_TO_MASK(cap: u8) u32 {
+ return u32(1) << u5(cap & 31);
+}
+
+pub fn CAP_TO_INDEX(cap: u8) u8 {
+ return cap >> 5;
+}
+
+pub const cap_t = extern struct {
+ hdrp: *cap_user_header_t,
+ datap: *cap_user_data_t,
+};
+
+pub const cap_user_header_t = extern struct {
+ version: u32,
+ pid: usize,
+};
+
+pub const cap_user_data_t = extern struct {
+ effective: u32,
+ permitted: u32,
+ inheritable: u32,
+};
+
+pub const inotify_event = extern struct {
+ wd: i32,
+ mask: u32,
+ cookie: u32,
+ len: u32,
+ //name: [?]u8,
+};
+
+pub const dirent64 = extern struct {
+ d_ino: u64,
+ d_off: u64,
+ d_reclen: u16,
+ d_type: u8,
+ d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173
+};
+
+pub const dl_phdr_info = extern struct {
+ dlpi_addr: usize,
+ dlpi_name: ?[*]const u8,
+ dlpi_phdr: [*]elf.Phdr,
+ dlpi_phnum: u16,
+};
+
+pub const pthread_attr_t = extern struct {
+ __size: [56]u8,
+ __align: c_long,
+};
diff --git a/std/os/linux/posix/arm64.zig b/std/os/bits/linux/arm64.zig
diff --git a/std/os/linux/errno.zig b/std/os/bits/linux/errno.zig
diff --git a/std/os/linux/posix/x86_64.zig b/std/os/bits/linux/x86_64.zig
diff --git a/std/os/bits/netbsd.zig b/std/os/bits/netbsd.zig
@@ -0,0 +1,731 @@
+const std = @import("../../std.zig");
+const maxInt = std.math.maxInt;
+
+pub const fd_t = c_int;
+pub const pid_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 pthread_attr_t = extern struct {
+ pta_magic: u32,
+ pta_flags: c_int,
+ pta_private: *c_void,
+};
+
+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: u64,
+ mode: u32,
+ ino: u64,
+ nlink: usize,
+
+ uid: u32,
+ gid: u32,
+ rdev: u64,
+
+ atim: timespec,
+ mtim: timespec,
+ ctim: timespec,
+ birthtim: timespec,
+
+ size: i64,
+ blocks: i64,
+ blksize: isize,
+ flags: u32,
+ gen: u32,
+ __spare: [2]u32,
+};
+
+pub const timespec = extern struct {
+ tv_sec: i64,
+ tv_nsec: isize,
+};
+
+pub const dirent = extern struct {
+ d_fileno: u64,
+ d_reclen: u16,
+ d_namlen: u16,
+ d_type: u8,
+ d_off: i64,
+ d_name: [512]u8,
+};
+
+pub const in_port_t = u16;
+pub const sa_family_t = u8;
+
+pub const sockaddr = extern union {
+ in: sockaddr_in,
+ in6: sockaddr_in6,
+};
+
+pub const sockaddr_in = extern struct {
+ len: u8,
+ family: sa_family_t,
+ port: in_port_t,
+ addr: u32,
+ zero: [8]u8,
+};
+
+pub const sockaddr_in6 = extern struct {
+ len: u8,
+ family: sa_family_t,
+ port: in_port_t,
+ flowinfo: u32,
+ addr: [16]u8,
+ scope_id: u32,
+};
+
+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 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_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 = 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
+
+pub const O_RDONLY = 0x0000;
+pub const O_WRONLY = 0x0001;
+pub const O_RDWR = 0x0002;
+pub const O_ACCMODE = 0x0003;
+
+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 = 0x00010000;
+pub const O_SYNC = 0x0080;
+pub const O_RSYNC = 0x00020000;
+pub const O_DIRECTORY = 0x00080000;
+pub const O_NOFOLLOW = 0x00000100;
+pub const O_CLOEXEC = 0x00400000;
+
+pub const O_ASYNC = 0x0040;
+pub const O_DIRECT = 0x00080000;
+pub const O_LARGEFILE = 0;
+pub const O_NOATIME = 0;
+pub const O_PATH = 0;
+pub const O_TMPFILE = 0;
+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 = 7;
+pub const F_SETLK = 8;
+pub const F_SETLKW = 9;
+
+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 PROTO_ip = 0;
+pub const PROTO_icmp = 1;
+pub const PROTO_igmp = 2;
+pub const PROTO_ggp = 3;
+pub const PROTO_ipencap = 4;
+pub const PROTO_tcp = 6;
+pub const PROTO_egp = 8;
+pub const PROTO_pup = 12;
+pub const PROTO_udp = 17;
+pub const PROTO_xns_idp = 22;
+pub const PROTO_iso_tp4 = 29;
+pub const PROTO_ipv6 = 41;
+pub const PROTO_ipv6_route = 43;
+pub const PROTO_ipv6_frag = 44;
+pub const PROTO_rsvp = 46;
+pub const PROTO_gre = 47;
+pub const PROTO_esp = 50;
+pub const PROTO_ah = 51;
+pub const PROTO_ipv6_icmp = 58;
+pub const PROTO_ipv6_nonxt = 59;
+pub const PROTO_ipv6_opts = 60;
+pub const PROTO_encap = 98;
+pub const PROTO_pim = 103;
+pub const PROTO_raw = 255;
+
+pub const PF_UNSPEC = 0;
+pub const PF_LOCAL = 1;
+pub const PF_UNIX = PF_LOCAL;
+pub const PF_FILE = PF_LOCAL;
+pub const PF_INET = 2;
+pub const PF_APPLETALK = 16;
+pub const PF_INET6 = 24;
+pub const PF_DECnet = 12;
+pub const PF_KEY = 29;
+pub const PF_ROUTE = 34;
+pub const PF_SNA = 11;
+pub const PF_MPLS = 33;
+pub const PF_CAN = 35;
+pub const PF_BLUETOOTH = 31;
+pub const PF_ISDN = 26;
+pub const PF_MAX = 37;
+
+pub const AF_UNSPEC = PF_UNSPEC;
+pub const AF_LOCAL = PF_LOCAL;
+pub const AF_UNIX = AF_LOCAL;
+pub const AF_FILE = AF_LOCAL;
+pub const AF_INET = PF_INET;
+pub const AF_APPLETALK = PF_APPLETALK;
+pub const AF_INET6 = PF_INET6;
+pub const AF_KEY = PF_KEY;
+pub const AF_ROUTE = PF_ROUTE;
+pub const AF_SNA = PF_SNA;
+pub const AF_MPLS = PF_MPLS;
+pub const AF_CAN = PF_CAN;
+pub const AF_BLUETOOTH = PF_BLUETOOTH;
+pub const AF_ISDN = PF_ISDN;
+pub const AF_MAX = PF_MAX;
+
+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;
+
+fn unsigned(s: i32) u32 {
+ return @bitCast(u32, s);
+}
+fn signed(s: u32) i32 {
+ return @bitCast(i32, s);
+}
+pub fn WEXITSTATUS(s: i32) i32 {
+ return signed((unsigned(s) >> 8) & 0xff);
+}
+pub fn WTERMSIG(s: i32) i32 {
+ return signed(unsigned(s) & 0x7f);
+}
+pub fn WSTOPSIG(s: i32) i32 {
+ return WEXITSTATUS(s);
+}
+pub fn WIFEXITED(s: i32) bool {
+ return WTERMSIG(s) == 0;
+}
+
+pub fn WIFCONTINUED(s: i32) bool {
+ return ((s & 0x7f) == 0xffff);
+}
+
+pub fn WIFSTOPPED(s: i32) bool {
+ return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s));
+}
+
+pub fn WIFSIGNALED(s: i32) 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_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
+pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
+pub const SIG_IGN = @intToPtr(extern fn (i32) 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: extern fn (i32) void,
+ __sa_sigaction: extern fn (i32, *__siginfo, usize) 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 EPERM = 1; // Operation not permitted
+pub const ENOENT = 2; // No such file or directory
+pub const ESRCH = 3; // No such process
+pub const EINTR = 4; // Interrupted system call
+pub const EIO = 5; // Input/output error
+pub const ENXIO = 6; // Device not configured
+pub const E2BIG = 7; // Argument list too long
+pub const ENOEXEC = 8; // Exec format error
+pub const EBADF = 9; // Bad file descriptor
+pub const ECHILD = 10; // No child processes
+pub const EDEADLK = 11; // Resource deadlock avoided
+// 11 was EAGAIN
+pub const ENOMEM = 12; // Cannot allocate memory
+pub const EACCES = 13; // Permission denied
+pub const EFAULT = 14; // Bad address
+pub const ENOTBLK = 15; // Block device required
+pub const EBUSY = 16; // Device busy
+pub const EEXIST = 17; // File exists
+pub const EXDEV = 18; // Cross-device link
+pub const ENODEV = 19; // Operation not supported by device
+pub const ENOTDIR = 20; // Not a directory
+pub const EISDIR = 21; // Is a directory
+pub const EINVAL = 22; // Invalid argument
+pub const ENFILE = 23; // Too many open files in system
+pub const EMFILE = 24; // Too many open files
+pub const ENOTTY = 25; // Inappropriate ioctl for device
+pub const ETXTBSY = 26; // Text file busy
+pub const EFBIG = 27; // File too large
+pub const ENOSPC = 28; // No space left on device
+pub const ESPIPE = 29; // Illegal seek
+pub const EROFS = 30; // Read-only file system
+pub const EMLINK = 31; // Too many links
+pub const EPIPE = 32; // Broken pipe
+
+// math software
+pub const EDOM = 33; // Numerical argument out of domain
+pub const ERANGE = 34; // Result too large or too small
+
+// non-blocking and interrupt i/o
+pub const EAGAIN = 35; // Resource temporarily unavailable
+pub const EWOULDBLOCK = EAGAIN; // Operation would block
+pub const EINPROGRESS = 36; // Operation now in progress
+pub const EALREADY = 37; // Operation already in progress
+
+// ipc/network software -- argument errors
+pub const ENOTSOCK = 38; // Socket operation on non-socket
+pub const EDESTADDRREQ = 39; // Destination address required
+pub const EMSGSIZE = 40; // Message too long
+pub const EPROTOTYPE = 41; // Protocol wrong type for socket
+pub const ENOPROTOOPT = 42; // Protocol option not available
+pub const EPROTONOSUPPORT = 43; // Protocol not supported
+pub const ESOCKTNOSUPPORT = 44; // Socket type not supported
+pub const EOPNOTSUPP = 45; // Operation not supported
+pub const EPFNOSUPPORT = 46; // Protocol family not supported
+pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family
+pub const EADDRINUSE = 48; // Address already in use
+pub const EADDRNOTAVAIL = 49; // Can't assign requested address
+
+// ipc/network software -- operational errors
+pub const ENETDOWN = 50; // Network is down
+pub const ENETUNREACH = 51; // Network is unreachable
+pub const ENETRESET = 52; // Network dropped connection on reset
+pub const ECONNABORTED = 53; // Software caused connection abort
+pub const ECONNRESET = 54; // Connection reset by peer
+pub const ENOBUFS = 55; // No buffer space available
+pub const EISCONN = 56; // Socket is already connected
+pub const ENOTCONN = 57; // Socket is not connected
+pub const ESHUTDOWN = 58; // Can't send after socket shutdown
+pub const ETOOMANYREFS = 59; // Too many references: can't splice
+pub const ETIMEDOUT = 60; // Operation timed out
+pub const ECONNREFUSED = 61; // Connection refused
+
+pub const ELOOP = 62; // Too many levels of symbolic links
+pub const ENAMETOOLONG = 63; // File name too long
+
+// should be rearranged
+pub const EHOSTDOWN = 64; // Host is down
+pub const EHOSTUNREACH = 65; // No route to host
+pub const ENOTEMPTY = 66; // Directory not empty
+
+// quotas & mush
+pub const EPROCLIM = 67; // Too many processes
+pub const EUSERS = 68; // Too many users
+pub const EDQUOT = 69; // Disc quota exceeded
+
+// Network File System
+pub const ESTALE = 70; // Stale NFS file handle
+pub const EREMOTE = 71; // Too many levels of remote in path
+pub const EBADRPC = 72; // RPC struct is bad
+pub const ERPCMISMATCH = 73; // RPC version wrong
+pub const EPROGUNAVAIL = 74; // RPC prog. not avail
+pub const EPROGMISMATCH = 75; // Program version wrong
+pub const EPROCUNAVAIL = 76; // Bad procedure for program
+
+pub const ENOLCK = 77; // No locks available
+pub const ENOSYS = 78; // Function not implemented
+
+pub const EFTYPE = 79; // Inappropriate file type or format
+pub const EAUTH = 80; // Authentication error
+pub const ENEEDAUTH = 81; // Need authenticator
+
+// SystemV IPC
+pub const EIDRM = 82; // Identifier removed
+pub const ENOMSG = 83; // No message of desired type
+pub const EOVERFLOW = 84; // Value too large to be stored in data type
+
+// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
+pub const EILSEQ = 85; // Illegal byte sequence
+
+// From IEEE Std 1003.1-2001
+// Base, Realtime, Threads or Thread Priority Scheduling option errors
+pub const ENOTSUP = 86; // Not supported
+
+// Realtime option errors
+pub const ECANCELED = 87; // Operation canceled
+
+// Realtime, XSI STREAMS option errors
+pub const EBADMSG = 88; // Bad or Corrupt message
+
+// XSI STREAMS option errors
+pub const ENODATA = 89; // No message available
+pub const ENOSR = 90; // No STREAM resources
+pub const ENOSTR = 91; // Not a STREAM
+pub const ETIME = 92; // STREAM ioctl timeout
+
+// File system extended attribute errors
+pub const ENOATTR = 93; // Attribute not found
+
+// Realtime, XSI STREAMS option errors
+pub const EMULTIHOP = 94; // Multihop attempted
+pub const ENOLINK = 95; // Link has been severed
+pub const EPROTO = 96; // Protocol error
+
+pub const ELAST = 96; // Must equal largest errno
diff --git a/std/os/wasi/posix.zig b/std/os/bits/wasi.zig
diff --git a/std/os/bits/windows.zig b/std/os/bits/windows.zig
@@ -0,0 +1,91 @@
+use @import("../windows.zig");
+
+pub const fd_t = HANDLE;
+pub const pid_t = HANDLE;
+
+pub const EPERM = 1;
+pub const ENOENT = 2;
+pub const ESRCH = 3;
+pub const EINTR = 4;
+pub const EIO = 5;
+pub const ENXIO = 6;
+pub const E2BIG = 7;
+pub const ENOEXEC = 8;
+pub const EBADF = 9;
+pub const ECHILD = 10;
+pub const EAGAIN = 11;
+pub const ENOMEM = 12;
+pub const EACCES = 13;
+pub const EFAULT = 14;
+pub const EBUSY = 16;
+pub const EEXIST = 17;
+pub const EXDEV = 18;
+pub const ENODEV = 19;
+pub const ENOTDIR = 20;
+pub const EISDIR = 21;
+pub const ENFILE = 23;
+pub const EMFILE = 24;
+pub const ENOTTY = 25;
+pub const EFBIG = 27;
+pub const ENOSPC = 28;
+pub const ESPIPE = 29;
+pub const EROFS = 30;
+pub const EMLINK = 31;
+pub const EPIPE = 32;
+pub const EDOM = 33;
+pub const EDEADLK = 36;
+pub const ENAMETOOLONG = 38;
+pub const ENOLCK = 39;
+pub const ENOSYS = 40;
+pub const ENOTEMPTY = 41;
+
+pub const EINVAL = 22;
+pub const ERANGE = 34;
+pub const EILSEQ = 42;
+pub const STRUNCATE = 80;
+
+// Support EDEADLOCK for compatibility with older Microsoft C versions
+pub const EDEADLOCK = EDEADLK;
+
+// POSIX Supplement
+pub const EADDRINUSE = 100;
+pub const EADDRNOTAVAIL = 101;
+pub const EAFNOSUPPORT = 102;
+pub const EALREADY = 103;
+pub const EBADMSG = 104;
+pub const ECANCELED = 105;
+pub const ECONNABORTED = 106;
+pub const ECONNREFUSED = 107;
+pub const ECONNRESET = 108;
+pub const EDESTADDRREQ = 109;
+pub const EHOSTUNREACH = 110;
+pub const EIDRM = 111;
+pub const EINPROGRESS = 112;
+pub const EISCONN = 113;
+pub const ELOOP = 114;
+pub const EMSGSIZE = 115;
+pub const ENETDOWN = 116;
+pub const ENETRESET = 117;
+pub const ENETUNREACH = 118;
+pub const ENOBUFS = 119;
+pub const ENODATA = 120;
+pub const ENOLINK = 121;
+pub const ENOMSG = 122;
+pub const ENOPROTOOPT = 123;
+pub const ENOSR = 124;
+pub const ENOSTR = 125;
+pub const ENOTCONN = 126;
+pub const ENOTRECOVERABLE = 127;
+pub const ENOTSOCK = 128;
+pub const ENOTSUP = 129;
+pub const EOPNOTSUPP = 130;
+pub const EOTHER = 131;
+pub const EOVERFLOW = 132;
+pub const EOWNERDEAD = 133;
+pub const EPROTO = 134;
+pub const EPROTONOSUPPORT = 135;
+pub const EPROTOTYPE = 136;
+pub const ETIME = 137;
+pub const ETIMEDOUT = 138;
+pub const ETXTBSY = 139;
+pub const EWOULDBLOCK = 140;
diff --git a/std/os/linux.zig b/std/os/linux.zig
@@ -4,7 +4,7 @@ pub const is_the_target = builtin.os == .linux;
pub const sys = @import("linux/sys.zig");
pub use if (builtin.link_libc) std.c else sys;
-test "import" {
+test "" {
if (is_the_target) {
_ = @import("linux/test.zig");
}
diff --git a/std/os/linux/posix.zig b/std/os/linux/posix.zig
@@ -1,917 +0,0 @@
-// Declarations that are intended to be imported into the POSIX namespace.
-// This includes Linux-only APIs.
-
-pub use @import("errno.zig");
-pub use switch (builtin.arch) {
- .x86_64 => @import("posix/x86_64.zig"),
- .aarch64 => @import("posix/arm64.zig"),
- else => struct {},
-};
-
-pub const pid_t = i32;
-pub const fd_t = i32;
-
-pub const PATH_MAX = 4096;
-pub const IOV_MAX = 1024;
-
-pub const STDIN_FILENO = 0;
-pub const STDOUT_FILENO = 1;
-pub const STDERR_FILENO = 2;
-
-pub const FUTEX_WAIT = 0;
-pub const FUTEX_WAKE = 1;
-pub const FUTEX_FD = 2;
-pub const FUTEX_REQUEUE = 3;
-pub const FUTEX_CMP_REQUEUE = 4;
-pub const FUTEX_WAKE_OP = 5;
-pub const FUTEX_LOCK_PI = 6;
-pub const FUTEX_UNLOCK_PI = 7;
-pub const FUTEX_TRYLOCK_PI = 8;
-pub const FUTEX_WAIT_BITSET = 9;
-
-pub const FUTEX_PRIVATE_FLAG = 128;
-
-pub const FUTEX_CLOCK_REALTIME = 256;
-
-pub const PROT_NONE = 0;
-pub const PROT_READ = 1;
-pub const PROT_WRITE = 2;
-pub const PROT_EXEC = 4;
-pub const PROT_GROWSDOWN = 0x01000000;
-pub const PROT_GROWSUP = 0x02000000;
-
-pub const MAP_FAILED = maxInt(usize);
-pub const MAP_SHARED = 0x01;
-pub const MAP_PRIVATE = 0x02;
-pub const MAP_TYPE = 0x0f;
-pub const MAP_FIXED = 0x10;
-pub const MAP_ANONYMOUS = 0x20;
-pub const MAP_NORESERVE = 0x4000;
-pub const MAP_GROWSDOWN = 0x0100;
-pub const MAP_DENYWRITE = 0x0800;
-pub const MAP_EXECUTABLE = 0x1000;
-pub const MAP_LOCKED = 0x2000;
-pub const MAP_POPULATE = 0x8000;
-pub const MAP_NONBLOCK = 0x10000;
-pub const MAP_STACK = 0x20000;
-pub const MAP_HUGETLB = 0x40000;
-pub const MAP_FILE = 0;
-
-pub const F_OK = 0;
-pub const X_OK = 1;
-pub const W_OK = 2;
-pub const R_OK = 4;
-
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WSTOPPED = 2;
-pub const WEXITED = 4;
-pub const WCONTINUED = 8;
-pub const WNOWAIT = 0x1000000;
-
-pub const SA_NOCLDSTOP = 1;
-pub const SA_NOCLDWAIT = 2;
-pub const SA_SIGINFO = 4;
-pub const SA_ONSTACK = 0x08000000;
-pub const SA_RESTART = 0x10000000;
-pub const SA_NODEFER = 0x40000000;
-pub const SA_RESETHAND = 0x80000000;
-pub const SA_RESTORER = 0x04000000;
-
-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 SIGBUS = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGUSR1 = 10;
-pub const SIGSEGV = 11;
-pub const SIGUSR2 = 12;
-pub const SIGPIPE = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGSTKFLT = 16;
-pub const SIGCHLD = 17;
-pub const SIGCONT = 18;
-pub const SIGSTOP = 19;
-pub const SIGTSTP = 20;
-pub const SIGTTIN = 21;
-pub const SIGTTOU = 22;
-pub const SIGURG = 23;
-pub const SIGXCPU = 24;
-pub const SIGXFSZ = 25;
-pub const SIGVTALRM = 26;
-pub const SIGPROF = 27;
-pub const SIGWINCH = 28;
-pub const SIGIO = 29;
-pub const SIGPOLL = 29;
-pub const SIGPWR = 30;
-pub const SIGSYS = 31;
-pub const SIGUNUSED = SIGSYS;
-
-pub const O_RDONLY = 0o0;
-pub const O_WRONLY = 0o1;
-pub const O_RDWR = 0o2;
-
-pub const SEEK_SET = 0;
-pub const SEEK_CUR = 1;
-pub const SEEK_END = 2;
-
-pub const SIG_BLOCK = 0;
-pub const SIG_UNBLOCK = 1;
-pub const SIG_SETMASK = 2;
-
-pub const PROTO_ip = 0o000;
-pub const PROTO_icmp = 0o001;
-pub const PROTO_igmp = 0o002;
-pub const PROTO_ggp = 0o003;
-pub const PROTO_ipencap = 0o004;
-pub const PROTO_st = 0o005;
-pub const PROTO_tcp = 0o006;
-pub const PROTO_egp = 0o010;
-pub const PROTO_pup = 0o014;
-pub const PROTO_udp = 0o021;
-pub const PROTO_hmp = 0o024;
-pub const PROTO_xns_idp = 0o026;
-pub const PROTO_rdp = 0o033;
-pub const PROTO_iso_tp4 = 0o035;
-pub const PROTO_xtp = 0o044;
-pub const PROTO_ddp = 0o045;
-pub const PROTO_idpr_cmtp = 0o046;
-pub const PROTO_ipv6 = 0o051;
-pub const PROTO_ipv6_route = 0o053;
-pub const PROTO_ipv6_frag = 0o054;
-pub const PROTO_idrp = 0o055;
-pub const PROTO_rsvp = 0o056;
-pub const PROTO_gre = 0o057;
-pub const PROTO_esp = 0o062;
-pub const PROTO_ah = 0o063;
-pub const PROTO_skip = 0o071;
-pub const PROTO_ipv6_icmp = 0o072;
-pub const PROTO_ipv6_nonxt = 0o073;
-pub const PROTO_ipv6_opts = 0o074;
-pub const PROTO_rspf = 0o111;
-pub const PROTO_vmtp = 0o121;
-pub const PROTO_ospf = 0o131;
-pub const PROTO_ipip = 0o136;
-pub const PROTO_encap = 0o142;
-pub const PROTO_pim = 0o147;
-pub const PROTO_raw = 0o377;
-
-pub const SHUT_RD = 0;
-pub const SHUT_WR = 1;
-pub const SHUT_RDWR = 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_DCCP = 6;
-pub const SOCK_PACKET = 10;
-pub const SOCK_CLOEXEC = 0o2000000;
-pub const SOCK_NONBLOCK = 0o4000;
-
-pub const PF_UNSPEC = 0;
-pub const PF_LOCAL = 1;
-pub const PF_UNIX = PF_LOCAL;
-pub const PF_FILE = PF_LOCAL;
-pub const PF_INET = 2;
-pub const PF_AX25 = 3;
-pub const PF_IPX = 4;
-pub const PF_APPLETALK = 5;
-pub const PF_NETROM = 6;
-pub const PF_BRIDGE = 7;
-pub const PF_ATMPVC = 8;
-pub const PF_X25 = 9;
-pub const PF_INET6 = 10;
-pub const PF_ROSE = 11;
-pub const PF_DECnet = 12;
-pub const PF_NETBEUI = 13;
-pub const PF_SECURITY = 14;
-pub const PF_KEY = 15;
-pub const PF_NETLINK = 16;
-pub const PF_ROUTE = PF_NETLINK;
-pub const PF_PACKET = 17;
-pub const PF_ASH = 18;
-pub const PF_ECONET = 19;
-pub const PF_ATMSVC = 20;
-pub const PF_RDS = 21;
-pub const PF_SNA = 22;
-pub const PF_IRDA = 23;
-pub const PF_PPPOX = 24;
-pub const PF_WANPIPE = 25;
-pub const PF_LLC = 26;
-pub const PF_IB = 27;
-pub const PF_MPLS = 28;
-pub const PF_CAN = 29;
-pub const PF_TIPC = 30;
-pub const PF_BLUETOOTH = 31;
-pub const PF_IUCV = 32;
-pub const PF_RXRPC = 33;
-pub const PF_ISDN = 34;
-pub const PF_PHONET = 35;
-pub const PF_IEEE802154 = 36;
-pub const PF_CAIF = 37;
-pub const PF_ALG = 38;
-pub const PF_NFC = 39;
-pub const PF_VSOCK = 40;
-pub const PF_KCM = 41;
-pub const PF_QIPCRTR = 42;
-pub const PF_SMC = 43;
-pub const PF_MAX = 44;
-
-pub const AF_UNSPEC = PF_UNSPEC;
-pub const AF_LOCAL = PF_LOCAL;
-pub const AF_UNIX = AF_LOCAL;
-pub const AF_FILE = AF_LOCAL;
-pub const AF_INET = PF_INET;
-pub const AF_AX25 = PF_AX25;
-pub const AF_IPX = PF_IPX;
-pub const AF_APPLETALK = PF_APPLETALK;
-pub const AF_NETROM = PF_NETROM;
-pub const AF_BRIDGE = PF_BRIDGE;
-pub const AF_ATMPVC = PF_ATMPVC;
-pub const AF_X25 = PF_X25;
-pub const AF_INET6 = PF_INET6;
-pub const AF_ROSE = PF_ROSE;
-pub const AF_DECnet = PF_DECnet;
-pub const AF_NETBEUI = PF_NETBEUI;
-pub const AF_SECURITY = PF_SECURITY;
-pub const AF_KEY = PF_KEY;
-pub const AF_NETLINK = PF_NETLINK;
-pub const AF_ROUTE = PF_ROUTE;
-pub const AF_PACKET = PF_PACKET;
-pub const AF_ASH = PF_ASH;
-pub const AF_ECONET = PF_ECONET;
-pub const AF_ATMSVC = PF_ATMSVC;
-pub const AF_RDS = PF_RDS;
-pub const AF_SNA = PF_SNA;
-pub const AF_IRDA = PF_IRDA;
-pub const AF_PPPOX = PF_PPPOX;
-pub const AF_WANPIPE = PF_WANPIPE;
-pub const AF_LLC = PF_LLC;
-pub const AF_IB = PF_IB;
-pub const AF_MPLS = PF_MPLS;
-pub const AF_CAN = PF_CAN;
-pub const AF_TIPC = PF_TIPC;
-pub const AF_BLUETOOTH = PF_BLUETOOTH;
-pub const AF_IUCV = PF_IUCV;
-pub const AF_RXRPC = PF_RXRPC;
-pub const AF_ISDN = PF_ISDN;
-pub const AF_PHONET = PF_PHONET;
-pub const AF_IEEE802154 = PF_IEEE802154;
-pub const AF_CAIF = PF_CAIF;
-pub const AF_ALG = PF_ALG;
-pub const AF_NFC = PF_NFC;
-pub const AF_VSOCK = PF_VSOCK;
-pub const AF_KCM = PF_KCM;
-pub const AF_QIPCRTR = PF_QIPCRTR;
-pub const AF_SMC = PF_SMC;
-pub const AF_MAX = PF_MAX;
-
-pub const SO_DEBUG = 1;
-pub const SO_REUSEADDR = 2;
-pub const SO_TYPE = 3;
-pub const SO_ERROR = 4;
-pub const SO_DONTROUTE = 5;
-pub const SO_BROADCAST = 6;
-pub const SO_SNDBUF = 7;
-pub const SO_RCVBUF = 8;
-pub const SO_KEEPALIVE = 9;
-pub const SO_OOBINLINE = 10;
-pub const SO_NO_CHECK = 11;
-pub const SO_PRIORITY = 12;
-pub const SO_LINGER = 13;
-pub const SO_BSDCOMPAT = 14;
-pub const SO_REUSEPORT = 15;
-pub const SO_PASSCRED = 16;
-pub const SO_PEERCRED = 17;
-pub const SO_RCVLOWAT = 18;
-pub const SO_SNDLOWAT = 19;
-pub const SO_RCVTIMEO = 20;
-pub const SO_SNDTIMEO = 21;
-pub const SO_ACCEPTCONN = 30;
-pub const SO_SNDBUFFORCE = 32;
-pub const SO_RCVBUFFORCE = 33;
-pub const SO_PROTOCOL = 38;
-pub const SO_DOMAIN = 39;
-
-pub const SO_SECURITY_AUTHENTICATION = 22;
-pub const SO_SECURITY_ENCRYPTION_TRANSPORT = 23;
-pub const SO_SECURITY_ENCRYPTION_NETWORK = 24;
-
-pub const SO_BINDTODEVICE = 25;
-
-pub const SO_ATTACH_FILTER = 26;
-pub const SO_DETACH_FILTER = 27;
-pub const SO_GET_FILTER = SO_ATTACH_FILTER;
-
-pub const SO_PEERNAME = 28;
-pub const SO_TIMESTAMP = 29;
-pub const SCM_TIMESTAMP = SO_TIMESTAMP;
-
-pub const SO_PEERSEC = 31;
-pub const SO_PASSSEC = 34;
-pub const SO_TIMESTAMPNS = 35;
-pub const SCM_TIMESTAMPNS = SO_TIMESTAMPNS;
-pub const SO_MARK = 36;
-pub const SO_TIMESTAMPING = 37;
-pub const SCM_TIMESTAMPING = SO_TIMESTAMPING;
-pub const SO_RXQ_OVFL = 40;
-pub const SO_WIFI_STATUS = 41;
-pub const SCM_WIFI_STATUS = SO_WIFI_STATUS;
-pub const SO_PEEK_OFF = 42;
-pub const SO_NOFCS = 43;
-pub const SO_LOCK_FILTER = 44;
-pub const SO_SELECT_ERR_QUEUE = 45;
-pub const SO_BUSY_POLL = 46;
-pub const SO_MAX_PACING_RATE = 47;
-pub const SO_BPF_EXTENSIONS = 48;
-pub const SO_INCOMING_CPU = 49;
-pub const SO_ATTACH_BPF = 50;
-pub const SO_DETACH_BPF = SO_DETACH_FILTER;
-pub const SO_ATTACH_REUSEPORT_CBPF = 51;
-pub const SO_ATTACH_REUSEPORT_EBPF = 52;
-pub const SO_CNX_ADVICE = 53;
-pub const SCM_TIMESTAMPING_OPT_STATS = 54;
-pub const SO_MEMINFO = 55;
-pub const SO_INCOMING_NAPI_ID = 56;
-pub const SO_COOKIE = 57;
-pub const SCM_TIMESTAMPING_PKTINFO = 58;
-pub const SO_PEERGROUPS = 59;
-pub const SO_ZEROCOPY = 60;
-
-pub const SOL_SOCKET = 1;
-
-pub const SOL_IP = 0;
-pub const SOL_IPV6 = 41;
-pub const SOL_ICMPV6 = 58;
-
-pub const SOL_RAW = 255;
-pub const SOL_DECNET = 261;
-pub const SOL_X25 = 262;
-pub const SOL_PACKET = 263;
-pub const SOL_ATM = 264;
-pub const SOL_AAL = 265;
-pub const SOL_IRDA = 266;
-pub const SOL_NETBEUI = 267;
-pub const SOL_LLC = 268;
-pub const SOL_DCCP = 269;
-pub const SOL_NETLINK = 270;
-pub const SOL_TIPC = 271;
-pub const SOL_RXRPC = 272;
-pub const SOL_PPPOL2TP = 273;
-pub const SOL_BLUETOOTH = 274;
-pub const SOL_PNPIPE = 275;
-pub const SOL_RDS = 276;
-pub const SOL_IUCV = 277;
-pub const SOL_CAIF = 278;
-pub const SOL_ALG = 279;
-pub const SOL_NFC = 280;
-pub const SOL_KCM = 281;
-pub const SOL_TLS = 282;
-
-pub const SOMAXCONN = 128;
-
-pub const MSG_OOB = 0x0001;
-pub const MSG_PEEK = 0x0002;
-pub const MSG_DONTROUTE = 0x0004;
-pub const MSG_CTRUNC = 0x0008;
-pub const MSG_PROXY = 0x0010;
-pub const MSG_TRUNC = 0x0020;
-pub const MSG_DONTWAIT = 0x0040;
-pub const MSG_EOR = 0x0080;
-pub const MSG_WAITALL = 0x0100;
-pub const MSG_FIN = 0x0200;
-pub const MSG_SYN = 0x0400;
-pub const MSG_CONFIRM = 0x0800;
-pub const MSG_RST = 0x1000;
-pub const MSG_ERRQUEUE = 0x2000;
-pub const MSG_NOSIGNAL = 0x4000;
-pub const MSG_MORE = 0x8000;
-pub const MSG_WAITFORONE = 0x10000;
-pub const MSG_BATCH = 0x40000;
-pub const MSG_ZEROCOPY = 0x4000000;
-pub const MSG_FASTOPEN = 0x20000000;
-pub const MSG_CMSG_CLOEXEC = 0x40000000;
-
-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 TCGETS = 0x5401;
-pub const TCSETS = 0x5402;
-pub const TCSETSW = 0x5403;
-pub const TCSETSF = 0x5404;
-pub const TCGETA = 0x5405;
-pub const TCSETA = 0x5406;
-pub const TCSETAW = 0x5407;
-pub const TCSETAF = 0x5408;
-pub const TCSBRK = 0x5409;
-pub const TCXONC = 0x540A;
-pub const TCFLSH = 0x540B;
-pub const TIOCEXCL = 0x540C;
-pub const TIOCNXCL = 0x540D;
-pub const TIOCSCTTY = 0x540E;
-pub const TIOCGPGRP = 0x540F;
-pub const TIOCSPGRP = 0x5410;
-pub const TIOCOUTQ = 0x5411;
-pub const TIOCSTI = 0x5412;
-pub const TIOCGWINSZ = 0x5413;
-pub const TIOCSWINSZ = 0x5414;
-pub const TIOCMGET = 0x5415;
-pub const TIOCMBIS = 0x5416;
-pub const TIOCMBIC = 0x5417;
-pub const TIOCMSET = 0x5418;
-pub const TIOCGSOFTCAR = 0x5419;
-pub const TIOCSSOFTCAR = 0x541A;
-pub const FIONREAD = 0x541B;
-pub const TIOCINQ = FIONREAD;
-pub const TIOCLINUX = 0x541C;
-pub const TIOCCONS = 0x541D;
-pub const TIOCGSERIAL = 0x541E;
-pub const TIOCSSERIAL = 0x541F;
-pub const TIOCPKT = 0x5420;
-pub const FIONBIO = 0x5421;
-pub const TIOCNOTTY = 0x5422;
-pub const TIOCSETD = 0x5423;
-pub const TIOCGETD = 0x5424;
-pub const TCSBRKP = 0x5425;
-pub const TIOCSBRK = 0x5427;
-pub const TIOCCBRK = 0x5428;
-pub const TIOCGSID = 0x5429;
-pub const TIOCGRS485 = 0x542E;
-pub const TIOCSRS485 = 0x542F;
-pub const TIOCGPTN = 0x80045430;
-pub const TIOCSPTLCK = 0x40045431;
-pub const TIOCGDEV = 0x80045432;
-pub const TCGETX = 0x5432;
-pub const TCSETX = 0x5433;
-pub const TCSETXF = 0x5434;
-pub const TCSETXW = 0x5435;
-pub const TIOCSIG = 0x40045436;
-pub const TIOCVHANGUP = 0x5437;
-pub const TIOCGPKT = 0x80045438;
-pub const TIOCGPTLCK = 0x80045439;
-pub const TIOCGEXCL = 0x80045440;
-
-pub const EPOLL_CLOEXEC = O_CLOEXEC;
-
-pub const EPOLL_CTL_ADD = 1;
-pub const EPOLL_CTL_DEL = 2;
-pub const EPOLL_CTL_MOD = 3;
-
-pub const EPOLLIN = 0x001;
-pub const EPOLLPRI = 0x002;
-pub const EPOLLOUT = 0x004;
-pub const EPOLLRDNORM = 0x040;
-pub const EPOLLRDBAND = 0x080;
-pub const EPOLLWRNORM = 0x100;
-pub const EPOLLWRBAND = 0x200;
-pub const EPOLLMSG = 0x400;
-pub const EPOLLERR = 0x008;
-pub const EPOLLHUP = 0x010;
-pub const EPOLLRDHUP = 0x2000;
-pub const EPOLLEXCLUSIVE = (u32(1) << 28);
-pub const EPOLLWAKEUP = (u32(1) << 29);
-pub const EPOLLONESHOT = (u32(1) << 30);
-pub const EPOLLET = (u32(1) << 31);
-
-pub const CLOCK_REALTIME = 0;
-pub const CLOCK_MONOTONIC = 1;
-pub const CLOCK_PROCESS_CPUTIME_ID = 2;
-pub const CLOCK_THREAD_CPUTIME_ID = 3;
-pub const CLOCK_MONOTONIC_RAW = 4;
-pub const CLOCK_REALTIME_COARSE = 5;
-pub const CLOCK_MONOTONIC_COARSE = 6;
-pub const CLOCK_BOOTTIME = 7;
-pub const CLOCK_REALTIME_ALARM = 8;
-pub const CLOCK_BOOTTIME_ALARM = 9;
-pub const CLOCK_SGI_CYCLE = 10;
-pub const CLOCK_TAI = 11;
-
-pub const CSIGNAL = 0x000000ff;
-pub const CLONE_VM = 0x00000100;
-pub const CLONE_FS = 0x00000200;
-pub const CLONE_FILES = 0x00000400;
-pub const CLONE_SIGHAND = 0x00000800;
-pub const CLONE_PTRACE = 0x00002000;
-pub const CLONE_VFORK = 0x00004000;
-pub const CLONE_PARENT = 0x00008000;
-pub const CLONE_THREAD = 0x00010000;
-pub const CLONE_NEWNS = 0x00020000;
-pub const CLONE_SYSVSEM = 0x00040000;
-pub const CLONE_SETTLS = 0x00080000;
-pub const CLONE_PARENT_SETTID = 0x00100000;
-pub const CLONE_CHILD_CLEARTID = 0x00200000;
-pub const CLONE_DETACHED = 0x00400000;
-pub const CLONE_UNTRACED = 0x00800000;
-pub const CLONE_CHILD_SETTID = 0x01000000;
-pub const CLONE_NEWCGROUP = 0x02000000;
-pub const CLONE_NEWUTS = 0x04000000;
-pub const CLONE_NEWIPC = 0x08000000;
-pub const CLONE_NEWUSER = 0x10000000;
-pub const CLONE_NEWPID = 0x20000000;
-pub const CLONE_NEWNET = 0x40000000;
-pub const CLONE_IO = 0x80000000;
-
-pub const EFD_SEMAPHORE = 1;
-pub const EFD_CLOEXEC = O_CLOEXEC;
-pub const EFD_NONBLOCK = O_NONBLOCK;
-
-pub const MS_RDONLY = 1;
-pub const MS_NOSUID = 2;
-pub const MS_NODEV = 4;
-pub const MS_NOEXEC = 8;
-pub const MS_SYNCHRONOUS = 16;
-pub const MS_REMOUNT = 32;
-pub const MS_MANDLOCK = 64;
-pub const MS_DIRSYNC = 128;
-pub const MS_NOATIME = 1024;
-pub const MS_NODIRATIME = 2048;
-pub const MS_BIND = 4096;
-pub const MS_MOVE = 8192;
-pub const MS_REC = 16384;
-pub const MS_SILENT = 32768;
-pub const MS_POSIXACL = (1 << 16);
-pub const MS_UNBINDABLE = (1 << 17);
-pub const MS_PRIVATE = (1 << 18);
-pub const MS_SLAVE = (1 << 19);
-pub const MS_SHARED = (1 << 20);
-pub const MS_RELATIME = (1 << 21);
-pub const MS_KERNMOUNT = (1 << 22);
-pub const MS_I_VERSION = (1 << 23);
-pub const MS_STRICTATIME = (1 << 24);
-pub const MS_LAZYTIME = (1 << 25);
-pub const MS_NOREMOTELOCK = (1 << 27);
-pub const MS_NOSEC = (1 << 28);
-pub const MS_BORN = (1 << 29);
-pub const MS_ACTIVE = (1 << 30);
-pub const MS_NOUSER = (1 << 31);
-
-pub const MS_RMT_MASK = (MS_RDONLY | MS_SYNCHRONOUS | MS_MANDLOCK | MS_I_VERSION | MS_LAZYTIME);
-
-pub const MS_MGC_VAL = 0xc0ed0000;
-pub const MS_MGC_MSK = 0xffff0000;
-
-pub const MNT_FORCE = 1;
-pub const MNT_DETACH = 2;
-pub const MNT_EXPIRE = 4;
-pub const UMOUNT_NOFOLLOW = 8;
-
-pub const IN_CLOEXEC = O_CLOEXEC;
-pub const IN_NONBLOCK = O_NONBLOCK;
-
-pub const IN_ACCESS = 0x00000001;
-pub const IN_MODIFY = 0x00000002;
-pub const IN_ATTRIB = 0x00000004;
-pub const IN_CLOSE_WRITE = 0x00000008;
-pub const IN_CLOSE_NOWRITE = 0x00000010;
-pub const IN_CLOSE = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
-pub const IN_OPEN = 0x00000020;
-pub const IN_MOVED_FROM = 0x00000040;
-pub const IN_MOVED_TO = 0x00000080;
-pub const IN_MOVE = IN_MOVED_FROM | IN_MOVED_TO;
-pub const IN_CREATE = 0x00000100;
-pub const IN_DELETE = 0x00000200;
-pub const IN_DELETE_SELF = 0x00000400;
-pub const IN_MOVE_SELF = 0x00000800;
-pub const IN_ALL_EVENTS = 0x00000fff;
-
-pub const IN_UNMOUNT = 0x00002000;
-pub const IN_Q_OVERFLOW = 0x00004000;
-pub const IN_IGNORED = 0x00008000;
-
-pub const IN_ONLYDIR = 0x01000000;
-pub const IN_DONT_FOLLOW = 0x02000000;
-pub const IN_EXCL_UNLINK = 0x04000000;
-pub const IN_MASK_ADD = 0x20000000;
-
-pub const IN_ISDIR = 0x40000000;
-pub const IN_ONESHOT = 0x80000000;
-
-pub const S_IFMT = 0o170000;
-
-pub const S_IFDIR = 0o040000;
-pub const S_IFCHR = 0o020000;
-pub const S_IFBLK = 0o060000;
-pub const S_IFREG = 0o100000;
-pub const S_IFIFO = 0o010000;
-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_IRUSR = 0o400;
-pub const S_IWUSR = 0o200;
-pub const S_IXUSR = 0o100;
-pub const S_IRWXU = 0o700;
-pub const S_IRGRP = 0o040;
-pub const S_IWGRP = 0o020;
-pub const S_IXGRP = 0o010;
-pub const S_IRWXG = 0o070;
-pub const S_IROTH = 0o004;
-pub const S_IWOTH = 0o002;
-pub const S_IXOTH = 0o001;
-pub const S_IRWXO = 0o007;
-
-pub fn S_ISREG(m: u32) bool {
- return m & S_IFMT == S_IFREG;
-}
-
-pub fn S_ISDIR(m: u32) bool {
- return m & S_IFMT == S_IFDIR;
-}
-
-pub fn S_ISCHR(m: u32) bool {
- return m & S_IFMT == S_IFCHR;
-}
-
-pub fn S_ISBLK(m: u32) bool {
- return m & S_IFMT == S_IFBLK;
-}
-
-pub fn S_ISFIFO(m: u32) bool {
- return m & S_IFMT == S_IFIFO;
-}
-
-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 const TFD_NONBLOCK = O_NONBLOCK;
-pub const TFD_CLOEXEC = O_CLOEXEC;
-
-pub const TFD_TIMER_ABSTIME = 1;
-pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
-
-fn unsigned(s: i32) u32 {
- return @bitCast(u32, s);
-}
-fn signed(s: u32) i32 {
- return @bitCast(i32, s);
-}
-pub fn WEXITSTATUS(s: i32) i32 {
- return signed((unsigned(s) & 0xff00) >> 8);
-}
-pub fn WTERMSIG(s: i32) i32 {
- return signed(unsigned(s) & 0x7f);
-}
-pub fn WSTOPSIG(s: i32) i32 {
- return WEXITSTATUS(s);
-}
-pub fn WIFEXITED(s: i32) bool {
- return WTERMSIG(s) == 0;
-}
-pub fn WIFSTOPPED(s: i32) bool {
- return @intCast(u16, ((unsigned(s) & 0xffff) *% 0x10001) >> 8) > 0x7f00;
-}
-pub fn WIFSIGNALED(s: i32) bool {
- return (unsigned(s) & 0xffff) -% 1 < 0xff;
-}
-
-pub const winsize = extern struct {
- ws_row: u16,
- ws_col: u16,
- ws_xpixel: u16,
- ws_ypixel: u16,
-};
-
-const NSIG = 65;
-const sigset_t = [128 / @sizeOf(usize)]usize;
-const all_mask = []u32{ 0xffffffff, 0xffffffff };
-const app_mask = []u32{ 0xfffffffc, 0x7fffffff };
-
-const k_sigaction = extern struct {
- handler: extern fn (i32) void,
- flags: usize,
- restorer: extern fn () void,
- mask: [2]u32,
-};
-
-/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
-pub const Sigaction = struct {
- handler: extern fn (i32) void,
- mask: sigset_t,
- flags: u32,
-};
-
-pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
-pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
-pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
-pub const empty_sigset = []usize{0} ** sigset_t.len;
-
-pub const in_port_t = u16;
-pub const sa_family_t = u16;
-pub const socklen_t = u32;
-
-/// This intentionally only has ip4 and ip6
-pub const sockaddr = extern union {
- in: sockaddr_in,
- in6: sockaddr_in6,
-};
-
-pub const sockaddr_in = extern struct {
- family: sa_family_t,
- port: in_port_t,
- addr: u32,
- zero: [8]u8,
-};
-
-pub const sockaddr_in6 = extern struct {
- family: sa_family_t,
- port: in_port_t,
- flowinfo: u32,
- addr: [16]u8,
- scope_id: u32,
-};
-
-pub const sockaddr_un = extern struct {
- family: sa_family_t,
- path: [108]u8,
-};
-
-pub const iovec = extern struct {
- iov_base: [*]u8,
- iov_len: usize,
-};
-
-pub const iovec_const = extern struct {
- iov_base: [*]const u8,
- iov_len: usize,
-};
-
-pub const mmsghdr = extern struct {
- msg_hdr: msghdr,
- msg_len: u32,
-};
-
-pub const mmsghdr_const = extern struct {
- msg_hdr: msghdr_const,
- msg_len: u32,
-};
-
-pub const epoll_data = extern union {
- ptr: usize,
- fd: i32,
- @"u32": u32,
- @"u64": u64,
-};
-
-// On x86_64 the structure is packed so that it matches the definition of its
-// 32bit counterpart
-pub const epoll_event = if (builtin.arch != .x86_64)
- extern struct {
- events: u32,
- data: epoll_data,
- }
-else
- packed struct {
- events: u32,
- data: epoll_data,
- };
-
-pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
-pub const _LINUX_CAPABILITY_U32S_1 = 1;
-
-pub const _LINUX_CAPABILITY_VERSION_2 = 0x20071026;
-pub const _LINUX_CAPABILITY_U32S_2 = 2;
-
-pub const _LINUX_CAPABILITY_VERSION_3 = 0x20080522;
-pub const _LINUX_CAPABILITY_U32S_3 = 2;
-
-pub const VFS_CAP_REVISION_MASK = 0xFF000000;
-pub const VFS_CAP_REVISION_SHIFT = 24;
-pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK;
-pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001;
-
-pub const VFS_CAP_REVISION_1 = 0x01000000;
-pub const VFS_CAP_U32_1 = 1;
-pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1);
-
-pub const VFS_CAP_REVISION_2 = 0x02000000;
-pub const VFS_CAP_U32_2 = 2;
-pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2);
-
-pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2;
-pub const VFS_CAP_U32 = VFS_CAP_U32_2;
-pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2;
-
-pub const vfs_cap_data = extern struct {
- //all of these are mandated as little endian
- //when on disk.
- const Data = struct {
- permitted: u32,
- inheritable: u32,
- };
-
- magic_etc: u32,
- data: [VFS_CAP_U32]Data,
-};
-
-pub const CAP_CHOWN = 0;
-pub const CAP_DAC_OVERRIDE = 1;
-pub const CAP_DAC_READ_SEARCH = 2;
-pub const CAP_FOWNER = 3;
-pub const CAP_FSETID = 4;
-pub const CAP_KILL = 5;
-pub const CAP_SETGID = 6;
-pub const CAP_SETUID = 7;
-pub const CAP_SETPCAP = 8;
-pub const CAP_LINUX_IMMUTABLE = 9;
-pub const CAP_NET_BIND_SERVICE = 10;
-pub const CAP_NET_BROADCAST = 11;
-pub const CAP_NET_ADMIN = 12;
-pub const CAP_NET_RAW = 13;
-pub const CAP_IPC_LOCK = 14;
-pub const CAP_IPC_OWNER = 15;
-pub const CAP_SYS_MODULE = 16;
-pub const CAP_SYS_RAWIO = 17;
-pub const CAP_SYS_CHROOT = 18;
-pub const CAP_SYS_PTRACE = 19;
-pub const CAP_SYS_PACCT = 20;
-pub const CAP_SYS_ADMIN = 21;
-pub const CAP_SYS_BOOT = 22;
-pub const CAP_SYS_NICE = 23;
-pub const CAP_SYS_RESOURCE = 24;
-pub const CAP_SYS_TIME = 25;
-pub const CAP_SYS_TTY_CONFIG = 26;
-pub const CAP_MKNOD = 27;
-pub const CAP_LEASE = 28;
-pub const CAP_AUDIT_WRITE = 29;
-pub const CAP_AUDIT_CONTROL = 30;
-pub const CAP_SETFCAP = 31;
-pub const CAP_MAC_OVERRIDE = 32;
-pub const CAP_MAC_ADMIN = 33;
-pub const CAP_SYSLOG = 34;
-pub const CAP_WAKE_ALARM = 35;
-pub const CAP_BLOCK_SUSPEND = 36;
-pub const CAP_AUDIT_READ = 37;
-pub const CAP_LAST_CAP = CAP_AUDIT_READ;
-
-pub fn cap_valid(u8: x) bool {
- return x >= 0 and x <= CAP_LAST_CAP;
-}
-
-pub fn CAP_TO_MASK(cap: u8) u32 {
- return u32(1) << u5(cap & 31);
-}
-
-pub fn CAP_TO_INDEX(cap: u8) u8 {
- return cap >> 5;
-}
-
-pub const cap_t = extern struct {
- hdrp: *cap_user_header_t,
- datap: *cap_user_data_t,
-};
-
-pub const cap_user_header_t = extern struct {
- version: u32,
- pid: usize,
-};
-
-pub const cap_user_data_t = extern struct {
- effective: u32,
- permitted: u32,
- inheritable: u32,
-};
-
-pub const inotify_event = extern struct {
- wd: i32,
- mask: u32,
- cookie: u32,
- len: u32,
- //name: [?]u8,
-};
-
-pub const dirent64 = extern struct {
- d_ino: u64,
- d_off: u64,
- d_reclen: u16,
- d_type: u8,
- d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173
-};
-
-pub const dl_phdr_info = extern struct {
- dlpi_addr: usize,
- dlpi_name: ?[*]const u8,
- dlpi_phdr: [*]elf.Phdr,
- dlpi_phnum: u16,
-};
diff --git a/std/os/linux/sys.zig b/std/os/linux/sys.zig
@@ -17,8 +17,7 @@ pub use switch (builtin.arch) {
.aarch64 => @import("arm64.zig"),
else => struct {},
};
-pub const posix = @import("posix.zig");
-pub use posix;
+pub use @import("../bits.zig");
/// See `std.os.posix.getauxval`.
pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
diff --git a/std/os/wasi.zig b/std/os/wasi.zig
@@ -1,11 +1,11 @@
// Based on https://github.com/CraneStation/wasi-sysroot/blob/wasi/libc-bottom-half/headers/public/wasi/core.h
// and https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md
+const builtin = @import("builtin");
const std = @import("std");
const assert = std.debug.assert;
-pub const is_the_target = @import("builtin").os == .wasi;
-pub const posix = @import("wasi/posix.zig");
-pub use posix;
+pub const is_the_target = builtin.os == .wasi;
+pub use @import("bits/wasi.zig");
comptime {
assert(@alignOf(i8) == 1);
diff --git a/std/os/windows.zig b/std/os/windows.zig
@@ -1,12 +1,14 @@
-// This file contains the types and constants of the Windows API,
-// as well as the Windows-equivalent of "Zig-flavored POSIX" API layer.
+// This file contains thin wrappers around Windows-specific APIs, with these
+// specific goals in mind:
+// * Convert "errno"-style error codes into Zig errors.
+// * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept
+// slices as well as APIs which accept null-terminated UTF16LE byte buffers.
+
const std = @import("../std.zig");
const assert = std.debug.assert;
const maxInt = std.math.maxInt;
pub const is_the_target = builtin.os == .windows;
-pub const posix = if (builtin.link_libc) struct {} else @import("windows/posix.zig");
-pub use posix;
pub const advapi32 = @import("windows/advapi32.zig");
pub const kernel32 = @import("windows/kernel32.zig");
@@ -565,7 +567,7 @@ pub fn CreateFile(
share_mode: DWORD,
creation_disposition: DWORD,
flags_and_attrs: DWORD,
-) CreateFileError!fd_t {
+) CreateFileError!HANDLE {
const file_path_w = try sliceToPrefixedFileW(file_path);
return CreateFileW(&file_path_w, desired_access, share_mode, creation_disposition, flags_and_attrs);
}
@@ -934,7 +936,7 @@ pub const GetStdHandleError = error{
Unexpected,
};
-pub fn GetStdHandle(handle_id: DWORD) GetStdHandleError!fd_t {
+pub fn GetStdHandle(handle_id: DWORD) GetStdHandleError!HANDLE {
const handle = kernel32.GetStdHandle(handle_id) orelse return error.NoStandardHandleAttached;
if (handle == INVALID_HANDLE_VALUE) {
switch (kernel32.GetLastError()) {
diff --git a/std/os/windows/posix.zig b/std/os/windows/posix.zig
@@ -1,6 +0,0 @@
-// Declarations that are intended to be imported into the POSIX namespace,
-// when not linking libc.
-const std = @import("../../std.zig");
-const builtin = @import("builtin");
-
-pub const fd_t = std.os.windows.HANDLE;
diff --git a/std/os/zen.zig b/std/os/zen.zig
@@ -80,7 +80,7 @@ pub const STDOUT_FILENO = 1;
pub const STDERR_FILENO = 2;
// FIXME: let's borrow Linux's error numbers for now.
-use @import("linux/errno.zig");
+use @import("../bits/linux/errno.zig");
// Get the errno from a syscall return value, or 0 for no error.
pub fn getErrno(r: usize) usize {
const signed_r = @bitCast(isize, r);