| author | |
| committer | |
| log | 1bbfcb95abc471374e5f8d74e04f0a002cc85c95 |
| tree | 76cb0df86a8a5f55e1f7f3bb0fd7dd4422581487 |
| parent | 3deda15e21ea3a8138d5b628f2649bbbfe7fa910 |
Behavior tests pass on x86_64-linux with -lc34 files changed, 9658 insertions(+), 9536 deletions(-)
lib/std/c.zig+110-86| ... | @@ -10,7 +10,8 @@ test { | ... | @@ -10,7 +10,8 @@ test { |
| 10 | _ = tokenizer; | 10 | _ = tokenizer; |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | pub usingnamespace switch (std.Target.current.os.tag) { | 13 | const generic = @import("c/generic.zig"); |
| 14 | const system = switch (builtin.os.tag) { | ||
| 14 | .linux => @import("c/linux.zig"), | 15 | .linux => @import("c/linux.zig"), |
| 15 | .windows => @import("c/windows.zig"), | 16 | .windows => @import("c/windows.zig"), |
| 16 | .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"), | 17 | .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"), |
| ... | @@ -27,6 +28,109 @@ pub usingnamespace switch (std.Target.current.os.tag) { | ... | @@ -27,6 +28,109 @@ pub usingnamespace switch (std.Target.current.os.tag) { |
| 27 | .wasi => @import("c/wasi.zig"), | 28 | .wasi => @import("c/wasi.zig"), |
| 28 | else => struct {}, | 29 | else => struct {}, |
| 29 | }; | 30 | }; |
| 31 | pub const E = system.E; | ||
| 32 | pub const _errno = system._errno; | ||
| 33 | pub const MAP_FAILED = system.MAP_FAILED; | ||
| 34 | pub const AI = system.AI; | ||
| 35 | pub const NI = system.NI; | ||
| 36 | pub const EAI = system.EAI; | ||
| 37 | pub const timespec = system.timespec; | ||
| 38 | pub const Sigaction = system.Sigaction; | ||
| 39 | pub const fallocate64 = system.fallocate64; | ||
| 40 | pub const fopen64 = system.fopen64; | ||
| 41 | pub const fstat64 = system.fstat64; | ||
| 42 | pub const fstatat64 = system.fstatat64; | ||
| 43 | pub const ftruncate64 = system.ftruncate64; | ||
| 44 | pub const getrlimit64 = system.getrlimit64; | ||
| 45 | pub const lseek64 = system.lseek64; | ||
| 46 | pub const mmap64 = system.mmap64; | ||
| 47 | pub const open64 = system.open64; | ||
| 48 | pub const openat64 = system.openat64; | ||
| 49 | pub const pread64 = system.pread64; | ||
| 50 | pub const preadv64 = system.preadv64; | ||
| 51 | pub const pwrite64 = system.pwrite64; | ||
| 52 | pub const pwritev64 = system.pwritev64; | ||
| 53 | pub const sendfile64 = system.sendfile64; | ||
| 54 | pub const setrlimit64 = system.setrlimit64; | ||
| 55 | |||
| 56 | pub const AT = system.AT; | ||
| 57 | pub const CLOCK = system.CLOCK; | ||
| 58 | pub const IOV_MAX = system.IOV_MAX; | ||
| 59 | pub const NAME_MAX = system.NAME_MAX; | ||
| 60 | pub const PATH_MAX = system.PATH_MAX; | ||
| 61 | pub const PROT = system.PROT; | ||
| 62 | pub const RTLD = system.RTLD; | ||
| 63 | pub const S = system.S; | ||
| 64 | pub const SA = system.SA; | ||
| 65 | pub const SIG = system.SIG; | ||
| 66 | pub const STDERR_FILENO = system.STDIN_FILENO; | ||
| 67 | pub const STDIN_FILENO = system.STDIN_FILENO; | ||
| 68 | pub const STDOUT_FILENO = system.STDIN_FILENO; | ||
| 69 | pub const Stat = system.Stat; | ||
| 70 | pub const copy_file_range = system.copy_file_range; | ||
| 71 | pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback; | ||
| 72 | pub const dl_phdr_info = system.dl_phdr_info; | ||
| 73 | pub const empty_sigset = system.empty_sigset; | ||
| 74 | pub const epoll_create1 = system.epoll_create1; | ||
| 75 | pub const epoll_ctl = system.epoll_ctl; | ||
| 76 | pub const epoll_pwait = system.epoll_pwait; | ||
| 77 | pub const epoll_wait = system.epoll_wait; | ||
| 78 | pub const eventfd = system.eventfd; | ||
| 79 | pub const fallocate = system.fallocate; | ||
| 80 | pub const fd_t = system.fd_t; | ||
| 81 | pub const getauxval = system.getauxval; | ||
| 82 | pub const getdents = system.getdents; | ||
| 83 | pub const getrandom = system.getrandom; | ||
| 84 | pub const inotify_add_watch = system.inotify_add_watch; | ||
| 85 | pub const inotify_init1 = system.inotify_init1; | ||
| 86 | pub const inotify_rm_watch = system.inotify_rm_watch; | ||
| 87 | pub const madvise = system.madvise; | ||
| 88 | pub const malloc_usable_size = system.malloc_usable_size; | ||
| 89 | pub const memfd_create = system.memfd_create; | ||
| 90 | pub const pipe2 = system.pipe2; | ||
| 91 | pub const pollfd = system.pollfd; | ||
| 92 | pub const posix_memalign = system.posix_memalign; | ||
| 93 | pub const prlimit = system.prlimit; | ||
| 94 | pub const pthread_attr_t = system.pthread_attr_t; | ||
| 95 | pub const pthread_cond_t = system.pthread_cond_t; | ||
| 96 | pub const pthread_getname_np = system.pthread_getname_np; | ||
| 97 | pub const pthread_mutex_t = system.pthread_mutex_t; | ||
| 98 | pub const pthread_rwlock_t = system.pthread_rwlock_t; | ||
| 99 | pub const pthread_setname_np = system.pthread_setname_np; | ||
| 100 | pub const rlimit = system.rlimit; | ||
| 101 | pub const rlimit_resource = system.rlimit_resource; | ||
| 102 | pub const sched_getaffinity = system.sched_getaffinity; | ||
| 103 | pub const sem_t = system.sem_t; | ||
| 104 | pub const sendfile = system.sendfile; | ||
| 105 | pub const sigaltstack = system.sigaltstack; | ||
| 106 | pub const siginfo_t = system.siginfo_t; | ||
| 107 | pub const signalfd = system.signalfd; | ||
| 108 | pub const sigset_t = system.sigset_t; | ||
| 109 | pub const MAP = system.MAP; | ||
| 110 | pub const LOCK = system.LOCK; | ||
| 111 | pub const REG = system.REG; | ||
| 112 | pub const dl_iterate_phdr = system.dl_iterate_phdr; | ||
| 113 | pub const ino_t = system.ino_t; | ||
| 114 | pub const mode_t = system.mode_t; | ||
| 115 | pub const ucontext_t = system.ucontext_t; | ||
| 116 | pub const O = system.O; | ||
| 117 | |||
| 118 | pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm; | ||
| 119 | pub const clock_getres = if (@hasDecl(system, "clock_getres")) system.clock_getres else generic.clock_getres; | ||
| 120 | pub const clock_gettime = if (@hasDecl(system, "clock_gettime")) system.clock_gettime else generic.clock_gettime; | ||
| 121 | pub const fstat = if (@hasDecl(system, "fstat")) system.fstat else generic.fstat; | ||
| 122 | pub const fstatat = if (@hasDecl(system, "fstatat")) system.fstatat else generic.fstatat; | ||
| 123 | pub const getrusage = if (@hasDecl(system, "getrusage")) system.getrusage else generic.getrusage; | ||
| 124 | pub const gettimeofday = if (@hasDecl(system, "gettimeofday")) system.gettimeofday else generic.gettimeofday; | ||
| 125 | pub const nanosleep = if (@hasDecl(system, "nanosleep")) system.nanosleep else generic.nanosleep; | ||
| 126 | pub const realpath = if (@hasDecl(system, "realpath")) system.realpath else generic.realpath; | ||
| 127 | pub const sched_yield = if (@hasDecl(system, "sched_yield")) system.sched_yield else generic.sched_yield; | ||
| 128 | pub const sigaction = if (@hasDecl(system, "sigaction")) system.sigaction else generic.sigaction; | ||
| 129 | pub const sigfillset = if (@hasDecl(system, "sigfillset")) system.sigfillset else generic.sigfillset; | ||
| 130 | pub const sigprocmask = if (@hasDecl(system, "sigprocmask")) system.sigprocmask else generic.sigprocmask; | ||
| 131 | pub const sigwait = if (@hasDecl(system, "sigwait")) system.sigwait else generic.sigwait; | ||
| 132 | pub const socket = if (@hasDecl(system, "socket")) system.socket else generic.socket; | ||
| 133 | pub const stat = if (@hasDecl(system, "stat")) system.stat else generic.stat; | ||
| 30 | 134 | ||
| 31 | pub fn getErrno(rc: anytype) E { | 135 | pub fn getErrno(rc: anytype) E { |
| 32 | if (rc == -1) { | 136 | if (rc == -1) { |
| ... | @@ -47,9 +151,9 @@ pub fn versionCheck(glibc_version: builtin.Version) type { | ... | @@ -47,9 +151,9 @@ pub fn versionCheck(glibc_version: builtin.Version) type { |
| 47 | return struct { | 151 | return struct { |
| 48 | pub const ok = blk: { | 152 | pub const ok = blk: { |
| 49 | if (!builtin.link_libc) break :blk false; | 153 | if (!builtin.link_libc) break :blk false; |
| 50 | if (std.Target.current.abi.isMusl()) break :blk true; | 154 | if (builtin.abi.isMusl()) break :blk true; |
| 51 | if (std.Target.current.isGnuLibC()) { | 155 | if (builtin.target.isGnuLibC()) { |
| 52 | const ver = std.Target.current.os.version_range.linux.glibc; | 156 | const ver = builtin.os.version_range.linux.glibc; |
| 53 | const order = ver.order(glibc_version); | 157 | const order = ver.order(glibc_version); |
| 54 | break :blk switch (order) { | 158 | break :blk switch (order) { |
| 55 | .gt, .eq => true, | 159 | .gt, .eq => true, |
| ... | @@ -115,17 +219,6 @@ pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; | ... | @@ -115,17 +219,6 @@ pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; |
| 115 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 219 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 116 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 220 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 117 | 221 | ||
| 118 | pub usingnamespace switch (builtin.os.tag) { | ||
| 119 | .macos, .ios, .watchos, .tvos => struct { | ||
| 120 | pub const realpath = @"realpath$DARWIN_EXTSN"; | ||
| 121 | pub const fstatat = _fstatat; | ||
| 122 | }, | ||
| 123 | else => struct { | ||
| 124 | pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | ||
| 125 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int; | ||
| 126 | }, | ||
| 127 | }; | ||
| 128 | |||
| 129 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; | 222 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; |
| 130 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; | 223 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; |
| 131 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 224 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| ... | @@ -172,75 +265,6 @@ pub extern "c" fn recvfrom( | ... | @@ -172,75 +265,6 @@ pub extern "c" fn recvfrom( |
| 172 | ) isize; | 265 | ) isize; |
| 173 | pub extern "c" fn recvmsg(sockfd: fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize; | 266 | pub extern "c" fn recvmsg(sockfd: fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize; |
| 174 | 267 | ||
| 175 | pub usingnamespace switch (builtin.os.tag) { | ||
| 176 | .netbsd => struct { | ||
| 177 | pub const clock_getres = __clock_getres50; | ||
| 178 | pub const clock_gettime = __clock_gettime50; | ||
| 179 | pub const fstat = __fstat50; | ||
| 180 | pub const getdents = __getdents30; | ||
| 181 | pub const getrusage = __getrusage50; | ||
| 182 | pub const gettimeofday = __gettimeofday50; | ||
| 183 | pub const nanosleep = __nanosleep50; | ||
| 184 | pub const sched_yield = __libc_thr_yield; | ||
| 185 | pub const sigaction = __sigaction14; | ||
| 186 | pub const sigaltstack = __sigaltstack14; | ||
| 187 | pub const sigprocmask = __sigprocmask14; | ||
| 188 | pub const socket = __socket30; | ||
| 189 | pub const stat = __stat50; | ||
| 190 | }, | ||
| 191 | .macos, .ios, .watchos, .tvos => struct { | ||
| 192 | // XXX: close -> close$NOCANCEL | ||
| 193 | // XXX: getdirentries -> _getdirentries64 | ||
| 194 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 195 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | ||
| 196 | pub const fstat = _fstat; | ||
| 197 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 198 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 199 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | ||
| 200 | pub extern "c" fn sched_yield() c_int; | ||
| 201 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | ||
| 202 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 203 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | ||
| 204 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int; | ||
| 205 | pub extern "c" fn sigfillset(set: ?*sigset_t) void; | ||
| 206 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | ||
| 207 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; | ||
| 208 | }, | ||
| 209 | .windows => struct { | ||
| 210 | // TODO: copied the else case and removed the socket function (because its in ws2_32) | ||
| 211 | // need to verify which of these is actually supported on windows | ||
| 212 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 213 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | ||
| 214 | pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int; | ||
| 215 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 216 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 217 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | ||
| 218 | pub extern "c" fn sched_yield() c_int; | ||
| 219 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | ||
| 220 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 221 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int; | ||
| 222 | pub extern "c" fn sigfillset(set: ?*sigset_t) void; | ||
| 223 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | ||
| 224 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; | ||
| 225 | }, | ||
| 226 | else => struct { | ||
| 227 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 228 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | ||
| 229 | pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int; | ||
| 230 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 231 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 232 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | ||
| 233 | pub extern "c" fn sched_yield() c_int; | ||
| 234 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | ||
| 235 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 236 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | ||
| 237 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int; | ||
| 238 | pub extern "c" fn sigfillset(set: ?*sigset_t) void; | ||
| 239 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | ||
| 240 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; | ||
| 241 | }, | ||
| 242 | }; | ||
| 243 | |||
| 244 | pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int; | 268 | pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int; |
| 245 | pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; | 269 | pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; |
| 246 | 270 | ||
| ... | @@ -375,9 +399,9 @@ pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int) | ... | @@ -375,9 +399,9 @@ pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int) |
| 375 | pub extern "c" fn closelog() void; | 399 | pub extern "c" fn closelog() void; |
| 376 | pub extern "c" fn setlogmask(maskpri: c_int) c_int; | 400 | pub extern "c" fn setlogmask(maskpri: c_int) c_int; |
| 377 | 401 | ||
| 378 | pub const max_align_t = if (std.Target.current.abi == .msvc) | 402 | pub const max_align_t = if (builtin.abi == .msvc) |
| 379 | f64 | 403 | f64 |
| 380 | else if (std.Target.current.isDarwin()) | 404 | else if (builtin.target.isDarwin()) |
| 381 | c_longdouble | 405 | c_longdouble |
| 382 | else | 406 | else |
| 383 | extern struct { | 407 | extern struct { |
lib/std/c/darwin.zig+1812-10| ... | @@ -3,6 +3,7 @@ const assert = std.debug.assert; | ... | @@ -3,6 +3,7 @@ const assert = std.debug.assert; |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const macho = std.macho; | 4 | const macho = std.macho; |
| 5 | const native_arch = builtin.target.cpu.arch; | 5 | const native_arch = builtin.target.cpu.arch; |
| 6 | const maxInt = std.math.maxInt; | ||
| 6 | 7 | ||
| 7 | extern "c" fn __error() *c_int; | 8 | extern "c" fn __error() *c_int; |
| 8 | pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32; | 9 | pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32; |
| ... | @@ -21,20 +22,25 @@ pub const copyfile_state_t = *opaque {}; | ... | @@ -21,20 +22,25 @@ pub const copyfile_state_t = *opaque {}; |
| 21 | pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int; | 22 | pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int; |
| 22 | 23 | ||
| 23 | pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 24 | pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 25 | pub const realpath = @"realpath$DARWIN_EXTSN"; | ||
| 24 | 26 | ||
| 25 | pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; | 27 | pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; |
| 26 | 28 | ||
| 27 | extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int; | 29 | const private = struct { |
| 28 | /// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to force 64bit version. | 30 | extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; |
| 29 | /// Note that this is fixed on aarch64 and no longer necessary. | 31 | /// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to |
| 30 | extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *libc_stat) c_int; | 32 | /// force 64bit version. |
| 31 | pub const _fstat = if (native_arch == .aarch64) fstat else @"fstat$INODE64"; | 33 | /// Note that this is fixed on aarch64 and no longer necessary. |
| 34 | extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int; | ||
| 32 | 35 | ||
| 33 | extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int; | 36 | extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; |
| 34 | /// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to force 64bit version. | 37 | /// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to |
| 35 | /// Note that this is fixed on aarch64 and no longer necessary. | 38 | /// force 64bit version. |
| 36 | extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *libc_stat, flags: u32) c_int; | 39 | /// Note that this is fixed on aarch64 and no longer necessary. |
| 37 | pub const _fstatat = if (native_arch == .aarch64) fstatat else @"fstatat$INODE64"; | 40 | extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *Stat, flags: u32) c_int; |
| 41 | }; | ||
| 42 | pub const fstat = if (native_arch == .aarch64) private.fstat else private.@"fstat$INODE64"; | ||
| 43 | pub const fstatat = if (native_arch == .aarch64) private.fstatat else private.@"fstatat$INODE64"; | ||
| 38 | 44 | ||
| 39 | pub extern "c" fn mach_absolute_time() u64; | 45 | pub extern "c" fn mach_absolute_time() u64; |
| 40 | pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void; | 46 | pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void; |
| ... | @@ -254,3 +260,1799 @@ pub extern "c" fn os_unfair_lock_unlock(o: os_unfair_lock_t) void; | ... | @@ -254,3 +260,1799 @@ pub extern "c" fn os_unfair_lock_unlock(o: os_unfair_lock_t) void; |
| 254 | pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool; | 260 | pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool; |
| 255 | pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void; | 261 | pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void; |
| 256 | pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void; | 262 | pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void; |
| 263 | |||
| 264 | // XXX: close -> close$NOCANCEL | ||
| 265 | // XXX: getdirentries -> _getdirentries64 | ||
| 266 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 267 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | ||
| 268 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 269 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 270 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | ||
| 271 | pub extern "c" fn sched_yield() c_int; | ||
| 272 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | ||
| 273 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 274 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | ||
| 275 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | ||
| 276 | pub extern "c" fn sigfillset(set: ?*sigset_t) void; | ||
| 277 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | ||
| 278 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; | ||
| 279 | |||
| 280 | // See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html | ||
| 281 | // TODO: audit mode_t/pid_t, should likely be u16/i32 | ||
| 282 | pub const fd_t = c_int; | ||
| 283 | pub const pid_t = c_int; | ||
| 284 | pub const mode_t = c_uint; | ||
| 285 | pub const uid_t = u32; | ||
| 286 | pub const gid_t = u32; | ||
| 287 | |||
| 288 | pub const in_port_t = u16; | ||
| 289 | pub const sa_family_t = u8; | ||
| 290 | pub const socklen_t = u32; | ||
| 291 | pub const sockaddr = extern struct { | ||
| 292 | len: u8, | ||
| 293 | family: sa_family_t, | ||
| 294 | data: [14]u8, | ||
| 295 | }; | ||
| 296 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 297 | pub const sockaddr_in = extern struct { | ||
| 298 | len: u8 = @sizeOf(sockaddr_in), | ||
| 299 | family: sa_family_t = AF_INET, | ||
| 300 | port: in_port_t, | ||
| 301 | addr: u32, | ||
| 302 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 303 | }; | ||
| 304 | pub const sockaddr_in6 = extern struct { | ||
| 305 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 306 | family: sa_family_t = AF_INET6, | ||
| 307 | port: in_port_t, | ||
| 308 | flowinfo: u32, | ||
| 309 | addr: [16]u8, | ||
| 310 | scope_id: u32, | ||
| 311 | }; | ||
| 312 | |||
| 313 | /// UNIX domain socket | ||
| 314 | pub const sockaddr_un = extern struct { | ||
| 315 | len: u8 = @sizeOf(sockaddr_un), | ||
| 316 | family: sa_family_t = AF_UNIX, | ||
| 317 | path: [104]u8, | ||
| 318 | }; | ||
| 319 | |||
| 320 | pub const timeval = extern struct { | ||
| 321 | tv_sec: c_long, | ||
| 322 | tv_usec: i32, | ||
| 323 | }; | ||
| 324 | |||
| 325 | pub const timezone = extern struct { | ||
| 326 | tz_minuteswest: i32, | ||
| 327 | tz_dsttime: i32, | ||
| 328 | }; | ||
| 329 | |||
| 330 | pub const mach_timebase_info_data = extern struct { | ||
| 331 | numer: u32, | ||
| 332 | denom: u32, | ||
| 333 | }; | ||
| 334 | |||
| 335 | pub const off_t = i64; | ||
| 336 | pub const ino_t = u64; | ||
| 337 | |||
| 338 | pub const Flock = extern struct { | ||
| 339 | l_start: off_t, | ||
| 340 | l_len: off_t, | ||
| 341 | l_pid: pid_t, | ||
| 342 | l_type: i16, | ||
| 343 | l_whence: i16, | ||
| 344 | }; | ||
| 345 | |||
| 346 | pub const Stat = extern struct { | ||
| 347 | dev: i32, | ||
| 348 | mode: u16, | ||
| 349 | nlink: u16, | ||
| 350 | ino: ino_t, | ||
| 351 | uid: uid_t, | ||
| 352 | gid: gid_t, | ||
| 353 | rdev: i32, | ||
| 354 | atimesec: isize, | ||
| 355 | atimensec: isize, | ||
| 356 | mtimesec: isize, | ||
| 357 | mtimensec: isize, | ||
| 358 | ctimesec: isize, | ||
| 359 | ctimensec: isize, | ||
| 360 | birthtimesec: isize, | ||
| 361 | birthtimensec: isize, | ||
| 362 | size: off_t, | ||
| 363 | blocks: i64, | ||
| 364 | blksize: i32, | ||
| 365 | flags: u32, | ||
| 366 | gen: u32, | ||
| 367 | lspare: i32, | ||
| 368 | qspare: [2]i64, | ||
| 369 | |||
| 370 | pub fn atime(self: @This()) timespec { | ||
| 371 | return timespec{ | ||
| 372 | .tv_sec = self.atimesec, | ||
| 373 | .tv_nsec = self.atimensec, | ||
| 374 | }; | ||
| 375 | } | ||
| 376 | |||
| 377 | pub fn mtime(self: @This()) timespec { | ||
| 378 | return timespec{ | ||
| 379 | .tv_sec = self.mtimesec, | ||
| 380 | .tv_nsec = self.mtimensec, | ||
| 381 | }; | ||
| 382 | } | ||
| 383 | |||
| 384 | pub fn ctime(self: @This()) timespec { | ||
| 385 | return timespec{ | ||
| 386 | .tv_sec = self.ctimesec, | ||
| 387 | .tv_nsec = self.ctimensec, | ||
| 388 | }; | ||
| 389 | } | ||
| 390 | }; | ||
| 391 | |||
| 392 | pub const timespec = extern struct { | ||
| 393 | tv_sec: isize, | ||
| 394 | tv_nsec: isize, | ||
| 395 | }; | ||
| 396 | |||
| 397 | pub const sigset_t = u32; | ||
| 398 | pub const empty_sigset: sigset_t = 0; | ||
| 399 | |||
| 400 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 401 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 402 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 403 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5); | ||
| 404 | |||
| 405 | pub const siginfo_t = extern struct { | ||
| 406 | signo: c_int, | ||
| 407 | errno: c_int, | ||
| 408 | code: c_int, | ||
| 409 | pid: pid_t, | ||
| 410 | uid: uid_t, | ||
| 411 | status: c_int, | ||
| 412 | addr: *c_void, | ||
| 413 | value: extern union { | ||
| 414 | int: c_int, | ||
| 415 | ptr: *c_void, | ||
| 416 | }, | ||
| 417 | si_band: c_long, | ||
| 418 | _pad: [7]c_ulong, | ||
| 419 | }; | ||
| 420 | |||
| 421 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. | ||
| 422 | pub const Sigaction = extern struct { | ||
| 423 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 424 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 425 | |||
| 426 | handler: extern union { | ||
| 427 | handler: ?handler_fn, | ||
| 428 | sigaction: ?sigaction_fn, | ||
| 429 | }, | ||
| 430 | mask: sigset_t, | ||
| 431 | flags: c_uint, | ||
| 432 | }; | ||
| 433 | |||
| 434 | pub const dirent = extern struct { | ||
| 435 | d_ino: usize, | ||
| 436 | d_seekoff: usize, | ||
| 437 | d_reclen: u16, | ||
| 438 | d_namlen: u16, | ||
| 439 | d_type: u8, | ||
| 440 | d_name: u8, // field address is address of first byte of name | ||
| 441 | |||
| 442 | pub fn reclen(self: dirent) u16 { | ||
| 443 | return self.d_reclen; | ||
| 444 | } | ||
| 445 | }; | ||
| 446 | |||
| 447 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 448 | pub const Kevent = extern struct { | ||
| 449 | ident: usize, | ||
| 450 | filter: i16, | ||
| 451 | flags: u16, | ||
| 452 | fflags: u32, | ||
| 453 | data: isize, | ||
| 454 | udata: usize, | ||
| 455 | }; | ||
| 456 | |||
| 457 | // sys/types.h on macos uses #pragma pack(4) so these checks are | ||
| 458 | // to make sure the struct is laid out the same. These values were | ||
| 459 | // produced from C code using the offsetof macro. | ||
| 460 | comptime { | ||
| 461 | assert(@offsetOf(Kevent, "ident") == 0); | ||
| 462 | assert(@offsetOf(Kevent, "filter") == 8); | ||
| 463 | assert(@offsetOf(Kevent, "flags") == 10); | ||
| 464 | assert(@offsetOf(Kevent, "fflags") == 12); | ||
| 465 | assert(@offsetOf(Kevent, "data") == 16); | ||
| 466 | assert(@offsetOf(Kevent, "udata") == 24); | ||
| 467 | } | ||
| 468 | |||
| 469 | pub const kevent64_s = extern struct { | ||
| 470 | ident: u64, | ||
| 471 | filter: i16, | ||
| 472 | flags: u16, | ||
| 473 | fflags: u32, | ||
| 474 | data: i64, | ||
| 475 | udata: u64, | ||
| 476 | ext: [2]u64, | ||
| 477 | }; | ||
| 478 | |||
| 479 | // sys/types.h on macos uses #pragma pack() so these checks are | ||
| 480 | // to make sure the struct is laid out the same. These values were | ||
| 481 | // produced from C code using the offsetof macro. | ||
| 482 | comptime { | ||
| 483 | assert(@offsetOf(kevent64_s, "ident") == 0); | ||
| 484 | assert(@offsetOf(kevent64_s, "filter") == 8); | ||
| 485 | assert(@offsetOf(kevent64_s, "flags") == 10); | ||
| 486 | assert(@offsetOf(kevent64_s, "fflags") == 12); | ||
| 487 | assert(@offsetOf(kevent64_s, "data") == 16); | ||
| 488 | assert(@offsetOf(kevent64_s, "udata") == 24); | ||
| 489 | assert(@offsetOf(kevent64_s, "ext") == 32); | ||
| 490 | } | ||
| 491 | |||
| 492 | pub const mach_port_t = c_uint; | ||
| 493 | pub const clock_serv_t = mach_port_t; | ||
| 494 | pub const clock_res_t = c_int; | ||
| 495 | pub const mach_port_name_t = natural_t; | ||
| 496 | pub const natural_t = c_uint; | ||
| 497 | pub const mach_timespec_t = extern struct { | ||
| 498 | tv_sec: c_uint, | ||
| 499 | tv_nsec: clock_res_t, | ||
| 500 | }; | ||
| 501 | pub const kern_return_t = c_int; | ||
| 502 | pub const host_t = mach_port_t; | ||
| 503 | pub const CALENDAR_CLOCK = 1; | ||
| 504 | |||
| 505 | pub const PATH_MAX = 1024; | ||
| 506 | pub const IOV_MAX = 16; | ||
| 507 | |||
| 508 | pub const STDIN_FILENO = 0; | ||
| 509 | pub const STDOUT_FILENO = 1; | ||
| 510 | pub const STDERR_FILENO = 2; | ||
| 511 | |||
| 512 | /// [MC2] no permissions | ||
| 513 | pub const PROT_NONE = 0x00; | ||
| 514 | |||
| 515 | /// [MC2] pages can be read | ||
| 516 | pub const PROT_READ = 0x01; | ||
| 517 | |||
| 518 | /// [MC2] pages can be written | ||
| 519 | pub const PROT_WRITE = 0x02; | ||
| 520 | |||
| 521 | /// [MC2] pages can be executed | ||
| 522 | pub const PROT_EXEC = 0x04; | ||
| 523 | |||
| 524 | /// allocated from memory, swap space | ||
| 525 | pub const MAP_ANONYMOUS = 0x1000; | ||
| 526 | |||
| 527 | /// map from file (default) | ||
| 528 | pub const MAP_FILE = 0x0000; | ||
| 529 | |||
| 530 | /// interpret addr exactly | ||
| 531 | pub const MAP_FIXED = 0x0010; | ||
| 532 | |||
| 533 | /// region may contain semaphores | ||
| 534 | pub const MAP_HASSEMAPHORE = 0x0200; | ||
| 535 | |||
| 536 | /// changes are private | ||
| 537 | pub const MAP_PRIVATE = 0x0002; | ||
| 538 | |||
| 539 | /// share changes | ||
| 540 | pub const MAP_SHARED = 0x0001; | ||
| 541 | |||
| 542 | /// don't cache pages for this mapping | ||
| 543 | pub const MAP_NOCACHE = 0x0400; | ||
| 544 | |||
| 545 | /// don't reserve needed swap area | ||
| 546 | pub const MAP_NORESERVE = 0x0040; | ||
| 547 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 548 | |||
| 549 | /// [XSI] no hang in wait/no child to reap | ||
| 550 | pub const WNOHANG = 0x00000001; | ||
| 551 | |||
| 552 | /// [XSI] notify on stop, untraced child | ||
| 553 | pub const WUNTRACED = 0x00000002; | ||
| 554 | |||
| 555 | /// take signal on signal stack | ||
| 556 | pub const SA_ONSTACK = 0x0001; | ||
| 557 | |||
| 558 | /// restart system on signal return | ||
| 559 | pub const SA_RESTART = 0x0002; | ||
| 560 | |||
| 561 | /// reset to SIG_DFL when taking signal | ||
| 562 | pub const SA_RESETHAND = 0x0004; | ||
| 563 | |||
| 564 | /// do not generate SIGCHLD on child stop | ||
| 565 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 566 | |||
| 567 | /// don't mask the signal we're delivering | ||
| 568 | pub const SA_NODEFER = 0x0010; | ||
| 569 | |||
| 570 | /// don't keep zombies around | ||
| 571 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 572 | |||
| 573 | /// signal handler with SA_SIGINFO args | ||
| 574 | pub const SA_SIGINFO = 0x0040; | ||
| 575 | |||
| 576 | /// do not bounce off kernel's sigtramp | ||
| 577 | pub const SA_USERTRAMP = 0x0100; | ||
| 578 | |||
| 579 | /// signal handler with SA_SIGINFO args with 64bit regs information | ||
| 580 | pub const SA_64REGSET = 0x0200; | ||
| 581 | |||
| 582 | pub const O_PATH = 0x0000; | ||
| 583 | |||
| 584 | pub const F_OK = 0; | ||
| 585 | pub const X_OK = 1; | ||
| 586 | pub const W_OK = 2; | ||
| 587 | pub const R_OK = 4; | ||
| 588 | |||
| 589 | /// open for reading only | ||
| 590 | pub const O_RDONLY = 0x0000; | ||
| 591 | |||
| 592 | /// open for writing only | ||
| 593 | pub const O_WRONLY = 0x0001; | ||
| 594 | |||
| 595 | /// open for reading and writing | ||
| 596 | pub const O_RDWR = 0x0002; | ||
| 597 | |||
| 598 | /// do not block on open or for data to become available | ||
| 599 | pub const O_NONBLOCK = 0x0004; | ||
| 600 | |||
| 601 | /// append on each write | ||
| 602 | pub const O_APPEND = 0x0008; | ||
| 603 | |||
| 604 | /// create file if it does not exist | ||
| 605 | pub const O_CREAT = 0x0200; | ||
| 606 | |||
| 607 | /// truncate size to 0 | ||
| 608 | pub const O_TRUNC = 0x0400; | ||
| 609 | |||
| 610 | /// error if O_CREAT and the file exists | ||
| 611 | pub const O_EXCL = 0x0800; | ||
| 612 | |||
| 613 | /// atomically obtain a shared lock | ||
| 614 | pub const O_SHLOCK = 0x0010; | ||
| 615 | |||
| 616 | /// atomically obtain an exclusive lock | ||
| 617 | pub const O_EXLOCK = 0x0020; | ||
| 618 | |||
| 619 | /// do not follow symlinks | ||
| 620 | pub const O_NOFOLLOW = 0x0100; | ||
| 621 | |||
| 622 | /// allow open of symlinks | ||
| 623 | pub const O_SYMLINK = 0x200000; | ||
| 624 | |||
| 625 | /// descriptor requested for event notifications only | ||
| 626 | pub const O_EVTONLY = 0x8000; | ||
| 627 | |||
| 628 | /// mark as close-on-exec | ||
| 629 | pub const O_CLOEXEC = 0x1000000; | ||
| 630 | |||
| 631 | pub const O_ACCMODE = 3; | ||
| 632 | pub const O_ALERT = 536870912; | ||
| 633 | pub const O_ASYNC = 64; | ||
| 634 | pub const O_DIRECTORY = 1048576; | ||
| 635 | pub const O_DP_GETRAWENCRYPTED = 1; | ||
| 636 | pub const O_DP_GETRAWUNENCRYPTED = 2; | ||
| 637 | pub const O_DSYNC = 4194304; | ||
| 638 | pub const O_FSYNC = O_SYNC; | ||
| 639 | pub const O_NOCTTY = 131072; | ||
| 640 | pub const O_POPUP = 2147483648; | ||
| 641 | pub const O_SYNC = 128; | ||
| 642 | |||
| 643 | pub const SEEK_SET = 0x0; | ||
| 644 | pub const SEEK_CUR = 0x1; | ||
| 645 | pub const SEEK_END = 0x2; | ||
| 646 | |||
| 647 | pub const DT_UNKNOWN = 0; | ||
| 648 | pub const DT_FIFO = 1; | ||
| 649 | pub const DT_CHR = 2; | ||
| 650 | pub const DT_DIR = 4; | ||
| 651 | pub const DT_BLK = 6; | ||
| 652 | pub const DT_REG = 8; | ||
| 653 | pub const DT_LNK = 10; | ||
| 654 | pub const DT_SOCK = 12; | ||
| 655 | pub const DT_WHT = 14; | ||
| 656 | |||
| 657 | /// block specified signal set | ||
| 658 | pub const SIG_BLOCK = 1; | ||
| 659 | |||
| 660 | /// unblock specified signal set | ||
| 661 | pub const SIG_UNBLOCK = 2; | ||
| 662 | |||
| 663 | /// set specified signal set | ||
| 664 | pub const SIG_SETMASK = 3; | ||
| 665 | |||
| 666 | /// hangup | ||
| 667 | pub const SIGHUP = 1; | ||
| 668 | |||
| 669 | /// interrupt | ||
| 670 | pub const SIGINT = 2; | ||
| 671 | |||
| 672 | /// quit | ||
| 673 | pub const SIGQUIT = 3; | ||
| 674 | |||
| 675 | /// illegal instruction (not reset when caught) | ||
| 676 | pub const SIGILL = 4; | ||
| 677 | |||
| 678 | /// trace trap (not reset when caught) | ||
| 679 | pub const SIGTRAP = 5; | ||
| 680 | |||
| 681 | /// abort() | ||
| 682 | pub const SIGABRT = 6; | ||
| 683 | |||
| 684 | /// pollable event ([XSR] generated, not supported) | ||
| 685 | pub const SIGPOLL = 7; | ||
| 686 | |||
| 687 | /// compatibility | ||
| 688 | pub const SIGIOT = SIGABRT; | ||
| 689 | |||
| 690 | /// EMT instruction | ||
| 691 | pub const SIGEMT = 7; | ||
| 692 | |||
| 693 | /// floating point exception | ||
| 694 | pub const SIGFPE = 8; | ||
| 695 | |||
| 696 | /// kill (cannot be caught or ignored) | ||
| 697 | pub const SIGKILL = 9; | ||
| 698 | |||
| 699 | /// bus error | ||
| 700 | pub const SIGBUS = 10; | ||
| 701 | |||
| 702 | /// segmentation violation | ||
| 703 | pub const SIGSEGV = 11; | ||
| 704 | |||
| 705 | /// bad argument to system call | ||
| 706 | pub const SIGSYS = 12; | ||
| 707 | |||
| 708 | /// write on a pipe with no one to read it | ||
| 709 | pub const SIGPIPE = 13; | ||
| 710 | |||
| 711 | /// alarm clock | ||
| 712 | pub const SIGALRM = 14; | ||
| 713 | |||
| 714 | /// software termination signal from kill | ||
| 715 | pub const SIGTERM = 15; | ||
| 716 | |||
| 717 | /// urgent condition on IO channel | ||
| 718 | pub const SIGURG = 16; | ||
| 719 | |||
| 720 | /// sendable stop signal not from tty | ||
| 721 | pub const SIGSTOP = 17; | ||
| 722 | |||
| 723 | /// stop signal from tty | ||
| 724 | pub const SIGTSTP = 18; | ||
| 725 | |||
| 726 | /// continue a stopped process | ||
| 727 | pub const SIGCONT = 19; | ||
| 728 | |||
| 729 | /// to parent on child stop or exit | ||
| 730 | pub const SIGCHLD = 20; | ||
| 731 | |||
| 732 | /// to readers pgrp upon background tty read | ||
| 733 | pub const SIGTTIN = 21; | ||
| 734 | |||
| 735 | /// like TTIN for output if (tp->t_local&LTOSTOP) | ||
| 736 | pub const SIGTTOU = 22; | ||
| 737 | |||
| 738 | /// input/output possible signal | ||
| 739 | pub const SIGIO = 23; | ||
| 740 | |||
| 741 | /// exceeded CPU time limit | ||
| 742 | pub const SIGXCPU = 24; | ||
| 743 | |||
| 744 | /// exceeded file size limit | ||
| 745 | pub const SIGXFSZ = 25; | ||
| 746 | |||
| 747 | /// virtual time alarm | ||
| 748 | pub const SIGVTALRM = 26; | ||
| 749 | |||
| 750 | /// profiling time alarm | ||
| 751 | pub const SIGPROF = 27; | ||
| 752 | |||
| 753 | /// window size changes | ||
| 754 | pub const SIGWINCH = 28; | ||
| 755 | |||
| 756 | /// information request | ||
| 757 | pub const SIGINFO = 29; | ||
| 758 | |||
| 759 | /// user defined signal 1 | ||
| 760 | pub const SIGUSR1 = 30; | ||
| 761 | |||
| 762 | /// user defined signal 2 | ||
| 763 | pub const SIGUSR2 = 31; | ||
| 764 | |||
| 765 | /// no flag value | ||
| 766 | pub const KEVENT_FLAG_NONE = 0x000; | ||
| 767 | |||
| 768 | /// immediate timeout | ||
| 769 | pub const KEVENT_FLAG_IMMEDIATE = 0x001; | ||
| 770 | |||
| 771 | /// output events only include change | ||
| 772 | pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; | ||
| 773 | |||
| 774 | /// add event to kq (implies enable) | ||
| 775 | pub const EV_ADD = 0x0001; | ||
| 776 | |||
| 777 | /// delete event from kq | ||
| 778 | pub const EV_DELETE = 0x0002; | ||
| 779 | |||
| 780 | /// enable event | ||
| 781 | pub const EV_ENABLE = 0x0004; | ||
| 782 | |||
| 783 | /// disable event (not reported) | ||
| 784 | pub const EV_DISABLE = 0x0008; | ||
| 785 | |||
| 786 | /// only report one occurrence | ||
| 787 | pub const EV_ONESHOT = 0x0010; | ||
| 788 | |||
| 789 | /// clear event state after reporting | ||
| 790 | pub const EV_CLEAR = 0x0020; | ||
| 791 | |||
| 792 | /// force immediate event output | ||
| 793 | /// ... with or without EV_ERROR | ||
| 794 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 795 | /// on syscalls supporting flags | ||
| 796 | pub const EV_RECEIPT = 0x0040; | ||
| 797 | |||
| 798 | /// disable event after reporting | ||
| 799 | pub const EV_DISPATCH = 0x0080; | ||
| 800 | |||
| 801 | /// unique kevent per udata value | ||
| 802 | pub const EV_UDATA_SPECIFIC = 0x0100; | ||
| 803 | |||
| 804 | /// ... in combination with EV_DELETE | ||
| 805 | /// will defer delete until udata-specific | ||
| 806 | /// event enabled. EINPROGRESS will be | ||
| 807 | /// returned to indicate the deferral | ||
| 808 | pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC; | ||
| 809 | |||
| 810 | /// report that source has vanished | ||
| 811 | /// ... only valid with EV_DISPATCH2 | ||
| 812 | pub const EV_VANISHED = 0x0200; | ||
| 813 | |||
| 814 | /// reserved by system | ||
| 815 | pub const EV_SYSFLAGS = 0xF000; | ||
| 816 | |||
| 817 | /// filter-specific flag | ||
| 818 | pub const EV_FLAG0 = 0x1000; | ||
| 819 | |||
| 820 | /// filter-specific flag | ||
| 821 | pub const EV_FLAG1 = 0x2000; | ||
| 822 | |||
| 823 | /// EOF detected | ||
| 824 | pub const EV_EOF = 0x8000; | ||
| 825 | |||
| 826 | /// error, data contains errno | ||
| 827 | pub const EV_ERROR = 0x4000; | ||
| 828 | |||
| 829 | pub const EV_POLL = EV_FLAG0; | ||
| 830 | pub const EV_OOBAND = EV_FLAG1; | ||
| 831 | |||
| 832 | pub const EVFILT_READ = -1; | ||
| 833 | pub const EVFILT_WRITE = -2; | ||
| 834 | |||
| 835 | /// attached to aio requests | ||
| 836 | pub const EVFILT_AIO = -3; | ||
| 837 | |||
| 838 | /// attached to vnodes | ||
| 839 | pub const EVFILT_VNODE = -4; | ||
| 840 | |||
| 841 | /// attached to struct proc | ||
| 842 | pub const EVFILT_PROC = -5; | ||
| 843 | |||
| 844 | /// attached to struct proc | ||
| 845 | pub const EVFILT_SIGNAL = -6; | ||
| 846 | |||
| 847 | /// timers | ||
| 848 | pub const EVFILT_TIMER = -7; | ||
| 849 | |||
| 850 | /// Mach portsets | ||
| 851 | pub const EVFILT_MACHPORT = -8; | ||
| 852 | |||
| 853 | /// Filesystem events | ||
| 854 | pub const EVFILT_FS = -9; | ||
| 855 | |||
| 856 | /// User events | ||
| 857 | pub const EVFILT_USER = -10; | ||
| 858 | |||
| 859 | /// Virtual memory events | ||
| 860 | pub const EVFILT_VM = -12; | ||
| 861 | |||
| 862 | /// Exception events | ||
| 863 | pub const EVFILT_EXCEPT = -15; | ||
| 864 | |||
| 865 | pub const EVFILT_SYSCOUNT = 17; | ||
| 866 | |||
| 867 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 868 | pub const NOTE_TRIGGER = 0x01000000; | ||
| 869 | |||
| 870 | /// ignore input fflags | ||
| 871 | pub const NOTE_FFNOP = 0x00000000; | ||
| 872 | |||
| 873 | /// and fflags | ||
| 874 | pub const NOTE_FFAND = 0x40000000; | ||
| 875 | |||
| 876 | /// or fflags | ||
| 877 | pub const NOTE_FFOR = 0x80000000; | ||
| 878 | |||
| 879 | /// copy fflags | ||
| 880 | pub const NOTE_FFCOPY = 0xc0000000; | ||
| 881 | |||
| 882 | /// mask for operations | ||
| 883 | pub const NOTE_FFCTRLMASK = 0xc0000000; | ||
| 884 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | ||
| 885 | |||
| 886 | /// low water mark | ||
| 887 | pub const NOTE_LOWAT = 0x00000001; | ||
| 888 | |||
| 889 | /// OOB data | ||
| 890 | pub const NOTE_OOB = 0x00000002; | ||
| 891 | |||
| 892 | /// vnode was removed | ||
| 893 | pub const NOTE_DELETE = 0x00000001; | ||
| 894 | |||
| 895 | /// data contents changed | ||
| 896 | pub const NOTE_WRITE = 0x00000002; | ||
| 897 | |||
| 898 | /// size increased | ||
| 899 | pub const NOTE_EXTEND = 0x00000004; | ||
| 900 | |||
| 901 | /// attributes changed | ||
| 902 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 903 | |||
| 904 | /// link count changed | ||
| 905 | pub const NOTE_LINK = 0x00000010; | ||
| 906 | |||
| 907 | /// vnode was renamed | ||
| 908 | pub const NOTE_RENAME = 0x00000020; | ||
| 909 | |||
| 910 | /// vnode access was revoked | ||
| 911 | pub const NOTE_REVOKE = 0x00000040; | ||
| 912 | |||
| 913 | /// No specific vnode event: to test for EVFILT_READ activation | ||
| 914 | pub const NOTE_NONE = 0x00000080; | ||
| 915 | |||
| 916 | /// vnode was unlocked by flock(2) | ||
| 917 | pub const NOTE_FUNLOCK = 0x00000100; | ||
| 918 | |||
| 919 | /// process exited | ||
| 920 | pub const NOTE_EXIT = 0x80000000; | ||
| 921 | |||
| 922 | /// process forked | ||
| 923 | pub const NOTE_FORK = 0x40000000; | ||
| 924 | |||
| 925 | /// process exec'd | ||
| 926 | pub const NOTE_EXEC = 0x20000000; | ||
| 927 | |||
| 928 | /// shared with EVFILT_SIGNAL | ||
| 929 | pub const NOTE_SIGNAL = 0x08000000; | ||
| 930 | |||
| 931 | /// exit status to be returned, valid for child process only | ||
| 932 | pub const NOTE_EXITSTATUS = 0x04000000; | ||
| 933 | |||
| 934 | /// provide details on reasons for exit | ||
| 935 | pub const NOTE_EXIT_DETAIL = 0x02000000; | ||
| 936 | |||
| 937 | /// mask for signal & exit status | ||
| 938 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 939 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | ||
| 940 | |||
| 941 | pub const NOTE_EXIT_DETAIL_MASK = 0x00070000; | ||
| 942 | pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000; | ||
| 943 | pub const NOTE_EXIT_MEMORY = 0x00020000; | ||
| 944 | pub const NOTE_EXIT_CSERROR = 0x00040000; | ||
| 945 | |||
| 946 | /// will react on memory pressure | ||
| 947 | pub const NOTE_VM_PRESSURE = 0x80000000; | ||
| 948 | |||
| 949 | /// will quit on memory pressure, possibly after cleaning up dirty state | ||
| 950 | pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; | ||
| 951 | |||
| 952 | /// will quit immediately on memory pressure | ||
| 953 | pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; | ||
| 954 | |||
| 955 | /// there was an error | ||
| 956 | pub const NOTE_VM_ERROR = 0x10000000; | ||
| 957 | |||
| 958 | /// data is seconds | ||
| 959 | pub const NOTE_SECONDS = 0x00000001; | ||
| 960 | |||
| 961 | /// data is microseconds | ||
| 962 | pub const NOTE_USECONDS = 0x00000002; | ||
| 963 | |||
| 964 | /// data is nanoseconds | ||
| 965 | pub const NOTE_NSECONDS = 0x00000004; | ||
| 966 | |||
| 967 | /// absolute timeout | ||
| 968 | pub const NOTE_ABSOLUTE = 0x00000008; | ||
| 969 | |||
| 970 | /// ext[1] holds leeway for power aware timers | ||
| 971 | pub const NOTE_LEEWAY = 0x00000010; | ||
| 972 | |||
| 973 | /// system does minimal timer coalescing | ||
| 974 | pub const NOTE_CRITICAL = 0x00000020; | ||
| 975 | |||
| 976 | /// system does maximum timer coalescing | ||
| 977 | pub const NOTE_BACKGROUND = 0x00000040; | ||
| 978 | pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080; | ||
| 979 | |||
| 980 | /// data is mach absolute time units | ||
| 981 | pub const NOTE_MACHTIME = 0x00000100; | ||
| 982 | |||
| 983 | pub const AF_UNSPEC = 0; | ||
| 984 | pub const AF_LOCAL = 1; | ||
| 985 | pub const AF_UNIX = AF_LOCAL; | ||
| 986 | pub const AF_INET = 2; | ||
| 987 | pub const AF_SYS_CONTROL = 2; | ||
| 988 | pub const AF_IMPLINK = 3; | ||
| 989 | pub const AF_PUP = 4; | ||
| 990 | pub const AF_CHAOS = 5; | ||
| 991 | pub const AF_NS = 6; | ||
| 992 | pub const AF_ISO = 7; | ||
| 993 | pub const AF_OSI = AF_ISO; | ||
| 994 | pub const AF_ECMA = 8; | ||
| 995 | pub const AF_DATAKIT = 9; | ||
| 996 | pub const AF_CCITT = 10; | ||
| 997 | pub const AF_SNA = 11; | ||
| 998 | pub const AF_DECnet = 12; | ||
| 999 | pub const AF_DLI = 13; | ||
| 1000 | pub const AF_LAT = 14; | ||
| 1001 | pub const AF_HYLINK = 15; | ||
| 1002 | pub const AF_APPLETALK = 16; | ||
| 1003 | pub const AF_ROUTE = 17; | ||
| 1004 | pub const AF_LINK = 18; | ||
| 1005 | pub const AF_XTP = 19; | ||
| 1006 | pub const AF_COIP = 20; | ||
| 1007 | pub const AF_CNT = 21; | ||
| 1008 | pub const AF_RTIP = 22; | ||
| 1009 | pub const AF_IPX = 23; | ||
| 1010 | pub const AF_SIP = 24; | ||
| 1011 | pub const AF_PIP = 25; | ||
| 1012 | pub const AF_ISDN = 28; | ||
| 1013 | pub const AF_E164 = AF_ISDN; | ||
| 1014 | pub const AF_KEY = 29; | ||
| 1015 | pub const AF_INET6 = 30; | ||
| 1016 | pub const AF_NATM = 31; | ||
| 1017 | pub const AF_SYSTEM = 32; | ||
| 1018 | pub const AF_NETBIOS = 33; | ||
| 1019 | pub const AF_PPP = 34; | ||
| 1020 | pub const AF_MAX = 40; | ||
| 1021 | |||
| 1022 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 1023 | pub const PF_LOCAL = AF_LOCAL; | ||
| 1024 | pub const PF_UNIX = PF_LOCAL; | ||
| 1025 | pub const PF_INET = AF_INET; | ||
| 1026 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 1027 | pub const PF_PUP = AF_PUP; | ||
| 1028 | pub const PF_CHAOS = AF_CHAOS; | ||
| 1029 | pub const PF_NS = AF_NS; | ||
| 1030 | pub const PF_ISO = AF_ISO; | ||
| 1031 | pub const PF_OSI = AF_ISO; | ||
| 1032 | pub const PF_ECMA = AF_ECMA; | ||
| 1033 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 1034 | pub const PF_CCITT = AF_CCITT; | ||
| 1035 | pub const PF_SNA = AF_SNA; | ||
| 1036 | pub const PF_DECnet = AF_DECnet; | ||
| 1037 | pub const PF_DLI = AF_DLI; | ||
| 1038 | pub const PF_LAT = AF_LAT; | ||
| 1039 | pub const PF_HYLINK = AF_HYLINK; | ||
| 1040 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 1041 | pub const PF_ROUTE = AF_ROUTE; | ||
| 1042 | pub const PF_LINK = AF_LINK; | ||
| 1043 | pub const PF_XTP = AF_XTP; | ||
| 1044 | pub const PF_COIP = AF_COIP; | ||
| 1045 | pub const PF_CNT = AF_CNT; | ||
| 1046 | pub const PF_SIP = AF_SIP; | ||
| 1047 | pub const PF_IPX = AF_IPX; | ||
| 1048 | pub const PF_RTIP = AF_RTIP; | ||
| 1049 | pub const PF_PIP = AF_PIP; | ||
| 1050 | pub const PF_ISDN = AF_ISDN; | ||
| 1051 | pub const PF_KEY = AF_KEY; | ||
| 1052 | pub const PF_INET6 = AF_INET6; | ||
| 1053 | pub const PF_NATM = AF_NATM; | ||
| 1054 | pub const PF_SYSTEM = AF_SYSTEM; | ||
| 1055 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 1056 | pub const PF_PPP = AF_PPP; | ||
| 1057 | pub const PF_MAX = AF_MAX; | ||
| 1058 | |||
| 1059 | pub const SYSPROTO_EVENT = 1; | ||
| 1060 | pub const SYSPROTO_CONTROL = 2; | ||
| 1061 | |||
| 1062 | pub const SOCK_STREAM = 1; | ||
| 1063 | pub const SOCK_DGRAM = 2; | ||
| 1064 | pub const SOCK_RAW = 3; | ||
| 1065 | pub const SOCK_RDM = 4; | ||
| 1066 | pub const SOCK_SEQPACKET = 5; | ||
| 1067 | pub const SOCK_MAXADDRLEN = 255; | ||
| 1068 | |||
| 1069 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 1070 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 1071 | /// with any other "SOCK_" bits. | ||
| 1072 | pub const SOCK_CLOEXEC = 1 << 15; | ||
| 1073 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 1074 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 1075 | /// with any other "SOCK_" bits. | ||
| 1076 | pub const SOCK_NONBLOCK = 1 << 16; | ||
| 1077 | |||
| 1078 | pub const IPPROTO_ICMP = 1; | ||
| 1079 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1080 | pub const IPPROTO_TCP = 6; | ||
| 1081 | pub const IPPROTO_UDP = 17; | ||
| 1082 | pub const IPPROTO_IP = 0; | ||
| 1083 | pub const IPPROTO_IPV6 = 41; | ||
| 1084 | |||
| 1085 | pub const SOL_SOCKET = 0xffff; | ||
| 1086 | |||
| 1087 | pub const SO_DEBUG = 0x0001; | ||
| 1088 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 1089 | pub const SO_REUSEADDR = 0x0004; | ||
| 1090 | pub const SO_KEEPALIVE = 0x0008; | ||
| 1091 | pub const SO_DONTROUTE = 0x0010; | ||
| 1092 | pub const SO_BROADCAST = 0x0020; | ||
| 1093 | pub const SO_USELOOPBACK = 0x0040; | ||
| 1094 | pub const SO_LINGER = 0x1080; | ||
| 1095 | pub const SO_OOBINLINE = 0x0100; | ||
| 1096 | pub const SO_REUSEPORT = 0x0200; | ||
| 1097 | pub const SO_ACCEPTFILTER = 0x1000; | ||
| 1098 | pub const SO_SNDBUF = 0x1001; | ||
| 1099 | pub const SO_RCVBUF = 0x1002; | ||
| 1100 | pub const SO_SNDLOWAT = 0x1003; | ||
| 1101 | pub const SO_RCVLOWAT = 0x1004; | ||
| 1102 | pub const SO_SNDTIMEO = 0x1005; | ||
| 1103 | pub const SO_RCVTIMEO = 0x1006; | ||
| 1104 | pub const SO_ERROR = 0x1007; | ||
| 1105 | pub const SO_TYPE = 0x1008; | ||
| 1106 | |||
| 1107 | pub const SO_NREAD = 0x1020; | ||
| 1108 | pub const SO_NKE = 0x1021; | ||
| 1109 | pub const SO_NOSIGPIPE = 0x1022; | ||
| 1110 | pub const SO_NOADDRERR = 0x1023; | ||
| 1111 | pub const SO_NWRITE = 0x1024; | ||
| 1112 | pub const SO_REUSESHAREUID = 0x1025; | ||
| 1113 | |||
| 1114 | fn wstatus(x: u32) u32 { | ||
| 1115 | return x & 0o177; | ||
| 1116 | } | ||
| 1117 | const wstopped = 0o177; | ||
| 1118 | pub fn WEXITSTATUS(x: u32) u8 { | ||
| 1119 | return @intCast(u8, x >> 8); | ||
| 1120 | } | ||
| 1121 | pub fn WTERMSIG(x: u32) u32 { | ||
| 1122 | return wstatus(x); | ||
| 1123 | } | ||
| 1124 | pub fn WSTOPSIG(x: u32) u32 { | ||
| 1125 | return x >> 8; | ||
| 1126 | } | ||
| 1127 | pub fn WIFEXITED(x: u32) bool { | ||
| 1128 | return wstatus(x) == 0; | ||
| 1129 | } | ||
| 1130 | pub fn WIFSTOPPED(x: u32) bool { | ||
| 1131 | return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13; | ||
| 1132 | } | ||
| 1133 | pub fn WIFSIGNALED(x: u32) bool { | ||
| 1134 | return wstatus(x) != wstopped and wstatus(x) != 0; | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | pub const E = enum(u16) { | ||
| 1138 | /// No error occurred. | ||
| 1139 | SUCCESS = 0, | ||
| 1140 | |||
| 1141 | /// Operation not permitted | ||
| 1142 | PERM = 1, | ||
| 1143 | |||
| 1144 | /// No such file or directory | ||
| 1145 | NOENT = 2, | ||
| 1146 | |||
| 1147 | /// No such process | ||
| 1148 | SRCH = 3, | ||
| 1149 | |||
| 1150 | /// Interrupted system call | ||
| 1151 | INTR = 4, | ||
| 1152 | |||
| 1153 | /// Input/output error | ||
| 1154 | IO = 5, | ||
| 1155 | |||
| 1156 | /// Device not configured | ||
| 1157 | NXIO = 6, | ||
| 1158 | |||
| 1159 | /// Argument list too long | ||
| 1160 | @"2BIG" = 7, | ||
| 1161 | |||
| 1162 | /// Exec format error | ||
| 1163 | NOEXEC = 8, | ||
| 1164 | |||
| 1165 | /// Bad file descriptor | ||
| 1166 | BADF = 9, | ||
| 1167 | |||
| 1168 | /// No child processes | ||
| 1169 | CHILD = 10, | ||
| 1170 | |||
| 1171 | /// Resource deadlock avoided | ||
| 1172 | DEADLK = 11, | ||
| 1173 | |||
| 1174 | /// Cannot allocate memory | ||
| 1175 | NOMEM = 12, | ||
| 1176 | |||
| 1177 | /// Permission denied | ||
| 1178 | ACCES = 13, | ||
| 1179 | |||
| 1180 | /// Bad address | ||
| 1181 | FAULT = 14, | ||
| 1182 | |||
| 1183 | /// Block device required | ||
| 1184 | NOTBLK = 15, | ||
| 1185 | |||
| 1186 | /// Device / Resource busy | ||
| 1187 | BUSY = 16, | ||
| 1188 | |||
| 1189 | /// File exists | ||
| 1190 | EXIST = 17, | ||
| 1191 | |||
| 1192 | /// Cross-device link | ||
| 1193 | XDEV = 18, | ||
| 1194 | |||
| 1195 | /// Operation not supported by device | ||
| 1196 | NODEV = 19, | ||
| 1197 | |||
| 1198 | /// Not a directory | ||
| 1199 | NOTDIR = 20, | ||
| 1200 | |||
| 1201 | /// Is a directory | ||
| 1202 | ISDIR = 21, | ||
| 1203 | |||
| 1204 | /// Invalid argument | ||
| 1205 | INVAL = 22, | ||
| 1206 | |||
| 1207 | /// Too many open files in system | ||
| 1208 | NFILE = 23, | ||
| 1209 | |||
| 1210 | /// Too many open files | ||
| 1211 | MFILE = 24, | ||
| 1212 | |||
| 1213 | /// Inappropriate ioctl for device | ||
| 1214 | NOTTY = 25, | ||
| 1215 | |||
| 1216 | /// Text file busy | ||
| 1217 | TXTBSY = 26, | ||
| 1218 | |||
| 1219 | /// File too large | ||
| 1220 | FBIG = 27, | ||
| 1221 | |||
| 1222 | /// No space left on device | ||
| 1223 | NOSPC = 28, | ||
| 1224 | |||
| 1225 | /// Illegal seek | ||
| 1226 | SPIPE = 29, | ||
| 1227 | |||
| 1228 | /// Read-only file system | ||
| 1229 | ROFS = 30, | ||
| 1230 | |||
| 1231 | /// Too many links | ||
| 1232 | MLINK = 31, | ||
| 1233 | |||
| 1234 | /// Broken pipe | ||
| 1235 | PIPE = 32, | ||
| 1236 | |||
| 1237 | // math software | ||
| 1238 | |||
| 1239 | /// Numerical argument out of domain | ||
| 1240 | DOM = 33, | ||
| 1241 | |||
| 1242 | /// Result too large | ||
| 1243 | RANGE = 34, | ||
| 1244 | |||
| 1245 | // non-blocking and interrupt i/o | ||
| 1246 | |||
| 1247 | /// Resource temporarily unavailable | ||
| 1248 | /// This is the same code used for `WOULDBLOCK`. | ||
| 1249 | AGAIN = 35, | ||
| 1250 | |||
| 1251 | /// Operation now in progress | ||
| 1252 | INPROGRESS = 36, | ||
| 1253 | |||
| 1254 | /// Operation already in progress | ||
| 1255 | ALREADY = 37, | ||
| 1256 | |||
| 1257 | // ipc/network software -- argument errors | ||
| 1258 | |||
| 1259 | /// Socket operation on non-socket | ||
| 1260 | NOTSOCK = 38, | ||
| 1261 | |||
| 1262 | /// Destination address required | ||
| 1263 | DESTADDRREQ = 39, | ||
| 1264 | |||
| 1265 | /// Message too long | ||
| 1266 | MSGSIZE = 40, | ||
| 1267 | |||
| 1268 | /// Protocol wrong type for socket | ||
| 1269 | PROTOTYPE = 41, | ||
| 1270 | |||
| 1271 | /// Protocol not available | ||
| 1272 | NOPROTOOPT = 42, | ||
| 1273 | |||
| 1274 | /// Protocol not supported | ||
| 1275 | PROTONOSUPPORT = 43, | ||
| 1276 | |||
| 1277 | /// Socket type not supported | ||
| 1278 | SOCKTNOSUPPORT = 44, | ||
| 1279 | |||
| 1280 | /// Operation not supported | ||
| 1281 | /// The same code is used for `NOTSUP`. | ||
| 1282 | OPNOTSUPP = 45, | ||
| 1283 | |||
| 1284 | /// Protocol family not supported | ||
| 1285 | PFNOSUPPORT = 46, | ||
| 1286 | |||
| 1287 | /// Address family not supported by protocol family | ||
| 1288 | AFNOSUPPORT = 47, | ||
| 1289 | |||
| 1290 | /// Address already in use | ||
| 1291 | ADDRINUSE = 48, | ||
| 1292 | /// Can't assign requested address | ||
| 1293 | |||
| 1294 | // ipc/network software -- operational errors | ||
| 1295 | ADDRNOTAVAIL = 49, | ||
| 1296 | |||
| 1297 | /// Network is down | ||
| 1298 | NETDOWN = 50, | ||
| 1299 | |||
| 1300 | /// Network is unreachable | ||
| 1301 | NETUNREACH = 51, | ||
| 1302 | |||
| 1303 | /// Network dropped connection on reset | ||
| 1304 | NETRESET = 52, | ||
| 1305 | |||
| 1306 | /// Software caused connection abort | ||
| 1307 | CONNABORTED = 53, | ||
| 1308 | |||
| 1309 | /// Connection reset by peer | ||
| 1310 | CONNRESET = 54, | ||
| 1311 | |||
| 1312 | /// No buffer space available | ||
| 1313 | NOBUFS = 55, | ||
| 1314 | |||
| 1315 | /// Socket is already connected | ||
| 1316 | ISCONN = 56, | ||
| 1317 | |||
| 1318 | /// Socket is not connected | ||
| 1319 | NOTCONN = 57, | ||
| 1320 | |||
| 1321 | /// Can't send after socket shutdown | ||
| 1322 | SHUTDOWN = 58, | ||
| 1323 | |||
| 1324 | /// Too many references: can't splice | ||
| 1325 | TOOMANYREFS = 59, | ||
| 1326 | |||
| 1327 | /// Operation timed out | ||
| 1328 | TIMEDOUT = 60, | ||
| 1329 | |||
| 1330 | /// Connection refused | ||
| 1331 | CONNREFUSED = 61, | ||
| 1332 | |||
| 1333 | /// Too many levels of symbolic links | ||
| 1334 | LOOP = 62, | ||
| 1335 | |||
| 1336 | /// File name too long | ||
| 1337 | NAMETOOLONG = 63, | ||
| 1338 | |||
| 1339 | /// Host is down | ||
| 1340 | HOSTDOWN = 64, | ||
| 1341 | |||
| 1342 | /// No route to host | ||
| 1343 | HOSTUNREACH = 65, | ||
| 1344 | /// Directory not empty | ||
| 1345 | |||
| 1346 | // quotas & mush | ||
| 1347 | NOTEMPTY = 66, | ||
| 1348 | |||
| 1349 | /// Too many processes | ||
| 1350 | PROCLIM = 67, | ||
| 1351 | |||
| 1352 | /// Too many users | ||
| 1353 | USERS = 68, | ||
| 1354 | /// Disc quota exceeded | ||
| 1355 | |||
| 1356 | // Network File System | ||
| 1357 | DQUOT = 69, | ||
| 1358 | |||
| 1359 | /// Stale NFS file handle | ||
| 1360 | STALE = 70, | ||
| 1361 | |||
| 1362 | /// Too many levels of remote in path | ||
| 1363 | REMOTE = 71, | ||
| 1364 | |||
| 1365 | /// RPC struct is bad | ||
| 1366 | BADRPC = 72, | ||
| 1367 | |||
| 1368 | /// RPC version wrong | ||
| 1369 | RPCMISMATCH = 73, | ||
| 1370 | |||
| 1371 | /// RPC prog. not avail | ||
| 1372 | PROGUNAVAIL = 74, | ||
| 1373 | |||
| 1374 | /// Program version wrong | ||
| 1375 | PROGMISMATCH = 75, | ||
| 1376 | |||
| 1377 | /// Bad procedure for program | ||
| 1378 | PROCUNAVAIL = 76, | ||
| 1379 | |||
| 1380 | /// No locks available | ||
| 1381 | NOLCK = 77, | ||
| 1382 | |||
| 1383 | /// Function not implemented | ||
| 1384 | NOSYS = 78, | ||
| 1385 | |||
| 1386 | /// Inappropriate file type or format | ||
| 1387 | FTYPE = 79, | ||
| 1388 | |||
| 1389 | /// Authentication error | ||
| 1390 | AUTH = 80, | ||
| 1391 | |||
| 1392 | /// Need authenticator | ||
| 1393 | NEEDAUTH = 81, | ||
| 1394 | |||
| 1395 | // Intelligent device errors | ||
| 1396 | |||
| 1397 | /// Device power is off | ||
| 1398 | PWROFF = 82, | ||
| 1399 | |||
| 1400 | /// Device error, e.g. paper out | ||
| 1401 | DEVERR = 83, | ||
| 1402 | |||
| 1403 | /// Value too large to be stored in data type | ||
| 1404 | OVERFLOW = 84, | ||
| 1405 | |||
| 1406 | // Program loading errors | ||
| 1407 | |||
| 1408 | /// Bad executable | ||
| 1409 | BADEXEC = 85, | ||
| 1410 | |||
| 1411 | /// Bad CPU type in executable | ||
| 1412 | BADARCH = 86, | ||
| 1413 | |||
| 1414 | /// Shared library version mismatch | ||
| 1415 | SHLIBVERS = 87, | ||
| 1416 | |||
| 1417 | /// Malformed Macho file | ||
| 1418 | BADMACHO = 88, | ||
| 1419 | |||
| 1420 | /// Operation canceled | ||
| 1421 | CANCELED = 89, | ||
| 1422 | |||
| 1423 | /// Identifier removed | ||
| 1424 | IDRM = 90, | ||
| 1425 | |||
| 1426 | /// No message of desired type | ||
| 1427 | NOMSG = 91, | ||
| 1428 | |||
| 1429 | /// Illegal byte sequence | ||
| 1430 | ILSEQ = 92, | ||
| 1431 | |||
| 1432 | /// Attribute not found | ||
| 1433 | NOATTR = 93, | ||
| 1434 | |||
| 1435 | /// Bad message | ||
| 1436 | BADMSG = 94, | ||
| 1437 | |||
| 1438 | /// Reserved | ||
| 1439 | MULTIHOP = 95, | ||
| 1440 | |||
| 1441 | /// No message available on STREAM | ||
| 1442 | NODATA = 96, | ||
| 1443 | |||
| 1444 | /// Reserved | ||
| 1445 | NOLINK = 97, | ||
| 1446 | |||
| 1447 | /// No STREAM resources | ||
| 1448 | NOSR = 98, | ||
| 1449 | |||
| 1450 | /// Not a STREAM | ||
| 1451 | NOSTR = 99, | ||
| 1452 | |||
| 1453 | /// Protocol error | ||
| 1454 | PROTO = 100, | ||
| 1455 | |||
| 1456 | /// STREAM ioctl timeout | ||
| 1457 | TIME = 101, | ||
| 1458 | |||
| 1459 | /// No such policy registered | ||
| 1460 | NOPOLICY = 103, | ||
| 1461 | |||
| 1462 | /// State not recoverable | ||
| 1463 | NOTRECOVERABLE = 104, | ||
| 1464 | |||
| 1465 | /// Previous owner died | ||
| 1466 | OWNERDEAD = 105, | ||
| 1467 | |||
| 1468 | /// Interface output queue is full | ||
| 1469 | QFULL = 106, | ||
| 1470 | |||
| 1471 | _, | ||
| 1472 | }; | ||
| 1473 | |||
| 1474 | pub const SIGSTKSZ = 131072; | ||
| 1475 | pub const MINSIGSTKSZ = 32768; | ||
| 1476 | |||
| 1477 | pub const SS_ONSTACK = 1; | ||
| 1478 | pub const SS_DISABLE = 4; | ||
| 1479 | |||
| 1480 | pub const stack_t = extern struct { | ||
| 1481 | ss_sp: [*]u8, | ||
| 1482 | ss_size: isize, | ||
| 1483 | ss_flags: i32, | ||
| 1484 | }; | ||
| 1485 | |||
| 1486 | pub const S_IFMT = 0o170000; | ||
| 1487 | |||
| 1488 | pub const S_IFIFO = 0o010000; | ||
| 1489 | pub const S_IFCHR = 0o020000; | ||
| 1490 | pub const S_IFDIR = 0o040000; | ||
| 1491 | pub const S_IFBLK = 0o060000; | ||
| 1492 | pub const S_IFREG = 0o100000; | ||
| 1493 | pub const S_IFLNK = 0o120000; | ||
| 1494 | pub const S_IFSOCK = 0o140000; | ||
| 1495 | pub const S_IFWHT = 0o160000; | ||
| 1496 | |||
| 1497 | pub const S_ISUID = 0o4000; | ||
| 1498 | pub const S_ISGID = 0o2000; | ||
| 1499 | pub const S_ISVTX = 0o1000; | ||
| 1500 | pub const S_IRWXU = 0o700; | ||
| 1501 | pub const S_IRUSR = 0o400; | ||
| 1502 | pub const S_IWUSR = 0o200; | ||
| 1503 | pub const S_IXUSR = 0o100; | ||
| 1504 | pub const S_IRWXG = 0o070; | ||
| 1505 | pub const S_IRGRP = 0o040; | ||
| 1506 | pub const S_IWGRP = 0o020; | ||
| 1507 | pub const S_IXGRP = 0o010; | ||
| 1508 | pub const S_IRWXO = 0o007; | ||
| 1509 | pub const S_IROTH = 0o004; | ||
| 1510 | pub const S_IWOTH = 0o002; | ||
| 1511 | pub const S_IXOTH = 0o001; | ||
| 1512 | |||
| 1513 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1514 | return m & S_IFMT == S_IFIFO; | ||
| 1515 | } | ||
| 1516 | |||
| 1517 | pub fn S_ISCHR(m: u32) bool { | ||
| 1518 | return m & S_IFMT == S_IFCHR; | ||
| 1519 | } | ||
| 1520 | |||
| 1521 | pub fn S_ISDIR(m: u32) bool { | ||
| 1522 | return m & S_IFMT == S_IFDIR; | ||
| 1523 | } | ||
| 1524 | |||
| 1525 | pub fn S_ISBLK(m: u32) bool { | ||
| 1526 | return m & S_IFMT == S_IFBLK; | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | pub fn S_ISREG(m: u32) bool { | ||
| 1530 | return m & S_IFMT == S_IFREG; | ||
| 1531 | } | ||
| 1532 | |||
| 1533 | pub fn S_ISLNK(m: u32) bool { | ||
| 1534 | return m & S_IFMT == S_IFLNK; | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1538 | return m & S_IFMT == S_IFSOCK; | ||
| 1539 | } | ||
| 1540 | |||
| 1541 | pub fn S_IWHT(m: u32) bool { | ||
| 1542 | return m & S_IFMT == S_IFWHT; | ||
| 1543 | } | ||
| 1544 | |||
| 1545 | pub const HOST_NAME_MAX = 72; | ||
| 1546 | |||
| 1547 | pub const AT_FDCWD = -2; | ||
| 1548 | |||
| 1549 | /// Use effective ids in access check | ||
| 1550 | pub const AT_EACCESS = 0x0010; | ||
| 1551 | |||
| 1552 | /// Act on the symlink itself not the target | ||
| 1553 | pub const AT_SYMLINK_NOFOLLOW = 0x0020; | ||
| 1554 | |||
| 1555 | /// Act on target of symlink | ||
| 1556 | pub const AT_SYMLINK_FOLLOW = 0x0040; | ||
| 1557 | |||
| 1558 | /// Path refers to directory | ||
| 1559 | pub const AT_REMOVEDIR = 0x0080; | ||
| 1560 | |||
| 1561 | pub const addrinfo = extern struct { | ||
| 1562 | flags: i32, | ||
| 1563 | family: i32, | ||
| 1564 | socktype: i32, | ||
| 1565 | protocol: i32, | ||
| 1566 | addrlen: socklen_t, | ||
| 1567 | canonname: ?[*:0]u8, | ||
| 1568 | addr: ?*sockaddr, | ||
| 1569 | next: ?*addrinfo, | ||
| 1570 | }; | ||
| 1571 | |||
| 1572 | pub const RTLD_LAZY = 0x1; | ||
| 1573 | pub const RTLD_NOW = 0x2; | ||
| 1574 | pub const RTLD_LOCAL = 0x4; | ||
| 1575 | pub const RTLD_GLOBAL = 0x8; | ||
| 1576 | pub const RTLD_NOLOAD = 0x10; | ||
| 1577 | pub const RTLD_NODELETE = 0x80; | ||
| 1578 | pub const RTLD_FIRST = 0x100; | ||
| 1579 | |||
| 1580 | pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); | ||
| 1581 | pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); | ||
| 1582 | pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); | ||
| 1583 | pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5))); | ||
| 1584 | |||
| 1585 | /// duplicate file descriptor | ||
| 1586 | pub const F_DUPFD = 0; | ||
| 1587 | |||
| 1588 | /// get file descriptor flags | ||
| 1589 | pub const F_GETFD = 1; | ||
| 1590 | |||
| 1591 | /// set file descriptor flags | ||
| 1592 | pub const F_SETFD = 2; | ||
| 1593 | |||
| 1594 | /// get file status flags | ||
| 1595 | pub const F_GETFL = 3; | ||
| 1596 | |||
| 1597 | /// set file status flags | ||
| 1598 | pub const F_SETFL = 4; | ||
| 1599 | |||
| 1600 | /// get SIGIO/SIGURG proc/pgrp | ||
| 1601 | pub const F_GETOWN = 5; | ||
| 1602 | |||
| 1603 | /// set SIGIO/SIGURG proc/pgrp | ||
| 1604 | pub const F_SETOWN = 6; | ||
| 1605 | |||
| 1606 | /// get record locking information | ||
| 1607 | pub const F_GETLK = 7; | ||
| 1608 | |||
| 1609 | /// set record locking information | ||
| 1610 | pub const F_SETLK = 8; | ||
| 1611 | |||
| 1612 | /// F_SETLK; wait if blocked | ||
| 1613 | pub const F_SETLKW = 9; | ||
| 1614 | |||
| 1615 | /// F_SETLK; wait if blocked, return on timeout | ||
| 1616 | pub const F_SETLKWTIMEOUT = 10; | ||
| 1617 | pub const F_FLUSH_DATA = 40; | ||
| 1618 | |||
| 1619 | /// Used for regression test | ||
| 1620 | pub const F_CHKCLEAN = 41; | ||
| 1621 | |||
| 1622 | /// Preallocate storage | ||
| 1623 | pub const F_PREALLOCATE = 42; | ||
| 1624 | |||
| 1625 | /// Truncate a file without zeroing space | ||
| 1626 | pub const F_SETSIZE = 43; | ||
| 1627 | |||
| 1628 | /// Issue an advisory read async with no copy to user | ||
| 1629 | pub const F_RDADVISE = 44; | ||
| 1630 | |||
| 1631 | /// turn read ahead off/on for this fd | ||
| 1632 | pub const F_RDAHEAD = 45; | ||
| 1633 | |||
| 1634 | /// turn data caching off/on for this fd | ||
| 1635 | pub const F_NOCACHE = 48; | ||
| 1636 | |||
| 1637 | /// file offset to device offset | ||
| 1638 | pub const F_LOG2PHYS = 49; | ||
| 1639 | |||
| 1640 | /// return the full path of the fd | ||
| 1641 | pub const F_GETPATH = 50; | ||
| 1642 | |||
| 1643 | /// fsync + ask the drive to flush to the media | ||
| 1644 | pub const F_FULLFSYNC = 51; | ||
| 1645 | |||
| 1646 | /// find which component (if any) is a package | ||
| 1647 | pub const F_PATHPKG_CHECK = 52; | ||
| 1648 | |||
| 1649 | /// "freeze" all fs operations | ||
| 1650 | pub const F_FREEZE_FS = 53; | ||
| 1651 | |||
| 1652 | /// "thaw" all fs operations | ||
| 1653 | pub const F_THAW_FS = 54; | ||
| 1654 | |||
| 1655 | /// turn data caching off/on (globally) for this file | ||
| 1656 | pub const F_GLOBAL_NOCACHE = 55; | ||
| 1657 | |||
| 1658 | /// add detached signatures | ||
| 1659 | pub const F_ADDSIGS = 59; | ||
| 1660 | |||
| 1661 | /// add signature from same file (used by dyld for shared libs) | ||
| 1662 | pub const F_ADDFILESIGS = 61; | ||
| 1663 | |||
| 1664 | /// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes | ||
| 1665 | /// should not be used (i.e. its ok to temporaily create cached pages) | ||
| 1666 | pub const F_NODIRECT = 62; | ||
| 1667 | |||
| 1668 | ///Get the protection class of a file from the EA, returns int | ||
| 1669 | pub const F_GETPROTECTIONCLASS = 63; | ||
| 1670 | |||
| 1671 | ///Set the protection class of a file for the EA, requires int | ||
| 1672 | pub const F_SETPROTECTIONCLASS = 64; | ||
| 1673 | |||
| 1674 | ///file offset to device offset, extended | ||
| 1675 | pub const F_LOG2PHYS_EXT = 65; | ||
| 1676 | |||
| 1677 | ///get record locking information, per-process | ||
| 1678 | pub const F_GETLKPID = 66; | ||
| 1679 | |||
| 1680 | ///Mark the file as being the backing store for another filesystem | ||
| 1681 | pub const F_SETBACKINGSTORE = 70; | ||
| 1682 | |||
| 1683 | ///return the full path of the FD, but error in specific mtmd circumstances | ||
| 1684 | pub const F_GETPATH_MTMINFO = 71; | ||
| 1685 | |||
| 1686 | ///Returns the code directory, with associated hashes, to the caller | ||
| 1687 | pub const F_GETCODEDIR = 72; | ||
| 1688 | |||
| 1689 | ///No SIGPIPE generated on EPIPE | ||
| 1690 | pub const F_SETNOSIGPIPE = 73; | ||
| 1691 | |||
| 1692 | ///Status of SIGPIPE for this fd | ||
| 1693 | pub const F_GETNOSIGPIPE = 74; | ||
| 1694 | |||
| 1695 | ///For some cases, we need to rewrap the key for AKS/MKB | ||
| 1696 | pub const F_TRANSCODEKEY = 75; | ||
| 1697 | |||
| 1698 | ///file being written to a by single writer... if throttling enabled, writes | ||
| 1699 | ///may be broken into smaller chunks with throttling in between | ||
| 1700 | pub const F_SINGLE_WRITER = 76; | ||
| 1701 | |||
| 1702 | ///Get the protection version number for this filesystem | ||
| 1703 | pub const F_GETPROTECTIONLEVEL = 77; | ||
| 1704 | |||
| 1705 | ///Add detached code signatures (used by dyld for shared libs) | ||
| 1706 | pub const F_FINDSIGS = 78; | ||
| 1707 | |||
| 1708 | ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator) | ||
| 1709 | pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83; | ||
| 1710 | |||
| 1711 | ///fsync + issue barrier to drive | ||
| 1712 | pub const F_BARRIERFSYNC = 85; | ||
| 1713 | |||
| 1714 | ///Add signature from same file, return end offset in structure on success | ||
| 1715 | pub const F_ADDFILESIGS_RETURN = 97; | ||
| 1716 | |||
| 1717 | ///Check if Library Validation allows this Mach-O file to be mapped into the calling process | ||
| 1718 | pub const F_CHECK_LV = 98; | ||
| 1719 | |||
| 1720 | ///Deallocate a range of the file | ||
| 1721 | pub const F_PUNCHHOLE = 99; | ||
| 1722 | |||
| 1723 | ///Trim an active file | ||
| 1724 | pub const F_TRIM_ACTIVE_FILE = 100; | ||
| 1725 | |||
| 1726 | pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000; | ||
| 1727 | |||
| 1728 | ///mark the dup with FD_CLOEXEC | ||
| 1729 | pub const F_DUPFD_CLOEXEC = 67; | ||
| 1730 | |||
| 1731 | ///close-on-exec flag | ||
| 1732 | pub const FD_CLOEXEC = 1; | ||
| 1733 | |||
| 1734 | /// shared or read lock | ||
| 1735 | pub const F_RDLCK = 1; | ||
| 1736 | |||
| 1737 | /// unlock | ||
| 1738 | pub const F_UNLCK = 2; | ||
| 1739 | |||
| 1740 | /// exclusive or write lock | ||
| 1741 | pub const F_WRLCK = 3; | ||
| 1742 | |||
| 1743 | pub const LOCK_SH = 1; | ||
| 1744 | pub const LOCK_EX = 2; | ||
| 1745 | pub const LOCK_UN = 8; | ||
| 1746 | pub const LOCK_NB = 4; | ||
| 1747 | |||
| 1748 | pub const nfds_t = u32; | ||
| 1749 | pub const pollfd = extern struct { | ||
| 1750 | fd: fd_t, | ||
| 1751 | events: i16, | ||
| 1752 | revents: i16, | ||
| 1753 | }; | ||
| 1754 | |||
| 1755 | pub const POLLIN = 0x001; | ||
| 1756 | pub const POLLPRI = 0x002; | ||
| 1757 | pub const POLLOUT = 0x004; | ||
| 1758 | pub const POLLRDNORM = 0x040; | ||
| 1759 | pub const POLLWRNORM = POLLOUT; | ||
| 1760 | pub const POLLRDBAND = 0x080; | ||
| 1761 | pub const POLLWRBAND = 0x100; | ||
| 1762 | |||
| 1763 | pub const POLLEXTEND = 0x0200; | ||
| 1764 | pub const POLLATTRIB = 0x0400; | ||
| 1765 | pub const POLLNLINK = 0x0800; | ||
| 1766 | pub const POLLWRITE = 0x1000; | ||
| 1767 | |||
| 1768 | pub const POLLERR = 0x008; | ||
| 1769 | pub const POLLHUP = 0x010; | ||
| 1770 | pub const POLLNVAL = 0x020; | ||
| 1771 | |||
| 1772 | pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; | ||
| 1773 | |||
| 1774 | pub const CLOCK_REALTIME = 0; | ||
| 1775 | pub const CLOCK_MONOTONIC = 6; | ||
| 1776 | pub const CLOCK_MONOTONIC_RAW = 4; | ||
| 1777 | pub const CLOCK_MONOTONIC_RAW_APPROX = 5; | ||
| 1778 | pub const CLOCK_UPTIME_RAW = 8; | ||
| 1779 | pub const CLOCK_UPTIME_RAW_APPROX = 9; | ||
| 1780 | pub const CLOCK_PROCESS_CPUTIME_ID = 12; | ||
| 1781 | pub const CLOCK_THREAD_CPUTIME_ID = 16; | ||
| 1782 | |||
| 1783 | /// Max open files per process | ||
| 1784 | /// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html | ||
| 1785 | pub const OPEN_MAX = 10240; | ||
| 1786 | pub const RUSAGE_SELF = 0; | ||
| 1787 | pub const RUSAGE_CHILDREN = -1; | ||
| 1788 | |||
| 1789 | pub const rusage = extern struct { | ||
| 1790 | utime: timeval, | ||
| 1791 | stime: timeval, | ||
| 1792 | maxrss: isize, | ||
| 1793 | ixrss: isize, | ||
| 1794 | idrss: isize, | ||
| 1795 | isrss: isize, | ||
| 1796 | minflt: isize, | ||
| 1797 | majflt: isize, | ||
| 1798 | nswap: isize, | ||
| 1799 | inblock: isize, | ||
| 1800 | oublock: isize, | ||
| 1801 | msgsnd: isize, | ||
| 1802 | msgrcv: isize, | ||
| 1803 | nsignals: isize, | ||
| 1804 | nvcsw: isize, | ||
| 1805 | nivcsw: isize, | ||
| 1806 | }; | ||
| 1807 | |||
| 1808 | pub const rlimit_resource = enum(c_int) { | ||
| 1809 | CPU = 0, | ||
| 1810 | FSIZE = 1, | ||
| 1811 | DATA = 2, | ||
| 1812 | STACK = 3, | ||
| 1813 | CORE = 4, | ||
| 1814 | RSS = 5, | ||
| 1815 | MEMLOCK = 6, | ||
| 1816 | NPROC = 7, | ||
| 1817 | NOFILE = 8, | ||
| 1818 | _, | ||
| 1819 | |||
| 1820 | pub const AS: rlimit_resource = .RSS; | ||
| 1821 | }; | ||
| 1822 | |||
| 1823 | pub const rlim_t = u64; | ||
| 1824 | |||
| 1825 | /// No limit | ||
| 1826 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1827 | |||
| 1828 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1829 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1830 | |||
| 1831 | pub const rlimit = extern struct { | ||
| 1832 | /// Soft limit | ||
| 1833 | cur: rlim_t, | ||
| 1834 | /// Hard limit | ||
| 1835 | max: rlim_t, | ||
| 1836 | }; | ||
| 1837 | |||
| 1838 | pub const SHUT_RD = 0; | ||
| 1839 | pub const SHUT_WR = 1; | ||
| 1840 | pub const SHUT_RDWR = 2; | ||
| 1841 | |||
| 1842 | // Term | ||
| 1843 | pub const VEOF = 0; | ||
| 1844 | pub const VEOL = 1; | ||
| 1845 | pub const VEOL2 = 2; | ||
| 1846 | pub const VERASE = 3; | ||
| 1847 | pub const VWERASE = 4; | ||
| 1848 | pub const VKILL = 5; | ||
| 1849 | pub const VREPRINT = 6; | ||
| 1850 | pub const VINTR = 8; | ||
| 1851 | pub const VQUIT = 9; | ||
| 1852 | pub const VSUSP = 10; | ||
| 1853 | pub const VDSUSP = 11; | ||
| 1854 | pub const VSTART = 12; | ||
| 1855 | pub const VSTOP = 13; | ||
| 1856 | pub const VLNEXT = 14; | ||
| 1857 | pub const VDISCARD = 15; | ||
| 1858 | pub const VMIN = 16; | ||
| 1859 | pub const VTIME = 17; | ||
| 1860 | pub const VSTATUS = 18; | ||
| 1861 | pub const NCCS = 20; // 2 spares (7, 19) | ||
| 1862 | |||
| 1863 | pub const IGNBRK = 0x00000001; // ignore BREAK condition | ||
| 1864 | pub const BRKINT = 0x00000002; // map BREAK to SIGINTR | ||
| 1865 | pub const IGNPAR = 0x00000004; // ignore (discard) parity errors | ||
| 1866 | pub const PARMRK = 0x00000008; // mark parity and framing errors | ||
| 1867 | pub const INPCK = 0x00000010; // enable checking of parity errors | ||
| 1868 | pub const ISTRIP = 0x00000020; // strip 8th bit off chars | ||
| 1869 | pub const INLCR = 0x00000040; // map NL into CR | ||
| 1870 | pub const IGNCR = 0x00000080; // ignore CR | ||
| 1871 | pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD) | ||
| 1872 | pub const IXON = 0x00000200; // enable output flow control | ||
| 1873 | pub const IXOFF = 0x00000400; // enable input flow control | ||
| 1874 | pub const IXANY = 0x00000800; // any char will restart after stop | ||
| 1875 | pub const IMAXBEL = 0x00002000; // ring bell on input queue full | ||
| 1876 | pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE | ||
| 1877 | |||
| 1878 | pub const OPOST = 0x00000001; //enable following output processing | ||
| 1879 | pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD) | ||
| 1880 | pub const OXTABS = 0x00000004; // expand tabs to spaces | ||
| 1881 | pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output) | ||
| 1882 | |||
| 1883 | pub const OCRNL = 0x00000010; // map CR to NL on output | ||
| 1884 | pub const ONOCR = 0x00000020; // no CR output at column 0 | ||
| 1885 | pub const ONLRET = 0x00000040; // NL performs CR function | ||
| 1886 | pub const OFILL = 0x00000080; // use fill characters for delay | ||
| 1887 | pub const NLDLY = 0x00000300; // \n delay | ||
| 1888 | pub const TABDLY = 0x00000c04; // horizontal tab delay | ||
| 1889 | pub const CRDLY = 0x00003000; // \r delay | ||
| 1890 | pub const FFDLY = 0x00004000; // form feed delay | ||
| 1891 | pub const BSDLY = 0x00008000; // \b delay | ||
| 1892 | pub const VTDLY = 0x00010000; // vertical tab delay | ||
| 1893 | pub const OFDEL = 0x00020000; // fill is DEL, else NUL | ||
| 1894 | |||
| 1895 | pub const NL0 = 0x00000000; | ||
| 1896 | pub const NL1 = 0x00000100; | ||
| 1897 | pub const NL2 = 0x00000200; | ||
| 1898 | pub const NL3 = 0x00000300; | ||
| 1899 | pub const TAB0 = 0x00000000; | ||
| 1900 | pub const TAB1 = 0x00000400; | ||
| 1901 | pub const TAB2 = 0x00000800; | ||
| 1902 | pub const TAB3 = 0x00000004; | ||
| 1903 | pub const CR0 = 0x00000000; | ||
| 1904 | pub const CR1 = 0x00001000; | ||
| 1905 | pub const CR2 = 0x00002000; | ||
| 1906 | pub const CR3 = 0x00003000; | ||
| 1907 | pub const FF0 = 0x00000000; | ||
| 1908 | pub const FF1 = 0x00004000; | ||
| 1909 | pub const BS0 = 0x00000000; | ||
| 1910 | pub const BS1 = 0x00008000; | ||
| 1911 | pub const VT0 = 0x00000000; | ||
| 1912 | pub const VT1 = 0x00010000; | ||
| 1913 | |||
| 1914 | pub const CIGNORE = 0x00000001; // ignore control flags | ||
| 1915 | pub const CSIZE = 0x00000300; // character size mask | ||
| 1916 | pub const CS5 = 0x00000000; // 5 bits (pseudo) | ||
| 1917 | pub const CS6 = 0x00000100; // 6 bits | ||
| 1918 | pub const CS7 = 0x00000200; // 7 bits | ||
| 1919 | pub const CS8 = 0x00000300; // 8 bits | ||
| 1920 | pub const CSTOPB = 0x0000040; // send 2 stop bits | ||
| 1921 | pub const CREAD = 0x00000800; // enable receiver | ||
| 1922 | pub const PARENB = 0x00001000; // parity enable | ||
| 1923 | pub const PARODD = 0x00002000; // odd parity, else even | ||
| 1924 | pub const HUPCL = 0x00004000; // hang up on last close | ||
| 1925 | pub const CLOCAL = 0x00008000; // ignore modem status lines | ||
| 1926 | pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output | ||
| 1927 | pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW); | ||
| 1928 | pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input | ||
| 1929 | pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input | ||
| 1930 | pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output | ||
| 1931 | pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output | ||
| 1932 | pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW | ||
| 1933 | |||
| 1934 | pub const ECHOKE = 0x00000001; // visual erase for line kill | ||
| 1935 | pub const ECHOE = 0x00000002; // visually erase chars | ||
| 1936 | pub const ECHOK = 0x00000004; // echo NL after line kill | ||
| 1937 | pub const ECHO = 0x00000008; // enable echoing | ||
| 1938 | pub const ECHONL = 0x00000010; // echo NL even if ECHO is off | ||
| 1939 | pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy | ||
| 1940 | pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char) | ||
| 1941 | pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP | ||
| 1942 | pub const ICANON = 0x00000100; // canonicalize input lines | ||
| 1943 | pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm | ||
| 1944 | pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT | ||
| 1945 | pub const EXTPROC = 0x00000800; // external processing | ||
| 1946 | pub const TOSTOP = 0x00400000; // stop background jobs from output | ||
| 1947 | pub const FLUSHO = 0x00800000; // output being flushed (state) | ||
| 1948 | pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS | ||
| 1949 | pub const PENDIN = 0x20000000; // XXX retype pending input (state) | ||
| 1950 | pub const NOFLSH = 0x80000000; // don't flush after interrupt | ||
| 1951 | |||
| 1952 | pub const TCSANOW = 0; // make change immediate | ||
| 1953 | pub const TCSADRAIN = 1; // drain output, then change | ||
| 1954 | pub const TCSAFLUSH = 2; // drain output, flush input | ||
| 1955 | pub const TCSASOFT = 0x10; // flag - don't alter h.w. state | ||
| 1956 | pub const TCSA = enum(c_uint) { | ||
| 1957 | NOW, | ||
| 1958 | DRAIN, | ||
| 1959 | FLUSH, | ||
| 1960 | _, | ||
| 1961 | }; | ||
| 1962 | |||
| 1963 | pub const B0 = 0; | ||
| 1964 | pub const B50 = 50; | ||
| 1965 | pub const B75 = 75; | ||
| 1966 | pub const B110 = 110; | ||
| 1967 | pub const B134 = 134; | ||
| 1968 | pub const B150 = 150; | ||
| 1969 | pub const B200 = 200; | ||
| 1970 | pub const B300 = 300; | ||
| 1971 | pub const B600 = 600; | ||
| 1972 | pub const B1200 = 1200; | ||
| 1973 | pub const B1800 = 1800; | ||
| 1974 | pub const B2400 = 2400; | ||
| 1975 | pub const B4800 = 4800; | ||
| 1976 | pub const B9600 = 9600; | ||
| 1977 | pub const B19200 = 19200; | ||
| 1978 | pub const B38400 = 38400; | ||
| 1979 | pub const B7200 = 7200; | ||
| 1980 | pub const B14400 = 14400; | ||
| 1981 | pub const B28800 = 28800; | ||
| 1982 | pub const B57600 = 57600; | ||
| 1983 | pub const B76800 = 76800; | ||
| 1984 | pub const B115200 = 115200; | ||
| 1985 | pub const B230400 = 230400; | ||
| 1986 | pub const EXTA = 19200; | ||
| 1987 | pub const EXTB = 38400; | ||
| 1988 | |||
| 1989 | pub const TCIFLUSH = 1; | ||
| 1990 | pub const TCOFLUSH = 2; | ||
| 1991 | pub const TCIOFLUSH = 3; | ||
| 1992 | pub const TCOOFF = 1; | ||
| 1993 | pub const TCOON = 2; | ||
| 1994 | pub const TCIOFF = 3; | ||
| 1995 | pub const TCION = 4; | ||
| 1996 | |||
| 1997 | pub const cc_t = u8; | ||
| 1998 | pub const speed_t = u64; | ||
| 1999 | pub const tcflag_t = u64; | ||
| 2000 | |||
| 2001 | pub const termios = extern struct { | ||
| 2002 | iflag: tcflag_t, // input flags | ||
| 2003 | oflag: tcflag_t, // output flags | ||
| 2004 | cflag: tcflag_t, // control flags | ||
| 2005 | lflag: tcflag_t, // local flags | ||
| 2006 | cc: [NCCS]cc_t, // control chars | ||
| 2007 | ispeed: speed_t align(8), // input speed | ||
| 2008 | ospeed: speed_t, // output speed | ||
| 2009 | }; | ||
| 2010 | |||
| 2011 | pub const winsize = extern struct { | ||
| 2012 | ws_row: u16, | ||
| 2013 | ws_col: u16, | ||
| 2014 | ws_xpixel: u16, | ||
| 2015 | ws_ypixel: u16, | ||
| 2016 | }; | ||
| 2017 | |||
| 2018 | pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); | ||
| 2019 | pub const IOCPARM_MASK = 0x1fff; | ||
| 2020 | |||
| 2021 | fn ior(inout: u32, group: usize, num: usize, len: usize) usize { | ||
| 2022 | return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)); | ||
| 2023 | } | ||
| 2024 | |||
| 2025 | // CPU families mapping | ||
| 2026 | pub const CPUFAMILY = enum(u32) { | ||
| 2027 | UNKNOWN = 0, | ||
| 2028 | POWERPC_G3 = 0xcee41549, | ||
| 2029 | POWERPC_G4 = 0x77c184ae, | ||
| 2030 | POWERPC_G5 = 0xed76d8aa, | ||
| 2031 | INTEL_6_13 = 0xaa33392b, | ||
| 2032 | INTEL_PENRYN = 0x78ea4fbc, | ||
| 2033 | INTEL_NEHALEM = 0x6b5a4cd2, | ||
| 2034 | INTEL_WESTMERE = 0x573b5eec, | ||
| 2035 | INTEL_SANDYBRIDGE = 0x5490b78c, | ||
| 2036 | INTEL_IVYBRIDGE = 0x1f65e835, | ||
| 2037 | INTEL_HASWELL = 0x10b282dc, | ||
| 2038 | INTEL_BROADWELL = 0x582ed09c, | ||
| 2039 | INTEL_SKYLAKE = 0x37fc219f, | ||
| 2040 | INTEL_KABYLAKE = 0x0f817246, | ||
| 2041 | ARM_9 = 0xe73283ae, | ||
| 2042 | ARM_11 = 0x8ff620d8, | ||
| 2043 | ARM_XSCALE = 0x53b005f5, | ||
| 2044 | ARM_12 = 0xbd1b0ae9, | ||
| 2045 | ARM_13 = 0x0cc90e64, | ||
| 2046 | ARM_14 = 0x96077ef1, | ||
| 2047 | ARM_15 = 0xa8511bca, | ||
| 2048 | ARM_SWIFT = 0x1e2d6381, | ||
| 2049 | ARM_CYCLONE = 0x37a09642, | ||
| 2050 | ARM_TYPHOON = 0x2c91a47e, | ||
| 2051 | ARM_TWISTER = 0x92fb37c8, | ||
| 2052 | ARM_HURRICANE = 0x67ceee93, | ||
| 2053 | ARM_MONSOON_MISTRAL = 0xe81e7ef6, | ||
| 2054 | ARM_VORTEX_TEMPEST = 0x07d34b9f, | ||
| 2055 | ARM_LIGHTNING_THUNDER = 0x462504d2, | ||
| 2056 | ARM_FIRESTORM_ICESTORM = 0x1b588bb3, | ||
| 2057 | _, | ||
| 2058 | }; |
lib/std/c/dragonfly.zig+1031-1| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | usingnamespace std.c; | 2 | const maxInt = std.math.maxInt; |
| 3 | |||
| 3 | extern "c" threadlocal var errno: c_int; | 4 | extern "c" threadlocal var errno: c_int; |
| 4 | pub fn _errno() *c_int { | 5 | pub fn _errno() *c_int { |
| 5 | return &errno; | 6 | return &errno; |
| ... | @@ -30,3 +31,1032 @@ pub const pthread_attr_t = extern struct { // copied from freebsd | ... | @@ -30,3 +31,1032 @@ pub const pthread_attr_t = extern struct { // copied from freebsd |
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | pub const sem_t = ?*opaque {}; | 33 | pub const sem_t = ?*opaque {}; |
| 34 | |||
| 35 | pub fn S_ISCHR(m: u32) bool { | ||
| 36 | return m & S_IFMT == S_IFCHR; | ||
| 37 | } | ||
| 38 | |||
| 39 | // See: | ||
| 40 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h | ||
| 41 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h | ||
| 42 | // TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well | ||
| 43 | pub const fd_t = c_int; | ||
| 44 | pub const pid_t = c_int; | ||
| 45 | pub const off_t = c_long; | ||
| 46 | pub const mode_t = c_uint; | ||
| 47 | pub const uid_t = u32; | ||
| 48 | pub const gid_t = u32; | ||
| 49 | pub const time_t = isize; | ||
| 50 | pub const suseconds_t = c_long; | ||
| 51 | |||
| 52 | pub const E = enum(u16) { | ||
| 53 | /// No error occurred. | ||
| 54 | SUCCESS = 0, | ||
| 55 | |||
| 56 | PERM = 1, | ||
| 57 | NOENT = 2, | ||
| 58 | SRCH = 3, | ||
| 59 | INTR = 4, | ||
| 60 | IO = 5, | ||
| 61 | NXIO = 6, | ||
| 62 | @"2BIG" = 7, | ||
| 63 | NOEXEC = 8, | ||
| 64 | BADF = 9, | ||
| 65 | CHILD = 10, | ||
| 66 | DEADLK = 11, | ||
| 67 | NOMEM = 12, | ||
| 68 | ACCES = 13, | ||
| 69 | FAULT = 14, | ||
| 70 | NOTBLK = 15, | ||
| 71 | BUSY = 16, | ||
| 72 | EXIST = 17, | ||
| 73 | XDEV = 18, | ||
| 74 | NODEV = 19, | ||
| 75 | NOTDIR = 20, | ||
| 76 | ISDIR = 21, | ||
| 77 | INVAL = 22, | ||
| 78 | NFILE = 23, | ||
| 79 | MFILE = 24, | ||
| 80 | NOTTY = 25, | ||
| 81 | TXTBSY = 26, | ||
| 82 | FBIG = 27, | ||
| 83 | NOSPC = 28, | ||
| 84 | SPIPE = 29, | ||
| 85 | ROFS = 30, | ||
| 86 | MLINK = 31, | ||
| 87 | PIPE = 32, | ||
| 88 | DOM = 33, | ||
| 89 | RANGE = 34, | ||
| 90 | /// This code is also used for `WOULDBLOCK`. | ||
| 91 | AGAIN = 35, | ||
| 92 | INPROGRESS = 36, | ||
| 93 | ALREADY = 37, | ||
| 94 | NOTSOCK = 38, | ||
| 95 | DESTADDRREQ = 39, | ||
| 96 | MSGSIZE = 40, | ||
| 97 | PROTOTYPE = 41, | ||
| 98 | NOPROTOOPT = 42, | ||
| 99 | PROTONOSUPPORT = 43, | ||
| 100 | SOCKTNOSUPPORT = 44, | ||
| 101 | /// This code is also used for `NOTSUP`. | ||
| 102 | OPNOTSUPP = 45, | ||
| 103 | PFNOSUPPORT = 46, | ||
| 104 | AFNOSUPPORT = 47, | ||
| 105 | ADDRINUSE = 48, | ||
| 106 | ADDRNOTAVAIL = 49, | ||
| 107 | NETDOWN = 50, | ||
| 108 | NETUNREACH = 51, | ||
| 109 | NETRESET = 52, | ||
| 110 | CONNABORTED = 53, | ||
| 111 | CONNRESET = 54, | ||
| 112 | NOBUFS = 55, | ||
| 113 | ISCONN = 56, | ||
| 114 | NOTCONN = 57, | ||
| 115 | SHUTDOWN = 58, | ||
| 116 | TOOMANYREFS = 59, | ||
| 117 | TIMEDOUT = 60, | ||
| 118 | CONNREFUSED = 61, | ||
| 119 | LOOP = 62, | ||
| 120 | NAMETOOLONG = 63, | ||
| 121 | HOSTDOWN = 64, | ||
| 122 | HOSTUNREACH = 65, | ||
| 123 | NOTEMPTY = 66, | ||
| 124 | PROCLIM = 67, | ||
| 125 | USERS = 68, | ||
| 126 | DQUOT = 69, | ||
| 127 | STALE = 70, | ||
| 128 | REMOTE = 71, | ||
| 129 | BADRPC = 72, | ||
| 130 | RPCMISMATCH = 73, | ||
| 131 | PROGUNAVAIL = 74, | ||
| 132 | PROGMISMATCH = 75, | ||
| 133 | PROCUNAVAIL = 76, | ||
| 134 | NOLCK = 77, | ||
| 135 | NOSYS = 78, | ||
| 136 | FTYPE = 79, | ||
| 137 | AUTH = 80, | ||
| 138 | NEEDAUTH = 81, | ||
| 139 | IDRM = 82, | ||
| 140 | NOMSG = 83, | ||
| 141 | OVERFLOW = 84, | ||
| 142 | CANCELED = 85, | ||
| 143 | ILSEQ = 86, | ||
| 144 | NOATTR = 87, | ||
| 145 | DOOFUS = 88, | ||
| 146 | BADMSG = 89, | ||
| 147 | MULTIHOP = 90, | ||
| 148 | NOLINK = 91, | ||
| 149 | PROTO = 92, | ||
| 150 | NOMEDIUM = 93, | ||
| 151 | ASYNC = 99, | ||
| 152 | _, | ||
| 153 | }; | ||
| 154 | |||
| 155 | pub const STDIN_FILENO = 0; | ||
| 156 | pub const STDOUT_FILENO = 1; | ||
| 157 | pub const STDERR_FILENO = 2; | ||
| 158 | |||
| 159 | pub const PROT_NONE = 0; | ||
| 160 | pub const PROT_READ = 1; | ||
| 161 | pub const PROT_WRITE = 2; | ||
| 162 | pub const PROT_EXEC = 4; | ||
| 163 | |||
| 164 | pub const MAP_FILE = 0; | ||
| 165 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 166 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 167 | pub const MAP_COPY = MAP_PRIVATE; | ||
| 168 | pub const MAP_SHARED = 1; | ||
| 169 | pub const MAP_PRIVATE = 2; | ||
| 170 | pub const MAP_FIXED = 16; | ||
| 171 | pub const MAP_RENAME = 32; | ||
| 172 | pub const MAP_NORESERVE = 64; | ||
| 173 | pub const MAP_INHERIT = 128; | ||
| 174 | pub const MAP_NOEXTEND = 256; | ||
| 175 | pub const MAP_HASSEMAPHORE = 512; | ||
| 176 | pub const MAP_STACK = 1024; | ||
| 177 | pub const MAP_NOSYNC = 2048; | ||
| 178 | pub const MAP_ANON = 4096; | ||
| 179 | pub const MAP_VPAGETABLE = 8192; | ||
| 180 | pub const MAP_TRYFIXED = 65536; | ||
| 181 | pub const MAP_NOCORE = 131072; | ||
| 182 | pub const MAP_SIZEALIGN = 262144; | ||
| 183 | |||
| 184 | pub const WNOHANG = 0x0001; | ||
| 185 | pub const WUNTRACED = 0x0002; | ||
| 186 | pub const WCONTINUED = 0x0004; | ||
| 187 | pub const WSTOPPED = WUNTRACED; | ||
| 188 | pub const WNOWAIT = 0x0008; | ||
| 189 | pub const WEXITED = 0x0010; | ||
| 190 | pub const WTRAPPED = 0x0020; | ||
| 191 | |||
| 192 | pub const SA_ONSTACK = 0x0001; | ||
| 193 | pub const SA_RESTART = 0x0002; | ||
| 194 | pub const SA_RESETHAND = 0x0004; | ||
| 195 | pub const SA_NODEFER = 0x0010; | ||
| 196 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 197 | pub const SA_SIGINFO = 0x0040; | ||
| 198 | |||
| 199 | pub const PATH_MAX = 1024; | ||
| 200 | pub const IOV_MAX = KERN_IOV_MAX; | ||
| 201 | |||
| 202 | pub const ino_t = c_ulong; | ||
| 203 | |||
| 204 | pub const Stat = extern struct { | ||
| 205 | ino: ino_t, | ||
| 206 | nlink: c_uint, | ||
| 207 | dev: c_uint, | ||
| 208 | mode: c_ushort, | ||
| 209 | padding1: u16, | ||
| 210 | uid: uid_t, | ||
| 211 | gid: gid_t, | ||
| 212 | rdev: c_uint, | ||
| 213 | atim: timespec, | ||
| 214 | mtim: timespec, | ||
| 215 | ctim: timespec, | ||
| 216 | size: c_ulong, | ||
| 217 | blocks: i64, | ||
| 218 | blksize: u32, | ||
| 219 | flags: u32, | ||
| 220 | gen: u32, | ||
| 221 | lspare: i32, | ||
| 222 | qspare1: i64, | ||
| 223 | qspare2: i64, | ||
| 224 | pub fn atime(self: @This()) timespec { | ||
| 225 | return self.atim; | ||
| 226 | } | ||
| 227 | |||
| 228 | pub fn mtime(self: @This()) timespec { | ||
| 229 | return self.mtim; | ||
| 230 | } | ||
| 231 | |||
| 232 | pub fn ctime(self: @This()) timespec { | ||
| 233 | return self.ctim; | ||
| 234 | } | ||
| 235 | }; | ||
| 236 | |||
| 237 | pub const timespec = extern struct { | ||
| 238 | tv_sec: c_long, | ||
| 239 | tv_nsec: c_long, | ||
| 240 | }; | ||
| 241 | |||
| 242 | pub const timeval = extern struct { | ||
| 243 | /// seconds | ||
| 244 | tv_sec: time_t, | ||
| 245 | /// microseconds | ||
| 246 | tv_usec: suseconds_t, | ||
| 247 | }; | ||
| 248 | |||
| 249 | pub const CTL_UNSPEC = 0; | ||
| 250 | pub const CTL_KERN = 1; | ||
| 251 | pub const CTL_VM = 2; | ||
| 252 | pub const CTL_VFS = 3; | ||
| 253 | pub const CTL_NET = 4; | ||
| 254 | pub const CTL_DEBUG = 5; | ||
| 255 | pub const CTL_HW = 6; | ||
| 256 | pub const CTL_MACHDEP = 7; | ||
| 257 | pub const CTL_USER = 8; | ||
| 258 | pub const CTL_LWKT = 10; | ||
| 259 | pub const CTL_MAXID = 11; | ||
| 260 | pub const CTL_MAXNAME = 12; | ||
| 261 | |||
| 262 | pub const KERN_PROC_ALL = 0; | ||
| 263 | pub const KERN_OSTYPE = 1; | ||
| 264 | pub const KERN_PROC_PID = 1; | ||
| 265 | pub const KERN_OSRELEASE = 2; | ||
| 266 | pub const KERN_PROC_PGRP = 2; | ||
| 267 | pub const KERN_OSREV = 3; | ||
| 268 | pub const KERN_PROC_SESSION = 3; | ||
| 269 | pub const KERN_VERSION = 4; | ||
| 270 | pub const KERN_PROC_TTY = 4; | ||
| 271 | pub const KERN_MAXVNODES = 5; | ||
| 272 | pub const KERN_PROC_UID = 5; | ||
| 273 | pub const KERN_MAXPROC = 6; | ||
| 274 | pub const KERN_PROC_RUID = 6; | ||
| 275 | pub const KERN_MAXFILES = 7; | ||
| 276 | pub const KERN_PROC_ARGS = 7; | ||
| 277 | pub const KERN_ARGMAX = 8; | ||
| 278 | pub const KERN_PROC_CWD = 8; | ||
| 279 | pub const KERN_PROC_PATHNAME = 9; | ||
| 280 | pub const KERN_SECURELVL = 9; | ||
| 281 | pub const KERN_PROC_SIGTRAMP = 10; | ||
| 282 | pub const KERN_HOSTNAME = 10; | ||
| 283 | pub const KERN_HOSTID = 11; | ||
| 284 | pub const KERN_CLOCKRATE = 12; | ||
| 285 | pub const KERN_VNODE = 13; | ||
| 286 | pub const KERN_PROC = 14; | ||
| 287 | pub const KERN_FILE = 15; | ||
| 288 | pub const KERN_PROC_FLAGMASK = 16; | ||
| 289 | pub const KERN_PROF = 16; | ||
| 290 | pub const KERN_PROC_FLAG_LWP = 16; | ||
| 291 | pub const KERN_POSIX1 = 17; | ||
| 292 | pub const KERN_NGROUPS = 18; | ||
| 293 | pub const KERN_JOB_CONTROL = 19; | ||
| 294 | pub const KERN_SAVED_IDS = 20; | ||
| 295 | pub const KERN_BOOTTIME = 21; | ||
| 296 | pub const KERN_NISDOMAINNAME = 22; | ||
| 297 | pub const KERN_UPDATEINTERVAL = 23; | ||
| 298 | pub const KERN_OSRELDATE = 24; | ||
| 299 | pub const KERN_NTP_PLL = 25; | ||
| 300 | pub const KERN_BOOTFILE = 26; | ||
| 301 | pub const KERN_MAXFILESPERPROC = 27; | ||
| 302 | pub const KERN_MAXPROCPERUID = 28; | ||
| 303 | pub const KERN_DUMPDEV = 29; | ||
| 304 | pub const KERN_IPC = 30; | ||
| 305 | pub const KERN_DUMMY = 31; | ||
| 306 | pub const KERN_PS_STRINGS = 32; | ||
| 307 | pub const KERN_USRSTACK = 33; | ||
| 308 | pub const KERN_LOGSIGEXIT = 34; | ||
| 309 | pub const KERN_IOV_MAX = 35; | ||
| 310 | pub const KERN_MAXPOSIXLOCKSPERUID = 36; | ||
| 311 | pub const KERN_MAXID = 37; | ||
| 312 | |||
| 313 | pub const HOST_NAME_MAX = 255; | ||
| 314 | |||
| 315 | // access function | ||
| 316 | pub const F_OK = 0; // test for existence of file | ||
| 317 | pub const X_OK = 1; // test for execute or search permission | ||
| 318 | pub const W_OK = 2; // test for write permission | ||
| 319 | pub const R_OK = 4; // test for read permission | ||
| 320 | |||
| 321 | pub const O_RDONLY = 0; | ||
| 322 | pub const O_NDELAY = O_NONBLOCK; | ||
| 323 | pub const O_WRONLY = 1; | ||
| 324 | pub const O_RDWR = 2; | ||
| 325 | pub const O_ACCMODE = 3; | ||
| 326 | pub const O_NONBLOCK = 4; | ||
| 327 | pub const O_APPEND = 8; | ||
| 328 | pub const O_SHLOCK = 16; | ||
| 329 | pub const O_EXLOCK = 32; | ||
| 330 | pub const O_ASYNC = 64; | ||
| 331 | pub const O_FSYNC = 128; | ||
| 332 | pub const O_SYNC = 128; | ||
| 333 | pub const O_NOFOLLOW = 256; | ||
| 334 | pub const O_CREAT = 512; | ||
| 335 | pub const O_TRUNC = 1024; | ||
| 336 | pub const O_EXCL = 2048; | ||
| 337 | pub const O_NOCTTY = 32768; | ||
| 338 | pub const O_DIRECT = 65536; | ||
| 339 | pub const O_CLOEXEC = 131072; | ||
| 340 | pub const O_FBLOCKING = 262144; | ||
| 341 | pub const O_FNONBLOCKING = 524288; | ||
| 342 | pub const O_FAPPEND = 1048576; | ||
| 343 | pub const O_FOFFSET = 2097152; | ||
| 344 | pub const O_FSYNCWRITE = 4194304; | ||
| 345 | pub const O_FASYNCWRITE = 8388608; | ||
| 346 | pub const O_DIRECTORY = 134217728; | ||
| 347 | |||
| 348 | pub const SEEK_SET = 0; | ||
| 349 | pub const SEEK_CUR = 1; | ||
| 350 | pub const SEEK_END = 2; | ||
| 351 | pub const SEEK_DATA = 3; | ||
| 352 | pub const SEEK_HOLE = 4; | ||
| 353 | |||
| 354 | pub const F_ULOCK = 0; | ||
| 355 | pub const F_LOCK = 1; | ||
| 356 | pub const F_TLOCK = 2; | ||
| 357 | pub const F_TEST = 3; | ||
| 358 | |||
| 359 | pub const FD_CLOEXEC = 1; | ||
| 360 | |||
| 361 | pub const AT_FDCWD = -328243; | ||
| 362 | pub const AT_SYMLINK_NOFOLLOW = 1; | ||
| 363 | pub const AT_REMOVEDIR = 2; | ||
| 364 | pub const AT_EACCESS = 4; | ||
| 365 | pub const AT_SYMLINK_FOLLOW = 8; | ||
| 366 | |||
| 367 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 368 | return @intCast(u8, (s & 0xff00) >> 8); | ||
| 369 | } | ||
| 370 | pub fn WTERMSIG(s: u32) u32 { | ||
| 371 | return s & 0x7f; | ||
| 372 | } | ||
| 373 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 374 | return WEXITSTATUS(s); | ||
| 375 | } | ||
| 376 | pub fn WIFEXITED(s: u32) bool { | ||
| 377 | return WTERMSIG(s) == 0; | ||
| 378 | } | ||
| 379 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 380 | return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | ||
| 381 | } | ||
| 382 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 383 | return (s & 0xffff) -% 1 < 0xff; | ||
| 384 | } | ||
| 385 | |||
| 386 | pub const dirent = extern struct { | ||
| 387 | d_fileno: c_ulong, | ||
| 388 | d_namlen: u16, | ||
| 389 | d_type: u8, | ||
| 390 | d_unused1: u8, | ||
| 391 | d_unused2: u32, | ||
| 392 | d_name: [256]u8, | ||
| 393 | |||
| 394 | pub fn reclen(self: dirent) u16 { | ||
| 395 | return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7); | ||
| 396 | } | ||
| 397 | }; | ||
| 398 | |||
| 399 | pub const DT_UNKNOWN = 0; | ||
| 400 | pub const DT_FIFO = 1; | ||
| 401 | pub const DT_CHR = 2; | ||
| 402 | pub const DT_DIR = 4; | ||
| 403 | pub const DT_BLK = 6; | ||
| 404 | pub const DT_REG = 8; | ||
| 405 | pub const DT_LNK = 10; | ||
| 406 | pub const DT_SOCK = 12; | ||
| 407 | pub const DT_WHT = 14; | ||
| 408 | pub const DT_DBF = 15; | ||
| 409 | |||
| 410 | pub const CLOCK_REALTIME = 0; | ||
| 411 | pub const CLOCK_VIRTUAL = 1; | ||
| 412 | pub const CLOCK_PROF = 2; | ||
| 413 | pub const CLOCK_MONOTONIC = 4; | ||
| 414 | pub const CLOCK_UPTIME = 5; | ||
| 415 | pub const CLOCK_UPTIME_PRECISE = 7; | ||
| 416 | pub const CLOCK_UPTIME_FAST = 8; | ||
| 417 | pub const CLOCK_REALTIME_PRECISE = 9; | ||
| 418 | pub const CLOCK_REALTIME_FAST = 10; | ||
| 419 | pub const CLOCK_MONOTONIC_PRECISE = 11; | ||
| 420 | pub const CLOCK_MONOTONIC_FAST = 12; | ||
| 421 | pub const CLOCK_SECOND = 13; | ||
| 422 | pub const CLOCK_THREAD_CPUTIME_ID = 14; | ||
| 423 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; | ||
| 424 | |||
| 425 | pub const sockaddr = extern struct { | ||
| 426 | len: u8, | ||
| 427 | family: u8, | ||
| 428 | data: [14]u8, | ||
| 429 | }; | ||
| 430 | |||
| 431 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 432 | |||
| 433 | pub const Kevent = extern struct { | ||
| 434 | ident: usize, | ||
| 435 | filter: c_short, | ||
| 436 | flags: c_ushort, | ||
| 437 | fflags: c_uint, | ||
| 438 | data: isize, | ||
| 439 | udata: usize, | ||
| 440 | }; | ||
| 441 | |||
| 442 | pub const EVFILT_FS = -10; | ||
| 443 | pub const EVFILT_USER = -9; | ||
| 444 | pub const EVFILT_EXCEPT = -8; | ||
| 445 | pub const EVFILT_TIMER = -7; | ||
| 446 | pub const EVFILT_SIGNAL = -6; | ||
| 447 | pub const EVFILT_PROC = -5; | ||
| 448 | pub const EVFILT_VNODE = -4; | ||
| 449 | pub const EVFILT_AIO = -3; | ||
| 450 | pub const EVFILT_WRITE = -2; | ||
| 451 | pub const EVFILT_READ = -1; | ||
| 452 | pub const EVFILT_SYSCOUNT = 10; | ||
| 453 | pub const EVFILT_MARKER = 15; | ||
| 454 | |||
| 455 | pub const EV_ADD = 1; | ||
| 456 | pub const EV_DELETE = 2; | ||
| 457 | pub const EV_ENABLE = 4; | ||
| 458 | pub const EV_DISABLE = 8; | ||
| 459 | pub const EV_ONESHOT = 16; | ||
| 460 | pub const EV_CLEAR = 32; | ||
| 461 | pub const EV_RECEIPT = 64; | ||
| 462 | pub const EV_DISPATCH = 128; | ||
| 463 | pub const EV_NODATA = 4096; | ||
| 464 | pub const EV_FLAG1 = 8192; | ||
| 465 | pub const EV_ERROR = 16384; | ||
| 466 | pub const EV_EOF = 32768; | ||
| 467 | pub const EV_SYSFLAGS = 61440; | ||
| 468 | |||
| 469 | pub const NOTE_FFNOP = 0; | ||
| 470 | pub const NOTE_TRACK = 1; | ||
| 471 | pub const NOTE_DELETE = 1; | ||
| 472 | pub const NOTE_LOWAT = 1; | ||
| 473 | pub const NOTE_TRACKERR = 2; | ||
| 474 | pub const NOTE_OOB = 2; | ||
| 475 | pub const NOTE_WRITE = 2; | ||
| 476 | pub const NOTE_EXTEND = 4; | ||
| 477 | pub const NOTE_CHILD = 4; | ||
| 478 | pub const NOTE_ATTRIB = 8; | ||
| 479 | pub const NOTE_LINK = 16; | ||
| 480 | pub const NOTE_RENAME = 32; | ||
| 481 | pub const NOTE_REVOKE = 64; | ||
| 482 | pub const NOTE_PDATAMASK = 1048575; | ||
| 483 | pub const NOTE_FFLAGSMASK = 16777215; | ||
| 484 | pub const NOTE_TRIGGER = 16777216; | ||
| 485 | pub const NOTE_EXEC = 536870912; | ||
| 486 | pub const NOTE_FFAND = 1073741824; | ||
| 487 | pub const NOTE_FORK = 1073741824; | ||
| 488 | pub const NOTE_EXIT = 2147483648; | ||
| 489 | pub const NOTE_FFOR = 2147483648; | ||
| 490 | pub const NOTE_FFCTRLMASK = 3221225472; | ||
| 491 | pub const NOTE_FFCOPY = 3221225472; | ||
| 492 | pub const NOTE_PCTRLMASK = 4026531840; | ||
| 493 | |||
| 494 | pub const stack_t = extern struct { | ||
| 495 | ss_sp: [*]u8, | ||
| 496 | ss_size: isize, | ||
| 497 | ss_flags: i32, | ||
| 498 | }; | ||
| 499 | |||
| 500 | pub const S_IREAD = S_IRUSR; | ||
| 501 | pub const S_IEXEC = S_IXUSR; | ||
| 502 | pub const S_IWRITE = S_IWUSR; | ||
| 503 | pub const S_IXOTH = 1; | ||
| 504 | pub const S_IWOTH = 2; | ||
| 505 | pub const S_IROTH = 4; | ||
| 506 | pub const S_IRWXO = 7; | ||
| 507 | pub const S_IXGRP = 8; | ||
| 508 | pub const S_IWGRP = 16; | ||
| 509 | pub const S_IRGRP = 32; | ||
| 510 | pub const S_IRWXG = 56; | ||
| 511 | pub const S_IXUSR = 64; | ||
| 512 | pub const S_IWUSR = 128; | ||
| 513 | pub const S_IRUSR = 256; | ||
| 514 | pub const S_IRWXU = 448; | ||
| 515 | pub const S_ISTXT = 512; | ||
| 516 | pub const S_BLKSIZE = 512; | ||
| 517 | pub const S_ISVTX = 512; | ||
| 518 | pub const S_ISGID = 1024; | ||
| 519 | pub const S_ISUID = 2048; | ||
| 520 | pub const S_IFIFO = 4096; | ||
| 521 | pub const S_IFCHR = 8192; | ||
| 522 | pub const S_IFDIR = 16384; | ||
| 523 | pub const S_IFBLK = 24576; | ||
| 524 | pub const S_IFREG = 32768; | ||
| 525 | pub const S_IFDB = 36864; | ||
| 526 | pub const S_IFLNK = 40960; | ||
| 527 | pub const S_IFSOCK = 49152; | ||
| 528 | pub const S_IFWHT = 57344; | ||
| 529 | pub const S_IFMT = 61440; | ||
| 530 | |||
| 531 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 532 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 533 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 534 | pub const BADSIG = SIG_ERR; | ||
| 535 | |||
| 536 | pub const SIG_BLOCK = 1; | ||
| 537 | pub const SIG_UNBLOCK = 2; | ||
| 538 | pub const SIG_SETMASK = 3; | ||
| 539 | |||
| 540 | pub const SIGIOT = SIGABRT; | ||
| 541 | pub const SIGHUP = 1; | ||
| 542 | pub const SIGINT = 2; | ||
| 543 | pub const SIGQUIT = 3; | ||
| 544 | pub const SIGILL = 4; | ||
| 545 | pub const SIGTRAP = 5; | ||
| 546 | pub const SIGABRT = 6; | ||
| 547 | pub const SIGEMT = 7; | ||
| 548 | pub const SIGFPE = 8; | ||
| 549 | pub const SIGKILL = 9; | ||
| 550 | pub const SIGBUS = 10; | ||
| 551 | pub const SIGSEGV = 11; | ||
| 552 | pub const SIGSYS = 12; | ||
| 553 | pub const SIGPIPE = 13; | ||
| 554 | pub const SIGALRM = 14; | ||
| 555 | pub const SIGTERM = 15; | ||
| 556 | pub const SIGURG = 16; | ||
| 557 | pub const SIGSTOP = 17; | ||
| 558 | pub const SIGTSTP = 18; | ||
| 559 | pub const SIGCONT = 19; | ||
| 560 | pub const SIGCHLD = 20; | ||
| 561 | pub const SIGTTIN = 21; | ||
| 562 | pub const SIGTTOU = 22; | ||
| 563 | pub const SIGIO = 23; | ||
| 564 | pub const SIGXCPU = 24; | ||
| 565 | pub const SIGXFSZ = 25; | ||
| 566 | pub const SIGVTALRM = 26; | ||
| 567 | pub const SIGPROF = 27; | ||
| 568 | pub const SIGWINCH = 28; | ||
| 569 | pub const SIGINFO = 29; | ||
| 570 | pub const SIGUSR1 = 30; | ||
| 571 | pub const SIGUSR2 = 31; | ||
| 572 | pub const SIGTHR = 32; | ||
| 573 | pub const SIGCKPT = 33; | ||
| 574 | pub const SIGCKPTEXIT = 34; | ||
| 575 | |||
| 576 | pub const siginfo_t = extern struct { | ||
| 577 | signo: c_int, | ||
| 578 | errno: c_int, | ||
| 579 | code: c_int, | ||
| 580 | pid: c_int, | ||
| 581 | uid: uid_t, | ||
| 582 | status: c_int, | ||
| 583 | addr: ?*c_void, | ||
| 584 | value: sigval, | ||
| 585 | band: c_long, | ||
| 586 | __spare__: [7]c_int, | ||
| 587 | }; | ||
| 588 | |||
| 589 | pub const sigval = extern union { | ||
| 590 | sival_int: c_int, | ||
| 591 | sival_ptr: ?*c_void, | ||
| 592 | }; | ||
| 593 | |||
| 594 | pub const _SIG_WORDS = 4; | ||
| 595 | |||
| 596 | pub const sigset_t = extern struct { | ||
| 597 | __bits: [_SIG_WORDS]c_uint, | ||
| 598 | }; | ||
| 599 | |||
| 600 | pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS }; | ||
| 601 | |||
| 602 | pub const sig_atomic_t = c_int; | ||
| 603 | |||
| 604 | pub const Sigaction = extern struct { | ||
| 605 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 606 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 607 | |||
| 608 | /// signal handler | ||
| 609 | handler: extern union { | ||
| 610 | handler: ?handler_fn, | ||
| 611 | sigaction: ?sigaction_fn, | ||
| 612 | }, | ||
| 613 | flags: c_uint, | ||
| 614 | mask: sigset_t, | ||
| 615 | }; | ||
| 616 | |||
| 617 | pub const sig_t = [*c]fn (c_int) callconv(.C) void; | ||
| 618 | |||
| 619 | pub const SOCK_STREAM = 1; | ||
| 620 | pub const SOCK_DGRAM = 2; | ||
| 621 | pub const SOCK_RAW = 3; | ||
| 622 | pub const SOCK_RDM = 4; | ||
| 623 | pub const SOCK_SEQPACKET = 5; | ||
| 624 | pub const SOCK_MAXADDRLEN = 255; | ||
| 625 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 626 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 627 | |||
| 628 | pub const SO_DEBUG = 0x0001; | ||
| 629 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 630 | pub const SO_REUSEADDR = 0x0004; | ||
| 631 | pub const SO_KEEPALIVE = 0x0008; | ||
| 632 | pub const SO_DONTROUTE = 0x0010; | ||
| 633 | pub const SO_BROADCAST = 0x0020; | ||
| 634 | pub const SO_USELOOPBACK = 0x0040; | ||
| 635 | pub const SO_LINGER = 0x0080; | ||
| 636 | pub const SO_OOBINLINE = 0x0100; | ||
| 637 | pub const SO_REUSEPORT = 0x0200; | ||
| 638 | pub const SO_TIMESTAMP = 0x0400; | ||
| 639 | pub const SO_NOSIGPIPE = 0x0800; | ||
| 640 | pub const SO_ACCEPTFILTER = 0x1000; | ||
| 641 | pub const SO_RERROR = 0x2000; | ||
| 642 | pub const SO_PASSCRED = 0x4000; | ||
| 643 | |||
| 644 | pub const SO_SNDBUF = 0x1001; | ||
| 645 | pub const SO_RCVBUF = 0x1002; | ||
| 646 | pub const SO_SNDLOWAT = 0x1003; | ||
| 647 | pub const SO_RCVLOWAT = 0x1004; | ||
| 648 | pub const SO_SNDTIMEO = 0x1005; | ||
| 649 | pub const SO_RCVTIMEO = 0x1006; | ||
| 650 | pub const SO_ERROR = 0x1007; | ||
| 651 | pub const SO_TYPE = 0x1008; | ||
| 652 | pub const SO_SNDSPACE = 0x100a; | ||
| 653 | pub const SO_CPUHINT = 0x1030; | ||
| 654 | |||
| 655 | pub const SOL_SOCKET = 0xffff; | ||
| 656 | |||
| 657 | pub const PF_INET6 = AF_INET6; | ||
| 658 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 659 | pub const PF_ROUTE = AF_ROUTE; | ||
| 660 | pub const PF_ISO = AF_ISO; | ||
| 661 | pub const PF_PIP = pseudo_AF_PIP; | ||
| 662 | pub const PF_CHAOS = AF_CHAOS; | ||
| 663 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 664 | pub const PF_INET = AF_INET; | ||
| 665 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 666 | pub const PF_SIP = AF_SIP; | ||
| 667 | pub const PF_OSI = AF_ISO; | ||
| 668 | pub const PF_CNT = AF_CNT; | ||
| 669 | pub const PF_LINK = AF_LINK; | ||
| 670 | pub const PF_HYLINK = AF_HYLINK; | ||
| 671 | pub const PF_MAX = AF_MAX; | ||
| 672 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 673 | pub const PF_PUP = AF_PUP; | ||
| 674 | pub const PF_COIP = AF_COIP; | ||
| 675 | pub const PF_SNA = AF_SNA; | ||
| 676 | pub const PF_LOCAL = AF_LOCAL; | ||
| 677 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 678 | pub const PF_NATM = AF_NATM; | ||
| 679 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 680 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 681 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 682 | pub const PF_ECMA = AF_ECMA; | ||
| 683 | pub const PF_IPX = AF_IPX; | ||
| 684 | pub const PF_DLI = AF_DLI; | ||
| 685 | pub const PF_ATM = AF_ATM; | ||
| 686 | pub const PF_CCITT = AF_CCITT; | ||
| 687 | pub const PF_ISDN = AF_ISDN; | ||
| 688 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 689 | pub const PF_LAT = AF_LAT; | ||
| 690 | pub const PF_UNIX = PF_LOCAL; | ||
| 691 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 692 | pub const PF_DECnet = AF_DECnet; | ||
| 693 | |||
| 694 | pub const AF_UNSPEC = 0; | ||
| 695 | pub const AF_OSI = AF_ISO; | ||
| 696 | pub const AF_UNIX = AF_LOCAL; | ||
| 697 | pub const AF_LOCAL = 1; | ||
| 698 | pub const AF_INET = 2; | ||
| 699 | pub const AF_IMPLINK = 3; | ||
| 700 | pub const AF_PUP = 4; | ||
| 701 | pub const AF_CHAOS = 5; | ||
| 702 | pub const AF_NETBIOS = 6; | ||
| 703 | pub const AF_ISO = 7; | ||
| 704 | pub const AF_ECMA = 8; | ||
| 705 | pub const AF_DATAKIT = 9; | ||
| 706 | pub const AF_CCITT = 10; | ||
| 707 | pub const AF_SNA = 11; | ||
| 708 | pub const AF_DLI = 13; | ||
| 709 | pub const AF_LAT = 14; | ||
| 710 | pub const AF_HYLINK = 15; | ||
| 711 | pub const AF_APPLETALK = 16; | ||
| 712 | pub const AF_ROUTE = 17; | ||
| 713 | pub const AF_LINK = 18; | ||
| 714 | pub const AF_COIP = 20; | ||
| 715 | pub const AF_CNT = 21; | ||
| 716 | pub const AF_IPX = 23; | ||
| 717 | pub const AF_SIP = 24; | ||
| 718 | pub const AF_ISDN = 26; | ||
| 719 | pub const AF_INET6 = 28; | ||
| 720 | pub const AF_NATM = 29; | ||
| 721 | pub const AF_ATM = 30; | ||
| 722 | pub const AF_NETGRAPH = 32; | ||
| 723 | pub const AF_BLUETOOTH = 33; | ||
| 724 | pub const AF_MPLS = 34; | ||
| 725 | pub const AF_MAX = 36; | ||
| 726 | |||
| 727 | pub const in_port_t = u16; | ||
| 728 | pub const sa_family_t = u8; | ||
| 729 | pub const socklen_t = u32; | ||
| 730 | |||
| 731 | pub const sockaddr_in = extern struct { | ||
| 732 | len: u8 = @sizeOf(sockaddr_in), | ||
| 733 | family: sa_family_t = AF_INET, | ||
| 734 | port: in_port_t, | ||
| 735 | addr: u32, | ||
| 736 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 737 | }; | ||
| 738 | |||
| 739 | pub const sockaddr_in6 = extern struct { | ||
| 740 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 741 | family: sa_family_t = AF_INET6, | ||
| 742 | port: in_port_t, | ||
| 743 | flowinfo: u32, | ||
| 744 | addr: [16]u8, | ||
| 745 | scope_id: u32, | ||
| 746 | }; | ||
| 747 | |||
| 748 | pub const EAI = enum(c_int) { | ||
| 749 | ADDRFAMILY = 1, | ||
| 750 | AGAIN = 2, | ||
| 751 | BADFLAGS = 3, | ||
| 752 | FAIL = 4, | ||
| 753 | FAMILY = 5, | ||
| 754 | MEMORY = 6, | ||
| 755 | NODATA = 7, | ||
| 756 | NONAME = 8, | ||
| 757 | SERVICE = 9, | ||
| 758 | SOCKTYPE = 10, | ||
| 759 | SYSTEM = 11, | ||
| 760 | BADHINTS = 12, | ||
| 761 | PROTOCOL = 13, | ||
| 762 | OVERFLOW = 14, | ||
| 763 | _, | ||
| 764 | }; | ||
| 765 | |||
| 766 | pub const AI_PASSIVE = 0x00000001; | ||
| 767 | pub const AI_CANONNAME = 0x00000002; | ||
| 768 | pub const AI_NUMERICHOST = 0x00000004; | ||
| 769 | pub const AI_NUMERICSERV = 0x00000008; | ||
| 770 | pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG; | ||
| 771 | pub const AI_ALL = 0x00000100; | ||
| 772 | pub const AI_V4MAPPED_CFG = 0x00000200; | ||
| 773 | pub const AI_ADDRCONFIG = 0x00000400; | ||
| 774 | pub const AI_V4MAPPED = 0x00000800; | ||
| 775 | pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG; | ||
| 776 | |||
| 777 | pub const RTLD_LAZY = 1; | ||
| 778 | pub const RTLD_NOW = 2; | ||
| 779 | pub const RTLD_MODEMASK = 0x3; | ||
| 780 | pub const RTLD_GLOBAL = 0x100; | ||
| 781 | pub const RTLD_LOCAL = 0; | ||
| 782 | pub const RTLD_TRACE = 0x200; | ||
| 783 | pub const RTLD_NODELETE = 0x01000; | ||
| 784 | pub const RTLD_NOLOAD = 0x02000; | ||
| 785 | |||
| 786 | pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); | ||
| 787 | pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); | ||
| 788 | pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); | ||
| 789 | pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4))); | ||
| 790 | |||
| 791 | pub const dl_phdr_info = extern struct { | ||
| 792 | dlpi_addr: usize, | ||
| 793 | dlpi_name: ?[*:0]const u8, | ||
| 794 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 795 | dlpi_phnum: u16, | ||
| 796 | }; | ||
| 797 | pub const cmsghdr = extern struct { | ||
| 798 | cmsg_len: socklen_t, | ||
| 799 | cmsg_level: c_int, | ||
| 800 | cmsg_type: c_int, | ||
| 801 | }; | ||
| 802 | pub const msghdr = extern struct { | ||
| 803 | msg_name: ?*c_void, | ||
| 804 | msg_namelen: socklen_t, | ||
| 805 | msg_iov: [*c]iovec, | ||
| 806 | msg_iovlen: c_int, | ||
| 807 | msg_control: ?*c_void, | ||
| 808 | msg_controllen: socklen_t, | ||
| 809 | msg_flags: c_int, | ||
| 810 | }; | ||
| 811 | pub const cmsgcred = extern struct { | ||
| 812 | cmcred_pid: pid_t, | ||
| 813 | cmcred_uid: uid_t, | ||
| 814 | cmcred_euid: uid_t, | ||
| 815 | cmcred_gid: gid_t, | ||
| 816 | cmcred_ngroups: c_short, | ||
| 817 | cmcred_groups: [16]gid_t, | ||
| 818 | }; | ||
| 819 | pub const sf_hdtr = extern struct { | ||
| 820 | headers: [*c]iovec, | ||
| 821 | hdr_cnt: c_int, | ||
| 822 | trailers: [*c]iovec, | ||
| 823 | trl_cnt: c_int, | ||
| 824 | }; | ||
| 825 | |||
| 826 | pub const MS_SYNC = 0; | ||
| 827 | pub const MS_ASYNC = 1; | ||
| 828 | pub const MS_INVALIDATE = 2; | ||
| 829 | |||
| 830 | pub const POSIX_MADV_SEQUENTIAL = 2; | ||
| 831 | pub const POSIX_MADV_RANDOM = 1; | ||
| 832 | pub const POSIX_MADV_DONTNEED = 4; | ||
| 833 | pub const POSIX_MADV_NORMAL = 0; | ||
| 834 | pub const POSIX_MADV_WILLNEED = 3; | ||
| 835 | |||
| 836 | pub const MADV_SEQUENTIAL = 2; | ||
| 837 | pub const MADV_CONTROL_END = MADV_SETMAP; | ||
| 838 | pub const MADV_DONTNEED = 4; | ||
| 839 | pub const MADV_RANDOM = 1; | ||
| 840 | pub const MADV_WILLNEED = 3; | ||
| 841 | pub const MADV_NORMAL = 0; | ||
| 842 | pub const MADV_CONTROL_START = MADV_INVAL; | ||
| 843 | pub const MADV_FREE = 5; | ||
| 844 | pub const MADV_NOSYNC = 6; | ||
| 845 | pub const MADV_AUTOSYNC = 7; | ||
| 846 | pub const MADV_NOCORE = 8; | ||
| 847 | pub const MADV_CORE = 9; | ||
| 848 | pub const MADV_INVAL = 10; | ||
| 849 | pub const MADV_SETMAP = 11; | ||
| 850 | |||
| 851 | pub const F_DUPFD = 0; | ||
| 852 | pub const F_GETFD = 1; | ||
| 853 | pub const F_RDLCK = 1; | ||
| 854 | pub const F_SETFD = 2; | ||
| 855 | pub const F_UNLCK = 2; | ||
| 856 | pub const F_WRLCK = 3; | ||
| 857 | pub const F_GETFL = 3; | ||
| 858 | pub const F_SETFL = 4; | ||
| 859 | pub const F_GETOWN = 5; | ||
| 860 | pub const F_SETOWN = 6; | ||
| 861 | pub const F_GETLK = 7; | ||
| 862 | pub const F_SETLK = 8; | ||
| 863 | pub const F_SETLKW = 9; | ||
| 864 | pub const F_DUP2FD = 10; | ||
| 865 | pub const F_DUPFD_CLOEXEC = 17; | ||
| 866 | pub const F_DUP2FD_CLOEXEC = 18; | ||
| 867 | |||
| 868 | pub const LOCK_SH = 1; | ||
| 869 | pub const LOCK_EX = 2; | ||
| 870 | pub const LOCK_UN = 8; | ||
| 871 | pub const LOCK_NB = 4; | ||
| 872 | |||
| 873 | pub const Flock = extern struct { | ||
| 874 | l_start: off_t, | ||
| 875 | l_len: off_t, | ||
| 876 | l_pid: pid_t, | ||
| 877 | l_type: c_short, | ||
| 878 | l_whence: c_short, | ||
| 879 | }; | ||
| 880 | |||
| 881 | pub const addrinfo = extern struct { | ||
| 882 | flags: i32, | ||
| 883 | family: i32, | ||
| 884 | socktype: i32, | ||
| 885 | protocol: i32, | ||
| 886 | addrlen: socklen_t, | ||
| 887 | canonname: ?[*:0]u8, | ||
| 888 | addr: ?*sockaddr, | ||
| 889 | next: ?*addrinfo, | ||
| 890 | }; | ||
| 891 | |||
| 892 | pub const IPPROTO_IP = 0; | ||
| 893 | pub const IPPROTO_ICMP = 1; | ||
| 894 | pub const IPPROTO_TCP = 6; | ||
| 895 | pub const IPPROTO_UDP = 17; | ||
| 896 | pub const IPPROTO_IPV6 = 41; | ||
| 897 | pub const IPPROTO_RAW = 255; | ||
| 898 | pub const IPPROTO_HOPOPTS = 0; | ||
| 899 | pub const IPPROTO_IGMP = 2; | ||
| 900 | pub const IPPROTO_GGP = 3; | ||
| 901 | pub const IPPROTO_IPV4 = 4; | ||
| 902 | pub const IPPROTO_IPIP = IPPROTO_IPV4; | ||
| 903 | pub const IPPROTO_ST = 7; | ||
| 904 | pub const IPPROTO_EGP = 8; | ||
| 905 | pub const IPPROTO_PIGP = 9; | ||
| 906 | pub const IPPROTO_RCCMON = 10; | ||
| 907 | pub const IPPROTO_NVPII = 11; | ||
| 908 | pub const IPPROTO_PUP = 12; | ||
| 909 | pub const IPPROTO_ARGUS = 13; | ||
| 910 | pub const IPPROTO_EMCON = 14; | ||
| 911 | pub const IPPROTO_XNET = 15; | ||
| 912 | pub const IPPROTO_CHAOS = 16; | ||
| 913 | pub const IPPROTO_MUX = 18; | ||
| 914 | pub const IPPROTO_MEAS = 19; | ||
| 915 | pub const IPPROTO_HMP = 20; | ||
| 916 | pub const IPPROTO_PRM = 21; | ||
| 917 | pub const IPPROTO_IDP = 22; | ||
| 918 | pub const IPPROTO_TRUNK1 = 23; | ||
| 919 | pub const IPPROTO_TRUNK2 = 24; | ||
| 920 | pub const IPPROTO_LEAF1 = 25; | ||
| 921 | pub const IPPROTO_LEAF2 = 26; | ||
| 922 | pub const IPPROTO_RDP = 27; | ||
| 923 | pub const IPPROTO_IRTP = 28; | ||
| 924 | pub const IPPROTO_TP = 29; | ||
| 925 | pub const IPPROTO_BLT = 30; | ||
| 926 | pub const IPPROTO_NSP = 31; | ||
| 927 | pub const IPPROTO_INP = 32; | ||
| 928 | pub const IPPROTO_SEP = 33; | ||
| 929 | pub const IPPROTO_3PC = 34; | ||
| 930 | pub const IPPROTO_IDPR = 35; | ||
| 931 | pub const IPPROTO_XTP = 36; | ||
| 932 | pub const IPPROTO_DDP = 37; | ||
| 933 | pub const IPPROTO_CMTP = 38; | ||
| 934 | pub const IPPROTO_TPXX = 39; | ||
| 935 | pub const IPPROTO_IL = 40; | ||
| 936 | pub const IPPROTO_SDRP = 42; | ||
| 937 | pub const IPPROTO_ROUTING = 43; | ||
| 938 | pub const IPPROTO_FRAGMENT = 44; | ||
| 939 | pub const IPPROTO_IDRP = 45; | ||
| 940 | pub const IPPROTO_RSVP = 46; | ||
| 941 | pub const IPPROTO_GRE = 47; | ||
| 942 | pub const IPPROTO_MHRP = 48; | ||
| 943 | pub const IPPROTO_BHA = 49; | ||
| 944 | pub const IPPROTO_ESP = 50; | ||
| 945 | pub const IPPROTO_AH = 51; | ||
| 946 | pub const IPPROTO_INLSP = 52; | ||
| 947 | pub const IPPROTO_SWIPE = 53; | ||
| 948 | pub const IPPROTO_NHRP = 54; | ||
| 949 | pub const IPPROTO_MOBILE = 55; | ||
| 950 | pub const IPPROTO_TLSP = 56; | ||
| 951 | pub const IPPROTO_SKIP = 57; | ||
| 952 | pub const IPPROTO_ICMPV6 = 58; | ||
| 953 | pub const IPPROTO_NONE = 59; | ||
| 954 | pub const IPPROTO_DSTOPTS = 60; | ||
| 955 | pub const IPPROTO_AHIP = 61; | ||
| 956 | pub const IPPROTO_CFTP = 62; | ||
| 957 | pub const IPPROTO_HELLO = 63; | ||
| 958 | pub const IPPROTO_SATEXPAK = 64; | ||
| 959 | pub const IPPROTO_KRYPTOLAN = 65; | ||
| 960 | pub const IPPROTO_RVD = 66; | ||
| 961 | pub const IPPROTO_IPPC = 67; | ||
| 962 | pub const IPPROTO_ADFS = 68; | ||
| 963 | pub const IPPROTO_SATMON = 69; | ||
| 964 | pub const IPPROTO_VISA = 70; | ||
| 965 | pub const IPPROTO_IPCV = 71; | ||
| 966 | pub const IPPROTO_CPNX = 72; | ||
| 967 | pub const IPPROTO_CPHB = 73; | ||
| 968 | pub const IPPROTO_WSN = 74; | ||
| 969 | pub const IPPROTO_PVP = 75; | ||
| 970 | pub const IPPROTO_BRSATMON = 76; | ||
| 971 | pub const IPPROTO_ND = 77; | ||
| 972 | pub const IPPROTO_WBMON = 78; | ||
| 973 | pub const IPPROTO_WBEXPAK = 79; | ||
| 974 | pub const IPPROTO_EON = 80; | ||
| 975 | pub const IPPROTO_VMTP = 81; | ||
| 976 | pub const IPPROTO_SVMTP = 82; | ||
| 977 | pub const IPPROTO_VINES = 83; | ||
| 978 | pub const IPPROTO_TTP = 84; | ||
| 979 | pub const IPPROTO_IGP = 85; | ||
| 980 | pub const IPPROTO_DGP = 86; | ||
| 981 | pub const IPPROTO_TCF = 87; | ||
| 982 | pub const IPPROTO_IGRP = 88; | ||
| 983 | pub const IPPROTO_OSPFIGP = 89; | ||
| 984 | pub const IPPROTO_SRPC = 90; | ||
| 985 | pub const IPPROTO_LARP = 91; | ||
| 986 | pub const IPPROTO_MTP = 92; | ||
| 987 | pub const IPPROTO_AX25 = 93; | ||
| 988 | pub const IPPROTO_IPEIP = 94; | ||
| 989 | pub const IPPROTO_MICP = 95; | ||
| 990 | pub const IPPROTO_SCCSP = 96; | ||
| 991 | pub const IPPROTO_ETHERIP = 97; | ||
| 992 | pub const IPPROTO_ENCAP = 98; | ||
| 993 | pub const IPPROTO_APES = 99; | ||
| 994 | pub const IPPROTO_GMTP = 100; | ||
| 995 | pub const IPPROTO_IPCOMP = 108; | ||
| 996 | pub const IPPROTO_PIM = 103; | ||
| 997 | pub const IPPROTO_CARP = 112; | ||
| 998 | pub const IPPROTO_PGM = 113; | ||
| 999 | pub const IPPROTO_PFSYNC = 240; | ||
| 1000 | pub const IPPROTO_DIVERT = 254; | ||
| 1001 | pub const IPPROTO_MAX = 256; | ||
| 1002 | pub const IPPROTO_DONE = 257; | ||
| 1003 | pub const IPPROTO_UNKNOWN = 258; | ||
| 1004 | |||
| 1005 | pub const rlimit_resource = enum(c_int) { | ||
| 1006 | CPU = 0, | ||
| 1007 | FSIZE = 1, | ||
| 1008 | DATA = 2, | ||
| 1009 | STACK = 3, | ||
| 1010 | CORE = 4, | ||
| 1011 | RSS = 5, | ||
| 1012 | MEMLOCK = 6, | ||
| 1013 | NPROC = 7, | ||
| 1014 | NOFILE = 8, | ||
| 1015 | SBSIZE = 9, | ||
| 1016 | VMEM = 10, | ||
| 1017 | POSIXLOCKS = 11, | ||
| 1018 | _, | ||
| 1019 | |||
| 1020 | pub const AS: rlimit_resource = .VMEM; | ||
| 1021 | }; | ||
| 1022 | |||
| 1023 | pub const rlim_t = i64; | ||
| 1024 | |||
| 1025 | /// No limit | ||
| 1026 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1027 | |||
| 1028 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1029 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1030 | |||
| 1031 | pub const rlimit = extern struct { | ||
| 1032 | /// Soft limit | ||
| 1033 | cur: rlim_t, | ||
| 1034 | /// Hard limit | ||
| 1035 | max: rlim_t, | ||
| 1036 | }; | ||
| 1037 | |||
| 1038 | pub const SHUT_RD = 0; | ||
| 1039 | pub const SHUT_WR = 1; | ||
| 1040 | pub const SHUT_RDWR = 2; | ||
| 1041 | |||
| 1042 | pub const nfds_t = u32; | ||
| 1043 | |||
| 1044 | pub const pollfd = extern struct { | ||
| 1045 | fd: fd_t, | ||
| 1046 | events: i16, | ||
| 1047 | revents: i16, | ||
| 1048 | }; | ||
| 1049 | |||
| 1050 | /// Requestable events. | ||
| 1051 | pub const POLLIN = 0x0001; | ||
| 1052 | pub const POLLPRI = 0x0002; | ||
| 1053 | pub const POLLOUT = 0x0004; | ||
| 1054 | pub const POLLRDNORM = 0x0040; | ||
| 1055 | pub const POLLWRNORM = POLLOUT; | ||
| 1056 | pub const POLLRDBAND = 0x0080; | ||
| 1057 | pub const POLLWRBAND = 0x0100; | ||
| 1058 | |||
| 1059 | /// These events are set if they occur regardless of whether they were requested. | ||
| 1060 | pub const POLLERR = 0x0008; | ||
| 1061 | pub const POLLHUP = 0x0010; | ||
| 1062 | pub const POLLNVAL = 0x0020; |
lib/std/c/freebsd.zig+1538-1| ... | @@ -1,5 +1,5 @@ | ... | @@ -1,5 +1,5 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | usingnamespace std.c; | 2 | const maxInt = std.math.maxInt; |
| 3 | 3 | ||
| 4 | extern "c" fn __error() *c_int; | 4 | extern "c" fn __error() *c_int; |
| 5 | pub const _errno = __error; | 5 | pub const _errno = __error; |
| ... | @@ -136,3 +136,1540 @@ pub const AI_V4MAPPED = 0x00000800; | ... | @@ -136,3 +136,1540 @@ pub const AI_V4MAPPED = 0x00000800; |
| 136 | 136 | ||
| 137 | /// special recommended flags for getipnodebyname | 137 | /// special recommended flags for getipnodebyname |
| 138 | pub const AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG); | 138 | pub const AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG); |
| 139 | |||
| 140 | pub const blksize_t = i32; | ||
| 141 | pub const blkcnt_t = i64; | ||
| 142 | pub const clockid_t = i32; | ||
| 143 | pub const fsblkcnt_t = u64; | ||
| 144 | pub const fsfilcnt_t = u64; | ||
| 145 | pub const nlink_t = u64; | ||
| 146 | pub const fd_t = i32; | ||
| 147 | pub const pid_t = i32; | ||
| 148 | pub const uid_t = u32; | ||
| 149 | pub const gid_t = u32; | ||
| 150 | pub const mode_t = u16; | ||
| 151 | pub const off_t = i64; | ||
| 152 | pub const ino_t = u64; | ||
| 153 | pub const dev_t = u64; | ||
| 154 | pub const time_t = i64; | ||
| 155 | // The signedness is not constant across different architectures. | ||
| 156 | pub const clock_t = isize; | ||
| 157 | |||
| 158 | pub const socklen_t = u32; | ||
| 159 | pub const suseconds_t = c_long; | ||
| 160 | |||
| 161 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 162 | pub const Kevent = extern struct { | ||
| 163 | ident: usize, | ||
| 164 | filter: i16, | ||
| 165 | flags: u16, | ||
| 166 | fflags: u32, | ||
| 167 | data: i64, | ||
| 168 | udata: usize, | ||
| 169 | // TODO ext | ||
| 170 | }; | ||
| 171 | |||
| 172 | // Modes and flags for dlopen() | ||
| 173 | // include/dlfcn.h | ||
| 174 | |||
| 175 | /// Bind function calls lazily. | ||
| 176 | pub const RTLD_LAZY = 1; | ||
| 177 | |||
| 178 | /// Bind function calls immediately. | ||
| 179 | pub const RTLD_NOW = 2; | ||
| 180 | |||
| 181 | pub const RTLD_MODEMASK = 0x3; | ||
| 182 | |||
| 183 | /// Make symbols globally available. | ||
| 184 | pub const RTLD_GLOBAL = 0x100; | ||
| 185 | |||
| 186 | /// Opposite of RTLD_GLOBAL, and the default. | ||
| 187 | pub const RTLD_LOCAL = 0; | ||
| 188 | |||
| 189 | /// Trace loaded objects and exit. | ||
| 190 | pub const RTLD_TRACE = 0x200; | ||
| 191 | |||
| 192 | /// Do not remove members. | ||
| 193 | pub const RTLD_NODELETE = 0x01000; | ||
| 194 | |||
| 195 | /// Do not load if not already loaded. | ||
| 196 | pub const RTLD_NOLOAD = 0x02000; | ||
| 197 | |||
| 198 | pub const dl_phdr_info = extern struct { | ||
| 199 | dlpi_addr: usize, | ||
| 200 | dlpi_name: ?[*:0]const u8, | ||
| 201 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 202 | dlpi_phnum: u16, | ||
| 203 | }; | ||
| 204 | |||
| 205 | pub const Flock = extern struct { | ||
| 206 | l_start: off_t, | ||
| 207 | l_len: off_t, | ||
| 208 | l_pid: pid_t, | ||
| 209 | l_type: i16, | ||
| 210 | l_whence: i16, | ||
| 211 | l_sysid: i32, | ||
| 212 | __unused: [4]u8, | ||
| 213 | }; | ||
| 214 | |||
| 215 | pub const msghdr = extern struct { | ||
| 216 | /// optional address | ||
| 217 | msg_name: ?*sockaddr, | ||
| 218 | |||
| 219 | /// size of address | ||
| 220 | msg_namelen: socklen_t, | ||
| 221 | |||
| 222 | /// scatter/gather array | ||
| 223 | msg_iov: [*]iovec, | ||
| 224 | |||
| 225 | /// # elements in msg_iov | ||
| 226 | msg_iovlen: i32, | ||
| 227 | |||
| 228 | /// ancillary data | ||
| 229 | msg_control: ?*c_void, | ||
| 230 | |||
| 231 | /// ancillary data buffer len | ||
| 232 | msg_controllen: socklen_t, | ||
| 233 | |||
| 234 | /// flags on received message | ||
| 235 | msg_flags: i32, | ||
| 236 | }; | ||
| 237 | |||
| 238 | pub const msghdr_const = extern struct { | ||
| 239 | /// optional address | ||
| 240 | msg_name: ?*const sockaddr, | ||
| 241 | |||
| 242 | /// size of address | ||
| 243 | msg_namelen: socklen_t, | ||
| 244 | |||
| 245 | /// scatter/gather array | ||
| 246 | msg_iov: [*]iovec_const, | ||
| 247 | |||
| 248 | /// # elements in msg_iov | ||
| 249 | msg_iovlen: i32, | ||
| 250 | |||
| 251 | /// ancillary data | ||
| 252 | msg_control: ?*c_void, | ||
| 253 | |||
| 254 | /// ancillary data buffer len | ||
| 255 | msg_controllen: socklen_t, | ||
| 256 | |||
| 257 | /// flags on received message | ||
| 258 | msg_flags: i32, | ||
| 259 | }; | ||
| 260 | |||
| 261 | pub const Stat = extern struct { | ||
| 262 | dev: dev_t, | ||
| 263 | ino: ino_t, | ||
| 264 | nlink: nlink_t, | ||
| 265 | |||
| 266 | mode: mode_t, | ||
| 267 | __pad0: u16, | ||
| 268 | uid: uid_t, | ||
| 269 | gid: gid_t, | ||
| 270 | __pad1: u32, | ||
| 271 | rdev: dev_t, | ||
| 272 | |||
| 273 | atim: timespec, | ||
| 274 | mtim: timespec, | ||
| 275 | ctim: timespec, | ||
| 276 | birthtim: timespec, | ||
| 277 | |||
| 278 | size: off_t, | ||
| 279 | blocks: i64, | ||
| 280 | blksize: isize, | ||
| 281 | flags: u32, | ||
| 282 | gen: u64, | ||
| 283 | __spare: [10]u64, | ||
| 284 | |||
| 285 | pub fn atime(self: @This()) timespec { | ||
| 286 | return self.atim; | ||
| 287 | } | ||
| 288 | |||
| 289 | pub fn mtime(self: @This()) timespec { | ||
| 290 | return self.mtim; | ||
| 291 | } | ||
| 292 | |||
| 293 | pub fn ctime(self: @This()) timespec { | ||
| 294 | return self.ctim; | ||
| 295 | } | ||
| 296 | }; | ||
| 297 | |||
| 298 | pub const timespec = extern struct { | ||
| 299 | tv_sec: isize, | ||
| 300 | tv_nsec: isize, | ||
| 301 | }; | ||
| 302 | |||
| 303 | pub const timeval = extern struct { | ||
| 304 | /// seconds | ||
| 305 | tv_sec: time_t, | ||
| 306 | /// microseconds | ||
| 307 | tv_usec: suseconds_t, | ||
| 308 | }; | ||
| 309 | |||
| 310 | pub const dirent = extern struct { | ||
| 311 | d_fileno: usize, | ||
| 312 | d_off: i64, | ||
| 313 | d_reclen: u16, | ||
| 314 | d_type: u8, | ||
| 315 | d_pad0: u8, | ||
| 316 | d_namlen: u16, | ||
| 317 | d_pad1: u16, | ||
| 318 | d_name: [256]u8, | ||
| 319 | |||
| 320 | pub fn reclen(self: dirent) u16 { | ||
| 321 | return self.d_reclen; | ||
| 322 | } | ||
| 323 | }; | ||
| 324 | |||
| 325 | pub const in_port_t = u16; | ||
| 326 | pub const sa_family_t = u8; | ||
| 327 | |||
| 328 | pub const sockaddr = extern struct { | ||
| 329 | /// total length | ||
| 330 | len: u8, | ||
| 331 | |||
| 332 | /// address family | ||
| 333 | family: sa_family_t, | ||
| 334 | |||
| 335 | /// actually longer; address value | ||
| 336 | data: [14]u8, | ||
| 337 | }; | ||
| 338 | |||
| 339 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 340 | |||
| 341 | pub const sockaddr_in = extern struct { | ||
| 342 | len: u8 = @sizeOf(sockaddr_in), | ||
| 343 | family: sa_family_t = AF_INET, | ||
| 344 | port: in_port_t, | ||
| 345 | addr: u32, | ||
| 346 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 347 | }; | ||
| 348 | |||
| 349 | pub const sockaddr_in6 = extern struct { | ||
| 350 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 351 | family: sa_family_t = AF_INET6, | ||
| 352 | port: in_port_t, | ||
| 353 | flowinfo: u32, | ||
| 354 | addr: [16]u8, | ||
| 355 | scope_id: u32, | ||
| 356 | }; | ||
| 357 | |||
| 358 | pub const sockaddr_un = extern struct { | ||
| 359 | len: u8 = @sizeOf(sockaddr_un), | ||
| 360 | family: sa_family_t = AF_UNIX, | ||
| 361 | path: [104]u8, | ||
| 362 | }; | ||
| 363 | |||
| 364 | pub const CTL_KERN = 1; | ||
| 365 | pub const CTL_DEBUG = 5; | ||
| 366 | |||
| 367 | pub const KERN_PROC = 14; // struct: process entries | ||
| 368 | pub const KERN_PROC_PATHNAME = 12; // path to executable | ||
| 369 | pub const KERN_IOV_MAX = 35; | ||
| 370 | |||
| 371 | pub const PATH_MAX = 1024; | ||
| 372 | pub const IOV_MAX = KERN_IOV_MAX; | ||
| 373 | |||
| 374 | pub const STDIN_FILENO = 0; | ||
| 375 | pub const STDOUT_FILENO = 1; | ||
| 376 | pub const STDERR_FILENO = 2; | ||
| 377 | |||
| 378 | pub const PROT_NONE = 0; | ||
| 379 | pub const PROT_READ = 1; | ||
| 380 | pub const PROT_WRITE = 2; | ||
| 381 | pub const PROT_EXEC = 4; | ||
| 382 | |||
| 383 | pub const CLOCK_REALTIME = 0; | ||
| 384 | pub const CLOCK_VIRTUAL = 1; | ||
| 385 | pub const CLOCK_PROF = 2; | ||
| 386 | pub const CLOCK_MONOTONIC = 4; | ||
| 387 | pub const CLOCK_UPTIME = 5; | ||
| 388 | pub const CLOCK_UPTIME_PRECISE = 7; | ||
| 389 | pub const CLOCK_UPTIME_FAST = 8; | ||
| 390 | pub const CLOCK_REALTIME_PRECISE = 9; | ||
| 391 | pub const CLOCK_REALTIME_FAST = 10; | ||
| 392 | pub const CLOCK_MONOTONIC_PRECISE = 11; | ||
| 393 | pub const CLOCK_MONOTONIC_FAST = 12; | ||
| 394 | pub const CLOCK_SECOND = 13; | ||
| 395 | pub const CLOCK_THREAD_CPUTIME_ID = 14; | ||
| 396 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; | ||
| 397 | |||
| 398 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 399 | pub const MAP_SHARED = 0x0001; | ||
| 400 | pub const MAP_PRIVATE = 0x0002; | ||
| 401 | pub const MAP_FIXED = 0x0010; | ||
| 402 | pub const MAP_STACK = 0x0400; | ||
| 403 | pub const MAP_NOSYNC = 0x0800; | ||
| 404 | pub const MAP_ANON = 0x1000; | ||
| 405 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 406 | pub const MAP_FILE = 0; | ||
| 407 | |||
| 408 | pub const MAP_GUARD = 0x00002000; | ||
| 409 | pub const MAP_EXCL = 0x00004000; | ||
| 410 | pub const MAP_NOCORE = 0x00020000; | ||
| 411 | pub const MAP_PREFAULT_READ = 0x00040000; | ||
| 412 | pub const MAP_32BIT = 0x00080000; | ||
| 413 | |||
| 414 | pub const WNOHANG = 1; | ||
| 415 | pub const WUNTRACED = 2; | ||
| 416 | pub const WSTOPPED = WUNTRACED; | ||
| 417 | pub const WCONTINUED = 4; | ||
| 418 | pub const WNOWAIT = 8; | ||
| 419 | pub const WEXITED = 16; | ||
| 420 | pub const WTRAPPED = 32; | ||
| 421 | |||
| 422 | pub const SA_ONSTACK = 0x0001; | ||
| 423 | pub const SA_RESTART = 0x0002; | ||
| 424 | pub const SA_RESETHAND = 0x0004; | ||
| 425 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 426 | pub const SA_NODEFER = 0x0010; | ||
| 427 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 428 | pub const SA_SIGINFO = 0x0040; | ||
| 429 | |||
| 430 | pub const SIGHUP = 1; | ||
| 431 | pub const SIGINT = 2; | ||
| 432 | pub const SIGQUIT = 3; | ||
| 433 | pub const SIGILL = 4; | ||
| 434 | pub const SIGTRAP = 5; | ||
| 435 | pub const SIGABRT = 6; | ||
| 436 | pub const SIGIOT = SIGABRT; | ||
| 437 | pub const SIGEMT = 7; | ||
| 438 | pub const SIGFPE = 8; | ||
| 439 | pub const SIGKILL = 9; | ||
| 440 | pub const SIGBUS = 10; | ||
| 441 | pub const SIGSEGV = 11; | ||
| 442 | pub const SIGSYS = 12; | ||
| 443 | pub const SIGPIPE = 13; | ||
| 444 | pub const SIGALRM = 14; | ||
| 445 | pub const SIGTERM = 15; | ||
| 446 | pub const SIGURG = 16; | ||
| 447 | pub const SIGSTOP = 17; | ||
| 448 | pub const SIGTSTP = 18; | ||
| 449 | pub const SIGCONT = 19; | ||
| 450 | pub const SIGCHLD = 20; | ||
| 451 | pub const SIGTTIN = 21; | ||
| 452 | pub const SIGTTOU = 22; | ||
| 453 | pub const SIGIO = 23; | ||
| 454 | pub const SIGXCPU = 24; | ||
| 455 | pub const SIGXFSZ = 25; | ||
| 456 | pub const SIGVTALRM = 26; | ||
| 457 | pub const SIGPROF = 27; | ||
| 458 | pub const SIGWINCH = 28; | ||
| 459 | pub const SIGINFO = 29; | ||
| 460 | pub const SIGUSR1 = 30; | ||
| 461 | pub const SIGUSR2 = 31; | ||
| 462 | pub const SIGTHR = 32; | ||
| 463 | pub const SIGLWP = SIGTHR; | ||
| 464 | pub const SIGLIBRT = 33; | ||
| 465 | |||
| 466 | pub const SIGRTMIN = 65; | ||
| 467 | pub const SIGRTMAX = 126; | ||
| 468 | |||
| 469 | // access function | ||
| 470 | pub const F_OK = 0; // test for existence of file | ||
| 471 | pub const X_OK = 1; // test for execute or search permission | ||
| 472 | pub const W_OK = 2; // test for write permission | ||
| 473 | pub const R_OK = 4; // test for read permission | ||
| 474 | |||
| 475 | pub const O_RDONLY = 0x0000; | ||
| 476 | pub const O_WRONLY = 0x0001; | ||
| 477 | pub const O_RDWR = 0x0002; | ||
| 478 | pub const O_ACCMODE = 0x0003; | ||
| 479 | |||
| 480 | pub const O_SHLOCK = 0x0010; | ||
| 481 | pub const O_EXLOCK = 0x0020; | ||
| 482 | |||
| 483 | pub const O_CREAT = 0x0200; | ||
| 484 | pub const O_EXCL = 0x0800; | ||
| 485 | pub const O_NOCTTY = 0x8000; | ||
| 486 | pub const O_TRUNC = 0x0400; | ||
| 487 | pub const O_APPEND = 0x0008; | ||
| 488 | pub const O_NONBLOCK = 0x0004; | ||
| 489 | pub const O_DSYNC = 0o10000; | ||
| 490 | pub const O_SYNC = 0x0080; | ||
| 491 | pub const O_RSYNC = 0o4010000; | ||
| 492 | pub const O_DIRECTORY = 0x20000; | ||
| 493 | pub const O_NOFOLLOW = 0x0100; | ||
| 494 | pub const O_CLOEXEC = 0x00100000; | ||
| 495 | |||
| 496 | pub const O_ASYNC = 0x0040; | ||
| 497 | pub const O_DIRECT = 0x00010000; | ||
| 498 | pub const O_NOATIME = 0o1000000; | ||
| 499 | pub const O_PATH = 0o10000000; | ||
| 500 | pub const O_TMPFILE = 0o20200000; | ||
| 501 | pub const O_NDELAY = O_NONBLOCK; | ||
| 502 | |||
| 503 | pub const F_DUPFD = 0; | ||
| 504 | pub const F_GETFD = 1; | ||
| 505 | pub const F_SETFD = 2; | ||
| 506 | pub const F_GETFL = 3; | ||
| 507 | pub const F_SETFL = 4; | ||
| 508 | |||
| 509 | pub const F_GETOWN = 5; | ||
| 510 | pub const F_SETOWN = 6; | ||
| 511 | |||
| 512 | pub const F_GETLK = 11; | ||
| 513 | pub const F_SETLK = 12; | ||
| 514 | pub const F_SETLKW = 13; | ||
| 515 | |||
| 516 | pub const F_RDLCK = 1; | ||
| 517 | pub const F_WRLCK = 3; | ||
| 518 | pub const F_UNLCK = 2; | ||
| 519 | |||
| 520 | pub const LOCK_SH = 1; | ||
| 521 | pub const LOCK_EX = 2; | ||
| 522 | pub const LOCK_UN = 8; | ||
| 523 | pub const LOCK_NB = 4; | ||
| 524 | |||
| 525 | pub const F_SETOWN_EX = 15; | ||
| 526 | pub const F_GETOWN_EX = 16; | ||
| 527 | |||
| 528 | pub const F_GETOWNER_UIDS = 17; | ||
| 529 | |||
| 530 | pub const FD_CLOEXEC = 1; | ||
| 531 | |||
| 532 | pub const SEEK_SET = 0; | ||
| 533 | pub const SEEK_CUR = 1; | ||
| 534 | pub const SEEK_END = 2; | ||
| 535 | |||
| 536 | pub const SIG_BLOCK = 1; | ||
| 537 | pub const SIG_UNBLOCK = 2; | ||
| 538 | pub const SIG_SETMASK = 3; | ||
| 539 | |||
| 540 | pub const SOCK_STREAM = 1; | ||
| 541 | pub const SOCK_DGRAM = 2; | ||
| 542 | pub const SOCK_RAW = 3; | ||
| 543 | pub const SOCK_RDM = 4; | ||
| 544 | pub const SOCK_SEQPACKET = 5; | ||
| 545 | |||
| 546 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 547 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 548 | |||
| 549 | pub const SO_DEBUG = 0x00000001; | ||
| 550 | pub const SO_ACCEPTCONN = 0x00000002; | ||
| 551 | pub const SO_REUSEADDR = 0x00000004; | ||
| 552 | pub const SO_KEEPALIVE = 0x00000008; | ||
| 553 | pub const SO_DONTROUTE = 0x00000010; | ||
| 554 | pub const SO_BROADCAST = 0x00000020; | ||
| 555 | pub const SO_USELOOPBACK = 0x00000040; | ||
| 556 | pub const SO_LINGER = 0x00000080; | ||
| 557 | pub const SO_OOBINLINE = 0x00000100; | ||
| 558 | pub const SO_REUSEPORT = 0x00000200; | ||
| 559 | pub const SO_TIMESTAMP = 0x00000400; | ||
| 560 | pub const SO_NOSIGPIPE = 0x00000800; | ||
| 561 | pub const SO_ACCEPTFILTER = 0x00001000; | ||
| 562 | pub const SO_BINTIME = 0x00002000; | ||
| 563 | pub const SO_NO_OFFLOAD = 0x00004000; | ||
| 564 | pub const SO_NO_DDP = 0x00008000; | ||
| 565 | pub const SO_REUSEPORT_LB = 0x00010000; | ||
| 566 | |||
| 567 | pub const SO_SNDBUF = 0x1001; | ||
| 568 | pub const SO_RCVBUF = 0x1002; | ||
| 569 | pub const SO_SNDLOWAT = 0x1003; | ||
| 570 | pub const SO_RCVLOWAT = 0x1004; | ||
| 571 | pub const SO_SNDTIMEO = 0x1005; | ||
| 572 | pub const SO_RCVTIMEO = 0x1006; | ||
| 573 | pub const SO_ERROR = 0x1007; | ||
| 574 | pub const SO_TYPE = 0x1008; | ||
| 575 | pub const SO_LABEL = 0x1009; | ||
| 576 | pub const SO_PEERLABEL = 0x1010; | ||
| 577 | pub const SO_LISTENQLIMIT = 0x1011; | ||
| 578 | pub const SO_LISTENQLEN = 0x1012; | ||
| 579 | pub const SO_LISTENINCQLEN = 0x1013; | ||
| 580 | pub const SO_SETFIB = 0x1014; | ||
| 581 | pub const SO_USER_COOKIE = 0x1015; | ||
| 582 | pub const SO_PROTOCOL = 0x1016; | ||
| 583 | pub const SO_PROTOTYPE = SO_PROTOCOL; | ||
| 584 | pub const SO_TS_CLOCK = 0x1017; | ||
| 585 | pub const SO_MAX_PACING_RATE = 0x1018; | ||
| 586 | pub const SO_DOMAIN = 0x1019; | ||
| 587 | |||
| 588 | pub const SOL_SOCKET = 0xffff; | ||
| 589 | |||
| 590 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 591 | pub const PF_LOCAL = AF_LOCAL; | ||
| 592 | pub const PF_UNIX = PF_LOCAL; | ||
| 593 | pub const PF_INET = AF_INET; | ||
| 594 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 595 | pub const PF_PUP = AF_PUP; | ||
| 596 | pub const PF_CHAOS = AF_CHAOS; | ||
| 597 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 598 | pub const PF_ISO = AF_ISO; | ||
| 599 | pub const PF_OSI = AF_ISO; | ||
| 600 | pub const PF_ECMA = AF_ECMA; | ||
| 601 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 602 | pub const PF_CCITT = AF_CCITT; | ||
| 603 | pub const PF_DECnet = AF_DECnet; | ||
| 604 | pub const PF_DLI = AF_DLI; | ||
| 605 | pub const PF_LAT = AF_LAT; | ||
| 606 | pub const PF_HYLINK = AF_HYLINK; | ||
| 607 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 608 | pub const PF_ROUTE = AF_ROUTE; | ||
| 609 | pub const PF_LINK = AF_LINK; | ||
| 610 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 611 | pub const PF_COIP = AF_COIP; | ||
| 612 | pub const PF_CNT = AF_CNT; | ||
| 613 | pub const PF_SIP = AF_SIP; | ||
| 614 | pub const PF_IPX = AF_IPX; | ||
| 615 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 616 | pub const PF_PIP = psuedo_AF_PIP; | ||
| 617 | pub const PF_ISDN = AF_ISDN; | ||
| 618 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 619 | pub const PF_INET6 = pseudo_AF_INET6; | ||
| 620 | pub const PF_NATM = AF_NATM; | ||
| 621 | pub const PF_ATM = AF_ATM; | ||
| 622 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 623 | pub const PF_SLOW = AF_SLOW; | ||
| 624 | pub const PF_SCLUSTER = AF_SCLUSTER; | ||
| 625 | pub const PF_ARP = AF_ARP; | ||
| 626 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 627 | pub const PF_IEEE80211 = AF_IEEE80211; | ||
| 628 | pub const PF_INET_SDP = AF_INET_SDP; | ||
| 629 | pub const PF_INET6_SDP = AF_INET6_SDP; | ||
| 630 | pub const PF_MAX = AF_MAX; | ||
| 631 | |||
| 632 | pub const AF_UNSPEC = 0; | ||
| 633 | pub const AF_UNIX = 1; | ||
| 634 | pub const AF_LOCAL = AF_UNIX; | ||
| 635 | pub const AF_FILE = AF_LOCAL; | ||
| 636 | pub const AF_INET = 2; | ||
| 637 | pub const AF_IMPLINK = 3; | ||
| 638 | pub const AF_PUP = 4; | ||
| 639 | pub const AF_CHAOS = 5; | ||
| 640 | pub const AF_NETBIOS = 6; | ||
| 641 | pub const AF_ISO = 7; | ||
| 642 | pub const AF_OSI = AF_ISO; | ||
| 643 | pub const AF_ECMA = 8; | ||
| 644 | pub const AF_DATAKIT = 9; | ||
| 645 | pub const AF_CCITT = 10; | ||
| 646 | pub const AF_SNA = 11; | ||
| 647 | pub const AF_DECnet = 12; | ||
| 648 | pub const AF_DLI = 13; | ||
| 649 | pub const AF_LAT = 14; | ||
| 650 | pub const AF_HYLINK = 15; | ||
| 651 | pub const AF_APPLETALK = 16; | ||
| 652 | pub const AF_ROUTE = 17; | ||
| 653 | pub const AF_LINK = 18; | ||
| 654 | pub const pseudo_AF_XTP = 19; | ||
| 655 | pub const AF_COIP = 20; | ||
| 656 | pub const AF_CNT = 21; | ||
| 657 | pub const pseudo_AF_RTIP = 22; | ||
| 658 | pub const AF_IPX = 23; | ||
| 659 | pub const AF_SIP = 24; | ||
| 660 | pub const pseudo_AF_PIP = 25; | ||
| 661 | pub const AF_ISDN = 26; | ||
| 662 | pub const AF_E164 = AF_ISDN; | ||
| 663 | pub const pseudo_AF_KEY = 27; | ||
| 664 | pub const AF_INET6 = 28; | ||
| 665 | pub const AF_NATM = 29; | ||
| 666 | pub const AF_ATM = 30; | ||
| 667 | pub const pseudo_AF_HDRCMPLT = 31; | ||
| 668 | pub const AF_NETGRAPH = 32; | ||
| 669 | pub const AF_SLOW = 33; | ||
| 670 | pub const AF_SCLUSTER = 34; | ||
| 671 | pub const AF_ARP = 35; | ||
| 672 | pub const AF_BLUETOOTH = 36; | ||
| 673 | pub const AF_IEEE80211 = 37; | ||
| 674 | pub const AF_INET_SDP = 40; | ||
| 675 | pub const AF_INET6_SDP = 42; | ||
| 676 | pub const AF_MAX = 42; | ||
| 677 | |||
| 678 | pub const DT_UNKNOWN = 0; | ||
| 679 | pub const DT_FIFO = 1; | ||
| 680 | pub const DT_CHR = 2; | ||
| 681 | pub const DT_DIR = 4; | ||
| 682 | pub const DT_BLK = 6; | ||
| 683 | pub const DT_REG = 8; | ||
| 684 | pub const DT_LNK = 10; | ||
| 685 | pub const DT_SOCK = 12; | ||
| 686 | pub const DT_WHT = 14; | ||
| 687 | |||
| 688 | /// add event to kq (implies enable) | ||
| 689 | pub const EV_ADD = 0x0001; | ||
| 690 | |||
| 691 | /// delete event from kq | ||
| 692 | pub const EV_DELETE = 0x0002; | ||
| 693 | |||
| 694 | /// enable event | ||
| 695 | pub const EV_ENABLE = 0x0004; | ||
| 696 | |||
| 697 | /// disable event (not reported) | ||
| 698 | pub const EV_DISABLE = 0x0008; | ||
| 699 | |||
| 700 | /// only report one occurrence | ||
| 701 | pub const EV_ONESHOT = 0x0010; | ||
| 702 | |||
| 703 | /// clear event state after reporting | ||
| 704 | pub const EV_CLEAR = 0x0020; | ||
| 705 | |||
| 706 | /// error, event data contains errno | ||
| 707 | pub const EV_ERROR = 0x4000; | ||
| 708 | |||
| 709 | /// force immediate event output | ||
| 710 | /// ... with or without EV_ERROR | ||
| 711 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 712 | /// on syscalls supporting flags | ||
| 713 | pub const EV_RECEIPT = 0x0040; | ||
| 714 | |||
| 715 | /// disable event after reporting | ||
| 716 | pub const EV_DISPATCH = 0x0080; | ||
| 717 | |||
| 718 | pub const EVFILT_READ = -1; | ||
| 719 | pub const EVFILT_WRITE = -2; | ||
| 720 | |||
| 721 | /// attached to aio requests | ||
| 722 | pub const EVFILT_AIO = -3; | ||
| 723 | |||
| 724 | /// attached to vnodes | ||
| 725 | pub const EVFILT_VNODE = -4; | ||
| 726 | |||
| 727 | /// attached to struct proc | ||
| 728 | pub const EVFILT_PROC = -5; | ||
| 729 | |||
| 730 | /// attached to struct proc | ||
| 731 | pub const EVFILT_SIGNAL = -6; | ||
| 732 | |||
| 733 | /// timers | ||
| 734 | pub const EVFILT_TIMER = -7; | ||
| 735 | |||
| 736 | /// Process descriptors | ||
| 737 | pub const EVFILT_PROCDESC = -8; | ||
| 738 | |||
| 739 | /// Filesystem events | ||
| 740 | pub const EVFILT_FS = -9; | ||
| 741 | |||
| 742 | pub const EVFILT_LIO = -10; | ||
| 743 | |||
| 744 | /// User events | ||
| 745 | pub const EVFILT_USER = -11; | ||
| 746 | |||
| 747 | /// Sendfile events | ||
| 748 | pub const EVFILT_SENDFILE = -12; | ||
| 749 | |||
| 750 | pub const EVFILT_EMPTY = -13; | ||
| 751 | |||
| 752 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 753 | pub const NOTE_TRIGGER = 0x01000000; | ||
| 754 | |||
| 755 | /// ignore input fflags | ||
| 756 | pub const NOTE_FFNOP = 0x00000000; | ||
| 757 | |||
| 758 | /// and fflags | ||
| 759 | pub const NOTE_FFAND = 0x40000000; | ||
| 760 | |||
| 761 | /// or fflags | ||
| 762 | pub const NOTE_FFOR = 0x80000000; | ||
| 763 | |||
| 764 | /// copy fflags | ||
| 765 | pub const NOTE_FFCOPY = 0xc0000000; | ||
| 766 | |||
| 767 | /// mask for operations | ||
| 768 | pub const NOTE_FFCTRLMASK = 0xc0000000; | ||
| 769 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | ||
| 770 | |||
| 771 | /// low water mark | ||
| 772 | pub const NOTE_LOWAT = 0x00000001; | ||
| 773 | |||
| 774 | /// behave like poll() | ||
| 775 | pub const NOTE_FILE_POLL = 0x00000002; | ||
| 776 | |||
| 777 | /// vnode was removed | ||
| 778 | pub const NOTE_DELETE = 0x00000001; | ||
| 779 | |||
| 780 | /// data contents changed | ||
| 781 | pub const NOTE_WRITE = 0x00000002; | ||
| 782 | |||
| 783 | /// size increased | ||
| 784 | pub const NOTE_EXTEND = 0x00000004; | ||
| 785 | |||
| 786 | /// attributes changed | ||
| 787 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 788 | |||
| 789 | /// link count changed | ||
| 790 | pub const NOTE_LINK = 0x00000010; | ||
| 791 | |||
| 792 | /// vnode was renamed | ||
| 793 | pub const NOTE_RENAME = 0x00000020; | ||
| 794 | |||
| 795 | /// vnode access was revoked | ||
| 796 | pub const NOTE_REVOKE = 0x00000040; | ||
| 797 | |||
| 798 | /// vnode was opened | ||
| 799 | pub const NOTE_OPEN = 0x00000080; | ||
| 800 | |||
| 801 | /// file closed, fd did not allow write | ||
| 802 | pub const NOTE_CLOSE = 0x00000100; | ||
| 803 | |||
| 804 | /// file closed, fd did allow write | ||
| 805 | pub const NOTE_CLOSE_WRITE = 0x00000200; | ||
| 806 | |||
| 807 | /// file was read | ||
| 808 | pub const NOTE_READ = 0x00000400; | ||
| 809 | |||
| 810 | /// process exited | ||
| 811 | pub const NOTE_EXIT = 0x80000000; | ||
| 812 | |||
| 813 | /// process forked | ||
| 814 | pub const NOTE_FORK = 0x40000000; | ||
| 815 | |||
| 816 | /// process exec'd | ||
| 817 | pub const NOTE_EXEC = 0x20000000; | ||
| 818 | |||
| 819 | /// mask for signal & exit status | ||
| 820 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 821 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | ||
| 822 | |||
| 823 | /// data is seconds | ||
| 824 | pub const NOTE_SECONDS = 0x00000001; | ||
| 825 | |||
| 826 | /// data is milliseconds | ||
| 827 | pub const NOTE_MSECONDS = 0x00000002; | ||
| 828 | |||
| 829 | /// data is microseconds | ||
| 830 | pub const NOTE_USECONDS = 0x00000004; | ||
| 831 | |||
| 832 | /// data is nanoseconds | ||
| 833 | pub const NOTE_NSECONDS = 0x00000008; | ||
| 834 | |||
| 835 | /// timeout is absolute | ||
| 836 | pub const NOTE_ABSTIME = 0x00000010; | ||
| 837 | |||
| 838 | pub const TIOCEXCL = 0x2000740d; | ||
| 839 | pub const TIOCNXCL = 0x2000740e; | ||
| 840 | pub const TIOCSCTTY = 0x20007461; | ||
| 841 | pub const TIOCGPGRP = 0x40047477; | ||
| 842 | pub const TIOCSPGRP = 0x80047476; | ||
| 843 | pub const TIOCOUTQ = 0x40047473; | ||
| 844 | pub const TIOCSTI = 0x80017472; | ||
| 845 | pub const TIOCGWINSZ = 0x40087468; | ||
| 846 | pub const TIOCSWINSZ = 0x80087467; | ||
| 847 | pub const TIOCMGET = 0x4004746a; | ||
| 848 | pub const TIOCMBIS = 0x8004746c; | ||
| 849 | pub const TIOCMBIC = 0x8004746b; | ||
| 850 | pub const TIOCMSET = 0x8004746d; | ||
| 851 | pub const FIONREAD = 0x4004667f; | ||
| 852 | pub const TIOCCONS = 0x80047462; | ||
| 853 | pub const TIOCPKT = 0x80047470; | ||
| 854 | pub const FIONBIO = 0x8004667e; | ||
| 855 | pub const TIOCNOTTY = 0x20007471; | ||
| 856 | pub const TIOCSETD = 0x8004741b; | ||
| 857 | pub const TIOCGETD = 0x4004741a; | ||
| 858 | pub const TIOCSBRK = 0x2000747b; | ||
| 859 | pub const TIOCCBRK = 0x2000747a; | ||
| 860 | pub const TIOCGSID = 0x40047463; | ||
| 861 | pub const TIOCGPTN = 0x4004740f; | ||
| 862 | pub const TIOCSIG = 0x2004745f; | ||
| 863 | |||
| 864 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 865 | return @intCast(u8, (s & 0xff00) >> 8); | ||
| 866 | } | ||
| 867 | pub fn WTERMSIG(s: u32) u32 { | ||
| 868 | return s & 0x7f; | ||
| 869 | } | ||
| 870 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 871 | return WEXITSTATUS(s); | ||
| 872 | } | ||
| 873 | pub fn WIFEXITED(s: u32) bool { | ||
| 874 | return WTERMSIG(s) == 0; | ||
| 875 | } | ||
| 876 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 877 | return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | ||
| 878 | } | ||
| 879 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 880 | return (s & 0xffff) -% 1 < 0xff; | ||
| 881 | } | ||
| 882 | |||
| 883 | pub const winsize = extern struct { | ||
| 884 | ws_row: u16, | ||
| 885 | ws_col: u16, | ||
| 886 | ws_xpixel: u16, | ||
| 887 | ws_ypixel: u16, | ||
| 888 | }; | ||
| 889 | |||
| 890 | const NSIG = 32; | ||
| 891 | |||
| 892 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 893 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 894 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 895 | |||
| 896 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 897 | pub const Sigaction = extern struct { | ||
| 898 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 899 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 900 | |||
| 901 | /// signal handler | ||
| 902 | handler: extern union { | ||
| 903 | handler: ?handler_fn, | ||
| 904 | sigaction: ?sigaction_fn, | ||
| 905 | }, | ||
| 906 | |||
| 907 | /// see signal options | ||
| 908 | flags: c_uint, | ||
| 909 | |||
| 910 | /// signal mask to apply | ||
| 911 | mask: sigset_t, | ||
| 912 | }; | ||
| 913 | |||
| 914 | pub const siginfo_t = extern struct { | ||
| 915 | signo: c_int, | ||
| 916 | errno: c_int, | ||
| 917 | code: c_int, | ||
| 918 | pid: pid_t, | ||
| 919 | uid: uid_t, | ||
| 920 | status: c_int, | ||
| 921 | addr: ?*c_void, | ||
| 922 | value: sigval, | ||
| 923 | reason: extern union { | ||
| 924 | fault: extern struct { | ||
| 925 | trapno: c_int, | ||
| 926 | }, | ||
| 927 | timer: extern struct { | ||
| 928 | timerid: c_int, | ||
| 929 | overrun: c_int, | ||
| 930 | }, | ||
| 931 | mesgq: extern struct { | ||
| 932 | mqd: c_int, | ||
| 933 | }, | ||
| 934 | poll: extern struct { | ||
| 935 | band: c_long, | ||
| 936 | }, | ||
| 937 | spare: extern struct { | ||
| 938 | spare1: c_long, | ||
| 939 | spare2: [7]c_int, | ||
| 940 | }, | ||
| 941 | }, | ||
| 942 | }; | ||
| 943 | |||
| 944 | pub const sigval = extern union { | ||
| 945 | int: c_int, | ||
| 946 | ptr: ?*c_void, | ||
| 947 | }; | ||
| 948 | |||
| 949 | pub const _SIG_WORDS = 4; | ||
| 950 | pub const _SIG_MAXSIG = 128; | ||
| 951 | |||
| 952 | pub inline fn _SIG_IDX(sig: usize) usize { | ||
| 953 | return sig - 1; | ||
| 954 | } | ||
| 955 | pub inline fn _SIG_WORD(sig: usize) usize { | ||
| 956 | return_SIG_IDX(sig) >> 5; | ||
| 957 | } | ||
| 958 | pub inline fn _SIG_BIT(sig: usize) usize { | ||
| 959 | return 1 << (_SIG_IDX(sig) & 31); | ||
| 960 | } | ||
| 961 | pub inline fn _SIG_VALID(sig: usize) usize { | ||
| 962 | return sig <= _SIG_MAXSIG and sig > 0; | ||
| 963 | } | ||
| 964 | |||
| 965 | pub const sigset_t = extern struct { | ||
| 966 | __bits: [_SIG_WORDS]u32, | ||
| 967 | }; | ||
| 968 | |||
| 969 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; | ||
| 970 | |||
| 971 | pub usingnamespace switch (builtin.cpu.arch) { | ||
| 972 | .x86_64 => struct { | ||
| 973 | pub const ucontext_t = extern struct { | ||
| 974 | sigmask: sigset_t, | ||
| 975 | mcontext: mcontext_t, | ||
| 976 | link: ?*ucontext_t, | ||
| 977 | stack: stack_t, | ||
| 978 | flags: c_int, | ||
| 979 | __spare__: [4]c_int, | ||
| 980 | }; | ||
| 981 | |||
| 982 | /// XXX x86_64 specific | ||
| 983 | pub const mcontext_t = extern struct { | ||
| 984 | onstack: u64, | ||
| 985 | rdi: u64, | ||
| 986 | rsi: u64, | ||
| 987 | rdx: u64, | ||
| 988 | rcx: u64, | ||
| 989 | r8: u64, | ||
| 990 | r9: u64, | ||
| 991 | rax: u64, | ||
| 992 | rbx: u64, | ||
| 993 | rbp: u64, | ||
| 994 | r10: u64, | ||
| 995 | r11: u64, | ||
| 996 | r12: u64, | ||
| 997 | r13: u64, | ||
| 998 | r14: u64, | ||
| 999 | r15: u64, | ||
| 1000 | trapno: u32, | ||
| 1001 | fs: u16, | ||
| 1002 | gs: u16, | ||
| 1003 | addr: u64, | ||
| 1004 | flags: u32, | ||
| 1005 | es: u16, | ||
| 1006 | ds: u16, | ||
| 1007 | err: u64, | ||
| 1008 | rip: u64, | ||
| 1009 | cs: u64, | ||
| 1010 | rflags: u64, | ||
| 1011 | rsp: u64, | ||
| 1012 | ss: u64, | ||
| 1013 | }; | ||
| 1014 | }, | ||
| 1015 | else => struct {}, | ||
| 1016 | }; | ||
| 1017 | |||
| 1018 | pub const E = enum(u16) { | ||
| 1019 | /// No error occurred. | ||
| 1020 | SUCCESS = 0, | ||
| 1021 | |||
| 1022 | PERM = 1, // Operation not permitted | ||
| 1023 | NOENT = 2, // No such file or directory | ||
| 1024 | SRCH = 3, // No such process | ||
| 1025 | INTR = 4, // Interrupted system call | ||
| 1026 | IO = 5, // Input/output error | ||
| 1027 | NXIO = 6, // Device not configured | ||
| 1028 | @"2BIG" = 7, // Argument list too long | ||
| 1029 | NOEXEC = 8, // Exec format error | ||
| 1030 | BADF = 9, // Bad file descriptor | ||
| 1031 | CHILD = 10, // No child processes | ||
| 1032 | DEADLK = 11, // Resource deadlock avoided | ||
| 1033 | // 11 was AGAIN | ||
| 1034 | NOMEM = 12, // Cannot allocate memory | ||
| 1035 | ACCES = 13, // Permission denied | ||
| 1036 | FAULT = 14, // Bad address | ||
| 1037 | NOTBLK = 15, // Block device required | ||
| 1038 | BUSY = 16, // Device busy | ||
| 1039 | EXIST = 17, // File exists | ||
| 1040 | XDEV = 18, // Cross-device link | ||
| 1041 | NODEV = 19, // Operation not supported by device | ||
| 1042 | NOTDIR = 20, // Not a directory | ||
| 1043 | ISDIR = 21, // Is a directory | ||
| 1044 | INVAL = 22, // Invalid argument | ||
| 1045 | NFILE = 23, // Too many open files in system | ||
| 1046 | MFILE = 24, // Too many open files | ||
| 1047 | NOTTY = 25, // Inappropriate ioctl for device | ||
| 1048 | TXTBSY = 26, // Text file busy | ||
| 1049 | FBIG = 27, // File too large | ||
| 1050 | NOSPC = 28, // No space left on device | ||
| 1051 | SPIPE = 29, // Illegal seek | ||
| 1052 | ROFS = 30, // Read-only filesystem | ||
| 1053 | MLINK = 31, // Too many links | ||
| 1054 | PIPE = 32, // Broken pipe | ||
| 1055 | |||
| 1056 | // math software | ||
| 1057 | DOM = 33, // Numerical argument out of domain | ||
| 1058 | RANGE = 34, // Result too large | ||
| 1059 | |||
| 1060 | // non-blocking and interrupt i/o | ||
| 1061 | |||
| 1062 | /// Resource temporarily unavailable | ||
| 1063 | /// This code is also used for `WOULDBLOCK`: operation would block. | ||
| 1064 | AGAIN = 35, | ||
| 1065 | INPROGRESS = 36, // Operation now in progress | ||
| 1066 | ALREADY = 37, // Operation already in progress | ||
| 1067 | |||
| 1068 | // ipc/network software -- argument errors | ||
| 1069 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 1070 | DESTADDRREQ = 39, // Destination address required | ||
| 1071 | MSGSIZE = 40, // Message too long | ||
| 1072 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 1073 | NOPROTOOPT = 42, // Protocol not available | ||
| 1074 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 1075 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 1076 | /// Operation not supported | ||
| 1077 | /// This code is also used for `NOTSUP`. | ||
| 1078 | OPNOTSUPP = 45, | ||
| 1079 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 1080 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 1081 | ADDRINUSE = 48, // Address already in use | ||
| 1082 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 1083 | |||
| 1084 | // ipc/network software -- operational errors | ||
| 1085 | NETDOWN = 50, // Network is down | ||
| 1086 | NETUNREACH = 51, // Network is unreachable | ||
| 1087 | NETRESET = 52, // Network dropped connection on reset | ||
| 1088 | CONNABORTED = 53, // Software caused connection abort | ||
| 1089 | CONNRESET = 54, // Connection reset by peer | ||
| 1090 | NOBUFS = 55, // No buffer space available | ||
| 1091 | ISCONN = 56, // Socket is already connected | ||
| 1092 | NOTCONN = 57, // Socket is not connected | ||
| 1093 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 1094 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 1095 | TIMEDOUT = 60, // Operation timed out | ||
| 1096 | CONNREFUSED = 61, // Connection refused | ||
| 1097 | |||
| 1098 | LOOP = 62, // Too many levels of symbolic links | ||
| 1099 | NAMETOOLONG = 63, // File name too long | ||
| 1100 | |||
| 1101 | // should be rearranged | ||
| 1102 | HOSTDOWN = 64, // Host is down | ||
| 1103 | HOSTUNREACH = 65, // No route to host | ||
| 1104 | NOTEMPTY = 66, // Directory not empty | ||
| 1105 | |||
| 1106 | // quotas & mush | ||
| 1107 | PROCLIM = 67, // Too many processes | ||
| 1108 | USERS = 68, // Too many users | ||
| 1109 | DQUOT = 69, // Disc quota exceeded | ||
| 1110 | |||
| 1111 | // Network File System | ||
| 1112 | STALE = 70, // Stale NFS file handle | ||
| 1113 | REMOTE = 71, // Too many levels of remote in path | ||
| 1114 | BADRPC = 72, // RPC struct is bad | ||
| 1115 | RPCMISMATCH = 73, // RPC version wrong | ||
| 1116 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 1117 | PROGMISMATCH = 75, // Program version wrong | ||
| 1118 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 1119 | |||
| 1120 | NOLCK = 77, // No locks available | ||
| 1121 | NOSYS = 78, // Function not implemented | ||
| 1122 | |||
| 1123 | FTYPE = 79, // Inappropriate file type or format | ||
| 1124 | AUTH = 80, // Authentication error | ||
| 1125 | NEEDAUTH = 81, // Need authenticator | ||
| 1126 | IDRM = 82, // Identifier removed | ||
| 1127 | NOMSG = 83, // No message of desired type | ||
| 1128 | OVERFLOW = 84, // Value too large to be stored in data type | ||
| 1129 | CANCELED = 85, // Operation canceled | ||
| 1130 | ILSEQ = 86, // Illegal byte sequence | ||
| 1131 | NOATTR = 87, // Attribute not found | ||
| 1132 | |||
| 1133 | DOOFUS = 88, // Programming error | ||
| 1134 | |||
| 1135 | BADMSG = 89, // Bad message | ||
| 1136 | MULTIHOP = 90, // Multihop attempted | ||
| 1137 | NOLINK = 91, // Link has been severed | ||
| 1138 | PROTO = 92, // Protocol error | ||
| 1139 | |||
| 1140 | NOTCAPABLE = 93, // Capabilities insufficient | ||
| 1141 | CAPMODE = 94, // Not permitted in capability mode | ||
| 1142 | NOTRECOVERABLE = 95, // State not recoverable | ||
| 1143 | OWNERDEAD = 96, // Previous owner died | ||
| 1144 | _, | ||
| 1145 | }; | ||
| 1146 | |||
| 1147 | pub const MINSIGSTKSZ = switch (builtin.cpu.arch) { | ||
| 1148 | .i386, .x86_64 => 2048, | ||
| 1149 | .arm, .aarch64 => 4096, | ||
| 1150 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), | ||
| 1151 | }; | ||
| 1152 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 1153 | |||
| 1154 | pub const SS_ONSTACK = 1; | ||
| 1155 | pub const SS_DISABLE = 4; | ||
| 1156 | |||
| 1157 | pub const stack_t = extern struct { | ||
| 1158 | ss_sp: [*]u8, | ||
| 1159 | ss_size: isize, | ||
| 1160 | ss_flags: i32, | ||
| 1161 | }; | ||
| 1162 | |||
| 1163 | pub const S_IFMT = 0o170000; | ||
| 1164 | |||
| 1165 | pub const S_IFIFO = 0o010000; | ||
| 1166 | pub const S_IFCHR = 0o020000; | ||
| 1167 | pub const S_IFDIR = 0o040000; | ||
| 1168 | pub const S_IFBLK = 0o060000; | ||
| 1169 | pub const S_IFREG = 0o100000; | ||
| 1170 | pub const S_IFLNK = 0o120000; | ||
| 1171 | pub const S_IFSOCK = 0o140000; | ||
| 1172 | pub const S_IFWHT = 0o160000; | ||
| 1173 | |||
| 1174 | pub const S_ISUID = 0o4000; | ||
| 1175 | pub const S_ISGID = 0o2000; | ||
| 1176 | pub const S_ISVTX = 0o1000; | ||
| 1177 | pub const S_IRWXU = 0o700; | ||
| 1178 | pub const S_IRUSR = 0o400; | ||
| 1179 | pub const S_IWUSR = 0o200; | ||
| 1180 | pub const S_IXUSR = 0o100; | ||
| 1181 | pub const S_IRWXG = 0o070; | ||
| 1182 | pub const S_IRGRP = 0o040; | ||
| 1183 | pub const S_IWGRP = 0o020; | ||
| 1184 | pub const S_IXGRP = 0o010; | ||
| 1185 | pub const S_IRWXO = 0o007; | ||
| 1186 | pub const S_IROTH = 0o004; | ||
| 1187 | pub const S_IWOTH = 0o002; | ||
| 1188 | pub const S_IXOTH = 0o001; | ||
| 1189 | |||
| 1190 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1191 | return m & S_IFMT == S_IFIFO; | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | pub fn S_ISCHR(m: u32) bool { | ||
| 1195 | return m & S_IFMT == S_IFCHR; | ||
| 1196 | } | ||
| 1197 | |||
| 1198 | pub fn S_ISDIR(m: u32) bool { | ||
| 1199 | return m & S_IFMT == S_IFDIR; | ||
| 1200 | } | ||
| 1201 | |||
| 1202 | pub fn S_ISBLK(m: u32) bool { | ||
| 1203 | return m & S_IFMT == S_IFBLK; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | pub fn S_ISREG(m: u32) bool { | ||
| 1207 | return m & S_IFMT == S_IFREG; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | pub fn S_ISLNK(m: u32) bool { | ||
| 1211 | return m & S_IFMT == S_IFLNK; | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1215 | return m & S_IFMT == S_IFSOCK; | ||
| 1216 | } | ||
| 1217 | |||
| 1218 | pub fn S_IWHT(m: u32) bool { | ||
| 1219 | return m & S_IFMT == S_IFWHT; | ||
| 1220 | } | ||
| 1221 | |||
| 1222 | pub const HOST_NAME_MAX = 255; | ||
| 1223 | |||
| 1224 | /// Magic value that specify the use of the current working directory | ||
| 1225 | /// to determine the target of relative file paths in the openat() and | ||
| 1226 | /// similar syscalls. | ||
| 1227 | pub const AT_FDCWD = -100; | ||
| 1228 | |||
| 1229 | /// Check access using effective user and group ID | ||
| 1230 | pub const AT_EACCESS = 0x0100; | ||
| 1231 | |||
| 1232 | /// Do not follow symbolic links | ||
| 1233 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | ||
| 1234 | |||
| 1235 | /// Follow symbolic link | ||
| 1236 | pub const AT_SYMLINK_FOLLOW = 0x0400; | ||
| 1237 | |||
| 1238 | /// Remove directory instead of file | ||
| 1239 | pub const AT_REMOVEDIR = 0x0800; | ||
| 1240 | |||
| 1241 | pub const addrinfo = extern struct { | ||
| 1242 | flags: i32, | ||
| 1243 | family: i32, | ||
| 1244 | socktype: i32, | ||
| 1245 | protocol: i32, | ||
| 1246 | addrlen: socklen_t, | ||
| 1247 | canonname: ?[*:0]u8, | ||
| 1248 | addr: ?*sockaddr, | ||
| 1249 | next: ?*addrinfo, | ||
| 1250 | }; | ||
| 1251 | |||
| 1252 | /// Fail if not under dirfd | ||
| 1253 | pub const AT_BENEATH = 0x1000; | ||
| 1254 | |||
| 1255 | /// dummy for IP | ||
| 1256 | pub const IPPROTO_IP = 0; | ||
| 1257 | |||
| 1258 | /// control message protocol | ||
| 1259 | pub const IPPROTO_ICMP = 1; | ||
| 1260 | |||
| 1261 | /// tcp | ||
| 1262 | pub const IPPROTO_TCP = 6; | ||
| 1263 | |||
| 1264 | /// user datagram protocol | ||
| 1265 | pub const IPPROTO_UDP = 17; | ||
| 1266 | |||
| 1267 | /// IP6 header | ||
| 1268 | pub const IPPROTO_IPV6 = 41; | ||
| 1269 | |||
| 1270 | /// raw IP packet | ||
| 1271 | pub const IPPROTO_RAW = 255; | ||
| 1272 | |||
| 1273 | /// IP6 hop-by-hop options | ||
| 1274 | pub const IPPROTO_HOPOPTS = 0; | ||
| 1275 | |||
| 1276 | /// group mgmt protocol | ||
| 1277 | pub const IPPROTO_IGMP = 2; | ||
| 1278 | |||
| 1279 | /// gateway^2 (deprecated) | ||
| 1280 | pub const IPPROTO_GGP = 3; | ||
| 1281 | |||
| 1282 | /// IPv4 encapsulation | ||
| 1283 | pub const IPPROTO_IPV4 = 4; | ||
| 1284 | |||
| 1285 | /// for compatibility | ||
| 1286 | pub const IPPROTO_IPIP = IPPROTO_IPV4; | ||
| 1287 | |||
| 1288 | /// Stream protocol II | ||
| 1289 | pub const IPPROTO_ST = 7; | ||
| 1290 | |||
| 1291 | /// exterior gateway protocol | ||
| 1292 | pub const IPPROTO_EGP = 8; | ||
| 1293 | |||
| 1294 | /// private interior gateway | ||
| 1295 | pub const IPPROTO_PIGP = 9; | ||
| 1296 | |||
| 1297 | /// BBN RCC Monitoring | ||
| 1298 | pub const IPPROTO_RCCMON = 10; | ||
| 1299 | |||
| 1300 | /// network voice protocol | ||
| 1301 | pub const IPPROTO_NVPII = 11; | ||
| 1302 | |||
| 1303 | /// pup | ||
| 1304 | pub const IPPROTO_PUP = 12; | ||
| 1305 | |||
| 1306 | /// Argus | ||
| 1307 | pub const IPPROTO_ARGUS = 13; | ||
| 1308 | |||
| 1309 | /// EMCON | ||
| 1310 | pub const IPPROTO_EMCON = 14; | ||
| 1311 | |||
| 1312 | /// Cross Net Debugger | ||
| 1313 | pub const IPPROTO_XNET = 15; | ||
| 1314 | |||
| 1315 | /// Chaos | ||
| 1316 | pub const IPPROTO_CHAOS = 16; | ||
| 1317 | |||
| 1318 | /// Multiplexing | ||
| 1319 | pub const IPPROTO_MUX = 18; | ||
| 1320 | |||
| 1321 | /// DCN Measurement Subsystems | ||
| 1322 | pub const IPPROTO_MEAS = 19; | ||
| 1323 | |||
| 1324 | /// Host Monitoring | ||
| 1325 | pub const IPPROTO_HMP = 20; | ||
| 1326 | |||
| 1327 | /// Packet Radio Measurement | ||
| 1328 | pub const IPPROTO_PRM = 21; | ||
| 1329 | |||
| 1330 | /// xns idp | ||
| 1331 | pub const IPPROTO_IDP = 22; | ||
| 1332 | |||
| 1333 | /// Trunk-1 | ||
| 1334 | pub const IPPROTO_TRUNK1 = 23; | ||
| 1335 | |||
| 1336 | /// Trunk-2 | ||
| 1337 | pub const IPPROTO_TRUNK2 = 24; | ||
| 1338 | |||
| 1339 | /// Leaf-1 | ||
| 1340 | pub const IPPROTO_LEAF1 = 25; | ||
| 1341 | |||
| 1342 | /// Leaf-2 | ||
| 1343 | pub const IPPROTO_LEAF2 = 26; | ||
| 1344 | |||
| 1345 | /// Reliable Data | ||
| 1346 | pub const IPPROTO_RDP = 27; | ||
| 1347 | |||
| 1348 | /// Reliable Transaction | ||
| 1349 | pub const IPPROTO_IRTP = 28; | ||
| 1350 | |||
| 1351 | /// tp-4 w/ class negotiation | ||
| 1352 | pub const IPPROTO_TP = 29; | ||
| 1353 | |||
| 1354 | /// Bulk Data Transfer | ||
| 1355 | pub const IPPROTO_BLT = 30; | ||
| 1356 | |||
| 1357 | /// Network Services | ||
| 1358 | pub const IPPROTO_NSP = 31; | ||
| 1359 | |||
| 1360 | /// Merit Internodal | ||
| 1361 | pub const IPPROTO_INP = 32; | ||
| 1362 | |||
| 1363 | /// Datagram Congestion Control Protocol | ||
| 1364 | pub const IPPROTO_DCCP = 33; | ||
| 1365 | |||
| 1366 | /// Third Party Connect | ||
| 1367 | pub const IPPROTO_3PC = 34; | ||
| 1368 | |||
| 1369 | /// InterDomain Policy Routing | ||
| 1370 | pub const IPPROTO_IDPR = 35; | ||
| 1371 | |||
| 1372 | /// XTP | ||
| 1373 | pub const IPPROTO_XTP = 36; | ||
| 1374 | |||
| 1375 | /// Datagram Delivery | ||
| 1376 | pub const IPPROTO_DDP = 37; | ||
| 1377 | |||
| 1378 | /// Control Message Transport | ||
| 1379 | pub const IPPROTO_CMTP = 38; | ||
| 1380 | |||
| 1381 | /// TP++ Transport | ||
| 1382 | pub const IPPROTO_TPXX = 39; | ||
| 1383 | |||
| 1384 | /// IL transport protocol | ||
| 1385 | pub const IPPROTO_IL = 40; | ||
| 1386 | |||
| 1387 | /// Source Demand Routing | ||
| 1388 | pub const IPPROTO_SDRP = 42; | ||
| 1389 | |||
| 1390 | /// IP6 routing header | ||
| 1391 | pub const IPPROTO_ROUTING = 43; | ||
| 1392 | |||
| 1393 | /// IP6 fragmentation header | ||
| 1394 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1395 | |||
| 1396 | /// InterDomain Routing | ||
| 1397 | pub const IPPROTO_IDRP = 45; | ||
| 1398 | |||
| 1399 | /// resource reservation | ||
| 1400 | pub const IPPROTO_RSVP = 46; | ||
| 1401 | |||
| 1402 | /// General Routing Encap. | ||
| 1403 | pub const IPPROTO_GRE = 47; | ||
| 1404 | |||
| 1405 | /// Mobile Host Routing | ||
| 1406 | pub const IPPROTO_MHRP = 48; | ||
| 1407 | |||
| 1408 | /// BHA | ||
| 1409 | pub const IPPROTO_BHA = 49; | ||
| 1410 | |||
| 1411 | /// IP6 Encap Sec. Payload | ||
| 1412 | pub const IPPROTO_ESP = 50; | ||
| 1413 | |||
| 1414 | /// IP6 Auth Header | ||
| 1415 | pub const IPPROTO_AH = 51; | ||
| 1416 | |||
| 1417 | /// Integ. Net Layer Security | ||
| 1418 | pub const IPPROTO_INLSP = 52; | ||
| 1419 | |||
| 1420 | /// IP with encryption | ||
| 1421 | pub const IPPROTO_SWIPE = 53; | ||
| 1422 | |||
| 1423 | /// Next Hop Resolution | ||
| 1424 | pub const IPPROTO_NHRP = 54; | ||
| 1425 | |||
| 1426 | /// IP Mobility | ||
| 1427 | pub const IPPROTO_MOBILE = 55; | ||
| 1428 | |||
| 1429 | /// Transport Layer Security | ||
| 1430 | pub const IPPROTO_TLSP = 56; | ||
| 1431 | |||
| 1432 | /// SKIP | ||
| 1433 | pub const IPPROTO_SKIP = 57; | ||
| 1434 | |||
| 1435 | /// ICMP6 | ||
| 1436 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1437 | |||
| 1438 | /// IP6 no next header | ||
| 1439 | pub const IPPROTO_NONE = 59; | ||
| 1440 | |||
| 1441 | /// IP6 destination option | ||
| 1442 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1443 | |||
| 1444 | /// any host internal protocol | ||
| 1445 | pub const IPPROTO_AHIP = 61; | ||
| 1446 | |||
| 1447 | /// CFTP | ||
| 1448 | pub const IPPROTO_CFTP = 62; | ||
| 1449 | |||
| 1450 | /// "hello" routing protocol | ||
| 1451 | pub const IPPROTO_HELLO = 63; | ||
| 1452 | |||
| 1453 | /// SATNET/Backroom EXPAK | ||
| 1454 | pub const IPPROTO_SATEXPAK = 64; | ||
| 1455 | |||
| 1456 | /// Kryptolan | ||
| 1457 | pub const IPPROTO_KRYPTOLAN = 65; | ||
| 1458 | |||
| 1459 | /// Remote Virtual Disk | ||
| 1460 | pub const IPPROTO_RVD = 66; | ||
| 1461 | |||
| 1462 | /// Pluribus Packet Core | ||
| 1463 | pub const IPPROTO_IPPC = 67; | ||
| 1464 | |||
| 1465 | /// Any distributed FS | ||
| 1466 | pub const IPPROTO_ADFS = 68; | ||
| 1467 | |||
| 1468 | /// Satnet Monitoring | ||
| 1469 | pub const IPPROTO_SATMON = 69; | ||
| 1470 | |||
| 1471 | /// VISA Protocol | ||
| 1472 | pub const IPPROTO_VISA = 70; | ||
| 1473 | |||
| 1474 | /// Packet Core Utility | ||
| 1475 | pub const IPPROTO_IPCV = 71; | ||
| 1476 | |||
| 1477 | /// Comp. Prot. Net. Executive | ||
| 1478 | pub const IPPROTO_CPNX = 72; | ||
| 1479 | |||
| 1480 | /// Comp. Prot. HeartBeat | ||
| 1481 | pub const IPPROTO_CPHB = 73; | ||
| 1482 | |||
| 1483 | /// Wang Span Network | ||
| 1484 | pub const IPPROTO_WSN = 74; | ||
| 1485 | |||
| 1486 | /// Packet Video Protocol | ||
| 1487 | pub const IPPROTO_PVP = 75; | ||
| 1488 | |||
| 1489 | /// BackRoom SATNET Monitoring | ||
| 1490 | pub const IPPROTO_BRSATMON = 76; | ||
| 1491 | |||
| 1492 | /// Sun net disk proto (temp.) | ||
| 1493 | pub const IPPROTO_ND = 77; | ||
| 1494 | |||
| 1495 | /// WIDEBAND Monitoring | ||
| 1496 | pub const IPPROTO_WBMON = 78; | ||
| 1497 | |||
| 1498 | /// WIDEBAND EXPAK | ||
| 1499 | pub const IPPROTO_WBEXPAK = 79; | ||
| 1500 | |||
| 1501 | /// ISO cnlp | ||
| 1502 | pub const IPPROTO_EON = 80; | ||
| 1503 | |||
| 1504 | /// VMTP | ||
| 1505 | pub const IPPROTO_VMTP = 81; | ||
| 1506 | |||
| 1507 | /// Secure VMTP | ||
| 1508 | pub const IPPROTO_SVMTP = 82; | ||
| 1509 | |||
| 1510 | /// Banyon VINES | ||
| 1511 | pub const IPPROTO_VINES = 83; | ||
| 1512 | |||
| 1513 | /// TTP | ||
| 1514 | pub const IPPROTO_TTP = 84; | ||
| 1515 | |||
| 1516 | /// NSFNET-IGP | ||
| 1517 | pub const IPPROTO_IGP = 85; | ||
| 1518 | |||
| 1519 | /// dissimilar gateway prot. | ||
| 1520 | pub const IPPROTO_DGP = 86; | ||
| 1521 | |||
| 1522 | /// TCF | ||
| 1523 | pub const IPPROTO_TCF = 87; | ||
| 1524 | |||
| 1525 | /// Cisco/GXS IGRP | ||
| 1526 | pub const IPPROTO_IGRP = 88; | ||
| 1527 | |||
| 1528 | /// OSPFIGP | ||
| 1529 | pub const IPPROTO_OSPFIGP = 89; | ||
| 1530 | |||
| 1531 | /// Strite RPC protocol | ||
| 1532 | pub const IPPROTO_SRPC = 90; | ||
| 1533 | |||
| 1534 | /// Locus Address Resoloution | ||
| 1535 | pub const IPPROTO_LARP = 91; | ||
| 1536 | |||
| 1537 | /// Multicast Transport | ||
| 1538 | pub const IPPROTO_MTP = 92; | ||
| 1539 | |||
| 1540 | /// AX.25 Frames | ||
| 1541 | pub const IPPROTO_AX25 = 93; | ||
| 1542 | |||
| 1543 | /// IP encapsulated in IP | ||
| 1544 | pub const IPPROTO_IPEIP = 94; | ||
| 1545 | |||
| 1546 | /// Mobile Int.ing control | ||
| 1547 | pub const IPPROTO_MICP = 95; | ||
| 1548 | |||
| 1549 | /// Semaphore Comm. security | ||
| 1550 | pub const IPPROTO_SCCSP = 96; | ||
| 1551 | |||
| 1552 | /// Ethernet IP encapsulation | ||
| 1553 | pub const IPPROTO_ETHERIP = 97; | ||
| 1554 | |||
| 1555 | /// encapsulation header | ||
| 1556 | pub const IPPROTO_ENCAP = 98; | ||
| 1557 | |||
| 1558 | /// any private encr. scheme | ||
| 1559 | pub const IPPROTO_APES = 99; | ||
| 1560 | |||
| 1561 | /// GMTP | ||
| 1562 | pub const IPPROTO_GMTP = 100; | ||
| 1563 | |||
| 1564 | /// payload compression (IPComp) | ||
| 1565 | pub const IPPROTO_IPCOMP = 108; | ||
| 1566 | |||
| 1567 | /// SCTP | ||
| 1568 | pub const IPPROTO_SCTP = 132; | ||
| 1569 | |||
| 1570 | /// IPv6 Mobility Header | ||
| 1571 | pub const IPPROTO_MH = 135; | ||
| 1572 | |||
| 1573 | /// UDP-Lite | ||
| 1574 | pub const IPPROTO_UDPLITE = 136; | ||
| 1575 | |||
| 1576 | /// IP6 Host Identity Protocol | ||
| 1577 | pub const IPPROTO_HIP = 139; | ||
| 1578 | |||
| 1579 | /// IP6 Shim6 Protocol | ||
| 1580 | pub const IPPROTO_SHIM6 = 140; | ||
| 1581 | |||
| 1582 | /// Protocol Independent Mcast | ||
| 1583 | pub const IPPROTO_PIM = 103; | ||
| 1584 | |||
| 1585 | /// CARP | ||
| 1586 | pub const IPPROTO_CARP = 112; | ||
| 1587 | |||
| 1588 | /// PGM | ||
| 1589 | pub const IPPROTO_PGM = 113; | ||
| 1590 | |||
| 1591 | /// MPLS-in-IP | ||
| 1592 | pub const IPPROTO_MPLS = 137; | ||
| 1593 | |||
| 1594 | /// PFSYNC | ||
| 1595 | pub const IPPROTO_PFSYNC = 240; | ||
| 1596 | |||
| 1597 | /// Reserved | ||
| 1598 | pub const IPPROTO_RESERVED_253 = 253; | ||
| 1599 | |||
| 1600 | /// Reserved | ||
| 1601 | pub const IPPROTO_RESERVED_254 = 254; | ||
| 1602 | |||
| 1603 | pub const rlimit_resource = enum(c_int) { | ||
| 1604 | CPU = 0, | ||
| 1605 | FSIZE = 1, | ||
| 1606 | DATA = 2, | ||
| 1607 | STACK = 3, | ||
| 1608 | CORE = 4, | ||
| 1609 | RSS = 5, | ||
| 1610 | MEMLOCK = 6, | ||
| 1611 | NPROC = 7, | ||
| 1612 | NOFILE = 8, | ||
| 1613 | SBSIZE = 9, | ||
| 1614 | VMEM = 10, | ||
| 1615 | NPTS = 11, | ||
| 1616 | SWAP = 12, | ||
| 1617 | KQUEUES = 13, | ||
| 1618 | UMTXP = 14, | ||
| 1619 | _, | ||
| 1620 | |||
| 1621 | pub const AS: rlimit_resource = .VMEM; | ||
| 1622 | }; | ||
| 1623 | |||
| 1624 | pub const rlim_t = i64; | ||
| 1625 | |||
| 1626 | /// No limit | ||
| 1627 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1628 | |||
| 1629 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1630 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1631 | |||
| 1632 | pub const rlimit = extern struct { | ||
| 1633 | /// Soft limit | ||
| 1634 | cur: rlim_t, | ||
| 1635 | /// Hard limit | ||
| 1636 | max: rlim_t, | ||
| 1637 | }; | ||
| 1638 | |||
| 1639 | pub const SHUT_RD = 0; | ||
| 1640 | pub const SHUT_WR = 1; | ||
| 1641 | pub const SHUT_RDWR = 2; | ||
| 1642 | |||
| 1643 | pub const nfds_t = u32; | ||
| 1644 | |||
| 1645 | pub const pollfd = extern struct { | ||
| 1646 | fd: fd_t, | ||
| 1647 | events: i16, | ||
| 1648 | revents: i16, | ||
| 1649 | }; | ||
| 1650 | |||
| 1651 | /// any readable data available. | ||
| 1652 | pub const POLLIN = 0x0001; | ||
| 1653 | /// OOB/Urgent readable data. | ||
| 1654 | pub const POLLPRI = 0x0002; | ||
| 1655 | /// file descriptor is writeable. | ||
| 1656 | pub const POLLOUT = 0x0004; | ||
| 1657 | /// non-OOB/URG data available. | ||
| 1658 | pub const POLLRDNORM = 0x0040; | ||
| 1659 | /// no write type differentiation. | ||
| 1660 | pub const POLLWRNORM = POLLOUT; | ||
| 1661 | /// OOB/Urgent readable data. | ||
| 1662 | pub const POLLRDBAND = 0x0080; | ||
| 1663 | /// OOB/Urgent data can be written. | ||
| 1664 | pub const POLLWRBAND = 0x0100; | ||
| 1665 | /// like POLLIN, except ignore EOF. | ||
| 1666 | pub const POLLINIGNEOF = 0x2000; | ||
| 1667 | /// some poll error occurred. | ||
| 1668 | pub const POLLERR = 0x0008; | ||
| 1669 | /// file descriptor was "hung up". | ||
| 1670 | pub const POLLHUP = 0x0010; | ||
| 1671 | /// requested events "invalid". | ||
| 1672 | pub const POLLNVAL = 0x0020; | ||
| 1673 | |||
| 1674 | pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | | ||
| 1675 | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; |
lib/std/c/generic.zig created+22| ... | @@ -0,0 +1,22 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | const Stat = std.c.Stat; | ||
| 3 | const timespec = std.c.timespec; | ||
| 4 | const Sigaction = std.c.Sigaction; | ||
| 5 | const sigset_t = std.c.sigset_t; | ||
| 6 | |||
| 7 | pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | ||
| 8 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; | ||
| 9 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 10 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | ||
| 11 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | ||
| 12 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 13 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 14 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | ||
| 15 | pub extern "c" fn sched_yield() c_int; | ||
| 16 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | ||
| 17 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 18 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | ||
| 19 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | ||
| 20 | pub extern "c" fn sigfillset(set: ?*sigset_t) void; | ||
| 21 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | ||
| 22 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; | ||
lib/std/c/haiku.zig+1373-3| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | // | ||
| 2 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 3 | const builtin = std.builtin; | 2 | const maxInt = std.math.maxInt; |
| 4 | 3 | ||
| 5 | usingnamespace std.c; | 4 | usingnamespace std.c; |
| 6 | 5 | ||
| ... | @@ -19,7 +18,7 @@ pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *i | ... | @@ -19,7 +18,7 @@ pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *i |
| 19 | 18 | ||
| 20 | pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize; | 19 | pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize; |
| 21 | 20 | ||
| 22 | pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, libc_stat: *libc_stat, stat_size: i32) usize; | 21 | pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, st: *Stat, stat_size: i32) usize; |
| 23 | 22 | ||
| 24 | pub extern "c" fn _kern_get_current_team() i32; | 23 | pub extern "c" fn _kern_get_current_team() i32; |
| 25 | 24 | ||
| ... | @@ -111,3 +110,1374 @@ pub const EAI = enum(c_int) { | ... | @@ -111,3 +110,1374 @@ pub const EAI = enum(c_int) { |
| 111 | }; | 110 | }; |
| 112 | 111 | ||
| 113 | pub const EAI_MAX = 15; | 112 | pub const EAI_MAX = 15; |
| 113 | |||
| 114 | pub const fd_t = c_int; | ||
| 115 | pub const pid_t = c_int; | ||
| 116 | pub const uid_t = u32; | ||
| 117 | pub const gid_t = u32; | ||
| 118 | pub const mode_t = c_uint; | ||
| 119 | |||
| 120 | pub const socklen_t = u32; | ||
| 121 | |||
| 122 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 123 | pub const Kevent = extern struct { | ||
| 124 | ident: usize, | ||
| 125 | filter: i16, | ||
| 126 | flags: u16, | ||
| 127 | fflags: u32, | ||
| 128 | data: i64, | ||
| 129 | udata: usize, | ||
| 130 | // TODO ext | ||
| 131 | }; | ||
| 132 | |||
| 133 | // Modes and flags for dlopen() | ||
| 134 | // include/dlfcn.h | ||
| 135 | |||
| 136 | pub const POLLIN = 0x0001; | ||
| 137 | pub const POLLERR = 0x0004; | ||
| 138 | pub const POLLNVAL = 0x1000; | ||
| 139 | pub const POLLHUP = 0x0080; | ||
| 140 | |||
| 141 | /// Bind function calls lazily. | ||
| 142 | pub const RTLD_LAZY = 1; | ||
| 143 | |||
| 144 | /// Bind function calls immediately. | ||
| 145 | pub const RTLD_NOW = 2; | ||
| 146 | |||
| 147 | pub const RTLD_MODEMASK = 0x3; | ||
| 148 | |||
| 149 | /// Make symbols globally available. | ||
| 150 | pub const RTLD_GLOBAL = 0x100; | ||
| 151 | |||
| 152 | /// Opposite of RTLD_GLOBAL, and the default. | ||
| 153 | pub const RTLD_LOCAL = 0; | ||
| 154 | |||
| 155 | /// Trace loaded objects and exit. | ||
| 156 | pub const RTLD_TRACE = 0x200; | ||
| 157 | |||
| 158 | /// Do not remove members. | ||
| 159 | pub const RTLD_NODELETE = 0x01000; | ||
| 160 | |||
| 161 | /// Do not load if not already loaded. | ||
| 162 | pub const RTLD_NOLOAD = 0x02000; | ||
| 163 | |||
| 164 | pub const dl_phdr_info = extern struct { | ||
| 165 | dlpi_addr: usize, | ||
| 166 | dlpi_name: ?[*:0]const u8, | ||
| 167 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 168 | dlpi_phnum: u16, | ||
| 169 | }; | ||
| 170 | |||
| 171 | pub const Flock = extern struct { | ||
| 172 | l_start: off_t, | ||
| 173 | l_len: off_t, | ||
| 174 | l_pid: pid_t, | ||
| 175 | l_type: i16, | ||
| 176 | l_whence: i16, | ||
| 177 | l_sysid: i32, | ||
| 178 | __unused: [4]u8, | ||
| 179 | }; | ||
| 180 | |||
| 181 | pub const msghdr = extern struct { | ||
| 182 | /// optional address | ||
| 183 | msg_name: ?*sockaddr, | ||
| 184 | |||
| 185 | /// size of address | ||
| 186 | msg_namelen: socklen_t, | ||
| 187 | |||
| 188 | /// scatter/gather array | ||
| 189 | msg_iov: [*]iovec, | ||
| 190 | |||
| 191 | /// # elements in msg_iov | ||
| 192 | msg_iovlen: i32, | ||
| 193 | |||
| 194 | /// ancillary data | ||
| 195 | msg_control: ?*c_void, | ||
| 196 | |||
| 197 | /// ancillary data buffer len | ||
| 198 | msg_controllen: socklen_t, | ||
| 199 | |||
| 200 | /// flags on received message | ||
| 201 | msg_flags: i32, | ||
| 202 | }; | ||
| 203 | |||
| 204 | pub const msghdr_const = extern struct { | ||
| 205 | /// optional address | ||
| 206 | msg_name: ?*const sockaddr, | ||
| 207 | |||
| 208 | /// size of address | ||
| 209 | msg_namelen: socklen_t, | ||
| 210 | |||
| 211 | /// scatter/gather array | ||
| 212 | msg_iov: [*]iovec_const, | ||
| 213 | |||
| 214 | /// # elements in msg_iov | ||
| 215 | msg_iovlen: i32, | ||
| 216 | |||
| 217 | /// ancillary data | ||
| 218 | msg_control: ?*c_void, | ||
| 219 | |||
| 220 | /// ancillary data buffer len | ||
| 221 | msg_controllen: socklen_t, | ||
| 222 | |||
| 223 | /// flags on received message | ||
| 224 | msg_flags: i32, | ||
| 225 | }; | ||
| 226 | |||
| 227 | pub const off_t = i64; | ||
| 228 | pub const ino_t = u64; | ||
| 229 | |||
| 230 | pub const nfds_t = u32; | ||
| 231 | |||
| 232 | pub const pollfd = extern struct { | ||
| 233 | fd: i32, | ||
| 234 | events: i16, | ||
| 235 | revents: i16, | ||
| 236 | }; | ||
| 237 | |||
| 238 | pub const Stat = extern struct { | ||
| 239 | dev: i32, | ||
| 240 | ino: u64, | ||
| 241 | mode: u32, | ||
| 242 | nlink: i32, | ||
| 243 | uid: i32, | ||
| 244 | gid: i32, | ||
| 245 | size: i64, | ||
| 246 | rdev: i32, | ||
| 247 | blksize: i32, | ||
| 248 | atim: timespec, | ||
| 249 | mtim: timespec, | ||
| 250 | ctim: timespec, | ||
| 251 | crtim: timespec, | ||
| 252 | st_type: u32, | ||
| 253 | blocks: i64, | ||
| 254 | |||
| 255 | pub fn atime(self: @This()) timespec { | ||
| 256 | return self.atim; | ||
| 257 | } | ||
| 258 | pub fn mtime(self: @This()) timespec { | ||
| 259 | return self.mtim; | ||
| 260 | } | ||
| 261 | pub fn ctime(self: @This()) timespec { | ||
| 262 | return self.ctim; | ||
| 263 | } | ||
| 264 | pub fn crtime(self: @This()) timespec { | ||
| 265 | return self.crtim; | ||
| 266 | } | ||
| 267 | }; | ||
| 268 | |||
| 269 | pub const timespec = extern struct { | ||
| 270 | tv_sec: isize, | ||
| 271 | tv_nsec: isize, | ||
| 272 | }; | ||
| 273 | |||
| 274 | pub const dirent = extern struct { | ||
| 275 | d_dev: i32, | ||
| 276 | d_pdev: i32, | ||
| 277 | d_ino: i64, | ||
| 278 | d_pino: i64, | ||
| 279 | d_reclen: u16, | ||
| 280 | d_name: [256]u8, | ||
| 281 | |||
| 282 | pub fn reclen(self: dirent) u16 { | ||
| 283 | return self.d_reclen; | ||
| 284 | } | ||
| 285 | }; | ||
| 286 | |||
| 287 | pub const image_info = extern struct { | ||
| 288 | id: u32, | ||
| 289 | type: u32, | ||
| 290 | sequence: i32, | ||
| 291 | init_order: i32, | ||
| 292 | init_routine: *c_void, | ||
| 293 | term_routine: *c_void, | ||
| 294 | device: i32, | ||
| 295 | node: i32, | ||
| 296 | name: [1024]u8, | ||
| 297 | text: *c_void, | ||
| 298 | data: *c_void, | ||
| 299 | text_size: i32, | ||
| 300 | data_size: i32, | ||
| 301 | api_version: i32, | ||
| 302 | abi: i32, | ||
| 303 | }; | ||
| 304 | |||
| 305 | pub const system_info = extern struct { | ||
| 306 | boot_time: i64, | ||
| 307 | cpu_count: u32, | ||
| 308 | max_pages: u64, | ||
| 309 | used_pages: u64, | ||
| 310 | cached_pages: u64, | ||
| 311 | block_cache_pages: u64, | ||
| 312 | ignored_pages: u64, | ||
| 313 | needed_memory: u64, | ||
| 314 | free_memory: u64, | ||
| 315 | max_swap_pages: u64, | ||
| 316 | free_swap_pages: u64, | ||
| 317 | page_faults: u32, | ||
| 318 | max_sems: u32, | ||
| 319 | used_sems: u32, | ||
| 320 | max_ports: u32, | ||
| 321 | used_ports: u32, | ||
| 322 | max_threads: u32, | ||
| 323 | used_threads: u32, | ||
| 324 | max_teams: u32, | ||
| 325 | used_teams: u32, | ||
| 326 | kernel_name: [256]u8, | ||
| 327 | kernel_build_date: [32]u8, | ||
| 328 | kernel_build_time: [32]u8, | ||
| 329 | kernel_version: i64, | ||
| 330 | abi: u32, | ||
| 331 | }; | ||
| 332 | |||
| 333 | pub const in_port_t = u16; | ||
| 334 | pub const sa_family_t = u8; | ||
| 335 | |||
| 336 | pub const sockaddr = extern struct { | ||
| 337 | /// total length | ||
| 338 | len: u8, | ||
| 339 | |||
| 340 | /// address family | ||
| 341 | family: sa_family_t, | ||
| 342 | |||
| 343 | /// actually longer; address value | ||
| 344 | data: [14]u8, | ||
| 345 | }; | ||
| 346 | |||
| 347 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 348 | |||
| 349 | pub const sockaddr_in = extern struct { | ||
| 350 | len: u8 = @sizeOf(sockaddr_in), | ||
| 351 | family: sa_family_t = AF_INET, | ||
| 352 | port: in_port_t, | ||
| 353 | addr: u32, | ||
| 354 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 355 | }; | ||
| 356 | |||
| 357 | pub const sockaddr_in6 = extern struct { | ||
| 358 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 359 | family: sa_family_t = AF_INET6, | ||
| 360 | port: in_port_t, | ||
| 361 | flowinfo: u32, | ||
| 362 | addr: [16]u8, | ||
| 363 | scope_id: u32, | ||
| 364 | }; | ||
| 365 | |||
| 366 | pub const sockaddr_un = extern struct { | ||
| 367 | len: u8 = @sizeOf(sockaddr_un), | ||
| 368 | family: sa_family_t = AF_UNIX, | ||
| 369 | path: [104]u8, | ||
| 370 | }; | ||
| 371 | |||
| 372 | pub const CTL_KERN = 1; | ||
| 373 | pub const CTL_DEBUG = 5; | ||
| 374 | |||
| 375 | pub const KERN_PROC = 14; // struct: process entries | ||
| 376 | pub const KERN_PROC_PATHNAME = 12; // path to executable | ||
| 377 | |||
| 378 | pub const PATH_MAX = 1024; | ||
| 379 | |||
| 380 | pub const STDIN_FILENO = 0; | ||
| 381 | pub const STDOUT_FILENO = 1; | ||
| 382 | pub const STDERR_FILENO = 2; | ||
| 383 | |||
| 384 | pub const PROT_NONE = 0; | ||
| 385 | pub const PROT_READ = 1; | ||
| 386 | pub const PROT_WRITE = 2; | ||
| 387 | pub const PROT_EXEC = 4; | ||
| 388 | |||
| 389 | pub const CLOCK_MONOTONIC = 0; | ||
| 390 | pub const CLOCK_REALTIME = -1; | ||
| 391 | pub const CLOCK_PROCESS_CPUTIME_ID = -2; | ||
| 392 | pub const CLOCK_THREAD_CPUTIME_ID = -3; | ||
| 393 | |||
| 394 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 395 | pub const MAP_SHARED = 0x0001; | ||
| 396 | pub const MAP_PRIVATE = 0x0002; | ||
| 397 | pub const MAP_FIXED = 0x0010; | ||
| 398 | pub const MAP_STACK = 0x0400; | ||
| 399 | pub const MAP_NOSYNC = 0x0800; | ||
| 400 | pub const MAP_ANON = 0x1000; | ||
| 401 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 402 | pub const MAP_FILE = 0; | ||
| 403 | |||
| 404 | pub const MAP_GUARD = 0x00002000; | ||
| 405 | pub const MAP_EXCL = 0x00004000; | ||
| 406 | pub const MAP_NOCORE = 0x00020000; | ||
| 407 | pub const MAP_PREFAULT_READ = 0x00040000; | ||
| 408 | pub const MAP_32BIT = 0x00080000; | ||
| 409 | |||
| 410 | pub const WNOHANG = 0x1; | ||
| 411 | pub const WUNTRACED = 0x2; | ||
| 412 | pub const WSTOPPED = 0x10; | ||
| 413 | pub const WCONTINUED = 0x4; | ||
| 414 | pub const WNOWAIT = 0x20; | ||
| 415 | pub const WEXITED = 0x08; | ||
| 416 | |||
| 417 | pub const SA_ONSTACK = 0x20; | ||
| 418 | pub const SA_RESTART = 0x10; | ||
| 419 | pub const SA_RESETHAND = 0x04; | ||
| 420 | pub const SA_NOCLDSTOP = 0x01; | ||
| 421 | pub const SA_NODEFER = 0x08; | ||
| 422 | pub const SA_NOCLDWAIT = 0x02; | ||
| 423 | pub const SA_SIGINFO = 0x40; | ||
| 424 | pub const SA_NOMASK = SA_NODEFER; | ||
| 425 | pub const SA_STACK = SA_ONSTACK; | ||
| 426 | pub const SA_ONESHOT = SA_RESETHAND; | ||
| 427 | |||
| 428 | pub const SIGHUP = 1; | ||
| 429 | pub const SIGINT = 2; | ||
| 430 | pub const SIGQUIT = 3; | ||
| 431 | pub const SIGILL = 4; | ||
| 432 | pub const SIGCHLD = 5; | ||
| 433 | pub const SIGABRT = 6; | ||
| 434 | pub const SIGIOT = SIGABRT; | ||
| 435 | pub const SIGPIPE = 7; | ||
| 436 | pub const SIGFPE = 8; | ||
| 437 | pub const SIGKILL = 9; | ||
| 438 | pub const SIGSTOP = 10; | ||
| 439 | pub const SIGSEGV = 11; | ||
| 440 | pub const SIGCONT = 12; | ||
| 441 | pub const SIGTSTP = 13; | ||
| 442 | pub const SIGALRM = 14; | ||
| 443 | pub const SIGTERM = 15; | ||
| 444 | pub const SIGTTIN = 16; | ||
| 445 | pub const SIGTTOU = 17; | ||
| 446 | pub const SIGUSR1 = 18; | ||
| 447 | pub const SIGUSR2 = 19; | ||
| 448 | pub const SIGWINCH = 20; | ||
| 449 | pub const SIGKILLTHR = 21; | ||
| 450 | pub const SIGTRAP = 22; | ||
| 451 | pub const SIGPOLL = 23; | ||
| 452 | pub const SIGPROF = 24; | ||
| 453 | pub const SIGSYS = 25; | ||
| 454 | pub const SIGURG = 26; | ||
| 455 | pub const SIGVTALRM = 27; | ||
| 456 | pub const SIGXCPU = 28; | ||
| 457 | pub const SIGXFSZ = 29; | ||
| 458 | pub const SIGBUS = 30; | ||
| 459 | pub const SIGRESERVED1 = 31; | ||
| 460 | pub const SIGRESERVED2 = 32; | ||
| 461 | |||
| 462 | // TODO: check | ||
| 463 | pub const SIGRTMIN = 65; | ||
| 464 | pub const SIGRTMAX = 126; | ||
| 465 | |||
| 466 | // access function | ||
| 467 | pub const F_OK = 0; // test for existence of file | ||
| 468 | pub const X_OK = 1; // test for execute or search permission | ||
| 469 | pub const W_OK = 2; // test for write permission | ||
| 470 | pub const R_OK = 4; // test for read permission | ||
| 471 | |||
| 472 | pub const O_RDONLY = 0x0000; | ||
| 473 | pub const O_WRONLY = 0x0001; | ||
| 474 | pub const O_RDWR = 0x0002; | ||
| 475 | pub const O_ACCMODE = 0x0003; | ||
| 476 | |||
| 477 | pub const O_SHLOCK = 0x0010; | ||
| 478 | pub const O_EXLOCK = 0x0020; | ||
| 479 | |||
| 480 | pub const O_CREAT = 0x0200; | ||
| 481 | pub const O_EXCL = 0x0800; | ||
| 482 | pub const O_NOCTTY = 0x8000; | ||
| 483 | pub const O_TRUNC = 0x0400; | ||
| 484 | pub const O_APPEND = 0x0008; | ||
| 485 | pub const O_NONBLOCK = 0x0004; | ||
| 486 | pub const O_DSYNC = 0o10000; | ||
| 487 | pub const O_SYNC = 0x0080; | ||
| 488 | pub const O_RSYNC = 0o4010000; | ||
| 489 | pub const O_DIRECTORY = 0x20000; | ||
| 490 | pub const O_NOFOLLOW = 0x0100; | ||
| 491 | pub const O_CLOEXEC = 0x00100000; | ||
| 492 | |||
| 493 | pub const O_ASYNC = 0x0040; | ||
| 494 | pub const O_DIRECT = 0x00010000; | ||
| 495 | pub const O_NOATIME = 0o1000000; | ||
| 496 | pub const O_PATH = 0o10000000; | ||
| 497 | pub const O_TMPFILE = 0o20200000; | ||
| 498 | pub const O_NDELAY = O_NONBLOCK; | ||
| 499 | |||
| 500 | pub const F_DUPFD = 0; | ||
| 501 | pub const F_GETFD = 1; | ||
| 502 | pub const F_SETFD = 2; | ||
| 503 | pub const F_GETFL = 3; | ||
| 504 | pub const F_SETFL = 4; | ||
| 505 | |||
| 506 | pub const F_GETOWN = 5; | ||
| 507 | pub const F_SETOWN = 6; | ||
| 508 | |||
| 509 | pub const F_GETLK = 11; | ||
| 510 | pub const F_SETLK = 12; | ||
| 511 | pub const F_SETLKW = 13; | ||
| 512 | |||
| 513 | pub const F_RDLCK = 1; | ||
| 514 | pub const F_WRLCK = 3; | ||
| 515 | pub const F_UNLCK = 2; | ||
| 516 | |||
| 517 | pub const LOCK_SH = 1; | ||
| 518 | pub const LOCK_EX = 2; | ||
| 519 | pub const LOCK_UN = 8; | ||
| 520 | pub const LOCK_NB = 4; | ||
| 521 | |||
| 522 | pub const F_SETOWN_EX = 15; | ||
| 523 | pub const F_GETOWN_EX = 16; | ||
| 524 | |||
| 525 | pub const F_GETOWNER_UIDS = 17; | ||
| 526 | |||
| 527 | pub const FD_CLOEXEC = 1; | ||
| 528 | |||
| 529 | pub const SEEK_SET = 0; | ||
| 530 | pub const SEEK_CUR = 1; | ||
| 531 | pub const SEEK_END = 2; | ||
| 532 | |||
| 533 | pub const SIG_BLOCK = 1; | ||
| 534 | pub const SIG_UNBLOCK = 2; | ||
| 535 | pub const SIG_SETMASK = 3; | ||
| 536 | |||
| 537 | pub const SOCK_STREAM = 1; | ||
| 538 | pub const SOCK_DGRAM = 2; | ||
| 539 | pub const SOCK_RAW = 3; | ||
| 540 | pub const SOCK_RDM = 4; | ||
| 541 | pub const SOCK_SEQPACKET = 5; | ||
| 542 | |||
| 543 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 544 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 545 | |||
| 546 | pub const SO_DEBUG = 0x00000001; | ||
| 547 | pub const SO_ACCEPTCONN = 0x00000002; | ||
| 548 | pub const SO_REUSEADDR = 0x00000004; | ||
| 549 | pub const SO_KEEPALIVE = 0x00000008; | ||
| 550 | pub const SO_DONTROUTE = 0x00000010; | ||
| 551 | pub const SO_BROADCAST = 0x00000020; | ||
| 552 | pub const SO_USELOOPBACK = 0x00000040; | ||
| 553 | pub const SO_LINGER = 0x00000080; | ||
| 554 | pub const SO_OOBINLINE = 0x00000100; | ||
| 555 | pub const SO_REUSEPORT = 0x00000200; | ||
| 556 | pub const SO_TIMESTAMP = 0x00000400; | ||
| 557 | pub const SO_NOSIGPIPE = 0x00000800; | ||
| 558 | pub const SO_ACCEPTFILTER = 0x00001000; | ||
| 559 | pub const SO_BINTIME = 0x00002000; | ||
| 560 | pub const SO_NO_OFFLOAD = 0x00004000; | ||
| 561 | pub const SO_NO_DDP = 0x00008000; | ||
| 562 | pub const SO_REUSEPORT_LB = 0x00010000; | ||
| 563 | |||
| 564 | pub const SO_SNDBUF = 0x1001; | ||
| 565 | pub const SO_RCVBUF = 0x1002; | ||
| 566 | pub const SO_SNDLOWAT = 0x1003; | ||
| 567 | pub const SO_RCVLOWAT = 0x1004; | ||
| 568 | pub const SO_SNDTIMEO = 0x1005; | ||
| 569 | pub const SO_RCVTIMEO = 0x1006; | ||
| 570 | pub const SO_ERROR = 0x1007; | ||
| 571 | pub const SO_TYPE = 0x1008; | ||
| 572 | pub const SO_LABEL = 0x1009; | ||
| 573 | pub const SO_PEERLABEL = 0x1010; | ||
| 574 | pub const SO_LISTENQLIMIT = 0x1011; | ||
| 575 | pub const SO_LISTENQLEN = 0x1012; | ||
| 576 | pub const SO_LISTENINCQLEN = 0x1013; | ||
| 577 | pub const SO_SETFIB = 0x1014; | ||
| 578 | pub const SO_USER_COOKIE = 0x1015; | ||
| 579 | pub const SO_PROTOCOL = 0x1016; | ||
| 580 | pub const SO_PROTOTYPE = SO_PROTOCOL; | ||
| 581 | pub const SO_TS_CLOCK = 0x1017; | ||
| 582 | pub const SO_MAX_PACING_RATE = 0x1018; | ||
| 583 | pub const SO_DOMAIN = 0x1019; | ||
| 584 | |||
| 585 | pub const SOL_SOCKET = 0xffff; | ||
| 586 | |||
| 587 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 588 | pub const PF_LOCAL = AF_LOCAL; | ||
| 589 | pub const PF_UNIX = PF_LOCAL; | ||
| 590 | pub const PF_INET = AF_INET; | ||
| 591 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 592 | pub const PF_PUP = AF_PUP; | ||
| 593 | pub const PF_CHAOS = AF_CHAOS; | ||
| 594 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 595 | pub const PF_ISO = AF_ISO; | ||
| 596 | pub const PF_OSI = AF_ISO; | ||
| 597 | pub const PF_ECMA = AF_ECMA; | ||
| 598 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 599 | pub const PF_CCITT = AF_CCITT; | ||
| 600 | pub const PF_DECnet = AF_DECnet; | ||
| 601 | pub const PF_DLI = AF_DLI; | ||
| 602 | pub const PF_LAT = AF_LAT; | ||
| 603 | pub const PF_HYLINK = AF_HYLINK; | ||
| 604 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 605 | pub const PF_ROUTE = AF_ROUTE; | ||
| 606 | pub const PF_LINK = AF_LINK; | ||
| 607 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 608 | pub const PF_COIP = AF_COIP; | ||
| 609 | pub const PF_CNT = AF_CNT; | ||
| 610 | pub const PF_SIP = AF_SIP; | ||
| 611 | pub const PF_IPX = AF_IPX; | ||
| 612 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 613 | pub const PF_PIP = psuedo_AF_PIP; | ||
| 614 | pub const PF_ISDN = AF_ISDN; | ||
| 615 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 616 | pub const PF_INET6 = pseudo_AF_INET6; | ||
| 617 | pub const PF_NATM = AF_NATM; | ||
| 618 | pub const PF_ATM = AF_ATM; | ||
| 619 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 620 | pub const PF_SLOW = AF_SLOW; | ||
| 621 | pub const PF_SCLUSTER = AF_SCLUSTER; | ||
| 622 | pub const PF_ARP = AF_ARP; | ||
| 623 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 624 | pub const PF_IEEE80211 = AF_IEEE80211; | ||
| 625 | pub const PF_INET_SDP = AF_INET_SDP; | ||
| 626 | pub const PF_INET6_SDP = AF_INET6_SDP; | ||
| 627 | pub const PF_MAX = AF_MAX; | ||
| 628 | |||
| 629 | pub const AF_UNSPEC = 0; | ||
| 630 | pub const AF_UNIX = 1; | ||
| 631 | pub const AF_LOCAL = AF_UNIX; | ||
| 632 | pub const AF_FILE = AF_LOCAL; | ||
| 633 | pub const AF_INET = 2; | ||
| 634 | pub const AF_IMPLINK = 3; | ||
| 635 | pub const AF_PUP = 4; | ||
| 636 | pub const AF_CHAOS = 5; | ||
| 637 | pub const AF_NETBIOS = 6; | ||
| 638 | pub const AF_ISO = 7; | ||
| 639 | pub const AF_OSI = AF_ISO; | ||
| 640 | pub const AF_ECMA = 8; | ||
| 641 | pub const AF_DATAKIT = 9; | ||
| 642 | pub const AF_CCITT = 10; | ||
| 643 | pub const AF_SNA = 11; | ||
| 644 | pub const AF_DECnet = 12; | ||
| 645 | pub const AF_DLI = 13; | ||
| 646 | pub const AF_LAT = 14; | ||
| 647 | pub const AF_HYLINK = 15; | ||
| 648 | pub const AF_APPLETALK = 16; | ||
| 649 | pub const AF_ROUTE = 17; | ||
| 650 | pub const AF_LINK = 18; | ||
| 651 | pub const pseudo_AF_XTP = 19; | ||
| 652 | pub const AF_COIP = 20; | ||
| 653 | pub const AF_CNT = 21; | ||
| 654 | pub const pseudo_AF_RTIP = 22; | ||
| 655 | pub const AF_IPX = 23; | ||
| 656 | pub const AF_SIP = 24; | ||
| 657 | pub const pseudo_AF_PIP = 25; | ||
| 658 | pub const AF_ISDN = 26; | ||
| 659 | pub const AF_E164 = AF_ISDN; | ||
| 660 | pub const pseudo_AF_KEY = 27; | ||
| 661 | pub const AF_INET6 = 28; | ||
| 662 | pub const AF_NATM = 29; | ||
| 663 | pub const AF_ATM = 30; | ||
| 664 | pub const pseudo_AF_HDRCMPLT = 31; | ||
| 665 | pub const AF_NETGRAPH = 32; | ||
| 666 | pub const AF_SLOW = 33; | ||
| 667 | pub const AF_SCLUSTER = 34; | ||
| 668 | pub const AF_ARP = 35; | ||
| 669 | pub const AF_BLUETOOTH = 36; | ||
| 670 | pub const AF_IEEE80211 = 37; | ||
| 671 | pub const AF_INET_SDP = 40; | ||
| 672 | pub const AF_INET6_SDP = 42; | ||
| 673 | pub const AF_MAX = 42; | ||
| 674 | |||
| 675 | pub const DT_UNKNOWN = 0; | ||
| 676 | pub const DT_FIFO = 1; | ||
| 677 | pub const DT_CHR = 2; | ||
| 678 | pub const DT_DIR = 4; | ||
| 679 | pub const DT_BLK = 6; | ||
| 680 | pub const DT_REG = 8; | ||
| 681 | pub const DT_LNK = 10; | ||
| 682 | pub const DT_SOCK = 12; | ||
| 683 | pub const DT_WHT = 14; | ||
| 684 | |||
| 685 | /// add event to kq (implies enable) | ||
| 686 | pub const EV_ADD = 0x0001; | ||
| 687 | |||
| 688 | /// delete event from kq | ||
| 689 | pub const EV_DELETE = 0x0002; | ||
| 690 | |||
| 691 | /// enable event | ||
| 692 | pub const EV_ENABLE = 0x0004; | ||
| 693 | |||
| 694 | /// disable event (not reported) | ||
| 695 | pub const EV_DISABLE = 0x0008; | ||
| 696 | |||
| 697 | /// only report one occurrence | ||
| 698 | pub const EV_ONESHOT = 0x0010; | ||
| 699 | |||
| 700 | /// clear event state after reporting | ||
| 701 | pub const EV_CLEAR = 0x0020; | ||
| 702 | |||
| 703 | /// force immediate event output | ||
| 704 | /// ... with or without EV_ERROR | ||
| 705 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 706 | /// on syscalls supporting flags | ||
| 707 | pub const EV_RECEIPT = 0x0040; | ||
| 708 | |||
| 709 | /// disable event after reporting | ||
| 710 | pub const EV_DISPATCH = 0x0080; | ||
| 711 | |||
| 712 | pub const EVFILT_READ = -1; | ||
| 713 | pub const EVFILT_WRITE = -2; | ||
| 714 | |||
| 715 | /// attached to aio requests | ||
| 716 | pub const EVFILT_AIO = -3; | ||
| 717 | |||
| 718 | /// attached to vnodes | ||
| 719 | pub const EVFILT_VNODE = -4; | ||
| 720 | |||
| 721 | /// attached to struct proc | ||
| 722 | pub const EVFILT_PROC = -5; | ||
| 723 | |||
| 724 | /// attached to struct proc | ||
| 725 | pub const EVFILT_SIGNAL = -6; | ||
| 726 | |||
| 727 | /// timers | ||
| 728 | pub const EVFILT_TIMER = -7; | ||
| 729 | |||
| 730 | /// Process descriptors | ||
| 731 | pub const EVFILT_PROCDESC = -8; | ||
| 732 | |||
| 733 | /// Filesystem events | ||
| 734 | pub const EVFILT_FS = -9; | ||
| 735 | |||
| 736 | pub const EVFILT_LIO = -10; | ||
| 737 | |||
| 738 | /// User events | ||
| 739 | pub const EVFILT_USER = -11; | ||
| 740 | |||
| 741 | /// Sendfile events | ||
| 742 | pub const EVFILT_SENDFILE = -12; | ||
| 743 | |||
| 744 | pub const EVFILT_EMPTY = -13; | ||
| 745 | |||
| 746 | pub const TCGETA = 0x8000; | ||
| 747 | pub const TCSETA = 0x8001; | ||
| 748 | pub const TCSETAW = 0x8004; | ||
| 749 | pub const TCSETAF = 0x8003; | ||
| 750 | pub const TCSBRK = 08005; | ||
| 751 | pub const TCXONC = 0x8007; | ||
| 752 | pub const TCFLSH = 0x8006; | ||
| 753 | |||
| 754 | pub const TIOCSCTTY = 0x8017; | ||
| 755 | pub const TIOCGPGRP = 0x8015; | ||
| 756 | pub const TIOCSPGRP = 0x8016; | ||
| 757 | pub const TIOCGWINSZ = 0x8012; | ||
| 758 | pub const TIOCSWINSZ = 0x8013; | ||
| 759 | pub const TIOCMGET = 0x8018; | ||
| 760 | pub const TIOCMBIS = 0x8022; | ||
| 761 | pub const TIOCMBIC = 0x8023; | ||
| 762 | pub const TIOCMSET = 0x8019; | ||
| 763 | pub const FIONREAD = 0xbe000001; | ||
| 764 | pub const FIONBIO = 0xbe000000; | ||
| 765 | pub const TIOCSBRK = 0x8020; | ||
| 766 | pub const TIOCCBRK = 0x8021; | ||
| 767 | pub const TIOCGSID = 0x8024; | ||
| 768 | |||
| 769 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 770 | return @intCast(u8, s & 0xff); | ||
| 771 | } | ||
| 772 | |||
| 773 | pub fn WTERMSIG(s: u32) u32 { | ||
| 774 | return (s >> 8) & 0xff; | ||
| 775 | } | ||
| 776 | |||
| 777 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 778 | return WEXITSTATUS(s); | ||
| 779 | } | ||
| 780 | |||
| 781 | pub fn WIFEXITED(s: u32) bool { | ||
| 782 | return WTERMSIG(s) == 0; | ||
| 783 | } | ||
| 784 | |||
| 785 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 786 | return ((s >> 16) & 0xff) != 0; | ||
| 787 | } | ||
| 788 | |||
| 789 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 790 | return ((s >> 8) & 0xff) != 0; | ||
| 791 | } | ||
| 792 | |||
| 793 | pub const winsize = extern struct { | ||
| 794 | ws_row: u16, | ||
| 795 | ws_col: u16, | ||
| 796 | ws_xpixel: u16, | ||
| 797 | ws_ypixel: u16, | ||
| 798 | }; | ||
| 799 | |||
| 800 | const NSIG = 32; | ||
| 801 | |||
| 802 | pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); | ||
| 803 | pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); | ||
| 804 | pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); | ||
| 805 | |||
| 806 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 807 | pub const Sigaction = extern struct { | ||
| 808 | /// signal handler | ||
| 809 | __sigaction_u: extern union { | ||
| 810 | __sa_handler: fn (i32) callconv(.C) void, | ||
| 811 | __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void, | ||
| 812 | }, | ||
| 813 | |||
| 814 | /// see signal options | ||
| 815 | sa_flags: u32, | ||
| 816 | |||
| 817 | /// signal mask to apply | ||
| 818 | sa_mask: sigset_t, | ||
| 819 | }; | ||
| 820 | |||
| 821 | pub const _SIG_WORDS = 4; | ||
| 822 | pub const _SIG_MAXSIG = 128; | ||
| 823 | pub inline fn _SIG_IDX(sig: usize) usize { | ||
| 824 | return sig - 1; | ||
| 825 | } | ||
| 826 | pub inline fn _SIG_WORD(sig: usize) usize { | ||
| 827 | return_SIG_IDX(sig) >> 5; | ||
| 828 | } | ||
| 829 | pub inline fn _SIG_BIT(sig: usize) usize { | ||
| 830 | return 1 << (_SIG_IDX(sig) & 31); | ||
| 831 | } | ||
| 832 | pub inline fn _SIG_VALID(sig: usize) usize { | ||
| 833 | return sig <= _SIG_MAXSIG and sig > 0; | ||
| 834 | } | ||
| 835 | |||
| 836 | pub const sigset_t = extern struct { | ||
| 837 | __bits: [_SIG_WORDS]u32, | ||
| 838 | }; | ||
| 839 | |||
| 840 | pub const E = enum(i32) { | ||
| 841 | /// No error occurred. | ||
| 842 | SUCCESS = 0, | ||
| 843 | PERM = -0x7ffffff1, // Operation not permitted | ||
| 844 | NOENT = -0x7fff9ffd, // No such file or directory | ||
| 845 | SRCH = -0x7fff8ff3, // No such process | ||
| 846 | INTR = -0x7ffffff6, // Interrupted system call | ||
| 847 | IO = -0x7fffffff, // Input/output error | ||
| 848 | NXIO = -0x7fff8ff5, // Device not configured | ||
| 849 | @"2BIG" = -0x7fff8fff, // Argument list too long | ||
| 850 | NOEXEC = -0x7fffecfe, // Exec format error | ||
| 851 | CHILD = -0x7fff8ffe, // No child processes | ||
| 852 | DEADLK = -0x7fff8ffd, // Resource deadlock avoided | ||
| 853 | NOMEM = -0x80000000, // Cannot allocate memory | ||
| 854 | ACCES = -0x7ffffffe, // Permission denied | ||
| 855 | FAULT = -0x7fffecff, // Bad address | ||
| 856 | BUSY = -0x7ffffff2, // Device busy | ||
| 857 | EXIST = -0x7fff9ffe, // File exists | ||
| 858 | XDEV = -0x7fff9ff5, // Cross-device link | ||
| 859 | NODEV = -0x7fff8ff9, // Operation not supported by device | ||
| 860 | NOTDIR = -0x7fff9ffb, // Not a directory | ||
| 861 | ISDIR = -0x7fff9ff7, // Is a directory | ||
| 862 | INVAL = -0x7ffffffb, // Invalid argument | ||
| 863 | NFILE = -0x7fff8ffa, // Too many open files in system | ||
| 864 | MFILE = -0x7fff9ff6, // Too many open files | ||
| 865 | NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device | ||
| 866 | TXTBSY = -0x7fff8fc5, // Text file busy | ||
| 867 | FBIG = -0x7fff8ffc, // File too large | ||
| 868 | NOSPC = -0x7fff9ff9, // No space left on device | ||
| 869 | SPIPE = -0x7fff8ff4, // Illegal seek | ||
| 870 | ROFS = -0x7fff9ff8, // Read-only filesystem | ||
| 871 | MLINK = -0x7fff8ffb, // Too many links | ||
| 872 | PIPE = -0x7fff9ff3, // Broken pipe | ||
| 873 | BADF = -0x7fffa000, // Bad file descriptor | ||
| 874 | |||
| 875 | // math software | ||
| 876 | DOM = 33, // Numerical argument out of domain | ||
| 877 | RANGE = 34, // Result too large | ||
| 878 | |||
| 879 | // non-blocking and interrupt i/o | ||
| 880 | |||
| 881 | /// Also used for `WOULDBLOCK`. | ||
| 882 | AGAIN = -0x7ffffff5, | ||
| 883 | INPROGRESS = -0x7fff8fdc, | ||
| 884 | ALREADY = -0x7fff8fdb, | ||
| 885 | |||
| 886 | // ipc/network software -- argument errors | ||
| 887 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 888 | DESTADDRREQ = 39, // Destination address required | ||
| 889 | MSGSIZE = 40, // Message too long | ||
| 890 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 891 | NOPROTOOPT = 42, // Protocol not available | ||
| 892 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 893 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 894 | /// Also used for `NOTSUP`. | ||
| 895 | OPNOTSUPP = 45, // Operation not supported | ||
| 896 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 897 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 898 | ADDRINUSE = 48, // Address already in use | ||
| 899 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 900 | |||
| 901 | // ipc/network software -- operational errors | ||
| 902 | NETDOWN = 50, // Network is down | ||
| 903 | NETUNREACH = 51, // Network is unreachable | ||
| 904 | NETRESET = 52, // Network dropped connection on reset | ||
| 905 | CONNABORTED = 53, // Software caused connection abort | ||
| 906 | CONNRESET = 54, // Connection reset by peer | ||
| 907 | NOBUFS = 55, // No buffer space available | ||
| 908 | ISCONN = 56, // Socket is already connected | ||
| 909 | NOTCONN = 57, // Socket is not connected | ||
| 910 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 911 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 912 | TIMEDOUT = 60, // Operation timed out | ||
| 913 | CONNREFUSED = 61, // Connection refused | ||
| 914 | |||
| 915 | LOOP = 62, // Too many levels of symbolic links | ||
| 916 | NAMETOOLONG = 63, // File name too long | ||
| 917 | |||
| 918 | // should be rearranged | ||
| 919 | HOSTDOWN = 64, // Host is down | ||
| 920 | HOSTUNREACH = 65, // No route to host | ||
| 921 | NOTEMPTY = 66, // Directory not empty | ||
| 922 | |||
| 923 | // quotas & mush | ||
| 924 | PROCLIM = 67, // Too many processes | ||
| 925 | USERS = 68, // Too many users | ||
| 926 | DQUOT = 69, // Disc quota exceeded | ||
| 927 | |||
| 928 | // Network File System | ||
| 929 | STALE = 70, // Stale NFS file handle | ||
| 930 | REMOTE = 71, // Too many levels of remote in path | ||
| 931 | BADRPC = 72, // RPC struct is bad | ||
| 932 | RPCMISMATCH = 73, // RPC version wrong | ||
| 933 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 934 | PROGMISMATCH = 75, // Program version wrong | ||
| 935 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 936 | |||
| 937 | NOLCK = 77, // No locks available | ||
| 938 | NOSYS = 78, // Function not implemented | ||
| 939 | |||
| 940 | FTYPE = 79, // Inappropriate file type or format | ||
| 941 | AUTH = 80, // Authentication error | ||
| 942 | NEEDAUTH = 81, // Need authenticator | ||
| 943 | IDRM = 82, // Identifier removed | ||
| 944 | NOMSG = 83, // No message of desired type | ||
| 945 | OVERFLOW = 84, // Value too large to be stored in data type | ||
| 946 | CANCELED = 85, // Operation canceled | ||
| 947 | ILSEQ = 86, // Illegal byte sequence | ||
| 948 | NOATTR = 87, // Attribute not found | ||
| 949 | |||
| 950 | DOOFUS = 88, // Programming error | ||
| 951 | |||
| 952 | BADMSG = 89, // Bad message | ||
| 953 | MULTIHOP = 90, // Multihop attempted | ||
| 954 | NOLINK = 91, // Link has been severed | ||
| 955 | PROTO = 92, // Protocol error | ||
| 956 | |||
| 957 | NOTCAPABLE = 93, // Capabilities insufficient | ||
| 958 | CAPMODE = 94, // Not permitted in capability mode | ||
| 959 | NOTRECOVERABLE = 95, // State not recoverable | ||
| 960 | OWNERDEAD = 96, // Previous owner died | ||
| 961 | |||
| 962 | _, | ||
| 963 | }; | ||
| 964 | |||
| 965 | pub const MINSIGSTKSZ = switch (builtin.cpu.arch) { | ||
| 966 | .i386, .x86_64 => 2048, | ||
| 967 | .arm, .aarch64 => 4096, | ||
| 968 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), | ||
| 969 | }; | ||
| 970 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 971 | |||
| 972 | pub const SS_ONSTACK = 1; | ||
| 973 | pub const SS_DISABLE = 4; | ||
| 974 | |||
| 975 | pub const stack_t = extern struct { | ||
| 976 | ss_sp: [*]u8, | ||
| 977 | ss_size: isize, | ||
| 978 | ss_flags: i32, | ||
| 979 | }; | ||
| 980 | |||
| 981 | pub const S_IFMT = 0o170000; | ||
| 982 | |||
| 983 | pub const S_IFIFO = 0o010000; | ||
| 984 | pub const S_IFCHR = 0o020000; | ||
| 985 | pub const S_IFDIR = 0o040000; | ||
| 986 | pub const S_IFBLK = 0o060000; | ||
| 987 | pub const S_IFREG = 0o100000; | ||
| 988 | pub const S_IFLNK = 0o120000; | ||
| 989 | pub const S_IFSOCK = 0o140000; | ||
| 990 | pub const S_IFWHT = 0o160000; | ||
| 991 | |||
| 992 | pub const S_ISUID = 0o4000; | ||
| 993 | pub const S_ISGID = 0o2000; | ||
| 994 | pub const S_ISVTX = 0o1000; | ||
| 995 | pub const S_IRWXU = 0o700; | ||
| 996 | pub const S_IRUSR = 0o400; | ||
| 997 | pub const S_IWUSR = 0o200; | ||
| 998 | pub const S_IXUSR = 0o100; | ||
| 999 | pub const S_IRWXG = 0o070; | ||
| 1000 | pub const S_IRGRP = 0o040; | ||
| 1001 | pub const S_IWGRP = 0o020; | ||
| 1002 | pub const S_IXGRP = 0o010; | ||
| 1003 | pub const S_IRWXO = 0o007; | ||
| 1004 | pub const S_IROTH = 0o004; | ||
| 1005 | pub const S_IWOTH = 0o002; | ||
| 1006 | pub const S_IXOTH = 0o001; | ||
| 1007 | |||
| 1008 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1009 | return m & S_IFMT == S_IFIFO; | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | pub fn S_ISCHR(m: u32) bool { | ||
| 1013 | return m & S_IFMT == S_IFCHR; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | pub fn S_ISDIR(m: u32) bool { | ||
| 1017 | return m & S_IFMT == S_IFDIR; | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | pub fn S_ISBLK(m: u32) bool { | ||
| 1021 | return m & S_IFMT == S_IFBLK; | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | pub fn S_ISREG(m: u32) bool { | ||
| 1025 | return m & S_IFMT == S_IFREG; | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | pub fn S_ISLNK(m: u32) bool { | ||
| 1029 | return m & S_IFMT == S_IFLNK; | ||
| 1030 | } | ||
| 1031 | |||
| 1032 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1033 | return m & S_IFMT == S_IFSOCK; | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | pub fn S_IWHT(m: u32) bool { | ||
| 1037 | return m & S_IFMT == S_IFWHT; | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | pub const HOST_NAME_MAX = 255; | ||
| 1041 | |||
| 1042 | /// Magic value that specify the use of the current working directory | ||
| 1043 | /// to determine the target of relative file paths in the openat() and | ||
| 1044 | /// similar syscalls. | ||
| 1045 | pub const AT_FDCWD = -100; | ||
| 1046 | |||
| 1047 | /// Check access using effective user and group ID | ||
| 1048 | pub const AT_EACCESS = 0x0100; | ||
| 1049 | |||
| 1050 | /// Do not follow symbolic links | ||
| 1051 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | ||
| 1052 | |||
| 1053 | /// Follow symbolic link | ||
| 1054 | pub const AT_SYMLINK_FOLLOW = 0x0400; | ||
| 1055 | |||
| 1056 | /// Remove directory instead of file | ||
| 1057 | pub const AT_REMOVEDIR = 0x0800; | ||
| 1058 | |||
| 1059 | pub const addrinfo = extern struct { | ||
| 1060 | flags: i32, | ||
| 1061 | family: i32, | ||
| 1062 | socktype: i32, | ||
| 1063 | protocol: i32, | ||
| 1064 | addrlen: socklen_t, | ||
| 1065 | canonname: ?[*:0]u8, | ||
| 1066 | addr: ?*sockaddr, | ||
| 1067 | next: ?*addrinfo, | ||
| 1068 | }; | ||
| 1069 | |||
| 1070 | /// Fail if not under dirfd | ||
| 1071 | pub const AT_BENEATH = 0x1000; | ||
| 1072 | |||
| 1073 | /// dummy for IP | ||
| 1074 | pub const IPPROTO_IP = 0; | ||
| 1075 | |||
| 1076 | /// control message protocol | ||
| 1077 | pub const IPPROTO_ICMP = 1; | ||
| 1078 | |||
| 1079 | /// tcp | ||
| 1080 | pub const IPPROTO_TCP = 6; | ||
| 1081 | |||
| 1082 | /// user datagram protocol | ||
| 1083 | pub const IPPROTO_UDP = 17; | ||
| 1084 | |||
| 1085 | /// IP6 header | ||
| 1086 | pub const IPPROTO_IPV6 = 41; | ||
| 1087 | |||
| 1088 | /// raw IP packet | ||
| 1089 | pub const IPPROTO_RAW = 255; | ||
| 1090 | |||
| 1091 | /// IP6 hop-by-hop options | ||
| 1092 | pub const IPPROTO_HOPOPTS = 0; | ||
| 1093 | |||
| 1094 | /// group mgmt protocol | ||
| 1095 | pub const IPPROTO_IGMP = 2; | ||
| 1096 | |||
| 1097 | /// gateway^2 (deprecated) | ||
| 1098 | pub const IPPROTO_GGP = 3; | ||
| 1099 | |||
| 1100 | /// IPv4 encapsulation | ||
| 1101 | pub const IPPROTO_IPV4 = 4; | ||
| 1102 | |||
| 1103 | /// for compatibility | ||
| 1104 | pub const IPPROTO_IPIP = IPPROTO_IPV4; | ||
| 1105 | |||
| 1106 | /// Stream protocol II | ||
| 1107 | pub const IPPROTO_ST = 7; | ||
| 1108 | |||
| 1109 | /// exterior gateway protocol | ||
| 1110 | pub const IPPROTO_EGP = 8; | ||
| 1111 | |||
| 1112 | /// private interior gateway | ||
| 1113 | pub const IPPROTO_PIGP = 9; | ||
| 1114 | |||
| 1115 | /// BBN RCC Monitoring | ||
| 1116 | pub const IPPROTO_RCCMON = 10; | ||
| 1117 | |||
| 1118 | /// network voice protocol | ||
| 1119 | pub const IPPROTO_NVPII = 11; | ||
| 1120 | |||
| 1121 | /// pup | ||
| 1122 | pub const IPPROTO_PUP = 12; | ||
| 1123 | |||
| 1124 | /// Argus | ||
| 1125 | pub const IPPROTO_ARGUS = 13; | ||
| 1126 | |||
| 1127 | /// EMCON | ||
| 1128 | pub const IPPROTO_EMCON = 14; | ||
| 1129 | |||
| 1130 | /// Cross Net Debugger | ||
| 1131 | pub const IPPROTO_XNET = 15; | ||
| 1132 | |||
| 1133 | /// Chaos | ||
| 1134 | pub const IPPROTO_CHAOS = 16; | ||
| 1135 | |||
| 1136 | /// Multiplexing | ||
| 1137 | pub const IPPROTO_MUX = 18; | ||
| 1138 | |||
| 1139 | /// DCN Measurement Subsystems | ||
| 1140 | pub const IPPROTO_MEAS = 19; | ||
| 1141 | |||
| 1142 | /// Host Monitoring | ||
| 1143 | pub const IPPROTO_HMP = 20; | ||
| 1144 | |||
| 1145 | /// Packet Radio Measurement | ||
| 1146 | pub const IPPROTO_PRM = 21; | ||
| 1147 | |||
| 1148 | /// xns idp | ||
| 1149 | pub const IPPROTO_IDP = 22; | ||
| 1150 | |||
| 1151 | /// Trunk-1 | ||
| 1152 | pub const IPPROTO_TRUNK1 = 23; | ||
| 1153 | |||
| 1154 | /// Trunk-2 | ||
| 1155 | pub const IPPROTO_TRUNK2 = 24; | ||
| 1156 | |||
| 1157 | /// Leaf-1 | ||
| 1158 | pub const IPPROTO_LEAF1 = 25; | ||
| 1159 | |||
| 1160 | /// Leaf-2 | ||
| 1161 | pub const IPPROTO_LEAF2 = 26; | ||
| 1162 | |||
| 1163 | /// Reliable Data | ||
| 1164 | pub const IPPROTO_RDP = 27; | ||
| 1165 | |||
| 1166 | /// Reliable Transaction | ||
| 1167 | pub const IPPROTO_IRTP = 28; | ||
| 1168 | |||
| 1169 | /// tp-4 w/ class negotiation | ||
| 1170 | pub const IPPROTO_TP = 29; | ||
| 1171 | |||
| 1172 | /// Bulk Data Transfer | ||
| 1173 | pub const IPPROTO_BLT = 30; | ||
| 1174 | |||
| 1175 | /// Network Services | ||
| 1176 | pub const IPPROTO_NSP = 31; | ||
| 1177 | |||
| 1178 | /// Merit Internodal | ||
| 1179 | pub const IPPROTO_INP = 32; | ||
| 1180 | |||
| 1181 | /// Datagram Congestion Control Protocol | ||
| 1182 | pub const IPPROTO_DCCP = 33; | ||
| 1183 | |||
| 1184 | /// Third Party Connect | ||
| 1185 | pub const IPPROTO_3PC = 34; | ||
| 1186 | |||
| 1187 | /// InterDomain Policy Routing | ||
| 1188 | pub const IPPROTO_IDPR = 35; | ||
| 1189 | |||
| 1190 | /// XTP | ||
| 1191 | pub const IPPROTO_XTP = 36; | ||
| 1192 | |||
| 1193 | /// Datagram Delivery | ||
| 1194 | pub const IPPROTO_DDP = 37; | ||
| 1195 | |||
| 1196 | /// Control Message Transport | ||
| 1197 | pub const IPPROTO_CMTP = 38; | ||
| 1198 | |||
| 1199 | /// TP++ Transport | ||
| 1200 | pub const IPPROTO_TPXX = 39; | ||
| 1201 | |||
| 1202 | /// IL transport protocol | ||
| 1203 | pub const IPPROTO_IL = 40; | ||
| 1204 | |||
| 1205 | /// Source Demand Routing | ||
| 1206 | pub const IPPROTO_SDRP = 42; | ||
| 1207 | |||
| 1208 | /// IP6 routing header | ||
| 1209 | pub const IPPROTO_ROUTING = 43; | ||
| 1210 | |||
| 1211 | /// IP6 fragmentation header | ||
| 1212 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1213 | |||
| 1214 | /// InterDomain Routing | ||
| 1215 | pub const IPPROTO_IDRP = 45; | ||
| 1216 | |||
| 1217 | /// resource reservation | ||
| 1218 | pub const IPPROTO_RSVP = 46; | ||
| 1219 | |||
| 1220 | /// General Routing Encap. | ||
| 1221 | pub const IPPROTO_GRE = 47; | ||
| 1222 | |||
| 1223 | /// Mobile Host Routing | ||
| 1224 | pub const IPPROTO_MHRP = 48; | ||
| 1225 | |||
| 1226 | /// BHA | ||
| 1227 | pub const IPPROTO_BHA = 49; | ||
| 1228 | |||
| 1229 | /// IP6 Encap Sec. Payload | ||
| 1230 | pub const IPPROTO_ESP = 50; | ||
| 1231 | |||
| 1232 | /// IP6 Auth Header | ||
| 1233 | pub const IPPROTO_AH = 51; | ||
| 1234 | |||
| 1235 | /// Integ. Net Layer Security | ||
| 1236 | pub const IPPROTO_INLSP = 52; | ||
| 1237 | |||
| 1238 | /// IP with encryption | ||
| 1239 | pub const IPPROTO_SWIPE = 53; | ||
| 1240 | |||
| 1241 | /// Next Hop Resolution | ||
| 1242 | pub const IPPROTO_NHRP = 54; | ||
| 1243 | |||
| 1244 | /// IP Mobility | ||
| 1245 | pub const IPPROTO_MOBILE = 55; | ||
| 1246 | |||
| 1247 | /// Transport Layer Security | ||
| 1248 | pub const IPPROTO_TLSP = 56; | ||
| 1249 | |||
| 1250 | /// SKIP | ||
| 1251 | pub const IPPROTO_SKIP = 57; | ||
| 1252 | |||
| 1253 | /// ICMP6 | ||
| 1254 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1255 | |||
| 1256 | /// IP6 no next header | ||
| 1257 | pub const IPPROTO_NONE = 59; | ||
| 1258 | |||
| 1259 | /// IP6 destination option | ||
| 1260 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1261 | |||
| 1262 | /// any host internal protocol | ||
| 1263 | pub const IPPROTO_AHIP = 61; | ||
| 1264 | |||
| 1265 | /// CFTP | ||
| 1266 | pub const IPPROTO_CFTP = 62; | ||
| 1267 | |||
| 1268 | /// "hello" routing protocol | ||
| 1269 | pub const IPPROTO_HELLO = 63; | ||
| 1270 | |||
| 1271 | /// SATNET/Backroom EXPAK | ||
| 1272 | pub const IPPROTO_SATEXPAK = 64; | ||
| 1273 | |||
| 1274 | /// Kryptolan | ||
| 1275 | pub const IPPROTO_KRYPTOLAN = 65; | ||
| 1276 | |||
| 1277 | /// Remote Virtual Disk | ||
| 1278 | pub const IPPROTO_RVD = 66; | ||
| 1279 | |||
| 1280 | /// Pluribus Packet Core | ||
| 1281 | pub const IPPROTO_IPPC = 67; | ||
| 1282 | |||
| 1283 | /// Any distributed FS | ||
| 1284 | pub const IPPROTO_ADFS = 68; | ||
| 1285 | |||
| 1286 | /// Satnet Monitoring | ||
| 1287 | pub const IPPROTO_SATMON = 69; | ||
| 1288 | |||
| 1289 | /// VISA Protocol | ||
| 1290 | pub const IPPROTO_VISA = 70; | ||
| 1291 | |||
| 1292 | /// Packet Core Utility | ||
| 1293 | pub const IPPROTO_IPCV = 71; | ||
| 1294 | |||
| 1295 | /// Comp. Prot. Net. Executive | ||
| 1296 | pub const IPPROTO_CPNX = 72; | ||
| 1297 | |||
| 1298 | /// Comp. Prot. HeartBeat | ||
| 1299 | pub const IPPROTO_CPHB = 73; | ||
| 1300 | |||
| 1301 | /// Wang Span Network | ||
| 1302 | pub const IPPROTO_WSN = 74; | ||
| 1303 | |||
| 1304 | /// Packet Video Protocol | ||
| 1305 | pub const IPPROTO_PVP = 75; | ||
| 1306 | |||
| 1307 | /// BackRoom SATNET Monitoring | ||
| 1308 | pub const IPPROTO_BRSATMON = 76; | ||
| 1309 | |||
| 1310 | /// Sun net disk proto (temp.) | ||
| 1311 | pub const IPPROTO_ND = 77; | ||
| 1312 | |||
| 1313 | /// WIDEBAND Monitoring | ||
| 1314 | pub const IPPROTO_WBMON = 78; | ||
| 1315 | |||
| 1316 | /// WIDEBAND EXPAK | ||
| 1317 | pub const IPPROTO_WBEXPAK = 79; | ||
| 1318 | |||
| 1319 | /// ISO cnlp | ||
| 1320 | pub const IPPROTO_EON = 80; | ||
| 1321 | |||
| 1322 | /// VMTP | ||
| 1323 | pub const IPPROTO_VMTP = 81; | ||
| 1324 | |||
| 1325 | /// Secure VMTP | ||
| 1326 | pub const IPPROTO_SVMTP = 82; | ||
| 1327 | |||
| 1328 | /// Banyon VINES | ||
| 1329 | pub const IPPROTO_VINES = 83; | ||
| 1330 | |||
| 1331 | /// TTP | ||
| 1332 | pub const IPPROTO_TTP = 84; | ||
| 1333 | |||
| 1334 | /// NSFNET-IGP | ||
| 1335 | pub const IPPROTO_IGP = 85; | ||
| 1336 | |||
| 1337 | /// dissimilar gateway prot. | ||
| 1338 | pub const IPPROTO_DGP = 86; | ||
| 1339 | |||
| 1340 | /// TCF | ||
| 1341 | pub const IPPROTO_TCF = 87; | ||
| 1342 | |||
| 1343 | /// Cisco/GXS IGRP | ||
| 1344 | pub const IPPROTO_IGRP = 88; | ||
| 1345 | |||
| 1346 | /// OSPFIGP | ||
| 1347 | pub const IPPROTO_OSPFIGP = 89; | ||
| 1348 | |||
| 1349 | /// Strite RPC protocol | ||
| 1350 | pub const IPPROTO_SRPC = 90; | ||
| 1351 | |||
| 1352 | /// Locus Address Resoloution | ||
| 1353 | pub const IPPROTO_LARP = 91; | ||
| 1354 | |||
| 1355 | /// Multicast Transport | ||
| 1356 | pub const IPPROTO_MTP = 92; | ||
| 1357 | |||
| 1358 | /// AX.25 Frames | ||
| 1359 | pub const IPPROTO_AX25 = 93; | ||
| 1360 | |||
| 1361 | /// IP encapsulated in IP | ||
| 1362 | pub const IPPROTO_IPEIP = 94; | ||
| 1363 | |||
| 1364 | /// Mobile Int.ing control | ||
| 1365 | pub const IPPROTO_MICP = 95; | ||
| 1366 | |||
| 1367 | /// Semaphore Comm. security | ||
| 1368 | pub const IPPROTO_SCCSP = 96; | ||
| 1369 | |||
| 1370 | /// Ethernet IP encapsulation | ||
| 1371 | pub const IPPROTO_ETHERIP = 97; | ||
| 1372 | |||
| 1373 | /// encapsulation header | ||
| 1374 | pub const IPPROTO_ENCAP = 98; | ||
| 1375 | |||
| 1376 | /// any private encr. scheme | ||
| 1377 | pub const IPPROTO_APES = 99; | ||
| 1378 | |||
| 1379 | /// GMTP | ||
| 1380 | pub const IPPROTO_GMTP = 100; | ||
| 1381 | |||
| 1382 | /// payload compression (IPComp) | ||
| 1383 | pub const IPPROTO_IPCOMP = 108; | ||
| 1384 | |||
| 1385 | /// SCTP | ||
| 1386 | pub const IPPROTO_SCTP = 132; | ||
| 1387 | |||
| 1388 | /// IPv6 Mobility Header | ||
| 1389 | pub const IPPROTO_MH = 135; | ||
| 1390 | |||
| 1391 | /// UDP-Lite | ||
| 1392 | pub const IPPROTO_UDPLITE = 136; | ||
| 1393 | |||
| 1394 | /// IP6 Host Identity Protocol | ||
| 1395 | pub const IPPROTO_HIP = 139; | ||
| 1396 | |||
| 1397 | /// IP6 Shim6 Protocol | ||
| 1398 | pub const IPPROTO_SHIM6 = 140; | ||
| 1399 | |||
| 1400 | /// Protocol Independent Mcast | ||
| 1401 | pub const IPPROTO_PIM = 103; | ||
| 1402 | |||
| 1403 | /// CARP | ||
| 1404 | pub const IPPROTO_CARP = 112; | ||
| 1405 | |||
| 1406 | /// PGM | ||
| 1407 | pub const IPPROTO_PGM = 113; | ||
| 1408 | |||
| 1409 | /// MPLS-in-IP | ||
| 1410 | pub const IPPROTO_MPLS = 137; | ||
| 1411 | |||
| 1412 | /// PFSYNC | ||
| 1413 | pub const IPPROTO_PFSYNC = 240; | ||
| 1414 | |||
| 1415 | /// Reserved | ||
| 1416 | pub const IPPROTO_RESERVED_253 = 253; | ||
| 1417 | |||
| 1418 | /// Reserved | ||
| 1419 | pub const IPPROTO_RESERVED_254 = 254; | ||
| 1420 | |||
| 1421 | pub const rlimit_resource = enum(c_int) { | ||
| 1422 | CPU = 0, | ||
| 1423 | FSIZE = 1, | ||
| 1424 | DATA = 2, | ||
| 1425 | STACK = 3, | ||
| 1426 | CORE = 4, | ||
| 1427 | RSS = 5, | ||
| 1428 | MEMLOCK = 6, | ||
| 1429 | NPROC = 7, | ||
| 1430 | NOFILE = 8, | ||
| 1431 | SBSIZE = 9, | ||
| 1432 | VMEM = 10, | ||
| 1433 | NPTS = 11, | ||
| 1434 | SWAP = 12, | ||
| 1435 | KQUEUES = 13, | ||
| 1436 | UMTXP = 14, | ||
| 1437 | _, | ||
| 1438 | |||
| 1439 | pub const AS: rlimit_resource = .VMEM; | ||
| 1440 | }; | ||
| 1441 | |||
| 1442 | pub const rlim_t = i64; | ||
| 1443 | |||
| 1444 | /// No limit | ||
| 1445 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1446 | |||
| 1447 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1448 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1449 | |||
| 1450 | pub const rlimit = extern struct { | ||
| 1451 | /// Soft limit | ||
| 1452 | cur: rlim_t, | ||
| 1453 | /// Hard limit | ||
| 1454 | max: rlim_t, | ||
| 1455 | }; | ||
| 1456 | |||
| 1457 | pub const SHUT_RD = 0; | ||
| 1458 | pub const SHUT_WR = 1; | ||
| 1459 | pub const SHUT_RDWR = 2; | ||
| 1460 | |||
| 1461 | // TODO fill out if needed | ||
| 1462 | pub const directory_which = enum(c_int) { | ||
| 1463 | B_USER_SETTINGS_DIRECTORY = 0xbbe, | ||
| 1464 | |||
| 1465 | _, | ||
| 1466 | }; | ||
| 1467 | |||
| 1468 | pub const cc_t = u8; | ||
| 1469 | pub const speed_t = u8; | ||
| 1470 | pub const tcflag_t = u32; | ||
| 1471 | |||
| 1472 | pub const NCCS = 32; | ||
| 1473 | |||
| 1474 | pub const termios = extern struct { | ||
| 1475 | c_iflag: tcflag_t, | ||
| 1476 | c_oflag: tcflag_t, | ||
| 1477 | c_cflag: tcflag_t, | ||
| 1478 | c_lflag: tcflag_t, | ||
| 1479 | c_line: cc_t, | ||
| 1480 | c_ispeed: speed_t, | ||
| 1481 | c_ospeed: speed_t, | ||
| 1482 | cc_t: [NCCS]cc_t, | ||
| 1483 | }; |
lib/std/c/linux.zig+160-31| ... | @@ -1,11 +1,66 @@ | ... | @@ -1,11 +1,66 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | const maxInt = std.math.maxInt; | 3 | const maxInt = std.math.maxInt; |
| 3 | const abi = std.Target.current.abi; | 4 | const native_abi = builtin.abi; |
| 4 | const arch = std.Target.current.cpu.arch; | 5 | const native_arch = builtin.cpu.arch; |
| 5 | const os_tag = std.Target.current.os.tag; | 6 | const linux = std.os.linux; |
| 6 | usingnamespace std.c; | ||
| 7 | 7 | ||
| 8 | pub const _errno = switch (abi) { | 8 | pub const E = linux.E; |
| 9 | pub const Sigaction = linux.Sigaction; | ||
| 10 | pub const dl_phdr_info = linux.dl_phdr_info; | ||
| 11 | pub const fd_t = linux.fd_t; | ||
| 12 | pub const rlimit = linux.rlimit; | ||
| 13 | pub const rlimit_resource = linux.rlimit_resource; | ||
| 14 | pub const timespec = linux.timespec; | ||
| 15 | pub const NAME_MAX = linux.NAME_MAX; | ||
| 16 | pub const PATH_MAX = linux.PATH_MAX; | ||
| 17 | pub const IOV_MAX = linux.IOV_MAX; | ||
| 18 | pub const STDIN_FILENO = linux.STDIN_FILENO; | ||
| 19 | pub const STDOUT_FILENO = linux.STDIN_FILENO; | ||
| 20 | pub const STDERR_FILENO = linux.STDIN_FILENO; | ||
| 21 | pub const AT = linux.AT; | ||
| 22 | pub const PROT = linux.PROT; | ||
| 23 | pub const CLOCK = linux.CLOCK; | ||
| 24 | pub const SIG = linux.SIG; | ||
| 25 | pub const empty_sigset = linux.empty_sigset; | ||
| 26 | pub const S = linux.S; | ||
| 27 | pub const siginfo_t = linux.siginfo_t; | ||
| 28 | pub const SA = linux.SA; | ||
| 29 | pub const pollfd = linux.pollfd; | ||
| 30 | pub const sigset_t = linux.sigset_t; | ||
| 31 | pub const ARCH = linux.ARCH; | ||
| 32 | pub const Elf_Symndx = linux.Elf_Symndx; | ||
| 33 | pub const F = linux.F; | ||
| 34 | pub const Flock = linux.Flock; | ||
| 35 | pub const LOCK = linux.LOCK; | ||
| 36 | pub const MAP = linux.MAP; | ||
| 37 | pub const MMAP2_UNIT = linux.MMAP2_UNIT; | ||
| 38 | pub const O = linux.O; | ||
| 39 | pub const REG = linux.REG; | ||
| 40 | pub const SC = linux.SC; | ||
| 41 | pub const SYS = linux.SYS; | ||
| 42 | pub const VDSO = linux.VDSO; | ||
| 43 | pub const blkcnt_t = linux.blkcnt_t; | ||
| 44 | pub const blksize_t = linux.blksize_t; | ||
| 45 | pub const dev_t = linux.dev_t; | ||
| 46 | pub const ino_t = linux.ino_t; | ||
| 47 | pub const mcontext_t = linux.mcontext_t; | ||
| 48 | pub const mode_t = linux.mode_t; | ||
| 49 | pub const msghdr = linux.msghdr; | ||
| 50 | pub const msghdr_const = linux.msghdr_const; | ||
| 51 | pub const nlink_t = linux.nlink_t; | ||
| 52 | pub const off_t = linux.off_t; | ||
| 53 | pub const time_t = linux.time_t; | ||
| 54 | pub const timeval = linux.timeval; | ||
| 55 | pub const timezone = linux.timezone; | ||
| 56 | pub const ucontext_t = linux.ucontext_t; | ||
| 57 | pub const user_desc = linux.user_desc; | ||
| 58 | pub const pid_t = linux.pid_t; | ||
| 59 | pub const uid_t = linux.uid_t; | ||
| 60 | pub const gid_t = linux.gid_t; | ||
| 61 | pub const clock_t = linux.clock_t; | ||
| 62 | |||
| 63 | pub const _errno = switch (native_abi) { | ||
| 9 | .android => struct { | 64 | .android => struct { |
| 10 | extern "c" var __errno: c_int; | 65 | extern "c" var __errno: c_int; |
| 11 | fn getErrno() *c_int { | 66 | fn getErrno() *c_int { |
| ... | @@ -17,22 +72,94 @@ pub const _errno = switch (abi) { | ... | @@ -17,22 +72,94 @@ pub const _errno = switch (abi) { |
| 17 | }.__errno_location, | 72 | }.__errno_location, |
| 18 | }; | 73 | }; |
| 19 | 74 | ||
| 75 | pub const Stat = switch (native_arch) { | ||
| 76 | .sparcv9 => extern struct { | ||
| 77 | dev: u64, | ||
| 78 | ino: ino_t, | ||
| 79 | mode: u32, | ||
| 80 | nlink: usize, | ||
| 81 | |||
| 82 | uid: u32, | ||
| 83 | gid: u32, | ||
| 84 | rdev: u64, | ||
| 85 | __pad0: u32, | ||
| 86 | |||
| 87 | size: off_t, | ||
| 88 | blksize: isize, | ||
| 89 | blocks: i64, | ||
| 90 | |||
| 91 | atim: timespec, | ||
| 92 | mtim: timespec, | ||
| 93 | ctim: timespec, | ||
| 94 | __unused: [2]isize, | ||
| 95 | |||
| 96 | pub fn atime(self: @This()) timespec { | ||
| 97 | return self.atim; | ||
| 98 | } | ||
| 99 | |||
| 100 | pub fn mtime(self: @This()) timespec { | ||
| 101 | return self.mtim; | ||
| 102 | } | ||
| 103 | |||
| 104 | pub fn ctime(self: @This()) timespec { | ||
| 105 | return self.ctim; | ||
| 106 | } | ||
| 107 | }, | ||
| 108 | .mips, .mipsel => extern struct { | ||
| 109 | dev: dev_t, | ||
| 110 | __pad0: [2]u32, | ||
| 111 | ino: ino_t, | ||
| 112 | mode: mode_t, | ||
| 113 | nlink: nlink_t, | ||
| 114 | uid: uid_t, | ||
| 115 | gid: gid_t, | ||
| 116 | rdev: dev_t, | ||
| 117 | __pad1: [2]u32, | ||
| 118 | size: off_t, | ||
| 119 | atim: timespec, | ||
| 120 | mtim: timespec, | ||
| 121 | ctim: timespec, | ||
| 122 | blksize: blksize_t, | ||
| 123 | __pad3: u32, | ||
| 124 | blocks: blkcnt_t, | ||
| 125 | __pad4: [14]u32, | ||
| 126 | |||
| 127 | pub fn atime(self: @This()) timespec { | ||
| 128 | return self.atim; | ||
| 129 | } | ||
| 130 | |||
| 131 | pub fn mtime(self: @This()) timespec { | ||
| 132 | return self.mtim; | ||
| 133 | } | ||
| 134 | |||
| 135 | pub fn ctime(self: @This()) timespec { | ||
| 136 | return self.ctim; | ||
| 137 | } | ||
| 138 | }, | ||
| 139 | |||
| 140 | else => std.os.linux.Stat, // libc stat is the same as kernel stat. | ||
| 141 | }; | ||
| 142 | |||
| 20 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | 143 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); |
| 21 | 144 | ||
| 22 | pub const AI_PASSIVE = 0x01; | 145 | pub const AI = struct { |
| 23 | pub const AI_CANONNAME = 0x02; | 146 | pub const PASSIVE = 0x01; |
| 24 | pub const AI_NUMERICHOST = 0x04; | 147 | pub const CANONNAME = 0x02; |
| 25 | pub const AI_V4MAPPED = 0x08; | 148 | pub const NUMERICHOST = 0x04; |
| 26 | pub const AI_ALL = 0x10; | 149 | pub const V4MAPPED = 0x08; |
| 27 | pub const AI_ADDRCONFIG = 0x20; | 150 | pub const ALL = 0x10; |
| 28 | pub const AI_NUMERICSERV = 0x400; | 151 | pub const ADDRCONFIG = 0x20; |
| 29 | 152 | pub const NUMERICSERV = 0x400; | |
| 30 | pub const NI_NUMERICHOST = 0x01; | 153 | }; |
| 31 | pub const NI_NUMERICSERV = 0x02; | 154 | |
| 32 | pub const NI_NOFQDN = 0x04; | 155 | pub const NI = struct { |
| 33 | pub const NI_NAMEREQD = 0x08; | 156 | pub const NUMERICHOST = 0x01; |
| 34 | pub const NI_DGRAM = 0x10; | 157 | pub const NUMERICSERV = 0x02; |
| 35 | pub const NI_NUMERICSCOPE = 0x100; | 158 | pub const NOFQDN = 0x04; |
| 159 | pub const NAMEREQD = 0x08; | ||
| 160 | pub const DGRAM = 0x10; | ||
| 161 | pub const NUMERICSCOPE = 0x100; | ||
| 162 | }; | ||
| 36 | 163 | ||
| 37 | pub const EAI = enum(c_int) { | 164 | pub const EAI = enum(c_int) { |
| 38 | BADFLAGS = -1, | 165 | BADFLAGS = -1, |
| ... | @@ -60,8 +187,8 @@ pub const EAI = enum(c_int) { | ... | @@ -60,8 +187,8 @@ pub const EAI = enum(c_int) { |
| 60 | 187 | ||
| 61 | pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; | 188 | pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; |
| 62 | pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; | 189 | pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; |
| 63 | pub extern "c" fn fstat64(fd: fd_t, buf: *libc_stat) c_int; | 190 | pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int; |
| 64 | pub extern "c" fn fstatat64(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int; | 191 | pub extern "c" fn fstatat64(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; |
| 65 | pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int; | 192 | pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int; |
| 66 | pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int; | 193 | pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int; |
| 67 | pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64; | 194 | pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64; |
| ... | @@ -137,7 +264,7 @@ pub const pthread_mutex_t = extern struct { | ... | @@ -137,7 +264,7 @@ pub const pthread_mutex_t = extern struct { |
| 137 | pub const pthread_cond_t = extern struct { | 264 | pub const pthread_cond_t = extern struct { |
| 138 | size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, | 265 | size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, |
| 139 | }; | 266 | }; |
| 140 | pub const pthread_rwlock_t = switch (abi) { | 267 | pub const pthread_rwlock_t = switch (native_abi) { |
| 141 | .android => switch (@sizeOf(usize)) { | 268 | .android => switch (@sizeOf(usize)) { |
| 142 | 4 => extern struct { | 269 | 4 => extern struct { |
| 143 | lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER, | 270 | lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER, |
| ... | @@ -168,11 +295,11 @@ pub const sem_t = extern struct { | ... | @@ -168,11 +295,11 @@ pub const sem_t = extern struct { |
| 168 | }; | 295 | }; |
| 169 | 296 | ||
| 170 | const __SIZEOF_PTHREAD_COND_T = 48; | 297 | const __SIZEOF_PTHREAD_COND_T = 48; |
| 171 | const __SIZEOF_PTHREAD_MUTEX_T = if (os_tag == .fuchsia) 40 else switch (abi) { | 298 | const __SIZEOF_PTHREAD_MUTEX_T = switch (native_abi) { |
| 172 | .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, | 299 | .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, |
| 173 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (arch) { | 300 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) { |
| 174 | .aarch64 => 48, | 301 | .aarch64 => 48, |
| 175 | .x86_64 => if (abi == .gnux32) 40 else 32, | 302 | .x86_64 => if (native_abi == .gnux32) 40 else 32, |
| 176 | .mips64, .powerpc64, .powerpc64le, .sparcv9 => 40, | 303 | .mips64, .powerpc64, .powerpc64le, .sparcv9 => 40, |
| 177 | else => if (@sizeOf(usize) == 8) 40 else 24, | 304 | else => if (@sizeOf(usize) == 8) 40 else 24, |
| 178 | }, | 305 | }, |
| ... | @@ -184,9 +311,11 @@ const __SIZEOF_SEM_T = 4 * @sizeOf(usize); | ... | @@ -184,9 +311,11 @@ const __SIZEOF_SEM_T = 4 * @sizeOf(usize); |
| 184 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E; | 311 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E; |
| 185 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; | 312 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; |
| 186 | 313 | ||
| 187 | pub const RTLD_LAZY = 1; | 314 | pub const RTLD = struct { |
| 188 | pub const RTLD_NOW = 2; | 315 | pub const LAZY = 1; |
| 189 | pub const RTLD_NOLOAD = 4; | 316 | pub const NOW = 2; |
| 190 | pub const RTLD_NODELETE = 4096; | 317 | pub const NOLOAD = 4; |
| 191 | pub const RTLD_GLOBAL = 256; | 318 | pub const NODELETE = 4096; |
| 192 | pub const RTLD_LOCAL = 0; | 319 | pub const GLOBAL = 256; |
| 320 | pub const LOCAL = 0; | ||
| 321 | }; |
lib/std/c/netbsd.zig+1343-4| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | 2 | const builtin = @import("builtin"); |
| 3 | const maxInt = std.math.maxInt; | ||
| 3 | 4 | ||
| 4 | usingnamespace std.c; | 5 | usingnamespace std.c; |
| 5 | 6 | ||
| ... | @@ -13,8 +14,8 @@ pub extern "c" fn _lwp_self() lwpid_t; | ... | @@ -13,8 +14,8 @@ pub extern "c" fn _lwp_self() lwpid_t; |
| 13 | 14 | ||
| 14 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; | 15 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; |
| 15 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | 16 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 16 | pub extern "c" fn __fstat50(fd: fd_t, buf: *libc_stat) c_int; | 17 | pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int; |
| 17 | pub extern "c" fn __stat50(path: [*:0]const u8, buf: *libc_stat) c_int; | 18 | pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int; |
| 18 | pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int; | 19 | pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int; |
| 19 | pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int; | 20 | pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int; |
| 20 | pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | 21 | pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; |
| ... | @@ -51,7 +52,7 @@ pub const pthread_cond_t = extern struct { | ... | @@ -51,7 +52,7 @@ pub const pthread_cond_t = extern struct { |
| 51 | 52 | ||
| 52 | pub const pthread_rwlock_t = extern struct { | 53 | pub const pthread_rwlock_t = extern struct { |
| 53 | ptr_magic: c_uint = 0x99990009, | 54 | ptr_magic: c_uint = 0x99990009, |
| 54 | ptr_interlock: switch (std.builtin.cpu.arch) { | 55 | ptr_interlock: switch (builtin.cpu.arch) { |
| 55 | .aarch64, .sparc, .x86_64, .i386 => u8, | 56 | .aarch64, .sparc, .x86_64, .i386 => u8, |
| 56 | .arm, .powerpc => c_int, | 57 | .arm, .powerpc => c_int, |
| 57 | else => unreachable, | 58 | else => unreachable, |
| ... | @@ -92,3 +93,1341 @@ pub const sem_t = ?*opaque {}; | ... | @@ -92,3 +93,1341 @@ pub const sem_t = ?*opaque {}; |
| 92 | 93 | ||
| 93 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E; | 94 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E; |
| 94 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; | 95 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; |
| 96 | |||
| 97 | pub const clock_getres = __clock_getres50; | ||
| 98 | pub const clock_gettime = __clock_gettime50; | ||
| 99 | pub const fstat = __fstat50; | ||
| 100 | pub const getdents = __getdents30; | ||
| 101 | pub const getrusage = __getrusage50; | ||
| 102 | pub const gettimeofday = __gettimeofday50; | ||
| 103 | pub const nanosleep = __nanosleep50; | ||
| 104 | pub const sched_yield = __libc_thr_yield; | ||
| 105 | pub const sigaction = __sigaction14; | ||
| 106 | pub const sigaltstack = __sigaltstack14; | ||
| 107 | pub const sigprocmask = __sigprocmask14; | ||
| 108 | pub const socket = __socket30; | ||
| 109 | pub const stat = __stat50; | ||
| 110 | |||
| 111 | pub const blkcnt_t = i64; | ||
| 112 | pub const blksize_t = i32; | ||
| 113 | pub const clock_t = u32; | ||
| 114 | pub const dev_t = u64; | ||
| 115 | pub const fd_t = i32; | ||
| 116 | pub const gid_t = u32; | ||
| 117 | pub const ino_t = u64; | ||
| 118 | pub const mode_t = u32; | ||
| 119 | pub const nlink_t = u32; | ||
| 120 | pub const off_t = i64; | ||
| 121 | pub const pid_t = i32; | ||
| 122 | pub const socklen_t = u32; | ||
| 123 | pub const time_t = i64; | ||
| 124 | pub const uid_t = u32; | ||
| 125 | pub const lwpid_t = i32; | ||
| 126 | pub const suseconds_t = c_int; | ||
| 127 | |||
| 128 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 129 | pub const Kevent = extern struct { | ||
| 130 | ident: usize, | ||
| 131 | filter: i32, | ||
| 132 | flags: u32, | ||
| 133 | fflags: u32, | ||
| 134 | data: i64, | ||
| 135 | udata: usize, | ||
| 136 | }; | ||
| 137 | |||
| 138 | pub const RTLD_LAZY = 1; | ||
| 139 | pub const RTLD_NOW = 2; | ||
| 140 | pub const RTLD_GLOBAL = 0x100; | ||
| 141 | pub const RTLD_LOCAL = 0x200; | ||
| 142 | pub const RTLD_NODELETE = 0x01000; | ||
| 143 | pub const RTLD_NOLOAD = 0x02000; | ||
| 144 | |||
| 145 | pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); | ||
| 146 | pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); | ||
| 147 | pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); | ||
| 148 | |||
| 149 | pub const dl_phdr_info = extern struct { | ||
| 150 | dlpi_addr: usize, | ||
| 151 | dlpi_name: ?[*:0]const u8, | ||
| 152 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 153 | dlpi_phnum: u16, | ||
| 154 | }; | ||
| 155 | |||
| 156 | pub const Flock = extern struct { | ||
| 157 | l_start: off_t, | ||
| 158 | l_len: off_t, | ||
| 159 | l_pid: pid_t, | ||
| 160 | l_type: i16, | ||
| 161 | l_whence: i16, | ||
| 162 | }; | ||
| 163 | |||
| 164 | pub const addrinfo = extern struct { | ||
| 165 | flags: i32, | ||
| 166 | family: i32, | ||
| 167 | socktype: i32, | ||
| 168 | protocol: i32, | ||
| 169 | addrlen: socklen_t, | ||
| 170 | canonname: ?[*:0]u8, | ||
| 171 | addr: ?*sockaddr, | ||
| 172 | next: ?*addrinfo, | ||
| 173 | }; | ||
| 174 | |||
| 175 | pub const EAI = enum(c_int) { | ||
| 176 | /// address family for hostname not supported | ||
| 177 | ADDRFAMILY = 1, | ||
| 178 | |||
| 179 | /// name could not be resolved at this time | ||
| 180 | AGAIN = 2, | ||
| 181 | |||
| 182 | /// flags parameter had an invalid value | ||
| 183 | BADFLAGS = 3, | ||
| 184 | |||
| 185 | /// non-recoverable failure in name resolution | ||
| 186 | FAIL = 4, | ||
| 187 | |||
| 188 | /// address family not recognized | ||
| 189 | FAMILY = 5, | ||
| 190 | |||
| 191 | /// memory allocation failure | ||
| 192 | MEMORY = 6, | ||
| 193 | |||
| 194 | /// no address associated with hostname | ||
| 195 | NODATA = 7, | ||
| 196 | |||
| 197 | /// name does not resolve | ||
| 198 | NONAME = 8, | ||
| 199 | |||
| 200 | /// service not recognized for socket type | ||
| 201 | SERVICE = 9, | ||
| 202 | |||
| 203 | /// intended socket type was not recognized | ||
| 204 | SOCKTYPE = 10, | ||
| 205 | |||
| 206 | /// system error returned in errno | ||
| 207 | SYSTEM = 11, | ||
| 208 | |||
| 209 | /// invalid value for hints | ||
| 210 | BADHINTS = 12, | ||
| 211 | |||
| 212 | /// resolved protocol is unknown | ||
| 213 | PROTOCOL = 13, | ||
| 214 | |||
| 215 | /// argument buffer overflow | ||
| 216 | OVERFLOW = 14, | ||
| 217 | |||
| 218 | _, | ||
| 219 | }; | ||
| 220 | |||
| 221 | pub const EAI_MAX = 15; | ||
| 222 | |||
| 223 | pub const msghdr = extern struct { | ||
| 224 | /// optional address | ||
| 225 | msg_name: ?*sockaddr, | ||
| 226 | |||
| 227 | /// size of address | ||
| 228 | msg_namelen: socklen_t, | ||
| 229 | |||
| 230 | /// scatter/gather array | ||
| 231 | msg_iov: [*]iovec, | ||
| 232 | |||
| 233 | /// # elements in msg_iov | ||
| 234 | msg_iovlen: i32, | ||
| 235 | |||
| 236 | /// ancillary data | ||
| 237 | msg_control: ?*c_void, | ||
| 238 | |||
| 239 | /// ancillary data buffer len | ||
| 240 | msg_controllen: socklen_t, | ||
| 241 | |||
| 242 | /// flags on received message | ||
| 243 | msg_flags: i32, | ||
| 244 | }; | ||
| 245 | |||
| 246 | pub const msghdr_const = extern struct { | ||
| 247 | /// optional address | ||
| 248 | msg_name: ?*const sockaddr, | ||
| 249 | |||
| 250 | /// size of address | ||
| 251 | msg_namelen: socklen_t, | ||
| 252 | |||
| 253 | /// scatter/gather array | ||
| 254 | msg_iov: [*]iovec_const, | ||
| 255 | |||
| 256 | /// # elements in msg_iov | ||
| 257 | msg_iovlen: i32, | ||
| 258 | |||
| 259 | /// ancillary data | ||
| 260 | msg_control: ?*c_void, | ||
| 261 | |||
| 262 | /// ancillary data buffer len | ||
| 263 | msg_controllen: socklen_t, | ||
| 264 | |||
| 265 | /// flags on received message | ||
| 266 | msg_flags: i32, | ||
| 267 | }; | ||
| 268 | |||
| 269 | /// The stat structure used by libc. | ||
| 270 | pub const Stat = extern struct { | ||
| 271 | dev: dev_t, | ||
| 272 | mode: mode_t, | ||
| 273 | ino: ino_t, | ||
| 274 | nlink: nlink_t, | ||
| 275 | uid: uid_t, | ||
| 276 | gid: gid_t, | ||
| 277 | rdev: dev_t, | ||
| 278 | atim: timespec, | ||
| 279 | mtim: timespec, | ||
| 280 | ctim: timespec, | ||
| 281 | birthtim: timespec, | ||
| 282 | size: off_t, | ||
| 283 | blocks: blkcnt_t, | ||
| 284 | blksize: blksize_t, | ||
| 285 | flags: u32, | ||
| 286 | gen: u32, | ||
| 287 | __spare: [2]u32, | ||
| 288 | |||
| 289 | pub fn atime(self: @This()) timespec { | ||
| 290 | return self.atim; | ||
| 291 | } | ||
| 292 | |||
| 293 | pub fn mtime(self: @This()) timespec { | ||
| 294 | return self.mtim; | ||
| 295 | } | ||
| 296 | |||
| 297 | pub fn ctime(self: @This()) timespec { | ||
| 298 | return self.ctim; | ||
| 299 | } | ||
| 300 | }; | ||
| 301 | |||
| 302 | pub const timespec = extern struct { | ||
| 303 | tv_sec: i64, | ||
| 304 | tv_nsec: isize, | ||
| 305 | }; | ||
| 306 | |||
| 307 | pub const timeval = extern struct { | ||
| 308 | /// seconds | ||
| 309 | tv_sec: time_t, | ||
| 310 | /// microseconds | ||
| 311 | tv_usec: suseconds_t, | ||
| 312 | }; | ||
| 313 | |||
| 314 | pub const MAXNAMLEN = 511; | ||
| 315 | |||
| 316 | pub const dirent = extern struct { | ||
| 317 | d_fileno: ino_t, | ||
| 318 | d_reclen: u16, | ||
| 319 | d_namlen: u16, | ||
| 320 | d_type: u8, | ||
| 321 | d_name: [MAXNAMLEN:0]u8, | ||
| 322 | |||
| 323 | pub fn reclen(self: dirent) u16 { | ||
| 324 | return self.d_reclen; | ||
| 325 | } | ||
| 326 | }; | ||
| 327 | |||
| 328 | pub const SOCK_STREAM = 1; | ||
| 329 | pub const SOCK_DGRAM = 2; | ||
| 330 | pub const SOCK_RAW = 3; | ||
| 331 | pub const SOCK_RDM = 4; | ||
| 332 | pub const SOCK_SEQPACKET = 5; | ||
| 333 | pub const SOCK_CONN_DGRAM = 6; | ||
| 334 | pub const SOCK_DCCP = SOCK_CONN_DGRAM; | ||
| 335 | |||
| 336 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 337 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 338 | pub const SOCK_NOSIGPIPE = 0x40000000; | ||
| 339 | pub const SOCK_FLAGS_MASK = 0xf0000000; | ||
| 340 | |||
| 341 | pub const SO_DEBUG = 0x0001; | ||
| 342 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 343 | pub const SO_REUSEADDR = 0x0004; | ||
| 344 | pub const SO_KEEPALIVE = 0x0008; | ||
| 345 | pub const SO_DONTROUTE = 0x0010; | ||
| 346 | pub const SO_BROADCAST = 0x0020; | ||
| 347 | pub const SO_USELOOPBACK = 0x0040; | ||
| 348 | pub const SO_LINGER = 0x0080; | ||
| 349 | pub const SO_OOBINLINE = 0x0100; | ||
| 350 | pub const SO_REUSEPORT = 0x0200; | ||
| 351 | pub const SO_NOSIGPIPE = 0x0800; | ||
| 352 | pub const SO_ACCEPTFILTER = 0x1000; | ||
| 353 | pub const SO_TIMESTAMP = 0x2000; | ||
| 354 | pub const SO_RERROR = 0x4000; | ||
| 355 | |||
| 356 | pub const SO_SNDBUF = 0x1001; | ||
| 357 | pub const SO_RCVBUF = 0x1002; | ||
| 358 | pub const SO_SNDLOWAT = 0x1003; | ||
| 359 | pub const SO_RCVLOWAT = 0x1004; | ||
| 360 | pub const SO_ERROR = 0x1007; | ||
| 361 | pub const SO_TYPE = 0x1008; | ||
| 362 | pub const SO_OVERFLOWED = 0x1009; | ||
| 363 | |||
| 364 | pub const SO_NOHEADER = 0x100a; | ||
| 365 | pub const SO_SNDTIMEO = 0x100b; | ||
| 366 | pub const SO_RCVTIMEO = 0x100c; | ||
| 367 | |||
| 368 | pub const SOL_SOCKET = 0xffff; | ||
| 369 | |||
| 370 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 371 | pub const PF_LOCAL = AF_LOCAL; | ||
| 372 | pub const PF_UNIX = PF_LOCAL; | ||
| 373 | pub const PF_INET = AF_INET; | ||
| 374 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 375 | pub const PF_PUP = AF_PUP; | ||
| 376 | pub const PF_CHAOS = AF_CHAOS; | ||
| 377 | pub const PF_NS = AF_NS; | ||
| 378 | pub const PF_ISO = AF_ISO; | ||
| 379 | pub const PF_OSI = AF_ISO; | ||
| 380 | pub const PF_ECMA = AF_ECMA; | ||
| 381 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 382 | pub const PF_CCITT = AF_CCITT; | ||
| 383 | pub const PF_SNA = AF_SNA; | ||
| 384 | pub const PF_DECnet = AF_DECnet; | ||
| 385 | pub const PF_DLI = AF_DLI; | ||
| 386 | pub const PF_LAT = AF_LAT; | ||
| 387 | pub const PF_HYLINK = AF_HYLINK; | ||
| 388 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 389 | pub const PF_OROUTE = AF_OROUTE; | ||
| 390 | pub const PF_LINK = AF_LINK; | ||
| 391 | pub const PF_COIP = AF_COIP; | ||
| 392 | pub const PF_CNT = AF_CNT; | ||
| 393 | pub const PF_INET6 = AF_INET6; | ||
| 394 | pub const PF_IPX = AF_IPX; | ||
| 395 | pub const PF_ISDN = AF_ISDN; | ||
| 396 | pub const PF_E164 = AF_E164; | ||
| 397 | pub const PF_NATM = AF_NATM; | ||
| 398 | pub const PF_ARP = AF_ARP; | ||
| 399 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 400 | pub const PF_MPLS = AF_MPLS; | ||
| 401 | pub const PF_ROUTE = AF_ROUTE; | ||
| 402 | pub const PF_CAN = AF_CAN; | ||
| 403 | pub const PF_ETHER = AF_ETHER; | ||
| 404 | pub const PF_MAX = AF_MAX; | ||
| 405 | |||
| 406 | pub const AF_UNSPEC = 0; | ||
| 407 | pub const AF_LOCAL = 1; | ||
| 408 | pub const AF_UNIX = AF_LOCAL; | ||
| 409 | pub const AF_INET = 2; | ||
| 410 | pub const AF_IMPLINK = 3; | ||
| 411 | pub const AF_PUP = 4; | ||
| 412 | pub const AF_CHAOS = 5; | ||
| 413 | pub const AF_NS = 6; | ||
| 414 | pub const AF_ISO = 7; | ||
| 415 | pub const AF_OSI = AF_ISO; | ||
| 416 | pub const AF_ECMA = 8; | ||
| 417 | pub const AF_DATAKIT = 9; | ||
| 418 | pub const AF_CCITT = 10; | ||
| 419 | pub const AF_SNA = 11; | ||
| 420 | pub const AF_DECnet = 12; | ||
| 421 | pub const AF_DLI = 13; | ||
| 422 | pub const AF_LAT = 14; | ||
| 423 | pub const AF_HYLINK = 15; | ||
| 424 | pub const AF_APPLETALK = 16; | ||
| 425 | pub const AF_OROUTE = 17; | ||
| 426 | pub const AF_LINK = 18; | ||
| 427 | pub const AF_COIP = 20; | ||
| 428 | pub const AF_CNT = 21; | ||
| 429 | pub const AF_IPX = 23; | ||
| 430 | pub const AF_INET6 = 24; | ||
| 431 | pub const AF_ISDN = 26; | ||
| 432 | pub const AF_E164 = AF_ISDN; | ||
| 433 | pub const AF_NATM = 27; | ||
| 434 | pub const AF_ARP = 28; | ||
| 435 | pub const AF_BLUETOOTH = 31; | ||
| 436 | pub const AF_IEEE80211 = 32; | ||
| 437 | pub const AF_MPLS = 33; | ||
| 438 | pub const AF_ROUTE = 34; | ||
| 439 | pub const AF_CAN = 35; | ||
| 440 | pub const AF_ETHER = 36; | ||
| 441 | pub const AF_MAX = 37; | ||
| 442 | |||
| 443 | pub const in_port_t = u16; | ||
| 444 | pub const sa_family_t = u8; | ||
| 445 | |||
| 446 | pub const sockaddr = extern struct { | ||
| 447 | /// total length | ||
| 448 | len: u8, | ||
| 449 | |||
| 450 | /// address family | ||
| 451 | family: sa_family_t, | ||
| 452 | |||
| 453 | /// actually longer; address value | ||
| 454 | data: [14]u8, | ||
| 455 | }; | ||
| 456 | |||
| 457 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 458 | |||
| 459 | pub const sockaddr_in = extern struct { | ||
| 460 | len: u8 = @sizeOf(sockaddr_in), | ||
| 461 | family: sa_family_t = AF_INET, | ||
| 462 | port: in_port_t, | ||
| 463 | addr: u32, | ||
| 464 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 465 | }; | ||
| 466 | |||
| 467 | pub const sockaddr_in6 = extern struct { | ||
| 468 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 469 | family: sa_family_t = AF_INET6, | ||
| 470 | port: in_port_t, | ||
| 471 | flowinfo: u32, | ||
| 472 | addr: [16]u8, | ||
| 473 | scope_id: u32, | ||
| 474 | }; | ||
| 475 | |||
| 476 | /// Definitions for UNIX IPC domain. | ||
| 477 | pub const sockaddr_un = extern struct { | ||
| 478 | /// total sockaddr length | ||
| 479 | len: u8 = @sizeOf(sockaddr_un), | ||
| 480 | |||
| 481 | /// AF_LOCAL | ||
| 482 | family: sa_family_t = AF_LOCAL, | ||
| 483 | |||
| 484 | /// path name | ||
| 485 | path: [104]u8, | ||
| 486 | }; | ||
| 487 | |||
| 488 | /// get address to use bind() | ||
| 489 | pub const AI_PASSIVE = 0x00000001; | ||
| 490 | |||
| 491 | /// fill ai_canonname | ||
| 492 | pub const AI_CANONNAME = 0x00000002; | ||
| 493 | |||
| 494 | /// prevent host name resolution | ||
| 495 | pub const AI_NUMERICHOST = 0x00000004; | ||
| 496 | |||
| 497 | /// prevent service name resolution | ||
| 498 | pub const AI_NUMERICSERV = 0x00000008; | ||
| 499 | |||
| 500 | /// only if any address is assigned | ||
| 501 | pub const AI_ADDRCONFIG = 0x00000400; | ||
| 502 | |||
| 503 | pub const CTL_KERN = 1; | ||
| 504 | pub const CTL_DEBUG = 5; | ||
| 505 | |||
| 506 | pub const KERN_PROC_ARGS = 48; // struct: process argv/env | ||
| 507 | pub const KERN_PROC_PATHNAME = 5; // path to executable | ||
| 508 | pub const KERN_IOV_MAX = 38; | ||
| 509 | |||
| 510 | pub const PATH_MAX = 1024; | ||
| 511 | pub const IOV_MAX = KERN_IOV_MAX; | ||
| 512 | |||
| 513 | pub const STDIN_FILENO = 0; | ||
| 514 | pub const STDOUT_FILENO = 1; | ||
| 515 | pub const STDERR_FILENO = 2; | ||
| 516 | |||
| 517 | pub const PROT_NONE = 0; | ||
| 518 | pub const PROT_READ = 1; | ||
| 519 | pub const PROT_WRITE = 2; | ||
| 520 | pub const PROT_EXEC = 4; | ||
| 521 | |||
| 522 | pub const CLOCK_REALTIME = 0; | ||
| 523 | pub const CLOCK_VIRTUAL = 1; | ||
| 524 | pub const CLOCK_PROF = 2; | ||
| 525 | pub const CLOCK_MONOTONIC = 3; | ||
| 526 | pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000; | ||
| 527 | pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000; | ||
| 528 | |||
| 529 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 530 | pub const MAP_SHARED = 0x0001; | ||
| 531 | pub const MAP_PRIVATE = 0x0002; | ||
| 532 | pub const MAP_REMAPDUP = 0x0004; | ||
| 533 | pub const MAP_FIXED = 0x0010; | ||
| 534 | pub const MAP_RENAME = 0x0020; | ||
| 535 | pub const MAP_NORESERVE = 0x0040; | ||
| 536 | pub const MAP_INHERIT = 0x0080; | ||
| 537 | pub const MAP_HASSEMAPHORE = 0x0200; | ||
| 538 | pub const MAP_TRYFIXED = 0x0400; | ||
| 539 | pub const MAP_WIRED = 0x0800; | ||
| 540 | |||
| 541 | pub const MAP_FILE = 0x0000; | ||
| 542 | pub const MAP_NOSYNC = 0x0800; | ||
| 543 | pub const MAP_ANON = 0x1000; | ||
| 544 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 545 | pub const MAP_STACK = 0x2000; | ||
| 546 | |||
| 547 | pub const WNOHANG = 0x00000001; | ||
| 548 | pub const WUNTRACED = 0x00000002; | ||
| 549 | pub const WSTOPPED = WUNTRACED; | ||
| 550 | pub const WCONTINUED = 0x00000010; | ||
| 551 | pub const WNOWAIT = 0x00010000; | ||
| 552 | pub const WEXITED = 0x00000020; | ||
| 553 | pub const WTRAPPED = 0x00000040; | ||
| 554 | |||
| 555 | pub const SA_ONSTACK = 0x0001; | ||
| 556 | pub const SA_RESTART = 0x0002; | ||
| 557 | pub const SA_RESETHAND = 0x0004; | ||
| 558 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 559 | pub const SA_NODEFER = 0x0010; | ||
| 560 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 561 | pub const SA_SIGINFO = 0x0040; | ||
| 562 | |||
| 563 | pub const SIGHUP = 1; | ||
| 564 | pub const SIGINT = 2; | ||
| 565 | pub const SIGQUIT = 3; | ||
| 566 | pub const SIGILL = 4; | ||
| 567 | pub const SIGTRAP = 5; | ||
| 568 | pub const SIGABRT = 6; | ||
| 569 | pub const SIGIOT = SIGABRT; | ||
| 570 | pub const SIGEMT = 7; | ||
| 571 | pub const SIGFPE = 8; | ||
| 572 | pub const SIGKILL = 9; | ||
| 573 | pub const SIGBUS = 10; | ||
| 574 | pub const SIGSEGV = 11; | ||
| 575 | pub const SIGSYS = 12; | ||
| 576 | pub const SIGPIPE = 13; | ||
| 577 | pub const SIGALRM = 14; | ||
| 578 | pub const SIGTERM = 15; | ||
| 579 | pub const SIGURG = 16; | ||
| 580 | pub const SIGSTOP = 17; | ||
| 581 | pub const SIGTSTP = 18; | ||
| 582 | pub const SIGCONT = 19; | ||
| 583 | pub const SIGCHLD = 20; | ||
| 584 | pub const SIGTTIN = 21; | ||
| 585 | pub const SIGTTOU = 22; | ||
| 586 | pub const SIGIO = 23; | ||
| 587 | pub const SIGXCPU = 24; | ||
| 588 | pub const SIGXFSZ = 25; | ||
| 589 | pub const SIGVTALRM = 26; | ||
| 590 | pub const SIGPROF = 27; | ||
| 591 | pub const SIGWINCH = 28; | ||
| 592 | pub const SIGINFO = 29; | ||
| 593 | pub const SIGUSR1 = 30; | ||
| 594 | pub const SIGUSR2 = 31; | ||
| 595 | pub const SIGPWR = 32; | ||
| 596 | |||
| 597 | pub const SIGRTMIN = 33; | ||
| 598 | pub const SIGRTMAX = 63; | ||
| 599 | |||
| 600 | // access function | ||
| 601 | pub const F_OK = 0; // test for existence of file | ||
| 602 | pub const X_OK = 1; // test for execute or search permission | ||
| 603 | pub const W_OK = 2; // test for write permission | ||
| 604 | pub const R_OK = 4; // test for read permission | ||
| 605 | |||
| 606 | /// open for reading only | ||
| 607 | pub const O_RDONLY = 0x00000000; | ||
| 608 | |||
| 609 | /// open for writing only | ||
| 610 | pub const O_WRONLY = 0x00000001; | ||
| 611 | |||
| 612 | /// open for reading and writing | ||
| 613 | pub const O_RDWR = 0x00000002; | ||
| 614 | |||
| 615 | /// mask for above modes | ||
| 616 | pub const O_ACCMODE = 0x00000003; | ||
| 617 | |||
| 618 | /// no delay | ||
| 619 | pub const O_NONBLOCK = 0x00000004; | ||
| 620 | |||
| 621 | /// set append mode | ||
| 622 | pub const O_APPEND = 0x00000008; | ||
| 623 | |||
| 624 | /// open with shared file lock | ||
| 625 | pub const O_SHLOCK = 0x00000010; | ||
| 626 | |||
| 627 | /// open with exclusive file lock | ||
| 628 | pub const O_EXLOCK = 0x00000020; | ||
| 629 | |||
| 630 | /// signal pgrp when data ready | ||
| 631 | pub const O_ASYNC = 0x00000040; | ||
| 632 | |||
| 633 | /// synchronous writes | ||
| 634 | pub const O_SYNC = 0x00000080; | ||
| 635 | |||
| 636 | /// don't follow symlinks on the last | ||
| 637 | pub const O_NOFOLLOW = 0x00000100; | ||
| 638 | |||
| 639 | /// create if nonexistent | ||
| 640 | pub const O_CREAT = 0x00000200; | ||
| 641 | |||
| 642 | /// truncate to zero length | ||
| 643 | pub const O_TRUNC = 0x00000400; | ||
| 644 | |||
| 645 | /// error if already exists | ||
| 646 | pub const O_EXCL = 0x00000800; | ||
| 647 | |||
| 648 | /// don't assign controlling terminal | ||
| 649 | pub const O_NOCTTY = 0x00008000; | ||
| 650 | |||
| 651 | /// write: I/O data completion | ||
| 652 | pub const O_DSYNC = 0x00010000; | ||
| 653 | |||
| 654 | /// read: I/O completion as for write | ||
| 655 | pub const O_RSYNC = 0x00020000; | ||
| 656 | |||
| 657 | /// use alternate i/o semantics | ||
| 658 | pub const O_ALT_IO = 0x00040000; | ||
| 659 | |||
| 660 | /// direct I/O hint | ||
| 661 | pub const O_DIRECT = 0x00080000; | ||
| 662 | |||
| 663 | /// fail if not a directory | ||
| 664 | pub const O_DIRECTORY = 0x00200000; | ||
| 665 | |||
| 666 | /// set close on exec | ||
| 667 | pub const O_CLOEXEC = 0x00400000; | ||
| 668 | |||
| 669 | /// skip search permission checks | ||
| 670 | pub const O_SEARCH = 0x00800000; | ||
| 671 | |||
| 672 | pub const F_DUPFD = 0; | ||
| 673 | pub const F_GETFD = 1; | ||
| 674 | pub const F_SETFD = 2; | ||
| 675 | pub const F_GETFL = 3; | ||
| 676 | pub const F_SETFL = 4; | ||
| 677 | |||
| 678 | pub const F_GETOWN = 5; | ||
| 679 | pub const F_SETOWN = 6; | ||
| 680 | |||
| 681 | pub const F_GETLK = 7; | ||
| 682 | pub const F_SETLK = 8; | ||
| 683 | pub const F_SETLKW = 9; | ||
| 684 | |||
| 685 | pub const F_RDLCK = 1; | ||
| 686 | pub const F_WRLCK = 3; | ||
| 687 | pub const F_UNLCK = 2; | ||
| 688 | |||
| 689 | pub const LOCK_SH = 1; | ||
| 690 | pub const LOCK_EX = 2; | ||
| 691 | pub const LOCK_UN = 8; | ||
| 692 | pub const LOCK_NB = 4; | ||
| 693 | |||
| 694 | pub const FD_CLOEXEC = 1; | ||
| 695 | |||
| 696 | pub const SEEK_SET = 0; | ||
| 697 | pub const SEEK_CUR = 1; | ||
| 698 | pub const SEEK_END = 2; | ||
| 699 | |||
| 700 | pub const SIG_BLOCK = 1; | ||
| 701 | pub const SIG_UNBLOCK = 2; | ||
| 702 | pub const SIG_SETMASK = 3; | ||
| 703 | |||
| 704 | pub const DT_UNKNOWN = 0; | ||
| 705 | pub const DT_FIFO = 1; | ||
| 706 | pub const DT_CHR = 2; | ||
| 707 | pub const DT_DIR = 4; | ||
| 708 | pub const DT_BLK = 6; | ||
| 709 | pub const DT_REG = 8; | ||
| 710 | pub const DT_LNK = 10; | ||
| 711 | pub const DT_SOCK = 12; | ||
| 712 | pub const DT_WHT = 14; | ||
| 713 | |||
| 714 | /// add event to kq (implies enable) | ||
| 715 | pub const EV_ADD = 0x0001; | ||
| 716 | |||
| 717 | /// delete event from kq | ||
| 718 | pub const EV_DELETE = 0x0002; | ||
| 719 | |||
| 720 | /// enable event | ||
| 721 | pub const EV_ENABLE = 0x0004; | ||
| 722 | |||
| 723 | /// disable event (not reported) | ||
| 724 | pub const EV_DISABLE = 0x0008; | ||
| 725 | |||
| 726 | /// only report one occurrence | ||
| 727 | pub const EV_ONESHOT = 0x0010; | ||
| 728 | |||
| 729 | /// clear event state after reporting | ||
| 730 | pub const EV_CLEAR = 0x0020; | ||
| 731 | |||
| 732 | /// force immediate event output | ||
| 733 | /// ... with or without EV_ERROR | ||
| 734 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 735 | /// on syscalls supporting flags | ||
| 736 | pub const EV_RECEIPT = 0x0040; | ||
| 737 | |||
| 738 | /// disable event after reporting | ||
| 739 | pub const EV_DISPATCH = 0x0080; | ||
| 740 | |||
| 741 | pub const EVFILT_READ = 0; | ||
| 742 | pub const EVFILT_WRITE = 1; | ||
| 743 | |||
| 744 | /// attached to aio requests | ||
| 745 | pub const EVFILT_AIO = 2; | ||
| 746 | |||
| 747 | /// attached to vnodes | ||
| 748 | pub const EVFILT_VNODE = 3; | ||
| 749 | |||
| 750 | /// attached to struct proc | ||
| 751 | pub const EVFILT_PROC = 4; | ||
| 752 | |||
| 753 | /// attached to struct proc | ||
| 754 | pub const EVFILT_SIGNAL = 5; | ||
| 755 | |||
| 756 | /// timers | ||
| 757 | pub const EVFILT_TIMER = 6; | ||
| 758 | |||
| 759 | /// Filesystem events | ||
| 760 | pub const EVFILT_FS = 7; | ||
| 761 | |||
| 762 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 763 | pub const NOTE_TRIGGER = 0x08000000; | ||
| 764 | |||
| 765 | /// low water mark | ||
| 766 | pub const NOTE_LOWAT = 0x00000001; | ||
| 767 | |||
| 768 | /// vnode was removed | ||
| 769 | pub const NOTE_DELETE = 0x00000001; | ||
| 770 | |||
| 771 | /// data contents changed | ||
| 772 | pub const NOTE_WRITE = 0x00000002; | ||
| 773 | |||
| 774 | /// size increased | ||
| 775 | pub const NOTE_EXTEND = 0x00000004; | ||
| 776 | |||
| 777 | /// attributes changed | ||
| 778 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 779 | |||
| 780 | /// link count changed | ||
| 781 | pub const NOTE_LINK = 0x00000010; | ||
| 782 | |||
| 783 | /// vnode was renamed | ||
| 784 | pub const NOTE_RENAME = 0x00000020; | ||
| 785 | |||
| 786 | /// vnode access was revoked | ||
| 787 | pub const NOTE_REVOKE = 0x00000040; | ||
| 788 | |||
| 789 | /// process exited | ||
| 790 | pub const NOTE_EXIT = 0x80000000; | ||
| 791 | |||
| 792 | /// process forked | ||
| 793 | pub const NOTE_FORK = 0x40000000; | ||
| 794 | |||
| 795 | /// process exec'd | ||
| 796 | pub const NOTE_EXEC = 0x20000000; | ||
| 797 | |||
| 798 | /// mask for signal & exit status | ||
| 799 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 800 | pub const NOTE_PCTRLMASK = 0xf0000000; | ||
| 801 | |||
| 802 | pub const TIOCCBRK = 0x2000747a; | ||
| 803 | pub const TIOCCDTR = 0x20007478; | ||
| 804 | pub const TIOCCONS = 0x80047462; | ||
| 805 | pub const TIOCDCDTIMESTAMP = 0x40107458; | ||
| 806 | pub const TIOCDRAIN = 0x2000745e; | ||
| 807 | pub const TIOCEXCL = 0x2000740d; | ||
| 808 | pub const TIOCEXT = 0x80047460; | ||
| 809 | pub const TIOCFLAG_CDTRCTS = 0x10; | ||
| 810 | pub const TIOCFLAG_CLOCAL = 0x2; | ||
| 811 | pub const TIOCFLAG_CRTSCTS = 0x4; | ||
| 812 | pub const TIOCFLAG_MDMBUF = 0x8; | ||
| 813 | pub const TIOCFLAG_SOFTCAR = 0x1; | ||
| 814 | pub const TIOCFLUSH = 0x80047410; | ||
| 815 | pub const TIOCGETA = 0x402c7413; | ||
| 816 | pub const TIOCGETD = 0x4004741a; | ||
| 817 | pub const TIOCGFLAGS = 0x4004745d; | ||
| 818 | pub const TIOCGLINED = 0x40207442; | ||
| 819 | pub const TIOCGPGRP = 0x40047477; | ||
| 820 | pub const TIOCGQSIZE = 0x40047481; | ||
| 821 | pub const TIOCGRANTPT = 0x20007447; | ||
| 822 | pub const TIOCGSID = 0x40047463; | ||
| 823 | pub const TIOCGSIZE = 0x40087468; | ||
| 824 | pub const TIOCGWINSZ = 0x40087468; | ||
| 825 | pub const TIOCMBIC = 0x8004746b; | ||
| 826 | pub const TIOCMBIS = 0x8004746c; | ||
| 827 | pub const TIOCMGET = 0x4004746a; | ||
| 828 | pub const TIOCMSET = 0x8004746d; | ||
| 829 | pub const TIOCM_CAR = 0x40; | ||
| 830 | pub const TIOCM_CD = 0x40; | ||
| 831 | pub const TIOCM_CTS = 0x20; | ||
| 832 | pub const TIOCM_DSR = 0x100; | ||
| 833 | pub const TIOCM_DTR = 0x2; | ||
| 834 | pub const TIOCM_LE = 0x1; | ||
| 835 | pub const TIOCM_RI = 0x80; | ||
| 836 | pub const TIOCM_RNG = 0x80; | ||
| 837 | pub const TIOCM_RTS = 0x4; | ||
| 838 | pub const TIOCM_SR = 0x10; | ||
| 839 | pub const TIOCM_ST = 0x8; | ||
| 840 | pub const TIOCNOTTY = 0x20007471; | ||
| 841 | pub const TIOCNXCL = 0x2000740e; | ||
| 842 | pub const TIOCOUTQ = 0x40047473; | ||
| 843 | pub const TIOCPKT = 0x80047470; | ||
| 844 | pub const TIOCPKT_DATA = 0x0; | ||
| 845 | pub const TIOCPKT_DOSTOP = 0x20; | ||
| 846 | pub const TIOCPKT_FLUSHREAD = 0x1; | ||
| 847 | pub const TIOCPKT_FLUSHWRITE = 0x2; | ||
| 848 | pub const TIOCPKT_IOCTL = 0x40; | ||
| 849 | pub const TIOCPKT_NOSTOP = 0x10; | ||
| 850 | pub const TIOCPKT_START = 0x8; | ||
| 851 | pub const TIOCPKT_STOP = 0x4; | ||
| 852 | pub const TIOCPTMGET = 0x40287446; | ||
| 853 | pub const TIOCPTSNAME = 0x40287448; | ||
| 854 | pub const TIOCRCVFRAME = 0x80087445; | ||
| 855 | pub const TIOCREMOTE = 0x80047469; | ||
| 856 | pub const TIOCSBRK = 0x2000747b; | ||
| 857 | pub const TIOCSCTTY = 0x20007461; | ||
| 858 | pub const TIOCSDTR = 0x20007479; | ||
| 859 | pub const TIOCSETA = 0x802c7414; | ||
| 860 | pub const TIOCSETAF = 0x802c7416; | ||
| 861 | pub const TIOCSETAW = 0x802c7415; | ||
| 862 | pub const TIOCSETD = 0x8004741b; | ||
| 863 | pub const TIOCSFLAGS = 0x8004745c; | ||
| 864 | pub const TIOCSIG = 0x2000745f; | ||
| 865 | pub const TIOCSLINED = 0x80207443; | ||
| 866 | pub const TIOCSPGRP = 0x80047476; | ||
| 867 | pub const TIOCSQSIZE = 0x80047480; | ||
| 868 | pub const TIOCSSIZE = 0x80087467; | ||
| 869 | pub const TIOCSTART = 0x2000746e; | ||
| 870 | pub const TIOCSTAT = 0x80047465; | ||
| 871 | pub const TIOCSTI = 0x80017472; | ||
| 872 | pub const TIOCSTOP = 0x2000746f; | ||
| 873 | pub const TIOCSWINSZ = 0x80087467; | ||
| 874 | pub const TIOCUCNTL = 0x80047466; | ||
| 875 | pub const TIOCXMTFRAME = 0x80087444; | ||
| 876 | |||
| 877 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 878 | return @intCast(u8, (s >> 8) & 0xff); | ||
| 879 | } | ||
| 880 | pub fn WTERMSIG(s: u32) u32 { | ||
| 881 | return s & 0x7f; | ||
| 882 | } | ||
| 883 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 884 | return WEXITSTATUS(s); | ||
| 885 | } | ||
| 886 | pub fn WIFEXITED(s: u32) bool { | ||
| 887 | return WTERMSIG(s) == 0; | ||
| 888 | } | ||
| 889 | |||
| 890 | pub fn WIFCONTINUED(s: u32) bool { | ||
| 891 | return ((s & 0x7f) == 0xffff); | ||
| 892 | } | ||
| 893 | |||
| 894 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 895 | return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s)); | ||
| 896 | } | ||
| 897 | |||
| 898 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 899 | return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s); | ||
| 900 | } | ||
| 901 | |||
| 902 | pub const winsize = extern struct { | ||
| 903 | ws_row: u16, | ||
| 904 | ws_col: u16, | ||
| 905 | ws_xpixel: u16, | ||
| 906 | ws_ypixel: u16, | ||
| 907 | }; | ||
| 908 | |||
| 909 | const NSIG = 32; | ||
| 910 | |||
| 911 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 912 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 913 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 914 | |||
| 915 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 916 | pub const Sigaction = extern struct { | ||
| 917 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 918 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 919 | |||
| 920 | /// signal handler | ||
| 921 | handler: extern union { | ||
| 922 | handler: ?handler_fn, | ||
| 923 | sigaction: ?sigaction_fn, | ||
| 924 | }, | ||
| 925 | /// signal mask to apply | ||
| 926 | mask: sigset_t, | ||
| 927 | /// signal options | ||
| 928 | flags: c_uint, | ||
| 929 | }; | ||
| 930 | |||
| 931 | pub const sigval_t = extern union { | ||
| 932 | int: i32, | ||
| 933 | ptr: ?*c_void, | ||
| 934 | }; | ||
| 935 | |||
| 936 | pub const siginfo_t = extern union { | ||
| 937 | pad: [128]u8, | ||
| 938 | info: _ksiginfo, | ||
| 939 | }; | ||
| 940 | |||
| 941 | pub const _ksiginfo = extern struct { | ||
| 942 | signo: i32, | ||
| 943 | code: i32, | ||
| 944 | errno: i32, | ||
| 945 | // 64bit architectures insert 4bytes of padding here, this is done by | ||
| 946 | // correctly aligning the reason field | ||
| 947 | reason: extern union { | ||
| 948 | rt: extern struct { | ||
| 949 | pid: pid_t, | ||
| 950 | uid: uid_t, | ||
| 951 | value: sigval_t, | ||
| 952 | }, | ||
| 953 | child: extern struct { | ||
| 954 | pid: pid_t, | ||
| 955 | uid: uid_t, | ||
| 956 | status: i32, | ||
| 957 | utime: clock_t, | ||
| 958 | stime: clock_t, | ||
| 959 | }, | ||
| 960 | fault: extern struct { | ||
| 961 | addr: ?*c_void, | ||
| 962 | trap: i32, | ||
| 963 | trap2: i32, | ||
| 964 | trap3: i32, | ||
| 965 | }, | ||
| 966 | poll: extern struct { | ||
| 967 | band: i32, | ||
| 968 | fd: i32, | ||
| 969 | }, | ||
| 970 | syscall: extern struct { | ||
| 971 | sysnum: i32, | ||
| 972 | retval: [2]i32, | ||
| 973 | @"error": i32, | ||
| 974 | args: [8]u64, | ||
| 975 | }, | ||
| 976 | ptrace_state: extern struct { | ||
| 977 | pe_report_event: i32, | ||
| 978 | option: extern union { | ||
| 979 | pe_other_pid: pid_t, | ||
| 980 | pe_lwp: lwpid_t, | ||
| 981 | }, | ||
| 982 | }, | ||
| 983 | } align(@sizeOf(usize)), | ||
| 984 | }; | ||
| 985 | |||
| 986 | pub const _SIG_WORDS = 4; | ||
| 987 | pub const _SIG_MAXSIG = 128; | ||
| 988 | |||
| 989 | pub inline fn _SIG_IDX(sig: usize) usize { | ||
| 990 | return sig - 1; | ||
| 991 | } | ||
| 992 | pub inline fn _SIG_WORD(sig: usize) usize { | ||
| 993 | return_SIG_IDX(sig) >> 5; | ||
| 994 | } | ||
| 995 | pub inline fn _SIG_BIT(sig: usize) usize { | ||
| 996 | return 1 << (_SIG_IDX(sig) & 31); | ||
| 997 | } | ||
| 998 | pub inline fn _SIG_VALID(sig: usize) usize { | ||
| 999 | return sig <= _SIG_MAXSIG and sig > 0; | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | pub const sigset_t = extern struct { | ||
| 1003 | __bits: [_SIG_WORDS]u32, | ||
| 1004 | }; | ||
| 1005 | |||
| 1006 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; | ||
| 1007 | |||
| 1008 | // XXX x86_64 specific | ||
| 1009 | pub const mcontext_t = extern struct { | ||
| 1010 | gregs: [26]u64, | ||
| 1011 | mc_tlsbase: u64, | ||
| 1012 | fpregs: [512]u8 align(8), | ||
| 1013 | }; | ||
| 1014 | |||
| 1015 | pub const REG_RBP = 12; | ||
| 1016 | pub const REG_RIP = 21; | ||
| 1017 | pub const REG_RSP = 24; | ||
| 1018 | |||
| 1019 | pub const ucontext_t = extern struct { | ||
| 1020 | flags: u32, | ||
| 1021 | link: ?*ucontext_t, | ||
| 1022 | sigmask: sigset_t, | ||
| 1023 | stack: stack_t, | ||
| 1024 | mcontext: mcontext_t, | ||
| 1025 | __pad: [ | ||
| 1026 | switch (builtin.cpu.arch) { | ||
| 1027 | .i386 => 4, | ||
| 1028 | .mips, .mipsel, .mips64, .mips64el => 14, | ||
| 1029 | .arm, .armeb, .thumb, .thumbeb => 1, | ||
| 1030 | .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, | ||
| 1031 | else => 0, | ||
| 1032 | } | ||
| 1033 | ]u32, | ||
| 1034 | }; | ||
| 1035 | |||
| 1036 | pub const E = enum(u16) { | ||
| 1037 | /// No error occurred. | ||
| 1038 | SUCCESS = 0, | ||
| 1039 | PERM = 1, // Operation not permitted | ||
| 1040 | NOENT = 2, // No such file or directory | ||
| 1041 | SRCH = 3, // No such process | ||
| 1042 | INTR = 4, // Interrupted system call | ||
| 1043 | IO = 5, // Input/output error | ||
| 1044 | NXIO = 6, // Device not configured | ||
| 1045 | @"2BIG" = 7, // Argument list too long | ||
| 1046 | NOEXEC = 8, // Exec format error | ||
| 1047 | BADF = 9, // Bad file descriptor | ||
| 1048 | CHILD = 10, // No child processes | ||
| 1049 | DEADLK = 11, // Resource deadlock avoided | ||
| 1050 | // 11 was AGAIN | ||
| 1051 | NOMEM = 12, // Cannot allocate memory | ||
| 1052 | ACCES = 13, // Permission denied | ||
| 1053 | FAULT = 14, // Bad address | ||
| 1054 | NOTBLK = 15, // Block device required | ||
| 1055 | BUSY = 16, // Device busy | ||
| 1056 | EXIST = 17, // File exists | ||
| 1057 | XDEV = 18, // Cross-device link | ||
| 1058 | NODEV = 19, // Operation not supported by device | ||
| 1059 | NOTDIR = 20, // Not a directory | ||
| 1060 | ISDIR = 21, // Is a directory | ||
| 1061 | INVAL = 22, // Invalid argument | ||
| 1062 | NFILE = 23, // Too many open files in system | ||
| 1063 | MFILE = 24, // Too many open files | ||
| 1064 | NOTTY = 25, // Inappropriate ioctl for device | ||
| 1065 | TXTBSY = 26, // Text file busy | ||
| 1066 | FBIG = 27, // File too large | ||
| 1067 | NOSPC = 28, // No space left on device | ||
| 1068 | SPIPE = 29, // Illegal seek | ||
| 1069 | ROFS = 30, // Read-only file system | ||
| 1070 | MLINK = 31, // Too many links | ||
| 1071 | PIPE = 32, // Broken pipe | ||
| 1072 | |||
| 1073 | // math software | ||
| 1074 | DOM = 33, // Numerical argument out of domain | ||
| 1075 | RANGE = 34, // Result too large or too small | ||
| 1076 | |||
| 1077 | // non-blocking and interrupt i/o | ||
| 1078 | // also: WOULDBLOCK: operation would block | ||
| 1079 | AGAIN = 35, // Resource temporarily unavailable | ||
| 1080 | INPROGRESS = 36, // Operation now in progress | ||
| 1081 | ALREADY = 37, // Operation already in progress | ||
| 1082 | |||
| 1083 | // ipc/network software -- argument errors | ||
| 1084 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 1085 | DESTADDRREQ = 39, // Destination address required | ||
| 1086 | MSGSIZE = 40, // Message too long | ||
| 1087 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 1088 | NOPROTOOPT = 42, // Protocol option not available | ||
| 1089 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 1090 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 1091 | OPNOTSUPP = 45, // Operation not supported | ||
| 1092 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 1093 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 1094 | ADDRINUSE = 48, // Address already in use | ||
| 1095 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 1096 | |||
| 1097 | // ipc/network software -- operational errors | ||
| 1098 | NETDOWN = 50, // Network is down | ||
| 1099 | NETUNREACH = 51, // Network is unreachable | ||
| 1100 | NETRESET = 52, // Network dropped connection on reset | ||
| 1101 | CONNABORTED = 53, // Software caused connection abort | ||
| 1102 | CONNRESET = 54, // Connection reset by peer | ||
| 1103 | NOBUFS = 55, // No buffer space available | ||
| 1104 | ISCONN = 56, // Socket is already connected | ||
| 1105 | NOTCONN = 57, // Socket is not connected | ||
| 1106 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 1107 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 1108 | TIMEDOUT = 60, // Operation timed out | ||
| 1109 | CONNREFUSED = 61, // Connection refused | ||
| 1110 | |||
| 1111 | LOOP = 62, // Too many levels of symbolic links | ||
| 1112 | NAMETOOLONG = 63, // File name too long | ||
| 1113 | |||
| 1114 | // should be rearranged | ||
| 1115 | HOSTDOWN = 64, // Host is down | ||
| 1116 | HOSTUNREACH = 65, // No route to host | ||
| 1117 | NOTEMPTY = 66, // Directory not empty | ||
| 1118 | |||
| 1119 | // quotas & mush | ||
| 1120 | PROCLIM = 67, // Too many processes | ||
| 1121 | USERS = 68, // Too many users | ||
| 1122 | DQUOT = 69, // Disc quota exceeded | ||
| 1123 | |||
| 1124 | // Network File System | ||
| 1125 | STALE = 70, // Stale NFS file handle | ||
| 1126 | REMOTE = 71, // Too many levels of remote in path | ||
| 1127 | BADRPC = 72, // RPC struct is bad | ||
| 1128 | RPCMISMATCH = 73, // RPC version wrong | ||
| 1129 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 1130 | PROGMISMATCH = 75, // Program version wrong | ||
| 1131 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 1132 | |||
| 1133 | NOLCK = 77, // No locks available | ||
| 1134 | NOSYS = 78, // Function not implemented | ||
| 1135 | |||
| 1136 | FTYPE = 79, // Inappropriate file type or format | ||
| 1137 | AUTH = 80, // Authentication error | ||
| 1138 | NEEDAUTH = 81, // Need authenticator | ||
| 1139 | |||
| 1140 | // SystemV IPC | ||
| 1141 | IDRM = 82, // Identifier removed | ||
| 1142 | NOMSG = 83, // No message of desired type | ||
| 1143 | OVERFLOW = 84, // Value too large to be stored in data type | ||
| 1144 | |||
| 1145 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | ||
| 1146 | ILSEQ = 85, // Illegal byte sequence | ||
| 1147 | |||
| 1148 | // From IEEE Std 1003.1-2001 | ||
| 1149 | // Base, Realtime, Threads or Thread Priority Scheduling option errors | ||
| 1150 | NOTSUP = 86, // Not supported | ||
| 1151 | |||
| 1152 | // Realtime option errors | ||
| 1153 | CANCELED = 87, // Operation canceled | ||
| 1154 | |||
| 1155 | // Realtime, XSI STREAMS option errors | ||
| 1156 | BADMSG = 88, // Bad or Corrupt message | ||
| 1157 | |||
| 1158 | // XSI STREAMS option errors | ||
| 1159 | NODATA = 89, // No message available | ||
| 1160 | NOSR = 90, // No STREAM resources | ||
| 1161 | NOSTR = 91, // Not a STREAM | ||
| 1162 | TIME = 92, // STREAM ioctl timeout | ||
| 1163 | |||
| 1164 | // File system extended attribute errors | ||
| 1165 | NOATTR = 93, // Attribute not found | ||
| 1166 | |||
| 1167 | // Realtime, XSI STREAMS option errors | ||
| 1168 | MULTIHOP = 94, // Multihop attempted | ||
| 1169 | NOLINK = 95, // Link has been severed | ||
| 1170 | PROTO = 96, // Protocol error | ||
| 1171 | |||
| 1172 | _, | ||
| 1173 | }; | ||
| 1174 | |||
| 1175 | pub const MINSIGSTKSZ = 8192; | ||
| 1176 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 1177 | |||
| 1178 | pub const SS_ONSTACK = 1; | ||
| 1179 | pub const SS_DISABLE = 4; | ||
| 1180 | |||
| 1181 | pub const stack_t = extern struct { | ||
| 1182 | ss_sp: [*]u8, | ||
| 1183 | ss_size: isize, | ||
| 1184 | ss_flags: i32, | ||
| 1185 | }; | ||
| 1186 | |||
| 1187 | pub const S_IFMT = 0o170000; | ||
| 1188 | |||
| 1189 | pub const S_IFIFO = 0o010000; | ||
| 1190 | pub const S_IFCHR = 0o020000; | ||
| 1191 | pub const S_IFDIR = 0o040000; | ||
| 1192 | pub const S_IFBLK = 0o060000; | ||
| 1193 | pub const S_IFREG = 0o100000; | ||
| 1194 | pub const S_IFLNK = 0o120000; | ||
| 1195 | pub const S_IFSOCK = 0o140000; | ||
| 1196 | pub const S_IFWHT = 0o160000; | ||
| 1197 | |||
| 1198 | pub const S_ISUID = 0o4000; | ||
| 1199 | pub const S_ISGID = 0o2000; | ||
| 1200 | pub const S_ISVTX = 0o1000; | ||
| 1201 | pub const S_IRWXU = 0o700; | ||
| 1202 | pub const S_IRUSR = 0o400; | ||
| 1203 | pub const S_IWUSR = 0o200; | ||
| 1204 | pub const S_IXUSR = 0o100; | ||
| 1205 | pub const S_IRWXG = 0o070; | ||
| 1206 | pub const S_IRGRP = 0o040; | ||
| 1207 | pub const S_IWGRP = 0o020; | ||
| 1208 | pub const S_IXGRP = 0o010; | ||
| 1209 | pub const S_IRWXO = 0o007; | ||
| 1210 | pub const S_IROTH = 0o004; | ||
| 1211 | pub const S_IWOTH = 0o002; | ||
| 1212 | pub const S_IXOTH = 0o001; | ||
| 1213 | |||
| 1214 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1215 | return m & S_IFMT == S_IFIFO; | ||
| 1216 | } | ||
| 1217 | |||
| 1218 | pub fn S_ISCHR(m: u32) bool { | ||
| 1219 | return m & S_IFMT == S_IFCHR; | ||
| 1220 | } | ||
| 1221 | |||
| 1222 | pub fn S_ISDIR(m: u32) bool { | ||
| 1223 | return m & S_IFMT == S_IFDIR; | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | pub fn S_ISBLK(m: u32) bool { | ||
| 1227 | return m & S_IFMT == S_IFBLK; | ||
| 1228 | } | ||
| 1229 | |||
| 1230 | pub fn S_ISREG(m: u32) bool { | ||
| 1231 | return m & S_IFMT == S_IFREG; | ||
| 1232 | } | ||
| 1233 | |||
| 1234 | pub fn S_ISLNK(m: u32) bool { | ||
| 1235 | return m & S_IFMT == S_IFLNK; | ||
| 1236 | } | ||
| 1237 | |||
| 1238 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1239 | return m & S_IFMT == S_IFSOCK; | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | pub fn S_IWHT(m: u32) bool { | ||
| 1243 | return m & S_IFMT == S_IFWHT; | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | /// Magic value that specify the use of the current working directory | ||
| 1247 | /// to determine the target of relative file paths in the openat() and | ||
| 1248 | /// similar syscalls. | ||
| 1249 | pub const AT_FDCWD = -100; | ||
| 1250 | |||
| 1251 | /// Check access using effective user and group ID | ||
| 1252 | pub const AT_EACCESS = 0x0100; | ||
| 1253 | |||
| 1254 | /// Do not follow symbolic links | ||
| 1255 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | ||
| 1256 | |||
| 1257 | /// Follow symbolic link | ||
| 1258 | pub const AT_SYMLINK_FOLLOW = 0x0400; | ||
| 1259 | |||
| 1260 | /// Remove directory instead of file | ||
| 1261 | pub const AT_REMOVEDIR = 0x0800; | ||
| 1262 | |||
| 1263 | pub const HOST_NAME_MAX = 255; | ||
| 1264 | |||
| 1265 | /// dummy for IP | ||
| 1266 | pub const IPPROTO_IP = 0; | ||
| 1267 | |||
| 1268 | /// IP6 hop-by-hop options | ||
| 1269 | pub const IPPROTO_HOPOPTS = 0; | ||
| 1270 | |||
| 1271 | /// control message protocol | ||
| 1272 | pub const IPPROTO_ICMP = 1; | ||
| 1273 | |||
| 1274 | /// group mgmt protocol | ||
| 1275 | pub const IPPROTO_IGMP = 2; | ||
| 1276 | |||
| 1277 | /// gateway^2 (deprecated) | ||
| 1278 | pub const IPPROTO_GGP = 3; | ||
| 1279 | |||
| 1280 | /// IP header | ||
| 1281 | pub const IPPROTO_IPV4 = 4; | ||
| 1282 | |||
| 1283 | /// IP inside IP | ||
| 1284 | pub const IPPROTO_IPIP = 4; | ||
| 1285 | |||
| 1286 | /// tcp | ||
| 1287 | pub const IPPROTO_TCP = 6; | ||
| 1288 | |||
| 1289 | /// exterior gateway protocol | ||
| 1290 | pub const IPPROTO_EGP = 8; | ||
| 1291 | |||
| 1292 | /// pup | ||
| 1293 | pub const IPPROTO_PUP = 12; | ||
| 1294 | |||
| 1295 | /// user datagram protocol | ||
| 1296 | pub const IPPROTO_UDP = 17; | ||
| 1297 | |||
| 1298 | /// xns idp | ||
| 1299 | pub const IPPROTO_IDP = 22; | ||
| 1300 | |||
| 1301 | /// tp-4 w/ class negotiation | ||
| 1302 | pub const IPPROTO_TP = 29; | ||
| 1303 | |||
| 1304 | /// DCCP | ||
| 1305 | pub const IPPROTO_DCCP = 33; | ||
| 1306 | |||
| 1307 | /// IP6 header | ||
| 1308 | pub const IPPROTO_IPV6 = 41; | ||
| 1309 | |||
| 1310 | /// IP6 routing header | ||
| 1311 | pub const IPPROTO_ROUTING = 43; | ||
| 1312 | |||
| 1313 | /// IP6 fragmentation header | ||
| 1314 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1315 | |||
| 1316 | /// resource reservation | ||
| 1317 | pub const IPPROTO_RSVP = 46; | ||
| 1318 | |||
| 1319 | /// GRE encaps RFC 1701 | ||
| 1320 | pub const IPPROTO_GRE = 47; | ||
| 1321 | |||
| 1322 | /// encap. security payload | ||
| 1323 | pub const IPPROTO_ESP = 50; | ||
| 1324 | |||
| 1325 | /// authentication header | ||
| 1326 | pub const IPPROTO_AH = 51; | ||
| 1327 | |||
| 1328 | /// IP Mobility RFC 2004 | ||
| 1329 | pub const IPPROTO_MOBILE = 55; | ||
| 1330 | |||
| 1331 | /// IPv6 ICMP | ||
| 1332 | pub const IPPROTO_IPV6_ICMP = 58; | ||
| 1333 | |||
| 1334 | /// ICMP6 | ||
| 1335 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1336 | |||
| 1337 | /// IP6 no next header | ||
| 1338 | pub const IPPROTO_NONE = 59; | ||
| 1339 | |||
| 1340 | /// IP6 destination option | ||
| 1341 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1342 | |||
| 1343 | /// ISO cnlp | ||
| 1344 | pub const IPPROTO_EON = 80; | ||
| 1345 | |||
| 1346 | /// Ethernet-in-IP | ||
| 1347 | pub const IPPROTO_ETHERIP = 97; | ||
| 1348 | |||
| 1349 | /// encapsulation header | ||
| 1350 | pub const IPPROTO_ENCAP = 98; | ||
| 1351 | |||
| 1352 | /// Protocol indep. multicast | ||
| 1353 | pub const IPPROTO_PIM = 103; | ||
| 1354 | |||
| 1355 | /// IP Payload Comp. Protocol | ||
| 1356 | pub const IPPROTO_IPCOMP = 108; | ||
| 1357 | |||
| 1358 | /// VRRP RFC 2338 | ||
| 1359 | pub const IPPROTO_VRRP = 112; | ||
| 1360 | |||
| 1361 | /// Common Address Resolution Protocol | ||
| 1362 | pub const IPPROTO_CARP = 112; | ||
| 1363 | |||
| 1364 | /// L2TPv3 | ||
| 1365 | pub const IPPROTO_L2TP = 115; | ||
| 1366 | |||
| 1367 | /// SCTP | ||
| 1368 | pub const IPPROTO_SCTP = 132; | ||
| 1369 | |||
| 1370 | /// PFSYNC | ||
| 1371 | pub const IPPROTO_PFSYNC = 240; | ||
| 1372 | |||
| 1373 | /// raw IP packet | ||
| 1374 | pub const IPPROTO_RAW = 255; | ||
| 1375 | |||
| 1376 | pub const rlimit_resource = enum(c_int) { | ||
| 1377 | CPU = 0, | ||
| 1378 | FSIZE = 1, | ||
| 1379 | DATA = 2, | ||
| 1380 | STACK = 3, | ||
| 1381 | CORE = 4, | ||
| 1382 | RSS = 5, | ||
| 1383 | MEMLOCK = 6, | ||
| 1384 | NPROC = 7, | ||
| 1385 | NOFILE = 8, | ||
| 1386 | SBSIZE = 9, | ||
| 1387 | VMEM = 10, | ||
| 1388 | NTHR = 11, | ||
| 1389 | _, | ||
| 1390 | |||
| 1391 | pub const AS: rlimit_resource = .VMEM; | ||
| 1392 | }; | ||
| 1393 | |||
| 1394 | pub const rlim_t = u64; | ||
| 1395 | |||
| 1396 | /// No limit | ||
| 1397 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1398 | |||
| 1399 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1400 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1401 | |||
| 1402 | pub const rlimit = extern struct { | ||
| 1403 | /// Soft limit | ||
| 1404 | cur: rlim_t, | ||
| 1405 | /// Hard limit | ||
| 1406 | max: rlim_t, | ||
| 1407 | }; | ||
| 1408 | |||
| 1409 | pub const SHUT_RD = 0; | ||
| 1410 | pub const SHUT_WR = 1; | ||
| 1411 | pub const SHUT_RDWR = 2; | ||
| 1412 | |||
| 1413 | pub const nfds_t = u32; | ||
| 1414 | |||
| 1415 | pub const pollfd = extern struct { | ||
| 1416 | fd: fd_t, | ||
| 1417 | events: i16, | ||
| 1418 | revents: i16, | ||
| 1419 | }; | ||
| 1420 | |||
| 1421 | /// Testable events (may be specified in events field). | ||
| 1422 | pub const POLLIN = 0x0001; | ||
| 1423 | pub const POLLPRI = 0x0002; | ||
| 1424 | pub const POLLOUT = 0x0004; | ||
| 1425 | pub const POLLRDNORM = 0x0040; | ||
| 1426 | pub const POLLWRNORM = POLLOUT; | ||
| 1427 | pub const POLLRDBAND = 0x0080; | ||
| 1428 | pub const POLLWRBAND = 0x0100; | ||
| 1429 | |||
| 1430 | /// Non-testable events (may not be specified in events field). | ||
| 1431 | pub const POLLERR = 0x0008; | ||
| 1432 | pub const POLLHUP = 0x0010; | ||
| 1433 | pub const POLLNVAL = 0x0020; |
lib/std/c/openbsd.zig+1327-3| ... | @@ -1,7 +1,6 @@ | ... | @@ -1,7 +1,6 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | 2 | const maxInt = std.math.maxInt; |
| 3 | 3 | const builtin = @import("builtin"); | |
| 4 | usingnamespace std.c; | ||
| 5 | 4 | ||
| 6 | extern "c" fn __errno() *c_int; | 5 | extern "c" fn __errno() *c_int; |
| 7 | pub const _errno = __errno; | 6 | pub const _errno = __errno; |
| ... | @@ -43,3 +42,1328 @@ pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_in | ... | @@ -43,3 +42,1328 @@ pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_in |
| 43 | 42 | ||
| 44 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; | 43 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; |
| 45 | pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void; | 44 | pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void; |
| 45 | |||
| 46 | pub const blkcnt_t = i64; | ||
| 47 | pub const blksize_t = i32; | ||
| 48 | pub const clock_t = i64; | ||
| 49 | pub const dev_t = i32; | ||
| 50 | pub const fd_t = c_int; | ||
| 51 | pub const gid_t = u32; | ||
| 52 | pub const ino_t = u64; | ||
| 53 | pub const mode_t = u32; | ||
| 54 | pub const nlink_t = u32; | ||
| 55 | pub const off_t = i64; | ||
| 56 | pub const pid_t = i32; | ||
| 57 | pub const socklen_t = u32; | ||
| 58 | pub const time_t = i64; | ||
| 59 | pub const uid_t = u32; | ||
| 60 | |||
| 61 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 62 | pub const Kevent = extern struct { | ||
| 63 | ident: usize, | ||
| 64 | filter: c_short, | ||
| 65 | flags: u16, | ||
| 66 | fflags: c_uint, | ||
| 67 | data: i64, | ||
| 68 | udata: usize, | ||
| 69 | }; | ||
| 70 | |||
| 71 | // Modes and flags for dlopen() | ||
| 72 | // include/dlfcn.h | ||
| 73 | |||
| 74 | /// Bind function calls lazily. | ||
| 75 | pub const RTLD_LAZY = 1; | ||
| 76 | |||
| 77 | /// Bind function calls immediately. | ||
| 78 | pub const RTLD_NOW = 2; | ||
| 79 | |||
| 80 | /// Make symbols globally available. | ||
| 81 | pub const RTLD_GLOBAL = 0x100; | ||
| 82 | |||
| 83 | /// Opposite of RTLD_GLOBAL, and the default. | ||
| 84 | pub const RTLD_LOCAL = 0x000; | ||
| 85 | |||
| 86 | /// Trace loaded objects and exit. | ||
| 87 | pub const RTLD_TRACE = 0x200; | ||
| 88 | |||
| 89 | pub const dl_phdr_info = extern struct { | ||
| 90 | dlpi_addr: std.elf.Addr, | ||
| 91 | dlpi_name: ?[*:0]const u8, | ||
| 92 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 93 | dlpi_phnum: std.elf.Half, | ||
| 94 | }; | ||
| 95 | |||
| 96 | pub const Flock = extern struct { | ||
| 97 | l_start: off_t, | ||
| 98 | l_len: off_t, | ||
| 99 | l_pid: pid_t, | ||
| 100 | l_type: c_short, | ||
| 101 | l_whence: c_short, | ||
| 102 | }; | ||
| 103 | |||
| 104 | pub const addrinfo = extern struct { | ||
| 105 | flags: c_int, | ||
| 106 | family: c_int, | ||
| 107 | socktype: c_int, | ||
| 108 | protocol: c_int, | ||
| 109 | addrlen: socklen_t, | ||
| 110 | addr: ?*sockaddr, | ||
| 111 | canonname: ?[*:0]u8, | ||
| 112 | next: ?*addrinfo, | ||
| 113 | }; | ||
| 114 | |||
| 115 | pub const EAI = enum(c_int) { | ||
| 116 | /// address family for hostname not supported | ||
| 117 | ADDRFAMILY = -9, | ||
| 118 | |||
| 119 | /// name could not be resolved at this time | ||
| 120 | AGAIN = -3, | ||
| 121 | |||
| 122 | /// flags parameter had an invalid value | ||
| 123 | BADFLAGS = -1, | ||
| 124 | |||
| 125 | /// non-recoverable failure in name resolution | ||
| 126 | FAIL = -4, | ||
| 127 | |||
| 128 | /// address family not recognized | ||
| 129 | FAMILY = -6, | ||
| 130 | |||
| 131 | /// memory allocation failure | ||
| 132 | MEMORY = -10, | ||
| 133 | |||
| 134 | /// no address associated with hostname | ||
| 135 | NODATA = -5, | ||
| 136 | |||
| 137 | /// name does not resolve | ||
| 138 | NONAME = -2, | ||
| 139 | |||
| 140 | /// service not recognized for socket type | ||
| 141 | SERVICE = -8, | ||
| 142 | |||
| 143 | /// intended socket type was not recognized | ||
| 144 | SOCKTYPE = -7, | ||
| 145 | |||
| 146 | /// system error returned in errno | ||
| 147 | SYSTEM = -11, | ||
| 148 | |||
| 149 | /// invalid value for hints | ||
| 150 | BADHINTS = -12, | ||
| 151 | |||
| 152 | /// resolved protocol is unknown | ||
| 153 | PROTOCOL = -13, | ||
| 154 | |||
| 155 | /// argument buffer overflow | ||
| 156 | OVERFLOW = -14, | ||
| 157 | |||
| 158 | _, | ||
| 159 | }; | ||
| 160 | |||
| 161 | pub const EAI_MAX = 15; | ||
| 162 | |||
| 163 | pub const msghdr = extern struct { | ||
| 164 | /// optional address | ||
| 165 | msg_name: ?*sockaddr, | ||
| 166 | |||
| 167 | /// size of address | ||
| 168 | msg_namelen: socklen_t, | ||
| 169 | |||
| 170 | /// scatter/gather array | ||
| 171 | msg_iov: [*]iovec, | ||
| 172 | |||
| 173 | /// # elements in msg_iov | ||
| 174 | msg_iovlen: c_uint, | ||
| 175 | |||
| 176 | /// ancillary data | ||
| 177 | msg_control: ?*c_void, | ||
| 178 | |||
| 179 | /// ancillary data buffer len | ||
| 180 | msg_controllen: socklen_t, | ||
| 181 | |||
| 182 | /// flags on received message | ||
| 183 | msg_flags: c_int, | ||
| 184 | }; | ||
| 185 | |||
| 186 | pub const msghdr_const = extern struct { | ||
| 187 | /// optional address | ||
| 188 | msg_name: ?*const sockaddr, | ||
| 189 | |||
| 190 | /// size of address | ||
| 191 | msg_namelen: socklen_t, | ||
| 192 | |||
| 193 | /// scatter/gather array | ||
| 194 | msg_iov: [*]iovec_const, | ||
| 195 | |||
| 196 | /// # elements in msg_iov | ||
| 197 | msg_iovlen: c_uint, | ||
| 198 | |||
| 199 | /// ancillary data | ||
| 200 | msg_control: ?*c_void, | ||
| 201 | |||
| 202 | /// ancillary data buffer len | ||
| 203 | msg_controllen: socklen_t, | ||
| 204 | |||
| 205 | /// flags on received message | ||
| 206 | msg_flags: c_int, | ||
| 207 | }; | ||
| 208 | |||
| 209 | pub const Stat = extern struct { | ||
| 210 | mode: mode_t, | ||
| 211 | dev: dev_t, | ||
| 212 | ino: ino_t, | ||
| 213 | nlink: nlink_t, | ||
| 214 | uid: uid_t, | ||
| 215 | gid: gid_t, | ||
| 216 | rdev: dev_t, | ||
| 217 | atim: timespec, | ||
| 218 | mtim: timespec, | ||
| 219 | ctim: timespec, | ||
| 220 | size: off_t, | ||
| 221 | blocks: blkcnt_t, | ||
| 222 | blksize: blksize_t, | ||
| 223 | flags: u32, | ||
| 224 | gen: u32, | ||
| 225 | birthtim: timespec, | ||
| 226 | |||
| 227 | pub fn atime(self: @This()) timespec { | ||
| 228 | return self.atim; | ||
| 229 | } | ||
| 230 | |||
| 231 | pub fn mtime(self: @This()) timespec { | ||
| 232 | return self.mtim; | ||
| 233 | } | ||
| 234 | |||
| 235 | pub fn ctime(self: @This()) timespec { | ||
| 236 | return self.ctim; | ||
| 237 | } | ||
| 238 | }; | ||
| 239 | |||
| 240 | pub const timespec = extern struct { | ||
| 241 | tv_sec: time_t, | ||
| 242 | tv_nsec: c_long, | ||
| 243 | }; | ||
| 244 | |||
| 245 | pub const timeval = extern struct { | ||
| 246 | tv_sec: time_t, | ||
| 247 | tv_usec: c_long, | ||
| 248 | }; | ||
| 249 | |||
| 250 | pub const timezone = extern struct { | ||
| 251 | tz_minuteswest: c_int, | ||
| 252 | tz_dsttime: c_int, | ||
| 253 | }; | ||
| 254 | |||
| 255 | pub const MAXNAMLEN = 255; | ||
| 256 | |||
| 257 | pub const dirent = extern struct { | ||
| 258 | d_fileno: ino_t, | ||
| 259 | d_off: off_t, | ||
| 260 | d_reclen: u16, | ||
| 261 | d_type: u8, | ||
| 262 | d_namlen: u8, | ||
| 263 | __d_padding: [4]u8, | ||
| 264 | d_name: [MAXNAMLEN + 1]u8, | ||
| 265 | |||
| 266 | pub fn reclen(self: dirent) u16 { | ||
| 267 | return self.d_reclen; | ||
| 268 | } | ||
| 269 | }; | ||
| 270 | |||
| 271 | pub const in_port_t = u16; | ||
| 272 | pub const sa_family_t = u8; | ||
| 273 | |||
| 274 | pub const sockaddr = extern struct { | ||
| 275 | /// total length | ||
| 276 | len: u8, | ||
| 277 | |||
| 278 | /// address family | ||
| 279 | family: sa_family_t, | ||
| 280 | |||
| 281 | /// actually longer; address value | ||
| 282 | data: [14]u8, | ||
| 283 | }; | ||
| 284 | |||
| 285 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 286 | |||
| 287 | pub const sockaddr_in = extern struct { | ||
| 288 | len: u8 = @sizeOf(sockaddr_in), | ||
| 289 | family: sa_family_t = AF_INET, | ||
| 290 | port: in_port_t, | ||
| 291 | addr: u32, | ||
| 292 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 293 | }; | ||
| 294 | |||
| 295 | pub const sockaddr_in6 = extern struct { | ||
| 296 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 297 | family: sa_family_t = AF_INET6, | ||
| 298 | port: in_port_t, | ||
| 299 | flowinfo: u32, | ||
| 300 | addr: [16]u8, | ||
| 301 | scope_id: u32, | ||
| 302 | }; | ||
| 303 | |||
| 304 | /// Definitions for UNIX IPC domain. | ||
| 305 | pub const sockaddr_un = extern struct { | ||
| 306 | /// total sockaddr length | ||
| 307 | len: u8 = @sizeOf(sockaddr_un), | ||
| 308 | |||
| 309 | /// AF_LOCAL | ||
| 310 | family: sa_family_t = AF_LOCAL, | ||
| 311 | |||
| 312 | /// path name | ||
| 313 | path: [104]u8, | ||
| 314 | }; | ||
| 315 | |||
| 316 | /// get address to use bind() | ||
| 317 | pub const AI_PASSIVE = 1; | ||
| 318 | |||
| 319 | /// fill ai_canonname | ||
| 320 | pub const AI_CANONNAME = 2; | ||
| 321 | |||
| 322 | /// prevent host name resolution | ||
| 323 | pub const AI_NUMERICHOST = 4; | ||
| 324 | |||
| 325 | /// prevent service name resolution | ||
| 326 | pub const AI_NUMERICSERV = 16; | ||
| 327 | |||
| 328 | /// only if any address is assigned | ||
| 329 | pub const AI_ADDRCONFIG = 64; | ||
| 330 | |||
| 331 | pub const PATH_MAX = 1024; | ||
| 332 | pub const IOV_MAX = 1024; | ||
| 333 | |||
| 334 | pub const STDIN_FILENO = 0; | ||
| 335 | pub const STDOUT_FILENO = 1; | ||
| 336 | pub const STDERR_FILENO = 2; | ||
| 337 | |||
| 338 | pub const PROT_NONE = 0; | ||
| 339 | pub const PROT_READ = 1; | ||
| 340 | pub const PROT_WRITE = 2; | ||
| 341 | pub const PROT_EXEC = 4; | ||
| 342 | |||
| 343 | pub const CLOCK_REALTIME = 0; | ||
| 344 | pub const CLOCK_PROCESS_CPUTIME_ID = 2; | ||
| 345 | pub const CLOCK_MONOTONIC = 3; | ||
| 346 | pub const CLOCK_THREAD_CPUTIME_ID = 4; | ||
| 347 | |||
| 348 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 349 | pub const MAP_SHARED = 0x0001; | ||
| 350 | pub const MAP_PRIVATE = 0x0002; | ||
| 351 | pub const MAP_FIXED = 0x0010; | ||
| 352 | pub const MAP_RENAME = 0; | ||
| 353 | pub const MAP_NORESERVE = 0; | ||
| 354 | pub const MAP_INHERIT = 0; | ||
| 355 | pub const MAP_HASSEMAPHORE = 0; | ||
| 356 | pub const MAP_TRYFIXED = 0; | ||
| 357 | |||
| 358 | pub const MAP_FILE = 0; | ||
| 359 | pub const MAP_ANON = 0x1000; | ||
| 360 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 361 | pub const MAP_STACK = 0x4000; | ||
| 362 | pub const MAP_CONCEAL = 0x8000; | ||
| 363 | |||
| 364 | pub const WNOHANG = 1; | ||
| 365 | pub const WUNTRACED = 2; | ||
| 366 | pub const WCONTINUED = 8; | ||
| 367 | |||
| 368 | pub const SA_ONSTACK = 0x0001; | ||
| 369 | pub const SA_RESTART = 0x0002; | ||
| 370 | pub const SA_RESETHAND = 0x0004; | ||
| 371 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 372 | pub const SA_NODEFER = 0x0010; | ||
| 373 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 374 | pub const SA_SIGINFO = 0x0040; | ||
| 375 | |||
| 376 | pub const SIGHUP = 1; | ||
| 377 | pub const SIGINT = 2; | ||
| 378 | pub const SIGQUIT = 3; | ||
| 379 | pub const SIGILL = 4; | ||
| 380 | pub const SIGTRAP = 5; | ||
| 381 | pub const SIGABRT = 6; | ||
| 382 | pub const SIGIOT = SIGABRT; | ||
| 383 | pub const SIGEMT = 7; | ||
| 384 | pub const SIGFPE = 8; | ||
| 385 | pub const SIGKILL = 9; | ||
| 386 | pub const SIGBUS = 10; | ||
| 387 | pub const SIGSEGV = 11; | ||
| 388 | pub const SIGSYS = 12; | ||
| 389 | pub const SIGPIPE = 13; | ||
| 390 | pub const SIGALRM = 14; | ||
| 391 | pub const SIGTERM = 15; | ||
| 392 | pub const SIGURG = 16; | ||
| 393 | pub const SIGSTOP = 17; | ||
| 394 | pub const SIGTSTP = 18; | ||
| 395 | pub const SIGCONT = 19; | ||
| 396 | pub const SIGCHLD = 20; | ||
| 397 | pub const SIGTTIN = 21; | ||
| 398 | pub const SIGTTOU = 22; | ||
| 399 | pub const SIGIO = 23; | ||
| 400 | pub const SIGXCPU = 24; | ||
| 401 | pub const SIGXFSZ = 25; | ||
| 402 | pub const SIGVTALRM = 26; | ||
| 403 | pub const SIGPROF = 27; | ||
| 404 | pub const SIGWINCH = 28; | ||
| 405 | pub const SIGINFO = 29; | ||
| 406 | pub const SIGUSR1 = 30; | ||
| 407 | pub const SIGUSR2 = 31; | ||
| 408 | pub const SIGPWR = 32; | ||
| 409 | |||
| 410 | // access function | ||
| 411 | pub const F_OK = 0; // test for existence of file | ||
| 412 | pub const X_OK = 1; // test for execute or search permission | ||
| 413 | pub const W_OK = 2; // test for write permission | ||
| 414 | pub const R_OK = 4; // test for read permission | ||
| 415 | |||
| 416 | /// open for reading only | ||
| 417 | pub const O_RDONLY = 0x00000000; | ||
| 418 | |||
| 419 | /// open for writing only | ||
| 420 | pub const O_WRONLY = 0x00000001; | ||
| 421 | |||
| 422 | /// open for reading and writing | ||
| 423 | pub const O_RDWR = 0x00000002; | ||
| 424 | |||
| 425 | /// mask for above modes | ||
| 426 | pub const O_ACCMODE = 0x00000003; | ||
| 427 | |||
| 428 | /// no delay | ||
| 429 | pub const O_NONBLOCK = 0x00000004; | ||
| 430 | |||
| 431 | /// set append mode | ||
| 432 | pub const O_APPEND = 0x00000008; | ||
| 433 | |||
| 434 | /// open with shared file lock | ||
| 435 | pub const O_SHLOCK = 0x00000010; | ||
| 436 | |||
| 437 | /// open with exclusive file lock | ||
| 438 | pub const O_EXLOCK = 0x00000020; | ||
| 439 | |||
| 440 | /// signal pgrp when data ready | ||
| 441 | pub const O_ASYNC = 0x00000040; | ||
| 442 | |||
| 443 | /// synchronous writes | ||
| 444 | pub const O_SYNC = 0x00000080; | ||
| 445 | |||
| 446 | /// don't follow symlinks on the last | ||
| 447 | pub const O_NOFOLLOW = 0x00000100; | ||
| 448 | |||
| 449 | /// create if nonexistent | ||
| 450 | pub const O_CREAT = 0x00000200; | ||
| 451 | |||
| 452 | /// truncate to zero length | ||
| 453 | pub const O_TRUNC = 0x00000400; | ||
| 454 | |||
| 455 | /// error if already exists | ||
| 456 | pub const O_EXCL = 0x00000800; | ||
| 457 | |||
| 458 | /// don't assign controlling terminal | ||
| 459 | pub const O_NOCTTY = 0x00008000; | ||
| 460 | |||
| 461 | /// write: I/O data completion | ||
| 462 | pub const O_DSYNC = O_SYNC; | ||
| 463 | |||
| 464 | /// read: I/O completion as for write | ||
| 465 | pub const O_RSYNC = O_SYNC; | ||
| 466 | |||
| 467 | /// fail if not a directory | ||
| 468 | pub const O_DIRECTORY = 0x20000; | ||
| 469 | |||
| 470 | /// set close on exec | ||
| 471 | pub const O_CLOEXEC = 0x10000; | ||
| 472 | |||
| 473 | pub const F_DUPFD = 0; | ||
| 474 | pub const F_GETFD = 1; | ||
| 475 | pub const F_SETFD = 2; | ||
| 476 | pub const F_GETFL = 3; | ||
| 477 | pub const F_SETFL = 4; | ||
| 478 | |||
| 479 | pub const F_GETOWN = 5; | ||
| 480 | pub const F_SETOWN = 6; | ||
| 481 | |||
| 482 | pub const F_GETLK = 7; | ||
| 483 | pub const F_SETLK = 8; | ||
| 484 | pub const F_SETLKW = 9; | ||
| 485 | |||
| 486 | pub const F_RDLCK = 1; | ||
| 487 | pub const F_UNLCK = 2; | ||
| 488 | pub const F_WRLCK = 3; | ||
| 489 | |||
| 490 | pub const LOCK_SH = 0x01; | ||
| 491 | pub const LOCK_EX = 0x02; | ||
| 492 | pub const LOCK_NB = 0x04; | ||
| 493 | pub const LOCK_UN = 0x08; | ||
| 494 | |||
| 495 | pub const FD_CLOEXEC = 1; | ||
| 496 | |||
| 497 | pub const SEEK_SET = 0; | ||
| 498 | pub const SEEK_CUR = 1; | ||
| 499 | pub const SEEK_END = 2; | ||
| 500 | |||
| 501 | pub const SIG_BLOCK = 1; | ||
| 502 | pub const SIG_UNBLOCK = 2; | ||
| 503 | pub const SIG_SETMASK = 3; | ||
| 504 | |||
| 505 | pub const SOCK_STREAM = 1; | ||
| 506 | pub const SOCK_DGRAM = 2; | ||
| 507 | pub const SOCK_RAW = 3; | ||
| 508 | pub const SOCK_RDM = 4; | ||
| 509 | pub const SOCK_SEQPACKET = 5; | ||
| 510 | |||
| 511 | pub const SOCK_CLOEXEC = 0x8000; | ||
| 512 | pub const SOCK_NONBLOCK = 0x4000; | ||
| 513 | |||
| 514 | pub const SO_DEBUG = 0x0001; | ||
| 515 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 516 | pub const SO_REUSEADDR = 0x0004; | ||
| 517 | pub const SO_KEEPALIVE = 0x0008; | ||
| 518 | pub const SO_DONTROUTE = 0x0010; | ||
| 519 | pub const SO_BROADCAST = 0x0020; | ||
| 520 | pub const SO_USELOOPBACK = 0x0040; | ||
| 521 | pub const SO_LINGER = 0x0080; | ||
| 522 | pub const SO_OOBINLINE = 0x0100; | ||
| 523 | pub const SO_REUSEPORT = 0x0200; | ||
| 524 | pub const SO_TIMESTAMP = 0x0800; | ||
| 525 | pub const SO_BINDANY = 0x1000; | ||
| 526 | pub const SO_ZEROIZE = 0x2000; | ||
| 527 | pub const SO_SNDBUF = 0x1001; | ||
| 528 | pub const SO_RCVBUF = 0x1002; | ||
| 529 | pub const SO_SNDLOWAT = 0x1003; | ||
| 530 | pub const SO_RCVLOWAT = 0x1004; | ||
| 531 | pub const SO_SNDTIMEO = 0x1005; | ||
| 532 | pub const SO_RCVTIMEO = 0x1006; | ||
| 533 | pub const SO_ERROR = 0x1007; | ||
| 534 | pub const SO_TYPE = 0x1008; | ||
| 535 | pub const SO_NETPROC = 0x1020; | ||
| 536 | pub const SO_RTABLE = 0x1021; | ||
| 537 | pub const SO_PEERCRED = 0x1022; | ||
| 538 | pub const SO_SPLICE = 0x1023; | ||
| 539 | pub const SO_DOMAIN = 0x1024; | ||
| 540 | pub const SO_PROTOCOL = 0x1025; | ||
| 541 | |||
| 542 | pub const SOL_SOCKET = 0xffff; | ||
| 543 | |||
| 544 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 545 | pub const PF_LOCAL = AF_LOCAL; | ||
| 546 | pub const PF_UNIX = AF_UNIX; | ||
| 547 | pub const PF_INET = AF_INET; | ||
| 548 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 549 | pub const PF_INET6 = AF_INET6; | ||
| 550 | pub const PF_DECnet = AF_DECnet; | ||
| 551 | pub const PF_KEY = AF_KEY; | ||
| 552 | pub const PF_ROUTE = AF_ROUTE; | ||
| 553 | pub const PF_SNA = AF_SNA; | ||
| 554 | pub const PF_MPLS = AF_MPLS; | ||
| 555 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 556 | pub const PF_ISDN = AF_ISDN; | ||
| 557 | pub const PF_MAX = AF_MAX; | ||
| 558 | |||
| 559 | pub const AF_UNSPEC = 0; | ||
| 560 | pub const AF_UNIX = 1; | ||
| 561 | pub const AF_LOCAL = AF_UNIX; | ||
| 562 | pub const AF_INET = 2; | ||
| 563 | pub const AF_APPLETALK = 16; | ||
| 564 | pub const AF_INET6 = 24; | ||
| 565 | pub const AF_KEY = 30; | ||
| 566 | pub const AF_ROUTE = 17; | ||
| 567 | pub const AF_SNA = 11; | ||
| 568 | pub const AF_MPLS = 33; | ||
| 569 | pub const AF_BLUETOOTH = 32; | ||
| 570 | pub const AF_ISDN = 26; | ||
| 571 | pub const AF_MAX = 36; | ||
| 572 | |||
| 573 | pub const DT_UNKNOWN = 0; | ||
| 574 | pub const DT_FIFO = 1; | ||
| 575 | pub const DT_CHR = 2; | ||
| 576 | pub const DT_DIR = 4; | ||
| 577 | pub const DT_BLK = 6; | ||
| 578 | pub const DT_REG = 8; | ||
| 579 | pub const DT_LNK = 10; | ||
| 580 | pub const DT_SOCK = 12; | ||
| 581 | pub const DT_WHT = 14; // XXX | ||
| 582 | |||
| 583 | pub const EV_ADD = 0x0001; | ||
| 584 | pub const EV_DELETE = 0x0002; | ||
| 585 | pub const EV_ENABLE = 0x0004; | ||
| 586 | pub const EV_DISABLE = 0x0008; | ||
| 587 | pub const EV_ONESHOT = 0x0010; | ||
| 588 | pub const EV_CLEAR = 0x0020; | ||
| 589 | pub const EV_RECEIPT = 0x0040; | ||
| 590 | pub const EV_DISPATCH = 0x0080; | ||
| 591 | pub const EV_FLAG1 = 0x2000; | ||
| 592 | pub const EV_ERROR = 0x4000; | ||
| 593 | pub const EV_EOF = 0x8000; | ||
| 594 | |||
| 595 | pub const EVFILT_READ = -1; | ||
| 596 | pub const EVFILT_WRITE = -2; | ||
| 597 | pub const EVFILT_AIO = -3; | ||
| 598 | pub const EVFILT_VNODE = -4; | ||
| 599 | pub const EVFILT_PROC = -5; | ||
| 600 | pub const EVFILT_SIGNAL = -6; | ||
| 601 | pub const EVFILT_TIMER = -7; | ||
| 602 | pub const EVFILT_EXCEPT = -9; | ||
| 603 | |||
| 604 | // data/hint flags for EVFILT_{READ|WRITE} | ||
| 605 | pub const NOTE_LOWAT = 0x0001; | ||
| 606 | pub const NOTE_EOF = 0x0002; | ||
| 607 | |||
| 608 | // data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE} | ||
| 609 | pub const NOTE_OOB = 0x0004; | ||
| 610 | |||
| 611 | // data/hint flags for EVFILT_VNODE | ||
| 612 | pub const NOTE_DELETE = 0x0001; | ||
| 613 | pub const NOTE_WRITE = 0x0002; | ||
| 614 | pub const NOTE_EXTEND = 0x0004; | ||
| 615 | pub const NOTE_ATTRIB = 0x0008; | ||
| 616 | pub const NOTE_LINK = 0x0010; | ||
| 617 | pub const NOTE_RENAME = 0x0020; | ||
| 618 | pub const NOTE_REVOKE = 0x0040; | ||
| 619 | pub const NOTE_TRUNCATE = 0x0080; | ||
| 620 | |||
| 621 | // data/hint flags for EVFILT_PROC | ||
| 622 | pub const NOTE_EXIT = 0x80000000; | ||
| 623 | pub const NOTE_FORK = 0x40000000; | ||
| 624 | pub const NOTE_EXEC = 0x20000000; | ||
| 625 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 626 | pub const NOTE_PCTRLMASK = 0xf0000000; | ||
| 627 | pub const NOTE_TRACK = 0x00000001; | ||
| 628 | pub const NOTE_TRACKERR = 0x00000002; | ||
| 629 | pub const NOTE_CHILD = 0x00000004; | ||
| 630 | |||
| 631 | // data/hint flags for EVFILT_DEVICE | ||
| 632 | pub const NOTE_CHANGE = 0x00000001; | ||
| 633 | |||
| 634 | pub const TIOCCBRK = 0x2000747a; | ||
| 635 | pub const TIOCCDTR = 0x20007478; | ||
| 636 | pub const TIOCCONS = 0x80047462; | ||
| 637 | pub const TIOCDCDTIMESTAMP = 0x40107458; | ||
| 638 | pub const TIOCDRAIN = 0x2000745e; | ||
| 639 | pub const TIOCEXCL = 0x2000740d; | ||
| 640 | pub const TIOCEXT = 0x80047460; | ||
| 641 | pub const TIOCFLAG_CDTRCTS = 0x10; | ||
| 642 | pub const TIOCFLAG_CLOCAL = 0x2; | ||
| 643 | pub const TIOCFLAG_CRTSCTS = 0x4; | ||
| 644 | pub const TIOCFLAG_MDMBUF = 0x8; | ||
| 645 | pub const TIOCFLAG_SOFTCAR = 0x1; | ||
| 646 | pub const TIOCFLUSH = 0x80047410; | ||
| 647 | pub const TIOCGETA = 0x402c7413; | ||
| 648 | pub const TIOCGETD = 0x4004741a; | ||
| 649 | pub const TIOCGFLAGS = 0x4004745d; | ||
| 650 | pub const TIOCGLINED = 0x40207442; | ||
| 651 | pub const TIOCGPGRP = 0x40047477; | ||
| 652 | pub const TIOCGQSIZE = 0x40047481; | ||
| 653 | pub const TIOCGRANTPT = 0x20007447; | ||
| 654 | pub const TIOCGSID = 0x40047463; | ||
| 655 | pub const TIOCGSIZE = 0x40087468; | ||
| 656 | pub const TIOCGWINSZ = 0x40087468; | ||
| 657 | pub const TIOCMBIC = 0x8004746b; | ||
| 658 | pub const TIOCMBIS = 0x8004746c; | ||
| 659 | pub const TIOCMGET = 0x4004746a; | ||
| 660 | pub const TIOCMSET = 0x8004746d; | ||
| 661 | pub const TIOCM_CAR = 0x40; | ||
| 662 | pub const TIOCM_CD = 0x40; | ||
| 663 | pub const TIOCM_CTS = 0x20; | ||
| 664 | pub const TIOCM_DSR = 0x100; | ||
| 665 | pub const TIOCM_DTR = 0x2; | ||
| 666 | pub const TIOCM_LE = 0x1; | ||
| 667 | pub const TIOCM_RI = 0x80; | ||
| 668 | pub const TIOCM_RNG = 0x80; | ||
| 669 | pub const TIOCM_RTS = 0x4; | ||
| 670 | pub const TIOCM_SR = 0x10; | ||
| 671 | pub const TIOCM_ST = 0x8; | ||
| 672 | pub const TIOCNOTTY = 0x20007471; | ||
| 673 | pub const TIOCNXCL = 0x2000740e; | ||
| 674 | pub const TIOCOUTQ = 0x40047473; | ||
| 675 | pub const TIOCPKT = 0x80047470; | ||
| 676 | pub const TIOCPKT_DATA = 0x0; | ||
| 677 | pub const TIOCPKT_DOSTOP = 0x20; | ||
| 678 | pub const TIOCPKT_FLUSHREAD = 0x1; | ||
| 679 | pub const TIOCPKT_FLUSHWRITE = 0x2; | ||
| 680 | pub const TIOCPKT_IOCTL = 0x40; | ||
| 681 | pub const TIOCPKT_NOSTOP = 0x10; | ||
| 682 | pub const TIOCPKT_START = 0x8; | ||
| 683 | pub const TIOCPKT_STOP = 0x4; | ||
| 684 | pub const TIOCPTMGET = 0x40287446; | ||
| 685 | pub const TIOCPTSNAME = 0x40287448; | ||
| 686 | pub const TIOCRCVFRAME = 0x80087445; | ||
| 687 | pub const TIOCREMOTE = 0x80047469; | ||
| 688 | pub const TIOCSBRK = 0x2000747b; | ||
| 689 | pub const TIOCSCTTY = 0x20007461; | ||
| 690 | pub const TIOCSDTR = 0x20007479; | ||
| 691 | pub const TIOCSETA = 0x802c7414; | ||
| 692 | pub const TIOCSETAF = 0x802c7416; | ||
| 693 | pub const TIOCSETAW = 0x802c7415; | ||
| 694 | pub const TIOCSETD = 0x8004741b; | ||
| 695 | pub const TIOCSFLAGS = 0x8004745c; | ||
| 696 | pub const TIOCSIG = 0x2000745f; | ||
| 697 | pub const TIOCSLINED = 0x80207443; | ||
| 698 | pub const TIOCSPGRP = 0x80047476; | ||
| 699 | pub const TIOCSQSIZE = 0x80047480; | ||
| 700 | pub const TIOCSSIZE = 0x80087467; | ||
| 701 | pub const TIOCSTART = 0x2000746e; | ||
| 702 | pub const TIOCSTAT = 0x80047465; | ||
| 703 | pub const TIOCSTI = 0x80017472; | ||
| 704 | pub const TIOCSTOP = 0x2000746f; | ||
| 705 | pub const TIOCSWINSZ = 0x80087467; | ||
| 706 | pub const TIOCUCNTL = 0x80047466; | ||
| 707 | pub const TIOCXMTFRAME = 0x80087444; | ||
| 708 | |||
| 709 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 710 | return @intCast(u8, (s >> 8) & 0xff); | ||
| 711 | } | ||
| 712 | pub fn WTERMSIG(s: u32) u32 { | ||
| 713 | return (s & 0x7f); | ||
| 714 | } | ||
| 715 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 716 | return WEXITSTATUS(s); | ||
| 717 | } | ||
| 718 | pub fn WIFEXITED(s: u32) bool { | ||
| 719 | return WTERMSIG(s) == 0; | ||
| 720 | } | ||
| 721 | |||
| 722 | pub fn WIFCONTINUED(s: u32) bool { | ||
| 723 | return ((s & 0o177777) == 0o177777); | ||
| 724 | } | ||
| 725 | |||
| 726 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 727 | return (s & 0xff == 0o177); | ||
| 728 | } | ||
| 729 | |||
| 730 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 731 | return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); | ||
| 732 | } | ||
| 733 | |||
| 734 | pub const winsize = extern struct { | ||
| 735 | ws_row: c_ushort, | ||
| 736 | ws_col: c_ushort, | ||
| 737 | ws_xpixel: c_ushort, | ||
| 738 | ws_ypixel: c_ushort, | ||
| 739 | }; | ||
| 740 | |||
| 741 | const NSIG = 33; | ||
| 742 | |||
| 743 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 744 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 745 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 746 | pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2); | ||
| 747 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3); | ||
| 748 | |||
| 749 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 750 | pub const Sigaction = extern struct { | ||
| 751 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 752 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 753 | |||
| 754 | /// signal handler | ||
| 755 | handler: extern union { | ||
| 756 | handler: ?handler_fn, | ||
| 757 | sigaction: ?sigaction_fn, | ||
| 758 | }, | ||
| 759 | /// signal mask to apply | ||
| 760 | mask: sigset_t, | ||
| 761 | /// signal options | ||
| 762 | flags: c_uint, | ||
| 763 | }; | ||
| 764 | |||
| 765 | pub const sigval = extern union { | ||
| 766 | int: c_int, | ||
| 767 | ptr: ?*c_void, | ||
| 768 | }; | ||
| 769 | |||
| 770 | pub const siginfo_t = extern struct { | ||
| 771 | signo: c_int, | ||
| 772 | code: c_int, | ||
| 773 | errno: c_int, | ||
| 774 | data: extern union { | ||
| 775 | proc: extern struct { | ||
| 776 | pid: pid_t, | ||
| 777 | pdata: extern union { | ||
| 778 | kill: extern struct { | ||
| 779 | uid: uid_t, | ||
| 780 | value: sigval, | ||
| 781 | }, | ||
| 782 | cld: extern struct { | ||
| 783 | utime: clock_t, | ||
| 784 | stime: clock_t, | ||
| 785 | status: c_int, | ||
| 786 | }, | ||
| 787 | }, | ||
| 788 | }, | ||
| 789 | fault: extern struct { | ||
| 790 | addr: ?*c_void, | ||
| 791 | trapno: c_int, | ||
| 792 | }, | ||
| 793 | __pad: [128 - 3 * @sizeOf(c_int)]u8, | ||
| 794 | }, | ||
| 795 | }; | ||
| 796 | |||
| 797 | comptime { | ||
| 798 | if (@sizeOf(usize) == 4) | ||
| 799 | std.debug.assert(@sizeOf(siginfo_t) == 128) | ||
| 800 | else | ||
| 801 | // Take into account the padding between errno and data fields. | ||
| 802 | std.debug.assert(@sizeOf(siginfo_t) == 136); | ||
| 803 | } | ||
| 804 | |||
| 805 | pub usingnamespace switch (builtin.cpu.arch) { | ||
| 806 | .x86_64 => struct { | ||
| 807 | pub const ucontext_t = extern struct { | ||
| 808 | sc_rdi: c_long, | ||
| 809 | sc_rsi: c_long, | ||
| 810 | sc_rdx: c_long, | ||
| 811 | sc_rcx: c_long, | ||
| 812 | sc_r8: c_long, | ||
| 813 | sc_r9: c_long, | ||
| 814 | sc_r10: c_long, | ||
| 815 | sc_r11: c_long, | ||
| 816 | sc_r12: c_long, | ||
| 817 | sc_r13: c_long, | ||
| 818 | sc_r14: c_long, | ||
| 819 | sc_r15: c_long, | ||
| 820 | sc_rbp: c_long, | ||
| 821 | sc_rbx: c_long, | ||
| 822 | sc_rax: c_long, | ||
| 823 | sc_gs: c_long, | ||
| 824 | sc_fs: c_long, | ||
| 825 | sc_es: c_long, | ||
| 826 | sc_ds: c_long, | ||
| 827 | sc_trapno: c_long, | ||
| 828 | sc_err: c_long, | ||
| 829 | sc_rip: c_long, | ||
| 830 | sc_cs: c_long, | ||
| 831 | sc_rflags: c_long, | ||
| 832 | sc_rsp: c_long, | ||
| 833 | sc_ss: c_long, | ||
| 834 | |||
| 835 | sc_fpstate: fxsave64, | ||
| 836 | __sc_unused: c_int, | ||
| 837 | sc_mask: c_int, | ||
| 838 | sc_cookie: c_long, | ||
| 839 | }; | ||
| 840 | |||
| 841 | pub const fxsave64 = packed struct { | ||
| 842 | fx_fcw: u16, | ||
| 843 | fx_fsw: u16, | ||
| 844 | fx_ftw: u8, | ||
| 845 | fx_unused1: u8, | ||
| 846 | fx_fop: u16, | ||
| 847 | fx_rip: u64, | ||
| 848 | fx_rdp: u64, | ||
| 849 | fx_mxcsr: u32, | ||
| 850 | fx_mxcsr_mask: u32, | ||
| 851 | fx_st: [8][2]u64, | ||
| 852 | fx_xmm: [16][2]u64, | ||
| 853 | fx_unused3: [96]u8, | ||
| 854 | }; | ||
| 855 | }, | ||
| 856 | else => struct {}, | ||
| 857 | }; | ||
| 858 | |||
| 859 | pub const sigset_t = c_uint; | ||
| 860 | pub const empty_sigset: sigset_t = 0; | ||
| 861 | |||
| 862 | pub const E = enum(u16) { | ||
| 863 | /// No error occurred. | ||
| 864 | SUCCESS = 0, | ||
| 865 | PERM = 1, // Operation not permitted | ||
| 866 | NOENT = 2, // No such file or directory | ||
| 867 | SRCH = 3, // No such process | ||
| 868 | INTR = 4, // Interrupted system call | ||
| 869 | IO = 5, // Input/output error | ||
| 870 | NXIO = 6, // Device not configured | ||
| 871 | @"2BIG" = 7, // Argument list too long | ||
| 872 | NOEXEC = 8, // Exec format error | ||
| 873 | BADF = 9, // Bad file descriptor | ||
| 874 | CHILD = 10, // No child processes | ||
| 875 | DEADLK = 11, // Resource deadlock avoided | ||
| 876 | // 11 was AGAIN | ||
| 877 | NOMEM = 12, // Cannot allocate memory | ||
| 878 | ACCES = 13, // Permission denied | ||
| 879 | FAULT = 14, // Bad address | ||
| 880 | NOTBLK = 15, // Block device required | ||
| 881 | BUSY = 16, // Device busy | ||
| 882 | EXIST = 17, // File exists | ||
| 883 | XDEV = 18, // Cross-device link | ||
| 884 | NODEV = 19, // Operation not supported by device | ||
| 885 | NOTDIR = 20, // Not a directory | ||
| 886 | ISDIR = 21, // Is a directory | ||
| 887 | INVAL = 22, // Invalid argument | ||
| 888 | NFILE = 23, // Too many open files in system | ||
| 889 | MFILE = 24, // Too many open files | ||
| 890 | NOTTY = 25, // Inappropriate ioctl for device | ||
| 891 | TXTBSY = 26, // Text file busy | ||
| 892 | FBIG = 27, // File too large | ||
| 893 | NOSPC = 28, // No space left on device | ||
| 894 | SPIPE = 29, // Illegal seek | ||
| 895 | ROFS = 30, // Read-only file system | ||
| 896 | MLINK = 31, // Too many links | ||
| 897 | PIPE = 32, // Broken pipe | ||
| 898 | |||
| 899 | // math software | ||
| 900 | DOM = 33, // Numerical argument out of domain | ||
| 901 | RANGE = 34, // Result too large or too small | ||
| 902 | |||
| 903 | // non-blocking and interrupt i/o | ||
| 904 | // also: WOULDBLOCK: operation would block | ||
| 905 | AGAIN = 35, // Resource temporarily unavailable | ||
| 906 | INPROGRESS = 36, // Operation now in progress | ||
| 907 | ALREADY = 37, // Operation already in progress | ||
| 908 | |||
| 909 | // ipc/network software -- argument errors | ||
| 910 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 911 | DESTADDRREQ = 39, // Destination address required | ||
| 912 | MSGSIZE = 40, // Message too long | ||
| 913 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 914 | NOPROTOOPT = 42, // Protocol option not available | ||
| 915 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 916 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 917 | OPNOTSUPP = 45, // Operation not supported | ||
| 918 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 919 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 920 | ADDRINUSE = 48, // Address already in use | ||
| 921 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 922 | |||
| 923 | // ipc/network software -- operational errors | ||
| 924 | NETDOWN = 50, // Network is down | ||
| 925 | NETUNREACH = 51, // Network is unreachable | ||
| 926 | NETRESET = 52, // Network dropped connection on reset | ||
| 927 | CONNABORTED = 53, // Software caused connection abort | ||
| 928 | CONNRESET = 54, // Connection reset by peer | ||
| 929 | NOBUFS = 55, // No buffer space available | ||
| 930 | ISCONN = 56, // Socket is already connected | ||
| 931 | NOTCONN = 57, // Socket is not connected | ||
| 932 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 933 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 934 | TIMEDOUT = 60, // Operation timed out | ||
| 935 | CONNREFUSED = 61, // Connection refused | ||
| 936 | |||
| 937 | LOOP = 62, // Too many levels of symbolic links | ||
| 938 | NAMETOOLONG = 63, // File name too long | ||
| 939 | |||
| 940 | // should be rearranged | ||
| 941 | HOSTDOWN = 64, // Host is down | ||
| 942 | HOSTUNREACH = 65, // No route to host | ||
| 943 | NOTEMPTY = 66, // Directory not empty | ||
| 944 | |||
| 945 | // quotas & mush | ||
| 946 | PROCLIM = 67, // Too many processes | ||
| 947 | USERS = 68, // Too many users | ||
| 948 | DQUOT = 69, // Disc quota exceeded | ||
| 949 | |||
| 950 | // Network File System | ||
| 951 | STALE = 70, // Stale NFS file handle | ||
| 952 | REMOTE = 71, // Too many levels of remote in path | ||
| 953 | BADRPC = 72, // RPC struct is bad | ||
| 954 | RPCMISMATCH = 73, // RPC version wrong | ||
| 955 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 956 | PROGMISMATCH = 75, // Program version wrong | ||
| 957 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 958 | |||
| 959 | NOLCK = 77, // No locks available | ||
| 960 | NOSYS = 78, // Function not implemented | ||
| 961 | |||
| 962 | FTYPE = 79, // Inappropriate file type or format | ||
| 963 | AUTH = 80, // Authentication error | ||
| 964 | NEEDAUTH = 81, // Need authenticator | ||
| 965 | IPSEC = 82, // IPsec processing failure | ||
| 966 | NOATTR = 83, // Attribute not found | ||
| 967 | |||
| 968 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | ||
| 969 | ILSEQ = 84, // Illegal byte sequence | ||
| 970 | |||
| 971 | NOMEDIUM = 85, // No medium found | ||
| 972 | MEDIUMTYPE = 86, // Wrong medium type | ||
| 973 | OVERFLOW = 87, // Value too large to be stored in data type | ||
| 974 | CANCELED = 88, // Operation canceled | ||
| 975 | IDRM = 89, // Identifier removed | ||
| 976 | NOMSG = 90, // No message of desired type | ||
| 977 | NOTSUP = 91, // Not supported | ||
| 978 | BADMSG = 92, // Bad or Corrupt message | ||
| 979 | NOTRECOVERABLE = 93, // State not recoverable | ||
| 980 | OWNERDEAD = 94, // Previous owner died | ||
| 981 | PROTO = 95, // Protocol error | ||
| 982 | |||
| 983 | _, | ||
| 984 | }; | ||
| 985 | |||
| 986 | const _MAX_PAGE_SHIFT = switch (builtin.cpu.arch) { | ||
| 987 | .i386 => 12, | ||
| 988 | .sparcv9 => 13, | ||
| 989 | }; | ||
| 990 | pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT; | ||
| 991 | pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4; | ||
| 992 | |||
| 993 | pub const SS_ONSTACK = 0x0001; | ||
| 994 | pub const SS_DISABLE = 0x0004; | ||
| 995 | |||
| 996 | pub const stack_t = extern struct { | ||
| 997 | ss_sp: [*]u8, | ||
| 998 | ss_size: usize, | ||
| 999 | ss_flags: c_int, | ||
| 1000 | }; | ||
| 1001 | |||
| 1002 | pub const S_IFMT = 0o170000; | ||
| 1003 | |||
| 1004 | pub const S_IFIFO = 0o010000; | ||
| 1005 | pub const S_IFCHR = 0o020000; | ||
| 1006 | pub const S_IFDIR = 0o040000; | ||
| 1007 | pub const S_IFBLK = 0o060000; | ||
| 1008 | pub const S_IFREG = 0o100000; | ||
| 1009 | pub const S_IFLNK = 0o120000; | ||
| 1010 | pub const S_IFSOCK = 0o140000; | ||
| 1011 | |||
| 1012 | pub const S_ISUID = 0o4000; | ||
| 1013 | pub const S_ISGID = 0o2000; | ||
| 1014 | pub const S_ISVTX = 0o1000; | ||
| 1015 | pub const S_IRWXU = 0o700; | ||
| 1016 | pub const S_IRUSR = 0o400; | ||
| 1017 | pub const S_IWUSR = 0o200; | ||
| 1018 | pub const S_IXUSR = 0o100; | ||
| 1019 | pub const S_IRWXG = 0o070; | ||
| 1020 | pub const S_IRGRP = 0o040; | ||
| 1021 | pub const S_IWGRP = 0o020; | ||
| 1022 | pub const S_IXGRP = 0o010; | ||
| 1023 | pub const S_IRWXO = 0o007; | ||
| 1024 | pub const S_IROTH = 0o004; | ||
| 1025 | pub const S_IWOTH = 0o002; | ||
| 1026 | pub const S_IXOTH = 0o001; | ||
| 1027 | |||
| 1028 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1029 | return m & S_IFMT == S_IFIFO; | ||
| 1030 | } | ||
| 1031 | |||
| 1032 | pub fn S_ISCHR(m: u32) bool { | ||
| 1033 | return m & S_IFMT == S_IFCHR; | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | pub fn S_ISDIR(m: u32) bool { | ||
| 1037 | return m & S_IFMT == S_IFDIR; | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | pub fn S_ISBLK(m: u32) bool { | ||
| 1041 | return m & S_IFMT == S_IFBLK; | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | pub fn S_ISREG(m: u32) bool { | ||
| 1045 | return m & S_IFMT == S_IFREG; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | pub fn S_ISLNK(m: u32) bool { | ||
| 1049 | return m & S_IFMT == S_IFLNK; | ||
| 1050 | } | ||
| 1051 | |||
| 1052 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1053 | return m & S_IFMT == S_IFSOCK; | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | /// Magic value that specify the use of the current working directory | ||
| 1057 | /// to determine the target of relative file paths in the openat() and | ||
| 1058 | /// similar syscalls. | ||
| 1059 | pub const AT_FDCWD = -100; | ||
| 1060 | |||
| 1061 | /// Check access using effective user and group ID | ||
| 1062 | pub const AT_EACCESS = 0x01; | ||
| 1063 | |||
| 1064 | /// Do not follow symbolic links | ||
| 1065 | pub const AT_SYMLINK_NOFOLLOW = 0x02; | ||
| 1066 | |||
| 1067 | /// Follow symbolic link | ||
| 1068 | pub const AT_SYMLINK_FOLLOW = 0x04; | ||
| 1069 | |||
| 1070 | /// Remove directory instead of file | ||
| 1071 | pub const AT_REMOVEDIR = 0x08; | ||
| 1072 | |||
| 1073 | pub const HOST_NAME_MAX = 255; | ||
| 1074 | |||
| 1075 | /// dummy for IP | ||
| 1076 | pub const IPPROTO_IP = 0; | ||
| 1077 | |||
| 1078 | /// IP6 hop-by-hop options | ||
| 1079 | pub const IPPROTO_HOPOPTS = IPPROTO_IP; | ||
| 1080 | |||
| 1081 | /// control message protocol | ||
| 1082 | pub const IPPROTO_ICMP = 1; | ||
| 1083 | |||
| 1084 | /// group mgmt protocol | ||
| 1085 | pub const IPPROTO_IGMP = 2; | ||
| 1086 | |||
| 1087 | /// gateway^2 (deprecated) | ||
| 1088 | pub const IPPROTO_GGP = 3; | ||
| 1089 | |||
| 1090 | /// IP header | ||
| 1091 | pub const IPPROTO_IPV4 = IPPROTO_IPIP; | ||
| 1092 | |||
| 1093 | /// IP inside IP | ||
| 1094 | pub const IPPROTO_IPIP = 4; | ||
| 1095 | |||
| 1096 | /// tcp | ||
| 1097 | pub const IPPROTO_TCP = 6; | ||
| 1098 | |||
| 1099 | /// exterior gateway protocol | ||
| 1100 | pub const IPPROTO_EGP = 8; | ||
| 1101 | |||
| 1102 | /// pup | ||
| 1103 | pub const IPPROTO_PUP = 12; | ||
| 1104 | |||
| 1105 | /// user datagram protocol | ||
| 1106 | pub const IPPROTO_UDP = 17; | ||
| 1107 | |||
| 1108 | /// xns idp | ||
| 1109 | pub const IPPROTO_IDP = 22; | ||
| 1110 | |||
| 1111 | /// tp-4 w/ class negotiation | ||
| 1112 | pub const IPPROTO_TP = 29; | ||
| 1113 | |||
| 1114 | /// IP6 header | ||
| 1115 | pub const IPPROTO_IPV6 = 41; | ||
| 1116 | |||
| 1117 | /// IP6 routing header | ||
| 1118 | pub const IPPROTO_ROUTING = 43; | ||
| 1119 | |||
| 1120 | /// IP6 fragmentation header | ||
| 1121 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1122 | |||
| 1123 | /// resource reservation | ||
| 1124 | pub const IPPROTO_RSVP = 46; | ||
| 1125 | |||
| 1126 | /// GRE encaps RFC 1701 | ||
| 1127 | pub const IPPROTO_GRE = 47; | ||
| 1128 | |||
| 1129 | /// encap. security payload | ||
| 1130 | pub const IPPROTO_ESP = 50; | ||
| 1131 | |||
| 1132 | /// authentication header | ||
| 1133 | pub const IPPROTO_AH = 51; | ||
| 1134 | |||
| 1135 | /// IP Mobility RFC 2004 | ||
| 1136 | pub const IPPROTO_MOBILE = 55; | ||
| 1137 | |||
| 1138 | /// IPv6 ICMP | ||
| 1139 | pub const IPPROTO_IPV6_ICMP = 58; | ||
| 1140 | |||
| 1141 | /// ICMP6 | ||
| 1142 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1143 | |||
| 1144 | /// IP6 no next header | ||
| 1145 | pub const IPPROTO_NONE = 59; | ||
| 1146 | |||
| 1147 | /// IP6 destination option | ||
| 1148 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1149 | |||
| 1150 | /// ISO cnlp | ||
| 1151 | pub const IPPROTO_EON = 80; | ||
| 1152 | |||
| 1153 | /// Ethernet-in-IP | ||
| 1154 | pub const IPPROTO_ETHERIP = 97; | ||
| 1155 | |||
| 1156 | /// encapsulation header | ||
| 1157 | pub const IPPROTO_ENCAP = 98; | ||
| 1158 | |||
| 1159 | /// Protocol indep. multicast | ||
| 1160 | pub const IPPROTO_PIM = 103; | ||
| 1161 | |||
| 1162 | /// IP Payload Comp. Protocol | ||
| 1163 | pub const IPPROTO_IPCOMP = 108; | ||
| 1164 | |||
| 1165 | /// VRRP RFC 2338 | ||
| 1166 | pub const IPPROTO_VRRP = 112; | ||
| 1167 | |||
| 1168 | /// Common Address Resolution Protocol | ||
| 1169 | pub const IPPROTO_CARP = 112; | ||
| 1170 | |||
| 1171 | /// PFSYNC | ||
| 1172 | pub const IPPROTO_PFSYNC = 240; | ||
| 1173 | |||
| 1174 | /// raw IP packet | ||
| 1175 | pub const IPPROTO_RAW = 255; | ||
| 1176 | |||
| 1177 | pub const rlimit_resource = enum(c_int) { | ||
| 1178 | CPU, | ||
| 1179 | FSIZE, | ||
| 1180 | DATA, | ||
| 1181 | STACK, | ||
| 1182 | CORE, | ||
| 1183 | RSS, | ||
| 1184 | MEMLOCK, | ||
| 1185 | NPROC, | ||
| 1186 | NOFILE, | ||
| 1187 | |||
| 1188 | _, | ||
| 1189 | }; | ||
| 1190 | |||
| 1191 | pub const rlim_t = u64; | ||
| 1192 | |||
| 1193 | /// No limit | ||
| 1194 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1195 | |||
| 1196 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1197 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1198 | |||
| 1199 | pub const rlimit = extern struct { | ||
| 1200 | /// Soft limit | ||
| 1201 | cur: rlim_t, | ||
| 1202 | /// Hard limit | ||
| 1203 | max: rlim_t, | ||
| 1204 | }; | ||
| 1205 | |||
| 1206 | pub const SHUT_RD = 0; | ||
| 1207 | pub const SHUT_WR = 1; | ||
| 1208 | pub const SHUT_RDWR = 2; | ||
| 1209 | |||
| 1210 | pub const nfds_t = c_uint; | ||
| 1211 | |||
| 1212 | pub const pollfd = extern struct { | ||
| 1213 | fd: fd_t, | ||
| 1214 | events: c_short, | ||
| 1215 | revents: c_short, | ||
| 1216 | }; | ||
| 1217 | |||
| 1218 | pub const POLLIN = 0x0001; | ||
| 1219 | pub const POLLPRI = 0x0002; | ||
| 1220 | pub const POLLOUT = 0x0004; | ||
| 1221 | pub const POLLERR = 0x0008; | ||
| 1222 | pub const POLLHUP = 0x0010; | ||
| 1223 | pub const POLLNVAL = 0x0020; | ||
| 1224 | pub const POLLRDNORM = 0x0040; | ||
| 1225 | pub const POLLNORM = POLLRDNORM; | ||
| 1226 | pub const POLLWRNORM = POLLOUT; | ||
| 1227 | pub const POLLRDBAND = 0x0080; | ||
| 1228 | pub const POLLWRBAND = 0x0100; | ||
| 1229 | |||
| 1230 | // sysctl mib | ||
| 1231 | pub const CTL_UNSPEC = 0; | ||
| 1232 | pub const CTL_KERN = 1; | ||
| 1233 | pub const CTL_VM = 2; | ||
| 1234 | pub const CTL_FS = 3; | ||
| 1235 | pub const CTL_NET = 4; | ||
| 1236 | pub const CTL_DEBUG = 5; | ||
| 1237 | pub const CTL_HW = 6; | ||
| 1238 | pub const CTL_MACHDEP = 7; | ||
| 1239 | |||
| 1240 | pub const CTL_DDB = 9; | ||
| 1241 | pub const CTL_VFS = 10; | ||
| 1242 | |||
| 1243 | pub const KERN_OSTYPE = 1; | ||
| 1244 | pub const KERN_OSRELEASE = 2; | ||
| 1245 | pub const KERN_OSREV = 3; | ||
| 1246 | pub const KERN_VERSION = 4; | ||
| 1247 | pub const KERN_MAXVNODES = 5; | ||
| 1248 | pub const KERN_MAXPROC = 6; | ||
| 1249 | pub const KERN_MAXFILES = 7; | ||
| 1250 | pub const KERN_ARGMAX = 8; | ||
| 1251 | pub const KERN_SECURELVL = 9; | ||
| 1252 | pub const KERN_HOSTNAME = 10; | ||
| 1253 | pub const KERN_HOSTID = 11; | ||
| 1254 | pub const KERN_CLOCKRATE = 12; | ||
| 1255 | |||
| 1256 | pub const KERN_PROF = 16; | ||
| 1257 | pub const KERN_POSIX1 = 17; | ||
| 1258 | pub const KERN_NGROUPS = 18; | ||
| 1259 | pub const KERN_JOB_CONTROL = 19; | ||
| 1260 | pub const KERN_SAVED_IDS = 20; | ||
| 1261 | pub const KERN_BOOTTIME = 21; | ||
| 1262 | pub const KERN_DOMAINNAME = 22; | ||
| 1263 | pub const KERN_MAXPARTITIONS = 23; | ||
| 1264 | pub const KERN_RAWPARTITION = 24; | ||
| 1265 | pub const KERN_MAXTHREAD = 25; | ||
| 1266 | pub const KERN_NTHREADS = 26; | ||
| 1267 | pub const KERN_OSVERSION = 27; | ||
| 1268 | pub const KERN_SOMAXCONN = 28; | ||
| 1269 | pub const KERN_SOMINCONN = 29; | ||
| 1270 | |||
| 1271 | pub const KERN_NOSUIDCOREDUMP = 32; | ||
| 1272 | pub const KERN_FSYNC = 33; | ||
| 1273 | pub const KERN_SYSVMSG = 34; | ||
| 1274 | pub const KERN_SYSVSEM = 35; | ||
| 1275 | pub const KERN_SYSVSHM = 36; | ||
| 1276 | |||
| 1277 | pub const KERN_MSGBUFSIZE = 38; | ||
| 1278 | pub const KERN_MALLOCSTATS = 39; | ||
| 1279 | pub const KERN_CPTIME = 40; | ||
| 1280 | pub const KERN_NCHSTATS = 41; | ||
| 1281 | pub const KERN_FORKSTAT = 42; | ||
| 1282 | pub const KERN_NSELCOLL = 43; | ||
| 1283 | pub const KERN_TTY = 44; | ||
| 1284 | pub const KERN_CCPU = 45; | ||
| 1285 | pub const KERN_FSCALE = 46; | ||
| 1286 | pub const KERN_NPROCS = 47; | ||
| 1287 | pub const KERN_MSGBUF = 48; | ||
| 1288 | pub const KERN_POOL = 49; | ||
| 1289 | pub const KERN_STACKGAPRANDOM = 50; | ||
| 1290 | pub const KERN_SYSVIPC_INFO = 51; | ||
| 1291 | pub const KERN_ALLOWKMEM = 52; | ||
| 1292 | pub const KERN_WITNESSWATCH = 53; | ||
| 1293 | pub const KERN_SPLASSERT = 54; | ||
| 1294 | pub const KERN_PROC_ARGS = 55; | ||
| 1295 | pub const KERN_NFILES = 56; | ||
| 1296 | pub const KERN_TTYCOUNT = 57; | ||
| 1297 | pub const KERN_NUMVNODES = 58; | ||
| 1298 | pub const KERN_MBSTAT = 59; | ||
| 1299 | pub const KERN_WITNESS = 60; | ||
| 1300 | pub const KERN_SEMINFO = 61; | ||
| 1301 | pub const KERN_SHMINFO = 62; | ||
| 1302 | pub const KERN_INTRCNT = 63; | ||
| 1303 | pub const KERN_WATCHDOG = 64; | ||
| 1304 | pub const KERN_ALLOWDT = 65; | ||
| 1305 | pub const KERN_PROC = 66; | ||
| 1306 | pub const KERN_MAXCLUSTERS = 67; | ||
| 1307 | pub const KERN_EVCOUNT = 68; | ||
| 1308 | pub const KERN_TIMECOUNTER = 69; | ||
| 1309 | pub const KERN_MAXLOCKSPERUID = 70; | ||
| 1310 | pub const KERN_CPTIME2 = 71; | ||
| 1311 | pub const KERN_CACHEPCT = 72; | ||
| 1312 | pub const KERN_FILE = 73; | ||
| 1313 | pub const KERN_WXABORT = 74; | ||
| 1314 | pub const KERN_CONSDEV = 75; | ||
| 1315 | pub const KERN_NETLIVELOCKS = 76; | ||
| 1316 | pub const KERN_POOL_DEBUG = 77; | ||
| 1317 | pub const KERN_PROC_CWD = 78; | ||
| 1318 | pub const KERN_PROC_NOBROADCASTKILL = 79; | ||
| 1319 | pub const KERN_PROC_VMMAP = 80; | ||
| 1320 | pub const KERN_GLOBAL_PTRACE = 81; | ||
| 1321 | pub const KERN_CONSBUFSIZE = 82; | ||
| 1322 | pub const KERN_CONSBUF = 83; | ||
| 1323 | pub const KERN_AUDIO = 84; | ||
| 1324 | pub const KERN_CPUSTATS = 85; | ||
| 1325 | pub const KERN_PFSTATUS = 86; | ||
| 1326 | pub const KERN_TIMEOUT_STATS = 87; | ||
| 1327 | pub const KERN_UTC_OFFSET = 88; | ||
| 1328 | pub const KERN_VIDEO = 89; | ||
| 1329 | |||
| 1330 | pub const HW_MACHINE = 1; | ||
| 1331 | pub const HW_MODEL = 2; | ||
| 1332 | pub const HW_NCPU = 3; | ||
| 1333 | pub const HW_BYTEORDER = 4; | ||
| 1334 | pub const HW_PHYSMEM = 5; | ||
| 1335 | pub const HW_USERMEM = 6; | ||
| 1336 | pub const HW_PAGESIZE = 7; | ||
| 1337 | pub const HW_DISKNAMES = 8; | ||
| 1338 | pub const HW_DISKSTATS = 9; | ||
| 1339 | pub const HW_DISKCOUNT = 10; | ||
| 1340 | pub const HW_SENSORS = 11; | ||
| 1341 | pub const HW_CPUSPEED = 12; | ||
| 1342 | pub const HW_SETPERF = 13; | ||
| 1343 | pub const HW_VENDOR = 14; | ||
| 1344 | pub const HW_PRODUCT = 15; | ||
| 1345 | pub const HW_VERSION = 16; | ||
| 1346 | pub const HW_SERIALNO = 17; | ||
| 1347 | pub const HW_UUID = 18; | ||
| 1348 | pub const HW_PHYSMEM64 = 19; | ||
| 1349 | pub const HW_USERMEM64 = 20; | ||
| 1350 | pub const HW_NCPUFOUND = 21; | ||
| 1351 | pub const HW_ALLOWPOWERDOWN = 22; | ||
| 1352 | pub const HW_PERFPOLICY = 23; | ||
| 1353 | pub const HW_SMT = 24; | ||
| 1354 | pub const HW_NCPUONLINE = 25; | ||
| 1355 | |||
| 1356 | pub const KERN_PROC_ALL = 0; | ||
| 1357 | pub const KERN_PROC_PID = 1; | ||
| 1358 | pub const KERN_PROC_PGRP = 2; | ||
| 1359 | pub const KERN_PROC_SESSION = 3; | ||
| 1360 | pub const KERN_PROC_TTY = 4; | ||
| 1361 | pub const KERN_PROC_UID = 5; | ||
| 1362 | pub const KERN_PROC_RUID = 6; | ||
| 1363 | pub const KERN_PROC_KTHREAD = 7; | ||
| 1364 | pub const KERN_PROC_SHOW_THREADS = 0x40000000; | ||
| 1365 | |||
| 1366 | pub const KERN_PROC_ARGV = 1; | ||
| 1367 | pub const KERN_PROC_NARGV = 2; | ||
| 1368 | pub const KERN_PROC_ENV = 3; | ||
| 1369 | pub const KERN_PROC_NENV = 4; |
lib/std/c/wasi.zig+26-1| ... | @@ -4,12 +4,13 @@ pub fn _errno() *c_int { | ... | @@ -4,12 +4,13 @@ pub fn _errno() *c_int { |
| 4 | return &errno; | 4 | return &errno; |
| 5 | } | 5 | } |
| 6 | 6 | ||
| 7 | pub const fd_t = c_int; | ||
| 7 | pub const pid_t = c_int; | 8 | pub const pid_t = c_int; |
| 8 | pub const uid_t = u32; | 9 | pub const uid_t = u32; |
| 9 | pub const gid_t = u32; | 10 | pub const gid_t = u32; |
| 10 | pub const off_t = i64; | 11 | pub const off_t = i64; |
| 11 | 12 | ||
| 12 | pub const libc_stat = extern struct { | 13 | pub const Stat = extern struct { |
| 13 | dev: i32, | 14 | dev: i32, |
| 14 | ino: ino_t, | 15 | ino: ino_t, |
| 15 | nlink: u64, | 16 | nlink: u64, |
| ... | @@ -51,3 +52,27 @@ pub const libc_stat = extern struct { | ... | @@ -51,3 +52,27 @@ pub const libc_stat = extern struct { |
| 51 | }; | 52 | }; |
| 52 | } | 53 | } |
| 53 | }; | 54 | }; |
| 55 | |||
| 56 | /// Derived from | ||
| 57 | /// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt | ||
| 58 | pub const O = struct { | ||
| 59 | pub const ACCMODE = (EXEC | RDWR | SEARCH); | ||
| 60 | pub const APPEND = FDFLAG_APPEND; | ||
| 61 | pub const CLOEXEC = (0); | ||
| 62 | pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12 | ||
| 63 | pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12 | ||
| 64 | pub const DSYNC = FDFLAG_DSYNC; | ||
| 65 | pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12 | ||
| 66 | pub const EXEC = (0x02000000); | ||
| 67 | pub const NOCTTY = (0); | ||
| 68 | pub const NOFOLLOW = (0x01000000); | ||
| 69 | pub const NONBLOCK = (1 << FDFLAG_NONBLOCK); | ||
| 70 | pub const RDONLY = (0x04000000); | ||
| 71 | pub const RDWR = (RDONLY | WRONLY); | ||
| 72 | pub const RSYNC = (1 << FDFLAG_RSYNC); | ||
| 73 | pub const SEARCH = (0x08000000); | ||
| 74 | pub const SYNC = (1 << FDFLAG_SYNC); | ||
| 75 | pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12 | ||
| 76 | pub const TTY_INIT = (0); | ||
| 77 | pub const WRONLY = (0x10000000); | ||
| 78 | }; |
lib/std/c/windows.zig+340| ... | @@ -1,3 +1,343 @@ | ... | @@ -1,3 +1,343 @@ |
| 1 | //! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime). | ||
| 2 | |||
| 3 | const ws2_32 = @import("../os/windows/ws2_32.zig"); | ||
| 4 | |||
| 1 | pub extern "c" fn _errno() *c_int; | 5 | pub extern "c" fn _errno() *c_int; |
| 2 | 6 | ||
| 3 | pub extern "c" fn _msize(memblock: ?*c_void) usize; | 7 | pub extern "c" fn _msize(memblock: ?*c_void) usize; |
| 8 | |||
| 9 | // TODO: copied the else case and removed the socket function (because its in ws2_32) | ||
| 10 | // need to verify which of these is actually supported on windows | ||
| 11 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 12 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | ||
| 13 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | ||
| 14 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 15 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 16 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | ||
| 17 | pub extern "c" fn sched_yield() c_int; | ||
| 18 | pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | ||
| 19 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 20 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | ||
| 21 | pub extern "c" fn sigfillset(set: ?*sigset_t) void; | ||
| 22 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | ||
| 23 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; | ||
| 24 | |||
| 25 | pub const fd_t = HANDLE; | ||
| 26 | pub const ino_t = LARGE_INTEGER; | ||
| 27 | pub const pid_t = HANDLE; | ||
| 28 | pub const mode_t = u0; | ||
| 29 | |||
| 30 | pub const PATH_MAX = 260; | ||
| 31 | |||
| 32 | pub const time_t = c_longlong; | ||
| 33 | |||
| 34 | pub const timespec = extern struct { | ||
| 35 | tv_sec: time_t, | ||
| 36 | tv_nsec: c_long, | ||
| 37 | }; | ||
| 38 | |||
| 39 | pub const timeval = extern struct { | ||
| 40 | tv_sec: c_long, | ||
| 41 | tv_usec: c_long, | ||
| 42 | }; | ||
| 43 | |||
| 44 | pub const sig_atomic_t = c_int; | ||
| 45 | |||
| 46 | /// maximum signal number + 1 | ||
| 47 | pub const NSIG = 23; | ||
| 48 | |||
| 49 | // Signal types | ||
| 50 | |||
| 51 | /// interrupt | ||
| 52 | pub const SIGINT = 2; | ||
| 53 | |||
| 54 | /// illegal instruction - invalid function image | ||
| 55 | pub const SIGILL = 4; | ||
| 56 | |||
| 57 | /// floating point exception | ||
| 58 | pub const SIGFPE = 8; | ||
| 59 | |||
| 60 | /// segment violation | ||
| 61 | pub const SIGSEGV = 11; | ||
| 62 | |||
| 63 | /// Software termination signal from kill | ||
| 64 | pub const SIGTERM = 15; | ||
| 65 | |||
| 66 | /// Ctrl-Break sequence | ||
| 67 | pub const SIGBREAK = 21; | ||
| 68 | |||
| 69 | /// abnormal termination triggered by abort call | ||
| 70 | pub const SIGABRT = 22; | ||
| 71 | |||
| 72 | /// SIGABRT compatible with other platforms, same as SIGABRT | ||
| 73 | pub const SIGABRT_COMPAT = 6; | ||
| 74 | |||
| 75 | // Signal action codes | ||
| 76 | |||
| 77 | /// default signal action | ||
| 78 | pub const SIG_DFL = 0; | ||
| 79 | |||
| 80 | /// ignore signal | ||
| 81 | pub const SIG_IGN = 1; | ||
| 82 | |||
| 83 | /// return current value | ||
| 84 | pub const SIG_GET = 2; | ||
| 85 | |||
| 86 | /// signal gets error | ||
| 87 | pub const SIG_SGE = 3; | ||
| 88 | |||
| 89 | /// acknowledge | ||
| 90 | pub const SIG_ACK = 4; | ||
| 91 | |||
| 92 | /// Signal error value (returned by signal call on error) | ||
| 93 | pub const SIG_ERR = -1; | ||
| 94 | |||
| 95 | pub const SEEK_SET = 0; | ||
| 96 | pub const SEEK_CUR = 1; | ||
| 97 | pub const SEEK_END = 2; | ||
| 98 | |||
| 99 | pub const E = enum(u16) { | ||
| 100 | /// No error occurred. | ||
| 101 | SUCCESS = 0, | ||
| 102 | PERM = 1, | ||
| 103 | NOENT = 2, | ||
| 104 | SRCH = 3, | ||
| 105 | INTR = 4, | ||
| 106 | IO = 5, | ||
| 107 | NXIO = 6, | ||
| 108 | @"2BIG" = 7, | ||
| 109 | NOEXEC = 8, | ||
| 110 | BADF = 9, | ||
| 111 | CHILD = 10, | ||
| 112 | AGAIN = 11, | ||
| 113 | NOMEM = 12, | ||
| 114 | ACCES = 13, | ||
| 115 | FAULT = 14, | ||
| 116 | BUSY = 16, | ||
| 117 | EXIST = 17, | ||
| 118 | XDEV = 18, | ||
| 119 | NODEV = 19, | ||
| 120 | NOTDIR = 20, | ||
| 121 | ISDIR = 21, | ||
| 122 | NFILE = 23, | ||
| 123 | MFILE = 24, | ||
| 124 | NOTTY = 25, | ||
| 125 | FBIG = 27, | ||
| 126 | NOSPC = 28, | ||
| 127 | SPIPE = 29, | ||
| 128 | ROFS = 30, | ||
| 129 | MLINK = 31, | ||
| 130 | PIPE = 32, | ||
| 131 | DOM = 33, | ||
| 132 | /// Also means `DEADLOCK`. | ||
| 133 | DEADLK = 36, | ||
| 134 | NAMETOOLONG = 38, | ||
| 135 | NOLCK = 39, | ||
| 136 | NOSYS = 40, | ||
| 137 | NOTEMPTY = 41, | ||
| 138 | |||
| 139 | INVAL = 22, | ||
| 140 | RANGE = 34, | ||
| 141 | ILSEQ = 42, | ||
| 142 | |||
| 143 | // POSIX Supplement | ||
| 144 | ADDRINUSE = 100, | ||
| 145 | ADDRNOTAVAIL = 101, | ||
| 146 | AFNOSUPPORT = 102, | ||
| 147 | ALREADY = 103, | ||
| 148 | BADMSG = 104, | ||
| 149 | CANCELED = 105, | ||
| 150 | CONNABORTED = 106, | ||
| 151 | CONNREFUSED = 107, | ||
| 152 | CONNRESET = 108, | ||
| 153 | DESTADDRREQ = 109, | ||
| 154 | HOSTUNREACH = 110, | ||
| 155 | IDRM = 111, | ||
| 156 | INPROGRESS = 112, | ||
| 157 | ISCONN = 113, | ||
| 158 | LOOP = 114, | ||
| 159 | MSGSIZE = 115, | ||
| 160 | NETDOWN = 116, | ||
| 161 | NETRESET = 117, | ||
| 162 | NETUNREACH = 118, | ||
| 163 | NOBUFS = 119, | ||
| 164 | NODATA = 120, | ||
| 165 | NOLINK = 121, | ||
| 166 | NOMSG = 122, | ||
| 167 | NOPROTOOPT = 123, | ||
| 168 | NOSR = 124, | ||
| 169 | NOSTR = 125, | ||
| 170 | NOTCONN = 126, | ||
| 171 | NOTRECOVERABLE = 127, | ||
| 172 | NOTSOCK = 128, | ||
| 173 | NOTSUP = 129, | ||
| 174 | OPNOTSUPP = 130, | ||
| 175 | OTHER = 131, | ||
| 176 | OVERFLOW = 132, | ||
| 177 | OWNERDEAD = 133, | ||
| 178 | PROTO = 134, | ||
| 179 | PROTONOSUPPORT = 135, | ||
| 180 | PROTOTYPE = 136, | ||
| 181 | TIME = 137, | ||
| 182 | TIMEDOUT = 138, | ||
| 183 | TXTBSY = 139, | ||
| 184 | WOULDBLOCK = 140, | ||
| 185 | DQUOT = 10069, | ||
| 186 | _, | ||
| 187 | }; | ||
| 188 | |||
| 189 | pub const STRUNCATE = 80; | ||
| 190 | |||
| 191 | pub const F_OK = 0; | ||
| 192 | |||
| 193 | /// Remove directory instead of unlinking file | ||
| 194 | pub const AT_REMOVEDIR = 0x200; | ||
| 195 | |||
| 196 | pub const in_port_t = u16; | ||
| 197 | pub const sa_family_t = ws2_32.ADDRESS_FAMILY; | ||
| 198 | pub const socklen_t = ws2_32.socklen_t; | ||
| 199 | |||
| 200 | pub const sockaddr = ws2_32.sockaddr; | ||
| 201 | pub const sockaddr_in = ws2_32.sockaddr_in; | ||
| 202 | pub const sockaddr_in6 = ws2_32.sockaddr_in6; | ||
| 203 | pub const sockaddr_un = ws2_32.sockaddr_un; | ||
| 204 | |||
| 205 | pub const in6_addr = [16]u8; | ||
| 206 | pub const in_addr = u32; | ||
| 207 | |||
| 208 | pub const addrinfo = ws2_32.addrinfo; | ||
| 209 | |||
| 210 | pub const AF_UNSPEC = ws2_32.AF_UNSPEC; | ||
| 211 | pub const AF_UNIX = ws2_32.AF_UNIX; | ||
| 212 | pub const AF_INET = ws2_32.AF_INET; | ||
| 213 | pub const AF_IMPLINK = ws2_32.AF_IMPLINK; | ||
| 214 | pub const AF_PUP = ws2_32.AF_PUP; | ||
| 215 | pub const AF_CHAOS = ws2_32.AF_CHAOS; | ||
| 216 | pub const AF_NS = ws2_32.AF_NS; | ||
| 217 | pub const AF_IPX = ws2_32.AF_IPX; | ||
| 218 | pub const AF_ISO = ws2_32.AF_ISO; | ||
| 219 | pub const AF_OSI = ws2_32.AF_OSI; | ||
| 220 | pub const AF_ECMA = ws2_32.AF_ECMA; | ||
| 221 | pub const AF_DATAKIT = ws2_32.AF_DATAKIT; | ||
| 222 | pub const AF_CCITT = ws2_32.AF_CCITT; | ||
| 223 | pub const AF_SNA = ws2_32.AF_SNA; | ||
| 224 | pub const AF_DECnet = ws2_32.AF_DECnet; | ||
| 225 | pub const AF_DLI = ws2_32.AF_DLI; | ||
| 226 | pub const AF_LAT = ws2_32.AF_LAT; | ||
| 227 | pub const AF_HYLINK = ws2_32.AF_HYLINK; | ||
| 228 | pub const AF_APPLETALK = ws2_32.AF_APPLETALK; | ||
| 229 | pub const AF_NETBIOS = ws2_32.AF_NETBIOS; | ||
| 230 | pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW; | ||
| 231 | pub const AF_FIREFOX = ws2_32.AF_FIREFOX; | ||
| 232 | pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1; | ||
| 233 | pub const AF_BAN = ws2_32.AF_BAN; | ||
| 234 | pub const AF_ATM = ws2_32.AF_ATM; | ||
| 235 | pub const AF_INET6 = ws2_32.AF_INET6; | ||
| 236 | pub const AF_CLUSTER = ws2_32.AF_CLUSTER; | ||
| 237 | pub const AF_12844 = ws2_32.AF_12844; | ||
| 238 | pub const AF_IRDA = ws2_32.AF_IRDA; | ||
| 239 | pub const AF_NETDES = ws2_32.AF_NETDES; | ||
| 240 | pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS; | ||
| 241 | pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE; | ||
| 242 | pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM; | ||
| 243 | pub const AF_BTH = ws2_32.AF_BTH; | ||
| 244 | pub const AF_MAX = ws2_32.AF_MAX; | ||
| 245 | |||
| 246 | pub const SOCK_STREAM = ws2_32.SOCK_STREAM; | ||
| 247 | pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM; | ||
| 248 | pub const SOCK_RAW = ws2_32.SOCK_RAW; | ||
| 249 | pub const SOCK_RDM = ws2_32.SOCK_RDM; | ||
| 250 | pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET; | ||
| 251 | |||
| 252 | /// WARNING: this flag is not supported by windows socket functions directly, | ||
| 253 | /// it is only supported by std.os.socket. Be sure that this value does | ||
| 254 | /// not share any bits with any of the SOCK_* values. | ||
| 255 | pub const SOCK_CLOEXEC = 0x10000; | ||
| 256 | /// WARNING: this flag is not supported by windows socket functions directly, | ||
| 257 | /// it is only supported by std.os.socket. Be sure that this value does | ||
| 258 | /// not share any bits with any of the SOCK_* values. | ||
| 259 | pub const SOCK_NONBLOCK = 0x20000; | ||
| 260 | |||
| 261 | pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP; | ||
| 262 | pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP; | ||
| 263 | pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM; | ||
| 264 | pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP; | ||
| 265 | pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP; | ||
| 266 | pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6; | ||
| 267 | pub const IPPROTO_RM = ws2_32.IPPROTO_RM; | ||
| 268 | |||
| 269 | pub const nfds_t = c_ulong; | ||
| 270 | pub const pollfd = ws2_32.pollfd; | ||
| 271 | |||
| 272 | pub const POLLRDNORM = ws2_32.POLLRDNORM; | ||
| 273 | pub const POLLRDBAND = ws2_32.POLLRDBAND; | ||
| 274 | pub const POLLIN = ws2_32.POLLIN; | ||
| 275 | pub const POLLPRI = ws2_32.POLLPRI; | ||
| 276 | pub const POLLWRNORM = ws2_32.POLLWRNORM; | ||
| 277 | pub const POLLOUT = ws2_32.POLLOUT; | ||
| 278 | pub const POLLWRBAND = ws2_32.POLLWRBAND; | ||
| 279 | pub const POLLERR = ws2_32.POLLERR; | ||
| 280 | pub const POLLHUP = ws2_32.POLLHUP; | ||
| 281 | pub const POLLNVAL = ws2_32.POLLNVAL; | ||
| 282 | |||
| 283 | pub const SOL_SOCKET = ws2_32.SOL_SOCKET; | ||
| 284 | |||
| 285 | pub const SO_DEBUG = ws2_32.SO_DEBUG; | ||
| 286 | pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN; | ||
| 287 | pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR; | ||
| 288 | pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE; | ||
| 289 | pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE; | ||
| 290 | pub const SO_BROADCAST = ws2_32.SO_BROADCAST; | ||
| 291 | pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK; | ||
| 292 | pub const SO_LINGER = ws2_32.SO_LINGER; | ||
| 293 | pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE; | ||
| 294 | |||
| 295 | pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER; | ||
| 296 | pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE; | ||
| 297 | |||
| 298 | pub const SO_SNDBUF = ws2_32.SO_SNDBUF; | ||
| 299 | pub const SO_RCVBUF = ws2_32.SO_RCVBUF; | ||
| 300 | pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT; | ||
| 301 | pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT; | ||
| 302 | pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO; | ||
| 303 | pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO; | ||
| 304 | pub const SO_ERROR = ws2_32.SO_ERROR; | ||
| 305 | pub const SO_TYPE = ws2_32.SO_TYPE; | ||
| 306 | |||
| 307 | pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID; | ||
| 308 | pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY; | ||
| 309 | pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE; | ||
| 310 | pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA; | ||
| 311 | pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW; | ||
| 312 | |||
| 313 | pub const PVD_CONFIG = ws2_32.PVD_CONFIG; | ||
| 314 | pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT; | ||
| 315 | |||
| 316 | pub const TCP_NODELAY = ws2_32.TCP_NODELAY; | ||
| 317 | |||
| 318 | pub const O_RDONLY = 0o0; | ||
| 319 | pub const O_WRONLY = 0o1; | ||
| 320 | pub const O_RDWR = 0o2; | ||
| 321 | |||
| 322 | pub const O_CREAT = 0o100; | ||
| 323 | pub const O_EXCL = 0o200; | ||
| 324 | pub const O_NOCTTY = 0o400; | ||
| 325 | pub const O_TRUNC = 0o1000; | ||
| 326 | pub const O_APPEND = 0o2000; | ||
| 327 | pub const O_NONBLOCK = 0o4000; | ||
| 328 | pub const O_DSYNC = 0o10000; | ||
| 329 | pub const O_SYNC = 0o4010000; | ||
| 330 | pub const O_RSYNC = 0o4010000; | ||
| 331 | pub const O_DIRECTORY = 0o200000; | ||
| 332 | pub const O_NOFOLLOW = 0o400000; | ||
| 333 | pub const O_CLOEXEC = 0o2000000; | ||
| 334 | |||
| 335 | pub const O_ASYNC = 0o20000; | ||
| 336 | pub const O_DIRECT = 0o40000; | ||
| 337 | pub const O_LARGEFILE = 0; | ||
| 338 | pub const O_NOATIME = 0o1000000; | ||
| 339 | pub const O_PATH = 0o10000000; | ||
| 340 | pub const O_TMPFILE = 0o20200000; | ||
| 341 | pub const O_NDELAY = O_NONBLOCK; | ||
| 342 | |||
| 343 | pub const IFNAMESIZE = 30; |
lib/std/fs.zig+1-1| ... | @@ -471,7 +471,7 @@ pub const Dir = struct { | ... | @@ -471,7 +471,7 @@ pub const Dir = struct { |
| 471 | continue :start_over; | 471 | continue :start_over; |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | var stat_info: os.libc_stat = undefined; | 474 | var stat_info: os.Stat = undefined; |
| 475 | _ = os.system._kern_read_stat( | 475 | _ = os.system._kern_read_stat( |
| 476 | self.dir.fd, | 476 | self.dir.fd, |
| 477 | &haiku_entry.d_name, | 477 | &haiku_entry.d_name, |
lib/std/os.zig+58-85| ... | @@ -40,15 +40,10 @@ comptime { | ... | @@ -40,15 +40,10 @@ comptime { |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | test { | 42 | test { |
| 43 | _ = darwin; | ||
| 44 | _ = freebsd; | ||
| 45 | _ = linux; | 43 | _ = linux; |
| 46 | _ = netbsd; | ||
| 47 | _ = openbsd; | ||
| 48 | _ = uefi; | 44 | _ = uefi; |
| 49 | _ = wasi; | 45 | _ = wasi; |
| 50 | _ = windows; | 46 | _ = windows; |
| 51 | _ = haiku; | ||
| 52 | 47 | ||
| 53 | _ = @import("os/test.zig"); | 48 | _ = @import("os/test.zig"); |
| 54 | } | 49 | } |
| ... | @@ -61,85 +56,68 @@ pub const system = if (@hasDecl(root, "os") and root.os != @This()) | ... | @@ -61,85 +56,68 @@ pub const system = if (@hasDecl(root, "os") and root.os != @This()) |
| 61 | else if (builtin.link_libc) | 56 | else if (builtin.link_libc) |
| 62 | std.c | 57 | std.c |
| 63 | else switch (builtin.os.tag) { | 58 | else switch (builtin.os.tag) { |
| 64 | .macos, .ios, .watchos, .tvos => darwin, | ||
| 65 | .freebsd => freebsd, | ||
| 66 | .haiku => haiku, | ||
| 67 | .linux => linux, | 59 | .linux => linux, |
| 68 | .netbsd => netbsd, | ||
| 69 | .openbsd => openbsd, | ||
| 70 | .dragonfly => dragonfly, | ||
| 71 | .wasi => wasi, | 60 | .wasi => wasi, |
| 72 | .windows => windows, | 61 | .windows => windows, |
| 62 | .uefi => uefi, | ||
| 73 | else => struct {}, | 63 | else => struct {}, |
| 74 | }; | 64 | }; |
| 75 | 65 | pub const ARCH = system.ARCH; | |
| 76 | const bits = switch (builtin.os.tag) { | 66 | pub const AT = system.AT; |
| 77 | .macos, .ios, .tvos, .watchos => std.c, | 67 | pub const CLOCK = system.CLOCK; |
| 78 | .dragonfly => @import("os/bits/dragonfly.zig"), | 68 | pub const E = system.E; |
| 79 | .freebsd => @import("os/bits/freebsd.zig"), | 69 | pub const Elf_Symndx = system.Elf_Symndx; |
| 80 | .haiku => @import("os/bits/haiku.zig"), | 70 | pub const F = system.F; |
| 81 | .linux => linux, | 71 | pub const Flock = system.Flock; |
| 82 | .netbsd => @import("os/bits/netbsd.zig"), | 72 | pub const IOV_MAX = system.IOV_MAX; |
| 83 | .openbsd => @import("os/bits/openbsd.zig"), | 73 | pub const LOCK = system.LOCK; |
| 84 | .wasi => @import("os/bits/wasi.zig"), | 74 | pub const MAP = system.MAP; |
| 85 | .windows => @import("os/bits/windows.zig"), | 75 | pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN; |
| 86 | else => struct {}, | 76 | pub const MMAP2_UNIT = system.MMAP2_UNIT; |
| 87 | }; | 77 | pub const NAME_MAX = system.NAME_MAX; |
| 88 | pub const E = bits.E; | 78 | pub const O = system.O; |
| 89 | pub const ARCH = bits.ARCH; | 79 | pub const PATH_MAX = system.PATH_MAX; |
| 90 | pub const Elf_Symndx = bits.Elf_Symndx; | 80 | pub const PROT = system.PROT; |
| 91 | pub const F = bits.F; | 81 | pub const REG = system.REG; |
| 92 | pub const Flock = bits.Flock; | 82 | pub const S = system.S; |
| 93 | pub const LOCK = bits.LOCK; | 83 | pub const SA = system.SA; |
| 94 | pub const MAP = bits.MAP; | 84 | pub const SC = system.SC; |
| 95 | pub const MMAP2_UNIT = bits.MMAP2_UNIT; | 85 | pub const SIG = system.SIG; |
| 96 | pub const O = bits.O; | 86 | pub const STDERR_FILENO = system.STDIN_FILENO; |
| 97 | pub const REG = bits.REG; | 87 | pub const STDIN_FILENO = system.STDIN_FILENO; |
| 98 | pub const SC = bits.SC; | 88 | pub const STDOUT_FILENO = system.STDIN_FILENO; |
| 99 | pub const SYS = bits.SYS; | 89 | pub const SYS = system.SYS; |
| 100 | pub const VDSO = bits.VDSO; | 90 | pub const Sigaction = system.Sigaction; |
| 101 | pub const blkcnt_t = bits.blkcnt_t; | 91 | pub const Stat = system.Stat; |
| 102 | pub const blksize_t = bits.blksize_t; | 92 | pub const VDSO = system.VDSO; |
| 103 | pub const dev_t = bits.dev_t; | 93 | pub const blkcnt_t = system.blkcnt_t; |
| 104 | pub const ino_t = bits.ino_t; | 94 | pub const blksize_t = system.blksize_t; |
| 105 | pub const kernel_stat = bits.kernel_stat; | 95 | pub const clock_t = system.clock_t; |
| 106 | pub const libc_stat = bits.libc_stat; | 96 | pub const dev_t = system.dev_t; |
| 107 | pub const mcontext_t = bits.mcontext_t; | 97 | pub const dl_phdr_info = system.dl_phdr_info; |
| 108 | pub const mode_t = bits.mode_t; | 98 | pub const empty_sigset = system.empty_sigset; |
| 109 | pub const msghdr = bits.msghdr; | 99 | pub const fd_t = system.fd_t; |
| 110 | pub const msghdr_const = bits.msghdr_const; | 100 | pub const gid_t = system.gid_t; |
| 111 | pub const nlink_t = bits.nlink_t; | 101 | pub const ino_t = system.ino_t; |
| 112 | pub const off_t = bits.off_t; | 102 | pub const mcontext_t = system.mcontext_t; |
| 113 | pub const time_t = bits.time_t; | 103 | pub const mode_t = system.mode_t; |
| 114 | pub const timespec = bits.timespec; | 104 | pub const msghdr = system.msghdr; |
| 115 | pub const timeval = bits.timeval; | 105 | pub const msghdr_const = system.msghdr_const; |
| 116 | pub const timezone = bits.timezone; | 106 | pub const nlink_t = system.nlink_t; |
| 117 | pub const ucontext_t = bits.ucontext_t; | 107 | pub const off_t = system.off_t; |
| 118 | pub const user_desc = bits.user_desc; | 108 | pub const pid_t = system.pid_t; |
| 119 | pub const pid_t = bits.pid_t; | 109 | pub const pollfd = system.pollfd; |
| 120 | pub const fd_t = bits.fd_t; | 110 | pub const rlimit = system.rlimit; |
| 121 | pub const uid_t = bits.uid_t; | 111 | pub const rlimit_resource = system.rlimit_resource; |
| 122 | pub const gid_t = bits.gid_t; | 112 | pub const siginfo_t = system.siginfo_t; |
| 123 | pub const clock_t = bits.clock_t; | 113 | pub const sigset_t = system.sigset_t; |
| 124 | pub const NAME_MAX = bits.NAME_MAX; | 114 | pub const time_t = system.time_t; |
| 125 | pub const PATH_MAX = bits.PATH_MAX; | 115 | pub const timespec = system.timespec; |
| 126 | pub const IOV_MAX = bits.IOV_MAX; | 116 | pub const timeval = system.timeval; |
| 127 | pub const MAX_ADDR_LEN = bits.MAX_ADDR_LEN; | 117 | pub const timezone = system.timezone; |
| 128 | pub const STDIN_FILENO = bits.STDIN_FILENO; | 118 | pub const ucontext_t = system.ucontext_t; |
| 129 | pub const STDOUT_FILENO = bits.STDIN_FILENO; | 119 | pub const uid_t = system.uid_t; |
| 130 | pub const STDERR_FILENO = bits.STDIN_FILENO; | 120 | pub const user_desc = system.user_desc; |
| 131 | pub const AT = bits.AT; | ||
| 132 | pub const PROT = bits.PROT; | ||
| 133 | pub const CLOCK = bits.CLOCK; | ||
| 134 | pub const dl_phdr_info = bits.dl_phdr_info; | ||
| 135 | pub const Sigaction = bits.Sigaction; | ||
| 136 | pub const rlimit_resource = bits.rlimit_resource; | ||
| 137 | pub const SIG = bits.SIG; | ||
| 138 | pub const rlimit = bits.rlimit; | ||
| 139 | pub const empty_sigset = bits.empty_sigset; | ||
| 140 | pub const S = bits.S; | ||
| 141 | pub const siginfo_t = bits.siginfo_t; | ||
| 142 | pub const SA = bits.SA; | ||
| 143 | 121 | ||
| 144 | pub const iovec = extern struct { | 122 | pub const iovec = extern struct { |
| 145 | iov_base: [*]u8, | 123 | iov_base: [*]u8, |
| ... | @@ -334,7 +312,7 @@ pub fn raise(sig: u8) RaiseError!void { | ... | @@ -334,7 +312,7 @@ pub fn raise(sig: u8) RaiseError!void { |
| 334 | } | 312 | } |
| 335 | 313 | ||
| 336 | if (builtin.os.tag == .linux) { | 314 | if (builtin.os.tag == .linux) { |
| 337 | var set: bits.sigset_t = undefined; | 315 | var set: sigset_t = undefined; |
| 338 | // block application signals | 316 | // block application signals |
| 339 | _ = linux.sigprocmask(SIG.BLOCK, &linux.app_mask, &set); | 317 | _ = linux.sigprocmask(SIG.BLOCK, &linux.app_mask, &set); |
| 340 | 318 | ||
| ... | @@ -3558,11 +3536,6 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult { | ... | @@ -3558,11 +3536,6 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult { |
| 3558 | } | 3536 | } |
| 3559 | } | 3537 | } |
| 3560 | 3538 | ||
| 3561 | pub const Stat = if (builtin.link_libc) | ||
| 3562 | system.libc_stat | ||
| 3563 | else | ||
| 3564 | system.kernel_stat; | ||
| 3565 | |||
| 3566 | pub const FStatError = error{ | 3539 | pub const FStatError = error{ |
| 3567 | SystemResources, | 3540 | SystemResources, |
| 3568 | 3541 |
lib/std/os/bits/darwin.zig deleted-1783| ... | @@ -1,1783 +0,0 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const assert = std.debug.assert; | ||
| 3 | const maxInt = std.math.maxInt; | ||
| 4 | |||
| 5 | // See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html | ||
| 6 | // TODO: audit mode_t/pid_t, should likely be u16/i32 | ||
| 7 | pub const fd_t = c_int; | ||
| 8 | pub const pid_t = c_int; | ||
| 9 | pub const mode_t = c_uint; | ||
| 10 | pub const uid_t = u32; | ||
| 11 | pub const gid_t = u32; | ||
| 12 | |||
| 13 | pub const in_port_t = u16; | ||
| 14 | pub const sa_family_t = u8; | ||
| 15 | pub const socklen_t = u32; | ||
| 16 | pub const sockaddr = extern struct { | ||
| 17 | len: u8, | ||
| 18 | family: sa_family_t, | ||
| 19 | data: [14]u8, | ||
| 20 | }; | ||
| 21 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 22 | pub const sockaddr_in = extern struct { | ||
| 23 | len: u8 = @sizeOf(sockaddr_in), | ||
| 24 | family: sa_family_t = AF_INET, | ||
| 25 | port: in_port_t, | ||
| 26 | addr: u32, | ||
| 27 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 28 | }; | ||
| 29 | pub const sockaddr_in6 = extern struct { | ||
| 30 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 31 | family: sa_family_t = AF_INET6, | ||
| 32 | port: in_port_t, | ||
| 33 | flowinfo: u32, | ||
| 34 | addr: [16]u8, | ||
| 35 | scope_id: u32, | ||
| 36 | }; | ||
| 37 | |||
| 38 | /// UNIX domain socket | ||
| 39 | pub const sockaddr_un = extern struct { | ||
| 40 | len: u8 = @sizeOf(sockaddr_un), | ||
| 41 | family: sa_family_t = AF_UNIX, | ||
| 42 | path: [104]u8, | ||
| 43 | }; | ||
| 44 | |||
| 45 | pub const timeval = extern struct { | ||
| 46 | tv_sec: c_long, | ||
| 47 | tv_usec: i32, | ||
| 48 | }; | ||
| 49 | |||
| 50 | pub const timezone = extern struct { | ||
| 51 | tz_minuteswest: i32, | ||
| 52 | tz_dsttime: i32, | ||
| 53 | }; | ||
| 54 | |||
| 55 | pub const mach_timebase_info_data = extern struct { | ||
| 56 | numer: u32, | ||
| 57 | denom: u32, | ||
| 58 | }; | ||
| 59 | |||
| 60 | pub const off_t = i64; | ||
| 61 | pub const ino_t = u64; | ||
| 62 | |||
| 63 | pub const Flock = extern struct { | ||
| 64 | l_start: off_t, | ||
| 65 | l_len: off_t, | ||
| 66 | l_pid: pid_t, | ||
| 67 | l_type: i16, | ||
| 68 | l_whence: i16, | ||
| 69 | }; | ||
| 70 | |||
| 71 | pub const libc_stat = extern struct { | ||
| 72 | dev: i32, | ||
| 73 | mode: u16, | ||
| 74 | nlink: u16, | ||
| 75 | ino: ino_t, | ||
| 76 | uid: uid_t, | ||
| 77 | gid: gid_t, | ||
| 78 | rdev: i32, | ||
| 79 | atimesec: isize, | ||
| 80 | atimensec: isize, | ||
| 81 | mtimesec: isize, | ||
| 82 | mtimensec: isize, | ||
| 83 | ctimesec: isize, | ||
| 84 | ctimensec: isize, | ||
| 85 | birthtimesec: isize, | ||
| 86 | birthtimensec: isize, | ||
| 87 | size: off_t, | ||
| 88 | blocks: i64, | ||
| 89 | blksize: i32, | ||
| 90 | flags: u32, | ||
| 91 | gen: u32, | ||
| 92 | lspare: i32, | ||
| 93 | qspare: [2]i64, | ||
| 94 | |||
| 95 | pub fn atime(self: @This()) timespec { | ||
| 96 | return timespec{ | ||
| 97 | .tv_sec = self.atimesec, | ||
| 98 | .tv_nsec = self.atimensec, | ||
| 99 | }; | ||
| 100 | } | ||
| 101 | |||
| 102 | pub fn mtime(self: @This()) timespec { | ||
| 103 | return timespec{ | ||
| 104 | .tv_sec = self.mtimesec, | ||
| 105 | .tv_nsec = self.mtimensec, | ||
| 106 | }; | ||
| 107 | } | ||
| 108 | |||
| 109 | pub fn ctime(self: @This()) timespec { | ||
| 110 | return timespec{ | ||
| 111 | .tv_sec = self.ctimesec, | ||
| 112 | .tv_nsec = self.ctimensec, | ||
| 113 | }; | ||
| 114 | } | ||
| 115 | }; | ||
| 116 | |||
| 117 | pub const timespec = extern struct { | ||
| 118 | tv_sec: isize, | ||
| 119 | tv_nsec: isize, | ||
| 120 | }; | ||
| 121 | |||
| 122 | pub const sigset_t = u32; | ||
| 123 | pub const empty_sigset: sigset_t = 0; | ||
| 124 | |||
| 125 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 126 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 127 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 128 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5); | ||
| 129 | |||
| 130 | pub const siginfo_t = extern struct { | ||
| 131 | signo: c_int, | ||
| 132 | errno: c_int, | ||
| 133 | code: c_int, | ||
| 134 | pid: pid_t, | ||
| 135 | uid: uid_t, | ||
| 136 | status: c_int, | ||
| 137 | addr: *c_void, | ||
| 138 | value: extern union { | ||
| 139 | int: c_int, | ||
| 140 | ptr: *c_void, | ||
| 141 | }, | ||
| 142 | si_band: c_long, | ||
| 143 | _pad: [7]c_ulong, | ||
| 144 | }; | ||
| 145 | |||
| 146 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. | ||
| 147 | pub const Sigaction = extern struct { | ||
| 148 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 149 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 150 | |||
| 151 | handler: extern union { | ||
| 152 | handler: ?handler_fn, | ||
| 153 | sigaction: ?sigaction_fn, | ||
| 154 | }, | ||
| 155 | mask: sigset_t, | ||
| 156 | flags: c_uint, | ||
| 157 | }; | ||
| 158 | |||
| 159 | pub const dirent = extern struct { | ||
| 160 | d_ino: usize, | ||
| 161 | d_seekoff: usize, | ||
| 162 | d_reclen: u16, | ||
| 163 | d_namlen: u16, | ||
| 164 | d_type: u8, | ||
| 165 | d_name: u8, // field address is address of first byte of name | ||
| 166 | |||
| 167 | pub fn reclen(self: dirent) u16 { | ||
| 168 | return self.d_reclen; | ||
| 169 | } | ||
| 170 | }; | ||
| 171 | |||
| 172 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 173 | pub const Kevent = extern struct { | ||
| 174 | ident: usize, | ||
| 175 | filter: i16, | ||
| 176 | flags: u16, | ||
| 177 | fflags: u32, | ||
| 178 | data: isize, | ||
| 179 | udata: usize, | ||
| 180 | }; | ||
| 181 | |||
| 182 | // sys/types.h on macos uses #pragma pack(4) so these checks are | ||
| 183 | // to make sure the struct is laid out the same. These values were | ||
| 184 | // produced from C code using the offsetof macro. | ||
| 185 | comptime { | ||
| 186 | assert(@offsetOf(Kevent, "ident") == 0); | ||
| 187 | assert(@offsetOf(Kevent, "filter") == 8); | ||
| 188 | assert(@offsetOf(Kevent, "flags") == 10); | ||
| 189 | assert(@offsetOf(Kevent, "fflags") == 12); | ||
| 190 | assert(@offsetOf(Kevent, "data") == 16); | ||
| 191 | assert(@offsetOf(Kevent, "udata") == 24); | ||
| 192 | } | ||
| 193 | |||
| 194 | pub const kevent64_s = extern struct { | ||
| 195 | ident: u64, | ||
| 196 | filter: i16, | ||
| 197 | flags: u16, | ||
| 198 | fflags: u32, | ||
| 199 | data: i64, | ||
| 200 | udata: u64, | ||
| 201 | ext: [2]u64, | ||
| 202 | }; | ||
| 203 | |||
| 204 | // sys/types.h on macos uses #pragma pack() so these checks are | ||
| 205 | // to make sure the struct is laid out the same. These values were | ||
| 206 | // produced from C code using the offsetof macro. | ||
| 207 | comptime { | ||
| 208 | assert(@offsetOf(kevent64_s, "ident") == 0); | ||
| 209 | assert(@offsetOf(kevent64_s, "filter") == 8); | ||
| 210 | assert(@offsetOf(kevent64_s, "flags") == 10); | ||
| 211 | assert(@offsetOf(kevent64_s, "fflags") == 12); | ||
| 212 | assert(@offsetOf(kevent64_s, "data") == 16); | ||
| 213 | assert(@offsetOf(kevent64_s, "udata") == 24); | ||
| 214 | assert(@offsetOf(kevent64_s, "ext") == 32); | ||
| 215 | } | ||
| 216 | |||
| 217 | pub const mach_port_t = c_uint; | ||
| 218 | pub const clock_serv_t = mach_port_t; | ||
| 219 | pub const clock_res_t = c_int; | ||
| 220 | pub const mach_port_name_t = natural_t; | ||
| 221 | pub const natural_t = c_uint; | ||
| 222 | pub const mach_timespec_t = extern struct { | ||
| 223 | tv_sec: c_uint, | ||
| 224 | tv_nsec: clock_res_t, | ||
| 225 | }; | ||
| 226 | pub const kern_return_t = c_int; | ||
| 227 | pub const host_t = mach_port_t; | ||
| 228 | pub const CALENDAR_CLOCK = 1; | ||
| 229 | |||
| 230 | pub const PATH_MAX = 1024; | ||
| 231 | pub const IOV_MAX = 16; | ||
| 232 | |||
| 233 | pub const STDIN_FILENO = 0; | ||
| 234 | pub const STDOUT_FILENO = 1; | ||
| 235 | pub const STDERR_FILENO = 2; | ||
| 236 | |||
| 237 | /// [MC2] no permissions | ||
| 238 | pub const PROT_NONE = 0x00; | ||
| 239 | |||
| 240 | /// [MC2] pages can be read | ||
| 241 | pub const PROT_READ = 0x01; | ||
| 242 | |||
| 243 | /// [MC2] pages can be written | ||
| 244 | pub const PROT_WRITE = 0x02; | ||
| 245 | |||
| 246 | /// [MC2] pages can be executed | ||
| 247 | pub const PROT_EXEC = 0x04; | ||
| 248 | |||
| 249 | /// allocated from memory, swap space | ||
| 250 | pub const MAP_ANONYMOUS = 0x1000; | ||
| 251 | |||
| 252 | /// map from file (default) | ||
| 253 | pub const MAP_FILE = 0x0000; | ||
| 254 | |||
| 255 | /// interpret addr exactly | ||
| 256 | pub const MAP_FIXED = 0x0010; | ||
| 257 | |||
| 258 | /// region may contain semaphores | ||
| 259 | pub const MAP_HASSEMAPHORE = 0x0200; | ||
| 260 | |||
| 261 | /// changes are private | ||
| 262 | pub const MAP_PRIVATE = 0x0002; | ||
| 263 | |||
| 264 | /// share changes | ||
| 265 | pub const MAP_SHARED = 0x0001; | ||
| 266 | |||
| 267 | /// don't cache pages for this mapping | ||
| 268 | pub const MAP_NOCACHE = 0x0400; | ||
| 269 | |||
| 270 | /// don't reserve needed swap area | ||
| 271 | pub const MAP_NORESERVE = 0x0040; | ||
| 272 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 273 | |||
| 274 | /// [XSI] no hang in wait/no child to reap | ||
| 275 | pub const WNOHANG = 0x00000001; | ||
| 276 | |||
| 277 | /// [XSI] notify on stop, untraced child | ||
| 278 | pub const WUNTRACED = 0x00000002; | ||
| 279 | |||
| 280 | /// take signal on signal stack | ||
| 281 | pub const SA_ONSTACK = 0x0001; | ||
| 282 | |||
| 283 | /// restart system on signal return | ||
| 284 | pub const SA_RESTART = 0x0002; | ||
| 285 | |||
| 286 | /// reset to SIG_DFL when taking signal | ||
| 287 | pub const SA_RESETHAND = 0x0004; | ||
| 288 | |||
| 289 | /// do not generate SIGCHLD on child stop | ||
| 290 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 291 | |||
| 292 | /// don't mask the signal we're delivering | ||
| 293 | pub const SA_NODEFER = 0x0010; | ||
| 294 | |||
| 295 | /// don't keep zombies around | ||
| 296 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 297 | |||
| 298 | /// signal handler with SA_SIGINFO args | ||
| 299 | pub const SA_SIGINFO = 0x0040; | ||
| 300 | |||
| 301 | /// do not bounce off kernel's sigtramp | ||
| 302 | pub const SA_USERTRAMP = 0x0100; | ||
| 303 | |||
| 304 | /// signal handler with SA_SIGINFO args with 64bit regs information | ||
| 305 | pub const SA_64REGSET = 0x0200; | ||
| 306 | |||
| 307 | pub const O_PATH = 0x0000; | ||
| 308 | |||
| 309 | pub const F_OK = 0; | ||
| 310 | pub const X_OK = 1; | ||
| 311 | pub const W_OK = 2; | ||
| 312 | pub const R_OK = 4; | ||
| 313 | |||
| 314 | /// open for reading only | ||
| 315 | pub const O_RDONLY = 0x0000; | ||
| 316 | |||
| 317 | /// open for writing only | ||
| 318 | pub const O_WRONLY = 0x0001; | ||
| 319 | |||
| 320 | /// open for reading and writing | ||
| 321 | pub const O_RDWR = 0x0002; | ||
| 322 | |||
| 323 | /// do not block on open or for data to become available | ||
| 324 | pub const O_NONBLOCK = 0x0004; | ||
| 325 | |||
| 326 | /// append on each write | ||
| 327 | pub const O_APPEND = 0x0008; | ||
| 328 | |||
| 329 | /// create file if it does not exist | ||
| 330 | pub const O_CREAT = 0x0200; | ||
| 331 | |||
| 332 | /// truncate size to 0 | ||
| 333 | pub const O_TRUNC = 0x0400; | ||
| 334 | |||
| 335 | /// error if O_CREAT and the file exists | ||
| 336 | pub const O_EXCL = 0x0800; | ||
| 337 | |||
| 338 | /// atomically obtain a shared lock | ||
| 339 | pub const O_SHLOCK = 0x0010; | ||
| 340 | |||
| 341 | /// atomically obtain an exclusive lock | ||
| 342 | pub const O_EXLOCK = 0x0020; | ||
| 343 | |||
| 344 | /// do not follow symlinks | ||
| 345 | pub const O_NOFOLLOW = 0x0100; | ||
| 346 | |||
| 347 | /// allow open of symlinks | ||
| 348 | pub const O_SYMLINK = 0x200000; | ||
| 349 | |||
| 350 | /// descriptor requested for event notifications only | ||
| 351 | pub const O_EVTONLY = 0x8000; | ||
| 352 | |||
| 353 | /// mark as close-on-exec | ||
| 354 | pub const O_CLOEXEC = 0x1000000; | ||
| 355 | |||
| 356 | pub const O_ACCMODE = 3; | ||
| 357 | pub const O_ALERT = 536870912; | ||
| 358 | pub const O_ASYNC = 64; | ||
| 359 | pub const O_DIRECTORY = 1048576; | ||
| 360 | pub const O_DP_GETRAWENCRYPTED = 1; | ||
| 361 | pub const O_DP_GETRAWUNENCRYPTED = 2; | ||
| 362 | pub const O_DSYNC = 4194304; | ||
| 363 | pub const O_FSYNC = O_SYNC; | ||
| 364 | pub const O_NOCTTY = 131072; | ||
| 365 | pub const O_POPUP = 2147483648; | ||
| 366 | pub const O_SYNC = 128; | ||
| 367 | |||
| 368 | pub const SEEK_SET = 0x0; | ||
| 369 | pub const SEEK_CUR = 0x1; | ||
| 370 | pub const SEEK_END = 0x2; | ||
| 371 | |||
| 372 | pub const DT_UNKNOWN = 0; | ||
| 373 | pub const DT_FIFO = 1; | ||
| 374 | pub const DT_CHR = 2; | ||
| 375 | pub const DT_DIR = 4; | ||
| 376 | pub const DT_BLK = 6; | ||
| 377 | pub const DT_REG = 8; | ||
| 378 | pub const DT_LNK = 10; | ||
| 379 | pub const DT_SOCK = 12; | ||
| 380 | pub const DT_WHT = 14; | ||
| 381 | |||
| 382 | /// block specified signal set | ||
| 383 | pub const SIG_BLOCK = 1; | ||
| 384 | |||
| 385 | /// unblock specified signal set | ||
| 386 | pub const SIG_UNBLOCK = 2; | ||
| 387 | |||
| 388 | /// set specified signal set | ||
| 389 | pub const SIG_SETMASK = 3; | ||
| 390 | |||
| 391 | /// hangup | ||
| 392 | pub const SIGHUP = 1; | ||
| 393 | |||
| 394 | /// interrupt | ||
| 395 | pub const SIGINT = 2; | ||
| 396 | |||
| 397 | /// quit | ||
| 398 | pub const SIGQUIT = 3; | ||
| 399 | |||
| 400 | /// illegal instruction (not reset when caught) | ||
| 401 | pub const SIGILL = 4; | ||
| 402 | |||
| 403 | /// trace trap (not reset when caught) | ||
| 404 | pub const SIGTRAP = 5; | ||
| 405 | |||
| 406 | /// abort() | ||
| 407 | pub const SIGABRT = 6; | ||
| 408 | |||
| 409 | /// pollable event ([XSR] generated, not supported) | ||
| 410 | pub const SIGPOLL = 7; | ||
| 411 | |||
| 412 | /// compatibility | ||
| 413 | pub const SIGIOT = SIGABRT; | ||
| 414 | |||
| 415 | /// EMT instruction | ||
| 416 | pub const SIGEMT = 7; | ||
| 417 | |||
| 418 | /// floating point exception | ||
| 419 | pub const SIGFPE = 8; | ||
| 420 | |||
| 421 | /// kill (cannot be caught or ignored) | ||
| 422 | pub const SIGKILL = 9; | ||
| 423 | |||
| 424 | /// bus error | ||
| 425 | pub const SIGBUS = 10; | ||
| 426 | |||
| 427 | /// segmentation violation | ||
| 428 | pub const SIGSEGV = 11; | ||
| 429 | |||
| 430 | /// bad argument to system call | ||
| 431 | pub const SIGSYS = 12; | ||
| 432 | |||
| 433 | /// write on a pipe with no one to read it | ||
| 434 | pub const SIGPIPE = 13; | ||
| 435 | |||
| 436 | /// alarm clock | ||
| 437 | pub const SIGALRM = 14; | ||
| 438 | |||
| 439 | /// software termination signal from kill | ||
| 440 | pub const SIGTERM = 15; | ||
| 441 | |||
| 442 | /// urgent condition on IO channel | ||
| 443 | pub const SIGURG = 16; | ||
| 444 | |||
| 445 | /// sendable stop signal not from tty | ||
| 446 | pub const SIGSTOP = 17; | ||
| 447 | |||
| 448 | /// stop signal from tty | ||
| 449 | pub const SIGTSTP = 18; | ||
| 450 | |||
| 451 | /// continue a stopped process | ||
| 452 | pub const SIGCONT = 19; | ||
| 453 | |||
| 454 | /// to parent on child stop or exit | ||
| 455 | pub const SIGCHLD = 20; | ||
| 456 | |||
| 457 | /// to readers pgrp upon background tty read | ||
| 458 | pub const SIGTTIN = 21; | ||
| 459 | |||
| 460 | /// like TTIN for output if (tp->t_local&LTOSTOP) | ||
| 461 | pub const SIGTTOU = 22; | ||
| 462 | |||
| 463 | /// input/output possible signal | ||
| 464 | pub const SIGIO = 23; | ||
| 465 | |||
| 466 | /// exceeded CPU time limit | ||
| 467 | pub const SIGXCPU = 24; | ||
| 468 | |||
| 469 | /// exceeded file size limit | ||
| 470 | pub const SIGXFSZ = 25; | ||
| 471 | |||
| 472 | /// virtual time alarm | ||
| 473 | pub const SIGVTALRM = 26; | ||
| 474 | |||
| 475 | /// profiling time alarm | ||
| 476 | pub const SIGPROF = 27; | ||
| 477 | |||
| 478 | /// window size changes | ||
| 479 | pub const SIGWINCH = 28; | ||
| 480 | |||
| 481 | /// information request | ||
| 482 | pub const SIGINFO = 29; | ||
| 483 | |||
| 484 | /// user defined signal 1 | ||
| 485 | pub const SIGUSR1 = 30; | ||
| 486 | |||
| 487 | /// user defined signal 2 | ||
| 488 | pub const SIGUSR2 = 31; | ||
| 489 | |||
| 490 | /// no flag value | ||
| 491 | pub const KEVENT_FLAG_NONE = 0x000; | ||
| 492 | |||
| 493 | /// immediate timeout | ||
| 494 | pub const KEVENT_FLAG_IMMEDIATE = 0x001; | ||
| 495 | |||
| 496 | /// output events only include change | ||
| 497 | pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; | ||
| 498 | |||
| 499 | /// add event to kq (implies enable) | ||
| 500 | pub const EV_ADD = 0x0001; | ||
| 501 | |||
| 502 | /// delete event from kq | ||
| 503 | pub const EV_DELETE = 0x0002; | ||
| 504 | |||
| 505 | /// enable event | ||
| 506 | pub const EV_ENABLE = 0x0004; | ||
| 507 | |||
| 508 | /// disable event (not reported) | ||
| 509 | pub const EV_DISABLE = 0x0008; | ||
| 510 | |||
| 511 | /// only report one occurrence | ||
| 512 | pub const EV_ONESHOT = 0x0010; | ||
| 513 | |||
| 514 | /// clear event state after reporting | ||
| 515 | pub const EV_CLEAR = 0x0020; | ||
| 516 | |||
| 517 | /// force immediate event output | ||
| 518 | /// ... with or without EV_ERROR | ||
| 519 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 520 | /// on syscalls supporting flags | ||
| 521 | pub const EV_RECEIPT = 0x0040; | ||
| 522 | |||
| 523 | /// disable event after reporting | ||
| 524 | pub const EV_DISPATCH = 0x0080; | ||
| 525 | |||
| 526 | /// unique kevent per udata value | ||
| 527 | pub const EV_UDATA_SPECIFIC = 0x0100; | ||
| 528 | |||
| 529 | /// ... in combination with EV_DELETE | ||
| 530 | /// will defer delete until udata-specific | ||
| 531 | /// event enabled. EINPROGRESS will be | ||
| 532 | /// returned to indicate the deferral | ||
| 533 | pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC; | ||
| 534 | |||
| 535 | /// report that source has vanished | ||
| 536 | /// ... only valid with EV_DISPATCH2 | ||
| 537 | pub const EV_VANISHED = 0x0200; | ||
| 538 | |||
| 539 | /// reserved by system | ||
| 540 | pub const EV_SYSFLAGS = 0xF000; | ||
| 541 | |||
| 542 | /// filter-specific flag | ||
| 543 | pub const EV_FLAG0 = 0x1000; | ||
| 544 | |||
| 545 | /// filter-specific flag | ||
| 546 | pub const EV_FLAG1 = 0x2000; | ||
| 547 | |||
| 548 | /// EOF detected | ||
| 549 | pub const EV_EOF = 0x8000; | ||
| 550 | |||
| 551 | /// error, data contains errno | ||
| 552 | pub const EV_ERROR = 0x4000; | ||
| 553 | |||
| 554 | pub const EV_POLL = EV_FLAG0; | ||
| 555 | pub const EV_OOBAND = EV_FLAG1; | ||
| 556 | |||
| 557 | pub const EVFILT_READ = -1; | ||
| 558 | pub const EVFILT_WRITE = -2; | ||
| 559 | |||
| 560 | /// attached to aio requests | ||
| 561 | pub const EVFILT_AIO = -3; | ||
| 562 | |||
| 563 | /// attached to vnodes | ||
| 564 | pub const EVFILT_VNODE = -4; | ||
| 565 | |||
| 566 | /// attached to struct proc | ||
| 567 | pub const EVFILT_PROC = -5; | ||
| 568 | |||
| 569 | /// attached to struct proc | ||
| 570 | pub const EVFILT_SIGNAL = -6; | ||
| 571 | |||
| 572 | /// timers | ||
| 573 | pub const EVFILT_TIMER = -7; | ||
| 574 | |||
| 575 | /// Mach portsets | ||
| 576 | pub const EVFILT_MACHPORT = -8; | ||
| 577 | |||
| 578 | /// Filesystem events | ||
| 579 | pub const EVFILT_FS = -9; | ||
| 580 | |||
| 581 | /// User events | ||
| 582 | pub const EVFILT_USER = -10; | ||
| 583 | |||
| 584 | /// Virtual memory events | ||
| 585 | pub const EVFILT_VM = -12; | ||
| 586 | |||
| 587 | /// Exception events | ||
| 588 | pub const EVFILT_EXCEPT = -15; | ||
| 589 | |||
| 590 | pub const EVFILT_SYSCOUNT = 17; | ||
| 591 | |||
| 592 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 593 | pub const NOTE_TRIGGER = 0x01000000; | ||
| 594 | |||
| 595 | /// ignore input fflags | ||
| 596 | pub const NOTE_FFNOP = 0x00000000; | ||
| 597 | |||
| 598 | /// and fflags | ||
| 599 | pub const NOTE_FFAND = 0x40000000; | ||
| 600 | |||
| 601 | /// or fflags | ||
| 602 | pub const NOTE_FFOR = 0x80000000; | ||
| 603 | |||
| 604 | /// copy fflags | ||
| 605 | pub const NOTE_FFCOPY = 0xc0000000; | ||
| 606 | |||
| 607 | /// mask for operations | ||
| 608 | pub const NOTE_FFCTRLMASK = 0xc0000000; | ||
| 609 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | ||
| 610 | |||
| 611 | /// low water mark | ||
| 612 | pub const NOTE_LOWAT = 0x00000001; | ||
| 613 | |||
| 614 | /// OOB data | ||
| 615 | pub const NOTE_OOB = 0x00000002; | ||
| 616 | |||
| 617 | /// vnode was removed | ||
| 618 | pub const NOTE_DELETE = 0x00000001; | ||
| 619 | |||
| 620 | /// data contents changed | ||
| 621 | pub const NOTE_WRITE = 0x00000002; | ||
| 622 | |||
| 623 | /// size increased | ||
| 624 | pub const NOTE_EXTEND = 0x00000004; | ||
| 625 | |||
| 626 | /// attributes changed | ||
| 627 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 628 | |||
| 629 | /// link count changed | ||
| 630 | pub const NOTE_LINK = 0x00000010; | ||
| 631 | |||
| 632 | /// vnode was renamed | ||
| 633 | pub const NOTE_RENAME = 0x00000020; | ||
| 634 | |||
| 635 | /// vnode access was revoked | ||
| 636 | pub const NOTE_REVOKE = 0x00000040; | ||
| 637 | |||
| 638 | /// No specific vnode event: to test for EVFILT_READ activation | ||
| 639 | pub const NOTE_NONE = 0x00000080; | ||
| 640 | |||
| 641 | /// vnode was unlocked by flock(2) | ||
| 642 | pub const NOTE_FUNLOCK = 0x00000100; | ||
| 643 | |||
| 644 | /// process exited | ||
| 645 | pub const NOTE_EXIT = 0x80000000; | ||
| 646 | |||
| 647 | /// process forked | ||
| 648 | pub const NOTE_FORK = 0x40000000; | ||
| 649 | |||
| 650 | /// process exec'd | ||
| 651 | pub const NOTE_EXEC = 0x20000000; | ||
| 652 | |||
| 653 | /// shared with EVFILT_SIGNAL | ||
| 654 | pub const NOTE_SIGNAL = 0x08000000; | ||
| 655 | |||
| 656 | /// exit status to be returned, valid for child process only | ||
| 657 | pub const NOTE_EXITSTATUS = 0x04000000; | ||
| 658 | |||
| 659 | /// provide details on reasons for exit | ||
| 660 | pub const NOTE_EXIT_DETAIL = 0x02000000; | ||
| 661 | |||
| 662 | /// mask for signal & exit status | ||
| 663 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 664 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | ||
| 665 | |||
| 666 | pub const NOTE_EXIT_DETAIL_MASK = 0x00070000; | ||
| 667 | pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000; | ||
| 668 | pub const NOTE_EXIT_MEMORY = 0x00020000; | ||
| 669 | pub const NOTE_EXIT_CSERROR = 0x00040000; | ||
| 670 | |||
| 671 | /// will react on memory pressure | ||
| 672 | pub const NOTE_VM_PRESSURE = 0x80000000; | ||
| 673 | |||
| 674 | /// will quit on memory pressure, possibly after cleaning up dirty state | ||
| 675 | pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; | ||
| 676 | |||
| 677 | /// will quit immediately on memory pressure | ||
| 678 | pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; | ||
| 679 | |||
| 680 | /// there was an error | ||
| 681 | pub const NOTE_VM_ERROR = 0x10000000; | ||
| 682 | |||
| 683 | /// data is seconds | ||
| 684 | pub const NOTE_SECONDS = 0x00000001; | ||
| 685 | |||
| 686 | /// data is microseconds | ||
| 687 | pub const NOTE_USECONDS = 0x00000002; | ||
| 688 | |||
| 689 | /// data is nanoseconds | ||
| 690 | pub const NOTE_NSECONDS = 0x00000004; | ||
| 691 | |||
| 692 | /// absolute timeout | ||
| 693 | pub const NOTE_ABSOLUTE = 0x00000008; | ||
| 694 | |||
| 695 | /// ext[1] holds leeway for power aware timers | ||
| 696 | pub const NOTE_LEEWAY = 0x00000010; | ||
| 697 | |||
| 698 | /// system does minimal timer coalescing | ||
| 699 | pub const NOTE_CRITICAL = 0x00000020; | ||
| 700 | |||
| 701 | /// system does maximum timer coalescing | ||
| 702 | pub const NOTE_BACKGROUND = 0x00000040; | ||
| 703 | pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080; | ||
| 704 | |||
| 705 | /// data is mach absolute time units | ||
| 706 | pub const NOTE_MACHTIME = 0x00000100; | ||
| 707 | |||
| 708 | pub const AF_UNSPEC = 0; | ||
| 709 | pub const AF_LOCAL = 1; | ||
| 710 | pub const AF_UNIX = AF_LOCAL; | ||
| 711 | pub const AF_INET = 2; | ||
| 712 | pub const AF_SYS_CONTROL = 2; | ||
| 713 | pub const AF_IMPLINK = 3; | ||
| 714 | pub const AF_PUP = 4; | ||
| 715 | pub const AF_CHAOS = 5; | ||
| 716 | pub const AF_NS = 6; | ||
| 717 | pub const AF_ISO = 7; | ||
| 718 | pub const AF_OSI = AF_ISO; | ||
| 719 | pub const AF_ECMA = 8; | ||
| 720 | pub const AF_DATAKIT = 9; | ||
| 721 | pub const AF_CCITT = 10; | ||
| 722 | pub const AF_SNA = 11; | ||
| 723 | pub const AF_DECnet = 12; | ||
| 724 | pub const AF_DLI = 13; | ||
| 725 | pub const AF_LAT = 14; | ||
| 726 | pub const AF_HYLINK = 15; | ||
| 727 | pub const AF_APPLETALK = 16; | ||
| 728 | pub const AF_ROUTE = 17; | ||
| 729 | pub const AF_LINK = 18; | ||
| 730 | pub const AF_XTP = 19; | ||
| 731 | pub const AF_COIP = 20; | ||
| 732 | pub const AF_CNT = 21; | ||
| 733 | pub const AF_RTIP = 22; | ||
| 734 | pub const AF_IPX = 23; | ||
| 735 | pub const AF_SIP = 24; | ||
| 736 | pub const AF_PIP = 25; | ||
| 737 | pub const AF_ISDN = 28; | ||
| 738 | pub const AF_E164 = AF_ISDN; | ||
| 739 | pub const AF_KEY = 29; | ||
| 740 | pub const AF_INET6 = 30; | ||
| 741 | pub const AF_NATM = 31; | ||
| 742 | pub const AF_SYSTEM = 32; | ||
| 743 | pub const AF_NETBIOS = 33; | ||
| 744 | pub const AF_PPP = 34; | ||
| 745 | pub const AF_MAX = 40; | ||
| 746 | |||
| 747 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 748 | pub const PF_LOCAL = AF_LOCAL; | ||
| 749 | pub const PF_UNIX = PF_LOCAL; | ||
| 750 | pub const PF_INET = AF_INET; | ||
| 751 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 752 | pub const PF_PUP = AF_PUP; | ||
| 753 | pub const PF_CHAOS = AF_CHAOS; | ||
| 754 | pub const PF_NS = AF_NS; | ||
| 755 | pub const PF_ISO = AF_ISO; | ||
| 756 | pub const PF_OSI = AF_ISO; | ||
| 757 | pub const PF_ECMA = AF_ECMA; | ||
| 758 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 759 | pub const PF_CCITT = AF_CCITT; | ||
| 760 | pub const PF_SNA = AF_SNA; | ||
| 761 | pub const PF_DECnet = AF_DECnet; | ||
| 762 | pub const PF_DLI = AF_DLI; | ||
| 763 | pub const PF_LAT = AF_LAT; | ||
| 764 | pub const PF_HYLINK = AF_HYLINK; | ||
| 765 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 766 | pub const PF_ROUTE = AF_ROUTE; | ||
| 767 | pub const PF_LINK = AF_LINK; | ||
| 768 | pub const PF_XTP = AF_XTP; | ||
| 769 | pub const PF_COIP = AF_COIP; | ||
| 770 | pub const PF_CNT = AF_CNT; | ||
| 771 | pub const PF_SIP = AF_SIP; | ||
| 772 | pub const PF_IPX = AF_IPX; | ||
| 773 | pub const PF_RTIP = AF_RTIP; | ||
| 774 | pub const PF_PIP = AF_PIP; | ||
| 775 | pub const PF_ISDN = AF_ISDN; | ||
| 776 | pub const PF_KEY = AF_KEY; | ||
| 777 | pub const PF_INET6 = AF_INET6; | ||
| 778 | pub const PF_NATM = AF_NATM; | ||
| 779 | pub const PF_SYSTEM = AF_SYSTEM; | ||
| 780 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 781 | pub const PF_PPP = AF_PPP; | ||
| 782 | pub const PF_MAX = AF_MAX; | ||
| 783 | |||
| 784 | pub const SYSPROTO_EVENT = 1; | ||
| 785 | pub const SYSPROTO_CONTROL = 2; | ||
| 786 | |||
| 787 | pub const SOCK_STREAM = 1; | ||
| 788 | pub const SOCK_DGRAM = 2; | ||
| 789 | pub const SOCK_RAW = 3; | ||
| 790 | pub const SOCK_RDM = 4; | ||
| 791 | pub const SOCK_SEQPACKET = 5; | ||
| 792 | pub const SOCK_MAXADDRLEN = 255; | ||
| 793 | |||
| 794 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 795 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 796 | /// with any other "SOCK_" bits. | ||
| 797 | pub const SOCK_CLOEXEC = 1 << 15; | ||
| 798 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 799 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 800 | /// with any other "SOCK_" bits. | ||
| 801 | pub const SOCK_NONBLOCK = 1 << 16; | ||
| 802 | |||
| 803 | pub const IPPROTO_ICMP = 1; | ||
| 804 | pub const IPPROTO_ICMPV6 = 58; | ||
| 805 | pub const IPPROTO_TCP = 6; | ||
| 806 | pub const IPPROTO_UDP = 17; | ||
| 807 | pub const IPPROTO_IP = 0; | ||
| 808 | pub const IPPROTO_IPV6 = 41; | ||
| 809 | |||
| 810 | pub const SOL_SOCKET = 0xffff; | ||
| 811 | |||
| 812 | pub const SO_DEBUG = 0x0001; | ||
| 813 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 814 | pub const SO_REUSEADDR = 0x0004; | ||
| 815 | pub const SO_KEEPALIVE = 0x0008; | ||
| 816 | pub const SO_DONTROUTE = 0x0010; | ||
| 817 | pub const SO_BROADCAST = 0x0020; | ||
| 818 | pub const SO_USELOOPBACK = 0x0040; | ||
| 819 | pub const SO_LINGER = 0x1080; | ||
| 820 | pub const SO_OOBINLINE = 0x0100; | ||
| 821 | pub const SO_REUSEPORT = 0x0200; | ||
| 822 | pub const SO_ACCEPTFILTER = 0x1000; | ||
| 823 | pub const SO_SNDBUF = 0x1001; | ||
| 824 | pub const SO_RCVBUF = 0x1002; | ||
| 825 | pub const SO_SNDLOWAT = 0x1003; | ||
| 826 | pub const SO_RCVLOWAT = 0x1004; | ||
| 827 | pub const SO_SNDTIMEO = 0x1005; | ||
| 828 | pub const SO_RCVTIMEO = 0x1006; | ||
| 829 | pub const SO_ERROR = 0x1007; | ||
| 830 | pub const SO_TYPE = 0x1008; | ||
| 831 | |||
| 832 | pub const SO_NREAD = 0x1020; | ||
| 833 | pub const SO_NKE = 0x1021; | ||
| 834 | pub const SO_NOSIGPIPE = 0x1022; | ||
| 835 | pub const SO_NOADDRERR = 0x1023; | ||
| 836 | pub const SO_NWRITE = 0x1024; | ||
| 837 | pub const SO_REUSESHAREUID = 0x1025; | ||
| 838 | |||
| 839 | fn wstatus(x: u32) u32 { | ||
| 840 | return x & 0o177; | ||
| 841 | } | ||
| 842 | const wstopped = 0o177; | ||
| 843 | pub fn WEXITSTATUS(x: u32) u8 { | ||
| 844 | return @intCast(u8, x >> 8); | ||
| 845 | } | ||
| 846 | pub fn WTERMSIG(x: u32) u32 { | ||
| 847 | return wstatus(x); | ||
| 848 | } | ||
| 849 | pub fn WSTOPSIG(x: u32) u32 { | ||
| 850 | return x >> 8; | ||
| 851 | } | ||
| 852 | pub fn WIFEXITED(x: u32) bool { | ||
| 853 | return wstatus(x) == 0; | ||
| 854 | } | ||
| 855 | pub fn WIFSTOPPED(x: u32) bool { | ||
| 856 | return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13; | ||
| 857 | } | ||
| 858 | pub fn WIFSIGNALED(x: u32) bool { | ||
| 859 | return wstatus(x) != wstopped and wstatus(x) != 0; | ||
| 860 | } | ||
| 861 | |||
| 862 | pub const E = enum(u16) { | ||
| 863 | /// No error occurred. | ||
| 864 | SUCCESS = 0, | ||
| 865 | |||
| 866 | /// Operation not permitted | ||
| 867 | PERM = 1, | ||
| 868 | |||
| 869 | /// No such file or directory | ||
| 870 | NOENT = 2, | ||
| 871 | |||
| 872 | /// No such process | ||
| 873 | SRCH = 3, | ||
| 874 | |||
| 875 | /// Interrupted system call | ||
| 876 | INTR = 4, | ||
| 877 | |||
| 878 | /// Input/output error | ||
| 879 | IO = 5, | ||
| 880 | |||
| 881 | /// Device not configured | ||
| 882 | NXIO = 6, | ||
| 883 | |||
| 884 | /// Argument list too long | ||
| 885 | @"2BIG" = 7, | ||
| 886 | |||
| 887 | /// Exec format error | ||
| 888 | NOEXEC = 8, | ||
| 889 | |||
| 890 | /// Bad file descriptor | ||
| 891 | BADF = 9, | ||
| 892 | |||
| 893 | /// No child processes | ||
| 894 | CHILD = 10, | ||
| 895 | |||
| 896 | /// Resource deadlock avoided | ||
| 897 | DEADLK = 11, | ||
| 898 | |||
| 899 | /// Cannot allocate memory | ||
| 900 | NOMEM = 12, | ||
| 901 | |||
| 902 | /// Permission denied | ||
| 903 | ACCES = 13, | ||
| 904 | |||
| 905 | /// Bad address | ||
| 906 | FAULT = 14, | ||
| 907 | |||
| 908 | /// Block device required | ||
| 909 | NOTBLK = 15, | ||
| 910 | |||
| 911 | /// Device / Resource busy | ||
| 912 | BUSY = 16, | ||
| 913 | |||
| 914 | /// File exists | ||
| 915 | EXIST = 17, | ||
| 916 | |||
| 917 | /// Cross-device link | ||
| 918 | XDEV = 18, | ||
| 919 | |||
| 920 | /// Operation not supported by device | ||
| 921 | NODEV = 19, | ||
| 922 | |||
| 923 | /// Not a directory | ||
| 924 | NOTDIR = 20, | ||
| 925 | |||
| 926 | /// Is a directory | ||
| 927 | ISDIR = 21, | ||
| 928 | |||
| 929 | /// Invalid argument | ||
| 930 | INVAL = 22, | ||
| 931 | |||
| 932 | /// Too many open files in system | ||
| 933 | NFILE = 23, | ||
| 934 | |||
| 935 | /// Too many open files | ||
| 936 | MFILE = 24, | ||
| 937 | |||
| 938 | /// Inappropriate ioctl for device | ||
| 939 | NOTTY = 25, | ||
| 940 | |||
| 941 | /// Text file busy | ||
| 942 | TXTBSY = 26, | ||
| 943 | |||
| 944 | /// File too large | ||
| 945 | FBIG = 27, | ||
| 946 | |||
| 947 | /// No space left on device | ||
| 948 | NOSPC = 28, | ||
| 949 | |||
| 950 | /// Illegal seek | ||
| 951 | SPIPE = 29, | ||
| 952 | |||
| 953 | /// Read-only file system | ||
| 954 | ROFS = 30, | ||
| 955 | |||
| 956 | /// Too many links | ||
| 957 | MLINK = 31, | ||
| 958 | |||
| 959 | /// Broken pipe | ||
| 960 | PIPE = 32, | ||
| 961 | |||
| 962 | // math software | ||
| 963 | |||
| 964 | /// Numerical argument out of domain | ||
| 965 | DOM = 33, | ||
| 966 | |||
| 967 | /// Result too large | ||
| 968 | RANGE = 34, | ||
| 969 | |||
| 970 | // non-blocking and interrupt i/o | ||
| 971 | |||
| 972 | /// Resource temporarily unavailable | ||
| 973 | /// This is the same code used for `WOULDBLOCK`. | ||
| 974 | AGAIN = 35, | ||
| 975 | |||
| 976 | /// Operation now in progress | ||
| 977 | INPROGRESS = 36, | ||
| 978 | |||
| 979 | /// Operation already in progress | ||
| 980 | ALREADY = 37, | ||
| 981 | |||
| 982 | // ipc/network software -- argument errors | ||
| 983 | |||
| 984 | /// Socket operation on non-socket | ||
| 985 | NOTSOCK = 38, | ||
| 986 | |||
| 987 | /// Destination address required | ||
| 988 | DESTADDRREQ = 39, | ||
| 989 | |||
| 990 | /// Message too long | ||
| 991 | MSGSIZE = 40, | ||
| 992 | |||
| 993 | /// Protocol wrong type for socket | ||
| 994 | PROTOTYPE = 41, | ||
| 995 | |||
| 996 | /// Protocol not available | ||
| 997 | NOPROTOOPT = 42, | ||
| 998 | |||
| 999 | /// Protocol not supported | ||
| 1000 | PROTONOSUPPORT = 43, | ||
| 1001 | |||
| 1002 | /// Socket type not supported | ||
| 1003 | SOCKTNOSUPPORT = 44, | ||
| 1004 | |||
| 1005 | /// Operation not supported | ||
| 1006 | /// The same code is used for `NOTSUP`. | ||
| 1007 | OPNOTSUPP = 45, | ||
| 1008 | |||
| 1009 | /// Protocol family not supported | ||
| 1010 | PFNOSUPPORT = 46, | ||
| 1011 | |||
| 1012 | /// Address family not supported by protocol family | ||
| 1013 | AFNOSUPPORT = 47, | ||
| 1014 | |||
| 1015 | /// Address already in use | ||
| 1016 | ADDRINUSE = 48, | ||
| 1017 | /// Can't assign requested address | ||
| 1018 | |||
| 1019 | // ipc/network software -- operational errors | ||
| 1020 | ADDRNOTAVAIL = 49, | ||
| 1021 | |||
| 1022 | /// Network is down | ||
| 1023 | NETDOWN = 50, | ||
| 1024 | |||
| 1025 | /// Network is unreachable | ||
| 1026 | NETUNREACH = 51, | ||
| 1027 | |||
| 1028 | /// Network dropped connection on reset | ||
| 1029 | NETRESET = 52, | ||
| 1030 | |||
| 1031 | /// Software caused connection abort | ||
| 1032 | CONNABORTED = 53, | ||
| 1033 | |||
| 1034 | /// Connection reset by peer | ||
| 1035 | CONNRESET = 54, | ||
| 1036 | |||
| 1037 | /// No buffer space available | ||
| 1038 | NOBUFS = 55, | ||
| 1039 | |||
| 1040 | /// Socket is already connected | ||
| 1041 | ISCONN = 56, | ||
| 1042 | |||
| 1043 | /// Socket is not connected | ||
| 1044 | NOTCONN = 57, | ||
| 1045 | |||
| 1046 | /// Can't send after socket shutdown | ||
| 1047 | SHUTDOWN = 58, | ||
| 1048 | |||
| 1049 | /// Too many references: can't splice | ||
| 1050 | TOOMANYREFS = 59, | ||
| 1051 | |||
| 1052 | /// Operation timed out | ||
| 1053 | TIMEDOUT = 60, | ||
| 1054 | |||
| 1055 | /// Connection refused | ||
| 1056 | CONNREFUSED = 61, | ||
| 1057 | |||
| 1058 | /// Too many levels of symbolic links | ||
| 1059 | LOOP = 62, | ||
| 1060 | |||
| 1061 | /// File name too long | ||
| 1062 | NAMETOOLONG = 63, | ||
| 1063 | |||
| 1064 | /// Host is down | ||
| 1065 | HOSTDOWN = 64, | ||
| 1066 | |||
| 1067 | /// No route to host | ||
| 1068 | HOSTUNREACH = 65, | ||
| 1069 | /// Directory not empty | ||
| 1070 | |||
| 1071 | // quotas & mush | ||
| 1072 | NOTEMPTY = 66, | ||
| 1073 | |||
| 1074 | /// Too many processes | ||
| 1075 | PROCLIM = 67, | ||
| 1076 | |||
| 1077 | /// Too many users | ||
| 1078 | USERS = 68, | ||
| 1079 | /// Disc quota exceeded | ||
| 1080 | |||
| 1081 | // Network File System | ||
| 1082 | DQUOT = 69, | ||
| 1083 | |||
| 1084 | /// Stale NFS file handle | ||
| 1085 | STALE = 70, | ||
| 1086 | |||
| 1087 | /// Too many levels of remote in path | ||
| 1088 | REMOTE = 71, | ||
| 1089 | |||
| 1090 | /// RPC struct is bad | ||
| 1091 | BADRPC = 72, | ||
| 1092 | |||
| 1093 | /// RPC version wrong | ||
| 1094 | RPCMISMATCH = 73, | ||
| 1095 | |||
| 1096 | /// RPC prog. not avail | ||
| 1097 | PROGUNAVAIL = 74, | ||
| 1098 | |||
| 1099 | /// Program version wrong | ||
| 1100 | PROGMISMATCH = 75, | ||
| 1101 | |||
| 1102 | /// Bad procedure for program | ||
| 1103 | PROCUNAVAIL = 76, | ||
| 1104 | |||
| 1105 | /// No locks available | ||
| 1106 | NOLCK = 77, | ||
| 1107 | |||
| 1108 | /// Function not implemented | ||
| 1109 | NOSYS = 78, | ||
| 1110 | |||
| 1111 | /// Inappropriate file type or format | ||
| 1112 | FTYPE = 79, | ||
| 1113 | |||
| 1114 | /// Authentication error | ||
| 1115 | AUTH = 80, | ||
| 1116 | |||
| 1117 | /// Need authenticator | ||
| 1118 | NEEDAUTH = 81, | ||
| 1119 | |||
| 1120 | // Intelligent device errors | ||
| 1121 | |||
| 1122 | /// Device power is off | ||
| 1123 | PWROFF = 82, | ||
| 1124 | |||
| 1125 | /// Device error, e.g. paper out | ||
| 1126 | DEVERR = 83, | ||
| 1127 | |||
| 1128 | /// Value too large to be stored in data type | ||
| 1129 | OVERFLOW = 84, | ||
| 1130 | |||
| 1131 | // Program loading errors | ||
| 1132 | |||
| 1133 | /// Bad executable | ||
| 1134 | BADEXEC = 85, | ||
| 1135 | |||
| 1136 | /// Bad CPU type in executable | ||
| 1137 | BADARCH = 86, | ||
| 1138 | |||
| 1139 | /// Shared library version mismatch | ||
| 1140 | SHLIBVERS = 87, | ||
| 1141 | |||
| 1142 | /// Malformed Macho file | ||
| 1143 | BADMACHO = 88, | ||
| 1144 | |||
| 1145 | /// Operation canceled | ||
| 1146 | CANCELED = 89, | ||
| 1147 | |||
| 1148 | /// Identifier removed | ||
| 1149 | IDRM = 90, | ||
| 1150 | |||
| 1151 | /// No message of desired type | ||
| 1152 | NOMSG = 91, | ||
| 1153 | |||
| 1154 | /// Illegal byte sequence | ||
| 1155 | ILSEQ = 92, | ||
| 1156 | |||
| 1157 | /// Attribute not found | ||
| 1158 | NOATTR = 93, | ||
| 1159 | |||
| 1160 | /// Bad message | ||
| 1161 | BADMSG = 94, | ||
| 1162 | |||
| 1163 | /// Reserved | ||
| 1164 | MULTIHOP = 95, | ||
| 1165 | |||
| 1166 | /// No message available on STREAM | ||
| 1167 | NODATA = 96, | ||
| 1168 | |||
| 1169 | /// Reserved | ||
| 1170 | NOLINK = 97, | ||
| 1171 | |||
| 1172 | /// No STREAM resources | ||
| 1173 | NOSR = 98, | ||
| 1174 | |||
| 1175 | /// Not a STREAM | ||
| 1176 | NOSTR = 99, | ||
| 1177 | |||
| 1178 | /// Protocol error | ||
| 1179 | PROTO = 100, | ||
| 1180 | |||
| 1181 | /// STREAM ioctl timeout | ||
| 1182 | TIME = 101, | ||
| 1183 | |||
| 1184 | /// No such policy registered | ||
| 1185 | NOPOLICY = 103, | ||
| 1186 | |||
| 1187 | /// State not recoverable | ||
| 1188 | NOTRECOVERABLE = 104, | ||
| 1189 | |||
| 1190 | /// Previous owner died | ||
| 1191 | OWNERDEAD = 105, | ||
| 1192 | |||
| 1193 | /// Interface output queue is full | ||
| 1194 | QFULL = 106, | ||
| 1195 | |||
| 1196 | _, | ||
| 1197 | }; | ||
| 1198 | |||
| 1199 | pub const SIGSTKSZ = 131072; | ||
| 1200 | pub const MINSIGSTKSZ = 32768; | ||
| 1201 | |||
| 1202 | pub const SS_ONSTACK = 1; | ||
| 1203 | pub const SS_DISABLE = 4; | ||
| 1204 | |||
| 1205 | pub const stack_t = extern struct { | ||
| 1206 | ss_sp: [*]u8, | ||
| 1207 | ss_size: isize, | ||
| 1208 | ss_flags: i32, | ||
| 1209 | }; | ||
| 1210 | |||
| 1211 | pub const S_IFMT = 0o170000; | ||
| 1212 | |||
| 1213 | pub const S_IFIFO = 0o010000; | ||
| 1214 | pub const S_IFCHR = 0o020000; | ||
| 1215 | pub const S_IFDIR = 0o040000; | ||
| 1216 | pub const S_IFBLK = 0o060000; | ||
| 1217 | pub const S_IFREG = 0o100000; | ||
| 1218 | pub const S_IFLNK = 0o120000; | ||
| 1219 | pub const S_IFSOCK = 0o140000; | ||
| 1220 | pub const S_IFWHT = 0o160000; | ||
| 1221 | |||
| 1222 | pub const S_ISUID = 0o4000; | ||
| 1223 | pub const S_ISGID = 0o2000; | ||
| 1224 | pub const S_ISVTX = 0o1000; | ||
| 1225 | pub const S_IRWXU = 0o700; | ||
| 1226 | pub const S_IRUSR = 0o400; | ||
| 1227 | pub const S_IWUSR = 0o200; | ||
| 1228 | pub const S_IXUSR = 0o100; | ||
| 1229 | pub const S_IRWXG = 0o070; | ||
| 1230 | pub const S_IRGRP = 0o040; | ||
| 1231 | pub const S_IWGRP = 0o020; | ||
| 1232 | pub const S_IXGRP = 0o010; | ||
| 1233 | pub const S_IRWXO = 0o007; | ||
| 1234 | pub const S_IROTH = 0o004; | ||
| 1235 | pub const S_IWOTH = 0o002; | ||
| 1236 | pub const S_IXOTH = 0o001; | ||
| 1237 | |||
| 1238 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1239 | return m & S_IFMT == S_IFIFO; | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | pub fn S_ISCHR(m: u32) bool { | ||
| 1243 | return m & S_IFMT == S_IFCHR; | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | pub fn S_ISDIR(m: u32) bool { | ||
| 1247 | return m & S_IFMT == S_IFDIR; | ||
| 1248 | } | ||
| 1249 | |||
| 1250 | pub fn S_ISBLK(m: u32) bool { | ||
| 1251 | return m & S_IFMT == S_IFBLK; | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | pub fn S_ISREG(m: u32) bool { | ||
| 1255 | return m & S_IFMT == S_IFREG; | ||
| 1256 | } | ||
| 1257 | |||
| 1258 | pub fn S_ISLNK(m: u32) bool { | ||
| 1259 | return m & S_IFMT == S_IFLNK; | ||
| 1260 | } | ||
| 1261 | |||
| 1262 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1263 | return m & S_IFMT == S_IFSOCK; | ||
| 1264 | } | ||
| 1265 | |||
| 1266 | pub fn S_IWHT(m: u32) bool { | ||
| 1267 | return m & S_IFMT == S_IFWHT; | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | pub const HOST_NAME_MAX = 72; | ||
| 1271 | |||
| 1272 | pub const AT_FDCWD = -2; | ||
| 1273 | |||
| 1274 | /// Use effective ids in access check | ||
| 1275 | pub const AT_EACCESS = 0x0010; | ||
| 1276 | |||
| 1277 | /// Act on the symlink itself not the target | ||
| 1278 | pub const AT_SYMLINK_NOFOLLOW = 0x0020; | ||
| 1279 | |||
| 1280 | /// Act on target of symlink | ||
| 1281 | pub const AT_SYMLINK_FOLLOW = 0x0040; | ||
| 1282 | |||
| 1283 | /// Path refers to directory | ||
| 1284 | pub const AT_REMOVEDIR = 0x0080; | ||
| 1285 | |||
| 1286 | pub const addrinfo = extern struct { | ||
| 1287 | flags: i32, | ||
| 1288 | family: i32, | ||
| 1289 | socktype: i32, | ||
| 1290 | protocol: i32, | ||
| 1291 | addrlen: socklen_t, | ||
| 1292 | canonname: ?[*:0]u8, | ||
| 1293 | addr: ?*sockaddr, | ||
| 1294 | next: ?*addrinfo, | ||
| 1295 | }; | ||
| 1296 | |||
| 1297 | pub const RTLD_LAZY = 0x1; | ||
| 1298 | pub const RTLD_NOW = 0x2; | ||
| 1299 | pub const RTLD_LOCAL = 0x4; | ||
| 1300 | pub const RTLD_GLOBAL = 0x8; | ||
| 1301 | pub const RTLD_NOLOAD = 0x10; | ||
| 1302 | pub const RTLD_NODELETE = 0x80; | ||
| 1303 | pub const RTLD_FIRST = 0x100; | ||
| 1304 | |||
| 1305 | pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); | ||
| 1306 | pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); | ||
| 1307 | pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); | ||
| 1308 | pub const RTLD_MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5))); | ||
| 1309 | |||
| 1310 | /// duplicate file descriptor | ||
| 1311 | pub const F_DUPFD = 0; | ||
| 1312 | |||
| 1313 | /// get file descriptor flags | ||
| 1314 | pub const F_GETFD = 1; | ||
| 1315 | |||
| 1316 | /// set file descriptor flags | ||
| 1317 | pub const F_SETFD = 2; | ||
| 1318 | |||
| 1319 | /// get file status flags | ||
| 1320 | pub const F_GETFL = 3; | ||
| 1321 | |||
| 1322 | /// set file status flags | ||
| 1323 | pub const F_SETFL = 4; | ||
| 1324 | |||
| 1325 | /// get SIGIO/SIGURG proc/pgrp | ||
| 1326 | pub const F_GETOWN = 5; | ||
| 1327 | |||
| 1328 | /// set SIGIO/SIGURG proc/pgrp | ||
| 1329 | pub const F_SETOWN = 6; | ||
| 1330 | |||
| 1331 | /// get record locking information | ||
| 1332 | pub const F_GETLK = 7; | ||
| 1333 | |||
| 1334 | /// set record locking information | ||
| 1335 | pub const F_SETLK = 8; | ||
| 1336 | |||
| 1337 | /// F_SETLK; wait if blocked | ||
| 1338 | pub const F_SETLKW = 9; | ||
| 1339 | |||
| 1340 | /// F_SETLK; wait if blocked, return on timeout | ||
| 1341 | pub const F_SETLKWTIMEOUT = 10; | ||
| 1342 | pub const F_FLUSH_DATA = 40; | ||
| 1343 | |||
| 1344 | /// Used for regression test | ||
| 1345 | pub const F_CHKCLEAN = 41; | ||
| 1346 | |||
| 1347 | /// Preallocate storage | ||
| 1348 | pub const F_PREALLOCATE = 42; | ||
| 1349 | |||
| 1350 | /// Truncate a file without zeroing space | ||
| 1351 | pub const F_SETSIZE = 43; | ||
| 1352 | |||
| 1353 | /// Issue an advisory read async with no copy to user | ||
| 1354 | pub const F_RDADVISE = 44; | ||
| 1355 | |||
| 1356 | /// turn read ahead off/on for this fd | ||
| 1357 | pub const F_RDAHEAD = 45; | ||
| 1358 | |||
| 1359 | /// turn data caching off/on for this fd | ||
| 1360 | pub const F_NOCACHE = 48; | ||
| 1361 | |||
| 1362 | /// file offset to device offset | ||
| 1363 | pub const F_LOG2PHYS = 49; | ||
| 1364 | |||
| 1365 | /// return the full path of the fd | ||
| 1366 | pub const F_GETPATH = 50; | ||
| 1367 | |||
| 1368 | /// fsync + ask the drive to flush to the media | ||
| 1369 | pub const F_FULLFSYNC = 51; | ||
| 1370 | |||
| 1371 | /// find which component (if any) is a package | ||
| 1372 | pub const F_PATHPKG_CHECK = 52; | ||
| 1373 | |||
| 1374 | /// "freeze" all fs operations | ||
| 1375 | pub const F_FREEZE_FS = 53; | ||
| 1376 | |||
| 1377 | /// "thaw" all fs operations | ||
| 1378 | pub const F_THAW_FS = 54; | ||
| 1379 | |||
| 1380 | /// turn data caching off/on (globally) for this file | ||
| 1381 | pub const F_GLOBAL_NOCACHE = 55; | ||
| 1382 | |||
| 1383 | /// add detached signatures | ||
| 1384 | pub const F_ADDSIGS = 59; | ||
| 1385 | |||
| 1386 | /// add signature from same file (used by dyld for shared libs) | ||
| 1387 | pub const F_ADDFILESIGS = 61; | ||
| 1388 | |||
| 1389 | /// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes | ||
| 1390 | /// should not be used (i.e. its ok to temporaily create cached pages) | ||
| 1391 | pub const F_NODIRECT = 62; | ||
| 1392 | |||
| 1393 | ///Get the protection class of a file from the EA, returns int | ||
| 1394 | pub const F_GETPROTECTIONCLASS = 63; | ||
| 1395 | |||
| 1396 | ///Set the protection class of a file for the EA, requires int | ||
| 1397 | pub const F_SETPROTECTIONCLASS = 64; | ||
| 1398 | |||
| 1399 | ///file offset to device offset, extended | ||
| 1400 | pub const F_LOG2PHYS_EXT = 65; | ||
| 1401 | |||
| 1402 | ///get record locking information, per-process | ||
| 1403 | pub const F_GETLKPID = 66; | ||
| 1404 | |||
| 1405 | ///Mark the file as being the backing store for another filesystem | ||
| 1406 | pub const F_SETBACKINGSTORE = 70; | ||
| 1407 | |||
| 1408 | ///return the full path of the FD, but error in specific mtmd circumstances | ||
| 1409 | pub const F_GETPATH_MTMINFO = 71; | ||
| 1410 | |||
| 1411 | ///Returns the code directory, with associated hashes, to the caller | ||
| 1412 | pub const F_GETCODEDIR = 72; | ||
| 1413 | |||
| 1414 | ///No SIGPIPE generated on EPIPE | ||
| 1415 | pub const F_SETNOSIGPIPE = 73; | ||
| 1416 | |||
| 1417 | ///Status of SIGPIPE for this fd | ||
| 1418 | pub const F_GETNOSIGPIPE = 74; | ||
| 1419 | |||
| 1420 | ///For some cases, we need to rewrap the key for AKS/MKB | ||
| 1421 | pub const F_TRANSCODEKEY = 75; | ||
| 1422 | |||
| 1423 | ///file being written to a by single writer... if throttling enabled, writes | ||
| 1424 | ///may be broken into smaller chunks with throttling in between | ||
| 1425 | pub const F_SINGLE_WRITER = 76; | ||
| 1426 | |||
| 1427 | ///Get the protection version number for this filesystem | ||
| 1428 | pub const F_GETPROTECTIONLEVEL = 77; | ||
| 1429 | |||
| 1430 | ///Add detached code signatures (used by dyld for shared libs) | ||
| 1431 | pub const F_FINDSIGS = 78; | ||
| 1432 | |||
| 1433 | ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator) | ||
| 1434 | pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83; | ||
| 1435 | |||
| 1436 | ///fsync + issue barrier to drive | ||
| 1437 | pub const F_BARRIERFSYNC = 85; | ||
| 1438 | |||
| 1439 | ///Add signature from same file, return end offset in structure on success | ||
| 1440 | pub const F_ADDFILESIGS_RETURN = 97; | ||
| 1441 | |||
| 1442 | ///Check if Library Validation allows this Mach-O file to be mapped into the calling process | ||
| 1443 | pub const F_CHECK_LV = 98; | ||
| 1444 | |||
| 1445 | ///Deallocate a range of the file | ||
| 1446 | pub const F_PUNCHHOLE = 99; | ||
| 1447 | |||
| 1448 | ///Trim an active file | ||
| 1449 | pub const F_TRIM_ACTIVE_FILE = 100; | ||
| 1450 | |||
| 1451 | pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000; | ||
| 1452 | |||
| 1453 | ///mark the dup with FD_CLOEXEC | ||
| 1454 | pub const F_DUPFD_CLOEXEC = 67; | ||
| 1455 | |||
| 1456 | ///close-on-exec flag | ||
| 1457 | pub const FD_CLOEXEC = 1; | ||
| 1458 | |||
| 1459 | /// shared or read lock | ||
| 1460 | pub const F_RDLCK = 1; | ||
| 1461 | |||
| 1462 | /// unlock | ||
| 1463 | pub const F_UNLCK = 2; | ||
| 1464 | |||
| 1465 | /// exclusive or write lock | ||
| 1466 | pub const F_WRLCK = 3; | ||
| 1467 | |||
| 1468 | pub const LOCK_SH = 1; | ||
| 1469 | pub const LOCK_EX = 2; | ||
| 1470 | pub const LOCK_UN = 8; | ||
| 1471 | pub const LOCK_NB = 4; | ||
| 1472 | |||
| 1473 | pub const nfds_t = u32; | ||
| 1474 | pub const pollfd = extern struct { | ||
| 1475 | fd: fd_t, | ||
| 1476 | events: i16, | ||
| 1477 | revents: i16, | ||
| 1478 | }; | ||
| 1479 | |||
| 1480 | pub const POLLIN = 0x001; | ||
| 1481 | pub const POLLPRI = 0x002; | ||
| 1482 | pub const POLLOUT = 0x004; | ||
| 1483 | pub const POLLRDNORM = 0x040; | ||
| 1484 | pub const POLLWRNORM = POLLOUT; | ||
| 1485 | pub const POLLRDBAND = 0x080; | ||
| 1486 | pub const POLLWRBAND = 0x100; | ||
| 1487 | |||
| 1488 | pub const POLLEXTEND = 0x0200; | ||
| 1489 | pub const POLLATTRIB = 0x0400; | ||
| 1490 | pub const POLLNLINK = 0x0800; | ||
| 1491 | pub const POLLWRITE = 0x1000; | ||
| 1492 | |||
| 1493 | pub const POLLERR = 0x008; | ||
| 1494 | pub const POLLHUP = 0x010; | ||
| 1495 | pub const POLLNVAL = 0x020; | ||
| 1496 | |||
| 1497 | pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; | ||
| 1498 | |||
| 1499 | pub const CLOCK_REALTIME = 0; | ||
| 1500 | pub const CLOCK_MONOTONIC = 6; | ||
| 1501 | pub const CLOCK_MONOTONIC_RAW = 4; | ||
| 1502 | pub const CLOCK_MONOTONIC_RAW_APPROX = 5; | ||
| 1503 | pub const CLOCK_UPTIME_RAW = 8; | ||
| 1504 | pub const CLOCK_UPTIME_RAW_APPROX = 9; | ||
| 1505 | pub const CLOCK_PROCESS_CPUTIME_ID = 12; | ||
| 1506 | pub const CLOCK_THREAD_CPUTIME_ID = 16; | ||
| 1507 | |||
| 1508 | /// Max open files per process | ||
| 1509 | /// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html | ||
| 1510 | pub const OPEN_MAX = 10240; | ||
| 1511 | pub const RUSAGE_SELF = 0; | ||
| 1512 | pub const RUSAGE_CHILDREN = -1; | ||
| 1513 | |||
| 1514 | pub const rusage = extern struct { | ||
| 1515 | utime: timeval, | ||
| 1516 | stime: timeval, | ||
| 1517 | maxrss: isize, | ||
| 1518 | ixrss: isize, | ||
| 1519 | idrss: isize, | ||
| 1520 | isrss: isize, | ||
| 1521 | minflt: isize, | ||
| 1522 | majflt: isize, | ||
| 1523 | nswap: isize, | ||
| 1524 | inblock: isize, | ||
| 1525 | oublock: isize, | ||
| 1526 | msgsnd: isize, | ||
| 1527 | msgrcv: isize, | ||
| 1528 | nsignals: isize, | ||
| 1529 | nvcsw: isize, | ||
| 1530 | nivcsw: isize, | ||
| 1531 | }; | ||
| 1532 | |||
| 1533 | pub const rlimit_resource = enum(c_int) { | ||
| 1534 | CPU = 0, | ||
| 1535 | FSIZE = 1, | ||
| 1536 | DATA = 2, | ||
| 1537 | STACK = 3, | ||
| 1538 | CORE = 4, | ||
| 1539 | RSS = 5, | ||
| 1540 | MEMLOCK = 6, | ||
| 1541 | NPROC = 7, | ||
| 1542 | NOFILE = 8, | ||
| 1543 | _, | ||
| 1544 | |||
| 1545 | pub const AS: rlimit_resource = .RSS; | ||
| 1546 | }; | ||
| 1547 | |||
| 1548 | pub const rlim_t = u64; | ||
| 1549 | |||
| 1550 | /// No limit | ||
| 1551 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1552 | |||
| 1553 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1554 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1555 | |||
| 1556 | pub const rlimit = extern struct { | ||
| 1557 | /// Soft limit | ||
| 1558 | cur: rlim_t, | ||
| 1559 | /// Hard limit | ||
| 1560 | max: rlim_t, | ||
| 1561 | }; | ||
| 1562 | |||
| 1563 | pub const SHUT_RD = 0; | ||
| 1564 | pub const SHUT_WR = 1; | ||
| 1565 | pub const SHUT_RDWR = 2; | ||
| 1566 | |||
| 1567 | // Term | ||
| 1568 | pub const VEOF = 0; | ||
| 1569 | pub const VEOL = 1; | ||
| 1570 | pub const VEOL2 = 2; | ||
| 1571 | pub const VERASE = 3; | ||
| 1572 | pub const VWERASE = 4; | ||
| 1573 | pub const VKILL = 5; | ||
| 1574 | pub const VREPRINT = 6; | ||
| 1575 | pub const VINTR = 8; | ||
| 1576 | pub const VQUIT = 9; | ||
| 1577 | pub const VSUSP = 10; | ||
| 1578 | pub const VDSUSP = 11; | ||
| 1579 | pub const VSTART = 12; | ||
| 1580 | pub const VSTOP = 13; | ||
| 1581 | pub const VLNEXT = 14; | ||
| 1582 | pub const VDISCARD = 15; | ||
| 1583 | pub const VMIN = 16; | ||
| 1584 | pub const VTIME = 17; | ||
| 1585 | pub const VSTATUS = 18; | ||
| 1586 | pub const NCCS = 20; // 2 spares (7, 19) | ||
| 1587 | |||
| 1588 | pub const IGNBRK = 0x00000001; // ignore BREAK condition | ||
| 1589 | pub const BRKINT = 0x00000002; // map BREAK to SIGINTR | ||
| 1590 | pub const IGNPAR = 0x00000004; // ignore (discard) parity errors | ||
| 1591 | pub const PARMRK = 0x00000008; // mark parity and framing errors | ||
| 1592 | pub const INPCK = 0x00000010; // enable checking of parity errors | ||
| 1593 | pub const ISTRIP = 0x00000020; // strip 8th bit off chars | ||
| 1594 | pub const INLCR = 0x00000040; // map NL into CR | ||
| 1595 | pub const IGNCR = 0x00000080; // ignore CR | ||
| 1596 | pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD) | ||
| 1597 | pub const IXON = 0x00000200; // enable output flow control | ||
| 1598 | pub const IXOFF = 0x00000400; // enable input flow control | ||
| 1599 | pub const IXANY = 0x00000800; // any char will restart after stop | ||
| 1600 | pub const IMAXBEL = 0x00002000; // ring bell on input queue full | ||
| 1601 | pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE | ||
| 1602 | |||
| 1603 | pub const OPOST = 0x00000001; //enable following output processing | ||
| 1604 | pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD) | ||
| 1605 | pub const OXTABS = 0x00000004; // expand tabs to spaces | ||
| 1606 | pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output) | ||
| 1607 | |||
| 1608 | pub const OCRNL = 0x00000010; // map CR to NL on output | ||
| 1609 | pub const ONOCR = 0x00000020; // no CR output at column 0 | ||
| 1610 | pub const ONLRET = 0x00000040; // NL performs CR function | ||
| 1611 | pub const OFILL = 0x00000080; // use fill characters for delay | ||
| 1612 | pub const NLDLY = 0x00000300; // \n delay | ||
| 1613 | pub const TABDLY = 0x00000c04; // horizontal tab delay | ||
| 1614 | pub const CRDLY = 0x00003000; // \r delay | ||
| 1615 | pub const FFDLY = 0x00004000; // form feed delay | ||
| 1616 | pub const BSDLY = 0x00008000; // \b delay | ||
| 1617 | pub const VTDLY = 0x00010000; // vertical tab delay | ||
| 1618 | pub const OFDEL = 0x00020000; // fill is DEL, else NUL | ||
| 1619 | |||
| 1620 | pub const NL0 = 0x00000000; | ||
| 1621 | pub const NL1 = 0x00000100; | ||
| 1622 | pub const NL2 = 0x00000200; | ||
| 1623 | pub const NL3 = 0x00000300; | ||
| 1624 | pub const TAB0 = 0x00000000; | ||
| 1625 | pub const TAB1 = 0x00000400; | ||
| 1626 | pub const TAB2 = 0x00000800; | ||
| 1627 | pub const TAB3 = 0x00000004; | ||
| 1628 | pub const CR0 = 0x00000000; | ||
| 1629 | pub const CR1 = 0x00001000; | ||
| 1630 | pub const CR2 = 0x00002000; | ||
| 1631 | pub const CR3 = 0x00003000; | ||
| 1632 | pub const FF0 = 0x00000000; | ||
| 1633 | pub const FF1 = 0x00004000; | ||
| 1634 | pub const BS0 = 0x00000000; | ||
| 1635 | pub const BS1 = 0x00008000; | ||
| 1636 | pub const VT0 = 0x00000000; | ||
| 1637 | pub const VT1 = 0x00010000; | ||
| 1638 | |||
| 1639 | pub const CIGNORE = 0x00000001; // ignore control flags | ||
| 1640 | pub const CSIZE = 0x00000300; // character size mask | ||
| 1641 | pub const CS5 = 0x00000000; // 5 bits (pseudo) | ||
| 1642 | pub const CS6 = 0x00000100; // 6 bits | ||
| 1643 | pub const CS7 = 0x00000200; // 7 bits | ||
| 1644 | pub const CS8 = 0x00000300; // 8 bits | ||
| 1645 | pub const CSTOPB = 0x0000040; // send 2 stop bits | ||
| 1646 | pub const CREAD = 0x00000800; // enable receiver | ||
| 1647 | pub const PARENB = 0x00001000; // parity enable | ||
| 1648 | pub const PARODD = 0x00002000; // odd parity, else even | ||
| 1649 | pub const HUPCL = 0x00004000; // hang up on last close | ||
| 1650 | pub const CLOCAL = 0x00008000; // ignore modem status lines | ||
| 1651 | pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output | ||
| 1652 | pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW); | ||
| 1653 | pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input | ||
| 1654 | pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input | ||
| 1655 | pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output | ||
| 1656 | pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output | ||
| 1657 | pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW | ||
| 1658 | |||
| 1659 | pub const ECHOKE = 0x00000001; // visual erase for line kill | ||
| 1660 | pub const ECHOE = 0x00000002; // visually erase chars | ||
| 1661 | pub const ECHOK = 0x00000004; // echo NL after line kill | ||
| 1662 | pub const ECHO = 0x00000008; // enable echoing | ||
| 1663 | pub const ECHONL = 0x00000010; // echo NL even if ECHO is off | ||
| 1664 | pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy | ||
| 1665 | pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char) | ||
| 1666 | pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP | ||
| 1667 | pub const ICANON = 0x00000100; // canonicalize input lines | ||
| 1668 | pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm | ||
| 1669 | pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT | ||
| 1670 | pub const EXTPROC = 0x00000800; // external processing | ||
| 1671 | pub const TOSTOP = 0x00400000; // stop background jobs from output | ||
| 1672 | pub const FLUSHO = 0x00800000; // output being flushed (state) | ||
| 1673 | pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS | ||
| 1674 | pub const PENDIN = 0x20000000; // XXX retype pending input (state) | ||
| 1675 | pub const NOFLSH = 0x80000000; // don't flush after interrupt | ||
| 1676 | |||
| 1677 | pub const TCSANOW = 0; // make change immediate | ||
| 1678 | pub const TCSADRAIN = 1; // drain output, then change | ||
| 1679 | pub const TCSAFLUSH = 2; // drain output, flush input | ||
| 1680 | pub const TCSASOFT = 0x10; // flag - don't alter h.w. state | ||
| 1681 | pub const TCSA = enum(c_uint) { | ||
| 1682 | NOW, | ||
| 1683 | DRAIN, | ||
| 1684 | FLUSH, | ||
| 1685 | _, | ||
| 1686 | }; | ||
| 1687 | |||
| 1688 | pub const B0 = 0; | ||
| 1689 | pub const B50 = 50; | ||
| 1690 | pub const B75 = 75; | ||
| 1691 | pub const B110 = 110; | ||
| 1692 | pub const B134 = 134; | ||
| 1693 | pub const B150 = 150; | ||
| 1694 | pub const B200 = 200; | ||
| 1695 | pub const B300 = 300; | ||
| 1696 | pub const B600 = 600; | ||
| 1697 | pub const B1200 = 1200; | ||
| 1698 | pub const B1800 = 1800; | ||
| 1699 | pub const B2400 = 2400; | ||
| 1700 | pub const B4800 = 4800; | ||
| 1701 | pub const B9600 = 9600; | ||
| 1702 | pub const B19200 = 19200; | ||
| 1703 | pub const B38400 = 38400; | ||
| 1704 | pub const B7200 = 7200; | ||
| 1705 | pub const B14400 = 14400; | ||
| 1706 | pub const B28800 = 28800; | ||
| 1707 | pub const B57600 = 57600; | ||
| 1708 | pub const B76800 = 76800; | ||
| 1709 | pub const B115200 = 115200; | ||
| 1710 | pub const B230400 = 230400; | ||
| 1711 | pub const EXTA = 19200; | ||
| 1712 | pub const EXTB = 38400; | ||
| 1713 | |||
| 1714 | pub const TCIFLUSH = 1; | ||
| 1715 | pub const TCOFLUSH = 2; | ||
| 1716 | pub const TCIOFLUSH = 3; | ||
| 1717 | pub const TCOOFF = 1; | ||
| 1718 | pub const TCOON = 2; | ||
| 1719 | pub const TCIOFF = 3; | ||
| 1720 | pub const TCION = 4; | ||
| 1721 | |||
| 1722 | pub const cc_t = u8; | ||
| 1723 | pub const speed_t = u64; | ||
| 1724 | pub const tcflag_t = u64; | ||
| 1725 | |||
| 1726 | pub const termios = extern struct { | ||
| 1727 | iflag: tcflag_t, // input flags | ||
| 1728 | oflag: tcflag_t, // output flags | ||
| 1729 | cflag: tcflag_t, // control flags | ||
| 1730 | lflag: tcflag_t, // local flags | ||
| 1731 | cc: [NCCS]cc_t, // control chars | ||
| 1732 | ispeed: speed_t align(8), // input speed | ||
| 1733 | ospeed: speed_t, // output speed | ||
| 1734 | }; | ||
| 1735 | |||
| 1736 | pub const winsize = extern struct { | ||
| 1737 | ws_row: u16, | ||
| 1738 | ws_col: u16, | ||
| 1739 | ws_xpixel: u16, | ||
| 1740 | ws_ypixel: u16, | ||
| 1741 | }; | ||
| 1742 | |||
| 1743 | pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); | ||
| 1744 | pub const IOCPARM_MASK = 0x1fff; | ||
| 1745 | |||
| 1746 | fn ior(inout: u32, group: usize, num: usize, len: usize) usize { | ||
| 1747 | return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)); | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | // CPU families mapping | ||
| 1751 | pub const CPUFAMILY = enum(u32) { | ||
| 1752 | UNKNOWN = 0, | ||
| 1753 | POWERPC_G3 = 0xcee41549, | ||
| 1754 | POWERPC_G4 = 0x77c184ae, | ||
| 1755 | POWERPC_G5 = 0xed76d8aa, | ||
| 1756 | INTEL_6_13 = 0xaa33392b, | ||
| 1757 | INTEL_PENRYN = 0x78ea4fbc, | ||
| 1758 | INTEL_NEHALEM = 0x6b5a4cd2, | ||
| 1759 | INTEL_WESTMERE = 0x573b5eec, | ||
| 1760 | INTEL_SANDYBRIDGE = 0x5490b78c, | ||
| 1761 | INTEL_IVYBRIDGE = 0x1f65e835, | ||
| 1762 | INTEL_HASWELL = 0x10b282dc, | ||
| 1763 | INTEL_BROADWELL = 0x582ed09c, | ||
| 1764 | INTEL_SKYLAKE = 0x37fc219f, | ||
| 1765 | INTEL_KABYLAKE = 0x0f817246, | ||
| 1766 | ARM_9 = 0xe73283ae, | ||
| 1767 | ARM_11 = 0x8ff620d8, | ||
| 1768 | ARM_XSCALE = 0x53b005f5, | ||
| 1769 | ARM_12 = 0xbd1b0ae9, | ||
| 1770 | ARM_13 = 0x0cc90e64, | ||
| 1771 | ARM_14 = 0x96077ef1, | ||
| 1772 | ARM_15 = 0xa8511bca, | ||
| 1773 | ARM_SWIFT = 0x1e2d6381, | ||
| 1774 | ARM_CYCLONE = 0x37a09642, | ||
| 1775 | ARM_TYPHOON = 0x2c91a47e, | ||
| 1776 | ARM_TWISTER = 0x92fb37c8, | ||
| 1777 | ARM_HURRICANE = 0x67ceee93, | ||
| 1778 | ARM_MONSOON_MISTRAL = 0xe81e7ef6, | ||
| 1779 | ARM_VORTEX_TEMPEST = 0x07d34b9f, | ||
| 1780 | ARM_LIGHTNING_THUNDER = 0x462504d2, | ||
| 1781 | ARM_FIRESTORM_ICESTORM = 0x1b588bb3, | ||
| 1782 | _, | ||
| 1783 | }; | ||
lib/std/os/bits/dragonfly.zig deleted-1031| ... | @@ -1,1031 +0,0 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const maxInt = std.math.maxInt; | ||
| 3 | |||
| 4 | pub fn S_ISCHR(m: u32) bool { | ||
| 5 | return m & S_IFMT == S_IFCHR; | ||
| 6 | } | ||
| 7 | |||
| 8 | // See: | ||
| 9 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h | ||
| 10 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h | ||
| 11 | // TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well | ||
| 12 | pub const fd_t = c_int; | ||
| 13 | pub const pid_t = c_int; | ||
| 14 | pub const off_t = c_long; | ||
| 15 | pub const mode_t = c_uint; | ||
| 16 | pub const uid_t = u32; | ||
| 17 | pub const gid_t = u32; | ||
| 18 | pub const time_t = isize; | ||
| 19 | pub const suseconds_t = c_long; | ||
| 20 | |||
| 21 | pub const E = enum(u16) { | ||
| 22 | /// No error occurred. | ||
| 23 | SUCCESS = 0, | ||
| 24 | |||
| 25 | PERM = 1, | ||
| 26 | NOENT = 2, | ||
| 27 | SRCH = 3, | ||
| 28 | INTR = 4, | ||
| 29 | IO = 5, | ||
| 30 | NXIO = 6, | ||
| 31 | @"2BIG" = 7, | ||
| 32 | NOEXEC = 8, | ||
| 33 | BADF = 9, | ||
| 34 | CHILD = 10, | ||
| 35 | DEADLK = 11, | ||
| 36 | NOMEM = 12, | ||
| 37 | ACCES = 13, | ||
| 38 | FAULT = 14, | ||
| 39 | NOTBLK = 15, | ||
| 40 | BUSY = 16, | ||
| 41 | EXIST = 17, | ||
| 42 | XDEV = 18, | ||
| 43 | NODEV = 19, | ||
| 44 | NOTDIR = 20, | ||
| 45 | ISDIR = 21, | ||
| 46 | INVAL = 22, | ||
| 47 | NFILE = 23, | ||
| 48 | MFILE = 24, | ||
| 49 | NOTTY = 25, | ||
| 50 | TXTBSY = 26, | ||
| 51 | FBIG = 27, | ||
| 52 | NOSPC = 28, | ||
| 53 | SPIPE = 29, | ||
| 54 | ROFS = 30, | ||
| 55 | MLINK = 31, | ||
| 56 | PIPE = 32, | ||
| 57 | DOM = 33, | ||
| 58 | RANGE = 34, | ||
| 59 | /// This code is also used for `WOULDBLOCK`. | ||
| 60 | AGAIN = 35, | ||
| 61 | INPROGRESS = 36, | ||
| 62 | ALREADY = 37, | ||
| 63 | NOTSOCK = 38, | ||
| 64 | DESTADDRREQ = 39, | ||
| 65 | MSGSIZE = 40, | ||
| 66 | PROTOTYPE = 41, | ||
| 67 | NOPROTOOPT = 42, | ||
| 68 | PROTONOSUPPORT = 43, | ||
| 69 | SOCKTNOSUPPORT = 44, | ||
| 70 | /// This code is also used for `NOTSUP`. | ||
| 71 | OPNOTSUPP = 45, | ||
| 72 | PFNOSUPPORT = 46, | ||
| 73 | AFNOSUPPORT = 47, | ||
| 74 | ADDRINUSE = 48, | ||
| 75 | ADDRNOTAVAIL = 49, | ||
| 76 | NETDOWN = 50, | ||
| 77 | NETUNREACH = 51, | ||
| 78 | NETRESET = 52, | ||
| 79 | CONNABORTED = 53, | ||
| 80 | CONNRESET = 54, | ||
| 81 | NOBUFS = 55, | ||
| 82 | ISCONN = 56, | ||
| 83 | NOTCONN = 57, | ||
| 84 | SHUTDOWN = 58, | ||
| 85 | TOOMANYREFS = 59, | ||
| 86 | TIMEDOUT = 60, | ||
| 87 | CONNREFUSED = 61, | ||
| 88 | LOOP = 62, | ||
| 89 | NAMETOOLONG = 63, | ||
| 90 | HOSTDOWN = 64, | ||
| 91 | HOSTUNREACH = 65, | ||
| 92 | NOTEMPTY = 66, | ||
| 93 | PROCLIM = 67, | ||
| 94 | USERS = 68, | ||
| 95 | DQUOT = 69, | ||
| 96 | STALE = 70, | ||
| 97 | REMOTE = 71, | ||
| 98 | BADRPC = 72, | ||
| 99 | RPCMISMATCH = 73, | ||
| 100 | PROGUNAVAIL = 74, | ||
| 101 | PROGMISMATCH = 75, | ||
| 102 | PROCUNAVAIL = 76, | ||
| 103 | NOLCK = 77, | ||
| 104 | NOSYS = 78, | ||
| 105 | FTYPE = 79, | ||
| 106 | AUTH = 80, | ||
| 107 | NEEDAUTH = 81, | ||
| 108 | IDRM = 82, | ||
| 109 | NOMSG = 83, | ||
| 110 | OVERFLOW = 84, | ||
| 111 | CANCELED = 85, | ||
| 112 | ILSEQ = 86, | ||
| 113 | NOATTR = 87, | ||
| 114 | DOOFUS = 88, | ||
| 115 | BADMSG = 89, | ||
| 116 | MULTIHOP = 90, | ||
| 117 | NOLINK = 91, | ||
| 118 | PROTO = 92, | ||
| 119 | NOMEDIUM = 93, | ||
| 120 | ASYNC = 99, | ||
| 121 | _, | ||
| 122 | }; | ||
| 123 | |||
| 124 | pub const STDIN_FILENO = 0; | ||
| 125 | pub const STDOUT_FILENO = 1; | ||
| 126 | pub const STDERR_FILENO = 2; | ||
| 127 | |||
| 128 | pub const PROT_NONE = 0; | ||
| 129 | pub const PROT_READ = 1; | ||
| 130 | pub const PROT_WRITE = 2; | ||
| 131 | pub const PROT_EXEC = 4; | ||
| 132 | |||
| 133 | pub const MAP_FILE = 0; | ||
| 134 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 135 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 136 | pub const MAP_COPY = MAP_PRIVATE; | ||
| 137 | pub const MAP_SHARED = 1; | ||
| 138 | pub const MAP_PRIVATE = 2; | ||
| 139 | pub const MAP_FIXED = 16; | ||
| 140 | pub const MAP_RENAME = 32; | ||
| 141 | pub const MAP_NORESERVE = 64; | ||
| 142 | pub const MAP_INHERIT = 128; | ||
| 143 | pub const MAP_NOEXTEND = 256; | ||
| 144 | pub const MAP_HASSEMAPHORE = 512; | ||
| 145 | pub const MAP_STACK = 1024; | ||
| 146 | pub const MAP_NOSYNC = 2048; | ||
| 147 | pub const MAP_ANON = 4096; | ||
| 148 | pub const MAP_VPAGETABLE = 8192; | ||
| 149 | pub const MAP_TRYFIXED = 65536; | ||
| 150 | pub const MAP_NOCORE = 131072; | ||
| 151 | pub const MAP_SIZEALIGN = 262144; | ||
| 152 | |||
| 153 | pub const WNOHANG = 0x0001; | ||
| 154 | pub const WUNTRACED = 0x0002; | ||
| 155 | pub const WCONTINUED = 0x0004; | ||
| 156 | pub const WSTOPPED = WUNTRACED; | ||
| 157 | pub const WNOWAIT = 0x0008; | ||
| 158 | pub const WEXITED = 0x0010; | ||
| 159 | pub const WTRAPPED = 0x0020; | ||
| 160 | |||
| 161 | pub const SA_ONSTACK = 0x0001; | ||
| 162 | pub const SA_RESTART = 0x0002; | ||
| 163 | pub const SA_RESETHAND = 0x0004; | ||
| 164 | pub const SA_NODEFER = 0x0010; | ||
| 165 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 166 | pub const SA_SIGINFO = 0x0040; | ||
| 167 | |||
| 168 | pub const PATH_MAX = 1024; | ||
| 169 | pub const IOV_MAX = KERN_IOV_MAX; | ||
| 170 | |||
| 171 | pub const ino_t = c_ulong; | ||
| 172 | |||
| 173 | pub const libc_stat = extern struct { | ||
| 174 | ino: ino_t, | ||
| 175 | nlink: c_uint, | ||
| 176 | dev: c_uint, | ||
| 177 | mode: c_ushort, | ||
| 178 | padding1: u16, | ||
| 179 | uid: uid_t, | ||
| 180 | gid: gid_t, | ||
| 181 | rdev: c_uint, | ||
| 182 | atim: timespec, | ||
| 183 | mtim: timespec, | ||
| 184 | ctim: timespec, | ||
| 185 | size: c_ulong, | ||
| 186 | blocks: i64, | ||
| 187 | blksize: u32, | ||
| 188 | flags: u32, | ||
| 189 | gen: u32, | ||
| 190 | lspare: i32, | ||
| 191 | qspare1: i64, | ||
| 192 | qspare2: i64, | ||
| 193 | pub fn atime(self: @This()) timespec { | ||
| 194 | return self.atim; | ||
| 195 | } | ||
| 196 | |||
| 197 | pub fn mtime(self: @This()) timespec { | ||
| 198 | return self.mtim; | ||
| 199 | } | ||
| 200 | |||
| 201 | pub fn ctime(self: @This()) timespec { | ||
| 202 | return self.ctim; | ||
| 203 | } | ||
| 204 | }; | ||
| 205 | |||
| 206 | pub const timespec = extern struct { | ||
| 207 | tv_sec: c_long, | ||
| 208 | tv_nsec: c_long, | ||
| 209 | }; | ||
| 210 | |||
| 211 | pub const timeval = extern struct { | ||
| 212 | /// seconds | ||
| 213 | tv_sec: time_t, | ||
| 214 | /// microseconds | ||
| 215 | tv_usec: suseconds_t, | ||
| 216 | }; | ||
| 217 | |||
| 218 | pub const CTL_UNSPEC = 0; | ||
| 219 | pub const CTL_KERN = 1; | ||
| 220 | pub const CTL_VM = 2; | ||
| 221 | pub const CTL_VFS = 3; | ||
| 222 | pub const CTL_NET = 4; | ||
| 223 | pub const CTL_DEBUG = 5; | ||
| 224 | pub const CTL_HW = 6; | ||
| 225 | pub const CTL_MACHDEP = 7; | ||
| 226 | pub const CTL_USER = 8; | ||
| 227 | pub const CTL_LWKT = 10; | ||
| 228 | pub const CTL_MAXID = 11; | ||
| 229 | pub const CTL_MAXNAME = 12; | ||
| 230 | |||
| 231 | pub const KERN_PROC_ALL = 0; | ||
| 232 | pub const KERN_OSTYPE = 1; | ||
| 233 | pub const KERN_PROC_PID = 1; | ||
| 234 | pub const KERN_OSRELEASE = 2; | ||
| 235 | pub const KERN_PROC_PGRP = 2; | ||
| 236 | pub const KERN_OSREV = 3; | ||
| 237 | pub const KERN_PROC_SESSION = 3; | ||
| 238 | pub const KERN_VERSION = 4; | ||
| 239 | pub const KERN_PROC_TTY = 4; | ||
| 240 | pub const KERN_MAXVNODES = 5; | ||
| 241 | pub const KERN_PROC_UID = 5; | ||
| 242 | pub const KERN_MAXPROC = 6; | ||
| 243 | pub const KERN_PROC_RUID = 6; | ||
| 244 | pub const KERN_MAXFILES = 7; | ||
| 245 | pub const KERN_PROC_ARGS = 7; | ||
| 246 | pub const KERN_ARGMAX = 8; | ||
| 247 | pub const KERN_PROC_CWD = 8; | ||
| 248 | pub const KERN_PROC_PATHNAME = 9; | ||
| 249 | pub const KERN_SECURELVL = 9; | ||
| 250 | pub const KERN_PROC_SIGTRAMP = 10; | ||
| 251 | pub const KERN_HOSTNAME = 10; | ||
| 252 | pub const KERN_HOSTID = 11; | ||
| 253 | pub const KERN_CLOCKRATE = 12; | ||
| 254 | pub const KERN_VNODE = 13; | ||
| 255 | pub const KERN_PROC = 14; | ||
| 256 | pub const KERN_FILE = 15; | ||
| 257 | pub const KERN_PROC_FLAGMASK = 16; | ||
| 258 | pub const KERN_PROF = 16; | ||
| 259 | pub const KERN_PROC_FLAG_LWP = 16; | ||
| 260 | pub const KERN_POSIX1 = 17; | ||
| 261 | pub const KERN_NGROUPS = 18; | ||
| 262 | pub const KERN_JOB_CONTROL = 19; | ||
| 263 | pub const KERN_SAVED_IDS = 20; | ||
| 264 | pub const KERN_BOOTTIME = 21; | ||
| 265 | pub const KERN_NISDOMAINNAME = 22; | ||
| 266 | pub const KERN_UPDATEINTERVAL = 23; | ||
| 267 | pub const KERN_OSRELDATE = 24; | ||
| 268 | pub const KERN_NTP_PLL = 25; | ||
| 269 | pub const KERN_BOOTFILE = 26; | ||
| 270 | pub const KERN_MAXFILESPERPROC = 27; | ||
| 271 | pub const KERN_MAXPROCPERUID = 28; | ||
| 272 | pub const KERN_DUMPDEV = 29; | ||
| 273 | pub const KERN_IPC = 30; | ||
| 274 | pub const KERN_DUMMY = 31; | ||
| 275 | pub const KERN_PS_STRINGS = 32; | ||
| 276 | pub const KERN_USRSTACK = 33; | ||
| 277 | pub const KERN_LOGSIGEXIT = 34; | ||
| 278 | pub const KERN_IOV_MAX = 35; | ||
| 279 | pub const KERN_MAXPOSIXLOCKSPERUID = 36; | ||
| 280 | pub const KERN_MAXID = 37; | ||
| 281 | |||
| 282 | pub const HOST_NAME_MAX = 255; | ||
| 283 | |||
| 284 | // access function | ||
| 285 | pub const F_OK = 0; // test for existence of file | ||
| 286 | pub const X_OK = 1; // test for execute or search permission | ||
| 287 | pub const W_OK = 2; // test for write permission | ||
| 288 | pub const R_OK = 4; // test for read permission | ||
| 289 | |||
| 290 | pub const O_RDONLY = 0; | ||
| 291 | pub const O_NDELAY = O_NONBLOCK; | ||
| 292 | pub const O_WRONLY = 1; | ||
| 293 | pub const O_RDWR = 2; | ||
| 294 | pub const O_ACCMODE = 3; | ||
| 295 | pub const O_NONBLOCK = 4; | ||
| 296 | pub const O_APPEND = 8; | ||
| 297 | pub const O_SHLOCK = 16; | ||
| 298 | pub const O_EXLOCK = 32; | ||
| 299 | pub const O_ASYNC = 64; | ||
| 300 | pub const O_FSYNC = 128; | ||
| 301 | pub const O_SYNC = 128; | ||
| 302 | pub const O_NOFOLLOW = 256; | ||
| 303 | pub const O_CREAT = 512; | ||
| 304 | pub const O_TRUNC = 1024; | ||
| 305 | pub const O_EXCL = 2048; | ||
| 306 | pub const O_NOCTTY = 32768; | ||
| 307 | pub const O_DIRECT = 65536; | ||
| 308 | pub const O_CLOEXEC = 131072; | ||
| 309 | pub const O_FBLOCKING = 262144; | ||
| 310 | pub const O_FNONBLOCKING = 524288; | ||
| 311 | pub const O_FAPPEND = 1048576; | ||
| 312 | pub const O_FOFFSET = 2097152; | ||
| 313 | pub const O_FSYNCWRITE = 4194304; | ||
| 314 | pub const O_FASYNCWRITE = 8388608; | ||
| 315 | pub const O_DIRECTORY = 134217728; | ||
| 316 | |||
| 317 | pub const SEEK_SET = 0; | ||
| 318 | pub const SEEK_CUR = 1; | ||
| 319 | pub const SEEK_END = 2; | ||
| 320 | pub const SEEK_DATA = 3; | ||
| 321 | pub const SEEK_HOLE = 4; | ||
| 322 | |||
| 323 | pub const F_ULOCK = 0; | ||
| 324 | pub const F_LOCK = 1; | ||
| 325 | pub const F_TLOCK = 2; | ||
| 326 | pub const F_TEST = 3; | ||
| 327 | |||
| 328 | pub const FD_CLOEXEC = 1; | ||
| 329 | |||
| 330 | pub const AT_FDCWD = -328243; | ||
| 331 | pub const AT_SYMLINK_NOFOLLOW = 1; | ||
| 332 | pub const AT_REMOVEDIR = 2; | ||
| 333 | pub const AT_EACCESS = 4; | ||
| 334 | pub const AT_SYMLINK_FOLLOW = 8; | ||
| 335 | |||
| 336 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 337 | return @intCast(u8, (s & 0xff00) >> 8); | ||
| 338 | } | ||
| 339 | pub fn WTERMSIG(s: u32) u32 { | ||
| 340 | return s & 0x7f; | ||
| 341 | } | ||
| 342 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 343 | return WEXITSTATUS(s); | ||
| 344 | } | ||
| 345 | pub fn WIFEXITED(s: u32) bool { | ||
| 346 | return WTERMSIG(s) == 0; | ||
| 347 | } | ||
| 348 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 349 | return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | ||
| 350 | } | ||
| 351 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 352 | return (s & 0xffff) -% 1 < 0xff; | ||
| 353 | } | ||
| 354 | |||
| 355 | pub const dirent = extern struct { | ||
| 356 | d_fileno: c_ulong, | ||
| 357 | d_namlen: u16, | ||
| 358 | d_type: u8, | ||
| 359 | d_unused1: u8, | ||
| 360 | d_unused2: u32, | ||
| 361 | d_name: [256]u8, | ||
| 362 | |||
| 363 | pub fn reclen(self: dirent) u16 { | ||
| 364 | return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7); | ||
| 365 | } | ||
| 366 | }; | ||
| 367 | |||
| 368 | pub const DT_UNKNOWN = 0; | ||
| 369 | pub const DT_FIFO = 1; | ||
| 370 | pub const DT_CHR = 2; | ||
| 371 | pub const DT_DIR = 4; | ||
| 372 | pub const DT_BLK = 6; | ||
| 373 | pub const DT_REG = 8; | ||
| 374 | pub const DT_LNK = 10; | ||
| 375 | pub const DT_SOCK = 12; | ||
| 376 | pub const DT_WHT = 14; | ||
| 377 | pub const DT_DBF = 15; | ||
| 378 | |||
| 379 | pub const CLOCK_REALTIME = 0; | ||
| 380 | pub const CLOCK_VIRTUAL = 1; | ||
| 381 | pub const CLOCK_PROF = 2; | ||
| 382 | pub const CLOCK_MONOTONIC = 4; | ||
| 383 | pub const CLOCK_UPTIME = 5; | ||
| 384 | pub const CLOCK_UPTIME_PRECISE = 7; | ||
| 385 | pub const CLOCK_UPTIME_FAST = 8; | ||
| 386 | pub const CLOCK_REALTIME_PRECISE = 9; | ||
| 387 | pub const CLOCK_REALTIME_FAST = 10; | ||
| 388 | pub const CLOCK_MONOTONIC_PRECISE = 11; | ||
| 389 | pub const CLOCK_MONOTONIC_FAST = 12; | ||
| 390 | pub const CLOCK_SECOND = 13; | ||
| 391 | pub const CLOCK_THREAD_CPUTIME_ID = 14; | ||
| 392 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; | ||
| 393 | |||
| 394 | pub const sockaddr = extern struct { | ||
| 395 | len: u8, | ||
| 396 | family: u8, | ||
| 397 | data: [14]u8, | ||
| 398 | }; | ||
| 399 | |||
| 400 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 401 | |||
| 402 | pub const Kevent = extern struct { | ||
| 403 | ident: usize, | ||
| 404 | filter: c_short, | ||
| 405 | flags: c_ushort, | ||
| 406 | fflags: c_uint, | ||
| 407 | data: isize, | ||
| 408 | udata: usize, | ||
| 409 | }; | ||
| 410 | |||
| 411 | pub const EVFILT_FS = -10; | ||
| 412 | pub const EVFILT_USER = -9; | ||
| 413 | pub const EVFILT_EXCEPT = -8; | ||
| 414 | pub const EVFILT_TIMER = -7; | ||
| 415 | pub const EVFILT_SIGNAL = -6; | ||
| 416 | pub const EVFILT_PROC = -5; | ||
| 417 | pub const EVFILT_VNODE = -4; | ||
| 418 | pub const EVFILT_AIO = -3; | ||
| 419 | pub const EVFILT_WRITE = -2; | ||
| 420 | pub const EVFILT_READ = -1; | ||
| 421 | pub const EVFILT_SYSCOUNT = 10; | ||
| 422 | pub const EVFILT_MARKER = 15; | ||
| 423 | |||
| 424 | pub const EV_ADD = 1; | ||
| 425 | pub const EV_DELETE = 2; | ||
| 426 | pub const EV_ENABLE = 4; | ||
| 427 | pub const EV_DISABLE = 8; | ||
| 428 | pub const EV_ONESHOT = 16; | ||
| 429 | pub const EV_CLEAR = 32; | ||
| 430 | pub const EV_RECEIPT = 64; | ||
| 431 | pub const EV_DISPATCH = 128; | ||
| 432 | pub const EV_NODATA = 4096; | ||
| 433 | pub const EV_FLAG1 = 8192; | ||
| 434 | pub const EV_ERROR = 16384; | ||
| 435 | pub const EV_EOF = 32768; | ||
| 436 | pub const EV_SYSFLAGS = 61440; | ||
| 437 | |||
| 438 | pub const NOTE_FFNOP = 0; | ||
| 439 | pub const NOTE_TRACK = 1; | ||
| 440 | pub const NOTE_DELETE = 1; | ||
| 441 | pub const NOTE_LOWAT = 1; | ||
| 442 | pub const NOTE_TRACKERR = 2; | ||
| 443 | pub const NOTE_OOB = 2; | ||
| 444 | pub const NOTE_WRITE = 2; | ||
| 445 | pub const NOTE_EXTEND = 4; | ||
| 446 | pub const NOTE_CHILD = 4; | ||
| 447 | pub const NOTE_ATTRIB = 8; | ||
| 448 | pub const NOTE_LINK = 16; | ||
| 449 | pub const NOTE_RENAME = 32; | ||
| 450 | pub const NOTE_REVOKE = 64; | ||
| 451 | pub const NOTE_PDATAMASK = 1048575; | ||
| 452 | pub const NOTE_FFLAGSMASK = 16777215; | ||
| 453 | pub const NOTE_TRIGGER = 16777216; | ||
| 454 | pub const NOTE_EXEC = 536870912; | ||
| 455 | pub const NOTE_FFAND = 1073741824; | ||
| 456 | pub const NOTE_FORK = 1073741824; | ||
| 457 | pub const NOTE_EXIT = 2147483648; | ||
| 458 | pub const NOTE_FFOR = 2147483648; | ||
| 459 | pub const NOTE_FFCTRLMASK = 3221225472; | ||
| 460 | pub const NOTE_FFCOPY = 3221225472; | ||
| 461 | pub const NOTE_PCTRLMASK = 4026531840; | ||
| 462 | |||
| 463 | pub const stack_t = extern struct { | ||
| 464 | ss_sp: [*]u8, | ||
| 465 | ss_size: isize, | ||
| 466 | ss_flags: i32, | ||
| 467 | }; | ||
| 468 | |||
| 469 | pub const S_IREAD = S_IRUSR; | ||
| 470 | pub const S_IEXEC = S_IXUSR; | ||
| 471 | pub const S_IWRITE = S_IWUSR; | ||
| 472 | pub const S_IXOTH = 1; | ||
| 473 | pub const S_IWOTH = 2; | ||
| 474 | pub const S_IROTH = 4; | ||
| 475 | pub const S_IRWXO = 7; | ||
| 476 | pub const S_IXGRP = 8; | ||
| 477 | pub const S_IWGRP = 16; | ||
| 478 | pub const S_IRGRP = 32; | ||
| 479 | pub const S_IRWXG = 56; | ||
| 480 | pub const S_IXUSR = 64; | ||
| 481 | pub const S_IWUSR = 128; | ||
| 482 | pub const S_IRUSR = 256; | ||
| 483 | pub const S_IRWXU = 448; | ||
| 484 | pub const S_ISTXT = 512; | ||
| 485 | pub const S_BLKSIZE = 512; | ||
| 486 | pub const S_ISVTX = 512; | ||
| 487 | pub const S_ISGID = 1024; | ||
| 488 | pub const S_ISUID = 2048; | ||
| 489 | pub const S_IFIFO = 4096; | ||
| 490 | pub const S_IFCHR = 8192; | ||
| 491 | pub const S_IFDIR = 16384; | ||
| 492 | pub const S_IFBLK = 24576; | ||
| 493 | pub const S_IFREG = 32768; | ||
| 494 | pub const S_IFDB = 36864; | ||
| 495 | pub const S_IFLNK = 40960; | ||
| 496 | pub const S_IFSOCK = 49152; | ||
| 497 | pub const S_IFWHT = 57344; | ||
| 498 | pub const S_IFMT = 61440; | ||
| 499 | |||
| 500 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 501 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 502 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 503 | pub const BADSIG = SIG_ERR; | ||
| 504 | |||
| 505 | pub const SIG_BLOCK = 1; | ||
| 506 | pub const SIG_UNBLOCK = 2; | ||
| 507 | pub const SIG_SETMASK = 3; | ||
| 508 | |||
| 509 | pub const SIGIOT = SIGABRT; | ||
| 510 | pub const SIGHUP = 1; | ||
| 511 | pub const SIGINT = 2; | ||
| 512 | pub const SIGQUIT = 3; | ||
| 513 | pub const SIGILL = 4; | ||
| 514 | pub const SIGTRAP = 5; | ||
| 515 | pub const SIGABRT = 6; | ||
| 516 | pub const SIGEMT = 7; | ||
| 517 | pub const SIGFPE = 8; | ||
| 518 | pub const SIGKILL = 9; | ||
| 519 | pub const SIGBUS = 10; | ||
| 520 | pub const SIGSEGV = 11; | ||
| 521 | pub const SIGSYS = 12; | ||
| 522 | pub const SIGPIPE = 13; | ||
| 523 | pub const SIGALRM = 14; | ||
| 524 | pub const SIGTERM = 15; | ||
| 525 | pub const SIGURG = 16; | ||
| 526 | pub const SIGSTOP = 17; | ||
| 527 | pub const SIGTSTP = 18; | ||
| 528 | pub const SIGCONT = 19; | ||
| 529 | pub const SIGCHLD = 20; | ||
| 530 | pub const SIGTTIN = 21; | ||
| 531 | pub const SIGTTOU = 22; | ||
| 532 | pub const SIGIO = 23; | ||
| 533 | pub const SIGXCPU = 24; | ||
| 534 | pub const SIGXFSZ = 25; | ||
| 535 | pub const SIGVTALRM = 26; | ||
| 536 | pub const SIGPROF = 27; | ||
| 537 | pub const SIGWINCH = 28; | ||
| 538 | pub const SIGINFO = 29; | ||
| 539 | pub const SIGUSR1 = 30; | ||
| 540 | pub const SIGUSR2 = 31; | ||
| 541 | pub const SIGTHR = 32; | ||
| 542 | pub const SIGCKPT = 33; | ||
| 543 | pub const SIGCKPTEXIT = 34; | ||
| 544 | |||
| 545 | pub const siginfo_t = extern struct { | ||
| 546 | signo: c_int, | ||
| 547 | errno: c_int, | ||
| 548 | code: c_int, | ||
| 549 | pid: c_int, | ||
| 550 | uid: uid_t, | ||
| 551 | status: c_int, | ||
| 552 | addr: ?*c_void, | ||
| 553 | value: sigval, | ||
| 554 | band: c_long, | ||
| 555 | __spare__: [7]c_int, | ||
| 556 | }; | ||
| 557 | |||
| 558 | pub const sigval = extern union { | ||
| 559 | sival_int: c_int, | ||
| 560 | sival_ptr: ?*c_void, | ||
| 561 | }; | ||
| 562 | |||
| 563 | pub const _SIG_WORDS = 4; | ||
| 564 | |||
| 565 | pub const sigset_t = extern struct { | ||
| 566 | __bits: [_SIG_WORDS]c_uint, | ||
| 567 | }; | ||
| 568 | |||
| 569 | pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS }; | ||
| 570 | |||
| 571 | pub const sig_atomic_t = c_int; | ||
| 572 | |||
| 573 | pub const Sigaction = extern struct { | ||
| 574 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 575 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 576 | |||
| 577 | /// signal handler | ||
| 578 | handler: extern union { | ||
| 579 | handler: ?handler_fn, | ||
| 580 | sigaction: ?sigaction_fn, | ||
| 581 | }, | ||
| 582 | flags: c_uint, | ||
| 583 | mask: sigset_t, | ||
| 584 | }; | ||
| 585 | |||
| 586 | pub const sig_t = [*c]fn (c_int) callconv(.C) void; | ||
| 587 | |||
| 588 | pub const SOCK_STREAM = 1; | ||
| 589 | pub const SOCK_DGRAM = 2; | ||
| 590 | pub const SOCK_RAW = 3; | ||
| 591 | pub const SOCK_RDM = 4; | ||
| 592 | pub const SOCK_SEQPACKET = 5; | ||
| 593 | pub const SOCK_MAXADDRLEN = 255; | ||
| 594 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 595 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 596 | |||
| 597 | pub const SO_DEBUG = 0x0001; | ||
| 598 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 599 | pub const SO_REUSEADDR = 0x0004; | ||
| 600 | pub const SO_KEEPALIVE = 0x0008; | ||
| 601 | pub const SO_DONTROUTE = 0x0010; | ||
| 602 | pub const SO_BROADCAST = 0x0020; | ||
| 603 | pub const SO_USELOOPBACK = 0x0040; | ||
| 604 | pub const SO_LINGER = 0x0080; | ||
| 605 | pub const SO_OOBINLINE = 0x0100; | ||
| 606 | pub const SO_REUSEPORT = 0x0200; | ||
| 607 | pub const SO_TIMESTAMP = 0x0400; | ||
| 608 | pub const SO_NOSIGPIPE = 0x0800; | ||
| 609 | pub const SO_ACCEPTFILTER = 0x1000; | ||
| 610 | pub const SO_RERROR = 0x2000; | ||
| 611 | pub const SO_PASSCRED = 0x4000; | ||
| 612 | |||
| 613 | pub const SO_SNDBUF = 0x1001; | ||
| 614 | pub const SO_RCVBUF = 0x1002; | ||
| 615 | pub const SO_SNDLOWAT = 0x1003; | ||
| 616 | pub const SO_RCVLOWAT = 0x1004; | ||
| 617 | pub const SO_SNDTIMEO = 0x1005; | ||
| 618 | pub const SO_RCVTIMEO = 0x1006; | ||
| 619 | pub const SO_ERROR = 0x1007; | ||
| 620 | pub const SO_TYPE = 0x1008; | ||
| 621 | pub const SO_SNDSPACE = 0x100a; | ||
| 622 | pub const SO_CPUHINT = 0x1030; | ||
| 623 | |||
| 624 | pub const SOL_SOCKET = 0xffff; | ||
| 625 | |||
| 626 | pub const PF_INET6 = AF_INET6; | ||
| 627 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 628 | pub const PF_ROUTE = AF_ROUTE; | ||
| 629 | pub const PF_ISO = AF_ISO; | ||
| 630 | pub const PF_PIP = pseudo_AF_PIP; | ||
| 631 | pub const PF_CHAOS = AF_CHAOS; | ||
| 632 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 633 | pub const PF_INET = AF_INET; | ||
| 634 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 635 | pub const PF_SIP = AF_SIP; | ||
| 636 | pub const PF_OSI = AF_ISO; | ||
| 637 | pub const PF_CNT = AF_CNT; | ||
| 638 | pub const PF_LINK = AF_LINK; | ||
| 639 | pub const PF_HYLINK = AF_HYLINK; | ||
| 640 | pub const PF_MAX = AF_MAX; | ||
| 641 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 642 | pub const PF_PUP = AF_PUP; | ||
| 643 | pub const PF_COIP = AF_COIP; | ||
| 644 | pub const PF_SNA = AF_SNA; | ||
| 645 | pub const PF_LOCAL = AF_LOCAL; | ||
| 646 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 647 | pub const PF_NATM = AF_NATM; | ||
| 648 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 649 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 650 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 651 | pub const PF_ECMA = AF_ECMA; | ||
| 652 | pub const PF_IPX = AF_IPX; | ||
| 653 | pub const PF_DLI = AF_DLI; | ||
| 654 | pub const PF_ATM = AF_ATM; | ||
| 655 | pub const PF_CCITT = AF_CCITT; | ||
| 656 | pub const PF_ISDN = AF_ISDN; | ||
| 657 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 658 | pub const PF_LAT = AF_LAT; | ||
| 659 | pub const PF_UNIX = PF_LOCAL; | ||
| 660 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 661 | pub const PF_DECnet = AF_DECnet; | ||
| 662 | |||
| 663 | pub const AF_UNSPEC = 0; | ||
| 664 | pub const AF_OSI = AF_ISO; | ||
| 665 | pub const AF_UNIX = AF_LOCAL; | ||
| 666 | pub const AF_LOCAL = 1; | ||
| 667 | pub const AF_INET = 2; | ||
| 668 | pub const AF_IMPLINK = 3; | ||
| 669 | pub const AF_PUP = 4; | ||
| 670 | pub const AF_CHAOS = 5; | ||
| 671 | pub const AF_NETBIOS = 6; | ||
| 672 | pub const AF_ISO = 7; | ||
| 673 | pub const AF_ECMA = 8; | ||
| 674 | pub const AF_DATAKIT = 9; | ||
| 675 | pub const AF_CCITT = 10; | ||
| 676 | pub const AF_SNA = 11; | ||
| 677 | pub const AF_DLI = 13; | ||
| 678 | pub const AF_LAT = 14; | ||
| 679 | pub const AF_HYLINK = 15; | ||
| 680 | pub const AF_APPLETALK = 16; | ||
| 681 | pub const AF_ROUTE = 17; | ||
| 682 | pub const AF_LINK = 18; | ||
| 683 | pub const AF_COIP = 20; | ||
| 684 | pub const AF_CNT = 21; | ||
| 685 | pub const AF_IPX = 23; | ||
| 686 | pub const AF_SIP = 24; | ||
| 687 | pub const AF_ISDN = 26; | ||
| 688 | pub const AF_INET6 = 28; | ||
| 689 | pub const AF_NATM = 29; | ||
| 690 | pub const AF_ATM = 30; | ||
| 691 | pub const AF_NETGRAPH = 32; | ||
| 692 | pub const AF_BLUETOOTH = 33; | ||
| 693 | pub const AF_MPLS = 34; | ||
| 694 | pub const AF_MAX = 36; | ||
| 695 | |||
| 696 | pub const in_port_t = u16; | ||
| 697 | pub const sa_family_t = u8; | ||
| 698 | pub const socklen_t = u32; | ||
| 699 | |||
| 700 | pub const sockaddr_in = extern struct { | ||
| 701 | len: u8 = @sizeOf(sockaddr_in), | ||
| 702 | family: sa_family_t = AF_INET, | ||
| 703 | port: in_port_t, | ||
| 704 | addr: u32, | ||
| 705 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 706 | }; | ||
| 707 | |||
| 708 | pub const sockaddr_in6 = extern struct { | ||
| 709 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 710 | family: sa_family_t = AF_INET6, | ||
| 711 | port: in_port_t, | ||
| 712 | flowinfo: u32, | ||
| 713 | addr: [16]u8, | ||
| 714 | scope_id: u32, | ||
| 715 | }; | ||
| 716 | |||
| 717 | pub const EAI = enum(c_int) { | ||
| 718 | ADDRFAMILY = 1, | ||
| 719 | AGAIN = 2, | ||
| 720 | BADFLAGS = 3, | ||
| 721 | FAIL = 4, | ||
| 722 | FAMILY = 5, | ||
| 723 | MEMORY = 6, | ||
| 724 | NODATA = 7, | ||
| 725 | NONAME = 8, | ||
| 726 | SERVICE = 9, | ||
| 727 | SOCKTYPE = 10, | ||
| 728 | SYSTEM = 11, | ||
| 729 | BADHINTS = 12, | ||
| 730 | PROTOCOL = 13, | ||
| 731 | OVERFLOW = 14, | ||
| 732 | _, | ||
| 733 | }; | ||
| 734 | |||
| 735 | pub const AI_PASSIVE = 0x00000001; | ||
| 736 | pub const AI_CANONNAME = 0x00000002; | ||
| 737 | pub const AI_NUMERICHOST = 0x00000004; | ||
| 738 | pub const AI_NUMERICSERV = 0x00000008; | ||
| 739 | pub const AI_MASK = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG; | ||
| 740 | pub const AI_ALL = 0x00000100; | ||
| 741 | pub const AI_V4MAPPED_CFG = 0x00000200; | ||
| 742 | pub const AI_ADDRCONFIG = 0x00000400; | ||
| 743 | pub const AI_V4MAPPED = 0x00000800; | ||
| 744 | pub const AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG; | ||
| 745 | |||
| 746 | pub const RTLD_LAZY = 1; | ||
| 747 | pub const RTLD_NOW = 2; | ||
| 748 | pub const RTLD_MODEMASK = 0x3; | ||
| 749 | pub const RTLD_GLOBAL = 0x100; | ||
| 750 | pub const RTLD_LOCAL = 0; | ||
| 751 | pub const RTLD_TRACE = 0x200; | ||
| 752 | pub const RTLD_NODELETE = 0x01000; | ||
| 753 | pub const RTLD_NOLOAD = 0x02000; | ||
| 754 | |||
| 755 | pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); | ||
| 756 | pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); | ||
| 757 | pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); | ||
| 758 | pub const RTLD_ALL = @intToPtr(*c_void, @bitCast(usize, @as(isize, -4))); | ||
| 759 | |||
| 760 | pub const dl_phdr_info = extern struct { | ||
| 761 | dlpi_addr: usize, | ||
| 762 | dlpi_name: ?[*:0]const u8, | ||
| 763 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 764 | dlpi_phnum: u16, | ||
| 765 | }; | ||
| 766 | pub const cmsghdr = extern struct { | ||
| 767 | cmsg_len: socklen_t, | ||
| 768 | cmsg_level: c_int, | ||
| 769 | cmsg_type: c_int, | ||
| 770 | }; | ||
| 771 | pub const msghdr = extern struct { | ||
| 772 | msg_name: ?*c_void, | ||
| 773 | msg_namelen: socklen_t, | ||
| 774 | msg_iov: [*c]iovec, | ||
| 775 | msg_iovlen: c_int, | ||
| 776 | msg_control: ?*c_void, | ||
| 777 | msg_controllen: socklen_t, | ||
| 778 | msg_flags: c_int, | ||
| 779 | }; | ||
| 780 | pub const cmsgcred = extern struct { | ||
| 781 | cmcred_pid: pid_t, | ||
| 782 | cmcred_uid: uid_t, | ||
| 783 | cmcred_euid: uid_t, | ||
| 784 | cmcred_gid: gid_t, | ||
| 785 | cmcred_ngroups: c_short, | ||
| 786 | cmcred_groups: [16]gid_t, | ||
| 787 | }; | ||
| 788 | pub const sf_hdtr = extern struct { | ||
| 789 | headers: [*c]iovec, | ||
| 790 | hdr_cnt: c_int, | ||
| 791 | trailers: [*c]iovec, | ||
| 792 | trl_cnt: c_int, | ||
| 793 | }; | ||
| 794 | |||
| 795 | pub const MS_SYNC = 0; | ||
| 796 | pub const MS_ASYNC = 1; | ||
| 797 | pub const MS_INVALIDATE = 2; | ||
| 798 | |||
| 799 | pub const POSIX_MADV_SEQUENTIAL = 2; | ||
| 800 | pub const POSIX_MADV_RANDOM = 1; | ||
| 801 | pub const POSIX_MADV_DONTNEED = 4; | ||
| 802 | pub const POSIX_MADV_NORMAL = 0; | ||
| 803 | pub const POSIX_MADV_WILLNEED = 3; | ||
| 804 | |||
| 805 | pub const MADV_SEQUENTIAL = 2; | ||
| 806 | pub const MADV_CONTROL_END = MADV_SETMAP; | ||
| 807 | pub const MADV_DONTNEED = 4; | ||
| 808 | pub const MADV_RANDOM = 1; | ||
| 809 | pub const MADV_WILLNEED = 3; | ||
| 810 | pub const MADV_NORMAL = 0; | ||
| 811 | pub const MADV_CONTROL_START = MADV_INVAL; | ||
| 812 | pub const MADV_FREE = 5; | ||
| 813 | pub const MADV_NOSYNC = 6; | ||
| 814 | pub const MADV_AUTOSYNC = 7; | ||
| 815 | pub const MADV_NOCORE = 8; | ||
| 816 | pub const MADV_CORE = 9; | ||
| 817 | pub const MADV_INVAL = 10; | ||
| 818 | pub const MADV_SETMAP = 11; | ||
| 819 | |||
| 820 | pub const F_DUPFD = 0; | ||
| 821 | pub const F_GETFD = 1; | ||
| 822 | pub const F_RDLCK = 1; | ||
| 823 | pub const F_SETFD = 2; | ||
| 824 | pub const F_UNLCK = 2; | ||
| 825 | pub const F_WRLCK = 3; | ||
| 826 | pub const F_GETFL = 3; | ||
| 827 | pub const F_SETFL = 4; | ||
| 828 | pub const F_GETOWN = 5; | ||
| 829 | pub const F_SETOWN = 6; | ||
| 830 | pub const F_GETLK = 7; | ||
| 831 | pub const F_SETLK = 8; | ||
| 832 | pub const F_SETLKW = 9; | ||
| 833 | pub const F_DUP2FD = 10; | ||
| 834 | pub const F_DUPFD_CLOEXEC = 17; | ||
| 835 | pub const F_DUP2FD_CLOEXEC = 18; | ||
| 836 | |||
| 837 | pub const LOCK_SH = 1; | ||
| 838 | pub const LOCK_EX = 2; | ||
| 839 | pub const LOCK_UN = 8; | ||
| 840 | pub const LOCK_NB = 4; | ||
| 841 | |||
| 842 | pub const Flock = extern struct { | ||
| 843 | l_start: off_t, | ||
| 844 | l_len: off_t, | ||
| 845 | l_pid: pid_t, | ||
| 846 | l_type: c_short, | ||
| 847 | l_whence: c_short, | ||
| 848 | }; | ||
| 849 | |||
| 850 | pub const addrinfo = extern struct { | ||
| 851 | flags: i32, | ||
| 852 | family: i32, | ||
| 853 | socktype: i32, | ||
| 854 | protocol: i32, | ||
| 855 | addrlen: socklen_t, | ||
| 856 | canonname: ?[*:0]u8, | ||
| 857 | addr: ?*sockaddr, | ||
| 858 | next: ?*addrinfo, | ||
| 859 | }; | ||
| 860 | |||
| 861 | pub const IPPROTO_IP = 0; | ||
| 862 | pub const IPPROTO_ICMP = 1; | ||
| 863 | pub const IPPROTO_TCP = 6; | ||
| 864 | pub const IPPROTO_UDP = 17; | ||
| 865 | pub const IPPROTO_IPV6 = 41; | ||
| 866 | pub const IPPROTO_RAW = 255; | ||
| 867 | pub const IPPROTO_HOPOPTS = 0; | ||
| 868 | pub const IPPROTO_IGMP = 2; | ||
| 869 | pub const IPPROTO_GGP = 3; | ||
| 870 | pub const IPPROTO_IPV4 = 4; | ||
| 871 | pub const IPPROTO_IPIP = IPPROTO_IPV4; | ||
| 872 | pub const IPPROTO_ST = 7; | ||
| 873 | pub const IPPROTO_EGP = 8; | ||
| 874 | pub const IPPROTO_PIGP = 9; | ||
| 875 | pub const IPPROTO_RCCMON = 10; | ||
| 876 | pub const IPPROTO_NVPII = 11; | ||
| 877 | pub const IPPROTO_PUP = 12; | ||
| 878 | pub const IPPROTO_ARGUS = 13; | ||
| 879 | pub const IPPROTO_EMCON = 14; | ||
| 880 | pub const IPPROTO_XNET = 15; | ||
| 881 | pub const IPPROTO_CHAOS = 16; | ||
| 882 | pub const IPPROTO_MUX = 18; | ||
| 883 | pub const IPPROTO_MEAS = 19; | ||
| 884 | pub const IPPROTO_HMP = 20; | ||
| 885 | pub const IPPROTO_PRM = 21; | ||
| 886 | pub const IPPROTO_IDP = 22; | ||
| 887 | pub const IPPROTO_TRUNK1 = 23; | ||
| 888 | pub const IPPROTO_TRUNK2 = 24; | ||
| 889 | pub const IPPROTO_LEAF1 = 25; | ||
| 890 | pub const IPPROTO_LEAF2 = 26; | ||
| 891 | pub const IPPROTO_RDP = 27; | ||
| 892 | pub const IPPROTO_IRTP = 28; | ||
| 893 | pub const IPPROTO_TP = 29; | ||
| 894 | pub const IPPROTO_BLT = 30; | ||
| 895 | pub const IPPROTO_NSP = 31; | ||
| 896 | pub const IPPROTO_INP = 32; | ||
| 897 | pub const IPPROTO_SEP = 33; | ||
| 898 | pub const IPPROTO_3PC = 34; | ||
| 899 | pub const IPPROTO_IDPR = 35; | ||
| 900 | pub const IPPROTO_XTP = 36; | ||
| 901 | pub const IPPROTO_DDP = 37; | ||
| 902 | pub const IPPROTO_CMTP = 38; | ||
| 903 | pub const IPPROTO_TPXX = 39; | ||
| 904 | pub const IPPROTO_IL = 40; | ||
| 905 | pub const IPPROTO_SDRP = 42; | ||
| 906 | pub const IPPROTO_ROUTING = 43; | ||
| 907 | pub const IPPROTO_FRAGMENT = 44; | ||
| 908 | pub const IPPROTO_IDRP = 45; | ||
| 909 | pub const IPPROTO_RSVP = 46; | ||
| 910 | pub const IPPROTO_GRE = 47; | ||
| 911 | pub const IPPROTO_MHRP = 48; | ||
| 912 | pub const IPPROTO_BHA = 49; | ||
| 913 | pub const IPPROTO_ESP = 50; | ||
| 914 | pub const IPPROTO_AH = 51; | ||
| 915 | pub const IPPROTO_INLSP = 52; | ||
| 916 | pub const IPPROTO_SWIPE = 53; | ||
| 917 | pub const IPPROTO_NHRP = 54; | ||
| 918 | pub const IPPROTO_MOBILE = 55; | ||
| 919 | pub const IPPROTO_TLSP = 56; | ||
| 920 | pub const IPPROTO_SKIP = 57; | ||
| 921 | pub const IPPROTO_ICMPV6 = 58; | ||
| 922 | pub const IPPROTO_NONE = 59; | ||
| 923 | pub const IPPROTO_DSTOPTS = 60; | ||
| 924 | pub const IPPROTO_AHIP = 61; | ||
| 925 | pub const IPPROTO_CFTP = 62; | ||
| 926 | pub const IPPROTO_HELLO = 63; | ||
| 927 | pub const IPPROTO_SATEXPAK = 64; | ||
| 928 | pub const IPPROTO_KRYPTOLAN = 65; | ||
| 929 | pub const IPPROTO_RVD = 66; | ||
| 930 | pub const IPPROTO_IPPC = 67; | ||
| 931 | pub const IPPROTO_ADFS = 68; | ||
| 932 | pub const IPPROTO_SATMON = 69; | ||
| 933 | pub const IPPROTO_VISA = 70; | ||
| 934 | pub const IPPROTO_IPCV = 71; | ||
| 935 | pub const IPPROTO_CPNX = 72; | ||
| 936 | pub const IPPROTO_CPHB = 73; | ||
| 937 | pub const IPPROTO_WSN = 74; | ||
| 938 | pub const IPPROTO_PVP = 75; | ||
| 939 | pub const IPPROTO_BRSATMON = 76; | ||
| 940 | pub const IPPROTO_ND = 77; | ||
| 941 | pub const IPPROTO_WBMON = 78; | ||
| 942 | pub const IPPROTO_WBEXPAK = 79; | ||
| 943 | pub const IPPROTO_EON = 80; | ||
| 944 | pub const IPPROTO_VMTP = 81; | ||
| 945 | pub const IPPROTO_SVMTP = 82; | ||
| 946 | pub const IPPROTO_VINES = 83; | ||
| 947 | pub const IPPROTO_TTP = 84; | ||
| 948 | pub const IPPROTO_IGP = 85; | ||
| 949 | pub const IPPROTO_DGP = 86; | ||
| 950 | pub const IPPROTO_TCF = 87; | ||
| 951 | pub const IPPROTO_IGRP = 88; | ||
| 952 | pub const IPPROTO_OSPFIGP = 89; | ||
| 953 | pub const IPPROTO_SRPC = 90; | ||
| 954 | pub const IPPROTO_LARP = 91; | ||
| 955 | pub const IPPROTO_MTP = 92; | ||
| 956 | pub const IPPROTO_AX25 = 93; | ||
| 957 | pub const IPPROTO_IPEIP = 94; | ||
| 958 | pub const IPPROTO_MICP = 95; | ||
| 959 | pub const IPPROTO_SCCSP = 96; | ||
| 960 | pub const IPPROTO_ETHERIP = 97; | ||
| 961 | pub const IPPROTO_ENCAP = 98; | ||
| 962 | pub const IPPROTO_APES = 99; | ||
| 963 | pub const IPPROTO_GMTP = 100; | ||
| 964 | pub const IPPROTO_IPCOMP = 108; | ||
| 965 | pub const IPPROTO_PIM = 103; | ||
| 966 | pub const IPPROTO_CARP = 112; | ||
| 967 | pub const IPPROTO_PGM = 113; | ||
| 968 | pub const IPPROTO_PFSYNC = 240; | ||
| 969 | pub const IPPROTO_DIVERT = 254; | ||
| 970 | pub const IPPROTO_MAX = 256; | ||
| 971 | pub const IPPROTO_DONE = 257; | ||
| 972 | pub const IPPROTO_UNKNOWN = 258; | ||
| 973 | |||
| 974 | pub const rlimit_resource = enum(c_int) { | ||
| 975 | CPU = 0, | ||
| 976 | FSIZE = 1, | ||
| 977 | DATA = 2, | ||
| 978 | STACK = 3, | ||
| 979 | CORE = 4, | ||
| 980 | RSS = 5, | ||
| 981 | MEMLOCK = 6, | ||
| 982 | NPROC = 7, | ||
| 983 | NOFILE = 8, | ||
| 984 | SBSIZE = 9, | ||
| 985 | VMEM = 10, | ||
| 986 | POSIXLOCKS = 11, | ||
| 987 | _, | ||
| 988 | |||
| 989 | pub const AS: rlimit_resource = .VMEM; | ||
| 990 | }; | ||
| 991 | |||
| 992 | pub const rlim_t = i64; | ||
| 993 | |||
| 994 | /// No limit | ||
| 995 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 996 | |||
| 997 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 998 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 999 | |||
| 1000 | pub const rlimit = extern struct { | ||
| 1001 | /// Soft limit | ||
| 1002 | cur: rlim_t, | ||
| 1003 | /// Hard limit | ||
| 1004 | max: rlim_t, | ||
| 1005 | }; | ||
| 1006 | |||
| 1007 | pub const SHUT_RD = 0; | ||
| 1008 | pub const SHUT_WR = 1; | ||
| 1009 | pub const SHUT_RDWR = 2; | ||
| 1010 | |||
| 1011 | pub const nfds_t = u32; | ||
| 1012 | |||
| 1013 | pub const pollfd = extern struct { | ||
| 1014 | fd: fd_t, | ||
| 1015 | events: i16, | ||
| 1016 | revents: i16, | ||
| 1017 | }; | ||
| 1018 | |||
| 1019 | /// Requestable events. | ||
| 1020 | pub const POLLIN = 0x0001; | ||
| 1021 | pub const POLLPRI = 0x0002; | ||
| 1022 | pub const POLLOUT = 0x0004; | ||
| 1023 | pub const POLLRDNORM = 0x0040; | ||
| 1024 | pub const POLLWRNORM = POLLOUT; | ||
| 1025 | pub const POLLRDBAND = 0x0080; | ||
| 1026 | pub const POLLWRBAND = 0x0100; | ||
| 1027 | |||
| 1028 | /// These events are set if they occur regardless of whether they were requested. | ||
| 1029 | pub const POLLERR = 0x0008; | ||
| 1030 | pub const POLLHUP = 0x0010; | ||
| 1031 | pub const POLLNVAL = 0x0020; | ||
lib/std/os/bits/freebsd.zig deleted-1540| ... | @@ -1,1540 +0,0 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const maxInt = std.math.maxInt; | ||
| 4 | |||
| 5 | pub const blksize_t = i32; | ||
| 6 | pub const blkcnt_t = i64; | ||
| 7 | pub const clockid_t = i32; | ||
| 8 | pub const fsblkcnt_t = u64; | ||
| 9 | pub const fsfilcnt_t = u64; | ||
| 10 | pub const nlink_t = u64; | ||
| 11 | pub const fd_t = i32; | ||
| 12 | pub const pid_t = i32; | ||
| 13 | pub const uid_t = u32; | ||
| 14 | pub const gid_t = u32; | ||
| 15 | pub const mode_t = u16; | ||
| 16 | pub const off_t = i64; | ||
| 17 | pub const ino_t = u64; | ||
| 18 | pub const dev_t = u64; | ||
| 19 | pub const time_t = i64; | ||
| 20 | // The signedness is not constant across different architectures. | ||
| 21 | pub const clock_t = isize; | ||
| 22 | |||
| 23 | pub const socklen_t = u32; | ||
| 24 | pub const suseconds_t = c_long; | ||
| 25 | |||
| 26 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 27 | pub const Kevent = extern struct { | ||
| 28 | ident: usize, | ||
| 29 | filter: i16, | ||
| 30 | flags: u16, | ||
| 31 | fflags: u32, | ||
| 32 | data: i64, | ||
| 33 | udata: usize, | ||
| 34 | // TODO ext | ||
| 35 | }; | ||
| 36 | |||
| 37 | // Modes and flags for dlopen() | ||
| 38 | // include/dlfcn.h | ||
| 39 | |||
| 40 | /// Bind function calls lazily. | ||
| 41 | pub const RTLD_LAZY = 1; | ||
| 42 | |||
| 43 | /// Bind function calls immediately. | ||
| 44 | pub const RTLD_NOW = 2; | ||
| 45 | |||
| 46 | pub const RTLD_MODEMASK = 0x3; | ||
| 47 | |||
| 48 | /// Make symbols globally available. | ||
| 49 | pub const RTLD_GLOBAL = 0x100; | ||
| 50 | |||
| 51 | /// Opposite of RTLD_GLOBAL, and the default. | ||
| 52 | pub const RTLD_LOCAL = 0; | ||
| 53 | |||
| 54 | /// Trace loaded objects and exit. | ||
| 55 | pub const RTLD_TRACE = 0x200; | ||
| 56 | |||
| 57 | /// Do not remove members. | ||
| 58 | pub const RTLD_NODELETE = 0x01000; | ||
| 59 | |||
| 60 | /// Do not load if not already loaded. | ||
| 61 | pub const RTLD_NOLOAD = 0x02000; | ||
| 62 | |||
| 63 | pub const dl_phdr_info = extern struct { | ||
| 64 | dlpi_addr: usize, | ||
| 65 | dlpi_name: ?[*:0]const u8, | ||
| 66 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 67 | dlpi_phnum: u16, | ||
| 68 | }; | ||
| 69 | |||
| 70 | pub const Flock = extern struct { | ||
| 71 | l_start: off_t, | ||
| 72 | l_len: off_t, | ||
| 73 | l_pid: pid_t, | ||
| 74 | l_type: i16, | ||
| 75 | l_whence: i16, | ||
| 76 | l_sysid: i32, | ||
| 77 | __unused: [4]u8, | ||
| 78 | }; | ||
| 79 | |||
| 80 | pub const msghdr = extern struct { | ||
| 81 | /// optional address | ||
| 82 | msg_name: ?*sockaddr, | ||
| 83 | |||
| 84 | /// size of address | ||
| 85 | msg_namelen: socklen_t, | ||
| 86 | |||
| 87 | /// scatter/gather array | ||
| 88 | msg_iov: [*]iovec, | ||
| 89 | |||
| 90 | /// # elements in msg_iov | ||
| 91 | msg_iovlen: i32, | ||
| 92 | |||
| 93 | /// ancillary data | ||
| 94 | msg_control: ?*c_void, | ||
| 95 | |||
| 96 | /// ancillary data buffer len | ||
| 97 | msg_controllen: socklen_t, | ||
| 98 | |||
| 99 | /// flags on received message | ||
| 100 | msg_flags: i32, | ||
| 101 | }; | ||
| 102 | |||
| 103 | pub const msghdr_const = extern struct { | ||
| 104 | /// optional address | ||
| 105 | msg_name: ?*const sockaddr, | ||
| 106 | |||
| 107 | /// size of address | ||
| 108 | msg_namelen: socklen_t, | ||
| 109 | |||
| 110 | /// scatter/gather array | ||
| 111 | msg_iov: [*]iovec_const, | ||
| 112 | |||
| 113 | /// # elements in msg_iov | ||
| 114 | msg_iovlen: i32, | ||
| 115 | |||
| 116 | /// ancillary data | ||
| 117 | msg_control: ?*c_void, | ||
| 118 | |||
| 119 | /// ancillary data buffer len | ||
| 120 | msg_controllen: socklen_t, | ||
| 121 | |||
| 122 | /// flags on received message | ||
| 123 | msg_flags: i32, | ||
| 124 | }; | ||
| 125 | |||
| 126 | pub const libc_stat = extern struct { | ||
| 127 | dev: dev_t, | ||
| 128 | ino: ino_t, | ||
| 129 | nlink: nlink_t, | ||
| 130 | |||
| 131 | mode: mode_t, | ||
| 132 | __pad0: u16, | ||
| 133 | uid: uid_t, | ||
| 134 | gid: gid_t, | ||
| 135 | __pad1: u32, | ||
| 136 | rdev: dev_t, | ||
| 137 | |||
| 138 | atim: timespec, | ||
| 139 | mtim: timespec, | ||
| 140 | ctim: timespec, | ||
| 141 | birthtim: timespec, | ||
| 142 | |||
| 143 | size: off_t, | ||
| 144 | blocks: i64, | ||
| 145 | blksize: isize, | ||
| 146 | flags: u32, | ||
| 147 | gen: u64, | ||
| 148 | __spare: [10]u64, | ||
| 149 | |||
| 150 | pub fn atime(self: @This()) timespec { | ||
| 151 | return self.atim; | ||
| 152 | } | ||
| 153 | |||
| 154 | pub fn mtime(self: @This()) timespec { | ||
| 155 | return self.mtim; | ||
| 156 | } | ||
| 157 | |||
| 158 | pub fn ctime(self: @This()) timespec { | ||
| 159 | return self.ctim; | ||
| 160 | } | ||
| 161 | }; | ||
| 162 | |||
| 163 | pub const timespec = extern struct { | ||
| 164 | tv_sec: isize, | ||
| 165 | tv_nsec: isize, | ||
| 166 | }; | ||
| 167 | |||
| 168 | pub const timeval = extern struct { | ||
| 169 | /// seconds | ||
| 170 | tv_sec: time_t, | ||
| 171 | /// microseconds | ||
| 172 | tv_usec: suseconds_t, | ||
| 173 | }; | ||
| 174 | |||
| 175 | pub const dirent = extern struct { | ||
| 176 | d_fileno: usize, | ||
| 177 | d_off: i64, | ||
| 178 | d_reclen: u16, | ||
| 179 | d_type: u8, | ||
| 180 | d_pad0: u8, | ||
| 181 | d_namlen: u16, | ||
| 182 | d_pad1: u16, | ||
| 183 | d_name: [256]u8, | ||
| 184 | |||
| 185 | pub fn reclen(self: dirent) u16 { | ||
| 186 | return self.d_reclen; | ||
| 187 | } | ||
| 188 | }; | ||
| 189 | |||
| 190 | pub const in_port_t = u16; | ||
| 191 | pub const sa_family_t = u8; | ||
| 192 | |||
| 193 | pub const sockaddr = extern struct { | ||
| 194 | /// total length | ||
| 195 | len: u8, | ||
| 196 | |||
| 197 | /// address family | ||
| 198 | family: sa_family_t, | ||
| 199 | |||
| 200 | /// actually longer; address value | ||
| 201 | data: [14]u8, | ||
| 202 | }; | ||
| 203 | |||
| 204 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 205 | |||
| 206 | pub const sockaddr_in = extern struct { | ||
| 207 | len: u8 = @sizeOf(sockaddr_in), | ||
| 208 | family: sa_family_t = AF_INET, | ||
| 209 | port: in_port_t, | ||
| 210 | addr: u32, | ||
| 211 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 212 | }; | ||
| 213 | |||
| 214 | pub const sockaddr_in6 = extern struct { | ||
| 215 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 216 | family: sa_family_t = AF_INET6, | ||
| 217 | port: in_port_t, | ||
| 218 | flowinfo: u32, | ||
| 219 | addr: [16]u8, | ||
| 220 | scope_id: u32, | ||
| 221 | }; | ||
| 222 | |||
| 223 | pub const sockaddr_un = extern struct { | ||
| 224 | len: u8 = @sizeOf(sockaddr_un), | ||
| 225 | family: sa_family_t = AF_UNIX, | ||
| 226 | path: [104]u8, | ||
| 227 | }; | ||
| 228 | |||
| 229 | pub const CTL_KERN = 1; | ||
| 230 | pub const CTL_DEBUG = 5; | ||
| 231 | |||
| 232 | pub const KERN_PROC = 14; // struct: process entries | ||
| 233 | pub const KERN_PROC_PATHNAME = 12; // path to executable | ||
| 234 | pub const KERN_IOV_MAX = 35; | ||
| 235 | |||
| 236 | pub const PATH_MAX = 1024; | ||
| 237 | pub const IOV_MAX = KERN_IOV_MAX; | ||
| 238 | |||
| 239 | pub const STDIN_FILENO = 0; | ||
| 240 | pub const STDOUT_FILENO = 1; | ||
| 241 | pub const STDERR_FILENO = 2; | ||
| 242 | |||
| 243 | pub const PROT_NONE = 0; | ||
| 244 | pub const PROT_READ = 1; | ||
| 245 | pub const PROT_WRITE = 2; | ||
| 246 | pub const PROT_EXEC = 4; | ||
| 247 | |||
| 248 | pub const CLOCK_REALTIME = 0; | ||
| 249 | pub const CLOCK_VIRTUAL = 1; | ||
| 250 | pub const CLOCK_PROF = 2; | ||
| 251 | pub const CLOCK_MONOTONIC = 4; | ||
| 252 | pub const CLOCK_UPTIME = 5; | ||
| 253 | pub const CLOCK_UPTIME_PRECISE = 7; | ||
| 254 | pub const CLOCK_UPTIME_FAST = 8; | ||
| 255 | pub const CLOCK_REALTIME_PRECISE = 9; | ||
| 256 | pub const CLOCK_REALTIME_FAST = 10; | ||
| 257 | pub const CLOCK_MONOTONIC_PRECISE = 11; | ||
| 258 | pub const CLOCK_MONOTONIC_FAST = 12; | ||
| 259 | pub const CLOCK_SECOND = 13; | ||
| 260 | pub const CLOCK_THREAD_CPUTIME_ID = 14; | ||
| 261 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; | ||
| 262 | |||
| 263 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 264 | pub const MAP_SHARED = 0x0001; | ||
| 265 | pub const MAP_PRIVATE = 0x0002; | ||
| 266 | pub const MAP_FIXED = 0x0010; | ||
| 267 | pub const MAP_STACK = 0x0400; | ||
| 268 | pub const MAP_NOSYNC = 0x0800; | ||
| 269 | pub const MAP_ANON = 0x1000; | ||
| 270 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 271 | pub const MAP_FILE = 0; | ||
| 272 | |||
| 273 | pub const MAP_GUARD = 0x00002000; | ||
| 274 | pub const MAP_EXCL = 0x00004000; | ||
| 275 | pub const MAP_NOCORE = 0x00020000; | ||
| 276 | pub const MAP_PREFAULT_READ = 0x00040000; | ||
| 277 | pub const MAP_32BIT = 0x00080000; | ||
| 278 | |||
| 279 | pub const WNOHANG = 1; | ||
| 280 | pub const WUNTRACED = 2; | ||
| 281 | pub const WSTOPPED = WUNTRACED; | ||
| 282 | pub const WCONTINUED = 4; | ||
| 283 | pub const WNOWAIT = 8; | ||
| 284 | pub const WEXITED = 16; | ||
| 285 | pub const WTRAPPED = 32; | ||
| 286 | |||
| 287 | pub const SA_ONSTACK = 0x0001; | ||
| 288 | pub const SA_RESTART = 0x0002; | ||
| 289 | pub const SA_RESETHAND = 0x0004; | ||
| 290 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 291 | pub const SA_NODEFER = 0x0010; | ||
| 292 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 293 | pub const SA_SIGINFO = 0x0040; | ||
| 294 | |||
| 295 | pub const SIGHUP = 1; | ||
| 296 | pub const SIGINT = 2; | ||
| 297 | pub const SIGQUIT = 3; | ||
| 298 | pub const SIGILL = 4; | ||
| 299 | pub const SIGTRAP = 5; | ||
| 300 | pub const SIGABRT = 6; | ||
| 301 | pub const SIGIOT = SIGABRT; | ||
| 302 | pub const SIGEMT = 7; | ||
| 303 | pub const SIGFPE = 8; | ||
| 304 | pub const SIGKILL = 9; | ||
| 305 | pub const SIGBUS = 10; | ||
| 306 | pub const SIGSEGV = 11; | ||
| 307 | pub const SIGSYS = 12; | ||
| 308 | pub const SIGPIPE = 13; | ||
| 309 | pub const SIGALRM = 14; | ||
| 310 | pub const SIGTERM = 15; | ||
| 311 | pub const SIGURG = 16; | ||
| 312 | pub const SIGSTOP = 17; | ||
| 313 | pub const SIGTSTP = 18; | ||
| 314 | pub const SIGCONT = 19; | ||
| 315 | pub const SIGCHLD = 20; | ||
| 316 | pub const SIGTTIN = 21; | ||
| 317 | pub const SIGTTOU = 22; | ||
| 318 | pub const SIGIO = 23; | ||
| 319 | pub const SIGXCPU = 24; | ||
| 320 | pub const SIGXFSZ = 25; | ||
| 321 | pub const SIGVTALRM = 26; | ||
| 322 | pub const SIGPROF = 27; | ||
| 323 | pub const SIGWINCH = 28; | ||
| 324 | pub const SIGINFO = 29; | ||
| 325 | pub const SIGUSR1 = 30; | ||
| 326 | pub const SIGUSR2 = 31; | ||
| 327 | pub const SIGTHR = 32; | ||
| 328 | pub const SIGLWP = SIGTHR; | ||
| 329 | pub const SIGLIBRT = 33; | ||
| 330 | |||
| 331 | pub const SIGRTMIN = 65; | ||
| 332 | pub const SIGRTMAX = 126; | ||
| 333 | |||
| 334 | // access function | ||
| 335 | pub const F_OK = 0; // test for existence of file | ||
| 336 | pub const X_OK = 1; // test for execute or search permission | ||
| 337 | pub const W_OK = 2; // test for write permission | ||
| 338 | pub const R_OK = 4; // test for read permission | ||
| 339 | |||
| 340 | pub const O_RDONLY = 0x0000; | ||
| 341 | pub const O_WRONLY = 0x0001; | ||
| 342 | pub const O_RDWR = 0x0002; | ||
| 343 | pub const O_ACCMODE = 0x0003; | ||
| 344 | |||
| 345 | pub const O_SHLOCK = 0x0010; | ||
| 346 | pub const O_EXLOCK = 0x0020; | ||
| 347 | |||
| 348 | pub const O_CREAT = 0x0200; | ||
| 349 | pub const O_EXCL = 0x0800; | ||
| 350 | pub const O_NOCTTY = 0x8000; | ||
| 351 | pub const O_TRUNC = 0x0400; | ||
| 352 | pub const O_APPEND = 0x0008; | ||
| 353 | pub const O_NONBLOCK = 0x0004; | ||
| 354 | pub const O_DSYNC = 0o10000; | ||
| 355 | pub const O_SYNC = 0x0080; | ||
| 356 | pub const O_RSYNC = 0o4010000; | ||
| 357 | pub const O_DIRECTORY = 0x20000; | ||
| 358 | pub const O_NOFOLLOW = 0x0100; | ||
| 359 | pub const O_CLOEXEC = 0x00100000; | ||
| 360 | |||
| 361 | pub const O_ASYNC = 0x0040; | ||
| 362 | pub const O_DIRECT = 0x00010000; | ||
| 363 | pub const O_NOATIME = 0o1000000; | ||
| 364 | pub const O_PATH = 0o10000000; | ||
| 365 | pub const O_TMPFILE = 0o20200000; | ||
| 366 | pub const O_NDELAY = O_NONBLOCK; | ||
| 367 | |||
| 368 | pub const F_DUPFD = 0; | ||
| 369 | pub const F_GETFD = 1; | ||
| 370 | pub const F_SETFD = 2; | ||
| 371 | pub const F_GETFL = 3; | ||
| 372 | pub const F_SETFL = 4; | ||
| 373 | |||
| 374 | pub const F_GETOWN = 5; | ||
| 375 | pub const F_SETOWN = 6; | ||
| 376 | |||
| 377 | pub const F_GETLK = 11; | ||
| 378 | pub const F_SETLK = 12; | ||
| 379 | pub const F_SETLKW = 13; | ||
| 380 | |||
| 381 | pub const F_RDLCK = 1; | ||
| 382 | pub const F_WRLCK = 3; | ||
| 383 | pub const F_UNLCK = 2; | ||
| 384 | |||
| 385 | pub const LOCK_SH = 1; | ||
| 386 | pub const LOCK_EX = 2; | ||
| 387 | pub const LOCK_UN = 8; | ||
| 388 | pub const LOCK_NB = 4; | ||
| 389 | |||
| 390 | pub const F_SETOWN_EX = 15; | ||
| 391 | pub const F_GETOWN_EX = 16; | ||
| 392 | |||
| 393 | pub const F_GETOWNER_UIDS = 17; | ||
| 394 | |||
| 395 | pub const FD_CLOEXEC = 1; | ||
| 396 | |||
| 397 | pub const SEEK_SET = 0; | ||
| 398 | pub const SEEK_CUR = 1; | ||
| 399 | pub const SEEK_END = 2; | ||
| 400 | |||
| 401 | pub const SIG_BLOCK = 1; | ||
| 402 | pub const SIG_UNBLOCK = 2; | ||
| 403 | pub const SIG_SETMASK = 3; | ||
| 404 | |||
| 405 | pub const SOCK_STREAM = 1; | ||
| 406 | pub const SOCK_DGRAM = 2; | ||
| 407 | pub const SOCK_RAW = 3; | ||
| 408 | pub const SOCK_RDM = 4; | ||
| 409 | pub const SOCK_SEQPACKET = 5; | ||
| 410 | |||
| 411 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 412 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 413 | |||
| 414 | pub const SO_DEBUG = 0x00000001; | ||
| 415 | pub const SO_ACCEPTCONN = 0x00000002; | ||
| 416 | pub const SO_REUSEADDR = 0x00000004; | ||
| 417 | pub const SO_KEEPALIVE = 0x00000008; | ||
| 418 | pub const SO_DONTROUTE = 0x00000010; | ||
| 419 | pub const SO_BROADCAST = 0x00000020; | ||
| 420 | pub const SO_USELOOPBACK = 0x00000040; | ||
| 421 | pub const SO_LINGER = 0x00000080; | ||
| 422 | pub const SO_OOBINLINE = 0x00000100; | ||
| 423 | pub const SO_REUSEPORT = 0x00000200; | ||
| 424 | pub const SO_TIMESTAMP = 0x00000400; | ||
| 425 | pub const SO_NOSIGPIPE = 0x00000800; | ||
| 426 | pub const SO_ACCEPTFILTER = 0x00001000; | ||
| 427 | pub const SO_BINTIME = 0x00002000; | ||
| 428 | pub const SO_NO_OFFLOAD = 0x00004000; | ||
| 429 | pub const SO_NO_DDP = 0x00008000; | ||
| 430 | pub const SO_REUSEPORT_LB = 0x00010000; | ||
| 431 | |||
| 432 | pub const SO_SNDBUF = 0x1001; | ||
| 433 | pub const SO_RCVBUF = 0x1002; | ||
| 434 | pub const SO_SNDLOWAT = 0x1003; | ||
| 435 | pub const SO_RCVLOWAT = 0x1004; | ||
| 436 | pub const SO_SNDTIMEO = 0x1005; | ||
| 437 | pub const SO_RCVTIMEO = 0x1006; | ||
| 438 | pub const SO_ERROR = 0x1007; | ||
| 439 | pub const SO_TYPE = 0x1008; | ||
| 440 | pub const SO_LABEL = 0x1009; | ||
| 441 | pub const SO_PEERLABEL = 0x1010; | ||
| 442 | pub const SO_LISTENQLIMIT = 0x1011; | ||
| 443 | pub const SO_LISTENQLEN = 0x1012; | ||
| 444 | pub const SO_LISTENINCQLEN = 0x1013; | ||
| 445 | pub const SO_SETFIB = 0x1014; | ||
| 446 | pub const SO_USER_COOKIE = 0x1015; | ||
| 447 | pub const SO_PROTOCOL = 0x1016; | ||
| 448 | pub const SO_PROTOTYPE = SO_PROTOCOL; | ||
| 449 | pub const SO_TS_CLOCK = 0x1017; | ||
| 450 | pub const SO_MAX_PACING_RATE = 0x1018; | ||
| 451 | pub const SO_DOMAIN = 0x1019; | ||
| 452 | |||
| 453 | pub const SOL_SOCKET = 0xffff; | ||
| 454 | |||
| 455 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 456 | pub const PF_LOCAL = AF_LOCAL; | ||
| 457 | pub const PF_UNIX = PF_LOCAL; | ||
| 458 | pub const PF_INET = AF_INET; | ||
| 459 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 460 | pub const PF_PUP = AF_PUP; | ||
| 461 | pub const PF_CHAOS = AF_CHAOS; | ||
| 462 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 463 | pub const PF_ISO = AF_ISO; | ||
| 464 | pub const PF_OSI = AF_ISO; | ||
| 465 | pub const PF_ECMA = AF_ECMA; | ||
| 466 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 467 | pub const PF_CCITT = AF_CCITT; | ||
| 468 | pub const PF_DECnet = AF_DECnet; | ||
| 469 | pub const PF_DLI = AF_DLI; | ||
| 470 | pub const PF_LAT = AF_LAT; | ||
| 471 | pub const PF_HYLINK = AF_HYLINK; | ||
| 472 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 473 | pub const PF_ROUTE = AF_ROUTE; | ||
| 474 | pub const PF_LINK = AF_LINK; | ||
| 475 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 476 | pub const PF_COIP = AF_COIP; | ||
| 477 | pub const PF_CNT = AF_CNT; | ||
| 478 | pub const PF_SIP = AF_SIP; | ||
| 479 | pub const PF_IPX = AF_IPX; | ||
| 480 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 481 | pub const PF_PIP = psuedo_AF_PIP; | ||
| 482 | pub const PF_ISDN = AF_ISDN; | ||
| 483 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 484 | pub const PF_INET6 = pseudo_AF_INET6; | ||
| 485 | pub const PF_NATM = AF_NATM; | ||
| 486 | pub const PF_ATM = AF_ATM; | ||
| 487 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 488 | pub const PF_SLOW = AF_SLOW; | ||
| 489 | pub const PF_SCLUSTER = AF_SCLUSTER; | ||
| 490 | pub const PF_ARP = AF_ARP; | ||
| 491 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 492 | pub const PF_IEEE80211 = AF_IEEE80211; | ||
| 493 | pub const PF_INET_SDP = AF_INET_SDP; | ||
| 494 | pub const PF_INET6_SDP = AF_INET6_SDP; | ||
| 495 | pub const PF_MAX = AF_MAX; | ||
| 496 | |||
| 497 | pub const AF_UNSPEC = 0; | ||
| 498 | pub const AF_UNIX = 1; | ||
| 499 | pub const AF_LOCAL = AF_UNIX; | ||
| 500 | pub const AF_FILE = AF_LOCAL; | ||
| 501 | pub const AF_INET = 2; | ||
| 502 | pub const AF_IMPLINK = 3; | ||
| 503 | pub const AF_PUP = 4; | ||
| 504 | pub const AF_CHAOS = 5; | ||
| 505 | pub const AF_NETBIOS = 6; | ||
| 506 | pub const AF_ISO = 7; | ||
| 507 | pub const AF_OSI = AF_ISO; | ||
| 508 | pub const AF_ECMA = 8; | ||
| 509 | pub const AF_DATAKIT = 9; | ||
| 510 | pub const AF_CCITT = 10; | ||
| 511 | pub const AF_SNA = 11; | ||
| 512 | pub const AF_DECnet = 12; | ||
| 513 | pub const AF_DLI = 13; | ||
| 514 | pub const AF_LAT = 14; | ||
| 515 | pub const AF_HYLINK = 15; | ||
| 516 | pub const AF_APPLETALK = 16; | ||
| 517 | pub const AF_ROUTE = 17; | ||
| 518 | pub const AF_LINK = 18; | ||
| 519 | pub const pseudo_AF_XTP = 19; | ||
| 520 | pub const AF_COIP = 20; | ||
| 521 | pub const AF_CNT = 21; | ||
| 522 | pub const pseudo_AF_RTIP = 22; | ||
| 523 | pub const AF_IPX = 23; | ||
| 524 | pub const AF_SIP = 24; | ||
| 525 | pub const pseudo_AF_PIP = 25; | ||
| 526 | pub const AF_ISDN = 26; | ||
| 527 | pub const AF_E164 = AF_ISDN; | ||
| 528 | pub const pseudo_AF_KEY = 27; | ||
| 529 | pub const AF_INET6 = 28; | ||
| 530 | pub const AF_NATM = 29; | ||
| 531 | pub const AF_ATM = 30; | ||
| 532 | pub const pseudo_AF_HDRCMPLT = 31; | ||
| 533 | pub const AF_NETGRAPH = 32; | ||
| 534 | pub const AF_SLOW = 33; | ||
| 535 | pub const AF_SCLUSTER = 34; | ||
| 536 | pub const AF_ARP = 35; | ||
| 537 | pub const AF_BLUETOOTH = 36; | ||
| 538 | pub const AF_IEEE80211 = 37; | ||
| 539 | pub const AF_INET_SDP = 40; | ||
| 540 | pub const AF_INET6_SDP = 42; | ||
| 541 | pub const AF_MAX = 42; | ||
| 542 | |||
| 543 | pub const DT_UNKNOWN = 0; | ||
| 544 | pub const DT_FIFO = 1; | ||
| 545 | pub const DT_CHR = 2; | ||
| 546 | pub const DT_DIR = 4; | ||
| 547 | pub const DT_BLK = 6; | ||
| 548 | pub const DT_REG = 8; | ||
| 549 | pub const DT_LNK = 10; | ||
| 550 | pub const DT_SOCK = 12; | ||
| 551 | pub const DT_WHT = 14; | ||
| 552 | |||
| 553 | /// add event to kq (implies enable) | ||
| 554 | pub const EV_ADD = 0x0001; | ||
| 555 | |||
| 556 | /// delete event from kq | ||
| 557 | pub const EV_DELETE = 0x0002; | ||
| 558 | |||
| 559 | /// enable event | ||
| 560 | pub const EV_ENABLE = 0x0004; | ||
| 561 | |||
| 562 | /// disable event (not reported) | ||
| 563 | pub const EV_DISABLE = 0x0008; | ||
| 564 | |||
| 565 | /// only report one occurrence | ||
| 566 | pub const EV_ONESHOT = 0x0010; | ||
| 567 | |||
| 568 | /// clear event state after reporting | ||
| 569 | pub const EV_CLEAR = 0x0020; | ||
| 570 | |||
| 571 | /// error, event data contains errno | ||
| 572 | pub const EV_ERROR = 0x4000; | ||
| 573 | |||
| 574 | /// force immediate event output | ||
| 575 | /// ... with or without EV_ERROR | ||
| 576 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 577 | /// on syscalls supporting flags | ||
| 578 | pub const EV_RECEIPT = 0x0040; | ||
| 579 | |||
| 580 | /// disable event after reporting | ||
| 581 | pub const EV_DISPATCH = 0x0080; | ||
| 582 | |||
| 583 | pub const EVFILT_READ = -1; | ||
| 584 | pub const EVFILT_WRITE = -2; | ||
| 585 | |||
| 586 | /// attached to aio requests | ||
| 587 | pub const EVFILT_AIO = -3; | ||
| 588 | |||
| 589 | /// attached to vnodes | ||
| 590 | pub const EVFILT_VNODE = -4; | ||
| 591 | |||
| 592 | /// attached to struct proc | ||
| 593 | pub const EVFILT_PROC = -5; | ||
| 594 | |||
| 595 | /// attached to struct proc | ||
| 596 | pub const EVFILT_SIGNAL = -6; | ||
| 597 | |||
| 598 | /// timers | ||
| 599 | pub const EVFILT_TIMER = -7; | ||
| 600 | |||
| 601 | /// Process descriptors | ||
| 602 | pub const EVFILT_PROCDESC = -8; | ||
| 603 | |||
| 604 | /// Filesystem events | ||
| 605 | pub const EVFILT_FS = -9; | ||
| 606 | |||
| 607 | pub const EVFILT_LIO = -10; | ||
| 608 | |||
| 609 | /// User events | ||
| 610 | pub const EVFILT_USER = -11; | ||
| 611 | |||
| 612 | /// Sendfile events | ||
| 613 | pub const EVFILT_SENDFILE = -12; | ||
| 614 | |||
| 615 | pub const EVFILT_EMPTY = -13; | ||
| 616 | |||
| 617 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 618 | pub const NOTE_TRIGGER = 0x01000000; | ||
| 619 | |||
| 620 | /// ignore input fflags | ||
| 621 | pub const NOTE_FFNOP = 0x00000000; | ||
| 622 | |||
| 623 | /// and fflags | ||
| 624 | pub const NOTE_FFAND = 0x40000000; | ||
| 625 | |||
| 626 | /// or fflags | ||
| 627 | pub const NOTE_FFOR = 0x80000000; | ||
| 628 | |||
| 629 | /// copy fflags | ||
| 630 | pub const NOTE_FFCOPY = 0xc0000000; | ||
| 631 | |||
| 632 | /// mask for operations | ||
| 633 | pub const NOTE_FFCTRLMASK = 0xc0000000; | ||
| 634 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | ||
| 635 | |||
| 636 | /// low water mark | ||
| 637 | pub const NOTE_LOWAT = 0x00000001; | ||
| 638 | |||
| 639 | /// behave like poll() | ||
| 640 | pub const NOTE_FILE_POLL = 0x00000002; | ||
| 641 | |||
| 642 | /// vnode was removed | ||
| 643 | pub const NOTE_DELETE = 0x00000001; | ||
| 644 | |||
| 645 | /// data contents changed | ||
| 646 | pub const NOTE_WRITE = 0x00000002; | ||
| 647 | |||
| 648 | /// size increased | ||
| 649 | pub const NOTE_EXTEND = 0x00000004; | ||
| 650 | |||
| 651 | /// attributes changed | ||
| 652 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 653 | |||
| 654 | /// link count changed | ||
| 655 | pub const NOTE_LINK = 0x00000010; | ||
| 656 | |||
| 657 | /// vnode was renamed | ||
| 658 | pub const NOTE_RENAME = 0x00000020; | ||
| 659 | |||
| 660 | /// vnode access was revoked | ||
| 661 | pub const NOTE_REVOKE = 0x00000040; | ||
| 662 | |||
| 663 | /// vnode was opened | ||
| 664 | pub const NOTE_OPEN = 0x00000080; | ||
| 665 | |||
| 666 | /// file closed, fd did not allow write | ||
| 667 | pub const NOTE_CLOSE = 0x00000100; | ||
| 668 | |||
| 669 | /// file closed, fd did allow write | ||
| 670 | pub const NOTE_CLOSE_WRITE = 0x00000200; | ||
| 671 | |||
| 672 | /// file was read | ||
| 673 | pub const NOTE_READ = 0x00000400; | ||
| 674 | |||
| 675 | /// process exited | ||
| 676 | pub const NOTE_EXIT = 0x80000000; | ||
| 677 | |||
| 678 | /// process forked | ||
| 679 | pub const NOTE_FORK = 0x40000000; | ||
| 680 | |||
| 681 | /// process exec'd | ||
| 682 | pub const NOTE_EXEC = 0x20000000; | ||
| 683 | |||
| 684 | /// mask for signal & exit status | ||
| 685 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 686 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | ||
| 687 | |||
| 688 | /// data is seconds | ||
| 689 | pub const NOTE_SECONDS = 0x00000001; | ||
| 690 | |||
| 691 | /// data is milliseconds | ||
| 692 | pub const NOTE_MSECONDS = 0x00000002; | ||
| 693 | |||
| 694 | /// data is microseconds | ||
| 695 | pub const NOTE_USECONDS = 0x00000004; | ||
| 696 | |||
| 697 | /// data is nanoseconds | ||
| 698 | pub const NOTE_NSECONDS = 0x00000008; | ||
| 699 | |||
| 700 | /// timeout is absolute | ||
| 701 | pub const NOTE_ABSTIME = 0x00000010; | ||
| 702 | |||
| 703 | pub const TIOCEXCL = 0x2000740d; | ||
| 704 | pub const TIOCNXCL = 0x2000740e; | ||
| 705 | pub const TIOCSCTTY = 0x20007461; | ||
| 706 | pub const TIOCGPGRP = 0x40047477; | ||
| 707 | pub const TIOCSPGRP = 0x80047476; | ||
| 708 | pub const TIOCOUTQ = 0x40047473; | ||
| 709 | pub const TIOCSTI = 0x80017472; | ||
| 710 | pub const TIOCGWINSZ = 0x40087468; | ||
| 711 | pub const TIOCSWINSZ = 0x80087467; | ||
| 712 | pub const TIOCMGET = 0x4004746a; | ||
| 713 | pub const TIOCMBIS = 0x8004746c; | ||
| 714 | pub const TIOCMBIC = 0x8004746b; | ||
| 715 | pub const TIOCMSET = 0x8004746d; | ||
| 716 | pub const FIONREAD = 0x4004667f; | ||
| 717 | pub const TIOCCONS = 0x80047462; | ||
| 718 | pub const TIOCPKT = 0x80047470; | ||
| 719 | pub const FIONBIO = 0x8004667e; | ||
| 720 | pub const TIOCNOTTY = 0x20007471; | ||
| 721 | pub const TIOCSETD = 0x8004741b; | ||
| 722 | pub const TIOCGETD = 0x4004741a; | ||
| 723 | pub const TIOCSBRK = 0x2000747b; | ||
| 724 | pub const TIOCCBRK = 0x2000747a; | ||
| 725 | pub const TIOCGSID = 0x40047463; | ||
| 726 | pub const TIOCGPTN = 0x4004740f; | ||
| 727 | pub const TIOCSIG = 0x2004745f; | ||
| 728 | |||
| 729 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 730 | return @intCast(u8, (s & 0xff00) >> 8); | ||
| 731 | } | ||
| 732 | pub fn WTERMSIG(s: u32) u32 { | ||
| 733 | return s & 0x7f; | ||
| 734 | } | ||
| 735 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 736 | return WEXITSTATUS(s); | ||
| 737 | } | ||
| 738 | pub fn WIFEXITED(s: u32) bool { | ||
| 739 | return WTERMSIG(s) == 0; | ||
| 740 | } | ||
| 741 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 742 | return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | ||
| 743 | } | ||
| 744 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 745 | return (s & 0xffff) -% 1 < 0xff; | ||
| 746 | } | ||
| 747 | |||
| 748 | pub const winsize = extern struct { | ||
| 749 | ws_row: u16, | ||
| 750 | ws_col: u16, | ||
| 751 | ws_xpixel: u16, | ||
| 752 | ws_ypixel: u16, | ||
| 753 | }; | ||
| 754 | |||
| 755 | const NSIG = 32; | ||
| 756 | |||
| 757 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 758 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 759 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 760 | |||
| 761 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 762 | pub const Sigaction = extern struct { | ||
| 763 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 764 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 765 | |||
| 766 | /// signal handler | ||
| 767 | handler: extern union { | ||
| 768 | handler: ?handler_fn, | ||
| 769 | sigaction: ?sigaction_fn, | ||
| 770 | }, | ||
| 771 | |||
| 772 | /// see signal options | ||
| 773 | flags: c_uint, | ||
| 774 | |||
| 775 | /// signal mask to apply | ||
| 776 | mask: sigset_t, | ||
| 777 | }; | ||
| 778 | |||
| 779 | pub const siginfo_t = extern struct { | ||
| 780 | signo: c_int, | ||
| 781 | errno: c_int, | ||
| 782 | code: c_int, | ||
| 783 | pid: pid_t, | ||
| 784 | uid: uid_t, | ||
| 785 | status: c_int, | ||
| 786 | addr: ?*c_void, | ||
| 787 | value: sigval, | ||
| 788 | reason: extern union { | ||
| 789 | fault: extern struct { | ||
| 790 | trapno: c_int, | ||
| 791 | }, | ||
| 792 | timer: extern struct { | ||
| 793 | timerid: c_int, | ||
| 794 | overrun: c_int, | ||
| 795 | }, | ||
| 796 | mesgq: extern struct { | ||
| 797 | mqd: c_int, | ||
| 798 | }, | ||
| 799 | poll: extern struct { | ||
| 800 | band: c_long, | ||
| 801 | }, | ||
| 802 | spare: extern struct { | ||
| 803 | spare1: c_long, | ||
| 804 | spare2: [7]c_int, | ||
| 805 | }, | ||
| 806 | }, | ||
| 807 | }; | ||
| 808 | |||
| 809 | pub const sigval = extern union { | ||
| 810 | int: c_int, | ||
| 811 | ptr: ?*c_void, | ||
| 812 | }; | ||
| 813 | |||
| 814 | pub const _SIG_WORDS = 4; | ||
| 815 | pub const _SIG_MAXSIG = 128; | ||
| 816 | |||
| 817 | pub inline fn _SIG_IDX(sig: usize) usize { | ||
| 818 | return sig - 1; | ||
| 819 | } | ||
| 820 | pub inline fn _SIG_WORD(sig: usize) usize { | ||
| 821 | return_SIG_IDX(sig) >> 5; | ||
| 822 | } | ||
| 823 | pub inline fn _SIG_BIT(sig: usize) usize { | ||
| 824 | return 1 << (_SIG_IDX(sig) & 31); | ||
| 825 | } | ||
| 826 | pub inline fn _SIG_VALID(sig: usize) usize { | ||
| 827 | return sig <= _SIG_MAXSIG and sig > 0; | ||
| 828 | } | ||
| 829 | |||
| 830 | pub const sigset_t = extern struct { | ||
| 831 | __bits: [_SIG_WORDS]u32, | ||
| 832 | }; | ||
| 833 | |||
| 834 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; | ||
| 835 | |||
| 836 | pub usingnamespace switch (builtin.target.cpu.arch) { | ||
| 837 | .x86_64 => struct { | ||
| 838 | pub const ucontext_t = extern struct { | ||
| 839 | sigmask: sigset_t, | ||
| 840 | mcontext: mcontext_t, | ||
| 841 | link: ?*ucontext_t, | ||
| 842 | stack: stack_t, | ||
| 843 | flags: c_int, | ||
| 844 | __spare__: [4]c_int, | ||
| 845 | }; | ||
| 846 | |||
| 847 | /// XXX x86_64 specific | ||
| 848 | pub const mcontext_t = extern struct { | ||
| 849 | onstack: u64, | ||
| 850 | rdi: u64, | ||
| 851 | rsi: u64, | ||
| 852 | rdx: u64, | ||
| 853 | rcx: u64, | ||
| 854 | r8: u64, | ||
| 855 | r9: u64, | ||
| 856 | rax: u64, | ||
| 857 | rbx: u64, | ||
| 858 | rbp: u64, | ||
| 859 | r10: u64, | ||
| 860 | r11: u64, | ||
| 861 | r12: u64, | ||
| 862 | r13: u64, | ||
| 863 | r14: u64, | ||
| 864 | r15: u64, | ||
| 865 | trapno: u32, | ||
| 866 | fs: u16, | ||
| 867 | gs: u16, | ||
| 868 | addr: u64, | ||
| 869 | flags: u32, | ||
| 870 | es: u16, | ||
| 871 | ds: u16, | ||
| 872 | err: u64, | ||
| 873 | rip: u64, | ||
| 874 | cs: u64, | ||
| 875 | rflags: u64, | ||
| 876 | rsp: u64, | ||
| 877 | ss: u64, | ||
| 878 | }; | ||
| 879 | }, | ||
| 880 | else => struct {}, | ||
| 881 | }; | ||
| 882 | |||
| 883 | pub const E = enum(u16) { | ||
| 884 | /// No error occurred. | ||
| 885 | SUCCESS = 0, | ||
| 886 | |||
| 887 | PERM = 1, // Operation not permitted | ||
| 888 | NOENT = 2, // No such file or directory | ||
| 889 | SRCH = 3, // No such process | ||
| 890 | INTR = 4, // Interrupted system call | ||
| 891 | IO = 5, // Input/output error | ||
| 892 | NXIO = 6, // Device not configured | ||
| 893 | @"2BIG" = 7, // Argument list too long | ||
| 894 | NOEXEC = 8, // Exec format error | ||
| 895 | BADF = 9, // Bad file descriptor | ||
| 896 | CHILD = 10, // No child processes | ||
| 897 | DEADLK = 11, // Resource deadlock avoided | ||
| 898 | // 11 was AGAIN | ||
| 899 | NOMEM = 12, // Cannot allocate memory | ||
| 900 | ACCES = 13, // Permission denied | ||
| 901 | FAULT = 14, // Bad address | ||
| 902 | NOTBLK = 15, // Block device required | ||
| 903 | BUSY = 16, // Device busy | ||
| 904 | EXIST = 17, // File exists | ||
| 905 | XDEV = 18, // Cross-device link | ||
| 906 | NODEV = 19, // Operation not supported by device | ||
| 907 | NOTDIR = 20, // Not a directory | ||
| 908 | ISDIR = 21, // Is a directory | ||
| 909 | INVAL = 22, // Invalid argument | ||
| 910 | NFILE = 23, // Too many open files in system | ||
| 911 | MFILE = 24, // Too many open files | ||
| 912 | NOTTY = 25, // Inappropriate ioctl for device | ||
| 913 | TXTBSY = 26, // Text file busy | ||
| 914 | FBIG = 27, // File too large | ||
| 915 | NOSPC = 28, // No space left on device | ||
| 916 | SPIPE = 29, // Illegal seek | ||
| 917 | ROFS = 30, // Read-only filesystem | ||
| 918 | MLINK = 31, // Too many links | ||
| 919 | PIPE = 32, // Broken pipe | ||
| 920 | |||
| 921 | // math software | ||
| 922 | DOM = 33, // Numerical argument out of domain | ||
| 923 | RANGE = 34, // Result too large | ||
| 924 | |||
| 925 | // non-blocking and interrupt i/o | ||
| 926 | |||
| 927 | /// Resource temporarily unavailable | ||
| 928 | /// This code is also used for `WOULDBLOCK`: operation would block. | ||
| 929 | AGAIN = 35, | ||
| 930 | INPROGRESS = 36, // Operation now in progress | ||
| 931 | ALREADY = 37, // Operation already in progress | ||
| 932 | |||
| 933 | // ipc/network software -- argument errors | ||
| 934 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 935 | DESTADDRREQ = 39, // Destination address required | ||
| 936 | MSGSIZE = 40, // Message too long | ||
| 937 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 938 | NOPROTOOPT = 42, // Protocol not available | ||
| 939 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 940 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 941 | /// Operation not supported | ||
| 942 | /// This code is also used for `NOTSUP`. | ||
| 943 | OPNOTSUPP = 45, | ||
| 944 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 945 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 946 | ADDRINUSE = 48, // Address already in use | ||
| 947 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 948 | |||
| 949 | // ipc/network software -- operational errors | ||
| 950 | NETDOWN = 50, // Network is down | ||
| 951 | NETUNREACH = 51, // Network is unreachable | ||
| 952 | NETRESET = 52, // Network dropped connection on reset | ||
| 953 | CONNABORTED = 53, // Software caused connection abort | ||
| 954 | CONNRESET = 54, // Connection reset by peer | ||
| 955 | NOBUFS = 55, // No buffer space available | ||
| 956 | ISCONN = 56, // Socket is already connected | ||
| 957 | NOTCONN = 57, // Socket is not connected | ||
| 958 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 959 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 960 | TIMEDOUT = 60, // Operation timed out | ||
| 961 | CONNREFUSED = 61, // Connection refused | ||
| 962 | |||
| 963 | LOOP = 62, // Too many levels of symbolic links | ||
| 964 | NAMETOOLONG = 63, // File name too long | ||
| 965 | |||
| 966 | // should be rearranged | ||
| 967 | HOSTDOWN = 64, // Host is down | ||
| 968 | HOSTUNREACH = 65, // No route to host | ||
| 969 | NOTEMPTY = 66, // Directory not empty | ||
| 970 | |||
| 971 | // quotas & mush | ||
| 972 | PROCLIM = 67, // Too many processes | ||
| 973 | USERS = 68, // Too many users | ||
| 974 | DQUOT = 69, // Disc quota exceeded | ||
| 975 | |||
| 976 | // Network File System | ||
| 977 | STALE = 70, // Stale NFS file handle | ||
| 978 | REMOTE = 71, // Too many levels of remote in path | ||
| 979 | BADRPC = 72, // RPC struct is bad | ||
| 980 | RPCMISMATCH = 73, // RPC version wrong | ||
| 981 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 982 | PROGMISMATCH = 75, // Program version wrong | ||
| 983 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 984 | |||
| 985 | NOLCK = 77, // No locks available | ||
| 986 | NOSYS = 78, // Function not implemented | ||
| 987 | |||
| 988 | FTYPE = 79, // Inappropriate file type or format | ||
| 989 | AUTH = 80, // Authentication error | ||
| 990 | NEEDAUTH = 81, // Need authenticator | ||
| 991 | IDRM = 82, // Identifier removed | ||
| 992 | NOMSG = 83, // No message of desired type | ||
| 993 | OVERFLOW = 84, // Value too large to be stored in data type | ||
| 994 | CANCELED = 85, // Operation canceled | ||
| 995 | ILSEQ = 86, // Illegal byte sequence | ||
| 996 | NOATTR = 87, // Attribute not found | ||
| 997 | |||
| 998 | DOOFUS = 88, // Programming error | ||
| 999 | |||
| 1000 | BADMSG = 89, // Bad message | ||
| 1001 | MULTIHOP = 90, // Multihop attempted | ||
| 1002 | NOLINK = 91, // Link has been severed | ||
| 1003 | PROTO = 92, // Protocol error | ||
| 1004 | |||
| 1005 | NOTCAPABLE = 93, // Capabilities insufficient | ||
| 1006 | CAPMODE = 94, // Not permitted in capability mode | ||
| 1007 | NOTRECOVERABLE = 95, // State not recoverable | ||
| 1008 | OWNERDEAD = 96, // Previous owner died | ||
| 1009 | _, | ||
| 1010 | }; | ||
| 1011 | |||
| 1012 | pub const MINSIGSTKSZ = switch (builtin.target.cpu.arch) { | ||
| 1013 | .i386, .x86_64 => 2048, | ||
| 1014 | .arm, .aarch64 => 4096, | ||
| 1015 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), | ||
| 1016 | }; | ||
| 1017 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 1018 | |||
| 1019 | pub const SS_ONSTACK = 1; | ||
| 1020 | pub const SS_DISABLE = 4; | ||
| 1021 | |||
| 1022 | pub const stack_t = extern struct { | ||
| 1023 | ss_sp: [*]u8, | ||
| 1024 | ss_size: isize, | ||
| 1025 | ss_flags: i32, | ||
| 1026 | }; | ||
| 1027 | |||
| 1028 | pub const S_IFMT = 0o170000; | ||
| 1029 | |||
| 1030 | pub const S_IFIFO = 0o010000; | ||
| 1031 | pub const S_IFCHR = 0o020000; | ||
| 1032 | pub const S_IFDIR = 0o040000; | ||
| 1033 | pub const S_IFBLK = 0o060000; | ||
| 1034 | pub const S_IFREG = 0o100000; | ||
| 1035 | pub const S_IFLNK = 0o120000; | ||
| 1036 | pub const S_IFSOCK = 0o140000; | ||
| 1037 | pub const S_IFWHT = 0o160000; | ||
| 1038 | |||
| 1039 | pub const S_ISUID = 0o4000; | ||
| 1040 | pub const S_ISGID = 0o2000; | ||
| 1041 | pub const S_ISVTX = 0o1000; | ||
| 1042 | pub const S_IRWXU = 0o700; | ||
| 1043 | pub const S_IRUSR = 0o400; | ||
| 1044 | pub const S_IWUSR = 0o200; | ||
| 1045 | pub const S_IXUSR = 0o100; | ||
| 1046 | pub const S_IRWXG = 0o070; | ||
| 1047 | pub const S_IRGRP = 0o040; | ||
| 1048 | pub const S_IWGRP = 0o020; | ||
| 1049 | pub const S_IXGRP = 0o010; | ||
| 1050 | pub const S_IRWXO = 0o007; | ||
| 1051 | pub const S_IROTH = 0o004; | ||
| 1052 | pub const S_IWOTH = 0o002; | ||
| 1053 | pub const S_IXOTH = 0o001; | ||
| 1054 | |||
| 1055 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1056 | return m & S_IFMT == S_IFIFO; | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | pub fn S_ISCHR(m: u32) bool { | ||
| 1060 | return m & S_IFMT == S_IFCHR; | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | pub fn S_ISDIR(m: u32) bool { | ||
| 1064 | return m & S_IFMT == S_IFDIR; | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | pub fn S_ISBLK(m: u32) bool { | ||
| 1068 | return m & S_IFMT == S_IFBLK; | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | pub fn S_ISREG(m: u32) bool { | ||
| 1072 | return m & S_IFMT == S_IFREG; | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | pub fn S_ISLNK(m: u32) bool { | ||
| 1076 | return m & S_IFMT == S_IFLNK; | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1080 | return m & S_IFMT == S_IFSOCK; | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | pub fn S_IWHT(m: u32) bool { | ||
| 1084 | return m & S_IFMT == S_IFWHT; | ||
| 1085 | } | ||
| 1086 | |||
| 1087 | pub const HOST_NAME_MAX = 255; | ||
| 1088 | |||
| 1089 | /// Magic value that specify the use of the current working directory | ||
| 1090 | /// to determine the target of relative file paths in the openat() and | ||
| 1091 | /// similar syscalls. | ||
| 1092 | pub const AT_FDCWD = -100; | ||
| 1093 | |||
| 1094 | /// Check access using effective user and group ID | ||
| 1095 | pub const AT_EACCESS = 0x0100; | ||
| 1096 | |||
| 1097 | /// Do not follow symbolic links | ||
| 1098 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | ||
| 1099 | |||
| 1100 | /// Follow symbolic link | ||
| 1101 | pub const AT_SYMLINK_FOLLOW = 0x0400; | ||
| 1102 | |||
| 1103 | /// Remove directory instead of file | ||
| 1104 | pub const AT_REMOVEDIR = 0x0800; | ||
| 1105 | |||
| 1106 | pub const addrinfo = extern struct { | ||
| 1107 | flags: i32, | ||
| 1108 | family: i32, | ||
| 1109 | socktype: i32, | ||
| 1110 | protocol: i32, | ||
| 1111 | addrlen: socklen_t, | ||
| 1112 | canonname: ?[*:0]u8, | ||
| 1113 | addr: ?*sockaddr, | ||
| 1114 | next: ?*addrinfo, | ||
| 1115 | }; | ||
| 1116 | |||
| 1117 | /// Fail if not under dirfd | ||
| 1118 | pub const AT_BENEATH = 0x1000; | ||
| 1119 | |||
| 1120 | /// dummy for IP | ||
| 1121 | pub const IPPROTO_IP = 0; | ||
| 1122 | |||
| 1123 | /// control message protocol | ||
| 1124 | pub const IPPROTO_ICMP = 1; | ||
| 1125 | |||
| 1126 | /// tcp | ||
| 1127 | pub const IPPROTO_TCP = 6; | ||
| 1128 | |||
| 1129 | /// user datagram protocol | ||
| 1130 | pub const IPPROTO_UDP = 17; | ||
| 1131 | |||
| 1132 | /// IP6 header | ||
| 1133 | pub const IPPROTO_IPV6 = 41; | ||
| 1134 | |||
| 1135 | /// raw IP packet | ||
| 1136 | pub const IPPROTO_RAW = 255; | ||
| 1137 | |||
| 1138 | /// IP6 hop-by-hop options | ||
| 1139 | pub const IPPROTO_HOPOPTS = 0; | ||
| 1140 | |||
| 1141 | /// group mgmt protocol | ||
| 1142 | pub const IPPROTO_IGMP = 2; | ||
| 1143 | |||
| 1144 | /// gateway^2 (deprecated) | ||
| 1145 | pub const IPPROTO_GGP = 3; | ||
| 1146 | |||
| 1147 | /// IPv4 encapsulation | ||
| 1148 | pub const IPPROTO_IPV4 = 4; | ||
| 1149 | |||
| 1150 | /// for compatibility | ||
| 1151 | pub const IPPROTO_IPIP = IPPROTO_IPV4; | ||
| 1152 | |||
| 1153 | /// Stream protocol II | ||
| 1154 | pub const IPPROTO_ST = 7; | ||
| 1155 | |||
| 1156 | /// exterior gateway protocol | ||
| 1157 | pub const IPPROTO_EGP = 8; | ||
| 1158 | |||
| 1159 | /// private interior gateway | ||
| 1160 | pub const IPPROTO_PIGP = 9; | ||
| 1161 | |||
| 1162 | /// BBN RCC Monitoring | ||
| 1163 | pub const IPPROTO_RCCMON = 10; | ||
| 1164 | |||
| 1165 | /// network voice protocol | ||
| 1166 | pub const IPPROTO_NVPII = 11; | ||
| 1167 | |||
| 1168 | /// pup | ||
| 1169 | pub const IPPROTO_PUP = 12; | ||
| 1170 | |||
| 1171 | /// Argus | ||
| 1172 | pub const IPPROTO_ARGUS = 13; | ||
| 1173 | |||
| 1174 | /// EMCON | ||
| 1175 | pub const IPPROTO_EMCON = 14; | ||
| 1176 | |||
| 1177 | /// Cross Net Debugger | ||
| 1178 | pub const IPPROTO_XNET = 15; | ||
| 1179 | |||
| 1180 | /// Chaos | ||
| 1181 | pub const IPPROTO_CHAOS = 16; | ||
| 1182 | |||
| 1183 | /// Multiplexing | ||
| 1184 | pub const IPPROTO_MUX = 18; | ||
| 1185 | |||
| 1186 | /// DCN Measurement Subsystems | ||
| 1187 | pub const IPPROTO_MEAS = 19; | ||
| 1188 | |||
| 1189 | /// Host Monitoring | ||
| 1190 | pub const IPPROTO_HMP = 20; | ||
| 1191 | |||
| 1192 | /// Packet Radio Measurement | ||
| 1193 | pub const IPPROTO_PRM = 21; | ||
| 1194 | |||
| 1195 | /// xns idp | ||
| 1196 | pub const IPPROTO_IDP = 22; | ||
| 1197 | |||
| 1198 | /// Trunk-1 | ||
| 1199 | pub const IPPROTO_TRUNK1 = 23; | ||
| 1200 | |||
| 1201 | /// Trunk-2 | ||
| 1202 | pub const IPPROTO_TRUNK2 = 24; | ||
| 1203 | |||
| 1204 | /// Leaf-1 | ||
| 1205 | pub const IPPROTO_LEAF1 = 25; | ||
| 1206 | |||
| 1207 | /// Leaf-2 | ||
| 1208 | pub const IPPROTO_LEAF2 = 26; | ||
| 1209 | |||
| 1210 | /// Reliable Data | ||
| 1211 | pub const IPPROTO_RDP = 27; | ||
| 1212 | |||
| 1213 | /// Reliable Transaction | ||
| 1214 | pub const IPPROTO_IRTP = 28; | ||
| 1215 | |||
| 1216 | /// tp-4 w/ class negotiation | ||
| 1217 | pub const IPPROTO_TP = 29; | ||
| 1218 | |||
| 1219 | /// Bulk Data Transfer | ||
| 1220 | pub const IPPROTO_BLT = 30; | ||
| 1221 | |||
| 1222 | /// Network Services | ||
| 1223 | pub const IPPROTO_NSP = 31; | ||
| 1224 | |||
| 1225 | /// Merit Internodal | ||
| 1226 | pub const IPPROTO_INP = 32; | ||
| 1227 | |||
| 1228 | /// Datagram Congestion Control Protocol | ||
| 1229 | pub const IPPROTO_DCCP = 33; | ||
| 1230 | |||
| 1231 | /// Third Party Connect | ||
| 1232 | pub const IPPROTO_3PC = 34; | ||
| 1233 | |||
| 1234 | /// InterDomain Policy Routing | ||
| 1235 | pub const IPPROTO_IDPR = 35; | ||
| 1236 | |||
| 1237 | /// XTP | ||
| 1238 | pub const IPPROTO_XTP = 36; | ||
| 1239 | |||
| 1240 | /// Datagram Delivery | ||
| 1241 | pub const IPPROTO_DDP = 37; | ||
| 1242 | |||
| 1243 | /// Control Message Transport | ||
| 1244 | pub const IPPROTO_CMTP = 38; | ||
| 1245 | |||
| 1246 | /// TP++ Transport | ||
| 1247 | pub const IPPROTO_TPXX = 39; | ||
| 1248 | |||
| 1249 | /// IL transport protocol | ||
| 1250 | pub const IPPROTO_IL = 40; | ||
| 1251 | |||
| 1252 | /// Source Demand Routing | ||
| 1253 | pub const IPPROTO_SDRP = 42; | ||
| 1254 | |||
| 1255 | /// IP6 routing header | ||
| 1256 | pub const IPPROTO_ROUTING = 43; | ||
| 1257 | |||
| 1258 | /// IP6 fragmentation header | ||
| 1259 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1260 | |||
| 1261 | /// InterDomain Routing | ||
| 1262 | pub const IPPROTO_IDRP = 45; | ||
| 1263 | |||
| 1264 | /// resource reservation | ||
| 1265 | pub const IPPROTO_RSVP = 46; | ||
| 1266 | |||
| 1267 | /// General Routing Encap. | ||
| 1268 | pub const IPPROTO_GRE = 47; | ||
| 1269 | |||
| 1270 | /// Mobile Host Routing | ||
| 1271 | pub const IPPROTO_MHRP = 48; | ||
| 1272 | |||
| 1273 | /// BHA | ||
| 1274 | pub const IPPROTO_BHA = 49; | ||
| 1275 | |||
| 1276 | /// IP6 Encap Sec. Payload | ||
| 1277 | pub const IPPROTO_ESP = 50; | ||
| 1278 | |||
| 1279 | /// IP6 Auth Header | ||
| 1280 | pub const IPPROTO_AH = 51; | ||
| 1281 | |||
| 1282 | /// Integ. Net Layer Security | ||
| 1283 | pub const IPPROTO_INLSP = 52; | ||
| 1284 | |||
| 1285 | /// IP with encryption | ||
| 1286 | pub const IPPROTO_SWIPE = 53; | ||
| 1287 | |||
| 1288 | /// Next Hop Resolution | ||
| 1289 | pub const IPPROTO_NHRP = 54; | ||
| 1290 | |||
| 1291 | /// IP Mobility | ||
| 1292 | pub const IPPROTO_MOBILE = 55; | ||
| 1293 | |||
| 1294 | /// Transport Layer Security | ||
| 1295 | pub const IPPROTO_TLSP = 56; | ||
| 1296 | |||
| 1297 | /// SKIP | ||
| 1298 | pub const IPPROTO_SKIP = 57; | ||
| 1299 | |||
| 1300 | /// ICMP6 | ||
| 1301 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1302 | |||
| 1303 | /// IP6 no next header | ||
| 1304 | pub const IPPROTO_NONE = 59; | ||
| 1305 | |||
| 1306 | /// IP6 destination option | ||
| 1307 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1308 | |||
| 1309 | /// any host internal protocol | ||
| 1310 | pub const IPPROTO_AHIP = 61; | ||
| 1311 | |||
| 1312 | /// CFTP | ||
| 1313 | pub const IPPROTO_CFTP = 62; | ||
| 1314 | |||
| 1315 | /// "hello" routing protocol | ||
| 1316 | pub const IPPROTO_HELLO = 63; | ||
| 1317 | |||
| 1318 | /// SATNET/Backroom EXPAK | ||
| 1319 | pub const IPPROTO_SATEXPAK = 64; | ||
| 1320 | |||
| 1321 | /// Kryptolan | ||
| 1322 | pub const IPPROTO_KRYPTOLAN = 65; | ||
| 1323 | |||
| 1324 | /// Remote Virtual Disk | ||
| 1325 | pub const IPPROTO_RVD = 66; | ||
| 1326 | |||
| 1327 | /// Pluribus Packet Core | ||
| 1328 | pub const IPPROTO_IPPC = 67; | ||
| 1329 | |||
| 1330 | /// Any distributed FS | ||
| 1331 | pub const IPPROTO_ADFS = 68; | ||
| 1332 | |||
| 1333 | /// Satnet Monitoring | ||
| 1334 | pub const IPPROTO_SATMON = 69; | ||
| 1335 | |||
| 1336 | /// VISA Protocol | ||
| 1337 | pub const IPPROTO_VISA = 70; | ||
| 1338 | |||
| 1339 | /// Packet Core Utility | ||
| 1340 | pub const IPPROTO_IPCV = 71; | ||
| 1341 | |||
| 1342 | /// Comp. Prot. Net. Executive | ||
| 1343 | pub const IPPROTO_CPNX = 72; | ||
| 1344 | |||
| 1345 | /// Comp. Prot. HeartBeat | ||
| 1346 | pub const IPPROTO_CPHB = 73; | ||
| 1347 | |||
| 1348 | /// Wang Span Network | ||
| 1349 | pub const IPPROTO_WSN = 74; | ||
| 1350 | |||
| 1351 | /// Packet Video Protocol | ||
| 1352 | pub const IPPROTO_PVP = 75; | ||
| 1353 | |||
| 1354 | /// BackRoom SATNET Monitoring | ||
| 1355 | pub const IPPROTO_BRSATMON = 76; | ||
| 1356 | |||
| 1357 | /// Sun net disk proto (temp.) | ||
| 1358 | pub const IPPROTO_ND = 77; | ||
| 1359 | |||
| 1360 | /// WIDEBAND Monitoring | ||
| 1361 | pub const IPPROTO_WBMON = 78; | ||
| 1362 | |||
| 1363 | /// WIDEBAND EXPAK | ||
| 1364 | pub const IPPROTO_WBEXPAK = 79; | ||
| 1365 | |||
| 1366 | /// ISO cnlp | ||
| 1367 | pub const IPPROTO_EON = 80; | ||
| 1368 | |||
| 1369 | /// VMTP | ||
| 1370 | pub const IPPROTO_VMTP = 81; | ||
| 1371 | |||
| 1372 | /// Secure VMTP | ||
| 1373 | pub const IPPROTO_SVMTP = 82; | ||
| 1374 | |||
| 1375 | /// Banyon VINES | ||
| 1376 | pub const IPPROTO_VINES = 83; | ||
| 1377 | |||
| 1378 | /// TTP | ||
| 1379 | pub const IPPROTO_TTP = 84; | ||
| 1380 | |||
| 1381 | /// NSFNET-IGP | ||
| 1382 | pub const IPPROTO_IGP = 85; | ||
| 1383 | |||
| 1384 | /// dissimilar gateway prot. | ||
| 1385 | pub const IPPROTO_DGP = 86; | ||
| 1386 | |||
| 1387 | /// TCF | ||
| 1388 | pub const IPPROTO_TCF = 87; | ||
| 1389 | |||
| 1390 | /// Cisco/GXS IGRP | ||
| 1391 | pub const IPPROTO_IGRP = 88; | ||
| 1392 | |||
| 1393 | /// OSPFIGP | ||
| 1394 | pub const IPPROTO_OSPFIGP = 89; | ||
| 1395 | |||
| 1396 | /// Strite RPC protocol | ||
| 1397 | pub const IPPROTO_SRPC = 90; | ||
| 1398 | |||
| 1399 | /// Locus Address Resoloution | ||
| 1400 | pub const IPPROTO_LARP = 91; | ||
| 1401 | |||
| 1402 | /// Multicast Transport | ||
| 1403 | pub const IPPROTO_MTP = 92; | ||
| 1404 | |||
| 1405 | /// AX.25 Frames | ||
| 1406 | pub const IPPROTO_AX25 = 93; | ||
| 1407 | |||
| 1408 | /// IP encapsulated in IP | ||
| 1409 | pub const IPPROTO_IPEIP = 94; | ||
| 1410 | |||
| 1411 | /// Mobile Int.ing control | ||
| 1412 | pub const IPPROTO_MICP = 95; | ||
| 1413 | |||
| 1414 | /// Semaphore Comm. security | ||
| 1415 | pub const IPPROTO_SCCSP = 96; | ||
| 1416 | |||
| 1417 | /// Ethernet IP encapsulation | ||
| 1418 | pub const IPPROTO_ETHERIP = 97; | ||
| 1419 | |||
| 1420 | /// encapsulation header | ||
| 1421 | pub const IPPROTO_ENCAP = 98; | ||
| 1422 | |||
| 1423 | /// any private encr. scheme | ||
| 1424 | pub const IPPROTO_APES = 99; | ||
| 1425 | |||
| 1426 | /// GMTP | ||
| 1427 | pub const IPPROTO_GMTP = 100; | ||
| 1428 | |||
| 1429 | /// payload compression (IPComp) | ||
| 1430 | pub const IPPROTO_IPCOMP = 108; | ||
| 1431 | |||
| 1432 | /// SCTP | ||
| 1433 | pub const IPPROTO_SCTP = 132; | ||
| 1434 | |||
| 1435 | /// IPv6 Mobility Header | ||
| 1436 | pub const IPPROTO_MH = 135; | ||
| 1437 | |||
| 1438 | /// UDP-Lite | ||
| 1439 | pub const IPPROTO_UDPLITE = 136; | ||
| 1440 | |||
| 1441 | /// IP6 Host Identity Protocol | ||
| 1442 | pub const IPPROTO_HIP = 139; | ||
| 1443 | |||
| 1444 | /// IP6 Shim6 Protocol | ||
| 1445 | pub const IPPROTO_SHIM6 = 140; | ||
| 1446 | |||
| 1447 | /// Protocol Independent Mcast | ||
| 1448 | pub const IPPROTO_PIM = 103; | ||
| 1449 | |||
| 1450 | /// CARP | ||
| 1451 | pub const IPPROTO_CARP = 112; | ||
| 1452 | |||
| 1453 | /// PGM | ||
| 1454 | pub const IPPROTO_PGM = 113; | ||
| 1455 | |||
| 1456 | /// MPLS-in-IP | ||
| 1457 | pub const IPPROTO_MPLS = 137; | ||
| 1458 | |||
| 1459 | /// PFSYNC | ||
| 1460 | pub const IPPROTO_PFSYNC = 240; | ||
| 1461 | |||
| 1462 | /// Reserved | ||
| 1463 | pub const IPPROTO_RESERVED_253 = 253; | ||
| 1464 | |||
| 1465 | /// Reserved | ||
| 1466 | pub const IPPROTO_RESERVED_254 = 254; | ||
| 1467 | |||
| 1468 | pub const rlimit_resource = enum(c_int) { | ||
| 1469 | CPU = 0, | ||
| 1470 | FSIZE = 1, | ||
| 1471 | DATA = 2, | ||
| 1472 | STACK = 3, | ||
| 1473 | CORE = 4, | ||
| 1474 | RSS = 5, | ||
| 1475 | MEMLOCK = 6, | ||
| 1476 | NPROC = 7, | ||
| 1477 | NOFILE = 8, | ||
| 1478 | SBSIZE = 9, | ||
| 1479 | VMEM = 10, | ||
| 1480 | NPTS = 11, | ||
| 1481 | SWAP = 12, | ||
| 1482 | KQUEUES = 13, | ||
| 1483 | UMTXP = 14, | ||
| 1484 | _, | ||
| 1485 | |||
| 1486 | pub const AS: rlimit_resource = .VMEM; | ||
| 1487 | }; | ||
| 1488 | |||
| 1489 | pub const rlim_t = i64; | ||
| 1490 | |||
| 1491 | /// No limit | ||
| 1492 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1493 | |||
| 1494 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1495 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1496 | |||
| 1497 | pub const rlimit = extern struct { | ||
| 1498 | /// Soft limit | ||
| 1499 | cur: rlim_t, | ||
| 1500 | /// Hard limit | ||
| 1501 | max: rlim_t, | ||
| 1502 | }; | ||
| 1503 | |||
| 1504 | pub const SHUT_RD = 0; | ||
| 1505 | pub const SHUT_WR = 1; | ||
| 1506 | pub const SHUT_RDWR = 2; | ||
| 1507 | |||
| 1508 | pub const nfds_t = u32; | ||
| 1509 | |||
| 1510 | pub const pollfd = extern struct { | ||
| 1511 | fd: fd_t, | ||
| 1512 | events: i16, | ||
| 1513 | revents: i16, | ||
| 1514 | }; | ||
| 1515 | |||
| 1516 | /// any readable data available. | ||
| 1517 | pub const POLLIN = 0x0001; | ||
| 1518 | /// OOB/Urgent readable data. | ||
| 1519 | pub const POLLPRI = 0x0002; | ||
| 1520 | /// file descriptor is writeable. | ||
| 1521 | pub const POLLOUT = 0x0004; | ||
| 1522 | /// non-OOB/URG data available. | ||
| 1523 | pub const POLLRDNORM = 0x0040; | ||
| 1524 | /// no write type differentiation. | ||
| 1525 | pub const POLLWRNORM = POLLOUT; | ||
| 1526 | /// OOB/Urgent readable data. | ||
| 1527 | pub const POLLRDBAND = 0x0080; | ||
| 1528 | /// OOB/Urgent data can be written. | ||
| 1529 | pub const POLLWRBAND = 0x0100; | ||
| 1530 | /// like POLLIN, except ignore EOF. | ||
| 1531 | pub const POLLINIGNEOF = 0x2000; | ||
| 1532 | /// some poll error occurred. | ||
| 1533 | pub const POLLERR = 0x0008; | ||
| 1534 | /// file descriptor was "hung up". | ||
| 1535 | pub const POLLHUP = 0x0010; | ||
| 1536 | /// requested events "invalid". | ||
| 1537 | pub const POLLNVAL = 0x0020; | ||
| 1538 | |||
| 1539 | pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | | ||
| 1540 | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; | ||
lib/std/os/bits/haiku.zig deleted-1373| ... | @@ -1,1373 +0,0 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const maxInt = std.math.maxInt; | ||
| 3 | |||
| 4 | pub const fd_t = c_int; | ||
| 5 | pub const pid_t = c_int; | ||
| 6 | pub const uid_t = u32; | ||
| 7 | pub const gid_t = u32; | ||
| 8 | pub const mode_t = c_uint; | ||
| 9 | |||
| 10 | pub const socklen_t = u32; | ||
| 11 | |||
| 12 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 13 | pub const Kevent = extern struct { | ||
| 14 | ident: usize, | ||
| 15 | filter: i16, | ||
| 16 | flags: u16, | ||
| 17 | fflags: u32, | ||
| 18 | data: i64, | ||
| 19 | udata: usize, | ||
| 20 | // TODO ext | ||
| 21 | }; | ||
| 22 | |||
| 23 | // Modes and flags for dlopen() | ||
| 24 | // include/dlfcn.h | ||
| 25 | |||
| 26 | pub const POLLIN = 0x0001; | ||
| 27 | pub const POLLERR = 0x0004; | ||
| 28 | pub const POLLNVAL = 0x1000; | ||
| 29 | pub const POLLHUP = 0x0080; | ||
| 30 | |||
| 31 | /// Bind function calls lazily. | ||
| 32 | pub const RTLD_LAZY = 1; | ||
| 33 | |||
| 34 | /// Bind function calls immediately. | ||
| 35 | pub const RTLD_NOW = 2; | ||
| 36 | |||
| 37 | pub const RTLD_MODEMASK = 0x3; | ||
| 38 | |||
| 39 | /// Make symbols globally available. | ||
| 40 | pub const RTLD_GLOBAL = 0x100; | ||
| 41 | |||
| 42 | /// Opposite of RTLD_GLOBAL, and the default. | ||
| 43 | pub const RTLD_LOCAL = 0; | ||
| 44 | |||
| 45 | /// Trace loaded objects and exit. | ||
| 46 | pub const RTLD_TRACE = 0x200; | ||
| 47 | |||
| 48 | /// Do not remove members. | ||
| 49 | pub const RTLD_NODELETE = 0x01000; | ||
| 50 | |||
| 51 | /// Do not load if not already loaded. | ||
| 52 | pub const RTLD_NOLOAD = 0x02000; | ||
| 53 | |||
| 54 | pub const dl_phdr_info = extern struct { | ||
| 55 | dlpi_addr: usize, | ||
| 56 | dlpi_name: ?[*:0]const u8, | ||
| 57 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 58 | dlpi_phnum: u16, | ||
| 59 | }; | ||
| 60 | |||
| 61 | pub const Flock = extern struct { | ||
| 62 | l_start: off_t, | ||
| 63 | l_len: off_t, | ||
| 64 | l_pid: pid_t, | ||
| 65 | l_type: i16, | ||
| 66 | l_whence: i16, | ||
| 67 | l_sysid: i32, | ||
| 68 | __unused: [4]u8, | ||
| 69 | }; | ||
| 70 | |||
| 71 | pub const msghdr = extern struct { | ||
| 72 | /// optional address | ||
| 73 | msg_name: ?*sockaddr, | ||
| 74 | |||
| 75 | /// size of address | ||
| 76 | msg_namelen: socklen_t, | ||
| 77 | |||
| 78 | /// scatter/gather array | ||
| 79 | msg_iov: [*]iovec, | ||
| 80 | |||
| 81 | /// # elements in msg_iov | ||
| 82 | msg_iovlen: i32, | ||
| 83 | |||
| 84 | /// ancillary data | ||
| 85 | msg_control: ?*c_void, | ||
| 86 | |||
| 87 | /// ancillary data buffer len | ||
| 88 | msg_controllen: socklen_t, | ||
| 89 | |||
| 90 | /// flags on received message | ||
| 91 | msg_flags: i32, | ||
| 92 | }; | ||
| 93 | |||
| 94 | pub const msghdr_const = extern struct { | ||
| 95 | /// optional address | ||
| 96 | msg_name: ?*const sockaddr, | ||
| 97 | |||
| 98 | /// size of address | ||
| 99 | msg_namelen: socklen_t, | ||
| 100 | |||
| 101 | /// scatter/gather array | ||
| 102 | msg_iov: [*]iovec_const, | ||
| 103 | |||
| 104 | /// # elements in msg_iov | ||
| 105 | msg_iovlen: i32, | ||
| 106 | |||
| 107 | /// ancillary data | ||
| 108 | msg_control: ?*c_void, | ||
| 109 | |||
| 110 | /// ancillary data buffer len | ||
| 111 | msg_controllen: socklen_t, | ||
| 112 | |||
| 113 | /// flags on received message | ||
| 114 | msg_flags: i32, | ||
| 115 | }; | ||
| 116 | |||
| 117 | pub const off_t = i64; | ||
| 118 | pub const ino_t = u64; | ||
| 119 | |||
| 120 | pub const nfds_t = u32; | ||
| 121 | |||
| 122 | pub const pollfd = extern struct { | ||
| 123 | fd: i32, | ||
| 124 | events: i16, | ||
| 125 | revents: i16, | ||
| 126 | }; | ||
| 127 | |||
| 128 | pub const libc_stat = extern struct { | ||
| 129 | dev: i32, | ||
| 130 | ino: u64, | ||
| 131 | mode: u32, | ||
| 132 | nlink: i32, | ||
| 133 | uid: i32, | ||
| 134 | gid: i32, | ||
| 135 | size: i64, | ||
| 136 | rdev: i32, | ||
| 137 | blksize: i32, | ||
| 138 | atim: timespec, | ||
| 139 | mtim: timespec, | ||
| 140 | ctim: timespec, | ||
| 141 | crtim: timespec, | ||
| 142 | st_type: u32, | ||
| 143 | blocks: i64, | ||
| 144 | |||
| 145 | pub fn atime(self: @This()) timespec { | ||
| 146 | return self.atim; | ||
| 147 | } | ||
| 148 | pub fn mtime(self: @This()) timespec { | ||
| 149 | return self.mtim; | ||
| 150 | } | ||
| 151 | pub fn ctime(self: @This()) timespec { | ||
| 152 | return self.ctim; | ||
| 153 | } | ||
| 154 | pub fn crtime(self: @This()) timespec { | ||
| 155 | return self.crtim; | ||
| 156 | } | ||
| 157 | }; | ||
| 158 | |||
| 159 | pub const timespec = extern struct { | ||
| 160 | tv_sec: isize, | ||
| 161 | tv_nsec: isize, | ||
| 162 | }; | ||
| 163 | |||
| 164 | pub const dirent = extern struct { | ||
| 165 | d_dev: i32, | ||
| 166 | d_pdev: i32, | ||
| 167 | d_ino: i64, | ||
| 168 | d_pino: i64, | ||
| 169 | d_reclen: u16, | ||
| 170 | d_name: [256]u8, | ||
| 171 | |||
| 172 | pub fn reclen(self: dirent) u16 { | ||
| 173 | return self.d_reclen; | ||
| 174 | } | ||
| 175 | }; | ||
| 176 | |||
| 177 | pub const image_info = extern struct { | ||
| 178 | id: u32, | ||
| 179 | type: u32, | ||
| 180 | sequence: i32, | ||
| 181 | init_order: i32, | ||
| 182 | init_routine: *c_void, | ||
| 183 | term_routine: *c_void, | ||
| 184 | device: i32, | ||
| 185 | node: i32, | ||
| 186 | name: [1024]u8, | ||
| 187 | text: *c_void, | ||
| 188 | data: *c_void, | ||
| 189 | text_size: i32, | ||
| 190 | data_size: i32, | ||
| 191 | api_version: i32, | ||
| 192 | abi: i32, | ||
| 193 | }; | ||
| 194 | |||
| 195 | pub const system_info = extern struct { | ||
| 196 | boot_time: i64, | ||
| 197 | cpu_count: u32, | ||
| 198 | max_pages: u64, | ||
| 199 | used_pages: u64, | ||
| 200 | cached_pages: u64, | ||
| 201 | block_cache_pages: u64, | ||
| 202 | ignored_pages: u64, | ||
| 203 | needed_memory: u64, | ||
| 204 | free_memory: u64, | ||
| 205 | max_swap_pages: u64, | ||
| 206 | free_swap_pages: u64, | ||
| 207 | page_faults: u32, | ||
| 208 | max_sems: u32, | ||
| 209 | used_sems: u32, | ||
| 210 | max_ports: u32, | ||
| 211 | used_ports: u32, | ||
| 212 | max_threads: u32, | ||
| 213 | used_threads: u32, | ||
| 214 | max_teams: u32, | ||
| 215 | used_teams: u32, | ||
| 216 | kernel_name: [256]u8, | ||
| 217 | kernel_build_date: [32]u8, | ||
| 218 | kernel_build_time: [32]u8, | ||
| 219 | kernel_version: i64, | ||
| 220 | abi: u32, | ||
| 221 | }; | ||
| 222 | |||
| 223 | pub const in_port_t = u16; | ||
| 224 | pub const sa_family_t = u8; | ||
| 225 | |||
| 226 | pub const sockaddr = extern struct { | ||
| 227 | /// total length | ||
| 228 | len: u8, | ||
| 229 | |||
| 230 | /// address family | ||
| 231 | family: sa_family_t, | ||
| 232 | |||
| 233 | /// actually longer; address value | ||
| 234 | data: [14]u8, | ||
| 235 | }; | ||
| 236 | |||
| 237 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 238 | |||
| 239 | pub const sockaddr_in = extern struct { | ||
| 240 | len: u8 = @sizeOf(sockaddr_in), | ||
| 241 | family: sa_family_t = AF_INET, | ||
| 242 | port: in_port_t, | ||
| 243 | addr: u32, | ||
| 244 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 245 | }; | ||
| 246 | |||
| 247 | pub const sockaddr_in6 = extern struct { | ||
| 248 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 249 | family: sa_family_t = AF_INET6, | ||
| 250 | port: in_port_t, | ||
| 251 | flowinfo: u32, | ||
| 252 | addr: [16]u8, | ||
| 253 | scope_id: u32, | ||
| 254 | }; | ||
| 255 | |||
| 256 | pub const sockaddr_un = extern struct { | ||
| 257 | len: u8 = @sizeOf(sockaddr_un), | ||
| 258 | family: sa_family_t = AF_UNIX, | ||
| 259 | path: [104]u8, | ||
| 260 | }; | ||
| 261 | |||
| 262 | pub const CTL_KERN = 1; | ||
| 263 | pub const CTL_DEBUG = 5; | ||
| 264 | |||
| 265 | pub const KERN_PROC = 14; // struct: process entries | ||
| 266 | pub const KERN_PROC_PATHNAME = 12; // path to executable | ||
| 267 | |||
| 268 | pub const PATH_MAX = 1024; | ||
| 269 | |||
| 270 | pub const STDIN_FILENO = 0; | ||
| 271 | pub const STDOUT_FILENO = 1; | ||
| 272 | pub const STDERR_FILENO = 2; | ||
| 273 | |||
| 274 | pub const PROT_NONE = 0; | ||
| 275 | pub const PROT_READ = 1; | ||
| 276 | pub const PROT_WRITE = 2; | ||
| 277 | pub const PROT_EXEC = 4; | ||
| 278 | |||
| 279 | pub const CLOCK_MONOTONIC = 0; | ||
| 280 | pub const CLOCK_REALTIME = -1; | ||
| 281 | pub const CLOCK_PROCESS_CPUTIME_ID = -2; | ||
| 282 | pub const CLOCK_THREAD_CPUTIME_ID = -3; | ||
| 283 | |||
| 284 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 285 | pub const MAP_SHARED = 0x0001; | ||
| 286 | pub const MAP_PRIVATE = 0x0002; | ||
| 287 | pub const MAP_FIXED = 0x0010; | ||
| 288 | pub const MAP_STACK = 0x0400; | ||
| 289 | pub const MAP_NOSYNC = 0x0800; | ||
| 290 | pub const MAP_ANON = 0x1000; | ||
| 291 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 292 | pub const MAP_FILE = 0; | ||
| 293 | |||
| 294 | pub const MAP_GUARD = 0x00002000; | ||
| 295 | pub const MAP_EXCL = 0x00004000; | ||
| 296 | pub const MAP_NOCORE = 0x00020000; | ||
| 297 | pub const MAP_PREFAULT_READ = 0x00040000; | ||
| 298 | pub const MAP_32BIT = 0x00080000; | ||
| 299 | |||
| 300 | pub const WNOHANG = 0x1; | ||
| 301 | pub const WUNTRACED = 0x2; | ||
| 302 | pub const WSTOPPED = 0x10; | ||
| 303 | pub const WCONTINUED = 0x4; | ||
| 304 | pub const WNOWAIT = 0x20; | ||
| 305 | pub const WEXITED = 0x08; | ||
| 306 | |||
| 307 | pub const SA_ONSTACK = 0x20; | ||
| 308 | pub const SA_RESTART = 0x10; | ||
| 309 | pub const SA_RESETHAND = 0x04; | ||
| 310 | pub const SA_NOCLDSTOP = 0x01; | ||
| 311 | pub const SA_NODEFER = 0x08; | ||
| 312 | pub const SA_NOCLDWAIT = 0x02; | ||
| 313 | pub const SA_SIGINFO = 0x40; | ||
| 314 | pub const SA_NOMASK = SA_NODEFER; | ||
| 315 | pub const SA_STACK = SA_ONSTACK; | ||
| 316 | pub const SA_ONESHOT = SA_RESETHAND; | ||
| 317 | |||
| 318 | pub const SIGHUP = 1; | ||
| 319 | pub const SIGINT = 2; | ||
| 320 | pub const SIGQUIT = 3; | ||
| 321 | pub const SIGILL = 4; | ||
| 322 | pub const SIGCHLD = 5; | ||
| 323 | pub const SIGABRT = 6; | ||
| 324 | pub const SIGIOT = SIGABRT; | ||
| 325 | pub const SIGPIPE = 7; | ||
| 326 | pub const SIGFPE = 8; | ||
| 327 | pub const SIGKILL = 9; | ||
| 328 | pub const SIGSTOP = 10; | ||
| 329 | pub const SIGSEGV = 11; | ||
| 330 | pub const SIGCONT = 12; | ||
| 331 | pub const SIGTSTP = 13; | ||
| 332 | pub const SIGALRM = 14; | ||
| 333 | pub const SIGTERM = 15; | ||
| 334 | pub const SIGTTIN = 16; | ||
| 335 | pub const SIGTTOU = 17; | ||
| 336 | pub const SIGUSR1 = 18; | ||
| 337 | pub const SIGUSR2 = 19; | ||
| 338 | pub const SIGWINCH = 20; | ||
| 339 | pub const SIGKILLTHR = 21; | ||
| 340 | pub const SIGTRAP = 22; | ||
| 341 | pub const SIGPOLL = 23; | ||
| 342 | pub const SIGPROF = 24; | ||
| 343 | pub const SIGSYS = 25; | ||
| 344 | pub const SIGURG = 26; | ||
| 345 | pub const SIGVTALRM = 27; | ||
| 346 | pub const SIGXCPU = 28; | ||
| 347 | pub const SIGXFSZ = 29; | ||
| 348 | pub const SIGBUS = 30; | ||
| 349 | pub const SIGRESERVED1 = 31; | ||
| 350 | pub const SIGRESERVED2 = 32; | ||
| 351 | |||
| 352 | // TODO: check | ||
| 353 | pub const SIGRTMIN = 65; | ||
| 354 | pub const SIGRTMAX = 126; | ||
| 355 | |||
| 356 | // access function | ||
| 357 | pub const F_OK = 0; // test for existence of file | ||
| 358 | pub const X_OK = 1; // test for execute or search permission | ||
| 359 | pub const W_OK = 2; // test for write permission | ||
| 360 | pub const R_OK = 4; // test for read permission | ||
| 361 | |||
| 362 | pub const O_RDONLY = 0x0000; | ||
| 363 | pub const O_WRONLY = 0x0001; | ||
| 364 | pub const O_RDWR = 0x0002; | ||
| 365 | pub const O_ACCMODE = 0x0003; | ||
| 366 | |||
| 367 | pub const O_SHLOCK = 0x0010; | ||
| 368 | pub const O_EXLOCK = 0x0020; | ||
| 369 | |||
| 370 | pub const O_CREAT = 0x0200; | ||
| 371 | pub const O_EXCL = 0x0800; | ||
| 372 | pub const O_NOCTTY = 0x8000; | ||
| 373 | pub const O_TRUNC = 0x0400; | ||
| 374 | pub const O_APPEND = 0x0008; | ||
| 375 | pub const O_NONBLOCK = 0x0004; | ||
| 376 | pub const O_DSYNC = 0o10000; | ||
| 377 | pub const O_SYNC = 0x0080; | ||
| 378 | pub const O_RSYNC = 0o4010000; | ||
| 379 | pub const O_DIRECTORY = 0x20000; | ||
| 380 | pub const O_NOFOLLOW = 0x0100; | ||
| 381 | pub const O_CLOEXEC = 0x00100000; | ||
| 382 | |||
| 383 | pub const O_ASYNC = 0x0040; | ||
| 384 | pub const O_DIRECT = 0x00010000; | ||
| 385 | pub const O_NOATIME = 0o1000000; | ||
| 386 | pub const O_PATH = 0o10000000; | ||
| 387 | pub const O_TMPFILE = 0o20200000; | ||
| 388 | pub const O_NDELAY = O_NONBLOCK; | ||
| 389 | |||
| 390 | pub const F_DUPFD = 0; | ||
| 391 | pub const F_GETFD = 1; | ||
| 392 | pub const F_SETFD = 2; | ||
| 393 | pub const F_GETFL = 3; | ||
| 394 | pub const F_SETFL = 4; | ||
| 395 | |||
| 396 | pub const F_GETOWN = 5; | ||
| 397 | pub const F_SETOWN = 6; | ||
| 398 | |||
| 399 | pub const F_GETLK = 11; | ||
| 400 | pub const F_SETLK = 12; | ||
| 401 | pub const F_SETLKW = 13; | ||
| 402 | |||
| 403 | pub const F_RDLCK = 1; | ||
| 404 | pub const F_WRLCK = 3; | ||
| 405 | pub const F_UNLCK = 2; | ||
| 406 | |||
| 407 | pub const LOCK_SH = 1; | ||
| 408 | pub const LOCK_EX = 2; | ||
| 409 | pub const LOCK_UN = 8; | ||
| 410 | pub const LOCK_NB = 4; | ||
| 411 | |||
| 412 | pub const F_SETOWN_EX = 15; | ||
| 413 | pub const F_GETOWN_EX = 16; | ||
| 414 | |||
| 415 | pub const F_GETOWNER_UIDS = 17; | ||
| 416 | |||
| 417 | pub const FD_CLOEXEC = 1; | ||
| 418 | |||
| 419 | pub const SEEK_SET = 0; | ||
| 420 | pub const SEEK_CUR = 1; | ||
| 421 | pub const SEEK_END = 2; | ||
| 422 | |||
| 423 | pub const SIG_BLOCK = 1; | ||
| 424 | pub const SIG_UNBLOCK = 2; | ||
| 425 | pub const SIG_SETMASK = 3; | ||
| 426 | |||
| 427 | pub const SOCK_STREAM = 1; | ||
| 428 | pub const SOCK_DGRAM = 2; | ||
| 429 | pub const SOCK_RAW = 3; | ||
| 430 | pub const SOCK_RDM = 4; | ||
| 431 | pub const SOCK_SEQPACKET = 5; | ||
| 432 | |||
| 433 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 434 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 435 | |||
| 436 | pub const SO_DEBUG = 0x00000001; | ||
| 437 | pub const SO_ACCEPTCONN = 0x00000002; | ||
| 438 | pub const SO_REUSEADDR = 0x00000004; | ||
| 439 | pub const SO_KEEPALIVE = 0x00000008; | ||
| 440 | pub const SO_DONTROUTE = 0x00000010; | ||
| 441 | pub const SO_BROADCAST = 0x00000020; | ||
| 442 | pub const SO_USELOOPBACK = 0x00000040; | ||
| 443 | pub const SO_LINGER = 0x00000080; | ||
| 444 | pub const SO_OOBINLINE = 0x00000100; | ||
| 445 | pub const SO_REUSEPORT = 0x00000200; | ||
| 446 | pub const SO_TIMESTAMP = 0x00000400; | ||
| 447 | pub const SO_NOSIGPIPE = 0x00000800; | ||
| 448 | pub const SO_ACCEPTFILTER = 0x00001000; | ||
| 449 | pub const SO_BINTIME = 0x00002000; | ||
| 450 | pub const SO_NO_OFFLOAD = 0x00004000; | ||
| 451 | pub const SO_NO_DDP = 0x00008000; | ||
| 452 | pub const SO_REUSEPORT_LB = 0x00010000; | ||
| 453 | |||
| 454 | pub const SO_SNDBUF = 0x1001; | ||
| 455 | pub const SO_RCVBUF = 0x1002; | ||
| 456 | pub const SO_SNDLOWAT = 0x1003; | ||
| 457 | pub const SO_RCVLOWAT = 0x1004; | ||
| 458 | pub const SO_SNDTIMEO = 0x1005; | ||
| 459 | pub const SO_RCVTIMEO = 0x1006; | ||
| 460 | pub const SO_ERROR = 0x1007; | ||
| 461 | pub const SO_TYPE = 0x1008; | ||
| 462 | pub const SO_LABEL = 0x1009; | ||
| 463 | pub const SO_PEERLABEL = 0x1010; | ||
| 464 | pub const SO_LISTENQLIMIT = 0x1011; | ||
| 465 | pub const SO_LISTENQLEN = 0x1012; | ||
| 466 | pub const SO_LISTENINCQLEN = 0x1013; | ||
| 467 | pub const SO_SETFIB = 0x1014; | ||
| 468 | pub const SO_USER_COOKIE = 0x1015; | ||
| 469 | pub const SO_PROTOCOL = 0x1016; | ||
| 470 | pub const SO_PROTOTYPE = SO_PROTOCOL; | ||
| 471 | pub const SO_TS_CLOCK = 0x1017; | ||
| 472 | pub const SO_MAX_PACING_RATE = 0x1018; | ||
| 473 | pub const SO_DOMAIN = 0x1019; | ||
| 474 | |||
| 475 | pub const SOL_SOCKET = 0xffff; | ||
| 476 | |||
| 477 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 478 | pub const PF_LOCAL = AF_LOCAL; | ||
| 479 | pub const PF_UNIX = PF_LOCAL; | ||
| 480 | pub const PF_INET = AF_INET; | ||
| 481 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 482 | pub const PF_PUP = AF_PUP; | ||
| 483 | pub const PF_CHAOS = AF_CHAOS; | ||
| 484 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 485 | pub const PF_ISO = AF_ISO; | ||
| 486 | pub const PF_OSI = AF_ISO; | ||
| 487 | pub const PF_ECMA = AF_ECMA; | ||
| 488 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 489 | pub const PF_CCITT = AF_CCITT; | ||
| 490 | pub const PF_DECnet = AF_DECnet; | ||
| 491 | pub const PF_DLI = AF_DLI; | ||
| 492 | pub const PF_LAT = AF_LAT; | ||
| 493 | pub const PF_HYLINK = AF_HYLINK; | ||
| 494 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 495 | pub const PF_ROUTE = AF_ROUTE; | ||
| 496 | pub const PF_LINK = AF_LINK; | ||
| 497 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 498 | pub const PF_COIP = AF_COIP; | ||
| 499 | pub const PF_CNT = AF_CNT; | ||
| 500 | pub const PF_SIP = AF_SIP; | ||
| 501 | pub const PF_IPX = AF_IPX; | ||
| 502 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 503 | pub const PF_PIP = psuedo_AF_PIP; | ||
| 504 | pub const PF_ISDN = AF_ISDN; | ||
| 505 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 506 | pub const PF_INET6 = pseudo_AF_INET6; | ||
| 507 | pub const PF_NATM = AF_NATM; | ||
| 508 | pub const PF_ATM = AF_ATM; | ||
| 509 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 510 | pub const PF_SLOW = AF_SLOW; | ||
| 511 | pub const PF_SCLUSTER = AF_SCLUSTER; | ||
| 512 | pub const PF_ARP = AF_ARP; | ||
| 513 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 514 | pub const PF_IEEE80211 = AF_IEEE80211; | ||
| 515 | pub const PF_INET_SDP = AF_INET_SDP; | ||
| 516 | pub const PF_INET6_SDP = AF_INET6_SDP; | ||
| 517 | pub const PF_MAX = AF_MAX; | ||
| 518 | |||
| 519 | pub const AF_UNSPEC = 0; | ||
| 520 | pub const AF_UNIX = 1; | ||
| 521 | pub const AF_LOCAL = AF_UNIX; | ||
| 522 | pub const AF_FILE = AF_LOCAL; | ||
| 523 | pub const AF_INET = 2; | ||
| 524 | pub const AF_IMPLINK = 3; | ||
| 525 | pub const AF_PUP = 4; | ||
| 526 | pub const AF_CHAOS = 5; | ||
| 527 | pub const AF_NETBIOS = 6; | ||
| 528 | pub const AF_ISO = 7; | ||
| 529 | pub const AF_OSI = AF_ISO; | ||
| 530 | pub const AF_ECMA = 8; | ||
| 531 | pub const AF_DATAKIT = 9; | ||
| 532 | pub const AF_CCITT = 10; | ||
| 533 | pub const AF_SNA = 11; | ||
| 534 | pub const AF_DECnet = 12; | ||
| 535 | pub const AF_DLI = 13; | ||
| 536 | pub const AF_LAT = 14; | ||
| 537 | pub const AF_HYLINK = 15; | ||
| 538 | pub const AF_APPLETALK = 16; | ||
| 539 | pub const AF_ROUTE = 17; | ||
| 540 | pub const AF_LINK = 18; | ||
| 541 | pub const pseudo_AF_XTP = 19; | ||
| 542 | pub const AF_COIP = 20; | ||
| 543 | pub const AF_CNT = 21; | ||
| 544 | pub const pseudo_AF_RTIP = 22; | ||
| 545 | pub const AF_IPX = 23; | ||
| 546 | pub const AF_SIP = 24; | ||
| 547 | pub const pseudo_AF_PIP = 25; | ||
| 548 | pub const AF_ISDN = 26; | ||
| 549 | pub const AF_E164 = AF_ISDN; | ||
| 550 | pub const pseudo_AF_KEY = 27; | ||
| 551 | pub const AF_INET6 = 28; | ||
| 552 | pub const AF_NATM = 29; | ||
| 553 | pub const AF_ATM = 30; | ||
| 554 | pub const pseudo_AF_HDRCMPLT = 31; | ||
| 555 | pub const AF_NETGRAPH = 32; | ||
| 556 | pub const AF_SLOW = 33; | ||
| 557 | pub const AF_SCLUSTER = 34; | ||
| 558 | pub const AF_ARP = 35; | ||
| 559 | pub const AF_BLUETOOTH = 36; | ||
| 560 | pub const AF_IEEE80211 = 37; | ||
| 561 | pub const AF_INET_SDP = 40; | ||
| 562 | pub const AF_INET6_SDP = 42; | ||
| 563 | pub const AF_MAX = 42; | ||
| 564 | |||
| 565 | pub const DT_UNKNOWN = 0; | ||
| 566 | pub const DT_FIFO = 1; | ||
| 567 | pub const DT_CHR = 2; | ||
| 568 | pub const DT_DIR = 4; | ||
| 569 | pub const DT_BLK = 6; | ||
| 570 | pub const DT_REG = 8; | ||
| 571 | pub const DT_LNK = 10; | ||
| 572 | pub const DT_SOCK = 12; | ||
| 573 | pub const DT_WHT = 14; | ||
| 574 | |||
| 575 | /// add event to kq (implies enable) | ||
| 576 | pub const EV_ADD = 0x0001; | ||
| 577 | |||
| 578 | /// delete event from kq | ||
| 579 | pub const EV_DELETE = 0x0002; | ||
| 580 | |||
| 581 | /// enable event | ||
| 582 | pub const EV_ENABLE = 0x0004; | ||
| 583 | |||
| 584 | /// disable event (not reported) | ||
| 585 | pub const EV_DISABLE = 0x0008; | ||
| 586 | |||
| 587 | /// only report one occurrence | ||
| 588 | pub const EV_ONESHOT = 0x0010; | ||
| 589 | |||
| 590 | /// clear event state after reporting | ||
| 591 | pub const EV_CLEAR = 0x0020; | ||
| 592 | |||
| 593 | /// force immediate event output | ||
| 594 | /// ... with or without EV_ERROR | ||
| 595 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 596 | /// on syscalls supporting flags | ||
| 597 | pub const EV_RECEIPT = 0x0040; | ||
| 598 | |||
| 599 | /// disable event after reporting | ||
| 600 | pub const EV_DISPATCH = 0x0080; | ||
| 601 | |||
| 602 | pub const EVFILT_READ = -1; | ||
| 603 | pub const EVFILT_WRITE = -2; | ||
| 604 | |||
| 605 | /// attached to aio requests | ||
| 606 | pub const EVFILT_AIO = -3; | ||
| 607 | |||
| 608 | /// attached to vnodes | ||
| 609 | pub const EVFILT_VNODE = -4; | ||
| 610 | |||
| 611 | /// attached to struct proc | ||
| 612 | pub const EVFILT_PROC = -5; | ||
| 613 | |||
| 614 | /// attached to struct proc | ||
| 615 | pub const EVFILT_SIGNAL = -6; | ||
| 616 | |||
| 617 | /// timers | ||
| 618 | pub const EVFILT_TIMER = -7; | ||
| 619 | |||
| 620 | /// Process descriptors | ||
| 621 | pub const EVFILT_PROCDESC = -8; | ||
| 622 | |||
| 623 | /// Filesystem events | ||
| 624 | pub const EVFILT_FS = -9; | ||
| 625 | |||
| 626 | pub const EVFILT_LIO = -10; | ||
| 627 | |||
| 628 | /// User events | ||
| 629 | pub const EVFILT_USER = -11; | ||
| 630 | |||
| 631 | /// Sendfile events | ||
| 632 | pub const EVFILT_SENDFILE = -12; | ||
| 633 | |||
| 634 | pub const EVFILT_EMPTY = -13; | ||
| 635 | |||
| 636 | pub const TCGETA = 0x8000; | ||
| 637 | pub const TCSETA = 0x8001; | ||
| 638 | pub const TCSETAW = 0x8004; | ||
| 639 | pub const TCSETAF = 0x8003; | ||
| 640 | pub const TCSBRK = 08005; | ||
| 641 | pub const TCXONC = 0x8007; | ||
| 642 | pub const TCFLSH = 0x8006; | ||
| 643 | |||
| 644 | pub const TIOCSCTTY = 0x8017; | ||
| 645 | pub const TIOCGPGRP = 0x8015; | ||
| 646 | pub const TIOCSPGRP = 0x8016; | ||
| 647 | pub const TIOCGWINSZ = 0x8012; | ||
| 648 | pub const TIOCSWINSZ = 0x8013; | ||
| 649 | pub const TIOCMGET = 0x8018; | ||
| 650 | pub const TIOCMBIS = 0x8022; | ||
| 651 | pub const TIOCMBIC = 0x8023; | ||
| 652 | pub const TIOCMSET = 0x8019; | ||
| 653 | pub const FIONREAD = 0xbe000001; | ||
| 654 | pub const FIONBIO = 0xbe000000; | ||
| 655 | pub const TIOCSBRK = 0x8020; | ||
| 656 | pub const TIOCCBRK = 0x8021; | ||
| 657 | pub const TIOCGSID = 0x8024; | ||
| 658 | |||
| 659 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 660 | return @intCast(u8, s & 0xff); | ||
| 661 | } | ||
| 662 | |||
| 663 | pub fn WTERMSIG(s: u32) u32 { | ||
| 664 | return (s >> 8) & 0xff; | ||
| 665 | } | ||
| 666 | |||
| 667 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 668 | return WEXITSTATUS(s); | ||
| 669 | } | ||
| 670 | |||
| 671 | pub fn WIFEXITED(s: u32) bool { | ||
| 672 | return WTERMSIG(s) == 0; | ||
| 673 | } | ||
| 674 | |||
| 675 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 676 | return ((s >> 16) & 0xff) != 0; | ||
| 677 | } | ||
| 678 | |||
| 679 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 680 | return ((s >> 8) & 0xff) != 0; | ||
| 681 | } | ||
| 682 | |||
| 683 | pub const winsize = extern struct { | ||
| 684 | ws_row: u16, | ||
| 685 | ws_col: u16, | ||
| 686 | ws_xpixel: u16, | ||
| 687 | ws_ypixel: u16, | ||
| 688 | }; | ||
| 689 | |||
| 690 | const NSIG = 32; | ||
| 691 | |||
| 692 | pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); | ||
| 693 | pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); | ||
| 694 | pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); | ||
| 695 | |||
| 696 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 697 | pub const Sigaction = extern struct { | ||
| 698 | /// signal handler | ||
| 699 | __sigaction_u: extern union { | ||
| 700 | __sa_handler: fn (i32) callconv(.C) void, | ||
| 701 | __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void, | ||
| 702 | }, | ||
| 703 | |||
| 704 | /// see signal options | ||
| 705 | sa_flags: u32, | ||
| 706 | |||
| 707 | /// signal mask to apply | ||
| 708 | sa_mask: sigset_t, | ||
| 709 | }; | ||
| 710 | |||
| 711 | pub const _SIG_WORDS = 4; | ||
| 712 | pub const _SIG_MAXSIG = 128; | ||
| 713 | pub inline fn _SIG_IDX(sig: usize) usize { | ||
| 714 | return sig - 1; | ||
| 715 | } | ||
| 716 | pub inline fn _SIG_WORD(sig: usize) usize { | ||
| 717 | return_SIG_IDX(sig) >> 5; | ||
| 718 | } | ||
| 719 | pub inline fn _SIG_BIT(sig: usize) usize { | ||
| 720 | return 1 << (_SIG_IDX(sig) & 31); | ||
| 721 | } | ||
| 722 | pub inline fn _SIG_VALID(sig: usize) usize { | ||
| 723 | return sig <= _SIG_MAXSIG and sig > 0; | ||
| 724 | } | ||
| 725 | |||
| 726 | pub const sigset_t = extern struct { | ||
| 727 | __bits: [_SIG_WORDS]u32, | ||
| 728 | }; | ||
| 729 | |||
| 730 | pub const E = enum(i32) { | ||
| 731 | /// No error occurred. | ||
| 732 | SUCCESS = 0, | ||
| 733 | PERM = -0x7ffffff1, // Operation not permitted | ||
| 734 | NOENT = -0x7fff9ffd, // No such file or directory | ||
| 735 | SRCH = -0x7fff8ff3, // No such process | ||
| 736 | INTR = -0x7ffffff6, // Interrupted system call | ||
| 737 | IO = -0x7fffffff, // Input/output error | ||
| 738 | NXIO = -0x7fff8ff5, // Device not configured | ||
| 739 | @"2BIG" = -0x7fff8fff, // Argument list too long | ||
| 740 | NOEXEC = -0x7fffecfe, // Exec format error | ||
| 741 | CHILD = -0x7fff8ffe, // No child processes | ||
| 742 | DEADLK = -0x7fff8ffd, // Resource deadlock avoided | ||
| 743 | NOMEM = -0x80000000, // Cannot allocate memory | ||
| 744 | ACCES = -0x7ffffffe, // Permission denied | ||
| 745 | FAULT = -0x7fffecff, // Bad address | ||
| 746 | BUSY = -0x7ffffff2, // Device busy | ||
| 747 | EXIST = -0x7fff9ffe, // File exists | ||
| 748 | XDEV = -0x7fff9ff5, // Cross-device link | ||
| 749 | NODEV = -0x7fff8ff9, // Operation not supported by device | ||
| 750 | NOTDIR = -0x7fff9ffb, // Not a directory | ||
| 751 | ISDIR = -0x7fff9ff7, // Is a directory | ||
| 752 | INVAL = -0x7ffffffb, // Invalid argument | ||
| 753 | NFILE = -0x7fff8ffa, // Too many open files in system | ||
| 754 | MFILE = -0x7fff9ff6, // Too many open files | ||
| 755 | NOTTY = -0x7fff8ff6, // Inappropriate ioctl for device | ||
| 756 | TXTBSY = -0x7fff8fc5, // Text file busy | ||
| 757 | FBIG = -0x7fff8ffc, // File too large | ||
| 758 | NOSPC = -0x7fff9ff9, // No space left on device | ||
| 759 | SPIPE = -0x7fff8ff4, // Illegal seek | ||
| 760 | ROFS = -0x7fff9ff8, // Read-only filesystem | ||
| 761 | MLINK = -0x7fff8ffb, // Too many links | ||
| 762 | PIPE = -0x7fff9ff3, // Broken pipe | ||
| 763 | BADF = -0x7fffa000, // Bad file descriptor | ||
| 764 | |||
| 765 | // math software | ||
| 766 | DOM = 33, // Numerical argument out of domain | ||
| 767 | RANGE = 34, // Result too large | ||
| 768 | |||
| 769 | // non-blocking and interrupt i/o | ||
| 770 | |||
| 771 | /// Also used for `WOULDBLOCK`. | ||
| 772 | AGAIN = -0x7ffffff5, | ||
| 773 | INPROGRESS = -0x7fff8fdc, | ||
| 774 | ALREADY = -0x7fff8fdb, | ||
| 775 | |||
| 776 | // ipc/network software -- argument errors | ||
| 777 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 778 | DESTADDRREQ = 39, // Destination address required | ||
| 779 | MSGSIZE = 40, // Message too long | ||
| 780 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 781 | NOPROTOOPT = 42, // Protocol not available | ||
| 782 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 783 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 784 | /// Also used for `NOTSUP`. | ||
| 785 | OPNOTSUPP = 45, // Operation not supported | ||
| 786 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 787 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 788 | ADDRINUSE = 48, // Address already in use | ||
| 789 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 790 | |||
| 791 | // ipc/network software -- operational errors | ||
| 792 | NETDOWN = 50, // Network is down | ||
| 793 | NETUNREACH = 51, // Network is unreachable | ||
| 794 | NETRESET = 52, // Network dropped connection on reset | ||
| 795 | CONNABORTED = 53, // Software caused connection abort | ||
| 796 | CONNRESET = 54, // Connection reset by peer | ||
| 797 | NOBUFS = 55, // No buffer space available | ||
| 798 | ISCONN = 56, // Socket is already connected | ||
| 799 | NOTCONN = 57, // Socket is not connected | ||
| 800 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 801 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 802 | TIMEDOUT = 60, // Operation timed out | ||
| 803 | CONNREFUSED = 61, // Connection refused | ||
| 804 | |||
| 805 | LOOP = 62, // Too many levels of symbolic links | ||
| 806 | NAMETOOLONG = 63, // File name too long | ||
| 807 | |||
| 808 | // should be rearranged | ||
| 809 | HOSTDOWN = 64, // Host is down | ||
| 810 | HOSTUNREACH = 65, // No route to host | ||
| 811 | NOTEMPTY = 66, // Directory not empty | ||
| 812 | |||
| 813 | // quotas & mush | ||
| 814 | PROCLIM = 67, // Too many processes | ||
| 815 | USERS = 68, // Too many users | ||
| 816 | DQUOT = 69, // Disc quota exceeded | ||
| 817 | |||
| 818 | // Network File System | ||
| 819 | STALE = 70, // Stale NFS file handle | ||
| 820 | REMOTE = 71, // Too many levels of remote in path | ||
| 821 | BADRPC = 72, // RPC struct is bad | ||
| 822 | RPCMISMATCH = 73, // RPC version wrong | ||
| 823 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 824 | PROGMISMATCH = 75, // Program version wrong | ||
| 825 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 826 | |||
| 827 | NOLCK = 77, // No locks available | ||
| 828 | NOSYS = 78, // Function not implemented | ||
| 829 | |||
| 830 | FTYPE = 79, // Inappropriate file type or format | ||
| 831 | AUTH = 80, // Authentication error | ||
| 832 | NEEDAUTH = 81, // Need authenticator | ||
| 833 | IDRM = 82, // Identifier removed | ||
| 834 | NOMSG = 83, // No message of desired type | ||
| 835 | OVERFLOW = 84, // Value too large to be stored in data type | ||
| 836 | CANCELED = 85, // Operation canceled | ||
| 837 | ILSEQ = 86, // Illegal byte sequence | ||
| 838 | NOATTR = 87, // Attribute not found | ||
| 839 | |||
| 840 | DOOFUS = 88, // Programming error | ||
| 841 | |||
| 842 | BADMSG = 89, // Bad message | ||
| 843 | MULTIHOP = 90, // Multihop attempted | ||
| 844 | NOLINK = 91, // Link has been severed | ||
| 845 | PROTO = 92, // Protocol error | ||
| 846 | |||
| 847 | NOTCAPABLE = 93, // Capabilities insufficient | ||
| 848 | CAPMODE = 94, // Not permitted in capability mode | ||
| 849 | NOTRECOVERABLE = 95, // State not recoverable | ||
| 850 | OWNERDEAD = 96, // Previous owner died | ||
| 851 | |||
| 852 | _, | ||
| 853 | }; | ||
| 854 | |||
| 855 | pub const MINSIGSTKSZ = switch (builtin.cpu.arch) { | ||
| 856 | .i386, .x86_64 => 2048, | ||
| 857 | .arm, .aarch64 => 4096, | ||
| 858 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), | ||
| 859 | }; | ||
| 860 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 861 | |||
| 862 | pub const SS_ONSTACK = 1; | ||
| 863 | pub const SS_DISABLE = 4; | ||
| 864 | |||
| 865 | pub const stack_t = extern struct { | ||
| 866 | ss_sp: [*]u8, | ||
| 867 | ss_size: isize, | ||
| 868 | ss_flags: i32, | ||
| 869 | }; | ||
| 870 | |||
| 871 | pub const S_IFMT = 0o170000; | ||
| 872 | |||
| 873 | pub const S_IFIFO = 0o010000; | ||
| 874 | pub const S_IFCHR = 0o020000; | ||
| 875 | pub const S_IFDIR = 0o040000; | ||
| 876 | pub const S_IFBLK = 0o060000; | ||
| 877 | pub const S_IFREG = 0o100000; | ||
| 878 | pub const S_IFLNK = 0o120000; | ||
| 879 | pub const S_IFSOCK = 0o140000; | ||
| 880 | pub const S_IFWHT = 0o160000; | ||
| 881 | |||
| 882 | pub const S_ISUID = 0o4000; | ||
| 883 | pub const S_ISGID = 0o2000; | ||
| 884 | pub const S_ISVTX = 0o1000; | ||
| 885 | pub const S_IRWXU = 0o700; | ||
| 886 | pub const S_IRUSR = 0o400; | ||
| 887 | pub const S_IWUSR = 0o200; | ||
| 888 | pub const S_IXUSR = 0o100; | ||
| 889 | pub const S_IRWXG = 0o070; | ||
| 890 | pub const S_IRGRP = 0o040; | ||
| 891 | pub const S_IWGRP = 0o020; | ||
| 892 | pub const S_IXGRP = 0o010; | ||
| 893 | pub const S_IRWXO = 0o007; | ||
| 894 | pub const S_IROTH = 0o004; | ||
| 895 | pub const S_IWOTH = 0o002; | ||
| 896 | pub const S_IXOTH = 0o001; | ||
| 897 | |||
| 898 | pub fn S_ISFIFO(m: u32) bool { | ||
| 899 | return m & S_IFMT == S_IFIFO; | ||
| 900 | } | ||
| 901 | |||
| 902 | pub fn S_ISCHR(m: u32) bool { | ||
| 903 | return m & S_IFMT == S_IFCHR; | ||
| 904 | } | ||
| 905 | |||
| 906 | pub fn S_ISDIR(m: u32) bool { | ||
| 907 | return m & S_IFMT == S_IFDIR; | ||
| 908 | } | ||
| 909 | |||
| 910 | pub fn S_ISBLK(m: u32) bool { | ||
| 911 | return m & S_IFMT == S_IFBLK; | ||
| 912 | } | ||
| 913 | |||
| 914 | pub fn S_ISREG(m: u32) bool { | ||
| 915 | return m & S_IFMT == S_IFREG; | ||
| 916 | } | ||
| 917 | |||
| 918 | pub fn S_ISLNK(m: u32) bool { | ||
| 919 | return m & S_IFMT == S_IFLNK; | ||
| 920 | } | ||
| 921 | |||
| 922 | pub fn S_ISSOCK(m: u32) bool { | ||
| 923 | return m & S_IFMT == S_IFSOCK; | ||
| 924 | } | ||
| 925 | |||
| 926 | pub fn S_IWHT(m: u32) bool { | ||
| 927 | return m & S_IFMT == S_IFWHT; | ||
| 928 | } | ||
| 929 | |||
| 930 | pub const HOST_NAME_MAX = 255; | ||
| 931 | |||
| 932 | /// Magic value that specify the use of the current working directory | ||
| 933 | /// to determine the target of relative file paths in the openat() and | ||
| 934 | /// similar syscalls. | ||
| 935 | pub const AT_FDCWD = -100; | ||
| 936 | |||
| 937 | /// Check access using effective user and group ID | ||
| 938 | pub const AT_EACCESS = 0x0100; | ||
| 939 | |||
| 940 | /// Do not follow symbolic links | ||
| 941 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | ||
| 942 | |||
| 943 | /// Follow symbolic link | ||
| 944 | pub const AT_SYMLINK_FOLLOW = 0x0400; | ||
| 945 | |||
| 946 | /// Remove directory instead of file | ||
| 947 | pub const AT_REMOVEDIR = 0x0800; | ||
| 948 | |||
| 949 | pub const addrinfo = extern struct { | ||
| 950 | flags: i32, | ||
| 951 | family: i32, | ||
| 952 | socktype: i32, | ||
| 953 | protocol: i32, | ||
| 954 | addrlen: socklen_t, | ||
| 955 | canonname: ?[*:0]u8, | ||
| 956 | addr: ?*sockaddr, | ||
| 957 | next: ?*addrinfo, | ||
| 958 | }; | ||
| 959 | |||
| 960 | /// Fail if not under dirfd | ||
| 961 | pub const AT_BENEATH = 0x1000; | ||
| 962 | |||
| 963 | /// dummy for IP | ||
| 964 | pub const IPPROTO_IP = 0; | ||
| 965 | |||
| 966 | /// control message protocol | ||
| 967 | pub const IPPROTO_ICMP = 1; | ||
| 968 | |||
| 969 | /// tcp | ||
| 970 | pub const IPPROTO_TCP = 6; | ||
| 971 | |||
| 972 | /// user datagram protocol | ||
| 973 | pub const IPPROTO_UDP = 17; | ||
| 974 | |||
| 975 | /// IP6 header | ||
| 976 | pub const IPPROTO_IPV6 = 41; | ||
| 977 | |||
| 978 | /// raw IP packet | ||
| 979 | pub const IPPROTO_RAW = 255; | ||
| 980 | |||
| 981 | /// IP6 hop-by-hop options | ||
| 982 | pub const IPPROTO_HOPOPTS = 0; | ||
| 983 | |||
| 984 | /// group mgmt protocol | ||
| 985 | pub const IPPROTO_IGMP = 2; | ||
| 986 | |||
| 987 | /// gateway^2 (deprecated) | ||
| 988 | pub const IPPROTO_GGP = 3; | ||
| 989 | |||
| 990 | /// IPv4 encapsulation | ||
| 991 | pub const IPPROTO_IPV4 = 4; | ||
| 992 | |||
| 993 | /// for compatibility | ||
| 994 | pub const IPPROTO_IPIP = IPPROTO_IPV4; | ||
| 995 | |||
| 996 | /// Stream protocol II | ||
| 997 | pub const IPPROTO_ST = 7; | ||
| 998 | |||
| 999 | /// exterior gateway protocol | ||
| 1000 | pub const IPPROTO_EGP = 8; | ||
| 1001 | |||
| 1002 | /// private interior gateway | ||
| 1003 | pub const IPPROTO_PIGP = 9; | ||
| 1004 | |||
| 1005 | /// BBN RCC Monitoring | ||
| 1006 | pub const IPPROTO_RCCMON = 10; | ||
| 1007 | |||
| 1008 | /// network voice protocol | ||
| 1009 | pub const IPPROTO_NVPII = 11; | ||
| 1010 | |||
| 1011 | /// pup | ||
| 1012 | pub const IPPROTO_PUP = 12; | ||
| 1013 | |||
| 1014 | /// Argus | ||
| 1015 | pub const IPPROTO_ARGUS = 13; | ||
| 1016 | |||
| 1017 | /// EMCON | ||
| 1018 | pub const IPPROTO_EMCON = 14; | ||
| 1019 | |||
| 1020 | /// Cross Net Debugger | ||
| 1021 | pub const IPPROTO_XNET = 15; | ||
| 1022 | |||
| 1023 | /// Chaos | ||
| 1024 | pub const IPPROTO_CHAOS = 16; | ||
| 1025 | |||
| 1026 | /// Multiplexing | ||
| 1027 | pub const IPPROTO_MUX = 18; | ||
| 1028 | |||
| 1029 | /// DCN Measurement Subsystems | ||
| 1030 | pub const IPPROTO_MEAS = 19; | ||
| 1031 | |||
| 1032 | /// Host Monitoring | ||
| 1033 | pub const IPPROTO_HMP = 20; | ||
| 1034 | |||
| 1035 | /// Packet Radio Measurement | ||
| 1036 | pub const IPPROTO_PRM = 21; | ||
| 1037 | |||
| 1038 | /// xns idp | ||
| 1039 | pub const IPPROTO_IDP = 22; | ||
| 1040 | |||
| 1041 | /// Trunk-1 | ||
| 1042 | pub const IPPROTO_TRUNK1 = 23; | ||
| 1043 | |||
| 1044 | /// Trunk-2 | ||
| 1045 | pub const IPPROTO_TRUNK2 = 24; | ||
| 1046 | |||
| 1047 | /// Leaf-1 | ||
| 1048 | pub const IPPROTO_LEAF1 = 25; | ||
| 1049 | |||
| 1050 | /// Leaf-2 | ||
| 1051 | pub const IPPROTO_LEAF2 = 26; | ||
| 1052 | |||
| 1053 | /// Reliable Data | ||
| 1054 | pub const IPPROTO_RDP = 27; | ||
| 1055 | |||
| 1056 | /// Reliable Transaction | ||
| 1057 | pub const IPPROTO_IRTP = 28; | ||
| 1058 | |||
| 1059 | /// tp-4 w/ class negotiation | ||
| 1060 | pub const IPPROTO_TP = 29; | ||
| 1061 | |||
| 1062 | /// Bulk Data Transfer | ||
| 1063 | pub const IPPROTO_BLT = 30; | ||
| 1064 | |||
| 1065 | /// Network Services | ||
| 1066 | pub const IPPROTO_NSP = 31; | ||
| 1067 | |||
| 1068 | /// Merit Internodal | ||
| 1069 | pub const IPPROTO_INP = 32; | ||
| 1070 | |||
| 1071 | /// Datagram Congestion Control Protocol | ||
| 1072 | pub const IPPROTO_DCCP = 33; | ||
| 1073 | |||
| 1074 | /// Third Party Connect | ||
| 1075 | pub const IPPROTO_3PC = 34; | ||
| 1076 | |||
| 1077 | /// InterDomain Policy Routing | ||
| 1078 | pub const IPPROTO_IDPR = 35; | ||
| 1079 | |||
| 1080 | /// XTP | ||
| 1081 | pub const IPPROTO_XTP = 36; | ||
| 1082 | |||
| 1083 | /// Datagram Delivery | ||
| 1084 | pub const IPPROTO_DDP = 37; | ||
| 1085 | |||
| 1086 | /// Control Message Transport | ||
| 1087 | pub const IPPROTO_CMTP = 38; | ||
| 1088 | |||
| 1089 | /// TP++ Transport | ||
| 1090 | pub const IPPROTO_TPXX = 39; | ||
| 1091 | |||
| 1092 | /// IL transport protocol | ||
| 1093 | pub const IPPROTO_IL = 40; | ||
| 1094 | |||
| 1095 | /// Source Demand Routing | ||
| 1096 | pub const IPPROTO_SDRP = 42; | ||
| 1097 | |||
| 1098 | /// IP6 routing header | ||
| 1099 | pub const IPPROTO_ROUTING = 43; | ||
| 1100 | |||
| 1101 | /// IP6 fragmentation header | ||
| 1102 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1103 | |||
| 1104 | /// InterDomain Routing | ||
| 1105 | pub const IPPROTO_IDRP = 45; | ||
| 1106 | |||
| 1107 | /// resource reservation | ||
| 1108 | pub const IPPROTO_RSVP = 46; | ||
| 1109 | |||
| 1110 | /// General Routing Encap. | ||
| 1111 | pub const IPPROTO_GRE = 47; | ||
| 1112 | |||
| 1113 | /// Mobile Host Routing | ||
| 1114 | pub const IPPROTO_MHRP = 48; | ||
| 1115 | |||
| 1116 | /// BHA | ||
| 1117 | pub const IPPROTO_BHA = 49; | ||
| 1118 | |||
| 1119 | /// IP6 Encap Sec. Payload | ||
| 1120 | pub const IPPROTO_ESP = 50; | ||
| 1121 | |||
| 1122 | /// IP6 Auth Header | ||
| 1123 | pub const IPPROTO_AH = 51; | ||
| 1124 | |||
| 1125 | /// Integ. Net Layer Security | ||
| 1126 | pub const IPPROTO_INLSP = 52; | ||
| 1127 | |||
| 1128 | /// IP with encryption | ||
| 1129 | pub const IPPROTO_SWIPE = 53; | ||
| 1130 | |||
| 1131 | /// Next Hop Resolution | ||
| 1132 | pub const IPPROTO_NHRP = 54; | ||
| 1133 | |||
| 1134 | /// IP Mobility | ||
| 1135 | pub const IPPROTO_MOBILE = 55; | ||
| 1136 | |||
| 1137 | /// Transport Layer Security | ||
| 1138 | pub const IPPROTO_TLSP = 56; | ||
| 1139 | |||
| 1140 | /// SKIP | ||
| 1141 | pub const IPPROTO_SKIP = 57; | ||
| 1142 | |||
| 1143 | /// ICMP6 | ||
| 1144 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1145 | |||
| 1146 | /// IP6 no next header | ||
| 1147 | pub const IPPROTO_NONE = 59; | ||
| 1148 | |||
| 1149 | /// IP6 destination option | ||
| 1150 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1151 | |||
| 1152 | /// any host internal protocol | ||
| 1153 | pub const IPPROTO_AHIP = 61; | ||
| 1154 | |||
| 1155 | /// CFTP | ||
| 1156 | pub const IPPROTO_CFTP = 62; | ||
| 1157 | |||
| 1158 | /// "hello" routing protocol | ||
| 1159 | pub const IPPROTO_HELLO = 63; | ||
| 1160 | |||
| 1161 | /// SATNET/Backroom EXPAK | ||
| 1162 | pub const IPPROTO_SATEXPAK = 64; | ||
| 1163 | |||
| 1164 | /// Kryptolan | ||
| 1165 | pub const IPPROTO_KRYPTOLAN = 65; | ||
| 1166 | |||
| 1167 | /// Remote Virtual Disk | ||
| 1168 | pub const IPPROTO_RVD = 66; | ||
| 1169 | |||
| 1170 | /// Pluribus Packet Core | ||
| 1171 | pub const IPPROTO_IPPC = 67; | ||
| 1172 | |||
| 1173 | /// Any distributed FS | ||
| 1174 | pub const IPPROTO_ADFS = 68; | ||
| 1175 | |||
| 1176 | /// Satnet Monitoring | ||
| 1177 | pub const IPPROTO_SATMON = 69; | ||
| 1178 | |||
| 1179 | /// VISA Protocol | ||
| 1180 | pub const IPPROTO_VISA = 70; | ||
| 1181 | |||
| 1182 | /// Packet Core Utility | ||
| 1183 | pub const IPPROTO_IPCV = 71; | ||
| 1184 | |||
| 1185 | /// Comp. Prot. Net. Executive | ||
| 1186 | pub const IPPROTO_CPNX = 72; | ||
| 1187 | |||
| 1188 | /// Comp. Prot. HeartBeat | ||
| 1189 | pub const IPPROTO_CPHB = 73; | ||
| 1190 | |||
| 1191 | /// Wang Span Network | ||
| 1192 | pub const IPPROTO_WSN = 74; | ||
| 1193 | |||
| 1194 | /// Packet Video Protocol | ||
| 1195 | pub const IPPROTO_PVP = 75; | ||
| 1196 | |||
| 1197 | /// BackRoom SATNET Monitoring | ||
| 1198 | pub const IPPROTO_BRSATMON = 76; | ||
| 1199 | |||
| 1200 | /// Sun net disk proto (temp.) | ||
| 1201 | pub const IPPROTO_ND = 77; | ||
| 1202 | |||
| 1203 | /// WIDEBAND Monitoring | ||
| 1204 | pub const IPPROTO_WBMON = 78; | ||
| 1205 | |||
| 1206 | /// WIDEBAND EXPAK | ||
| 1207 | pub const IPPROTO_WBEXPAK = 79; | ||
| 1208 | |||
| 1209 | /// ISO cnlp | ||
| 1210 | pub const IPPROTO_EON = 80; | ||
| 1211 | |||
| 1212 | /// VMTP | ||
| 1213 | pub const IPPROTO_VMTP = 81; | ||
| 1214 | |||
| 1215 | /// Secure VMTP | ||
| 1216 | pub const IPPROTO_SVMTP = 82; | ||
| 1217 | |||
| 1218 | /// Banyon VINES | ||
| 1219 | pub const IPPROTO_VINES = 83; | ||
| 1220 | |||
| 1221 | /// TTP | ||
| 1222 | pub const IPPROTO_TTP = 84; | ||
| 1223 | |||
| 1224 | /// NSFNET-IGP | ||
| 1225 | pub const IPPROTO_IGP = 85; | ||
| 1226 | |||
| 1227 | /// dissimilar gateway prot. | ||
| 1228 | pub const IPPROTO_DGP = 86; | ||
| 1229 | |||
| 1230 | /// TCF | ||
| 1231 | pub const IPPROTO_TCF = 87; | ||
| 1232 | |||
| 1233 | /// Cisco/GXS IGRP | ||
| 1234 | pub const IPPROTO_IGRP = 88; | ||
| 1235 | |||
| 1236 | /// OSPFIGP | ||
| 1237 | pub const IPPROTO_OSPFIGP = 89; | ||
| 1238 | |||
| 1239 | /// Strite RPC protocol | ||
| 1240 | pub const IPPROTO_SRPC = 90; | ||
| 1241 | |||
| 1242 | /// Locus Address Resoloution | ||
| 1243 | pub const IPPROTO_LARP = 91; | ||
| 1244 | |||
| 1245 | /// Multicast Transport | ||
| 1246 | pub const IPPROTO_MTP = 92; | ||
| 1247 | |||
| 1248 | /// AX.25 Frames | ||
| 1249 | pub const IPPROTO_AX25 = 93; | ||
| 1250 | |||
| 1251 | /// IP encapsulated in IP | ||
| 1252 | pub const IPPROTO_IPEIP = 94; | ||
| 1253 | |||
| 1254 | /// Mobile Int.ing control | ||
| 1255 | pub const IPPROTO_MICP = 95; | ||
| 1256 | |||
| 1257 | /// Semaphore Comm. security | ||
| 1258 | pub const IPPROTO_SCCSP = 96; | ||
| 1259 | |||
| 1260 | /// Ethernet IP encapsulation | ||
| 1261 | pub const IPPROTO_ETHERIP = 97; | ||
| 1262 | |||
| 1263 | /// encapsulation header | ||
| 1264 | pub const IPPROTO_ENCAP = 98; | ||
| 1265 | |||
| 1266 | /// any private encr. scheme | ||
| 1267 | pub const IPPROTO_APES = 99; | ||
| 1268 | |||
| 1269 | /// GMTP | ||
| 1270 | pub const IPPROTO_GMTP = 100; | ||
| 1271 | |||
| 1272 | /// payload compression (IPComp) | ||
| 1273 | pub const IPPROTO_IPCOMP = 108; | ||
| 1274 | |||
| 1275 | /// SCTP | ||
| 1276 | pub const IPPROTO_SCTP = 132; | ||
| 1277 | |||
| 1278 | /// IPv6 Mobility Header | ||
| 1279 | pub const IPPROTO_MH = 135; | ||
| 1280 | |||
| 1281 | /// UDP-Lite | ||
| 1282 | pub const IPPROTO_UDPLITE = 136; | ||
| 1283 | |||
| 1284 | /// IP6 Host Identity Protocol | ||
| 1285 | pub const IPPROTO_HIP = 139; | ||
| 1286 | |||
| 1287 | /// IP6 Shim6 Protocol | ||
| 1288 | pub const IPPROTO_SHIM6 = 140; | ||
| 1289 | |||
| 1290 | /// Protocol Independent Mcast | ||
| 1291 | pub const IPPROTO_PIM = 103; | ||
| 1292 | |||
| 1293 | /// CARP | ||
| 1294 | pub const IPPROTO_CARP = 112; | ||
| 1295 | |||
| 1296 | /// PGM | ||
| 1297 | pub const IPPROTO_PGM = 113; | ||
| 1298 | |||
| 1299 | /// MPLS-in-IP | ||
| 1300 | pub const IPPROTO_MPLS = 137; | ||
| 1301 | |||
| 1302 | /// PFSYNC | ||
| 1303 | pub const IPPROTO_PFSYNC = 240; | ||
| 1304 | |||
| 1305 | /// Reserved | ||
| 1306 | pub const IPPROTO_RESERVED_253 = 253; | ||
| 1307 | |||
| 1308 | /// Reserved | ||
| 1309 | pub const IPPROTO_RESERVED_254 = 254; | ||
| 1310 | |||
| 1311 | pub const rlimit_resource = enum(c_int) { | ||
| 1312 | CPU = 0, | ||
| 1313 | FSIZE = 1, | ||
| 1314 | DATA = 2, | ||
| 1315 | STACK = 3, | ||
| 1316 | CORE = 4, | ||
| 1317 | RSS = 5, | ||
| 1318 | MEMLOCK = 6, | ||
| 1319 | NPROC = 7, | ||
| 1320 | NOFILE = 8, | ||
| 1321 | SBSIZE = 9, | ||
| 1322 | VMEM = 10, | ||
| 1323 | NPTS = 11, | ||
| 1324 | SWAP = 12, | ||
| 1325 | KQUEUES = 13, | ||
| 1326 | UMTXP = 14, | ||
| 1327 | _, | ||
| 1328 | |||
| 1329 | pub const AS: rlimit_resource = .VMEM; | ||
| 1330 | }; | ||
| 1331 | |||
| 1332 | pub const rlim_t = i64; | ||
| 1333 | |||
| 1334 | /// No limit | ||
| 1335 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1336 | |||
| 1337 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1338 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1339 | |||
| 1340 | pub const rlimit = extern struct { | ||
| 1341 | /// Soft limit | ||
| 1342 | cur: rlim_t, | ||
| 1343 | /// Hard limit | ||
| 1344 | max: rlim_t, | ||
| 1345 | }; | ||
| 1346 | |||
| 1347 | pub const SHUT_RD = 0; | ||
| 1348 | pub const SHUT_WR = 1; | ||
| 1349 | pub const SHUT_RDWR = 2; | ||
| 1350 | |||
| 1351 | // TODO fill out if needed | ||
| 1352 | pub const directory_which = enum(c_int) { | ||
| 1353 | B_USER_SETTINGS_DIRECTORY = 0xbbe, | ||
| 1354 | |||
| 1355 | _, | ||
| 1356 | }; | ||
| 1357 | |||
| 1358 | pub const cc_t = u8; | ||
| 1359 | pub const speed_t = u8; | ||
| 1360 | pub const tcflag_t = u32; | ||
| 1361 | |||
| 1362 | pub const NCCS = 32; | ||
| 1363 | |||
| 1364 | pub const termios = extern struct { | ||
| 1365 | c_iflag: tcflag_t, | ||
| 1366 | c_oflag: tcflag_t, | ||
| 1367 | c_cflag: tcflag_t, | ||
| 1368 | c_lflag: tcflag_t, | ||
| 1369 | c_line: cc_t, | ||
| 1370 | c_ispeed: speed_t, | ||
| 1371 | c_ospeed: speed_t, | ||
| 1372 | cc_t: [NCCS]cc_t, | ||
| 1373 | }; | ||
lib/std/os/bits/linux/arm-eabi.zig+1-4| ... | @@ -551,7 +551,7 @@ pub const dev_t = u64; | ... | @@ -551,7 +551,7 @@ pub const dev_t = u64; |
| 551 | pub const blkcnt_t = i64; | 551 | pub const blkcnt_t = i64; |
| 552 | 552 | ||
| 553 | // The `stat` definition used by the Linux kernel. | 553 | // The `stat` definition used by the Linux kernel. |
| 554 | pub const kernel_stat = extern struct { | 554 | pub const Stat = extern struct { |
| 555 | dev: dev_t, | 555 | dev: dev_t, |
| 556 | __dev_padding: u32, | 556 | __dev_padding: u32, |
| 557 | __ino_truncated: u32, | 557 | __ino_truncated: u32, |
| ... | @@ -582,9 +582,6 @@ pub const kernel_stat = extern struct { | ... | @@ -582,9 +582,6 @@ pub const kernel_stat = extern struct { |
| 582 | } | 582 | } |
| 583 | }; | 583 | }; |
| 584 | 584 | ||
| 585 | // The `stat64` definition used by the libc. | ||
| 586 | pub const libc_stat = kernel_stat; | ||
| 587 | |||
| 588 | pub const timespec = extern struct { | 585 | pub const timespec = extern struct { |
| 589 | tv_sec: i32, | 586 | tv_sec: i32, |
| 590 | tv_nsec: i32, | 587 | tv_nsec: i32, |
lib/std/os/bits/linux/arm64.zig+1-4| ... | @@ -424,7 +424,7 @@ pub const dev_t = usize; | ... | @@ -424,7 +424,7 @@ pub const dev_t = usize; |
| 424 | pub const blkcnt_t = isize; | 424 | pub const blkcnt_t = isize; |
| 425 | 425 | ||
| 426 | // The `stat` definition used by the Linux kernel. | 426 | // The `stat` definition used by the Linux kernel. |
| 427 | pub const kernel_stat = extern struct { | 427 | pub const Stat = extern struct { |
| 428 | dev: dev_t, | 428 | dev: dev_t, |
| 429 | ino: ino_t, | 429 | ino: ino_t, |
| 430 | mode: mode_t, | 430 | mode: mode_t, |
| ... | @@ -455,9 +455,6 @@ pub const kernel_stat = extern struct { | ... | @@ -455,9 +455,6 @@ pub const kernel_stat = extern struct { |
| 455 | } | 455 | } |
| 456 | }; | 456 | }; |
| 457 | 457 | ||
| 458 | // The `stat64` definition used by the libc. | ||
| 459 | pub const libc_stat = kernel_stat; | ||
| 460 | |||
| 461 | pub const timespec = extern struct { | 458 | pub const timespec = extern struct { |
| 462 | tv_sec: time_t, | 459 | tv_sec: time_t, |
| 463 | tv_nsec: isize, | 460 | tv_nsec: isize, |
lib/std/os/bits/linux/i386.zig+1-4| ... | @@ -599,7 +599,7 @@ pub const dev_t = u64; | ... | @@ -599,7 +599,7 @@ pub const dev_t = u64; |
| 599 | pub const blkcnt_t = i64; | 599 | pub const blkcnt_t = i64; |
| 600 | 600 | ||
| 601 | // The `stat` definition used by the Linux kernel. | 601 | // The `stat` definition used by the Linux kernel. |
| 602 | pub const kernel_stat = extern struct { | 602 | pub const Stat = extern struct { |
| 603 | dev: dev_t, | 603 | dev: dev_t, |
| 604 | __dev_padding: u32, | 604 | __dev_padding: u32, |
| 605 | __ino_truncated: u32, | 605 | __ino_truncated: u32, |
| ... | @@ -630,9 +630,6 @@ pub const kernel_stat = extern struct { | ... | @@ -630,9 +630,6 @@ pub const kernel_stat = extern struct { |
| 630 | } | 630 | } |
| 631 | }; | 631 | }; |
| 632 | 632 | ||
| 633 | // The `stat64` definition used by the libc. | ||
| 634 | pub const libc_stat = kernel_stat; | ||
| 635 | |||
| 636 | pub const timespec = extern struct { | 633 | pub const timespec = extern struct { |
| 637 | tv_sec: i32, | 634 | tv_sec: i32, |
| 638 | tv_nsec: i32, | 635 | tv_nsec: i32, |
lib/std/os/bits/linux/mips.zig+1-33| ... | @@ -540,7 +540,7 @@ pub const dev_t = u64; | ... | @@ -540,7 +540,7 @@ pub const dev_t = u64; |
| 540 | pub const blkcnt_t = i64; | 540 | pub const blkcnt_t = i64; |
| 541 | 541 | ||
| 542 | // The `stat` definition used by the Linux kernel. | 542 | // The `stat` definition used by the Linux kernel. |
| 543 | pub const kernel_stat = extern struct { | 543 | pub const Stat = extern struct { |
| 544 | dev: u32, | 544 | dev: u32, |
| 545 | __pad0: [3]u32, // Reserved for st_dev expansion | 545 | __pad0: [3]u32, // Reserved for st_dev expansion |
| 546 | ino: ino_t, | 546 | ino: ino_t, |
| ... | @@ -572,38 +572,6 @@ pub const kernel_stat = extern struct { | ... | @@ -572,38 +572,6 @@ pub const kernel_stat = extern struct { |
| 572 | } | 572 | } |
| 573 | }; | 573 | }; |
| 574 | 574 | ||
| 575 | pub const libc_stat = extern struct { | ||
| 576 | dev: dev_t, | ||
| 577 | __pad0: [2]u32, | ||
| 578 | ino: ino_t, | ||
| 579 | mode: mode_t, | ||
| 580 | nlink: nlink_t, | ||
| 581 | uid: uid_t, | ||
| 582 | gid: gid_t, | ||
| 583 | rdev: dev_t, | ||
| 584 | __pad1: [2]u32, | ||
| 585 | size: off_t, | ||
| 586 | atim: timespec, | ||
| 587 | mtim: timespec, | ||
| 588 | ctim: timespec, | ||
| 589 | blksize: blksize_t, | ||
| 590 | __pad3: u32, | ||
| 591 | blocks: blkcnt_t, | ||
| 592 | __pad4: [14]u32, | ||
| 593 | |||
| 594 | pub fn atime(self: @This()) timespec { | ||
| 595 | return self.atim; | ||
| 596 | } | ||
| 597 | |||
| 598 | pub fn mtime(self: @This()) timespec { | ||
| 599 | return self.mtim; | ||
| 600 | } | ||
| 601 | |||
| 602 | pub fn ctime(self: @This()) timespec { | ||
| 603 | return self.ctim; | ||
| 604 | } | ||
| 605 | }; | ||
| 606 | |||
| 607 | pub const timespec = extern struct { | 575 | pub const timespec = extern struct { |
| 608 | tv_sec: isize, | 576 | tv_sec: isize, |
| 609 | tv_nsec: isize, | 577 | tv_nsec: isize, |
lib/std/os/bits/linux/powerpc.zig+1-4| ... | @@ -539,7 +539,7 @@ pub const dev_t = u64; | ... | @@ -539,7 +539,7 @@ pub const dev_t = u64; |
| 539 | pub const blkcnt_t = i64; | 539 | pub const blkcnt_t = i64; |
| 540 | 540 | ||
| 541 | // The `stat` definition used by the Linux kernel. | 541 | // The `stat` definition used by the Linux kernel. |
| 542 | pub const kernel_stat = extern struct { | 542 | pub const Stat = extern struct { |
| 543 | dev: dev_t, | 543 | dev: dev_t, |
| 544 | ino: ino_t, | 544 | ino: ino_t, |
| 545 | mode: mode_t, | 545 | mode: mode_t, |
| ... | @@ -569,9 +569,6 @@ pub const kernel_stat = extern struct { | ... | @@ -569,9 +569,6 @@ pub const kernel_stat = extern struct { |
| 569 | } | 569 | } |
| 570 | }; | 570 | }; |
| 571 | 571 | ||
| 572 | // The `stat64` definition used by the libc. | ||
| 573 | pub const libc_stat = kernel_stat; | ||
| 574 | |||
| 575 | pub const timespec = extern struct { | 572 | pub const timespec = extern struct { |
| 576 | tv_sec: time_t, | 573 | tv_sec: time_t, |
| 577 | tv_nsec: isize, | 574 | tv_nsec: isize, |
lib/std/os/bits/linux/powerpc64.zig+1-4| ... | @@ -515,7 +515,7 @@ pub const dev_t = u64; | ... | @@ -515,7 +515,7 @@ pub const dev_t = u64; |
| 515 | pub const blkcnt_t = i64; | 515 | pub const blkcnt_t = i64; |
| 516 | 516 | ||
| 517 | // The `stat` definition used by the Linux kernel. | 517 | // The `stat` definition used by the Linux kernel. |
| 518 | pub const kernel_stat = extern struct { | 518 | pub const Stat = extern struct { |
| 519 | dev: dev_t, | 519 | dev: dev_t, |
| 520 | ino: ino_t, | 520 | ino: ino_t, |
| 521 | nlink: nlink_t, | 521 | nlink: nlink_t, |
| ... | @@ -544,9 +544,6 @@ pub const kernel_stat = extern struct { | ... | @@ -544,9 +544,6 @@ pub const kernel_stat = extern struct { |
| 544 | } | 544 | } |
| 545 | }; | 545 | }; |
| 546 | 546 | ||
| 547 | // The `stat64` definition used by the libc. | ||
| 548 | pub const libc_stat = kernel_stat; | ||
| 549 | |||
| 550 | pub const timespec = extern struct { | 547 | pub const timespec = extern struct { |
| 551 | tv_sec: time_t, | 548 | tv_sec: time_t, |
| 552 | tv_nsec: isize, | 549 | tv_nsec: isize, |
lib/std/os/bits/linux/riscv64.zig+1-4| ... | @@ -386,7 +386,7 @@ pub const Flock = extern struct { | ... | @@ -386,7 +386,7 @@ pub const Flock = extern struct { |
| 386 | }; | 386 | }; |
| 387 | 387 | ||
| 388 | // The `stat` definition used by the Linux kernel. | 388 | // The `stat` definition used by the Linux kernel. |
| 389 | pub const kernel_stat = extern struct { | 389 | pub const Stat = extern struct { |
| 390 | dev: dev_t, | 390 | dev: dev_t, |
| 391 | ino: ino_t, | 391 | ino: ino_t, |
| 392 | mode: mode_t, | 392 | mode: mode_t, |
| ... | @@ -417,7 +417,4 @@ pub const kernel_stat = extern struct { | ... | @@ -417,7 +417,4 @@ pub const kernel_stat = extern struct { |
| 417 | } | 417 | } |
| 418 | }; | 418 | }; |
| 419 | 419 | ||
| 420 | // The `stat64` definition used by the libc. | ||
| 421 | pub const libc_stat = kernel_stat; | ||
| 422 | |||
| 423 | pub const Elf_Symndx = u32; | 420 | pub const Elf_Symndx = u32; |
lib/std/os/bits/linux/sparc64.zig+1-35| ... | @@ -489,42 +489,8 @@ pub const off_t = i64; | ... | @@ -489,42 +489,8 @@ pub const off_t = i64; |
| 489 | pub const ino_t = u64; | 489 | pub const ino_t = u64; |
| 490 | pub const mode_t = u32; | 490 | pub const mode_t = u32; |
| 491 | 491 | ||
| 492 | // The `stat64` definition used by the libc. | ||
| 493 | pub const libc_stat = extern struct { | ||
| 494 | dev: u64, | ||
| 495 | ino: ino_t, | ||
| 496 | mode: u32, | ||
| 497 | nlink: usize, | ||
| 498 | |||
| 499 | uid: u32, | ||
| 500 | gid: u32, | ||
| 501 | rdev: u64, | ||
| 502 | __pad0: u32, | ||
| 503 | |||
| 504 | size: off_t, | ||
| 505 | blksize: isize, | ||
| 506 | blocks: i64, | ||
| 507 | |||
| 508 | atim: timespec, | ||
| 509 | mtim: timespec, | ||
| 510 | ctim: timespec, | ||
| 511 | __unused: [2]isize, | ||
| 512 | |||
| 513 | pub fn atime(self: libc_stat) timespec { | ||
| 514 | return self.atim; | ||
| 515 | } | ||
| 516 | |||
| 517 | pub fn mtime(self: libc_stat) timespec { | ||
| 518 | return self.mtim; | ||
| 519 | } | ||
| 520 | |||
| 521 | pub fn ctime(self: libc_stat) timespec { | ||
| 522 | return self.ctim; | ||
| 523 | } | ||
| 524 | }; | ||
| 525 | |||
| 526 | // The `stat64` definition used by the kernel. | 492 | // The `stat64` definition used by the kernel. |
| 527 | pub const kernel_stat = extern struct { | 493 | pub const Stat = extern struct { |
| 528 | dev: u64, | 494 | dev: u64, |
| 529 | ino: u64, | 495 | ino: u64, |
| 530 | nlink: u64, | 496 | nlink: u64, |
lib/std/os/bits/netbsd.zig deleted-1326| ... | @@ -1,1326 +0,0 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const builtin = std.builtin; | ||
| 3 | const maxInt = std.math.maxInt; | ||
| 4 | |||
| 5 | pub const blkcnt_t = i64; | ||
| 6 | pub const blksize_t = i32; | ||
| 7 | pub const clock_t = u32; | ||
| 8 | pub const dev_t = u64; | ||
| 9 | pub const fd_t = i32; | ||
| 10 | pub const gid_t = u32; | ||
| 11 | pub const ino_t = u64; | ||
| 12 | pub const mode_t = u32; | ||
| 13 | pub const nlink_t = u32; | ||
| 14 | pub const off_t = i64; | ||
| 15 | pub const pid_t = i32; | ||
| 16 | pub const socklen_t = u32; | ||
| 17 | pub const time_t = i64; | ||
| 18 | pub const uid_t = u32; | ||
| 19 | pub const lwpid_t = i32; | ||
| 20 | pub const suseconds_t = c_int; | ||
| 21 | |||
| 22 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 23 | pub const Kevent = extern struct { | ||
| 24 | ident: usize, | ||
| 25 | filter: i32, | ||
| 26 | flags: u32, | ||
| 27 | fflags: u32, | ||
| 28 | data: i64, | ||
| 29 | udata: usize, | ||
| 30 | }; | ||
| 31 | |||
| 32 | pub const RTLD_LAZY = 1; | ||
| 33 | pub const RTLD_NOW = 2; | ||
| 34 | pub const RTLD_GLOBAL = 0x100; | ||
| 35 | pub const RTLD_LOCAL = 0x200; | ||
| 36 | pub const RTLD_NODELETE = 0x01000; | ||
| 37 | pub const RTLD_NOLOAD = 0x02000; | ||
| 38 | |||
| 39 | pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1))); | ||
| 40 | pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2))); | ||
| 41 | pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3))); | ||
| 42 | |||
| 43 | pub const dl_phdr_info = extern struct { | ||
| 44 | dlpi_addr: usize, | ||
| 45 | dlpi_name: ?[*:0]const u8, | ||
| 46 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 47 | dlpi_phnum: u16, | ||
| 48 | }; | ||
| 49 | |||
| 50 | pub const Flock = extern struct { | ||
| 51 | l_start: off_t, | ||
| 52 | l_len: off_t, | ||
| 53 | l_pid: pid_t, | ||
| 54 | l_type: i16, | ||
| 55 | l_whence: i16, | ||
| 56 | }; | ||
| 57 | |||
| 58 | pub const addrinfo = extern struct { | ||
| 59 | flags: i32, | ||
| 60 | family: i32, | ||
| 61 | socktype: i32, | ||
| 62 | protocol: i32, | ||
| 63 | addrlen: socklen_t, | ||
| 64 | canonname: ?[*:0]u8, | ||
| 65 | addr: ?*sockaddr, | ||
| 66 | next: ?*addrinfo, | ||
| 67 | }; | ||
| 68 | |||
| 69 | pub const EAI = enum(c_int) { | ||
| 70 | /// address family for hostname not supported | ||
| 71 | ADDRFAMILY = 1, | ||
| 72 | |||
| 73 | /// name could not be resolved at this time | ||
| 74 | AGAIN = 2, | ||
| 75 | |||
| 76 | /// flags parameter had an invalid value | ||
| 77 | BADFLAGS = 3, | ||
| 78 | |||
| 79 | /// non-recoverable failure in name resolution | ||
| 80 | FAIL = 4, | ||
| 81 | |||
| 82 | /// address family not recognized | ||
| 83 | FAMILY = 5, | ||
| 84 | |||
| 85 | /// memory allocation failure | ||
| 86 | MEMORY = 6, | ||
| 87 | |||
| 88 | /// no address associated with hostname | ||
| 89 | NODATA = 7, | ||
| 90 | |||
| 91 | /// name does not resolve | ||
| 92 | NONAME = 8, | ||
| 93 | |||
| 94 | /// service not recognized for socket type | ||
| 95 | SERVICE = 9, | ||
| 96 | |||
| 97 | /// intended socket type was not recognized | ||
| 98 | SOCKTYPE = 10, | ||
| 99 | |||
| 100 | /// system error returned in errno | ||
| 101 | SYSTEM = 11, | ||
| 102 | |||
| 103 | /// invalid value for hints | ||
| 104 | BADHINTS = 12, | ||
| 105 | |||
| 106 | /// resolved protocol is unknown | ||
| 107 | PROTOCOL = 13, | ||
| 108 | |||
| 109 | /// argument buffer overflow | ||
| 110 | OVERFLOW = 14, | ||
| 111 | |||
| 112 | _, | ||
| 113 | }; | ||
| 114 | |||
| 115 | pub const EAI_MAX = 15; | ||
| 116 | |||
| 117 | pub const msghdr = extern struct { | ||
| 118 | /// optional address | ||
| 119 | msg_name: ?*sockaddr, | ||
| 120 | |||
| 121 | /// size of address | ||
| 122 | msg_namelen: socklen_t, | ||
| 123 | |||
| 124 | /// scatter/gather array | ||
| 125 | msg_iov: [*]iovec, | ||
| 126 | |||
| 127 | /// # elements in msg_iov | ||
| 128 | msg_iovlen: i32, | ||
| 129 | |||
| 130 | /// ancillary data | ||
| 131 | msg_control: ?*c_void, | ||
| 132 | |||
| 133 | /// ancillary data buffer len | ||
| 134 | msg_controllen: socklen_t, | ||
| 135 | |||
| 136 | /// flags on received message | ||
| 137 | msg_flags: i32, | ||
| 138 | }; | ||
| 139 | |||
| 140 | pub const msghdr_const = extern struct { | ||
| 141 | /// optional address | ||
| 142 | msg_name: ?*const sockaddr, | ||
| 143 | |||
| 144 | /// size of address | ||
| 145 | msg_namelen: socklen_t, | ||
| 146 | |||
| 147 | /// scatter/gather array | ||
| 148 | msg_iov: [*]iovec_const, | ||
| 149 | |||
| 150 | /// # elements in msg_iov | ||
| 151 | msg_iovlen: i32, | ||
| 152 | |||
| 153 | /// ancillary data | ||
| 154 | msg_control: ?*c_void, | ||
| 155 | |||
| 156 | /// ancillary data buffer len | ||
| 157 | msg_controllen: socklen_t, | ||
| 158 | |||
| 159 | /// flags on received message | ||
| 160 | msg_flags: i32, | ||
| 161 | }; | ||
| 162 | |||
| 163 | pub const libc_stat = extern struct { | ||
| 164 | dev: dev_t, | ||
| 165 | mode: mode_t, | ||
| 166 | ino: ino_t, | ||
| 167 | nlink: nlink_t, | ||
| 168 | uid: uid_t, | ||
| 169 | gid: gid_t, | ||
| 170 | rdev: dev_t, | ||
| 171 | atim: timespec, | ||
| 172 | mtim: timespec, | ||
| 173 | ctim: timespec, | ||
| 174 | birthtim: timespec, | ||
| 175 | size: off_t, | ||
| 176 | blocks: blkcnt_t, | ||
| 177 | blksize: blksize_t, | ||
| 178 | flags: u32, | ||
| 179 | gen: u32, | ||
| 180 | __spare: [2]u32, | ||
| 181 | |||
| 182 | pub fn atime(self: @This()) timespec { | ||
| 183 | return self.atim; | ||
| 184 | } | ||
| 185 | |||
| 186 | pub fn mtime(self: @This()) timespec { | ||
| 187 | return self.mtim; | ||
| 188 | } | ||
| 189 | |||
| 190 | pub fn ctime(self: @This()) timespec { | ||
| 191 | return self.ctim; | ||
| 192 | } | ||
| 193 | }; | ||
| 194 | |||
| 195 | pub const timespec = extern struct { | ||
| 196 | tv_sec: i64, | ||
| 197 | tv_nsec: isize, | ||
| 198 | }; | ||
| 199 | |||
| 200 | pub const timeval = extern struct { | ||
| 201 | /// seconds | ||
| 202 | tv_sec: time_t, | ||
| 203 | /// microseconds | ||
| 204 | tv_usec: suseconds_t, | ||
| 205 | }; | ||
| 206 | |||
| 207 | pub const MAXNAMLEN = 511; | ||
| 208 | |||
| 209 | pub const dirent = extern struct { | ||
| 210 | d_fileno: ino_t, | ||
| 211 | d_reclen: u16, | ||
| 212 | d_namlen: u16, | ||
| 213 | d_type: u8, | ||
| 214 | d_name: [MAXNAMLEN:0]u8, | ||
| 215 | |||
| 216 | pub fn reclen(self: dirent) u16 { | ||
| 217 | return self.d_reclen; | ||
| 218 | } | ||
| 219 | }; | ||
| 220 | |||
| 221 | pub const SOCK_STREAM = 1; | ||
| 222 | pub const SOCK_DGRAM = 2; | ||
| 223 | pub const SOCK_RAW = 3; | ||
| 224 | pub const SOCK_RDM = 4; | ||
| 225 | pub const SOCK_SEQPACKET = 5; | ||
| 226 | pub const SOCK_CONN_DGRAM = 6; | ||
| 227 | pub const SOCK_DCCP = SOCK_CONN_DGRAM; | ||
| 228 | |||
| 229 | pub const SOCK_CLOEXEC = 0x10000000; | ||
| 230 | pub const SOCK_NONBLOCK = 0x20000000; | ||
| 231 | pub const SOCK_NOSIGPIPE = 0x40000000; | ||
| 232 | pub const SOCK_FLAGS_MASK = 0xf0000000; | ||
| 233 | |||
| 234 | pub const SO_DEBUG = 0x0001; | ||
| 235 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 236 | pub const SO_REUSEADDR = 0x0004; | ||
| 237 | pub const SO_KEEPALIVE = 0x0008; | ||
| 238 | pub const SO_DONTROUTE = 0x0010; | ||
| 239 | pub const SO_BROADCAST = 0x0020; | ||
| 240 | pub const SO_USELOOPBACK = 0x0040; | ||
| 241 | pub const SO_LINGER = 0x0080; | ||
| 242 | pub const SO_OOBINLINE = 0x0100; | ||
| 243 | pub const SO_REUSEPORT = 0x0200; | ||
| 244 | pub const SO_NOSIGPIPE = 0x0800; | ||
| 245 | pub const SO_ACCEPTFILTER = 0x1000; | ||
| 246 | pub const SO_TIMESTAMP = 0x2000; | ||
| 247 | pub const SO_RERROR = 0x4000; | ||
| 248 | |||
| 249 | pub const SO_SNDBUF = 0x1001; | ||
| 250 | pub const SO_RCVBUF = 0x1002; | ||
| 251 | pub const SO_SNDLOWAT = 0x1003; | ||
| 252 | pub const SO_RCVLOWAT = 0x1004; | ||
| 253 | pub const SO_ERROR = 0x1007; | ||
| 254 | pub const SO_TYPE = 0x1008; | ||
| 255 | pub const SO_OVERFLOWED = 0x1009; | ||
| 256 | |||
| 257 | pub const SO_NOHEADER = 0x100a; | ||
| 258 | pub const SO_SNDTIMEO = 0x100b; | ||
| 259 | pub const SO_RCVTIMEO = 0x100c; | ||
| 260 | |||
| 261 | pub const SOL_SOCKET = 0xffff; | ||
| 262 | |||
| 263 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 264 | pub const PF_LOCAL = AF_LOCAL; | ||
| 265 | pub const PF_UNIX = PF_LOCAL; | ||
| 266 | pub const PF_INET = AF_INET; | ||
| 267 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 268 | pub const PF_PUP = AF_PUP; | ||
| 269 | pub const PF_CHAOS = AF_CHAOS; | ||
| 270 | pub const PF_NS = AF_NS; | ||
| 271 | pub const PF_ISO = AF_ISO; | ||
| 272 | pub const PF_OSI = AF_ISO; | ||
| 273 | pub const PF_ECMA = AF_ECMA; | ||
| 274 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 275 | pub const PF_CCITT = AF_CCITT; | ||
| 276 | pub const PF_SNA = AF_SNA; | ||
| 277 | pub const PF_DECnet = AF_DECnet; | ||
| 278 | pub const PF_DLI = AF_DLI; | ||
| 279 | pub const PF_LAT = AF_LAT; | ||
| 280 | pub const PF_HYLINK = AF_HYLINK; | ||
| 281 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 282 | pub const PF_OROUTE = AF_OROUTE; | ||
| 283 | pub const PF_LINK = AF_LINK; | ||
| 284 | pub const PF_COIP = AF_COIP; | ||
| 285 | pub const PF_CNT = AF_CNT; | ||
| 286 | pub const PF_INET6 = AF_INET6; | ||
| 287 | pub const PF_IPX = AF_IPX; | ||
| 288 | pub const PF_ISDN = AF_ISDN; | ||
| 289 | pub const PF_E164 = AF_E164; | ||
| 290 | pub const PF_NATM = AF_NATM; | ||
| 291 | pub const PF_ARP = AF_ARP; | ||
| 292 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 293 | pub const PF_MPLS = AF_MPLS; | ||
| 294 | pub const PF_ROUTE = AF_ROUTE; | ||
| 295 | pub const PF_CAN = AF_CAN; | ||
| 296 | pub const PF_ETHER = AF_ETHER; | ||
| 297 | pub const PF_MAX = AF_MAX; | ||
| 298 | |||
| 299 | pub const AF_UNSPEC = 0; | ||
| 300 | pub const AF_LOCAL = 1; | ||
| 301 | pub const AF_UNIX = AF_LOCAL; | ||
| 302 | pub const AF_INET = 2; | ||
| 303 | pub const AF_IMPLINK = 3; | ||
| 304 | pub const AF_PUP = 4; | ||
| 305 | pub const AF_CHAOS = 5; | ||
| 306 | pub const AF_NS = 6; | ||
| 307 | pub const AF_ISO = 7; | ||
| 308 | pub const AF_OSI = AF_ISO; | ||
| 309 | pub const AF_ECMA = 8; | ||
| 310 | pub const AF_DATAKIT = 9; | ||
| 311 | pub const AF_CCITT = 10; | ||
| 312 | pub const AF_SNA = 11; | ||
| 313 | pub const AF_DECnet = 12; | ||
| 314 | pub const AF_DLI = 13; | ||
| 315 | pub const AF_LAT = 14; | ||
| 316 | pub const AF_HYLINK = 15; | ||
| 317 | pub const AF_APPLETALK = 16; | ||
| 318 | pub const AF_OROUTE = 17; | ||
| 319 | pub const AF_LINK = 18; | ||
| 320 | pub const AF_COIP = 20; | ||
| 321 | pub const AF_CNT = 21; | ||
| 322 | pub const AF_IPX = 23; | ||
| 323 | pub const AF_INET6 = 24; | ||
| 324 | pub const AF_ISDN = 26; | ||
| 325 | pub const AF_E164 = AF_ISDN; | ||
| 326 | pub const AF_NATM = 27; | ||
| 327 | pub const AF_ARP = 28; | ||
| 328 | pub const AF_BLUETOOTH = 31; | ||
| 329 | pub const AF_IEEE80211 = 32; | ||
| 330 | pub const AF_MPLS = 33; | ||
| 331 | pub const AF_ROUTE = 34; | ||
| 332 | pub const AF_CAN = 35; | ||
| 333 | pub const AF_ETHER = 36; | ||
| 334 | pub const AF_MAX = 37; | ||
| 335 | |||
| 336 | pub const in_port_t = u16; | ||
| 337 | pub const sa_family_t = u8; | ||
| 338 | |||
| 339 | pub const sockaddr = extern struct { | ||
| 340 | /// total length | ||
| 341 | len: u8, | ||
| 342 | |||
| 343 | /// address family | ||
| 344 | family: sa_family_t, | ||
| 345 | |||
| 346 | /// actually longer; address value | ||
| 347 | data: [14]u8, | ||
| 348 | }; | ||
| 349 | |||
| 350 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 351 | |||
| 352 | pub const sockaddr_in = extern struct { | ||
| 353 | len: u8 = @sizeOf(sockaddr_in), | ||
| 354 | family: sa_family_t = AF_INET, | ||
| 355 | port: in_port_t, | ||
| 356 | addr: u32, | ||
| 357 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 358 | }; | ||
| 359 | |||
| 360 | pub const sockaddr_in6 = extern struct { | ||
| 361 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 362 | family: sa_family_t = AF_INET6, | ||
| 363 | port: in_port_t, | ||
| 364 | flowinfo: u32, | ||
| 365 | addr: [16]u8, | ||
| 366 | scope_id: u32, | ||
| 367 | }; | ||
| 368 | |||
| 369 | /// Definitions for UNIX IPC domain. | ||
| 370 | pub const sockaddr_un = extern struct { | ||
| 371 | /// total sockaddr length | ||
| 372 | len: u8 = @sizeOf(sockaddr_un), | ||
| 373 | |||
| 374 | /// AF_LOCAL | ||
| 375 | family: sa_family_t = AF_LOCAL, | ||
| 376 | |||
| 377 | /// path name | ||
| 378 | path: [104]u8, | ||
| 379 | }; | ||
| 380 | |||
| 381 | /// get address to use bind() | ||
| 382 | pub const AI_PASSIVE = 0x00000001; | ||
| 383 | |||
| 384 | /// fill ai_canonname | ||
| 385 | pub const AI_CANONNAME = 0x00000002; | ||
| 386 | |||
| 387 | /// prevent host name resolution | ||
| 388 | pub const AI_NUMERICHOST = 0x00000004; | ||
| 389 | |||
| 390 | /// prevent service name resolution | ||
| 391 | pub const AI_NUMERICSERV = 0x00000008; | ||
| 392 | |||
| 393 | /// only if any address is assigned | ||
| 394 | pub const AI_ADDRCONFIG = 0x00000400; | ||
| 395 | |||
| 396 | pub const CTL_KERN = 1; | ||
| 397 | pub const CTL_DEBUG = 5; | ||
| 398 | |||
| 399 | pub const KERN_PROC_ARGS = 48; // struct: process argv/env | ||
| 400 | pub const KERN_PROC_PATHNAME = 5; // path to executable | ||
| 401 | pub const KERN_IOV_MAX = 38; | ||
| 402 | |||
| 403 | pub const PATH_MAX = 1024; | ||
| 404 | pub const IOV_MAX = KERN_IOV_MAX; | ||
| 405 | |||
| 406 | pub const STDIN_FILENO = 0; | ||
| 407 | pub const STDOUT_FILENO = 1; | ||
| 408 | pub const STDERR_FILENO = 2; | ||
| 409 | |||
| 410 | pub const PROT_NONE = 0; | ||
| 411 | pub const PROT_READ = 1; | ||
| 412 | pub const PROT_WRITE = 2; | ||
| 413 | pub const PROT_EXEC = 4; | ||
| 414 | |||
| 415 | pub const CLOCK_REALTIME = 0; | ||
| 416 | pub const CLOCK_VIRTUAL = 1; | ||
| 417 | pub const CLOCK_PROF = 2; | ||
| 418 | pub const CLOCK_MONOTONIC = 3; | ||
| 419 | pub const CLOCK_THREAD_CPUTIME_ID = 0x20000000; | ||
| 420 | pub const CLOCK_PROCESS_CPUTIME_ID = 0x40000000; | ||
| 421 | |||
| 422 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 423 | pub const MAP_SHARED = 0x0001; | ||
| 424 | pub const MAP_PRIVATE = 0x0002; | ||
| 425 | pub const MAP_REMAPDUP = 0x0004; | ||
| 426 | pub const MAP_FIXED = 0x0010; | ||
| 427 | pub const MAP_RENAME = 0x0020; | ||
| 428 | pub const MAP_NORESERVE = 0x0040; | ||
| 429 | pub const MAP_INHERIT = 0x0080; | ||
| 430 | pub const MAP_HASSEMAPHORE = 0x0200; | ||
| 431 | pub const MAP_TRYFIXED = 0x0400; | ||
| 432 | pub const MAP_WIRED = 0x0800; | ||
| 433 | |||
| 434 | pub const MAP_FILE = 0x0000; | ||
| 435 | pub const MAP_NOSYNC = 0x0800; | ||
| 436 | pub const MAP_ANON = 0x1000; | ||
| 437 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 438 | pub const MAP_STACK = 0x2000; | ||
| 439 | |||
| 440 | pub const WNOHANG = 0x00000001; | ||
| 441 | pub const WUNTRACED = 0x00000002; | ||
| 442 | pub const WSTOPPED = WUNTRACED; | ||
| 443 | pub const WCONTINUED = 0x00000010; | ||
| 444 | pub const WNOWAIT = 0x00010000; | ||
| 445 | pub const WEXITED = 0x00000020; | ||
| 446 | pub const WTRAPPED = 0x00000040; | ||
| 447 | |||
| 448 | pub const SA_ONSTACK = 0x0001; | ||
| 449 | pub const SA_RESTART = 0x0002; | ||
| 450 | pub const SA_RESETHAND = 0x0004; | ||
| 451 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 452 | pub const SA_NODEFER = 0x0010; | ||
| 453 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 454 | pub const SA_SIGINFO = 0x0040; | ||
| 455 | |||
| 456 | pub const SIGHUP = 1; | ||
| 457 | pub const SIGINT = 2; | ||
| 458 | pub const SIGQUIT = 3; | ||
| 459 | pub const SIGILL = 4; | ||
| 460 | pub const SIGTRAP = 5; | ||
| 461 | pub const SIGABRT = 6; | ||
| 462 | pub const SIGIOT = SIGABRT; | ||
| 463 | pub const SIGEMT = 7; | ||
| 464 | pub const SIGFPE = 8; | ||
| 465 | pub const SIGKILL = 9; | ||
| 466 | pub const SIGBUS = 10; | ||
| 467 | pub const SIGSEGV = 11; | ||
| 468 | pub const SIGSYS = 12; | ||
| 469 | pub const SIGPIPE = 13; | ||
| 470 | pub const SIGALRM = 14; | ||
| 471 | pub const SIGTERM = 15; | ||
| 472 | pub const SIGURG = 16; | ||
| 473 | pub const SIGSTOP = 17; | ||
| 474 | pub const SIGTSTP = 18; | ||
| 475 | pub const SIGCONT = 19; | ||
| 476 | pub const SIGCHLD = 20; | ||
| 477 | pub const SIGTTIN = 21; | ||
| 478 | pub const SIGTTOU = 22; | ||
| 479 | pub const SIGIO = 23; | ||
| 480 | pub const SIGXCPU = 24; | ||
| 481 | pub const SIGXFSZ = 25; | ||
| 482 | pub const SIGVTALRM = 26; | ||
| 483 | pub const SIGPROF = 27; | ||
| 484 | pub const SIGWINCH = 28; | ||
| 485 | pub const SIGINFO = 29; | ||
| 486 | pub const SIGUSR1 = 30; | ||
| 487 | pub const SIGUSR2 = 31; | ||
| 488 | pub const SIGPWR = 32; | ||
| 489 | |||
| 490 | pub const SIGRTMIN = 33; | ||
| 491 | pub const SIGRTMAX = 63; | ||
| 492 | |||
| 493 | // access function | ||
| 494 | pub const F_OK = 0; // test for existence of file | ||
| 495 | pub const X_OK = 1; // test for execute or search permission | ||
| 496 | pub const W_OK = 2; // test for write permission | ||
| 497 | pub const R_OK = 4; // test for read permission | ||
| 498 | |||
| 499 | /// open for reading only | ||
| 500 | pub const O_RDONLY = 0x00000000; | ||
| 501 | |||
| 502 | /// open for writing only | ||
| 503 | pub const O_WRONLY = 0x00000001; | ||
| 504 | |||
| 505 | /// open for reading and writing | ||
| 506 | pub const O_RDWR = 0x00000002; | ||
| 507 | |||
| 508 | /// mask for above modes | ||
| 509 | pub const O_ACCMODE = 0x00000003; | ||
| 510 | |||
| 511 | /// no delay | ||
| 512 | pub const O_NONBLOCK = 0x00000004; | ||
| 513 | |||
| 514 | /// set append mode | ||
| 515 | pub const O_APPEND = 0x00000008; | ||
| 516 | |||
| 517 | /// open with shared file lock | ||
| 518 | pub const O_SHLOCK = 0x00000010; | ||
| 519 | |||
| 520 | /// open with exclusive file lock | ||
| 521 | pub const O_EXLOCK = 0x00000020; | ||
| 522 | |||
| 523 | /// signal pgrp when data ready | ||
| 524 | pub const O_ASYNC = 0x00000040; | ||
| 525 | |||
| 526 | /// synchronous writes | ||
| 527 | pub const O_SYNC = 0x00000080; | ||
| 528 | |||
| 529 | /// don't follow symlinks on the last | ||
| 530 | pub const O_NOFOLLOW = 0x00000100; | ||
| 531 | |||
| 532 | /// create if nonexistent | ||
| 533 | pub const O_CREAT = 0x00000200; | ||
| 534 | |||
| 535 | /// truncate to zero length | ||
| 536 | pub const O_TRUNC = 0x00000400; | ||
| 537 | |||
| 538 | /// error if already exists | ||
| 539 | pub const O_EXCL = 0x00000800; | ||
| 540 | |||
| 541 | /// don't assign controlling terminal | ||
| 542 | pub const O_NOCTTY = 0x00008000; | ||
| 543 | |||
| 544 | /// write: I/O data completion | ||
| 545 | pub const O_DSYNC = 0x00010000; | ||
| 546 | |||
| 547 | /// read: I/O completion as for write | ||
| 548 | pub const O_RSYNC = 0x00020000; | ||
| 549 | |||
| 550 | /// use alternate i/o semantics | ||
| 551 | pub const O_ALT_IO = 0x00040000; | ||
| 552 | |||
| 553 | /// direct I/O hint | ||
| 554 | pub const O_DIRECT = 0x00080000; | ||
| 555 | |||
| 556 | /// fail if not a directory | ||
| 557 | pub const O_DIRECTORY = 0x00200000; | ||
| 558 | |||
| 559 | /// set close on exec | ||
| 560 | pub const O_CLOEXEC = 0x00400000; | ||
| 561 | |||
| 562 | /// skip search permission checks | ||
| 563 | pub const O_SEARCH = 0x00800000; | ||
| 564 | |||
| 565 | pub const F_DUPFD = 0; | ||
| 566 | pub const F_GETFD = 1; | ||
| 567 | pub const F_SETFD = 2; | ||
| 568 | pub const F_GETFL = 3; | ||
| 569 | pub const F_SETFL = 4; | ||
| 570 | |||
| 571 | pub const F_GETOWN = 5; | ||
| 572 | pub const F_SETOWN = 6; | ||
| 573 | |||
| 574 | pub const F_GETLK = 7; | ||
| 575 | pub const F_SETLK = 8; | ||
| 576 | pub const F_SETLKW = 9; | ||
| 577 | |||
| 578 | pub const F_RDLCK = 1; | ||
| 579 | pub const F_WRLCK = 3; | ||
| 580 | pub const F_UNLCK = 2; | ||
| 581 | |||
| 582 | pub const LOCK_SH = 1; | ||
| 583 | pub const LOCK_EX = 2; | ||
| 584 | pub const LOCK_UN = 8; | ||
| 585 | pub const LOCK_NB = 4; | ||
| 586 | |||
| 587 | pub const FD_CLOEXEC = 1; | ||
| 588 | |||
| 589 | pub const SEEK_SET = 0; | ||
| 590 | pub const SEEK_CUR = 1; | ||
| 591 | pub const SEEK_END = 2; | ||
| 592 | |||
| 593 | pub const SIG_BLOCK = 1; | ||
| 594 | pub const SIG_UNBLOCK = 2; | ||
| 595 | pub const SIG_SETMASK = 3; | ||
| 596 | |||
| 597 | pub const DT_UNKNOWN = 0; | ||
| 598 | pub const DT_FIFO = 1; | ||
| 599 | pub const DT_CHR = 2; | ||
| 600 | pub const DT_DIR = 4; | ||
| 601 | pub const DT_BLK = 6; | ||
| 602 | pub const DT_REG = 8; | ||
| 603 | pub const DT_LNK = 10; | ||
| 604 | pub const DT_SOCK = 12; | ||
| 605 | pub const DT_WHT = 14; | ||
| 606 | |||
| 607 | /// add event to kq (implies enable) | ||
| 608 | pub const EV_ADD = 0x0001; | ||
| 609 | |||
| 610 | /// delete event from kq | ||
| 611 | pub const EV_DELETE = 0x0002; | ||
| 612 | |||
| 613 | /// enable event | ||
| 614 | pub const EV_ENABLE = 0x0004; | ||
| 615 | |||
| 616 | /// disable event (not reported) | ||
| 617 | pub const EV_DISABLE = 0x0008; | ||
| 618 | |||
| 619 | /// only report one occurrence | ||
| 620 | pub const EV_ONESHOT = 0x0010; | ||
| 621 | |||
| 622 | /// clear event state after reporting | ||
| 623 | pub const EV_CLEAR = 0x0020; | ||
| 624 | |||
| 625 | /// force immediate event output | ||
| 626 | /// ... with or without EV_ERROR | ||
| 627 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 628 | /// on syscalls supporting flags | ||
| 629 | pub const EV_RECEIPT = 0x0040; | ||
| 630 | |||
| 631 | /// disable event after reporting | ||
| 632 | pub const EV_DISPATCH = 0x0080; | ||
| 633 | |||
| 634 | pub const EVFILT_READ = 0; | ||
| 635 | pub const EVFILT_WRITE = 1; | ||
| 636 | |||
| 637 | /// attached to aio requests | ||
| 638 | pub const EVFILT_AIO = 2; | ||
| 639 | |||
| 640 | /// attached to vnodes | ||
| 641 | pub const EVFILT_VNODE = 3; | ||
| 642 | |||
| 643 | /// attached to struct proc | ||
| 644 | pub const EVFILT_PROC = 4; | ||
| 645 | |||
| 646 | /// attached to struct proc | ||
| 647 | pub const EVFILT_SIGNAL = 5; | ||
| 648 | |||
| 649 | /// timers | ||
| 650 | pub const EVFILT_TIMER = 6; | ||
| 651 | |||
| 652 | /// Filesystem events | ||
| 653 | pub const EVFILT_FS = 7; | ||
| 654 | |||
| 655 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 656 | pub const NOTE_TRIGGER = 0x08000000; | ||
| 657 | |||
| 658 | /// low water mark | ||
| 659 | pub const NOTE_LOWAT = 0x00000001; | ||
| 660 | |||
| 661 | /// vnode was removed | ||
| 662 | pub const NOTE_DELETE = 0x00000001; | ||
| 663 | |||
| 664 | /// data contents changed | ||
| 665 | pub const NOTE_WRITE = 0x00000002; | ||
| 666 | |||
| 667 | /// size increased | ||
| 668 | pub const NOTE_EXTEND = 0x00000004; | ||
| 669 | |||
| 670 | /// attributes changed | ||
| 671 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 672 | |||
| 673 | /// link count changed | ||
| 674 | pub const NOTE_LINK = 0x00000010; | ||
| 675 | |||
| 676 | /// vnode was renamed | ||
| 677 | pub const NOTE_RENAME = 0x00000020; | ||
| 678 | |||
| 679 | /// vnode access was revoked | ||
| 680 | pub const NOTE_REVOKE = 0x00000040; | ||
| 681 | |||
| 682 | /// process exited | ||
| 683 | pub const NOTE_EXIT = 0x80000000; | ||
| 684 | |||
| 685 | /// process forked | ||
| 686 | pub const NOTE_FORK = 0x40000000; | ||
| 687 | |||
| 688 | /// process exec'd | ||
| 689 | pub const NOTE_EXEC = 0x20000000; | ||
| 690 | |||
| 691 | /// mask for signal & exit status | ||
| 692 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 693 | pub const NOTE_PCTRLMASK = 0xf0000000; | ||
| 694 | |||
| 695 | pub const TIOCCBRK = 0x2000747a; | ||
| 696 | pub const TIOCCDTR = 0x20007478; | ||
| 697 | pub const TIOCCONS = 0x80047462; | ||
| 698 | pub const TIOCDCDTIMESTAMP = 0x40107458; | ||
| 699 | pub const TIOCDRAIN = 0x2000745e; | ||
| 700 | pub const TIOCEXCL = 0x2000740d; | ||
| 701 | pub const TIOCEXT = 0x80047460; | ||
| 702 | pub const TIOCFLAG_CDTRCTS = 0x10; | ||
| 703 | pub const TIOCFLAG_CLOCAL = 0x2; | ||
| 704 | pub const TIOCFLAG_CRTSCTS = 0x4; | ||
| 705 | pub const TIOCFLAG_MDMBUF = 0x8; | ||
| 706 | pub const TIOCFLAG_SOFTCAR = 0x1; | ||
| 707 | pub const TIOCFLUSH = 0x80047410; | ||
| 708 | pub const TIOCGETA = 0x402c7413; | ||
| 709 | pub const TIOCGETD = 0x4004741a; | ||
| 710 | pub const TIOCGFLAGS = 0x4004745d; | ||
| 711 | pub const TIOCGLINED = 0x40207442; | ||
| 712 | pub const TIOCGPGRP = 0x40047477; | ||
| 713 | pub const TIOCGQSIZE = 0x40047481; | ||
| 714 | pub const TIOCGRANTPT = 0x20007447; | ||
| 715 | pub const TIOCGSID = 0x40047463; | ||
| 716 | pub const TIOCGSIZE = 0x40087468; | ||
| 717 | pub const TIOCGWINSZ = 0x40087468; | ||
| 718 | pub const TIOCMBIC = 0x8004746b; | ||
| 719 | pub const TIOCMBIS = 0x8004746c; | ||
| 720 | pub const TIOCMGET = 0x4004746a; | ||
| 721 | pub const TIOCMSET = 0x8004746d; | ||
| 722 | pub const TIOCM_CAR = 0x40; | ||
| 723 | pub const TIOCM_CD = 0x40; | ||
| 724 | pub const TIOCM_CTS = 0x20; | ||
| 725 | pub const TIOCM_DSR = 0x100; | ||
| 726 | pub const TIOCM_DTR = 0x2; | ||
| 727 | pub const TIOCM_LE = 0x1; | ||
| 728 | pub const TIOCM_RI = 0x80; | ||
| 729 | pub const TIOCM_RNG = 0x80; | ||
| 730 | pub const TIOCM_RTS = 0x4; | ||
| 731 | pub const TIOCM_SR = 0x10; | ||
| 732 | pub const TIOCM_ST = 0x8; | ||
| 733 | pub const TIOCNOTTY = 0x20007471; | ||
| 734 | pub const TIOCNXCL = 0x2000740e; | ||
| 735 | pub const TIOCOUTQ = 0x40047473; | ||
| 736 | pub const TIOCPKT = 0x80047470; | ||
| 737 | pub const TIOCPKT_DATA = 0x0; | ||
| 738 | pub const TIOCPKT_DOSTOP = 0x20; | ||
| 739 | pub const TIOCPKT_FLUSHREAD = 0x1; | ||
| 740 | pub const TIOCPKT_FLUSHWRITE = 0x2; | ||
| 741 | pub const TIOCPKT_IOCTL = 0x40; | ||
| 742 | pub const TIOCPKT_NOSTOP = 0x10; | ||
| 743 | pub const TIOCPKT_START = 0x8; | ||
| 744 | pub const TIOCPKT_STOP = 0x4; | ||
| 745 | pub const TIOCPTMGET = 0x40287446; | ||
| 746 | pub const TIOCPTSNAME = 0x40287448; | ||
| 747 | pub const TIOCRCVFRAME = 0x80087445; | ||
| 748 | pub const TIOCREMOTE = 0x80047469; | ||
| 749 | pub const TIOCSBRK = 0x2000747b; | ||
| 750 | pub const TIOCSCTTY = 0x20007461; | ||
| 751 | pub const TIOCSDTR = 0x20007479; | ||
| 752 | pub const TIOCSETA = 0x802c7414; | ||
| 753 | pub const TIOCSETAF = 0x802c7416; | ||
| 754 | pub const TIOCSETAW = 0x802c7415; | ||
| 755 | pub const TIOCSETD = 0x8004741b; | ||
| 756 | pub const TIOCSFLAGS = 0x8004745c; | ||
| 757 | pub const TIOCSIG = 0x2000745f; | ||
| 758 | pub const TIOCSLINED = 0x80207443; | ||
| 759 | pub const TIOCSPGRP = 0x80047476; | ||
| 760 | pub const TIOCSQSIZE = 0x80047480; | ||
| 761 | pub const TIOCSSIZE = 0x80087467; | ||
| 762 | pub const TIOCSTART = 0x2000746e; | ||
| 763 | pub const TIOCSTAT = 0x80047465; | ||
| 764 | pub const TIOCSTI = 0x80017472; | ||
| 765 | pub const TIOCSTOP = 0x2000746f; | ||
| 766 | pub const TIOCSWINSZ = 0x80087467; | ||
| 767 | pub const TIOCUCNTL = 0x80047466; | ||
| 768 | pub const TIOCXMTFRAME = 0x80087444; | ||
| 769 | |||
| 770 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 771 | return @intCast(u8, (s >> 8) & 0xff); | ||
| 772 | } | ||
| 773 | pub fn WTERMSIG(s: u32) u32 { | ||
| 774 | return s & 0x7f; | ||
| 775 | } | ||
| 776 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 777 | return WEXITSTATUS(s); | ||
| 778 | } | ||
| 779 | pub fn WIFEXITED(s: u32) bool { | ||
| 780 | return WTERMSIG(s) == 0; | ||
| 781 | } | ||
| 782 | |||
| 783 | pub fn WIFCONTINUED(s: u32) bool { | ||
| 784 | return ((s & 0x7f) == 0xffff); | ||
| 785 | } | ||
| 786 | |||
| 787 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 788 | return ((s & 0x7f != 0x7f) and !WIFCONTINUED(s)); | ||
| 789 | } | ||
| 790 | |||
| 791 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 792 | return !WIFSTOPPED(s) and !WIFCONTINUED(s) and !WIFEXITED(s); | ||
| 793 | } | ||
| 794 | |||
| 795 | pub const winsize = extern struct { | ||
| 796 | ws_row: u16, | ||
| 797 | ws_col: u16, | ||
| 798 | ws_xpixel: u16, | ||
| 799 | ws_ypixel: u16, | ||
| 800 | }; | ||
| 801 | |||
| 802 | const NSIG = 32; | ||
| 803 | |||
| 804 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 805 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 806 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 807 | |||
| 808 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 809 | pub const Sigaction = extern struct { | ||
| 810 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 811 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 812 | |||
| 813 | /// signal handler | ||
| 814 | handler: extern union { | ||
| 815 | handler: ?handler_fn, | ||
| 816 | sigaction: ?sigaction_fn, | ||
| 817 | }, | ||
| 818 | /// signal mask to apply | ||
| 819 | mask: sigset_t, | ||
| 820 | /// signal options | ||
| 821 | flags: c_uint, | ||
| 822 | }; | ||
| 823 | |||
| 824 | pub const sigval_t = extern union { | ||
| 825 | int: i32, | ||
| 826 | ptr: ?*c_void, | ||
| 827 | }; | ||
| 828 | |||
| 829 | pub const siginfo_t = extern union { | ||
| 830 | pad: [128]u8, | ||
| 831 | info: _ksiginfo, | ||
| 832 | }; | ||
| 833 | |||
| 834 | pub const _ksiginfo = extern struct { | ||
| 835 | signo: i32, | ||
| 836 | code: i32, | ||
| 837 | errno: i32, | ||
| 838 | // 64bit architectures insert 4bytes of padding here, this is done by | ||
| 839 | // correctly aligning the reason field | ||
| 840 | reason: extern union { | ||
| 841 | rt: extern struct { | ||
| 842 | pid: pid_t, | ||
| 843 | uid: uid_t, | ||
| 844 | value: sigval_t, | ||
| 845 | }, | ||
| 846 | child: extern struct { | ||
| 847 | pid: pid_t, | ||
| 848 | uid: uid_t, | ||
| 849 | status: i32, | ||
| 850 | utime: clock_t, | ||
| 851 | stime: clock_t, | ||
| 852 | }, | ||
| 853 | fault: extern struct { | ||
| 854 | addr: ?*c_void, | ||
| 855 | trap: i32, | ||
| 856 | trap2: i32, | ||
| 857 | trap3: i32, | ||
| 858 | }, | ||
| 859 | poll: extern struct { | ||
| 860 | band: i32, | ||
| 861 | fd: i32, | ||
| 862 | }, | ||
| 863 | syscall: extern struct { | ||
| 864 | sysnum: i32, | ||
| 865 | retval: [2]i32, | ||
| 866 | @"error": i32, | ||
| 867 | args: [8]u64, | ||
| 868 | }, | ||
| 869 | ptrace_state: extern struct { | ||
| 870 | pe_report_event: i32, | ||
| 871 | option: extern union { | ||
| 872 | pe_other_pid: pid_t, | ||
| 873 | pe_lwp: lwpid_t, | ||
| 874 | }, | ||
| 875 | }, | ||
| 876 | } align(@sizeOf(usize)), | ||
| 877 | }; | ||
| 878 | |||
| 879 | pub const _SIG_WORDS = 4; | ||
| 880 | pub const _SIG_MAXSIG = 128; | ||
| 881 | |||
| 882 | pub inline fn _SIG_IDX(sig: usize) usize { | ||
| 883 | return sig - 1; | ||
| 884 | } | ||
| 885 | pub inline fn _SIG_WORD(sig: usize) usize { | ||
| 886 | return_SIG_IDX(sig) >> 5; | ||
| 887 | } | ||
| 888 | pub inline fn _SIG_BIT(sig: usize) usize { | ||
| 889 | return 1 << (_SIG_IDX(sig) & 31); | ||
| 890 | } | ||
| 891 | pub inline fn _SIG_VALID(sig: usize) usize { | ||
| 892 | return sig <= _SIG_MAXSIG and sig > 0; | ||
| 893 | } | ||
| 894 | |||
| 895 | pub const sigset_t = extern struct { | ||
| 896 | __bits: [_SIG_WORDS]u32, | ||
| 897 | }; | ||
| 898 | |||
| 899 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; | ||
| 900 | |||
| 901 | // XXX x86_64 specific | ||
| 902 | pub const mcontext_t = extern struct { | ||
| 903 | gregs: [26]u64, | ||
| 904 | mc_tlsbase: u64, | ||
| 905 | fpregs: [512]u8 align(8), | ||
| 906 | }; | ||
| 907 | |||
| 908 | pub const REG_RBP = 12; | ||
| 909 | pub const REG_RIP = 21; | ||
| 910 | pub const REG_RSP = 24; | ||
| 911 | |||
| 912 | pub const ucontext_t = extern struct { | ||
| 913 | flags: u32, | ||
| 914 | link: ?*ucontext_t, | ||
| 915 | sigmask: sigset_t, | ||
| 916 | stack: stack_t, | ||
| 917 | mcontext: mcontext_t, | ||
| 918 | __pad: [ | ||
| 919 | switch (builtin.cpu.arch) { | ||
| 920 | .i386 => 4, | ||
| 921 | .mips, .mipsel, .mips64, .mips64el => 14, | ||
| 922 | .arm, .armeb, .thumb, .thumbeb => 1, | ||
| 923 | .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, | ||
| 924 | else => 0, | ||
| 925 | } | ||
| 926 | ]u32, | ||
| 927 | }; | ||
| 928 | |||
| 929 | pub const E = enum(u16) { | ||
| 930 | /// No error occurred. | ||
| 931 | SUCCESS = 0, | ||
| 932 | PERM = 1, // Operation not permitted | ||
| 933 | NOENT = 2, // No such file or directory | ||
| 934 | SRCH = 3, // No such process | ||
| 935 | INTR = 4, // Interrupted system call | ||
| 936 | IO = 5, // Input/output error | ||
| 937 | NXIO = 6, // Device not configured | ||
| 938 | @"2BIG" = 7, // Argument list too long | ||
| 939 | NOEXEC = 8, // Exec format error | ||
| 940 | BADF = 9, // Bad file descriptor | ||
| 941 | CHILD = 10, // No child processes | ||
| 942 | DEADLK = 11, // Resource deadlock avoided | ||
| 943 | // 11 was AGAIN | ||
| 944 | NOMEM = 12, // Cannot allocate memory | ||
| 945 | ACCES = 13, // Permission denied | ||
| 946 | FAULT = 14, // Bad address | ||
| 947 | NOTBLK = 15, // Block device required | ||
| 948 | BUSY = 16, // Device busy | ||
| 949 | EXIST = 17, // File exists | ||
| 950 | XDEV = 18, // Cross-device link | ||
| 951 | NODEV = 19, // Operation not supported by device | ||
| 952 | NOTDIR = 20, // Not a directory | ||
| 953 | ISDIR = 21, // Is a directory | ||
| 954 | INVAL = 22, // Invalid argument | ||
| 955 | NFILE = 23, // Too many open files in system | ||
| 956 | MFILE = 24, // Too many open files | ||
| 957 | NOTTY = 25, // Inappropriate ioctl for device | ||
| 958 | TXTBSY = 26, // Text file busy | ||
| 959 | FBIG = 27, // File too large | ||
| 960 | NOSPC = 28, // No space left on device | ||
| 961 | SPIPE = 29, // Illegal seek | ||
| 962 | ROFS = 30, // Read-only file system | ||
| 963 | MLINK = 31, // Too many links | ||
| 964 | PIPE = 32, // Broken pipe | ||
| 965 | |||
| 966 | // math software | ||
| 967 | DOM = 33, // Numerical argument out of domain | ||
| 968 | RANGE = 34, // Result too large or too small | ||
| 969 | |||
| 970 | // non-blocking and interrupt i/o | ||
| 971 | // also: WOULDBLOCK: operation would block | ||
| 972 | AGAIN = 35, // Resource temporarily unavailable | ||
| 973 | INPROGRESS = 36, // Operation now in progress | ||
| 974 | ALREADY = 37, // Operation already in progress | ||
| 975 | |||
| 976 | // ipc/network software -- argument errors | ||
| 977 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 978 | DESTADDRREQ = 39, // Destination address required | ||
| 979 | MSGSIZE = 40, // Message too long | ||
| 980 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 981 | NOPROTOOPT = 42, // Protocol option not available | ||
| 982 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 983 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 984 | OPNOTSUPP = 45, // Operation not supported | ||
| 985 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 986 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 987 | ADDRINUSE = 48, // Address already in use | ||
| 988 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 989 | |||
| 990 | // ipc/network software -- operational errors | ||
| 991 | NETDOWN = 50, // Network is down | ||
| 992 | NETUNREACH = 51, // Network is unreachable | ||
| 993 | NETRESET = 52, // Network dropped connection on reset | ||
| 994 | CONNABORTED = 53, // Software caused connection abort | ||
| 995 | CONNRESET = 54, // Connection reset by peer | ||
| 996 | NOBUFS = 55, // No buffer space available | ||
| 997 | ISCONN = 56, // Socket is already connected | ||
| 998 | NOTCONN = 57, // Socket is not connected | ||
| 999 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 1000 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 1001 | TIMEDOUT = 60, // Operation timed out | ||
| 1002 | CONNREFUSED = 61, // Connection refused | ||
| 1003 | |||
| 1004 | LOOP = 62, // Too many levels of symbolic links | ||
| 1005 | NAMETOOLONG = 63, // File name too long | ||
| 1006 | |||
| 1007 | // should be rearranged | ||
| 1008 | HOSTDOWN = 64, // Host is down | ||
| 1009 | HOSTUNREACH = 65, // No route to host | ||
| 1010 | NOTEMPTY = 66, // Directory not empty | ||
| 1011 | |||
| 1012 | // quotas & mush | ||
| 1013 | PROCLIM = 67, // Too many processes | ||
| 1014 | USERS = 68, // Too many users | ||
| 1015 | DQUOT = 69, // Disc quota exceeded | ||
| 1016 | |||
| 1017 | // Network File System | ||
| 1018 | STALE = 70, // Stale NFS file handle | ||
| 1019 | REMOTE = 71, // Too many levels of remote in path | ||
| 1020 | BADRPC = 72, // RPC struct is bad | ||
| 1021 | RPCMISMATCH = 73, // RPC version wrong | ||
| 1022 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 1023 | PROGMISMATCH = 75, // Program version wrong | ||
| 1024 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 1025 | |||
| 1026 | NOLCK = 77, // No locks available | ||
| 1027 | NOSYS = 78, // Function not implemented | ||
| 1028 | |||
| 1029 | FTYPE = 79, // Inappropriate file type or format | ||
| 1030 | AUTH = 80, // Authentication error | ||
| 1031 | NEEDAUTH = 81, // Need authenticator | ||
| 1032 | |||
| 1033 | // SystemV IPC | ||
| 1034 | IDRM = 82, // Identifier removed | ||
| 1035 | NOMSG = 83, // No message of desired type | ||
| 1036 | OVERFLOW = 84, // Value too large to be stored in data type | ||
| 1037 | |||
| 1038 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | ||
| 1039 | ILSEQ = 85, // Illegal byte sequence | ||
| 1040 | |||
| 1041 | // From IEEE Std 1003.1-2001 | ||
| 1042 | // Base, Realtime, Threads or Thread Priority Scheduling option errors | ||
| 1043 | NOTSUP = 86, // Not supported | ||
| 1044 | |||
| 1045 | // Realtime option errors | ||
| 1046 | CANCELED = 87, // Operation canceled | ||
| 1047 | |||
| 1048 | // Realtime, XSI STREAMS option errors | ||
| 1049 | BADMSG = 88, // Bad or Corrupt message | ||
| 1050 | |||
| 1051 | // XSI STREAMS option errors | ||
| 1052 | NODATA = 89, // No message available | ||
| 1053 | NOSR = 90, // No STREAM resources | ||
| 1054 | NOSTR = 91, // Not a STREAM | ||
| 1055 | TIME = 92, // STREAM ioctl timeout | ||
| 1056 | |||
| 1057 | // File system extended attribute errors | ||
| 1058 | NOATTR = 93, // Attribute not found | ||
| 1059 | |||
| 1060 | // Realtime, XSI STREAMS option errors | ||
| 1061 | MULTIHOP = 94, // Multihop attempted | ||
| 1062 | NOLINK = 95, // Link has been severed | ||
| 1063 | PROTO = 96, // Protocol error | ||
| 1064 | |||
| 1065 | _, | ||
| 1066 | }; | ||
| 1067 | |||
| 1068 | pub const MINSIGSTKSZ = 8192; | ||
| 1069 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 1070 | |||
| 1071 | pub const SS_ONSTACK = 1; | ||
| 1072 | pub const SS_DISABLE = 4; | ||
| 1073 | |||
| 1074 | pub const stack_t = extern struct { | ||
| 1075 | ss_sp: [*]u8, | ||
| 1076 | ss_size: isize, | ||
| 1077 | ss_flags: i32, | ||
| 1078 | }; | ||
| 1079 | |||
| 1080 | pub const S_IFMT = 0o170000; | ||
| 1081 | |||
| 1082 | pub const S_IFIFO = 0o010000; | ||
| 1083 | pub const S_IFCHR = 0o020000; | ||
| 1084 | pub const S_IFDIR = 0o040000; | ||
| 1085 | pub const S_IFBLK = 0o060000; | ||
| 1086 | pub const S_IFREG = 0o100000; | ||
| 1087 | pub const S_IFLNK = 0o120000; | ||
| 1088 | pub const S_IFSOCK = 0o140000; | ||
| 1089 | pub const S_IFWHT = 0o160000; | ||
| 1090 | |||
| 1091 | pub const S_ISUID = 0o4000; | ||
| 1092 | pub const S_ISGID = 0o2000; | ||
| 1093 | pub const S_ISVTX = 0o1000; | ||
| 1094 | pub const S_IRWXU = 0o700; | ||
| 1095 | pub const S_IRUSR = 0o400; | ||
| 1096 | pub const S_IWUSR = 0o200; | ||
| 1097 | pub const S_IXUSR = 0o100; | ||
| 1098 | pub const S_IRWXG = 0o070; | ||
| 1099 | pub const S_IRGRP = 0o040; | ||
| 1100 | pub const S_IWGRP = 0o020; | ||
| 1101 | pub const S_IXGRP = 0o010; | ||
| 1102 | pub const S_IRWXO = 0o007; | ||
| 1103 | pub const S_IROTH = 0o004; | ||
| 1104 | pub const S_IWOTH = 0o002; | ||
| 1105 | pub const S_IXOTH = 0o001; | ||
| 1106 | |||
| 1107 | pub fn S_ISFIFO(m: u32) bool { | ||
| 1108 | return m & S_IFMT == S_IFIFO; | ||
| 1109 | } | ||
| 1110 | |||
| 1111 | pub fn S_ISCHR(m: u32) bool { | ||
| 1112 | return m & S_IFMT == S_IFCHR; | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | pub fn S_ISDIR(m: u32) bool { | ||
| 1116 | return m & S_IFMT == S_IFDIR; | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | pub fn S_ISBLK(m: u32) bool { | ||
| 1120 | return m & S_IFMT == S_IFBLK; | ||
| 1121 | } | ||
| 1122 | |||
| 1123 | pub fn S_ISREG(m: u32) bool { | ||
| 1124 | return m & S_IFMT == S_IFREG; | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | pub fn S_ISLNK(m: u32) bool { | ||
| 1128 | return m & S_IFMT == S_IFLNK; | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1132 | return m & S_IFMT == S_IFSOCK; | ||
| 1133 | } | ||
| 1134 | |||
| 1135 | pub fn S_IWHT(m: u32) bool { | ||
| 1136 | return m & S_IFMT == S_IFWHT; | ||
| 1137 | } | ||
| 1138 | |||
| 1139 | /// Magic value that specify the use of the current working directory | ||
| 1140 | /// to determine the target of relative file paths in the openat() and | ||
| 1141 | /// similar syscalls. | ||
| 1142 | pub const AT_FDCWD = -100; | ||
| 1143 | |||
| 1144 | /// Check access using effective user and group ID | ||
| 1145 | pub const AT_EACCESS = 0x0100; | ||
| 1146 | |||
| 1147 | /// Do not follow symbolic links | ||
| 1148 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; | ||
| 1149 | |||
| 1150 | /// Follow symbolic link | ||
| 1151 | pub const AT_SYMLINK_FOLLOW = 0x0400; | ||
| 1152 | |||
| 1153 | /// Remove directory instead of file | ||
| 1154 | pub const AT_REMOVEDIR = 0x0800; | ||
| 1155 | |||
| 1156 | pub const HOST_NAME_MAX = 255; | ||
| 1157 | |||
| 1158 | /// dummy for IP | ||
| 1159 | pub const IPPROTO_IP = 0; | ||
| 1160 | |||
| 1161 | /// IP6 hop-by-hop options | ||
| 1162 | pub const IPPROTO_HOPOPTS = 0; | ||
| 1163 | |||
| 1164 | /// control message protocol | ||
| 1165 | pub const IPPROTO_ICMP = 1; | ||
| 1166 | |||
| 1167 | /// group mgmt protocol | ||
| 1168 | pub const IPPROTO_IGMP = 2; | ||
| 1169 | |||
| 1170 | /// gateway^2 (deprecated) | ||
| 1171 | pub const IPPROTO_GGP = 3; | ||
| 1172 | |||
| 1173 | /// IP header | ||
| 1174 | pub const IPPROTO_IPV4 = 4; | ||
| 1175 | |||
| 1176 | /// IP inside IP | ||
| 1177 | pub const IPPROTO_IPIP = 4; | ||
| 1178 | |||
| 1179 | /// tcp | ||
| 1180 | pub const IPPROTO_TCP = 6; | ||
| 1181 | |||
| 1182 | /// exterior gateway protocol | ||
| 1183 | pub const IPPROTO_EGP = 8; | ||
| 1184 | |||
| 1185 | /// pup | ||
| 1186 | pub const IPPROTO_PUP = 12; | ||
| 1187 | |||
| 1188 | /// user datagram protocol | ||
| 1189 | pub const IPPROTO_UDP = 17; | ||
| 1190 | |||
| 1191 | /// xns idp | ||
| 1192 | pub const IPPROTO_IDP = 22; | ||
| 1193 | |||
| 1194 | /// tp-4 w/ class negotiation | ||
| 1195 | pub const IPPROTO_TP = 29; | ||
| 1196 | |||
| 1197 | /// DCCP | ||
| 1198 | pub const IPPROTO_DCCP = 33; | ||
| 1199 | |||
| 1200 | /// IP6 header | ||
| 1201 | pub const IPPROTO_IPV6 = 41; | ||
| 1202 | |||
| 1203 | /// IP6 routing header | ||
| 1204 | pub const IPPROTO_ROUTING = 43; | ||
| 1205 | |||
| 1206 | /// IP6 fragmentation header | ||
| 1207 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1208 | |||
| 1209 | /// resource reservation | ||
| 1210 | pub const IPPROTO_RSVP = 46; | ||
| 1211 | |||
| 1212 | /// GRE encaps RFC 1701 | ||
| 1213 | pub const IPPROTO_GRE = 47; | ||
| 1214 | |||
| 1215 | /// encap. security payload | ||
| 1216 | pub const IPPROTO_ESP = 50; | ||
| 1217 | |||
| 1218 | /// authentication header | ||
| 1219 | pub const IPPROTO_AH = 51; | ||
| 1220 | |||
| 1221 | /// IP Mobility RFC 2004 | ||
| 1222 | pub const IPPROTO_MOBILE = 55; | ||
| 1223 | |||
| 1224 | /// IPv6 ICMP | ||
| 1225 | pub const IPPROTO_IPV6_ICMP = 58; | ||
| 1226 | |||
| 1227 | /// ICMP6 | ||
| 1228 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1229 | |||
| 1230 | /// IP6 no next header | ||
| 1231 | pub const IPPROTO_NONE = 59; | ||
| 1232 | |||
| 1233 | /// IP6 destination option | ||
| 1234 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1235 | |||
| 1236 | /// ISO cnlp | ||
| 1237 | pub const IPPROTO_EON = 80; | ||
| 1238 | |||
| 1239 | /// Ethernet-in-IP | ||
| 1240 | pub const IPPROTO_ETHERIP = 97; | ||
| 1241 | |||
| 1242 | /// encapsulation header | ||
| 1243 | pub const IPPROTO_ENCAP = 98; | ||
| 1244 | |||
| 1245 | /// Protocol indep. multicast | ||
| 1246 | pub const IPPROTO_PIM = 103; | ||
| 1247 | |||
| 1248 | /// IP Payload Comp. Protocol | ||
| 1249 | pub const IPPROTO_IPCOMP = 108; | ||
| 1250 | |||
| 1251 | /// VRRP RFC 2338 | ||
| 1252 | pub const IPPROTO_VRRP = 112; | ||
| 1253 | |||
| 1254 | /// Common Address Resolution Protocol | ||
| 1255 | pub const IPPROTO_CARP = 112; | ||
| 1256 | |||
| 1257 | /// L2TPv3 | ||
| 1258 | pub const IPPROTO_L2TP = 115; | ||
| 1259 | |||
| 1260 | /// SCTP | ||
| 1261 | pub const IPPROTO_SCTP = 132; | ||
| 1262 | |||
| 1263 | /// PFSYNC | ||
| 1264 | pub const IPPROTO_PFSYNC = 240; | ||
| 1265 | |||
| 1266 | /// raw IP packet | ||
| 1267 | pub const IPPROTO_RAW = 255; | ||
| 1268 | |||
| 1269 | pub const rlimit_resource = enum(c_int) { | ||
| 1270 | CPU = 0, | ||
| 1271 | FSIZE = 1, | ||
| 1272 | DATA = 2, | ||
| 1273 | STACK = 3, | ||
| 1274 | CORE = 4, | ||
| 1275 | RSS = 5, | ||
| 1276 | MEMLOCK = 6, | ||
| 1277 | NPROC = 7, | ||
| 1278 | NOFILE = 8, | ||
| 1279 | SBSIZE = 9, | ||
| 1280 | VMEM = 10, | ||
| 1281 | NTHR = 11, | ||
| 1282 | _, | ||
| 1283 | |||
| 1284 | pub const AS: rlimit_resource = .VMEM; | ||
| 1285 | }; | ||
| 1286 | |||
| 1287 | pub const rlim_t = u64; | ||
| 1288 | |||
| 1289 | /// No limit | ||
| 1290 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1291 | |||
| 1292 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1293 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1294 | |||
| 1295 | pub const rlimit = extern struct { | ||
| 1296 | /// Soft limit | ||
| 1297 | cur: rlim_t, | ||
| 1298 | /// Hard limit | ||
| 1299 | max: rlim_t, | ||
| 1300 | }; | ||
| 1301 | |||
| 1302 | pub const SHUT_RD = 0; | ||
| 1303 | pub const SHUT_WR = 1; | ||
| 1304 | pub const SHUT_RDWR = 2; | ||
| 1305 | |||
| 1306 | pub const nfds_t = u32; | ||
| 1307 | |||
| 1308 | pub const pollfd = extern struct { | ||
| 1309 | fd: fd_t, | ||
| 1310 | events: i16, | ||
| 1311 | revents: i16, | ||
| 1312 | }; | ||
| 1313 | |||
| 1314 | /// Testable events (may be specified in events field). | ||
| 1315 | pub const POLLIN = 0x0001; | ||
| 1316 | pub const POLLPRI = 0x0002; | ||
| 1317 | pub const POLLOUT = 0x0004; | ||
| 1318 | pub const POLLRDNORM = 0x0040; | ||
| 1319 | pub const POLLWRNORM = POLLOUT; | ||
| 1320 | pub const POLLRDBAND = 0x0080; | ||
| 1321 | pub const POLLWRBAND = 0x0100; | ||
| 1322 | |||
| 1323 | /// Non-testable events (may not be specified in events field). | ||
| 1324 | pub const POLLERR = 0x0008; | ||
| 1325 | pub const POLLHUP = 0x0010; | ||
| 1326 | pub const POLLNVAL = 0x0020; | ||
lib/std/os/bits/openbsd.zig deleted-1328| ... | @@ -1,1328 +0,0 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const builtin = std.builtin; | ||
| 3 | const maxInt = std.math.maxInt; | ||
| 4 | |||
| 5 | pub const blkcnt_t = i64; | ||
| 6 | pub const blksize_t = i32; | ||
| 7 | pub const clock_t = i64; | ||
| 8 | pub const dev_t = i32; | ||
| 9 | pub const fd_t = c_int; | ||
| 10 | pub const gid_t = u32; | ||
| 11 | pub const ino_t = u64; | ||
| 12 | pub const mode_t = u32; | ||
| 13 | pub const nlink_t = u32; | ||
| 14 | pub const off_t = i64; | ||
| 15 | pub const pid_t = i32; | ||
| 16 | pub const socklen_t = u32; | ||
| 17 | pub const time_t = i64; | ||
| 18 | pub const uid_t = u32; | ||
| 19 | |||
| 20 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 21 | pub const Kevent = extern struct { | ||
| 22 | ident: usize, | ||
| 23 | filter: c_short, | ||
| 24 | flags: u16, | ||
| 25 | fflags: c_uint, | ||
| 26 | data: i64, | ||
| 27 | udata: usize, | ||
| 28 | }; | ||
| 29 | |||
| 30 | // Modes and flags for dlopen() | ||
| 31 | // include/dlfcn.h | ||
| 32 | |||
| 33 | /// Bind function calls lazily. | ||
| 34 | pub const RTLD_LAZY = 1; | ||
| 35 | |||
| 36 | /// Bind function calls immediately. | ||
| 37 | pub const RTLD_NOW = 2; | ||
| 38 | |||
| 39 | /// Make symbols globally available. | ||
| 40 | pub const RTLD_GLOBAL = 0x100; | ||
| 41 | |||
| 42 | /// Opposite of RTLD_GLOBAL, and the default. | ||
| 43 | pub const RTLD_LOCAL = 0x000; | ||
| 44 | |||
| 45 | /// Trace loaded objects and exit. | ||
| 46 | pub const RTLD_TRACE = 0x200; | ||
| 47 | |||
| 48 | pub const dl_phdr_info = extern struct { | ||
| 49 | dlpi_addr: std.elf.Addr, | ||
| 50 | dlpi_name: ?[*:0]const u8, | ||
| 51 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 52 | dlpi_phnum: std.elf.Half, | ||
| 53 | }; | ||
| 54 | |||
| 55 | pub const Flock = extern struct { | ||
| 56 | l_start: off_t, | ||
| 57 | l_len: off_t, | ||
| 58 | l_pid: pid_t, | ||
| 59 | l_type: c_short, | ||
| 60 | l_whence: c_short, | ||
| 61 | }; | ||
| 62 | |||
| 63 | pub const addrinfo = extern struct { | ||
| 64 | flags: c_int, | ||
| 65 | family: c_int, | ||
| 66 | socktype: c_int, | ||
| 67 | protocol: c_int, | ||
| 68 | addrlen: socklen_t, | ||
| 69 | addr: ?*sockaddr, | ||
| 70 | canonname: ?[*:0]u8, | ||
| 71 | next: ?*addrinfo, | ||
| 72 | }; | ||
| 73 | |||
| 74 | pub const EAI = enum(c_int) { | ||
| 75 | /// address family for hostname not supported | ||
| 76 | ADDRFAMILY = -9, | ||
| 77 | |||
| 78 | /// name could not be resolved at this time | ||
| 79 | AGAIN = -3, | ||
| 80 | |||
| 81 | /// flags parameter had an invalid value | ||
| 82 | BADFLAGS = -1, | ||
| 83 | |||
| 84 | /// non-recoverable failure in name resolution | ||
| 85 | FAIL = -4, | ||
| 86 | |||
| 87 | /// address family not recognized | ||
| 88 | FAMILY = -6, | ||
| 89 | |||
| 90 | /// memory allocation failure | ||
| 91 | MEMORY = -10, | ||
| 92 | |||
| 93 | /// no address associated with hostname | ||
| 94 | NODATA = -5, | ||
| 95 | |||
| 96 | /// name does not resolve | ||
| 97 | NONAME = -2, | ||
| 98 | |||
| 99 | /// service not recognized for socket type | ||
| 100 | SERVICE = -8, | ||
| 101 | |||
| 102 | /// intended socket type was not recognized | ||
| 103 | SOCKTYPE = -7, | ||
| 104 | |||
| 105 | /// system error returned in errno | ||
| 106 | SYSTEM = -11, | ||
| 107 | |||
| 108 | /// invalid value for hints | ||
| 109 | BADHINTS = -12, | ||
| 110 | |||
| 111 | /// resolved protocol is unknown | ||
| 112 | PROTOCOL = -13, | ||
| 113 | |||
| 114 | /// argument buffer overflow | ||
| 115 | OVERFLOW = -14, | ||
| 116 | |||
| 117 | _, | ||
| 118 | }; | ||
| 119 | |||
| 120 | pub const EAI_MAX = 15; | ||
| 121 | |||
| 122 | pub const msghdr = extern struct { | ||
| 123 | /// optional address | ||
| 124 | msg_name: ?*sockaddr, | ||
| 125 | |||
| 126 | /// size of address | ||
| 127 | msg_namelen: socklen_t, | ||
| 128 | |||
| 129 | /// scatter/gather array | ||
| 130 | msg_iov: [*]iovec, | ||
| 131 | |||
| 132 | /// # elements in msg_iov | ||
| 133 | msg_iovlen: c_uint, | ||
| 134 | |||
| 135 | /// ancillary data | ||
| 136 | msg_control: ?*c_void, | ||
| 137 | |||
| 138 | /// ancillary data buffer len | ||
| 139 | msg_controllen: socklen_t, | ||
| 140 | |||
| 141 | /// flags on received message | ||
| 142 | msg_flags: c_int, | ||
| 143 | }; | ||
| 144 | |||
| 145 | pub const msghdr_const = extern struct { | ||
| 146 | /// optional address | ||
| 147 | msg_name: ?*const sockaddr, | ||
| 148 | |||
| 149 | /// size of address | ||
| 150 | msg_namelen: socklen_t, | ||
| 151 | |||
| 152 | /// scatter/gather array | ||
| 153 | msg_iov: [*]iovec_const, | ||
| 154 | |||
| 155 | /// # elements in msg_iov | ||
| 156 | msg_iovlen: c_uint, | ||
| 157 | |||
| 158 | /// ancillary data | ||
| 159 | msg_control: ?*c_void, | ||
| 160 | |||
| 161 | /// ancillary data buffer len | ||
| 162 | msg_controllen: socklen_t, | ||
| 163 | |||
| 164 | /// flags on received message | ||
| 165 | msg_flags: c_int, | ||
| 166 | }; | ||
| 167 | |||
| 168 | pub const libc_stat = extern struct { | ||
| 169 | mode: mode_t, | ||
| 170 | dev: dev_t, | ||
| 171 | ino: ino_t, | ||
| 172 | nlink: nlink_t, | ||
| 173 | uid: uid_t, | ||
| 174 | gid: gid_t, | ||
| 175 | rdev: dev_t, | ||
| 176 | atim: timespec, | ||
| 177 | mtim: timespec, | ||
| 178 | ctim: timespec, | ||
| 179 | size: off_t, | ||
| 180 | blocks: blkcnt_t, | ||
| 181 | blksize: blksize_t, | ||
| 182 | flags: u32, | ||
| 183 | gen: u32, | ||
| 184 | birthtim: timespec, | ||
| 185 | |||
| 186 | pub fn atime(self: @This()) timespec { | ||
| 187 | return self.atim; | ||
| 188 | } | ||
| 189 | |||
| 190 | pub fn mtime(self: @This()) timespec { | ||
| 191 | return self.mtim; | ||
| 192 | } | ||
| 193 | |||
| 194 | pub fn ctime(self: @This()) timespec { | ||
| 195 | return self.ctim; | ||
| 196 | } | ||
| 197 | }; | ||
| 198 | |||
| 199 | pub const timespec = extern struct { | ||
| 200 | tv_sec: time_t, | ||
| 201 | tv_nsec: c_long, | ||
| 202 | }; | ||
| 203 | |||
| 204 | pub const timeval = extern struct { | ||
| 205 | tv_sec: time_t, | ||
| 206 | tv_usec: c_long, | ||
| 207 | }; | ||
| 208 | |||
| 209 | pub const timezone = extern struct { | ||
| 210 | tz_minuteswest: c_int, | ||
| 211 | tz_dsttime: c_int, | ||
| 212 | }; | ||
| 213 | |||
| 214 | pub const MAXNAMLEN = 255; | ||
| 215 | |||
| 216 | pub const dirent = extern struct { | ||
| 217 | d_fileno: ino_t, | ||
| 218 | d_off: off_t, | ||
| 219 | d_reclen: u16, | ||
| 220 | d_type: u8, | ||
| 221 | d_namlen: u8, | ||
| 222 | __d_padding: [4]u8, | ||
| 223 | d_name: [MAXNAMLEN + 1]u8, | ||
| 224 | |||
| 225 | pub fn reclen(self: dirent) u16 { | ||
| 226 | return self.d_reclen; | ||
| 227 | } | ||
| 228 | }; | ||
| 229 | |||
| 230 | pub const in_port_t = u16; | ||
| 231 | pub const sa_family_t = u8; | ||
| 232 | |||
| 233 | pub const sockaddr = extern struct { | ||
| 234 | /// total length | ||
| 235 | len: u8, | ||
| 236 | |||
| 237 | /// address family | ||
| 238 | family: sa_family_t, | ||
| 239 | |||
| 240 | /// actually longer; address value | ||
| 241 | data: [14]u8, | ||
| 242 | }; | ||
| 243 | |||
| 244 | pub const sockaddr_storage = std.x.os.Socket.Address.Native.Storage; | ||
| 245 | |||
| 246 | pub const sockaddr_in = extern struct { | ||
| 247 | len: u8 = @sizeOf(sockaddr_in), | ||
| 248 | family: sa_family_t = AF_INET, | ||
| 249 | port: in_port_t, | ||
| 250 | addr: u32, | ||
| 251 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 252 | }; | ||
| 253 | |||
| 254 | pub const sockaddr_in6 = extern struct { | ||
| 255 | len: u8 = @sizeOf(sockaddr_in6), | ||
| 256 | family: sa_family_t = AF_INET6, | ||
| 257 | port: in_port_t, | ||
| 258 | flowinfo: u32, | ||
| 259 | addr: [16]u8, | ||
| 260 | scope_id: u32, | ||
| 261 | }; | ||
| 262 | |||
| 263 | /// Definitions for UNIX IPC domain. | ||
| 264 | pub const sockaddr_un = extern struct { | ||
| 265 | /// total sockaddr length | ||
| 266 | len: u8 = @sizeOf(sockaddr_un), | ||
| 267 | |||
| 268 | /// AF_LOCAL | ||
| 269 | family: sa_family_t = AF_LOCAL, | ||
| 270 | |||
| 271 | /// path name | ||
| 272 | path: [104]u8, | ||
| 273 | }; | ||
| 274 | |||
| 275 | /// get address to use bind() | ||
| 276 | pub const AI_PASSIVE = 1; | ||
| 277 | |||
| 278 | /// fill ai_canonname | ||
| 279 | pub const AI_CANONNAME = 2; | ||
| 280 | |||
| 281 | /// prevent host name resolution | ||
| 282 | pub const AI_NUMERICHOST = 4; | ||
| 283 | |||
| 284 | /// prevent service name resolution | ||
| 285 | pub const AI_NUMERICSERV = 16; | ||
| 286 | |||
| 287 | /// only if any address is assigned | ||
| 288 | pub const AI_ADDRCONFIG = 64; | ||
| 289 | |||
| 290 | pub const PATH_MAX = 1024; | ||
| 291 | pub const IOV_MAX = 1024; | ||
| 292 | |||
| 293 | pub const STDIN_FILENO = 0; | ||
| 294 | pub const STDOUT_FILENO = 1; | ||
| 295 | pub const STDERR_FILENO = 2; | ||
| 296 | |||
| 297 | pub const PROT_NONE = 0; | ||
| 298 | pub const PROT_READ = 1; | ||
| 299 | pub const PROT_WRITE = 2; | ||
| 300 | pub const PROT_EXEC = 4; | ||
| 301 | |||
| 302 | pub const CLOCK_REALTIME = 0; | ||
| 303 | pub const CLOCK_PROCESS_CPUTIME_ID = 2; | ||
| 304 | pub const CLOCK_MONOTONIC = 3; | ||
| 305 | pub const CLOCK_THREAD_CPUTIME_ID = 4; | ||
| 306 | |||
| 307 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 308 | pub const MAP_SHARED = 0x0001; | ||
| 309 | pub const MAP_PRIVATE = 0x0002; | ||
| 310 | pub const MAP_FIXED = 0x0010; | ||
| 311 | pub const MAP_RENAME = 0; | ||
| 312 | pub const MAP_NORESERVE = 0; | ||
| 313 | pub const MAP_INHERIT = 0; | ||
| 314 | pub const MAP_HASSEMAPHORE = 0; | ||
| 315 | pub const MAP_TRYFIXED = 0; | ||
| 316 | |||
| 317 | pub const MAP_FILE = 0; | ||
| 318 | pub const MAP_ANON = 0x1000; | ||
| 319 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 320 | pub const MAP_STACK = 0x4000; | ||
| 321 | pub const MAP_CONCEAL = 0x8000; | ||
| 322 | |||
| 323 | pub const WNOHANG = 1; | ||
| 324 | pub const WUNTRACED = 2; | ||
| 325 | pub const WCONTINUED = 8; | ||
| 326 | |||
| 327 | pub const SA_ONSTACK = 0x0001; | ||
| 328 | pub const SA_RESTART = 0x0002; | ||
| 329 | pub const SA_RESETHAND = 0x0004; | ||
| 330 | pub const SA_NOCLDSTOP = 0x0008; | ||
| 331 | pub const SA_NODEFER = 0x0010; | ||
| 332 | pub const SA_NOCLDWAIT = 0x0020; | ||
| 333 | pub const SA_SIGINFO = 0x0040; | ||
| 334 | |||
| 335 | pub const SIGHUP = 1; | ||
| 336 | pub const SIGINT = 2; | ||
| 337 | pub const SIGQUIT = 3; | ||
| 338 | pub const SIGILL = 4; | ||
| 339 | pub const SIGTRAP = 5; | ||
| 340 | pub const SIGABRT = 6; | ||
| 341 | pub const SIGIOT = SIGABRT; | ||
| 342 | pub const SIGEMT = 7; | ||
| 343 | pub const SIGFPE = 8; | ||
| 344 | pub const SIGKILL = 9; | ||
| 345 | pub const SIGBUS = 10; | ||
| 346 | pub const SIGSEGV = 11; | ||
| 347 | pub const SIGSYS = 12; | ||
| 348 | pub const SIGPIPE = 13; | ||
| 349 | pub const SIGALRM = 14; | ||
| 350 | pub const SIGTERM = 15; | ||
| 351 | pub const SIGURG = 16; | ||
| 352 | pub const SIGSTOP = 17; | ||
| 353 | pub const SIGTSTP = 18; | ||
| 354 | pub const SIGCONT = 19; | ||
| 355 | pub const SIGCHLD = 20; | ||
| 356 | pub const SIGTTIN = 21; | ||
| 357 | pub const SIGTTOU = 22; | ||
| 358 | pub const SIGIO = 23; | ||
| 359 | pub const SIGXCPU = 24; | ||
| 360 | pub const SIGXFSZ = 25; | ||
| 361 | pub const SIGVTALRM = 26; | ||
| 362 | pub const SIGPROF = 27; | ||
| 363 | pub const SIGWINCH = 28; | ||
| 364 | pub const SIGINFO = 29; | ||
| 365 | pub const SIGUSR1 = 30; | ||
| 366 | pub const SIGUSR2 = 31; | ||
| 367 | pub const SIGPWR = 32; | ||
| 368 | |||
| 369 | // access function | ||
| 370 | pub const F_OK = 0; // test for existence of file | ||
| 371 | pub const X_OK = 1; // test for execute or search permission | ||
| 372 | pub const W_OK = 2; // test for write permission | ||
| 373 | pub const R_OK = 4; // test for read permission | ||
| 374 | |||
| 375 | /// open for reading only | ||
| 376 | pub const O_RDONLY = 0x00000000; | ||
| 377 | |||
| 378 | /// open for writing only | ||
| 379 | pub const O_WRONLY = 0x00000001; | ||
| 380 | |||
| 381 | /// open for reading and writing | ||
| 382 | pub const O_RDWR = 0x00000002; | ||
| 383 | |||
| 384 | /// mask for above modes | ||
| 385 | pub const O_ACCMODE = 0x00000003; | ||
| 386 | |||
| 387 | /// no delay | ||
| 388 | pub const O_NONBLOCK = 0x00000004; | ||
| 389 | |||
| 390 | /// set append mode | ||
| 391 | pub const O_APPEND = 0x00000008; | ||
| 392 | |||
| 393 | /// open with shared file lock | ||
| 394 | pub const O_SHLOCK = 0x00000010; | ||
| 395 | |||
| 396 | /// open with exclusive file lock | ||
| 397 | pub const O_EXLOCK = 0x00000020; | ||
| 398 | |||
| 399 | /// signal pgrp when data ready | ||
| 400 | pub const O_ASYNC = 0x00000040; | ||
| 401 | |||
| 402 | /// synchronous writes | ||
| 403 | pub const O_SYNC = 0x00000080; | ||
| 404 | |||
| 405 | /// don't follow symlinks on the last | ||
| 406 | pub const O_NOFOLLOW = 0x00000100; | ||
| 407 | |||
| 408 | /// create if nonexistent | ||
| 409 | pub const O_CREAT = 0x00000200; | ||
| 410 | |||
| 411 | /// truncate to zero length | ||
| 412 | pub const O_TRUNC = 0x00000400; | ||
| 413 | |||
| 414 | /// error if already exists | ||
| 415 | pub const O_EXCL = 0x00000800; | ||
| 416 | |||
| 417 | /// don't assign controlling terminal | ||
| 418 | pub const O_NOCTTY = 0x00008000; | ||
| 419 | |||
| 420 | /// write: I/O data completion | ||
| 421 | pub const O_DSYNC = O_SYNC; | ||
| 422 | |||
| 423 | /// read: I/O completion as for write | ||
| 424 | pub const O_RSYNC = O_SYNC; | ||
| 425 | |||
| 426 | /// fail if not a directory | ||
| 427 | pub const O_DIRECTORY = 0x20000; | ||
| 428 | |||
| 429 | /// set close on exec | ||
| 430 | pub const O_CLOEXEC = 0x10000; | ||
| 431 | |||
| 432 | pub const F_DUPFD = 0; | ||
| 433 | pub const F_GETFD = 1; | ||
| 434 | pub const F_SETFD = 2; | ||
| 435 | pub const F_GETFL = 3; | ||
| 436 | pub const F_SETFL = 4; | ||
| 437 | |||
| 438 | pub const F_GETOWN = 5; | ||
| 439 | pub const F_SETOWN = 6; | ||
| 440 | |||
| 441 | pub const F_GETLK = 7; | ||
| 442 | pub const F_SETLK = 8; | ||
| 443 | pub const F_SETLKW = 9; | ||
| 444 | |||
| 445 | pub const F_RDLCK = 1; | ||
| 446 | pub const F_UNLCK = 2; | ||
| 447 | pub const F_WRLCK = 3; | ||
| 448 | |||
| 449 | pub const LOCK_SH = 0x01; | ||
| 450 | pub const LOCK_EX = 0x02; | ||
| 451 | pub const LOCK_NB = 0x04; | ||
| 452 | pub const LOCK_UN = 0x08; | ||
| 453 | |||
| 454 | pub const FD_CLOEXEC = 1; | ||
| 455 | |||
| 456 | pub const SEEK_SET = 0; | ||
| 457 | pub const SEEK_CUR = 1; | ||
| 458 | pub const SEEK_END = 2; | ||
| 459 | |||
| 460 | pub const SIG_BLOCK = 1; | ||
| 461 | pub const SIG_UNBLOCK = 2; | ||
| 462 | pub const SIG_SETMASK = 3; | ||
| 463 | |||
| 464 | pub const SOCK_STREAM = 1; | ||
| 465 | pub const SOCK_DGRAM = 2; | ||
| 466 | pub const SOCK_RAW = 3; | ||
| 467 | pub const SOCK_RDM = 4; | ||
| 468 | pub const SOCK_SEQPACKET = 5; | ||
| 469 | |||
| 470 | pub const SOCK_CLOEXEC = 0x8000; | ||
| 471 | pub const SOCK_NONBLOCK = 0x4000; | ||
| 472 | |||
| 473 | pub const SO_DEBUG = 0x0001; | ||
| 474 | pub const SO_ACCEPTCONN = 0x0002; | ||
| 475 | pub const SO_REUSEADDR = 0x0004; | ||
| 476 | pub const SO_KEEPALIVE = 0x0008; | ||
| 477 | pub const SO_DONTROUTE = 0x0010; | ||
| 478 | pub const SO_BROADCAST = 0x0020; | ||
| 479 | pub const SO_USELOOPBACK = 0x0040; | ||
| 480 | pub const SO_LINGER = 0x0080; | ||
| 481 | pub const SO_OOBINLINE = 0x0100; | ||
| 482 | pub const SO_REUSEPORT = 0x0200; | ||
| 483 | pub const SO_TIMESTAMP = 0x0800; | ||
| 484 | pub const SO_BINDANY = 0x1000; | ||
| 485 | pub const SO_ZEROIZE = 0x2000; | ||
| 486 | pub const SO_SNDBUF = 0x1001; | ||
| 487 | pub const SO_RCVBUF = 0x1002; | ||
| 488 | pub const SO_SNDLOWAT = 0x1003; | ||
| 489 | pub const SO_RCVLOWAT = 0x1004; | ||
| 490 | pub const SO_SNDTIMEO = 0x1005; | ||
| 491 | pub const SO_RCVTIMEO = 0x1006; | ||
| 492 | pub const SO_ERROR = 0x1007; | ||
| 493 | pub const SO_TYPE = 0x1008; | ||
| 494 | pub const SO_NETPROC = 0x1020; | ||
| 495 | pub const SO_RTABLE = 0x1021; | ||
| 496 | pub const SO_PEERCRED = 0x1022; | ||
| 497 | pub const SO_SPLICE = 0x1023; | ||
| 498 | pub const SO_DOMAIN = 0x1024; | ||
| 499 | pub const SO_PROTOCOL = 0x1025; | ||
| 500 | |||
| 501 | pub const SOL_SOCKET = 0xffff; | ||
| 502 | |||
| 503 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 504 | pub const PF_LOCAL = AF_LOCAL; | ||
| 505 | pub const PF_UNIX = AF_UNIX; | ||
| 506 | pub const PF_INET = AF_INET; | ||
| 507 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 508 | pub const PF_INET6 = AF_INET6; | ||
| 509 | pub const PF_DECnet = AF_DECnet; | ||
| 510 | pub const PF_KEY = AF_KEY; | ||
| 511 | pub const PF_ROUTE = AF_ROUTE; | ||
| 512 | pub const PF_SNA = AF_SNA; | ||
| 513 | pub const PF_MPLS = AF_MPLS; | ||
| 514 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 515 | pub const PF_ISDN = AF_ISDN; | ||
| 516 | pub const PF_MAX = AF_MAX; | ||
| 517 | |||
| 518 | pub const AF_UNSPEC = 0; | ||
| 519 | pub const AF_UNIX = 1; | ||
| 520 | pub const AF_LOCAL = AF_UNIX; | ||
| 521 | pub const AF_INET = 2; | ||
| 522 | pub const AF_APPLETALK = 16; | ||
| 523 | pub const AF_INET6 = 24; | ||
| 524 | pub const AF_KEY = 30; | ||
| 525 | pub const AF_ROUTE = 17; | ||
| 526 | pub const AF_SNA = 11; | ||
| 527 | pub const AF_MPLS = 33; | ||
| 528 | pub const AF_BLUETOOTH = 32; | ||
| 529 | pub const AF_ISDN = 26; | ||
| 530 | pub const AF_MAX = 36; | ||
| 531 | |||
| 532 | pub const DT_UNKNOWN = 0; | ||
| 533 | pub const DT_FIFO = 1; | ||
| 534 | pub const DT_CHR = 2; | ||
| 535 | pub const DT_DIR = 4; | ||
| 536 | pub const DT_BLK = 6; | ||
| 537 | pub const DT_REG = 8; | ||
| 538 | pub const DT_LNK = 10; | ||
| 539 | pub const DT_SOCK = 12; | ||
| 540 | pub const DT_WHT = 14; // XXX | ||
| 541 | |||
| 542 | pub const EV_ADD = 0x0001; | ||
| 543 | pub const EV_DELETE = 0x0002; | ||
| 544 | pub const EV_ENABLE = 0x0004; | ||
| 545 | pub const EV_DISABLE = 0x0008; | ||
| 546 | pub const EV_ONESHOT = 0x0010; | ||
| 547 | pub const EV_CLEAR = 0x0020; | ||
| 548 | pub const EV_RECEIPT = 0x0040; | ||
| 549 | pub const EV_DISPATCH = 0x0080; | ||
| 550 | pub const EV_FLAG1 = 0x2000; | ||
| 551 | pub const EV_ERROR = 0x4000; | ||
| 552 | pub const EV_EOF = 0x8000; | ||
| 553 | |||
| 554 | pub const EVFILT_READ = -1; | ||
| 555 | pub const EVFILT_WRITE = -2; | ||
| 556 | pub const EVFILT_AIO = -3; | ||
| 557 | pub const EVFILT_VNODE = -4; | ||
| 558 | pub const EVFILT_PROC = -5; | ||
| 559 | pub const EVFILT_SIGNAL = -6; | ||
| 560 | pub const EVFILT_TIMER = -7; | ||
| 561 | pub const EVFILT_EXCEPT = -9; | ||
| 562 | |||
| 563 | // data/hint flags for EVFILT_{READ|WRITE} | ||
| 564 | pub const NOTE_LOWAT = 0x0001; | ||
| 565 | pub const NOTE_EOF = 0x0002; | ||
| 566 | |||
| 567 | // data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE} | ||
| 568 | pub const NOTE_OOB = 0x0004; | ||
| 569 | |||
| 570 | // data/hint flags for EVFILT_VNODE | ||
| 571 | pub const NOTE_DELETE = 0x0001; | ||
| 572 | pub const NOTE_WRITE = 0x0002; | ||
| 573 | pub const NOTE_EXTEND = 0x0004; | ||
| 574 | pub const NOTE_ATTRIB = 0x0008; | ||
| 575 | pub const NOTE_LINK = 0x0010; | ||
| 576 | pub const NOTE_RENAME = 0x0020; | ||
| 577 | pub const NOTE_REVOKE = 0x0040; | ||
| 578 | pub const NOTE_TRUNCATE = 0x0080; | ||
| 579 | |||
| 580 | // data/hint flags for EVFILT_PROC | ||
| 581 | pub const NOTE_EXIT = 0x80000000; | ||
| 582 | pub const NOTE_FORK = 0x40000000; | ||
| 583 | pub const NOTE_EXEC = 0x20000000; | ||
| 584 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 585 | pub const NOTE_PCTRLMASK = 0xf0000000; | ||
| 586 | pub const NOTE_TRACK = 0x00000001; | ||
| 587 | pub const NOTE_TRACKERR = 0x00000002; | ||
| 588 | pub const NOTE_CHILD = 0x00000004; | ||
| 589 | |||
| 590 | // data/hint flags for EVFILT_DEVICE | ||
| 591 | pub const NOTE_CHANGE = 0x00000001; | ||
| 592 | |||
| 593 | pub const TIOCCBRK = 0x2000747a; | ||
| 594 | pub const TIOCCDTR = 0x20007478; | ||
| 595 | pub const TIOCCONS = 0x80047462; | ||
| 596 | pub const TIOCDCDTIMESTAMP = 0x40107458; | ||
| 597 | pub const TIOCDRAIN = 0x2000745e; | ||
| 598 | pub const TIOCEXCL = 0x2000740d; | ||
| 599 | pub const TIOCEXT = 0x80047460; | ||
| 600 | pub const TIOCFLAG_CDTRCTS = 0x10; | ||
| 601 | pub const TIOCFLAG_CLOCAL = 0x2; | ||
| 602 | pub const TIOCFLAG_CRTSCTS = 0x4; | ||
| 603 | pub const TIOCFLAG_MDMBUF = 0x8; | ||
| 604 | pub const TIOCFLAG_SOFTCAR = 0x1; | ||
| 605 | pub const TIOCFLUSH = 0x80047410; | ||
| 606 | pub const TIOCGETA = 0x402c7413; | ||
| 607 | pub const TIOCGETD = 0x4004741a; | ||
| 608 | pub const TIOCGFLAGS = 0x4004745d; | ||
| 609 | pub const TIOCGLINED = 0x40207442; | ||
| 610 | pub const TIOCGPGRP = 0x40047477; | ||
| 611 | pub const TIOCGQSIZE = 0x40047481; | ||
| 612 | pub const TIOCGRANTPT = 0x20007447; | ||
| 613 | pub const TIOCGSID = 0x40047463; | ||
| 614 | pub const TIOCGSIZE = 0x40087468; | ||
| 615 | pub const TIOCGWINSZ = 0x40087468; | ||
| 616 | pub const TIOCMBIC = 0x8004746b; | ||
| 617 | pub const TIOCMBIS = 0x8004746c; | ||
| 618 | pub const TIOCMGET = 0x4004746a; | ||
| 619 | pub const TIOCMSET = 0x8004746d; | ||
| 620 | pub const TIOCM_CAR = 0x40; | ||
| 621 | pub const TIOCM_CD = 0x40; | ||
| 622 | pub const TIOCM_CTS = 0x20; | ||
| 623 | pub const TIOCM_DSR = 0x100; | ||
| 624 | pub const TIOCM_DTR = 0x2; | ||
| 625 | pub const TIOCM_LE = 0x1; | ||
| 626 | pub const TIOCM_RI = 0x80; | ||
| 627 | pub const TIOCM_RNG = 0x80; | ||
| 628 | pub const TIOCM_RTS = 0x4; | ||
| 629 | pub const TIOCM_SR = 0x10; | ||
| 630 | pub const TIOCM_ST = 0x8; | ||
| 631 | pub const TIOCNOTTY = 0x20007471; | ||
| 632 | pub const TIOCNXCL = 0x2000740e; | ||
| 633 | pub const TIOCOUTQ = 0x40047473; | ||
| 634 | pub const TIOCPKT = 0x80047470; | ||
| 635 | pub const TIOCPKT_DATA = 0x0; | ||
| 636 | pub const TIOCPKT_DOSTOP = 0x20; | ||
| 637 | pub const TIOCPKT_FLUSHREAD = 0x1; | ||
| 638 | pub const TIOCPKT_FLUSHWRITE = 0x2; | ||
| 639 | pub const TIOCPKT_IOCTL = 0x40; | ||
| 640 | pub const TIOCPKT_NOSTOP = 0x10; | ||
| 641 | pub const TIOCPKT_START = 0x8; | ||
| 642 | pub const TIOCPKT_STOP = 0x4; | ||
| 643 | pub const TIOCPTMGET = 0x40287446; | ||
| 644 | pub const TIOCPTSNAME = 0x40287448; | ||
| 645 | pub const TIOCRCVFRAME = 0x80087445; | ||
| 646 | pub const TIOCREMOTE = 0x80047469; | ||
| 647 | pub const TIOCSBRK = 0x2000747b; | ||
| 648 | pub const TIOCSCTTY = 0x20007461; | ||
| 649 | pub const TIOCSDTR = 0x20007479; | ||
| 650 | pub const TIOCSETA = 0x802c7414; | ||
| 651 | pub const TIOCSETAF = 0x802c7416; | ||
| 652 | pub const TIOCSETAW = 0x802c7415; | ||
| 653 | pub const TIOCSETD = 0x8004741b; | ||
| 654 | pub const TIOCSFLAGS = 0x8004745c; | ||
| 655 | pub const TIOCSIG = 0x2000745f; | ||
| 656 | pub const TIOCSLINED = 0x80207443; | ||
| 657 | pub const TIOCSPGRP = 0x80047476; | ||
| 658 | pub const TIOCSQSIZE = 0x80047480; | ||
| 659 | pub const TIOCSSIZE = 0x80087467; | ||
| 660 | pub const TIOCSTART = 0x2000746e; | ||
| 661 | pub const TIOCSTAT = 0x80047465; | ||
| 662 | pub const TIOCSTI = 0x80017472; | ||
| 663 | pub const TIOCSTOP = 0x2000746f; | ||
| 664 | pub const TIOCSWINSZ = 0x80087467; | ||
| 665 | pub const TIOCUCNTL = 0x80047466; | ||
| 666 | pub const TIOCXMTFRAME = 0x80087444; | ||
| 667 | |||
| 668 | pub fn WEXITSTATUS(s: u32) u8 { | ||
| 669 | return @intCast(u8, (s >> 8) & 0xff); | ||
| 670 | } | ||
| 671 | pub fn WTERMSIG(s: u32) u32 { | ||
| 672 | return (s & 0x7f); | ||
| 673 | } | ||
| 674 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 675 | return WEXITSTATUS(s); | ||
| 676 | } | ||
| 677 | pub fn WIFEXITED(s: u32) bool { | ||
| 678 | return WTERMSIG(s) == 0; | ||
| 679 | } | ||
| 680 | |||
| 681 | pub fn WIFCONTINUED(s: u32) bool { | ||
| 682 | return ((s & 0o177777) == 0o177777); | ||
| 683 | } | ||
| 684 | |||
| 685 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 686 | return (s & 0xff == 0o177); | ||
| 687 | } | ||
| 688 | |||
| 689 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 690 | return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); | ||
| 691 | } | ||
| 692 | |||
| 693 | pub const winsize = extern struct { | ||
| 694 | ws_row: c_ushort, | ||
| 695 | ws_col: c_ushort, | ||
| 696 | ws_xpixel: c_ushort, | ||
| 697 | ws_ypixel: c_ushort, | ||
| 698 | }; | ||
| 699 | |||
| 700 | const NSIG = 33; | ||
| 701 | |||
| 702 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | ||
| 703 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | ||
| 704 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | ||
| 705 | pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2); | ||
| 706 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3); | ||
| 707 | |||
| 708 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 709 | pub const Sigaction = extern struct { | ||
| 710 | pub const handler_fn = fn (c_int) callconv(.C) void; | ||
| 711 | pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void; | ||
| 712 | |||
| 713 | /// signal handler | ||
| 714 | handler: extern union { | ||
| 715 | handler: ?handler_fn, | ||
| 716 | sigaction: ?sigaction_fn, | ||
| 717 | }, | ||
| 718 | /// signal mask to apply | ||
| 719 | mask: sigset_t, | ||
| 720 | /// signal options | ||
| 721 | flags: c_uint, | ||
| 722 | }; | ||
| 723 | |||
| 724 | pub const sigval = extern union { | ||
| 725 | int: c_int, | ||
| 726 | ptr: ?*c_void, | ||
| 727 | }; | ||
| 728 | |||
| 729 | pub const siginfo_t = extern struct { | ||
| 730 | signo: c_int, | ||
| 731 | code: c_int, | ||
| 732 | errno: c_int, | ||
| 733 | data: extern union { | ||
| 734 | proc: extern struct { | ||
| 735 | pid: pid_t, | ||
| 736 | pdata: extern union { | ||
| 737 | kill: extern struct { | ||
| 738 | uid: uid_t, | ||
| 739 | value: sigval, | ||
| 740 | }, | ||
| 741 | cld: extern struct { | ||
| 742 | utime: clock_t, | ||
| 743 | stime: clock_t, | ||
| 744 | status: c_int, | ||
| 745 | }, | ||
| 746 | }, | ||
| 747 | }, | ||
| 748 | fault: extern struct { | ||
| 749 | addr: ?*c_void, | ||
| 750 | trapno: c_int, | ||
| 751 | }, | ||
| 752 | __pad: [128 - 3 * @sizeOf(c_int)]u8, | ||
| 753 | }, | ||
| 754 | }; | ||
| 755 | |||
| 756 | comptime { | ||
| 757 | if (@sizeOf(usize) == 4) | ||
| 758 | std.debug.assert(@sizeOf(siginfo_t) == 128) | ||
| 759 | else | ||
| 760 | // Take into account the padding between errno and data fields. | ||
| 761 | std.debug.assert(@sizeOf(siginfo_t) == 136); | ||
| 762 | } | ||
| 763 | |||
| 764 | pub usingnamespace switch (builtin.target.cpu.arch) { | ||
| 765 | .x86_64 => struct { | ||
| 766 | pub const ucontext_t = extern struct { | ||
| 767 | sc_rdi: c_long, | ||
| 768 | sc_rsi: c_long, | ||
| 769 | sc_rdx: c_long, | ||
| 770 | sc_rcx: c_long, | ||
| 771 | sc_r8: c_long, | ||
| 772 | sc_r9: c_long, | ||
| 773 | sc_r10: c_long, | ||
| 774 | sc_r11: c_long, | ||
| 775 | sc_r12: c_long, | ||
| 776 | sc_r13: c_long, | ||
| 777 | sc_r14: c_long, | ||
| 778 | sc_r15: c_long, | ||
| 779 | sc_rbp: c_long, | ||
| 780 | sc_rbx: c_long, | ||
| 781 | sc_rax: c_long, | ||
| 782 | sc_gs: c_long, | ||
| 783 | sc_fs: c_long, | ||
| 784 | sc_es: c_long, | ||
| 785 | sc_ds: c_long, | ||
| 786 | sc_trapno: c_long, | ||
| 787 | sc_err: c_long, | ||
| 788 | sc_rip: c_long, | ||
| 789 | sc_cs: c_long, | ||
| 790 | sc_rflags: c_long, | ||
| 791 | sc_rsp: c_long, | ||
| 792 | sc_ss: c_long, | ||
| 793 | |||
| 794 | sc_fpstate: fxsave64, | ||
| 795 | __sc_unused: c_int, | ||
| 796 | sc_mask: c_int, | ||
| 797 | sc_cookie: c_long, | ||
| 798 | }; | ||
| 799 | |||
| 800 | pub const fxsave64 = packed struct { | ||
| 801 | fx_fcw: u16, | ||
| 802 | fx_fsw: u16, | ||
| 803 | fx_ftw: u8, | ||
| 804 | fx_unused1: u8, | ||
| 805 | fx_fop: u16, | ||
| 806 | fx_rip: u64, | ||
| 807 | fx_rdp: u64, | ||
| 808 | fx_mxcsr: u32, | ||
| 809 | fx_mxcsr_mask: u32, | ||
| 810 | fx_st: [8][2]u64, | ||
| 811 | fx_xmm: [16][2]u64, | ||
| 812 | fx_unused3: [96]u8, | ||
| 813 | }; | ||
| 814 | }, | ||
| 815 | else => struct {}, | ||
| 816 | }; | ||
| 817 | |||
| 818 | pub const sigset_t = c_uint; | ||
| 819 | pub const empty_sigset: sigset_t = 0; | ||
| 820 | |||
| 821 | pub const E = enum(u16) { | ||
| 822 | /// No error occurred. | ||
| 823 | SUCCESS = 0, | ||
| 824 | PERM = 1, // Operation not permitted | ||
| 825 | NOENT = 2, // No such file or directory | ||
| 826 | SRCH = 3, // No such process | ||
| 827 | INTR = 4, // Interrupted system call | ||
| 828 | IO = 5, // Input/output error | ||
| 829 | NXIO = 6, // Device not configured | ||
| 830 | @"2BIG" = 7, // Argument list too long | ||
| 831 | NOEXEC = 8, // Exec format error | ||
| 832 | BADF = 9, // Bad file descriptor | ||
| 833 | CHILD = 10, // No child processes | ||
| 834 | DEADLK = 11, // Resource deadlock avoided | ||
| 835 | // 11 was AGAIN | ||
| 836 | NOMEM = 12, // Cannot allocate memory | ||
| 837 | ACCES = 13, // Permission denied | ||
| 838 | FAULT = 14, // Bad address | ||
| 839 | NOTBLK = 15, // Block device required | ||
| 840 | BUSY = 16, // Device busy | ||
| 841 | EXIST = 17, // File exists | ||
| 842 | XDEV = 18, // Cross-device link | ||
| 843 | NODEV = 19, // Operation not supported by device | ||
| 844 | NOTDIR = 20, // Not a directory | ||
| 845 | ISDIR = 21, // Is a directory | ||
| 846 | INVAL = 22, // Invalid argument | ||
| 847 | NFILE = 23, // Too many open files in system | ||
| 848 | MFILE = 24, // Too many open files | ||
| 849 | NOTTY = 25, // Inappropriate ioctl for device | ||
| 850 | TXTBSY = 26, // Text file busy | ||
| 851 | FBIG = 27, // File too large | ||
| 852 | NOSPC = 28, // No space left on device | ||
| 853 | SPIPE = 29, // Illegal seek | ||
| 854 | ROFS = 30, // Read-only file system | ||
| 855 | MLINK = 31, // Too many links | ||
| 856 | PIPE = 32, // Broken pipe | ||
| 857 | |||
| 858 | // math software | ||
| 859 | DOM = 33, // Numerical argument out of domain | ||
| 860 | RANGE = 34, // Result too large or too small | ||
| 861 | |||
| 862 | // non-blocking and interrupt i/o | ||
| 863 | // also: WOULDBLOCK: operation would block | ||
| 864 | AGAIN = 35, // Resource temporarily unavailable | ||
| 865 | INPROGRESS = 36, // Operation now in progress | ||
| 866 | ALREADY = 37, // Operation already in progress | ||
| 867 | |||
| 868 | // ipc/network software -- argument errors | ||
| 869 | NOTSOCK = 38, // Socket operation on non-socket | ||
| 870 | DESTADDRREQ = 39, // Destination address required | ||
| 871 | MSGSIZE = 40, // Message too long | ||
| 872 | PROTOTYPE = 41, // Protocol wrong type for socket | ||
| 873 | NOPROTOOPT = 42, // Protocol option not available | ||
| 874 | PROTONOSUPPORT = 43, // Protocol not supported | ||
| 875 | SOCKTNOSUPPORT = 44, // Socket type not supported | ||
| 876 | OPNOTSUPP = 45, // Operation not supported | ||
| 877 | PFNOSUPPORT = 46, // Protocol family not supported | ||
| 878 | AFNOSUPPORT = 47, // Address family not supported by protocol family | ||
| 879 | ADDRINUSE = 48, // Address already in use | ||
| 880 | ADDRNOTAVAIL = 49, // Can't assign requested address | ||
| 881 | |||
| 882 | // ipc/network software -- operational errors | ||
| 883 | NETDOWN = 50, // Network is down | ||
| 884 | NETUNREACH = 51, // Network is unreachable | ||
| 885 | NETRESET = 52, // Network dropped connection on reset | ||
| 886 | CONNABORTED = 53, // Software caused connection abort | ||
| 887 | CONNRESET = 54, // Connection reset by peer | ||
| 888 | NOBUFS = 55, // No buffer space available | ||
| 889 | ISCONN = 56, // Socket is already connected | ||
| 890 | NOTCONN = 57, // Socket is not connected | ||
| 891 | SHUTDOWN = 58, // Can't send after socket shutdown | ||
| 892 | TOOMANYREFS = 59, // Too many references: can't splice | ||
| 893 | TIMEDOUT = 60, // Operation timed out | ||
| 894 | CONNREFUSED = 61, // Connection refused | ||
| 895 | |||
| 896 | LOOP = 62, // Too many levels of symbolic links | ||
| 897 | NAMETOOLONG = 63, // File name too long | ||
| 898 | |||
| 899 | // should be rearranged | ||
| 900 | HOSTDOWN = 64, // Host is down | ||
| 901 | HOSTUNREACH = 65, // No route to host | ||
| 902 | NOTEMPTY = 66, // Directory not empty | ||
| 903 | |||
| 904 | // quotas & mush | ||
| 905 | PROCLIM = 67, // Too many processes | ||
| 906 | USERS = 68, // Too many users | ||
| 907 | DQUOT = 69, // Disc quota exceeded | ||
| 908 | |||
| 909 | // Network File System | ||
| 910 | STALE = 70, // Stale NFS file handle | ||
| 911 | REMOTE = 71, // Too many levels of remote in path | ||
| 912 | BADRPC = 72, // RPC struct is bad | ||
| 913 | RPCMISMATCH = 73, // RPC version wrong | ||
| 914 | PROGUNAVAIL = 74, // RPC prog. not avail | ||
| 915 | PROGMISMATCH = 75, // Program version wrong | ||
| 916 | PROCUNAVAIL = 76, // Bad procedure for program | ||
| 917 | |||
| 918 | NOLCK = 77, // No locks available | ||
| 919 | NOSYS = 78, // Function not implemented | ||
| 920 | |||
| 921 | FTYPE = 79, // Inappropriate file type or format | ||
| 922 | AUTH = 80, // Authentication error | ||
| 923 | NEEDAUTH = 81, // Need authenticator | ||
| 924 | IPSEC = 82, // IPsec processing failure | ||
| 925 | NOATTR = 83, // Attribute not found | ||
| 926 | |||
| 927 | // Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 | ||
| 928 | ILSEQ = 84, // Illegal byte sequence | ||
| 929 | |||
| 930 | NOMEDIUM = 85, // No medium found | ||
| 931 | MEDIUMTYPE = 86, // Wrong medium type | ||
| 932 | OVERFLOW = 87, // Value too large to be stored in data type | ||
| 933 | CANCELED = 88, // Operation canceled | ||
| 934 | IDRM = 89, // Identifier removed | ||
| 935 | NOMSG = 90, // No message of desired type | ||
| 936 | NOTSUP = 91, // Not supported | ||
| 937 | BADMSG = 92, // Bad or Corrupt message | ||
| 938 | NOTRECOVERABLE = 93, // State not recoverable | ||
| 939 | OWNERDEAD = 94, // Previous owner died | ||
| 940 | PROTO = 95, // Protocol error | ||
| 941 | |||
| 942 | _, | ||
| 943 | }; | ||
| 944 | |||
| 945 | const _MAX_PAGE_SHIFT = switch (builtin.target.cpu.arch) { | ||
| 946 | .i386 => 12, | ||
| 947 | .sparcv9 => 13, | ||
| 948 | }; | ||
| 949 | pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT; | ||
| 950 | pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4; | ||
| 951 | |||
| 952 | pub const SS_ONSTACK = 0x0001; | ||
| 953 | pub const SS_DISABLE = 0x0004; | ||
| 954 | |||
| 955 | pub const stack_t = extern struct { | ||
| 956 | ss_sp: [*]u8, | ||
| 957 | ss_size: usize, | ||
| 958 | ss_flags: c_int, | ||
| 959 | }; | ||
| 960 | |||
| 961 | pub const S_IFMT = 0o170000; | ||
| 962 | |||
| 963 | pub const S_IFIFO = 0o010000; | ||
| 964 | pub const S_IFCHR = 0o020000; | ||
| 965 | pub const S_IFDIR = 0o040000; | ||
| 966 | pub const S_IFBLK = 0o060000; | ||
| 967 | pub const S_IFREG = 0o100000; | ||
| 968 | pub const S_IFLNK = 0o120000; | ||
| 969 | pub const S_IFSOCK = 0o140000; | ||
| 970 | |||
| 971 | pub const S_ISUID = 0o4000; | ||
| 972 | pub const S_ISGID = 0o2000; | ||
| 973 | pub const S_ISVTX = 0o1000; | ||
| 974 | pub const S_IRWXU = 0o700; | ||
| 975 | pub const S_IRUSR = 0o400; | ||
| 976 | pub const S_IWUSR = 0o200; | ||
| 977 | pub const S_IXUSR = 0o100; | ||
| 978 | pub const S_IRWXG = 0o070; | ||
| 979 | pub const S_IRGRP = 0o040; | ||
| 980 | pub const S_IWGRP = 0o020; | ||
| 981 | pub const S_IXGRP = 0o010; | ||
| 982 | pub const S_IRWXO = 0o007; | ||
| 983 | pub const S_IROTH = 0o004; | ||
| 984 | pub const S_IWOTH = 0o002; | ||
| 985 | pub const S_IXOTH = 0o001; | ||
| 986 | |||
| 987 | pub fn S_ISFIFO(m: u32) bool { | ||
| 988 | return m & S_IFMT == S_IFIFO; | ||
| 989 | } | ||
| 990 | |||
| 991 | pub fn S_ISCHR(m: u32) bool { | ||
| 992 | return m & S_IFMT == S_IFCHR; | ||
| 993 | } | ||
| 994 | |||
| 995 | pub fn S_ISDIR(m: u32) bool { | ||
| 996 | return m & S_IFMT == S_IFDIR; | ||
| 997 | } | ||
| 998 | |||
| 999 | pub fn S_ISBLK(m: u32) bool { | ||
| 1000 | return m & S_IFMT == S_IFBLK; | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | pub fn S_ISREG(m: u32) bool { | ||
| 1004 | return m & S_IFMT == S_IFREG; | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | pub fn S_ISLNK(m: u32) bool { | ||
| 1008 | return m & S_IFMT == S_IFLNK; | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | pub fn S_ISSOCK(m: u32) bool { | ||
| 1012 | return m & S_IFMT == S_IFSOCK; | ||
| 1013 | } | ||
| 1014 | |||
| 1015 | /// Magic value that specify the use of the current working directory | ||
| 1016 | /// to determine the target of relative file paths in the openat() and | ||
| 1017 | /// similar syscalls. | ||
| 1018 | pub const AT_FDCWD = -100; | ||
| 1019 | |||
| 1020 | /// Check access using effective user and group ID | ||
| 1021 | pub const AT_EACCESS = 0x01; | ||
| 1022 | |||
| 1023 | /// Do not follow symbolic links | ||
| 1024 | pub const AT_SYMLINK_NOFOLLOW = 0x02; | ||
| 1025 | |||
| 1026 | /// Follow symbolic link | ||
| 1027 | pub const AT_SYMLINK_FOLLOW = 0x04; | ||
| 1028 | |||
| 1029 | /// Remove directory instead of file | ||
| 1030 | pub const AT_REMOVEDIR = 0x08; | ||
| 1031 | |||
| 1032 | pub const HOST_NAME_MAX = 255; | ||
| 1033 | |||
| 1034 | /// dummy for IP | ||
| 1035 | pub const IPPROTO_IP = 0; | ||
| 1036 | |||
| 1037 | /// IP6 hop-by-hop options | ||
| 1038 | pub const IPPROTO_HOPOPTS = IPPROTO_IP; | ||
| 1039 | |||
| 1040 | /// control message protocol | ||
| 1041 | pub const IPPROTO_ICMP = 1; | ||
| 1042 | |||
| 1043 | /// group mgmt protocol | ||
| 1044 | pub const IPPROTO_IGMP = 2; | ||
| 1045 | |||
| 1046 | /// gateway^2 (deprecated) | ||
| 1047 | pub const IPPROTO_GGP = 3; | ||
| 1048 | |||
| 1049 | /// IP header | ||
| 1050 | pub const IPPROTO_IPV4 = IPPROTO_IPIP; | ||
| 1051 | |||
| 1052 | /// IP inside IP | ||
| 1053 | pub const IPPROTO_IPIP = 4; | ||
| 1054 | |||
| 1055 | /// tcp | ||
| 1056 | pub const IPPROTO_TCP = 6; | ||
| 1057 | |||
| 1058 | /// exterior gateway protocol | ||
| 1059 | pub const IPPROTO_EGP = 8; | ||
| 1060 | |||
| 1061 | /// pup | ||
| 1062 | pub const IPPROTO_PUP = 12; | ||
| 1063 | |||
| 1064 | /// user datagram protocol | ||
| 1065 | pub const IPPROTO_UDP = 17; | ||
| 1066 | |||
| 1067 | /// xns idp | ||
| 1068 | pub const IPPROTO_IDP = 22; | ||
| 1069 | |||
| 1070 | /// tp-4 w/ class negotiation | ||
| 1071 | pub const IPPROTO_TP = 29; | ||
| 1072 | |||
| 1073 | /// IP6 header | ||
| 1074 | pub const IPPROTO_IPV6 = 41; | ||
| 1075 | |||
| 1076 | /// IP6 routing header | ||
| 1077 | pub const IPPROTO_ROUTING = 43; | ||
| 1078 | |||
| 1079 | /// IP6 fragmentation header | ||
| 1080 | pub const IPPROTO_FRAGMENT = 44; | ||
| 1081 | |||
| 1082 | /// resource reservation | ||
| 1083 | pub const IPPROTO_RSVP = 46; | ||
| 1084 | |||
| 1085 | /// GRE encaps RFC 1701 | ||
| 1086 | pub const IPPROTO_GRE = 47; | ||
| 1087 | |||
| 1088 | /// encap. security payload | ||
| 1089 | pub const IPPROTO_ESP = 50; | ||
| 1090 | |||
| 1091 | /// authentication header | ||
| 1092 | pub const IPPROTO_AH = 51; | ||
| 1093 | |||
| 1094 | /// IP Mobility RFC 2004 | ||
| 1095 | pub const IPPROTO_MOBILE = 55; | ||
| 1096 | |||
| 1097 | /// IPv6 ICMP | ||
| 1098 | pub const IPPROTO_IPV6_ICMP = 58; | ||
| 1099 | |||
| 1100 | /// ICMP6 | ||
| 1101 | pub const IPPROTO_ICMPV6 = 58; | ||
| 1102 | |||
| 1103 | /// IP6 no next header | ||
| 1104 | pub const IPPROTO_NONE = 59; | ||
| 1105 | |||
| 1106 | /// IP6 destination option | ||
| 1107 | pub const IPPROTO_DSTOPTS = 60; | ||
| 1108 | |||
| 1109 | /// ISO cnlp | ||
| 1110 | pub const IPPROTO_EON = 80; | ||
| 1111 | |||
| 1112 | /// Ethernet-in-IP | ||
| 1113 | pub const IPPROTO_ETHERIP = 97; | ||
| 1114 | |||
| 1115 | /// encapsulation header | ||
| 1116 | pub const IPPROTO_ENCAP = 98; | ||
| 1117 | |||
| 1118 | /// Protocol indep. multicast | ||
| 1119 | pub const IPPROTO_PIM = 103; | ||
| 1120 | |||
| 1121 | /// IP Payload Comp. Protocol | ||
| 1122 | pub const IPPROTO_IPCOMP = 108; | ||
| 1123 | |||
| 1124 | /// VRRP RFC 2338 | ||
| 1125 | pub const IPPROTO_VRRP = 112; | ||
| 1126 | |||
| 1127 | /// Common Address Resolution Protocol | ||
| 1128 | pub const IPPROTO_CARP = 112; | ||
| 1129 | |||
| 1130 | /// PFSYNC | ||
| 1131 | pub const IPPROTO_PFSYNC = 240; | ||
| 1132 | |||
| 1133 | /// raw IP packet | ||
| 1134 | pub const IPPROTO_RAW = 255; | ||
| 1135 | |||
| 1136 | pub const rlimit_resource = enum(c_int) { | ||
| 1137 | CPU, | ||
| 1138 | FSIZE, | ||
| 1139 | DATA, | ||
| 1140 | STACK, | ||
| 1141 | CORE, | ||
| 1142 | RSS, | ||
| 1143 | MEMLOCK, | ||
| 1144 | NPROC, | ||
| 1145 | NOFILE, | ||
| 1146 | |||
| 1147 | _, | ||
| 1148 | }; | ||
| 1149 | |||
| 1150 | pub const rlim_t = u64; | ||
| 1151 | |||
| 1152 | /// No limit | ||
| 1153 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1154 | |||
| 1155 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; | ||
| 1156 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; | ||
| 1157 | |||
| 1158 | pub const rlimit = extern struct { | ||
| 1159 | /// Soft limit | ||
| 1160 | cur: rlim_t, | ||
| 1161 | /// Hard limit | ||
| 1162 | max: rlim_t, | ||
| 1163 | }; | ||
| 1164 | |||
| 1165 | pub const SHUT_RD = 0; | ||
| 1166 | pub const SHUT_WR = 1; | ||
| 1167 | pub const SHUT_RDWR = 2; | ||
| 1168 | |||
| 1169 | pub const nfds_t = c_uint; | ||
| 1170 | |||
| 1171 | pub const pollfd = extern struct { | ||
| 1172 | fd: fd_t, | ||
| 1173 | events: c_short, | ||
| 1174 | revents: c_short, | ||
| 1175 | }; | ||
| 1176 | |||
| 1177 | pub const POLLIN = 0x0001; | ||
| 1178 | pub const POLLPRI = 0x0002; | ||
| 1179 | pub const POLLOUT = 0x0004; | ||
| 1180 | pub const POLLERR = 0x0008; | ||
| 1181 | pub const POLLHUP = 0x0010; | ||
| 1182 | pub const POLLNVAL = 0x0020; | ||
| 1183 | pub const POLLRDNORM = 0x0040; | ||
| 1184 | pub const POLLNORM = POLLRDNORM; | ||
| 1185 | pub const POLLWRNORM = POLLOUT; | ||
| 1186 | pub const POLLRDBAND = 0x0080; | ||
| 1187 | pub const POLLWRBAND = 0x0100; | ||
| 1188 | |||
| 1189 | // sysctl mib | ||
| 1190 | pub const CTL_UNSPEC = 0; | ||
| 1191 | pub const CTL_KERN = 1; | ||
| 1192 | pub const CTL_VM = 2; | ||
| 1193 | pub const CTL_FS = 3; | ||
| 1194 | pub const CTL_NET = 4; | ||
| 1195 | pub const CTL_DEBUG = 5; | ||
| 1196 | pub const CTL_HW = 6; | ||
| 1197 | pub const CTL_MACHDEP = 7; | ||
| 1198 | |||
| 1199 | pub const CTL_DDB = 9; | ||
| 1200 | pub const CTL_VFS = 10; | ||
| 1201 | |||
| 1202 | pub const KERN_OSTYPE = 1; | ||
| 1203 | pub const KERN_OSRELEASE = 2; | ||
| 1204 | pub const KERN_OSREV = 3; | ||
| 1205 | pub const KERN_VERSION = 4; | ||
| 1206 | pub const KERN_MAXVNODES = 5; | ||
| 1207 | pub const KERN_MAXPROC = 6; | ||
| 1208 | pub const KERN_MAXFILES = 7; | ||
| 1209 | pub const KERN_ARGMAX = 8; | ||
| 1210 | pub const KERN_SECURELVL = 9; | ||
| 1211 | pub const KERN_HOSTNAME = 10; | ||
| 1212 | pub const KERN_HOSTID = 11; | ||
| 1213 | pub const KERN_CLOCKRATE = 12; | ||
| 1214 | |||
| 1215 | pub const KERN_PROF = 16; | ||
| 1216 | pub const KERN_POSIX1 = 17; | ||
| 1217 | pub const KERN_NGROUPS = 18; | ||
| 1218 | pub const KERN_JOB_CONTROL = 19; | ||
| 1219 | pub const KERN_SAVED_IDS = 20; | ||
| 1220 | pub const KERN_BOOTTIME = 21; | ||
| 1221 | pub const KERN_DOMAINNAME = 22; | ||
| 1222 | pub const KERN_MAXPARTITIONS = 23; | ||
| 1223 | pub const KERN_RAWPARTITION = 24; | ||
| 1224 | pub const KERN_MAXTHREAD = 25; | ||
| 1225 | pub const KERN_NTHREADS = 26; | ||
| 1226 | pub const KERN_OSVERSION = 27; | ||
| 1227 | pub const KERN_SOMAXCONN = 28; | ||
| 1228 | pub const KERN_SOMINCONN = 29; | ||
| 1229 | |||
| 1230 | pub const KERN_NOSUIDCOREDUMP = 32; | ||
| 1231 | pub const KERN_FSYNC = 33; | ||
| 1232 | pub const KERN_SYSVMSG = 34; | ||
| 1233 | pub const KERN_SYSVSEM = 35; | ||
| 1234 | pub const KERN_SYSVSHM = 36; | ||
| 1235 | |||
| 1236 | pub const KERN_MSGBUFSIZE = 38; | ||
| 1237 | pub const KERN_MALLOCSTATS = 39; | ||
| 1238 | pub const KERN_CPTIME = 40; | ||
| 1239 | pub const KERN_NCHSTATS = 41; | ||
| 1240 | pub const KERN_FORKSTAT = 42; | ||
| 1241 | pub const KERN_NSELCOLL = 43; | ||
| 1242 | pub const KERN_TTY = 44; | ||
| 1243 | pub const KERN_CCPU = 45; | ||
| 1244 | pub const KERN_FSCALE = 46; | ||
| 1245 | pub const KERN_NPROCS = 47; | ||
| 1246 | pub const KERN_MSGBUF = 48; | ||
| 1247 | pub const KERN_POOL = 49; | ||
| 1248 | pub const KERN_STACKGAPRANDOM = 50; | ||
| 1249 | pub const KERN_SYSVIPC_INFO = 51; | ||
| 1250 | pub const KERN_ALLOWKMEM = 52; | ||
| 1251 | pub const KERN_WITNESSWATCH = 53; | ||
| 1252 | pub const KERN_SPLASSERT = 54; | ||
| 1253 | pub const KERN_PROC_ARGS = 55; | ||
| 1254 | pub const KERN_NFILES = 56; | ||
| 1255 | pub const KERN_TTYCOUNT = 57; | ||
| 1256 | pub const KERN_NUMVNODES = 58; | ||
| 1257 | pub const KERN_MBSTAT = 59; | ||
| 1258 | pub const KERN_WITNESS = 60; | ||
| 1259 | pub const KERN_SEMINFO = 61; | ||
| 1260 | pub const KERN_SHMINFO = 62; | ||
| 1261 | pub const KERN_INTRCNT = 63; | ||
| 1262 | pub const KERN_WATCHDOG = 64; | ||
| 1263 | pub const KERN_ALLOWDT = 65; | ||
| 1264 | pub const KERN_PROC = 66; | ||
| 1265 | pub const KERN_MAXCLUSTERS = 67; | ||
| 1266 | pub const KERN_EVCOUNT = 68; | ||
| 1267 | pub const KERN_TIMECOUNTER = 69; | ||
| 1268 | pub const KERN_MAXLOCKSPERUID = 70; | ||
| 1269 | pub const KERN_CPTIME2 = 71; | ||
| 1270 | pub const KERN_CACHEPCT = 72; | ||
| 1271 | pub const KERN_FILE = 73; | ||
| 1272 | pub const KERN_WXABORT = 74; | ||
| 1273 | pub const KERN_CONSDEV = 75; | ||
| 1274 | pub const KERN_NETLIVELOCKS = 76; | ||
| 1275 | pub const KERN_POOL_DEBUG = 77; | ||
| 1276 | pub const KERN_PROC_CWD = 78; | ||
| 1277 | pub const KERN_PROC_NOBROADCASTKILL = 79; | ||
| 1278 | pub const KERN_PROC_VMMAP = 80; | ||
| 1279 | pub const KERN_GLOBAL_PTRACE = 81; | ||
| 1280 | pub const KERN_CONSBUFSIZE = 82; | ||
| 1281 | pub const KERN_CONSBUF = 83; | ||
| 1282 | pub const KERN_AUDIO = 84; | ||
| 1283 | pub const KERN_CPUSTATS = 85; | ||
| 1284 | pub const KERN_PFSTATUS = 86; | ||
| 1285 | pub const KERN_TIMEOUT_STATS = 87; | ||
| 1286 | pub const KERN_UTC_OFFSET = 88; | ||
| 1287 | pub const KERN_VIDEO = 89; | ||
| 1288 | |||
| 1289 | pub const HW_MACHINE = 1; | ||
| 1290 | pub const HW_MODEL = 2; | ||
| 1291 | pub const HW_NCPU = 3; | ||
| 1292 | pub const HW_BYTEORDER = 4; | ||
| 1293 | pub const HW_PHYSMEM = 5; | ||
| 1294 | pub const HW_USERMEM = 6; | ||
| 1295 | pub const HW_PAGESIZE = 7; | ||
| 1296 | pub const HW_DISKNAMES = 8; | ||
| 1297 | pub const HW_DISKSTATS = 9; | ||
| 1298 | pub const HW_DISKCOUNT = 10; | ||
| 1299 | pub const HW_SENSORS = 11; | ||
| 1300 | pub const HW_CPUSPEED = 12; | ||
| 1301 | pub const HW_SETPERF = 13; | ||
| 1302 | pub const HW_VENDOR = 14; | ||
| 1303 | pub const HW_PRODUCT = 15; | ||
| 1304 | pub const HW_VERSION = 16; | ||
| 1305 | pub const HW_SERIALNO = 17; | ||
| 1306 | pub const HW_UUID = 18; | ||
| 1307 | pub const HW_PHYSMEM64 = 19; | ||
| 1308 | pub const HW_USERMEM64 = 20; | ||
| 1309 | pub const HW_NCPUFOUND = 21; | ||
| 1310 | pub const HW_ALLOWPOWERDOWN = 22; | ||
| 1311 | pub const HW_PERFPOLICY = 23; | ||
| 1312 | pub const HW_SMT = 24; | ||
| 1313 | pub const HW_NCPUONLINE = 25; | ||
| 1314 | |||
| 1315 | pub const KERN_PROC_ALL = 0; | ||
| 1316 | pub const KERN_PROC_PID = 1; | ||
| 1317 | pub const KERN_PROC_PGRP = 2; | ||
| 1318 | pub const KERN_PROC_SESSION = 3; | ||
| 1319 | pub const KERN_PROC_TTY = 4; | ||
| 1320 | pub const KERN_PROC_UID = 5; | ||
| 1321 | pub const KERN_PROC_RUID = 6; | ||
| 1322 | pub const KERN_PROC_KTHREAD = 7; | ||
| 1323 | pub const KERN_PROC_SHOW_THREADS = 0x40000000; | ||
| 1324 | |||
| 1325 | pub const KERN_PROC_ARGV = 1; | ||
| 1326 | pub const KERN_PROC_NARGV = 2; | ||
| 1327 | pub const KERN_PROC_ENV = 3; | ||
| 1328 | pub const KERN_PROC_NENV = 4; | ||
lib/std/os/bits/wasi.zig deleted-491| ... | @@ -1,491 +0,0 @@ | ||
| 1 | // Convenience types and consts used by std.os module | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | pub const iovec = posix.iovec; | ||
| 4 | pub const iovec_const = posix.iovec_const; | ||
| 5 | |||
| 6 | pub const STDIN_FILENO = 0; | ||
| 7 | pub const STDOUT_FILENO = 1; | ||
| 8 | pub const STDERR_FILENO = 2; | ||
| 9 | |||
| 10 | pub const mode_t = u32; | ||
| 11 | |||
| 12 | pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc | ||
| 13 | |||
| 14 | pub const timespec = struct { | ||
| 15 | tv_sec: time_t, | ||
| 16 | tv_nsec: isize, | ||
| 17 | |||
| 18 | pub fn fromTimestamp(tm: timestamp_t) timespec { | ||
| 19 | const tv_sec: timestamp_t = tm / 1_000_000_000; | ||
| 20 | const tv_nsec = tm - tv_sec * 1_000_000_000; | ||
| 21 | return timespec{ | ||
| 22 | .tv_sec = @intCast(time_t, tv_sec), | ||
| 23 | .tv_nsec = @intCast(isize, tv_nsec), | ||
| 24 | }; | ||
| 25 | } | ||
| 26 | |||
| 27 | pub fn toTimestamp(ts: timespec) timestamp_t { | ||
| 28 | const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec); | ||
| 29 | return tm; | ||
| 30 | } | ||
| 31 | }; | ||
| 32 | |||
| 33 | pub const kernel_stat = struct { | ||
| 34 | dev: device_t, | ||
| 35 | ino: inode_t, | ||
| 36 | mode: mode_t, | ||
| 37 | filetype: filetype_t, | ||
| 38 | nlink: linkcount_t, | ||
| 39 | size: filesize_t, | ||
| 40 | atim: timespec, | ||
| 41 | mtim: timespec, | ||
| 42 | ctim: timespec, | ||
| 43 | |||
| 44 | const Self = @This(); | ||
| 45 | |||
| 46 | pub fn fromFilestat(stat: filestat_t) Self { | ||
| 47 | return Self{ | ||
| 48 | .dev = stat.dev, | ||
| 49 | .ino = stat.ino, | ||
| 50 | .mode = 0, | ||
| 51 | .filetype = stat.filetype, | ||
| 52 | .nlink = stat.nlink, | ||
| 53 | .size = stat.size, | ||
| 54 | .atim = stat.atime(), | ||
| 55 | .mtim = stat.mtime(), | ||
| 56 | .ctim = stat.ctime(), | ||
| 57 | }; | ||
| 58 | } | ||
| 59 | |||
| 60 | pub fn atime(self: Self) timespec { | ||
| 61 | return self.atim; | ||
| 62 | } | ||
| 63 | |||
| 64 | pub fn mtime(self: Self) timespec { | ||
| 65 | return self.mtim; | ||
| 66 | } | ||
| 67 | |||
| 68 | pub fn ctime(self: Self) timespec { | ||
| 69 | return self.ctim; | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | |||
| 73 | pub const IOV_MAX = 1024; | ||
| 74 | |||
| 75 | pub const AT_REMOVEDIR: u32 = 0x4; | ||
| 76 | pub const AT_FDCWD: fd_t = -2; | ||
| 77 | |||
| 78 | // As defined in the wasi_snapshot_preview1 spec file: | ||
| 79 | // https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx | ||
| 80 | pub const advice_t = u8; | ||
| 81 | pub const ADVICE_NORMAL: advice_t = 0; | ||
| 82 | pub const ADVICE_SEQUENTIAL: advice_t = 1; | ||
| 83 | pub const ADVICE_RANDOM: advice_t = 2; | ||
| 84 | pub const ADVICE_WILLNEED: advice_t = 3; | ||
| 85 | pub const ADVICE_DONTNEED: advice_t = 4; | ||
| 86 | pub const ADVICE_NOREUSE: advice_t = 5; | ||
| 87 | |||
| 88 | pub const clockid_t = u32; | ||
| 89 | pub const CLOCK = struct { | ||
| 90 | pub const REALTIME: clockid_t = 0; | ||
| 91 | pub const MONOTONIC: clockid_t = 1; | ||
| 92 | pub const PROCESS_CPUTIME_ID: clockid_t = 2; | ||
| 93 | pub const THREAD_CPUTIME_ID: clockid_t = 3; | ||
| 94 | }; | ||
| 95 | |||
| 96 | pub const device_t = u64; | ||
| 97 | |||
| 98 | pub const dircookie_t = u64; | ||
| 99 | pub const DIRCOOKIE_START: dircookie_t = 0; | ||
| 100 | |||
| 101 | pub const dirnamlen_t = u32; | ||
| 102 | |||
| 103 | pub const dirent_t = extern struct { | ||
| 104 | d_next: dircookie_t, | ||
| 105 | d_ino: inode_t, | ||
| 106 | d_namlen: dirnamlen_t, | ||
| 107 | d_type: filetype_t, | ||
| 108 | }; | ||
| 109 | |||
| 110 | pub const errno_t = enum(u16) { | ||
| 111 | SUCCESS = 0, | ||
| 112 | @"2BIG" = 1, | ||
| 113 | ACCES = 2, | ||
| 114 | ADDRINUSE = 3, | ||
| 115 | ADDRNOTAVAIL = 4, | ||
| 116 | AFNOSUPPORT = 5, | ||
| 117 | /// This is also the error code used for `WOULDBLOCK`. | ||
| 118 | AGAIN = 6, | ||
| 119 | ALREADY = 7, | ||
| 120 | BADF = 8, | ||
| 121 | BADMSG = 9, | ||
| 122 | BUSY = 10, | ||
| 123 | CANCELED = 11, | ||
| 124 | CHILD = 12, | ||
| 125 | CONNABORTED = 13, | ||
| 126 | CONNREFUSED = 14, | ||
| 127 | CONNRESET = 15, | ||
| 128 | DEADLK = 16, | ||
| 129 | DESTADDRREQ = 17, | ||
| 130 | DOM = 18, | ||
| 131 | DQUOT = 19, | ||
| 132 | EXIST = 20, | ||
| 133 | FAULT = 21, | ||
| 134 | FBIG = 22, | ||
| 135 | HOSTUNREACH = 23, | ||
| 136 | IDRM = 24, | ||
| 137 | ILSEQ = 25, | ||
| 138 | INPROGRESS = 26, | ||
| 139 | INTR = 27, | ||
| 140 | INVAL = 28, | ||
| 141 | IO = 29, | ||
| 142 | ISCONN = 30, | ||
| 143 | ISDIR = 31, | ||
| 144 | LOOP = 32, | ||
| 145 | MFILE = 33, | ||
| 146 | MLINK = 34, | ||
| 147 | MSGSIZE = 35, | ||
| 148 | MULTIHOP = 36, | ||
| 149 | NAMETOOLONG = 37, | ||
| 150 | NETDOWN = 38, | ||
| 151 | NETRESET = 39, | ||
| 152 | NETUNREACH = 40, | ||
| 153 | NFILE = 41, | ||
| 154 | NOBUFS = 42, | ||
| 155 | NODEV = 43, | ||
| 156 | NOENT = 44, | ||
| 157 | NOEXEC = 45, | ||
| 158 | NOLCK = 46, | ||
| 159 | NOLINK = 47, | ||
| 160 | NOMEM = 48, | ||
| 161 | NOMSG = 49, | ||
| 162 | NOPROTOOPT = 50, | ||
| 163 | NOSPC = 51, | ||
| 164 | NOSYS = 52, | ||
| 165 | NOTCONN = 53, | ||
| 166 | NOTDIR = 54, | ||
| 167 | NOTEMPTY = 55, | ||
| 168 | NOTRECOVERABLE = 56, | ||
| 169 | NOTSOCK = 57, | ||
| 170 | /// This is also the code used for `NOTSUP`. | ||
| 171 | OPNOTSUPP = 58, | ||
| 172 | NOTTY = 59, | ||
| 173 | NXIO = 60, | ||
| 174 | OVERFLOW = 61, | ||
| 175 | OWNERDEAD = 62, | ||
| 176 | PERM = 63, | ||
| 177 | PIPE = 64, | ||
| 178 | PROTO = 65, | ||
| 179 | PROTONOSUPPORT = 66, | ||
| 180 | PROTOTYPE = 67, | ||
| 181 | RANGE = 68, | ||
| 182 | ROFS = 69, | ||
| 183 | SPIPE = 70, | ||
| 184 | SRCH = 71, | ||
| 185 | STALE = 72, | ||
| 186 | TIMEDOUT = 73, | ||
| 187 | TXTBSY = 74, | ||
| 188 | XDEV = 75, | ||
| 189 | NOTCAPABLE = 76, | ||
| 190 | _, | ||
| 191 | }; | ||
| 192 | pub const E = errno_t; | ||
| 193 | |||
| 194 | pub const event_t = extern struct { | ||
| 195 | userdata: userdata_t, | ||
| 196 | @"error": errno_t, | ||
| 197 | @"type": eventtype_t, | ||
| 198 | fd_readwrite: eventfdreadwrite_t, | ||
| 199 | }; | ||
| 200 | |||
| 201 | pub const eventfdreadwrite_t = extern struct { | ||
| 202 | nbytes: filesize_t, | ||
| 203 | flags: eventrwflags_t, | ||
| 204 | }; | ||
| 205 | |||
| 206 | pub const eventrwflags_t = u16; | ||
| 207 | pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001; | ||
| 208 | |||
| 209 | pub const eventtype_t = u8; | ||
| 210 | pub const EVENTTYPE_CLOCK: eventtype_t = 0; | ||
| 211 | pub const EVENTTYPE_FD_READ: eventtype_t = 1; | ||
| 212 | pub const EVENTTYPE_FD_WRITE: eventtype_t = 2; | ||
| 213 | |||
| 214 | pub const exitcode_t = u32; | ||
| 215 | |||
| 216 | pub const fd_t = if (builtin.link_libc) c_int else u32; | ||
| 217 | |||
| 218 | pub const fdflags_t = u16; | ||
| 219 | pub const FDFLAG_APPEND: fdflags_t = 0x0001; | ||
| 220 | pub const FDFLAG_DSYNC: fdflags_t = 0x0002; | ||
| 221 | pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004; | ||
| 222 | pub const FDFLAG_RSYNC: fdflags_t = 0x0008; | ||
| 223 | pub const FDFLAG_SYNC: fdflags_t = 0x0010; | ||
| 224 | |||
| 225 | pub const fdstat_t = extern struct { | ||
| 226 | fs_filetype: filetype_t, | ||
| 227 | fs_flags: fdflags_t, | ||
| 228 | fs_rights_base: rights_t, | ||
| 229 | fs_rights_inheriting: rights_t, | ||
| 230 | }; | ||
| 231 | |||
| 232 | pub const filedelta_t = i64; | ||
| 233 | |||
| 234 | pub const filesize_t = u64; | ||
| 235 | |||
| 236 | pub const filestat_t = extern struct { | ||
| 237 | dev: device_t, | ||
| 238 | ino: inode_t, | ||
| 239 | filetype: filetype_t, | ||
| 240 | nlink: linkcount_t, | ||
| 241 | size: filesize_t, | ||
| 242 | atim: timestamp_t, | ||
| 243 | mtim: timestamp_t, | ||
| 244 | ctim: timestamp_t, | ||
| 245 | |||
| 246 | pub fn atime(self: filestat_t) timespec { | ||
| 247 | return timespec.fromTimestamp(self.atim); | ||
| 248 | } | ||
| 249 | |||
| 250 | pub fn mtime(self: filestat_t) timespec { | ||
| 251 | return timespec.fromTimestamp(self.mtim); | ||
| 252 | } | ||
| 253 | |||
| 254 | pub fn ctime(self: filestat_t) timespec { | ||
| 255 | return timespec.fromTimestamp(self.ctim); | ||
| 256 | } | ||
| 257 | }; | ||
| 258 | |||
| 259 | pub const filetype_t = u8; | ||
| 260 | pub const FILETYPE_UNKNOWN: filetype_t = 0; | ||
| 261 | pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1; | ||
| 262 | pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2; | ||
| 263 | pub const FILETYPE_DIRECTORY: filetype_t = 3; | ||
| 264 | pub const FILETYPE_REGULAR_FILE: filetype_t = 4; | ||
| 265 | pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5; | ||
| 266 | pub const FILETYPE_SOCKET_STREAM: filetype_t = 6; | ||
| 267 | pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7; | ||
| 268 | |||
| 269 | pub const fstflags_t = u16; | ||
| 270 | pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001; | ||
| 271 | pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002; | ||
| 272 | pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004; | ||
| 273 | pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; | ||
| 274 | |||
| 275 | pub const inode_t = u64; | ||
| 276 | pub const ino_t = inode_t; | ||
| 277 | |||
| 278 | pub const linkcount_t = u64; | ||
| 279 | |||
| 280 | pub const lookupflags_t = u32; | ||
| 281 | pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001; | ||
| 282 | |||
| 283 | pub usingnamespace if (builtin.link_libc) struct { | ||
| 284 | // Derived from https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt | ||
| 285 | pub const O_ACCMODE = (O_EXEC | O_RDWR | O_SEARCH); | ||
| 286 | pub const O_APPEND = FDFLAG_APPEND; | ||
| 287 | pub const O_CLOEXEC = (0); | ||
| 288 | pub const O_CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12 | ||
| 289 | pub const O_DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12 | ||
| 290 | pub const O_DSYNC = FDFLAG_DSYNC; | ||
| 291 | pub const O_EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12 | ||
| 292 | pub const O_EXEC = (0x02000000); | ||
| 293 | pub const O_NOCTTY = (0); | ||
| 294 | pub const O_NOFOLLOW = (0x01000000); | ||
| 295 | pub const O_NONBLOCK = (1 << FDFLAG_NONBLOCK); | ||
| 296 | pub const O_RDONLY = (0x04000000); | ||
| 297 | pub const O_RDWR = (O_RDONLY | O_WRONLY); | ||
| 298 | pub const O_RSYNC = (1 << FDFLAG_RSYNC); | ||
| 299 | pub const O_SEARCH = (0x08000000); | ||
| 300 | pub const O_SYNC = (1 << FDFLAG_SYNC); | ||
| 301 | pub const O_TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12 | ||
| 302 | pub const O_TTY_INIT = (0); | ||
| 303 | pub const O_WRONLY = (0x10000000); | ||
| 304 | } else struct { | ||
| 305 | pub const oflags_t = u16; | ||
| 306 | pub const O_CREAT: oflags_t = 0x0001; | ||
| 307 | pub const O_DIRECTORY: oflags_t = 0x0002; | ||
| 308 | pub const O_EXCL: oflags_t = 0x0004; | ||
| 309 | pub const O_TRUNC: oflags_t = 0x0008; | ||
| 310 | }; | ||
| 311 | |||
| 312 | pub const preopentype_t = u8; | ||
| 313 | pub const PREOPENTYPE_DIR: preopentype_t = 0; | ||
| 314 | |||
| 315 | pub const prestat_t = extern struct { | ||
| 316 | pr_type: preopentype_t, | ||
| 317 | u: prestat_u_t, | ||
| 318 | }; | ||
| 319 | |||
| 320 | pub const prestat_dir_t = extern struct { | ||
| 321 | pr_name_len: usize, | ||
| 322 | }; | ||
| 323 | |||
| 324 | pub const prestat_u_t = extern union { | ||
| 325 | dir: prestat_dir_t, | ||
| 326 | }; | ||
| 327 | |||
| 328 | pub const riflags_t = u16; | ||
| 329 | pub const SOCK_RECV_PEEK: riflags_t = 0x0001; | ||
| 330 | pub const SOCK_RECV_WAITALL: riflags_t = 0x0002; | ||
| 331 | |||
| 332 | pub const rights_t = u64; | ||
| 333 | pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001; | ||
| 334 | pub const RIGHT_FD_READ: rights_t = 0x0000000000000002; | ||
| 335 | pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004; | ||
| 336 | pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008; | ||
| 337 | pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010; | ||
| 338 | pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020; | ||
| 339 | pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040; | ||
| 340 | pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080; | ||
| 341 | pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100; | ||
| 342 | pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200; | ||
| 343 | pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400; | ||
| 344 | pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800; | ||
| 345 | pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000; | ||
| 346 | pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000; | ||
| 347 | pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000; | ||
| 348 | pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000; | ||
| 349 | pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000; | ||
| 350 | pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000; | ||
| 351 | pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000; | ||
| 352 | pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000; | ||
| 353 | pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000; | ||
| 354 | pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000; | ||
| 355 | pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000; | ||
| 356 | pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000; | ||
| 357 | pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000; | ||
| 358 | pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000; | ||
| 359 | pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000; | ||
| 360 | pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000; | ||
| 361 | pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000; | ||
| 362 | pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC | | ||
| 363 | RIGHT_FD_READ | | ||
| 364 | RIGHT_FD_SEEK | | ||
| 365 | RIGHT_FD_FDSTAT_SET_FLAGS | | ||
| 366 | RIGHT_FD_SYNC | | ||
| 367 | RIGHT_FD_TELL | | ||
| 368 | RIGHT_FD_WRITE | | ||
| 369 | RIGHT_FD_ADVISE | | ||
| 370 | RIGHT_FD_ALLOCATE | | ||
| 371 | RIGHT_PATH_CREATE_DIRECTORY | | ||
| 372 | RIGHT_PATH_CREATE_FILE | | ||
| 373 | RIGHT_PATH_LINK_SOURCE | | ||
| 374 | RIGHT_PATH_LINK_TARGET | | ||
| 375 | RIGHT_PATH_OPEN | | ||
| 376 | RIGHT_FD_READDIR | | ||
| 377 | RIGHT_PATH_READLINK | | ||
| 378 | RIGHT_PATH_RENAME_SOURCE | | ||
| 379 | RIGHT_PATH_RENAME_TARGET | | ||
| 380 | RIGHT_PATH_FILESTAT_GET | | ||
| 381 | RIGHT_PATH_FILESTAT_SET_SIZE | | ||
| 382 | RIGHT_PATH_FILESTAT_SET_TIMES | | ||
| 383 | RIGHT_FD_FILESTAT_GET | | ||
| 384 | RIGHT_FD_FILESTAT_SET_SIZE | | ||
| 385 | RIGHT_FD_FILESTAT_SET_TIMES | | ||
| 386 | RIGHT_PATH_SYMLINK | | ||
| 387 | RIGHT_PATH_REMOVE_DIRECTORY | | ||
| 388 | RIGHT_PATH_UNLINK_FILE | | ||
| 389 | RIGHT_POLL_FD_READWRITE | | ||
| 390 | RIGHT_SOCK_SHUTDOWN; | ||
| 391 | |||
| 392 | pub const roflags_t = u16; | ||
| 393 | pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001; | ||
| 394 | |||
| 395 | pub const sdflags_t = u8; | ||
| 396 | pub const SHUT_RD: sdflags_t = 0x01; | ||
| 397 | pub const SHUT_WR: sdflags_t = 0x02; | ||
| 398 | |||
| 399 | pub const siflags_t = u16; | ||
| 400 | |||
| 401 | pub const signal_t = u8; | ||
| 402 | pub const SIGNONE: signal_t = 0; | ||
| 403 | pub const SIGHUP: signal_t = 1; | ||
| 404 | pub const SIGINT: signal_t = 2; | ||
| 405 | pub const SIGQUIT: signal_t = 3; | ||
| 406 | pub const SIGILL: signal_t = 4; | ||
| 407 | pub const SIGTRAP: signal_t = 5; | ||
| 408 | pub const SIGABRT: signal_t = 6; | ||
| 409 | pub const SIGBUS: signal_t = 7; | ||
| 410 | pub const SIGFPE: signal_t = 8; | ||
| 411 | pub const SIGKILL: signal_t = 9; | ||
| 412 | pub const SIGUSR1: signal_t = 10; | ||
| 413 | pub const SIGSEGV: signal_t = 11; | ||
| 414 | pub const SIGUSR2: signal_t = 12; | ||
| 415 | pub const SIGPIPE: signal_t = 13; | ||
| 416 | pub const SIGALRM: signal_t = 14; | ||
| 417 | pub const SIGTERM: signal_t = 15; | ||
| 418 | pub const SIGCHLD: signal_t = 16; | ||
| 419 | pub const SIGCONT: signal_t = 17; | ||
| 420 | pub const SIGSTOP: signal_t = 18; | ||
| 421 | pub const SIGTSTP: signal_t = 19; | ||
| 422 | pub const SIGTTIN: signal_t = 20; | ||
| 423 | pub const SIGTTOU: signal_t = 21; | ||
| 424 | pub const SIGURG: signal_t = 22; | ||
| 425 | pub const SIGXCPU: signal_t = 23; | ||
| 426 | pub const SIGXFSZ: signal_t = 24; | ||
| 427 | pub const SIGVTALRM: signal_t = 25; | ||
| 428 | pub const SIGPROF: signal_t = 26; | ||
| 429 | pub const SIGWINCH: signal_t = 27; | ||
| 430 | pub const SIGPOLL: signal_t = 28; | ||
| 431 | pub const SIGPWR: signal_t = 29; | ||
| 432 | pub const SIGSYS: signal_t = 30; | ||
| 433 | |||
| 434 | pub const subclockflags_t = u16; | ||
| 435 | pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001; | ||
| 436 | |||
| 437 | pub const subscription_t = extern struct { | ||
| 438 | userdata: userdata_t, | ||
| 439 | u: subscription_u_t, | ||
| 440 | }; | ||
| 441 | |||
| 442 | pub const subscription_clock_t = extern struct { | ||
| 443 | id: clockid_t, | ||
| 444 | timeout: timestamp_t, | ||
| 445 | precision: timestamp_t, | ||
| 446 | flags: subclockflags_t, | ||
| 447 | }; | ||
| 448 | |||
| 449 | pub const subscription_fd_readwrite_t = extern struct { | ||
| 450 | fd: fd_t, | ||
| 451 | }; | ||
| 452 | |||
| 453 | pub const subscription_u_t = extern struct { | ||
| 454 | tag: eventtype_t, | ||
| 455 | u: subscription_u_u_t, | ||
| 456 | }; | ||
| 457 | |||
| 458 | pub const subscription_u_u_t = extern union { | ||
| 459 | clock: subscription_clock_t, | ||
| 460 | fd_read: subscription_fd_readwrite_t, | ||
| 461 | fd_write: subscription_fd_readwrite_t, | ||
| 462 | }; | ||
| 463 | |||
| 464 | pub const timestamp_t = u64; | ||
| 465 | |||
| 466 | pub const userdata_t = u64; | ||
| 467 | |||
| 468 | pub const whence_t = u8; | ||
| 469 | pub const WHENCE_SET: whence_t = 0; | ||
| 470 | pub const WHENCE_CUR: whence_t = 1; | ||
| 471 | pub const WHENCE_END: whence_t = 2; | ||
| 472 | |||
| 473 | pub const S_IEXEC = S_IXUSR; | ||
| 474 | pub const S_IFBLK = 0x6000; | ||
| 475 | pub const S_IFCHR = 0x2000; | ||
| 476 | pub const S_IFDIR = 0x4000; | ||
| 477 | pub const S_IFIFO = 0xc000; | ||
| 478 | pub const S_IFLNK = 0xa000; | ||
| 479 | pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK; | ||
| 480 | pub const S_IFREG = 0x8000; | ||
| 481 | // There's no concept of UNIX domain socket but we define this value here in order to line with other OSes. | ||
| 482 | pub const S_IFSOCK = 0x1; | ||
| 483 | |||
| 484 | pub const SEEK_SET = WHENCE_SET; | ||
| 485 | pub const SEEK_CUR = WHENCE_CUR; | ||
| 486 | pub const SEEK_END = WHENCE_END; | ||
| 487 | |||
| 488 | pub const LOCK_SH = 0x1; | ||
| 489 | pub const LOCK_EX = 0x2; | ||
| 490 | pub const LOCK_NB = 0x4; | ||
| 491 | pub const LOCK_UN = 0x8; | ||
lib/std/os/bits/windows.zig deleted-324| ... | @@ -1,324 +0,0 @@ | ||
| 1 | // The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime). | ||
| 2 | |||
| 3 | usingnamespace @import("../windows/bits.zig"); | ||
| 4 | const ws2_32 = @import("../windows/ws2_32.zig"); | ||
| 5 | |||
| 6 | pub const fd_t = HANDLE; | ||
| 7 | pub const ino_t = LARGE_INTEGER; | ||
| 8 | pub const pid_t = HANDLE; | ||
| 9 | pub const mode_t = u0; | ||
| 10 | |||
| 11 | pub const PATH_MAX = 260; | ||
| 12 | |||
| 13 | pub const time_t = c_longlong; | ||
| 14 | |||
| 15 | pub const timespec = extern struct { | ||
| 16 | tv_sec: time_t, | ||
| 17 | tv_nsec: c_long, | ||
| 18 | }; | ||
| 19 | |||
| 20 | pub const timeval = extern struct { | ||
| 21 | tv_sec: c_long, | ||
| 22 | tv_usec: c_long, | ||
| 23 | }; | ||
| 24 | |||
| 25 | pub const sig_atomic_t = c_int; | ||
| 26 | |||
| 27 | /// maximum signal number + 1 | ||
| 28 | pub const NSIG = 23; | ||
| 29 | |||
| 30 | // Signal types | ||
| 31 | |||
| 32 | /// interrupt | ||
| 33 | pub const SIGINT = 2; | ||
| 34 | |||
| 35 | /// illegal instruction - invalid function image | ||
| 36 | pub const SIGILL = 4; | ||
| 37 | |||
| 38 | /// floating point exception | ||
| 39 | pub const SIGFPE = 8; | ||
| 40 | |||
| 41 | /// segment violation | ||
| 42 | pub const SIGSEGV = 11; | ||
| 43 | |||
| 44 | /// Software termination signal from kill | ||
| 45 | pub const SIGTERM = 15; | ||
| 46 | |||
| 47 | /// Ctrl-Break sequence | ||
| 48 | pub const SIGBREAK = 21; | ||
| 49 | |||
| 50 | /// abnormal termination triggered by abort call | ||
| 51 | pub const SIGABRT = 22; | ||
| 52 | |||
| 53 | /// SIGABRT compatible with other platforms, same as SIGABRT | ||
| 54 | pub const SIGABRT_COMPAT = 6; | ||
| 55 | |||
| 56 | // Signal action codes | ||
| 57 | |||
| 58 | /// default signal action | ||
| 59 | pub const SIG_DFL = 0; | ||
| 60 | |||
| 61 | /// ignore signal | ||
| 62 | pub const SIG_IGN = 1; | ||
| 63 | |||
| 64 | /// return current value | ||
| 65 | pub const SIG_GET = 2; | ||
| 66 | |||
| 67 | /// signal gets error | ||
| 68 | pub const SIG_SGE = 3; | ||
| 69 | |||
| 70 | /// acknowledge | ||
| 71 | pub const SIG_ACK = 4; | ||
| 72 | |||
| 73 | /// Signal error value (returned by signal call on error) | ||
| 74 | pub const SIG_ERR = -1; | ||
| 75 | |||
| 76 | pub const SEEK_SET = 0; | ||
| 77 | pub const SEEK_CUR = 1; | ||
| 78 | pub const SEEK_END = 2; | ||
| 79 | |||
| 80 | pub const E = enum(u16) { | ||
| 81 | /// No error occurred. | ||
| 82 | SUCCESS = 0, | ||
| 83 | PERM = 1, | ||
| 84 | NOENT = 2, | ||
| 85 | SRCH = 3, | ||
| 86 | INTR = 4, | ||
| 87 | IO = 5, | ||
| 88 | NXIO = 6, | ||
| 89 | @"2BIG" = 7, | ||
| 90 | NOEXEC = 8, | ||
| 91 | BADF = 9, | ||
| 92 | CHILD = 10, | ||
| 93 | AGAIN = 11, | ||
| 94 | NOMEM = 12, | ||
| 95 | ACCES = 13, | ||
| 96 | FAULT = 14, | ||
| 97 | BUSY = 16, | ||
| 98 | EXIST = 17, | ||
| 99 | XDEV = 18, | ||
| 100 | NODEV = 19, | ||
| 101 | NOTDIR = 20, | ||
| 102 | ISDIR = 21, | ||
| 103 | NFILE = 23, | ||
| 104 | MFILE = 24, | ||
| 105 | NOTTY = 25, | ||
| 106 | FBIG = 27, | ||
| 107 | NOSPC = 28, | ||
| 108 | SPIPE = 29, | ||
| 109 | ROFS = 30, | ||
| 110 | MLINK = 31, | ||
| 111 | PIPE = 32, | ||
| 112 | DOM = 33, | ||
| 113 | /// Also means `DEADLOCK`. | ||
| 114 | DEADLK = 36, | ||
| 115 | NAMETOOLONG = 38, | ||
| 116 | NOLCK = 39, | ||
| 117 | NOSYS = 40, | ||
| 118 | NOTEMPTY = 41, | ||
| 119 | |||
| 120 | INVAL = 22, | ||
| 121 | RANGE = 34, | ||
| 122 | ILSEQ = 42, | ||
| 123 | |||
| 124 | // POSIX Supplement | ||
| 125 | ADDRINUSE = 100, | ||
| 126 | ADDRNOTAVAIL = 101, | ||
| 127 | AFNOSUPPORT = 102, | ||
| 128 | ALREADY = 103, | ||
| 129 | BADMSG = 104, | ||
| 130 | CANCELED = 105, | ||
| 131 | CONNABORTED = 106, | ||
| 132 | CONNREFUSED = 107, | ||
| 133 | CONNRESET = 108, | ||
| 134 | DESTADDRREQ = 109, | ||
| 135 | HOSTUNREACH = 110, | ||
| 136 | IDRM = 111, | ||
| 137 | INPROGRESS = 112, | ||
| 138 | ISCONN = 113, | ||
| 139 | LOOP = 114, | ||
| 140 | MSGSIZE = 115, | ||
| 141 | NETDOWN = 116, | ||
| 142 | NETRESET = 117, | ||
| 143 | NETUNREACH = 118, | ||
| 144 | NOBUFS = 119, | ||
| 145 | NODATA = 120, | ||
| 146 | NOLINK = 121, | ||
| 147 | NOMSG = 122, | ||
| 148 | NOPROTOOPT = 123, | ||
| 149 | NOSR = 124, | ||
| 150 | NOSTR = 125, | ||
| 151 | NOTCONN = 126, | ||
| 152 | NOTRECOVERABLE = 127, | ||
| 153 | NOTSOCK = 128, | ||
| 154 | NOTSUP = 129, | ||
| 155 | OPNOTSUPP = 130, | ||
| 156 | OTHER = 131, | ||
| 157 | OVERFLOW = 132, | ||
| 158 | OWNERDEAD = 133, | ||
| 159 | PROTO = 134, | ||
| 160 | PROTONOSUPPORT = 135, | ||
| 161 | PROTOTYPE = 136, | ||
| 162 | TIME = 137, | ||
| 163 | TIMEDOUT = 138, | ||
| 164 | TXTBSY = 139, | ||
| 165 | WOULDBLOCK = 140, | ||
| 166 | DQUOT = 10069, | ||
| 167 | _, | ||
| 168 | }; | ||
| 169 | |||
| 170 | pub const STRUNCATE = 80; | ||
| 171 | |||
| 172 | pub const F_OK = 0; | ||
| 173 | |||
| 174 | /// Remove directory instead of unlinking file | ||
| 175 | pub const AT_REMOVEDIR = 0x200; | ||
| 176 | |||
| 177 | pub const in_port_t = u16; | ||
| 178 | pub const sa_family_t = ws2_32.ADDRESS_FAMILY; | ||
| 179 | pub const socklen_t = ws2_32.socklen_t; | ||
| 180 | |||
| 181 | pub const sockaddr = ws2_32.sockaddr; | ||
| 182 | pub const sockaddr_in = ws2_32.sockaddr_in; | ||
| 183 | pub const sockaddr_in6 = ws2_32.sockaddr_in6; | ||
| 184 | pub const sockaddr_un = ws2_32.sockaddr_un; | ||
| 185 | |||
| 186 | pub const in6_addr = [16]u8; | ||
| 187 | pub const in_addr = u32; | ||
| 188 | |||
| 189 | pub const addrinfo = ws2_32.addrinfo; | ||
| 190 | |||
| 191 | pub const AF_UNSPEC = ws2_32.AF_UNSPEC; | ||
| 192 | pub const AF_UNIX = ws2_32.AF_UNIX; | ||
| 193 | pub const AF_INET = ws2_32.AF_INET; | ||
| 194 | pub const AF_IMPLINK = ws2_32.AF_IMPLINK; | ||
| 195 | pub const AF_PUP = ws2_32.AF_PUP; | ||
| 196 | pub const AF_CHAOS = ws2_32.AF_CHAOS; | ||
| 197 | pub const AF_NS = ws2_32.AF_NS; | ||
| 198 | pub const AF_IPX = ws2_32.AF_IPX; | ||
| 199 | pub const AF_ISO = ws2_32.AF_ISO; | ||
| 200 | pub const AF_OSI = ws2_32.AF_OSI; | ||
| 201 | pub const AF_ECMA = ws2_32.AF_ECMA; | ||
| 202 | pub const AF_DATAKIT = ws2_32.AF_DATAKIT; | ||
| 203 | pub const AF_CCITT = ws2_32.AF_CCITT; | ||
| 204 | pub const AF_SNA = ws2_32.AF_SNA; | ||
| 205 | pub const AF_DECnet = ws2_32.AF_DECnet; | ||
| 206 | pub const AF_DLI = ws2_32.AF_DLI; | ||
| 207 | pub const AF_LAT = ws2_32.AF_LAT; | ||
| 208 | pub const AF_HYLINK = ws2_32.AF_HYLINK; | ||
| 209 | pub const AF_APPLETALK = ws2_32.AF_APPLETALK; | ||
| 210 | pub const AF_NETBIOS = ws2_32.AF_NETBIOS; | ||
| 211 | pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW; | ||
| 212 | pub const AF_FIREFOX = ws2_32.AF_FIREFOX; | ||
| 213 | pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1; | ||
| 214 | pub const AF_BAN = ws2_32.AF_BAN; | ||
| 215 | pub const AF_ATM = ws2_32.AF_ATM; | ||
| 216 | pub const AF_INET6 = ws2_32.AF_INET6; | ||
| 217 | pub const AF_CLUSTER = ws2_32.AF_CLUSTER; | ||
| 218 | pub const AF_12844 = ws2_32.AF_12844; | ||
| 219 | pub const AF_IRDA = ws2_32.AF_IRDA; | ||
| 220 | pub const AF_NETDES = ws2_32.AF_NETDES; | ||
| 221 | pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS; | ||
| 222 | pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE; | ||
| 223 | pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM; | ||
| 224 | pub const AF_BTH = ws2_32.AF_BTH; | ||
| 225 | pub const AF_MAX = ws2_32.AF_MAX; | ||
| 226 | |||
| 227 | pub const SOCK_STREAM = ws2_32.SOCK_STREAM; | ||
| 228 | pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM; | ||
| 229 | pub const SOCK_RAW = ws2_32.SOCK_RAW; | ||
| 230 | pub const SOCK_RDM = ws2_32.SOCK_RDM; | ||
| 231 | pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET; | ||
| 232 | |||
| 233 | /// WARNING: this flag is not supported by windows socket functions directly, | ||
| 234 | /// it is only supported by std.os.socket. Be sure that this value does | ||
| 235 | /// not share any bits with any of the SOCK_* values. | ||
| 236 | pub const SOCK_CLOEXEC = 0x10000; | ||
| 237 | /// WARNING: this flag is not supported by windows socket functions directly, | ||
| 238 | /// it is only supported by std.os.socket. Be sure that this value does | ||
| 239 | /// not share any bits with any of the SOCK_* values. | ||
| 240 | pub const SOCK_NONBLOCK = 0x20000; | ||
| 241 | |||
| 242 | pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP; | ||
| 243 | pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP; | ||
| 244 | pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM; | ||
| 245 | pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP; | ||
| 246 | pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP; | ||
| 247 | pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6; | ||
| 248 | pub const IPPROTO_RM = ws2_32.IPPROTO_RM; | ||
| 249 | |||
| 250 | pub const nfds_t = c_ulong; | ||
| 251 | pub const pollfd = ws2_32.pollfd; | ||
| 252 | |||
| 253 | pub const POLLRDNORM = ws2_32.POLLRDNORM; | ||
| 254 | pub const POLLRDBAND = ws2_32.POLLRDBAND; | ||
| 255 | pub const POLLIN = ws2_32.POLLIN; | ||
| 256 | pub const POLLPRI = ws2_32.POLLPRI; | ||
| 257 | pub const POLLWRNORM = ws2_32.POLLWRNORM; | ||
| 258 | pub const POLLOUT = ws2_32.POLLOUT; | ||
| 259 | pub const POLLWRBAND = ws2_32.POLLWRBAND; | ||
| 260 | pub const POLLERR = ws2_32.POLLERR; | ||
| 261 | pub const POLLHUP = ws2_32.POLLHUP; | ||
| 262 | pub const POLLNVAL = ws2_32.POLLNVAL; | ||
| 263 | |||
| 264 | pub const SOL_SOCKET = ws2_32.SOL_SOCKET; | ||
| 265 | |||
| 266 | pub const SO_DEBUG = ws2_32.SO_DEBUG; | ||
| 267 | pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN; | ||
| 268 | pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR; | ||
| 269 | pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE; | ||
| 270 | pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE; | ||
| 271 | pub const SO_BROADCAST = ws2_32.SO_BROADCAST; | ||
| 272 | pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK; | ||
| 273 | pub const SO_LINGER = ws2_32.SO_LINGER; | ||
| 274 | pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE; | ||
| 275 | |||
| 276 | pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER; | ||
| 277 | pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE; | ||
| 278 | |||
| 279 | pub const SO_SNDBUF = ws2_32.SO_SNDBUF; | ||
| 280 | pub const SO_RCVBUF = ws2_32.SO_RCVBUF; | ||
| 281 | pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT; | ||
| 282 | pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT; | ||
| 283 | pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO; | ||
| 284 | pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO; | ||
| 285 | pub const SO_ERROR = ws2_32.SO_ERROR; | ||
| 286 | pub const SO_TYPE = ws2_32.SO_TYPE; | ||
| 287 | |||
| 288 | pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID; | ||
| 289 | pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY; | ||
| 290 | pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE; | ||
| 291 | pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA; | ||
| 292 | pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW; | ||
| 293 | |||
| 294 | pub const PVD_CONFIG = ws2_32.PVD_CONFIG; | ||
| 295 | pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT; | ||
| 296 | |||
| 297 | pub const TCP_NODELAY = ws2_32.TCP_NODELAY; | ||
| 298 | |||
| 299 | pub const O_RDONLY = 0o0; | ||
| 300 | pub const O_WRONLY = 0o1; | ||
| 301 | pub const O_RDWR = 0o2; | ||
| 302 | |||
| 303 | pub const O_CREAT = 0o100; | ||
| 304 | pub const O_EXCL = 0o200; | ||
| 305 | pub const O_NOCTTY = 0o400; | ||
| 306 | pub const O_TRUNC = 0o1000; | ||
| 307 | pub const O_APPEND = 0o2000; | ||
| 308 | pub const O_NONBLOCK = 0o4000; | ||
| 309 | pub const O_DSYNC = 0o10000; | ||
| 310 | pub const O_SYNC = 0o4010000; | ||
| 311 | pub const O_RSYNC = 0o4010000; | ||
| 312 | pub const O_DIRECTORY = 0o200000; | ||
| 313 | pub const O_NOFOLLOW = 0o400000; | ||
| 314 | pub const O_CLOEXEC = 0o2000000; | ||
| 315 | |||
| 316 | pub const O_ASYNC = 0o20000; | ||
| 317 | pub const O_DIRECT = 0o40000; | ||
| 318 | pub const O_LARGEFILE = 0; | ||
| 319 | pub const O_NOATIME = 0o1000000; | ||
| 320 | pub const O_PATH = 0o10000000; | ||
| 321 | pub const O_TMPFILE = 0o20200000; | ||
| 322 | pub const O_NDELAY = O_NONBLOCK; | ||
| 323 | |||
| 324 | pub const IFNAMESIZE = 30; | ||
lib/std/os/linux.zig+36-14| ... | @@ -1,10 +1,10 @@ | ... | @@ -1,10 +1,10 @@ |
| 1 | // This file provides the system interface functions for Linux matching those | 1 | //! This file provides the system interface functions for Linux matching those |
| 2 | // that are provided by libc, whether or not libc is linked. The following | 2 | //! that are provided by libc, whether or not libc is linked. The following |
| 3 | // abstractions are made: | 3 | //! abstractions are made: |
| 4 | // * Work around kernel bugs and limitations. For example, see sendmmsg. | 4 | //! * Work around kernel bugs and limitations. For example, see sendmmsg. |
| 5 | // * Implement all the syscalls in the same way that libc functions will | 5 | //! * Implement all the syscalls in the same way that libc functions will |
| 6 | // provide `rename` when only the `renameat` syscall exists. | 6 | //! provide `rename` when only the `renameat` syscall exists. |
| 7 | // * Does not support POSIX thread cancellation. | 7 | //! * Does not support POSIX thread cancellation. |
| 8 | const std = @import("../std.zig"); | 8 | const std = @import("../std.zig"); |
| 9 | const assert = std.debug.assert; | 9 | const assert = std.debug.assert; |
| 10 | const maxInt = std.math.maxInt; | 10 | const maxInt = std.math.maxInt; |
| ... | @@ -63,8 +63,7 @@ pub const blkcnt_t = arch_bits.blkcnt_t; | ... | @@ -63,8 +63,7 @@ pub const blkcnt_t = arch_bits.blkcnt_t; |
| 63 | pub const blksize_t = arch_bits.blksize_t; | 63 | pub const blksize_t = arch_bits.blksize_t; |
| 64 | pub const dev_t = arch_bits.dev_t; | 64 | pub const dev_t = arch_bits.dev_t; |
| 65 | pub const ino_t = arch_bits.ino_t; | 65 | pub const ino_t = arch_bits.ino_t; |
| 66 | pub const kernel_stat = arch_bits.kernel_stat; | 66 | pub const Stat = arch_bits.Stat; |
| 67 | pub const libc_stat = arch_bits.libc_stat; | ||
| 68 | pub const mcontext_t = arch_bits.mcontext_t; | 67 | pub const mcontext_t = arch_bits.mcontext_t; |
| 69 | pub const mode_t = arch_bits.mode_t; | 68 | pub const mode_t = arch_bits.mode_t; |
| 70 | pub const msghdr = arch_bits.msghdr; | 69 | pub const msghdr = arch_bits.msghdr; |
| ... | @@ -81,7 +80,30 @@ pub const user_desc = arch_bits.user_desc; | ... | @@ -81,7 +80,30 @@ pub const user_desc = arch_bits.user_desc; |
| 81 | pub const tls = @import("linux/tls.zig"); | 80 | pub const tls = @import("linux/tls.zig"); |
| 82 | pub const pie = @import("linux/start_pie.zig"); | 81 | pub const pie = @import("linux/start_pie.zig"); |
| 83 | pub const BPF = @import("linux/bpf.zig"); | 82 | pub const BPF = @import("linux/bpf.zig"); |
| 84 | pub usingnamespace @import("linux/io_uring.zig"); | 83 | |
| 84 | const io_uring = @import("linux/io_uring.zig"); | ||
| 85 | pub const IO_Uring = io_uring.IO_Uring; | ||
| 86 | pub const SubmissionQueue = io_uring.SubmissionQueue; | ||
| 87 | pub const CompletionQueue = io_uring.CompletionQueue; | ||
| 88 | pub const io_uring_prep_nop = io_uring.io_uring_prep_nop; | ||
| 89 | pub const io_uring_prep_fsync = io_uring.io_uring_prep_fsync; | ||
| 90 | pub const io_uring_prep_rw = io_uring.io_uring_prep_rw; | ||
| 91 | pub const io_uring_prep_read = io_uring.io_uring_prep_read; | ||
| 92 | pub const io_uring_prep_write = io_uring.io_uring_prep_write; | ||
| 93 | pub const io_uring_prep_readv = io_uring.io_uring_prep_readv; | ||
| 94 | pub const io_uring_prep_writev = io_uring.io_uring_prep_writev; | ||
| 95 | pub const io_uring_prep_accept = io_uring.io_uring_prep_accept; | ||
| 96 | pub const io_uring_prep_connect = io_uring.io_uring_prep_connect; | ||
| 97 | pub const io_uring_prep_epoll_ctl = io_uring.io_uring_prep_epoll_ctl; | ||
| 98 | pub const io_uring_prep_recv = io_uring.io_uring_prep_recv; | ||
| 99 | pub const io_uring_prep_send = io_uring.io_uring_prep_send; | ||
| 100 | pub const io_uring_prep_openat = io_uring.io_uring_prep_openat; | ||
| 101 | pub const io_uring_prep_close = io_uring.io_uring_prep_close; | ||
| 102 | pub const io_uring_prep_timeout = io_uring.io_uring_prep_timeout; | ||
| 103 | pub const io_uring_prep_timeout_remove = io_uring.io_uring_prep_timeout_remove; | ||
| 104 | pub const io_uring_prep_poll_add = io_uring.io_uring_prep_poll_add; | ||
| 105 | pub const io_uring_prep_poll_remove = io_uring.io_uring_prep_poll_remove; | ||
| 106 | pub const io_uring_prep_fallocate = io_uring.io_uring_prep_fallocate; | ||
| 85 | 107 | ||
| 86 | /// Set by startup code, used by `getauxval`. | 108 | /// Set by startup code, used by `getauxval`. |
| 87 | pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; | 109 | pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; |
| ... | @@ -1205,7 +1227,7 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag | ... | @@ -1205,7 +1227,7 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag |
| 1205 | return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); | 1227 | return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); |
| 1206 | } | 1228 | } |
| 1207 | 1229 | ||
| 1208 | pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize { | 1230 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { |
| 1209 | if (@hasField(SYS, "fstat64")) { | 1231 | if (@hasField(SYS, "fstat64")) { |
| 1210 | return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf)); | 1232 | return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf)); |
| 1211 | } else { | 1233 | } else { |
| ... | @@ -1213,7 +1235,7 @@ pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize { | ... | @@ -1213,7 +1235,7 @@ pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize { |
| 1213 | } | 1235 | } |
| 1214 | } | 1236 | } |
| 1215 | 1237 | ||
| 1216 | pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { | 1238 | pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1217 | if (@hasField(SYS, "stat64")) { | 1239 | if (@hasField(SYS, "stat64")) { |
| 1218 | return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf)); | 1240 | return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf)); |
| 1219 | } else { | 1241 | } else { |
| ... | @@ -1221,7 +1243,7 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { | ... | @@ -1221,7 +1243,7 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { |
| 1221 | } | 1243 | } |
| 1222 | } | 1244 | } |
| 1223 | 1245 | ||
| 1224 | pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { | 1246 | pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1225 | if (@hasField(SYS, "lstat64")) { | 1247 | if (@hasField(SYS, "lstat64")) { |
| 1226 | return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf)); | 1248 | return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf)); |
| 1227 | } else { | 1249 | } else { |
| ... | @@ -1229,7 +1251,7 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { | ... | @@ -1229,7 +1251,7 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { |
| 1229 | } | 1251 | } |
| 1230 | } | 1252 | } |
| 1231 | 1253 | ||
| 1232 | pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *kernel_stat, flags: u32) usize { | 1254 | pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize { |
| 1233 | if (@hasField(SYS, "fstatat64")) { | 1255 | if (@hasField(SYS, "fstatat64")) { |
| 1234 | return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); | 1256 | return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); |
| 1235 | } else { | 1257 | } else { |
lib/std/os/linux/test.zig+1-1| ... | @@ -82,7 +82,7 @@ test "statx" { | ... | @@ -82,7 +82,7 @@ test "statx" { |
| 82 | else => unreachable, | 82 | else => unreachable, |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | var stat_buf: linux.kernel_stat = undefined; | 85 | var stat_buf: linux.Stat = undefined; |
| 86 | switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) { | 86 | switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) { |
| 87 | .SUCCESS => {}, | 87 | .SUCCESS => {}, |
| 88 | else => unreachable, | 88 | else => unreachable, |
lib/std/os/linux/x86_64.zig+4-4| ... | @@ -112,6 +112,9 @@ pub fn restore_rt() callconv(.Naked) void { | ... | @@ -112,6 +112,9 @@ pub fn restore_rt() callconv(.Naked) void { |
| 112 | 112 | ||
| 113 | pub const mode_t = usize; | 113 | pub const mode_t = usize; |
| 114 | pub const time_t = isize; | 114 | pub const time_t = isize; |
| 115 | pub const nlink_t = usize; | ||
| 116 | pub const blksize_t = isize; | ||
| 117 | pub const blkcnt_t = isize; | ||
| 115 | 118 | ||
| 116 | pub const SYS = enum(usize) { | 119 | pub const SYS = enum(usize) { |
| 117 | read = 0, | 120 | read = 0, |
| ... | @@ -664,7 +667,7 @@ pub const ino_t = u64; | ... | @@ -664,7 +667,7 @@ pub const ino_t = u64; |
| 664 | pub const dev_t = u64; | 667 | pub const dev_t = u64; |
| 665 | 668 | ||
| 666 | // The `stat` definition used by the Linux kernel. | 669 | // The `stat` definition used by the Linux kernel. |
| 667 | pub const kernel_stat = extern struct { | 670 | pub const Stat = extern struct { |
| 668 | dev: dev_t, | 671 | dev: dev_t, |
| 669 | ino: ino_t, | 672 | ino: ino_t, |
| 670 | nlink: usize, | 673 | nlink: usize, |
| ... | @@ -696,9 +699,6 @@ pub const kernel_stat = extern struct { | ... | @@ -696,9 +699,6 @@ pub const kernel_stat = extern struct { |
| 696 | } | 699 | } |
| 697 | }; | 700 | }; |
| 698 | 701 | ||
| 699 | // The `stat64` definition used by the libc. | ||
| 700 | pub const libc_stat = kernel_stat; | ||
| 701 | |||
| 702 | pub const timespec = extern struct { | 702 | pub const timespec = extern struct { |
| 703 | tv_sec: isize, | 703 | tv_sec: isize, |
| 704 | tv_nsec: isize, | 704 | tv_nsec: isize, |
lib/std/os/wasi.zig+468-2| ... | @@ -15,8 +15,8 @@ comptime { | ... | @@ -15,8 +15,8 @@ comptime { |
| 15 | // assert(@alignOf(u64) == 8); | 15 | // assert(@alignOf(u64) == 8); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | pub const iovec_t = iovec; | 18 | pub const iovec_t = std.os.iovec; |
| 19 | pub const ciovec_t = iovec_const; | 19 | pub const ciovec_t = std.os.iovec_const; |
| 20 | 20 | ||
| 21 | pub extern "wasi_snapshot_preview1" fn args_get(argv: [*][*:0]u8, argv_buf: [*]u8) errno_t; | 21 | pub extern "wasi_snapshot_preview1" fn args_get(argv: [*][*:0]u8, argv_buf: [*]u8) errno_t; |
| 22 | pub extern "wasi_snapshot_preview1" fn args_sizes_get(argc: *usize, argv_buf_size: *usize) errno_t; | 22 | pub extern "wasi_snapshot_preview1" fn args_sizes_get(argc: *usize, argv_buf_size: *usize) errno_t; |
| ... | @@ -79,3 +79,469 @@ pub extern "wasi_snapshot_preview1" fn sock_shutdown(sock: fd_t, how: sdflags_t) | ... | @@ -79,3 +79,469 @@ pub extern "wasi_snapshot_preview1" fn sock_shutdown(sock: fd_t, how: sdflags_t) |
| 79 | pub fn getErrno(r: errno_t) errno_t { | 79 | pub fn getErrno(r: errno_t) errno_t { |
| 80 | return r; | 80 | return r; |
| 81 | } | 81 | } |
| 82 | |||
| 83 | pub const STDIN_FILENO = 0; | ||
| 84 | pub const STDOUT_FILENO = 1; | ||
| 85 | pub const STDERR_FILENO = 2; | ||
| 86 | |||
| 87 | pub const mode_t = u32; | ||
| 88 | |||
| 89 | pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc | ||
| 90 | |||
| 91 | pub const timespec = struct { | ||
| 92 | tv_sec: time_t, | ||
| 93 | tv_nsec: isize, | ||
| 94 | |||
| 95 | pub fn fromTimestamp(tm: timestamp_t) timespec { | ||
| 96 | const tv_sec: timestamp_t = tm / 1_000_000_000; | ||
| 97 | const tv_nsec = tm - tv_sec * 1_000_000_000; | ||
| 98 | return timespec{ | ||
| 99 | .tv_sec = @intCast(time_t, tv_sec), | ||
| 100 | .tv_nsec = @intCast(isize, tv_nsec), | ||
| 101 | }; | ||
| 102 | } | ||
| 103 | |||
| 104 | pub fn toTimestamp(ts: timespec) timestamp_t { | ||
| 105 | const tm = @intCast(timestamp_t, ts.tv_sec * 1_000_000_000) + @intCast(timestamp_t, ts.tv_nsec); | ||
| 106 | return tm; | ||
| 107 | } | ||
| 108 | }; | ||
| 109 | |||
| 110 | pub const Stat = struct { | ||
| 111 | dev: device_t, | ||
| 112 | ino: inode_t, | ||
| 113 | mode: mode_t, | ||
| 114 | filetype: filetype_t, | ||
| 115 | nlink: linkcount_t, | ||
| 116 | size: filesize_t, | ||
| 117 | atim: timespec, | ||
| 118 | mtim: timespec, | ||
| 119 | ctim: timespec, | ||
| 120 | |||
| 121 | const Self = @This(); | ||
| 122 | |||
| 123 | pub fn fromFilestat(stat: filestat_t) Self { | ||
| 124 | return Self{ | ||
| 125 | .dev = stat.dev, | ||
| 126 | .ino = stat.ino, | ||
| 127 | .mode = 0, | ||
| 128 | .filetype = stat.filetype, | ||
| 129 | .nlink = stat.nlink, | ||
| 130 | .size = stat.size, | ||
| 131 | .atim = stat.atime(), | ||
| 132 | .mtim = stat.mtime(), | ||
| 133 | .ctim = stat.ctime(), | ||
| 134 | }; | ||
| 135 | } | ||
| 136 | |||
| 137 | pub fn atime(self: Self) timespec { | ||
| 138 | return self.atim; | ||
| 139 | } | ||
| 140 | |||
| 141 | pub fn mtime(self: Self) timespec { | ||
| 142 | return self.mtim; | ||
| 143 | } | ||
| 144 | |||
| 145 | pub fn ctime(self: Self) timespec { | ||
| 146 | return self.ctim; | ||
| 147 | } | ||
| 148 | }; | ||
| 149 | |||
| 150 | pub const IOV_MAX = 1024; | ||
| 151 | |||
| 152 | pub const AT_REMOVEDIR: u32 = 0x4; | ||
| 153 | pub const AT_FDCWD: fd_t = -2; | ||
| 154 | |||
| 155 | // As defined in the wasi_snapshot_preview1 spec file: | ||
| 156 | // https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx | ||
| 157 | pub const advice_t = u8; | ||
| 158 | pub const ADVICE_NORMAL: advice_t = 0; | ||
| 159 | pub const ADVICE_SEQUENTIAL: advice_t = 1; | ||
| 160 | pub const ADVICE_RANDOM: advice_t = 2; | ||
| 161 | pub const ADVICE_WILLNEED: advice_t = 3; | ||
| 162 | pub const ADVICE_DONTNEED: advice_t = 4; | ||
| 163 | pub const ADVICE_NOREUSE: advice_t = 5; | ||
| 164 | |||
| 165 | pub const clockid_t = u32; | ||
| 166 | pub const CLOCK = struct { | ||
| 167 | pub const REALTIME: clockid_t = 0; | ||
| 168 | pub const MONOTONIC: clockid_t = 1; | ||
| 169 | pub const PROCESS_CPUTIME_ID: clockid_t = 2; | ||
| 170 | pub const THREAD_CPUTIME_ID: clockid_t = 3; | ||
| 171 | }; | ||
| 172 | |||
| 173 | pub const device_t = u64; | ||
| 174 | |||
| 175 | pub const dircookie_t = u64; | ||
| 176 | pub const DIRCOOKIE_START: dircookie_t = 0; | ||
| 177 | |||
| 178 | pub const dirnamlen_t = u32; | ||
| 179 | |||
| 180 | pub const dirent_t = extern struct { | ||
| 181 | d_next: dircookie_t, | ||
| 182 | d_ino: inode_t, | ||
| 183 | d_namlen: dirnamlen_t, | ||
| 184 | d_type: filetype_t, | ||
| 185 | }; | ||
| 186 | |||
| 187 | pub const errno_t = enum(u16) { | ||
| 188 | SUCCESS = 0, | ||
| 189 | @"2BIG" = 1, | ||
| 190 | ACCES = 2, | ||
| 191 | ADDRINUSE = 3, | ||
| 192 | ADDRNOTAVAIL = 4, | ||
| 193 | AFNOSUPPORT = 5, | ||
| 194 | /// This is also the error code used for `WOULDBLOCK`. | ||
| 195 | AGAIN = 6, | ||
| 196 | ALREADY = 7, | ||
| 197 | BADF = 8, | ||
| 198 | BADMSG = 9, | ||
| 199 | BUSY = 10, | ||
| 200 | CANCELED = 11, | ||
| 201 | CHILD = 12, | ||
| 202 | CONNABORTED = 13, | ||
| 203 | CONNREFUSED = 14, | ||
| 204 | CONNRESET = 15, | ||
| 205 | DEADLK = 16, | ||
| 206 | DESTADDRREQ = 17, | ||
| 207 | DOM = 18, | ||
| 208 | DQUOT = 19, | ||
| 209 | EXIST = 20, | ||
| 210 | FAULT = 21, | ||
| 211 | FBIG = 22, | ||
| 212 | HOSTUNREACH = 23, | ||
| 213 | IDRM = 24, | ||
| 214 | ILSEQ = 25, | ||
| 215 | INPROGRESS = 26, | ||
| 216 | INTR = 27, | ||
| 217 | INVAL = 28, | ||
| 218 | IO = 29, | ||
| 219 | ISCONN = 30, | ||
| 220 | ISDIR = 31, | ||
| 221 | LOOP = 32, | ||
| 222 | MFILE = 33, | ||
| 223 | MLINK = 34, | ||
| 224 | MSGSIZE = 35, | ||
| 225 | MULTIHOP = 36, | ||
| 226 | NAMETOOLONG = 37, | ||
| 227 | NETDOWN = 38, | ||
| 228 | NETRESET = 39, | ||
| 229 | NETUNREACH = 40, | ||
| 230 | NFILE = 41, | ||
| 231 | NOBUFS = 42, | ||
| 232 | NODEV = 43, | ||
| 233 | NOENT = 44, | ||
| 234 | NOEXEC = 45, | ||
| 235 | NOLCK = 46, | ||
| 236 | NOLINK = 47, | ||
| 237 | NOMEM = 48, | ||
| 238 | NOMSG = 49, | ||
| 239 | NOPROTOOPT = 50, | ||
| 240 | NOSPC = 51, | ||
| 241 | NOSYS = 52, | ||
| 242 | NOTCONN = 53, | ||
| 243 | NOTDIR = 54, | ||
| 244 | NOTEMPTY = 55, | ||
| 245 | NOTRECOVERABLE = 56, | ||
| 246 | NOTSOCK = 57, | ||
| 247 | /// This is also the code used for `NOTSUP`. | ||
| 248 | OPNOTSUPP = 58, | ||
| 249 | NOTTY = 59, | ||
| 250 | NXIO = 60, | ||
| 251 | OVERFLOW = 61, | ||
| 252 | OWNERDEAD = 62, | ||
| 253 | PERM = 63, | ||
| 254 | PIPE = 64, | ||
| 255 | PROTO = 65, | ||
| 256 | PROTONOSUPPORT = 66, | ||
| 257 | PROTOTYPE = 67, | ||
| 258 | RANGE = 68, | ||
| 259 | ROFS = 69, | ||
| 260 | SPIPE = 70, | ||
| 261 | SRCH = 71, | ||
| 262 | STALE = 72, | ||
| 263 | TIMEDOUT = 73, | ||
| 264 | TXTBSY = 74, | ||
| 265 | XDEV = 75, | ||
| 266 | NOTCAPABLE = 76, | ||
| 267 | _, | ||
| 268 | }; | ||
| 269 | pub const E = errno_t; | ||
| 270 | |||
| 271 | pub const event_t = extern struct { | ||
| 272 | userdata: userdata_t, | ||
| 273 | @"error": errno_t, | ||
| 274 | @"type": eventtype_t, | ||
| 275 | fd_readwrite: eventfdreadwrite_t, | ||
| 276 | }; | ||
| 277 | |||
| 278 | pub const eventfdreadwrite_t = extern struct { | ||
| 279 | nbytes: filesize_t, | ||
| 280 | flags: eventrwflags_t, | ||
| 281 | }; | ||
| 282 | |||
| 283 | pub const eventrwflags_t = u16; | ||
| 284 | pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001; | ||
| 285 | |||
| 286 | pub const eventtype_t = u8; | ||
| 287 | pub const EVENTTYPE_CLOCK: eventtype_t = 0; | ||
| 288 | pub const EVENTTYPE_FD_READ: eventtype_t = 1; | ||
| 289 | pub const EVENTTYPE_FD_WRITE: eventtype_t = 2; | ||
| 290 | |||
| 291 | pub const exitcode_t = u32; | ||
| 292 | |||
| 293 | pub const fd_t = u32; | ||
| 294 | |||
| 295 | pub const fdflags_t = u16; | ||
| 296 | pub const FDFLAG_APPEND: fdflags_t = 0x0001; | ||
| 297 | pub const FDFLAG_DSYNC: fdflags_t = 0x0002; | ||
| 298 | pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004; | ||
| 299 | pub const FDFLAG_RSYNC: fdflags_t = 0x0008; | ||
| 300 | pub const FDFLAG_SYNC: fdflags_t = 0x0010; | ||
| 301 | |||
| 302 | pub const fdstat_t = extern struct { | ||
| 303 | fs_filetype: filetype_t, | ||
| 304 | fs_flags: fdflags_t, | ||
| 305 | fs_rights_base: rights_t, | ||
| 306 | fs_rights_inheriting: rights_t, | ||
| 307 | }; | ||
| 308 | |||
| 309 | pub const filedelta_t = i64; | ||
| 310 | |||
| 311 | pub const filesize_t = u64; | ||
| 312 | |||
| 313 | pub const filestat_t = extern struct { | ||
| 314 | dev: device_t, | ||
| 315 | ino: inode_t, | ||
| 316 | filetype: filetype_t, | ||
| 317 | nlink: linkcount_t, | ||
| 318 | size: filesize_t, | ||
| 319 | atim: timestamp_t, | ||
| 320 | mtim: timestamp_t, | ||
| 321 | ctim: timestamp_t, | ||
| 322 | |||
| 323 | pub fn atime(self: filestat_t) timespec { | ||
| 324 | return timespec.fromTimestamp(self.atim); | ||
| 325 | } | ||
| 326 | |||
| 327 | pub fn mtime(self: filestat_t) timespec { | ||
| 328 | return timespec.fromTimestamp(self.mtim); | ||
| 329 | } | ||
| 330 | |||
| 331 | pub fn ctime(self: filestat_t) timespec { | ||
| 332 | return timespec.fromTimestamp(self.ctim); | ||
| 333 | } | ||
| 334 | }; | ||
| 335 | |||
| 336 | pub const filetype_t = u8; | ||
| 337 | pub const FILETYPE_UNKNOWN: filetype_t = 0; | ||
| 338 | pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1; | ||
| 339 | pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2; | ||
| 340 | pub const FILETYPE_DIRECTORY: filetype_t = 3; | ||
| 341 | pub const FILETYPE_REGULAR_FILE: filetype_t = 4; | ||
| 342 | pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5; | ||
| 343 | pub const FILETYPE_SOCKET_STREAM: filetype_t = 6; | ||
| 344 | pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7; | ||
| 345 | |||
| 346 | pub const fstflags_t = u16; | ||
| 347 | pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001; | ||
| 348 | pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002; | ||
| 349 | pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004; | ||
| 350 | pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; | ||
| 351 | |||
| 352 | pub const inode_t = u64; | ||
| 353 | pub const ino_t = inode_t; | ||
| 354 | |||
| 355 | pub const linkcount_t = u64; | ||
| 356 | |||
| 357 | pub const lookupflags_t = u32; | ||
| 358 | pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001; | ||
| 359 | |||
| 360 | pub const oflags_t = u16; | ||
| 361 | pub const O = struct { | ||
| 362 | pub const CREAT: oflags_t = 0x0001; | ||
| 363 | pub const DIRECTORY: oflags_t = 0x0002; | ||
| 364 | pub const EXCL: oflags_t = 0x0004; | ||
| 365 | pub const TRUNC: oflags_t = 0x0008; | ||
| 366 | }; | ||
| 367 | |||
| 368 | pub const preopentype_t = u8; | ||
| 369 | pub const PREOPENTYPE_DIR: preopentype_t = 0; | ||
| 370 | |||
| 371 | pub const prestat_t = extern struct { | ||
| 372 | pr_type: preopentype_t, | ||
| 373 | u: prestat_u_t, | ||
| 374 | }; | ||
| 375 | |||
| 376 | pub const prestat_dir_t = extern struct { | ||
| 377 | pr_name_len: usize, | ||
| 378 | }; | ||
| 379 | |||
| 380 | pub const prestat_u_t = extern union { | ||
| 381 | dir: prestat_dir_t, | ||
| 382 | }; | ||
| 383 | |||
| 384 | pub const riflags_t = u16; | ||
| 385 | pub const SOCK_RECV_PEEK: riflags_t = 0x0001; | ||
| 386 | pub const SOCK_RECV_WAITALL: riflags_t = 0x0002; | ||
| 387 | |||
| 388 | pub const rights_t = u64; | ||
| 389 | pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001; | ||
| 390 | pub const RIGHT_FD_READ: rights_t = 0x0000000000000002; | ||
| 391 | pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004; | ||
| 392 | pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008; | ||
| 393 | pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010; | ||
| 394 | pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020; | ||
| 395 | pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040; | ||
| 396 | pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080; | ||
| 397 | pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100; | ||
| 398 | pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200; | ||
| 399 | pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400; | ||
| 400 | pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800; | ||
| 401 | pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000; | ||
| 402 | pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000; | ||
| 403 | pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000; | ||
| 404 | pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000; | ||
| 405 | pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000; | ||
| 406 | pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000; | ||
| 407 | pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000; | ||
| 408 | pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000; | ||
| 409 | pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000; | ||
| 410 | pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000; | ||
| 411 | pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000; | ||
| 412 | pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000; | ||
| 413 | pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000; | ||
| 414 | pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000; | ||
| 415 | pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000; | ||
| 416 | pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000; | ||
| 417 | pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000; | ||
| 418 | pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC | | ||
| 419 | RIGHT_FD_READ | | ||
| 420 | RIGHT_FD_SEEK | | ||
| 421 | RIGHT_FD_FDSTAT_SET_FLAGS | | ||
| 422 | RIGHT_FD_SYNC | | ||
| 423 | RIGHT_FD_TELL | | ||
| 424 | RIGHT_FD_WRITE | | ||
| 425 | RIGHT_FD_ADVISE | | ||
| 426 | RIGHT_FD_ALLOCATE | | ||
| 427 | RIGHT_PATH_CREATE_DIRECTORY | | ||
| 428 | RIGHT_PATH_CREATE_FILE | | ||
| 429 | RIGHT_PATH_LINK_SOURCE | | ||
| 430 | RIGHT_PATH_LINK_TARGET | | ||
| 431 | RIGHT_PATH_OPEN | | ||
| 432 | RIGHT_FD_READDIR | | ||
| 433 | RIGHT_PATH_READLINK | | ||
| 434 | RIGHT_PATH_RENAME_SOURCE | | ||
| 435 | RIGHT_PATH_RENAME_TARGET | | ||
| 436 | RIGHT_PATH_FILESTAT_GET | | ||
| 437 | RIGHT_PATH_FILESTAT_SET_SIZE | | ||
| 438 | RIGHT_PATH_FILESTAT_SET_TIMES | | ||
| 439 | RIGHT_FD_FILESTAT_GET | | ||
| 440 | RIGHT_FD_FILESTAT_SET_SIZE | | ||
| 441 | RIGHT_FD_FILESTAT_SET_TIMES | | ||
| 442 | RIGHT_PATH_SYMLINK | | ||
| 443 | RIGHT_PATH_REMOVE_DIRECTORY | | ||
| 444 | RIGHT_PATH_UNLINK_FILE | | ||
| 445 | RIGHT_POLL_FD_READWRITE | | ||
| 446 | RIGHT_SOCK_SHUTDOWN; | ||
| 447 | |||
| 448 | pub const roflags_t = u16; | ||
| 449 | pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001; | ||
| 450 | |||
| 451 | pub const sdflags_t = u8; | ||
| 452 | pub const SHUT_RD: sdflags_t = 0x01; | ||
| 453 | pub const SHUT_WR: sdflags_t = 0x02; | ||
| 454 | |||
| 455 | pub const siflags_t = u16; | ||
| 456 | |||
| 457 | pub const signal_t = u8; | ||
| 458 | pub const SIGNONE: signal_t = 0; | ||
| 459 | pub const SIGHUP: signal_t = 1; | ||
| 460 | pub const SIGINT: signal_t = 2; | ||
| 461 | pub const SIGQUIT: signal_t = 3; | ||
| 462 | pub const SIGILL: signal_t = 4; | ||
| 463 | pub const SIGTRAP: signal_t = 5; | ||
| 464 | pub const SIGABRT: signal_t = 6; | ||
| 465 | pub const SIGBUS: signal_t = 7; | ||
| 466 | pub const SIGFPE: signal_t = 8; | ||
| 467 | pub const SIGKILL: signal_t = 9; | ||
| 468 | pub const SIGUSR1: signal_t = 10; | ||
| 469 | pub const SIGSEGV: signal_t = 11; | ||
| 470 | pub const SIGUSR2: signal_t = 12; | ||
| 471 | pub const SIGPIPE: signal_t = 13; | ||
| 472 | pub const SIGALRM: signal_t = 14; | ||
| 473 | pub const SIGTERM: signal_t = 15; | ||
| 474 | pub const SIGCHLD: signal_t = 16; | ||
| 475 | pub const SIGCONT: signal_t = 17; | ||
| 476 | pub const SIGSTOP: signal_t = 18; | ||
| 477 | pub const SIGTSTP: signal_t = 19; | ||
| 478 | pub const SIGTTIN: signal_t = 20; | ||
| 479 | pub const SIGTTOU: signal_t = 21; | ||
| 480 | pub const SIGURG: signal_t = 22; | ||
| 481 | pub const SIGXCPU: signal_t = 23; | ||
| 482 | pub const SIGXFSZ: signal_t = 24; | ||
| 483 | pub const SIGVTALRM: signal_t = 25; | ||
| 484 | pub const SIGPROF: signal_t = 26; | ||
| 485 | pub const SIGWINCH: signal_t = 27; | ||
| 486 | pub const SIGPOLL: signal_t = 28; | ||
| 487 | pub const SIGPWR: signal_t = 29; | ||
| 488 | pub const SIGSYS: signal_t = 30; | ||
| 489 | |||
| 490 | pub const subclockflags_t = u16; | ||
| 491 | pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001; | ||
| 492 | |||
| 493 | pub const subscription_t = extern struct { | ||
| 494 | userdata: userdata_t, | ||
| 495 | u: subscription_u_t, | ||
| 496 | }; | ||
| 497 | |||
| 498 | pub const subscription_clock_t = extern struct { | ||
| 499 | id: clockid_t, | ||
| 500 | timeout: timestamp_t, | ||
| 501 | precision: timestamp_t, | ||
| 502 | flags: subclockflags_t, | ||
| 503 | }; | ||
| 504 | |||
| 505 | pub const subscription_fd_readwrite_t = extern struct { | ||
| 506 | fd: fd_t, | ||
| 507 | }; | ||
| 508 | |||
| 509 | pub const subscription_u_t = extern struct { | ||
| 510 | tag: eventtype_t, | ||
| 511 | u: subscription_u_u_t, | ||
| 512 | }; | ||
| 513 | |||
| 514 | pub const subscription_u_u_t = extern union { | ||
| 515 | clock: subscription_clock_t, | ||
| 516 | fd_read: subscription_fd_readwrite_t, | ||
| 517 | fd_write: subscription_fd_readwrite_t, | ||
| 518 | }; | ||
| 519 | |||
| 520 | pub const timestamp_t = u64; | ||
| 521 | |||
| 522 | pub const userdata_t = u64; | ||
| 523 | |||
| 524 | pub const whence_t = u8; | ||
| 525 | pub const WHENCE_SET: whence_t = 0; | ||
| 526 | pub const WHENCE_CUR: whence_t = 1; | ||
| 527 | pub const WHENCE_END: whence_t = 2; | ||
| 528 | |||
| 529 | pub const S_IEXEC = S_IXUSR; | ||
| 530 | pub const S_IFBLK = 0x6000; | ||
| 531 | pub const S_IFCHR = 0x2000; | ||
| 532 | pub const S_IFDIR = 0x4000; | ||
| 533 | pub const S_IFIFO = 0xc000; | ||
| 534 | pub const S_IFLNK = 0xa000; | ||
| 535 | pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK; | ||
| 536 | pub const S_IFREG = 0x8000; | ||
| 537 | // There's no concept of UNIX domain socket but we define this value here in order to line with other OSes. | ||
| 538 | pub const S_IFSOCK = 0x1; | ||
| 539 | |||
| 540 | pub const SEEK_SET = WHENCE_SET; | ||
| 541 | pub const SEEK_CUR = WHENCE_CUR; | ||
| 542 | pub const SEEK_END = WHENCE_END; | ||
| 543 | |||
| 544 | pub const LOCK_SH = 0x1; | ||
| 545 | pub const LOCK_EX = 0x2; | ||
| 546 | pub const LOCK_NB = 0x4; | ||
| 547 | pub const LOCK_UN = 0x8; |
lib/std/os/windows/ws2_32.zig-1| ... | @@ -1,5 +1,4 @@ | ... | @@ -1,5 +1,4 @@ |
| 1 | const std = @import("../../std.zig"); | 1 | const std = @import("../../std.zig"); |
| 2 | usingnamespace @import("bits.zig"); | ||
| 3 | 2 | ||
| 4 | pub const SOCKET = *opaque {}; | 3 | pub const SOCKET = *opaque {}; |
| 5 | pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0)); | 4 | pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0)); |