diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-09-15 14:46:31 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-09-15 14:51:08 -0700 |
| commit | f3ebfcae3882c03da84821abed40167ea07a8c78 (patch) | |
| tree | f1b759c94cba5b020a9ffb141fc62cb686fc5f04 /lib/std/os/bits | |
| parent | 111a2dcf3ad53c0c8ad2c9e7c9bd042b81e90c82 (diff) | |
| parent | 0395b35cee8d4082cc40b0dcd0298f797f42309d (diff) | |
| download | zig-f3ebfcae3882c03da84821abed40167ea07a8c78.tar.gz zig-f3ebfcae3882c03da84821abed40167ea07a8c78.zip | |
Merge remote-tracking branch 'origin/master' into llvm13
Conflicts:
* cmake/Findclang.cmake
* cmake/Findlld.cmake
* cmake/Findllvm.cmake
In master branch, more search paths were added to these files with "12"
in the path. In this commit I updated them to "13".
* src/stage1/codegen.cpp
* src/zig_llvm.cpp
* src/zig_llvm.h
In master branch, ZigLLVMBuildCmpXchg is improved to add
`is_single_threaded`. However, the LLVM 13 C API has this already, and
in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C
API. In this commit I updated stage2 to use the LLVM 13 C API rather
than depending on an improved ZigLLVMBuildCmpXchg.
Additionally, src/target.zig largestAtomicBits needed to be updated to
include the new m68k ISA.
Diffstat (limited to 'lib/std/os/bits')
26 files changed, 0 insertions, 18668 deletions
diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig deleted file mode 100644 index a0f5e5a400..0000000000 --- a/lib/std/os/bits/darwin.zig +++ /dev/null @@ -1,1785 +0,0 @@ -const std = @import("../../std.zig"); -const assert = std.debug.assert; -const maxInt = std.math.maxInt; - -pub usingnamespace @import("posix.zig"); - -// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html -// TODO: audit mode_t/pid_t, should likely be u16/i32 -pub const fd_t = c_int; -pub const pid_t = c_int; -pub const mode_t = c_uint; -pub const uid_t = u32; -pub const gid_t = u32; - -pub const in_port_t = u16; -pub const sa_family_t = u8; -pub const socklen_t = u32; -pub const sockaddr = extern struct { - len: u8, - family: sa_family_t, - data: [14]u8, -}; -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; -pub const sockaddr_in = extern struct { - len: u8 = @sizeOf(sockaddr_in), - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; -pub const sockaddr_in6 = extern struct { - len: u8 = @sizeOf(sockaddr_in6), - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -/// UNIX domain socket -pub const sockaddr_un = extern struct { - len: u8 = @sizeOf(sockaddr_un), - family: sa_family_t = AF_UNIX, - path: [104]u8, -}; - -pub const timeval = extern struct { - tv_sec: c_long, - tv_usec: i32, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const mach_timebase_info_data = extern struct { - numer: u32, - denom: u32, -}; - -pub const off_t = i64; -pub const ino_t = u64; - -pub const Flock = extern struct { - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - l_type: i16, - l_whence: i16, -}; - -pub const libc_stat = extern struct { - dev: i32, - mode: u16, - nlink: u16, - ino: ino_t, - uid: uid_t, - gid: gid_t, - rdev: i32, - atimesec: isize, - atimensec: isize, - mtimesec: isize, - mtimensec: isize, - ctimesec: isize, - ctimensec: isize, - birthtimesec: isize, - birthtimensec: isize, - size: off_t, - blocks: i64, - blksize: i32, - flags: u32, - gen: u32, - lspare: i32, - qspare: [2]i64, - - pub fn atime(self: @This()) timespec { - return timespec{ - .tv_sec = self.atimesec, - .tv_nsec = self.atimensec, - }; - } - - pub fn mtime(self: @This()) timespec { - return timespec{ - .tv_sec = self.mtimesec, - .tv_nsec = self.mtimensec, - }; - } - - pub fn ctime(self: @This()) timespec { - return timespec{ - .tv_sec = self.ctimesec, - .tv_nsec = self.ctimensec, - }; - } -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const sigset_t = u32; -pub const empty_sigset: sigset_t = 0; - -pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); -pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); -pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); -pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5); - -pub const siginfo_t = extern struct { - signo: c_int, - errno: c_int, - code: c_int, - pid: pid_t, - uid: uid_t, - status: c_int, - addr: *c_void, - value: extern union { - int: c_int, - ptr: *c_void, - }, - si_band: c_long, - _pad: [7]c_ulong, -}; - -/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. -pub const Sigaction = extern struct { - pub const handler_fn = fn (c_int) callconv(.C) void; - pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; - - handler: extern union { - handler: ?handler_fn, - sigaction: ?sigaction_fn, - }, - mask: sigset_t, - flags: c_uint, -}; - -pub const dirent = extern struct { - d_ino: usize, - d_seekoff: usize, - d_reclen: u16, - d_namlen: u16, - d_type: u8, - d_name: u8, // field address is address of first byte of name - - pub fn reclen(self: dirent) u16 { - return self.d_reclen; - } -}; - -/// Renamed from `kevent` to `Kevent` to avoid conflict with function name. -pub const Kevent = extern struct { - ident: usize, - filter: i16, - flags: u16, - fflags: u32, - data: isize, - udata: usize, -}; - -// sys/types.h on macos uses #pragma pack(4) so these checks are -// to make sure the struct is laid out the same. These values were -// produced from C code using the offsetof macro. -comptime { - assert(@offsetOf(Kevent, "ident") == 0); - assert(@offsetOf(Kevent, "filter") == 8); - assert(@offsetOf(Kevent, "flags") == 10); - assert(@offsetOf(Kevent, "fflags") == 12); - assert(@offsetOf(Kevent, "data") == 16); - assert(@offsetOf(Kevent, "udata") == 24); -} - -pub const kevent64_s = extern struct { - ident: u64, - filter: i16, - flags: u16, - fflags: u32, - data: i64, - udata: u64, - ext: [2]u64, -}; - -// sys/types.h on macos uses #pragma pack() so these checks are -// to make sure the struct is laid out the same. These values were -// produced from C code using the offsetof macro. -comptime { - assert(@offsetOf(kevent64_s, "ident") == 0); - assert(@offsetOf(kevent64_s, "filter") == 8); - assert(@offsetOf(kevent64_s, "flags") == 10); - assert(@offsetOf(kevent64_s, "fflags") == 12); - assert(@offsetOf(kevent64_s, "data") == 16); - assert(@offsetOf(kevent64_s, "udata") == 24); - assert(@offsetOf(kevent64_s, "ext") == 32); -} - -pub const mach_port_t = c_uint; -pub const clock_serv_t = mach_port_t; -pub const clock_res_t = c_int; -pub const mach_port_name_t = natural_t; -pub const natural_t = c_uint; -pub const mach_timespec_t = extern struct { - tv_sec: c_uint, - tv_nsec: clock_res_t, -}; -pub const kern_return_t = c_int; -pub const host_t = mach_port_t; -pub const CALENDAR_CLOCK = 1; - -pub const PATH_MAX = 1024; -pub const IOV_MAX = 16; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -/// [MC2] no permissions -pub const PROT_NONE = 0x00; - -/// [MC2] pages can be read -pub const PROT_READ = 0x01; - -/// [MC2] pages can be written -pub const PROT_WRITE = 0x02; - -/// [MC2] pages can be executed -pub const PROT_EXEC = 0x04; - -/// allocated from memory, swap space -pub const MAP_ANONYMOUS = 0x1000; - -/// map from file (default) -pub const MAP_FILE = 0x0000; - -/// interpret addr exactly -pub const MAP_FIXED = 0x0010; - -/// region may contain semaphores -pub const MAP_HASSEMAPHORE = 0x0200; - -/// changes are private -pub const MAP_PRIVATE = 0x0002; - -/// share changes -pub const MAP_SHARED = 0x0001; - -/// don't cache pages for this mapping -pub const MAP_NOCACHE = 0x0400; - -/// don't reserve needed swap area -pub const MAP_NORESERVE = 0x0040; -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); - -/// [XSI] no hang in wait/no child to reap -pub const WNOHANG = 0x00000001; - -/// [XSI] notify on stop, untraced child -pub const WUNTRACED = 0x00000002; - -/// take signal on signal stack -pub const SA_ONSTACK = 0x0001; - -/// restart system on signal return -pub const SA_RESTART = 0x0002; - -/// reset to SIG_DFL when taking signal -pub const SA_RESETHAND = 0x0004; - -/// do not generate SIGCHLD on child stop -pub const SA_NOCLDSTOP = 0x0008; - -/// don't mask the signal we're delivering -pub const SA_NODEFER = 0x0010; - -/// don't keep zombies around -pub const SA_NOCLDWAIT = 0x0020; - -/// signal handler with SA_SIGINFO args -pub const SA_SIGINFO = 0x0040; - -/// do not bounce off kernel's sigtramp -pub const SA_USERTRAMP = 0x0100; - -/// signal handler with SA_SIGINFO args with 64bit regs information -pub const SA_64REGSET = 0x0200; - -pub const O_PATH = 0x0000; - -pub const F_OK = 0; -pub const X_OK = 1; -pub const W_OK = 2; -pub const R_OK = 4; - -/// open for reading only -pub const O_RDONLY = 0x0000; - -/// open for writing only -pub const O_WRONLY = 0x0001; - -/// open for reading and writing -pub const O_RDWR = 0x0002; - -/// do not block on open or for data to become available -pub const O_NONBLOCK = 0x0004; - -/// append on each write -pub const O_APPEND = 0x0008; - -/// create file if it does not exist -pub const O_CREAT = 0x0200; - -/// truncate size to 0 -pub const O_TRUNC = 0x0400; - -/// error if O_CREAT and the file exists -pub const O_EXCL = 0x0800; - -/// atomically obtain a shared lock -pub const O_SHLOCK = 0x0010; - -/// atomically obtain an exclusive lock -pub const O_EXLOCK = 0x0020; - -/// do not follow symlinks -pub const O_NOFOLLOW = 0x0100; - -/// allow open of symlinks -pub const O_SYMLINK = 0x200000; - -/// descriptor requested for event notifications only -pub const O_EVTONLY = 0x8000; - -/// mark as close-on-exec -pub const O_CLOEXEC = 0x1000000; - -pub const O_ACCMODE = 3; -pub const O_ALERT = 536870912; -pub const O_ASYNC = 64; -pub const O_DIRECTORY = 1048576; -pub const O_DP_GETRAWENCRYPTED = 1; -pub const O_DP_GETRAWUNENCRYPTED = 2; -pub const O_DSYNC = 4194304; -pub const O_FSYNC = O_SYNC; -pub const O_NOCTTY = 131072; -pub const O_POPUP = 2147483648; -pub const O_SYNC = 128; - -pub const SEEK_SET = 0x0; -pub const SEEK_CUR = 0x1; -pub const SEEK_END = 0x2; - -pub const DT_UNKNOWN = 0; -pub const DT_FIFO = 1; -pub const DT_CHR = 2; -pub const DT_DIR = 4; -pub const DT_BLK = 6; -pub const DT_REG = 8; -pub const DT_LNK = 10; -pub const DT_SOCK = 12; -pub const DT_WHT = 14; - -/// block specified signal set -pub const SIG_BLOCK = 1; - -/// unblock specified signal set -pub const SIG_UNBLOCK = 2; - -/// set specified signal set -pub const SIG_SETMASK = 3; - -/// hangup -pub const SIGHUP = 1; - -/// interrupt -pub const SIGINT = 2; - -/// quit -pub const SIGQUIT = 3; - -/// illegal instruction (not reset when caught) -pub const SIGILL = 4; - -/// trace trap (not reset when caught) -pub const SIGTRAP = 5; - -/// abort() -pub const SIGABRT = 6; - -/// pollable event ([XSR] generated, not supported) -pub const SIGPOLL = 7; - -/// compatibility -pub const SIGIOT = SIGABRT; - -/// EMT instruction -pub const SIGEMT = 7; - -/// floating point exception -pub const SIGFPE = 8; - -/// kill (cannot be caught or ignored) -pub const SIGKILL = 9; - -/// bus error -pub const SIGBUS = 10; - -/// segmentation violation -pub const SIGSEGV = 11; - -/// bad argument to system call -pub const SIGSYS = 12; - -/// write on a pipe with no one to read it -pub const SIGPIPE = 13; - -/// alarm clock -pub const SIGALRM = 14; - -/// software termination signal from kill -pub const SIGTERM = 15; - -/// urgent condition on IO channel -pub const SIGURG = 16; - -/// sendable stop signal not from tty -pub const SIGSTOP = 17; - -/// stop signal from tty -pub const SIGTSTP = 18; - -/// continue a stopped process -pub const SIGCONT = 19; - -/// to parent on child stop or exit -pub const SIGCHLD = 20; - -/// to readers pgrp upon background tty read -pub const SIGTTIN = 21; - -/// like TTIN for output if (tp->t_local<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; - -/// Not actually supported by Darwin, but Zig supplies a shim. -/// This numerical value is not ABI-stable. It need only not conflict -/// with any other "SOCK_" bits. -pub const SOCK_CLOEXEC = 1 << 15; -/// Not actually supported by Darwin, but Zig supplies a shim. -/// This numerical value is not ABI-stable. It need only not conflict -/// with any other "SOCK_" bits. -pub const SOCK_NONBLOCK = 1 << 16; - -pub const IPPROTO_ICMP = 1; -pub const IPPROTO_ICMPV6 = 58; -pub const IPPROTO_TCP = 6; -pub const IPPROTO_UDP = 17; -pub const IPPROTO_IP = 0; -pub const IPPROTO_IPV6 = 41; - -pub const SOL_SOCKET = 0xffff; - -pub const SO_DEBUG = 0x0001; -pub const SO_ACCEPTCONN = 0x0002; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_USELOOPBACK = 0x0040; -pub const SO_LINGER = 0x1080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_ACCEPTFILTER = 0x1000; -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; - -pub const SO_NREAD = 0x1020; -pub const SO_NKE = 0x1021; -pub const SO_NOSIGPIPE = 0x1022; -pub const SO_NOADDRERR = 0x1023; -pub const SO_NWRITE = 0x1024; -pub const SO_REUSESHAREUID = 0x1025; - -fn wstatus(x: u32) u32 { - return x & 0o177; -} -const wstopped = 0o177; -pub fn WEXITSTATUS(x: u32) u8 { - return @intCast(u8, x >> 8); -} -pub fn WTERMSIG(x: u32) u32 { - return wstatus(x); -} -pub fn WSTOPSIG(x: u32) u32 { - return x >> 8; -} -pub fn WIFEXITED(x: u32) bool { - return wstatus(x) == 0; -} -pub fn WIFSTOPPED(x: u32) bool { - return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13; -} -pub fn WIFSIGNALED(x: u32) bool { - return wstatus(x) != wstopped and wstatus(x) != 0; -} - -pub const E = enum(u16) { - /// No error occurred. - SUCCESS = 0, - - /// Operation not permitted - PERM = 1, - - /// No such file or directory - NOENT = 2, - - /// No such process - SRCH = 3, - - /// Interrupted system call - INTR = 4, - - /// Input/output error - IO = 5, - - /// Device not configured - NXIO = 6, - - /// Argument list too long - @"2BIG" = 7, - - /// Exec format error - NOEXEC = 8, - - /// Bad file descriptor - BADF = 9, - - /// No child processes - CHILD = 10, - - /// Resource deadlock avoided - DEADLK = 11, - - /// Cannot allocate memory - NOMEM = 12, - - /// Permission denied - ACCES = 13, - - /// Bad address - FAULT = 14, - - /// Block device required - NOTBLK = 15, - - /// Device / Resource busy - BUSY = 16, - - /// File exists - EXIST = 17, - - /// Cross-device link - XDEV = 18, - - /// Operation not supported by device - NODEV = 19, - - /// Not a directory - NOTDIR = 20, - - /// Is a directory - ISDIR = 21, - - /// Invalid argument - INVAL = 22, - - /// Too many open files in system - NFILE = 23, - - /// Too many open files - MFILE = 24, - - /// Inappropriate ioctl for device - NOTTY = 25, - - /// Text file busy - TXTBSY = 26, - - /// File too large - FBIG = 27, - - /// No space left on device - NOSPC = 28, - - /// Illegal seek - SPIPE = 29, - - /// Read-only file system - ROFS = 30, - - /// Too many links - MLINK = 31, - - /// Broken pipe - PIPE = 32, - - // math software - - /// Numerical argument out of domain - DOM = 33, - - /// Result too large - RANGE = 34, - - // non-blocking and interrupt i/o - - /// Resource temporarily unavailable - /// This is the same code used for `WOULDBLOCK`. - AGAIN = 35, - - /// Operation now in progress - INPROGRESS = 36, - - /// Operation already in progress - ALREADY = 37, - - // ipc/network software -- argument errors - - /// Socket operation on non-socket - NOTSOCK = 38, - - /// Destination address required - DESTADDRREQ = 39, - - /// Message too long - MSGSIZE = 40, - - /// Protocol wrong type for socket - PROTOTYPE = 41, - - /// Protocol not available - NOPROTOOPT = 42, - - /// Protocol not supported - PROTONOSUPPORT = 43, - - /// Socket type not supported - SOCKTNOSUPPORT = 44, - - /// Operation not supported - /// The same code is used for `NOTSUP`. - OPNOTSUPP = 45, - - /// Protocol family not supported - PFNOSUPPORT = 46, - - /// Address family not supported by protocol family - AFNOSUPPORT = 47, - - /// Address already in use - ADDRINUSE = 48, - /// Can't assign requested address - - // ipc/network software -- operational errors - ADDRNOTAVAIL = 49, - - /// Network is down - NETDOWN = 50, - - /// Network is unreachable - NETUNREACH = 51, - - /// Network dropped connection on reset - NETRESET = 52, - - /// Software caused connection abort - CONNABORTED = 53, - - /// Connection reset by peer - CONNRESET = 54, - - /// No buffer space available - NOBUFS = 55, - - /// Socket is already connected - ISCONN = 56, - - /// Socket is not connected - NOTCONN = 57, - - /// Can't send after socket shutdown - SHUTDOWN = 58, - - /// Too many references: can't splice - TOOMANYREFS = 59, - - /// Operation timed out - TIMEDOUT = 60, - - /// Connection refused - CONNREFUSED = 61, - - /// Too many levels of symbolic links - LOOP = 62, - - /// File name too long - NAMETOOLONG = 63, - - /// Host is down - HOSTDOWN = 64, - - /// No route to host - HOSTUNREACH = 65, - /// Directory not empty - - // quotas & mush - NOTEMPTY = 66, - - /// Too many processes - PROCLIM = 67, - - /// Too many users - USERS = 68, - /// Disc quota exceeded - - // Network File System - DQUOT = 69, - - /// Stale NFS file handle - STALE = 70, - - /// Too many levels of remote in path - REMOTE = 71, - - /// RPC struct is bad - BADRPC = 72, - - /// RPC version wrong - RPCMISMATCH = 73, - - /// RPC prog. not avail - PROGUNAVAIL = 74, - - /// Program version wrong - PROGMISMATCH = 75, - - /// Bad procedure for program - PROCUNAVAIL = 76, - - /// No locks available - NOLCK = 77, - - /// Function not implemented - NOSYS = 78, - - /// Inappropriate file type or format - FTYPE = 79, - - /// Authentication error - AUTH = 80, - - /// Need authenticator - NEEDAUTH = 81, - - // Intelligent device errors - - /// Device power is off - PWROFF = 82, - - /// Device error, e.g. paper out - DEVERR = 83, - - /// Value too large to be stored in data type - OVERFLOW = 84, - - // Program loading errors - - /// Bad executable - BADEXEC = 85, - - /// Bad CPU type in executable - BADARCH = 86, - - /// Shared library version mismatch - SHLIBVERS = 87, - - /// Malformed Macho file - BADMACHO = 88, - - /// Operation canceled - CANCELED = 89, - - /// Identifier removed - IDRM = 90, - - /// No message of desired type - NOMSG = 91, - - /// Illegal byte sequence - ILSEQ = 92, - - /// Attribute not found - NOATTR = 93, - - /// Bad message - BADMSG = 94, - - /// Reserved - MULTIHOP = 95, - - /// No message available on STREAM - NODATA = 96, - - /// Reserved - NOLINK = 97, - - /// No STREAM resources - NOSR = 98, - - /// Not a STREAM - NOSTR = 99, - - /// Protocol error - PROTO = 100, - - /// STREAM ioctl timeout - TIME = 101, - - /// No such policy registered - NOPOLICY = 103, - - /// State not recoverable - NOTRECOVERABLE = 104, - - /// Previous owner died - OWNERDEAD = 105, - - /// Interface output queue is full - QFULL = 106, - - _, -}; - -pub const SIGSTKSZ = 131072; -pub const MINSIGSTKSZ = 32768; - -pub const SS_ONSTACK = 1; -pub const SS_DISABLE = 4; - -pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, -}; - -pub const S_IFMT = 0o170000; - -pub const S_IFIFO = 0o010000; -pub const S_IFCHR = 0o020000; -pub const S_IFDIR = 0o040000; -pub const S_IFBLK = 0o060000; -pub const S_IFREG = 0o100000; -pub const S_IFLNK = 0o120000; -pub const S_IFSOCK = 0o140000; -pub const S_IFWHT = 0o160000; - -pub const S_ISUID = 0o4000; -pub const S_ISGID = 0o2000; -pub const S_ISVTX = 0o1000; -pub const S_IRWXU = 0o700; -pub const S_IRUSR = 0o400; -pub const S_IWUSR = 0o200; -pub const S_IXUSR = 0o100; -pub const S_IRWXG = 0o070; -pub const S_IRGRP = 0o040; -pub const S_IWGRP = 0o020; -pub const S_IXGRP = 0o010; -pub const S_IRWXO = 0o007; -pub const S_IROTH = 0o004; -pub const S_IWOTH = 0o002; -pub const S_IXOTH = 0o001; - -pub fn S_ISFIFO(m: u32) bool { - return m & S_IFMT == S_IFIFO; -} - -pub fn S_ISCHR(m: u32) bool { - return m & S_IFMT == S_IFCHR; -} - -pub fn S_ISDIR(m: u32) bool { - return m & S_IFMT == S_IFDIR; -} - -pub fn S_ISBLK(m: u32) bool { - return m & S_IFMT == S_IFBLK; -} - -pub fn S_ISREG(m: u32) bool { - return m & S_IFMT == S_IFREG; -} - -pub fn S_ISLNK(m: u32) bool { - return m & S_IFMT == S_IFLNK; -} - -pub fn S_ISSOCK(m: u32) bool { - return m & S_IFMT == S_IFSOCK; -} - -pub fn S_IWHT(m: u32) bool { - return m & S_IFMT == S_IFWHT; -} - -pub const HOST_NAME_MAX = 72; - -pub const AT_FDCWD = -2; - -/// Use effective ids in access check -pub const AT_EACCESS = 0x0010; - -/// Act on the symlink itself not the target -pub const AT_SYMLINK_NOFOLLOW = 0x0020; - -/// Act on target of symlink -pub const AT_SYMLINK_FOLLOW = 0x0040; - -/// Path refers to directory -pub const AT_REMOVEDIR = 0x0080; - -pub const addrinfo = extern struct { - flags: i32, - family: i32, - socktype: i32, - protocol: i32, - addrlen: socklen_t, - canonname: ?[*:0]u8, - addr: ?*sockaddr, - next: ?*addrinfo, -}; - -pub const RTLD_LAZY = 0x1; -pub const RTLD_NOW = 0x2; -pub const RTLD_LOCAL = 0x4; -pub const RTLD_GLOBAL = 0x8; -pub const RTLD_NOLOAD = 0x10; -pub const RTLD_NODELETE = 0x80; -pub const RTLD_FIRST = 0x100; - -pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); -pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); -pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); -pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5))); - -/// duplicate file descriptor -pub const F_DUPFD = 0; - -/// get file descriptor flags -pub const F_GETFD = 1; - -/// set file descriptor flags -pub const F_SETFD = 2; - -/// get file status flags -pub const F_GETFL = 3; - -/// set file status flags -pub const F_SETFL = 4; - -/// get SIGIO/SIGURG proc/pgrp -pub const F_GETOWN = 5; - -/// set SIGIO/SIGURG proc/pgrp -pub const F_SETOWN = 6; - -/// get record locking information -pub const F_GETLK = 7; - -/// set record locking information -pub const F_SETLK = 8; - -/// F_SETLK; wait if blocked -pub const F_SETLKW = 9; - -/// F_SETLK; wait if blocked, return on timeout -pub const F_SETLKWTIMEOUT = 10; -pub const F_FLUSH_DATA = 40; - -/// Used for regression test -pub const F_CHKCLEAN = 41; - -/// Preallocate storage -pub const F_PREALLOCATE = 42; - -/// Truncate a file without zeroing space -pub const F_SETSIZE = 43; - -/// Issue an advisory read async with no copy to user -pub const F_RDADVISE = 44; - -/// turn read ahead off/on for this fd -pub const F_RDAHEAD = 45; - -/// turn data caching off/on for this fd -pub const F_NOCACHE = 48; - -/// file offset to device offset -pub const F_LOG2PHYS = 49; - -/// return the full path of the fd -pub const F_GETPATH = 50; - -/// fsync + ask the drive to flush to the media -pub const F_FULLFSYNC = 51; - -/// find which component (if any) is a package -pub const F_PATHPKG_CHECK = 52; - -/// "freeze" all fs operations -pub const F_FREEZE_FS = 53; - -/// "thaw" all fs operations -pub const F_THAW_FS = 54; - -/// turn data caching off/on (globally) for this file -pub const F_GLOBAL_NOCACHE = 55; - -/// add detached signatures -pub const F_ADDSIGS = 59; - -/// add signature from same file (used by dyld for shared libs) -pub const F_ADDFILESIGS = 61; - -/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes -/// should not be used (i.e. its ok to temporaily create cached pages) -pub const F_NODIRECT = 62; - -///Get the protection class of a file from the EA, returns int -pub const F_GETPROTECTIONCLASS = 63; - -///Set the protection class of a file for the EA, requires int -pub const F_SETPROTECTIONCLASS = 64; - -///file offset to device offset, extended -pub const F_LOG2PHYS_EXT = 65; - -///get record locking information, per-process -pub const F_GETLKPID = 66; - -///Mark the file as being the backing store for another filesystem -pub const F_SETBACKINGSTORE = 70; - -///return the full path of the FD, but error in specific mtmd circumstances -pub const F_GETPATH_MTMINFO = 71; - -///Returns the code directory, with associated hashes, to the caller -pub const F_GETCODEDIR = 72; - -///No SIGPIPE generated on EPIPE -pub const F_SETNOSIGPIPE = 73; - -///Status of SIGPIPE for this fd -pub const F_GETNOSIGPIPE = 74; - -///For some cases, we need to rewrap the key for AKS/MKB -pub const F_TRANSCODEKEY = 75; - -///file being written to a by single writer... if throttling enabled, writes -///may be broken into smaller chunks with throttling in between -pub const F_SINGLE_WRITER = 76; - -///Get the protection version number for this filesystem -pub const F_GETPROTECTIONLEVEL = 77; - -///Add detached code signatures (used by dyld for shared libs) -pub const F_FINDSIGS = 78; - -///Add signature from same file, only if it is signed by Apple (used by dyld for simulator) -pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83; - -///fsync + issue barrier to drive -pub const F_BARRIERFSYNC = 85; - -///Add signature from same file, return end offset in structure on success -pub const F_ADDFILESIGS_RETURN = 97; - -///Check if Library Validation allows this Mach-O file to be mapped into the calling process -pub const F_CHECK_LV = 98; - -///Deallocate a range of the file -pub const F_PUNCHHOLE = 99; - -///Trim an active file -pub const F_TRIM_ACTIVE_FILE = 100; - -pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000; - -///mark the dup with FD_CLOEXEC -pub const F_DUPFD_CLOEXEC = 67; - -///close-on-exec flag -pub const FD_CLOEXEC = 1; - -/// shared or read lock -pub const F_RDLCK = 1; - -/// unlock -pub const F_UNLCK = 2; - -/// exclusive or write lock -pub const F_WRLCK = 3; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const nfds_t = u32; -pub const pollfd = extern struct { - fd: fd_t, - events: i16, - revents: i16, -}; - -pub const POLLIN = 0x001; -pub const POLLPRI = 0x002; -pub const POLLOUT = 0x004; -pub const POLLRDNORM = 0x040; -pub const POLLWRNORM = POLLOUT; -pub const POLLRDBAND = 0x080; -pub const POLLWRBAND = 0x100; - -pub const POLLEXTEND = 0x0200; -pub const POLLATTRIB = 0x0400; -pub const POLLNLINK = 0x0800; -pub const POLLWRITE = 0x1000; - -pub const POLLERR = 0x008; -pub const POLLHUP = 0x010; -pub const POLLNVAL = 0x020; - -pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; - -pub const CLOCK_REALTIME = 0; -pub const CLOCK_MONOTONIC = 6; -pub const CLOCK_MONOTONIC_RAW = 4; -pub const CLOCK_MONOTONIC_RAW_APPROX = 5; -pub const CLOCK_UPTIME_RAW = 8; -pub const CLOCK_UPTIME_RAW_APPROX = 9; -pub const CLOCK_PROCESS_CPUTIME_ID = 12; -pub const CLOCK_THREAD_CPUTIME_ID = 16; - -/// Max open files per process -/// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html -pub const OPEN_MAX = 10240; -pub const RUSAGE_SELF = 0; -pub const RUSAGE_CHILDREN = -1; - -pub const rusage = extern struct { - utime: timeval, - stime: timeval, - maxrss: isize, - ixrss: isize, - idrss: isize, - isrss: isize, - minflt: isize, - majflt: isize, - nswap: isize, - inblock: isize, - oublock: isize, - msgsnd: isize, - msgrcv: isize, - nsignals: isize, - nvcsw: isize, - nivcsw: isize, -}; - -pub const rlimit_resource = enum(c_int) { - CPU = 0, - FSIZE = 1, - DATA = 2, - STACK = 3, - CORE = 4, - RSS = 5, - MEMLOCK = 6, - NPROC = 7, - NOFILE = 8, - _, - - pub const AS: rlimit_resource = .RSS; -}; - -pub const rlim_t = u64; - -/// No limit -pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -// Term -pub const VEOF = 0; -pub const VEOL = 1; -pub const VEOL2 = 2; -pub const VERASE = 3; -pub const VWERASE = 4; -pub const VKILL = 5; -pub const VREPRINT = 6; -pub const VINTR = 8; -pub const VQUIT = 9; -pub const VSUSP = 10; -pub const VDSUSP = 11; -pub const VSTART = 12; -pub const VSTOP = 13; -pub const VLNEXT = 14; -pub const VDISCARD = 15; -pub const VMIN = 16; -pub const VTIME = 17; -pub const VSTATUS = 18; -pub const NCCS = 20; // 2 spares (7, 19) - -pub const IGNBRK = 0x00000001; // ignore BREAK condition -pub const BRKINT = 0x00000002; // map BREAK to SIGINTR -pub const IGNPAR = 0x00000004; // ignore (discard) parity errors -pub const PARMRK = 0x00000008; // mark parity and framing errors -pub const INPCK = 0x00000010; // enable checking of parity errors -pub const ISTRIP = 0x00000020; // strip 8th bit off chars -pub const INLCR = 0x00000040; // map NL into CR -pub const IGNCR = 0x00000080; // ignore CR -pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD) -pub const IXON = 0x00000200; // enable output flow control -pub const IXOFF = 0x00000400; // enable input flow control -pub const IXANY = 0x00000800; // any char will restart after stop -pub const IMAXBEL = 0x00002000; // ring bell on input queue full -pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE - -pub const OPOST = 0x00000001; //enable following output processing -pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD) -pub const OXTABS = 0x00000004; // expand tabs to spaces -pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output) - -pub const OCRNL = 0x00000010; // map CR to NL on output -pub const ONOCR = 0x00000020; // no CR output at column 0 -pub const ONLRET = 0x00000040; // NL performs CR function -pub const OFILL = 0x00000080; // use fill characters for delay -pub const NLDLY = 0x00000300; // \n delay -pub const TABDLY = 0x00000c04; // horizontal tab delay -pub const CRDLY = 0x00003000; // \r delay -pub const FFDLY = 0x00004000; // form feed delay -pub const BSDLY = 0x00008000; // \b delay -pub const VTDLY = 0x00010000; // vertical tab delay -pub const OFDEL = 0x00020000; // fill is DEL, else NUL - -pub const NL0 = 0x00000000; -pub const NL1 = 0x00000100; -pub const NL2 = 0x00000200; -pub const NL3 = 0x00000300; -pub const TAB0 = 0x00000000; -pub const TAB1 = 0x00000400; -pub const TAB2 = 0x00000800; -pub const TAB3 = 0x00000004; -pub const CR0 = 0x00000000; -pub const CR1 = 0x00001000; -pub const CR2 = 0x00002000; -pub const CR3 = 0x00003000; -pub const FF0 = 0x00000000; -pub const FF1 = 0x00004000; -pub const BS0 = 0x00000000; -pub const BS1 = 0x00008000; -pub const VT0 = 0x00000000; -pub const VT1 = 0x00010000; - -pub const CIGNORE = 0x00000001; // ignore control flags -pub const CSIZE = 0x00000300; // character size mask -pub const CS5 = 0x00000000; // 5 bits (pseudo) -pub const CS6 = 0x00000100; // 6 bits -pub const CS7 = 0x00000200; // 7 bits -pub const CS8 = 0x00000300; // 8 bits -pub const CSTOPB = 0x0000040; // send 2 stop bits -pub const CREAD = 0x00000800; // enable receiver -pub const PARENB = 0x00001000; // parity enable -pub const PARODD = 0x00002000; // odd parity, else even -pub const HUPCL = 0x00004000; // hang up on last close -pub const CLOCAL = 0x00008000; // ignore modem status lines -pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output -pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW); -pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input -pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input -pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output -pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output -pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW - -pub const ECHOKE = 0x00000001; // visual erase for line kill -pub const ECHOE = 0x00000002; // visually erase chars -pub const ECHOK = 0x00000004; // echo NL after line kill -pub const ECHO = 0x00000008; // enable echoing -pub const ECHONL = 0x00000010; // echo NL even if ECHO is off -pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy -pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char) -pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP -pub const ICANON = 0x00000100; // canonicalize input lines -pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm -pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT -pub const EXTPROC = 0x00000800; // external processing -pub const TOSTOP = 0x00400000; // stop background jobs from output -pub const FLUSHO = 0x00800000; // output being flushed (state) -pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS -pub const PENDIN = 0x20000000; // XXX retype pending input (state) -pub const NOFLSH = 0x80000000; // don't flush after interrupt - -pub const TCSANOW = 0; // make change immediate -pub const TCSADRAIN = 1; // drain output, then change -pub const TCSAFLUSH = 2; // drain output, flush input -pub const TCSASOFT = 0x10; // flag - don't alter h.w. state -pub const TCSA = enum(c_uint) { - NOW, - DRAIN, - FLUSH, - _, -}; - -pub const B0 = 0; -pub const B50 = 50; -pub const B75 = 75; -pub const B110 = 110; -pub const B134 = 134; -pub const B150 = 150; -pub const B200 = 200; -pub const B300 = 300; -pub const B600 = 600; -pub const B1200 = 1200; -pub const B1800 = 1800; -pub const B2400 = 2400; -pub const B4800 = 4800; -pub const B9600 = 9600; -pub const B19200 = 19200; -pub const B38400 = 38400; -pub const B7200 = 7200; -pub const B14400 = 14400; -pub const B28800 = 28800; -pub const B57600 = 57600; -pub const B76800 = 76800; -pub const B115200 = 115200; -pub const B230400 = 230400; -pub const EXTA = 19200; -pub const EXTB = 38400; - -pub const TCIFLUSH = 1; -pub const TCOFLUSH = 2; -pub const TCIOFLUSH = 3; -pub const TCOOFF = 1; -pub const TCOON = 2; -pub const TCIOFF = 3; -pub const TCION = 4; - -pub const cc_t = u8; -pub const speed_t = u64; -pub const tcflag_t = u64; - -pub const termios = extern struct { - iflag: tcflag_t, // input flags - oflag: tcflag_t, // output flags - cflag: tcflag_t, // control flags - lflag: tcflag_t, // local flags - cc: [NCCS]cc_t, // control chars - ispeed: speed_t align(8), // input speed - ospeed: speed_t, // output speed -}; - -pub const winsize = extern struct { - ws_row: u16, - ws_col: u16, - ws_xpixel: u16, - ws_ypixel: u16, -}; - -pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); -pub const IOCPARM_MASK = 0x1fff; - -fn ior(inout: u32, group: usize, num: usize, len: usize) usize { - return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)); -} - -// CPU families mapping -pub const CPUFAMILY = enum(u32) { - UNKNOWN = 0, - POWERPC_G3 = 0xcee41549, - POWERPC_G4 = 0x77c184ae, - POWERPC_G5 = 0xed76d8aa, - INTEL_6_13 = 0xaa33392b, - INTEL_PENRYN = 0x78ea4fbc, - INTEL_NEHALEM = 0x6b5a4cd2, - INTEL_WESTMERE = 0x573b5eec, - INTEL_SANDYBRIDGE = 0x5490b78c, - INTEL_IVYBRIDGE = 0x1f65e835, - INTEL_HASWELL = 0x10b282dc, - INTEL_BROADWELL = 0x582ed09c, - INTEL_SKYLAKE = 0x37fc219f, - INTEL_KABYLAKE = 0x0f817246, - ARM_9 = 0xe73283ae, - ARM_11 = 0x8ff620d8, - ARM_XSCALE = 0x53b005f5, - ARM_12 = 0xbd1b0ae9, - ARM_13 = 0x0cc90e64, - ARM_14 = 0x96077ef1, - ARM_15 = 0xa8511bca, - ARM_SWIFT = 0x1e2d6381, - ARM_CYCLONE = 0x37a09642, - ARM_TYPHOON = 0x2c91a47e, - ARM_TWISTER = 0x92fb37c8, - ARM_HURRICANE = 0x67ceee93, - ARM_MONSOON_MISTRAL = 0xe81e7ef6, - ARM_VORTEX_TEMPEST = 0x07d34b9f, - ARM_LIGHTNING_THUNDER = 0x462504d2, - ARM_FIRESTORM_ICESTORM = 0x1b588bb3, - _, -}; diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig deleted file mode 100644 index c13a3aea91..0000000000 --- a/lib/std/os/bits/dragonfly.zig +++ /dev/null @@ -1,1033 +0,0 @@ -const std = @import("../../std.zig"); -const maxInt = std.math.maxInt; - -pub usingnamespace @import("posix.zig"); - -pub fn S_ISCHR(m: u32) bool { - return m & S_IFMT == S_IFCHR; -} - -// See: -// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h -// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h -// TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well -pub const fd_t = c_int; -pub const pid_t = c_int; -pub const off_t = c_long; -pub const mode_t = c_uint; -pub const uid_t = u32; -pub const gid_t = u32; -pub const time_t = isize; -pub const suseconds_t = c_long; - -pub const E = enum(u16) { - /// No error occurred. - SUCCESS = 0, - - PERM = 1, - NOENT = 2, - SRCH = 3, - INTR = 4, - IO = 5, - NXIO = 6, - @"2BIG" = 7, - NOEXEC = 8, - BADF = 9, - CHILD = 10, - DEADLK = 11, - NOMEM = 12, - ACCES = 13, - FAULT = 14, - NOTBLK = 15, - BUSY = 16, - EXIST = 17, - XDEV = 18, - NODEV = 19, - NOTDIR = 20, - ISDIR = 21, - INVAL = 22, - NFILE = 23, - MFILE = 24, - NOTTY = 25, - TXTBSY = 26, - FBIG = 27, - NOSPC = 28, - SPIPE = 29, - ROFS = 30, - MLINK = 31, - PIPE = 32, - DOM = 33, - RANGE = 34, - /// This code is also used for `WOULDBLOCK`. - AGAIN = 35, - INPROGRESS = 36, - ALREADY = 37, - NOTSOCK = 38, - DESTADDRREQ = 39, - MSGSIZE = 40, - PROTOTYPE = 41, - NOPROTOOPT = 42, - PROTONOSUPPORT = 43, - SOCKTNOSUPPORT = 44, - /// This code is also used for `NOTSUP`. - OPNOTSUPP = 45, - PFNOSUPPORT = 46, - AFNOSUPPORT = 47, - ADDRINUSE = 48, - ADDRNOTAVAIL = 49, - NETDOWN = 50, - NETUNREACH = 51, - NETRESET = 52, - CONNABORTED = 53, - CONNRESET = 54, - NOBUFS = 55, - ISCONN = 56, - NOTCONN = 57, - SHUTDOWN = 58, - TOOMANYREFS = 59, - TIMEDOUT = 60, - CONNREFUSED = 61, - LOOP = 62, - NAMETOOLONG = 63, - HOSTDOWN = 64, - HOSTUNREACH = 65, - NOTEMPTY = 66, - PROCLIM = 67, - USERS = 68, - DQUOT = 69, - STALE = 70, - REMOTE = 71, - BADRPC = 72, - RPCMISMATCH = 73, - PROGUNAVAIL = 74, - PROGMISMATCH = 75, - PROCUNAVAIL = 76, - NOLCK = 77, - NOSYS = 78, - FTYPE = 79, - AUTH = 80, - NEEDAUTH = 81, - IDRM = 82, - NOMSG = 83, - OVERFLOW = 84, - CANCELED = 85, - ILSEQ = 86, - NOATTR = 87, - DOOFUS = 88, - BADMSG = 89, - MULTIHOP = 90, - NOLINK = 91, - PROTO = 92, - NOMEDIUM = 93, - ASYNC = 99, - _, -}; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -pub const PROT_NONE = 0; -pub const PROT_READ = 1; -pub const PROT_WRITE = 2; -pub const PROT_EXEC = 4; - -pub const MAP_FILE = 0; -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); -pub const MAP_ANONYMOUS = MAP_ANON; -pub const MAP_COPY = MAP_PRIVATE; -pub const MAP_SHARED = 1; -pub const MAP_PRIVATE = 2; -pub const MAP_FIXED = 16; -pub const MAP_RENAME = 32; -pub const MAP_NORESERVE = 64; -pub const MAP_INHERIT = 128; -pub const MAP_NOEXTEND = 256; -pub const MAP_HASSEMAPHORE = 512; -pub const MAP_STACK = 1024; -pub const MAP_NOSYNC = 2048; -pub const MAP_ANON = 4096; -pub const MAP_VPAGETABLE = 8192; -pub const MAP_TRYFIXED = 65536; -pub const MAP_NOCORE = 131072; -pub const MAP_SIZEALIGN = 262144; - -pub const WNOHANG = 0x0001; -pub const WUNTRACED = 0x0002; -pub const WCONTINUED = 0x0004; -pub const WSTOPPED = WUNTRACED; -pub const WNOWAIT = 0x0008; -pub const WEXITED = 0x0010; -pub const WTRAPPED = 0x0020; - -pub const SA_ONSTACK = 0x0001; -pub const SA_RESTART = 0x0002; -pub const SA_RESETHAND = 0x0004; -pub const SA_NODEFER = 0x0010; -pub const SA_NOCLDWAIT = 0x0020; -pub const SA_SIGINFO = 0x0040; - -pub const PATH_MAX = 1024; -pub const IOV_MAX = KERN_IOV_MAX; - -pub const ino_t = c_ulong; - -pub const libc_stat = extern struct { - ino: ino_t, - nlink: c_uint, - dev: c_uint, - mode: c_ushort, - padding1: u16, - uid: uid_t, - gid: gid_t, - rdev: c_uint, - atim: timespec, - mtim: timespec, - ctim: timespec, - size: c_ulong, - blocks: i64, - blksize: u32, - flags: u32, - gen: u32, - lspare: i32, - qspare1: i64, - qspare2: i64, - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: c_long, - tv_nsec: c_long, -}; - -pub const timeval = extern struct { - /// seconds - tv_sec: time_t, - /// microseconds - tv_usec: suseconds_t, -}; - -pub const CTL_UNSPEC = 0; -pub const CTL_KERN = 1; -pub const CTL_VM = 2; -pub const CTL_VFS = 3; -pub const CTL_NET = 4; -pub const CTL_DEBUG = 5; -pub const CTL_HW = 6; -pub const CTL_MACHDEP = 7; -pub const CTL_USER = 8; -pub const CTL_LWKT = 10; -pub const CTL_MAXID = 11; -pub const CTL_MAXNAME = 12; - -pub const KERN_PROC_ALL = 0; -pub const KERN_OSTYPE = 1; -pub const KERN_PROC_PID = 1; -pub const KERN_OSRELEASE = 2; -pub const KERN_PROC_PGRP = 2; -pub const KERN_OSREV = 3; -pub const KERN_PROC_SESSION = 3; -pub const KERN_VERSION = 4; -pub const KERN_PROC_TTY = 4; -pub const KERN_MAXVNODES = 5; -pub const KERN_PROC_UID = 5; -pub const KERN_MAXPROC = 6; -pub const KERN_PROC_RUID = 6; -pub const KERN_MAXFILES = 7; -pub const KERN_PROC_ARGS = 7; -pub const KERN_ARGMAX = 8; -pub const KERN_PROC_CWD = 8; -pub const KERN_PROC_PATHNAME = 9; -pub const KERN_SECURELVL = 9; -pub const KERN_PROC_SIGTRAMP = 10; -pub const KERN_HOSTNAME = 10; -pub const KERN_HOSTID = 11; -pub const KERN_CLOCKRATE = 12; -pub const KERN_VNODE = 13; -pub const KERN_PROC = 14; -pub const KERN_FILE = 15; -pub const KERN_PROC_FLAGMASK = 16; -pub const KERN_PROF = 16; -pub const KERN_PROC_FLAG_LWP = 16; -pub const KERN_POSIX1 = 17; -pub const KERN_NGROUPS = 18; -pub const KERN_JOB_CONTROL = 19; -pub const KERN_SAVED_IDS = 20; -pub const KERN_BOOTTIME = 21; -pub const KERN_NISDOMAINNAME = 22; -pub const KERN_UPDATEINTERVAL = 23; -pub const KERN_OSRELDATE = 24; -pub const KERN_NTP_PLL = 25; -pub const KERN_BOOTFILE = 26; -pub const KERN_MAXFILESPERPROC = 27; -pub const KERN_MAXPROCPERUID = 28; -pub const KERN_DUMPDEV = 29; -pub const KERN_IPC = 30; -pub const KERN_DUMMY = 31; -pub const KERN_PS_STRINGS = 32; -pub const KERN_USRSTACK = 33; -pub const KERN_LOGSIGEXIT = 34; -pub const KERN_IOV_MAX = 35; -pub const KERN_MAXPOSIXLOCKSPERUID = 36; -pub const KERN_MAXID = 37; - -pub const HOST_NAME_MAX = 255; - -// access function -pub const F_OK = 0; // test for existence of file -pub const X_OK = 1; // test for execute or search permission -pub const W_OK = 2; // test for write permission -pub const R_OK = 4; // test for read permission - -pub const O_RDONLY = 0; -pub const O_NDELAY = O_NONBLOCK; -pub const O_WRONLY = 1; -pub const O_RDWR = 2; -pub const O_ACCMODE = 3; -pub const O_NONBLOCK = 4; -pub const O_APPEND = 8; -pub const O_SHLOCK = 16; -pub const O_EXLOCK = 32; -pub const O_ASYNC = 64; -pub const O_FSYNC = 128; -pub const O_SYNC = 128; -pub const O_NOFOLLOW = 256; -pub const O_CREAT = 512; -pub const O_TRUNC = 1024; -pub const O_EXCL = 2048; -pub const O_NOCTTY = 32768; -pub const O_DIRECT = 65536; -pub const O_CLOEXEC = 131072; -pub const O_FBLOCKING = 262144; -pub const O_FNONBLOCKING = 524288; -pub const O_FAPPEND = 1048576; -pub const O_FOFFSET = 2097152; -pub const O_FSYNCWRITE = 4194304; -pub const O_FASYNCWRITE = 8388608; -pub const O_DIRECTORY = 134217728; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; -pub const SEEK_DATA = 3; -pub const SEEK_HOLE = 4; - -pub const F_ULOCK = 0; -pub const F_LOCK = 1; -pub const F_TLOCK = 2; -pub const F_TEST = 3; - -pub const FD_CLOEXEC = 1; - -pub const AT_FDCWD = -328243; -pub const AT_SYMLINK_NOFOLLOW = 1; -pub const AT_REMOVEDIR = 2; -pub const AT_EACCESS = 4; -pub const AT_SYMLINK_FOLLOW = 8; - -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, (s & 0xff00) >> 8); -} -pub fn WTERMSIG(s: u32) u32 { - return s & 0x7f; -} -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} -pub fn WIFSTOPPED(s: u32) bool { - return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; -} -pub fn WIFSIGNALED(s: u32) bool { - return (s & 0xffff) -% 1 < 0xff; -} - -pub const dirent = extern struct { - d_fileno: c_ulong, - d_namlen: u16, - d_type: u8, - d_unused1: u8, - d_unused2: u32, - d_name: [256]u8, - - pub fn reclen(self: dirent) u16 { - return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7); - } -}; - -pub const DT_UNKNOWN = 0; -pub const DT_FIFO = 1; -pub const DT_CHR = 2; -pub const DT_DIR = 4; -pub const DT_BLK = 6; -pub const DT_REG = 8; -pub const DT_LNK = 10; -pub const DT_SOCK = 12; -pub const DT_WHT = 14; -pub const DT_DBF = 15; - -pub const CLOCK_REALTIME = 0; -pub const CLOCK_VIRTUAL = 1; -pub const CLOCK_PROF = 2; -pub const CLOCK_MONOTONIC = 4; -pub const CLOCK_UPTIME = 5; -pub const CLOCK_UPTIME_PRECISE = 7; -pub const CLOCK_UPTIME_FAST = 8; -pub const CLOCK_REALTIME_PRECISE = 9; -pub const CLOCK_REALTIME_FAST = 10; -pub const CLOCK_MONOTONIC_PRECISE = 11; -pub const CLOCK_MONOTONIC_FAST = 12; -pub const CLOCK_SECOND = 13; -pub const CLOCK_THREAD_CPUTIME_ID = 14; -pub const CLOCK_PROCESS_CPUTIME_ID = 15; - -pub const sockaddr = extern struct { - len: u8, - family: u8, - data: [14]u8, -}; - -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; - -pub const Kevent = extern struct { - ident: usize, - filter: c_short, - flags: c_ushort, - fflags: c_uint, - data: isize, - udata: usize, -}; - -pub const EVFILT_FS = -10; -pub const EVFILT_USER = -9; -pub const EVFILT_EXCEPT = -8; -pub const EVFILT_TIMER = -7; -pub const EVFILT_SIGNAL = -6; -pub const EVFILT_PROC = -5; -pub const EVFILT_VNODE = -4; -pub const EVFILT_AIO = -3; -pub const EVFILT_WRITE = -2; -pub const EVFILT_READ = -1; -pub const EVFILT_SYSCOUNT = 10; -pub const EVFILT_MARKER = 15; - -pub const EV_ADD = 1; -pub const EV_DELETE = 2; -pub const EV_ENABLE = 4; -pub const EV_DISABLE = 8; -pub const EV_ONESHOT = 16; -pub const EV_CLEAR = 32; -pub const EV_RECEIPT = 64; -pub const EV_DISPATCH = 128; -pub const EV_NODATA = 4096; -pub const EV_FLAG1 = 8192; -pub const EV_ERROR = 16384; -pub const EV_EOF = 32768; -pub const EV_SYSFLAGS = 61440; - -pub const NOTE_FFNOP = 0; -pub const NOTE_TRACK = 1; -pub const NOTE_DELETE = 1; -pub const NOTE_LOWAT = 1; -pub const NOTE_TRACKERR = 2; -pub const NOTE_OOB = 2; -pub const NOTE_WRITE = 2; -pub const NOTE_EXTEND = 4; -pub const NOTE_CHILD = 4; -pub const NOTE_ATTRIB = 8; -pub const NOTE_LINK = 16; -pub const NOTE_RENAME = 32; -pub const NOTE_REVOKE = 64; -pub const NOTE_PDATAMASK = 1048575; -pub const NOTE_FFLAGSMASK = 16777215; -pub const NOTE_TRIGGER = 16777216; -pub const NOTE_EXEC = 536870912; -pub const NOTE_FFAND = 1073741824; -pub const NOTE_FORK = 1073741824; -pub const NOTE_EXIT = 2147483648; -pub const NOTE_FFOR = 2147483648; -pub const NOTE_FFCTRLMASK = 3221225472; -pub const NOTE_FFCOPY = 3221225472; -pub const NOTE_PCTRLMASK = 4026531840; - -pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, -}; - -pub const S_IREAD = S_IRUSR; -pub const S_IEXEC = S_IXUSR; -pub const S_IWRITE = S_IWUSR; -pub const S_IXOTH = 1; -pub const S_IWOTH = 2; -pub const S_IROTH = 4; -pub const S_IRWXO = 7; -pub const S_IXGRP = 8; -pub const S_IWGRP = 16; -pub const S_IRGRP = 32; -pub const S_IRWXG = 56; -pub const S_IXUSR = 64; -pub const S_IWUSR = 128; -pub const S_IRUSR = 256; -pub const S_IRWXU = 448; -pub const S_ISTXT = 512; -pub const S_BLKSIZE = 512; -pub const S_ISVTX = 512; -pub const S_ISGID = 1024; -pub const S_ISUID = 2048; -pub const S_IFIFO = 4096; -pub const S_IFCHR = 8192; -pub const S_IFDIR = 16384; -pub const S_IFBLK = 24576; -pub const S_IFREG = 32768; -pub const S_IFDB = 36864; -pub const S_IFLNK = 40960; -pub const S_IFSOCK = 49152; -pub const S_IFWHT = 57344; -pub const S_IFMT = 61440; - -pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); -pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); -pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); -pub const BADSIG = SIG_ERR; - -pub const SIG_BLOCK = 1; -pub const SIG_UNBLOCK = 2; -pub const SIG_SETMASK = 3; - -pub const SIGIOT = SIGABRT; -pub const SIGHUP = 1; -pub const SIGINT = 2; -pub const SIGQUIT = 3; -pub const SIGILL = 4; -pub const SIGTRAP = 5; -pub const SIGABRT = 6; -pub const SIGEMT = 7; -pub const SIGFPE = 8; -pub const SIGKILL = 9; -pub const SIGBUS = 10; -pub const SIGSEGV = 11; -pub const SIGSYS = 12; -pub const SIGPIPE = 13; -pub const SIGALRM = 14; -pub const SIGTERM = 15; -pub const SIGURG = 16; -pub const SIGSTOP = 17; -pub const SIGTSTP = 18; -pub const SIGCONT = 19; -pub const SIGCHLD = 20; -pub const SIGTTIN = 21; -pub const SIGTTOU = 22; -pub const SIGIO = 23; -pub const SIGXCPU = 24; -pub const SIGXFSZ = 25; -pub const SIGVTALRM = 26; -pub const SIGPROF = 27; -pub const SIGWINCH = 28; -pub const SIGINFO = 29; -pub const SIGUSR1 = 30; -pub const SIGUSR2 = 31; -pub const SIGTHR = 32; -pub const SIGCKPT = 33; -pub const SIGCKPTEXIT = 34; - -pub const siginfo_t = extern struct { - signo: c_int, - errno: c_int, - code: c_int, - pid: c_int, - uid: uid_t, - status: c_int, - addr: ?*c_void, - value: sigval, - band: c_long, - __spare__: [7]c_int, -}; - -pub const sigval = extern union { - sival_int: c_int, - sival_ptr: ?*c_void, -}; - -pub const _SIG_WORDS = 4; - -pub const sigset_t = extern struct { - __bits: [_SIG_WORDS]c_uint, -}; - -pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS }; - -pub const sig_atomic_t = c_int; - -pub const Sigaction = extern struct { - pub const handler_fn = fn (c_int) callconv(.C) void; - pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; - - /// signal handler - handler: extern union { - handler: ?handler_fn, - sigaction: ?sigaction_fn, - }, - flags: c_uint, - mask: sigset_t, -}; - -pub const sig_t = [*c]fn (c_int) callconv(.C) void; - -pub const SOCK_STREAM = 1; -pub const SOCK_DGRAM = 2; -pub const SOCK_RAW = 3; -pub const SOCK_RDM = 4; -pub const SOCK_SEQPACKET = 5; -pub const SOCK_MAXADDRLEN = 255; -pub const SOCK_CLOEXEC = 0x10000000; -pub const SOCK_NONBLOCK = 0x20000000; - -pub const SO_DEBUG = 0x0001; -pub const SO_ACCEPTCONN = 0x0002; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_USELOOPBACK = 0x0040; -pub const SO_LINGER = 0x0080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_TIMESTAMP = 0x0400; -pub const SO_NOSIGPIPE = 0x0800; -pub const SO_ACCEPTFILTER = 0x1000; -pub const SO_RERROR = 0x2000; -pub const SO_PASSCRED = 0x4000; - -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_SNDSPACE = 0x100a; -pub const SO_CPUHINT = 0x1030; - -pub const SOL_SOCKET = 0xffff; - -pub const PF_INET6 = AF_INET6; -pub const PF_IMPLINK = AF_IMPLINK; -pub const PF_ROUTE = AF_ROUTE; -pub const PF_ISO = AF_ISO; -pub const PF_PIP = pseudo_AF_PIP; -pub const PF_CHAOS = AF_CHAOS; -pub const PF_DATAKIT = AF_DATAKIT; -pub const PF_INET = AF_INET; -pub const PF_APPLETALK = AF_APPLETALK; -pub const PF_SIP = AF_SIP; -pub const PF_OSI = AF_ISO; -pub const PF_CNT = AF_CNT; -pub const PF_LINK = AF_LINK; -pub const PF_HYLINK = AF_HYLINK; -pub const PF_MAX = AF_MAX; -pub const PF_KEY = pseudo_AF_KEY; -pub const PF_PUP = AF_PUP; -pub const PF_COIP = AF_COIP; -pub const PF_SNA = AF_SNA; -pub const PF_LOCAL = AF_LOCAL; -pub const PF_NETBIOS = AF_NETBIOS; -pub const PF_NATM = AF_NATM; -pub const PF_BLUETOOTH = AF_BLUETOOTH; -pub const PF_UNSPEC = AF_UNSPEC; -pub const PF_NETGRAPH = AF_NETGRAPH; -pub const PF_ECMA = AF_ECMA; -pub const PF_IPX = AF_IPX; -pub const PF_DLI = AF_DLI; -pub const PF_ATM = AF_ATM; -pub const PF_CCITT = AF_CCITT; -pub const PF_ISDN = AF_ISDN; -pub const PF_RTIP = pseudo_AF_RTIP; -pub const PF_LAT = AF_LAT; -pub const PF_UNIX = PF_LOCAL; -pub const PF_XTP = pseudo_AF_XTP; -pub const PF_DECnet = AF_DECnet; - -pub const AF_UNSPEC = 0; -pub const AF_OSI = AF_ISO; -pub const AF_UNIX = AF_LOCAL; -pub const AF_LOCAL = 1; -pub const AF_INET = 2; -pub const AF_IMPLINK = 3; -pub const AF_PUP = 4; -pub const AF_CHAOS = 5; -pub const AF_NETBIOS = 6; -pub const AF_ISO = 7; -pub const AF_ECMA = 8; -pub const AF_DATAKIT = 9; -pub const AF_CCITT = 10; -pub const AF_SNA = 11; -pub const AF_DLI = 13; -pub const AF_LAT = 14; -pub const AF_HYLINK = 15; -pub const AF_APPLETALK = 16; -pub const AF_ROUTE = 17; -pub const AF_LINK = 18; -pub const AF_COIP = 20; -pub const AF_CNT = 21; -pub const AF_IPX = 23; -pub const AF_SIP = 24; -pub const AF_ISDN = 26; -pub const AF_INET6 = 28; -pub const AF_NATM = 29; -pub const AF_ATM = 30; -pub const AF_NETGRAPH = 32; -pub const AF_BLUETOOTH = 33; -pub const AF_MPLS = 34; -pub const AF_MAX = 36; - -pub const in_port_t = u16; -pub const sa_family_t = u8; -pub const socklen_t = u32; - -pub const sockaddr_in = extern struct { - len: u8 = @sizeOf(sockaddr_in), - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -pub const sockaddr_in6 = extern struct { - len: u8 = @sizeOf(sockaddr_in6), - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -pub const EAI = enum(c_int) { - ADDRFAMILY = 1, - AGAIN = 2, - BADFLAGS = 3, - FAIL = 4, - FAMILY = 5, - MEMORY = 6, - NODATA = 7, - NONAME = 8, - SERVICE = 9, - SOCKTYPE = 10, - SYSTEM = 11, - BADHINTS = 12, - PROTOCOL = 13, - OVERFLOW = 14, - _, -}; - -pub const AI_PASSIVE = 0x00000001; -pub const AI_CANONNAME = 0x00000002; -pub const AI_NUMERICHOST = 0x00000004; -pub const AI_NUMERICSERV = 0x00000008; -pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG; -pub const AI_ALL = 0x00000100; -pub const AI_V4MAPPED_CFG = 0x00000200; -pub const AI_ADDRCONFIG = 0x00000400; -pub const AI_V4MAPPED = 0x00000800; -pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG; - -pub const RTLD_LAZY = 1; -pub const RTLD_NOW = 2; -pub const RTLD_MODEMASK = 0x3; -pub const RTLD_GLOBAL = 0x100; -pub const RTLD_LOCAL = 0; -pub const RTLD_TRACE = 0x200; -pub const RTLD_NODELETE = 0x01000; -pub const RTLD_NOLOAD = 0x02000; - -pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); -pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); -pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); -pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4))); - -pub const dl_phdr_info = extern struct { - dlpi_addr: usize, - dlpi_name: ?[*:0]const u8, - dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: u16, -}; -pub const cmsghdr = extern struct { - cmsg_len: socklen_t, - cmsg_level: c_int, - cmsg_type: c_int, -}; -pub const msghdr = extern struct { - msg_name: ?*c_void, - msg_namelen: socklen_t, - msg_iov: [*c]iovec, - msg_iovlen: c_int, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: c_int, -}; -pub const cmsgcred = extern struct { - cmcred_pid: pid_t, - cmcred_uid: uid_t, - cmcred_euid: uid_t, - cmcred_gid: gid_t, - cmcred_ngroups: c_short, - cmcred_groups: [16]gid_t, -}; -pub const sf_hdtr = extern struct { - headers: [*c]iovec, - hdr_cnt: c_int, - trailers: [*c]iovec, - trl_cnt: c_int, -}; - -pub const MS_SYNC = 0; -pub const MS_ASYNC = 1; -pub const MS_INVALIDATE = 2; - -pub const POSIX_MADV_SEQUENTIAL = 2; -pub const POSIX_MADV_RANDOM = 1; -pub const POSIX_MADV_DONTNEED = 4; -pub const POSIX_MADV_NORMAL = 0; -pub const POSIX_MADV_WILLNEED = 3; - -pub const MADV_SEQUENTIAL = 2; -pub const MADV_CONTROL_END = MADV_SETMAP; -pub const MADV_DONTNEED = 4; -pub const MADV_RANDOM = 1; -pub const MADV_WILLNEED = 3; -pub const MADV_NORMAL = 0; -pub const MADV_CONTROL_START = MADV_INVAL; -pub const MADV_FREE = 5; -pub const MADV_NOSYNC = 6; -pub const MADV_AUTOSYNC = 7; -pub const MADV_NOCORE = 8; -pub const MADV_CORE = 9; -pub const MADV_INVAL = 10; -pub const MADV_SETMAP = 11; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_RDLCK = 1; -pub const F_SETFD = 2; -pub const F_UNLCK = 2; -pub const F_WRLCK = 3; -pub const F_GETFL = 3; -pub const F_SETFL = 4; -pub const F_GETOWN = 5; -pub const F_SETOWN = 6; -pub const F_GETLK = 7; -pub const F_SETLK = 8; -pub const F_SETLKW = 9; -pub const F_DUP2FD = 10; -pub const F_DUPFD_CLOEXEC = 17; -pub const F_DUP2FD_CLOEXEC = 18; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const Flock = extern struct { - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - l_type: c_short, - l_whence: c_short, -}; - -pub const addrinfo = extern struct { - flags: i32, - family: i32, - socktype: i32, - protocol: i32, - addrlen: socklen_t, - canonname: ?[*:0]u8, - addr: ?*sockaddr, - next: ?*addrinfo, -}; - -pub const IPPROTO_IP = 0; -pub const IPPROTO_ICMP = 1; -pub const IPPROTO_TCP = 6; -pub const IPPROTO_UDP = 17; -pub const IPPROTO_IPV6 = 41; -pub const IPPROTO_RAW = 255; -pub const IPPROTO_HOPOPTS = 0; -pub const IPPROTO_IGMP = 2; -pub const IPPROTO_GGP = 3; -pub const IPPROTO_IPV4 = 4; -pub const IPPROTO_IPIP = IPPROTO_IPV4; -pub const IPPROTO_ST = 7; -pub const IPPROTO_EGP = 8; -pub const IPPROTO_PIGP = 9; -pub const IPPROTO_RCCMON = 10; -pub const IPPROTO_NVPII = 11; -pub const IPPROTO_PUP = 12; -pub const IPPROTO_ARGUS = 13; -pub const IPPROTO_EMCON = 14; -pub const IPPROTO_XNET = 15; -pub const IPPROTO_CHAOS = 16; -pub const IPPROTO_MUX = 18; -pub const IPPROTO_MEAS = 19; -pub const IPPROTO_HMP = 20; -pub const IPPROTO_PRM = 21; -pub const IPPROTO_IDP = 22; -pub const IPPROTO_TRUNK1 = 23; -pub const IPPROTO_TRUNK2 = 24; -pub const IPPROTO_LEAF1 = 25; -pub const IPPROTO_LEAF2 = 26; -pub const IPPROTO_RDP = 27; -pub const IPPROTO_IRTP = 28; -pub const IPPROTO_TP = 29; -pub const IPPROTO_BLT = 30; -pub const IPPROTO_NSP = 31; -pub const IPPROTO_INP = 32; -pub const IPPROTO_SEP = 33; -pub const IPPROTO_3PC = 34; -pub const IPPROTO_IDPR = 35; -pub const IPPROTO_XTP = 36; -pub const IPPROTO_DDP = 37; -pub const IPPROTO_CMTP = 38; -pub const IPPROTO_TPXX = 39; -pub const IPPROTO_IL = 40; -pub const IPPROTO_SDRP = 42; -pub const IPPROTO_ROUTING = 43; -pub const IPPROTO_FRAGMENT = 44; -pub const IPPROTO_IDRP = 45; -pub const IPPROTO_RSVP = 46; -pub const IPPROTO_GRE = 47; -pub const IPPROTO_MHRP = 48; -pub const IPPROTO_BHA = 49; -pub const IPPROTO_ESP = 50; -pub const IPPROTO_AH = 51; -pub const IPPROTO_INLSP = 52; -pub const IPPROTO_SWIPE = 53; -pub const IPPROTO_NHRP = 54; -pub const IPPROTO_MOBILE = 55; -pub const IPPROTO_TLSP = 56; -pub const IPPROTO_SKIP = 57; -pub const IPPROTO_ICMPV6 = 58; -pub const IPPROTO_NONE = 59; -pub const IPPROTO_DSTOPTS = 60; -pub const IPPROTO_AHIP = 61; -pub const IPPROTO_CFTP = 62; -pub const IPPROTO_HELLO = 63; -pub const IPPROTO_SATEXPAK = 64; -pub const IPPROTO_KRYPTOLAN = 65; -pub const IPPROTO_RVD = 66; -pub const IPPROTO_IPPC = 67; -pub const IPPROTO_ADFS = 68; -pub const IPPROTO_SATMON = 69; -pub const IPPROTO_VISA = 70; -pub const IPPROTO_IPCV = 71; -pub const IPPROTO_CPNX = 72; -pub const IPPROTO_CPHB = 73; -pub const IPPROTO_WSN = 74; -pub const IPPROTO_PVP = 75; -pub const IPPROTO_BRSATMON = 76; -pub const IPPROTO_ND = 77; -pub const IPPROTO_WBMON = 78; -pub const IPPROTO_WBEXPAK = 79; -pub const IPPROTO_EON = 80; -pub const IPPROTO_VMTP = 81; -pub const IPPROTO_SVMTP = 82; -pub const IPPROTO_VINES = 83; -pub const IPPROTO_TTP = 84; -pub const IPPROTO_IGP = 85; -pub const IPPROTO_DGP = 86; -pub const IPPROTO_TCF = 87; -pub const IPPROTO_IGRP = 88; -pub const IPPROTO_OSPFIGP = 89; -pub const IPPROTO_SRPC = 90; -pub const IPPROTO_LARP = 91; -pub const IPPROTO_MTP = 92; -pub const IPPROTO_AX25 = 93; -pub const IPPROTO_IPEIP = 94; -pub const IPPROTO_MICP = 95; -pub const IPPROTO_SCCSP = 96; -pub const IPPROTO_ETHERIP = 97; -pub const IPPROTO_ENCAP = 98; -pub const IPPROTO_APES = 99; -pub const IPPROTO_GMTP = 100; -pub const IPPROTO_IPCOMP = 108; -pub const IPPROTO_PIM = 103; -pub const IPPROTO_CARP = 112; -pub const IPPROTO_PGM = 113; -pub const IPPROTO_PFSYNC = 240; -pub const IPPROTO_DIVERT = 254; -pub const IPPROTO_MAX = 256; -pub const IPPROTO_DONE = 257; -pub const IPPROTO_UNKNOWN = 258; - -pub const rlimit_resource = enum(c_int) { - CPU = 0, - FSIZE = 1, - DATA = 2, - STACK = 3, - CORE = 4, - RSS = 5, - MEMLOCK = 6, - NPROC = 7, - NOFILE = 8, - SBSIZE = 9, - VMEM = 10, - POSIXLOCKS = 11, - _, - - pub const AS: rlimit_resource = .VMEM; -}; - -pub const rlim_t = i64; - -/// No limit -pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -pub const nfds_t = u32; - -pub const pollfd = extern struct { - fd: fd_t, - events: i16, - revents: i16, -}; - -/// Requestable events. -pub const POLLIN = 0x0001; -pub const POLLPRI = 0x0002; -pub const POLLOUT = 0x0004; -pub const POLLRDNORM = 0x0040; -pub const POLLWRNORM = POLLOUT; -pub const POLLRDBAND = 0x0080; -pub const POLLWRBAND = 0x0100; - -/// These events are set if they occur regardless of whether they were requested. -pub const POLLERR = 0x0008; -pub const POLLHUP = 0x0010; -pub const POLLNVAL = 0x0020; diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig deleted file mode 100644 index 51b7ef9f4d..0000000000 --- a/lib/std/os/bits/freebsd.zig +++ /dev/null @@ -1,1542 +0,0 @@ -const std = @import("../../std.zig"); -const builtin = @import("builtin"); -const maxInt = std.math.maxInt; - -pub usingnamespace @import("posix.zig"); - -pub const blksize_t = i32; -pub const blkcnt_t = i64; -pub const clockid_t = i32; -pub const fsblkcnt_t = u64; -pub const fsfilcnt_t = u64; -pub const nlink_t = u64; -pub const fd_t = i32; -pub const pid_t = i32; -pub const uid_t = u32; -pub const gid_t = u32; -pub const mode_t = u16; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; -pub const time_t = i64; -// The signedness is not constant across different architectures. -pub const clock_t = isize; - -pub const socklen_t = u32; -pub const suseconds_t = c_long; - -/// Renamed from `kevent` to `Kevent` to avoid conflict with function name. -pub const Kevent = extern struct { - ident: usize, - filter: i16, - flags: u16, - fflags: u32, - data: i64, - udata: usize, - // TODO ext -}; - -// Modes and flags for dlopen() -// include/dlfcn.h - -/// Bind function calls lazily. -pub const RTLD_LAZY = 1; - -/// Bind function calls immediately. -pub const RTLD_NOW = 2; - -pub const RTLD_MODEMASK = 0x3; - -/// Make symbols globally available. -pub const RTLD_GLOBAL = 0x100; - -/// Opposite of RTLD_GLOBAL, and the default. -pub const RTLD_LOCAL = 0; - -/// Trace loaded objects and exit. -pub const RTLD_TRACE = 0x200; - -/// Do not remove members. -pub const RTLD_NODELETE = 0x01000; - -/// Do not load if not already loaded. -pub const RTLD_NOLOAD = 0x02000; - -pub const dl_phdr_info = extern struct { - dlpi_addr: usize, - dlpi_name: ?[*:0]const u8, - dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: u16, -}; - -pub const Flock = extern struct { - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - l_type: i16, - l_whence: i16, - l_sysid: i32, - __unused: [4]u8, -}; - -pub const msghdr = extern struct { - /// optional address - msg_name: ?*sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec, - - /// # elements in msg_iov - msg_iovlen: i32, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - /// optional address - msg_name: ?*const sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec_const, - - /// # elements in msg_iov - msg_iovlen: i32, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: i32, -}; - -pub const libc_stat = extern struct { - dev: dev_t, - ino: ino_t, - nlink: nlink_t, - - mode: mode_t, - __pad0: u16, - uid: uid_t, - gid: gid_t, - __pad1: u32, - rdev: dev_t, - - atim: timespec, - mtim: timespec, - ctim: timespec, - birthtim: timespec, - - size: off_t, - blocks: i64, - blksize: isize, - flags: u32, - gen: u64, - __spare: [10]u64, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - /// seconds - tv_sec: time_t, - /// microseconds - tv_usec: suseconds_t, -}; - -pub const dirent = extern struct { - d_fileno: usize, - d_off: i64, - d_reclen: u16, - d_type: u8, - d_pad0: u8, - d_namlen: u16, - d_pad1: u16, - d_name: [256]u8, - - pub fn reclen(self: dirent) u16 { - return self.d_reclen; - } -}; - -pub const in_port_t = u16; -pub const sa_family_t = u8; - -pub const sockaddr = extern struct { - /// total length - len: u8, - - /// address family - family: sa_family_t, - - /// actually longer; address value - data: [14]u8, -}; - -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; - -pub const sockaddr_in = extern struct { - len: u8 = @sizeOf(sockaddr_in), - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -pub const sockaddr_in6 = extern struct { - len: u8 = @sizeOf(sockaddr_in6), - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -pub const sockaddr_un = extern struct { - len: u8 = @sizeOf(sockaddr_un), - family: sa_family_t = AF_UNIX, - path: [104]u8, -}; - -pub const CTL_KERN = 1; -pub const CTL_DEBUG = 5; - -pub const KERN_PROC = 14; // struct: process entries -pub const KERN_PROC_PATHNAME = 12; // path to executable -pub const KERN_IOV_MAX = 35; - -pub const PATH_MAX = 1024; -pub const IOV_MAX = KERN_IOV_MAX; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -pub const PROT_NONE = 0; -pub const PROT_READ = 1; -pub const PROT_WRITE = 2; -pub const PROT_EXEC = 4; - -pub const CLOCK_REALTIME = 0; -pub const CLOCK_VIRTUAL = 1; -pub const CLOCK_PROF = 2; -pub const CLOCK_MONOTONIC = 4; -pub const CLOCK_UPTIME = 5; -pub const CLOCK_UPTIME_PRECISE = 7; -pub const CLOCK_UPTIME_FAST = 8; -pub const CLOCK_REALTIME_PRECISE = 9; -pub const CLOCK_REALTIME_FAST = 10; -pub const CLOCK_MONOTONIC_PRECISE = 11; -pub const CLOCK_MONOTONIC_FAST = 12; -pub const CLOCK_SECOND = 13; -pub const CLOCK_THREAD_CPUTIME_ID = 14; -pub const CLOCK_PROCESS_CPUTIME_ID = 15; - -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); -pub const MAP_SHARED = 0x0001; -pub const MAP_PRIVATE = 0x0002; -pub const MAP_FIXED = 0x0010; -pub const MAP_STACK = 0x0400; -pub const MAP_NOSYNC = 0x0800; -pub const MAP_ANON = 0x1000; -pub const MAP_ANONYMOUS = MAP_ANON; -pub const MAP_FILE = 0; - -pub const MAP_GUARD = 0x00002000; -pub const MAP_EXCL = 0x00004000; -pub const MAP_NOCORE = 0x00020000; -pub const MAP_PREFAULT_READ = 0x00040000; -pub const MAP_32BIT = 0x00080000; - -pub const WNOHANG = 1; -pub const WUNTRACED = 2; -pub const WSTOPPED = WUNTRACED; -pub const WCONTINUED = 4; -pub const WNOWAIT = 8; -pub const WEXITED = 16; -pub const WTRAPPED = 32; - -pub const SA_ONSTACK = 0x0001; -pub const SA_RESTART = 0x0002; -pub const SA_RESETHAND = 0x0004; -pub const SA_NOCLDSTOP = 0x0008; -pub const SA_NODEFER = 0x0010; -pub const SA_NOCLDWAIT = 0x0020; -pub const SA_SIGINFO = 0x0040; - -pub const SIGHUP = 1; -pub const SIGINT = 2; -pub const SIGQUIT = 3; -pub const SIGILL = 4; -pub const SIGTRAP = 5; -pub const SIGABRT = 6; -pub const SIGIOT = SIGABRT; -pub const SIGEMT = 7; -pub const SIGFPE = 8; -pub const SIGKILL = 9; -pub const SIGBUS = 10; -pub const SIGSEGV = 11; -pub const SIGSYS = 12; -pub const SIGPIPE = 13; -pub const SIGALRM = 14; -pub const SIGTERM = 15; -pub const SIGURG = 16; -pub const SIGSTOP = 17; -pub const SIGTSTP = 18; -pub const SIGCONT = 19; -pub const SIGCHLD = 20; -pub const SIGTTIN = 21; -pub const SIGTTOU = 22; -pub const SIGIO = 23; -pub const SIGXCPU = 24; -pub const SIGXFSZ = 25; -pub const SIGVTALRM = 26; -pub const SIGPROF = 27; -pub const SIGWINCH = 28; -pub const SIGINFO = 29; -pub const SIGUSR1 = 30; -pub const SIGUSR2 = 31; -pub const SIGTHR = 32; -pub const SIGLWP = SIGTHR; -pub const SIGLIBRT = 33; - -pub const SIGRTMIN = 65; -pub const SIGRTMAX = 126; - -// access function -pub const F_OK = 0; // test for existence of file -pub const X_OK = 1; // test for execute or search permission -pub const W_OK = 2; // test for write permission -pub const R_OK = 4; // test for read permission - -pub const O_RDONLY = 0x0000; -pub const O_WRONLY = 0x0001; -pub const O_RDWR = 0x0002; -pub const O_ACCMODE = 0x0003; - -pub const O_SHLOCK = 0x0010; -pub const O_EXLOCK = 0x0020; - -pub const O_CREAT = 0x0200; -pub const O_EXCL = 0x0800; -pub const O_NOCTTY = 0x8000; -pub const O_TRUNC = 0x0400; -pub const O_APPEND = 0x0008; -pub const O_NONBLOCK = 0x0004; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0x0080; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0x20000; -pub const O_NOFOLLOW = 0x0100; -pub const O_CLOEXEC = 0x00100000; - -pub const O_ASYNC = 0x0040; -pub const O_DIRECT = 0x00010000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_GETOWN = 5; -pub const F_SETOWN = 6; - -pub const F_GETLK = 11; -pub const F_SETLK = 12; -pub const F_SETLKW = 13; - -pub const F_RDLCK = 1; -pub const F_WRLCK = 3; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const FD_CLOEXEC = 1; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; - -pub const SIG_BLOCK = 1; -pub const SIG_UNBLOCK = 2; -pub const SIG_SETMASK = 3; - -pub const SOCK_STREAM = 1; -pub const SOCK_DGRAM = 2; -pub const SOCK_RAW = 3; -pub const SOCK_RDM = 4; -pub const SOCK_SEQPACKET = 5; - -pub const SOCK_CLOEXEC = 0x10000000; -pub const SOCK_NONBLOCK = 0x20000000; - -pub const SO_DEBUG = 0x00000001; -pub const SO_ACCEPTCONN = 0x00000002; -pub const SO_REUSEADDR = 0x00000004; -pub const SO_KEEPALIVE = 0x00000008; -pub const SO_DONTROUTE = 0x00000010; -pub const SO_BROADCAST = 0x00000020; -pub const SO_USELOOPBACK = 0x00000040; -pub const SO_LINGER = 0x00000080; -pub const SO_OOBINLINE = 0x00000100; -pub const SO_REUSEPORT = 0x00000200; -pub const SO_TIMESTAMP = 0x00000400; -pub const SO_NOSIGPIPE = 0x00000800; -pub const SO_ACCEPTFILTER = 0x00001000; -pub const SO_BINTIME = 0x00002000; -pub const SO_NO_OFFLOAD = 0x00004000; -pub const SO_NO_DDP = 0x00008000; -pub const SO_REUSEPORT_LB = 0x00010000; - -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_LABEL = 0x1009; -pub const SO_PEERLABEL = 0x1010; -pub const SO_LISTENQLIMIT = 0x1011; -pub const SO_LISTENQLEN = 0x1012; -pub const SO_LISTENINCQLEN = 0x1013; -pub const SO_SETFIB = 0x1014; -pub const SO_USER_COOKIE = 0x1015; -pub const SO_PROTOCOL = 0x1016; -pub const SO_PROTOTYPE = SO_PROTOCOL; -pub const SO_TS_CLOCK = 0x1017; -pub const SO_MAX_PACING_RATE = 0x1018; -pub const SO_DOMAIN = 0x1019; - -pub const SOL_SOCKET = 0xffff; - -pub const PF_UNSPEC = AF_UNSPEC; -pub const PF_LOCAL = AF_LOCAL; -pub const PF_UNIX = PF_LOCAL; -pub const PF_INET = AF_INET; -pub const PF_IMPLINK = AF_IMPLINK; -pub const PF_PUP = AF_PUP; -pub const PF_CHAOS = AF_CHAOS; -pub const PF_NETBIOS = AF_NETBIOS; -pub const PF_ISO = AF_ISO; -pub const PF_OSI = AF_ISO; -pub const PF_ECMA = AF_ECMA; -pub const PF_DATAKIT = AF_DATAKIT; -pub const PF_CCITT = AF_CCITT; -pub const PF_DECnet = AF_DECnet; -pub const PF_DLI = AF_DLI; -pub const PF_LAT = AF_LAT; -pub const PF_HYLINK = AF_HYLINK; -pub const PF_APPLETALK = AF_APPLETALK; -pub const PF_ROUTE = AF_ROUTE; -pub const PF_LINK = AF_LINK; -pub const PF_XTP = pseudo_AF_XTP; -pub const PF_COIP = AF_COIP; -pub const PF_CNT = AF_CNT; -pub const PF_SIP = AF_SIP; -pub const PF_IPX = AF_IPX; -pub const PF_RTIP = pseudo_AF_RTIP; -pub const PF_PIP = psuedo_AF_PIP; -pub const PF_ISDN = AF_ISDN; -pub const PF_KEY = pseudo_AF_KEY; -pub const PF_INET6 = pseudo_AF_INET6; -pub const PF_NATM = AF_NATM; -pub const PF_ATM = AF_ATM; -pub const PF_NETGRAPH = AF_NETGRAPH; -pub const PF_SLOW = AF_SLOW; -pub const PF_SCLUSTER = AF_SCLUSTER; -pub const PF_ARP = AF_ARP; -pub const PF_BLUETOOTH = AF_BLUETOOTH; -pub const PF_IEEE80211 = AF_IEEE80211; -pub const PF_INET_SDP = AF_INET_SDP; -pub const PF_INET6_SDP = AF_INET6_SDP; -pub const PF_MAX = AF_MAX; - -pub const AF_UNSPEC = 0; -pub const AF_UNIX = 1; -pub const AF_LOCAL = AF_UNIX; -pub const AF_FILE = AF_LOCAL; -pub const AF_INET = 2; -pub const AF_IMPLINK = 3; -pub const AF_PUP = 4; -pub const AF_CHAOS = 5; -pub const AF_NETBIOS = 6; -pub const AF_ISO = 7; -pub const AF_OSI = AF_ISO; -pub const AF_ECMA = 8; -pub const AF_DATAKIT = 9; -pub const AF_CCITT = 10; -pub const AF_SNA = 11; -pub const AF_DECnet = 12; -pub const AF_DLI = 13; -pub const AF_LAT = 14; -pub const AF_HYLINK = 15; -pub const AF_APPLETALK = 16; -pub const AF_ROUTE = 17; -pub const AF_LINK = 18; -pub const pseudo_AF_XTP = 19; -pub const AF_COIP = 20; -pub const AF_CNT = 21; -pub const pseudo_AF_RTIP = 22; -pub const AF_IPX = 23; -pub const AF_SIP = 24; -pub const pseudo_AF_PIP = 25; -pub const AF_ISDN = 26; -pub const AF_E164 = AF_ISDN; -pub const pseudo_AF_KEY = 27; -pub const AF_INET6 = 28; -pub const AF_NATM = 29; -pub const AF_ATM = 30; -pub const pseudo_AF_HDRCMPLT = 31; -pub const AF_NETGRAPH = 32; -pub const AF_SLOW = 33; -pub const AF_SCLUSTER = 34; -pub const AF_ARP = 35; -pub const AF_BLUETOOTH = 36; -pub const AF_IEEE80211 = 37; -pub const AF_INET_SDP = 40; -pub const AF_INET6_SDP = 42; -pub const AF_MAX = 42; - -pub const DT_UNKNOWN = 0; -pub const DT_FIFO = 1; -pub const DT_CHR = 2; -pub const DT_DIR = 4; -pub const DT_BLK = 6; -pub const DT_REG = 8; -pub const DT_LNK = 10; -pub const DT_SOCK = 12; -pub const DT_WHT = 14; - -/// add event to kq (implies enable) -pub const EV_ADD = 0x0001; - -/// delete event from kq -pub const EV_DELETE = 0x0002; - -/// enable event -pub const EV_ENABLE = 0x0004; - -/// disable event (not reported) -pub const EV_DISABLE = 0x0008; - -/// only report one occurrence -pub const EV_ONESHOT = 0x0010; - -/// clear event state after reporting -pub const EV_CLEAR = 0x0020; - -/// error, event data contains errno -pub const EV_ERROR = 0x4000; - -/// force immediate event output -/// ... with or without EV_ERROR -/// ... use KEVENT_FLAG_ERROR_EVENTS -/// on syscalls supporting flags -pub const EV_RECEIPT = 0x0040; - -/// disable event after reporting -pub const EV_DISPATCH = 0x0080; - -pub const EVFILT_READ = -1; -pub const EVFILT_WRITE = -2; - -/// attached to aio requests -pub const EVFILT_AIO = -3; - -/// attached to vnodes -pub const EVFILT_VNODE = -4; - -/// attached to struct proc -pub const EVFILT_PROC = -5; - -/// attached to struct proc -pub const EVFILT_SIGNAL = -6; - -/// timers -pub const EVFILT_TIMER = -7; - -/// Process descriptors -pub const EVFILT_PROCDESC = -8; - -/// Filesystem events -pub const EVFILT_FS = -9; - -pub const EVFILT_LIO = -10; - -/// User events -pub const EVFILT_USER = -11; - -/// Sendfile events -pub const EVFILT_SENDFILE = -12; - -pub const EVFILT_EMPTY = -13; - -/// On input, NOTE_TRIGGER causes the event to be triggered for output. -pub const NOTE_TRIGGER = 0x01000000; - -/// ignore input fflags -pub const NOTE_FFNOP = 0x00000000; - -/// and fflags -pub const NOTE_FFAND = 0x40000000; - -/// or fflags -pub const NOTE_FFOR = 0x80000000; - -/// copy fflags -pub const NOTE_FFCOPY = 0xc0000000; - -/// mask for operations -pub const NOTE_FFCTRLMASK = 0xc0000000; -pub const NOTE_FFLAGSMASK = 0x00ffffff; - -/// low water mark -pub const NOTE_LOWAT = 0x00000001; - -/// behave like poll() -pub const NOTE_FILE_POLL = 0x00000002; - -/// vnode was removed -pub const NOTE_DELETE = 0x00000001; - -/// data contents changed -pub const NOTE_WRITE = 0x00000002; - -/// size increased -pub const NOTE_EXTEND = 0x00000004; - -/// attributes changed -pub const NOTE_ATTRIB = 0x00000008; - -/// link count changed -pub const NOTE_LINK = 0x00000010; - -/// vnode was renamed -pub const NOTE_RENAME = 0x00000020; - -/// vnode access was revoked -pub const NOTE_REVOKE = 0x00000040; - -/// vnode was opened -pub const NOTE_OPEN = 0x00000080; - -/// file closed, fd did not allow write -pub const NOTE_CLOSE = 0x00000100; - -/// file closed, fd did allow write -pub const NOTE_CLOSE_WRITE = 0x00000200; - -/// file was read -pub const NOTE_READ = 0x00000400; - -/// process exited -pub const NOTE_EXIT = 0x80000000; - -/// process forked -pub const NOTE_FORK = 0x40000000; - -/// process exec'd -pub const NOTE_EXEC = 0x20000000; - -/// mask for signal & exit status -pub const NOTE_PDATAMASK = 0x000fffff; -pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); - -/// data is seconds -pub const NOTE_SECONDS = 0x00000001; - -/// data is milliseconds -pub const NOTE_MSECONDS = 0x00000002; - -/// data is microseconds -pub const NOTE_USECONDS = 0x00000004; - -/// data is nanoseconds -pub const NOTE_NSECONDS = 0x00000008; - -/// timeout is absolute -pub const NOTE_ABSTIME = 0x00000010; - -pub const TIOCEXCL = 0x2000740d; -pub const TIOCNXCL = 0x2000740e; -pub const TIOCSCTTY = 0x20007461; -pub const TIOCGPGRP = 0x40047477; -pub const TIOCSPGRP = 0x80047476; -pub const TIOCOUTQ = 0x40047473; -pub const TIOCSTI = 0x80017472; -pub const TIOCGWINSZ = 0x40087468; -pub const TIOCSWINSZ = 0x80087467; -pub const TIOCMGET = 0x4004746a; -pub const TIOCMBIS = 0x8004746c; -pub const TIOCMBIC = 0x8004746b; -pub const TIOCMSET = 0x8004746d; -pub const FIONREAD = 0x4004667f; -pub const TIOCCONS = 0x80047462; -pub const TIOCPKT = 0x80047470; -pub const FIONBIO = 0x8004667e; -pub const TIOCNOTTY = 0x20007471; -pub const TIOCSETD = 0x8004741b; -pub const TIOCGETD = 0x4004741a; -pub const TIOCSBRK = 0x2000747b; -pub const TIOCCBRK = 0x2000747a; -pub const TIOCGSID = 0x40047463; -pub const TIOCGPTN = 0x4004740f; -pub const TIOCSIG = 0x2004745f; - -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, (s & 0xff00) >> 8); -} -pub fn WTERMSIG(s: u32) u32 { - return s & 0x7f; -} -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} -pub fn WIFSTOPPED(s: u32) bool { - return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; -} -pub fn WIFSIGNALED(s: u32) bool { - return (s & 0xffff) -% 1 < 0xff; -} - -pub const winsize = extern struct { - ws_row: u16, - ws_col: u16, - ws_xpixel: u16, - ws_ypixel: u16, -}; - -const NSIG = 32; - -pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); -pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); -pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); - -/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. -pub const Sigaction = extern struct { - pub const handler_fn = fn (c_int) callconv(.C) void; - pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; - - /// signal handler - handler: extern union { - handler: ?handler_fn, - sigaction: ?sigaction_fn, - }, - - /// see signal options - flags: c_uint, - - /// signal mask to apply - mask: sigset_t, -}; - -pub const siginfo_t = extern struct { - signo: c_int, - errno: c_int, - code: c_int, - pid: pid_t, - uid: uid_t, - status: c_int, - addr: ?*c_void, - value: sigval, - reason: extern union { - fault: extern struct { - trapno: c_int, - }, - timer: extern struct { - timerid: c_int, - overrun: c_int, - }, - mesgq: extern struct { - mqd: c_int, - }, - poll: extern struct { - band: c_long, - }, - spare: extern struct { - spare1: c_long, - spare2: [7]c_int, - }, - }, -}; - -pub const sigval = extern union { - int: c_int, - ptr: ?*c_void, -}; - -pub const _SIG_WORDS = 4; -pub const _SIG_MAXSIG = 128; - -pub inline fn _SIG_IDX(sig: usize) usize { - return sig - 1; -} -pub inline fn _SIG_WORD(sig: usize) usize { - return_SIG_IDX(sig) >> 5; -} -pub inline fn _SIG_BIT(sig: usize) usize { - return 1 << (_SIG_IDX(sig) & 31); -} -pub inline fn _SIG_VALID(sig: usize) usize { - return sig <= _SIG_MAXSIG and sig > 0; -} - -pub const sigset_t = extern struct { - __bits: [_SIG_WORDS]u32, -}; - -pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; - -pub usingnamespace switch (builtin.target.cpu.arch) { - .x86_64 => struct { - pub const ucontext_t = extern struct { - sigmask: sigset_t, - mcontext: mcontext_t, - link: ?*ucontext_t, - stack: stack_t, - flags: c_int, - __spare__: [4]c_int, - }; - - /// XXX x86_64 specific - pub const mcontext_t = extern struct { - onstack: u64, - rdi: u64, - rsi: u64, - rdx: u64, - rcx: u64, - r8: u64, - r9: u64, - rax: u64, - rbx: u64, - rbp: u64, - r10: u64, - r11: u64, - r12: u64, - r13: u64, - r14: u64, - r15: u64, - trapno: u32, - fs: u16, - gs: u16, - addr: u64, - flags: u32, - es: u16, - ds: u16, - err: u64, - rip: u64, - cs: u64, - rflags: u64, - rsp: u64, - ss: u64, - }; - }, - else => struct {}, -}; - -pub const E = enum(u16) { - /// No error occurred. - SUCCESS = 0, - - PERM = 1, // Operation not permitted - NOENT = 2, // No such file or directory - SRCH = 3, // No such process - INTR = 4, // Interrupted system call - IO = 5, // Input/output error - NXIO = 6, // Device not configured - @"2BIG" = 7, // Argument list too long - NOEXEC = 8, // Exec format error - BADF = 9, // Bad file descriptor - CHILD = 10, // No child processes - DEADLK = 11, // Resource deadlock avoided - // 11 was AGAIN - NOMEM = 12, // Cannot allocate memory - ACCES = 13, // Permission denied - FAULT = 14, // Bad address - NOTBLK = 15, // Block device required - BUSY = 16, // Device busy - EXIST = 17, // File exists - XDEV = 18, // Cross-device link - NODEV = 19, // Operation not supported by device - NOTDIR = 20, // Not a directory - ISDIR = 21, // Is a directory - INVAL = 22, // Invalid argument - NFILE = 23, // Too many open files in system - MFILE = 24, // Too many open files - NOTTY = 25, // Inappropriate ioctl for device - TXTBSY = 26, // Text file busy - FBIG = 27, // File too large - NOSPC = 28, // No space left on device - SPIPE = 29, // Illegal seek - ROFS = 30, // Read-only filesystem - MLINK = 31, // Too many links - PIPE = 32, // Broken pipe - - // math software - DOM = 33, // Numerical argument out of domain - RANGE = 34, // Result too large - - // non-blocking and interrupt i/o - - /// Resource temporarily unavailable - /// This code is also used for `WOULDBLOCK`: operation would block. - AGAIN = 35, - INPROGRESS = 36, // Operation now in progress - ALREADY = 37, // Operation already in progress - - // ipc/network software -- argument errors - NOTSOCK = 38, // Socket operation on non-socket - DESTADDRREQ = 39, // Destination address required - MSGSIZE = 40, // Message too long - PROTOTYPE = 41, // Protocol wrong type for socket - NOPROTOOPT = 42, // Protocol not available - PROTONOSUPPORT = 43, // Protocol not supported - SOCKTNOSUPPORT = 44, // Socket type not supported - /// Operation not supported - /// This code is also used for `NOTSUP`. - OPNOTSUPP = 45, - PFNOSUPPORT = 46, // Protocol family not supported - AFNOSUPPORT = 47, // Address family not supported by protocol family - ADDRINUSE = 48, // Address already in use - ADDRNOTAVAIL = 49, // Can't assign requested address - - // ipc/network software -- operational errors - NETDOWN = 50, // Network is down - NETUNREACH = 51, // Network is unreachable - NETRESET = 52, // Network dropped connection on reset - CONNABORTED = 53, // Software caused connection abort - CONNRESET = 54, // Connection reset by peer - NOBUFS = 55, // No buffer space available - ISCONN = 56, // Socket is already connected - NOTCONN = 57, // Socket is not connected - SHUTDOWN = 58, // Can't send after socket shutdown - TOOMANYREFS = 59, // Too many references: can't splice - TIMEDOUT = 60, // Operation timed out - CONNREFUSED = 61, // Connection refused - - LOOP = 62, // Too many levels of symbolic links - NAMETOOLONG = 63, // File name too long - - // should be rearranged - HOSTDOWN = 64, // Host is down - HOSTUNREACH = 65, // No route to host - NOTEMPTY = 66, // Directory not empty - - // quotas & mush - PROCLIM = 67, // Too many processes - USERS = 68, // Too many users - DQUOT = 69, // Disc quota exceeded - - // Network File System - STALE = 70, // Stale NFS file handle - REMOTE = 71, // Too many levels of remote in path - BADRPC = 72, // RPC struct is bad - RPCMISMATCH = 73, // RPC version wrong - PROGUNAVAIL = 74, // RPC prog. not avail - PROGMISMATCH = 75, // Program version wrong - PROCUNAVAIL = 76, // Bad procedure for program - - NOLCK = 77, // No locks available - NOSYS = 78, // Function not implemented - - FTYPE = 79, // Inappropriate file type or format - AUTH = 80, // Authentication error - NEEDAUTH = 81, // Need authenticator - IDRM = 82, // Identifier removed - NOMSG = 83, // No message of desired type - OVERFLOW = 84, // Value too large to be stored in data type - CANCELED = 85, // Operation canceled - ILSEQ = 86, // Illegal byte sequence - NOATTR = 87, // Attribute not found - - DOOFUS = 88, // Programming error - - BADMSG = 89, // Bad message - MULTIHOP = 90, // Multihop attempted - NOLINK = 91, // Link has been severed - PROTO = 92, // Protocol error - - NOTCAPABLE = 93, // Capabilities insufficient - CAPMODE = 94, // Not permitted in capability mode - NOTRECOVERABLE = 95, // State not recoverable - OWNERDEAD = 96, // Previous owner died - _, -}; - -pub const MINSIGSTKSZ = switch (builtin.target.cpu.arch) { - .i386, .x86_64 => 2048, - .arm, .aarch64 => 4096, - else => @compileError("MINSIGSTKSZ not defined for this architecture"), -}; -pub const SIGSTKSZ = MINSIGSTKSZ + 32768; - -pub const SS_ONSTACK = 1; -pub const SS_DISABLE = 4; - -pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, -}; - -pub const S_IFMT = 0o170000; - -pub const S_IFIFO = 0o010000; -pub const S_IFCHR = 0o020000; -pub const S_IFDIR = 0o040000; -pub const S_IFBLK = 0o060000; -pub const S_IFREG = 0o100000; -pub const S_IFLNK = 0o120000; -pub const S_IFSOCK = 0o140000; -pub const S_IFWHT = 0o160000; - -pub const S_ISUID = 0o4000; -pub const S_ISGID = 0o2000; -pub const S_ISVTX = 0o1000; -pub const S_IRWXU = 0o700; -pub const S_IRUSR = 0o400; -pub const S_IWUSR = 0o200; -pub const S_IXUSR = 0o100; -pub const S_IRWXG = 0o070; -pub const S_IRGRP = 0o040; -pub const S_IWGRP = 0o020; -pub const S_IXGRP = 0o010; -pub const S_IRWXO = 0o007; -pub const S_IROTH = 0o004; -pub const S_IWOTH = 0o002; -pub const S_IXOTH = 0o001; - -pub fn S_ISFIFO(m: u32) bool { - return m & S_IFMT == S_IFIFO; -} - -pub fn S_ISCHR(m: u32) bool { - return m & S_IFMT == S_IFCHR; -} - -pub fn S_ISDIR(m: u32) bool { - return m & S_IFMT == S_IFDIR; -} - -pub fn S_ISBLK(m: u32) bool { - return m & S_IFMT == S_IFBLK; -} - -pub fn S_ISREG(m: u32) bool { - return m & S_IFMT == S_IFREG; -} - -pub fn S_ISLNK(m: u32) bool { - return m & S_IFMT == S_IFLNK; -} - -pub fn S_ISSOCK(m: u32) bool { - return m & S_IFMT == S_IFSOCK; -} - -pub fn S_IWHT(m: u32) bool { - return m & S_IFMT == S_IFWHT; -} - -pub const HOST_NAME_MAX = 255; - -/// Magic value that specify the use of the current working directory -/// to determine the target of relative file paths in the openat() and -/// similar syscalls. -pub const AT_FDCWD = -100; - -/// Check access using effective user and group ID -pub const AT_EACCESS = 0x0100; - -/// Do not follow symbolic links -pub const AT_SYMLINK_NOFOLLOW = 0x0200; - -/// Follow symbolic link -pub const AT_SYMLINK_FOLLOW = 0x0400; - -/// Remove directory instead of file -pub const AT_REMOVEDIR = 0x0800; - -pub const addrinfo = extern struct { - flags: i32, - family: i32, - socktype: i32, - protocol: i32, - addrlen: socklen_t, - canonname: ?[*:0]u8, - addr: ?*sockaddr, - next: ?*addrinfo, -}; - -/// Fail if not under dirfd -pub const AT_BENEATH = 0x1000; - -/// dummy for IP -pub const IPPROTO_IP = 0; - -/// control message protocol -pub const IPPROTO_ICMP = 1; - -/// tcp -pub const IPPROTO_TCP = 6; - -/// user datagram protocol -pub const IPPROTO_UDP = 17; - -/// IP6 header -pub const IPPROTO_IPV6 = 41; - -/// raw IP packet -pub const IPPROTO_RAW = 255; - -/// IP6 hop-by-hop options -pub const IPPROTO_HOPOPTS = 0; - -/// group mgmt protocol -pub const IPPROTO_IGMP = 2; - -/// gateway^2 (deprecated) -pub const IPPROTO_GGP = 3; - -/// IPv4 encapsulation -pub const IPPROTO_IPV4 = 4; - -/// for compatibility -pub const IPPROTO_IPIP = IPPROTO_IPV4; - -/// Stream protocol II -pub const IPPROTO_ST = 7; - -/// exterior gateway protocol -pub const IPPROTO_EGP = 8; - -/// private interior gateway -pub const IPPROTO_PIGP = 9; - -/// BBN RCC Monitoring -pub const IPPROTO_RCCMON = 10; - -/// network voice protocol -pub const IPPROTO_NVPII = 11; - -/// pup -pub const IPPROTO_PUP = 12; - -/// Argus -pub const IPPROTO_ARGUS = 13; - -/// EMCON -pub const IPPROTO_EMCON = 14; - -/// Cross Net Debugger -pub const IPPROTO_XNET = 15; - -/// Chaos -pub const IPPROTO_CHAOS = 16; - -/// Multiplexing -pub const IPPROTO_MUX = 18; - -/// DCN Measurement Subsystems -pub const IPPROTO_MEAS = 19; - -/// Host Monitoring -pub const IPPROTO_HMP = 20; - -/// Packet Radio Measurement -pub const IPPROTO_PRM = 21; - -/// xns idp -pub const IPPROTO_IDP = 22; - -/// Trunk-1 -pub const IPPROTO_TRUNK1 = 23; - -/// Trunk-2 -pub const IPPROTO_TRUNK2 = 24; - -/// Leaf-1 -pub const IPPROTO_LEAF1 = 25; - -/// Leaf-2 -pub const IPPROTO_LEAF2 = 26; - -/// Reliable Data -pub const IPPROTO_RDP = 27; - -/// Reliable Transaction -pub const IPPROTO_IRTP = 28; - -/// tp-4 w/ class negotiation -pub const IPPROTO_TP = 29; - -/// Bulk Data Transfer -pub const IPPROTO_BLT = 30; - -/// Network Services -pub const IPPROTO_NSP = 31; - -/// Merit Internodal -pub const IPPROTO_INP = 32; - -/// Datagram Congestion Control Protocol -pub const IPPROTO_DCCP = 33; - -/// Third Party Connect -pub const IPPROTO_3PC = 34; - -/// InterDomain Policy Routing -pub const IPPROTO_IDPR = 35; - -/// XTP -pub const IPPROTO_XTP = 36; - -/// Datagram Delivery -pub const IPPROTO_DDP = 37; - -/// Control Message Transport -pub const IPPROTO_CMTP = 38; - -/// TP++ Transport -pub const IPPROTO_TPXX = 39; - -/// IL transport protocol -pub const IPPROTO_IL = 40; - -/// Source Demand Routing -pub const IPPROTO_SDRP = 42; - -/// IP6 routing header -pub const IPPROTO_ROUTING = 43; - -/// IP6 fragmentation header -pub const IPPROTO_FRAGMENT = 44; - -/// InterDomain Routing -pub const IPPROTO_IDRP = 45; - -/// resource reservation -pub const IPPROTO_RSVP = 46; - -/// General Routing Encap. -pub const IPPROTO_GRE = 47; - -/// Mobile Host Routing -pub const IPPROTO_MHRP = 48; - -/// BHA -pub const IPPROTO_BHA = 49; - -/// IP6 Encap Sec. Payload -pub const IPPROTO_ESP = 50; - -/// IP6 Auth Header -pub const IPPROTO_AH = 51; - -/// Integ. Net Layer Security -pub const IPPROTO_INLSP = 52; - -/// IP with encryption -pub const IPPROTO_SWIPE = 53; - -/// Next Hop Resolution -pub const IPPROTO_NHRP = 54; - -/// IP Mobility -pub const IPPROTO_MOBILE = 55; - -/// Transport Layer Security -pub const IPPROTO_TLSP = 56; - -/// SKIP -pub const IPPROTO_SKIP = 57; - -/// ICMP6 -pub const IPPROTO_ICMPV6 = 58; - -/// IP6 no next header -pub const IPPROTO_NONE = 59; - -/// IP6 destination option -pub const IPPROTO_DSTOPTS = 60; - -/// any host internal protocol -pub const IPPROTO_AHIP = 61; - -/// CFTP -pub const IPPROTO_CFTP = 62; - -/// "hello" routing protocol -pub const IPPROTO_HELLO = 63; - -/// SATNET/Backroom EXPAK -pub const IPPROTO_SATEXPAK = 64; - -/// Kryptolan -pub const IPPROTO_KRYPTOLAN = 65; - -/// Remote Virtual Disk -pub const IPPROTO_RVD = 66; - -/// Pluribus Packet Core -pub const IPPROTO_IPPC = 67; - -/// Any distributed FS -pub const IPPROTO_ADFS = 68; - -/// Satnet Monitoring -pub const IPPROTO_SATMON = 69; - -/// VISA Protocol -pub const IPPROTO_VISA = 70; - -/// Packet Core Utility -pub const IPPROTO_IPCV = 71; - -/// Comp. Prot. Net. Executive -pub const IPPROTO_CPNX = 72; - -/// Comp. Prot. HeartBeat -pub const IPPROTO_CPHB = 73; - -/// Wang Span Network -pub const IPPROTO_WSN = 74; - -/// Packet Video Protocol -pub const IPPROTO_PVP = 75; - -/// BackRoom SATNET Monitoring -pub const IPPROTO_BRSATMON = 76; - -/// Sun net disk proto (temp.) -pub const IPPROTO_ND = 77; - -/// WIDEBAND Monitoring -pub const IPPROTO_WBMON = 78; - -/// WIDEBAND EXPAK -pub const IPPROTO_WBEXPAK = 79; - -/// ISO cnlp -pub const IPPROTO_EON = 80; - -/// VMTP -pub const IPPROTO_VMTP = 81; - -/// Secure VMTP -pub const IPPROTO_SVMTP = 82; - -/// Banyon VINES -pub const IPPROTO_VINES = 83; - -/// TTP -pub const IPPROTO_TTP = 84; - -/// NSFNET-IGP -pub const IPPROTO_IGP = 85; - -/// dissimilar gateway prot. -pub const IPPROTO_DGP = 86; - -/// TCF -pub const IPPROTO_TCF = 87; - -/// Cisco/GXS IGRP -pub const IPPROTO_IGRP = 88; - -/// OSPFIGP -pub const IPPROTO_OSPFIGP = 89; - -/// Strite RPC protocol -pub const IPPROTO_SRPC = 90; - -/// Locus Address Resoloution -pub const IPPROTO_LARP = 91; - -/// Multicast Transport -pub const IPPROTO_MTP = 92; - -/// AX.25 Frames -pub const IPPROTO_AX25 = 93; - -/// IP encapsulated in IP -pub const IPPROTO_IPEIP = 94; - -/// Mobile Int.ing control -pub const IPPROTO_MICP = 95; - -/// Semaphore Comm. security -pub const IPPROTO_SCCSP = 96; - -/// Ethernet IP encapsulation -pub const IPPROTO_ETHERIP = 97; - -/// encapsulation header -pub const IPPROTO_ENCAP = 98; - -/// any private encr. scheme -pub const IPPROTO_APES = 99; - -/// GMTP -pub const IPPROTO_GMTP = 100; - -/// payload compression (IPComp) -pub const IPPROTO_IPCOMP = 108; - -/// SCTP -pub const IPPROTO_SCTP = 132; - -/// IPv6 Mobility Header -pub const IPPROTO_MH = 135; - -/// UDP-Lite -pub const IPPROTO_UDPLITE = 136; - -/// IP6 Host Identity Protocol -pub const IPPROTO_HIP = 139; - -/// IP6 Shim6 Protocol -pub const IPPROTO_SHIM6 = 140; - -/// Protocol Independent Mcast -pub const IPPROTO_PIM = 103; - -/// CARP -pub const IPPROTO_CARP = 112; - -/// PGM -pub const IPPROTO_PGM = 113; - -/// MPLS-in-IP -pub const IPPROTO_MPLS = 137; - -/// PFSYNC -pub const IPPROTO_PFSYNC = 240; - -/// Reserved -pub const IPPROTO_RESERVED_253 = 253; - -/// Reserved -pub const IPPROTO_RESERVED_254 = 254; - -pub const rlimit_resource = enum(c_int) { - CPU = 0, - FSIZE = 1, - DATA = 2, - STACK = 3, - CORE = 4, - RSS = 5, - MEMLOCK = 6, - NPROC = 7, - NOFILE = 8, - SBSIZE = 9, - VMEM = 10, - NPTS = 11, - SWAP = 12, - KQUEUES = 13, - UMTXP = 14, - _, - - pub const AS: rlimit_resource = .VMEM; -}; - -pub const rlim_t = i64; - -/// No limit -pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -pub const nfds_t = u32; - -pub const pollfd = extern struct { - fd: fd_t, - events: i16, - revents: i16, -}; - -/// any readable data available. -pub const POLLIN = 0x0001; -/// OOB/Urgent readable data. -pub const POLLPRI = 0x0002; -/// file descriptor is writeable. -pub const POLLOUT = 0x0004; -/// non-OOB/URG data available. -pub const POLLRDNORM = 0x0040; -/// no write type differentiation. -pub const POLLWRNORM = POLLOUT; -/// OOB/Urgent readable data. -pub const POLLRDBAND = 0x0080; -/// OOB/Urgent data can be written. -pub const POLLWRBAND = 0x0100; -/// like POLLIN, except ignore EOF. -pub const POLLINIGNEOF = 0x2000; -/// some poll error occurred. -pub const POLLERR = 0x0008; -/// file descriptor was "hung up". -pub const POLLHUP = 0x0010; -/// requested events "invalid". -pub const POLLNVAL = 0x0020; - -pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | - POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; diff --git a/lib/std/os/bits/haiku.zig b/lib/std/os/bits/haiku.zig deleted file mode 100644 index 620bf23414..0000000000 --- a/lib/std/os/bits/haiku.zig +++ /dev/null @@ -1,1375 +0,0 @@ -const std = @import("../../std.zig"); -const maxInt = std.math.maxInt; - -pub usingnamespace @import("posix.zig"); - -pub const fd_t = c_int; -pub const pid_t = c_int; -pub const uid_t = u32; -pub const gid_t = u32; -pub const mode_t = c_uint; - -pub const socklen_t = u32; - -/// Renamed from `kevent` to `Kevent` to avoid conflict with function name. -pub const Kevent = extern struct { - ident: usize, - filter: i16, - flags: u16, - fflags: u32, - data: i64, - udata: usize, - // TODO ext -}; - -// Modes and flags for dlopen() -// include/dlfcn.h - -pub const POLLIN = 0x0001; -pub const POLLERR = 0x0004; -pub const POLLNVAL = 0x1000; -pub const POLLHUP = 0x0080; - -/// Bind function calls lazily. -pub const RTLD_LAZY = 1; - -/// Bind function calls immediately. -pub const RTLD_NOW = 2; - -pub const RTLD_MODEMASK = 0x3; - -/// Make symbols globally available. -pub const RTLD_GLOBAL = 0x100; - -/// Opposite of RTLD_GLOBAL, and the default. -pub const RTLD_LOCAL = 0; - -/// Trace loaded objects and exit. -pub const RTLD_TRACE = 0x200; - -/// Do not remove members. -pub const RTLD_NODELETE = 0x01000; - -/// Do not load if not already loaded. -pub const RTLD_NOLOAD = 0x02000; - -pub const dl_phdr_info = extern struct { - dlpi_addr: usize, - dlpi_name: ?[*:0]const u8, - dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: u16, -}; - -pub const Flock = extern struct { - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - l_type: i16, - l_whence: i16, - l_sysid: i32, - __unused: [4]u8, -}; - -pub const msghdr = extern struct { - /// optional address - msg_name: ?*sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec, - - /// # elements in msg_iov - msg_iovlen: i32, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - /// optional address - msg_name: ?*const sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec_const, - - /// # elements in msg_iov - msg_iovlen: i32, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: i32, -}; - -pub const off_t = i64; -pub const ino_t = u64; - -pub const nfds_t = u32; - -pub const pollfd = extern struct { - fd: i32, - events: i16, - revents: i16, -}; - -pub const libc_stat = extern struct { - dev: i32, - ino: u64, - mode: u32, - nlink: i32, - uid: i32, - gid: i32, - size: i64, - rdev: i32, - blksize: i32, - atim: timespec, - mtim: timespec, - ctim: timespec, - crtim: timespec, - st_type: u32, - blocks: i64, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - pub fn ctime(self: @This()) timespec { - return self.ctim; - } - pub fn crtime(self: @This()) timespec { - return self.crtim; - } -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const dirent = extern struct { - d_dev: i32, - d_pdev: i32, - d_ino: i64, - d_pino: i64, - d_reclen: u16, - d_name: [256]u8, - - pub fn reclen(self: dirent) u16 { - return self.d_reclen; - } -}; - -pub const image_info = extern struct { - id: u32, - type: u32, - sequence: i32, - init_order: i32, - init_routine: *c_void, - term_routine: *c_void, - device: i32, - node: i32, - name: [1024]u8, - text: *c_void, - data: *c_void, - text_size: i32, - data_size: i32, - api_version: i32, - abi: i32, -}; - -pub const system_info = extern struct { - boot_time: i64, - cpu_count: u32, - max_pages: u64, - used_pages: u64, - cached_pages: u64, - block_cache_pages: u64, - ignored_pages: u64, - needed_memory: u64, - free_memory: u64, - max_swap_pages: u64, - free_swap_pages: u64, - page_faults: u32, - max_sems: u32, - used_sems: u32, - max_ports: u32, - used_ports: u32, - max_threads: u32, - used_threads: u32, - max_teams: u32, - used_teams: u32, - kernel_name: [256]u8, - kernel_build_date: [32]u8, - kernel_build_time: [32]u8, - kernel_version: i64, - abi: u32, -}; - -pub const in_port_t = u16; -pub const sa_family_t = u8; - -pub const sockaddr = extern struct { - /// total length - len: u8, - - /// address family - family: sa_family_t, - - /// actually longer; address value - data: [14]u8, -}; - -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; - -pub const sockaddr_in = extern struct { - len: u8 = @sizeOf(sockaddr_in), - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -pub const sockaddr_in6 = extern struct { - len: u8 = @sizeOf(sockaddr_in6), - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -pub const sockaddr_un = extern struct { - len: u8 = @sizeOf(sockaddr_un), - family: sa_family_t = AF_UNIX, - path: [104]u8, -}; - -pub const CTL_KERN = 1; -pub const CTL_DEBUG = 5; - -pub const KERN_PROC = 14; // struct: process entries -pub const KERN_PROC_PATHNAME = 12; // path to executable - -pub const PATH_MAX = 1024; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -pub const PROT_NONE = 0; -pub const PROT_READ = 1; -pub const PROT_WRITE = 2; -pub const PROT_EXEC = 4; - -pub const CLOCK_MONOTONIC = 0; -pub const CLOCK_REALTIME = -1; -pub const CLOCK_PROCESS_CPUTIME_ID = -2; -pub const CLOCK_THREAD_CPUTIME_ID = -3; - -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); -pub const MAP_SHARED = 0x0001; -pub const MAP_PRIVATE = 0x0002; -pub const MAP_FIXED = 0x0010; -pub const MAP_STACK = 0x0400; -pub const MAP_NOSYNC = 0x0800; -pub const MAP_ANON = 0x1000; -pub const MAP_ANONYMOUS = MAP_ANON; -pub const MAP_FILE = 0; - -pub const MAP_GUARD = 0x00002000; -pub const MAP_EXCL = 0x00004000; -pub const MAP_NOCORE = 0x00020000; -pub const MAP_PREFAULT_READ = 0x00040000; -pub const MAP_32BIT = 0x00080000; - -pub const WNOHANG = 0x1; -pub const WUNTRACED = 0x2; -pub const WSTOPPED = 0x10; -pub const WCONTINUED = 0x4; -pub const WNOWAIT = 0x20; -pub const WEXITED = 0x08; - -pub const SA_ONSTACK = 0x20; -pub const SA_RESTART = 0x10; -pub const SA_RESETHAND = 0x04; -pub const SA_NOCLDSTOP = 0x01; -pub const SA_NODEFER = 0x08; -pub const SA_NOCLDWAIT = 0x02; -pub const SA_SIGINFO = 0x40; -pub const SA_NOMASK = SA_NODEFER; -pub const SA_STACK = SA_ONSTACK; -pub const SA_ONESHOT = SA_RESETHAND; - -pub const SIGHUP = 1; -pub const SIGINT = 2; -pub const SIGQUIT = 3; -pub const SIGILL = 4; -pub const SIGCHLD = 5; -pub const SIGABRT = 6; -pub const SIGIOT = SIGABRT; -pub const SIGPIPE = 7; -pub const SIGFPE = 8; -pub const SIGKILL = 9; -pub const SIGSTOP = 10; -pub const SIGSEGV = 11; -pub const SIGCONT = 12; -pub const SIGTSTP = 13; -pub const SIGALRM = 14; -pub const SIGTERM = 15; -pub const SIGTTIN = 16; -pub const SIGTTOU = 17; -pub const SIGUSR1 = 18; -pub const SIGUSR2 = 19; -pub const SIGWINCH = 20; -pub const SIGKILLTHR = 21; -pub const SIGTRAP = 22; -pub const SIGPOLL = 23; -pub const SIGPROF = 24; -pub const SIGSYS = 25; -pub const SIGURG = 26; -pub const SIGVTALRM = 27; -pub const SIGXCPU = 28; -pub const SIGXFSZ = 29; -pub const SIGBUS = 30; -pub const SIGRESERVED1 = 31; -pub const SIGRESERVED2 = 32; - -// TODO: check -pub const SIGRTMIN = 65; -pub const SIGRTMAX = 126; - -// access function -pub const F_OK = 0; // test for existence of file -pub const X_OK = 1; // test for execute or search permission -pub const W_OK = 2; // test for write permission -pub const R_OK = 4; // test for read permission - -pub const O_RDONLY = 0x0000; -pub const O_WRONLY = 0x0001; -pub const O_RDWR = 0x0002; -pub const O_ACCMODE = 0x0003; - -pub const O_SHLOCK = 0x0010; -pub const O_EXLOCK = 0x0020; - -pub const O_CREAT = 0x0200; -pub const O_EXCL = 0x0800; -pub const O_NOCTTY = 0x8000; -pub const O_TRUNC = 0x0400; -pub const O_APPEND = 0x0008; -pub const O_NONBLOCK = 0x0004; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0x0080; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0x20000; -pub const O_NOFOLLOW = 0x0100; -pub const O_CLOEXEC = 0x00100000; - -pub const O_ASYNC = 0x0040; -pub const O_DIRECT = 0x00010000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_GETOWN = 5; -pub const F_SETOWN = 6; - -pub const F_GETLK = 11; -pub const F_SETLK = 12; -pub const F_SETLKW = 13; - -pub const F_RDLCK = 1; -pub const F_WRLCK = 3; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const FD_CLOEXEC = 1; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; - -pub const SIG_BLOCK = 1; -pub const SIG_UNBLOCK = 2; -pub const SIG_SETMASK = 3; - -pub const SOCK_STREAM = 1; -pub const SOCK_DGRAM = 2; -pub const SOCK_RAW = 3; -pub const SOCK_RDM = 4; -pub const SOCK_SEQPACKET = 5; - -pub const SOCK_CLOEXEC = 0x10000000; -pub const SOCK_NONBLOCK = 0x20000000; - -pub const SO_DEBUG = 0x00000001; -pub const SO_ACCEPTCONN = 0x00000002; -pub const SO_REUSEADDR = 0x00000004; -pub const SO_KEEPALIVE = 0x00000008; -pub const SO_DONTROUTE = 0x00000010; -pub const SO_BROADCAST = 0x00000020; -pub const SO_USELOOPBACK = 0x00000040; -pub const SO_LINGER = 0x00000080; -pub const SO_OOBINLINE = 0x00000100; -pub const SO_REUSEPORT = 0x00000200; -pub const SO_TIMESTAMP = 0x00000400; -pub const SO_NOSIGPIPE = 0x00000800; -pub const SO_ACCEPTFILTER = 0x00001000; -pub const SO_BINTIME = 0x00002000; -pub const SO_NO_OFFLOAD = 0x00004000; -pub const SO_NO_DDP = 0x00008000; -pub const SO_REUSEPORT_LB = 0x00010000; - -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_LABEL = 0x1009; -pub const SO_PEERLABEL = 0x1010; -pub const SO_LISTENQLIMIT = 0x1011; -pub const SO_LISTENQLEN = 0x1012; -pub const SO_LISTENINCQLEN = 0x1013; -pub const SO_SETFIB = 0x1014; -pub const SO_USER_COOKIE = 0x1015; -pub const SO_PROTOCOL = 0x1016; -pub const SO_PROTOTYPE = SO_PROTOCOL; -pub const SO_TS_CLOCK = 0x1017; -pub const SO_MAX_PACING_RATE = 0x1018; -pub const SO_DOMAIN = 0x1019; - -pub const SOL_SOCKET = 0xffff; - -pub const PF_UNSPEC = AF_UNSPEC; -pub const PF_LOCAL = AF_LOCAL; -pub const PF_UNIX = PF_LOCAL; -pub const PF_INET = AF_INET; -pub const PF_IMPLINK = AF_IMPLINK; -pub const PF_PUP = AF_PUP; -pub const PF_CHAOS = AF_CHAOS; -pub const PF_NETBIOS = AF_NETBIOS; -pub const PF_ISO = AF_ISO; -pub const PF_OSI = AF_ISO; -pub const PF_ECMA = AF_ECMA; -pub const PF_DATAKIT = AF_DATAKIT; -pub const PF_CCITT = AF_CCITT; -pub const PF_DECnet = AF_DECnet; -pub const PF_DLI = AF_DLI; -pub const PF_LAT = AF_LAT; -pub const PF_HYLINK = AF_HYLINK; -pub const PF_APPLETALK = AF_APPLETALK; -pub const PF_ROUTE = AF_ROUTE; -pub const PF_LINK = AF_LINK; -pub const PF_XTP = pseudo_AF_XTP; -pub const PF_COIP = AF_COIP; -pub const PF_CNT = AF_CNT; -pub const PF_SIP = AF_SIP; -pub const PF_IPX = AF_IPX; -pub const PF_RTIP = pseudo_AF_RTIP; -pub const PF_PIP = psuedo_AF_PIP; -pub const PF_ISDN = AF_ISDN; -pub const PF_KEY = pseudo_AF_KEY; -pub const PF_INET6 = pseudo_AF_INET6; -pub const PF_NATM = AF_NATM; -pub const PF_ATM = AF_ATM; -pub const PF_NETGRAPH = AF_NETGRAPH; -pub const PF_SLOW = AF_SLOW; -pub const PF_SCLUSTER = AF_SCLUSTER; -pub const PF_ARP = AF_ARP; -pub const PF_BLUETOOTH = AF_BLUETOOTH; -pub const PF_IEEE80211 = AF_IEEE80211; -pub const PF_INET_SDP = AF_INET_SDP; -pub const PF_INET6_SDP = AF_INET6_SDP; -pub const PF_MAX = AF_MAX; - -pub const AF_UNSPEC = 0; -pub const AF_UNIX = 1; -pub const AF_LOCAL = AF_UNIX; -pub const AF_FILE = AF_LOCAL; -pub const AF_INET = 2; -pub const AF_IMPLINK = 3; -pub const AF_PUP = 4; -pub const AF_CHAOS = 5; -pub const AF_NETBIOS = 6; -pub const AF_ISO = 7; -pub const AF_OSI = AF_ISO; -pub const AF_ECMA = 8; -pub const AF_DATAKIT = 9; -pub const AF_CCITT = 10; -pub const AF_SNA = 11; -pub const AF_DECnet = 12; -pub const AF_DLI = 13; -pub const AF_LAT = 14; -pub const AF_HYLINK = 15; -pub const AF_APPLETALK = 16; -pub const AF_ROUTE = 17; -pub const AF_LINK = 18; -pub const pseudo_AF_XTP = 19; -pub const AF_COIP = 20; -pub const AF_CNT = 21; -pub const pseudo_AF_RTIP = 22; -pub const AF_IPX = 23; -pub const AF_SIP = 24; -pub const pseudo_AF_PIP = 25; -pub const AF_ISDN = 26; -pub const AF_E164 = AF_ISDN; -pub const pseudo_AF_KEY = 27; -pub const AF_INET6 = 28; -pub const AF_NATM = 29; -pub const AF_ATM = 30; -pub const pseudo_AF_HDRCMPLT = 31; -pub const AF_NETGRAPH = 32; -pub const AF_SLOW = 33; -pub const AF_SCLUSTER = 34; -pub const AF_ARP = 35; -pub const AF_BLUETOOTH = 36; -pub const AF_IEEE80211 = 37; -pub const AF_INET_SDP = 40; -pub const AF_INET6_SDP = 42; -pub const AF_MAX = 42; - -pub const DT_UNKNOWN = 0; -pub const DT_FIFO = 1; -pub const DT_CHR = 2; -pub const DT_DIR = 4; -pub const DT_BLK = 6; -pub const DT_REG = 8; -pub const DT_LNK = 10; -pub const DT_SOCK = 12; -pub const DT_WHT = 14; - -/// add event to kq (implies enable) -pub const EV_ADD = 0x0001; - -/// delete event from kq -pub const EV_DELETE = 0x0002; - -/// enable event -pub const EV_ENABLE = 0x0004; - -/// disable event (not reported) -pub const EV_DISABLE = 0x0008; - -/// only report one occurrence -pub const EV_ONESHOT = 0x0010; - -/// clear event state after reporting -pub const EV_CLEAR = 0x0020; - -/// force immediate event output -/// ... with or without EV_ERROR -/// ... use KEVENT_FLAG_ERROR_EVENTS -/// on syscalls supporting flags -pub const EV_RECEIPT = 0x0040; - -/// disable event after reporting -pub const EV_DISPATCH = 0x0080; - -pub const EVFILT_READ = -1; -pub const EVFILT_WRITE = -2; - -/// attached to aio requests -pub const EVFILT_AIO = -3; - -/// attached to vnodes -pub const EVFILT_VNODE = -4; - -/// attached to struct proc -pub const EVFILT_PROC = -5; - -/// attached to struct proc -pub const EVFILT_SIGNAL = -6; - -/// timers -pub const EVFILT_TIMER = -7; - -/// Process descriptors -pub const EVFILT_PROCDESC = -8; - -/// Filesystem events -pub const EVFILT_FS = -9; - -pub const EVFILT_LIO = -10; - -/// User events -pub const EVFILT_USER = -11; - -/// Sendfile events -pub const EVFILT_SENDFILE = -12; - -pub const EVFILT_EMPTY = -13; - -pub const TCGETA = 0x8000; -pub const TCSETA = 0x8001; -pub const TCSETAW = 0x8004; -pub const TCSETAF = 0x8003; -pub const TCSBRK = 08005; -pub const TCXONC = 0x8007; -pub const TCFLSH = 0x8006; - -pub const TIOCSCTTY = 0x8017; -pub const TIOCGPGRP = 0x8015; -pub const TIOCSPGRP = 0x8016; -pub const TIOCGWINSZ = 0x8012; -pub const TIOCSWINSZ = 0x8013; -pub const TIOCMGET = 0x8018; -pub const TIOCMBIS = 0x8022; -pub const TIOCMBIC = 0x8023; -pub const TIOCMSET = 0x8019; -pub const FIONREAD = 0xbe000001; -pub const FIONBIO = 0xbe000000; -pub const TIOCSBRK = 0x8020; -pub const TIOCCBRK = 0x8021; -pub const TIOCGSID = 0x8024; - -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, s & 0xff); -} - -pub fn WTERMSIG(s: u32) u32 { - return (s >> 8) & 0xff; -} - -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} - -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} - -pub fn WIFSTOPPED(s: u32) bool { - return ((s >> 16) & 0xff) != 0; -} - -pub fn WIFSIGNALED(s: u32) bool { - return ((s >> 8) & 0xff) != 0; -} - -pub const winsize = extern struct { - ws_row: u16, - ws_col: u16, - ws_xpixel: u16, - ws_ypixel: u16, -}; - -const NSIG = 32; - -pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); -pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); -pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); - -/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. -pub const Sigaction = extern struct { - /// signal handler - __sigaction_u: extern union { - __sa_handler: fn (i32) callconv(.C) void, - __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void, - }, - - /// see signal options - sa_flags: u32, - - /// signal mask to apply - sa_mask: sigset_t, -}; - -pub const _SIG_WORDS = 4; -pub const _SIG_MAXSIG = 128; -pub inline fn _SIG_IDX(sig: usize) usize { - return sig - 1; -} -pub inline fn _SIG_WORD(sig: usize) usize { - return_SIG_IDX(sig) >> 5; -} -pub inline fn _SIG_BIT(sig: usize) usize { - return 1 << (_SIG_IDX(sig) & 31); -} -pub inline fn _SIG_VALID(sig: usize) usize { - return sig <= _SIG_MAXSIG and sig > 0; -} - -pub const sigset_t = extern struct { - __bits: [_SIG_WORDS]u32, -}; - -pub const E = enum(i32) { - /// No error occurred. - SUCCESS = 0, - PERM = -0x7ffffff1, // Operation not permitted - NOENT = -0x7fff9ffd, // No such file or directory - SRCH = -0x7fff8ff3, // No such process - INTR = -0x7ffffff6, // Interrupted system call - IO = -0x7fffffff, // Input/output error - NXIO = -0x7fff8ff5, // Device not configured - @"2BIG" = -0x7fff8fff, // Argument list too long - NOEXEC = -0x7fffecfe, // Exec format error - CHILD = -0x7fff8ffe, // No child processes - DEADLK = -0x7fff8ffd, // Resource deadlock avoided - NOMEM = -0x80000000, // Cannot allocate memory - ACCES = -0x7ffffffe, // Permission denied - FAULT = -0x7fffecff, // Bad address - BUSY = -0x7ffffff2, // Device busy - EXIST = -0x7fff9ffe, // File exists - XDEV = -0x7fff9ff5, // Cross-device link - NODEV = -0x7fff8ff9, // Operation not supported by device - NOTDIR = -0x7fff9ffb, // Not a directory - ISDIR = -0x7fff9ff7, // Is a directory - INVAL = -0x7ffffffb, // Invalid argument - NFILE = -0x7fff8ffa, // Too many open files in system - MFILE = -0x7fff9ff6, // Too many open files - NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device - TXTBSY = -0x7fff8fc5, // Text file busy - FBIG = -0x7fff8ffc, // File too large - NOSPC = -0x7fff9ff9, // No space left on device - SPIPE = -0x7fff8ff4, // Illegal seek - ROFS = -0x7fff9ff8, // Read-only filesystem - MLINK = -0x7fff8ffb, // Too many links - PIPE = -0x7fff9ff3, // Broken pipe - BADF = -0x7fffa000, // Bad file descriptor - - // math software - DOM = 33, // Numerical argument out of domain - RANGE = 34, // Result too large - - // non-blocking and interrupt i/o - - /// Also used for `WOULDBLOCK`. - AGAIN = -0x7ffffff5, - INPROGRESS = -0x7fff8fdc, - ALREADY = -0x7fff8fdb, - - // ipc/network software -- argument errors - NOTSOCK = 38, // Socket operation on non-socket - DESTADDRREQ = 39, // Destination address required - MSGSIZE = 40, // Message too long - PROTOTYPE = 41, // Protocol wrong type for socket - NOPROTOOPT = 42, // Protocol not available - PROTONOSUPPORT = 43, // Protocol not supported - SOCKTNOSUPPORT = 44, // Socket type not supported - /// Also used for `NOTSUP`. - OPNOTSUPP = 45, // Operation not supported - PFNOSUPPORT = 46, // Protocol family not supported - AFNOSUPPORT = 47, // Address family not supported by protocol family - ADDRINUSE = 48, // Address already in use - ADDRNOTAVAIL = 49, // Can't assign requested address - - // ipc/network software -- operational errors - NETDOWN = 50, // Network is down - NETUNREACH = 51, // Network is unreachable - NETRESET = 52, // Network dropped connection on reset - CONNABORTED = 53, // Software caused connection abort - CONNRESET = 54, // Connection reset by peer - NOBUFS = 55, // No buffer space available - ISCONN = 56, // Socket is already connected - NOTCONN = 57, // Socket is not connected - SHUTDOWN = 58, // Can't send after socket shutdown - TOOMANYREFS = 59, // Too many references: can't splice - TIMEDOUT = 60, // Operation timed out - CONNREFUSED = 61, // Connection refused - - LOOP = 62, // Too many levels of symbolic links - NAMETOOLONG = 63, // File name too long - - // should be rearranged - HOSTDOWN = 64, // Host is down - HOSTUNREACH = 65, // No route to host - NOTEMPTY = 66, // Directory not empty - - // quotas & mush - PROCLIM = 67, // Too many processes - USERS = 68, // Too many users - DQUOT = 69, // Disc quota exceeded - - // Network File System - STALE = 70, // Stale NFS file handle - REMOTE = 71, // Too many levels of remote in path - BADRPC = 72, // RPC struct is bad - RPCMISMATCH = 73, // RPC version wrong - PROGUNAVAIL = 74, // RPC prog. not avail - PROGMISMATCH = 75, // Program version wrong - PROCUNAVAIL = 76, // Bad procedure for program - - NOLCK = 77, // No locks available - NOSYS = 78, // Function not implemented - - FTYPE = 79, // Inappropriate file type or format - AUTH = 80, // Authentication error - NEEDAUTH = 81, // Need authenticator - IDRM = 82, // Identifier removed - NOMSG = 83, // No message of desired type - OVERFLOW = 84, // Value too large to be stored in data type - CANCELED = 85, // Operation canceled - ILSEQ = 86, // Illegal byte sequence - NOATTR = 87, // Attribute not found - - DOOFUS = 88, // Programming error - - BADMSG = 89, // Bad message - MULTIHOP = 90, // Multihop attempted - NOLINK = 91, // Link has been severed - PROTO = 92, // Protocol error - - NOTCAPABLE = 93, // Capabilities insufficient - CAPMODE = 94, // Not permitted in capability mode - NOTRECOVERABLE = 95, // State not recoverable - OWNERDEAD = 96, // Previous owner died - - _, -}; - -pub const MINSIGSTKSZ = switch (builtin.cpu.arch) { - .i386, .x86_64 => 2048, - .arm, .aarch64 => 4096, - else => @compileError("MINSIGSTKSZ not defined for this architecture"), -}; -pub const SIGSTKSZ = MINSIGSTKSZ + 32768; - -pub const SS_ONSTACK = 1; -pub const SS_DISABLE = 4; - -pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, -}; - -pub const S_IFMT = 0o170000; - -pub const S_IFIFO = 0o010000; -pub const S_IFCHR = 0o020000; -pub const S_IFDIR = 0o040000; -pub const S_IFBLK = 0o060000; -pub const S_IFREG = 0o100000; -pub const S_IFLNK = 0o120000; -pub const S_IFSOCK = 0o140000; -pub const S_IFWHT = 0o160000; - -pub const S_ISUID = 0o4000; -pub const S_ISGID = 0o2000; -pub const S_ISVTX = 0o1000; -pub const S_IRWXU = 0o700; -pub const S_IRUSR = 0o400; -pub const S_IWUSR = 0o200; -pub const S_IXUSR = 0o100; -pub const S_IRWXG = 0o070; -pub const S_IRGRP = 0o040; -pub const S_IWGRP = 0o020; -pub const S_IXGRP = 0o010; -pub const S_IRWXO = 0o007; -pub const S_IROTH = 0o004; -pub const S_IWOTH = 0o002; -pub const S_IXOTH = 0o001; - -pub fn S_ISFIFO(m: u32) bool { - return m & S_IFMT == S_IFIFO; -} - -pub fn S_ISCHR(m: u32) bool { - return m & S_IFMT == S_IFCHR; -} - -pub fn S_ISDIR(m: u32) bool { - return m & S_IFMT == S_IFDIR; -} - -pub fn S_ISBLK(m: u32) bool { - return m & S_IFMT == S_IFBLK; -} - -pub fn S_ISREG(m: u32) bool { - return m & S_IFMT == S_IFREG; -} - -pub fn S_ISLNK(m: u32) bool { - return m & S_IFMT == S_IFLNK; -} - -pub fn S_ISSOCK(m: u32) bool { - return m & S_IFMT == S_IFSOCK; -} - -pub fn S_IWHT(m: u32) bool { - return m & S_IFMT == S_IFWHT; -} - -pub const HOST_NAME_MAX = 255; - -/// Magic value that specify the use of the current working directory -/// to determine the target of relative file paths in the openat() and -/// similar syscalls. -pub const AT_FDCWD = -100; - -/// Check access using effective user and group ID -pub const AT_EACCESS = 0x0100; - -/// Do not follow symbolic links -pub const AT_SYMLINK_NOFOLLOW = 0x0200; - -/// Follow symbolic link -pub const AT_SYMLINK_FOLLOW = 0x0400; - -/// Remove directory instead of file -pub const AT_REMOVEDIR = 0x0800; - -pub const addrinfo = extern struct { - flags: i32, - family: i32, - socktype: i32, - protocol: i32, - addrlen: socklen_t, - canonname: ?[*:0]u8, - addr: ?*sockaddr, - next: ?*addrinfo, -}; - -/// Fail if not under dirfd -pub const AT_BENEATH = 0x1000; - -/// dummy for IP -pub const IPPROTO_IP = 0; - -/// control message protocol -pub const IPPROTO_ICMP = 1; - -/// tcp -pub const IPPROTO_TCP = 6; - -/// user datagram protocol -pub const IPPROTO_UDP = 17; - -/// IP6 header -pub const IPPROTO_IPV6 = 41; - -/// raw IP packet -pub const IPPROTO_RAW = 255; - -/// IP6 hop-by-hop options -pub const IPPROTO_HOPOPTS = 0; - -/// group mgmt protocol -pub const IPPROTO_IGMP = 2; - -/// gateway^2 (deprecated) -pub const IPPROTO_GGP = 3; - -/// IPv4 encapsulation -pub const IPPROTO_IPV4 = 4; - -/// for compatibility -pub const IPPROTO_IPIP = IPPROTO_IPV4; - -/// Stream protocol II -pub const IPPROTO_ST = 7; - -/// exterior gateway protocol -pub const IPPROTO_EGP = 8; - -/// private interior gateway -pub const IPPROTO_PIGP = 9; - -/// BBN RCC Monitoring -pub const IPPROTO_RCCMON = 10; - -/// network voice protocol -pub const IPPROTO_NVPII = 11; - -/// pup -pub const IPPROTO_PUP = 12; - -/// Argus -pub const IPPROTO_ARGUS = 13; - -/// EMCON -pub const IPPROTO_EMCON = 14; - -/// Cross Net Debugger -pub const IPPROTO_XNET = 15; - -/// Chaos -pub const IPPROTO_CHAOS = 16; - -/// Multiplexing -pub const IPPROTO_MUX = 18; - -/// DCN Measurement Subsystems -pub const IPPROTO_MEAS = 19; - -/// Host Monitoring -pub const IPPROTO_HMP = 20; - -/// Packet Radio Measurement -pub const IPPROTO_PRM = 21; - -/// xns idp -pub const IPPROTO_IDP = 22; - -/// Trunk-1 -pub const IPPROTO_TRUNK1 = 23; - -/// Trunk-2 -pub const IPPROTO_TRUNK2 = 24; - -/// Leaf-1 -pub const IPPROTO_LEAF1 = 25; - -/// Leaf-2 -pub const IPPROTO_LEAF2 = 26; - -/// Reliable Data -pub const IPPROTO_RDP = 27; - -/// Reliable Transaction -pub const IPPROTO_IRTP = 28; - -/// tp-4 w/ class negotiation -pub const IPPROTO_TP = 29; - -/// Bulk Data Transfer -pub const IPPROTO_BLT = 30; - -/// Network Services -pub const IPPROTO_NSP = 31; - -/// Merit Internodal -pub const IPPROTO_INP = 32; - -/// Datagram Congestion Control Protocol -pub const IPPROTO_DCCP = 33; - -/// Third Party Connect -pub const IPPROTO_3PC = 34; - -/// InterDomain Policy Routing -pub const IPPROTO_IDPR = 35; - -/// XTP -pub const IPPROTO_XTP = 36; - -/// Datagram Delivery -pub const IPPROTO_DDP = 37; - -/// Control Message Transport -pub const IPPROTO_CMTP = 38; - -/// TP++ Transport -pub const IPPROTO_TPXX = 39; - -/// IL transport protocol -pub const IPPROTO_IL = 40; - -/// Source Demand Routing -pub const IPPROTO_SDRP = 42; - -/// IP6 routing header -pub const IPPROTO_ROUTING = 43; - -/// IP6 fragmentation header -pub const IPPROTO_FRAGMENT = 44; - -/// InterDomain Routing -pub const IPPROTO_IDRP = 45; - -/// resource reservation -pub const IPPROTO_RSVP = 46; - -/// General Routing Encap. -pub const IPPROTO_GRE = 47; - -/// Mobile Host Routing -pub const IPPROTO_MHRP = 48; - -/// BHA -pub const IPPROTO_BHA = 49; - -/// IP6 Encap Sec. Payload -pub const IPPROTO_ESP = 50; - -/// IP6 Auth Header -pub const IPPROTO_AH = 51; - -/// Integ. Net Layer Security -pub const IPPROTO_INLSP = 52; - -/// IP with encryption -pub const IPPROTO_SWIPE = 53; - -/// Next Hop Resolution -pub const IPPROTO_NHRP = 54; - -/// IP Mobility -pub const IPPROTO_MOBILE = 55; - -/// Transport Layer Security -pub const IPPROTO_TLSP = 56; - -/// SKIP -pub const IPPROTO_SKIP = 57; - -/// ICMP6 -pub const IPPROTO_ICMPV6 = 58; - -/// IP6 no next header -pub const IPPROTO_NONE = 59; - -/// IP6 destination option -pub const IPPROTO_DSTOPTS = 60; - -/// any host internal protocol -pub const IPPROTO_AHIP = 61; - -/// CFTP -pub const IPPROTO_CFTP = 62; - -/// "hello" routing protocol -pub const IPPROTO_HELLO = 63; - -/// SATNET/Backroom EXPAK -pub const IPPROTO_SATEXPAK = 64; - -/// Kryptolan -pub const IPPROTO_KRYPTOLAN = 65; - -/// Remote Virtual Disk -pub const IPPROTO_RVD = 66; - -/// Pluribus Packet Core -pub const IPPROTO_IPPC = 67; - -/// Any distributed FS -pub const IPPROTO_ADFS = 68; - -/// Satnet Monitoring -pub const IPPROTO_SATMON = 69; - -/// VISA Protocol -pub const IPPROTO_VISA = 70; - -/// Packet Core Utility -pub const IPPROTO_IPCV = 71; - -/// Comp. Prot. Net. Executive -pub const IPPROTO_CPNX = 72; - -/// Comp. Prot. HeartBeat -pub const IPPROTO_CPHB = 73; - -/// Wang Span Network -pub const IPPROTO_WSN = 74; - -/// Packet Video Protocol -pub const IPPROTO_PVP = 75; - -/// BackRoom SATNET Monitoring -pub const IPPROTO_BRSATMON = 76; - -/// Sun net disk proto (temp.) -pub const IPPROTO_ND = 77; - -/// WIDEBAND Monitoring -pub const IPPROTO_WBMON = 78; - -/// WIDEBAND EXPAK -pub const IPPROTO_WBEXPAK = 79; - -/// ISO cnlp -pub const IPPROTO_EON = 80; - -/// VMTP -pub const IPPROTO_VMTP = 81; - -/// Secure VMTP -pub const IPPROTO_SVMTP = 82; - -/// Banyon VINES -pub const IPPROTO_VINES = 83; - -/// TTP -pub const IPPROTO_TTP = 84; - -/// NSFNET-IGP -pub const IPPROTO_IGP = 85; - -/// dissimilar gateway prot. -pub const IPPROTO_DGP = 86; - -/// TCF -pub const IPPROTO_TCF = 87; - -/// Cisco/GXS IGRP -pub const IPPROTO_IGRP = 88; - -/// OSPFIGP -pub const IPPROTO_OSPFIGP = 89; - -/// Strite RPC protocol -pub const IPPROTO_SRPC = 90; - -/// Locus Address Resoloution -pub const IPPROTO_LARP = 91; - -/// Multicast Transport -pub const IPPROTO_MTP = 92; - -/// AX.25 Frames -pub const IPPROTO_AX25 = 93; - -/// IP encapsulated in IP -pub const IPPROTO_IPEIP = 94; - -/// Mobile Int.ing control -pub const IPPROTO_MICP = 95; - -/// Semaphore Comm. security -pub const IPPROTO_SCCSP = 96; - -/// Ethernet IP encapsulation -pub const IPPROTO_ETHERIP = 97; - -/// encapsulation header -pub const IPPROTO_ENCAP = 98; - -/// any private encr. scheme -pub const IPPROTO_APES = 99; - -/// GMTP -pub const IPPROTO_GMTP = 100; - -/// payload compression (IPComp) -pub const IPPROTO_IPCOMP = 108; - -/// SCTP -pub const IPPROTO_SCTP = 132; - -/// IPv6 Mobility Header -pub const IPPROTO_MH = 135; - -/// UDP-Lite -pub const IPPROTO_UDPLITE = 136; - -/// IP6 Host Identity Protocol -pub const IPPROTO_HIP = 139; - -/// IP6 Shim6 Protocol -pub const IPPROTO_SHIM6 = 140; - -/// Protocol Independent Mcast -pub const IPPROTO_PIM = 103; - -/// CARP -pub const IPPROTO_CARP = 112; - -/// PGM -pub const IPPROTO_PGM = 113; - -/// MPLS-in-IP -pub const IPPROTO_MPLS = 137; - -/// PFSYNC -pub const IPPROTO_PFSYNC = 240; - -/// Reserved -pub const IPPROTO_RESERVED_253 = 253; - -/// Reserved -pub const IPPROTO_RESERVED_254 = 254; - -pub const rlimit_resource = enum(c_int) { - CPU = 0, - FSIZE = 1, - DATA = 2, - STACK = 3, - CORE = 4, - RSS = 5, - MEMLOCK = 6, - NPROC = 7, - NOFILE = 8, - SBSIZE = 9, - VMEM = 10, - NPTS = 11, - SWAP = 12, - KQUEUES = 13, - UMTXP = 14, - _, - - pub const AS: rlimit_resource = .VMEM; -}; - -pub const rlim_t = i64; - -/// No limit -pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -// TODO fill out if needed -pub const directory_which = enum(c_int) { - B_USER_SETTINGS_DIRECTORY = 0xbbe, - - _, -}; - -pub const cc_t = u8; -pub const speed_t = u8; -pub const tcflag_t = u32; - -pub const NCCS = 32; - -pub const termios = extern struct { - c_iflag: tcflag_t, - c_oflag: tcflag_t, - c_cflag: tcflag_t, - c_lflag: tcflag_t, - c_line: cc_t, - c_ispeed: speed_t, - c_ospeed: speed_t, - cc_t: [NCCS]cc_t, -}; diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig deleted file mode 100644 index 653fb8f1e1..0000000000 --- a/lib/std/os/bits/linux.zig +++ /dev/null @@ -1,2455 +0,0 @@ -const std = @import("../../std.zig"); -const maxInt = std.math.maxInt; -const arch = @import("builtin").target.cpu.arch; -pub usingnamespace @import("posix.zig"); - -pub const E = switch (arch) { - .mips, .mipsel => @import("linux/errno/mips.zig").E, - .sparc, .sparcel, .sparcv9 => @import("linux/errno/sparc.zig").E, - else => @import("linux/errno/generic.zig").E, -}; - -pub usingnamespace switch (arch) { - .i386 => @import("linux/i386.zig"), - .x86_64 => @import("linux/x86_64.zig"), - .aarch64 => @import("linux/arm64.zig"), - .arm, .thumb => @import("linux/arm-eabi.zig"), - .riscv64 => @import("linux/riscv64.zig"), - .sparcv9 => @import("linux/sparc64.zig"), - .mips, .mipsel => @import("linux/mips.zig"), - .powerpc => @import("linux/powerpc.zig"), - .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), - else => struct {}, -}; - -pub usingnamespace @import("linux/netlink.zig"); -pub usingnamespace @import("linux/prctl.zig"); -pub usingnamespace @import("linux/securebits.zig"); -pub usingnamespace @import("linux/xdp.zig"); - -const is_mips = arch.isMIPS(); -const is_ppc = arch.isPPC(); -const is_ppc64 = arch.isPPC64(); -const is_sparc = arch.isSPARC(); - -pub const pid_t = i32; -pub const fd_t = i32; -pub const uid_t = u32; -pub const gid_t = u32; -pub const clock_t = isize; - -pub const NAME_MAX = 255; -pub const PATH_MAX = 4096; -pub const IOV_MAX = 1024; - -/// Largest hardware address length -/// e.g. a mac address is a type of hardware address -pub const MAX_ADDR_LEN = 32; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -/// Special value used to indicate openat should use the current working directory -pub const AT_FDCWD = -100; - -/// Do not follow symbolic links -pub const AT_SYMLINK_NOFOLLOW = 0x100; - -/// Remove directory instead of unlinking file -pub const AT_REMOVEDIR = 0x200; - -/// Follow symbolic links. -pub const AT_SYMLINK_FOLLOW = 0x400; - -/// Suppress terminal automount traversal -pub const AT_NO_AUTOMOUNT = 0x800; - -/// Allow empty relative pathname -pub const AT_EMPTY_PATH = 0x1000; - -/// Type of synchronisation required from statx() -pub const AT_STATX_SYNC_TYPE = 0x6000; - -/// - Do whatever stat() does -pub const AT_STATX_SYNC_AS_STAT = 0x0000; - -/// - Force the attributes to be sync'd with the server -pub const AT_STATX_FORCE_SYNC = 0x2000; - -/// - Don't sync attributes with the server -pub const AT_STATX_DONT_SYNC = 0x4000; - -/// Apply to the entire subtree -pub const AT_RECURSIVE = 0x8000; - -/// Default is extend size -pub const FALLOC_FL_KEEP_SIZE = 0x01; - -/// De-allocates range -pub const FALLOC_FL_PUNCH_HOLE = 0x02; - -/// Reserved codepoint -pub const FALLOC_FL_NO_HIDE_STALE = 0x04; - -/// Removes a range of a file without leaving a hole in the file -pub const FALLOC_FL_COLLAPSE_RANGE = 0x08; - -/// Converts a range of file to zeros preferably without issuing data IO -pub const FALLOC_FL_ZERO_RANGE = 0x10; - -/// Inserts space within the file size without overwriting any existing data -pub const FALLOC_FL_INSERT_RANGE = 0x20; - -/// Unshares shared blocks within the file size without overwriting any existing data -pub const FALLOC_FL_UNSHARE_RANGE = 0x40; - -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_WAKE_BITSET = 10; -pub const FUTEX_WAIT_REQUEUE_PI = 11; -pub const FUTEX_CMP_REQUEUE_PI = 12; - -pub const FUTEX_PRIVATE_FLAG = 128; - -pub const FUTEX_CLOCK_REALTIME = 256; - -/// page can not be accessed -pub const PROT_NONE = 0x0; - -/// page can be read -pub const PROT_READ = 0x1; - -/// page can be written -pub const PROT_WRITE = 0x2; - -/// page can be executed -pub const PROT_EXEC = 0x4; - -/// page may be used for atomic ops -pub const PROT_SEM = switch (arch) { - // TODO: also xtensa - .mips, .mipsel, .mips64, .mips64el => 0x10, - else => 0x8, -}; - -/// mprotect flag: extend change to start of growsdown vma -pub const PROT_GROWSDOWN = 0x01000000; - -/// mprotect flag: extend change to end of growsup vma -pub const PROT_GROWSUP = 0x02000000; - -/// Share changes -pub const MAP_SHARED = 0x01; - -/// Changes are private -pub const MAP_PRIVATE = 0x02; - -/// share + validate extension flags -pub const MAP_SHARED_VALIDATE = 0x03; - -/// Mask for type of mapping -pub const MAP_TYPE = 0x0f; - -/// Interpret addr exactly -pub const MAP_FIXED = 0x10; - -/// don't use a file -pub const MAP_ANONYMOUS = if (is_mips) 0x800 else 0x20; - -// MAP_ 0x0100 - 0x4000 flags are per architecture - -/// populate (prefault) pagetables -pub const MAP_POPULATE = if (is_mips) 0x10000 else 0x8000; - -/// do not block on IO -pub const MAP_NONBLOCK = if (is_mips) 0x20000 else 0x10000; - -/// give out an address that is best suited for process/thread stacks -pub const MAP_STACK = if (is_mips) 0x40000 else 0x20000; - -/// create a huge page mapping -pub const MAP_HUGETLB = if (is_mips) 0x80000 else 0x40000; - -/// perform synchronous page faults for the mapping -pub const MAP_SYNC = 0x80000; - -/// MAP_FIXED which doesn't unmap underlying mapping -pub const MAP_FIXED_NOREPLACE = 0x100000; - -/// For anonymous mmap, memory could be uninitialized -pub const MAP_UNINITIALIZED = 0x4000000; - -pub const FD_CLOEXEC = 1; - -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; - -// waitid id types -pub const P = enum(c_uint) { - ALL = 0, - PID = 1, - PGID = 2, - PIDFD = 3, - _, -}; - -pub usingnamespace if (is_mips) - struct { - pub const SA_NOCLDSTOP = 1; - pub const SA_NOCLDWAIT = 0x10000; - pub const SA_SIGINFO = 8; - pub const SA_RESTART = 0x10000000; - pub const SA_RESETHAND = 0x80000000; - pub const SA_ONSTACK = 0x08000000; - pub const SA_NODEFER = 0x40000000; - pub const SA_RESTORER = 0x04000000; - - pub const SIG_BLOCK = 1; - pub const SIG_UNBLOCK = 2; - pub const SIG_SETMASK = 3; - } -else if (is_sparc) - struct { - pub const SA_NOCLDSTOP = 0x8; - pub const SA_NOCLDWAIT = 0x100; - pub const SA_SIGINFO = 0x200; - pub const SA_RESTART = 0x2; - pub const SA_RESETHAND = 0x4; - pub const SA_ONSTACK = 0x1; - pub const SA_NODEFER = 0x20; - pub const SA_RESTORER = 0x04000000; - - pub const SIG_BLOCK = 1; - pub const SIG_UNBLOCK = 2; - pub const SIG_SETMASK = 4; - } -else - struct { - pub const SA_NOCLDSTOP = 1; - pub const SA_NOCLDWAIT = 2; - pub const SA_SIGINFO = 4; - pub const SA_RESTART = 0x10000000; - pub const SA_RESETHAND = 0x80000000; - pub const SA_ONSTACK = 0x08000000; - pub const SA_NODEFER = 0x40000000; - pub const SA_RESTORER = 0x04000000; - - pub const SIG_BLOCK = 0; - pub const SIG_UNBLOCK = 1; - pub const SIG_SETMASK = 2; - }; - -pub usingnamespace if (is_sparc) struct { - pub const SIGHUP = 1; - pub const SIGINT = 2; - pub const SIGQUIT = 3; - pub const SIGILL = 4; - pub const SIGTRAP = 5; - pub const SIGABRT = 6; - pub const SIGEMT = 7; - pub const SIGFPE = 8; - pub const SIGKILL = 9; - pub const SIGBUS = 10; - pub const SIGSEGV = 11; - pub const SIGSYS = 12; - pub const SIGPIPE = 13; - pub const SIGALRM = 14; - pub const SIGTERM = 15; - pub const SIGURG = 16; - pub const SIGSTOP = 17; - pub const SIGTSTP = 18; - pub const SIGCONT = 19; - pub const SIGCHLD = 20; - pub const SIGTTIN = 21; - pub const SIGTTOU = 22; - pub const SIGPOLL = 23; - pub const SIGXCPU = 24; - pub const SIGXFSZ = 25; - pub const SIGVTALRM = 26; - pub const SIGPROF = 27; - pub const SIGWINCH = 28; - pub const SIGLOST = 29; - pub const SIGUSR1 = 30; - pub const SIGUSR2 = 31; - pub const SIGIOT = SIGABRT; - pub const SIGCLD = SIGCHLD; - pub const SIGPWR = SIGLOST; - pub const SIGIO = SIGPOLL; -} else struct { - 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 kernel_rwf = u32; - -/// high priority request, poll if possible -pub const RWF_HIPRI: kernel_rwf = 0x00000001; - -/// per-IO O_DSYNC -pub const RWF_DSYNC: kernel_rwf = 0x00000002; - -/// per-IO O_SYNC -pub const RWF_SYNC: kernel_rwf = 0x00000004; - -/// per-IO, return -EAGAIN if operation would block -pub const RWF_NOWAIT: kernel_rwf = 0x00000008; - -/// per-IO O_APPEND -pub const RWF_APPEND: kernel_rwf = 0x00000010; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -pub const SOCK_STREAM = if (is_mips) 2 else 1; -pub const SOCK_DGRAM = if (is_mips) 1 else 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 = if (is_mips) 0o200 else 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_XDP = 44; -pub const PF_MAX = 45; - -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_XDP = PF_XDP; -pub const AF_MAX = PF_MAX; - -pub usingnamespace if (is_mips) - struct {} -else if (is_ppc or is_ppc64) - struct { - 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_RCVLOWAT = 16; - pub const SO_SNDLOWAT = 17; - pub const SO_RCVTIMEO = 18; - pub const SO_SNDTIMEO = 19; - pub const SO_PASSCRED = 20; - pub const SO_PEERCRED = 21; - pub const SO_ACCEPTCONN = 30; - pub const SO_PEERSEC = 31; - pub const SO_SNDBUFFORCE = 32; - pub const SO_RCVBUFFORCE = 33; - pub const SO_PROTOCOL = 38; - pub const SO_DOMAIN = 39; - } -else - struct { - 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_PEERSEC = 31; - 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_OLD = 29; -pub const SO_PASSSEC = 34; -pub const SO_TIMESTAMPNS_OLD = 35; -pub const SO_MARK = 36; -pub const SO_TIMESTAMPING_OLD = 37; - -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 SO_TXTIME = 61; -pub const SCM_TXTIME = SO_TXTIME; -pub const SO_BINDTOIFINDEX = 62; -pub const SO_TIMESTAMP_NEW = 63; -pub const SO_TIMESTAMPNS_NEW = 64; -pub const SO_TIMESTAMPING_NEW = 65; -pub const SO_RCVTIMEO_NEW = 66; -pub const SO_SNDTIMEO_NEW = 67; -pub const SO_DETACH_REUSEPORT_BPF = 68; - -pub const SOL_SOCKET = if (is_mips) 65535 else 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 SOL_XDP = 283; - -pub const SOMAXCONN = 128; - -pub const IP_TOS = 1; -pub const IP_TTL = 2; -pub const IP_HDRINCL = 3; -pub const IP_OPTIONS = 4; -pub const IP_ROUTER_ALERT = 5; -pub const IP_RECVOPTS = 6; -pub const IP_RETOPTS = 7; -pub const IP_PKTINFO = 8; -pub const IP_PKTOPTIONS = 9; -pub const IP_PMTUDISC = 10; -pub const IP_MTU_DISCOVER = 10; -pub const IP_RECVERR = 11; -pub const IP_RECVTTL = 12; -pub const IP_RECVTOS = 13; -pub const IP_MTU = 14; -pub const IP_FREEBIND = 15; -pub const IP_IPSEC_POLICY = 16; -pub const IP_XFRM_POLICY = 17; -pub const IP_PASSSEC = 18; -pub const IP_TRANSPARENT = 19; -pub const IP_ORIGDSTADDR = 20; -pub const IP_RECVORIGDSTADDR = IP_ORIGDSTADDR; -pub const IP_MINTTL = 21; -pub const IP_NODEFRAG = 22; -pub const IP_CHECKSUM = 23; -pub const IP_BIND_ADDRESS_NO_PORT = 24; -pub const IP_RECVFRAGSIZE = 25; -pub const IP_MULTICAST_IF = 32; -pub const IP_MULTICAST_TTL = 33; -pub const IP_MULTICAST_LOOP = 34; -pub const IP_ADD_MEMBERSHIP = 35; -pub const IP_DROP_MEMBERSHIP = 36; -pub const IP_UNBLOCK_SOURCE = 37; -pub const IP_BLOCK_SOURCE = 38; -pub const IP_ADD_SOURCE_MEMBERSHIP = 39; -pub const IP_DROP_SOURCE_MEMBERSHIP = 40; -pub const IP_MSFILTER = 41; -pub const IP_MULTICAST_ALL = 49; -pub const IP_UNICAST_IF = 50; - -pub const IP_RECVRETOPTS = IP_RETOPTS; - -pub const IP_PMTUDISC_DONT = 0; -pub const IP_PMTUDISC_WANT = 1; -pub const IP_PMTUDISC_DO = 2; -pub const IP_PMTUDISC_PROBE = 3; -pub const IP_PMTUDISC_INTERFACE = 4; -pub const IP_PMTUDISC_OMIT = 5; - -pub const IP_DEFAULT_MULTICAST_TTL = 1; -pub const IP_DEFAULT_MULTICAST_LOOP = 1; -pub const IP_MAX_MEMBERSHIPS = 20; - -// IPv6 socket options - -pub const IPV6_ADDRFORM = 1; -pub const IPV6_2292PKTINFO = 2; -pub const IPV6_2292HOPOPTS = 3; -pub const IPV6_2292DSTOPTS = 4; -pub const IPV6_2292RTHDR = 5; -pub const IPV6_2292PKTOPTIONS = 6; -pub const IPV6_CHECKSUM = 7; -pub const IPV6_2292HOPLIMIT = 8; -pub const IPV6_NEXTHOP = 9; -pub const IPV6_AUTHHDR = 10; -pub const IPV6_FLOWINFO = 11; - -pub const IPV6_UNICAST_HOPS = 16; -pub const IPV6_MULTICAST_IF = 17; -pub const IPV6_MULTICAST_HOPS = 18; -pub const IPV6_MULTICAST_LOOP = 19; -pub const IPV6_ADD_MEMBERSHIP = 20; -pub const IPV6_DROP_MEMBERSHIP = 21; -pub const IPV6_ROUTER_ALERT = 22; -pub const IPV6_MTU_DISCOVER = 23; -pub const IPV6_MTU = 24; -pub const IPV6_RECVERR = 25; -pub const IPV6_V6ONLY = 26; -pub const IPV6_JOIN_ANYCAST = 27; -pub const IPV6_LEAVE_ANYCAST = 28; - -// IPV6_MTU_DISCOVER values -pub const IPV6_PMTUDISC_DONT = 0; -pub const IPV6_PMTUDISC_WANT = 1; -pub const IPV6_PMTUDISC_DO = 2; -pub const IPV6_PMTUDISC_PROBE = 3; -pub const IPV6_PMTUDISC_INTERFACE = 4; -pub const IPV6_PMTUDISC_OMIT = 5; - -// Flowlabel -pub const IPV6_FLOWLABEL_MGR = 32; -pub const IPV6_FLOWINFO_SEND = 33; -pub const IPV6_IPSEC_POLICY = 34; -pub const IPV6_XFRM_POLICY = 35; -pub const IPV6_HDRINCL = 36; - -// Advanced API (RFC3542) (1) -pub const IPV6_RECVPKTINFO = 49; -pub const IPV6_PKTINFO = 50; -pub const IPV6_RECVHOPLIMIT = 51; -pub const IPV6_HOPLIMIT = 52; -pub const IPV6_RECVHOPOPTS = 53; -pub const IPV6_HOPOPTS = 54; -pub const IPV6_RTHDRDSTOPTS = 55; -pub const IPV6_RECVRTHDR = 56; -pub const IPV6_RTHDR = 57; -pub const IPV6_RECVDSTOPTS = 58; -pub const IPV6_DSTOPTS = 59; -pub const IPV6_RECVPATHMTU = 60; -pub const IPV6_PATHMTU = 61; -pub const IPV6_DONTFRAG = 62; - -// Advanced API (RFC3542) (2) -pub const IPV6_RECVTCLASS = 66; -pub const IPV6_TCLASS = 67; - -pub const IPV6_AUTOFLOWLABEL = 70; - -// RFC5014: Source address selection -pub const IPV6_ADDR_PREFERENCES = 72; - -pub const IPV6_PREFER_SRC_TMP = 0x0001; -pub const IPV6_PREFER_SRC_PUBLIC = 0x0002; -pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x0100; -pub const IPV6_PREFER_SRC_COA = 0x0004; -pub const IPV6_PREFER_SRC_HOME = 0x0400; -pub const IPV6_PREFER_SRC_CGA = 0x0008; -pub const IPV6_PREFER_SRC_NONCGA = 0x0800; - -// RFC5082: Generalized Ttl Security Mechanism -pub const IPV6_MINHOPCOUNT = 73; - -pub const IPV6_ORIGDSTADDR = 74; -pub const IPV6_RECVORIGDSTADDR = IPV6_ORIGDSTADDR; -pub const IPV6_TRANSPARENT = 75; -pub const IPV6_UNICAST_IF = 76; -pub const IPV6_RECVFRAGSIZE = 77; -pub const IPV6_FREEBIND = 78; - -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 = if (is_mips) 0x540D else 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 = if (is_mips) 0x7472 else 0x5411; -pub const TIOCSTI = 0x5412; -pub const TIOCGWINSZ = if (is_mips or is_ppc64) 0x40087468 else 0x5413; -pub const TIOCSWINSZ = if (is_mips or is_ppc64) 0x80087467 else 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 = if (is_mips) 0x467F else 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 = if (is_mips) 0x004 else 0x100; -pub const EPOLLWRBAND = if (is_mips) 0x100 else 0x200; -pub const EPOLLMSG = 0x400; -pub const EPOLLERR = 0x008; -pub const EPOLLHUP = 0x010; -pub const EPOLLRDHUP = 0x2000; -pub const EPOLLEXCLUSIVE = (@as(u32, 1) << 28); -pub const EPOLLWAKEUP = (@as(u32, 1) << 29); -pub const EPOLLONESHOT = (@as(u32, 1) << 30); -pub const EPOLLET = (@as(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_PIDFD = 0x00001000; -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; - -// Flags for the clone3() syscall. - -/// Clear any signal handler and reset to SIG_DFL. -pub const CLONE_CLEAR_SIGHAND = 0x100000000; -/// Clone into a specific cgroup given the right permissions. -pub const CLONE_INTO_CGROUP = 0x200000000; - -// cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only. - -/// New time namespace -pub const CLONE_NEWTIME = 0x00000080; - -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 UTIME_NOW = 0x3fffffff; -pub const UTIME_OMIT = 0x3ffffffe; - -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); - -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, (s & 0xff00) >> 8); -} -pub fn WTERMSIG(s: u32) u32 { - return s & 0x7f; -} -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} -pub fn WIFSTOPPED(s: u32) bool { - return @intCast(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00; -} -pub fn WIFSIGNALED(s: u32) bool { - return (s & 0xffff) -% 1 < 0xff; -} - -pub const winsize = extern struct { - ws_row: u16, - ws_col: u16, - ws_xpixel: u16, - ws_ypixel: u16, -}; - -/// NSIG is the total number of signals defined. -/// As signal numbers are sequential, NSIG is one greater than the largest defined signal number. -pub const NSIG = if (is_mips) 128 else 65; - -pub const sigset_t = [1024 / 32]u32; - -pub const all_mask: sigset_t = [_]u32{0xffffffff} ** sigset_t.len; -pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; - -pub const k_sigaction = switch (arch) { - .mips, .mipsel => extern struct { - flags: c_uint, - handler: ?fn (c_int) callconv(.C) void, - mask: [4]c_ulong, - restorer: fn () callconv(.C) void, - }, - .mips64, .mips64el => extern struct { - flags: c_uint, - handler: ?fn (c_int) callconv(.C) void, - mask: [2]c_ulong, - restorer: fn () callconv(.C) void, - }, - else => extern struct { - handler: ?fn (c_int) callconv(.C) void, - flags: c_ulong, - restorer: fn () callconv(.C) void, - mask: [2]c_uint, - }, -}; - -/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. -pub const Sigaction = extern struct { - pub const handler_fn = fn (c_int) callconv(.C) void; - pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; - - handler: extern union { - handler: ?handler_fn, - sigaction: ?sigaction_fn, - }, - mask: sigset_t, - flags: c_uint, - restorer: ?fn () callconv(.C) void = null, -}; - -pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); -pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); -pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); - -pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len; - -pub const SFD_CLOEXEC = O_CLOEXEC; -pub const SFD_NONBLOCK = O_NONBLOCK; - -pub const signalfd_siginfo = extern struct { - signo: u32, - errno: i32, - code: i32, - pid: u32, - uid: uid_t, - fd: i32, - tid: u32, - band: u32, - overrun: u32, - trapno: u32, - status: i32, - int: i32, - ptr: u64, - utime: u64, - stime: u64, - addr: u64, - addr_lsb: u16, - __pad2: u16, - syscall: i32, - call_addr: u64, - arch: u32, - __pad: [28]u8, -}; - -pub const in_port_t = u16; -pub const sa_family_t = u16; -pub const socklen_t = u32; - -pub const sockaddr = extern struct { - family: sa_family_t, - data: [14]u8, -}; - -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; - -/// IPv4 socket address -pub const sockaddr_in = extern struct { - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -/// IPv6 socket address -pub const sockaddr_in6 = extern struct { - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -/// UNIX domain socket address -pub const sockaddr_un = extern struct { - family: sa_family_t = AF_UNIX, - path: [108]u8, -}; - -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 = switch (arch) { - .x86_64 => packed struct { - events: u32, - data: epoll_data, - }, - else => extern 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(x: u8) bool { - return x >= 0 and x <= CAP_LAST_CAP; -} - -pub fn CAP_TO_MASK(cap: u8) u32 { - return @as(u32, 1) << @intCast(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 fn reclen(self: dirent64) u16 { - return self.d_reclen; - } -}; - -pub const dl_phdr_info = extern struct { - dlpi_addr: usize, - dlpi_name: ?[*:0]const u8, - dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: u16, -}; - -pub const CPU_SETSIZE = 128; -pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; -pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); - -pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { - var sum: cpu_count_t = 0; - for (set) |x| { - sum += @popCount(usize, x); - } - return sum; -} - -// TODO port these over -//#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) -//#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set) -//#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set) -//#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2) -//#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2) -//#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2) -//#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set) -//#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) -//#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2) - -pub const MINSIGSTKSZ = switch (arch) { - .i386, .x86_64, .arm, .mipsel => 2048, - .aarch64 => 5120, - else => @compileError("MINSIGSTKSZ not defined for this architecture"), -}; -pub const SIGSTKSZ = switch (arch) { - .i386, .x86_64, .arm, .mipsel => 8192, - .aarch64 => 16384, - else => @compileError("SIGSTKSZ not defined for this architecture"), -}; - -pub const SS_ONSTACK = 1; -pub const SS_DISABLE = 2; -pub const SS_AUTODISARM = 1 << 31; - -pub const stack_t = if (is_mips) - // IRIX compatible stack_t - extern struct { - ss_sp: [*]u8, - ss_size: usize, - ss_flags: i32, - } -else - extern struct { - ss_sp: [*]u8, - ss_flags: i32, - ss_size: usize, - }; - -pub const sigval = extern union { - int: i32, - ptr: *c_void, -}; - -const siginfo_fields_union = extern union { - pad: [128 - 2 * @sizeOf(c_int) - @sizeOf(c_long)]u8, - common: extern struct { - first: extern union { - piduid: extern struct { - pid: pid_t, - uid: uid_t, - }, - timer: extern struct { - timerid: i32, - overrun: i32, - }, - }, - second: extern union { - value: sigval, - sigchld: extern struct { - status: i32, - utime: clock_t, - stime: clock_t, - }, - }, - }, - sigfault: extern struct { - addr: *c_void, - addr_lsb: i16, - first: extern union { - addr_bnd: extern struct { - lower: *c_void, - upper: *c_void, - }, - pkey: u32, - }, - }, - sigpoll: extern struct { - band: isize, - fd: i32, - }, - sigsys: extern struct { - call_addr: *c_void, - syscall: i32, - arch: u32, - }, -}; - -pub const siginfo_t = if (is_mips) - extern struct { - signo: i32, - code: i32, - errno: i32, - fields: siginfo_fields_union, - } -else - extern struct { - signo: i32, - errno: i32, - code: i32, - fields: siginfo_fields_union, - }; - -pub const io_uring_params = extern struct { - sq_entries: u32, - cq_entries: u32, - flags: u32, - sq_thread_cpu: u32, - sq_thread_idle: u32, - features: u32, - wq_fd: u32, - resv: [3]u32, - sq_off: io_sqring_offsets, - cq_off: io_cqring_offsets, -}; - -// io_uring_params.features flags - -pub const IORING_FEAT_SINGLE_MMAP = 1 << 0; -pub const IORING_FEAT_NODROP = 1 << 1; -pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2; -pub const IORING_FEAT_RW_CUR_POS = 1 << 3; -pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4; -pub const IORING_FEAT_FAST_POLL = 1 << 5; -pub const IORING_FEAT_POLL_32BITS = 1 << 6; - -// io_uring_params.flags - -/// io_context is polled -pub const IORING_SETUP_IOPOLL = 1 << 0; - -/// SQ poll thread -pub const IORING_SETUP_SQPOLL = 1 << 1; - -/// sq_thread_cpu is valid -pub const IORING_SETUP_SQ_AFF = 1 << 2; - -/// app defines CQ size -pub const IORING_SETUP_CQSIZE = 1 << 3; - -/// clamp SQ/CQ ring sizes -pub const IORING_SETUP_CLAMP = 1 << 4; - -/// attach to existing wq -pub const IORING_SETUP_ATTACH_WQ = 1 << 5; - -/// start with ring disabled -pub const IORING_SETUP_R_DISABLED = 1 << 6; - -pub const io_sqring_offsets = extern struct { - /// offset of ring head - head: u32, - - /// offset of ring tail - tail: u32, - - /// ring mask value - ring_mask: u32, - - /// entries in ring - ring_entries: u32, - - /// ring flags - flags: u32, - - /// number of sqes not submitted - dropped: u32, - - /// sqe index array - array: u32, - - resv1: u32, - resv2: u64, -}; - -// io_sqring_offsets.flags - -/// needs io_uring_enter wakeup -pub const IORING_SQ_NEED_WAKEUP = 1 << 0; - -/// kernel has cqes waiting beyond the cq ring -pub const IORING_SQ_CQ_OVERFLOW = 1 << 1; - -pub const io_cqring_offsets = extern struct { - head: u32, - tail: u32, - ring_mask: u32, - ring_entries: u32, - overflow: u32, - cqes: u32, - resv: [2]u64, -}; - -pub const io_uring_sqe = extern struct { - opcode: IORING_OP, - flags: u8, - ioprio: u16, - fd: i32, - off: u64, - addr: u64, - len: u32, - rw_flags: u32, - user_data: u64, - buf_index: u16, - personality: u16, - splice_fd_in: i32, - __pad2: [2]u64, -}; - -pub const IOSQE_BIT = enum(u8) { - FIXED_FILE, - IO_DRAIN, - IO_LINK, - IO_HARDLINK, - ASYNC, - BUFFER_SELECT, - - _, -}; - -// io_uring_sqe.flags - -/// use fixed fileset -pub const IOSQE_FIXED_FILE = 1 << @enumToInt(IOSQE_BIT.FIXED_FILE); - -/// issue after inflight IO -pub const IOSQE_IO_DRAIN = 1 << @enumToInt(IOSQE_BIT.IO_DRAIN); - -/// links next sqe -pub const IOSQE_IO_LINK = 1 << @enumToInt(IOSQE_BIT.IO_LINK); - -/// like LINK, but stronger -pub const IOSQE_IO_HARDLINK = 1 << @enumToInt(IOSQE_BIT.IO_HARDLINK); - -/// always go async -pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC); - -/// select buffer from buf_group -pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT); - -pub const IORING_OP = enum(u8) { - NOP, - READV, - WRITEV, - FSYNC, - READ_FIXED, - WRITE_FIXED, - POLL_ADD, - POLL_REMOVE, - SYNC_FILE_RANGE, - SENDMSG, - RECVMSG, - TIMEOUT, - TIMEOUT_REMOVE, - ACCEPT, - ASYNC_CANCEL, - LINK_TIMEOUT, - CONNECT, - FALLOCATE, - OPENAT, - CLOSE, - FILES_UPDATE, - STATX, - READ, - WRITE, - FADVISE, - MADVISE, - SEND, - RECV, - OPENAT2, - EPOLL_CTL, - SPLICE, - PROVIDE_BUFFERS, - REMOVE_BUFFERS, - TEE, - - _, -}; - -// io_uring_sqe.fsync_flags -pub const IORING_FSYNC_DATASYNC = 1 << 0; - -// io_uring_sqe.timeout_flags -pub const IORING_TIMEOUT_ABS = 1 << 0; - -// IO completion data structure (Completion Queue Entry) -pub const io_uring_cqe = extern struct { - /// io_uring_sqe.data submission passed back - user_data: u64, - - /// result code for this event - res: i32, - flags: u32, - - pub fn err(self: io_uring_cqe) E { - if (self.res > -4096 and self.res < 0) { - return @intToEnum(E, -self.res); - } - return .SUCCESS; - } -}; - -// io_uring_cqe.flags - -/// If set, the upper 16 bits are the buffer ID -pub const IORING_CQE_F_BUFFER = 1 << 0; - -pub const IORING_OFF_SQ_RING = 0; -pub const IORING_OFF_CQ_RING = 0x8000000; -pub const IORING_OFF_SQES = 0x10000000; - -// io_uring_enter flags -pub const IORING_ENTER_GETEVENTS = 1 << 0; -pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; - -// io_uring_register opcodes and arguments -pub const IORING_REGISTER = enum(u8) { - REGISTER_BUFFERS, - UNREGISTER_BUFFERS, - REGISTER_FILES, - UNREGISTER_FILES, - REGISTER_EVENTFD, - UNREGISTER_EVENTFD, - REGISTER_FILES_UPDATE, - REGISTER_EVENTFD_ASYNC, - REGISTER_PROBE, - REGISTER_PERSONALITY, - UNREGISTER_PERSONALITY, - REGISTER_RESTRICTIONS, - REGISTER_ENABLE_RINGS, - - _, -}; - -pub const io_uring_files_update = extern struct { - offset: u32, - resv: u32, - fds: u64, -}; - -pub const IO_URING_OP_SUPPORTED = 1 << 0; - -pub const io_uring_probe_op = extern struct { - op: IORING_OP, - - resv: u8, - - /// IO_URING_OP_* flags - flags: u16, - - resv2: u32, -}; - -pub const io_uring_probe = extern struct { - /// last opcode supported - last_op: IORING_OP, - - /// Number of io_uring_probe_op following - ops_len: u8, - - resv: u16, - resv2: u32[3], - - // Followed by up to `ops_len` io_uring_probe_op structures -}; - -pub const io_uring_restriction = extern struct { - opcode: u16, - arg: extern union { - /// IORING_RESTRICTION_REGISTER_OP - register_op: IORING_REGISTER, - - /// IORING_RESTRICTION_SQE_OP - sqe_op: IORING_OP, - - /// IORING_RESTRICTION_SQE_FLAGS_* - sqe_flags: u8, - }, - resv: u8, - resv2: u32[3], -}; - -/// io_uring_restriction->opcode values -pub const IORING_RESTRICTION = enum(u8) { - /// Allow an io_uring_register(2) opcode - REGISTER_OP = 0, - - /// Allow an sqe opcode - SQE_OP = 1, - - /// Allow sqe flags - SQE_FLAGS_ALLOWED = 2, - - /// Require sqe flags (these flags must be set on each submission) - SQE_FLAGS_REQUIRED = 3, - - _, -}; - -pub const utsname = extern struct { - sysname: [64:0]u8, - nodename: [64:0]u8, - release: [64:0]u8, - version: [64:0]u8, - machine: [64:0]u8, - domainname: [64:0]u8, -}; -pub const HOST_NAME_MAX = 64; - -pub const STATX_TYPE = 0x0001; -pub const STATX_MODE = 0x0002; -pub const STATX_NLINK = 0x0004; -pub const STATX_UID = 0x0008; -pub const STATX_GID = 0x0010; -pub const STATX_ATIME = 0x0020; -pub const STATX_MTIME = 0x0040; -pub const STATX_CTIME = 0x0080; -pub const STATX_INO = 0x0100; -pub const STATX_SIZE = 0x0200; -pub const STATX_BLOCKS = 0x0400; -pub const STATX_BASIC_STATS = 0x07ff; - -pub const STATX_BTIME = 0x0800; - -pub const STATX_ATTR_COMPRESSED = 0x0004; -pub const STATX_ATTR_IMMUTABLE = 0x0010; -pub const STATX_ATTR_APPEND = 0x0020; -pub const STATX_ATTR_NODUMP = 0x0040; -pub const STATX_ATTR_ENCRYPTED = 0x0800; -pub const STATX_ATTR_AUTOMOUNT = 0x1000; - -pub const statx_timestamp = extern struct { - tv_sec: i64, - tv_nsec: u32, - __pad1: u32, -}; - -/// Renamed to `Statx` to not conflict with the `statx` function. -pub const Statx = extern struct { - /// Mask of bits indicating filled fields - mask: u32, - - /// Block size for filesystem I/O - blksize: u32, - - /// Extra file attribute indicators - attributes: u64, - - /// Number of hard links - nlink: u32, - - /// User ID of owner - uid: uid_t, - - /// Group ID of owner - gid: gid_t, - - /// File type and mode - mode: u16, - __pad1: u16, - - /// Inode number - ino: u64, - - /// Total size in bytes - size: u64, - - /// Number of 512B blocks allocated - blocks: u64, - - /// Mask to show what's supported in `attributes`. - attributes_mask: u64, - - /// Last access file timestamp - atime: statx_timestamp, - - /// Creation file timestamp - btime: statx_timestamp, - - /// Last status change file timestamp - ctime: statx_timestamp, - - /// Last modification file timestamp - mtime: statx_timestamp, - - /// Major ID, if this file represents a device. - rdev_major: u32, - - /// Minor ID, if this file represents a device. - rdev_minor: u32, - - /// Major ID of the device containing the filesystem where this file resides. - dev_major: u32, - - /// Minor ID of the device containing the filesystem where this file resides. - dev_minor: u32, - - __pad2: [14]u64, -}; - -pub const addrinfo = extern struct { - flags: i32, - family: i32, - socktype: i32, - protocol: i32, - addrlen: socklen_t, - addr: ?*sockaddr, - canonname: ?[*:0]u8, - next: ?*addrinfo, -}; - -pub const IPPORT_RESERVED = 1024; - -pub const IPPROTO_IP = 0; -pub const IPPROTO_HOPOPTS = 0; -pub const IPPROTO_ICMP = 1; -pub const IPPROTO_IGMP = 2; -pub const IPPROTO_IPIP = 4; -pub const IPPROTO_TCP = 6; -pub const IPPROTO_EGP = 8; -pub const IPPROTO_PUP = 12; -pub const IPPROTO_UDP = 17; -pub const IPPROTO_IDP = 22; -pub const IPPROTO_TP = 29; -pub const IPPROTO_DCCP = 33; -pub const IPPROTO_IPV6 = 41; -pub const IPPROTO_ROUTING = 43; -pub const IPPROTO_FRAGMENT = 44; -pub const IPPROTO_RSVP = 46; -pub const IPPROTO_GRE = 47; -pub const IPPROTO_ESP = 50; -pub const IPPROTO_AH = 51; -pub const IPPROTO_ICMPV6 = 58; -pub const IPPROTO_NONE = 59; -pub const IPPROTO_DSTOPTS = 60; -pub const IPPROTO_MTP = 92; -pub const IPPROTO_BEETPH = 94; -pub const IPPROTO_ENCAP = 98; -pub const IPPROTO_PIM = 103; -pub const IPPROTO_COMP = 108; -pub const IPPROTO_SCTP = 132; -pub const IPPROTO_MH = 135; -pub const IPPROTO_UDPLITE = 136; -pub const IPPROTO_MPLS = 137; -pub const IPPROTO_RAW = 255; -pub const IPPROTO_MAX = 256; - -pub const RR_A = 1; -pub const RR_CNAME = 5; -pub const RR_AAAA = 28; - -/// Turn off Nagle's algorithm -pub const TCP_NODELAY = 1; -/// Limit MSS -pub const TCP_MAXSEG = 2; -/// Never send partially complete segments. -pub const TCP_CORK = 3; -/// Start keeplives after this period, in seconds -pub const TCP_KEEPIDLE = 4; -/// Interval between keepalives -pub const TCP_KEEPINTVL = 5; -/// Number of keepalives before death -pub const TCP_KEEPCNT = 6; -/// Number of SYN retransmits -pub const TCP_SYNCNT = 7; -/// Life time of orphaned FIN-WAIT-2 state -pub const TCP_LINGER2 = 8; -/// Wake up listener only when data arrive -pub const TCP_DEFER_ACCEPT = 9; -/// Bound advertised window -pub const TCP_WINDOW_CLAMP = 10; -/// Information about this connection. -pub const TCP_INFO = 11; -/// Block/reenable quick acks -pub const TCP_QUICKACK = 12; -/// Congestion control algorithm -pub const TCP_CONGESTION = 13; -/// TCP MD5 Signature (RFC2385) -pub const TCP_MD5SIG = 14; -/// Use linear timeouts for thin streams -pub const TCP_THIN_LINEAR_TIMEOUTS = 16; -/// Fast retrans. after 1 dupack -pub const TCP_THIN_DUPACK = 17; -/// How long for loss retry before timeout -pub const TCP_USER_TIMEOUT = 18; -/// TCP sock is under repair right now -pub const TCP_REPAIR = 19; -pub const TCP_REPAIR_QUEUE = 20; -pub const TCP_QUEUE_SEQ = 21; -pub const TCP_REPAIR_OPTIONS = 22; -/// Enable FastOpen on listeners -pub const TCP_FASTOPEN = 23; -pub const TCP_TIMESTAMP = 24; -/// limit number of unsent bytes in write queue -pub const TCP_NOTSENT_LOWAT = 25; -/// Get Congestion Control (optional) info -pub const TCP_CC_INFO = 26; -/// Record SYN headers for new connections -pub const TCP_SAVE_SYN = 27; -/// Get SYN headers recorded for connection -pub const TCP_SAVED_SYN = 28; -/// Get/set window parameters -pub const TCP_REPAIR_WINDOW = 29; -/// Attempt FastOpen with connect -pub const TCP_FASTOPEN_CONNECT = 30; -/// Attach a ULP to a TCP connection -pub const TCP_ULP = 31; -/// TCP MD5 Signature with extensions -pub const TCP_MD5SIG_EXT = 32; -/// Set the key for Fast Open (cookie) -pub const TCP_FASTOPEN_KEY = 33; -/// Enable TFO without a TFO cookie -pub const TCP_FASTOPEN_NO_COOKIE = 34; -pub const TCP_ZEROCOPY_RECEIVE = 35; -/// Notify bytes available to read as a cmsg on read -pub const TCP_INQ = 36; -pub const TCP_CM_INQ = TCP_INQ; -/// delay outgoing packets by XX usec -pub const TCP_TX_DELAY = 37; - -pub const TCP_REPAIR_ON = 1; -pub const TCP_REPAIR_OFF = 0; -/// Turn off without window probes -pub const TCP_REPAIR_OFF_NO_WP = -1; - -pub const tcp_repair_opt = extern struct { - opt_code: u32, - opt_val: u32, -}; - -pub const tcp_repair_window = extern struct { - snd_wl1: u32, - snd_wnd: u32, - max_window: u32, - rcv_wnd: u32, - rcv_wup: u32, -}; - -pub const TcpRepairOption = enum { - TCP_NO_QUEUE, - TCP_RECV_QUEUE, - TCP_SEND_QUEUE, - TCP_QUEUES_NR, -}; - -/// why fastopen failed from client perspective -pub const tcp_fastopen_client_fail = enum { - /// catch-all - TFO_STATUS_UNSPEC, - /// if not in TFO_CLIENT_NO_COOKIE mode - TFO_COOKIE_UNAVAILABLE, - /// SYN-ACK did not ack SYN data - TFO_DATA_NOT_ACKED, - /// SYN-ACK did not ack SYN data after timeout - TFO_SYN_RETRANSMITTED, -}; - -/// for TCP_INFO socket option -pub const TCPI_OPT_TIMESTAMPS = 1; -pub const TCPI_OPT_SACK = 2; -pub const TCPI_OPT_WSCALE = 4; -/// ECN was negociated at TCP session init -pub const TCPI_OPT_ECN = 8; -/// we received at least one packet with ECT -pub const TCPI_OPT_ECN_SEEN = 16; -/// SYN-ACK acked data in SYN sent or rcvd -pub const TCPI_OPT_SYN_DATA = 32; - -pub const nfds_t = usize; -pub const pollfd = extern struct { - fd: fd_t, - events: i16, - revents: i16, -}; - -pub const POLLIN = 0x001; -pub const POLLPRI = 0x002; -pub const POLLOUT = 0x004; -pub const POLLERR = 0x008; -pub const POLLHUP = 0x010; -pub const POLLNVAL = 0x020; -pub const POLLRDNORM = 0x040; -pub const POLLRDBAND = 0x080; - -pub const MFD_CLOEXEC = 0x0001; -pub const MFD_ALLOW_SEALING = 0x0002; -pub const MFD_HUGETLB = 0x0004; -pub const MFD_ALL_FLAGS = MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB; - -pub const HUGETLB_FLAG_ENCODE_SHIFT = 26; -pub const HUGETLB_FLAG_ENCODE_MASK = 0x3f; -pub const HUGETLB_FLAG_ENCODE_64KB = 16 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_512KB = 19 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_1MB = 20 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_2MB = 21 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_8MB = 23 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_16MB = 24 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_32MB = 25 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_256MB = 28 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_512MB = 29 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_1GB = 30 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_2GB = 31 << HUGETLB_FLAG_ENCODE_SHIFT; -pub const HUGETLB_FLAG_ENCODE_16GB = 34 << HUGETLB_FLAG_ENCODE_SHIFT; - -pub const MFD_HUGE_SHIFT = HUGETLB_FLAG_ENCODE_SHIFT; -pub const MFD_HUGE_MASK = HUGETLB_FLAG_ENCODE_MASK; -pub const MFD_HUGE_64KB = HUGETLB_FLAG_ENCODE_64KB; -pub const MFD_HUGE_512KB = HUGETLB_FLAG_ENCODE_512KB; -pub const MFD_HUGE_1MB = HUGETLB_FLAG_ENCODE_1MB; -pub const MFD_HUGE_2MB = HUGETLB_FLAG_ENCODE_2MB; -pub const MFD_HUGE_8MB = HUGETLB_FLAG_ENCODE_8MB; -pub const MFD_HUGE_16MB = HUGETLB_FLAG_ENCODE_16MB; -pub const MFD_HUGE_32MB = HUGETLB_FLAG_ENCODE_32MB; -pub const MFD_HUGE_256MB = HUGETLB_FLAG_ENCODE_256MB; -pub const MFD_HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB; -pub const MFD_HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB; -pub const MFD_HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB; -pub const MFD_HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB; - -pub const RUSAGE_SELF = 0; -pub const RUSAGE_CHILDREN = -1; -pub const RUSAGE_THREAD = 1; - -pub const rusage = extern struct { - utime: timeval, - stime: timeval, - maxrss: isize, - ixrss: isize, - idrss: isize, - isrss: isize, - minflt: isize, - majflt: isize, - nswap: isize, - inblock: isize, - oublock: isize, - msgsnd: isize, - msgrcv: isize, - nsignals: isize, - nvcsw: isize, - nivcsw: isize, - __reserved: [16]isize = [1]isize{0} ** 16, -}; - -pub const cc_t = u8; -pub const speed_t = u32; -pub const tcflag_t = u32; - -pub const NCCS = 32; - -pub const B0 = 0o0000000; -pub const B50 = 0o0000001; -pub const B75 = 0o0000002; -pub const B110 = 0o0000003; -pub const B134 = 0o0000004; -pub const B150 = 0o0000005; -pub const B200 = 0o0000006; -pub const B300 = 0o0000007; -pub const B600 = 0o0000010; -pub const B1200 = 0o0000011; -pub const B1800 = 0o0000012; -pub const B2400 = 0o0000013; -pub const B4800 = 0o0000014; -pub const B9600 = 0o0000015; -pub const B19200 = 0o0000016; -pub const B38400 = 0o0000017; -pub const BOTHER = 0o0010000; -pub const B57600 = 0o0010001; -pub const B115200 = 0o0010002; -pub const B230400 = 0o0010003; -pub const B460800 = 0o0010004; -pub const B500000 = 0o0010005; -pub const B576000 = 0o0010006; -pub const B921600 = 0o0010007; -pub const B1000000 = 0o0010010; -pub const B1152000 = 0o0010011; -pub const B1500000 = 0o0010012; -pub const B2000000 = 0o0010013; -pub const B2500000 = 0o0010014; -pub const B3000000 = 0o0010015; -pub const B3500000 = 0o0010016; -pub const B4000000 = 0o0010017; - -pub usingnamespace switch (arch) { - .powerpc, .powerpc64, .powerpc64le => struct { - pub const VINTR = 0; - pub const VQUIT = 1; - pub const VERASE = 2; - pub const VKILL = 3; - pub const VEOF = 4; - pub const VMIN = 5; - pub const VEOL = 6; - pub const VTIME = 7; - pub const VEOL2 = 8; - pub const VSWTC = 9; - pub const VWERASE = 10; - pub const VREPRINT = 11; - pub const VSUSP = 12; - pub const VSTART = 13; - pub const VSTOP = 14; - pub const VLNEXT = 15; - pub const VDISCARD = 16; - }, - .sparc, .sparcv9 => struct { - pub const VINTR = 0; - pub const VQUIT = 1; - pub const VERASE = 2; - pub const VKILL = 3; - pub const VEOF = 4; - pub const VEOL = 5; - pub const VEOL2 = 6; - pub const VSWTC = 7; - pub const VSTART = 8; - pub const VSTOP = 9; - pub const VSUSP = 10; - pub const VDSUSP = 11; - pub const VREPRINT = 12; - pub const VDISCARD = 13; - pub const VWERASE = 14; - pub const VLNEXT = 15; - pub const VMIN = VEOF; - pub const VTIME = VEOL; - }, - .mips, .mipsel, .mips64, .mips64el => struct { - pub const VINTR = 0; - pub const VQUIT = 1; - pub const VERASE = 2; - pub const VKILL = 3; - pub const VMIN = 4; - pub const VTIME = 5; - pub const VEOL2 = 6; - pub const VSWTC = 7; - pub const VSWTCH = 7; - pub const VSTART = 8; - pub const VSTOP = 9; - pub const VSUSP = 10; - pub const VREPRINT = 12; - pub const VDISCARD = 13; - pub const VWERASE = 14; - pub const VLNEXT = 15; - pub const VEOF = 16; - pub const VEOL = 17; - }, - else => struct { - pub const VINTR = 0; - pub const VQUIT = 1; - pub const VERASE = 2; - pub const VKILL = 3; - pub const VEOF = 4; - pub const VTIME = 5; - pub const VMIN = 6; - pub const VSWTC = 7; - pub const VSTART = 8; - pub const VSTOP = 9; - pub const VSUSP = 10; - pub const VEOL = 11; - pub const VREPRINT = 12; - pub const VDISCARD = 13; - pub const VWERASE = 14; - pub const VLNEXT = 15; - pub const VEOL2 = 16; - }, -}; - -pub const IGNBRK = 1; -pub const BRKINT = 2; -pub const IGNPAR = 4; -pub const PARMRK = 8; -pub const INPCK = 16; -pub const ISTRIP = 32; -pub const INLCR = 64; -pub const IGNCR = 128; -pub const ICRNL = 256; -pub const IUCLC = 512; -pub const IXON = 1024; -pub const IXANY = 2048; -pub const IXOFF = 4096; -pub const IMAXBEL = 8192; -pub const IUTF8 = 16384; - -pub const OPOST = 1; -pub const OLCUC = 2; -pub const ONLCR = 4; -pub const OCRNL = 8; -pub const ONOCR = 16; -pub const ONLRET = 32; -pub const OFILL = 64; -pub const OFDEL = 128; -pub const VTDLY = 16384; -pub const VT0 = 0; -pub const VT1 = 16384; - -pub const CSIZE = 48; -pub const CS5 = 0; -pub const CS6 = 16; -pub const CS7 = 32; -pub const CS8 = 48; -pub const CSTOPB = 64; -pub const CREAD = 128; -pub const PARENB = 256; -pub const PARODD = 512; -pub const HUPCL = 1024; -pub const CLOCAL = 2048; - -pub const ISIG = 1; -pub const ICANON = 2; -pub const ECHO = 8; -pub const ECHOE = 16; -pub const ECHOK = 32; -pub const ECHONL = 64; -pub const NOFLSH = 128; -pub const TOSTOP = 256; -pub const IEXTEN = 32768; - -pub const TCSA = enum(c_uint) { - NOW, - DRAIN, - FLUSH, - _, -}; - -pub const termios = extern struct { - iflag: tcflag_t, - oflag: tcflag_t, - cflag: tcflag_t, - lflag: tcflag_t, - line: cc_t, - cc: [NCCS]cc_t, - ispeed: speed_t, - ospeed: speed_t, -}; - -pub const SIOCGIFINDEX = 0x8933; -pub const IFNAMESIZE = 16; - -pub const ifmap = extern struct { - mem_start: u32, - mem_end: u32, - base_addr: u16, - irq: u8, - dma: u8, - port: u8, -}; - -pub const ifreq = extern struct { - ifrn: extern union { - name: [IFNAMESIZE]u8, - }, - ifru: extern union { - addr: sockaddr, - dstaddr: sockaddr, - broadaddr: sockaddr, - netmask: sockaddr, - hwaddr: sockaddr, - flags: i16, - ivalue: i32, - mtu: i32, - map: ifmap, - slave: [IFNAMESIZE - 1:0]u8, - newname: [IFNAMESIZE - 1:0]u8, - data: ?[*]u8, - }, -}; - -// doc comments copied from musl -pub const rlimit_resource = enum(c_int) { - /// Per-process CPU limit, in seconds. - CPU, - - /// Largest file that can be created, in bytes. - FSIZE, - - /// Maximum size of data segment, in bytes. - DATA, - - /// Maximum size of stack segment, in bytes. - STACK, - - /// Largest core file that can be created, in bytes. - CORE, - - /// Largest resident set size, in bytes. - /// This affects swapping; processes that are exceeding their - /// resident set size will be more likely to have physical memory - /// taken from them. - RSS, - - /// Number of processes. - NPROC, - - /// Number of open files. - NOFILE, - - /// Locked-in-memory address space. - MEMLOCK, - - /// Address space limit. - AS, - - /// Maximum number of file locks. - LOCKS, - - /// Maximum number of pending signals. - SIGPENDING, - - /// Maximum bytes in POSIX message queues. - MSGQUEUE, - - /// Maximum nice priority allowed to raise to. - /// Nice levels 19 .. -20 correspond to 0 .. 39 - /// values of this resource limit. - NICE, - - /// Maximum realtime priority allowed for non-priviledged - /// processes. - RTPRIO, - - /// Maximum CPU time in µs that a process scheduled under a real-time - /// scheduling policy may consume without making a blocking system - /// call before being forcibly descheduled. - RTTIME, - - _, -}; - -pub const rlim_t = u64; - -/// No limit -pub const RLIM_INFINITY = ~@as(rlim_t, 0); - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const MADV_NORMAL = 0; -pub const MADV_RANDOM = 1; -pub const MADV_SEQUENTIAL = 2; -pub const MADV_WILLNEED = 3; -pub const MADV_DONTNEED = 4; -pub const MADV_FREE = 8; -pub const MADV_REMOVE = 9; -pub const MADV_DONTFORK = 10; -pub const MADV_DOFORK = 11; -pub const MADV_MERGEABLE = 12; -pub const MADV_UNMERGEABLE = 13; -pub const MADV_HUGEPAGE = 14; -pub const MADV_NOHUGEPAGE = 15; -pub const MADV_DONTDUMP = 16; -pub const MADV_DODUMP = 17; -pub const MADV_WIPEONFORK = 18; -pub const MADV_KEEPONFORK = 19; -pub const MADV_COLD = 20; -pub const MADV_PAGEOUT = 21; -pub const MADV_HWPOISON = 100; -pub const MADV_SOFT_OFFLINE = 101; - -pub const POSIX_FADV_NORMAL = 0; -pub const POSIX_FADV_RANDOM = 1; -pub const POSIX_FADV_SEQUENTIAL = 2; -pub const POSIX_FADV_WILLNEED = 3; -pub usingnamespace switch (arch) { - .s390x => if (@typeInfo(usize).Int.bits == 64) - struct { - pub const POSIX_FADV_DONTNEED = 6; - pub const POSIX_FADV_NOREUSE = 7; - } - else - struct { - pub const POSIX_FADV_DONTNEED = 4; - pub const POSIX_FADV_NOREUSE = 5; - }, - else => struct { - pub const POSIX_FADV_DONTNEED = 4; - pub const POSIX_FADV_NOREUSE = 5; - }, -}; - -pub const __kernel_timespec = extern struct { - tv_sec: i64, - tv_nsec: i64, -}; diff --git a/lib/std/os/bits/linux/arm-eabi.zig b/lib/std/os/bits/linux/arm-eabi.zig deleted file mode 100644 index 91ca2b32d2..0000000000 --- a/lib/std/os/bits/linux/arm-eabi.zig +++ /dev/null @@ -1,636 +0,0 @@ -// arm-eabi-specific declarations that are intended to be imported into the POSIX namespace. -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; - -pub const SYS = enum(usize) { - restart_syscall = 0, - exit = 1, - fork = 2, - read = 3, - write = 4, - open = 5, - close = 6, - creat = 8, - link = 9, - unlink = 10, - execve = 11, - chdir = 12, - mknod = 14, - chmod = 15, - lchown = 16, - lseek = 19, - getpid = 20, - mount = 21, - setuid = 23, - getuid = 24, - ptrace = 26, - pause = 29, - access = 33, - nice = 34, - sync = 36, - kill = 37, - rename = 38, - mkdir = 39, - rmdir = 40, - dup = 41, - pipe = 42, - times = 43, - brk = 45, - setgid = 46, - getgid = 47, - geteuid = 49, - getegid = 50, - acct = 51, - umount2 = 52, - ioctl = 54, - fcntl = 55, - setpgid = 57, - umask = 60, - chroot = 61, - ustat = 62, - dup2 = 63, - getppid = 64, - getpgrp = 65, - setsid = 66, - sigaction = 67, - setreuid = 70, - setregid = 71, - sigsuspend = 72, - sigpending = 73, - sethostname = 74, - setrlimit = 75, - getrusage = 77, - gettimeofday = 78, - settimeofday = 79, - getgroups = 80, - setgroups = 81, - symlink = 83, - readlink = 85, - uselib = 86, - swapon = 87, - reboot = 88, - munmap = 91, - truncate = 92, - ftruncate = 93, - fchmod = 94, - fchown = 95, - getpriority = 96, - setpriority = 97, - statfs = 99, - fstatfs = 100, - syslog = 103, - setitimer = 104, - getitimer = 105, - stat = 106, - lstat = 107, - fstat = 108, - vhangup = 111, - wait4 = 114, - swapoff = 115, - sysinfo = 116, - fsync = 118, - sigreturn = 119, - clone = 120, - setdomainname = 121, - uname = 122, - adjtimex = 124, - mprotect = 125, - sigprocmask = 126, - init_module = 128, - delete_module = 129, - quotactl = 131, - getpgid = 132, - fchdir = 133, - bdflush = 134, - sysfs = 135, - personality = 136, - setfsuid = 138, - setfsgid = 139, - _llseek = 140, - getdents = 141, - _newselect = 142, - flock = 143, - msync = 144, - readv = 145, - writev = 146, - getsid = 147, - fdatasync = 148, - _sysctl = 149, - mlock = 150, - munlock = 151, - mlockall = 152, - munlockall = 153, - sched_setparam = 154, - sched_getparam = 155, - sched_setscheduler = 156, - sched_getscheduler = 157, - sched_yield = 158, - sched_get_priority_max = 159, - sched_get_priority_min = 160, - sched_rr_get_interval = 161, - nanosleep = 162, - mremap = 163, - setresuid = 164, - getresuid = 165, - poll = 168, - nfsservctl = 169, - setresgid = 170, - getresgid = 171, - prctl = 172, - rt_sigreturn = 173, - rt_sigaction = 174, - rt_sigprocmask = 175, - rt_sigpending = 176, - rt_sigtimedwait = 177, - rt_sigqueueinfo = 178, - rt_sigsuspend = 179, - pread64 = 180, - pwrite64 = 181, - chown = 182, - getcwd = 183, - capget = 184, - capset = 185, - sigaltstack = 186, - sendfile = 187, - vfork = 190, - ugetrlimit = 191, - mmap2 = 192, - truncate64 = 193, - ftruncate64 = 194, - stat64 = 195, - lstat64 = 196, - fstat64 = 197, - lchown32 = 198, - getuid32 = 199, - getgid32 = 200, - geteuid32 = 201, - getegid32 = 202, - setreuid32 = 203, - setregid32 = 204, - getgroups32 = 205, - setgroups32 = 206, - fchown32 = 207, - setresuid32 = 208, - getresuid32 = 209, - setresgid32 = 210, - getresgid32 = 211, - chown32 = 212, - setuid32 = 213, - setgid32 = 214, - setfsuid32 = 215, - setfsgid32 = 216, - getdents64 = 217, - pivot_root = 218, - mincore = 219, - madvise = 220, - fcntl64 = 221, - gettid = 224, - readahead = 225, - setxattr = 226, - lsetxattr = 227, - fsetxattr = 228, - getxattr = 229, - lgetxattr = 230, - fgetxattr = 231, - listxattr = 232, - llistxattr = 233, - flistxattr = 234, - removexattr = 235, - lremovexattr = 236, - fremovexattr = 237, - tkill = 238, - sendfile64 = 239, - futex = 240, - sched_setaffinity = 241, - sched_getaffinity = 242, - io_setup = 243, - io_destroy = 244, - io_getevents = 245, - io_submit = 246, - io_cancel = 247, - exit_group = 248, - lookup_dcookie = 249, - epoll_create = 250, - epoll_ctl = 251, - epoll_wait = 252, - remap_file_pages = 253, - set_tid_address = 256, - timer_create = 257, - timer_settime = 258, - timer_gettime = 259, - timer_getoverrun = 260, - timer_delete = 261, - clock_settime = 262, - clock_gettime = 263, - clock_getres = 264, - clock_nanosleep = 265, - statfs64 = 266, - fstatfs64 = 267, - tgkill = 268, - utimes = 269, - fadvise64_64 = 270, - pciconfig_iobase = 271, - pciconfig_read = 272, - pciconfig_write = 273, - mq_open = 274, - mq_unlink = 275, - mq_timedsend = 276, - mq_timedreceive = 277, - mq_notify = 278, - mq_getsetattr = 279, - waitid = 280, - socket = 281, - bind = 282, - connect = 283, - listen = 284, - accept = 285, - getsockname = 286, - getpeername = 287, - socketpair = 288, - send = 289, - sendto = 290, - recv = 291, - recvfrom = 292, - shutdown = 293, - setsockopt = 294, - getsockopt = 295, - sendmsg = 296, - recvmsg = 297, - semop = 298, - semget = 299, - semctl = 300, - msgsnd = 301, - msgrcv = 302, - msgget = 303, - msgctl = 304, - shmat = 305, - shmdt = 306, - shmget = 307, - shmctl = 308, - add_key = 309, - request_key = 310, - keyctl = 311, - semtimedop = 312, - vserver = 313, - ioprio_set = 314, - ioprio_get = 315, - inotify_init = 316, - inotify_add_watch = 317, - inotify_rm_watch = 318, - mbind = 319, - get_mempolicy = 320, - set_mempolicy = 321, - openat = 322, - mkdirat = 323, - mknodat = 324, - fchownat = 325, - futimesat = 326, - fstatat64 = 327, - unlinkat = 328, - renameat = 329, - linkat = 330, - symlinkat = 331, - readlinkat = 332, - fchmodat = 333, - faccessat = 334, - pselect6 = 335, - ppoll = 336, - unshare = 337, - set_robust_list = 338, - get_robust_list = 339, - splice = 340, - sync_file_range = 341, - tee = 342, - vmsplice = 343, - move_pages = 344, - getcpu = 345, - epoll_pwait = 346, - kexec_load = 347, - utimensat = 348, - signalfd = 349, - timerfd_create = 350, - eventfd = 351, - fallocate = 352, - timerfd_settime = 353, - timerfd_gettime = 354, - signalfd4 = 355, - eventfd2 = 356, - epoll_create1 = 357, - dup3 = 358, - pipe2 = 359, - inotify_init1 = 360, - preadv = 361, - pwritev = 362, - rt_tgsigqueueinfo = 363, - perf_event_open = 364, - recvmmsg = 365, - accept4 = 366, - fanotify_init = 367, - fanotify_mark = 368, - prlimit64 = 369, - name_to_handle_at = 370, - open_by_handle_at = 371, - clock_adjtime = 372, - syncfs = 373, - sendmmsg = 374, - setns = 375, - process_vm_readv = 376, - process_vm_writev = 377, - kcmp = 378, - finit_module = 379, - sched_setattr = 380, - sched_getattr = 381, - renameat2 = 382, - seccomp = 383, - getrandom = 384, - memfd_create = 385, - bpf = 386, - execveat = 387, - userfaultfd = 388, - membarrier = 389, - mlock2 = 390, - copy_file_range = 391, - preadv2 = 392, - pwritev2 = 393, - pkey_mprotect = 394, - pkey_alloc = 395, - pkey_free = 396, - statx = 397, - rseq = 398, - io_pgetevents = 399, - migrate_pages = 400, - kexec_file_load = 401, - clock_gettime64 = 403, - clock_settime64 = 404, - clock_adjtime64 = 405, - clock_getres_time64 = 406, - clock_nanosleep_time64 = 407, - timer_gettime64 = 408, - timer_settime64 = 409, - timerfd_gettime64 = 410, - timerfd_settime64 = 411, - utimensat_time64 = 412, - pselect6_time64 = 413, - ppoll_time64 = 414, - io_pgetevents_time64 = 416, - recvmmsg_time64 = 417, - mq_timedsend_time64 = 418, - mq_timedreceive_time64 = 419, - semtimedop_time64 = 420, - rt_sigtimedwait_time64 = 421, - futex_time64 = 422, - sched_rr_get_interval_time64 = 423, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - breakpoint = 0x0f0001, - cacheflush = 0x0f0002, - usr26 = 0x0f0003, - usr32 = 0x0f0004, - set_tls = 0x0f0005, - get_tls = 0x0f0006, - - _, -}; - -pub const MMAP2_UNIT = 4096; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o200000; -pub const O_LARGEFILE = 0o400000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20040000; -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 = 12; -pub const F_SETLK = 13; -pub const F_SETLKW = 14; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x2000; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x4000; - -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6"; - -pub const HWCAP_SWP = 1 << 0; -pub const HWCAP_HALF = 1 << 1; -pub const HWCAP_THUMB = 1 << 2; -pub const HWCAP_26BIT = 1 << 3; -pub const HWCAP_FAST_MULT = 1 << 4; -pub const HWCAP_FPA = 1 << 5; -pub const HWCAP_VFP = 1 << 6; -pub const HWCAP_EDSP = 1 << 7; -pub const HWCAP_JAVA = 1 << 8; -pub const HWCAP_IWMMXT = 1 << 9; -pub const HWCAP_CRUNCH = 1 << 10; -pub const HWCAP_THUMBEE = 1 << 11; -pub const HWCAP_NEON = 1 << 12; -pub const HWCAP_VFPv3 = 1 << 13; -pub const HWCAP_VFPv3D16 = 1 << 14; -pub const HWCAP_TLS = 1 << 15; -pub const HWCAP_VFPv4 = 1 << 16; -pub const HWCAP_IDIVA = 1 << 17; -pub const HWCAP_IDIVT = 1 << 18; -pub const HWCAP_VFPD32 = 1 << 19; -pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT; -pub const HWCAP_LPAE = 1 << 20; -pub const HWCAP_EVTSTRM = 1 << 21; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - __pad0: [4]u8, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - __unused: [4]u8, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: i32, -}; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = isize; -pub const mode_t = u32; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; -pub const blkcnt_t = i64; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - __dev_padding: u32, - __ino_truncated: u32, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __rdev_padding: u32, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - ino: ino_t, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const timespec = extern struct { - tv_sec: i32, - tv_nsec: i32, -}; - -pub const timeval = extern struct { - tv_sec: i32, - tv_usec: i32, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const mcontext_t = extern struct { - trap_no: usize, - error_code: usize, - oldmask: usize, - arm_r0: usize, - arm_r1: usize, - arm_r2: usize, - arm_r3: usize, - arm_r4: usize, - arm_r5: usize, - arm_r6: usize, - arm_r7: usize, - arm_r8: usize, - arm_r9: usize, - arm_r10: usize, - arm_fp: usize, - arm_ip: usize, - arm_sp: usize, - arm_lr: usize, - arm_pc: usize, - arm_cpsr: usize, - fault_address: usize, -}; - -pub const ucontext_t = extern struct { - flags: usize, - link: *ucontext_t, - stack: stack_t, - mcontext: mcontext_t, - sigmask: sigset_t, - regspace: [64]u64, -}; - -pub const Elf_Symndx = u32; diff --git a/lib/std/os/bits/linux/arm64.zig b/lib/std/os/bits/linux/arm64.zig deleted file mode 100644 index 67c77ce186..0000000000 --- a/lib/std/os/bits/linux/arm64.zig +++ /dev/null @@ -1,495 +0,0 @@ -// arm64-specific declarations that are intended to be imported into the POSIX namespace. -// This does include Linux-only APIs. - -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const sockaddr = linux.sockaddr; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; -pub const SYS = enum(usize) { - io_setup = 0, - io_destroy = 1, - io_submit = 2, - io_cancel = 3, - io_getevents = 4, - setxattr = 5, - lsetxattr = 6, - fsetxattr = 7, - getxattr = 8, - lgetxattr = 9, - fgetxattr = 10, - listxattr = 11, - llistxattr = 12, - flistxattr = 13, - removexattr = 14, - lremovexattr = 15, - fremovexattr = 16, - getcwd = 17, - lookup_dcookie = 18, - eventfd2 = 19, - epoll_create1 = 20, - epoll_ctl = 21, - epoll_pwait = 22, - dup = 23, - dup3 = 24, - fcntl = 25, - inotify_init1 = 26, - inotify_add_watch = 27, - inotify_rm_watch = 28, - ioctl = 29, - ioprio_set = 30, - ioprio_get = 31, - flock = 32, - mknodat = 33, - mkdirat = 34, - unlinkat = 35, - symlinkat = 36, - linkat = 37, - renameat = 38, - umount2 = 39, - mount = 40, - pivot_root = 41, - nfsservctl = 42, - statfs = 43, - fstatfs = 44, - truncate = 45, - ftruncate = 46, - fallocate = 47, - faccessat = 48, - chdir = 49, - fchdir = 50, - chroot = 51, - fchmod = 52, - fchmodat = 53, - fchownat = 54, - fchown = 55, - openat = 56, - close = 57, - vhangup = 58, - pipe2 = 59, - quotactl = 60, - getdents64 = 61, - lseek = 62, - read = 63, - write = 64, - readv = 65, - writev = 66, - pread64 = 67, - pwrite64 = 68, - preadv = 69, - pwritev = 70, - sendfile = 71, - pselect6 = 72, - ppoll = 73, - signalfd4 = 74, - vmsplice = 75, - splice = 76, - tee = 77, - readlinkat = 78, - fstatat = 79, - fstat = 80, - sync = 81, - fsync = 82, - fdatasync = 83, - sync_file_range = 84, - timerfd_create = 85, - timerfd_settime = 86, - timerfd_gettime = 87, - utimensat = 88, - acct = 89, - capget = 90, - capset = 91, - personality = 92, - exit = 93, - exit_group = 94, - waitid = 95, - set_tid_address = 96, - unshare = 97, - futex = 98, - set_robust_list = 99, - get_robust_list = 100, - nanosleep = 101, - getitimer = 102, - setitimer = 103, - kexec_load = 104, - init_module = 105, - delete_module = 106, - timer_create = 107, - timer_gettime = 108, - timer_getoverrun = 109, - timer_settime = 110, - timer_delete = 111, - clock_settime = 112, - clock_gettime = 113, - clock_getres = 114, - clock_nanosleep = 115, - syslog = 116, - ptrace = 117, - sched_setparam = 118, - sched_setscheduler = 119, - sched_getscheduler = 120, - sched_getparam = 121, - sched_setaffinity = 122, - sched_getaffinity = 123, - sched_yield = 124, - sched_get_priority_max = 125, - sched_get_priority_min = 126, - sched_rr_get_interval = 127, - restart_syscall = 128, - kill = 129, - tkill = 130, - tgkill = 131, - sigaltstack = 132, - rt_sigsuspend = 133, - rt_sigaction = 134, - rt_sigprocmask = 135, - rt_sigpending = 136, - rt_sigtimedwait = 137, - rt_sigqueueinfo = 138, - rt_sigreturn = 139, - setpriority = 140, - getpriority = 141, - reboot = 142, - setregid = 143, - setgid = 144, - setreuid = 145, - setuid = 146, - setresuid = 147, - getresuid = 148, - setresgid = 149, - getresgid = 150, - setfsuid = 151, - setfsgid = 152, - times = 153, - setpgid = 154, - getpgid = 155, - getsid = 156, - setsid = 157, - getgroups = 158, - setgroups = 159, - uname = 160, - sethostname = 161, - setdomainname = 162, - getrlimit = 163, - setrlimit = 164, - getrusage = 165, - umask = 166, - prctl = 167, - getcpu = 168, - gettimeofday = 169, - settimeofday = 170, - adjtimex = 171, - getpid = 172, - getppid = 173, - getuid = 174, - geteuid = 175, - getgid = 176, - getegid = 177, - gettid = 178, - sysinfo = 179, - mq_open = 180, - mq_unlink = 181, - mq_timedsend = 182, - mq_timedreceive = 183, - mq_notify = 184, - mq_getsetattr = 185, - msgget = 186, - msgctl = 187, - msgrcv = 188, - msgsnd = 189, - semget = 190, - semctl = 191, - semtimedop = 192, - semop = 193, - shmget = 194, - shmctl = 195, - shmat = 196, - shmdt = 197, - socket = 198, - socketpair = 199, - bind = 200, - listen = 201, - accept = 202, - connect = 203, - getsockname = 204, - getpeername = 205, - sendto = 206, - recvfrom = 207, - setsockopt = 208, - getsockopt = 209, - shutdown = 210, - sendmsg = 211, - recvmsg = 212, - readahead = 213, - brk = 214, - munmap = 215, - mremap = 216, - add_key = 217, - request_key = 218, - keyctl = 219, - clone = 220, - execve = 221, - mmap = 222, - fadvise64 = 223, - swapon = 224, - swapoff = 225, - mprotect = 226, - msync = 227, - mlock = 228, - munlock = 229, - mlockall = 230, - munlockall = 231, - mincore = 232, - madvise = 233, - remap_file_pages = 234, - mbind = 235, - get_mempolicy = 236, - set_mempolicy = 237, - migrate_pages = 238, - move_pages = 239, - rt_tgsigqueueinfo = 240, - perf_event_open = 241, - accept4 = 242, - recvmmsg = 243, - arch_specific_syscall = 244, - wait4 = 260, - prlimit64 = 261, - fanotify_init = 262, - fanotify_mark = 263, - clock_adjtime = 266, - syncfs = 267, - setns = 268, - sendmmsg = 269, - process_vm_readv = 270, - process_vm_writev = 271, - kcmp = 272, - finit_module = 273, - sched_setattr = 274, - sched_getattr = 275, - renameat2 = 276, - seccomp = 277, - getrandom = 278, - memfd_create = 279, - bpf = 280, - execveat = 281, - userfaultfd = 282, - membarrier = 283, - mlock2 = 284, - copy_file_range = 285, - preadv2 = 286, - pwritev2 = 287, - pkey_mprotect = 288, - pkey_alloc = 289, - pkey_free = 290, - statx = 291, - io_pgetevents = 292, - rseq = 293, - kexec_file_load = 294, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - _, -}; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o200000; -pub const O_LARGEFILE = 0o400000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20040000; -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_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x2000; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x4000; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6.39"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - __unused: [4]u8, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: i32, - __pad1: i32 = 0, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t = 0, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: i32, - __pad1: i32 = 0, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t = 0, - msg_flags: i32, -}; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = isize; -pub const mode_t = u32; -pub const off_t = isize; -pub const ino_t = usize; -pub const dev_t = usize; -pub const blkcnt_t = isize; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad: usize, - size: off_t, - blksize: blksize_t, - __pad2: i32, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const mcontext_t = extern struct { - fault_address: usize, - regs: [31]usize, - sp: usize, - pc: usize, - pstate: usize, - // Make sure the field is correctly aligned since this area - // holds various FP/vector registers - reserved1: [256 * 16]u8 align(16), -}; - -pub const ucontext_t = extern struct { - flags: usize, - link: *ucontext_t, - stack: stack_t, - sigmask: sigset_t, - mcontext: mcontext_t, -}; - -pub const Elf_Symndx = u32; diff --git a/lib/std/os/bits/linux/errno/generic.zig b/lib/std/os/bits/linux/errno/generic.zig deleted file mode 100644 index 730c71a5a2..0000000000 --- a/lib/std/os/bits/linux/errno/generic.zig +++ /dev/null @@ -1,460 +0,0 @@ -pub const E = enum(u16) { - /// No error occurred. - /// Same code used for `NSROK`. - SUCCESS = 0, - - /// Operation not permitted - PERM = 1, - - /// No such file or directory - NOENT = 2, - - /// No such process - SRCH = 3, - - /// Interrupted system call - INTR = 4, - - /// I/O error - IO = 5, - - /// No such device or address - NXIO = 6, - - /// Arg list too long - @"2BIG" = 7, - - /// Exec format error - NOEXEC = 8, - - /// Bad file number - BADF = 9, - - /// No child processes - CHILD = 10, - - /// Try again - /// Also means: WOULDBLOCK: operation would block - AGAIN = 11, - - /// Out of memory - NOMEM = 12, - - /// Permission denied - ACCES = 13, - - /// Bad address - FAULT = 14, - - /// Block device required - NOTBLK = 15, - - /// Device or resource busy - BUSY = 16, - - /// File exists - EXIST = 17, - - /// Cross-device link - XDEV = 18, - - /// No such device - NODEV = 19, - - /// Not a directory - NOTDIR = 20, - - /// Is a directory - ISDIR = 21, - - /// Invalid argument - INVAL = 22, - - /// File table overflow - NFILE = 23, - - /// Too many open files - MFILE = 24, - - /// Not a typewriter - NOTTY = 25, - - /// Text file busy - TXTBSY = 26, - - /// File too large - FBIG = 27, - - /// No space left on device - NOSPC = 28, - - /// Illegal seek - SPIPE = 29, - - /// Read-only file system - ROFS = 30, - - /// Too many links - MLINK = 31, - - /// Broken pipe - PIPE = 32, - - /// Math argument out of domain of func - DOM = 33, - - /// Math result not representable - RANGE = 34, - - /// Resource deadlock would occur - DEADLK = 35, - - /// File name too long - NAMETOOLONG = 36, - - /// No record locks available - NOLCK = 37, - - /// Function not implemented - NOSYS = 38, - - /// Directory not empty - NOTEMPTY = 39, - - /// Too many symbolic links encountered - LOOP = 40, - - /// No message of desired type - NOMSG = 42, - - /// Identifier removed - IDRM = 43, - - /// Channel number out of range - CHRNG = 44, - - /// Level 2 not synchronized - L2NSYNC = 45, - - /// Level 3 halted - L3HLT = 46, - - /// Level 3 reset - L3RST = 47, - - /// Link number out of range - LNRNG = 48, - - /// Protocol driver not attached - UNATCH = 49, - - /// No CSI structure available - NOCSI = 50, - - /// Level 2 halted - L2HLT = 51, - - /// Invalid exchange - BADE = 52, - - /// Invalid request descriptor - BADR = 53, - - /// Exchange full - XFULL = 54, - - /// No anode - NOANO = 55, - - /// Invalid request code - BADRQC = 56, - - /// Invalid slot - BADSLT = 57, - - /// Bad font file format - BFONT = 59, - - /// Device not a stream - NOSTR = 60, - - /// No data available - NODATA = 61, - - /// Timer expired - TIME = 62, - - /// Out of streams resources - NOSR = 63, - - /// Machine is not on the network - NONET = 64, - - /// Package not installed - NOPKG = 65, - - /// Object is remote - REMOTE = 66, - - /// Link has been severed - NOLINK = 67, - - /// Advertise error - ADV = 68, - - /// Srmount error - SRMNT = 69, - - /// Communication error on send - COMM = 70, - - /// Protocol error - PROTO = 71, - - /// Multihop attempted - MULTIHOP = 72, - - /// RFS specific error - DOTDOT = 73, - - /// Not a data message - BADMSG = 74, - - /// Value too large for defined data type - OVERFLOW = 75, - - /// Name not unique on network - NOTUNIQ = 76, - - /// File descriptor in bad state - BADFD = 77, - - /// Remote address changed - REMCHG = 78, - - /// Can not access a needed shared library - LIBACC = 79, - - /// Accessing a corrupted shared library - LIBBAD = 80, - - /// .lib section in a.out corrupted - LIBSCN = 81, - - /// Attempting to link in too many shared libraries - LIBMAX = 82, - - /// Cannot exec a shared library directly - LIBEXEC = 83, - - /// Illegal byte sequence - ILSEQ = 84, - - /// Interrupted system call should be restarted - RESTART = 85, - - /// Streams pipe error - STRPIPE = 86, - - /// Too many users - USERS = 87, - - /// Socket operation on non-socket - NOTSOCK = 88, - - /// Destination address required - DESTADDRREQ = 89, - - /// Message too long - MSGSIZE = 90, - - /// Protocol wrong type for socket - PROTOTYPE = 91, - - /// Protocol not available - NOPROTOOPT = 92, - - /// Protocol not supported - PROTONOSUPPORT = 93, - - /// Socket type not supported - SOCKTNOSUPPORT = 94, - - /// Operation not supported on transport endpoint - /// This code also means `NOTSUP`. - OPNOTSUPP = 95, - - /// Protocol family not supported - PFNOSUPPORT = 96, - - /// Address family not supported by protocol - AFNOSUPPORT = 97, - - /// Address already in use - ADDRINUSE = 98, - - /// Cannot assign requested address - ADDRNOTAVAIL = 99, - - /// Network is down - NETDOWN = 100, - - /// Network is unreachable - NETUNREACH = 101, - - /// Network dropped connection because of reset - NETRESET = 102, - - /// Software caused connection abort - CONNABORTED = 103, - - /// Connection reset by peer - CONNRESET = 104, - - /// No buffer space available - NOBUFS = 105, - - /// Transport endpoint is already connected - ISCONN = 106, - - /// Transport endpoint is not connected - NOTCONN = 107, - - /// Cannot send after transport endpoint shutdown - SHUTDOWN = 108, - - /// Too many references: cannot splice - TOOMANYREFS = 109, - - /// Connection timed out - TIMEDOUT = 110, - - /// Connection refused - CONNREFUSED = 111, - - /// Host is down - HOSTDOWN = 112, - - /// No route to host - HOSTUNREACH = 113, - - /// Operation already in progress - ALREADY = 114, - - /// Operation now in progress - INPROGRESS = 115, - - /// Stale NFS file handle - STALE = 116, - - /// Structure needs cleaning - UCLEAN = 117, - - /// Not a XENIX named type file - NOTNAM = 118, - - /// No XENIX semaphores available - NAVAIL = 119, - - /// Is a named type file - ISNAM = 120, - - /// Remote I/O error - REMOTEIO = 121, - - /// Quota exceeded - DQUOT = 122, - - /// No medium found - NOMEDIUM = 123, - - /// Wrong medium type - MEDIUMTYPE = 124, - - /// Operation canceled - CANCELED = 125, - - /// Required key not available - NOKEY = 126, - - /// Key has expired - KEYEXPIRED = 127, - - /// Key has been revoked - KEYREVOKED = 128, - - /// Key was rejected by service - KEYREJECTED = 129, - - // for robust mutexes - - /// Owner died - OWNERDEAD = 130, - - /// State not recoverable - NOTRECOVERABLE = 131, - - /// Operation not possible due to RF-kill - RFKILL = 132, - - /// Memory page has hardware error - HWPOISON = 133, - - // nameserver query return codes - - /// DNS server returned answer with no data - NSRNODATA = 160, - - /// DNS server claims query was misformatted - NSRFORMERR = 161, - - /// DNS server returned general failure - NSRSERVFAIL = 162, - - /// Domain name not found - NSRNOTFOUND = 163, - - /// DNS server does not implement requested operation - NSRNOTIMP = 164, - - /// DNS server refused query - NSRREFUSED = 165, - - /// Misformatted DNS query - NSRBADQUERY = 166, - - /// Misformatted domain name - NSRBADNAME = 167, - - /// Unsupported address family - NSRBADFAMILY = 168, - - /// Misformatted DNS reply - NSRBADRESP = 169, - - /// Could not contact DNS servers - NSRCONNREFUSED = 170, - - /// Timeout while contacting DNS servers - NSRTIMEOUT = 171, - - /// End of file - NSROF = 172, - - /// Error reading file - NSRFILE = 173, - - /// Out of memory - NSRNOMEM = 174, - - /// Application terminated lookup - NSRDESTRUCTION = 175, - - /// Domain name is too long - NSRQUERYDOMAINTOOLONG = 176, - - /// Domain name is too long - NSRCNAMELOOP = 177, - - _, -}; diff --git a/lib/std/os/bits/linux/errno/mips.zig b/lib/std/os/bits/linux/errno/mips.zig deleted file mode 100644 index 39fb9f71ea..0000000000 --- a/lib/std/os/bits/linux/errno/mips.zig +++ /dev/null @@ -1,141 +0,0 @@ -//! These are MIPS ABI compatible. -pub const E = enum(i32) { - /// No error occurred. - SUCCESS = 0, - - PERM = 1, - NOENT = 2, - SRCH = 3, - INTR = 4, - IO = 5, - NXIO = 6, - @"2BIG" = 7, - NOEXEC = 8, - BADF = 9, - CHILD = 10, - /// Also used for WOULDBLOCK. - AGAIN = 11, - NOMEM = 12, - ACCES = 13, - FAULT = 14, - NOTBLK = 15, - BUSY = 16, - EXIST = 17, - XDEV = 18, - NODEV = 19, - NOTDIR = 20, - ISDIR = 21, - INVAL = 22, - NFILE = 23, - MFILE = 24, - NOTTY = 25, - TXTBSY = 26, - FBIG = 27, - NOSPC = 28, - SPIPE = 29, - ROFS = 30, - MLINK = 31, - PIPE = 32, - DOM = 33, - RANGE = 34, - - NOMSG = 35, - IDRM = 36, - CHRNG = 37, - L2NSYNC = 38, - L3HLT = 39, - L3RST = 40, - LNRNG = 41, - UNATCH = 42, - NOCSI = 43, - L2HLT = 44, - DEADLK = 45, - NOLCK = 46, - BADE = 50, - BADR = 51, - XFULL = 52, - NOANO = 53, - BADRQC = 54, - BADSLT = 55, - DEADLOCK = 56, - BFONT = 59, - NOSTR = 60, - NODATA = 61, - TIME = 62, - NOSR = 63, - NONET = 64, - NOPKG = 65, - REMOTE = 66, - NOLINK = 67, - ADV = 68, - SRMNT = 69, - COMM = 70, - PROTO = 71, - DOTDOT = 73, - MULTIHOP = 74, - BADMSG = 77, - NAMETOOLONG = 78, - OVERFLOW = 79, - NOTUNIQ = 80, - BADFD = 81, - REMCHG = 82, - LIBACC = 83, - LIBBAD = 84, - LIBSCN = 85, - LIBMAX = 86, - LIBEXEC = 87, - ILSEQ = 88, - NOSYS = 89, - LOOP = 90, - RESTART = 91, - STRPIPE = 92, - NOTEMPTY = 93, - USERS = 94, - NOTSOCK = 95, - DESTADDRREQ = 96, - MSGSIZE = 97, - PROTOTYPE = 98, - NOPROTOOPT = 99, - PROTONOSUPPORT = 120, - SOCKTNOSUPPORT = 121, - OPNOTSUPP = 122, - PFNOSUPPORT = 123, - AFNOSUPPORT = 124, - ADDRINUSE = 125, - ADDRNOTAVAIL = 126, - NETDOWN = 127, - NETUNREACH = 128, - NETRESET = 129, - CONNABORTED = 130, - CONNRESET = 131, - NOBUFS = 132, - ISCONN = 133, - NOTCONN = 134, - UCLEAN = 135, - NOTNAM = 137, - NAVAIL = 138, - ISNAM = 139, - REMOTEIO = 140, - SHUTDOWN = 143, - TOOMANYREFS = 144, - TIMEDOUT = 145, - CONNREFUSED = 146, - HOSTDOWN = 147, - HOSTUNREACH = 148, - ALREADY = 149, - INPROGRESS = 150, - STALE = 151, - CANCELED = 158, - NOMEDIUM = 159, - MEDIUMTYPE = 160, - NOKEY = 161, - KEYEXPIRED = 162, - KEYREVOKED = 163, - KEYREJECTED = 164, - OWNERDEAD = 165, - NOTRECOVERABLE = 166, - RFKILL = 167, - HWPOISON = 168, - DQUOT = 1133, - _, -}; diff --git a/lib/std/os/bits/linux/errno/sparc.zig b/lib/std/os/bits/linux/errno/sparc.zig deleted file mode 100644 index c4ab65f34a..0000000000 --- a/lib/std/os/bits/linux/errno/sparc.zig +++ /dev/null @@ -1,144 +0,0 @@ -//! These match the SunOS error numbering scheme. -pub const E = enum(i32) { - /// No error occurred. - SUCCESS = 0, - - PERM = 1, - NOENT = 2, - SRCH = 3, - INTR = 4, - IO = 5, - NXIO = 6, - @"2BIG" = 7, - NOEXEC = 8, - BADF = 9, - CHILD = 10, - /// Also used for WOULDBLOCK - AGAIN = 11, - NOMEM = 12, - ACCES = 13, - FAULT = 14, - NOTBLK = 15, - BUSY = 16, - EXIST = 17, - XDEV = 18, - NODEV = 19, - NOTDIR = 20, - ISDIR = 21, - INVAL = 22, - NFILE = 23, - MFILE = 24, - NOTTY = 25, - TXTBSY = 26, - FBIG = 27, - NOSPC = 28, - SPIPE = 29, - ROFS = 30, - MLINK = 31, - PIPE = 32, - DOM = 33, - RANGE = 34, - - INPROGRESS = 36, - ALREADY = 37, - NOTSOCK = 38, - DESTADDRREQ = 39, - MSGSIZE = 40, - PROTOTYPE = 41, - NOPROTOOPT = 42, - PROTONOSUPPORT = 43, - SOCKTNOSUPPORT = 44, - /// Also used for NOTSUP - OPNOTSUPP = 45, - PFNOSUPPORT = 46, - AFNOSUPPORT = 47, - ADDRINUSE = 48, - ADDRNOTAVAIL = 49, - NETDOWN = 50, - NETUNREACH = 51, - NETRESET = 52, - CONNABORTED = 53, - CONNRESET = 54, - NOBUFS = 55, - ISCONN = 56, - NOTCONN = 57, - SHUTDOWN = 58, - TOOMANYREFS = 59, - TIMEDOUT = 60, - CONNREFUSED = 61, - LOOP = 62, - NAMETOOLONG = 63, - HOSTDOWN = 64, - HOSTUNREACH = 65, - NOTEMPTY = 66, - PROCLIM = 67, - USERS = 68, - DQUOT = 69, - STALE = 70, - REMOTE = 71, - NOSTR = 72, - TIME = 73, - NOSR = 74, - NOMSG = 75, - BADMSG = 76, - IDRM = 77, - DEADLK = 78, - NOLCK = 79, - NONET = 80, - RREMOTE = 81, - NOLINK = 82, - ADV = 83, - SRMNT = 84, - COMM = 85, - PROTO = 86, - MULTIHOP = 87, - DOTDOT = 88, - REMCHG = 89, - NOSYS = 90, - STRPIPE = 91, - OVERFLOW = 92, - BADFD = 93, - CHRNG = 94, - L2NSYNC = 95, - L3HLT = 96, - L3RST = 97, - LNRNG = 98, - UNATCH = 99, - NOCSI = 100, - L2HLT = 101, - BADE = 102, - BADR = 103, - XFULL = 104, - NOANO = 105, - BADRQC = 106, - BADSLT = 107, - DEADLOCK = 108, - BFONT = 109, - LIBEXEC = 110, - NODATA = 111, - LIBBAD = 112, - NOPKG = 113, - LIBACC = 114, - NOTUNIQ = 115, - RESTART = 116, - UCLEAN = 117, - NOTNAM = 118, - NAVAIL = 119, - ISNAM = 120, - REMOTEIO = 121, - ILSEQ = 122, - LIBMAX = 123, - LIBSCN = 124, - NOMEDIUM = 125, - MEDIUMTYPE = 126, - CANCELED = 127, - NOKEY = 128, - KEYEXPIRED = 129, - KEYREVOKED = 130, - KEYREJECTED = 131, - OWNERDEAD = 132, - NOTRECOVERABLE = 133, - RFKILL = 134, - HWPOISON = 135, - _, -}; diff --git a/lib/std/os/bits/linux/i386.zig b/lib/std/os/bits/linux/i386.zig deleted file mode 100644 index 12c8fa4713..0000000000 --- a/lib/std/os/bits/linux/i386.zig +++ /dev/null @@ -1,670 +0,0 @@ -// i386-specific declarations that are intended to be imported into the POSIX namespace. -// This does include Linux-only APIs. - -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; - -pub const SYS = enum(usize) { - restart_syscall = 0, - exit = 1, - fork = 2, - read = 3, - write = 4, - open = 5, - close = 6, - waitpid = 7, - creat = 8, - link = 9, - unlink = 10, - execve = 11, - chdir = 12, - time = 13, - mknod = 14, - chmod = 15, - lchown = 16, - @"break" = 17, - oldstat = 18, - lseek = 19, - getpid = 20, - mount = 21, - umount = 22, - setuid = 23, - getuid = 24, - stime = 25, - ptrace = 26, - alarm = 27, - oldfstat = 28, - pause = 29, - utime = 30, - stty = 31, - gtty = 32, - access = 33, - nice = 34, - ftime = 35, - sync = 36, - kill = 37, - rename = 38, - mkdir = 39, - rmdir = 40, - dup = 41, - pipe = 42, - times = 43, - prof = 44, - brk = 45, - setgid = 46, - getgid = 47, - signal = 48, - geteuid = 49, - getegid = 50, - acct = 51, - umount2 = 52, - lock = 53, - ioctl = 54, - fcntl = 55, - mpx = 56, - setpgid = 57, - ulimit = 58, - oldolduname = 59, - umask = 60, - chroot = 61, - ustat = 62, - dup2 = 63, - getppid = 64, - getpgrp = 65, - setsid = 66, - sigaction = 67, - sgetmask = 68, - ssetmask = 69, - setreuid = 70, - setregid = 71, - sigsuspend = 72, - sigpending = 73, - sethostname = 74, - setrlimit = 75, - getrlimit = 76, - getrusage = 77, - gettimeofday = 78, - settimeofday = 79, - getgroups = 80, - setgroups = 81, - select = 82, - symlink = 83, - oldlstat = 84, - readlink = 85, - uselib = 86, - swapon = 87, - reboot = 88, - readdir = 89, - mmap = 90, - munmap = 91, - truncate = 92, - ftruncate = 93, - fchmod = 94, - fchown = 95, - getpriority = 96, - setpriority = 97, - profil = 98, - statfs = 99, - fstatfs = 100, - ioperm = 101, - socketcall = 102, - syslog = 103, - setitimer = 104, - getitimer = 105, - stat = 106, - lstat = 107, - fstat = 108, - olduname = 109, - iopl = 110, - vhangup = 111, - idle = 112, - vm86old = 113, - wait4 = 114, - swapoff = 115, - sysinfo = 116, - ipc = 117, - fsync = 118, - sigreturn = 119, - clone = 120, - setdomainname = 121, - uname = 122, - modify_ldt = 123, - adjtimex = 124, - mprotect = 125, - sigprocmask = 126, - create_module = 127, - init_module = 128, - delete_module = 129, - get_kernel_syms = 130, - quotactl = 131, - getpgid = 132, - fchdir = 133, - bdflush = 134, - sysfs = 135, - personality = 136, - afs_syscall = 137, - setfsuid = 138, - setfsgid = 139, - _llseek = 140, - getdents = 141, - _newselect = 142, - flock = 143, - msync = 144, - readv = 145, - writev = 146, - getsid = 147, - fdatasync = 148, - _sysctl = 149, - mlock = 150, - munlock = 151, - mlockall = 152, - munlockall = 153, - sched_setparam = 154, - sched_getparam = 155, - sched_setscheduler = 156, - sched_getscheduler = 157, - sched_yield = 158, - sched_get_priority_max = 159, - sched_get_priority_min = 160, - sched_rr_get_interval = 161, - nanosleep = 162, - mremap = 163, - setresuid = 164, - getresuid = 165, - vm86 = 166, - query_module = 167, - poll = 168, - nfsservctl = 169, - setresgid = 170, - getresgid = 171, - prctl = 172, - rt_sigreturn = 173, - rt_sigaction = 174, - rt_sigprocmask = 175, - rt_sigpending = 176, - rt_sigtimedwait = 177, - rt_sigqueueinfo = 178, - rt_sigsuspend = 179, - pread64 = 180, - pwrite64 = 181, - chown = 182, - getcwd = 183, - capget = 184, - capset = 185, - sigaltstack = 186, - sendfile = 187, - getpmsg = 188, - putpmsg = 189, - vfork = 190, - ugetrlimit = 191, - mmap2 = 192, - truncate64 = 193, - ftruncate64 = 194, - stat64 = 195, - lstat64 = 196, - fstat64 = 197, - lchown32 = 198, - getuid32 = 199, - getgid32 = 200, - geteuid32 = 201, - getegid32 = 202, - setreuid32 = 203, - setregid32 = 204, - getgroups32 = 205, - setgroups32 = 206, - fchown32 = 207, - setresuid32 = 208, - getresuid32 = 209, - setresgid32 = 210, - getresgid32 = 211, - chown32 = 212, - setuid32 = 213, - setgid32 = 214, - setfsuid32 = 215, - setfsgid32 = 216, - pivot_root = 217, - mincore = 218, - madvise = 219, - getdents64 = 220, - fcntl64 = 221, - gettid = 224, - readahead = 225, - setxattr = 226, - lsetxattr = 227, - fsetxattr = 228, - getxattr = 229, - lgetxattr = 230, - fgetxattr = 231, - listxattr = 232, - llistxattr = 233, - flistxattr = 234, - removexattr = 235, - lremovexattr = 236, - fremovexattr = 237, - tkill = 238, - sendfile64 = 239, - futex = 240, - sched_setaffinity = 241, - sched_getaffinity = 242, - set_thread_area = 243, - get_thread_area = 244, - io_setup = 245, - io_destroy = 246, - io_getevents = 247, - io_submit = 248, - io_cancel = 249, - fadvise64 = 250, - exit_group = 252, - lookup_dcookie = 253, - epoll_create = 254, - epoll_ctl = 255, - epoll_wait = 256, - remap_file_pages = 257, - set_tid_address = 258, - timer_create = 259, - timer_settime, // SYS_timer_create + 1 - timer_gettime, // SYS_timer_create + 2 - timer_getoverrun, // SYS_timer_create + 3 - timer_delete, // SYS_timer_create + 4 - clock_settime, // SYS_timer_create + 5 - clock_gettime, // SYS_timer_create + 6 - clock_getres, // SYS_timer_create + 7 - clock_nanosleep, // SYS_timer_create + 8 - statfs64 = 268, - fstatfs64 = 269, - tgkill = 270, - utimes = 271, - fadvise64_64 = 272, - vserver = 273, - mbind = 274, - get_mempolicy = 275, - set_mempolicy = 276, - mq_open = 277, - mq_unlink, // SYS_mq_open + 1 - mq_timedsend, // SYS_mq_open + 2 - mq_timedreceive, // SYS_mq_open + 3 - mq_notify, // SYS_mq_open + 4 - mq_getsetattr, // SYS_mq_open + 5 - kexec_load = 283, - waitid = 284, - add_key = 286, - request_key = 287, - keyctl = 288, - ioprio_set = 289, - ioprio_get = 290, - inotify_init = 291, - inotify_add_watch = 292, - inotify_rm_watch = 293, - migrate_pages = 294, - openat = 295, - mkdirat = 296, - mknodat = 297, - fchownat = 298, - futimesat = 299, - fstatat64 = 300, - unlinkat = 301, - renameat = 302, - linkat = 303, - symlinkat = 304, - readlinkat = 305, - fchmodat = 306, - faccessat = 307, - pselect6 = 308, - ppoll = 309, - unshare = 310, - set_robust_list = 311, - get_robust_list = 312, - splice = 313, - sync_file_range = 314, - tee = 315, - vmsplice = 316, - move_pages = 317, - getcpu = 318, - epoll_pwait = 319, - utimensat = 320, - signalfd = 321, - timerfd_create = 322, - eventfd = 323, - fallocate = 324, - timerfd_settime = 325, - timerfd_gettime = 326, - signalfd4 = 327, - eventfd2 = 328, - epoll_create1 = 329, - dup3 = 330, - pipe2 = 331, - inotify_init1 = 332, - preadv = 333, - pwritev = 334, - rt_tgsigqueueinfo = 335, - perf_event_open = 336, - recvmmsg = 337, - fanotify_init = 338, - fanotify_mark = 339, - prlimit64 = 340, - name_to_handle_at = 341, - open_by_handle_at = 342, - clock_adjtime = 343, - syncfs = 344, - sendmmsg = 345, - setns = 346, - process_vm_readv = 347, - process_vm_writev = 348, - kcmp = 349, - finit_module = 350, - sched_setattr = 351, - sched_getattr = 352, - renameat2 = 353, - seccomp = 354, - getrandom = 355, - memfd_create = 356, - bpf = 357, - execveat = 358, - socket = 359, - socketpair = 360, - bind = 361, - connect = 362, - listen = 363, - accept4 = 364, - getsockopt = 365, - setsockopt = 366, - getsockname = 367, - getpeername = 368, - sendto = 369, - sendmsg = 370, - recvfrom = 371, - recvmsg = 372, - shutdown = 373, - userfaultfd = 374, - membarrier = 375, - mlock2 = 376, - copy_file_range = 377, - preadv2 = 378, - pwritev2 = 379, - pkey_mprotect = 380, - pkey_alloc = 381, - pkey_free = 382, - statx = 383, - arch_prctl = 384, - io_pgetevents = 385, - rseq = 386, - semget = 393, - semctl = 394, - shmget = 395, - shmctl = 396, - shmat = 397, - shmdt = 398, - msgget = 399, - msgsnd = 400, - msgrcv = 401, - msgctl = 402, - clock_gettime64 = 403, - clock_settime64 = 404, - clock_adjtime64 = 405, - clock_getres_time64 = 406, - clock_nanosleep_time64 = 407, - timer_gettime64 = 408, - timer_settime64 = 409, - timerfd_gettime64 = 410, - timerfd_settime64 = 411, - utimensat_time64 = 412, - pselect6_time64 = 413, - ppoll_time64 = 414, - io_pgetevents_time64 = 416, - recvmmsg_time64 = 417, - mq_timedsend_time64 = 418, - mq_timedreceive_time64 = 419, - semtimedop_time64 = 420, - rt_sigtimedwait_time64 = 421, - futex_time64 = 422, - sched_rr_get_interval_time64 = 423, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - _, -}; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0o100000; -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 = 12; -pub const F_SETLK = 13; -pub const F_SETLKW = 14; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const 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_32BIT = 0x40; - -pub const MMAP2_UNIT = 4096; - -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: i32, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: i32, -}; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = isize; -pub const mode_t = u32; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; -pub const blkcnt_t = i64; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - __dev_padding: u32, - __ino_truncated: u32, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __rdev_padding: u32, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - ino: ino_t, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const timespec = extern struct { - tv_sec: i32, - tv_nsec: i32, -}; - -pub const timeval = extern struct { - tv_sec: i32, - tv_usec: i32, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const mcontext_t = extern struct { - gregs: [19]usize, - fpregs: [*]u8, - oldmask: usize, - cr2: usize, -}; - -pub const REG_GS = 0; -pub const REG_FS = 1; -pub const REG_ES = 2; -pub const REG_DS = 3; -pub const REG_EDI = 4; -pub const REG_ESI = 5; -pub const REG_EBP = 6; -pub const REG_ESP = 7; -pub const REG_EBX = 8; -pub const REG_EDX = 9; -pub const REG_ECX = 10; -pub const REG_EAX = 11; -pub const REG_TRAPNO = 12; -pub const REG_ERR = 13; -pub const REG_EIP = 14; -pub const REG_CS = 15; -pub const REG_EFL = 16; -pub const REG_UESP = 17; -pub const REG_SS = 18; - -pub const ucontext_t = extern struct { - flags: usize, - link: *ucontext_t, - stack: stack_t, - mcontext: mcontext_t, - sigmask: sigset_t, - regspace: [64]u64, -}; - -pub const Elf_Symndx = u32; - -pub const user_desc = packed struct { - entry_number: u32, - base_addr: u32, - limit: u32, - seg_32bit: u1, - contents: u2, - read_exec_only: u1, - limit_in_pages: u1, - seg_not_present: u1, - useable: u1, -}; - -// socketcall() call numbers -pub const SC_socket = 1; -pub const SC_bind = 2; -pub const SC_connect = 3; -pub const SC_listen = 4; -pub const SC_accept = 5; -pub const SC_getsockname = 6; -pub const SC_getpeername = 7; -pub const SC_socketpair = 8; -pub const SC_send = 9; -pub const SC_recv = 10; -pub const SC_sendto = 11; -pub const SC_recvfrom = 12; -pub const SC_shutdown = 13; -pub const SC_setsockopt = 14; -pub const SC_getsockopt = 15; -pub const SC_sendmsg = 16; -pub const SC_recvmsg = 17; -pub const SC_accept4 = 18; -pub const SC_recvmmsg = 19; -pub const SC_sendmmsg = 20; diff --git a/lib/std/os/bits/linux/mips.zig b/lib/std/os/bits/linux/mips.zig deleted file mode 100644 index ddf241fb4d..0000000000 --- a/lib/std/os/bits/linux/mips.zig +++ /dev/null @@ -1,622 +0,0 @@ -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; - -pub const SYS = enum(usize) { - pub const Linux = 4000; - - syscall = Linux + 0, - exit = Linux + 1, - fork = Linux + 2, - read = Linux + 3, - write = Linux + 4, - open = Linux + 5, - close = Linux + 6, - waitpid = Linux + 7, - creat = Linux + 8, - link = Linux + 9, - unlink = Linux + 10, - execve = Linux + 11, - chdir = Linux + 12, - time = Linux + 13, - mknod = Linux + 14, - chmod = Linux + 15, - lchown = Linux + 16, - @"break" = Linux + 17, - unused18 = Linux + 18, - lseek = Linux + 19, - getpid = Linux + 20, - mount = Linux + 21, - umount = Linux + 22, - setuid = Linux + 23, - getuid = Linux + 24, - stime = Linux + 25, - ptrace = Linux + 26, - alarm = Linux + 27, - unused28 = Linux + 28, - pause = Linux + 29, - utime = Linux + 30, - stty = Linux + 31, - gtty = Linux + 32, - access = Linux + 33, - nice = Linux + 34, - ftime = Linux + 35, - sync = Linux + 36, - kill = Linux + 37, - rename = Linux + 38, - mkdir = Linux + 39, - rmdir = Linux + 40, - dup = Linux + 41, - pipe = Linux + 42, - times = Linux + 43, - prof = Linux + 44, - brk = Linux + 45, - setgid = Linux + 46, - getgid = Linux + 47, - signal = Linux + 48, - geteuid = Linux + 49, - getegid = Linux + 50, - acct = Linux + 51, - umount2 = Linux + 52, - lock = Linux + 53, - ioctl = Linux + 54, - fcntl = Linux + 55, - mpx = Linux + 56, - setpgid = Linux + 57, - ulimit = Linux + 58, - unused59 = Linux + 59, - umask = Linux + 60, - chroot = Linux + 61, - ustat = Linux + 62, - dup2 = Linux + 63, - getppid = Linux + 64, - getpgrp = Linux + 65, - setsid = Linux + 66, - sigaction = Linux + 67, - sgetmask = Linux + 68, - ssetmask = Linux + 69, - setreuid = Linux + 70, - setregid = Linux + 71, - sigsuspend = Linux + 72, - sigpending = Linux + 73, - sethostname = Linux + 74, - setrlimit = Linux + 75, - getrlimit = Linux + 76, - getrusage = Linux + 77, - gettimeofday = Linux + 78, - settimeofday = Linux + 79, - getgroups = Linux + 80, - setgroups = Linux + 81, - reserved82 = Linux + 82, - symlink = Linux + 83, - unused84 = Linux + 84, - readlink = Linux + 85, - uselib = Linux + 86, - swapon = Linux + 87, - reboot = Linux + 88, - readdir = Linux + 89, - mmap = Linux + 90, - munmap = Linux + 91, - truncate = Linux + 92, - ftruncate = Linux + 93, - fchmod = Linux + 94, - fchown = Linux + 95, - getpriority = Linux + 96, - setpriority = Linux + 97, - profil = Linux + 98, - statfs = Linux + 99, - fstatfs = Linux + 100, - ioperm = Linux + 101, - socketcall = Linux + 102, - syslog = Linux + 103, - setitimer = Linux + 104, - getitimer = Linux + 105, - stat = Linux + 106, - lstat = Linux + 107, - fstat = Linux + 108, - unused109 = Linux + 109, - iopl = Linux + 110, - vhangup = Linux + 111, - idle = Linux + 112, - vm86 = Linux + 113, - wait4 = Linux + 114, - swapoff = Linux + 115, - sysinfo = Linux + 116, - ipc = Linux + 117, - fsync = Linux + 118, - sigreturn = Linux + 119, - clone = Linux + 120, - setdomainname = Linux + 121, - uname = Linux + 122, - modify_ldt = Linux + 123, - adjtimex = Linux + 124, - mprotect = Linux + 125, - sigprocmask = Linux + 126, - create_module = Linux + 127, - init_module = Linux + 128, - delete_module = Linux + 129, - get_kernel_syms = Linux + 130, - quotactl = Linux + 131, - getpgid = Linux + 132, - fchdir = Linux + 133, - bdflush = Linux + 134, - sysfs = Linux + 135, - personality = Linux + 136, - afs_syscall = Linux + 137, - setfsuid = Linux + 138, - setfsgid = Linux + 139, - _llseek = Linux + 140, - getdents = Linux + 141, - _newselect = Linux + 142, - flock = Linux + 143, - msync = Linux + 144, - readv = Linux + 145, - writev = Linux + 146, - cacheflush = Linux + 147, - cachectl = Linux + 148, - sysmips = Linux + 149, - unused150 = Linux + 150, - getsid = Linux + 151, - fdatasync = Linux + 152, - _sysctl = Linux + 153, - mlock = Linux + 154, - munlock = Linux + 155, - mlockall = Linux + 156, - munlockall = Linux + 157, - sched_setparam = Linux + 158, - sched_getparam = Linux + 159, - sched_setscheduler = Linux + 160, - sched_getscheduler = Linux + 161, - sched_yield = Linux + 162, - sched_get_priority_max = Linux + 163, - sched_get_priority_min = Linux + 164, - sched_rr_get_interval = Linux + 165, - nanosleep = Linux + 166, - mremap = Linux + 167, - accept = Linux + 168, - bind = Linux + 169, - connect = Linux + 170, - getpeername = Linux + 171, - getsockname = Linux + 172, - getsockopt = Linux + 173, - listen = Linux + 174, - recv = Linux + 175, - recvfrom = Linux + 176, - recvmsg = Linux + 177, - send = Linux + 178, - sendmsg = Linux + 179, - sendto = Linux + 180, - setsockopt = Linux + 181, - shutdown = Linux + 182, - socket = Linux + 183, - socketpair = Linux + 184, - setresuid = Linux + 185, - getresuid = Linux + 186, - query_module = Linux + 187, - poll = Linux + 188, - nfsservctl = Linux + 189, - setresgid = Linux + 190, - getresgid = Linux + 191, - prctl = Linux + 192, - rt_sigreturn = Linux + 193, - rt_sigaction = Linux + 194, - rt_sigprocmask = Linux + 195, - rt_sigpending = Linux + 196, - rt_sigtimedwait = Linux + 197, - rt_sigqueueinfo = Linux + 198, - rt_sigsuspend = Linux + 199, - pread64 = Linux + 200, - pwrite64 = Linux + 201, - chown = Linux + 202, - getcwd = Linux + 203, - capget = Linux + 204, - capset = Linux + 205, - sigaltstack = Linux + 206, - sendfile = Linux + 207, - getpmsg = Linux + 208, - putpmsg = Linux + 209, - mmap2 = Linux + 210, - truncate64 = Linux + 211, - ftruncate64 = Linux + 212, - stat64 = Linux + 213, - lstat64 = Linux + 214, - fstat64 = Linux + 215, - pivot_root = Linux + 216, - mincore = Linux + 217, - madvise = Linux + 218, - getdents64 = Linux + 219, - fcntl64 = Linux + 220, - reserved221 = Linux + 221, - gettid = Linux + 222, - readahead = Linux + 223, - setxattr = Linux + 224, - lsetxattr = Linux + 225, - fsetxattr = Linux + 226, - getxattr = Linux + 227, - lgetxattr = Linux + 228, - fgetxattr = Linux + 229, - listxattr = Linux + 230, - llistxattr = Linux + 231, - flistxattr = Linux + 232, - removexattr = Linux + 233, - lremovexattr = Linux + 234, - fremovexattr = Linux + 235, - tkill = Linux + 236, - sendfile64 = Linux + 237, - futex = Linux + 238, - sched_setaffinity = Linux + 239, - sched_getaffinity = Linux + 240, - io_setup = Linux + 241, - io_destroy = Linux + 242, - io_getevents = Linux + 243, - io_submit = Linux + 244, - io_cancel = Linux + 245, - exit_group = Linux + 246, - lookup_dcookie = Linux + 247, - epoll_create = Linux + 248, - epoll_ctl = Linux + 249, - epoll_wait = Linux + 250, - remap_file_pages = Linux + 251, - set_tid_address = Linux + 252, - restart_syscall = Linux + 253, - fadvise64 = Linux + 254, - statfs64 = Linux + 255, - fstatfs64 = Linux + 256, - timer_create = Linux + 257, - timer_settime = Linux + 258, - timer_gettime = Linux + 259, - timer_getoverrun = Linux + 260, - timer_delete = Linux + 261, - clock_settime = Linux + 262, - clock_gettime = Linux + 263, - clock_getres = Linux + 264, - clock_nanosleep = Linux + 265, - tgkill = Linux + 266, - utimes = Linux + 267, - mbind = Linux + 268, - get_mempolicy = Linux + 269, - set_mempolicy = Linux + 270, - mq_open = Linux + 271, - mq_unlink = Linux + 272, - mq_timedsend = Linux + 273, - mq_timedreceive = Linux + 274, - mq_notify = Linux + 275, - mq_getsetattr = Linux + 276, - vserver = Linux + 277, - waitid = Linux + 278, - add_key = Linux + 280, - request_key = Linux + 281, - keyctl = Linux + 282, - set_thread_area = Linux + 283, - inotify_init = Linux + 284, - inotify_add_watch = Linux + 285, - inotify_rm_watch = Linux + 286, - migrate_pages = Linux + 287, - openat = Linux + 288, - mkdirat = Linux + 289, - mknodat = Linux + 290, - fchownat = Linux + 291, - futimesat = Linux + 292, - fstatat64 = Linux + 293, - unlinkat = Linux + 294, - renameat = Linux + 295, - linkat = Linux + 296, - symlinkat = Linux + 297, - readlinkat = Linux + 298, - fchmodat = Linux + 299, - faccessat = Linux + 300, - pselect6 = Linux + 301, - ppoll = Linux + 302, - unshare = Linux + 303, - splice = Linux + 304, - sync_file_range = Linux + 305, - tee = Linux + 306, - vmsplice = Linux + 307, - move_pages = Linux + 308, - set_robust_list = Linux + 309, - get_robust_list = Linux + 310, - kexec_load = Linux + 311, - getcpu = Linux + 312, - epoll_pwait = Linux + 313, - ioprio_set = Linux + 314, - ioprio_get = Linux + 315, - utimensat = Linux + 316, - signalfd = Linux + 317, - timerfd = Linux + 318, - eventfd = Linux + 319, - fallocate = Linux + 320, - timerfd_create = Linux + 321, - timerfd_gettime = Linux + 322, - timerfd_settime = Linux + 323, - signalfd4 = Linux + 324, - eventfd2 = Linux + 325, - epoll_create1 = Linux + 326, - dup3 = Linux + 327, - pipe2 = Linux + 328, - inotify_init1 = Linux + 329, - preadv = Linux + 330, - pwritev = Linux + 331, - rt_tgsigqueueinfo = Linux + 332, - perf_event_open = Linux + 333, - accept4 = Linux + 334, - recvmmsg = Linux + 335, - fanotify_init = Linux + 336, - fanotify_mark = Linux + 337, - prlimit64 = Linux + 338, - name_to_handle_at = Linux + 339, - open_by_handle_at = Linux + 340, - clock_adjtime = Linux + 341, - syncfs = Linux + 342, - sendmmsg = Linux + 343, - setns = Linux + 344, - process_vm_readv = Linux + 345, - process_vm_writev = Linux + 346, - kcmp = Linux + 347, - finit_module = Linux + 348, - sched_setattr = Linux + 349, - sched_getattr = Linux + 350, - renameat2 = Linux + 351, - seccomp = Linux + 352, - getrandom = Linux + 353, - memfd_create = Linux + 354, - bpf = Linux + 355, - execveat = Linux + 356, - userfaultfd = Linux + 357, - membarrier = Linux + 358, - mlock2 = Linux + 359, - copy_file_range = Linux + 360, - preadv2 = Linux + 361, - pwritev2 = Linux + 362, - pkey_mprotect = Linux + 363, - pkey_alloc = Linux + 364, - pkey_free = Linux + 365, - statx = Linux + 366, - rseq = Linux + 367, - io_pgetevents = Linux + 368, - semget = Linux + 393, - semctl = Linux + 394, - shmget = Linux + 395, - shmctl = Linux + 396, - shmat = Linux + 397, - shmdt = Linux + 398, - msgget = Linux + 399, - msgsnd = Linux + 400, - msgrcv = Linux + 401, - msgctl = Linux + 402, - clock_gettime64 = Linux + 403, - clock_settime64 = Linux + 404, - clock_adjtime64 = Linux + 405, - clock_getres_time64 = Linux + 406, - clock_nanosleep_time64 = Linux + 407, - timer_gettime64 = Linux + 408, - timer_settime64 = Linux + 409, - timerfd_gettime64 = Linux + 410, - timerfd_settime64 = Linux + 411, - utimensat_time64 = Linux + 412, - pselect6_time64 = Linux + 413, - ppoll_time64 = Linux + 414, - io_pgetevents_time64 = Linux + 416, - recvmmsg_time64 = Linux + 417, - mq_timedsend_time64 = Linux + 418, - mq_timedreceive_time64 = Linux + 419, - semtimedop_time64 = Linux + 420, - rt_sigtimedwait_time64 = Linux + 421, - futex_time64 = Linux + 422, - sched_rr_get_interval_time64 = Linux + 423, - pidfd_send_signal = Linux + 424, - io_uring_setup = Linux + 425, - io_uring_enter = Linux + 426, - io_uring_register = Linux + 427, - open_tree = Linux + 428, - move_mount = Linux + 429, - fsopen = Linux + 430, - fsconfig = Linux + 431, - fsmount = Linux + 432, - fspick = Linux + 433, - pidfd_open = Linux + 434, - clone3 = Linux + 435, - close_range = Linux + 436, - openat2 = Linux + 437, - pidfd_getfd = Linux + 438, - faccessat2 = Linux + 439, - process_madvise = Linux + 440, - epoll_pwait2 = Linux + 441, - - _, -}; - -pub const O_CREAT = 0o0400; -pub const O_EXCL = 0o02000; -pub const O_NOCTTY = 0o04000; -pub const O_TRUNC = 0o01000; -pub const O_APPEND = 0o0010; -pub const O_NONBLOCK = 0o0200; -pub const O_DSYNC = 0o0020; -pub const O_SYNC = 0o040020; -pub const O_RSYNC = 0o040020; -pub const O_DIRECTORY = 0o0200000; -pub const O_NOFOLLOW = 0o0400000; -pub const O_CLOEXEC = 0o02000000; - -pub const O_ASYNC = 0o010000; -pub const O_DIRECT = 0o0100000; -pub const O_LARGEFILE = 0o020000; -pub const O_NOATIME = 0o01000000; -pub const O_PATH = 0o010000000; -pub const O_TMPFILE = 0o020200000; -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 = 24; -pub const F_GETOWN = 23; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_GETLK = 33; -pub const F_SETLK = 34; -pub const F_SETLKW = 35; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const MMAP2_UNIT = 4096; - -pub const MAP_NORESERVE = 0x0400; -pub const MAP_GROWSDOWN = 0x1000; -pub const MAP_DENYWRITE = 0x2000; -pub const MAP_EXECUTABLE = 0x4000; -pub const MAP_LOCKED = 0x8000; -pub const MAP_32BIT = 0x40; - -pub const SO_DEBUG = 1; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_LINGER = 0x0080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_ACCEPTCONN = 0x1009; -pub const SO_PROTOCOL = 0x1028; -pub const SO_DOMAIN = 0x1029; -pub const SO_NO_CHECK = 11; -pub const SO_PRIORITY = 12; -pub const SO_BSDCOMPAT = 14; -pub const SO_PASSCRED = 17; -pub const SO_PEERCRED = 18; -pub const SO_PEERSEC = 30; -pub const SO_SNDBUFFORCE = 31; -pub const SO_RCVBUFFORCE = 33; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6.39"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - __pad0: [4]u8, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - __unused: [4]u8, -}; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = i32; -pub const mode_t = u32; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; -pub const blkcnt_t = i64; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: u32, - __pad0: [3]u32, // Reserved for st_dev expansion - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: u32, - __pad1: [3]u32, - size: off_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - blksize: blksize_t, - __pad3: u32, - blocks: blkcnt_t, - __pad4: [14]usize, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const libc_stat = extern struct { - dev: dev_t, - __pad0: [2]u32, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad1: [2]u32, - size: off_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - blksize: blksize_t, - __pad3: u32, - blocks: blkcnt_t, - __pad4: [14]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const Elf_Symndx = u32; diff --git a/lib/std/os/bits/linux/netlink.zig b/lib/std/os/bits/linux/netlink.zig deleted file mode 100644 index 9de546fb20..0000000000 --- a/lib/std/os/bits/linux/netlink.zig +++ /dev/null @@ -1,498 +0,0 @@ -usingnamespace @import("../linux.zig"); - -/// Routing/device hook -pub const NETLINK_ROUTE = 0; - -/// Unused number -pub const NETLINK_UNUSED = 1; - -/// Reserved for user mode socket protocols -pub const NETLINK_USERSOCK = 2; - -/// Unused number, formerly ip_queue -pub const NETLINK_FIREWALL = 3; - -/// socket monitoring -pub const NETLINK_SOCK_DIAG = 4; - -/// netfilter/iptables ULOG -pub const NETLINK_NFLOG = 5; - -/// ipsec -pub const NETLINK_XFRM = 6; - -/// SELinux event notifications -pub const NETLINK_SELINUX = 7; - -/// Open-iSCSI -pub const NETLINK_ISCSI = 8; - -/// auditing -pub const NETLINK_AUDIT = 9; - -pub const NETLINK_FIB_LOOKUP = 10; - -pub const NETLINK_CONNECTOR = 11; - -/// netfilter subsystem -pub const NETLINK_NETFILTER = 12; - -pub const NETLINK_IP6_FW = 13; - -/// DECnet routing messages -pub const NETLINK_DNRTMSG = 14; - -/// Kernel messages to userspace -pub const NETLINK_KOBJECT_UEVENT = 15; - -pub const NETLINK_GENERIC = 16; - -// leave room for NETLINK_DM (DM Events) - -/// SCSI Transports -pub const NETLINK_SCSITRANSPORT = 18; - -pub const NETLINK_ECRYPTFS = 19; - -pub const NETLINK_RDMA = 20; - -/// Crypto layer -pub const NETLINK_CRYPTO = 21; - -/// SMC monitoring -pub const NETLINK_SMC = 22; - -// Flags values - -/// It is request message. -pub const NLM_F_REQUEST = 0x01; - -/// Multipart message, terminated by NLMSG_DONE -pub const NLM_F_MULTI = 0x02; - -/// Reply with ack, with zero or error code -pub const NLM_F_ACK = 0x04; - -/// Echo this request -pub const NLM_F_ECHO = 0x08; - -/// Dump was inconsistent due to sequence change -pub const NLM_F_DUMP_INTR = 0x10; - -/// Dump was filtered as requested -pub const NLM_F_DUMP_FILTERED = 0x20; - -// Modifiers to GET request - -/// specify tree root -pub const NLM_F_ROOT = 0x100; - -/// return all matching -pub const NLM_F_MATCH = 0x200; - -/// atomic GET -pub const NLM_F_ATOMIC = 0x400; -pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH; - -// Modifiers to NEW request - -/// Override existing -pub const NLM_F_REPLACE = 0x100; - -/// Do not touch, if it exists -pub const NLM_F_EXCL = 0x200; - -/// Create, if it does not exist -pub const NLM_F_CREATE = 0x400; - -/// Add to end of list -pub const NLM_F_APPEND = 0x800; - -// Modifiers to DELETE request - -/// Do not delete recursively -pub const NLM_F_NONREC = 0x100; - -// Flags for ACK message - -/// request was capped -pub const NLM_F_CAPPED = 0x100; - -/// extended ACK TVLs were included -pub const NLM_F_ACK_TLVS = 0x200; - -pub const NetlinkMessageType = enum(u16) { - /// < 0x10: reserved control messages - pub const MIN_TYPE = 0x10; - - /// Nothing. - NOOP = 0x1, - - /// Error - ERROR = 0x2, - - /// End of a dump - DONE = 0x3, - - /// Data lost - OVERRUN = 0x4, - - // rtlink types - - RTM_NEWLINK = 16, - RTM_DELLINK, - RTM_GETLINK, - RTM_SETLINK, - - RTM_NEWADDR = 20, - RTM_DELADDR, - RTM_GETADDR, - - RTM_NEWROUTE = 24, - RTM_DELROUTE, - RTM_GETROUTE, - - RTM_NEWNEIGH = 28, - RTM_DELNEIGH, - RTM_GETNEIGH, - - RTM_NEWRULE = 32, - RTM_DELRULE, - RTM_GETRULE, - - RTM_NEWQDISC = 36, - RTM_DELQDISC, - RTM_GETQDISC, - - RTM_NEWTCLASS = 40, - RTM_DELTCLASS, - RTM_GETTCLASS, - - RTM_NEWTFILTER = 44, - RTM_DELTFILTER, - RTM_GETTFILTER, - - RTM_NEWACTION = 48, - RTM_DELACTION, - RTM_GETACTION, - - RTM_NEWPREFIX = 52, - - RTM_GETMULTICAST = 58, - - RTM_GETANYCAST = 62, - - RTM_NEWNEIGHTBL = 64, - RTM_GETNEIGHTBL = 66, - RTM_SETNEIGHTBL, - - RTM_NEWNDUSEROPT = 68, - - RTM_NEWADDRLABEL = 72, - RTM_DELADDRLABEL, - RTM_GETADDRLABEL, - - RTM_GETDCB = 78, - RTM_SETDCB, - - RTM_NEWNETCONF = 80, - RTM_DELNETCONF, - RTM_GETNETCONF = 82, - - RTM_NEWMDB = 84, - RTM_DELMDB = 85, - RTM_GETMDB = 86, - - RTM_NEWNSID = 88, - RTM_DELNSID = 89, - RTM_GETNSID = 90, - - RTM_NEWSTATS = 92, - RTM_GETSTATS = 94, - - RTM_NEWCACHEREPORT = 96, - - RTM_NEWCHAIN = 100, - RTM_DELCHAIN, - RTM_GETCHAIN, - - RTM_NEWNEXTHOP = 104, - RTM_DELNEXTHOP, - RTM_GETNEXTHOP, - - _, -}; - -/// Netlink socket address -pub const sockaddr_nl = extern struct { - family: sa_family_t = AF_NETLINK, - __pad1: c_ushort = 0, - - /// port ID - pid: u32, - - /// multicast groups mask - groups: u32, -}; - -/// Netlink message header -/// Specified in RFC 3549 Section 2.3.2 -pub const nlmsghdr = extern struct { - /// Length of message including header - len: u32, - - /// Message content - @"type": NetlinkMessageType, - - /// Additional flags - flags: u16, - - /// Sequence number - seq: u32, - - /// Sending process port ID - pid: u32, -}; - -pub const ifinfomsg = extern struct { - family: u8, - __pad1: u8 = 0, - - /// ARPHRD_* - @"type": c_ushort, - - /// Link index - index: c_int, - - /// IFF_* flags - flags: c_uint, - - /// IFF_* change mask - change: c_uint, -}; - -pub const rtattr = extern struct { - /// Length of option - len: c_ushort, - - /// Type of option - @"type": IFLA, - - pub const ALIGNTO = 4; -}; - -pub const IFLA = enum(c_ushort) { - UNSPEC, - ADDRESS, - BROADCAST, - IFNAME, - MTU, - LINK, - QDISC, - STATS, - COST, - PRIORITY, - MASTER, - - /// Wireless Extension event - WIRELESS, - - /// Protocol specific information for a link - PROTINFO, - - TXQLEN, - MAP, - WEIGHT, - OPERSTATE, - LINKMODE, - LINKINFO, - NET_NS_PID, - IFALIAS, - - /// Number of VFs if device is SR-IOV PF - NUM_VF, - - VFINFO_LIST, - STATS64, - VF_PORTS, - PORT_SELF, - AF_SPEC, - - /// Group the device belongs to - GROUP, - - NET_NS_FD, - - /// Extended info mask, VFs, etc - EXT_MASK, - - /// Promiscuity count: > 0 means acts PROMISC - PROMISCUITY, - - NUM_TX_QUEUES, - NUM_RX_QUEUES, - CARRIER, - PHYS_PORT_ID, - CARRIER_CHANGES, - PHYS_SWITCH_ID, - LINK_NETNSID, - PHYS_PORT_NAME, - PROTO_DOWN, - GSO_MAX_SEGS, - GSO_MAX_SIZE, - PAD, - XDP, - EVENT, - - NEW_NETNSID, - IF_NETNSID, - - CARRIER_UP_COUNT, - CARRIER_DOWN_COUNT, - NEW_IFINDEX, - MIN_MTU, - MAX_MTU, - - _, - - pub const TARGET_NETNSID: IFLA = .IF_NETNSID; -}; - -pub const rtnl_link_ifmap = extern struct { - mem_start: u64, - mem_end: u64, - base_addr: u64, - irq: u16, - dma: u8, - port: u8, -}; - -pub const rtnl_link_stats = extern struct { - /// total packets received - rx_packets: u32, - - /// total packets transmitted - tx_packets: u32, - - /// total bytes received - rx_bytes: u32, - - /// total bytes transmitted - tx_bytes: u32, - - /// bad packets received - rx_errors: u32, - - /// packet transmit problems - tx_errors: u32, - - /// no space in linux buffers - rx_dropped: u32, - - /// no space available in linux - tx_dropped: u32, - - /// multicast packets received - multicast: u32, - - collisions: u32, - - // detailed rx_errors - - rx_length_errors: u32, - - /// receiver ring buff overflow - rx_over_errors: u32, - - /// recved pkt with crc error - rx_crc_errors: u32, - - /// recv'd frame alignment error - rx_frame_errors: u32, - - /// recv'r fifo overrun - rx_fifo_errors: u32, - - /// receiver missed packet - rx_missed_errors: u32, - - // detailed tx_errors - tx_aborted_errors: u32, - tx_carrier_errors: u32, - tx_fifo_errors: u32, - tx_heartbeat_errors: u32, - tx_window_errors: u32, - - // for cslip etc - - rx_compressed: u32, - tx_compressed: u32, - - /// dropped, no handler found - rx_nohandler: u32, -}; - -pub const rtnl_link_stats64 = extern struct { - /// total packets received - rx_packets: u64, - - /// total packets transmitted - tx_packets: u64, - - /// total bytes received - rx_bytes: u64, - - /// total bytes transmitted - tx_bytes: u64, - - /// bad packets received - rx_errors: u64, - - /// packet transmit problems - tx_errors: u64, - - /// no space in linux buffers - rx_dropped: u64, - - /// no space available in linux - tx_dropped: u64, - - /// multicast packets received - multicast: u64, - - collisions: u64, - - // detailed rx_errors - - rx_length_errors: u64, - - /// receiver ring buff overflow - rx_over_errors: u64, - - /// recved pkt with crc error - rx_crc_errors: u64, - - /// recv'd frame alignment error - rx_frame_errors: u64, - - /// recv'r fifo overrun - rx_fifo_errors: u64, - - /// receiver missed packet - rx_missed_errors: u64, - - // detailed tx_errors - tx_aborted_errors: u64, - tx_carrier_errors: u64, - tx_fifo_errors: u64, - tx_heartbeat_errors: u64, - tx_window_errors: u64, - - // for cslip etc - - rx_compressed: u64, - tx_compressed: u64, - - /// dropped, no handler found - rx_nohandler: u64, -}; diff --git a/lib/std/os/bits/linux/powerpc.zig b/lib/std/os/bits/linux/powerpc.zig deleted file mode 100644 index 06f8e326ba..0000000000 --- a/lib/std/os/bits/linux/powerpc.zig +++ /dev/null @@ -1,621 +0,0 @@ -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; -pub const SYS = enum(usize) { - restart_syscall = 0, - exit = 1, - fork = 2, - read = 3, - write = 4, - open = 5, - close = 6, - waitpid = 7, - creat = 8, - link = 9, - unlink = 10, - execve = 11, - chdir = 12, - time = 13, - mknod = 14, - chmod = 15, - lchown = 16, - @"break" = 17, - oldstat = 18, - lseek = 19, - getpid = 20, - mount = 21, - umount = 22, - setuid = 23, - getuid = 24, - stime = 25, - ptrace = 26, - alarm = 27, - oldfstat = 28, - pause = 29, - utime = 30, - stty = 31, - gtty = 32, - access = 33, - nice = 34, - ftime = 35, - sync = 36, - kill = 37, - rename = 38, - mkdir = 39, - rmdir = 40, - dup = 41, - pipe = 42, - times = 43, - prof = 44, - brk = 45, - setgid = 46, - getgid = 47, - signal = 48, - geteuid = 49, - getegid = 50, - acct = 51, - umount2 = 52, - lock = 53, - ioctl = 54, - fcntl = 55, - mpx = 56, - setpgid = 57, - ulimit = 58, - oldolduname = 59, - umask = 60, - chroot = 61, - ustat = 62, - dup2 = 63, - getppid = 64, - getpgrp = 65, - setsid = 66, - sigaction = 67, - sgetmask = 68, - ssetmask = 69, - setreuid = 70, - setregid = 71, - sigsuspend = 72, - sigpending = 73, - sethostname = 74, - setrlimit = 75, - getrlimit = 76, - getrusage = 77, - gettimeofday = 78, - settimeofday = 79, - getgroups = 80, - setgroups = 81, - select = 82, - symlink = 83, - oldlstat = 84, - readlink = 85, - uselib = 86, - swapon = 87, - reboot = 88, - readdir = 89, - mmap = 90, - munmap = 91, - truncate = 92, - ftruncate = 93, - fchmod = 94, - fchown = 95, - getpriority = 96, - setpriority = 97, - profil = 98, - statfs = 99, - fstatfs = 100, - ioperm = 101, - socketcall = 102, - syslog = 103, - setitimer = 104, - getitimer = 105, - stat = 106, - lstat = 107, - fstat = 108, - olduname = 109, - iopl = 110, - vhangup = 111, - idle = 112, - vm86 = 113, - wait4 = 114, - swapoff = 115, - sysinfo = 116, - ipc = 117, - fsync = 118, - sigreturn = 119, - clone = 120, - setdomainname = 121, - uname = 122, - modify_ldt = 123, - adjtimex = 124, - mprotect = 125, - sigprocmask = 126, - create_module = 127, - init_module = 128, - delete_module = 129, - get_kernel_syms = 130, - quotactl = 131, - getpgid = 132, - fchdir = 133, - bdflush = 134, - sysfs = 135, - personality = 136, - afs_syscall = 137, - setfsuid = 138, - setfsgid = 139, - _llseek = 140, - getdents = 141, - _newselect = 142, - flock = 143, - msync = 144, - readv = 145, - writev = 146, - getsid = 147, - fdatasync = 148, - _sysctl = 149, - mlock = 150, - munlock = 151, - mlockall = 152, - munlockall = 153, - sched_setparam = 154, - sched_getparam = 155, - sched_setscheduler = 156, - sched_getscheduler = 157, - sched_yield = 158, - sched_get_priority_max = 159, - sched_get_priority_min = 160, - sched_rr_get_interval = 161, - nanosleep = 162, - mremap = 163, - setresuid = 164, - getresuid = 165, - query_module = 166, - poll = 167, - nfsservctl = 168, - setresgid = 169, - getresgid = 170, - prctl = 171, - rt_sigreturn = 172, - rt_sigaction = 173, - rt_sigprocmask = 174, - rt_sigpending = 175, - rt_sigtimedwait = 176, - rt_sigqueueinfo = 177, - rt_sigsuspend = 178, - pread64 = 179, - pwrite64 = 180, - chown = 181, - getcwd = 182, - capget = 183, - capset = 184, - sigaltstack = 185, - sendfile = 186, - getpmsg = 187, - putpmsg = 188, - vfork = 189, - ugetrlimit = 190, - readahead = 191, - mmap2 = 192, - truncate64 = 193, - ftruncate64 = 194, - stat64 = 195, - lstat64 = 196, - fstat64 = 197, - pciconfig_read = 198, - pciconfig_write = 199, - pciconfig_iobase = 200, - multiplexer = 201, - getdents64 = 202, - pivot_root = 203, - fcntl64 = 204, - madvise = 205, - mincore = 206, - gettid = 207, - tkill = 208, - setxattr = 209, - lsetxattr = 210, - fsetxattr = 211, - getxattr = 212, - lgetxattr = 213, - fgetxattr = 214, - listxattr = 215, - llistxattr = 216, - flistxattr = 217, - removexattr = 218, - lremovexattr = 219, - fremovexattr = 220, - futex = 221, - sched_setaffinity = 222, - sched_getaffinity = 223, - tuxcall = 225, - sendfile64 = 226, - io_setup = 227, - io_destroy = 228, - io_getevents = 229, - io_submit = 230, - io_cancel = 231, - set_tid_address = 232, - fadvise64 = 233, - exit_group = 234, - lookup_dcookie = 235, - epoll_create = 236, - epoll_ctl = 237, - epoll_wait = 238, - remap_file_pages = 239, - timer_create = 240, - timer_settime = 241, - timer_gettime = 242, - timer_getoverrun = 243, - timer_delete = 244, - clock_settime = 245, - clock_gettime = 246, - clock_getres = 247, - clock_nanosleep = 248, - swapcontext = 249, - tgkill = 250, - utimes = 251, - statfs64 = 252, - fstatfs64 = 253, - fadvise64_64 = 254, - rtas = 255, - sys_debug_setcontext = 256, - migrate_pages = 258, - mbind = 259, - get_mempolicy = 260, - set_mempolicy = 261, - mq_open = 262, - mq_unlink = 263, - mq_timedsend = 264, - mq_timedreceive = 265, - mq_notify = 266, - mq_getsetattr = 267, - kexec_load = 268, - add_key = 269, - request_key = 270, - keyctl = 271, - waitid = 272, - ioprio_set = 273, - ioprio_get = 274, - inotify_init = 275, - inotify_add_watch = 276, - inotify_rm_watch = 277, - spu_run = 278, - spu_create = 279, - pselect6 = 280, - ppoll = 281, - unshare = 282, - splice = 283, - tee = 284, - vmsplice = 285, - openat = 286, - mkdirat = 287, - mknodat = 288, - fchownat = 289, - futimesat = 290, - fstatat64 = 291, - unlinkat = 292, - renameat = 293, - linkat = 294, - symlinkat = 295, - readlinkat = 296, - fchmodat = 297, - faccessat = 298, - get_robust_list = 299, - set_robust_list = 300, - move_pages = 301, - getcpu = 302, - epoll_pwait = 303, - utimensat = 304, - signalfd = 305, - timerfd_create = 306, - eventfd = 307, - sync_file_range = 308, - fallocate = 309, - subpage_prot = 310, - timerfd_settime = 311, - timerfd_gettime = 312, - signalfd4 = 313, - eventfd2 = 314, - epoll_create1 = 315, - dup3 = 316, - pipe2 = 317, - inotify_init1 = 318, - perf_event_open = 319, - preadv = 320, - pwritev = 321, - rt_tgsigqueueinfo = 322, - fanotify_init = 323, - fanotify_mark = 324, - prlimit64 = 325, - socket = 326, - bind = 327, - connect = 328, - listen = 329, - accept = 330, - getsockname = 331, - getpeername = 332, - socketpair = 333, - send = 334, - sendto = 335, - recv = 336, - recvfrom = 337, - shutdown = 338, - setsockopt = 339, - getsockopt = 340, - sendmsg = 341, - recvmsg = 342, - recvmmsg = 343, - accept4 = 344, - name_to_handle_at = 345, - open_by_handle_at = 346, - clock_adjtime = 347, - syncfs = 348, - sendmmsg = 349, - setns = 350, - process_vm_readv = 351, - process_vm_writev = 352, - finit_module = 353, - kcmp = 354, - sched_setattr = 355, - sched_getattr = 356, - renameat2 = 357, - seccomp = 358, - getrandom = 359, - memfd_create = 360, - bpf = 361, - execveat = 362, - switch_endian = 363, - userfaultfd = 364, - membarrier = 365, - mlock2 = 378, - copy_file_range = 379, - preadv2 = 380, - pwritev2 = 381, - kexec_file_load = 382, - statx = 383, - pkey_alloc = 384, - pkey_free = 385, - pkey_mprotect = 386, - rseq = 387, - io_pgetevents = 388, - semget = 393, - semctl = 394, - shmget = 395, - shmctl = 396, - shmat = 397, - shmdt = 398, - msgget = 399, - msgsnd = 400, - msgrcv = 401, - msgctl = 402, - clock_gettime64 = 403, - clock_settime64 = 404, - clock_adjtime64 = 405, - clock_getres_time64 = 406, - clock_nanosleep_time64 = 407, - timer_gettime64 = 408, - timer_settime64 = 409, - timerfd_gettime64 = 410, - timerfd_settime64 = 411, - utimensat_time64 = 412, - pselect6_time64 = 413, - ppoll_time64 = 414, - io_pgetevents_time64 = 416, - recvmmsg_time64 = 417, - mq_timedsend_time64 = 418, - mq_timedreceive_time64 = 419, - semtimedop_time64 = 420, - rt_sigtimedwait_time64 = 421, - futex_time64 = 422, - sched_rr_get_interval_time64 = 423, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, -}; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o400000; -pub const O_LARGEFILE = 0o200000; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20040000; -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 = 12; -pub const F_SETLK = 13; -pub const F_SETLKW = 14; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x0080; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x0040; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6.15"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: usize, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: usize, - msg_control: ?*c_void, - msg_controllen: socklen_t, - msg_flags: i32, -}; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = isize; -pub const mode_t = u32; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; -pub const blkcnt_t = i64; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __rdev_padding: i16, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: time_t, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const greg_t = u32; -pub const gregset_t = [48]greg_t; -pub const fpregset_t = [33]f64; - -pub const vrregset = extern struct { - vrregs: [32][4]u32, - vrsave: u32, - _pad: [2]u32, - vscr: u32, -}; -pub const vrregset_t = vrregset; - -pub const mcontext_t = extern struct { - gp_regs: gregset_t, - fp_regs: fpregset_t, - v_regs: vrregset_t align(16), -}; - -pub const ucontext_t = extern struct { - flags: u32, - link: *ucontext_t, - stack: stack_t, - pad: [7]i32, - regs: *mcontext_t, - sigmask: sigset_t, - pad2: [3]i32, - mcontext: mcontext_t, -}; - -pub const Elf_Symndx = u32; - -pub const MMAP2_UNIT = 4096; diff --git a/lib/std/os/bits/linux/powerpc64.zig b/lib/std/os/bits/linux/powerpc64.zig deleted file mode 100644 index 74c6ad11fc..0000000000 --- a/lib/std/os/bits/linux/powerpc64.zig +++ /dev/null @@ -1,604 +0,0 @@ -const std = @import("../../../std.zig"); -const linux = std.os.linux; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const pid_t = linux.pid_t; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; -pub const SYS = enum(usize) { - restart_syscall = 0, - exit = 1, - fork = 2, - read = 3, - write = 4, - open = 5, - close = 6, - waitpid = 7, - creat = 8, - link = 9, - unlink = 10, - execve = 11, - chdir = 12, - time = 13, - mknod = 14, - chmod = 15, - lchown = 16, - @"break" = 17, - oldstat = 18, - lseek = 19, - getpid = 20, - mount = 21, - umount = 22, - setuid = 23, - getuid = 24, - stime = 25, - ptrace = 26, - alarm = 27, - oldfstat = 28, - pause = 29, - utime = 30, - stty = 31, - gtty = 32, - access = 33, - nice = 34, - ftime = 35, - sync = 36, - kill = 37, - rename = 38, - mkdir = 39, - rmdir = 40, - dup = 41, - pipe = 42, - times = 43, - prof = 44, - brk = 45, - setgid = 46, - getgid = 47, - signal = 48, - geteuid = 49, - getegid = 50, - acct = 51, - umount2 = 52, - lock = 53, - ioctl = 54, - fcntl = 55, - mpx = 56, - setpgid = 57, - ulimit = 58, - oldolduname = 59, - umask = 60, - chroot = 61, - ustat = 62, - dup2 = 63, - getppid = 64, - getpgrp = 65, - setsid = 66, - sigaction = 67, - sgetmask = 68, - ssetmask = 69, - setreuid = 70, - setregid = 71, - sigsuspend = 72, - sigpending = 73, - sethostname = 74, - setrlimit = 75, - getrlimit = 76, - getrusage = 77, - gettimeofday = 78, - settimeofday = 79, - getgroups = 80, - setgroups = 81, - select = 82, - symlink = 83, - oldlstat = 84, - readlink = 85, - uselib = 86, - swapon = 87, - reboot = 88, - readdir = 89, - mmap = 90, - munmap = 91, - truncate = 92, - ftruncate = 93, - fchmod = 94, - fchown = 95, - getpriority = 96, - setpriority = 97, - profil = 98, - statfs = 99, - fstatfs = 100, - ioperm = 101, - socketcall = 102, - syslog = 103, - setitimer = 104, - getitimer = 105, - stat = 106, - lstat = 107, - fstat = 108, - olduname = 109, - iopl = 110, - vhangup = 111, - idle = 112, - vm86 = 113, - wait4 = 114, - swapoff = 115, - sysinfo = 116, - ipc = 117, - fsync = 118, - sigreturn = 119, - clone = 120, - setdomainname = 121, - uname = 122, - modify_ldt = 123, - adjtimex = 124, - mprotect = 125, - sigprocmask = 126, - create_module = 127, - init_module = 128, - delete_module = 129, - get_kernel_syms = 130, - quotactl = 131, - getpgid = 132, - fchdir = 133, - bdflush = 134, - sysfs = 135, - personality = 136, - afs_syscall = 137, - setfsuid = 138, - setfsgid = 139, - _llseek = 140, - getdents = 141, - _newselect = 142, - flock = 143, - msync = 144, - readv = 145, - writev = 146, - getsid = 147, - fdatasync = 148, - _sysctl = 149, - mlock = 150, - munlock = 151, - mlockall = 152, - munlockall = 153, - sched_setparam = 154, - sched_getparam = 155, - sched_setscheduler = 156, - sched_getscheduler = 157, - sched_yield = 158, - sched_get_priority_max = 159, - sched_get_priority_min = 160, - sched_rr_get_interval = 161, - nanosleep = 162, - mremap = 163, - setresuid = 164, - getresuid = 165, - query_module = 166, - poll = 167, - nfsservctl = 168, - setresgid = 169, - getresgid = 170, - prctl = 171, - rt_sigreturn = 172, - rt_sigaction = 173, - rt_sigprocmask = 174, - rt_sigpending = 175, - rt_sigtimedwait = 176, - rt_sigqueueinfo = 177, - rt_sigsuspend = 178, - pread64 = 179, - pwrite64 = 180, - chown = 181, - getcwd = 182, - capget = 183, - capset = 184, - sigaltstack = 185, - sendfile = 186, - getpmsg = 187, - putpmsg = 188, - vfork = 189, - ugetrlimit = 190, - readahead = 191, - pciconfig_read = 198, - pciconfig_write = 199, - pciconfig_iobase = 200, - multiplexer = 201, - getdents64 = 202, - pivot_root = 203, - madvise = 205, - mincore = 206, - gettid = 207, - tkill = 208, - setxattr = 209, - lsetxattr = 210, - fsetxattr = 211, - getxattr = 212, - lgetxattr = 213, - fgetxattr = 214, - listxattr = 215, - llistxattr = 216, - flistxattr = 217, - removexattr = 218, - lremovexattr = 219, - fremovexattr = 220, - futex = 221, - sched_setaffinity = 222, - sched_getaffinity = 223, - tuxcall = 225, - io_setup = 227, - io_destroy = 228, - io_getevents = 229, - io_submit = 230, - io_cancel = 231, - set_tid_address = 232, - fadvise64 = 233, - exit_group = 234, - lookup_dcookie = 235, - epoll_create = 236, - epoll_ctl = 237, - epoll_wait = 238, - remap_file_pages = 239, - timer_create = 240, - timer_settime = 241, - timer_gettime = 242, - timer_getoverrun = 243, - timer_delete = 244, - clock_settime = 245, - clock_gettime = 246, - clock_getres = 247, - clock_nanosleep = 248, - swapcontext = 249, - tgkill = 250, - utimes = 251, - statfs64 = 252, - fstatfs64 = 253, - rtas = 255, - sys_debug_setcontext = 256, - migrate_pages = 258, - mbind = 259, - get_mempolicy = 260, - set_mempolicy = 261, - mq_open = 262, - mq_unlink = 263, - mq_timedsend = 264, - mq_timedreceive = 265, - mq_notify = 266, - mq_getsetattr = 267, - kexec_load = 268, - add_key = 269, - request_key = 270, - keyctl = 271, - waitid = 272, - ioprio_set = 273, - ioprio_get = 274, - inotify_init = 275, - inotify_add_watch = 276, - inotify_rm_watch = 277, - spu_run = 278, - spu_create = 279, - pselect6 = 280, - ppoll = 281, - unshare = 282, - splice = 283, - tee = 284, - vmsplice = 285, - openat = 286, - mkdirat = 287, - mknodat = 288, - fchownat = 289, - futimesat = 290, - fstatat = 291, - unlinkat = 292, - renameat = 293, - linkat = 294, - symlinkat = 295, - readlinkat = 296, - fchmodat = 297, - faccessat = 298, - get_robust_list = 299, - set_robust_list = 300, - move_pages = 301, - getcpu = 302, - epoll_pwait = 303, - utimensat = 304, - signalfd = 305, - timerfd_create = 306, - eventfd = 307, - sync_file_range = 308, - fallocate = 309, - subpage_prot = 310, - timerfd_settime = 311, - timerfd_gettime = 312, - signalfd4 = 313, - eventfd2 = 314, - epoll_create1 = 315, - dup3 = 316, - pipe2 = 317, - inotify_init1 = 318, - perf_event_open = 319, - preadv = 320, - pwritev = 321, - rt_tgsigqueueinfo = 322, - fanotify_init = 323, - fanotify_mark = 324, - prlimit64 = 325, - socket = 326, - bind = 327, - connect = 328, - listen = 329, - accept = 330, - getsockname = 331, - getpeername = 332, - socketpair = 333, - send = 334, - sendto = 335, - recv = 336, - recvfrom = 337, - shutdown = 338, - setsockopt = 339, - getsockopt = 340, - sendmsg = 341, - recvmsg = 342, - recvmmsg = 343, - accept4 = 344, - name_to_handle_at = 345, - open_by_handle_at = 346, - clock_adjtime = 347, - syncfs = 348, - sendmmsg = 349, - setns = 350, - process_vm_readv = 351, - process_vm_writev = 352, - finit_module = 353, - kcmp = 354, - sched_setattr = 355, - sched_getattr = 356, - renameat2 = 357, - seccomp = 358, - getrandom = 359, - memfd_create = 360, - bpf = 361, - execveat = 362, - switch_endian = 363, - userfaultfd = 364, - membarrier = 365, - mlock2 = 378, - copy_file_range = 379, - preadv2 = 380, - pwritev2 = 381, - kexec_file_load = 382, - statx = 383, - pkey_alloc = 384, - pkey_free = 385, - pkey_mprotect = 386, - rseq = 387, - io_pgetevents = 388, - semtimedop = 392, - semget = 393, - semctl = 394, - shmget = 395, - shmctl = 396, - shmat = 397, - shmdt = 398, - msgget = 399, - msgsnd = 400, - msgrcv = 401, - msgctl = 402, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - _, -}; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o40000; -pub const O_NOFOLLOW = 0o100000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o400000; -pub const O_LARGEFILE = 0o200000; -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_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x0080; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x0040; - -pub const VDSO_CGT_SYM = "__kernel_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6.15"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - __unused: [4]u8, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: usize, - msg_control: ?*c_void, - msg_controllen: usize, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: usize, - msg_control: ?*c_void, - msg_controllen: usize, - msg_flags: i32, -}; - -pub const blksize_t = i64; -pub const nlink_t = u64; -pub const time_t = i64; -pub const mode_t = u32; -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; -pub const blkcnt_t = i64; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - ino: ino_t, - nlink: nlink_t, - mode: mode_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]u64, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const greg_t = u64; -pub const gregset_t = [48]greg_t; -pub const fpregset_t = [33]f64; - -/// The position of the vscr register depends on endianness. -/// On C, macros are used to change vscr_word's offset to -/// account for this. Here we'll just define vscr_word_le -/// and vscr_word_be. Code must take care to use the correct one. -pub const vrregset = extern struct { - vrregs: [32][4]u32 align(16), - vscr_word_le: u32, - _pad1: [2]u32, - vscr_word_be: u32, - vrsave: u32, - _pad2: [3]u32, -}; -pub const vrregset_t = vrregset; - -pub const mcontext_t = extern struct { - __unused: [4]u64, - signal: i32, - _pad0: i32, - handler: u64, - oldmask: u64, - regs: ?*c_void, - gp_regs: gregset_t, - fp_regs: fpregset_t, - v_regs: *vrregset_t, - vmx_reserve: [34 + 34 + 32 + 1]i64, -}; - -pub const ucontext_t = extern struct { - flags: u32, - link: *ucontext_t, - stack: stack_t, - sigmask: sigset_t, - mcontext: mcontext_t, -}; - -pub const Elf_Symndx = u32; diff --git a/lib/std/os/bits/linux/prctl.zig b/lib/std/os/bits/linux/prctl.zig deleted file mode 100644 index d29b6021b6..0000000000 --- a/lib/std/os/bits/linux/prctl.zig +++ /dev/null @@ -1,234 +0,0 @@ -pub const PR = enum(i32) { - SET_PDEATHSIG = 1, - GET_PDEATHSIG = 2, - - GET_DUMPABLE = 3, - SET_DUMPABLE = 4, - - GET_UNALIGN = 5, - SET_UNALIGN = 6, - - GET_KEEPCAPS = 7, - SET_KEEPCAPS = 8, - - GET_FPEMU = 9, - SET_FPEMU = 10, - - GET_FPEXC = 11, - SET_FPEXC = 12, - - GET_TIMING = 13, - SET_TIMING = 14, - - SET_NAME = 15, - GET_NAME = 16, - - GET_ENDIAN = 19, - SET_ENDIAN = 20, - - GET_SECCOMP = 21, - SET_SECCOMP = 22, - - CAPBSET_READ = 23, - CAPBSET_DROP = 24, - - GET_TSC = 25, - SET_TSC = 26, - - GET_SECUREBITS = 27, - SET_SECUREBITS = 28, - - SET_TIMERSLACK = 29, - GET_TIMERSLACK = 30, - - TASK_PERF_EVENTS_DISABLE = 31, - TASK_PERF_EVENTS_ENABLE = 32, - - MCE_KILL = 33, - - MCE_KILL_GET = 34, - - SET_MM = 35, - - SET_PTRACER = 0x59616d61, - - SET_CHILD_SUBREAPER = 36, - GET_CHILD_SUBREAPER = 37, - - SET_NO_NEW_PRIVS = 38, - GET_NO_NEW_PRIVS = 39, - - GET_TID_ADDRESS = 40, - - SET_THP_DISABLE = 41, - GET_THP_DISABLE = 42, - - MPX_ENABLE_MANAGEMENT = 43, - MPX_DISABLE_MANAGEMENT = 44, - - SET_FP_MODE = 45, - GET_FP_MODE = 46, - - CAP_AMBIENT = 47, - - SVE_SET_VL = 50, - SVE_GET_VL = 51, - - GET_SPECULATION_CTRL = 52, - SET_SPECULATION_CTRL = 53, - - _, -}; - -pub const PR_SET_PDEATHSIG = @enumToInt(PR.SET_PDEATHSIG); -pub const PR_GET_PDEATHSIG = @enumToInt(PR.GET_PDEATHSIG); - -pub const PR_GET_DUMPABLE = @enumToInt(PR.GET_DUMPABLE); -pub const PR_SET_DUMPABLE = @enumToInt(PR.SET_DUMPABLE); - -pub const PR_GET_UNALIGN = @enumToInt(PR.GET_UNALIGN); -pub const PR_SET_UNALIGN = @enumToInt(PR.SET_UNALIGN); -pub const PR_UNALIGN_NOPRINT = 1; -pub const PR_UNALIGN_SIGBUS = 2; - -pub const PR_GET_KEEPCAPS = @enumToInt(PR.GET_KEEPCAPS); -pub const PR_SET_KEEPCAPS = @enumToInt(PR.SET_KEEPCAPS); - -pub const PR_GET_FPEMU = @enumToInt(PR.GET_FPEMU); -pub const PR_SET_FPEMU = @enumToInt(PR.SET_FPEMU); -pub const PR_FPEMU_NOPRINT = 1; -pub const PR_FPEMU_SIGFPE = 2; - -pub const PR_GET_FPEXC = @enumToInt(PR.GET_FPEXC); -pub const PR_SET_FPEXC = @enumToInt(PR.SET_FPEXC); -pub const PR_FP_EXC_SW_ENABLE = 0x80; -pub const PR_FP_EXC_DIV = 0x010000; -pub const PR_FP_EXC_OVF = 0x020000; -pub const PR_FP_EXC_UND = 0x040000; -pub const PR_FP_EXC_RES = 0x080000; -pub const PR_FP_EXC_INV = 0x100000; -pub const PR_FP_EXC_DISABLED = 0; -pub const PR_FP_EXC_NONRECOV = 1; -pub const PR_FP_EXC_ASYNC = 2; -pub const PR_FP_EXC_PRECISE = 3; - -pub const PR_GET_TIMING = @enumToInt(PR.GET_TIMING); -pub const PR_SET_TIMING = @enumToInt(PR.SET_TIMING); -pub const PR_TIMING_STATISTICAL = 0; -pub const PR_TIMING_TIMESTAMP = 1; - -pub const PR_SET_NAME = @enumToInt(PR.SET_NAME); -pub const PR_GET_NAME = @enumToInt(PR.GET_NAME); - -pub const PR_GET_ENDIAN = @enumToInt(PR.GET_ENDIAN); -pub const PR_SET_ENDIAN = @enumToInt(PR.SET_ENDIAN); -pub const PR_ENDIAN_BIG = 0; -pub const PR_ENDIAN_LITTLE = 1; -pub const PR_ENDIAN_PPC_LITTLE = 2; - -pub const PR_GET_SECCOMP = @enumToInt(PR.GET_SECCOMP); -pub const PR_SET_SECCOMP = @enumToInt(PR.SET_SECCOMP); - -pub const PR_CAPBSET_READ = @enumToInt(PR.CAPBSET_READ); -pub const PR_CAPBSET_DROP = @enumToInt(PR.CAPBSET_DROP); - -pub const PR_GET_TSC = @enumToInt(PR.GET_TSC); -pub const PR_SET_TSC = @enumToInt(PR.SET_TSC); -pub const PR_TSC_ENABLE = 1; -pub const PR_TSC_SIGSEGV = 2; - -pub const PR_GET_SECUREBITS = @enumToInt(PR.GET_SECUREBITS); -pub const PR_SET_SECUREBITS = @enumToInt(PR.SET_SECUREBITS); - -pub const PR_SET_TIMERSLACK = @enumToInt(PR.SET_TIMERSLACK); -pub const PR_GET_TIMERSLACK = @enumToInt(PR.GET_TIMERSLACK); - -pub const PR_TASK_PERF_EVENTS_DISABLE = @enumToInt(PR.TASK_PERF_EVENTS_DISABLE); -pub const PR_TASK_PERF_EVENTS_ENABLE = @enumToInt(PR.TASK_PERF_EVENTS_ENABLE); - -pub const PR_MCE_KILL = @enumToInt(PR.MCE_KILL); -pub const PR_MCE_KILL_CLEAR = 0; -pub const PR_MCE_KILL_SET = 1; - -pub const PR_MCE_KILL_LATE = 0; -pub const PR_MCE_KILL_EARLY = 1; -pub const PR_MCE_KILL_DEFAULT = 2; - -pub const PR_MCE_KILL_GET = @enumToInt(PR.MCE_KILL_GET); - -pub const PR_SET_MM = @enumToInt(PR.SET_MM); -pub const PR_SET_MM_START_CODE = 1; -pub const PR_SET_MM_END_CODE = 2; -pub const PR_SET_MM_START_DATA = 3; -pub const PR_SET_MM_END_DATA = 4; -pub const PR_SET_MM_START_STACK = 5; -pub const PR_SET_MM_START_BRK = 6; -pub const PR_SET_MM_BRK = 7; -pub const PR_SET_MM_ARG_START = 8; -pub const PR_SET_MM_ARG_END = 9; -pub const PR_SET_MM_ENV_START = 10; -pub const PR_SET_MM_ENV_END = 11; -pub const PR_SET_MM_AUXV = 12; -pub const PR_SET_MM_EXE_FILE = 13; -pub const PR_SET_MM_MAP = 14; -pub const PR_SET_MM_MAP_SIZE = 15; - -pub const prctl_mm_map = extern struct { - start_code: u64, - end_code: u64, - start_data: u64, - end_data: u64, - start_brk: u64, - brk: u64, - start_stack: u64, - arg_start: u64, - arg_end: u64, - env_start: u64, - env_end: u64, - auxv: *u64, - auxv_size: u32, - exe_fd: u32, -}; - -pub const PR_SET_PTRACER = @enumToInt(PR.SET_PTRACER); -pub const PR_SET_PTRACER_ANY = std.math.maxInt(c_ulong); - -pub const PR_SET_CHILD_SUBREAPER = @enumToInt(PR.SET_CHILD_SUBREAPER); -pub const PR_GET_CHILD_SUBREAPER = @enumToInt(PR.GET_CHILD_SUBREAPER); - -pub const PR_SET_NO_NEW_PRIVS = @enumToInt(PR.SET_NO_NEW_PRIVS); -pub const PR_GET_NO_NEW_PRIVS = @enumToInt(PR.GET_NO_NEW_PRIVS); - -pub const PR_GET_TID_ADDRESS = @enumToInt(PR.GET_TID_ADDRESS); - -pub const PR_SET_THP_DISABLE = @enumToInt(PR.SET_THP_DISABLE); -pub const PR_GET_THP_DISABLE = @enumToInt(PR.GET_THP_DISABLE); - -pub const PR_MPX_ENABLE_MANAGEMENT = @enumToInt(PR.MPX_ENABLE_MANAGEMENT); -pub const PR_MPX_DISABLE_MANAGEMENT = @enumToInt(PR.MPX_DISABLE_MANAGEMENT); - -pub const PR_SET_FP_MODE = @enumToInt(PR.SET_FP_MODE); -pub const PR_GET_FP_MODE = @enumToInt(PR.GET_FP_MODE); -pub const PR_FP_MODE_FR = 1 << 0; -pub const PR_FP_MODE_FRE = 1 << 1; - -pub const PR_CAP_AMBIENT = @enumToInt(PR.CAP_AMBIENT); -pub const PR_CAP_AMBIENT_IS_SET = 1; -pub const PR_CAP_AMBIENT_RAISE = 2; -pub const PR_CAP_AMBIENT_LOWER = 3; -pub const PR_CAP_AMBIENT_CLEAR_ALL = 4; - -pub const PR_SVE_SET_VL = @enumToInt(PR.SVE_SET_VL); -pub const PR_SVE_SET_VL_ONEXEC = 1 << 18; -pub const PR_SVE_GET_VL = @enumToInt(PR.SVE_GET_VL); -pub const PR_SVE_VL_LEN_MASK = 0xffff; -pub const PR_SVE_VL_INHERIT = 1 << 17; - -pub const PR_GET_SPECULATION_CTRL = @enumToInt(PR.GET_SPECULATION_CTRL); -pub const PR_SET_SPECULATION_CTRL = @enumToInt(PR.SET_SPECULATION_CTRL); -pub const PR_SPEC_STORE_BYPASS = 0; -pub const PR_SPEC_NOT_AFFECTED = 0; -pub const PR_SPEC_PRCTL = 1 << 0; -pub const PR_SPEC_ENABLE = 1 << 1; -pub const PR_SPEC_DISABLE = 1 << 2; -pub const PR_SPEC_FORCE_DISABLE = 1 << 3; diff --git a/lib/std/os/bits/linux/riscv64.zig b/lib/std/os/bits/linux/riscv64.zig deleted file mode 100644 index 7a0811cc1a..0000000000 --- a/lib/std/os/bits/linux/riscv64.zig +++ /dev/null @@ -1,423 +0,0 @@ -// riscv64-specific declarations that are intended to be imported into the POSIX namespace. -const std = @import("../../../std.zig"); -const uid_t = std.os.linux.uid_t; -const gid_t = std.os.linux.gid_t; -const pid_t = std.os.linux.pid_t; - -pub const SYS = enum(usize) { - pub const arch_specific_syscall = 244; - - io_setup = 0, - io_destroy = 1, - io_submit = 2, - io_cancel = 3, - io_getevents = 4, - setxattr = 5, - lsetxattr = 6, - fsetxattr = 7, - getxattr = 8, - lgetxattr = 9, - fgetxattr = 10, - listxattr = 11, - llistxattr = 12, - flistxattr = 13, - removexattr = 14, - lremovexattr = 15, - fremovexattr = 16, - getcwd = 17, - lookup_dcookie = 18, - eventfd2 = 19, - epoll_create1 = 20, - epoll_ctl = 21, - epoll_pwait = 22, - dup = 23, - dup3 = 24, - fcntl = 25, - inotify_init1 = 26, - inotify_add_watch = 27, - inotify_rm_watch = 28, - ioctl = 29, - ioprio_set = 30, - ioprio_get = 31, - flock = 32, - mknodat = 33, - mkdirat = 34, - unlinkat = 35, - symlinkat = 36, - linkat = 37, - umount2 = 39, - mount = 40, - pivot_root = 41, - nfsservctl = 42, - statfs = 43, - fstatfs = 44, - truncate = 45, - ftruncate = 46, - fallocate = 47, - faccessat = 48, - chdir = 49, - fchdir = 50, - chroot = 51, - fchmod = 52, - fchmodat = 53, - fchownat = 54, - fchown = 55, - openat = 56, - close = 57, - vhangup = 58, - pipe2 = 59, - quotactl = 60, - getdents64 = 61, - lseek = 62, - read = 63, - write = 64, - readv = 65, - writev = 66, - pread64 = 67, - pwrite64 = 68, - preadv = 69, - pwritev = 70, - sendfile = 71, - pselect6 = 72, - ppoll = 73, - signalfd4 = 74, - vmsplice = 75, - splice = 76, - tee = 77, - readlinkat = 78, - fstatat = 79, - fstat = 80, - sync = 81, - fsync = 82, - fdatasync = 83, - sync_file_range = 84, - timerfd_create = 85, - timerfd_settime = 86, - timerfd_gettime = 87, - utimensat = 88, - acct = 89, - capget = 90, - capset = 91, - personality = 92, - exit = 93, - exit_group = 94, - waitid = 95, - set_tid_address = 96, - unshare = 97, - futex = 98, - set_robust_list = 99, - get_robust_list = 100, - nanosleep = 101, - getitimer = 102, - setitimer = 103, - kexec_load = 104, - init_module = 105, - delete_module = 106, - timer_create = 107, - timer_gettime = 108, - timer_getoverrun = 109, - timer_settime = 110, - timer_delete = 111, - clock_settime = 112, - clock_gettime = 113, - clock_getres = 114, - clock_nanosleep = 115, - syslog = 116, - ptrace = 117, - sched_setparam = 118, - sched_setscheduler = 119, - sched_getscheduler = 120, - sched_getparam = 121, - sched_setaffinity = 122, - sched_getaffinity = 123, - sched_yield = 124, - sched_get_priority_max = 125, - sched_get_priority_min = 126, - sched_rr_get_interval = 127, - restart_syscall = 128, - kill = 129, - tkill = 130, - tgkill = 131, - sigaltstack = 132, - rt_sigsuspend = 133, - rt_sigaction = 134, - rt_sigprocmask = 135, - rt_sigpending = 136, - rt_sigtimedwait = 137, - rt_sigqueueinfo = 138, - rt_sigreturn = 139, - setpriority = 140, - getpriority = 141, - reboot = 142, - setregid = 143, - setgid = 144, - setreuid = 145, - setuid = 146, - setresuid = 147, - getresuid = 148, - setresgid = 149, - getresgid = 150, - setfsuid = 151, - setfsgid = 152, - times = 153, - setpgid = 154, - getpgid = 155, - getsid = 156, - setsid = 157, - getgroups = 158, - setgroups = 159, - uname = 160, - sethostname = 161, - setdomainname = 162, - getrlimit = 163, - setrlimit = 164, - getrusage = 165, - umask = 166, - prctl = 167, - getcpu = 168, - gettimeofday = 169, - settimeofday = 170, - adjtimex = 171, - getpid = 172, - getppid = 173, - getuid = 174, - geteuid = 175, - getgid = 176, - getegid = 177, - gettid = 178, - sysinfo = 179, - mq_open = 180, - mq_unlink = 181, - mq_timedsend = 182, - mq_timedreceive = 183, - mq_notify = 184, - mq_getsetattr = 185, - msgget = 186, - msgctl = 187, - msgrcv = 188, - msgsnd = 189, - semget = 190, - semctl = 191, - semtimedop = 192, - semop = 193, - shmget = 194, - shmctl = 195, - shmat = 196, - shmdt = 197, - socket = 198, - socketpair = 199, - bind = 200, - listen = 201, - accept = 202, - connect = 203, - getsockname = 204, - getpeername = 205, - sendto = 206, - recvfrom = 207, - setsockopt = 208, - getsockopt = 209, - shutdown = 210, - sendmsg = 211, - recvmsg = 212, - readahead = 213, - brk = 214, - munmap = 215, - mremap = 216, - add_key = 217, - request_key = 218, - keyctl = 219, - clone = 220, - execve = 221, - mmap = 222, - fadvise64 = 223, - swapon = 224, - swapoff = 225, - mprotect = 226, - msync = 227, - mlock = 228, - munlock = 229, - mlockall = 230, - munlockall = 231, - mincore = 232, - madvise = 233, - remap_file_pages = 234, - mbind = 235, - get_mempolicy = 236, - set_mempolicy = 237, - migrate_pages = 238, - move_pages = 239, - rt_tgsigqueueinfo = 240, - perf_event_open = 241, - accept4 = 242, - recvmmsg = 243, - - riscv_flush_icache = arch_specific_syscall + 15, - - wait4 = 260, - prlimit64 = 261, - fanotify_init = 262, - fanotify_mark = 263, - name_to_handle_at = 264, - open_by_handle_at = 265, - clock_adjtime = 266, - syncfs = 267, - setns = 268, - sendmmsg = 269, - process_vm_readv = 270, - process_vm_writev = 271, - kcmp = 272, - finit_module = 273, - sched_setattr = 274, - sched_getattr = 275, - renameat2 = 276, - seccomp = 277, - getrandom = 278, - memfd_create = 279, - bpf = 280, - execveat = 281, - userfaultfd = 282, - membarrier = 283, - mlock2 = 284, - copy_file_range = 285, - preadv2 = 286, - pwritev2 = 287, - pkey_mprotect = 288, - pkey_alloc = 289, - pkey_free = 290, - statx = 291, - io_pgetevents = 292, - rseq = 293, - kexec_file_load = 294, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - _, -}; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0o100000; -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_GETLK = 5; -pub const F_SETLK = 6; -pub const F_SETLKW = 7; -pub const F_SETOWN = 8; -pub const F_GETOWN = 9; -pub const F_SETSIG = 10; -pub const F_GETSIG = 11; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const blksize_t = i32; -pub const nlink_t = u32; -pub const time_t = isize; -pub const mode_t = u32; -pub const off_t = isize; -pub const ino_t = usize; -pub const dev_t = usize; -pub const blkcnt_t = isize; -pub const timespec = extern struct { - tv_sec: time_t, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: time_t, - tv_usec: i64, -}; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - __unused: [4]u8, -}; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad: usize, - size: off_t, - blksize: blksize_t, - __pad2: i32, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const Elf_Symndx = u32; diff --git a/lib/std/os/bits/linux/securebits.zig b/lib/std/os/bits/linux/securebits.zig deleted file mode 100644 index a23ced3cf2..0000000000 --- a/lib/std/os/bits/linux/securebits.zig +++ /dev/null @@ -1,35 +0,0 @@ -fn issecure_mask(comptime x: comptime_int) comptime_int { - return 1 << x; -} - -pub const SECUREBITS_DEFAULT = 0x00000000; - -pub const SECURE_NOROOT = 0; -pub const SECURE_NOROOT_LOCKED = 1; - -pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT); -pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED); - -pub const SECURE_NO_SETUID_FIXUP = 2; -pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3; - -pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP); -pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED); - -pub const SECURE_KEEP_CAPS = 4; -pub const SECURE_KEEP_CAPS_LOCKED = 5; - -pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS); -pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED); - -pub const SECURE_NO_CAP_AMBIENT_RAISE = 6; -pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7; - -pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); -pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); - -pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) | - issecure_mask(SECURE_NO_SETUID_FIXUP) | - issecure_mask(SECURE_KEEP_CAPS) | - issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); -pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1; diff --git a/lib/std/os/bits/linux/sparc64.zig b/lib/std/os/bits/linux/sparc64.zig deleted file mode 100644 index 5c67b745f0..0000000000 --- a/lib/std/os/bits/linux/sparc64.zig +++ /dev/null @@ -1,675 +0,0 @@ -// sparc64-specific declarations that are intended to be imported into the POSIX namespace. -const std = @import("../../../std.zig"); -const pid_t = linux.pid_t; -const uid_t = linux.uid_t; -const clock_t = linux.clock_t; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; - -const linux = std.os.linux; -const sockaddr = linux.sockaddr; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; - -pub const SYS = enum(usize) { - restart_syscall = 0, - exit = 1, - fork = 2, - read = 3, - write = 4, - open = 5, - close = 6, - wait4 = 7, - creat = 8, - link = 9, - unlink = 10, - execv = 11, - chdir = 12, - chown = 13, - mknod = 14, - chmod = 15, - lchown = 16, - brk = 17, - perfctr = 18, - lseek = 19, - getpid = 20, - capget = 21, - capset = 22, - setuid = 23, - getuid = 24, - vmsplice = 25, - ptrace = 26, - alarm = 27, - sigaltstack = 28, - pause = 29, - utime = 30, - access = 33, - nice = 34, - sync = 36, - kill = 37, - stat = 38, - sendfile = 39, - lstat = 40, - dup = 41, - pipe = 42, - times = 43, - umount2 = 45, - setgid = 46, - getgid = 47, - signal = 48, - geteuid = 49, - getegid = 50, - acct = 51, - memory_ordering = 52, - ioctl = 54, - reboot = 55, - symlink = 57, - readlink = 58, - execve = 59, - umask = 60, - chroot = 61, - fstat = 62, - fstat64 = 63, - getpagesize = 64, - msync = 65, - vfork = 66, - pread64 = 67, - pwrite64 = 68, - mmap = 71, - munmap = 73, - mprotect = 74, - madvise = 75, - vhangup = 76, - mincore = 78, - getgroups = 79, - setgroups = 80, - getpgrp = 81, - setitimer = 83, - swapon = 85, - getitimer = 86, - sethostname = 88, - dup2 = 90, - fcntl = 92, - select = 93, - fsync = 95, - setpriority = 96, - socket = 97, - connect = 98, - accept = 99, - getpriority = 100, - rt_sigreturn = 101, - rt_sigaction = 102, - rt_sigprocmask = 103, - rt_sigpending = 104, - rt_sigtimedwait = 105, - rt_sigqueueinfo = 106, - rt_sigsuspend = 107, - setresuid = 108, - getresuid = 109, - setresgid = 110, - getresgid = 111, - recvmsg = 113, - sendmsg = 114, - gettimeofday = 116, - getrusage = 117, - getsockopt = 118, - getcwd = 119, - readv = 120, - writev = 121, - settimeofday = 122, - fchown = 123, - fchmod = 124, - recvfrom = 125, - setreuid = 126, - setregid = 127, - rename = 128, - truncate = 129, - ftruncate = 130, - flock = 131, - lstat64 = 132, - sendto = 133, - shutdown = 134, - socketpair = 135, - mkdir = 136, - rmdir = 137, - utimes = 138, - stat64 = 139, - sendfile64 = 140, - getpeername = 141, - futex = 142, - gettid = 143, - getrlimit = 144, - setrlimit = 145, - pivot_root = 146, - prctl = 147, - pciconfig_read = 148, - pciconfig_write = 149, - getsockname = 150, - inotify_init = 151, - inotify_add_watch = 152, - poll = 153, - getdents64 = 154, - inotify_rm_watch = 156, - statfs = 157, - fstatfs = 158, - umount = 159, - sched_set_affinity = 160, - sched_get_affinity = 161, - getdomainname = 162, - setdomainname = 163, - utrap_install = 164, - quotactl = 165, - set_tid_address = 166, - mount = 167, - ustat = 168, - setxattr = 169, - lsetxattr = 170, - fsetxattr = 171, - getxattr = 172, - lgetxattr = 173, - getdents = 174, - setsid = 175, - fchdir = 176, - fgetxattr = 177, - listxattr = 178, - llistxattr = 179, - flistxattr = 180, - removexattr = 181, - lremovexattr = 182, - sigpending = 183, - query_module = 184, - setpgid = 185, - fremovexattr = 186, - tkill = 187, - exit_group = 188, - uname = 189, - init_module = 190, - personality = 191, - remap_file_pages = 192, - epoll_create = 193, - epoll_ctl = 194, - epoll_wait = 195, - ioprio_set = 196, - getppid = 197, - sigaction = 198, - sgetmask = 199, - ssetmask = 200, - sigsuspend = 201, - oldlstat = 202, - uselib = 203, - readdir = 204, - readahead = 205, - socketcall = 206, - syslog = 207, - lookup_dcookie = 208, - fadvise64 = 209, - fadvise64_64 = 210, - tgkill = 211, - waitpid = 212, - swapoff = 213, - sysinfo = 214, - ipc = 215, - sigreturn = 216, - clone = 217, - ioprio_get = 218, - adjtimex = 219, - sigprocmask = 220, - create_module = 221, - delete_module = 222, - get_kernel_syms = 223, - getpgid = 224, - bdflush = 225, - sysfs = 226, - afs_syscall = 227, - setfsuid = 228, - setfsgid = 229, - _newselect = 230, - splice = 232, - stime = 233, - statfs64 = 234, - fstatfs64 = 235, - _llseek = 236, - mlock = 237, - munlock = 238, - mlockall = 239, - munlockall = 240, - sched_setparam = 241, - sched_getparam = 242, - sched_setscheduler = 243, - sched_getscheduler = 244, - sched_yield = 245, - sched_get_priority_max = 246, - sched_get_priority_min = 247, - sched_rr_get_interval = 248, - nanosleep = 249, - mremap = 250, - _sysctl = 251, - getsid = 252, - fdatasync = 253, - nfsservctl = 254, - sync_file_range = 255, - clock_settime = 256, - clock_gettime = 257, - clock_getres = 258, - clock_nanosleep = 259, - sched_getaffinity = 260, - sched_setaffinity = 261, - timer_settime = 262, - timer_gettime = 263, - timer_getoverrun = 264, - timer_delete = 265, - timer_create = 266, - vserver = 267, - io_setup = 268, - io_destroy = 269, - io_submit = 270, - io_cancel = 271, - io_getevents = 272, - mq_open = 273, - mq_unlink = 274, - mq_timedsend = 275, - mq_timedreceive = 276, - mq_notify = 277, - mq_getsetattr = 278, - waitid = 279, - tee = 280, - add_key = 281, - request_key = 282, - keyctl = 283, - openat = 284, - mkdirat = 285, - mknodat = 286, - fchownat = 287, - futimesat = 288, - fstatat64 = 289, - unlinkat = 290, - renameat = 291, - linkat = 292, - symlinkat = 293, - readlinkat = 294, - fchmodat = 295, - faccessat = 296, - pselect6 = 297, - ppoll = 298, - unshare = 299, - set_robust_list = 300, - get_robust_list = 301, - migrate_pages = 302, - mbind = 303, - get_mempolicy = 304, - set_mempolicy = 305, - kexec_load = 306, - move_pages = 307, - getcpu = 308, - epoll_pwait = 309, - utimensat = 310, - signalfd = 311, - timerfd_create = 312, - eventfd = 313, - fallocate = 314, - timerfd_settime = 315, - timerfd_gettime = 316, - signalfd4 = 317, - eventfd2 = 318, - epoll_create1 = 319, - dup3 = 320, - pipe2 = 321, - inotify_init1 = 322, - accept4 = 323, - preadv = 324, - pwritev = 325, - rt_tgsigqueueinfo = 326, - perf_event_open = 327, - recvmmsg = 328, - fanotify_init = 329, - fanotify_mark = 330, - prlimit64 = 331, - name_to_handle_at = 332, - open_by_handle_at = 333, - clock_adjtime = 334, - syncfs = 335, - sendmmsg = 336, - setns = 337, - process_vm_readv = 338, - process_vm_writev = 339, - kern_features = 340, - kcmp = 341, - finit_module = 342, - sched_setattr = 343, - sched_getattr = 344, - renameat2 = 345, - seccomp = 346, - getrandom = 347, - memfd_create = 348, - bpf = 349, - execveat = 350, - membarrier = 351, - userfaultfd = 352, - bind = 353, - listen = 354, - setsockopt = 355, - mlock2 = 356, - copy_file_range = 357, - preadv2 = 358, - pwritev2 = 359, - statx = 360, - io_pgetevents = 361, - pkey_mprotect = 362, - pkey_alloc = 363, - pkey_free = 364, - rseq = 365, - semtimedop = 392, - semget = 393, - semctl = 394, - shmget = 395, - shmctl = 396, - shmat = 397, - shmdt = 398, - msgget = 399, - msgsnd = 400, - msgrcv = 401, - msgctl = 402, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - _, -}; - -pub const O_CREAT = 0x200; -pub const O_EXCL = 0x800; -pub const O_NOCTTY = 0x8000; -pub const O_TRUNC = 0x400; -pub const O_APPEND = 0x8; -pub const O_NONBLOCK = 0x4000; -pub const O_SYNC = 0x802000; -pub const O_DSYNC = 0x2000; -pub const O_RSYNC = O_SYNC; -pub const O_DIRECTORY = 0x10000; -pub const O_NOFOLLOW = 0x20000; -pub const O_CLOEXEC = 0x400000; - -pub const O_ASYNC = 0x40; -pub const O_DIRECT = 0x100000; -pub const O_LARGEFILE = 0; -pub const O_NOATIME = 0x200000; -pub const O_PATH = 0x1000000; -pub const O_TMPFILE = 0x2010000; -pub const O_NDELAY = O_NONBLOCK | 0x4; - -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 = 5; -pub const F_GETOWN = 6; -pub const F_GETLK = 7; -pub const F_SETLK = 8; -pub const F_SETLKW = 9; - -pub const F_RDLCK = 1; -pub const F_WRLCK = 2; -pub const F_UNLCK = 3; - -pub const F_SETOWN_EX = 15; -pub const F_GETOWN_EX = 16; - -pub const F_GETOWNER_UIDS = 17; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_NB = 4; -pub const LOCK_UN = 8; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0200; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x0100; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x0040; - -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6"; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: u64, - msg_control: ?*c_void, - msg_controllen: u64, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: u64, - msg_control: ?*c_void, - msg_controllen: u64, - msg_flags: i32, -}; - -pub const off_t = i64; -pub const ino_t = u64; -pub const mode_t = u32; - -// The `stat64` definition used by the libc. -pub const libc_stat = extern struct { - dev: u64, - ino: ino_t, - mode: u32, - nlink: usize, - - uid: u32, - gid: u32, - rdev: u64, - __pad0: u32, - - size: off_t, - blksize: isize, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]isize, - - pub fn atime(self: libc_stat) timespec { - return self.atim; - } - - pub fn mtime(self: libc_stat) timespec { - return self.mtim; - } - - pub fn ctime(self: libc_stat) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the kernel. -pub const kernel_stat = extern struct { - dev: u64, - ino: u64, - nlink: u64, - - mode: u32, - uid: u32, - gid: u32, - __pad0: u32, - - rdev: u64, - size: i64, - blksize: i64, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]u64, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -// TODO I'm not sure if the code below is correct, need someone with more -// knowledge about sparc64 linux internals to look into. - -pub const Elf_Symndx = u32; - -pub const fpstate = extern struct { - regs: [32]u64, - fsr: u64, - gsr: u64, - fprs: u64, -}; - -pub const __fpq = extern struct { - fpq_addr: *u32, - fpq_instr: u32, -}; - -pub const __fq = extern struct { - FQu: extern union { - whole: f64, - fpq: __fpq, - }, -}; - -pub const fpregset_t = extern struct { - fpu_fr: extern union { - fpu_regs: [32]u32, - fpu_dregs: [32]f64, - fpu_qregs: [16]c_longdouble, - }, - fpu_q: *__fq, - fpu_fsr: u64, - fpu_qcnt: u8, - fpu_q_entrysize: u8, - fpu_en: u8, -}; - -pub const siginfo_fpu_t = extern struct { - float_regs: [64]u32, - fsr: u64, - gsr: u64, - fprs: u64, -}; - -pub const sigcontext = extern struct { - info: [128]i8, - regs: extern struct { - u_regs: [16]u64, - tstate: u64, - tpc: u64, - tnpc: u64, - y: u64, - fprs: u64, - }, - fpu_save: *siginfo_fpu_t, - stack: extern struct { - sp: usize, - flags: i32, - size: u64, - }, - mask: u64, -}; - -pub const greg_t = u64; -pub const gregset_t = [19]greg_t; - -pub const fq = extern struct { - addr: *u64, - insn: u32, -}; - -pub const fpu_t = extern struct { - fregs: extern union { - sregs: [32]u32, - dregs: [32]u64, - qregs: [16]c_longdouble, - }, - fsr: u64, - fprs: u64, - gsr: u64, - fq: *fq, - qcnt: u8, - qentsz: u8, - enab: u8, -}; - -pub const mcontext_t = extern struct { - gregs: gregset_t, - fp: greg_t, - @"i7": greg_t, - fpregs: fpu_t, -}; - -pub const ucontext_t = extern struct { - link: *ucontext_t, - flags: u64, - sigmask: u64, - mcontext: mcontext_t, - stack: stack_t, - sigmask: sigset_t, -}; diff --git a/lib/std/os/bits/linux/x86_64.zig b/lib/std/os/bits/linux/x86_64.zig deleted file mode 100644 index 69beac9d87..0000000000 --- a/lib/std/os/bits/linux/x86_64.zig +++ /dev/null @@ -1,638 +0,0 @@ -// x86-64-specific declarations that are intended to be imported into the POSIX namespace. -const std = @import("../../../std.zig"); -const pid_t = linux.pid_t; -const uid_t = linux.uid_t; -const gid_t = linux.gid_t; -const clock_t = linux.clock_t; -const stack_t = linux.stack_t; -const sigset_t = linux.sigset_t; - -const linux = std.os.linux; -const sockaddr = linux.sockaddr; -const socklen_t = linux.socklen_t; -const iovec = linux.iovec; -const iovec_const = linux.iovec_const; - -pub const mode_t = usize; -pub const time_t = isize; - -pub const SYS = enum(usize) { - read = 0, - write = 1, - open = 2, - close = 3, - stat = 4, - fstat = 5, - lstat = 6, - poll = 7, - lseek = 8, - mmap = 9, - mprotect = 10, - munmap = 11, - brk = 12, - rt_sigaction = 13, - rt_sigprocmask = 14, - rt_sigreturn = 15, - ioctl = 16, - pread = 17, - pwrite = 18, - readv = 19, - writev = 20, - access = 21, - pipe = 22, - select = 23, - sched_yield = 24, - mremap = 25, - msync = 26, - mincore = 27, - madvise = 28, - shmget = 29, - shmat = 30, - shmctl = 31, - dup = 32, - dup2 = 33, - pause = 34, - nanosleep = 35, - getitimer = 36, - alarm = 37, - setitimer = 38, - getpid = 39, - sendfile = 40, - socket = 41, - connect = 42, - accept = 43, - sendto = 44, - recvfrom = 45, - sendmsg = 46, - recvmsg = 47, - shutdown = 48, - bind = 49, - listen = 50, - getsockname = 51, - getpeername = 52, - socketpair = 53, - setsockopt = 54, - getsockopt = 55, - clone = 56, - fork = 57, - vfork = 58, - execve = 59, - exit = 60, - wait4 = 61, - kill = 62, - uname = 63, - semget = 64, - semop = 65, - semctl = 66, - shmdt = 67, - msgget = 68, - msgsnd = 69, - msgrcv = 70, - msgctl = 71, - fcntl = 72, - flock = 73, - fsync = 74, - fdatasync = 75, - truncate = 76, - ftruncate = 77, - getdents = 78, - getcwd = 79, - chdir = 80, - fchdir = 81, - rename = 82, - mkdir = 83, - rmdir = 84, - creat = 85, - link = 86, - unlink = 87, - symlink = 88, - readlink = 89, - chmod = 90, - fchmod = 91, - chown = 92, - fchown = 93, - lchown = 94, - umask = 95, - gettimeofday = 96, - getrlimit = 97, - getrusage = 98, - sysinfo = 99, - times = 100, - ptrace = 101, - getuid = 102, - syslog = 103, - getgid = 104, - setuid = 105, - setgid = 106, - geteuid = 107, - getegid = 108, - setpgid = 109, - getppid = 110, - getpgrp = 111, - setsid = 112, - setreuid = 113, - setregid = 114, - getgroups = 115, - setgroups = 116, - setresuid = 117, - getresuid = 118, - setresgid = 119, - getresgid = 120, - getpgid = 121, - setfsuid = 122, - setfsgid = 123, - getsid = 124, - capget = 125, - capset = 126, - rt_sigpending = 127, - rt_sigtimedwait = 128, - rt_sigqueueinfo = 129, - rt_sigsuspend = 130, - sigaltstack = 131, - utime = 132, - mknod = 133, - uselib = 134, - personality = 135, - ustat = 136, - statfs = 137, - fstatfs = 138, - sysfs = 139, - getpriority = 140, - setpriority = 141, - sched_setparam = 142, - sched_getparam = 143, - sched_setscheduler = 144, - sched_getscheduler = 145, - sched_get_priority_max = 146, - sched_get_priority_min = 147, - sched_rr_get_interval = 148, - mlock = 149, - munlock = 150, - mlockall = 151, - munlockall = 152, - vhangup = 153, - modify_ldt = 154, - pivot_root = 155, - _sysctl = 156, - prctl = 157, - arch_prctl = 158, - adjtimex = 159, - setrlimit = 160, - chroot = 161, - sync = 162, - acct = 163, - settimeofday = 164, - mount = 165, - umount2 = 166, - swapon = 167, - swapoff = 168, - reboot = 169, - sethostname = 170, - setdomainname = 171, - iopl = 172, - ioperm = 173, - create_module = 174, - init_module = 175, - delete_module = 176, - get_kernel_syms = 177, - query_module = 178, - quotactl = 179, - nfsservctl = 180, - getpmsg = 181, - putpmsg = 182, - afs_syscall = 183, - tuxcall = 184, - security = 185, - gettid = 186, - readahead = 187, - setxattr = 188, - lsetxattr = 189, - fsetxattr = 190, - getxattr = 191, - lgetxattr = 192, - fgetxattr = 193, - listxattr = 194, - llistxattr = 195, - flistxattr = 196, - removexattr = 197, - lremovexattr = 198, - fremovexattr = 199, - tkill = 200, - time = 201, - futex = 202, - sched_setaffinity = 203, - sched_getaffinity = 204, - set_thread_area = 205, - io_setup = 206, - io_destroy = 207, - io_getevents = 208, - io_submit = 209, - io_cancel = 210, - get_thread_area = 211, - lookup_dcookie = 212, - epoll_create = 213, - epoll_ctl_old = 214, - epoll_wait_old = 215, - remap_file_pages = 216, - getdents64 = 217, - set_tid_address = 218, - restart_syscall = 219, - semtimedop = 220, - fadvise64 = 221, - timer_create = 222, - timer_settime = 223, - timer_gettime = 224, - timer_getoverrun = 225, - timer_delete = 226, - clock_settime = 227, - clock_gettime = 228, - clock_getres = 229, - clock_nanosleep = 230, - exit_group = 231, - epoll_wait = 232, - epoll_ctl = 233, - tgkill = 234, - utimes = 235, - vserver = 236, - mbind = 237, - set_mempolicy = 238, - get_mempolicy = 239, - mq_open = 240, - mq_unlink = 241, - mq_timedsend = 242, - mq_timedreceive = 243, - mq_notify = 244, - mq_getsetattr = 245, - kexec_load = 246, - waitid = 247, - add_key = 248, - request_key = 249, - keyctl = 250, - ioprio_set = 251, - ioprio_get = 252, - inotify_init = 253, - inotify_add_watch = 254, - inotify_rm_watch = 255, - migrate_pages = 256, - openat = 257, - mkdirat = 258, - mknodat = 259, - fchownat = 260, - futimesat = 261, - fstatat = 262, - unlinkat = 263, - renameat = 264, - linkat = 265, - symlinkat = 266, - readlinkat = 267, - fchmodat = 268, - faccessat = 269, - pselect6 = 270, - ppoll = 271, - unshare = 272, - set_robust_list = 273, - get_robust_list = 274, - splice = 275, - tee = 276, - sync_file_range = 277, - vmsplice = 278, - move_pages = 279, - utimensat = 280, - epoll_pwait = 281, - signalfd = 282, - timerfd_create = 283, - eventfd = 284, - fallocate = 285, - timerfd_settime = 286, - timerfd_gettime = 287, - accept4 = 288, - signalfd4 = 289, - eventfd2 = 290, - epoll_create1 = 291, - dup3 = 292, - pipe2 = 293, - inotify_init1 = 294, - preadv = 295, - pwritev = 296, - rt_tgsigqueueinfo = 297, - perf_event_open = 298, - recvmmsg = 299, - fanotify_init = 300, - fanotify_mark = 301, - prlimit64 = 302, - name_to_handle_at = 303, - open_by_handle_at = 304, - clock_adjtime = 305, - syncfs = 306, - sendmmsg = 307, - setns = 308, - getcpu = 309, - process_vm_readv = 310, - process_vm_writev = 311, - kcmp = 312, - finit_module = 313, - sched_setattr = 314, - sched_getattr = 315, - renameat2 = 316, - seccomp = 317, - getrandom = 318, - memfd_create = 319, - kexec_file_load = 320, - bpf = 321, - execveat = 322, - userfaultfd = 323, - membarrier = 324, - mlock2 = 325, - copy_file_range = 326, - preadv2 = 327, - pwritev2 = 328, - pkey_mprotect = 329, - pkey_alloc = 330, - pkey_free = 331, - statx = 332, - io_pgetevents = 333, - rseq = 334, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - - _, -}; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const 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; - -/// only give out 32bit addresses -pub const MAP_32BIT = 0x40; - -/// stack-like segment -pub const MAP_GROWSDOWN = 0x0100; - -/// ETXTBSY -pub const MAP_DENYWRITE = 0x0800; - -/// mark it as an executable -pub const MAP_EXECUTABLE = 0x1000; - -/// pages are locked -pub const MAP_LOCKED = 0x2000; - -/// don't check for reservations -pub const MAP_NORESERVE = 0x4000; - -pub const VDSO_CGT_SYM = "__vdso_clock_gettime"; -pub const VDSO_CGT_VER = "LINUX_2.6"; -pub const VDSO_GETCPU_SYM = "__vdso_getcpu"; -pub const VDSO_GETCPU_VER = "LINUX_2.6"; - -pub const ARCH_SET_GS = 0x1001; -pub const ARCH_SET_FS = 0x1002; -pub const ARCH_GET_FS = 0x1003; -pub const ARCH_GET_GS = 0x1004; - -pub const REG_R8 = 0; -pub const REG_R9 = 1; -pub const REG_R10 = 2; -pub const REG_R11 = 3; -pub const REG_R12 = 4; -pub const REG_R13 = 5; -pub const REG_R14 = 6; -pub const REG_R15 = 7; -pub const REG_RDI = 8; -pub const REG_RSI = 9; -pub const REG_RBP = 10; -pub const REG_RBX = 11; -pub const REG_RDX = 12; -pub const REG_RAX = 13; -pub const REG_RCX = 14; -pub const REG_RSP = 15; -pub const REG_RIP = 16; -pub const REG_EFL = 17; -pub const REG_CSGSFS = 18; -pub const REG_ERR = 19; -pub const REG_TRAPNO = 20; -pub const REG_OLDMASK = 21; -pub const REG_CR2 = 22; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const F_RDLCK = 0; -pub const F_WRLCK = 1; -pub const F_UNLCK = 2; - -pub const Flock = extern struct { - l_type: i16, - l_whence: i16, - l_start: off_t, - l_len: off_t, - l_pid: pid_t, -}; - -pub const msghdr = extern struct { - msg_name: ?*sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec, - msg_iovlen: i32, - __pad1: i32 = 0, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t = 0, - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - msg_name: ?*const sockaddr, - msg_namelen: socklen_t, - msg_iov: [*]iovec_const, - msg_iovlen: i32, - __pad1: i32 = 0, - msg_control: ?*c_void, - msg_controllen: socklen_t, - __pad2: socklen_t = 0, - msg_flags: i32, -}; - -pub const off_t = i64; -pub const ino_t = u64; -pub const dev_t = u64; - -// The `stat` definition used by the Linux kernel. -pub const kernel_stat = extern struct { - dev: dev_t, - ino: ino_t, - nlink: usize, - - mode: u32, - uid: uid_t, - gid: gid_t, - __pad0: u32, - rdev: dev_t, - size: off_t, - blksize: isize, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]isize, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -// The `stat64` definition used by the libc. -pub const libc_stat = kernel_stat; - -pub const timespec = extern struct { - tv_sec: isize, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - tv_sec: isize, - tv_usec: isize, -}; - -pub const timezone = extern struct { - tz_minuteswest: i32, - tz_dsttime: i32, -}; - -pub const Elf_Symndx = u32; - -pub const greg_t = usize; -pub const gregset_t = [23]greg_t; -pub const fpstate = extern struct { - cwd: u16, - swd: u16, - ftw: u16, - fop: u16, - rip: usize, - rdp: usize, - mxcsr: u32, - mxcr_mask: u32, - st: [8]extern struct { - significand: [4]u16, - exponent: u16, - padding: [3]u16 = undefined, - }, - xmm: [16]extern struct { - element: [4]u32, - }, - padding: [24]u32 = undefined, -}; -pub const fpregset_t = *fpstate; -pub const sigcontext = extern struct { - r8: usize, - r9: usize, - r10: usize, - r11: usize, - r12: usize, - r13: usize, - r14: usize, - r15: usize, - - rdi: usize, - rsi: usize, - rbp: usize, - rbx: usize, - rdx: usize, - rax: usize, - rcx: usize, - rsp: usize, - rip: usize, - eflags: usize, - - cs: u16, - gs: u16, - fs: u16, - pad0: u16 = undefined, - - err: usize, - trapno: usize, - oldmask: usize, - cr2: usize, - - fpstate: *fpstate, - reserved1: [8]usize = undefined, -}; - -pub const mcontext_t = extern struct { - gregs: gregset_t, - fpregs: fpregset_t, - reserved1: [8]usize = undefined, -}; - -pub const ucontext_t = extern struct { - flags: usize, - link: *ucontext_t, - stack: stack_t, - mcontext: mcontext_t, - sigmask: sigset_t, - fpregs_mem: [64]usize, -}; diff --git a/lib/std/os/bits/linux/xdp.zig b/lib/std/os/bits/linux/xdp.zig deleted file mode 100644 index 88fa9918a3..0000000000 --- a/lib/std/os/bits/linux/xdp.zig +++ /dev/null @@ -1,77 +0,0 @@ -usingnamespace @import("../linux.zig"); - -pub const XDP_SHARED_UMEM = (1 << 0); -pub const XDP_COPY = (1 << 1); -pub const XDP_ZEROCOPY = (1 << 2); - -pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG = (1 << 0); - -pub const sockaddr_xdp = extern struct { - family: u16 = AF_XDP, - flags: u16, - ifindex: u32, - queue_id: u32, - shared_umem_fd: u32, -}; - -pub const XDP_USE_NEED_WAKEUP = (1 << 3); - -pub const xdp_ring_offset = extern struct { - producer: u64, - consumer: u64, - desc: u64, - flags: u64, -}; - -pub const xdp_mmap_offsets = extern struct { - rx: xdp_ring_offset, - tx: xdp_ring_offset, - fr: xdp_ring_offset, - cr: xdp_ring_offset, -}; - -pub const XDP_MMAP_OFFSETS = 1; -pub const XDP_RX_RING = 2; -pub const XDP_TX_RING = 3; -pub const XDP_UMEM_REG = 4; -pub const XDP_UMEM_FILL_RING = 5; -pub const XDP_UMEM_COMPLETION_RING = 6; -pub const XDP_STATISTICS = 7; -pub const XDP_OPTIONS = 8; - -pub const xdp_umem_reg = extern struct { - addr: u64, - len: u64, - chunk_size: u32, - headroom: u32, - flags: u32, -}; - -pub const xdp_statistics = extern struct { - rx_dropped: u64, - rx_invalid_descs: u64, - tx_invalid_descs: u64, - rx_ring_full: u64, - rx_fill_ring_empty_descs: u64, - tx_ring_empty_descs: u64, -}; - -pub const xdp_options = extern struct { - flags: u32, -}; - -pub const XDP_OPTIONS_ZEROCOPY = (1 << 0); - -pub const XDP_PGOFF_RX_RING = 0; -pub const XDP_PGOFF_TX_RING = 0x80000000; -pub const XDP_UMEM_PGOFF_FILL_RING = 0x100000000; -pub const XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000; - -pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT = 48; -pub const XSK_UNALIGNED_BUF_ADDR_MASK = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; - -pub const xdp_desc = extern struct { - addr: u64, - len: u32, - options: u32, -}; diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig deleted file mode 100644 index be35889042..0000000000 --- a/lib/std/os/bits/netbsd.zig +++ /dev/null @@ -1,1328 +0,0 @@ -const std = @import("../../std.zig"); -const builtin = std.builtin; -const maxInt = std.math.maxInt; - -pub usingnamespace @import("posix.zig"); - -pub const blkcnt_t = i64; -pub const blksize_t = i32; -pub const clock_t = u32; -pub const dev_t = u64; -pub const fd_t = i32; -pub const gid_t = u32; -pub const ino_t = u64; -pub const mode_t = u32; -pub const nlink_t = u32; -pub const off_t = i64; -pub const pid_t = i32; -pub const socklen_t = u32; -pub const time_t = i64; -pub const uid_t = u32; -pub const lwpid_t = i32; -pub const suseconds_t = c_int; - -/// Renamed from `kevent` to `Kevent` to avoid conflict with function name. -pub const Kevent = extern struct { - ident: usize, - filter: i32, - flags: u32, - fflags: u32, - data: i64, - udata: usize, -}; - -pub const RTLD_LAZY = 1; -pub const RTLD_NOW = 2; -pub const RTLD_GLOBAL = 0x100; -pub const RTLD_LOCAL = 0x200; -pub const RTLD_NODELETE = 0x01000; -pub const RTLD_NOLOAD = 0x02000; - -pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); -pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); -pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); - -pub const dl_phdr_info = extern struct { - dlpi_addr: usize, - dlpi_name: ?[*:0]const u8, - dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: u16, -}; - -pub const Flock = extern struct { - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - l_type: i16, - l_whence: i16, -}; - -pub const addrinfo = extern struct { - flags: i32, - family: i32, - socktype: i32, - protocol: i32, - addrlen: socklen_t, - canonname: ?[*:0]u8, - addr: ?*sockaddr, - next: ?*addrinfo, -}; - -pub const EAI = enum(c_int) { - /// address family for hostname not supported - ADDRFAMILY = 1, - - /// name could not be resolved at this time - AGAIN = 2, - - /// flags parameter had an invalid value - BADFLAGS = 3, - - /// non-recoverable failure in name resolution - FAIL = 4, - - /// address family not recognized - FAMILY = 5, - - /// memory allocation failure - MEMORY = 6, - - /// no address associated with hostname - NODATA = 7, - - /// name does not resolve - NONAME = 8, - - /// service not recognized for socket type - SERVICE = 9, - - /// intended socket type was not recognized - SOCKTYPE = 10, - - /// system error returned in errno - SYSTEM = 11, - - /// invalid value for hints - BADHINTS = 12, - - /// resolved protocol is unknown - PROTOCOL = 13, - - /// argument buffer overflow - OVERFLOW = 14, - - _, -}; - -pub const EAI_MAX = 15; - -pub const msghdr = extern struct { - /// optional address - msg_name: ?*sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec, - - /// # elements in msg_iov - msg_iovlen: i32, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: i32, -}; - -pub const msghdr_const = extern struct { - /// optional address - msg_name: ?*const sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec_const, - - /// # elements in msg_iov - msg_iovlen: i32, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: i32, -}; - -pub const libc_stat = extern struct { - dev: dev_t, - mode: mode_t, - ino: ino_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - birthtim: timespec, - size: off_t, - blocks: blkcnt_t, - blksize: blksize_t, - flags: u32, - gen: u32, - __spare: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: i64, - tv_nsec: isize, -}; - -pub const timeval = extern struct { - /// seconds - tv_sec: time_t, - /// microseconds - tv_usec: suseconds_t, -}; - -pub const MAXNAMLEN = 511; - -pub const dirent = extern struct { - d_fileno: ino_t, - d_reclen: u16, - d_namlen: u16, - d_type: u8, - d_name: [MAXNAMLEN:0]u8, - - pub fn reclen(self: dirent) u16 { - return self.d_reclen; - } -}; - -pub const SOCK_STREAM = 1; -pub const SOCK_DGRAM = 2; -pub const SOCK_RAW = 3; -pub const SOCK_RDM = 4; -pub const SOCK_SEQPACKET = 5; -pub const SOCK_CONN_DGRAM = 6; -pub const SOCK_DCCP = SOCK_CONN_DGRAM; - -pub const SOCK_CLOEXEC = 0x10000000; -pub const SOCK_NONBLOCK = 0x20000000; -pub const SOCK_NOSIGPIPE = 0x40000000; -pub const SOCK_FLAGS_MASK = 0xf0000000; - -pub const SO_DEBUG = 0x0001; -pub const SO_ACCEPTCONN = 0x0002; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_USELOOPBACK = 0x0040; -pub const SO_LINGER = 0x0080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_NOSIGPIPE = 0x0800; -pub const SO_ACCEPTFILTER = 0x1000; -pub const SO_TIMESTAMP = 0x2000; -pub const SO_RERROR = 0x4000; - -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_OVERFLOWED = 0x1009; - -pub const SO_NOHEADER = 0x100a; -pub const SO_SNDTIMEO = 0x100b; -pub const SO_RCVTIMEO = 0x100c; - -pub const SOL_SOCKET = 0xffff; - -pub const PF_UNSPEC = AF_UNSPEC; -pub const PF_LOCAL = AF_LOCAL; -pub const PF_UNIX = PF_LOCAL; -pub const PF_INET = AF_INET; -pub const PF_IMPLINK = AF_IMPLINK; -pub const PF_PUP = AF_PUP; -pub const PF_CHAOS = AF_CHAOS; -pub const PF_NS = AF_NS; -pub const PF_ISO = AF_ISO; -pub const PF_OSI = AF_ISO; -pub const PF_ECMA = AF_ECMA; -pub const PF_DATAKIT = AF_DATAKIT; -pub const PF_CCITT = AF_CCITT; -pub const PF_SNA = AF_SNA; -pub const PF_DECnet = AF_DECnet; -pub const PF_DLI = AF_DLI; -pub const PF_LAT = AF_LAT; -pub const PF_HYLINK = AF_HYLINK; -pub const PF_APPLETALK = AF_APPLETALK; -pub const PF_OROUTE = AF_OROUTE; -pub const PF_LINK = AF_LINK; -pub const PF_COIP = AF_COIP; -pub const PF_CNT = AF_CNT; -pub const PF_INET6 = AF_INET6; -pub const PF_IPX = AF_IPX; -pub const PF_ISDN = AF_ISDN; -pub const PF_E164 = AF_E164; -pub const PF_NATM = AF_NATM; -pub const PF_ARP = AF_ARP; -pub const PF_BLUETOOTH = AF_BLUETOOTH; -pub const PF_MPLS = AF_MPLS; -pub const PF_ROUTE = AF_ROUTE; -pub const PF_CAN = AF_CAN; -pub const PF_ETHER = AF_ETHER; -pub const PF_MAX = AF_MAX; - -pub const AF_UNSPEC = 0; -pub const AF_LOCAL = 1; -pub const AF_UNIX = AF_LOCAL; -pub const AF_INET = 2; -pub const AF_IMPLINK = 3; -pub const AF_PUP = 4; -pub const AF_CHAOS = 5; -pub const AF_NS = 6; -pub const AF_ISO = 7; -pub const AF_OSI = AF_ISO; -pub const AF_ECMA = 8; -pub const AF_DATAKIT = 9; -pub const AF_CCITT = 10; -pub const AF_SNA = 11; -pub const AF_DECnet = 12; -pub const AF_DLI = 13; -pub const AF_LAT = 14; -pub const AF_HYLINK = 15; -pub const AF_APPLETALK = 16; -pub const AF_OROUTE = 17; -pub const AF_LINK = 18; -pub const AF_COIP = 20; -pub const AF_CNT = 21; -pub const AF_IPX = 23; -pub const AF_INET6 = 24; -pub const AF_ISDN = 26; -pub const AF_E164 = AF_ISDN; -pub const AF_NATM = 27; -pub const AF_ARP = 28; -pub const AF_BLUETOOTH = 31; -pub const AF_IEEE80211 = 32; -pub const AF_MPLS = 33; -pub const AF_ROUTE = 34; -pub const AF_CAN = 35; -pub const AF_ETHER = 36; -pub const AF_MAX = 37; - -pub const in_port_t = u16; -pub const sa_family_t = u8; - -pub const sockaddr = extern struct { - /// total length - len: u8, - - /// address family - family: sa_family_t, - - /// actually longer; address value - data: [14]u8, -}; - -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; - -pub const sockaddr_in = extern struct { - len: u8 = @sizeOf(sockaddr_in), - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -pub const sockaddr_in6 = extern struct { - len: u8 = @sizeOf(sockaddr_in6), - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -/// Definitions for UNIX IPC domain. -pub const sockaddr_un = extern struct { - /// total sockaddr length - len: u8 = @sizeOf(sockaddr_un), - - /// AF_LOCAL - family: sa_family_t = AF_LOCAL, - - /// path name - path: [104]u8, -}; - -/// get address to use bind() -pub const AI_PASSIVE = 0x00000001; - -/// fill ai_canonname -pub const AI_CANONNAME = 0x00000002; - -/// prevent host name resolution -pub const AI_NUMERICHOST = 0x00000004; - -/// prevent service name resolution -pub const AI_NUMERICSERV = 0x00000008; - -/// only if any address is assigned -pub const AI_ADDRCONFIG = 0x00000400; - -pub const CTL_KERN = 1; -pub const CTL_DEBUG = 5; - -pub const KERN_PROC_ARGS = 48; // struct: process argv/env -pub const KERN_PROC_PATHNAME = 5; // path to executable -pub const KERN_IOV_MAX = 38; - -pub const PATH_MAX = 1024; -pub const IOV_MAX = KERN_IOV_MAX; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -pub const PROT_NONE = 0; -pub const PROT_READ = 1; -pub const PROT_WRITE = 2; -pub const PROT_EXEC = 4; - -pub const CLOCK_REALTIME = 0; -pub const CLOCK_VIRTUAL = 1; -pub const CLOCK_PROF = 2; -pub const CLOCK_MONOTONIC = 3; -pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000; -pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000; - -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); -pub const MAP_SHARED = 0x0001; -pub const MAP_PRIVATE = 0x0002; -pub const MAP_REMAPDUP = 0x0004; -pub const MAP_FIXED = 0x0010; -pub const MAP_RENAME = 0x0020; -pub const MAP_NORESERVE = 0x0040; -pub const MAP_INHERIT = 0x0080; -pub const MAP_HASSEMAPHORE = 0x0200; -pub const MAP_TRYFIXED = 0x0400; -pub const MAP_WIRED = 0x0800; - -pub const MAP_FILE = 0x0000; -pub const MAP_NOSYNC = 0x0800; -pub const MAP_ANON = 0x1000; -pub const MAP_ANONYMOUS = MAP_ANON; -pub const MAP_STACK = 0x2000; - -pub const WNOHANG = 0x00000001; -pub const WUNTRACED = 0x00000002; -pub const WSTOPPED = WUNTRACED; -pub const WCONTINUED = 0x00000010; -pub const WNOWAIT = 0x00010000; -pub const WEXITED = 0x00000020; -pub const WTRAPPED = 0x00000040; - -pub const SA_ONSTACK = 0x0001; -pub const SA_RESTART = 0x0002; -pub const SA_RESETHAND = 0x0004; -pub const SA_NOCLDSTOP = 0x0008; -pub const SA_NODEFER = 0x0010; -pub const SA_NOCLDWAIT = 0x0020; -pub const SA_SIGINFO = 0x0040; - -pub const SIGHUP = 1; -pub const SIGINT = 2; -pub const SIGQUIT = 3; -pub const SIGILL = 4; -pub const SIGTRAP = 5; -pub const SIGABRT = 6; -pub const SIGIOT = SIGABRT; -pub const SIGEMT = 7; -pub const SIGFPE = 8; -pub const SIGKILL = 9; -pub const SIGBUS = 10; -pub const SIGSEGV = 11; -pub const SIGSYS = 12; -pub const SIGPIPE = 13; -pub const SIGALRM = 14; -pub const SIGTERM = 15; -pub const SIGURG = 16; -pub const SIGSTOP = 17; -pub const SIGTSTP = 18; -pub const SIGCONT = 19; -pub const SIGCHLD = 20; -pub const SIGTTIN = 21; -pub const SIGTTOU = 22; -pub const SIGIO = 23; -pub const SIGXCPU = 24; -pub const SIGXFSZ = 25; -pub const SIGVTALRM = 26; -pub const SIGPROF = 27; -pub const SIGWINCH = 28; -pub const SIGINFO = 29; -pub const SIGUSR1 = 30; -pub const SIGUSR2 = 31; -pub const SIGPWR = 32; - -pub const SIGRTMIN = 33; -pub const SIGRTMAX = 63; - -// access function -pub const F_OK = 0; // test for existence of file -pub const X_OK = 1; // test for execute or search permission -pub const W_OK = 2; // test for write permission -pub const R_OK = 4; // test for read permission - -/// open for reading only -pub const O_RDONLY = 0x00000000; - -/// open for writing only -pub const O_WRONLY = 0x00000001; - -/// open for reading and writing -pub const O_RDWR = 0x00000002; - -/// mask for above modes -pub const O_ACCMODE = 0x00000003; - -/// no delay -pub const O_NONBLOCK = 0x00000004; - -/// set append mode -pub const O_APPEND = 0x00000008; - -/// open with shared file lock -pub const O_SHLOCK = 0x00000010; - -/// open with exclusive file lock -pub const O_EXLOCK = 0x00000020; - -/// signal pgrp when data ready -pub const O_ASYNC = 0x00000040; - -/// synchronous writes -pub const O_SYNC = 0x00000080; - -/// don't follow symlinks on the last -pub const O_NOFOLLOW = 0x00000100; - -/// create if nonexistent -pub const O_CREAT = 0x00000200; - -/// truncate to zero length -pub const O_TRUNC = 0x00000400; - -/// error if already exists -pub const O_EXCL = 0x00000800; - -/// don't assign controlling terminal -pub const O_NOCTTY = 0x00008000; - -/// write: I/O data completion -pub const O_DSYNC = 0x00010000; - -/// read: I/O completion as for write -pub const O_RSYNC = 0x00020000; - -/// use alternate i/o semantics -pub const O_ALT_IO = 0x00040000; - -/// direct I/O hint -pub const O_DIRECT = 0x00080000; - -/// fail if not a directory -pub const O_DIRECTORY = 0x00200000; - -/// set close on exec -pub const O_CLOEXEC = 0x00400000; - -/// skip search permission checks -pub const O_SEARCH = 0x00800000; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_GETOWN = 5; -pub const F_SETOWN = 6; - -pub const F_GETLK = 7; -pub const F_SETLK = 8; -pub const F_SETLKW = 9; - -pub const F_RDLCK = 1; -pub const F_WRLCK = 3; -pub const F_UNLCK = 2; - -pub const LOCK_SH = 1; -pub const LOCK_EX = 2; -pub const LOCK_UN = 8; -pub const LOCK_NB = 4; - -pub const FD_CLOEXEC = 1; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; - -pub const SIG_BLOCK = 1; -pub const SIG_UNBLOCK = 2; -pub const SIG_SETMASK = 3; - -pub const DT_UNKNOWN = 0; -pub const DT_FIFO = 1; -pub const DT_CHR = 2; -pub const DT_DIR = 4; -pub const DT_BLK = 6; -pub const DT_REG = 8; -pub const DT_LNK = 10; -pub const DT_SOCK = 12; -pub const DT_WHT = 14; - -/// add event to kq (implies enable) -pub const EV_ADD = 0x0001; - -/// delete event from kq -pub const EV_DELETE = 0x0002; - -/// enable event -pub const EV_ENABLE = 0x0004; - -/// disable event (not reported) -pub const EV_DISABLE = 0x0008; - -/// only report one occurrence -pub const EV_ONESHOT = 0x0010; - -/// clear event state after reporting -pub const EV_CLEAR = 0x0020; - -/// force immediate event output -/// ... with or without EV_ERROR -/// ... use KEVENT_FLAG_ERROR_EVENTS -/// on syscalls supporting flags -pub const EV_RECEIPT = 0x0040; - -/// disable event after reporting -pub const EV_DISPATCH = 0x0080; - -pub const EVFILT_READ = 0; -pub const EVFILT_WRITE = 1; - -/// attached to aio requests -pub const EVFILT_AIO = 2; - -/// attached to vnodes -pub const EVFILT_VNODE = 3; - -/// attached to struct proc -pub const EVFILT_PROC = 4; - -/// attached to struct proc -pub const EVFILT_SIGNAL = 5; - -/// timers -pub const EVFILT_TIMER = 6; - -/// Filesystem events -pub const EVFILT_FS = 7; - -/// On input, NOTE_TRIGGER causes the event to be triggered for output. -pub const NOTE_TRIGGER = 0x08000000; - -/// low water mark -pub const NOTE_LOWAT = 0x00000001; - -/// vnode was removed -pub const NOTE_DELETE = 0x00000001; - -/// data contents changed -pub const NOTE_WRITE = 0x00000002; - -/// size increased -pub const NOTE_EXTEND = 0x00000004; - -/// attributes changed -pub const NOTE_ATTRIB = 0x00000008; - -/// link count changed -pub const NOTE_LINK = 0x00000010; - -/// vnode was renamed -pub const NOTE_RENAME = 0x00000020; - -/// vnode access was revoked -pub const NOTE_REVOKE = 0x00000040; - -/// process exited -pub const NOTE_EXIT = 0x80000000; - -/// process forked -pub const NOTE_FORK = 0x40000000; - -/// process exec'd -pub const NOTE_EXEC = 0x20000000; - -/// mask for signal & exit status -pub const NOTE_PDATAMASK = 0x000fffff; -pub const NOTE_PCTRLMASK = 0xf0000000; - -pub const TIOCCBRK = 0x2000747a; -pub const TIOCCDTR = 0x20007478; -pub const TIOCCONS = 0x80047462; -pub const TIOCDCDTIMESTAMP = 0x40107458; -pub const TIOCDRAIN = 0x2000745e; -pub const TIOCEXCL = 0x2000740d; -pub const TIOCEXT = 0x80047460; -pub const TIOCFLAG_CDTRCTS = 0x10; -pub const TIOCFLAG_CLOCAL = 0x2; -pub const TIOCFLAG_CRTSCTS = 0x4; -pub const TIOCFLAG_MDMBUF = 0x8; -pub const TIOCFLAG_SOFTCAR = 0x1; -pub const TIOCFLUSH = 0x80047410; -pub const TIOCGETA = 0x402c7413; -pub const TIOCGETD = 0x4004741a; -pub const TIOCGFLAGS = 0x4004745d; -pub const TIOCGLINED = 0x40207442; -pub const TIOCGPGRP = 0x40047477; -pub const TIOCGQSIZE = 0x40047481; -pub const TIOCGRANTPT = 0x20007447; -pub const TIOCGSID = 0x40047463; -pub const TIOCGSIZE = 0x40087468; -pub const TIOCGWINSZ = 0x40087468; -pub const TIOCMBIC = 0x8004746b; -pub const TIOCMBIS = 0x8004746c; -pub const TIOCMGET = 0x4004746a; -pub const TIOCMSET = 0x8004746d; -pub const TIOCM_CAR = 0x40; -pub const TIOCM_CD = 0x40; -pub const TIOCM_CTS = 0x20; -pub const TIOCM_DSR = 0x100; -pub const TIOCM_DTR = 0x2; -pub const TIOCM_LE = 0x1; -pub const TIOCM_RI = 0x80; -pub const TIOCM_RNG = 0x80; -pub const TIOCM_RTS = 0x4; -pub const TIOCM_SR = 0x10; -pub const TIOCM_ST = 0x8; -pub const TIOCNOTTY = 0x20007471; -pub const TIOCNXCL = 0x2000740e; -pub const TIOCOUTQ = 0x40047473; -pub const TIOCPKT = 0x80047470; -pub const TIOCPKT_DATA = 0x0; -pub const TIOCPKT_DOSTOP = 0x20; -pub const TIOCPKT_FLUSHREAD = 0x1; -pub const TIOCPKT_FLUSHWRITE = 0x2; -pub const TIOCPKT_IOCTL = 0x40; -pub const TIOCPKT_NOSTOP = 0x10; -pub const TIOCPKT_START = 0x8; -pub const TIOCPKT_STOP = 0x4; -pub const TIOCPTMGET = 0x40287446; -pub const TIOCPTSNAME = 0x40287448; -pub const TIOCRCVFRAME = 0x80087445; -pub const TIOCREMOTE = 0x80047469; -pub const TIOCSBRK = 0x2000747b; -pub const TIOCSCTTY = 0x20007461; -pub const TIOCSDTR = 0x20007479; -pub const TIOCSETA = 0x802c7414; -pub const TIOCSETAF = 0x802c7416; -pub const TIOCSETAW = 0x802c7415; -pub const TIOCSETD = 0x8004741b; -pub const TIOCSFLAGS = 0x8004745c; -pub const TIOCSIG = 0x2000745f; -pub const TIOCSLINED = 0x80207443; -pub const TIOCSPGRP = 0x80047476; -pub const TIOCSQSIZE = 0x80047480; -pub const TIOCSSIZE = 0x80087467; -pub const TIOCSTART = 0x2000746e; -pub const TIOCSTAT = 0x80047465; -pub const TIOCSTI = 0x80017472; -pub const TIOCSTOP = 0x2000746f; -pub const TIOCSWINSZ = 0x80087467; -pub const TIOCUCNTL = 0x80047466; -pub const TIOCXMTFRAME = 0x80087444; - -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, (s >> 8) & 0xff); -} -pub fn WTERMSIG(s: u32) u32 { - return s & 0x7f; -} -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} - -pub fn WIFCONTINUED(s: u32) bool { - return ((s & 0x7f) == 0xffff); -} - -pub fn WIFSTOPPED(s: u32) bool { - return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s)); -} - -pub fn WIFSIGNALED(s: u32) bool { - return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s); -} - -pub const winsize = extern struct { - ws_row: u16, - ws_col: u16, - ws_xpixel: u16, - ws_ypixel: u16, -}; - -const NSIG = 32; - -pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); -pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); -pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); - -/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. -pub const Sigaction = extern struct { - pub const handler_fn = fn (c_int) callconv(.C) void; - pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; - - /// signal handler - handler: extern union { - handler: ?handler_fn, - sigaction: ?sigaction_fn, - }, - /// signal mask to apply - mask: sigset_t, - /// signal options - flags: c_uint, -}; - -pub const sigval_t = extern union { - int: i32, - ptr: ?*c_void, -}; - -pub const siginfo_t = extern union { - pad: [128]u8, - info: _ksiginfo, -}; - -pub const _ksiginfo = extern struct { - signo: i32, - code: i32, - errno: i32, - // 64bit architectures insert 4bytes of padding here, this is done by - // correctly aligning the reason field - reason: extern union { - rt: extern struct { - pid: pid_t, - uid: uid_t, - value: sigval_t, - }, - child: extern struct { - pid: pid_t, - uid: uid_t, - status: i32, - utime: clock_t, - stime: clock_t, - }, - fault: extern struct { - addr: ?*c_void, - trap: i32, - trap2: i32, - trap3: i32, - }, - poll: extern struct { - band: i32, - fd: i32, - }, - syscall: extern struct { - sysnum: i32, - retval: [2]i32, - @"error": i32, - args: [8]u64, - }, - ptrace_state: extern struct { - pe_report_event: i32, - option: extern union { - pe_other_pid: pid_t, - pe_lwp: lwpid_t, - }, - }, - } align(@sizeOf(usize)), -}; - -pub const _SIG_WORDS = 4; -pub const _SIG_MAXSIG = 128; - -pub inline fn _SIG_IDX(sig: usize) usize { - return sig - 1; -} -pub inline fn _SIG_WORD(sig: usize) usize { - return_SIG_IDX(sig) >> 5; -} -pub inline fn _SIG_BIT(sig: usize) usize { - return 1 << (_SIG_IDX(sig) & 31); -} -pub inline fn _SIG_VALID(sig: usize) usize { - return sig <= _SIG_MAXSIG and sig > 0; -} - -pub const sigset_t = extern struct { - __bits: [_SIG_WORDS]u32, -}; - -pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; - -// XXX x86_64 specific -pub const mcontext_t = extern struct { - gregs: [26]u64, - mc_tlsbase: u64, - fpregs: [512]u8 align(8), -}; - -pub const REG_RBP = 12; -pub const REG_RIP = 21; -pub const REG_RSP = 24; - -pub const ucontext_t = extern struct { - flags: u32, - link: ?*ucontext_t, - sigmask: sigset_t, - stack: stack_t, - mcontext: mcontext_t, - __pad: [ - switch (builtin.cpu.arch) { - .i386 => 4, - .mips, .mipsel, .mips64, .mips64el => 14, - .arm, .armeb, .thumb, .thumbeb => 1, - .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, - else => 0, - } - ]u32, -}; - -pub const E = enum(u16) { - /// No error occurred. - SUCCESS = 0, - PERM = 1, // Operation not permitted - NOENT = 2, // No such file or directory - SRCH = 3, // No such process - INTR = 4, // Interrupted system call - IO = 5, // Input/output error - NXIO = 6, // Device not configured - @"2BIG" = 7, // Argument list too long - NOEXEC = 8, // Exec format error - BADF = 9, // Bad file descriptor - CHILD = 10, // No child processes - DEADLK = 11, // Resource deadlock avoided - // 11 was AGAIN - NOMEM = 12, // Cannot allocate memory - ACCES = 13, // Permission denied - FAULT = 14, // Bad address - NOTBLK = 15, // Block device required - BUSY = 16, // Device busy - EXIST = 17, // File exists - XDEV = 18, // Cross-device link - NODEV = 19, // Operation not supported by device - NOTDIR = 20, // Not a directory - ISDIR = 21, // Is a directory - INVAL = 22, // Invalid argument - NFILE = 23, // Too many open files in system - MFILE = 24, // Too many open files - NOTTY = 25, // Inappropriate ioctl for device - TXTBSY = 26, // Text file busy - FBIG = 27, // File too large - NOSPC = 28, // No space left on device - SPIPE = 29, // Illegal seek - ROFS = 30, // Read-only file system - MLINK = 31, // Too many links - PIPE = 32, // Broken pipe - - // math software - DOM = 33, // Numerical argument out of domain - RANGE = 34, // Result too large or too small - - // non-blocking and interrupt i/o - // also: WOULDBLOCK: operation would block - AGAIN = 35, // Resource temporarily unavailable - INPROGRESS = 36, // Operation now in progress - ALREADY = 37, // Operation already in progress - - // ipc/network software -- argument errors - NOTSOCK = 38, // Socket operation on non-socket - DESTADDRREQ = 39, // Destination address required - MSGSIZE = 40, // Message too long - PROTOTYPE = 41, // Protocol wrong type for socket - NOPROTOOPT = 42, // Protocol option not available - PROTONOSUPPORT = 43, // Protocol not supported - SOCKTNOSUPPORT = 44, // Socket type not supported - OPNOTSUPP = 45, // Operation not supported - PFNOSUPPORT = 46, // Protocol family not supported - AFNOSUPPORT = 47, // Address family not supported by protocol family - ADDRINUSE = 48, // Address already in use - ADDRNOTAVAIL = 49, // Can't assign requested address - - // ipc/network software -- operational errors - NETDOWN = 50, // Network is down - NETUNREACH = 51, // Network is unreachable - NETRESET = 52, // Network dropped connection on reset - CONNABORTED = 53, // Software caused connection abort - CONNRESET = 54, // Connection reset by peer - NOBUFS = 55, // No buffer space available - ISCONN = 56, // Socket is already connected - NOTCONN = 57, // Socket is not connected - SHUTDOWN = 58, // Can't send after socket shutdown - TOOMANYREFS = 59, // Too many references: can't splice - TIMEDOUT = 60, // Operation timed out - CONNREFUSED = 61, // Connection refused - - LOOP = 62, // Too many levels of symbolic links - NAMETOOLONG = 63, // File name too long - - // should be rearranged - HOSTDOWN = 64, // Host is down - HOSTUNREACH = 65, // No route to host - NOTEMPTY = 66, // Directory not empty - - // quotas & mush - PROCLIM = 67, // Too many processes - USERS = 68, // Too many users - DQUOT = 69, // Disc quota exceeded - - // Network File System - STALE = 70, // Stale NFS file handle - REMOTE = 71, // Too many levels of remote in path - BADRPC = 72, // RPC struct is bad - RPCMISMATCH = 73, // RPC version wrong - PROGUNAVAIL = 74, // RPC prog. not avail - PROGMISMATCH = 75, // Program version wrong - PROCUNAVAIL = 76, // Bad procedure for program - - NOLCK = 77, // No locks available - NOSYS = 78, // Function not implemented - - FTYPE = 79, // Inappropriate file type or format - AUTH = 80, // Authentication error - NEEDAUTH = 81, // Need authenticator - - // SystemV IPC - IDRM = 82, // Identifier removed - NOMSG = 83, // No message of desired type - OVERFLOW = 84, // Value too large to be stored in data type - - // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 - ILSEQ = 85, // Illegal byte sequence - - // From IEEE Std 1003.1-2001 - // Base, Realtime, Threads or Thread Priority Scheduling option errors - NOTSUP = 86, // Not supported - - // Realtime option errors - CANCELED = 87, // Operation canceled - - // Realtime, XSI STREAMS option errors - BADMSG = 88, // Bad or Corrupt message - - // XSI STREAMS option errors - NODATA = 89, // No message available - NOSR = 90, // No STREAM resources - NOSTR = 91, // Not a STREAM - TIME = 92, // STREAM ioctl timeout - - // File system extended attribute errors - NOATTR = 93, // Attribute not found - - // Realtime, XSI STREAMS option errors - MULTIHOP = 94, // Multihop attempted - NOLINK = 95, // Link has been severed - PROTO = 96, // Protocol error - - _, -}; - -pub const MINSIGSTKSZ = 8192; -pub const SIGSTKSZ = MINSIGSTKSZ + 32768; - -pub const SS_ONSTACK = 1; -pub const SS_DISABLE = 4; - -pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, -}; - -pub const S_IFMT = 0o170000; - -pub const S_IFIFO = 0o010000; -pub const S_IFCHR = 0o020000; -pub const S_IFDIR = 0o040000; -pub const S_IFBLK = 0o060000; -pub const S_IFREG = 0o100000; -pub const S_IFLNK = 0o120000; -pub const S_IFSOCK = 0o140000; -pub const S_IFWHT = 0o160000; - -pub const S_ISUID = 0o4000; -pub const S_ISGID = 0o2000; -pub const S_ISVTX = 0o1000; -pub const S_IRWXU = 0o700; -pub const S_IRUSR = 0o400; -pub const S_IWUSR = 0o200; -pub const S_IXUSR = 0o100; -pub const S_IRWXG = 0o070; -pub const S_IRGRP = 0o040; -pub const S_IWGRP = 0o020; -pub const S_IXGRP = 0o010; -pub const S_IRWXO = 0o007; -pub const S_IROTH = 0o004; -pub const S_IWOTH = 0o002; -pub const S_IXOTH = 0o001; - -pub fn S_ISFIFO(m: u32) bool { - return m & S_IFMT == S_IFIFO; -} - -pub fn S_ISCHR(m: u32) bool { - return m & S_IFMT == S_IFCHR; -} - -pub fn S_ISDIR(m: u32) bool { - return m & S_IFMT == S_IFDIR; -} - -pub fn S_ISBLK(m: u32) bool { - return m & S_IFMT == S_IFBLK; -} - -pub fn S_ISREG(m: u32) bool { - return m & S_IFMT == S_IFREG; -} - -pub fn S_ISLNK(m: u32) bool { - return m & S_IFMT == S_IFLNK; -} - -pub fn S_ISSOCK(m: u32) bool { - return m & S_IFMT == S_IFSOCK; -} - -pub fn S_IWHT(m: u32) bool { - return m & S_IFMT == S_IFWHT; -} - -/// Magic value that specify the use of the current working directory -/// to determine the target of relative file paths in the openat() and -/// similar syscalls. -pub const AT_FDCWD = -100; - -/// Check access using effective user and group ID -pub const AT_EACCESS = 0x0100; - -/// Do not follow symbolic links -pub const AT_SYMLINK_NOFOLLOW = 0x0200; - -/// Follow symbolic link -pub const AT_SYMLINK_FOLLOW = 0x0400; - -/// Remove directory instead of file -pub const AT_REMOVEDIR = 0x0800; - -pub const HOST_NAME_MAX = 255; - -/// dummy for IP -pub const IPPROTO_IP = 0; - -/// IP6 hop-by-hop options -pub const IPPROTO_HOPOPTS = 0; - -/// control message protocol -pub const IPPROTO_ICMP = 1; - -/// group mgmt protocol -pub const IPPROTO_IGMP = 2; - -/// gateway^2 (deprecated) -pub const IPPROTO_GGP = 3; - -/// IP header -pub const IPPROTO_IPV4 = 4; - -/// IP inside IP -pub const IPPROTO_IPIP = 4; - -/// tcp -pub const IPPROTO_TCP = 6; - -/// exterior gateway protocol -pub const IPPROTO_EGP = 8; - -/// pup -pub const IPPROTO_PUP = 12; - -/// user datagram protocol -pub const IPPROTO_UDP = 17; - -/// xns idp -pub const IPPROTO_IDP = 22; - -/// tp-4 w/ class negotiation -pub const IPPROTO_TP = 29; - -/// DCCP -pub const IPPROTO_DCCP = 33; - -/// IP6 header -pub const IPPROTO_IPV6 = 41; - -/// IP6 routing header -pub const IPPROTO_ROUTING = 43; - -/// IP6 fragmentation header -pub const IPPROTO_FRAGMENT = 44; - -/// resource reservation -pub const IPPROTO_RSVP = 46; - -/// GRE encaps RFC 1701 -pub const IPPROTO_GRE = 47; - -/// encap. security payload -pub const IPPROTO_ESP = 50; - -/// authentication header -pub const IPPROTO_AH = 51; - -/// IP Mobility RFC 2004 -pub const IPPROTO_MOBILE = 55; - -/// IPv6 ICMP -pub const IPPROTO_IPV6_ICMP = 58; - -/// ICMP6 -pub const IPPROTO_ICMPV6 = 58; - -/// IP6 no next header -pub const IPPROTO_NONE = 59; - -/// IP6 destination option -pub const IPPROTO_DSTOPTS = 60; - -/// ISO cnlp -pub const IPPROTO_EON = 80; - -/// Ethernet-in-IP -pub const IPPROTO_ETHERIP = 97; - -/// encapsulation header -pub const IPPROTO_ENCAP = 98; - -/// Protocol indep. multicast -pub const IPPROTO_PIM = 103; - -/// IP Payload Comp. Protocol -pub const IPPROTO_IPCOMP = 108; - -/// VRRP RFC 2338 -pub const IPPROTO_VRRP = 112; - -/// Common Address Resolution Protocol -pub const IPPROTO_CARP = 112; - -/// L2TPv3 -pub const IPPROTO_L2TP = 115; - -/// SCTP -pub const IPPROTO_SCTP = 132; - -/// PFSYNC -pub const IPPROTO_PFSYNC = 240; - -/// raw IP packet -pub const IPPROTO_RAW = 255; - -pub const rlimit_resource = enum(c_int) { - CPU = 0, - FSIZE = 1, - DATA = 2, - STACK = 3, - CORE = 4, - RSS = 5, - MEMLOCK = 6, - NPROC = 7, - NOFILE = 8, - SBSIZE = 9, - VMEM = 10, - NTHR = 11, - _, - - pub const AS: rlimit_resource = .VMEM; -}; - -pub const rlim_t = u64; - -/// No limit -pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -pub const nfds_t = u32; - -pub const pollfd = extern struct { - fd: fd_t, - events: i16, - revents: i16, -}; - -/// Testable events (may be specified in events field). -pub const POLLIN = 0x0001; -pub const POLLPRI = 0x0002; -pub const POLLOUT = 0x0004; -pub const POLLRDNORM = 0x0040; -pub const POLLWRNORM = POLLOUT; -pub const POLLRDBAND = 0x0080; -pub const POLLWRBAND = 0x0100; - -/// Non-testable events (may not be specified in events field). -pub const POLLERR = 0x0008; -pub const POLLHUP = 0x0010; -pub const POLLNVAL = 0x0020; diff --git a/lib/std/os/bits/openbsd.zig b/lib/std/os/bits/openbsd.zig deleted file mode 100644 index c7d1c0583b..0000000000 --- a/lib/std/os/bits/openbsd.zig +++ /dev/null @@ -1,1330 +0,0 @@ -const std = @import("../../std.zig"); -const builtin = std.builtin; -const maxInt = std.math.maxInt; - -pub usingnamespace @import("posix.zig"); - -pub const blkcnt_t = i64; -pub const blksize_t = i32; -pub const clock_t = i64; -pub const dev_t = i32; -pub const fd_t = c_int; -pub const gid_t = u32; -pub const ino_t = u64; -pub const mode_t = u32; -pub const nlink_t = u32; -pub const off_t = i64; -pub const pid_t = i32; -pub const socklen_t = u32; -pub const time_t = i64; -pub const uid_t = u32; - -/// Renamed from `kevent` to `Kevent` to avoid conflict with function name. -pub const Kevent = extern struct { - ident: usize, - filter: c_short, - flags: u16, - fflags: c_uint, - data: i64, - udata: usize, -}; - -// Modes and flags for dlopen() -// include/dlfcn.h - -/// Bind function calls lazily. -pub const RTLD_LAZY = 1; - -/// Bind function calls immediately. -pub const RTLD_NOW = 2; - -/// Make symbols globally available. -pub const RTLD_GLOBAL = 0x100; - -/// Opposite of RTLD_GLOBAL, and the default. -pub const RTLD_LOCAL = 0x000; - -/// Trace loaded objects and exit. -pub const RTLD_TRACE = 0x200; - -pub const dl_phdr_info = extern struct { - dlpi_addr: std.elf.Addr, - dlpi_name: ?[*:0]const u8, - dlpi_phdr: [*]std.elf.Phdr, - dlpi_phnum: std.elf.Half, -}; - -pub const Flock = extern struct { - l_start: off_t, - l_len: off_t, - l_pid: pid_t, - l_type: c_short, - l_whence: c_short, -}; - -pub const addrinfo = extern struct { - flags: c_int, - family: c_int, - socktype: c_int, - protocol: c_int, - addrlen: socklen_t, - addr: ?*sockaddr, - canonname: ?[*:0]u8, - next: ?*addrinfo, -}; - -pub const EAI = enum(c_int) { - /// address family for hostname not supported - ADDRFAMILY = -9, - - /// name could not be resolved at this time - AGAIN = -3, - - /// flags parameter had an invalid value - BADFLAGS = -1, - - /// non-recoverable failure in name resolution - FAIL = -4, - - /// address family not recognized - FAMILY = -6, - - /// memory allocation failure - MEMORY = -10, - - /// no address associated with hostname - NODATA = -5, - - /// name does not resolve - NONAME = -2, - - /// service not recognized for socket type - SERVICE = -8, - - /// intended socket type was not recognized - SOCKTYPE = -7, - - /// system error returned in errno - SYSTEM = -11, - - /// invalid value for hints - BADHINTS = -12, - - /// resolved protocol is unknown - PROTOCOL = -13, - - /// argument buffer overflow - OVERFLOW = -14, - - _, -}; - -pub const EAI_MAX = 15; - -pub const msghdr = extern struct { - /// optional address - msg_name: ?*sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec, - - /// # elements in msg_iov - msg_iovlen: c_uint, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: c_int, -}; - -pub const msghdr_const = extern struct { - /// optional address - msg_name: ?*const sockaddr, - - /// size of address - msg_namelen: socklen_t, - - /// scatter/gather array - msg_iov: [*]iovec_const, - - /// # elements in msg_iov - msg_iovlen: c_uint, - - /// ancillary data - msg_control: ?*c_void, - - /// ancillary data buffer len - msg_controllen: socklen_t, - - /// flags on received message - msg_flags: c_int, -}; - -pub const libc_stat = extern struct { - mode: mode_t, - dev: dev_t, - ino: ino_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - size: off_t, - blocks: blkcnt_t, - blksize: blksize_t, - flags: u32, - gen: u32, - birthtim: timespec, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - -pub const timespec = extern struct { - tv_sec: time_t, - tv_nsec: c_long, -}; - -pub const timeval = extern struct { - tv_sec: time_t, - tv_usec: c_long, -}; - -pub const timezone = extern struct { - tz_minuteswest: c_int, - tz_dsttime: c_int, -}; - -pub const MAXNAMLEN = 255; - -pub const dirent = extern struct { - d_fileno: ino_t, - d_off: off_t, - d_reclen: u16, - d_type: u8, - d_namlen: u8, - __d_padding: [4]u8, - d_name: [MAXNAMLEN + 1]u8, - - pub fn reclen(self: dirent) u16 { - return self.d_reclen; - } -}; - -pub const in_port_t = u16; -pub const sa_family_t = u8; - -pub const sockaddr = extern struct { - /// total length - len: u8, - - /// address family - family: sa_family_t, - - /// actually longer; address value - data: [14]u8, -}; - -pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; - -pub const sockaddr_in = extern struct { - len: u8 = @sizeOf(sockaddr_in), - family: sa_family_t = AF_INET, - port: in_port_t, - addr: u32, - zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -pub const sockaddr_in6 = extern struct { - len: u8 = @sizeOf(sockaddr_in6), - family: sa_family_t = AF_INET6, - port: in_port_t, - flowinfo: u32, - addr: [16]u8, - scope_id: u32, -}; - -/// Definitions for UNIX IPC domain. -pub const sockaddr_un = extern struct { - /// total sockaddr length - len: u8 = @sizeOf(sockaddr_un), - - /// AF_LOCAL - family: sa_family_t = AF_LOCAL, - - /// path name - path: [104]u8, -}; - -/// get address to use bind() -pub const AI_PASSIVE = 1; - -/// fill ai_canonname -pub const AI_CANONNAME = 2; - -/// prevent host name resolution -pub const AI_NUMERICHOST = 4; - -/// prevent service name resolution -pub const AI_NUMERICSERV = 16; - -/// only if any address is assigned -pub const AI_ADDRCONFIG = 64; - -pub const PATH_MAX = 1024; -pub const IOV_MAX = 1024; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -pub const PROT_NONE = 0; -pub const PROT_READ = 1; -pub const PROT_WRITE = 2; -pub const PROT_EXEC = 4; - -pub const CLOCK_REALTIME = 0; -pub const CLOCK_PROCESS_CPUTIME_ID = 2; -pub const CLOCK_MONOTONIC = 3; -pub const CLOCK_THREAD_CPUTIME_ID = 4; - -pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); -pub const MAP_SHARED = 0x0001; -pub const MAP_PRIVATE = 0x0002; -pub const MAP_FIXED = 0x0010; -pub const MAP_RENAME = 0; -pub const MAP_NORESERVE = 0; -pub const MAP_INHERIT = 0; -pub const MAP_HASSEMAPHORE = 0; -pub const MAP_TRYFIXED = 0; - -pub const MAP_FILE = 0; -pub const MAP_ANON = 0x1000; -pub const MAP_ANONYMOUS = MAP_ANON; -pub const MAP_STACK = 0x4000; -pub const MAP_CONCEAL = 0x8000; - -pub const WNOHANG = 1; -pub const WUNTRACED = 2; -pub const WCONTINUED = 8; - -pub const SA_ONSTACK = 0x0001; -pub const SA_RESTART = 0x0002; -pub const SA_RESETHAND = 0x0004; -pub const SA_NOCLDSTOP = 0x0008; -pub const SA_NODEFER = 0x0010; -pub const SA_NOCLDWAIT = 0x0020; -pub const SA_SIGINFO = 0x0040; - -pub const SIGHUP = 1; -pub const SIGINT = 2; -pub const SIGQUIT = 3; -pub const SIGILL = 4; -pub const SIGTRAP = 5; -pub const SIGABRT = 6; -pub const SIGIOT = SIGABRT; -pub const SIGEMT = 7; -pub const SIGFPE = 8; -pub const SIGKILL = 9; -pub const SIGBUS = 10; -pub const SIGSEGV = 11; -pub const SIGSYS = 12; -pub const SIGPIPE = 13; -pub const SIGALRM = 14; -pub const SIGTERM = 15; -pub const SIGURG = 16; -pub const SIGSTOP = 17; -pub const SIGTSTP = 18; -pub const SIGCONT = 19; -pub const SIGCHLD = 20; -pub const SIGTTIN = 21; -pub const SIGTTOU = 22; -pub const SIGIO = 23; -pub const SIGXCPU = 24; -pub const SIGXFSZ = 25; -pub const SIGVTALRM = 26; -pub const SIGPROF = 27; -pub const SIGWINCH = 28; -pub const SIGINFO = 29; -pub const SIGUSR1 = 30; -pub const SIGUSR2 = 31; -pub const SIGPWR = 32; - -// access function -pub const F_OK = 0; // test for existence of file -pub const X_OK = 1; // test for execute or search permission -pub const W_OK = 2; // test for write permission -pub const R_OK = 4; // test for read permission - -/// open for reading only -pub const O_RDONLY = 0x00000000; - -/// open for writing only -pub const O_WRONLY = 0x00000001; - -/// open for reading and writing -pub const O_RDWR = 0x00000002; - -/// mask for above modes -pub const O_ACCMODE = 0x00000003; - -/// no delay -pub const O_NONBLOCK = 0x00000004; - -/// set append mode -pub const O_APPEND = 0x00000008; - -/// open with shared file lock -pub const O_SHLOCK = 0x00000010; - -/// open with exclusive file lock -pub const O_EXLOCK = 0x00000020; - -/// signal pgrp when data ready -pub const O_ASYNC = 0x00000040; - -/// synchronous writes -pub const O_SYNC = 0x00000080; - -/// don't follow symlinks on the last -pub const O_NOFOLLOW = 0x00000100; - -/// create if nonexistent -pub const O_CREAT = 0x00000200; - -/// truncate to zero length -pub const O_TRUNC = 0x00000400; - -/// error if already exists -pub const O_EXCL = 0x00000800; - -/// don't assign controlling terminal -pub const O_NOCTTY = 0x00008000; - -/// write: I/O data completion -pub const O_DSYNC = O_SYNC; - -/// read: I/O completion as for write -pub const O_RSYNC = O_SYNC; - -/// fail if not a directory -pub const O_DIRECTORY = 0x20000; - -/// set close on exec -pub const O_CLOEXEC = 0x10000; - -pub const F_DUPFD = 0; -pub const F_GETFD = 1; -pub const F_SETFD = 2; -pub const F_GETFL = 3; -pub const F_SETFL = 4; - -pub const F_GETOWN = 5; -pub const F_SETOWN = 6; - -pub const F_GETLK = 7; -pub const F_SETLK = 8; -pub const F_SETLKW = 9; - -pub const F_RDLCK = 1; -pub const F_UNLCK = 2; -pub const F_WRLCK = 3; - -pub const LOCK_SH = 0x01; -pub const LOCK_EX = 0x02; -pub const LOCK_NB = 0x04; -pub const LOCK_UN = 0x08; - -pub const FD_CLOEXEC = 1; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; - -pub const SIG_BLOCK = 1; -pub const SIG_UNBLOCK = 2; -pub const SIG_SETMASK = 3; - -pub const SOCK_STREAM = 1; -pub const SOCK_DGRAM = 2; -pub const SOCK_RAW = 3; -pub const SOCK_RDM = 4; -pub const SOCK_SEQPACKET = 5; - -pub const SOCK_CLOEXEC = 0x8000; -pub const SOCK_NONBLOCK = 0x4000; - -pub const SO_DEBUG = 0x0001; -pub const SO_ACCEPTCONN = 0x0002; -pub const SO_REUSEADDR = 0x0004; -pub const SO_KEEPALIVE = 0x0008; -pub const SO_DONTROUTE = 0x0010; -pub const SO_BROADCAST = 0x0020; -pub const SO_USELOOPBACK = 0x0040; -pub const SO_LINGER = 0x0080; -pub const SO_OOBINLINE = 0x0100; -pub const SO_REUSEPORT = 0x0200; -pub const SO_TIMESTAMP = 0x0800; -pub const SO_BINDANY = 0x1000; -pub const SO_ZEROIZE = 0x2000; -pub const SO_SNDBUF = 0x1001; -pub const SO_RCVBUF = 0x1002; -pub const SO_SNDLOWAT = 0x1003; -pub const SO_RCVLOWAT = 0x1004; -pub const SO_SNDTIMEO = 0x1005; -pub const SO_RCVTIMEO = 0x1006; -pub const SO_ERROR = 0x1007; -pub const SO_TYPE = 0x1008; -pub const SO_NETPROC = 0x1020; -pub const SO_RTABLE = 0x1021; -pub const SO_PEERCRED = 0x1022; -pub const SO_SPLICE = 0x1023; -pub const SO_DOMAIN = 0x1024; -pub const SO_PROTOCOL = 0x1025; - -pub const SOL_SOCKET = 0xffff; - -pub const PF_UNSPEC = AF_UNSPEC; -pub const PF_LOCAL = AF_LOCAL; -pub const PF_UNIX = AF_UNIX; -pub const PF_INET = AF_INET; -pub const PF_APPLETALK = AF_APPLETALK; -pub const PF_INET6 = AF_INET6; -pub const PF_DECnet = AF_DECnet; -pub const PF_KEY = AF_KEY; -pub const PF_ROUTE = AF_ROUTE; -pub const PF_SNA = AF_SNA; -pub const PF_MPLS = AF_MPLS; -pub const PF_BLUETOOTH = AF_BLUETOOTH; -pub const PF_ISDN = AF_ISDN; -pub const PF_MAX = AF_MAX; - -pub const AF_UNSPEC = 0; -pub const AF_UNIX = 1; -pub const AF_LOCAL = AF_UNIX; -pub const AF_INET = 2; -pub const AF_APPLETALK = 16; -pub const AF_INET6 = 24; -pub const AF_KEY = 30; -pub const AF_ROUTE = 17; -pub const AF_SNA = 11; -pub const AF_MPLS = 33; -pub const AF_BLUETOOTH = 32; -pub const AF_ISDN = 26; -pub const AF_MAX = 36; - -pub const DT_UNKNOWN = 0; -pub const DT_FIFO = 1; -pub const DT_CHR = 2; -pub const DT_DIR = 4; -pub const DT_BLK = 6; -pub const DT_REG = 8; -pub const DT_LNK = 10; -pub const DT_SOCK = 12; -pub const DT_WHT = 14; // XXX - -pub const EV_ADD = 0x0001; -pub const EV_DELETE = 0x0002; -pub const EV_ENABLE = 0x0004; -pub const EV_DISABLE = 0x0008; -pub const EV_ONESHOT = 0x0010; -pub const EV_CLEAR = 0x0020; -pub const EV_RECEIPT = 0x0040; -pub const EV_DISPATCH = 0x0080; -pub const EV_FLAG1 = 0x2000; -pub const EV_ERROR = 0x4000; -pub const EV_EOF = 0x8000; - -pub const EVFILT_READ = -1; -pub const EVFILT_WRITE = -2; -pub const EVFILT_AIO = -3; -pub const EVFILT_VNODE = -4; -pub const EVFILT_PROC = -5; -pub const EVFILT_SIGNAL = -6; -pub const EVFILT_TIMER = -7; -pub const EVFILT_EXCEPT = -9; - -// data/hint flags for EVFILT_{READ|WRITE} -pub const NOTE_LOWAT = 0x0001; -pub const NOTE_EOF = 0x0002; - -// data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE} -pub const NOTE_OOB = 0x0004; - -// data/hint flags for EVFILT_VNODE -pub const NOTE_DELETE = 0x0001; -pub const NOTE_WRITE = 0x0002; -pub const NOTE_EXTEND = 0x0004; -pub const NOTE_ATTRIB = 0x0008; -pub const NOTE_LINK = 0x0010; -pub const NOTE_RENAME = 0x0020; -pub const NOTE_REVOKE = 0x0040; -pub const NOTE_TRUNCATE = 0x0080; - -// data/hint flags for EVFILT_PROC -pub const NOTE_EXIT = 0x80000000; -pub const NOTE_FORK = 0x40000000; -pub const NOTE_EXEC = 0x20000000; -pub const NOTE_PDATAMASK = 0x000fffff; -pub const NOTE_PCTRLMASK = 0xf0000000; -pub const NOTE_TRACK = 0x00000001; -pub const NOTE_TRACKERR = 0x00000002; -pub const NOTE_CHILD = 0x00000004; - -// data/hint flags for EVFILT_DEVICE -pub const NOTE_CHANGE = 0x00000001; - -pub const TIOCCBRK = 0x2000747a; -pub const TIOCCDTR = 0x20007478; -pub const TIOCCONS = 0x80047462; -pub const TIOCDCDTIMESTAMP = 0x40107458; -pub const TIOCDRAIN = 0x2000745e; -pub const TIOCEXCL = 0x2000740d; -pub const TIOCEXT = 0x80047460; -pub const TIOCFLAG_CDTRCTS = 0x10; -pub const TIOCFLAG_CLOCAL = 0x2; -pub const TIOCFLAG_CRTSCTS = 0x4; -pub const TIOCFLAG_MDMBUF = 0x8; -pub const TIOCFLAG_SOFTCAR = 0x1; -pub const TIOCFLUSH = 0x80047410; -pub const TIOCGETA = 0x402c7413; -pub const TIOCGETD = 0x4004741a; -pub const TIOCGFLAGS = 0x4004745d; -pub const TIOCGLINED = 0x40207442; -pub const TIOCGPGRP = 0x40047477; -pub const TIOCGQSIZE = 0x40047481; -pub const TIOCGRANTPT = 0x20007447; -pub const TIOCGSID = 0x40047463; -pub const TIOCGSIZE = 0x40087468; -pub const TIOCGWINSZ = 0x40087468; -pub const TIOCMBIC = 0x8004746b; -pub const TIOCMBIS = 0x8004746c; -pub const TIOCMGET = 0x4004746a; -pub const TIOCMSET = 0x8004746d; -pub const TIOCM_CAR = 0x40; -pub const TIOCM_CD = 0x40; -pub const TIOCM_CTS = 0x20; -pub const TIOCM_DSR = 0x100; -pub const TIOCM_DTR = 0x2; -pub const TIOCM_LE = 0x1; -pub const TIOCM_RI = 0x80; -pub const TIOCM_RNG = 0x80; -pub const TIOCM_RTS = 0x4; -pub const TIOCM_SR = 0x10; -pub const TIOCM_ST = 0x8; -pub const TIOCNOTTY = 0x20007471; -pub const TIOCNXCL = 0x2000740e; -pub const TIOCOUTQ = 0x40047473; -pub const TIOCPKT = 0x80047470; -pub const TIOCPKT_DATA = 0x0; -pub const TIOCPKT_DOSTOP = 0x20; -pub const TIOCPKT_FLUSHREAD = 0x1; -pub const TIOCPKT_FLUSHWRITE = 0x2; -pub const TIOCPKT_IOCTL = 0x40; -pub const TIOCPKT_NOSTOP = 0x10; -pub const TIOCPKT_START = 0x8; -pub const TIOCPKT_STOP = 0x4; -pub const TIOCPTMGET = 0x40287446; -pub const TIOCPTSNAME = 0x40287448; -pub const TIOCRCVFRAME = 0x80087445; -pub const TIOCREMOTE = 0x80047469; -pub const TIOCSBRK = 0x2000747b; -pub const TIOCSCTTY = 0x20007461; -pub const TIOCSDTR = 0x20007479; -pub const TIOCSETA = 0x802c7414; -pub const TIOCSETAF = 0x802c7416; -pub const TIOCSETAW = 0x802c7415; -pub const TIOCSETD = 0x8004741b; -pub const TIOCSFLAGS = 0x8004745c; -pub const TIOCSIG = 0x2000745f; -pub const TIOCSLINED = 0x80207443; -pub const TIOCSPGRP = 0x80047476; -pub const TIOCSQSIZE = 0x80047480; -pub const TIOCSSIZE = 0x80087467; -pub const TIOCSTART = 0x2000746e; -pub const TIOCSTAT = 0x80047465; -pub const TIOCSTI = 0x80017472; -pub const TIOCSTOP = 0x2000746f; -pub const TIOCSWINSZ = 0x80087467; -pub const TIOCUCNTL = 0x80047466; -pub const TIOCXMTFRAME = 0x80087444; - -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, (s >> 8) & 0xff); -} -pub fn WTERMSIG(s: u32) u32 { - return (s & 0x7f); -} -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} - -pub fn WIFCONTINUED(s: u32) bool { - return ((s & 0o177777) == 0o177777); -} - -pub fn WIFSTOPPED(s: u32) bool { - return (s & 0xff == 0o177); -} - -pub fn WIFSIGNALED(s: u32) bool { - return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); -} - -pub const winsize = extern struct { - ws_row: c_ushort, - ws_col: c_ushort, - ws_xpixel: c_ushort, - ws_ypixel: c_ushort, -}; - -const NSIG = 33; - -pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); -pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); -pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); -pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2); -pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3); - -/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. -pub const Sigaction = extern struct { - pub const handler_fn = fn (c_int) callconv(.C) void; - pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; - - /// signal handler - handler: extern union { - handler: ?handler_fn, - sigaction: ?sigaction_fn, - }, - /// signal mask to apply - mask: sigset_t, - /// signal options - flags: c_uint, -}; - -pub const sigval = extern union { - int: c_int, - ptr: ?*c_void, -}; - -pub const siginfo_t = extern struct { - signo: c_int, - code: c_int, - errno: c_int, - data: extern union { - proc: extern struct { - pid: pid_t, - pdata: extern union { - kill: extern struct { - uid: uid_t, - value: sigval, - }, - cld: extern struct { - utime: clock_t, - stime: clock_t, - status: c_int, - }, - }, - }, - fault: extern struct { - addr: ?*c_void, - trapno: c_int, - }, - __pad: [128 - 3 * @sizeOf(c_int)]u8, - }, -}; - -comptime { - if (@sizeOf(usize) == 4) - std.debug.assert(@sizeOf(siginfo_t) == 128) - else - // Take into account the padding between errno and data fields. - std.debug.assert(@sizeOf(siginfo_t) == 136); -} - -pub usingnamespace switch (builtin.target.cpu.arch) { - .x86_64 => struct { - pub const ucontext_t = extern struct { - sc_rdi: c_long, - sc_rsi: c_long, - sc_rdx: c_long, - sc_rcx: c_long, - sc_r8: c_long, - sc_r9: c_long, - sc_r10: c_long, - sc_r11: c_long, - sc_r12: c_long, - sc_r13: c_long, - sc_r14: c_long, - sc_r15: c_long, - sc_rbp: c_long, - sc_rbx: c_long, - sc_rax: c_long, - sc_gs: c_long, - sc_fs: c_long, - sc_es: c_long, - sc_ds: c_long, - sc_trapno: c_long, - sc_err: c_long, - sc_rip: c_long, - sc_cs: c_long, - sc_rflags: c_long, - sc_rsp: c_long, - sc_ss: c_long, - - sc_fpstate: fxsave64, - __sc_unused: c_int, - sc_mask: c_int, - sc_cookie: c_long, - }; - - pub const fxsave64 = packed struct { - fx_fcw: u16, - fx_fsw: u16, - fx_ftw: u8, - fx_unused1: u8, - fx_fop: u16, - fx_rip: u64, - fx_rdp: u64, - fx_mxcsr: u32, - fx_mxcsr_mask: u32, - fx_st: [8][2]u64, - fx_xmm: [16][2]u64, - fx_unused3: [96]u8, - }; - }, - else => struct {}, -}; - -pub const sigset_t = c_uint; -pub const empty_sigset: sigset_t = 0; - -pub const E = enum(u16) { - /// No error occurred. - SUCCESS = 0, - PERM = 1, // Operation not permitted - NOENT = 2, // No such file or directory - SRCH = 3, // No such process - INTR = 4, // Interrupted system call - IO = 5, // Input/output error - NXIO = 6, // Device not configured - @"2BIG" = 7, // Argument list too long - NOEXEC = 8, // Exec format error - BADF = 9, // Bad file descriptor - CHILD = 10, // No child processes - DEADLK = 11, // Resource deadlock avoided - // 11 was AGAIN - NOMEM = 12, // Cannot allocate memory - ACCES = 13, // Permission denied - FAULT = 14, // Bad address - NOTBLK = 15, // Block device required - BUSY = 16, // Device busy - EXIST = 17, // File exists - XDEV = 18, // Cross-device link - NODEV = 19, // Operation not supported by device - NOTDIR = 20, // Not a directory - ISDIR = 21, // Is a directory - INVAL = 22, // Invalid argument - NFILE = 23, // Too many open files in system - MFILE = 24, // Too many open files - NOTTY = 25, // Inappropriate ioctl for device - TXTBSY = 26, // Text file busy - FBIG = 27, // File too large - NOSPC = 28, // No space left on device - SPIPE = 29, // Illegal seek - ROFS = 30, // Read-only file system - MLINK = 31, // Too many links - PIPE = 32, // Broken pipe - - // math software - DOM = 33, // Numerical argument out of domain - RANGE = 34, // Result too large or too small - - // non-blocking and interrupt i/o - // also: WOULDBLOCK: operation would block - AGAIN = 35, // Resource temporarily unavailable - INPROGRESS = 36, // Operation now in progress - ALREADY = 37, // Operation already in progress - - // ipc/network software -- argument errors - NOTSOCK = 38, // Socket operation on non-socket - DESTADDRREQ = 39, // Destination address required - MSGSIZE = 40, // Message too long - PROTOTYPE = 41, // Protocol wrong type for socket - NOPROTOOPT = 42, // Protocol option not available - PROTONOSUPPORT = 43, // Protocol not supported - SOCKTNOSUPPORT = 44, // Socket type not supported - OPNOTSUPP = 45, // Operation not supported - PFNOSUPPORT = 46, // Protocol family not supported - AFNOSUPPORT = 47, // Address family not supported by protocol family - ADDRINUSE = 48, // Address already in use - ADDRNOTAVAIL = 49, // Can't assign requested address - - // ipc/network software -- operational errors - NETDOWN = 50, // Network is down - NETUNREACH = 51, // Network is unreachable - NETRESET = 52, // Network dropped connection on reset - CONNABORTED = 53, // Software caused connection abort - CONNRESET = 54, // Connection reset by peer - NOBUFS = 55, // No buffer space available - ISCONN = 56, // Socket is already connected - NOTCONN = 57, // Socket is not connected - SHUTDOWN = 58, // Can't send after socket shutdown - TOOMANYREFS = 59, // Too many references: can't splice - TIMEDOUT = 60, // Operation timed out - CONNREFUSED = 61, // Connection refused - - LOOP = 62, // Too many levels of symbolic links - NAMETOOLONG = 63, // File name too long - - // should be rearranged - HOSTDOWN = 64, // Host is down - HOSTUNREACH = 65, // No route to host - NOTEMPTY = 66, // Directory not empty - - // quotas & mush - PROCLIM = 67, // Too many processes - USERS = 68, // Too many users - DQUOT = 69, // Disc quota exceeded - - // Network File System - STALE = 70, // Stale NFS file handle - REMOTE = 71, // Too many levels of remote in path - BADRPC = 72, // RPC struct is bad - RPCMISMATCH = 73, // RPC version wrong - PROGUNAVAIL = 74, // RPC prog. not avail - PROGMISMATCH = 75, // Program version wrong - PROCUNAVAIL = 76, // Bad procedure for program - - NOLCK = 77, // No locks available - NOSYS = 78, // Function not implemented - - FTYPE = 79, // Inappropriate file type or format - AUTH = 80, // Authentication error - NEEDAUTH = 81, // Need authenticator - IPSEC = 82, // IPsec processing failure - NOATTR = 83, // Attribute not found - - // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 - ILSEQ = 84, // Illegal byte sequence - - NOMEDIUM = 85, // No medium found - MEDIUMTYPE = 86, // Wrong medium type - OVERFLOW = 87, // Value too large to be stored in data type - CANCELED = 88, // Operation canceled - IDRM = 89, // Identifier removed - NOMSG = 90, // No message of desired type - NOTSUP = 91, // Not supported - BADMSG = 92, // Bad or Corrupt message - NOTRECOVERABLE = 93, // State not recoverable - OWNERDEAD = 94, // Previous owner died - PROTO = 95, // Protocol error - - _, -}; - -const _MAX_PAGE_SHIFT = switch (builtin.target.cpu.arch) { - .i386 => 12, - .sparcv9 => 13, -}; -pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT; -pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4; - -pub const SS_ONSTACK = 0x0001; -pub const SS_DISABLE = 0x0004; - -pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: usize, - ss_flags: c_int, -}; - -pub const S_IFMT = 0o170000; - -pub const S_IFIFO = 0o010000; -pub const S_IFCHR = 0o020000; -pub const S_IFDIR = 0o040000; -pub const S_IFBLK = 0o060000; -pub const S_IFREG = 0o100000; -pub const S_IFLNK = 0o120000; -pub const S_IFSOCK = 0o140000; - -pub const S_ISUID = 0o4000; -pub const S_ISGID = 0o2000; -pub const S_ISVTX = 0o1000; -pub const S_IRWXU = 0o700; -pub const S_IRUSR = 0o400; -pub const S_IWUSR = 0o200; -pub const S_IXUSR = 0o100; -pub const S_IRWXG = 0o070; -pub const S_IRGRP = 0o040; -pub const S_IWGRP = 0o020; -pub const S_IXGRP = 0o010; -pub const S_IRWXO = 0o007; -pub const S_IROTH = 0o004; -pub const S_IWOTH = 0o002; -pub const S_IXOTH = 0o001; - -pub fn S_ISFIFO(m: u32) bool { - return m & S_IFMT == S_IFIFO; -} - -pub fn S_ISCHR(m: u32) bool { - return m & S_IFMT == S_IFCHR; -} - -pub fn S_ISDIR(m: u32) bool { - return m & S_IFMT == S_IFDIR; -} - -pub fn S_ISBLK(m: u32) bool { - return m & S_IFMT == S_IFBLK; -} - -pub fn S_ISREG(m: u32) bool { - return m & S_IFMT == S_IFREG; -} - -pub fn S_ISLNK(m: u32) bool { - return m & S_IFMT == S_IFLNK; -} - -pub fn S_ISSOCK(m: u32) bool { - return m & S_IFMT == S_IFSOCK; -} - -/// Magic value that specify the use of the current working directory -/// to determine the target of relative file paths in the openat() and -/// similar syscalls. -pub const AT_FDCWD = -100; - -/// Check access using effective user and group ID -pub const AT_EACCESS = 0x01; - -/// Do not follow symbolic links -pub const AT_SYMLINK_NOFOLLOW = 0x02; - -/// Follow symbolic link -pub const AT_SYMLINK_FOLLOW = 0x04; - -/// Remove directory instead of file -pub const AT_REMOVEDIR = 0x08; - -pub const HOST_NAME_MAX = 255; - -/// dummy for IP -pub const IPPROTO_IP = 0; - -/// IP6 hop-by-hop options -pub const IPPROTO_HOPOPTS = IPPROTO_IP; - -/// control message protocol -pub const IPPROTO_ICMP = 1; - -/// group mgmt protocol -pub const IPPROTO_IGMP = 2; - -/// gateway^2 (deprecated) -pub const IPPROTO_GGP = 3; - -/// IP header -pub const IPPROTO_IPV4 = IPPROTO_IPIP; - -/// IP inside IP -pub const IPPROTO_IPIP = 4; - -/// tcp -pub const IPPROTO_TCP = 6; - -/// exterior gateway protocol -pub const IPPROTO_EGP = 8; - -/// pup -pub const IPPROTO_PUP = 12; - -/// user datagram protocol -pub const IPPROTO_UDP = 17; - -/// xns idp -pub const IPPROTO_IDP = 22; - -/// tp-4 w/ class negotiation -pub const IPPROTO_TP = 29; - -/// IP6 header -pub const IPPROTO_IPV6 = 41; - -/// IP6 routing header -pub const IPPROTO_ROUTING = 43; - -/// IP6 fragmentation header -pub const IPPROTO_FRAGMENT = 44; - -/// resource reservation -pub const IPPROTO_RSVP = 46; - -/// GRE encaps RFC 1701 -pub const IPPROTO_GRE = 47; - -/// encap. security payload -pub const IPPROTO_ESP = 50; - -/// authentication header -pub const IPPROTO_AH = 51; - -/// IP Mobility RFC 2004 -pub const IPPROTO_MOBILE = 55; - -/// IPv6 ICMP -pub const IPPROTO_IPV6_ICMP = 58; - -/// ICMP6 -pub const IPPROTO_ICMPV6 = 58; - -/// IP6 no next header -pub const IPPROTO_NONE = 59; - -/// IP6 destination option -pub const IPPROTO_DSTOPTS = 60; - -/// ISO cnlp -pub const IPPROTO_EON = 80; - -/// Ethernet-in-IP -pub const IPPROTO_ETHERIP = 97; - -/// encapsulation header -pub const IPPROTO_ENCAP = 98; - -/// Protocol indep. multicast -pub const IPPROTO_PIM = 103; - -/// IP Payload Comp. Protocol -pub const IPPROTO_IPCOMP = 108; - -/// VRRP RFC 2338 -pub const IPPROTO_VRRP = 112; - -/// Common Address Resolution Protocol -pub const IPPROTO_CARP = 112; - -/// PFSYNC -pub const IPPROTO_PFSYNC = 240; - -/// raw IP packet -pub const IPPROTO_RAW = 255; - -pub const rlimit_resource = enum(c_int) { - CPU, - FSIZE, - DATA, - STACK, - CORE, - RSS, - MEMLOCK, - NPROC, - NOFILE, - - _, -}; - -pub const rlim_t = u64; - -/// No limit -pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; - -pub const RLIM_SAVED_MAX = RLIM_INFINITY; -pub const RLIM_SAVED_CUR = RLIM_INFINITY; - -pub const rlimit = extern struct { - /// Soft limit - cur: rlim_t, - /// Hard limit - max: rlim_t, -}; - -pub const SHUT_RD = 0; -pub const SHUT_WR = 1; -pub const SHUT_RDWR = 2; - -pub const nfds_t = c_uint; - -pub const pollfd = extern struct { - fd: fd_t, - events: c_short, - revents: c_short, -}; - -pub const POLLIN = 0x0001; -pub const POLLPRI = 0x0002; -pub const POLLOUT = 0x0004; -pub const POLLERR = 0x0008; -pub const POLLHUP = 0x0010; -pub const POLLNVAL = 0x0020; -pub const POLLRDNORM = 0x0040; -pub const POLLNORM = POLLRDNORM; -pub const POLLWRNORM = POLLOUT; -pub const POLLRDBAND = 0x0080; -pub const POLLWRBAND = 0x0100; - -// sysctl mib -pub const CTL_UNSPEC = 0; -pub const CTL_KERN = 1; -pub const CTL_VM = 2; -pub const CTL_FS = 3; -pub const CTL_NET = 4; -pub const CTL_DEBUG = 5; -pub const CTL_HW = 6; -pub const CTL_MACHDEP = 7; - -pub const CTL_DDB = 9; -pub const CTL_VFS = 10; - -pub const KERN_OSTYPE = 1; -pub const KERN_OSRELEASE = 2; -pub const KERN_OSREV = 3; -pub const KERN_VERSION = 4; -pub const KERN_MAXVNODES = 5; -pub const KERN_MAXPROC = 6; -pub const KERN_MAXFILES = 7; -pub const KERN_ARGMAX = 8; -pub const KERN_SECURELVL = 9; -pub const KERN_HOSTNAME = 10; -pub const KERN_HOSTID = 11; -pub const KERN_CLOCKRATE = 12; - -pub const KERN_PROF = 16; -pub const KERN_POSIX1 = 17; -pub const KERN_NGROUPS = 18; -pub const KERN_JOB_CONTROL = 19; -pub const KERN_SAVED_IDS = 20; -pub const KERN_BOOTTIME = 21; -pub const KERN_DOMAINNAME = 22; -pub const KERN_MAXPARTITIONS = 23; -pub const KERN_RAWPARTITION = 24; -pub const KERN_MAXTHREAD = 25; -pub const KERN_NTHREADS = 26; -pub const KERN_OSVERSION = 27; -pub const KERN_SOMAXCONN = 28; -pub const KERN_SOMINCONN = 29; - -pub const KERN_NOSUIDCOREDUMP = 32; -pub const KERN_FSYNC = 33; -pub const KERN_SYSVMSG = 34; -pub const KERN_SYSVSEM = 35; -pub const KERN_SYSVSHM = 36; - -pub const KERN_MSGBUFSIZE = 38; -pub const KERN_MALLOCSTATS = 39; -pub const KERN_CPTIME = 40; -pub const KERN_NCHSTATS = 41; -pub const KERN_FORKSTAT = 42; -pub const KERN_NSELCOLL = 43; -pub const KERN_TTY = 44; -pub const KERN_CCPU = 45; -pub const KERN_FSCALE = 46; -pub const KERN_NPROCS = 47; -pub const KERN_MSGBUF = 48; -pub const KERN_POOL = 49; -pub const KERN_STACKGAPRANDOM = 50; -pub const KERN_SYSVIPC_INFO = 51; -pub const KERN_ALLOWKMEM = 52; -pub const KERN_WITNESSWATCH = 53; -pub const KERN_SPLASSERT = 54; -pub const KERN_PROC_ARGS = 55; -pub const KERN_NFILES = 56; -pub const KERN_TTYCOUNT = 57; -pub const KERN_NUMVNODES = 58; -pub const KERN_MBSTAT = 59; -pub const KERN_WITNESS = 60; -pub const KERN_SEMINFO = 61; -pub const KERN_SHMINFO = 62; -pub const KERN_INTRCNT = 63; -pub const KERN_WATCHDOG = 64; -pub const KERN_ALLOWDT = 65; -pub const KERN_PROC = 66; -pub const KERN_MAXCLUSTERS = 67; -pub const KERN_EVCOUNT = 68; -pub const KERN_TIMECOUNTER = 69; -pub const KERN_MAXLOCKSPERUID = 70; -pub const KERN_CPTIME2 = 71; -pub const KERN_CACHEPCT = 72; -pub const KERN_FILE = 73; -pub const KERN_WXABORT = 74; -pub const KERN_CONSDEV = 75; -pub const KERN_NETLIVELOCKS = 76; -pub const KERN_POOL_DEBUG = 77; -pub const KERN_PROC_CWD = 78; -pub const KERN_PROC_NOBROADCASTKILL = 79; -pub const KERN_PROC_VMMAP = 80; -pub const KERN_GLOBAL_PTRACE = 81; -pub const KERN_CONSBUFSIZE = 82; -pub const KERN_CONSBUF = 83; -pub const KERN_AUDIO = 84; -pub const KERN_CPUSTATS = 85; -pub const KERN_PFSTATUS = 86; -pub const KERN_TIMEOUT_STATS = 87; -pub const KERN_UTC_OFFSET = 88; -pub const KERN_VIDEO = 89; - -pub const HW_MACHINE = 1; -pub const HW_MODEL = 2; -pub const HW_NCPU = 3; -pub const HW_BYTEORDER = 4; -pub const HW_PHYSMEM = 5; -pub const HW_USERMEM = 6; -pub const HW_PAGESIZE = 7; -pub const HW_DISKNAMES = 8; -pub const HW_DISKSTATS = 9; -pub const HW_DISKCOUNT = 10; -pub const HW_SENSORS = 11; -pub const HW_CPUSPEED = 12; -pub const HW_SETPERF = 13; -pub const HW_VENDOR = 14; -pub const HW_PRODUCT = 15; -pub const HW_VERSION = 16; -pub const HW_SERIALNO = 17; -pub const HW_UUID = 18; -pub const HW_PHYSMEM64 = 19; -pub const HW_USERMEM64 = 20; -pub const HW_NCPUFOUND = 21; -pub const HW_ALLOWPOWERDOWN = 22; -pub const HW_PERFPOLICY = 23; -pub const HW_SMT = 24; -pub const HW_NCPUONLINE = 25; - -pub const KERN_PROC_ALL = 0; -pub const KERN_PROC_PID = 1; -pub const KERN_PROC_PGRP = 2; -pub const KERN_PROC_SESSION = 3; -pub const KERN_PROC_TTY = 4; -pub const KERN_PROC_UID = 5; -pub const KERN_PROC_RUID = 6; -pub const KERN_PROC_KTHREAD = 7; -pub const KERN_PROC_SHOW_THREADS = 0x40000000; - -pub const KERN_PROC_ARGV = 1; -pub const KERN_PROC_NARGV = 2; -pub const KERN_PROC_ENV = 3; -pub const KERN_PROC_NENV = 4; diff --git a/lib/std/os/bits/posix.zig b/lib/std/os/bits/posix.zig deleted file mode 100644 index 6ffd2dcf6a..0000000000 --- a/lib/std/os/bits/posix.zig +++ /dev/null @@ -1,28 +0,0 @@ -pub const iovec = extern struct { - iov_base: [*]u8, - iov_len: usize, -}; - -pub const iovec_const = extern struct { - iov_base: [*]const u8, - iov_len: usize, -}; - -// syslog - -/// system is unusable -pub const LOG_EMERG = 0; -/// action must be taken immediately -pub const LOG_ALERT = 1; -/// critical conditions -pub const LOG_CRIT = 2; -/// error conditions -pub const LOG_ERR = 3; -/// warning conditions -pub const LOG_WARNING = 4; -/// normal but significant condition -pub const LOG_NOTICE = 5; -/// informational -pub const LOG_INFO = 6; -/// debug-level messages -pub const LOG_DEBUG = 7; diff --git a/lib/std/os/bits/wasi.zig b/lib/std/os/bits/wasi.zig deleted file mode 100644 index 567d74961e..0000000000 --- a/lib/std/os/bits/wasi.zig +++ /dev/null @@ -1,490 +0,0 @@ -// Convenience types and consts used by std.os module -const builtin = @import("builtin"); -const posix = @import("posix.zig"); -pub const iovec = posix.iovec; -pub const iovec_const = posix.iovec_const; - -pub const STDIN_FILENO = 0; -pub const STDOUT_FILENO = 1; -pub const STDERR_FILENO = 2; - -pub const mode_t = u32; - -pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc - -pub const timespec = struct { - tv_sec: time_t, - tv_nsec: isize, - - pub fn fromTimestamp(tm: timestamp_t) timespec { - const tv_sec: timestamp_t = tm / 1_000_000_000; - const tv_nsec = tm - tv_sec * 1_000_000_000; - return timespec{ - .tv_sec = @intCast(time_t, tv_sec), - .tv_nsec = @intCast(isize, tv_nsec), - }; - } - - pub fn toTimestamp(ts: timespec) timestamp_t { - const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec); - return tm; - } -}; - -pub const kernel_stat = struct { - dev: device_t, - ino: inode_t, - mode: mode_t, - filetype: filetype_t, - nlink: linkcount_t, - size: filesize_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - - const Self = @This(); - - pub fn fromFilestat(stat: filestat_t) Self { - return Self{ - .dev = stat.dev, - .ino = stat.ino, - .mode = 0, - .filetype = stat.filetype, - .nlink = stat.nlink, - .size = stat.size, - .atim = stat.atime(), - .mtim = stat.mtime(), - .ctim = stat.ctime(), - }; - } - - pub fn atime(self: Self) timespec { - return self.atim; - } - - pub fn mtime(self: Self) timespec { - return self.mtim; - } - - pub fn ctime(self: Self) timespec { - return self.ctim; - } -}; - -pub const IOV_MAX = 1024; - -pub const AT_REMOVEDIR: u32 = 0x4; -pub const AT_FDCWD: fd_t = -2; - -// As defined in the wasi_snapshot_preview1 spec file: -// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx -pub const advice_t = u8; -pub const ADVICE_NORMAL: advice_t = 0; -pub const ADVICE_SEQUENTIAL: advice_t = 1; -pub const ADVICE_RANDOM: advice_t = 2; -pub const ADVICE_WILLNEED: advice_t = 3; -pub const ADVICE_DONTNEED: advice_t = 4; -pub const ADVICE_NOREUSE: advice_t = 5; - -pub const clockid_t = u32; -pub const CLOCK_REALTIME: clockid_t = 0; -pub const CLOCK_MONOTONIC: clockid_t = 1; -pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2; -pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3; - -pub const device_t = u64; - -pub const dircookie_t = u64; -pub const DIRCOOKIE_START: dircookie_t = 0; - -pub const dirnamlen_t = u32; - -pub const dirent_t = extern struct { - d_next: dircookie_t, - d_ino: inode_t, - d_namlen: dirnamlen_t, - d_type: filetype_t, -}; - -pub const errno_t = enum(u16) { - SUCCESS = 0, - @"2BIG" = 1, - ACCES = 2, - ADDRINUSE = 3, - ADDRNOTAVAIL = 4, - AFNOSUPPORT = 5, - /// This is also the error code used for `WOULDBLOCK`. - AGAIN = 6, - ALREADY = 7, - BADF = 8, - BADMSG = 9, - BUSY = 10, - CANCELED = 11, - CHILD = 12, - CONNABORTED = 13, - CONNREFUSED = 14, - CONNRESET = 15, - DEADLK = 16, - DESTADDRREQ = 17, - DOM = 18, - DQUOT = 19, - EXIST = 20, - FAULT = 21, - FBIG = 22, - HOSTUNREACH = 23, - IDRM = 24, - ILSEQ = 25, - INPROGRESS = 26, - INTR = 27, - INVAL = 28, - IO = 29, - ISCONN = 30, - ISDIR = 31, - LOOP = 32, - MFILE = 33, - MLINK = 34, - MSGSIZE = 35, - MULTIHOP = 36, - NAMETOOLONG = 37, - NETDOWN = 38, - NETRESET = 39, - NETUNREACH = 40, - NFILE = 41, - NOBUFS = 42, - NODEV = 43, - NOENT = 44, - NOEXEC = 45, - NOLCK = 46, - NOLINK = 47, - NOMEM = 48, - NOMSG = 49, - NOPROTOOPT = 50, - NOSPC = 51, - NOSYS = 52, - NOTCONN = 53, - NOTDIR = 54, - NOTEMPTY = 55, - NOTRECOVERABLE = 56, - NOTSOCK = 57, - /// This is also the code used for `NOTSUP`. - OPNOTSUPP = 58, - NOTTY = 59, - NXIO = 60, - OVERFLOW = 61, - OWNERDEAD = 62, - PERM = 63, - PIPE = 64, - PROTO = 65, - PROTONOSUPPORT = 66, - PROTOTYPE = 67, - RANGE = 68, - ROFS = 69, - SPIPE = 70, - SRCH = 71, - STALE = 72, - TIMEDOUT = 73, - TXTBSY = 74, - XDEV = 75, - NOTCAPABLE = 76, - _, -}; -pub const E = errno_t; - -pub const event_t = extern struct { - userdata: userdata_t, - @"error": errno_t, - @"type": eventtype_t, - fd_readwrite: eventfdreadwrite_t, -}; - -pub const eventfdreadwrite_t = extern struct { - nbytes: filesize_t, - flags: eventrwflags_t, -}; - -pub const eventrwflags_t = u16; -pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001; - -pub const eventtype_t = u8; -pub const EVENTTYPE_CLOCK: eventtype_t = 0; -pub const EVENTTYPE_FD_READ: eventtype_t = 1; -pub const EVENTTYPE_FD_WRITE: eventtype_t = 2; - -pub const exitcode_t = u32; - -pub const fd_t = if (builtin.link_libc) c_int else u32; - -pub const fdflags_t = u16; -pub const FDFLAG_APPEND: fdflags_t = 0x0001; -pub const FDFLAG_DSYNC: fdflags_t = 0x0002; -pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004; -pub const FDFLAG_RSYNC: fdflags_t = 0x0008; -pub const FDFLAG_SYNC: fdflags_t = 0x0010; - -pub const fdstat_t = extern struct { - fs_filetype: filetype_t, - fs_flags: fdflags_t, - fs_rights_base: rights_t, - fs_rights_inheriting: rights_t, -}; - -pub const filedelta_t = i64; - -pub const filesize_t = u64; - -pub const filestat_t = extern struct { - dev: device_t, - ino: inode_t, - filetype: filetype_t, - nlink: linkcount_t, - size: filesize_t, - atim: timestamp_t, - mtim: timestamp_t, - ctim: timestamp_t, - - pub fn atime(self: filestat_t) timespec { - return timespec.fromTimestamp(self.atim); - } - - pub fn mtime(self: filestat_t) timespec { - return timespec.fromTimestamp(self.mtim); - } - - pub fn ctime(self: filestat_t) timespec { - return timespec.fromTimestamp(self.ctim); - } -}; - -pub const filetype_t = u8; -pub const FILETYPE_UNKNOWN: filetype_t = 0; -pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1; -pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2; -pub const FILETYPE_DIRECTORY: filetype_t = 3; -pub const FILETYPE_REGULAR_FILE: filetype_t = 4; -pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5; -pub const FILETYPE_SOCKET_STREAM: filetype_t = 6; -pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7; - -pub const fstflags_t = u16; -pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001; -pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002; -pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004; -pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; - -pub const inode_t = u64; -pub const ino_t = inode_t; - -pub const linkcount_t = u64; - -pub const lookupflags_t = u32; -pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001; - -pub usingnamespace if (builtin.link_libc) struct { - // Derived from https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt - pub const O_ACCMODE = (O_EXEC | O_RDWR | O_SEARCH); - pub const O_APPEND = FDFLAG_APPEND; - pub const O_CLOEXEC = (0); - pub const O_CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12 - pub const O_DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12 - pub const O_DSYNC = FDFLAG_DSYNC; - pub const O_EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12 - pub const O_EXEC = (0x02000000); - pub const O_NOCTTY = (0); - pub const O_NOFOLLOW = (0x01000000); - pub const O_NONBLOCK = (1 << FDFLAG_NONBLOCK); - pub const O_RDONLY = (0x04000000); - pub const O_RDWR = (O_RDONLY | O_WRONLY); - pub const O_RSYNC = (1 << FDFLAG_RSYNC); - pub const O_SEARCH = (0x08000000); - pub const O_SYNC = (1 << FDFLAG_SYNC); - pub const O_TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12 - pub const O_TTY_INIT = (0); - pub const O_WRONLY = (0x10000000); -} else struct { - pub const oflags_t = u16; - pub const O_CREAT: oflags_t = 0x0001; - pub const O_DIRECTORY: oflags_t = 0x0002; - pub const O_EXCL: oflags_t = 0x0004; - pub const O_TRUNC: oflags_t = 0x0008; -}; - -pub const preopentype_t = u8; -pub const PREOPENTYPE_DIR: preopentype_t = 0; - -pub const prestat_t = extern struct { - pr_type: preopentype_t, - u: prestat_u_t, -}; - -pub const prestat_dir_t = extern struct { - pr_name_len: usize, -}; - -pub const prestat_u_t = extern union { - dir: prestat_dir_t, -}; - -pub const riflags_t = u16; -pub const SOCK_RECV_PEEK: riflags_t = 0x0001; -pub const SOCK_RECV_WAITALL: riflags_t = 0x0002; - -pub const rights_t = u64; -pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001; -pub const RIGHT_FD_READ: rights_t = 0x0000000000000002; -pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004; -pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008; -pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010; -pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020; -pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040; -pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080; -pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100; -pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200; -pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400; -pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800; -pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000; -pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000; -pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000; -pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000; -pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000; -pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000; -pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000; -pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000; -pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000; -pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000; -pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000; -pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000; -pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000; -pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000; -pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000; -pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000; -pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000; -pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC | - RIGHT_FD_READ | - RIGHT_FD_SEEK | - RIGHT_FD_FDSTAT_SET_FLAGS | - RIGHT_FD_SYNC | - RIGHT_FD_TELL | - RIGHT_FD_WRITE | - RIGHT_FD_ADVISE | - RIGHT_FD_ALLOCATE | - RIGHT_PATH_CREATE_DIRECTORY | - RIGHT_PATH_CREATE_FILE | - RIGHT_PATH_LINK_SOURCE | - RIGHT_PATH_LINK_TARGET | - RIGHT_PATH_OPEN | - RIGHT_FD_READDIR | - RIGHT_PATH_READLINK | - RIGHT_PATH_RENAME_SOURCE | - RIGHT_PATH_RENAME_TARGET | - RIGHT_PATH_FILESTAT_GET | - RIGHT_PATH_FILESTAT_SET_SIZE | - RIGHT_PATH_FILESTAT_SET_TIMES | - RIGHT_FD_FILESTAT_GET | - RIGHT_FD_FILESTAT_SET_SIZE | - RIGHT_FD_FILESTAT_SET_TIMES | - RIGHT_PATH_SYMLINK | - RIGHT_PATH_REMOVE_DIRECTORY | - RIGHT_PATH_UNLINK_FILE | - RIGHT_POLL_FD_READWRITE | - RIGHT_SOCK_SHUTDOWN; - -pub const roflags_t = u16; -pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001; - -pub const sdflags_t = u8; -pub const SHUT_RD: sdflags_t = 0x01; -pub const SHUT_WR: sdflags_t = 0x02; - -pub const siflags_t = u16; - -pub const signal_t = u8; -pub const SIGNONE: signal_t = 0; -pub const SIGHUP: signal_t = 1; -pub const SIGINT: signal_t = 2; -pub const SIGQUIT: signal_t = 3; -pub const SIGILL: signal_t = 4; -pub const SIGTRAP: signal_t = 5; -pub const SIGABRT: signal_t = 6; -pub const SIGBUS: signal_t = 7; -pub const SIGFPE: signal_t = 8; -pub const SIGKILL: signal_t = 9; -pub const SIGUSR1: signal_t = 10; -pub const SIGSEGV: signal_t = 11; -pub const SIGUSR2: signal_t = 12; -pub const SIGPIPE: signal_t = 13; -pub const SIGALRM: signal_t = 14; -pub const SIGTERM: signal_t = 15; -pub const SIGCHLD: signal_t = 16; -pub const SIGCONT: signal_t = 17; -pub const SIGSTOP: signal_t = 18; -pub const SIGTSTP: signal_t = 19; -pub const SIGTTIN: signal_t = 20; -pub const SIGTTOU: signal_t = 21; -pub const SIGURG: signal_t = 22; -pub const SIGXCPU: signal_t = 23; -pub const SIGXFSZ: signal_t = 24; -pub const SIGVTALRM: signal_t = 25; -pub const SIGPROF: signal_t = 26; -pub const SIGWINCH: signal_t = 27; -pub const SIGPOLL: signal_t = 28; -pub const SIGPWR: signal_t = 29; -pub const SIGSYS: signal_t = 30; - -pub const subclockflags_t = u16; -pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001; - -pub const subscription_t = extern struct { - userdata: userdata_t, - u: subscription_u_t, -}; - -pub const subscription_clock_t = extern struct { - id: clockid_t, - timeout: timestamp_t, - precision: timestamp_t, - flags: subclockflags_t, -}; - -pub const subscription_fd_readwrite_t = extern struct { - fd: fd_t, -}; - -pub const subscription_u_t = extern struct { - tag: eventtype_t, - u: subscription_u_u_t, -}; - -pub const subscription_u_u_t = extern union { - clock: subscription_clock_t, - fd_read: subscription_fd_readwrite_t, - fd_write: subscription_fd_readwrite_t, -}; - -pub const timestamp_t = u64; - -pub const userdata_t = u64; - -pub const whence_t = u8; -pub const WHENCE_SET: whence_t = 0; -pub const WHENCE_CUR: whence_t = 1; -pub const WHENCE_END: whence_t = 2; - -pub const S_IEXEC = S_IXUSR; -pub const S_IFBLK = 0x6000; -pub const S_IFCHR = 0x2000; -pub const S_IFDIR = 0x4000; -pub const S_IFIFO = 0xc000; -pub const S_IFLNK = 0xa000; -pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK; -pub const S_IFREG = 0x8000; -// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes. -pub const S_IFSOCK = 0x1; - -pub const SEEK_SET = WHENCE_SET; -pub const SEEK_CUR = WHENCE_CUR; -pub const SEEK_END = WHENCE_END; - -pub const LOCK_SH = 0x1; -pub const LOCK_EX = 0x2; -pub const LOCK_NB = 0x4; -pub const LOCK_UN = 0x8; diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig deleted file mode 100644 index bb57a13ffe..0000000000 --- a/lib/std/os/bits/windows.zig +++ /dev/null @@ -1,329 +0,0 @@ -// The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime). - -usingnamespace @import("../windows/bits.zig"); -const ws2_32 = @import("../windows/ws2_32.zig"); - -// TODO: Stop using os.iovec in std.fs et al on Windows in the future -const posix = @import("posix.zig"); -pub const iovec = posix.iovec; -pub const iovec_const = posix.iovec_const; - -pub const fd_t = HANDLE; -pub const ino_t = LARGE_INTEGER; -pub const pid_t = HANDLE; -pub const mode_t = u0; - -pub const PATH_MAX = 260; - -pub const time_t = c_longlong; - -pub const timespec = extern struct { - tv_sec: time_t, - tv_nsec: c_long, -}; - -pub const timeval = extern struct { - tv_sec: c_long, - tv_usec: c_long, -}; - -pub const sig_atomic_t = c_int; - -/// maximum signal number + 1 -pub const NSIG = 23; - -// Signal types - -/// interrupt -pub const SIGINT = 2; - -/// illegal instruction - invalid function image -pub const SIGILL = 4; - -/// floating point exception -pub const SIGFPE = 8; - -/// segment violation -pub const SIGSEGV = 11; - -/// Software termination signal from kill -pub const SIGTERM = 15; - -/// Ctrl-Break sequence -pub const SIGBREAK = 21; - -/// abnormal termination triggered by abort call -pub const SIGABRT = 22; - -/// SIGABRT compatible with other platforms, same as SIGABRT -pub const SIGABRT_COMPAT = 6; - -// Signal action codes - -/// default signal action -pub const SIG_DFL = 0; - -/// ignore signal -pub const SIG_IGN = 1; - -/// return current value -pub const SIG_GET = 2; - -/// signal gets error -pub const SIG_SGE = 3; - -/// acknowledge -pub const SIG_ACK = 4; - -/// Signal error value (returned by signal call on error) -pub const SIG_ERR = -1; - -pub const SEEK_SET = 0; -pub const SEEK_CUR = 1; -pub const SEEK_END = 2; - -pub const E = enum(u16) { - /// No error occurred. - SUCCESS = 0, - PERM = 1, - NOENT = 2, - SRCH = 3, - INTR = 4, - IO = 5, - NXIO = 6, - @"2BIG" = 7, - NOEXEC = 8, - BADF = 9, - CHILD = 10, - AGAIN = 11, - NOMEM = 12, - ACCES = 13, - FAULT = 14, - BUSY = 16, - EXIST = 17, - XDEV = 18, - NODEV = 19, - NOTDIR = 20, - ISDIR = 21, - NFILE = 23, - MFILE = 24, - NOTTY = 25, - FBIG = 27, - NOSPC = 28, - SPIPE = 29, - ROFS = 30, - MLINK = 31, - PIPE = 32, - DOM = 33, - /// Also means `DEADLOCK`. - DEADLK = 36, - NAMETOOLONG = 38, - NOLCK = 39, - NOSYS = 40, - NOTEMPTY = 41, - - INVAL = 22, - RANGE = 34, - ILSEQ = 42, - - // POSIX Supplement - ADDRINUSE = 100, - ADDRNOTAVAIL = 101, - AFNOSUPPORT = 102, - ALREADY = 103, - BADMSG = 104, - CANCELED = 105, - CONNABORTED = 106, - CONNREFUSED = 107, - CONNRESET = 108, - DESTADDRREQ = 109, - HOSTUNREACH = 110, - IDRM = 111, - INPROGRESS = 112, - ISCONN = 113, - LOOP = 114, - MSGSIZE = 115, - NETDOWN = 116, - NETRESET = 117, - NETUNREACH = 118, - NOBUFS = 119, - NODATA = 120, - NOLINK = 121, - NOMSG = 122, - NOPROTOOPT = 123, - NOSR = 124, - NOSTR = 125, - NOTCONN = 126, - NOTRECOVERABLE = 127, - NOTSOCK = 128, - NOTSUP = 129, - OPNOTSUPP = 130, - OTHER = 131, - OVERFLOW = 132, - OWNERDEAD = 133, - PROTO = 134, - PROTONOSUPPORT = 135, - PROTOTYPE = 136, - TIME = 137, - TIMEDOUT = 138, - TXTBSY = 139, - WOULDBLOCK = 140, - DQUOT = 10069, - _, -}; - -pub const STRUNCATE = 80; - -pub const F_OK = 0; - -/// Remove directory instead of unlinking file -pub const AT_REMOVEDIR = 0x200; - -pub const in_port_t = u16; -pub const sa_family_t = ws2_32.ADDRESS_FAMILY; -pub const socklen_t = ws2_32.socklen_t; - -pub const sockaddr = ws2_32.sockaddr; -pub const sockaddr_in = ws2_32.sockaddr_in; -pub const sockaddr_in6 = ws2_32.sockaddr_in6; -pub const sockaddr_un = ws2_32.sockaddr_un; - -pub const in6_addr = [16]u8; -pub const in_addr = u32; - -pub const addrinfo = ws2_32.addrinfo; - -pub const AF_UNSPEC = ws2_32.AF_UNSPEC; -pub const AF_UNIX = ws2_32.AF_UNIX; -pub const AF_INET = ws2_32.AF_INET; -pub const AF_IMPLINK = ws2_32.AF_IMPLINK; -pub const AF_PUP = ws2_32.AF_PUP; -pub const AF_CHAOS = ws2_32.AF_CHAOS; -pub const AF_NS = ws2_32.AF_NS; -pub const AF_IPX = ws2_32.AF_IPX; -pub const AF_ISO = ws2_32.AF_ISO; -pub const AF_OSI = ws2_32.AF_OSI; -pub const AF_ECMA = ws2_32.AF_ECMA; -pub const AF_DATAKIT = ws2_32.AF_DATAKIT; -pub const AF_CCITT = ws2_32.AF_CCITT; -pub const AF_SNA = ws2_32.AF_SNA; -pub const AF_DECnet = ws2_32.AF_DECnet; -pub const AF_DLI = ws2_32.AF_DLI; -pub const AF_LAT = ws2_32.AF_LAT; -pub const AF_HYLINK = ws2_32.AF_HYLINK; -pub const AF_APPLETALK = ws2_32.AF_APPLETALK; -pub const AF_NETBIOS = ws2_32.AF_NETBIOS; -pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW; -pub const AF_FIREFOX = ws2_32.AF_FIREFOX; -pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1; -pub const AF_BAN = ws2_32.AF_BAN; -pub const AF_ATM = ws2_32.AF_ATM; -pub const AF_INET6 = ws2_32.AF_INET6; -pub const AF_CLUSTER = ws2_32.AF_CLUSTER; -pub const AF_12844 = ws2_32.AF_12844; -pub const AF_IRDA = ws2_32.AF_IRDA; -pub const AF_NETDES = ws2_32.AF_NETDES; -pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS; -pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE; -pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM; -pub const AF_BTH = ws2_32.AF_BTH; -pub const AF_MAX = ws2_32.AF_MAX; - -pub const SOCK_STREAM = ws2_32.SOCK_STREAM; -pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM; -pub const SOCK_RAW = ws2_32.SOCK_RAW; -pub const SOCK_RDM = ws2_32.SOCK_RDM; -pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET; - -/// WARNING: this flag is not supported by windows socket functions directly, -/// it is only supported by std.os.socket. Be sure that this value does -/// not share any bits with any of the SOCK_* values. -pub const SOCK_CLOEXEC = 0x10000; -/// WARNING: this flag is not supported by windows socket functions directly, -/// it is only supported by std.os.socket. Be sure that this value does -/// not share any bits with any of the SOCK_* values. -pub const SOCK_NONBLOCK = 0x20000; - -pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP; -pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP; -pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM; -pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP; -pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP; -pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6; -pub const IPPROTO_RM = ws2_32.IPPROTO_RM; - -pub const nfds_t = c_ulong; -pub const pollfd = ws2_32.pollfd; - -pub const POLLRDNORM = ws2_32.POLLRDNORM; -pub const POLLRDBAND = ws2_32.POLLRDBAND; -pub const POLLIN = ws2_32.POLLIN; -pub const POLLPRI = ws2_32.POLLPRI; -pub const POLLWRNORM = ws2_32.POLLWRNORM; -pub const POLLOUT = ws2_32.POLLOUT; -pub const POLLWRBAND = ws2_32.POLLWRBAND; -pub const POLLERR = ws2_32.POLLERR; -pub const POLLHUP = ws2_32.POLLHUP; -pub const POLLNVAL = ws2_32.POLLNVAL; - -pub const SOL_SOCKET = ws2_32.SOL_SOCKET; - -pub const SO_DEBUG = ws2_32.SO_DEBUG; -pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN; -pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR; -pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE; -pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE; -pub const SO_BROADCAST = ws2_32.SO_BROADCAST; -pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK; -pub const SO_LINGER = ws2_32.SO_LINGER; -pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE; - -pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER; -pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE; - -pub const SO_SNDBUF = ws2_32.SO_SNDBUF; -pub const SO_RCVBUF = ws2_32.SO_RCVBUF; -pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT; -pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT; -pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO; -pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO; -pub const SO_ERROR = ws2_32.SO_ERROR; -pub const SO_TYPE = ws2_32.SO_TYPE; - -pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID; -pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY; -pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE; -pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA; -pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW; - -pub const PVD_CONFIG = ws2_32.PVD_CONFIG; -pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT; - -pub const TCP_NODELAY = ws2_32.TCP_NODELAY; - -pub const O_RDONLY = 0o0; -pub const O_WRONLY = 0o1; -pub const O_RDWR = 0o2; - -pub const O_CREAT = 0o100; -pub const O_EXCL = 0o200; -pub const O_NOCTTY = 0o400; -pub const O_TRUNC = 0o1000; -pub const O_APPEND = 0o2000; -pub const O_NONBLOCK = 0o4000; -pub const O_DSYNC = 0o10000; -pub const O_SYNC = 0o4010000; -pub const O_RSYNC = 0o4010000; -pub const O_DIRECTORY = 0o200000; -pub const O_NOFOLLOW = 0o400000; -pub const O_CLOEXEC = 0o2000000; - -pub const O_ASYNC = 0o20000; -pub const O_DIRECT = 0o40000; -pub const O_LARGEFILE = 0; -pub const O_NOATIME = 0o1000000; -pub const O_PATH = 0o10000000; -pub const O_TMPFILE = 0o20200000; -pub const O_NDELAY = O_NONBLOCK; - -pub const IFNAMESIZE = 30; |
