| author | |
| committer | |
| log | 0d1db794d580eeeb39603613baf5123df15d731a |
| tree | b5510d71e31159bdc20c41cb9b8ccb71197bd234 |
| parent | 89e4c38fe36bd8d460f5327b38134fe733300b07 |
| parent | 01337e209366bf7eed9a8aca0b80be0e8c9c04f5 |
| signature |
std.c reorganization49 files changed, 9775 insertions(+), 11584 deletions(-)
CMakeLists.txt-1| ... | @@ -404,7 +404,6 @@ set(ZIG_STAGE2_SOURCES | ... | @@ -404,7 +404,6 @@ set(ZIG_STAGE2_SOURCES |
| 404 | lib/std/buf_map.zig | 404 | lib/std/buf_map.zig |
| 405 | lib/std/builtin.zig | 405 | lib/std/builtin.zig |
| 406 | lib/std/c.zig | 406 | lib/std/c.zig |
| 407 | lib/std/c/linux.zig | ||
| 408 | lib/std/coff.zig | 407 | lib/std/coff.zig |
| 409 | lib/std/crypto.zig | 408 | lib/std/crypto.zig |
| 410 | lib/std/crypto/blake3.zig | 409 | lib/std/crypto/blake3.zig |
lib/std/Progress.zig+6-6| ... | @@ -1349,16 +1349,16 @@ fn maybeUpdateSize(resize_flag: bool) void { | ... | @@ -1349,16 +1349,16 @@ fn maybeUpdateSize(resize_flag: bool) void { |
| 1349 | } | 1349 | } |
| 1350 | } else { | 1350 | } else { |
| 1351 | var winsize: posix.winsize = .{ | 1351 | var winsize: posix.winsize = .{ |
| 1352 | .ws_row = 0, | 1352 | .row = 0, |
| 1353 | .ws_col = 0, | 1353 | .col = 0, |
| 1354 | .ws_xpixel = 0, | 1354 | .xpixel = 0, |
| 1355 | .ws_ypixel = 0, | 1355 | .ypixel = 0, |
| 1356 | }; | 1356 | }; |
| 1357 | 1357 | ||
| 1358 | const err = posix.system.ioctl(fd, posix.T.IOCGWINSZ, @intFromPtr(&winsize)); | 1358 | const err = posix.system.ioctl(fd, posix.T.IOCGWINSZ, @intFromPtr(&winsize)); |
| 1359 | if (posix.errno(err) == .SUCCESS) { | 1359 | if (posix.errno(err) == .SUCCESS) { |
| 1360 | global_progress.rows = winsize.ws_row; | 1360 | global_progress.rows = winsize.row; |
| 1361 | global_progress.cols = winsize.ws_col; | 1361 | global_progress.cols = winsize.col; |
| 1362 | } else { | 1362 | } else { |
| 1363 | std.log.debug("failed to determine terminal size; using conservative guess 80x25", .{}); | 1363 | std.log.debug("failed to determine terminal size; using conservative guess 80x25", .{}); |
| 1364 | global_progress.rows = 25; | 1364 | global_progress.rows = 25; |
lib/std/Thread/Futex.zig+28-24| ... | @@ -196,7 +196,10 @@ const DarwinImpl = struct { | ... | @@ -196,7 +196,10 @@ const DarwinImpl = struct { |
| 196 | var timeout_overflowed = false; | 196 | var timeout_overflowed = false; |
| 197 | 197 | ||
| 198 | const addr: *const anyopaque = ptr; | 198 | const addr: *const anyopaque = ptr; |
| 199 | const flags = c.UL_COMPARE_AND_WAIT | c.ULF_NO_ERRNO; | 199 | const flags: c.UL = .{ |
| 200 | .op = .COMPARE_AND_WAIT, | ||
| 201 | .NO_ERRNO = true, | ||
| 202 | }; | ||
| 200 | const status = blk: { | 203 | const status = blk: { |
| 201 | if (supports_ulock_wait2) { | 204 | if (supports_ulock_wait2) { |
| 202 | break :blk c.__ulock_wait2(flags, addr, expect, timeout_ns, 0); | 205 | break :blk c.__ulock_wait2(flags, addr, expect, timeout_ns, 0); |
| ... | @@ -228,10 +231,11 @@ const DarwinImpl = struct { | ... | @@ -228,10 +231,11 @@ const DarwinImpl = struct { |
| 228 | } | 231 | } |
| 229 | 232 | ||
| 230 | fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { | 233 | fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { |
| 231 | var flags: u32 = c.UL_COMPARE_AND_WAIT | c.ULF_NO_ERRNO; | 234 | const flags: c.UL = .{ |
| 232 | if (max_waiters > 1) { | 235 | .op = .COMPARE_AND_WAIT, |
| 233 | flags |= c.ULF_WAKE_ALL; | 236 | .NO_ERRNO = true, |
| 234 | } | 237 | .WAKE_ALL = max_waiters > 1, |
| 238 | }; | ||
| 235 | 239 | ||
| 236 | while (true) { | 240 | while (true) { |
| 237 | const addr: *const anyopaque = ptr; | 241 | const addr: *const anyopaque = ptr; |
| ... | @@ -242,7 +246,7 @@ const DarwinImpl = struct { | ... | @@ -242,7 +246,7 @@ const DarwinImpl = struct { |
| 242 | .INTR => continue, // spurious wake() | 246 | .INTR => continue, // spurious wake() |
| 243 | .FAULT => unreachable, // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t | 247 | .FAULT => unreachable, // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t |
| 244 | .NOENT => return, // nothing was woken up | 248 | .NOENT => return, // nothing was woken up |
| 245 | .ALREADY => unreachable, // only for ULF_WAKE_THREAD | 249 | .ALREADY => unreachable, // only for UL.Op.WAKE_THREAD |
| 246 | else => unreachable, | 250 | else => unreachable, |
| 247 | } | 251 | } |
| 248 | } | 252 | } |
| ... | @@ -254,8 +258,8 @@ const LinuxImpl = struct { | ... | @@ -254,8 +258,8 @@ const LinuxImpl = struct { |
| 254 | fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout: ?u64) error{Timeout}!void { | 258 | fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout: ?u64) error{Timeout}!void { |
| 255 | var ts: linux.timespec = undefined; | 259 | var ts: linux.timespec = undefined; |
| 256 | if (timeout) |timeout_ns| { | 260 | if (timeout) |timeout_ns| { |
| 257 | ts.tv_sec = @as(@TypeOf(ts.tv_sec), @intCast(timeout_ns / std.time.ns_per_s)); | 261 | ts.sec = @as(@TypeOf(ts.sec), @intCast(timeout_ns / std.time.ns_per_s)); |
| 258 | ts.tv_nsec = @as(@TypeOf(ts.tv_nsec), @intCast(timeout_ns % std.time.ns_per_s)); | 262 | ts.nsec = @as(@TypeOf(ts.nsec), @intCast(timeout_ns % std.time.ns_per_s)); |
| 259 | } | 263 | } |
| 260 | 264 | ||
| 261 | const rc = linux.futex_wait( | 265 | const rc = linux.futex_wait( |
| ... | @@ -306,10 +310,10 @@ const FreebsdImpl = struct { | ... | @@ -306,10 +310,10 @@ const FreebsdImpl = struct { |
| 306 | tm_ptr = &tm; | 310 | tm_ptr = &tm; |
| 307 | tm_size = @sizeOf(@TypeOf(tm)); | 311 | tm_size = @sizeOf(@TypeOf(tm)); |
| 308 | 312 | ||
| 309 | tm._flags = 0; // use relative time not UMTX_ABSTIME | 313 | tm.flags = 0; // use relative time not UMTX_ABSTIME |
| 310 | tm._clockid = c.CLOCK.MONOTONIC; | 314 | tm.clockid = .MONOTONIC; |
| 311 | tm._timeout.tv_sec = @as(@TypeOf(tm._timeout.tv_sec), @intCast(timeout_ns / std.time.ns_per_s)); | 315 | tm.timeout.sec = @as(@TypeOf(tm.timeout.sec), @intCast(timeout_ns / std.time.ns_per_s)); |
| 312 | tm._timeout.tv_nsec = @as(@TypeOf(tm._timeout.tv_nsec), @intCast(timeout_ns % std.time.ns_per_s)); | 316 | tm.timeout.nsec = @as(@TypeOf(tm.timeout.nsec), @intCast(timeout_ns % std.time.ns_per_s)); |
| 313 | } | 317 | } |
| 314 | 318 | ||
| 315 | const rc = c._umtx_op( | 319 | const rc = c._umtx_op( |
| ... | @@ -356,16 +360,16 @@ const OpenbsdImpl = struct { | ... | @@ -356,16 +360,16 @@ const OpenbsdImpl = struct { |
| 356 | fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout: ?u64) error{Timeout}!void { | 360 | fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout: ?u64) error{Timeout}!void { |
| 357 | var ts: c.timespec = undefined; | 361 | var ts: c.timespec = undefined; |
| 358 | if (timeout) |timeout_ns| { | 362 | if (timeout) |timeout_ns| { |
| 359 | ts.tv_sec = @as(@TypeOf(ts.tv_sec), @intCast(timeout_ns / std.time.ns_per_s)); | 363 | ts.sec = @as(@TypeOf(ts.sec), @intCast(timeout_ns / std.time.ns_per_s)); |
| 360 | ts.tv_nsec = @as(@TypeOf(ts.tv_nsec), @intCast(timeout_ns % std.time.ns_per_s)); | 364 | ts.nsec = @as(@TypeOf(ts.nsec), @intCast(timeout_ns % std.time.ns_per_s)); |
| 361 | } | 365 | } |
| 362 | 366 | ||
| 363 | const rc = c.futex( | 367 | const rc = c.futex( |
| 364 | @as(*const volatile u32, @ptrCast(&ptr.raw)), | 368 | @as(*const volatile u32, @ptrCast(&ptr.raw)), |
| 365 | c.FUTEX_WAIT | c.FUTEX_PRIVATE_FLAG, | 369 | c.FUTEX.WAIT | c.FUTEX.PRIVATE_FLAG, |
| 366 | @as(c_int, @bitCast(expect)), | 370 | @as(c_int, @bitCast(expect)), |
| 367 | if (timeout != null) &ts else null, | 371 | if (timeout != null) &ts else null, |
| 368 | null, // FUTEX_WAIT takes no requeue address | 372 | null, // FUTEX.WAIT takes no requeue address |
| 369 | ); | 373 | ); |
| 370 | 374 | ||
| 371 | switch (std.posix.errno(rc)) { | 375 | switch (std.posix.errno(rc)) { |
| ... | @@ -387,10 +391,10 @@ const OpenbsdImpl = struct { | ... | @@ -387,10 +391,10 @@ const OpenbsdImpl = struct { |
| 387 | fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { | 391 | fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { |
| 388 | const rc = c.futex( | 392 | const rc = c.futex( |
| 389 | @as(*const volatile u32, @ptrCast(&ptr.raw)), | 393 | @as(*const volatile u32, @ptrCast(&ptr.raw)), |
| 390 | c.FUTEX_WAKE | c.FUTEX_PRIVATE_FLAG, | 394 | c.FUTEX.WAKE | c.FUTEX.PRIVATE_FLAG, |
| 391 | std.math.cast(c_int, max_waiters) orelse std.math.maxInt(c_int), | 395 | std.math.cast(c_int, max_waiters) orelse std.math.maxInt(c_int), |
| 392 | null, // FUTEX_WAKE takes no timeout ptr | 396 | null, // FUTEX.WAKE takes no timeout ptr |
| 393 | null, // FUTEX_WAKE takes no requeue address | 397 | null, // FUTEX.WAKE takes no requeue address |
| 394 | ); | 398 | ); |
| 395 | 399 | ||
| 396 | // returns number of threads woken up. | 400 | // returns number of threads woken up. |
| ... | @@ -540,12 +544,12 @@ const PosixImpl = struct { | ... | @@ -540,12 +544,12 @@ const PosixImpl = struct { |
| 540 | var ts: c.timespec = undefined; | 544 | var ts: c.timespec = undefined; |
| 541 | if (timeout) |timeout_ns| { | 545 | if (timeout) |timeout_ns| { |
| 542 | std.posix.clock_gettime(c.CLOCK.REALTIME, &ts) catch unreachable; | 546 | std.posix.clock_gettime(c.CLOCK.REALTIME, &ts) catch unreachable; |
| 543 | ts.tv_sec +|= @as(@TypeOf(ts.tv_sec), @intCast(timeout_ns / std.time.ns_per_s)); | 547 | ts.sec +|= @as(@TypeOf(ts.sec), @intCast(timeout_ns / std.time.ns_per_s)); |
| 544 | ts.tv_nsec += @as(@TypeOf(ts.tv_nsec), @intCast(timeout_ns % std.time.ns_per_s)); | 548 | ts.nsec += @as(@TypeOf(ts.nsec), @intCast(timeout_ns % std.time.ns_per_s)); |
| 545 | 549 | ||
| 546 | if (ts.tv_nsec >= std.time.ns_per_s) { | 550 | if (ts.nsec >= std.time.ns_per_s) { |
| 547 | ts.tv_sec +|= 1; | 551 | ts.sec +|= 1; |
| 548 | ts.tv_nsec -= std.time.ns_per_s; | 552 | ts.nsec -= std.time.ns_per_s; |
| 549 | } | 553 | } |
| 550 | } | 554 | } |
| 551 | 555 |
lib/std/Thread/Mutex.zig+3-3| ... | @@ -103,8 +103,8 @@ const SingleThreadedImpl = struct { | ... | @@ -103,8 +103,8 @@ const SingleThreadedImpl = struct { |
| 103 | } | 103 | } |
| 104 | }; | 104 | }; |
| 105 | 105 | ||
| 106 | // SRWLOCK on windows is almost always faster than Futex solution. | 106 | /// SRWLOCK on windows is almost always faster than Futex solution. |
| 107 | // It also implements an efficient Condition with requeue support for us. | 107 | /// It also implements an efficient Condition with requeue support for us. |
| 108 | const WindowsImpl = struct { | 108 | const WindowsImpl = struct { |
| 109 | srwlock: windows.SRWLOCK = .{}, | 109 | srwlock: windows.SRWLOCK = .{}, |
| 110 | 110 | ||
| ... | @@ -123,7 +123,7 @@ const WindowsImpl = struct { | ... | @@ -123,7 +123,7 @@ const WindowsImpl = struct { |
| 123 | const windows = std.os.windows; | 123 | const windows = std.os.windows; |
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | // os_unfair_lock on darwin supports priority inheritance and is generally faster than Futex solutions. | 126 | /// os_unfair_lock on darwin supports priority inheritance and is generally faster than Futex solutions. |
| 127 | const DarwinImpl = struct { | 127 | const DarwinImpl = struct { |
| 128 | oul: c.os_unfair_lock = .{}, | 128 | oul: c.os_unfair_lock = .{}, |
| 129 | 129 |
lib/std/c.zig+8000-220| ... | @@ -1,14 +1,48 @@ | ... | @@ -1,14 +1,48 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const c = @This(); | 3 | const c = @This(); |
| 4 | const maxInt = std.math.maxInt; | ||
| 5 | const assert = std.debug.assert; | ||
| 4 | const page_size = std.mem.page_size; | 6 | const page_size = std.mem.page_size; |
| 5 | const iovec = std.posix.iovec; | ||
| 6 | const iovec_const = std.posix.iovec_const; | ||
| 7 | const wasi = @import("c/wasi.zig"); | ||
| 8 | const native_abi = builtin.abi; | 7 | const native_abi = builtin.abi; |
| 9 | const native_arch = builtin.cpu.arch; | 8 | const native_arch = builtin.cpu.arch; |
| 10 | const native_os = builtin.os.tag; | 9 | const native_os = builtin.os.tag; |
| 11 | const linux = std.os.linux; | 10 | const linux = std.os.linux; |
| 11 | const emscripten = std.os.emscripten; | ||
| 12 | const wasi = std.os.wasi; | ||
| 13 | const windows = std.os.windows; | ||
| 14 | const ws2_32 = std.os.windows.ws2_32; | ||
| 15 | const darwin = @import("c/darwin.zig"); | ||
| 16 | const freebsd = @import("c/freebsd.zig"); | ||
| 17 | const solaris = @import("c/solaris.zig"); | ||
| 18 | const netbsd = @import("c/netbsd.zig"); | ||
| 19 | const dragonfly = @import("c/dragonfly.zig"); | ||
| 20 | const haiku = @import("c/haiku.zig"); | ||
| 21 | const openbsd = @import("c/openbsd.zig"); | ||
| 22 | |||
| 23 | // These constants are shared among all operating systems even when not linking | ||
| 24 | // libc. | ||
| 25 | |||
| 26 | pub const iovec = std.posix.iovec; | ||
| 27 | pub const iovec_const = std.posix.iovec_const; | ||
| 28 | pub const LOCK = std.posix.LOCK; | ||
| 29 | pub const winsize = std.posix.winsize; | ||
| 30 | |||
| 31 | /// The value of the link editor defined symbol _MH_EXECUTE_SYM is the address | ||
| 32 | /// of the mach header in a Mach-O executable file type. It does not appear in | ||
| 33 | /// any file type other than a MH_EXECUTE file type. The type of the symbol is | ||
| 34 | /// absolute as the header is not part of any section. | ||
| 35 | /// This symbol is populated when linking the system's libc, which is guaranteed | ||
| 36 | /// on this operating system. However when building object files or libraries, | ||
| 37 | /// the system libc won't be linked until the final executable. So we | ||
| 38 | /// export a weak symbol here, to be overridden by the real one. | ||
| 39 | pub extern var _mh_execute_header: mach_hdr; | ||
| 40 | var dummy_execute_header: mach_hdr = undefined; | ||
| 41 | comptime { | ||
| 42 | if (native_os.isDarwin()) { | ||
| 43 | @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); | ||
| 44 | } | ||
| 45 | } | ||
| 12 | 46 | ||
| 13 | /// If not linking libc, returns false. | 47 | /// If not linking libc, returns false. |
| 14 | /// If linking musl libc, returns true. | 48 | /// If linking musl libc, returns true. |
| ... | @@ -26,25 +60,6562 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool { | ... | @@ -26,25 +60,6562 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool { |
| 26 | .gt, .eq => true, | 60 | .gt, .eq => true, |
| 27 | .lt => false, | 61 | .lt => false, |
| 28 | }; | 62 | }; |
| 29 | } else { | 63 | } else { |
| 30 | break :blk false; | 64 | break :blk false; |
| 65 | } | ||
| 66 | }; | ||
| 67 | } | ||
| 68 | |||
| 69 | pub const ino_t = switch (native_os) { | ||
| 70 | .linux => linux.ino_t, | ||
| 71 | .emscripten => emscripten.ino_t, | ||
| 72 | .wasi => wasi.inode_t, | ||
| 73 | .windows => windows.LARGE_INTEGER, | ||
| 74 | .haiku => i64, | ||
| 75 | else => u64, | ||
| 76 | }; | ||
| 77 | |||
| 78 | pub const off_t = switch (native_os) { | ||
| 79 | .linux => linux.off_t, | ||
| 80 | .emscripten => emscripten.off_t, | ||
| 81 | else => i64, | ||
| 82 | }; | ||
| 83 | |||
| 84 | pub const timespec = switch (native_os) { | ||
| 85 | .linux => linux.timespec, | ||
| 86 | .emscripten => emscripten.timespec, | ||
| 87 | .wasi => extern struct { | ||
| 88 | sec: time_t, | ||
| 89 | nsec: isize, | ||
| 90 | |||
| 91 | pub fn fromTimestamp(tm: wasi.timestamp_t) timespec { | ||
| 92 | const sec: wasi.timestamp_t = tm / 1_000_000_000; | ||
| 93 | const nsec = tm - sec * 1_000_000_000; | ||
| 94 | return .{ | ||
| 95 | .sec = @as(time_t, @intCast(sec)), | ||
| 96 | .nsec = @as(isize, @intCast(nsec)), | ||
| 97 | }; | ||
| 98 | } | ||
| 99 | |||
| 100 | pub fn toTimestamp(ts: timespec) wasi.timestamp_t { | ||
| 101 | return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) + | ||
| 102 | @as(wasi.timestamp_t, @intCast(ts.nsec)); | ||
| 103 | } | ||
| 104 | }, | ||
| 105 | .windows => extern struct { | ||
| 106 | sec: time_t, | ||
| 107 | nsec: c_long, | ||
| 108 | }, | ||
| 109 | .dragonfly, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 110 | sec: isize, | ||
| 111 | nsec: isize, | ||
| 112 | }, | ||
| 113 | .netbsd, .solaris, .illumos => extern struct { | ||
| 114 | sec: i64, | ||
| 115 | nsec: isize, | ||
| 116 | }, | ||
| 117 | .openbsd, .haiku => extern struct { | ||
| 118 | sec: time_t, | ||
| 119 | nsec: isize, | ||
| 120 | }, | ||
| 121 | else => void, | ||
| 122 | }; | ||
| 123 | |||
| 124 | pub const dev_t = switch (native_os) { | ||
| 125 | .linux => linux.dev_t, | ||
| 126 | .emscripten => emscripten.dev_t, | ||
| 127 | .wasi => wasi.device_t, | ||
| 128 | .openbsd, .haiku, .solaris, .illumos, .macos, .ios, .tvos, .watchos, .visionos => i32, | ||
| 129 | .netbsd, .freebsd, .kfreebsd => u64, | ||
| 130 | else => void, | ||
| 131 | }; | ||
| 132 | |||
| 133 | pub const mode_t = switch (native_os) { | ||
| 134 | .linux => linux.mode_t, | ||
| 135 | .emscripten => emscripten.mode_t, | ||
| 136 | .openbsd, .haiku, .netbsd, .solaris, .illumos, .wasi => u32, | ||
| 137 | .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => u16, | ||
| 138 | else => u0, | ||
| 139 | }; | ||
| 140 | |||
| 141 | pub const nlink_t = switch (native_os) { | ||
| 142 | .linux => linux.nlink_t, | ||
| 143 | .emscripten => emscripten.nlink_t, | ||
| 144 | .wasi => c_ulonglong, | ||
| 145 | .freebsd, .kfreebsd => u64, | ||
| 146 | .openbsd, .netbsd, .solaris, .illumos => u32, | ||
| 147 | .haiku => i32, | ||
| 148 | else => void, | ||
| 149 | }; | ||
| 150 | |||
| 151 | pub const uid_t = switch (native_os) { | ||
| 152 | .linux => linux.uid_t, | ||
| 153 | .emscripten => emscripten.uid_t, | ||
| 154 | else => u32, | ||
| 155 | }; | ||
| 156 | |||
| 157 | pub const gid_t = switch (native_os) { | ||
| 158 | .linux => linux.gid_t, | ||
| 159 | .emscripten => emscripten.gid_t, | ||
| 160 | else => u32, | ||
| 161 | }; | ||
| 162 | |||
| 163 | pub const blksize_t = switch (native_os) { | ||
| 164 | .linux => linux.blksize_t, | ||
| 165 | .emscripten => emscripten.blksize_t, | ||
| 166 | .wasi => c_long, | ||
| 167 | else => i32, | ||
| 168 | }; | ||
| 169 | |||
| 170 | pub const passwd = switch (native_os) { | ||
| 171 | .linux => extern struct { | ||
| 172 | name: ?[*:0]const u8, // username | ||
| 173 | passwd: ?[*:0]const u8, // user password | ||
| 174 | uid: uid_t, // user ID | ||
| 175 | gid: gid_t, // group ID | ||
| 176 | gecos: ?[*:0]const u8, // user information | ||
| 177 | dir: ?[*:0]const u8, // home directory | ||
| 178 | shell: ?[*:0]const u8, // shell program | ||
| 179 | }, | ||
| 180 | .openbsd => extern struct { | ||
| 181 | name: ?[*:0]const u8, // user name | ||
| 182 | passwd: ?[*:0]const u8, // encrypted password | ||
| 183 | uid: uid_t, // user uid | ||
| 184 | gid: gid_t, // user gid | ||
| 185 | change: time_t, // password change time | ||
| 186 | class: ?[*:0]const u8, // user access class | ||
| 187 | gecos: ?[*:0]const u8, // Honeywell login info | ||
| 188 | dir: ?[*:0]const u8, // home directory | ||
| 189 | shell: ?[*:0]const u8, // default shell | ||
| 190 | expire: time_t, // account expiration | ||
| 191 | }, | ||
| 192 | else => void, | ||
| 193 | }; | ||
| 194 | |||
| 195 | pub const blkcnt_t = switch (native_os) { | ||
| 196 | .linux => linux.blkcnt_t, | ||
| 197 | .emscripten => emscripten.blkcnt_t, | ||
| 198 | .wasi => c_longlong, | ||
| 199 | else => i64, | ||
| 200 | }; | ||
| 201 | |||
| 202 | pub const fd_t = switch (native_os) { | ||
| 203 | .linux => linux.fd_t, | ||
| 204 | .wasi => wasi.fd_t, | ||
| 205 | .windows => windows.HANDLE, | ||
| 206 | else => i32, | ||
| 207 | }; | ||
| 208 | |||
| 209 | pub const ARCH = switch (native_os) { | ||
| 210 | .linux => linux.ARCH, | ||
| 211 | else => void, | ||
| 212 | }; | ||
| 213 | pub const CLOCK = clockid_t; | ||
| 214 | pub const clockid_t = switch (native_os) { | ||
| 215 | .linux, .emscripten => linux.clockid_t, | ||
| 216 | .wasi => wasi.clockid_t, | ||
| 217 | .macos, .ios, .tvos, .watchos, .visionos => enum(u32) { | ||
| 218 | REALTIME = 0, | ||
| 219 | MONOTONIC = 6, | ||
| 220 | MONOTONIC_RAW = 4, | ||
| 221 | MONOTONIC_RAW_APPROX = 5, | ||
| 222 | UPTIME_RAW = 8, | ||
| 223 | UPTIME_RAW_APPROX = 9, | ||
| 224 | PROCESS_CPUTIME_ID = 12, | ||
| 225 | THREAD_CPUTIME_ID = 16, | ||
| 226 | _, | ||
| 227 | }, | ||
| 228 | .haiku => enum(i32) { | ||
| 229 | /// system-wide monotonic clock (aka system time) | ||
| 230 | MONOTONIC = 0, | ||
| 231 | /// system-wide real time clock | ||
| 232 | REALTIME = -1, | ||
| 233 | /// clock measuring the used CPU time of the current process | ||
| 234 | PROCESS_CPUTIME_ID = -2, | ||
| 235 | /// clock measuring the used CPU time of the current thread | ||
| 236 | THREAD_CPUTIME_ID = -3, | ||
| 237 | }, | ||
| 238 | .freebsd, .kfreebsd => enum(u32) { | ||
| 239 | REALTIME = 0, | ||
| 240 | VIRTUAL = 1, | ||
| 241 | PROF = 2, | ||
| 242 | MONOTONIC = 4, | ||
| 243 | UPTIME = 5, | ||
| 244 | UPTIME_PRECISE = 7, | ||
| 245 | UPTIME_FAST = 8, | ||
| 246 | REALTIME_PRECISE = 9, | ||
| 247 | REALTIME_FAST = 10, | ||
| 248 | MONOTONIC_PRECISE = 11, | ||
| 249 | MONOTONIC_FAST = 12, | ||
| 250 | SECOND = 13, | ||
| 251 | THREAD_CPUTIME_ID = 14, | ||
| 252 | PROCESS_CPUTIME_ID = 15, | ||
| 253 | }, | ||
| 254 | .solaris, .illumos => enum(u32) { | ||
| 255 | VIRTUAL = 1, | ||
| 256 | THREAD_CPUTIME_ID = 2, | ||
| 257 | REALTIME = 3, | ||
| 258 | MONOTONIC = 4, | ||
| 259 | PROCESS_CPUTIME_ID = 5, | ||
| 260 | }, | ||
| 261 | .netbsd => enum(u32) { | ||
| 262 | REALTIME = 0, | ||
| 263 | VIRTUAL = 1, | ||
| 264 | PROF = 2, | ||
| 265 | MONOTONIC = 3, | ||
| 266 | THREAD_CPUTIME_ID = 0x20000000, | ||
| 267 | PROCESS_CPUTIME_ID = 0x40000000, | ||
| 268 | }, | ||
| 269 | .dragonfly => enum(u32) { | ||
| 270 | REALTIME = 0, | ||
| 271 | VIRTUAL = 1, | ||
| 272 | PROF = 2, | ||
| 273 | MONOTONIC = 4, | ||
| 274 | UPTIME = 5, | ||
| 275 | UPTIME_PRECISE = 7, | ||
| 276 | UPTIME_FAST = 8, | ||
| 277 | REALTIME_PRECISE = 9, | ||
| 278 | REALTIME_FAST = 10, | ||
| 279 | MONOTONIC_PRECISE = 11, | ||
| 280 | MONOTONIC_FAST = 12, | ||
| 281 | SECOND = 13, | ||
| 282 | THREAD_CPUTIME_ID = 14, | ||
| 283 | PROCESS_CPUTIME_ID = 15, | ||
| 284 | }, | ||
| 285 | .openbsd => enum(u32) { | ||
| 286 | REALTIME = 0, | ||
| 287 | PROCESS_CPUTIME_ID = 2, | ||
| 288 | MONOTONIC = 3, | ||
| 289 | THREAD_CPUTIME_ID = 4, | ||
| 290 | }, | ||
| 291 | else => void, | ||
| 292 | }; | ||
| 293 | pub const CPU_COUNT = switch (native_os) { | ||
| 294 | .linux => linux.CPU_COUNT, | ||
| 295 | .emscripten => emscripten.CPU_COUNT, | ||
| 296 | else => void, | ||
| 297 | }; | ||
| 298 | pub const E = switch (native_os) { | ||
| 299 | .linux => linux.E, | ||
| 300 | .emscripten => emscripten.E, | ||
| 301 | .wasi => wasi.errno_t, | ||
| 302 | .windows => enum(u16) { | ||
| 303 | /// No error occurred. | ||
| 304 | SUCCESS = 0, | ||
| 305 | PERM = 1, | ||
| 306 | NOENT = 2, | ||
| 307 | SRCH = 3, | ||
| 308 | INTR = 4, | ||
| 309 | IO = 5, | ||
| 310 | NXIO = 6, | ||
| 311 | @"2BIG" = 7, | ||
| 312 | NOEXEC = 8, | ||
| 313 | BADF = 9, | ||
| 314 | CHILD = 10, | ||
| 315 | AGAIN = 11, | ||
| 316 | NOMEM = 12, | ||
| 317 | ACCES = 13, | ||
| 318 | FAULT = 14, | ||
| 319 | BUSY = 16, | ||
| 320 | EXIST = 17, | ||
| 321 | XDEV = 18, | ||
| 322 | NODEV = 19, | ||
| 323 | NOTDIR = 20, | ||
| 324 | ISDIR = 21, | ||
| 325 | NFILE = 23, | ||
| 326 | MFILE = 24, | ||
| 327 | NOTTY = 25, | ||
| 328 | FBIG = 27, | ||
| 329 | NOSPC = 28, | ||
| 330 | SPIPE = 29, | ||
| 331 | ROFS = 30, | ||
| 332 | MLINK = 31, | ||
| 333 | PIPE = 32, | ||
| 334 | DOM = 33, | ||
| 335 | /// Also means `DEADLOCK`. | ||
| 336 | DEADLK = 36, | ||
| 337 | NAMETOOLONG = 38, | ||
| 338 | NOLCK = 39, | ||
| 339 | NOSYS = 40, | ||
| 340 | NOTEMPTY = 41, | ||
| 341 | |||
| 342 | INVAL = 22, | ||
| 343 | RANGE = 34, | ||
| 344 | ILSEQ = 42, | ||
| 345 | |||
| 346 | // POSIX Supplement | ||
| 347 | ADDRINUSE = 100, | ||
| 348 | ADDRNOTAVAIL = 101, | ||
| 349 | AFNOSUPPORT = 102, | ||
| 350 | ALREADY = 103, | ||
| 351 | BADMSG = 104, | ||
| 352 | CANCELED = 105, | ||
| 353 | CONNABORTED = 106, | ||
| 354 | CONNREFUSED = 107, | ||
| 355 | CONNRESET = 108, | ||
| 356 | DESTADDRREQ = 109, | ||
| 357 | HOSTUNREACH = 110, | ||
| 358 | IDRM = 111, | ||
| 359 | INPROGRESS = 112, | ||
| 360 | ISCONN = 113, | ||
| 361 | LOOP = 114, | ||
| 362 | MSGSIZE = 115, | ||
| 363 | NETDOWN = 116, | ||
| 364 | NETRESET = 117, | ||
| 365 | NETUNREACH = 118, | ||
| 366 | NOBUFS = 119, | ||
| 367 | NODATA = 120, | ||
| 368 | NOLINK = 121, | ||
| 369 | NOMSG = 122, | ||
| 370 | NOPROTOOPT = 123, | ||
| 371 | NOSR = 124, | ||
| 372 | NOSTR = 125, | ||
| 373 | NOTCONN = 126, | ||
| 374 | NOTRECOVERABLE = 127, | ||
| 375 | NOTSOCK = 128, | ||
| 376 | NOTSUP = 129, | ||
| 377 | OPNOTSUPP = 130, | ||
| 378 | OTHER = 131, | ||
| 379 | OVERFLOW = 132, | ||
| 380 | OWNERDEAD = 133, | ||
| 381 | PROTO = 134, | ||
| 382 | PROTONOSUPPORT = 135, | ||
| 383 | PROTOTYPE = 136, | ||
| 384 | TIME = 137, | ||
| 385 | TIMEDOUT = 138, | ||
| 386 | TXTBSY = 139, | ||
| 387 | WOULDBLOCK = 140, | ||
| 388 | DQUOT = 10069, | ||
| 389 | _, | ||
| 390 | }, | ||
| 391 | .macos, .ios, .tvos, .watchos, .visionos => darwin.E, | ||
| 392 | .freebsd, .kfreebsd => freebsd.E, | ||
| 393 | .solaris, .illumos => enum(u16) { | ||
| 394 | /// No error occurred. | ||
| 395 | SUCCESS = 0, | ||
| 396 | /// Not super-user | ||
| 397 | PERM = 1, | ||
| 398 | /// No such file or directory | ||
| 399 | NOENT = 2, | ||
| 400 | /// No such process | ||
| 401 | SRCH = 3, | ||
| 402 | /// interrupted system call | ||
| 403 | INTR = 4, | ||
| 404 | /// I/O error | ||
| 405 | IO = 5, | ||
| 406 | /// No such device or address | ||
| 407 | NXIO = 6, | ||
| 408 | /// Arg list too long | ||
| 409 | @"2BIG" = 7, | ||
| 410 | /// Exec format error | ||
| 411 | NOEXEC = 8, | ||
| 412 | /// Bad file number | ||
| 413 | BADF = 9, | ||
| 414 | /// No children | ||
| 415 | CHILD = 10, | ||
| 416 | /// Resource temporarily unavailable. | ||
| 417 | /// also: WOULDBLOCK: Operation would block. | ||
| 418 | AGAIN = 11, | ||
| 419 | /// Not enough core | ||
| 420 | NOMEM = 12, | ||
| 421 | /// Permission denied | ||
| 422 | ACCES = 13, | ||
| 423 | /// Bad address | ||
| 424 | FAULT = 14, | ||
| 425 | /// Block device required | ||
| 426 | NOTBLK = 15, | ||
| 427 | /// Mount device busy | ||
| 428 | BUSY = 16, | ||
| 429 | /// File exists | ||
| 430 | EXIST = 17, | ||
| 431 | /// Cross-device link | ||
| 432 | XDEV = 18, | ||
| 433 | /// No such device | ||
| 434 | NODEV = 19, | ||
| 435 | /// Not a directory | ||
| 436 | NOTDIR = 20, | ||
| 437 | /// Is a directory | ||
| 438 | ISDIR = 21, | ||
| 439 | /// Invalid argument | ||
| 440 | INVAL = 22, | ||
| 441 | /// File table overflow | ||
| 442 | NFILE = 23, | ||
| 443 | /// Too many open files | ||
| 444 | MFILE = 24, | ||
| 445 | /// Inappropriate ioctl for device | ||
| 446 | NOTTY = 25, | ||
| 447 | /// Text file busy | ||
| 448 | TXTBSY = 26, | ||
| 449 | /// File too large | ||
| 450 | FBIG = 27, | ||
| 451 | /// No space left on device | ||
| 452 | NOSPC = 28, | ||
| 453 | /// Illegal seek | ||
| 454 | SPIPE = 29, | ||
| 455 | /// Read only file system | ||
| 456 | ROFS = 30, | ||
| 457 | /// Too many links | ||
| 458 | MLINK = 31, | ||
| 459 | /// Broken pipe | ||
| 460 | PIPE = 32, | ||
| 461 | /// Math arg out of domain of func | ||
| 462 | DOM = 33, | ||
| 463 | /// Math result not representable | ||
| 464 | RANGE = 34, | ||
| 465 | /// No message of desired type | ||
| 466 | NOMSG = 35, | ||
| 467 | /// Identifier removed | ||
| 468 | IDRM = 36, | ||
| 469 | /// Channel number out of range | ||
| 470 | CHRNG = 37, | ||
| 471 | /// Level 2 not synchronized | ||
| 472 | L2NSYNC = 38, | ||
| 473 | /// Level 3 halted | ||
| 474 | L3HLT = 39, | ||
| 475 | /// Level 3 reset | ||
| 476 | L3RST = 40, | ||
| 477 | /// Link number out of range | ||
| 478 | LNRNG = 41, | ||
| 479 | /// Protocol driver not attached | ||
| 480 | UNATCH = 42, | ||
| 481 | /// No CSI structure available | ||
| 482 | NOCSI = 43, | ||
| 483 | /// Level 2 halted | ||
| 484 | L2HLT = 44, | ||
| 485 | /// Deadlock condition. | ||
| 486 | DEADLK = 45, | ||
| 487 | /// No record locks available. | ||
| 488 | NOLCK = 46, | ||
| 489 | /// Operation canceled | ||
| 490 | CANCELED = 47, | ||
| 491 | /// Operation not supported | ||
| 492 | NOTSUP = 48, | ||
| 493 | |||
| 494 | // Filesystem Quotas | ||
| 495 | /// Disc quota exceeded | ||
| 496 | DQUOT = 49, | ||
| 497 | |||
| 498 | // Convergent Error Returns | ||
| 499 | /// invalid exchange | ||
| 500 | BADE = 50, | ||
| 501 | /// invalid request descriptor | ||
| 502 | BADR = 51, | ||
| 503 | /// exchange full | ||
| 504 | XFULL = 52, | ||
| 505 | /// no anode | ||
| 506 | NOANO = 53, | ||
| 507 | /// invalid request code | ||
| 508 | BADRQC = 54, | ||
| 509 | /// invalid slot | ||
| 510 | BADSLT = 55, | ||
| 511 | /// file locking deadlock error | ||
| 512 | DEADLOCK = 56, | ||
| 513 | /// bad font file fmt | ||
| 514 | BFONT = 57, | ||
| 515 | |||
| 516 | // Interprocess Robust Locks | ||
| 517 | /// process died with the lock | ||
| 518 | OWNERDEAD = 58, | ||
| 519 | /// lock is not recoverable | ||
| 520 | NOTRECOVERABLE = 59, | ||
| 521 | /// locked lock was unmapped | ||
| 522 | LOCKUNMAPPED = 72, | ||
| 523 | /// Facility is not active | ||
| 524 | NOTACTIVE = 73, | ||
| 525 | /// multihop attempted | ||
| 526 | MULTIHOP = 74, | ||
| 527 | /// trying to read unreadable message | ||
| 528 | BADMSG = 77, | ||
| 529 | /// path name is too long | ||
| 530 | NAMETOOLONG = 78, | ||
| 531 | /// value too large to be stored in data type | ||
| 532 | OVERFLOW = 79, | ||
| 533 | /// given log. name not unique | ||
| 534 | NOTUNIQ = 80, | ||
| 535 | /// f.d. invalid for this operation | ||
| 536 | BADFD = 81, | ||
| 537 | /// Remote address changed | ||
| 538 | REMCHG = 82, | ||
| 539 | |||
| 540 | // Stream Problems | ||
| 541 | /// Device not a stream | ||
| 542 | NOSTR = 60, | ||
| 543 | /// no data (for no delay io) | ||
| 544 | NODATA = 61, | ||
| 545 | /// timer expired | ||
| 546 | TIME = 62, | ||
| 547 | /// out of streams resources | ||
| 548 | NOSR = 63, | ||
| 549 | /// Machine is not on the network | ||
| 550 | NONET = 64, | ||
| 551 | /// Package not installed | ||
| 552 | NOPKG = 65, | ||
| 553 | /// The object is remote | ||
| 554 | REMOTE = 66, | ||
| 555 | /// the link has been severed | ||
| 556 | NOLINK = 67, | ||
| 557 | /// advertise error | ||
| 558 | ADV = 68, | ||
| 559 | /// srmount error | ||
| 560 | SRMNT = 69, | ||
| 561 | /// Communication error on send | ||
| 562 | COMM = 70, | ||
| 563 | /// Protocol error | ||
| 564 | PROTO = 71, | ||
| 565 | |||
| 566 | // Shared Library Problems | ||
| 567 | /// Can't access a needed shared lib. | ||
| 568 | LIBACC = 83, | ||
| 569 | /// Accessing a corrupted shared lib. | ||
| 570 | LIBBAD = 84, | ||
| 571 | /// .lib section in a.out corrupted. | ||
| 572 | LIBSCN = 85, | ||
| 573 | /// Attempting to link in too many libs. | ||
| 574 | LIBMAX = 86, | ||
| 575 | /// Attempting to exec a shared library. | ||
| 576 | LIBEXEC = 87, | ||
| 577 | /// Illegal byte sequence. | ||
| 578 | ILSEQ = 88, | ||
| 579 | /// Unsupported file system operation | ||
| 580 | NOSYS = 89, | ||
| 581 | /// Symbolic link loop | ||
| 582 | LOOP = 90, | ||
| 583 | /// Restartable system call | ||
| 584 | RESTART = 91, | ||
| 585 | /// if pipe/FIFO, don't sleep in stream head | ||
| 586 | STRPIPE = 92, | ||
| 587 | /// directory not empty | ||
| 588 | NOTEMPTY = 93, | ||
| 589 | /// Too many users (for UFS) | ||
| 590 | USERS = 94, | ||
| 591 | |||
| 592 | // BSD Networking Software | ||
| 593 | // Argument Errors | ||
| 594 | /// Socket operation on non-socket | ||
| 595 | NOTSOCK = 95, | ||
| 596 | /// Destination address required | ||
| 597 | DESTADDRREQ = 96, | ||
| 598 | /// Message too long | ||
| 599 | MSGSIZE = 97, | ||
| 600 | /// Protocol wrong type for socket | ||
| 601 | PROTOTYPE = 98, | ||
| 602 | /// Protocol not available | ||
| 603 | NOPROTOOPT = 99, | ||
| 604 | /// Protocol not supported | ||
| 605 | PROTONOSUPPORT = 120, | ||
| 606 | /// Socket type not supported | ||
| 607 | SOCKTNOSUPPORT = 121, | ||
| 608 | /// Operation not supported on socket | ||
| 609 | OPNOTSUPP = 122, | ||
| 610 | /// Protocol family not supported | ||
| 611 | PFNOSUPPORT = 123, | ||
| 612 | /// Address family not supported by | ||
| 613 | AFNOSUPPORT = 124, | ||
| 614 | /// Address already in use | ||
| 615 | ADDRINUSE = 125, | ||
| 616 | /// Can't assign requested address | ||
| 617 | ADDRNOTAVAIL = 126, | ||
| 618 | |||
| 619 | // Operational Errors | ||
| 620 | /// Network is down | ||
| 621 | NETDOWN = 127, | ||
| 622 | /// Network is unreachable | ||
| 623 | NETUNREACH = 128, | ||
| 624 | /// Network dropped connection because | ||
| 625 | NETRESET = 129, | ||
| 626 | /// Software caused connection abort | ||
| 627 | CONNABORTED = 130, | ||
| 628 | /// Connection reset by peer | ||
| 629 | CONNRESET = 131, | ||
| 630 | /// No buffer space available | ||
| 631 | NOBUFS = 132, | ||
| 632 | /// Socket is already connected | ||
| 633 | ISCONN = 133, | ||
| 634 | /// Socket is not connected | ||
| 635 | NOTCONN = 134, | ||
| 636 | /// Can't send after socket shutdown | ||
| 637 | SHUTDOWN = 143, | ||
| 638 | /// Too many references: can't splice | ||
| 639 | TOOMANYREFS = 144, | ||
| 640 | /// Connection timed out | ||
| 641 | TIMEDOUT = 145, | ||
| 642 | /// Connection refused | ||
| 643 | CONNREFUSED = 146, | ||
| 644 | /// Host is down | ||
| 645 | HOSTDOWN = 147, | ||
| 646 | /// No route to host | ||
| 647 | HOSTUNREACH = 148, | ||
| 648 | /// operation already in progress | ||
| 649 | ALREADY = 149, | ||
| 650 | /// operation now in progress | ||
| 651 | INPROGRESS = 150, | ||
| 652 | |||
| 653 | // SUN Network File System | ||
| 654 | /// Stale NFS file handle | ||
| 655 | STALE = 151, | ||
| 656 | |||
| 657 | _, | ||
| 658 | }, | ||
| 659 | .netbsd => netbsd.E, | ||
| 660 | .dragonfly => dragonfly.E, | ||
| 661 | .haiku => haiku.E, | ||
| 662 | .openbsd => openbsd.E, | ||
| 663 | else => void, | ||
| 664 | }; | ||
| 665 | pub const Elf_Symndx = switch (native_os) { | ||
| 666 | .linux => linux.Elf_Symndx, | ||
| 667 | else => void, | ||
| 668 | }; | ||
| 669 | /// Command flags for fcntl(2). | ||
| 670 | pub const F = switch (native_os) { | ||
| 671 | .linux => linux.F, | ||
| 672 | .emscripten => emscripten.F, | ||
| 673 | .wasi => struct { | ||
| 674 | pub const GETFD = 1; | ||
| 675 | pub const SETFD = 2; | ||
| 676 | pub const GETFL = 3; | ||
| 677 | pub const SETFL = 4; | ||
| 678 | }, | ||
| 679 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 680 | /// duplicate file descriptor | ||
| 681 | pub const DUPFD = 0; | ||
| 682 | /// get file descriptor flags | ||
| 683 | pub const GETFD = 1; | ||
| 684 | /// set file descriptor flags | ||
| 685 | pub const SETFD = 2; | ||
| 686 | /// get file status flags | ||
| 687 | pub const GETFL = 3; | ||
| 688 | /// set file status flags | ||
| 689 | pub const SETFL = 4; | ||
| 690 | /// get SIGIO/SIGURG proc/pgrp | ||
| 691 | pub const GETOWN = 5; | ||
| 692 | /// set SIGIO/SIGURG proc/pgrp | ||
| 693 | pub const SETOWN = 6; | ||
| 694 | /// get record locking information | ||
| 695 | pub const GETLK = 7; | ||
| 696 | /// set record locking information | ||
| 697 | pub const SETLK = 8; | ||
| 698 | /// F.SETLK; wait if blocked | ||
| 699 | pub const SETLKW = 9; | ||
| 700 | /// F.SETLK; wait if blocked, return on timeout | ||
| 701 | pub const SETLKWTIMEOUT = 10; | ||
| 702 | pub const FLUSH_DATA = 40; | ||
| 703 | /// Used for regression test | ||
| 704 | pub const CHKCLEAN = 41; | ||
| 705 | /// Preallocate storage | ||
| 706 | pub const PREALLOCATE = 42; | ||
| 707 | /// Truncate a file without zeroing space | ||
| 708 | pub const SETSIZE = 43; | ||
| 709 | /// Issue an advisory read async with no copy to user | ||
| 710 | pub const RDADVISE = 44; | ||
| 711 | /// turn read ahead off/on for this fd | ||
| 712 | pub const RDAHEAD = 45; | ||
| 713 | /// turn data caching off/on for this fd | ||
| 714 | pub const NOCACHE = 48; | ||
| 715 | /// file offset to device offset | ||
| 716 | pub const LOG2PHYS = 49; | ||
| 717 | /// return the full path of the fd | ||
| 718 | pub const GETPATH = 50; | ||
| 719 | /// fsync + ask the drive to flush to the media | ||
| 720 | pub const FULLFSYNC = 51; | ||
| 721 | /// find which component (if any) is a package | ||
| 722 | pub const PATHPKG_CHECK = 52; | ||
| 723 | /// "freeze" all fs operations | ||
| 724 | pub const FREEZE_FS = 53; | ||
| 725 | /// "thaw" all fs operations | ||
| 726 | pub const THAW_FS = 54; | ||
| 727 | /// turn data caching off/on (globally) for this file | ||
| 728 | pub const GLOBAL_NOCACHE = 55; | ||
| 729 | /// add detached signatures | ||
| 730 | pub const ADDSIGS = 59; | ||
| 731 | /// add signature from same file (used by dyld for shared libs) | ||
| 732 | pub const ADDFILESIGS = 61; | ||
| 733 | /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchronous writes | ||
| 734 | /// should not be used (i.e. its ok to temporarily create cached pages) | ||
| 735 | pub const NODIRECT = 62; | ||
| 736 | ///Get the protection class of a file from the EA, returns int | ||
| 737 | pub const GETPROTECTIONCLASS = 63; | ||
| 738 | ///Set the protection class of a file for the EA, requires int | ||
| 739 | pub const SETPROTECTIONCLASS = 64; | ||
| 740 | ///file offset to device offset, extended | ||
| 741 | pub const LOG2PHYS_EXT = 65; | ||
| 742 | ///get record locking information, per-process | ||
| 743 | pub const GETLKPID = 66; | ||
| 744 | ///Mark the file as being the backing store for another filesystem | ||
| 745 | pub const SETBACKINGSTORE = 70; | ||
| 746 | ///return the full path of the FD, but error in specific mtmd circumstances | ||
| 747 | pub const GETPATH_MTMINFO = 71; | ||
| 748 | ///Returns the code directory, with associated hashes, to the caller | ||
| 749 | pub const GETCODEDIR = 72; | ||
| 750 | ///No SIGPIPE generated on EPIPE | ||
| 751 | pub const SETNOSIGPIPE = 73; | ||
| 752 | ///Status of SIGPIPE for this fd | ||
| 753 | pub const GETNOSIGPIPE = 74; | ||
| 754 | ///For some cases, we need to rewrap the key for AKS/MKB | ||
| 755 | pub const TRANSCODEKEY = 75; | ||
| 756 | ///file being written to a by single writer... if throttling enabled, writes | ||
| 757 | ///may be broken into smaller chunks with throttling in between | ||
| 758 | pub const SINGLE_WRITER = 76; | ||
| 759 | ///Get the protection version number for this filesystem | ||
| 760 | pub const GETPROTECTIONLEVEL = 77; | ||
| 761 | ///Add detached code signatures (used by dyld for shared libs) | ||
| 762 | pub const FINDSIGS = 78; | ||
| 763 | ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator) | ||
| 764 | pub const ADDFILESIGS_FOR_DYLD_SIM = 83; | ||
| 765 | ///fsync + issue barrier to drive | ||
| 766 | pub const BARRIERFSYNC = 85; | ||
| 767 | ///Add signature from same file, return end offset in structure on success | ||
| 768 | pub const ADDFILESIGS_RETURN = 97; | ||
| 769 | ///Check if Library Validation allows this Mach-O file to be mapped into the calling process | ||
| 770 | pub const CHECK_LV = 98; | ||
| 771 | ///Deallocate a range of the file | ||
| 772 | pub const PUNCHHOLE = 99; | ||
| 773 | ///Trim an active file | ||
| 774 | pub const TRIM_ACTIVE_FILE = 100; | ||
| 775 | ///mark the dup with FD_CLOEXEC | ||
| 776 | pub const DUPFD_CLOEXEC = 67; | ||
| 777 | /// shared or read lock | ||
| 778 | pub const RDLCK = 1; | ||
| 779 | /// unlock | ||
| 780 | pub const UNLCK = 2; | ||
| 781 | /// exclusive or write lock | ||
| 782 | pub const WRLCK = 3; | ||
| 783 | }, | ||
| 784 | .freebsd, .kfreebsd => struct { | ||
| 785 | /// Duplicate file descriptor. | ||
| 786 | pub const DUPFD = 0; | ||
| 787 | /// Get file descriptor flags. | ||
| 788 | pub const GETFD = 1; | ||
| 789 | /// Set file descriptor flags. | ||
| 790 | pub const SETFD = 2; | ||
| 791 | /// Get file status flags. | ||
| 792 | pub const GETFL = 3; | ||
| 793 | /// Set file status flags. | ||
| 794 | pub const SETFL = 4; | ||
| 795 | |||
| 796 | /// Get SIGIO/SIGURG proc/pgrrp. | ||
| 797 | pub const GETOWN = 5; | ||
| 798 | /// Set SIGIO/SIGURG proc/pgrrp. | ||
| 799 | pub const SETOWN = 6; | ||
| 800 | |||
| 801 | /// Get record locking information. | ||
| 802 | pub const GETLK = 11; | ||
| 803 | /// Set record locking information. | ||
| 804 | pub const SETLK = 12; | ||
| 805 | /// Set record locking information and wait if blocked. | ||
| 806 | pub const SETLKW = 13; | ||
| 807 | |||
| 808 | /// Debugging support for remote locks. | ||
| 809 | pub const SETLK_REMOTE = 14; | ||
| 810 | /// Read ahead. | ||
| 811 | pub const READAHEAD = 15; | ||
| 812 | |||
| 813 | /// DUPFD with FD_CLOEXEC set. | ||
| 814 | pub const DUPFD_CLOEXEC = 17; | ||
| 815 | /// DUP2FD with FD_CLOEXEC set. | ||
| 816 | pub const DUP2FD_CLOEXEC = 18; | ||
| 817 | |||
| 818 | pub const ADD_SEALS = 19; | ||
| 819 | pub const GET_SEALS = 20; | ||
| 820 | /// Return `kinfo_file` for a file descriptor. | ||
| 821 | pub const KINFO = 22; | ||
| 822 | |||
| 823 | // Seals (ADD_SEALS, GET_SEALS) | ||
| 824 | /// Prevent adding sealings. | ||
| 825 | pub const SEAL_SEAL = 0x0001; | ||
| 826 | /// May not shrink | ||
| 827 | pub const SEAL_SHRINK = 0x0002; | ||
| 828 | /// May not grow. | ||
| 829 | pub const SEAL_GROW = 0x0004; | ||
| 830 | /// May not write. | ||
| 831 | pub const SEAL_WRITE = 0x0008; | ||
| 832 | |||
| 833 | // Record locking flags (GETLK, SETLK, SETLKW). | ||
| 834 | /// Shared or read lock. | ||
| 835 | pub const RDLCK = 1; | ||
| 836 | /// Unlock. | ||
| 837 | pub const UNLCK = 2; | ||
| 838 | /// Exclusive or write lock. | ||
| 839 | pub const WRLCK = 3; | ||
| 840 | /// Purge locks for a given system ID. | ||
| 841 | pub const UNLCKSYS = 4; | ||
| 842 | /// Cancel an async lock request. | ||
| 843 | pub const CANCEL = 5; | ||
| 844 | |||
| 845 | pub const SETOWN_EX = 15; | ||
| 846 | pub const GETOWN_EX = 16; | ||
| 847 | |||
| 848 | pub const GETOWNER_UIDS = 17; | ||
| 849 | }, | ||
| 850 | .solaris, .illumos => struct { | ||
| 851 | /// Unlock a previously locked region | ||
| 852 | pub const ULOCK = 0; | ||
| 853 | /// Lock a region for exclusive use | ||
| 854 | pub const LOCK = 1; | ||
| 855 | /// Test and lock a region for exclusive use | ||
| 856 | pub const TLOCK = 2; | ||
| 857 | /// Test a region for other processes locks | ||
| 858 | pub const TEST = 3; | ||
| 859 | |||
| 860 | /// Duplicate fildes | ||
| 861 | pub const DUPFD = 0; | ||
| 862 | /// Get fildes flags | ||
| 863 | pub const GETFD = 1; | ||
| 864 | /// Set fildes flags | ||
| 865 | pub const SETFD = 2; | ||
| 866 | /// Get file flags | ||
| 867 | pub const GETFL = 3; | ||
| 868 | /// Get file flags including open-only flags | ||
| 869 | pub const GETXFL = 45; | ||
| 870 | /// Set file flags | ||
| 871 | pub const SETFL = 4; | ||
| 872 | |||
| 873 | /// Unused | ||
| 874 | pub const CHKFL = 8; | ||
| 875 | /// Duplicate fildes at third arg | ||
| 876 | pub const DUP2FD = 9; | ||
| 877 | /// Like DUP2FD with O_CLOEXEC set EINVAL is fildes matches arg1 | ||
| 878 | pub const DUP2FD_CLOEXEC = 36; | ||
| 879 | /// Like DUPFD with O_CLOEXEC set | ||
| 880 | pub const DUPFD_CLOEXEC = 37; | ||
| 881 | |||
| 882 | /// Is the file desc. a stream ? | ||
| 883 | pub const ISSTREAM = 13; | ||
| 884 | /// Turn on private access to file | ||
| 885 | pub const PRIV = 15; | ||
| 886 | /// Turn off private access to file | ||
| 887 | pub const NPRIV = 16; | ||
| 888 | /// UFS quota call | ||
| 889 | pub const QUOTACTL = 17; | ||
| 890 | /// Get number of BLKSIZE blocks allocated | ||
| 891 | pub const BLOCKS = 18; | ||
| 892 | /// Get optimal I/O block size | ||
| 893 | pub const BLKSIZE = 19; | ||
| 894 | /// Get owner (socket emulation) | ||
| 895 | pub const GETOWN = 23; | ||
| 896 | /// Set owner (socket emulation) | ||
| 897 | pub const SETOWN = 24; | ||
| 898 | /// Object reuse revoke access to file desc. | ||
| 899 | pub const REVOKE = 25; | ||
| 900 | /// Does vp have NFS locks private to lock manager | ||
| 901 | pub const HASREMOTELOCKS = 26; | ||
| 902 | |||
| 903 | /// Set file lock | ||
| 904 | pub const SETLK = 6; | ||
| 905 | /// Set file lock and wait | ||
| 906 | pub const SETLKW = 7; | ||
| 907 | /// Allocate file space | ||
| 908 | pub const ALLOCSP = 10; | ||
| 909 | /// Free file space | ||
| 910 | pub const FREESP = 11; | ||
| 911 | /// Get file lock | ||
| 912 | pub const GETLK = 14; | ||
| 913 | /// Get file lock owned by file | ||
| 914 | pub const OFD_GETLK = 47; | ||
| 915 | /// Set file lock owned by file | ||
| 916 | pub const OFD_SETLK = 48; | ||
| 917 | /// Set file lock owned by file and wait | ||
| 918 | pub const OFD_SETLKW = 49; | ||
| 919 | /// Set a file share reservation | ||
| 920 | pub const SHARE = 40; | ||
| 921 | /// Remove a file share reservation | ||
| 922 | pub const UNSHARE = 41; | ||
| 923 | /// Create Poison FD | ||
| 924 | pub const BADFD = 46; | ||
| 925 | |||
| 926 | /// Read lock | ||
| 927 | pub const RDLCK = 1; | ||
| 928 | /// Write lock | ||
| 929 | pub const WRLCK = 2; | ||
| 930 | /// Remove lock(s) | ||
| 931 | pub const UNLCK = 3; | ||
| 932 | /// remove remote locks for a given system | ||
| 933 | pub const UNLKSYS = 4; | ||
| 934 | |||
| 935 | // f_access values | ||
| 936 | /// Read-only share access | ||
| 937 | pub const RDACC = 0x1; | ||
| 938 | /// Write-only share access | ||
| 939 | pub const WRACC = 0x2; | ||
| 940 | /// Read-Write share access | ||
| 941 | pub const RWACC = 0x3; | ||
| 942 | |||
| 943 | // f_deny values | ||
| 944 | /// Don't deny others access | ||
| 945 | pub const NODNY = 0x0; | ||
| 946 | /// Deny others read share access | ||
| 947 | pub const RDDNY = 0x1; | ||
| 948 | /// Deny others write share access | ||
| 949 | pub const WRDNY = 0x2; | ||
| 950 | /// Deny others read or write share access | ||
| 951 | pub const RWDNY = 0x3; | ||
| 952 | /// private flag: Deny delete share access | ||
| 953 | pub const RMDNY = 0x4; | ||
| 954 | }, | ||
| 955 | .netbsd => struct { | ||
| 956 | pub const DUPFD = 0; | ||
| 957 | pub const GETFD = 1; | ||
| 958 | pub const SETFD = 2; | ||
| 959 | pub const GETFL = 3; | ||
| 960 | pub const SETFL = 4; | ||
| 961 | pub const GETOWN = 5; | ||
| 962 | pub const SETOWN = 6; | ||
| 963 | pub const GETLK = 7; | ||
| 964 | pub const SETLK = 8; | ||
| 965 | pub const SETLKW = 9; | ||
| 966 | pub const CLOSEM = 10; | ||
| 967 | pub const MAXFD = 11; | ||
| 968 | pub const DUPFD_CLOEXEC = 12; | ||
| 969 | pub const GETNOSIGPIPE = 13; | ||
| 970 | pub const SETNOSIGPIPE = 14; | ||
| 971 | pub const GETPATH = 15; | ||
| 972 | |||
| 973 | pub const RDLCK = 1; | ||
| 974 | pub const WRLCK = 3; | ||
| 975 | pub const UNLCK = 2; | ||
| 976 | }, | ||
| 977 | .dragonfly => struct { | ||
| 978 | pub const ULOCK = 0; | ||
| 979 | pub const LOCK = 1; | ||
| 980 | pub const TLOCK = 2; | ||
| 981 | pub const TEST = 3; | ||
| 982 | |||
| 983 | pub const DUPFD = 0; | ||
| 984 | pub const GETFD = 1; | ||
| 985 | pub const RDLCK = 1; | ||
| 986 | pub const SETFD = 2; | ||
| 987 | pub const UNLCK = 2; | ||
| 988 | pub const WRLCK = 3; | ||
| 989 | pub const GETFL = 3; | ||
| 990 | pub const SETFL = 4; | ||
| 991 | pub const GETOWN = 5; | ||
| 992 | pub const SETOWN = 6; | ||
| 993 | pub const GETLK = 7; | ||
| 994 | pub const SETLK = 8; | ||
| 995 | pub const SETLKW = 9; | ||
| 996 | pub const DUP2FD = 10; | ||
| 997 | pub const DUPFD_CLOEXEC = 17; | ||
| 998 | pub const DUP2FD_CLOEXEC = 18; | ||
| 999 | pub const GETPATH = 19; | ||
| 1000 | }, | ||
| 1001 | .haiku => struct { | ||
| 1002 | pub const DUPFD = 0x0001; | ||
| 1003 | pub const GETFD = 0x0002; | ||
| 1004 | pub const SETFD = 0x0004; | ||
| 1005 | pub const GETFL = 0x0008; | ||
| 1006 | pub const SETFL = 0x0010; | ||
| 1007 | |||
| 1008 | pub const GETLK = 0x0020; | ||
| 1009 | pub const SETLK = 0x0080; | ||
| 1010 | pub const SETLKW = 0x0100; | ||
| 1011 | pub const DUPFD_CLOEXEC = 0x0200; | ||
| 1012 | |||
| 1013 | pub const RDLCK = 0x0040; | ||
| 1014 | pub const UNLCK = 0x0200; | ||
| 1015 | pub const WRLCK = 0x0400; | ||
| 1016 | }, | ||
| 1017 | .openbsd => struct { | ||
| 1018 | pub const DUPFD = 0; | ||
| 1019 | pub const GETFD = 1; | ||
| 1020 | pub const SETFD = 2; | ||
| 1021 | pub const GETFL = 3; | ||
| 1022 | pub const SETFL = 4; | ||
| 1023 | |||
| 1024 | pub const GETOWN = 5; | ||
| 1025 | pub const SETOWN = 6; | ||
| 1026 | |||
| 1027 | pub const GETLK = 7; | ||
| 1028 | pub const SETLK = 8; | ||
| 1029 | pub const SETLKW = 9; | ||
| 1030 | |||
| 1031 | pub const RDLCK = 1; | ||
| 1032 | pub const UNLCK = 2; | ||
| 1033 | pub const WRLCK = 3; | ||
| 1034 | }, | ||
| 1035 | else => void, | ||
| 1036 | }; | ||
| 1037 | pub const FD_CLOEXEC = switch (native_os) { | ||
| 1038 | .linux => linux.FD_CLOEXEC, | ||
| 1039 | .emscripten => emscripten.FD_CLOEXEC, | ||
| 1040 | else => 1, | ||
| 1041 | }; | ||
| 1042 | |||
| 1043 | /// Test for existence of file. | ||
| 1044 | pub const F_OK = switch (native_os) { | ||
| 1045 | .linux => linux.F_OK, | ||
| 1046 | .emscripten => emscripten.F_OK, | ||
| 1047 | else => 0, | ||
| 1048 | }; | ||
| 1049 | /// Test for execute or search permission. | ||
| 1050 | pub const X_OK = switch (native_os) { | ||
| 1051 | .linux => linux.X_OK, | ||
| 1052 | .emscripten => emscripten.X_OK, | ||
| 1053 | else => 1, | ||
| 1054 | }; | ||
| 1055 | /// Test for write permission. | ||
| 1056 | pub const W_OK = switch (native_os) { | ||
| 1057 | .linux => linux.W_OK, | ||
| 1058 | .emscripten => emscripten.W_OK, | ||
| 1059 | else => 2, | ||
| 1060 | }; | ||
| 1061 | /// Test for read permission. | ||
| 1062 | pub const R_OK = switch (native_os) { | ||
| 1063 | .linux => linux.R_OK, | ||
| 1064 | .emscripten => emscripten.R_OK, | ||
| 1065 | else => 4, | ||
| 1066 | }; | ||
| 1067 | |||
| 1068 | pub const Flock = switch (native_os) { | ||
| 1069 | .linux => linux.Flock, | ||
| 1070 | .emscripten => emscripten.Flock, | ||
| 1071 | .openbsd, .dragonfly, .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 1072 | start: off_t, | ||
| 1073 | len: off_t, | ||
| 1074 | pid: pid_t, | ||
| 1075 | type: i16, | ||
| 1076 | whence: i16, | ||
| 1077 | }, | ||
| 1078 | .freebsd, .kfreebsd => extern struct { | ||
| 1079 | /// Starting offset. | ||
| 1080 | start: off_t, | ||
| 1081 | /// Number of consecutive bytes to be locked. | ||
| 1082 | /// A value of 0 means to the end of the file. | ||
| 1083 | len: off_t, | ||
| 1084 | /// Lock owner. | ||
| 1085 | pid: pid_t, | ||
| 1086 | /// Lock type. | ||
| 1087 | type: i16, | ||
| 1088 | /// Type of the start member. | ||
| 1089 | whence: i16, | ||
| 1090 | /// Remote system id or zero for local. | ||
| 1091 | sysid: i32, | ||
| 1092 | }, | ||
| 1093 | .solaris, .illumos => extern struct { | ||
| 1094 | type: c_short, | ||
| 1095 | whence: c_short, | ||
| 1096 | start: off_t, | ||
| 1097 | // len == 0 means until end of file. | ||
| 1098 | len: off_t, | ||
| 1099 | sysid: c_int, | ||
| 1100 | pid: pid_t, | ||
| 1101 | __pad: [4]c_long, | ||
| 1102 | }, | ||
| 1103 | .haiku => extern struct { | ||
| 1104 | type: i16, | ||
| 1105 | whence: i16, | ||
| 1106 | start: off_t, | ||
| 1107 | len: off_t, | ||
| 1108 | pid: pid_t, | ||
| 1109 | }, | ||
| 1110 | else => void, | ||
| 1111 | }; | ||
| 1112 | pub const HOST_NAME_MAX = switch (native_os) { | ||
| 1113 | .linux => linux.HOST_NAME_MAX, | ||
| 1114 | .macos, .ios, .tvos, .watchos, .visionos => 72, | ||
| 1115 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd => 255, | ||
| 1116 | else => {}, | ||
| 1117 | }; | ||
| 1118 | pub const IOV_MAX = switch (native_os) { | ||
| 1119 | .linux => linux.IOV_MAX, | ||
| 1120 | .emscripten => emscripten.IOV_MAX, | ||
| 1121 | .openbsd, .haiku, .solaris, .illumos, .wasi => 1024, | ||
| 1122 | .macos, .ios, .tvos, .watchos, .visionos => 16, | ||
| 1123 | .dragonfly, .netbsd, .freebsd, .kfreebsd => KERN.IOV_MAX, | ||
| 1124 | else => {}, | ||
| 1125 | }; | ||
| 1126 | pub const CTL = switch (native_os) { | ||
| 1127 | .freebsd, .kfreebsd => struct { | ||
| 1128 | pub const KERN = 1; | ||
| 1129 | pub const DEBUG = 5; | ||
| 1130 | }, | ||
| 1131 | .netbsd => struct { | ||
| 1132 | pub const KERN = 1; | ||
| 1133 | pub const DEBUG = 5; | ||
| 1134 | }, | ||
| 1135 | .dragonfly => struct { | ||
| 1136 | pub const UNSPEC = 0; | ||
| 1137 | pub const KERN = 1; | ||
| 1138 | pub const VM = 2; | ||
| 1139 | pub const VFS = 3; | ||
| 1140 | pub const NET = 4; | ||
| 1141 | pub const DEBUG = 5; | ||
| 1142 | pub const HW = 6; | ||
| 1143 | pub const MACHDEP = 7; | ||
| 1144 | pub const USER = 8; | ||
| 1145 | pub const LWKT = 10; | ||
| 1146 | pub const MAXID = 11; | ||
| 1147 | pub const MAXNAME = 12; | ||
| 1148 | }, | ||
| 1149 | .openbsd => struct { | ||
| 1150 | pub const UNSPEC = 0; | ||
| 1151 | pub const KERN = 1; | ||
| 1152 | pub const VM = 2; | ||
| 1153 | pub const FS = 3; | ||
| 1154 | pub const NET = 4; | ||
| 1155 | pub const DEBUG = 5; | ||
| 1156 | pub const HW = 6; | ||
| 1157 | pub const MACHDEP = 7; | ||
| 1158 | |||
| 1159 | pub const DDB = 9; | ||
| 1160 | pub const VFS = 10; | ||
| 1161 | }, | ||
| 1162 | else => void, | ||
| 1163 | }; | ||
| 1164 | pub const KERN = switch (native_os) { | ||
| 1165 | .freebsd, .kfreebsd => struct { | ||
| 1166 | /// struct: process entries | ||
| 1167 | pub const PROC = 14; | ||
| 1168 | /// path to executable | ||
| 1169 | pub const PROC_PATHNAME = 12; | ||
| 1170 | /// file descriptors for process | ||
| 1171 | pub const PROC_FILEDESC = 33; | ||
| 1172 | pub const IOV_MAX = 35; | ||
| 1173 | }, | ||
| 1174 | .netbsd => struct { | ||
| 1175 | /// struct: process argv/env | ||
| 1176 | pub const PROC_ARGS = 48; | ||
| 1177 | /// path to executable | ||
| 1178 | pub const PROC_PATHNAME = 5; | ||
| 1179 | pub const IOV_MAX = 38; | ||
| 1180 | }, | ||
| 1181 | .dragonfly => struct { | ||
| 1182 | pub const PROC_ALL = 0; | ||
| 1183 | pub const OSTYPE = 1; | ||
| 1184 | pub const PROC_PID = 1; | ||
| 1185 | pub const OSRELEASE = 2; | ||
| 1186 | pub const PROC_PGRP = 2; | ||
| 1187 | pub const OSREV = 3; | ||
| 1188 | pub const PROC_SESSION = 3; | ||
| 1189 | pub const VERSION = 4; | ||
| 1190 | pub const PROC_TTY = 4; | ||
| 1191 | pub const MAXVNODES = 5; | ||
| 1192 | pub const PROC_UID = 5; | ||
| 1193 | pub const MAXPROC = 6; | ||
| 1194 | pub const PROC_RUID = 6; | ||
| 1195 | pub const MAXFILES = 7; | ||
| 1196 | pub const PROC_ARGS = 7; | ||
| 1197 | pub const ARGMAX = 8; | ||
| 1198 | pub const PROC_CWD = 8; | ||
| 1199 | pub const PROC_PATHNAME = 9; | ||
| 1200 | pub const SECURELVL = 9; | ||
| 1201 | pub const PROC_SIGTRAMP = 10; | ||
| 1202 | pub const HOSTNAME = 10; | ||
| 1203 | pub const HOSTID = 11; | ||
| 1204 | pub const CLOCKRATE = 12; | ||
| 1205 | pub const VNODE = 13; | ||
| 1206 | pub const PROC = 14; | ||
| 1207 | pub const FILE = 15; | ||
| 1208 | pub const PROC_FLAGMASK = 16; | ||
| 1209 | pub const PROF = 16; | ||
| 1210 | pub const PROC_FLAG_LWP = 16; | ||
| 1211 | pub const POSIX1 = 17; | ||
| 1212 | pub const NGROUPS = 18; | ||
| 1213 | pub const JOB_CONTROL = 19; | ||
| 1214 | pub const SAVED_IDS = 20; | ||
| 1215 | pub const BOOTTIME = 21; | ||
| 1216 | pub const NISDOMAINNAME = 22; | ||
| 1217 | pub const UPDATEINTERVAL = 23; | ||
| 1218 | pub const OSRELDATE = 24; | ||
| 1219 | pub const NTP_PLL = 25; | ||
| 1220 | pub const BOOTFILE = 26; | ||
| 1221 | pub const MAXFILESPERPROC = 27; | ||
| 1222 | pub const MAXPROCPERUID = 28; | ||
| 1223 | pub const DUMPDEV = 29; | ||
| 1224 | pub const IPC = 30; | ||
| 1225 | pub const DUMMY = 31; | ||
| 1226 | pub const PS_STRINGS = 32; | ||
| 1227 | pub const USRSTACK = 33; | ||
| 1228 | pub const LOGSIGEXIT = 34; | ||
| 1229 | pub const IOV_MAX = 35; | ||
| 1230 | pub const MAXPOSIXLOCKSPERUID = 36; | ||
| 1231 | pub const MAXID = 37; | ||
| 1232 | }, | ||
| 1233 | .openbsd => struct { | ||
| 1234 | pub const OSTYPE = 1; | ||
| 1235 | pub const OSRELEASE = 2; | ||
| 1236 | pub const OSREV = 3; | ||
| 1237 | pub const VERSION = 4; | ||
| 1238 | pub const MAXVNODES = 5; | ||
| 1239 | pub const MAXPROC = 6; | ||
| 1240 | pub const MAXFILES = 7; | ||
| 1241 | pub const ARGMAX = 8; | ||
| 1242 | pub const SECURELVL = 9; | ||
| 1243 | pub const HOSTNAME = 10; | ||
| 1244 | pub const HOSTID = 11; | ||
| 1245 | pub const CLOCKRATE = 12; | ||
| 1246 | |||
| 1247 | pub const PROF = 16; | ||
| 1248 | pub const POSIX1 = 17; | ||
| 1249 | pub const NGROUPS = 18; | ||
| 1250 | pub const JOB_CONTROL = 19; | ||
| 1251 | pub const SAVED_IDS = 20; | ||
| 1252 | pub const BOOTTIME = 21; | ||
| 1253 | pub const DOMAINNAME = 22; | ||
| 1254 | pub const MAXPARTITIONS = 23; | ||
| 1255 | pub const RAWPARTITION = 24; | ||
| 1256 | pub const MAXTHREAD = 25; | ||
| 1257 | pub const NTHREADS = 26; | ||
| 1258 | pub const OSVERSION = 27; | ||
| 1259 | pub const SOMAXCONN = 28; | ||
| 1260 | pub const SOMINCONN = 29; | ||
| 1261 | |||
| 1262 | pub const NOSUIDCOREDUMP = 32; | ||
| 1263 | pub const FSYNC = 33; | ||
| 1264 | pub const SYSVMSG = 34; | ||
| 1265 | pub const SYSVSEM = 35; | ||
| 1266 | pub const SYSVSHM = 36; | ||
| 1267 | |||
| 1268 | pub const MSGBUFSIZE = 38; | ||
| 1269 | pub const MALLOCSTATS = 39; | ||
| 1270 | pub const CPTIME = 40; | ||
| 1271 | pub const NCHSTATS = 41; | ||
| 1272 | pub const FORKSTAT = 42; | ||
| 1273 | pub const NSELCOLL = 43; | ||
| 1274 | pub const TTY = 44; | ||
| 1275 | pub const CCPU = 45; | ||
| 1276 | pub const FSCALE = 46; | ||
| 1277 | pub const NPROCS = 47; | ||
| 1278 | pub const MSGBUF = 48; | ||
| 1279 | pub const POOL = 49; | ||
| 1280 | pub const STACKGAPRANDOM = 50; | ||
| 1281 | pub const SYSVIPC_INFO = 51; | ||
| 1282 | pub const ALLOWKMEM = 52; | ||
| 1283 | pub const WITNESSWATCH = 53; | ||
| 1284 | pub const SPLASSERT = 54; | ||
| 1285 | pub const PROC_ARGS = 55; | ||
| 1286 | pub const NFILES = 56; | ||
| 1287 | pub const TTYCOUNT = 57; | ||
| 1288 | pub const NUMVNODES = 58; | ||
| 1289 | pub const MBSTAT = 59; | ||
| 1290 | pub const WITNESS = 60; | ||
| 1291 | pub const SEMINFO = 61; | ||
| 1292 | pub const SHMINFO = 62; | ||
| 1293 | pub const INTRCNT = 63; | ||
| 1294 | pub const WATCHDOG = 64; | ||
| 1295 | pub const ALLOWDT = 65; | ||
| 1296 | pub const PROC = 66; | ||
| 1297 | pub const MAXCLUSTERS = 67; | ||
| 1298 | pub const EVCOUNT = 68; | ||
| 1299 | pub const TIMECOUNTER = 69; | ||
| 1300 | pub const MAXLOCKSPERUID = 70; | ||
| 1301 | pub const CPTIME2 = 71; | ||
| 1302 | pub const CACHEPCT = 72; | ||
| 1303 | pub const FILE = 73; | ||
| 1304 | pub const WXABORT = 74; | ||
| 1305 | pub const CONSDEV = 75; | ||
| 1306 | pub const NETLIVELOCKS = 76; | ||
| 1307 | pub const POOL_DEBUG = 77; | ||
| 1308 | pub const PROC_CWD = 78; | ||
| 1309 | pub const PROC_NOBROADCASTKILL = 79; | ||
| 1310 | pub const PROC_VMMAP = 80; | ||
| 1311 | pub const GLOBAL_PTRACE = 81; | ||
| 1312 | pub const CONSBUFSIZE = 82; | ||
| 1313 | pub const CONSBUF = 83; | ||
| 1314 | pub const AUDIO = 84; | ||
| 1315 | pub const CPUSTATS = 85; | ||
| 1316 | pub const PFSTATUS = 86; | ||
| 1317 | pub const TIMEOUT_STATS = 87; | ||
| 1318 | pub const UTC_OFFSET = 88; | ||
| 1319 | pub const VIDEO = 89; | ||
| 1320 | |||
| 1321 | pub const PROC_ALL = 0; | ||
| 1322 | pub const PROC_PID = 1; | ||
| 1323 | pub const PROC_PGRP = 2; | ||
| 1324 | pub const PROC_SESSION = 3; | ||
| 1325 | pub const PROC_TTY = 4; | ||
| 1326 | pub const PROC_UID = 5; | ||
| 1327 | pub const PROC_RUID = 6; | ||
| 1328 | pub const PROC_KTHREAD = 7; | ||
| 1329 | pub const PROC_SHOW_THREADS = 0x40000000; | ||
| 1330 | |||
| 1331 | pub const PROC_ARGV = 1; | ||
| 1332 | pub const PROC_NARGV = 2; | ||
| 1333 | pub const PROC_ENV = 3; | ||
| 1334 | pub const PROC_NENV = 4; | ||
| 1335 | }, | ||
| 1336 | else => void, | ||
| 1337 | }; | ||
| 1338 | pub const MADV = switch (native_os) { | ||
| 1339 | .linux => linux.MADV, | ||
| 1340 | .emscripten => emscripten.MADV, | ||
| 1341 | .freebsd, .kfreebsd => struct { | ||
| 1342 | pub const NORMAL = 0; | ||
| 1343 | pub const RANDOM = 1; | ||
| 1344 | pub const SEQUENTIAL = 2; | ||
| 1345 | pub const WILLNEED = 3; | ||
| 1346 | pub const DONTNEED = 4; | ||
| 1347 | pub const FREE = 5; | ||
| 1348 | pub const NOSYNC = 6; | ||
| 1349 | pub const AUTOSYNC = 7; | ||
| 1350 | pub const NOCORE = 8; | ||
| 1351 | pub const CORE = 9; | ||
| 1352 | pub const PROTECT = 10; | ||
| 1353 | }, | ||
| 1354 | .solaris, .illumos => struct { | ||
| 1355 | /// no further special treatment | ||
| 1356 | pub const NORMAL = 0; | ||
| 1357 | /// expect random page references | ||
| 1358 | pub const RANDOM = 1; | ||
| 1359 | /// expect sequential page references | ||
| 1360 | pub const SEQUENTIAL = 2; | ||
| 1361 | /// will need these pages | ||
| 1362 | pub const WILLNEED = 3; | ||
| 1363 | /// don't need these pages | ||
| 1364 | pub const DONTNEED = 4; | ||
| 1365 | /// contents can be freed | ||
| 1366 | pub const FREE = 5; | ||
| 1367 | /// default access | ||
| 1368 | pub const ACCESS_DEFAULT = 6; | ||
| 1369 | /// next LWP to access heavily | ||
| 1370 | pub const ACCESS_LWP = 7; | ||
| 1371 | /// many processes to access heavily | ||
| 1372 | pub const ACCESS_MANY = 8; | ||
| 1373 | /// contents will be purged | ||
| 1374 | pub const PURGE = 9; | ||
| 1375 | }, | ||
| 1376 | .dragonfly => struct { | ||
| 1377 | pub const SEQUENTIAL = 2; | ||
| 1378 | pub const CONTROL_END = SETMAP; | ||
| 1379 | pub const DONTNEED = 4; | ||
| 1380 | pub const RANDOM = 1; | ||
| 1381 | pub const WILLNEED = 3; | ||
| 1382 | pub const NORMAL = 0; | ||
| 1383 | pub const CONTROL_START = INVAL; | ||
| 1384 | pub const FREE = 5; | ||
| 1385 | pub const NOSYNC = 6; | ||
| 1386 | pub const AUTOSYNC = 7; | ||
| 1387 | pub const NOCORE = 8; | ||
| 1388 | pub const CORE = 9; | ||
| 1389 | pub const INVAL = 10; | ||
| 1390 | pub const SETMAP = 11; | ||
| 1391 | }, | ||
| 1392 | else => void, | ||
| 1393 | }; | ||
| 1394 | pub const MSF = switch (native_os) { | ||
| 1395 | .linux => linux.MSF, | ||
| 1396 | .emscripten => emscripten.MSF, | ||
| 1397 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 1398 | pub const ASYNC = 0x1; | ||
| 1399 | pub const INVALIDATE = 0x2; | ||
| 1400 | /// invalidate, leave mapped | ||
| 1401 | pub const KILLPAGES = 0x4; | ||
| 1402 | /// deactivate, leave mapped | ||
| 1403 | pub const DEACTIVATE = 0x8; | ||
| 1404 | pub const SYNC = 0x10; | ||
| 1405 | }, | ||
| 1406 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd => struct { | ||
| 1407 | pub const ASYNC = 1; | ||
| 1408 | pub const INVALIDATE = 2; | ||
| 1409 | pub const SYNC = 4; | ||
| 1410 | }, | ||
| 1411 | else => void, | ||
| 1412 | }; | ||
| 1413 | pub const MMAP2_UNIT = switch (native_os) { | ||
| 1414 | .linux => linux.MMAP2_UNIT, | ||
| 1415 | else => void, | ||
| 1416 | }; | ||
| 1417 | pub const NAME_MAX = switch (native_os) { | ||
| 1418 | .linux => linux.NAME_MAX, | ||
| 1419 | .emscripten => emscripten.NAME_MAX, | ||
| 1420 | // Haiku's headers make this 256, to contain room for the terminating null | ||
| 1421 | // character, but POSIX definition says that NAME_MAX does not include the | ||
| 1422 | // terminating null. | ||
| 1423 | .haiku, .openbsd, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => 255, | ||
| 1424 | else => {}, | ||
| 1425 | }; | ||
| 1426 | pub const PATH_MAX = switch (native_os) { | ||
| 1427 | .linux => linux.PATH_MAX, | ||
| 1428 | .emscripten => emscripten.PATH_MAX, | ||
| 1429 | .wasi => 4096, | ||
| 1430 | .windows => 260, | ||
| 1431 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => 1024, | ||
| 1432 | else => {}, | ||
| 1433 | }; | ||
| 1434 | |||
| 1435 | pub const POLL = switch (native_os) { | ||
| 1436 | .linux => linux.POLL, | ||
| 1437 | .emscripten => emscripten.POLL, | ||
| 1438 | .wasi => struct { | ||
| 1439 | pub const RDNORM = 0x1; | ||
| 1440 | pub const WRNORM = 0x2; | ||
| 1441 | pub const IN = RDNORM; | ||
| 1442 | pub const OUT = WRNORM; | ||
| 1443 | pub const ERR = 0x1000; | ||
| 1444 | pub const HUP = 0x2000; | ||
| 1445 | pub const NVAL = 0x4000; | ||
| 1446 | }, | ||
| 1447 | .windows => ws2_32.POLL, | ||
| 1448 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 1449 | pub const IN = 0x001; | ||
| 1450 | pub const PRI = 0x002; | ||
| 1451 | pub const OUT = 0x004; | ||
| 1452 | pub const RDNORM = 0x040; | ||
| 1453 | pub const WRNORM = OUT; | ||
| 1454 | pub const RDBAND = 0x080; | ||
| 1455 | pub const WRBAND = 0x100; | ||
| 1456 | |||
| 1457 | pub const EXTEND = 0x0200; | ||
| 1458 | pub const ATTRIB = 0x0400; | ||
| 1459 | pub const NLINK = 0x0800; | ||
| 1460 | pub const WRITE = 0x1000; | ||
| 1461 | |||
| 1462 | pub const ERR = 0x008; | ||
| 1463 | pub const HUP = 0x010; | ||
| 1464 | pub const NVAL = 0x020; | ||
| 1465 | |||
| 1466 | pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL; | ||
| 1467 | }, | ||
| 1468 | .freebsd, .kfreebsd => struct { | ||
| 1469 | /// any readable data available. | ||
| 1470 | pub const IN = 0x0001; | ||
| 1471 | /// OOB/Urgent readable data. | ||
| 1472 | pub const PRI = 0x0002; | ||
| 1473 | /// file descriptor is writeable. | ||
| 1474 | pub const OUT = 0x0004; | ||
| 1475 | /// non-OOB/URG data available. | ||
| 1476 | pub const RDNORM = 0x0040; | ||
| 1477 | /// no write type differentiation. | ||
| 1478 | pub const WRNORM = OUT; | ||
| 1479 | /// OOB/Urgent readable data. | ||
| 1480 | pub const RDBAND = 0x0080; | ||
| 1481 | /// OOB/Urgent data can be written. | ||
| 1482 | pub const WRBAND = 0x0100; | ||
| 1483 | /// like IN, except ignore EOF. | ||
| 1484 | pub const INIGNEOF = 0x2000; | ||
| 1485 | /// some poll error occurred. | ||
| 1486 | pub const ERR = 0x0008; | ||
| 1487 | /// file descriptor was "hung up". | ||
| 1488 | pub const HUP = 0x0010; | ||
| 1489 | /// requested events "invalid". | ||
| 1490 | pub const NVAL = 0x0020; | ||
| 1491 | |||
| 1492 | pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL; | ||
| 1493 | }, | ||
| 1494 | .solaris, .illumos => struct { | ||
| 1495 | pub const IN = 0x0001; | ||
| 1496 | pub const PRI = 0x0002; | ||
| 1497 | pub const OUT = 0x0004; | ||
| 1498 | pub const RDNORM = 0x0040; | ||
| 1499 | pub const WRNORM = .OUT; | ||
| 1500 | pub const RDBAND = 0x0080; | ||
| 1501 | pub const WRBAND = 0x0100; | ||
| 1502 | /// Read-side hangup. | ||
| 1503 | pub const RDHUP = 0x4000; | ||
| 1504 | |||
| 1505 | /// Non-testable events (may not be specified in events). | ||
| 1506 | pub const ERR = 0x0008; | ||
| 1507 | pub const HUP = 0x0010; | ||
| 1508 | pub const NVAL = 0x0020; | ||
| 1509 | |||
| 1510 | /// Events to control `/dev/poll` (not specified in revents) | ||
| 1511 | pub const REMOVE = 0x0800; | ||
| 1512 | pub const ONESHOT = 0x1000; | ||
| 1513 | pub const ET = 0x2000; | ||
| 1514 | }, | ||
| 1515 | .dragonfly, .netbsd => struct { | ||
| 1516 | /// Testable events (may be specified in events field). | ||
| 1517 | pub const IN = 0x0001; | ||
| 1518 | pub const PRI = 0x0002; | ||
| 1519 | pub const OUT = 0x0004; | ||
| 1520 | pub const RDNORM = 0x0040; | ||
| 1521 | pub const WRNORM = OUT; | ||
| 1522 | pub const RDBAND = 0x0080; | ||
| 1523 | pub const WRBAND = 0x0100; | ||
| 1524 | |||
| 1525 | /// Non-testable events (may not be specified in events field). | ||
| 1526 | pub const ERR = 0x0008; | ||
| 1527 | pub const HUP = 0x0010; | ||
| 1528 | pub const NVAL = 0x0020; | ||
| 1529 | }, | ||
| 1530 | .haiku => struct { | ||
| 1531 | /// any readable data available | ||
| 1532 | pub const IN = 0x0001; | ||
| 1533 | /// file descriptor is writeable | ||
| 1534 | pub const OUT = 0x0002; | ||
| 1535 | pub const RDNORM = IN; | ||
| 1536 | pub const WRNORM = OUT; | ||
| 1537 | /// priority readable data | ||
| 1538 | pub const RDBAND = 0x0008; | ||
| 1539 | /// priority data can be written | ||
| 1540 | pub const WRBAND = 0x0010; | ||
| 1541 | /// high priority readable data | ||
| 1542 | pub const PRI = 0x0020; | ||
| 1543 | |||
| 1544 | /// errors pending | ||
| 1545 | pub const ERR = 0x0004; | ||
| 1546 | /// disconnected | ||
| 1547 | pub const HUP = 0x0080; | ||
| 1548 | /// invalid file descriptor | ||
| 1549 | pub const NVAL = 0x1000; | ||
| 1550 | }, | ||
| 1551 | .openbsd => struct { | ||
| 1552 | pub const IN = 0x0001; | ||
| 1553 | pub const PRI = 0x0002; | ||
| 1554 | pub const OUT = 0x0004; | ||
| 1555 | pub const ERR = 0x0008; | ||
| 1556 | pub const HUP = 0x0010; | ||
| 1557 | pub const NVAL = 0x0020; | ||
| 1558 | pub const RDNORM = 0x0040; | ||
| 1559 | pub const NORM = RDNORM; | ||
| 1560 | pub const WRNORM = OUT; | ||
| 1561 | pub const RDBAND = 0x0080; | ||
| 1562 | pub const WRBAND = 0x0100; | ||
| 1563 | }, | ||
| 1564 | else => void, | ||
| 1565 | }; | ||
| 1566 | |||
| 1567 | /// Basic memory protection flags | ||
| 1568 | pub const PROT = switch (native_os) { | ||
| 1569 | .linux => linux.PROT, | ||
| 1570 | .emscripten => emscripten.PROT, | ||
| 1571 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd, .windows => struct { | ||
| 1572 | /// page can not be accessed | ||
| 1573 | pub const NONE = 0x0; | ||
| 1574 | /// page can be read | ||
| 1575 | pub const READ = 0x1; | ||
| 1576 | /// page can be written | ||
| 1577 | pub const WRITE = 0x2; | ||
| 1578 | /// page can be executed | ||
| 1579 | pub const EXEC = 0x4; | ||
| 1580 | }, | ||
| 1581 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 1582 | /// [MC2] no permissions | ||
| 1583 | pub const NONE: vm_prot_t = 0x00; | ||
| 1584 | /// [MC2] pages can be read | ||
| 1585 | pub const READ: vm_prot_t = 0x01; | ||
| 1586 | /// [MC2] pages can be written | ||
| 1587 | pub const WRITE: vm_prot_t = 0x02; | ||
| 1588 | /// [MC2] pages can be executed | ||
| 1589 | pub const EXEC: vm_prot_t = 0x04; | ||
| 1590 | /// When a caller finds that they cannot obtain write permission on a | ||
| 1591 | /// mapped entry, the following flag can be used. The entry will be | ||
| 1592 | /// made "needs copy" effectively copying the object (using COW), | ||
| 1593 | /// and write permission will be added to the maximum protections for | ||
| 1594 | /// the associated entry. | ||
| 1595 | pub const COPY: vm_prot_t = 0x10; | ||
| 1596 | }, | ||
| 1597 | else => void, | ||
| 1598 | }; | ||
| 1599 | |||
| 1600 | pub const REG = switch (native_os) { | ||
| 1601 | .linux => linux.REG, | ||
| 1602 | .emscripten => emscripten.REG, | ||
| 1603 | .freebsd, .kfreebsd => switch (builtin.cpu.arch) { | ||
| 1604 | .aarch64 => struct { | ||
| 1605 | pub const FP = 29; | ||
| 1606 | pub const SP = 31; | ||
| 1607 | pub const PC = 32; | ||
| 1608 | }, | ||
| 1609 | .arm => struct { | ||
| 1610 | pub const FP = 11; | ||
| 1611 | pub const SP = 13; | ||
| 1612 | pub const PC = 15; | ||
| 1613 | }, | ||
| 1614 | .x86_64 => struct { | ||
| 1615 | pub const RBP = 12; | ||
| 1616 | pub const RIP = 21; | ||
| 1617 | pub const RSP = 24; | ||
| 1618 | }, | ||
| 1619 | else => struct {}, | ||
| 1620 | }, | ||
| 1621 | .solaris, .illumos => struct { | ||
| 1622 | pub const R15 = 0; | ||
| 1623 | pub const R14 = 1; | ||
| 1624 | pub const R13 = 2; | ||
| 1625 | pub const R12 = 3; | ||
| 1626 | pub const R11 = 4; | ||
| 1627 | pub const R10 = 5; | ||
| 1628 | pub const R9 = 6; | ||
| 1629 | pub const R8 = 7; | ||
| 1630 | pub const RDI = 8; | ||
| 1631 | pub const RSI = 9; | ||
| 1632 | pub const RBP = 10; | ||
| 1633 | pub const RBX = 11; | ||
| 1634 | pub const RDX = 12; | ||
| 1635 | pub const RCX = 13; | ||
| 1636 | pub const RAX = 14; | ||
| 1637 | pub const RIP = 17; | ||
| 1638 | pub const RSP = 20; | ||
| 1639 | }, | ||
| 1640 | .netbsd => switch (builtin.cpu.arch) { | ||
| 1641 | .aarch64 => struct { | ||
| 1642 | pub const FP = 29; | ||
| 1643 | pub const SP = 31; | ||
| 1644 | pub const PC = 32; | ||
| 1645 | }, | ||
| 1646 | .arm => struct { | ||
| 1647 | pub const FP = 11; | ||
| 1648 | pub const SP = 13; | ||
| 1649 | pub const PC = 15; | ||
| 1650 | }, | ||
| 1651 | .x86_64 => struct { | ||
| 1652 | pub const RDI = 0; | ||
| 1653 | pub const RSI = 1; | ||
| 1654 | pub const RDX = 2; | ||
| 1655 | pub const RCX = 3; | ||
| 1656 | pub const R8 = 4; | ||
| 1657 | pub const R9 = 5; | ||
| 1658 | pub const R10 = 6; | ||
| 1659 | pub const R11 = 7; | ||
| 1660 | pub const R12 = 8; | ||
| 1661 | pub const R13 = 9; | ||
| 1662 | pub const R14 = 10; | ||
| 1663 | pub const R15 = 11; | ||
| 1664 | pub const RBP = 12; | ||
| 1665 | pub const RBX = 13; | ||
| 1666 | pub const RAX = 14; | ||
| 1667 | pub const GS = 15; | ||
| 1668 | pub const FS = 16; | ||
| 1669 | pub const ES = 17; | ||
| 1670 | pub const DS = 18; | ||
| 1671 | pub const TRAPNO = 19; | ||
| 1672 | pub const ERR = 20; | ||
| 1673 | pub const RIP = 21; | ||
| 1674 | pub const CS = 22; | ||
| 1675 | pub const RFLAGS = 23; | ||
| 1676 | pub const RSP = 24; | ||
| 1677 | pub const SS = 25; | ||
| 1678 | }, | ||
| 1679 | else => struct {}, | ||
| 1680 | }, | ||
| 1681 | else => struct {}, | ||
| 1682 | }; | ||
| 1683 | pub const RLIM = switch (native_os) { | ||
| 1684 | .linux => linux.RLIM, | ||
| 1685 | .emscripten => emscripten.RLIM, | ||
| 1686 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 1687 | /// No limit | ||
| 1688 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1689 | |||
| 1690 | pub const SAVED_MAX = INFINITY; | ||
| 1691 | pub const SAVED_CUR = INFINITY; | ||
| 1692 | }, | ||
| 1693 | .solaris, .illumos => struct { | ||
| 1694 | /// No limit | ||
| 1695 | pub const INFINITY: rlim_t = (1 << 63) - 3; | ||
| 1696 | pub const SAVED_MAX: rlim_t = (1 << 63) - 2; | ||
| 1697 | pub const SAVED_CUR: rlim_t = (1 << 63) - 1; | ||
| 1698 | }, | ||
| 1699 | else => void, | ||
| 1700 | }; | ||
| 1701 | pub const S = switch (native_os) { | ||
| 1702 | .linux => linux.S, | ||
| 1703 | .emscripten => emscripten.S, | ||
| 1704 | .wasi => struct { | ||
| 1705 | pub const IEXEC = @compileError("TODO audit this"); | ||
| 1706 | pub const IFBLK = 0x6000; | ||
| 1707 | pub const IFCHR = 0x2000; | ||
| 1708 | pub const IFDIR = 0x4000; | ||
| 1709 | pub const IFIFO = 0xc000; | ||
| 1710 | pub const IFLNK = 0xa000; | ||
| 1711 | pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK; | ||
| 1712 | pub const IFREG = 0x8000; | ||
| 1713 | /// There's no concept of UNIX domain socket but we define this value here | ||
| 1714 | /// in order to line with other OSes. | ||
| 1715 | pub const IFSOCK = 0x1; | ||
| 1716 | }, | ||
| 1717 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 1718 | pub const IFMT = 0o170000; | ||
| 1719 | |||
| 1720 | pub const IFIFO = 0o010000; | ||
| 1721 | pub const IFCHR = 0o020000; | ||
| 1722 | pub const IFDIR = 0o040000; | ||
| 1723 | pub const IFBLK = 0o060000; | ||
| 1724 | pub const IFREG = 0o100000; | ||
| 1725 | pub const IFLNK = 0o120000; | ||
| 1726 | pub const IFSOCK = 0o140000; | ||
| 1727 | pub const IFWHT = 0o160000; | ||
| 1728 | |||
| 1729 | pub const ISUID = 0o4000; | ||
| 1730 | pub const ISGID = 0o2000; | ||
| 1731 | pub const ISVTX = 0o1000; | ||
| 1732 | pub const IRWXU = 0o700; | ||
| 1733 | pub const IRUSR = 0o400; | ||
| 1734 | pub const IWUSR = 0o200; | ||
| 1735 | pub const IXUSR = 0o100; | ||
| 1736 | pub const IRWXG = 0o070; | ||
| 1737 | pub const IRGRP = 0o040; | ||
| 1738 | pub const IWGRP = 0o020; | ||
| 1739 | pub const IXGRP = 0o010; | ||
| 1740 | pub const IRWXO = 0o007; | ||
| 1741 | pub const IROTH = 0o004; | ||
| 1742 | pub const IWOTH = 0o002; | ||
| 1743 | pub const IXOTH = 0o001; | ||
| 1744 | |||
| 1745 | pub fn ISFIFO(m: u32) bool { | ||
| 1746 | return m & IFMT == IFIFO; | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | pub fn ISCHR(m: u32) bool { | ||
| 1750 | return m & IFMT == IFCHR; | ||
| 1751 | } | ||
| 1752 | |||
| 1753 | pub fn ISDIR(m: u32) bool { | ||
| 1754 | return m & IFMT == IFDIR; | ||
| 1755 | } | ||
| 1756 | |||
| 1757 | pub fn ISBLK(m: u32) bool { | ||
| 1758 | return m & IFMT == IFBLK; | ||
| 1759 | } | ||
| 1760 | |||
| 1761 | pub fn ISREG(m: u32) bool { | ||
| 1762 | return m & IFMT == IFREG; | ||
| 1763 | } | ||
| 1764 | |||
| 1765 | pub fn ISLNK(m: u32) bool { | ||
| 1766 | return m & IFMT == IFLNK; | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | pub fn ISSOCK(m: u32) bool { | ||
| 1770 | return m & IFMT == IFSOCK; | ||
| 1771 | } | ||
| 1772 | |||
| 1773 | pub fn IWHT(m: u32) bool { | ||
| 1774 | return m & IFMT == IFWHT; | ||
| 1775 | } | ||
| 1776 | }, | ||
| 1777 | .freebsd, .kfreebsd => struct { | ||
| 1778 | pub const IFMT = 0o170000; | ||
| 1779 | |||
| 1780 | pub const IFIFO = 0o010000; | ||
| 1781 | pub const IFCHR = 0o020000; | ||
| 1782 | pub const IFDIR = 0o040000; | ||
| 1783 | pub const IFBLK = 0o060000; | ||
| 1784 | pub const IFREG = 0o100000; | ||
| 1785 | pub const IFLNK = 0o120000; | ||
| 1786 | pub const IFSOCK = 0o140000; | ||
| 1787 | pub const IFWHT = 0o160000; | ||
| 1788 | |||
| 1789 | pub const ISUID = 0o4000; | ||
| 1790 | pub const ISGID = 0o2000; | ||
| 1791 | pub const ISVTX = 0o1000; | ||
| 1792 | pub const IRWXU = 0o700; | ||
| 1793 | pub const IRUSR = 0o400; | ||
| 1794 | pub const IWUSR = 0o200; | ||
| 1795 | pub const IXUSR = 0o100; | ||
| 1796 | pub const IRWXG = 0o070; | ||
| 1797 | pub const IRGRP = 0o040; | ||
| 1798 | pub const IWGRP = 0o020; | ||
| 1799 | pub const IXGRP = 0o010; | ||
| 1800 | pub const IRWXO = 0o007; | ||
| 1801 | pub const IROTH = 0o004; | ||
| 1802 | pub const IWOTH = 0o002; | ||
| 1803 | pub const IXOTH = 0o001; | ||
| 1804 | |||
| 1805 | pub fn ISFIFO(m: u32) bool { | ||
| 1806 | return m & IFMT == IFIFO; | ||
| 1807 | } | ||
| 1808 | |||
| 1809 | pub fn ISCHR(m: u32) bool { | ||
| 1810 | return m & IFMT == IFCHR; | ||
| 1811 | } | ||
| 1812 | |||
| 1813 | pub fn ISDIR(m: u32) bool { | ||
| 1814 | return m & IFMT == IFDIR; | ||
| 1815 | } | ||
| 1816 | |||
| 1817 | pub fn ISBLK(m: u32) bool { | ||
| 1818 | return m & IFMT == IFBLK; | ||
| 1819 | } | ||
| 1820 | |||
| 1821 | pub fn ISREG(m: u32) bool { | ||
| 1822 | return m & IFMT == IFREG; | ||
| 1823 | } | ||
| 1824 | |||
| 1825 | pub fn ISLNK(m: u32) bool { | ||
| 1826 | return m & IFMT == IFLNK; | ||
| 1827 | } | ||
| 1828 | |||
| 1829 | pub fn ISSOCK(m: u32) bool { | ||
| 1830 | return m & IFMT == IFSOCK; | ||
| 1831 | } | ||
| 1832 | |||
| 1833 | pub fn IWHT(m: u32) bool { | ||
| 1834 | return m & IFMT == IFWHT; | ||
| 1835 | } | ||
| 1836 | }, | ||
| 1837 | .solaris, .illumos => struct { | ||
| 1838 | pub const IFMT = 0o170000; | ||
| 1839 | |||
| 1840 | pub const IFIFO = 0o010000; | ||
| 1841 | pub const IFCHR = 0o020000; | ||
| 1842 | pub const IFDIR = 0o040000; | ||
| 1843 | pub const IFBLK = 0o060000; | ||
| 1844 | pub const IFREG = 0o100000; | ||
| 1845 | pub const IFLNK = 0o120000; | ||
| 1846 | pub const IFSOCK = 0o140000; | ||
| 1847 | /// SunOS 2.6 Door | ||
| 1848 | pub const IFDOOR = 0o150000; | ||
| 1849 | /// Solaris 10 Event Port | ||
| 1850 | pub const IFPORT = 0o160000; | ||
| 1851 | |||
| 1852 | pub const ISUID = 0o4000; | ||
| 1853 | pub const ISGID = 0o2000; | ||
| 1854 | pub const ISVTX = 0o1000; | ||
| 1855 | pub const IRWXU = 0o700; | ||
| 1856 | pub const IRUSR = 0o400; | ||
| 1857 | pub const IWUSR = 0o200; | ||
| 1858 | pub const IXUSR = 0o100; | ||
| 1859 | pub const IRWXG = 0o070; | ||
| 1860 | pub const IRGRP = 0o040; | ||
| 1861 | pub const IWGRP = 0o020; | ||
| 1862 | pub const IXGRP = 0o010; | ||
| 1863 | pub const IRWXO = 0o007; | ||
| 1864 | pub const IROTH = 0o004; | ||
| 1865 | pub const IWOTH = 0o002; | ||
| 1866 | pub const IXOTH = 0o001; | ||
| 1867 | |||
| 1868 | pub fn ISFIFO(m: u32) bool { | ||
| 1869 | return m & IFMT == IFIFO; | ||
| 1870 | } | ||
| 1871 | |||
| 1872 | pub fn ISCHR(m: u32) bool { | ||
| 1873 | return m & IFMT == IFCHR; | ||
| 1874 | } | ||
| 1875 | |||
| 1876 | pub fn ISDIR(m: u32) bool { | ||
| 1877 | return m & IFMT == IFDIR; | ||
| 1878 | } | ||
| 1879 | |||
| 1880 | pub fn ISBLK(m: u32) bool { | ||
| 1881 | return m & IFMT == IFBLK; | ||
| 1882 | } | ||
| 1883 | |||
| 1884 | pub fn ISREG(m: u32) bool { | ||
| 1885 | return m & IFMT == IFREG; | ||
| 1886 | } | ||
| 1887 | |||
| 1888 | pub fn ISLNK(m: u32) bool { | ||
| 1889 | return m & IFMT == IFLNK; | ||
| 1890 | } | ||
| 1891 | |||
| 1892 | pub fn ISSOCK(m: u32) bool { | ||
| 1893 | return m & IFMT == IFSOCK; | ||
| 1894 | } | ||
| 1895 | |||
| 1896 | pub fn ISDOOR(m: u32) bool { | ||
| 1897 | return m & IFMT == IFDOOR; | ||
| 1898 | } | ||
| 1899 | |||
| 1900 | pub fn ISPORT(m: u32) bool { | ||
| 1901 | return m & IFMT == IFPORT; | ||
| 1902 | } | ||
| 1903 | }, | ||
| 1904 | .netbsd => struct { | ||
| 1905 | pub const IFMT = 0o170000; | ||
| 1906 | |||
| 1907 | pub const IFIFO = 0o010000; | ||
| 1908 | pub const IFCHR = 0o020000; | ||
| 1909 | pub const IFDIR = 0o040000; | ||
| 1910 | pub const IFBLK = 0o060000; | ||
| 1911 | pub const IFREG = 0o100000; | ||
| 1912 | pub const IFLNK = 0o120000; | ||
| 1913 | pub const IFSOCK = 0o140000; | ||
| 1914 | pub const IFWHT = 0o160000; | ||
| 1915 | |||
| 1916 | pub const ISUID = 0o4000; | ||
| 1917 | pub const ISGID = 0o2000; | ||
| 1918 | pub const ISVTX = 0o1000; | ||
| 1919 | pub const IRWXU = 0o700; | ||
| 1920 | pub const IRUSR = 0o400; | ||
| 1921 | pub const IWUSR = 0o200; | ||
| 1922 | pub const IXUSR = 0o100; | ||
| 1923 | pub const IRWXG = 0o070; | ||
| 1924 | pub const IRGRP = 0o040; | ||
| 1925 | pub const IWGRP = 0o020; | ||
| 1926 | pub const IXGRP = 0o010; | ||
| 1927 | pub const IRWXO = 0o007; | ||
| 1928 | pub const IROTH = 0o004; | ||
| 1929 | pub const IWOTH = 0o002; | ||
| 1930 | pub const IXOTH = 0o001; | ||
| 1931 | |||
| 1932 | pub fn ISFIFO(m: u32) bool { | ||
| 1933 | return m & IFMT == IFIFO; | ||
| 1934 | } | ||
| 1935 | |||
| 1936 | pub fn ISCHR(m: u32) bool { | ||
| 1937 | return m & IFMT == IFCHR; | ||
| 1938 | } | ||
| 1939 | |||
| 1940 | pub fn ISDIR(m: u32) bool { | ||
| 1941 | return m & IFMT == IFDIR; | ||
| 1942 | } | ||
| 1943 | |||
| 1944 | pub fn ISBLK(m: u32) bool { | ||
| 1945 | return m & IFMT == IFBLK; | ||
| 1946 | } | ||
| 1947 | |||
| 1948 | pub fn ISREG(m: u32) bool { | ||
| 1949 | return m & IFMT == IFREG; | ||
| 1950 | } | ||
| 1951 | |||
| 1952 | pub fn ISLNK(m: u32) bool { | ||
| 1953 | return m & IFMT == IFLNK; | ||
| 1954 | } | ||
| 1955 | |||
| 1956 | pub fn ISSOCK(m: u32) bool { | ||
| 1957 | return m & IFMT == IFSOCK; | ||
| 1958 | } | ||
| 1959 | |||
| 1960 | pub fn IWHT(m: u32) bool { | ||
| 1961 | return m & IFMT == IFWHT; | ||
| 1962 | } | ||
| 1963 | }, | ||
| 1964 | .dragonfly => struct { | ||
| 1965 | pub const IREAD = IRUSR; | ||
| 1966 | pub const IEXEC = IXUSR; | ||
| 1967 | pub const IWRITE = IWUSR; | ||
| 1968 | pub const IXOTH = 1; | ||
| 1969 | pub const IWOTH = 2; | ||
| 1970 | pub const IROTH = 4; | ||
| 1971 | pub const IRWXO = 7; | ||
| 1972 | pub const IXGRP = 8; | ||
| 1973 | pub const IWGRP = 16; | ||
| 1974 | pub const IRGRP = 32; | ||
| 1975 | pub const IRWXG = 56; | ||
| 1976 | pub const IXUSR = 64; | ||
| 1977 | pub const IWUSR = 128; | ||
| 1978 | pub const IRUSR = 256; | ||
| 1979 | pub const IRWXU = 448; | ||
| 1980 | pub const ISTXT = 512; | ||
| 1981 | pub const BLKSIZE = 512; | ||
| 1982 | pub const ISVTX = 512; | ||
| 1983 | pub const ISGID = 1024; | ||
| 1984 | pub const ISUID = 2048; | ||
| 1985 | pub const IFIFO = 4096; | ||
| 1986 | pub const IFCHR = 8192; | ||
| 1987 | pub const IFDIR = 16384; | ||
| 1988 | pub const IFBLK = 24576; | ||
| 1989 | pub const IFREG = 32768; | ||
| 1990 | pub const IFDB = 36864; | ||
| 1991 | pub const IFLNK = 40960; | ||
| 1992 | pub const IFSOCK = 49152; | ||
| 1993 | pub const IFWHT = 57344; | ||
| 1994 | pub const IFMT = 61440; | ||
| 1995 | |||
| 1996 | pub fn ISCHR(m: u32) bool { | ||
| 1997 | return m & IFMT == IFCHR; | ||
| 1998 | } | ||
| 1999 | }, | ||
| 2000 | .haiku => struct { | ||
| 2001 | pub const IFMT = 0o170000; | ||
| 2002 | pub const IFSOCK = 0o140000; | ||
| 2003 | pub const IFLNK = 0o120000; | ||
| 2004 | pub const IFREG = 0o100000; | ||
| 2005 | pub const IFBLK = 0o060000; | ||
| 2006 | pub const IFDIR = 0o040000; | ||
| 2007 | pub const IFCHR = 0o020000; | ||
| 2008 | pub const IFIFO = 0o010000; | ||
| 2009 | pub const INDEX_DIR = 0o4000000000; | ||
| 2010 | |||
| 2011 | pub const IUMSK = 0o7777; | ||
| 2012 | pub const ISUID = 0o4000; | ||
| 2013 | pub const ISGID = 0o2000; | ||
| 2014 | pub const ISVTX = 0o1000; | ||
| 2015 | pub const IRWXU = 0o700; | ||
| 2016 | pub const IRUSR = 0o400; | ||
| 2017 | pub const IWUSR = 0o200; | ||
| 2018 | pub const IXUSR = 0o100; | ||
| 2019 | pub const IRWXG = 0o070; | ||
| 2020 | pub const IRGRP = 0o040; | ||
| 2021 | pub const IWGRP = 0o020; | ||
| 2022 | pub const IXGRP = 0o010; | ||
| 2023 | pub const IRWXO = 0o007; | ||
| 2024 | pub const IROTH = 0o004; | ||
| 2025 | pub const IWOTH = 0o002; | ||
| 2026 | pub const IXOTH = 0o001; | ||
| 2027 | |||
| 2028 | pub fn ISREG(m: u32) bool { | ||
| 2029 | return m & IFMT == IFREG; | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | pub fn ISLNK(m: u32) bool { | ||
| 2033 | return m & IFMT == IFLNK; | ||
| 2034 | } | ||
| 2035 | |||
| 2036 | pub fn ISBLK(m: u32) bool { | ||
| 2037 | return m & IFMT == IFBLK; | ||
| 2038 | } | ||
| 2039 | |||
| 2040 | pub fn ISDIR(m: u32) bool { | ||
| 2041 | return m & IFMT == IFDIR; | ||
| 2042 | } | ||
| 2043 | |||
| 2044 | pub fn ISCHR(m: u32) bool { | ||
| 2045 | return m & IFMT == IFCHR; | ||
| 2046 | } | ||
| 2047 | |||
| 2048 | pub fn ISFIFO(m: u32) bool { | ||
| 2049 | return m & IFMT == IFIFO; | ||
| 2050 | } | ||
| 2051 | |||
| 2052 | pub fn ISSOCK(m: u32) bool { | ||
| 2053 | return m & IFMT == IFSOCK; | ||
| 2054 | } | ||
| 2055 | |||
| 2056 | pub fn ISINDEX(m: u32) bool { | ||
| 2057 | return m & INDEX_DIR == INDEX_DIR; | ||
| 2058 | } | ||
| 2059 | }, | ||
| 2060 | .openbsd => struct { | ||
| 2061 | pub const IFMT = 0o170000; | ||
| 2062 | |||
| 2063 | pub const IFIFO = 0o010000; | ||
| 2064 | pub const IFCHR = 0o020000; | ||
| 2065 | pub const IFDIR = 0o040000; | ||
| 2066 | pub const IFBLK = 0o060000; | ||
| 2067 | pub const IFREG = 0o100000; | ||
| 2068 | pub const IFLNK = 0o120000; | ||
| 2069 | pub const IFSOCK = 0o140000; | ||
| 2070 | |||
| 2071 | pub const ISUID = 0o4000; | ||
| 2072 | pub const ISGID = 0o2000; | ||
| 2073 | pub const ISVTX = 0o1000; | ||
| 2074 | pub const IRWXU = 0o700; | ||
| 2075 | pub const IRUSR = 0o400; | ||
| 2076 | pub const IWUSR = 0o200; | ||
| 2077 | pub const IXUSR = 0o100; | ||
| 2078 | pub const IRWXG = 0o070; | ||
| 2079 | pub const IRGRP = 0o040; | ||
| 2080 | pub const IWGRP = 0o020; | ||
| 2081 | pub const IXGRP = 0o010; | ||
| 2082 | pub const IRWXO = 0o007; | ||
| 2083 | pub const IROTH = 0o004; | ||
| 2084 | pub const IWOTH = 0o002; | ||
| 2085 | pub const IXOTH = 0o001; | ||
| 2086 | |||
| 2087 | pub fn ISFIFO(m: u32) bool { | ||
| 2088 | return m & IFMT == IFIFO; | ||
| 2089 | } | ||
| 2090 | |||
| 2091 | pub fn ISCHR(m: u32) bool { | ||
| 2092 | return m & IFMT == IFCHR; | ||
| 2093 | } | ||
| 2094 | |||
| 2095 | pub fn ISDIR(m: u32) bool { | ||
| 2096 | return m & IFMT == IFDIR; | ||
| 2097 | } | ||
| 2098 | |||
| 2099 | pub fn ISBLK(m: u32) bool { | ||
| 2100 | return m & IFMT == IFBLK; | ||
| 2101 | } | ||
| 2102 | |||
| 2103 | pub fn ISREG(m: u32) bool { | ||
| 2104 | return m & IFMT == IFREG; | ||
| 2105 | } | ||
| 2106 | |||
| 2107 | pub fn ISLNK(m: u32) bool { | ||
| 2108 | return m & IFMT == IFLNK; | ||
| 2109 | } | ||
| 2110 | |||
| 2111 | pub fn ISSOCK(m: u32) bool { | ||
| 2112 | return m & IFMT == IFSOCK; | ||
| 2113 | } | ||
| 2114 | }, | ||
| 2115 | else => void, | ||
| 2116 | }; | ||
| 2117 | pub const SA = switch (native_os) { | ||
| 2118 | .linux => linux.SA, | ||
| 2119 | .emscripten => emscripten.SA, | ||
| 2120 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 2121 | /// take signal on signal stack | ||
| 2122 | pub const ONSTACK = 0x0001; | ||
| 2123 | /// restart system on signal return | ||
| 2124 | pub const RESTART = 0x0002; | ||
| 2125 | /// reset to SIG.DFL when taking signal | ||
| 2126 | pub const RESETHAND = 0x0004; | ||
| 2127 | /// do not generate SIG.CHLD on child stop | ||
| 2128 | pub const NOCLDSTOP = 0x0008; | ||
| 2129 | /// don't mask the signal we're delivering | ||
| 2130 | pub const NODEFER = 0x0010; | ||
| 2131 | /// don't keep zombies around | ||
| 2132 | pub const NOCLDWAIT = 0x0020; | ||
| 2133 | /// signal handler with SIGINFO args | ||
| 2134 | pub const SIGINFO = 0x0040; | ||
| 2135 | /// do not bounce off kernel's sigtramp | ||
| 2136 | pub const USERTRAMP = 0x0100; | ||
| 2137 | /// signal handler with SIGINFO args with 64bit regs information | ||
| 2138 | pub const @"64REGSET" = 0x0200; | ||
| 2139 | }, | ||
| 2140 | .freebsd, .kfreebsd => struct { | ||
| 2141 | pub const ONSTACK = 0x0001; | ||
| 2142 | pub const RESTART = 0x0002; | ||
| 2143 | pub const RESETHAND = 0x0004; | ||
| 2144 | pub const NOCLDSTOP = 0x0008; | ||
| 2145 | pub const NODEFER = 0x0010; | ||
| 2146 | pub const NOCLDWAIT = 0x0020; | ||
| 2147 | pub const SIGINFO = 0x0040; | ||
| 2148 | }, | ||
| 2149 | .solaris, .illumos => struct { | ||
| 2150 | pub const ONSTACK = 0x00000001; | ||
| 2151 | pub const RESETHAND = 0x00000002; | ||
| 2152 | pub const RESTART = 0x00000004; | ||
| 2153 | pub const SIGINFO = 0x00000008; | ||
| 2154 | pub const NODEFER = 0x00000010; | ||
| 2155 | pub const NOCLDWAIT = 0x00010000; | ||
| 2156 | }, | ||
| 2157 | .netbsd => struct { | ||
| 2158 | pub const ONSTACK = 0x0001; | ||
| 2159 | pub const RESTART = 0x0002; | ||
| 2160 | pub const RESETHAND = 0x0004; | ||
| 2161 | pub const NOCLDSTOP = 0x0008; | ||
| 2162 | pub const NODEFER = 0x0010; | ||
| 2163 | pub const NOCLDWAIT = 0x0020; | ||
| 2164 | pub const SIGINFO = 0x0040; | ||
| 2165 | }, | ||
| 2166 | .dragonfly => struct { | ||
| 2167 | pub const ONSTACK = 0x0001; | ||
| 2168 | pub const RESTART = 0x0002; | ||
| 2169 | pub const RESETHAND = 0x0004; | ||
| 2170 | pub const NODEFER = 0x0010; | ||
| 2171 | pub const NOCLDWAIT = 0x0020; | ||
| 2172 | pub const SIGINFO = 0x0040; | ||
| 2173 | }, | ||
| 2174 | .haiku => struct { | ||
| 2175 | pub const NOCLDSTOP = 0x01; | ||
| 2176 | pub const NOCLDWAIT = 0x02; | ||
| 2177 | pub const RESETHAND = 0x04; | ||
| 2178 | pub const NODEFER = 0x08; | ||
| 2179 | pub const RESTART = 0x10; | ||
| 2180 | pub const ONSTACK = 0x20; | ||
| 2181 | pub const SIGINFO = 0x40; | ||
| 2182 | pub const NOMASK = NODEFER; | ||
| 2183 | pub const STACK = ONSTACK; | ||
| 2184 | pub const ONESHOT = RESETHAND; | ||
| 2185 | }, | ||
| 2186 | .openbsd => struct { | ||
| 2187 | pub const ONSTACK = 0x0001; | ||
| 2188 | pub const RESTART = 0x0002; | ||
| 2189 | pub const RESETHAND = 0x0004; | ||
| 2190 | pub const NOCLDSTOP = 0x0008; | ||
| 2191 | pub const NODEFER = 0x0010; | ||
| 2192 | pub const NOCLDWAIT = 0x0020; | ||
| 2193 | pub const SIGINFO = 0x0040; | ||
| 2194 | }, | ||
| 2195 | else => void, | ||
| 2196 | }; | ||
| 2197 | pub const sigval_t = switch (native_os) { | ||
| 2198 | .netbsd, .solaris, .illumos => extern union { | ||
| 2199 | int: i32, | ||
| 2200 | ptr: ?*anyopaque, | ||
| 2201 | }, | ||
| 2202 | else => void, | ||
| 2203 | }; | ||
| 2204 | |||
| 2205 | pub const SC = switch (native_os) { | ||
| 2206 | .linux => linux.SC, | ||
| 2207 | else => void, | ||
| 2208 | }; | ||
| 2209 | pub const SEEK = switch (native_os) { | ||
| 2210 | .linux => linux.SEEK, | ||
| 2211 | .emscripten => emscripten.SEEK, | ||
| 2212 | .wasi => struct { | ||
| 2213 | pub const SET: wasi.whence_t = .SET; | ||
| 2214 | pub const CUR: wasi.whence_t = .CUR; | ||
| 2215 | pub const END: wasi.whence_t = .END; | ||
| 2216 | }, | ||
| 2217 | .openbsd, .haiku, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos, .windows => struct { | ||
| 2218 | pub const SET = 0; | ||
| 2219 | pub const CUR = 1; | ||
| 2220 | pub const END = 2; | ||
| 2221 | }, | ||
| 2222 | .dragonfly, .solaris, .illumos => struct { | ||
| 2223 | pub const SET = 0; | ||
| 2224 | pub const CUR = 1; | ||
| 2225 | pub const END = 2; | ||
| 2226 | pub const DATA = 3; | ||
| 2227 | pub const HOLE = 4; | ||
| 2228 | }, | ||
| 2229 | else => void, | ||
| 2230 | }; | ||
| 2231 | pub const SHUT = switch (native_os) { | ||
| 2232 | .linux => linux.SHUT, | ||
| 2233 | .emscripten => emscripten.SHUT, | ||
| 2234 | else => struct { | ||
| 2235 | pub const RD = 0; | ||
| 2236 | pub const WR = 1; | ||
| 2237 | pub const RDWR = 2; | ||
| 2238 | }, | ||
| 2239 | }; | ||
| 2240 | |||
| 2241 | /// Signal types | ||
| 2242 | pub const SIG = switch (native_os) { | ||
| 2243 | .linux => linux.SIG, | ||
| 2244 | .emscripten => emscripten.SIG, | ||
| 2245 | .windows => struct { | ||
| 2246 | /// interrupt | ||
| 2247 | pub const INT = 2; | ||
| 2248 | /// illegal instruction - invalid function image | ||
| 2249 | pub const ILL = 4; | ||
| 2250 | /// floating point exception | ||
| 2251 | pub const FPE = 8; | ||
| 2252 | /// segment violation | ||
| 2253 | pub const SEGV = 11; | ||
| 2254 | /// Software termination signal from kill | ||
| 2255 | pub const TERM = 15; | ||
| 2256 | /// Ctrl-Break sequence | ||
| 2257 | pub const BREAK = 21; | ||
| 2258 | /// abnormal termination triggered by abort call | ||
| 2259 | pub const ABRT = 22; | ||
| 2260 | /// SIGABRT compatible with other platforms, same as SIGABRT | ||
| 2261 | pub const ABRT_COMPAT = 6; | ||
| 2262 | |||
| 2263 | // Signal action codes | ||
| 2264 | /// default signal action | ||
| 2265 | pub const DFL = 0; | ||
| 2266 | /// ignore signal | ||
| 2267 | pub const IGN = 1; | ||
| 2268 | /// return current value | ||
| 2269 | pub const GET = 2; | ||
| 2270 | /// signal gets error | ||
| 2271 | pub const SGE = 3; | ||
| 2272 | /// acknowledge | ||
| 2273 | pub const ACK = 4; | ||
| 2274 | /// Signal error value (returned by signal call on error) | ||
| 2275 | pub const ERR = -1; | ||
| 2276 | }, | ||
| 2277 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 2278 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2279 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2280 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2281 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(5); | ||
| 2282 | |||
| 2283 | /// block specified signal set | ||
| 2284 | pub const BLOCK = 1; | ||
| 2285 | /// unblock specified signal set | ||
| 2286 | pub const UNBLOCK = 2; | ||
| 2287 | /// set specified signal set | ||
| 2288 | pub const SETMASK = 3; | ||
| 2289 | /// hangup | ||
| 2290 | pub const HUP = 1; | ||
| 2291 | /// interrupt | ||
| 2292 | pub const INT = 2; | ||
| 2293 | /// quit | ||
| 2294 | pub const QUIT = 3; | ||
| 2295 | /// illegal instruction (not reset when caught) | ||
| 2296 | pub const ILL = 4; | ||
| 2297 | /// trace trap (not reset when caught) | ||
| 2298 | pub const TRAP = 5; | ||
| 2299 | /// abort() | ||
| 2300 | pub const ABRT = 6; | ||
| 2301 | /// pollable event ([XSR] generated, not supported) | ||
| 2302 | pub const POLL = 7; | ||
| 2303 | /// compatibility | ||
| 2304 | pub const IOT = ABRT; | ||
| 2305 | /// EMT instruction | ||
| 2306 | pub const EMT = 7; | ||
| 2307 | /// floating point exception | ||
| 2308 | pub const FPE = 8; | ||
| 2309 | /// kill (cannot be caught or ignored) | ||
| 2310 | pub const KILL = 9; | ||
| 2311 | /// bus error | ||
| 2312 | pub const BUS = 10; | ||
| 2313 | /// segmentation violation | ||
| 2314 | pub const SEGV = 11; | ||
| 2315 | /// bad argument to system call | ||
| 2316 | pub const SYS = 12; | ||
| 2317 | /// write on a pipe with no one to read it | ||
| 2318 | pub const PIPE = 13; | ||
| 2319 | /// alarm clock | ||
| 2320 | pub const ALRM = 14; | ||
| 2321 | /// software termination signal from kill | ||
| 2322 | pub const TERM = 15; | ||
| 2323 | /// urgent condition on IO channel | ||
| 2324 | pub const URG = 16; | ||
| 2325 | /// sendable stop signal not from tty | ||
| 2326 | pub const STOP = 17; | ||
| 2327 | /// stop signal from tty | ||
| 2328 | pub const TSTP = 18; | ||
| 2329 | /// continue a stopped process | ||
| 2330 | pub const CONT = 19; | ||
| 2331 | /// to parent on child stop or exit | ||
| 2332 | pub const CHLD = 20; | ||
| 2333 | /// to readers pgrp upon background tty read | ||
| 2334 | pub const TTIN = 21; | ||
| 2335 | /// like TTIN for output if (tp->t_local&LTOSTOP) | ||
| 2336 | pub const TTOU = 22; | ||
| 2337 | /// input/output possible signal | ||
| 2338 | pub const IO = 23; | ||
| 2339 | /// exceeded CPU time limit | ||
| 2340 | pub const XCPU = 24; | ||
| 2341 | /// exceeded file size limit | ||
| 2342 | pub const XFSZ = 25; | ||
| 2343 | /// virtual time alarm | ||
| 2344 | pub const VTALRM = 26; | ||
| 2345 | /// profiling time alarm | ||
| 2346 | pub const PROF = 27; | ||
| 2347 | /// window size changes | ||
| 2348 | pub const WINCH = 28; | ||
| 2349 | /// information request | ||
| 2350 | pub const INFO = 29; | ||
| 2351 | /// user defined signal 1 | ||
| 2352 | pub const USR1 = 30; | ||
| 2353 | /// user defined signal 2 | ||
| 2354 | pub const USR2 = 31; | ||
| 2355 | }, | ||
| 2356 | .freebsd, .kfreebsd => struct { | ||
| 2357 | pub const HUP = 1; | ||
| 2358 | pub const INT = 2; | ||
| 2359 | pub const QUIT = 3; | ||
| 2360 | pub const ILL = 4; | ||
| 2361 | pub const TRAP = 5; | ||
| 2362 | pub const ABRT = 6; | ||
| 2363 | pub const IOT = ABRT; | ||
| 2364 | pub const EMT = 7; | ||
| 2365 | pub const FPE = 8; | ||
| 2366 | pub const KILL = 9; | ||
| 2367 | pub const BUS = 10; | ||
| 2368 | pub const SEGV = 11; | ||
| 2369 | pub const SYS = 12; | ||
| 2370 | pub const PIPE = 13; | ||
| 2371 | pub const ALRM = 14; | ||
| 2372 | pub const TERM = 15; | ||
| 2373 | pub const URG = 16; | ||
| 2374 | pub const STOP = 17; | ||
| 2375 | pub const TSTP = 18; | ||
| 2376 | pub const CONT = 19; | ||
| 2377 | pub const CHLD = 20; | ||
| 2378 | pub const TTIN = 21; | ||
| 2379 | pub const TTOU = 22; | ||
| 2380 | pub const IO = 23; | ||
| 2381 | pub const XCPU = 24; | ||
| 2382 | pub const XFSZ = 25; | ||
| 2383 | pub const VTALRM = 26; | ||
| 2384 | pub const PROF = 27; | ||
| 2385 | pub const WINCH = 28; | ||
| 2386 | pub const INFO = 29; | ||
| 2387 | pub const USR1 = 30; | ||
| 2388 | pub const USR2 = 31; | ||
| 2389 | pub const THR = 32; | ||
| 2390 | pub const LWP = THR; | ||
| 2391 | pub const LIBRT = 33; | ||
| 2392 | |||
| 2393 | pub const RTMIN = 65; | ||
| 2394 | pub const RTMAX = 126; | ||
| 2395 | |||
| 2396 | pub const BLOCK = 1; | ||
| 2397 | pub const UNBLOCK = 2; | ||
| 2398 | pub const SETMASK = 3; | ||
| 2399 | |||
| 2400 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2401 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2402 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2403 | |||
| 2404 | pub const WORDS = 4; | ||
| 2405 | pub const MAXSIG = 128; | ||
| 2406 | |||
| 2407 | pub inline fn IDX(sig: usize) usize { | ||
| 2408 | return sig - 1; | ||
| 2409 | } | ||
| 2410 | pub inline fn WORD(sig: usize) usize { | ||
| 2411 | return IDX(sig) >> 5; | ||
| 2412 | } | ||
| 2413 | pub inline fn BIT(sig: usize) usize { | ||
| 2414 | return 1 << (IDX(sig) & 31); | ||
| 2415 | } | ||
| 2416 | pub inline fn VALID(sig: usize) usize { | ||
| 2417 | return sig <= MAXSIG and sig > 0; | ||
| 2418 | } | ||
| 2419 | }, | ||
| 2420 | .solaris, .illumos => struct { | ||
| 2421 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2422 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2423 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2424 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(2); | ||
| 2425 | |||
| 2426 | pub const WORDS = 4; | ||
| 2427 | pub const MAXSIG = 75; | ||
| 2428 | |||
| 2429 | pub const SIG_BLOCK = 1; | ||
| 2430 | pub const SIG_UNBLOCK = 2; | ||
| 2431 | pub const SIG_SETMASK = 3; | ||
| 2432 | |||
| 2433 | pub const HUP = 1; | ||
| 2434 | pub const INT = 2; | ||
| 2435 | pub const QUIT = 3; | ||
| 2436 | pub const ILL = 4; | ||
| 2437 | pub const TRAP = 5; | ||
| 2438 | pub const IOT = 6; | ||
| 2439 | pub const ABRT = 6; | ||
| 2440 | pub const EMT = 7; | ||
| 2441 | pub const FPE = 8; | ||
| 2442 | pub const KILL = 9; | ||
| 2443 | pub const BUS = 10; | ||
| 2444 | pub const SEGV = 11; | ||
| 2445 | pub const SYS = 12; | ||
| 2446 | pub const PIPE = 13; | ||
| 2447 | pub const ALRM = 14; | ||
| 2448 | pub const TERM = 15; | ||
| 2449 | pub const USR1 = 16; | ||
| 2450 | pub const USR2 = 17; | ||
| 2451 | pub const CLD = 18; | ||
| 2452 | pub const CHLD = 18; | ||
| 2453 | pub const PWR = 19; | ||
| 2454 | pub const WINCH = 20; | ||
| 2455 | pub const URG = 21; | ||
| 2456 | pub const POLL = 22; | ||
| 2457 | pub const IO = .POLL; | ||
| 2458 | pub const STOP = 23; | ||
| 2459 | pub const TSTP = 24; | ||
| 2460 | pub const CONT = 25; | ||
| 2461 | pub const TTIN = 26; | ||
| 2462 | pub const TTOU = 27; | ||
| 2463 | pub const VTALRM = 28; | ||
| 2464 | pub const PROF = 29; | ||
| 2465 | pub const XCPU = 30; | ||
| 2466 | pub const XFSZ = 31; | ||
| 2467 | pub const WAITING = 32; | ||
| 2468 | pub const LWP = 33; | ||
| 2469 | pub const FREEZE = 34; | ||
| 2470 | pub const THAW = 35; | ||
| 2471 | pub const CANCEL = 36; | ||
| 2472 | pub const LOST = 37; | ||
| 2473 | pub const XRES = 38; | ||
| 2474 | pub const JVM1 = 39; | ||
| 2475 | pub const JVM2 = 40; | ||
| 2476 | pub const INFO = 41; | ||
| 2477 | |||
| 2478 | pub const RTMIN = 42; | ||
| 2479 | pub const RTMAX = 74; | ||
| 2480 | |||
| 2481 | pub inline fn IDX(sig: usize) usize { | ||
| 2482 | return sig - 1; | ||
| 2483 | } | ||
| 2484 | pub inline fn WORD(sig: usize) usize { | ||
| 2485 | return IDX(sig) >> 5; | ||
| 2486 | } | ||
| 2487 | pub inline fn BIT(sig: usize) usize { | ||
| 2488 | return 1 << (IDX(sig) & 31); | ||
| 2489 | } | ||
| 2490 | pub inline fn VALID(sig: usize) usize { | ||
| 2491 | return sig <= MAXSIG and sig > 0; | ||
| 2492 | } | ||
| 2493 | }, | ||
| 2494 | .netbsd => struct { | ||
| 2495 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2496 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2497 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2498 | |||
| 2499 | pub const WORDS = 4; | ||
| 2500 | pub const MAXSIG = 128; | ||
| 2501 | |||
| 2502 | pub const BLOCK = 1; | ||
| 2503 | pub const UNBLOCK = 2; | ||
| 2504 | pub const SETMASK = 3; | ||
| 2505 | |||
| 2506 | pub const HUP = 1; | ||
| 2507 | pub const INT = 2; | ||
| 2508 | pub const QUIT = 3; | ||
| 2509 | pub const ILL = 4; | ||
| 2510 | pub const TRAP = 5; | ||
| 2511 | pub const ABRT = 6; | ||
| 2512 | pub const IOT = ABRT; | ||
| 2513 | pub const EMT = 7; | ||
| 2514 | pub const FPE = 8; | ||
| 2515 | pub const KILL = 9; | ||
| 2516 | pub const BUS = 10; | ||
| 2517 | pub const SEGV = 11; | ||
| 2518 | pub const SYS = 12; | ||
| 2519 | pub const PIPE = 13; | ||
| 2520 | pub const ALRM = 14; | ||
| 2521 | pub const TERM = 15; | ||
| 2522 | pub const URG = 16; | ||
| 2523 | pub const STOP = 17; | ||
| 2524 | pub const TSTP = 18; | ||
| 2525 | pub const CONT = 19; | ||
| 2526 | pub const CHLD = 20; | ||
| 2527 | pub const TTIN = 21; | ||
| 2528 | pub const TTOU = 22; | ||
| 2529 | pub const IO = 23; | ||
| 2530 | pub const XCPU = 24; | ||
| 2531 | pub const XFSZ = 25; | ||
| 2532 | pub const VTALRM = 26; | ||
| 2533 | pub const PROF = 27; | ||
| 2534 | pub const WINCH = 28; | ||
| 2535 | pub const INFO = 29; | ||
| 2536 | pub const USR1 = 30; | ||
| 2537 | pub const USR2 = 31; | ||
| 2538 | pub const PWR = 32; | ||
| 2539 | |||
| 2540 | pub const RTMIN = 33; | ||
| 2541 | pub const RTMAX = 63; | ||
| 2542 | |||
| 2543 | pub inline fn IDX(sig: usize) usize { | ||
| 2544 | return sig - 1; | ||
| 2545 | } | ||
| 2546 | pub inline fn WORD(sig: usize) usize { | ||
| 2547 | return IDX(sig) >> 5; | ||
| 2548 | } | ||
| 2549 | pub inline fn BIT(sig: usize) usize { | ||
| 2550 | return 1 << (IDX(sig) & 31); | ||
| 2551 | } | ||
| 2552 | pub inline fn VALID(sig: usize) usize { | ||
| 2553 | return sig <= MAXSIG and sig > 0; | ||
| 2554 | } | ||
| 2555 | }, | ||
| 2556 | .dragonfly => struct { | ||
| 2557 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2558 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2559 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2560 | |||
| 2561 | pub const BLOCK = 1; | ||
| 2562 | pub const UNBLOCK = 2; | ||
| 2563 | pub const SETMASK = 3; | ||
| 2564 | |||
| 2565 | pub const IOT = ABRT; | ||
| 2566 | pub const HUP = 1; | ||
| 2567 | pub const INT = 2; | ||
| 2568 | pub const QUIT = 3; | ||
| 2569 | pub const ILL = 4; | ||
| 2570 | pub const TRAP = 5; | ||
| 2571 | pub const ABRT = 6; | ||
| 2572 | pub const EMT = 7; | ||
| 2573 | pub const FPE = 8; | ||
| 2574 | pub const KILL = 9; | ||
| 2575 | pub const BUS = 10; | ||
| 2576 | pub const SEGV = 11; | ||
| 2577 | pub const SYS = 12; | ||
| 2578 | pub const PIPE = 13; | ||
| 2579 | pub const ALRM = 14; | ||
| 2580 | pub const TERM = 15; | ||
| 2581 | pub const URG = 16; | ||
| 2582 | pub const STOP = 17; | ||
| 2583 | pub const TSTP = 18; | ||
| 2584 | pub const CONT = 19; | ||
| 2585 | pub const CHLD = 20; | ||
| 2586 | pub const TTIN = 21; | ||
| 2587 | pub const TTOU = 22; | ||
| 2588 | pub const IO = 23; | ||
| 2589 | pub const XCPU = 24; | ||
| 2590 | pub const XFSZ = 25; | ||
| 2591 | pub const VTALRM = 26; | ||
| 2592 | pub const PROF = 27; | ||
| 2593 | pub const WINCH = 28; | ||
| 2594 | pub const INFO = 29; | ||
| 2595 | pub const USR1 = 30; | ||
| 2596 | pub const USR2 = 31; | ||
| 2597 | pub const THR = 32; | ||
| 2598 | pub const CKPT = 33; | ||
| 2599 | pub const CKPTEXIT = 34; | ||
| 2600 | |||
| 2601 | pub const WORDS = 4; | ||
| 2602 | }, | ||
| 2603 | .haiku => struct { | ||
| 2604 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2605 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2606 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2607 | |||
| 2608 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); | ||
| 2609 | |||
| 2610 | pub const HUP = 1; | ||
| 2611 | pub const INT = 2; | ||
| 2612 | pub const QUIT = 3; | ||
| 2613 | pub const ILL = 4; | ||
| 2614 | pub const CHLD = 5; | ||
| 2615 | pub const ABRT = 6; | ||
| 2616 | pub const IOT = ABRT; | ||
| 2617 | pub const PIPE = 7; | ||
| 2618 | pub const FPE = 8; | ||
| 2619 | pub const KILL = 9; | ||
| 2620 | pub const STOP = 10; | ||
| 2621 | pub const SEGV = 11; | ||
| 2622 | pub const CONT = 12; | ||
| 2623 | pub const TSTP = 13; | ||
| 2624 | pub const ALRM = 14; | ||
| 2625 | pub const TERM = 15; | ||
| 2626 | pub const TTIN = 16; | ||
| 2627 | pub const TTOU = 17; | ||
| 2628 | pub const USR1 = 18; | ||
| 2629 | pub const USR2 = 19; | ||
| 2630 | pub const WINCH = 20; | ||
| 2631 | pub const KILLTHR = 21; | ||
| 2632 | pub const TRAP = 22; | ||
| 2633 | pub const POLL = 23; | ||
| 2634 | pub const PROF = 24; | ||
| 2635 | pub const SYS = 25; | ||
| 2636 | pub const URG = 26; | ||
| 2637 | pub const VTALRM = 27; | ||
| 2638 | pub const XCPU = 28; | ||
| 2639 | pub const XFSZ = 29; | ||
| 2640 | pub const BUS = 30; | ||
| 2641 | pub const RESERVED1 = 31; | ||
| 2642 | pub const RESERVED2 = 32; | ||
| 2643 | |||
| 2644 | pub const BLOCK = 1; | ||
| 2645 | pub const UNBLOCK = 2; | ||
| 2646 | pub const SETMASK = 3; | ||
| 2647 | }, | ||
| 2648 | .openbsd => struct { | ||
| 2649 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 2650 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 2651 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 2652 | pub const CATCH: ?Sigaction.handler_fn = @ptrFromInt(2); | ||
| 2653 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); | ||
| 2654 | |||
| 2655 | pub const HUP = 1; | ||
| 2656 | pub const INT = 2; | ||
| 2657 | pub const QUIT = 3; | ||
| 2658 | pub const ILL = 4; | ||
| 2659 | pub const TRAP = 5; | ||
| 2660 | pub const ABRT = 6; | ||
| 2661 | pub const IOT = ABRT; | ||
| 2662 | pub const EMT = 7; | ||
| 2663 | pub const FPE = 8; | ||
| 2664 | pub const KILL = 9; | ||
| 2665 | pub const BUS = 10; | ||
| 2666 | pub const SEGV = 11; | ||
| 2667 | pub const SYS = 12; | ||
| 2668 | pub const PIPE = 13; | ||
| 2669 | pub const ALRM = 14; | ||
| 2670 | pub const TERM = 15; | ||
| 2671 | pub const URG = 16; | ||
| 2672 | pub const STOP = 17; | ||
| 2673 | pub const TSTP = 18; | ||
| 2674 | pub const CONT = 19; | ||
| 2675 | pub const CHLD = 20; | ||
| 2676 | pub const TTIN = 21; | ||
| 2677 | pub const TTOU = 22; | ||
| 2678 | pub const IO = 23; | ||
| 2679 | pub const XCPU = 24; | ||
| 2680 | pub const XFSZ = 25; | ||
| 2681 | pub const VTALRM = 26; | ||
| 2682 | pub const PROF = 27; | ||
| 2683 | pub const WINCH = 28; | ||
| 2684 | pub const INFO = 29; | ||
| 2685 | pub const USR1 = 30; | ||
| 2686 | pub const USR2 = 31; | ||
| 2687 | pub const PWR = 32; | ||
| 2688 | |||
| 2689 | pub const BLOCK = 1; | ||
| 2690 | pub const UNBLOCK = 2; | ||
| 2691 | pub const SETMASK = 3; | ||
| 2692 | }, | ||
| 2693 | else => void, | ||
| 2694 | }; | ||
| 2695 | |||
| 2696 | pub const SIOCGIFINDEX = switch (native_os) { | ||
| 2697 | .linux => linux.SIOCGIFINDEX, | ||
| 2698 | .emscripten => emscripten.SIOCGIFINDEX, | ||
| 2699 | .solaris, .illumos => solaris.SIOCGLIFINDEX, | ||
| 2700 | else => void, | ||
| 2701 | }; | ||
| 2702 | |||
| 2703 | pub const STDIN_FILENO = switch (native_os) { | ||
| 2704 | .linux => linux.STDIN_FILENO, | ||
| 2705 | .emscripten => emscripten.STDIN_FILENO, | ||
| 2706 | else => 0, | ||
| 2707 | }; | ||
| 2708 | pub const STDOUT_FILENO = switch (native_os) { | ||
| 2709 | .linux => linux.STDOUT_FILENO, | ||
| 2710 | .emscripten => emscripten.STDOUT_FILENO, | ||
| 2711 | else => 1, | ||
| 2712 | }; | ||
| 2713 | pub const STDERR_FILENO = switch (native_os) { | ||
| 2714 | .linux => linux.STDERR_FILENO, | ||
| 2715 | .emscripten => emscripten.STDERR_FILENO, | ||
| 2716 | else => 2, | ||
| 2717 | }; | ||
| 2718 | |||
| 2719 | pub const SYS = switch (native_os) { | ||
| 2720 | .linux => linux.SYS, | ||
| 2721 | else => void, | ||
| 2722 | }; | ||
| 2723 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. | ||
| 2724 | pub const Sigaction = switch (native_os) { | ||
| 2725 | .linux => linux.Sigaction, | ||
| 2726 | .emscripten => emscripten.Sigaction, | ||
| 2727 | .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 2728 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 2729 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 2730 | |||
| 2731 | handler: extern union { | ||
| 2732 | handler: ?handler_fn, | ||
| 2733 | sigaction: ?sigaction_fn, | ||
| 2734 | }, | ||
| 2735 | mask: sigset_t, | ||
| 2736 | flags: c_uint, | ||
| 2737 | }, | ||
| 2738 | .dragonfly, .freebsd, .kfreebsd => extern struct { | ||
| 2739 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 2740 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 2741 | |||
| 2742 | /// signal handler | ||
| 2743 | handler: extern union { | ||
| 2744 | handler: ?handler_fn, | ||
| 2745 | sigaction: ?sigaction_fn, | ||
| 2746 | }, | ||
| 2747 | /// see signal options | ||
| 2748 | flags: c_uint, | ||
| 2749 | /// signal mask to apply | ||
| 2750 | mask: sigset_t, | ||
| 2751 | }, | ||
| 2752 | .solaris, .illumos => extern struct { | ||
| 2753 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 2754 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 2755 | |||
| 2756 | /// signal options | ||
| 2757 | flags: c_uint, | ||
| 2758 | /// signal handler | ||
| 2759 | handler: extern union { | ||
| 2760 | handler: ?handler_fn, | ||
| 2761 | sigaction: ?sigaction_fn, | ||
| 2762 | }, | ||
| 2763 | /// signal mask to apply | ||
| 2764 | mask: sigset_t, | ||
| 2765 | }, | ||
| 2766 | .haiku => extern struct { | ||
| 2767 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 2768 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 2769 | |||
| 2770 | /// signal handler | ||
| 2771 | handler: extern union { | ||
| 2772 | handler: handler_fn, | ||
| 2773 | sigaction: sigaction_fn, | ||
| 2774 | }, | ||
| 2775 | |||
| 2776 | /// signal mask to apply | ||
| 2777 | mask: sigset_t, | ||
| 2778 | |||
| 2779 | /// see signal options | ||
| 2780 | flags: i32, | ||
| 2781 | |||
| 2782 | /// will be passed to the signal handler, BeOS extension | ||
| 2783 | userdata: *allowzero anyopaque = undefined, | ||
| 2784 | }, | ||
| 2785 | .openbsd => extern struct { | ||
| 2786 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 2787 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 2788 | |||
| 2789 | /// signal handler | ||
| 2790 | handler: extern union { | ||
| 2791 | handler: ?handler_fn, | ||
| 2792 | sigaction: ?sigaction_fn, | ||
| 2793 | }, | ||
| 2794 | /// signal mask to apply | ||
| 2795 | mask: sigset_t, | ||
| 2796 | /// signal options | ||
| 2797 | flags: c_uint, | ||
| 2798 | }, | ||
| 2799 | else => void, | ||
| 2800 | }; | ||
| 2801 | pub const T = switch (native_os) { | ||
| 2802 | .linux => linux.T, | ||
| 2803 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 2804 | pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); | ||
| 2805 | |||
| 2806 | fn ior(inout: u32, group: usize, num: usize, len: usize) usize { | ||
| 2807 | return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)); | ||
| 2808 | } | ||
| 2809 | }, | ||
| 2810 | .freebsd, .kfreebsd => struct { | ||
| 2811 | pub const IOCEXCL = 0x2000740d; | ||
| 2812 | pub const IOCNXCL = 0x2000740e; | ||
| 2813 | pub const IOCSCTTY = 0x20007461; | ||
| 2814 | pub const IOCGPGRP = 0x40047477; | ||
| 2815 | pub const IOCSPGRP = 0x80047476; | ||
| 2816 | pub const IOCOUTQ = 0x40047473; | ||
| 2817 | pub const IOCSTI = 0x80017472; | ||
| 2818 | pub const IOCGWINSZ = 0x40087468; | ||
| 2819 | pub const IOCSWINSZ = 0x80087467; | ||
| 2820 | pub const IOCMGET = 0x4004746a; | ||
| 2821 | pub const IOCMBIS = 0x8004746c; | ||
| 2822 | pub const IOCMBIC = 0x8004746b; | ||
| 2823 | pub const IOCMSET = 0x8004746d; | ||
| 2824 | pub const FIONREAD = 0x4004667f; | ||
| 2825 | pub const IOCCONS = 0x80047462; | ||
| 2826 | pub const IOCPKT = 0x80047470; | ||
| 2827 | pub const FIONBIO = 0x8004667e; | ||
| 2828 | pub const IOCNOTTY = 0x20007471; | ||
| 2829 | pub const IOCSETD = 0x8004741b; | ||
| 2830 | pub const IOCGETD = 0x4004741a; | ||
| 2831 | pub const IOCSBRK = 0x2000747b; | ||
| 2832 | pub const IOCCBRK = 0x2000747a; | ||
| 2833 | pub const IOCGSID = 0x40047463; | ||
| 2834 | pub const IOCGPTN = 0x4004740f; | ||
| 2835 | pub const IOCSIG = 0x2004745f; | ||
| 2836 | }, | ||
| 2837 | .solaris, .illumos => struct { | ||
| 2838 | pub const CGETA = tioc('T', 1); | ||
| 2839 | pub const CSETA = tioc('T', 2); | ||
| 2840 | pub const CSETAW = tioc('T', 3); | ||
| 2841 | pub const CSETAF = tioc('T', 4); | ||
| 2842 | pub const CSBRK = tioc('T', 5); | ||
| 2843 | pub const CXONC = tioc('T', 6); | ||
| 2844 | pub const CFLSH = tioc('T', 7); | ||
| 2845 | pub const IOCGWINSZ = tioc('T', 104); | ||
| 2846 | pub const IOCSWINSZ = tioc('T', 103); | ||
| 2847 | // Softcarrier ioctls | ||
| 2848 | pub const IOCGSOFTCAR = tioc('T', 105); | ||
| 2849 | pub const IOCSSOFTCAR = tioc('T', 106); | ||
| 2850 | // termios ioctls | ||
| 2851 | pub const CGETS = tioc('T', 13); | ||
| 2852 | pub const CSETS = tioc('T', 14); | ||
| 2853 | pub const CSANOW = tioc('T', 14); | ||
| 2854 | pub const CSETSW = tioc('T', 15); | ||
| 2855 | pub const CSADRAIN = tioc('T', 15); | ||
| 2856 | pub const CSETSF = tioc('T', 16); | ||
| 2857 | pub const IOCSETLD = tioc('T', 123); | ||
| 2858 | pub const IOCGETLD = tioc('T', 124); | ||
| 2859 | // NTP PPS ioctls | ||
| 2860 | pub const IOCGPPS = tioc('T', 125); | ||
| 2861 | pub const IOCSPPS = tioc('T', 126); | ||
| 2862 | pub const IOCGPPSEV = tioc('T', 127); | ||
| 2863 | |||
| 2864 | pub const IOCGETD = tioc('t', 0); | ||
| 2865 | pub const IOCSETD = tioc('t', 1); | ||
| 2866 | pub const IOCHPCL = tioc('t', 2); | ||
| 2867 | pub const IOCGETP = tioc('t', 8); | ||
| 2868 | pub const IOCSETP = tioc('t', 9); | ||
| 2869 | pub const IOCSETN = tioc('t', 10); | ||
| 2870 | pub const IOCEXCL = tioc('t', 13); | ||
| 2871 | pub const IOCNXCL = tioc('t', 14); | ||
| 2872 | pub const IOCFLUSH = tioc('t', 16); | ||
| 2873 | pub const IOCSETC = tioc('t', 17); | ||
| 2874 | pub const IOCGETC = tioc('t', 18); | ||
| 2875 | /// bis local mode bits | ||
| 2876 | pub const IOCLBIS = tioc('t', 127); | ||
| 2877 | /// bic local mode bits | ||
| 2878 | pub const IOCLBIC = tioc('t', 126); | ||
| 2879 | /// set entire local mode word | ||
| 2880 | pub const IOCLSET = tioc('t', 125); | ||
| 2881 | /// get local modes | ||
| 2882 | pub const IOCLGET = tioc('t', 124); | ||
| 2883 | /// set break bit | ||
| 2884 | pub const IOCSBRK = tioc('t', 123); | ||
| 2885 | /// clear break bit | ||
| 2886 | pub const IOCCBRK = tioc('t', 122); | ||
| 2887 | /// set data terminal ready | ||
| 2888 | pub const IOCSDTR = tioc('t', 121); | ||
| 2889 | /// clear data terminal ready | ||
| 2890 | pub const IOCCDTR = tioc('t', 120); | ||
| 2891 | /// set local special chars | ||
| 2892 | pub const IOCSLTC = tioc('t', 117); | ||
| 2893 | /// get local special chars | ||
| 2894 | pub const IOCGLTC = tioc('t', 116); | ||
| 2895 | /// driver output queue size | ||
| 2896 | pub const IOCOUTQ = tioc('t', 115); | ||
| 2897 | /// void tty association | ||
| 2898 | pub const IOCNOTTY = tioc('t', 113); | ||
| 2899 | /// get a ctty | ||
| 2900 | pub const IOCSCTTY = tioc('t', 132); | ||
| 2901 | /// stop output, like ^S | ||
| 2902 | pub const IOCSTOP = tioc('t', 111); | ||
| 2903 | /// start output, like ^Q | ||
| 2904 | pub const IOCSTART = tioc('t', 110); | ||
| 2905 | /// get pgrp of tty | ||
| 2906 | pub const IOCGPGRP = tioc('t', 20); | ||
| 2907 | /// set pgrp of tty | ||
| 2908 | pub const IOCSPGRP = tioc('t', 21); | ||
| 2909 | /// get session id on ctty | ||
| 2910 | pub const IOCGSID = tioc('t', 22); | ||
| 2911 | /// simulate terminal input | ||
| 2912 | pub const IOCSTI = tioc('t', 23); | ||
| 2913 | /// set all modem bits | ||
| 2914 | pub const IOCMSET = tioc('t', 26); | ||
| 2915 | /// bis modem bits | ||
| 2916 | pub const IOCMBIS = tioc('t', 27); | ||
| 2917 | /// bic modem bits | ||
| 2918 | pub const IOCMBIC = tioc('t', 28); | ||
| 2919 | /// get all modem bits | ||
| 2920 | pub const IOCMGET = tioc('t', 29); | ||
| 2921 | |||
| 2922 | fn tioc(t: u16, num: u8) u16 { | ||
| 2923 | return (t << 8) | num; | ||
| 2924 | } | ||
| 2925 | }, | ||
| 2926 | .netbsd => struct { | ||
| 2927 | pub const IOCCBRK = 0x2000747a; | ||
| 2928 | pub const IOCCDTR = 0x20007478; | ||
| 2929 | pub const IOCCONS = 0x80047462; | ||
| 2930 | pub const IOCDCDTIMESTAMP = 0x40107458; | ||
| 2931 | pub const IOCDRAIN = 0x2000745e; | ||
| 2932 | pub const IOCEXCL = 0x2000740d; | ||
| 2933 | pub const IOCEXT = 0x80047460; | ||
| 2934 | pub const IOCFLAG_CDTRCTS = 0x10; | ||
| 2935 | pub const IOCFLAG_CLOCAL = 0x2; | ||
| 2936 | pub const IOCFLAG_CRTSCTS = 0x4; | ||
| 2937 | pub const IOCFLAG_MDMBUF = 0x8; | ||
| 2938 | pub const IOCFLAG_SOFTCAR = 0x1; | ||
| 2939 | pub const IOCFLUSH = 0x80047410; | ||
| 2940 | pub const IOCGETA = 0x402c7413; | ||
| 2941 | pub const IOCGETD = 0x4004741a; | ||
| 2942 | pub const IOCGFLAGS = 0x4004745d; | ||
| 2943 | pub const IOCGLINED = 0x40207442; | ||
| 2944 | pub const IOCGPGRP = 0x40047477; | ||
| 2945 | pub const IOCGQSIZE = 0x40047481; | ||
| 2946 | pub const IOCGRANTPT = 0x20007447; | ||
| 2947 | pub const IOCGSID = 0x40047463; | ||
| 2948 | pub const IOCGSIZE = 0x40087468; | ||
| 2949 | pub const IOCGWINSZ = 0x40087468; | ||
| 2950 | pub const IOCMBIC = 0x8004746b; | ||
| 2951 | pub const IOCMBIS = 0x8004746c; | ||
| 2952 | pub const IOCMGET = 0x4004746a; | ||
| 2953 | pub const IOCMSET = 0x8004746d; | ||
| 2954 | pub const IOCM_CAR = 0x40; | ||
| 2955 | pub const IOCM_CD = 0x40; | ||
| 2956 | pub const IOCM_CTS = 0x20; | ||
| 2957 | pub const IOCM_DSR = 0x100; | ||
| 2958 | pub const IOCM_DTR = 0x2; | ||
| 2959 | pub const IOCM_LE = 0x1; | ||
| 2960 | pub const IOCM_RI = 0x80; | ||
| 2961 | pub const IOCM_RNG = 0x80; | ||
| 2962 | pub const IOCM_RTS = 0x4; | ||
| 2963 | pub const IOCM_SR = 0x10; | ||
| 2964 | pub const IOCM_ST = 0x8; | ||
| 2965 | pub const IOCNOTTY = 0x20007471; | ||
| 2966 | pub const IOCNXCL = 0x2000740e; | ||
| 2967 | pub const IOCOUTQ = 0x40047473; | ||
| 2968 | pub const IOCPKT = 0x80047470; | ||
| 2969 | pub const IOCPKT_DATA = 0x0; | ||
| 2970 | pub const IOCPKT_DOSTOP = 0x20; | ||
| 2971 | pub const IOCPKT_FLUSHREAD = 0x1; | ||
| 2972 | pub const IOCPKT_FLUSHWRITE = 0x2; | ||
| 2973 | pub const IOCPKT_IOCTL = 0x40; | ||
| 2974 | pub const IOCPKT_NOSTOP = 0x10; | ||
| 2975 | pub const IOCPKT_START = 0x8; | ||
| 2976 | pub const IOCPKT_STOP = 0x4; | ||
| 2977 | pub const IOCPTMGET = 0x40287446; | ||
| 2978 | pub const IOCPTSNAME = 0x40287448; | ||
| 2979 | pub const IOCRCVFRAME = 0x80087445; | ||
| 2980 | pub const IOCREMOTE = 0x80047469; | ||
| 2981 | pub const IOCSBRK = 0x2000747b; | ||
| 2982 | pub const IOCSCTTY = 0x20007461; | ||
| 2983 | pub const IOCSDTR = 0x20007479; | ||
| 2984 | pub const IOCSETA = 0x802c7414; | ||
| 2985 | pub const IOCSETAF = 0x802c7416; | ||
| 2986 | pub const IOCSETAW = 0x802c7415; | ||
| 2987 | pub const IOCSETD = 0x8004741b; | ||
| 2988 | pub const IOCSFLAGS = 0x8004745c; | ||
| 2989 | pub const IOCSIG = 0x2000745f; | ||
| 2990 | pub const IOCSLINED = 0x80207443; | ||
| 2991 | pub const IOCSPGRP = 0x80047476; | ||
| 2992 | pub const IOCSQSIZE = 0x80047480; | ||
| 2993 | pub const IOCSSIZE = 0x80087467; | ||
| 2994 | pub const IOCSTART = 0x2000746e; | ||
| 2995 | pub const IOCSTAT = 0x80047465; | ||
| 2996 | pub const IOCSTI = 0x80017472; | ||
| 2997 | pub const IOCSTOP = 0x2000746f; | ||
| 2998 | pub const IOCSWINSZ = 0x80087467; | ||
| 2999 | pub const IOCUCNTL = 0x80047466; | ||
| 3000 | pub const IOCXMTFRAME = 0x80087444; | ||
| 3001 | }, | ||
| 3002 | .haiku => struct { | ||
| 3003 | pub const CGETA = 0x8000; | ||
| 3004 | pub const CSETA = 0x8001; | ||
| 3005 | pub const CSETAF = 0x8002; | ||
| 3006 | pub const CSETAW = 0x8003; | ||
| 3007 | pub const CWAITEVENT = 0x8004; | ||
| 3008 | pub const CSBRK = 0x8005; | ||
| 3009 | pub const CFLSH = 0x8006; | ||
| 3010 | pub const CXONC = 0x8007; | ||
| 3011 | pub const CQUERYCONNECTED = 0x8008; | ||
| 3012 | pub const CGETBITS = 0x8009; | ||
| 3013 | pub const CSETDTR = 0x8010; | ||
| 3014 | pub const CSETRTS = 0x8011; | ||
| 3015 | pub const IOCGWINSZ = 0x8012; | ||
| 3016 | pub const IOCSWINSZ = 0x8013; | ||
| 3017 | pub const CVTIME = 0x8014; | ||
| 3018 | pub const IOCGPGRP = 0x8015; | ||
| 3019 | pub const IOCSPGRP = 0x8016; | ||
| 3020 | pub const IOCSCTTY = 0x8017; | ||
| 3021 | pub const IOCMGET = 0x8018; | ||
| 3022 | pub const IOCMSET = 0x8019; | ||
| 3023 | pub const IOCSBRK = 0x8020; | ||
| 3024 | pub const IOCCBRK = 0x8021; | ||
| 3025 | pub const IOCMBIS = 0x8022; | ||
| 3026 | pub const IOCMBIC = 0x8023; | ||
| 3027 | pub const IOCGSID = 0x8024; | ||
| 3028 | |||
| 3029 | pub const FIONREAD = 0xbe000001; | ||
| 3030 | pub const FIONBIO = 0xbe000000; | ||
| 3031 | }, | ||
| 3032 | .openbsd => struct { | ||
| 3033 | pub const IOCCBRK = 0x2000747a; | ||
| 3034 | pub const IOCCDTR = 0x20007478; | ||
| 3035 | pub const IOCCONS = 0x80047462; | ||
| 3036 | pub const IOCDCDTIMESTAMP = 0x40107458; | ||
| 3037 | pub const IOCDRAIN = 0x2000745e; | ||
| 3038 | pub const IOCEXCL = 0x2000740d; | ||
| 3039 | pub const IOCEXT = 0x80047460; | ||
| 3040 | pub const IOCFLAG_CDTRCTS = 0x10; | ||
| 3041 | pub const IOCFLAG_CLOCAL = 0x2; | ||
| 3042 | pub const IOCFLAG_CRTSCTS = 0x4; | ||
| 3043 | pub const IOCFLAG_MDMBUF = 0x8; | ||
| 3044 | pub const IOCFLAG_SOFTCAR = 0x1; | ||
| 3045 | pub const IOCFLUSH = 0x80047410; | ||
| 3046 | pub const IOCGETA = 0x402c7413; | ||
| 3047 | pub const IOCGETD = 0x4004741a; | ||
| 3048 | pub const IOCGFLAGS = 0x4004745d; | ||
| 3049 | pub const IOCGLINED = 0x40207442; | ||
| 3050 | pub const IOCGPGRP = 0x40047477; | ||
| 3051 | pub const IOCGQSIZE = 0x40047481; | ||
| 3052 | pub const IOCGRANTPT = 0x20007447; | ||
| 3053 | pub const IOCGSID = 0x40047463; | ||
| 3054 | pub const IOCGSIZE = 0x40087468; | ||
| 3055 | pub const IOCGWINSZ = 0x40087468; | ||
| 3056 | pub const IOCMBIC = 0x8004746b; | ||
| 3057 | pub const IOCMBIS = 0x8004746c; | ||
| 3058 | pub const IOCMGET = 0x4004746a; | ||
| 3059 | pub const IOCMSET = 0x8004746d; | ||
| 3060 | pub const IOCM_CAR = 0x40; | ||
| 3061 | pub const IOCM_CD = 0x40; | ||
| 3062 | pub const IOCM_CTS = 0x20; | ||
| 3063 | pub const IOCM_DSR = 0x100; | ||
| 3064 | pub const IOCM_DTR = 0x2; | ||
| 3065 | pub const IOCM_LE = 0x1; | ||
| 3066 | pub const IOCM_RI = 0x80; | ||
| 3067 | pub const IOCM_RNG = 0x80; | ||
| 3068 | pub const IOCM_RTS = 0x4; | ||
| 3069 | pub const IOCM_SR = 0x10; | ||
| 3070 | pub const IOCM_ST = 0x8; | ||
| 3071 | pub const IOCNOTTY = 0x20007471; | ||
| 3072 | pub const IOCNXCL = 0x2000740e; | ||
| 3073 | pub const IOCOUTQ = 0x40047473; | ||
| 3074 | pub const IOCPKT = 0x80047470; | ||
| 3075 | pub const IOCPKT_DATA = 0x0; | ||
| 3076 | pub const IOCPKT_DOSTOP = 0x20; | ||
| 3077 | pub const IOCPKT_FLUSHREAD = 0x1; | ||
| 3078 | pub const IOCPKT_FLUSHWRITE = 0x2; | ||
| 3079 | pub const IOCPKT_IOCTL = 0x40; | ||
| 3080 | pub const IOCPKT_NOSTOP = 0x10; | ||
| 3081 | pub const IOCPKT_START = 0x8; | ||
| 3082 | pub const IOCPKT_STOP = 0x4; | ||
| 3083 | pub const IOCPTMGET = 0x40287446; | ||
| 3084 | pub const IOCPTSNAME = 0x40287448; | ||
| 3085 | pub const IOCRCVFRAME = 0x80087445; | ||
| 3086 | pub const IOCREMOTE = 0x80047469; | ||
| 3087 | pub const IOCSBRK = 0x2000747b; | ||
| 3088 | pub const IOCSCTTY = 0x20007461; | ||
| 3089 | pub const IOCSDTR = 0x20007479; | ||
| 3090 | pub const IOCSETA = 0x802c7414; | ||
| 3091 | pub const IOCSETAF = 0x802c7416; | ||
| 3092 | pub const IOCSETAW = 0x802c7415; | ||
| 3093 | pub const IOCSETD = 0x8004741b; | ||
| 3094 | pub const IOCSFLAGS = 0x8004745c; | ||
| 3095 | pub const IOCSIG = 0x2000745f; | ||
| 3096 | pub const IOCSLINED = 0x80207443; | ||
| 3097 | pub const IOCSPGRP = 0x80047476; | ||
| 3098 | pub const IOCSQSIZE = 0x80047480; | ||
| 3099 | pub const IOCSSIZE = 0x80087467; | ||
| 3100 | pub const IOCSTART = 0x2000746e; | ||
| 3101 | pub const IOCSTAT = 0x80047465; | ||
| 3102 | pub const IOCSTI = 0x80017472; | ||
| 3103 | pub const IOCSTOP = 0x2000746f; | ||
| 3104 | pub const IOCSWINSZ = 0x80087467; | ||
| 3105 | pub const IOCUCNTL = 0x80047466; | ||
| 3106 | pub const IOCXMTFRAME = 0x80087444; | ||
| 3107 | }, | ||
| 3108 | else => void, | ||
| 3109 | }; | ||
| 3110 | pub const IOCPARM_MASK = switch (native_os) { | ||
| 3111 | .windows => ws2_32.IOCPARM_MASK, | ||
| 3112 | .macos, .ios, .tvos, .watchos, .visionos => 0x1fff, | ||
| 3113 | else => void, | ||
| 3114 | }; | ||
| 3115 | pub const TCSA = std.posix.TCSA; | ||
| 3116 | pub const TFD = switch (native_os) { | ||
| 3117 | .linux => linux.TFD, | ||
| 3118 | else => void, | ||
| 3119 | }; | ||
| 3120 | pub const VDSO = switch (native_os) { | ||
| 3121 | .linux => linux.VDSO, | ||
| 3122 | else => void, | ||
| 3123 | }; | ||
| 3124 | pub const W = switch (native_os) { | ||
| 3125 | .linux => linux.W, | ||
| 3126 | .emscripten => emscripten.W, | ||
| 3127 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 3128 | /// [XSI] no hang in wait/no child to reap | ||
| 3129 | pub const NOHANG = 0x00000001; | ||
| 3130 | /// [XSI] notify on stop, untraced child | ||
| 3131 | pub const UNTRACED = 0x00000002; | ||
| 3132 | |||
| 3133 | pub fn EXITSTATUS(x: u32) u8 { | ||
| 3134 | return @as(u8, @intCast(x >> 8)); | ||
| 3135 | } | ||
| 3136 | pub fn TERMSIG(x: u32) u32 { | ||
| 3137 | return status(x); | ||
| 3138 | } | ||
| 3139 | pub fn STOPSIG(x: u32) u32 { | ||
| 3140 | return x >> 8; | ||
| 3141 | } | ||
| 3142 | pub fn IFEXITED(x: u32) bool { | ||
| 3143 | return status(x) == 0; | ||
| 3144 | } | ||
| 3145 | pub fn IFSTOPPED(x: u32) bool { | ||
| 3146 | return status(x) == stopped and STOPSIG(x) != 0x13; | ||
| 3147 | } | ||
| 3148 | pub fn IFSIGNALED(x: u32) bool { | ||
| 3149 | return status(x) != stopped and status(x) != 0; | ||
| 3150 | } | ||
| 3151 | |||
| 3152 | fn status(x: u32) u32 { | ||
| 3153 | return x & 0o177; | ||
| 3154 | } | ||
| 3155 | const stopped = 0o177; | ||
| 3156 | }, | ||
| 3157 | .freebsd, .kfreebsd => struct { | ||
| 3158 | pub const NOHANG = 1; | ||
| 3159 | pub const UNTRACED = 2; | ||
| 3160 | pub const STOPPED = UNTRACED; | ||
| 3161 | pub const CONTINUED = 4; | ||
| 3162 | pub const NOWAIT = 8; | ||
| 3163 | pub const EXITED = 16; | ||
| 3164 | pub const TRAPPED = 32; | ||
| 3165 | |||
| 3166 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 3167 | return @as(u8, @intCast((s & 0xff00) >> 8)); | ||
| 3168 | } | ||
| 3169 | pub fn TERMSIG(s: u32) u32 { | ||
| 3170 | return s & 0x7f; | ||
| 3171 | } | ||
| 3172 | pub fn STOPSIG(s: u32) u32 { | ||
| 3173 | return EXITSTATUS(s); | ||
| 3174 | } | ||
| 3175 | pub fn IFEXITED(s: u32) bool { | ||
| 3176 | return TERMSIG(s) == 0; | ||
| 3177 | } | ||
| 3178 | pub fn IFSTOPPED(s: u32) bool { | ||
| 3179 | return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; | ||
| 3180 | } | ||
| 3181 | pub fn IFSIGNALED(s: u32) bool { | ||
| 3182 | return (s & 0xffff) -% 1 < 0xff; | ||
| 3183 | } | ||
| 3184 | }, | ||
| 3185 | .solaris, .illumos => struct { | ||
| 3186 | pub const EXITED = 0o001; | ||
| 3187 | pub const TRAPPED = 0o002; | ||
| 3188 | pub const UNTRACED = 0o004; | ||
| 3189 | pub const STOPPED = UNTRACED; | ||
| 3190 | pub const CONTINUED = 0o010; | ||
| 3191 | pub const NOHANG = 0o100; | ||
| 3192 | pub const NOWAIT = 0o200; | ||
| 3193 | |||
| 3194 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 3195 | return @as(u8, @intCast((s >> 8) & 0xff)); | ||
| 3196 | } | ||
| 3197 | pub fn TERMSIG(s: u32) u32 { | ||
| 3198 | return s & 0x7f; | ||
| 3199 | } | ||
| 3200 | pub fn STOPSIG(s: u32) u32 { | ||
| 3201 | return EXITSTATUS(s); | ||
| 3202 | } | ||
| 3203 | pub fn IFEXITED(s: u32) bool { | ||
| 3204 | return TERMSIG(s) == 0; | ||
| 3205 | } | ||
| 3206 | |||
| 3207 | pub fn IFCONTINUED(s: u32) bool { | ||
| 3208 | return ((s & 0o177777) == 0o177777); | ||
| 3209 | } | ||
| 3210 | |||
| 3211 | pub fn IFSTOPPED(s: u32) bool { | ||
| 3212 | return (s & 0x00ff != 0o177) and !(s & 0xff00 != 0); | ||
| 3213 | } | ||
| 3214 | |||
| 3215 | pub fn IFSIGNALED(s: u32) bool { | ||
| 3216 | return s & 0x00ff > 0 and s & 0xff00 == 0; | ||
| 3217 | } | ||
| 3218 | }, | ||
| 3219 | .netbsd => struct { | ||
| 3220 | pub const NOHANG = 0x00000001; | ||
| 3221 | pub const UNTRACED = 0x00000002; | ||
| 3222 | pub const STOPPED = UNTRACED; | ||
| 3223 | pub const CONTINUED = 0x00000010; | ||
| 3224 | pub const NOWAIT = 0x00010000; | ||
| 3225 | pub const EXITED = 0x00000020; | ||
| 3226 | pub const TRAPPED = 0x00000040; | ||
| 3227 | |||
| 3228 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 3229 | return @as(u8, @intCast((s >> 8) & 0xff)); | ||
| 3230 | } | ||
| 3231 | pub fn TERMSIG(s: u32) u32 { | ||
| 3232 | return s & 0x7f; | ||
| 3233 | } | ||
| 3234 | pub fn STOPSIG(s: u32) u32 { | ||
| 3235 | return EXITSTATUS(s); | ||
| 3236 | } | ||
| 3237 | pub fn IFEXITED(s: u32) bool { | ||
| 3238 | return TERMSIG(s) == 0; | ||
| 3239 | } | ||
| 3240 | |||
| 3241 | pub fn IFCONTINUED(s: u32) bool { | ||
| 3242 | return ((s & 0x7f) == 0xffff); | ||
| 3243 | } | ||
| 3244 | |||
| 3245 | pub fn IFSTOPPED(s: u32) bool { | ||
| 3246 | return ((s & 0x7f != 0x7f) and !IFCONTINUED(s)); | ||
| 3247 | } | ||
| 3248 | |||
| 3249 | pub fn IFSIGNALED(s: u32) bool { | ||
| 3250 | return !IFSTOPPED(s) and !IFCONTINUED(s) and !IFEXITED(s); | ||
| 3251 | } | ||
| 3252 | }, | ||
| 3253 | .dragonfly => struct { | ||
| 3254 | pub const NOHANG = 0x0001; | ||
| 3255 | pub const UNTRACED = 0x0002; | ||
| 3256 | pub const CONTINUED = 0x0004; | ||
| 3257 | pub const STOPPED = UNTRACED; | ||
| 3258 | pub const NOWAIT = 0x0008; | ||
| 3259 | pub const EXITED = 0x0010; | ||
| 3260 | pub const TRAPPED = 0x0020; | ||
| 3261 | |||
| 3262 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 3263 | return @as(u8, @intCast((s & 0xff00) >> 8)); | ||
| 3264 | } | ||
| 3265 | pub fn TERMSIG(s: u32) u32 { | ||
| 3266 | return s & 0x7f; | ||
| 3267 | } | ||
| 3268 | pub fn STOPSIG(s: u32) u32 { | ||
| 3269 | return EXITSTATUS(s); | ||
| 3270 | } | ||
| 3271 | pub fn IFEXITED(s: u32) bool { | ||
| 3272 | return TERMSIG(s) == 0; | ||
| 3273 | } | ||
| 3274 | pub fn IFSTOPPED(s: u32) bool { | ||
| 3275 | return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; | ||
| 3276 | } | ||
| 3277 | pub fn IFSIGNALED(s: u32) bool { | ||
| 3278 | return (s & 0xffff) -% 1 < 0xff; | ||
| 3279 | } | ||
| 3280 | }, | ||
| 3281 | .haiku => struct { | ||
| 3282 | pub const NOHANG = 0x1; | ||
| 3283 | pub const UNTRACED = 0x2; | ||
| 3284 | pub const CONTINUED = 0x4; | ||
| 3285 | pub const EXITED = 0x08; | ||
| 3286 | pub const STOPPED = 0x10; | ||
| 3287 | pub const NOWAIT = 0x20; | ||
| 3288 | |||
| 3289 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 3290 | return @as(u8, @intCast(s & 0xff)); | ||
| 3291 | } | ||
| 3292 | |||
| 3293 | pub fn TERMSIG(s: u32) u32 { | ||
| 3294 | return (s >> 8) & 0xff; | ||
| 3295 | } | ||
| 3296 | |||
| 3297 | pub fn STOPSIG(s: u32) u32 { | ||
| 3298 | return (s >> 16) & 0xff; | ||
| 3299 | } | ||
| 3300 | |||
| 3301 | pub fn IFEXITED(s: u32) bool { | ||
| 3302 | return (s & ~@as(u32, 0xff)) == 0; | ||
| 3303 | } | ||
| 3304 | |||
| 3305 | pub fn IFSTOPPED(s: u32) bool { | ||
| 3306 | return ((s >> 16) & 0xff) != 0; | ||
| 3307 | } | ||
| 3308 | |||
| 3309 | pub fn IFSIGNALED(s: u32) bool { | ||
| 3310 | return ((s >> 8) & 0xff) != 0; | ||
| 3311 | } | ||
| 3312 | }, | ||
| 3313 | .openbsd => struct { | ||
| 3314 | pub const NOHANG = 1; | ||
| 3315 | pub const UNTRACED = 2; | ||
| 3316 | pub const CONTINUED = 8; | ||
| 3317 | |||
| 3318 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 3319 | return @as(u8, @intCast((s >> 8) & 0xff)); | ||
| 3320 | } | ||
| 3321 | pub fn TERMSIG(s: u32) u32 { | ||
| 3322 | return (s & 0x7f); | ||
| 3323 | } | ||
| 3324 | pub fn STOPSIG(s: u32) u32 { | ||
| 3325 | return EXITSTATUS(s); | ||
| 3326 | } | ||
| 3327 | pub fn IFEXITED(s: u32) bool { | ||
| 3328 | return TERMSIG(s) == 0; | ||
| 3329 | } | ||
| 3330 | |||
| 3331 | pub fn IFCONTINUED(s: u32) bool { | ||
| 3332 | return ((s & 0o177777) == 0o177777); | ||
| 3333 | } | ||
| 3334 | |||
| 3335 | pub fn IFSTOPPED(s: u32) bool { | ||
| 3336 | return (s & 0xff == 0o177); | ||
| 3337 | } | ||
| 3338 | |||
| 3339 | pub fn IFSIGNALED(s: u32) bool { | ||
| 3340 | return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); | ||
| 3341 | } | ||
| 3342 | }, | ||
| 3343 | else => void, | ||
| 3344 | }; | ||
| 3345 | pub const clock_t = switch (native_os) { | ||
| 3346 | .linux => linux.clock_t, | ||
| 3347 | .emscripten => emscripten.clock_t, | ||
| 3348 | .macos, .ios, .tvos, .watchos, .visionos => c_ulong, | ||
| 3349 | .freebsd, .kfreebsd => isize, | ||
| 3350 | .openbsd, .solaris, .illumos => i64, | ||
| 3351 | .netbsd => u32, | ||
| 3352 | .haiku => i32, | ||
| 3353 | else => void, | ||
| 3354 | }; | ||
| 3355 | pub const cpu_set_t = switch (native_os) { | ||
| 3356 | .linux => linux.cpu_set_t, | ||
| 3357 | .emscripten => emscripten.cpu_set_t, | ||
| 3358 | else => void, | ||
| 3359 | }; | ||
| 3360 | pub const dl_phdr_info = switch (native_os) { | ||
| 3361 | .linux => linux.dl_phdr_info, | ||
| 3362 | .emscripten => emscripten.dl_phdr_info, | ||
| 3363 | .freebsd, .kfreebsd => extern struct { | ||
| 3364 | /// Module relocation base. | ||
| 3365 | addr: if (builtin.target.ptrBitWidth() == 32) std.elf.Elf32_Addr else std.elf.Elf64_Addr, | ||
| 3366 | /// Module name. | ||
| 3367 | name: ?[*:0]const u8, | ||
| 3368 | /// Pointer to module's phdr. | ||
| 3369 | phdr: [*]std.elf.Phdr, | ||
| 3370 | /// Number of entries in phdr. | ||
| 3371 | phnum: u16, | ||
| 3372 | /// Total number of loads. | ||
| 3373 | adds: u64, | ||
| 3374 | /// Total number of unloads. | ||
| 3375 | subs: u64, | ||
| 3376 | tls_modid: usize, | ||
| 3377 | tls_data: ?*anyopaque, | ||
| 3378 | }, | ||
| 3379 | .solaris, .illumos => extern struct { | ||
| 3380 | addr: std.elf.Addr, | ||
| 3381 | name: ?[*:0]const u8, | ||
| 3382 | phdr: [*]std.elf.Phdr, | ||
| 3383 | phnum: std.elf.Half, | ||
| 3384 | /// Incremented when a new object is mapped into the process. | ||
| 3385 | adds: u64, | ||
| 3386 | /// Incremented when an object is unmapped from the process. | ||
| 3387 | subs: u64, | ||
| 3388 | }, | ||
| 3389 | .openbsd, .haiku, .dragonfly, .netbsd => extern struct { | ||
| 3390 | addr: usize, | ||
| 3391 | name: ?[*:0]const u8, | ||
| 3392 | phdr: [*]std.elf.Phdr, | ||
| 3393 | phnum: u16, | ||
| 3394 | }, | ||
| 3395 | else => void, | ||
| 3396 | }; | ||
| 3397 | pub const epoll_event = switch (native_os) { | ||
| 3398 | .linux => linux.epoll_event, | ||
| 3399 | else => void, | ||
| 3400 | }; | ||
| 3401 | pub const ifreq = switch (native_os) { | ||
| 3402 | .linux => linux.ifreq, | ||
| 3403 | .emscripten => emscripten.ifreq, | ||
| 3404 | .solaris, .illumos => lifreq, | ||
| 3405 | else => void, | ||
| 3406 | }; | ||
| 3407 | pub const itimerspec = switch (native_os) { | ||
| 3408 | .linux => linux.itimerspec, | ||
| 3409 | .haiku => extern struct { | ||
| 3410 | interval: timespec, | ||
| 3411 | value: timespec, | ||
| 3412 | }, | ||
| 3413 | else => void, | ||
| 3414 | }; | ||
| 3415 | pub const msghdr = switch (native_os) { | ||
| 3416 | .linux => linux.msghdr, | ||
| 3417 | .openbsd, .emscripten, .dragonfly, .freebsd, .kfreebsd, .netbsd, .haiku, .solaris, .illumos => extern struct { | ||
| 3418 | /// optional address | ||
| 3419 | name: ?*sockaddr, | ||
| 3420 | /// size of address | ||
| 3421 | namelen: socklen_t, | ||
| 3422 | /// scatter/gather array | ||
| 3423 | iov: [*]iovec, | ||
| 3424 | /// # elements in iov | ||
| 3425 | iovlen: i32, | ||
| 3426 | /// ancillary data | ||
| 3427 | control: ?*anyopaque, | ||
| 3428 | /// ancillary data buffer len | ||
| 3429 | controllen: socklen_t, | ||
| 3430 | /// flags on received message | ||
| 3431 | flags: i32, | ||
| 3432 | }, | ||
| 3433 | else => void, | ||
| 3434 | }; | ||
| 3435 | pub const msghdr_const = switch (native_os) { | ||
| 3436 | .linux => linux.msghdr_const, | ||
| 3437 | .openbsd, .emscripten, .dragonfly, .freebsd, .kfreebsd, .netbsd, .haiku, .solaris, .illumos => extern struct { | ||
| 3438 | /// optional address | ||
| 3439 | name: ?*const sockaddr, | ||
| 3440 | /// size of address | ||
| 3441 | namelen: socklen_t, | ||
| 3442 | /// scatter/gather array | ||
| 3443 | iov: [*]const iovec_const, | ||
| 3444 | /// # elements in iov | ||
| 3445 | iovlen: i32, | ||
| 3446 | /// ancillary data | ||
| 3447 | control: ?*const anyopaque, | ||
| 3448 | /// ancillary data buffer len | ||
| 3449 | controllen: socklen_t, | ||
| 3450 | /// flags on received message | ||
| 3451 | flags: i32, | ||
| 3452 | }, | ||
| 3453 | else => void, | ||
| 3454 | }; | ||
| 3455 | pub const nfds_t = switch (native_os) { | ||
| 3456 | .linux => linux.nfds_t, | ||
| 3457 | .emscripten => emscripten.nfds_t, | ||
| 3458 | .haiku, .solaris, .illumos, .wasi => usize, | ||
| 3459 | .windows => c_ulong, | ||
| 3460 | .openbsd, .dragonfly, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => u32, | ||
| 3461 | else => void, | ||
| 3462 | }; | ||
| 3463 | pub const perf_event_attr = switch (native_os) { | ||
| 3464 | .linux => linux.perf_event_attr, | ||
| 3465 | else => void, | ||
| 3466 | }; | ||
| 3467 | pub const pid_t = switch (native_os) { | ||
| 3468 | .linux => linux.pid_t, | ||
| 3469 | .emscripten => emscripten.pid_t, | ||
| 3470 | .windows => windows.HANDLE, | ||
| 3471 | else => i32, | ||
| 3472 | }; | ||
| 3473 | pub const pollfd = switch (native_os) { | ||
| 3474 | .linux => linux.pollfd, | ||
| 3475 | .emscripten => emscripten.pollfd, | ||
| 3476 | .windows => ws2_32.pollfd, | ||
| 3477 | else => extern struct { | ||
| 3478 | fd: fd_t, | ||
| 3479 | events: i16, | ||
| 3480 | revents: i16, | ||
| 3481 | }, | ||
| 3482 | }; | ||
| 3483 | pub const rlim_t = switch (native_os) { | ||
| 3484 | .linux => linux.rlim_t, | ||
| 3485 | .emscripten => emscripten.rlim_t, | ||
| 3486 | .openbsd, .netbsd, .solaris, .illumos, .macos, .ios, .tvos, .watchos, .visionos => u64, | ||
| 3487 | .haiku, .dragonfly, .freebsd, .kfreebsd => i64, | ||
| 3488 | else => void, | ||
| 3489 | }; | ||
| 3490 | pub const rlimit = switch (native_os) { | ||
| 3491 | .linux, .emscripten => linux.rlimit, | ||
| 3492 | .windows => void, | ||
| 3493 | else => extern struct { | ||
| 3494 | /// Soft limit | ||
| 3495 | cur: rlim_t, | ||
| 3496 | /// Hard limit | ||
| 3497 | max: rlim_t, | ||
| 3498 | }, | ||
| 3499 | }; | ||
| 3500 | pub const rlimit_resource = switch (native_os) { | ||
| 3501 | .linux => linux.rlimit_resource, | ||
| 3502 | .emscripten => emscripten.rlimit_resource, | ||
| 3503 | .openbsd, .macos, .ios, .tvos, .watchos, .visionos => enum(c_int) { | ||
| 3504 | CPU = 0, | ||
| 3505 | FSIZE = 1, | ||
| 3506 | DATA = 2, | ||
| 3507 | STACK = 3, | ||
| 3508 | CORE = 4, | ||
| 3509 | RSS = 5, | ||
| 3510 | MEMLOCK = 6, | ||
| 3511 | NPROC = 7, | ||
| 3512 | NOFILE = 8, | ||
| 3513 | _, | ||
| 3514 | |||
| 3515 | pub const AS: rlimit_resource = .RSS; | ||
| 3516 | }, | ||
| 3517 | .freebsd, .kfreebsd => enum(c_int) { | ||
| 3518 | CPU = 0, | ||
| 3519 | FSIZE = 1, | ||
| 3520 | DATA = 2, | ||
| 3521 | STACK = 3, | ||
| 3522 | CORE = 4, | ||
| 3523 | RSS = 5, | ||
| 3524 | MEMLOCK = 6, | ||
| 3525 | NPROC = 7, | ||
| 3526 | NOFILE = 8, | ||
| 3527 | SBSIZE = 9, | ||
| 3528 | VMEM = 10, | ||
| 3529 | NPTS = 11, | ||
| 3530 | SWAP = 12, | ||
| 3531 | KQUEUES = 13, | ||
| 3532 | UMTXP = 14, | ||
| 3533 | _, | ||
| 3534 | |||
| 3535 | pub const AS: rlimit_resource = .VMEM; | ||
| 3536 | }, | ||
| 3537 | .solaris, .illumos => enum(c_int) { | ||
| 3538 | CPU = 0, | ||
| 3539 | FSIZE = 1, | ||
| 3540 | DATA = 2, | ||
| 3541 | STACK = 3, | ||
| 3542 | CORE = 4, | ||
| 3543 | NOFILE = 5, | ||
| 3544 | VMEM = 6, | ||
| 3545 | _, | ||
| 3546 | |||
| 3547 | pub const AS: rlimit_resource = .VMEM; | ||
| 3548 | }, | ||
| 3549 | .netbsd => enum(c_int) { | ||
| 3550 | CPU = 0, | ||
| 3551 | FSIZE = 1, | ||
| 3552 | DATA = 2, | ||
| 3553 | STACK = 3, | ||
| 3554 | CORE = 4, | ||
| 3555 | RSS = 5, | ||
| 3556 | MEMLOCK = 6, | ||
| 3557 | NPROC = 7, | ||
| 3558 | NOFILE = 8, | ||
| 3559 | SBSIZE = 9, | ||
| 3560 | VMEM = 10, | ||
| 3561 | NTHR = 11, | ||
| 3562 | _, | ||
| 3563 | |||
| 3564 | pub const AS: rlimit_resource = .VMEM; | ||
| 3565 | }, | ||
| 3566 | .dragonfly => enum(c_int) { | ||
| 3567 | CPU = 0, | ||
| 3568 | FSIZE = 1, | ||
| 3569 | DATA = 2, | ||
| 3570 | STACK = 3, | ||
| 3571 | CORE = 4, | ||
| 3572 | RSS = 5, | ||
| 3573 | MEMLOCK = 6, | ||
| 3574 | NPROC = 7, | ||
| 3575 | NOFILE = 8, | ||
| 3576 | SBSIZE = 9, | ||
| 3577 | VMEM = 10, | ||
| 3578 | POSIXLOCKS = 11, | ||
| 3579 | _, | ||
| 3580 | |||
| 3581 | pub const AS: rlimit_resource = .VMEM; | ||
| 3582 | }, | ||
| 3583 | .haiku => enum(i32) { | ||
| 3584 | CORE = 0, | ||
| 3585 | CPU = 1, | ||
| 3586 | DATA = 2, | ||
| 3587 | FSIZE = 3, | ||
| 3588 | NOFILE = 4, | ||
| 3589 | STACK = 5, | ||
| 3590 | AS = 6, | ||
| 3591 | NOVMON = 7, | ||
| 3592 | _, | ||
| 3593 | }, | ||
| 3594 | else => void, | ||
| 3595 | }; | ||
| 3596 | pub const rusage = switch (native_os) { | ||
| 3597 | .linux => linux.rusage, | ||
| 3598 | .emscripten => emscripten.rusage, | ||
| 3599 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 3600 | utime: timeval, | ||
| 3601 | stime: timeval, | ||
| 3602 | maxrss: isize, | ||
| 3603 | ixrss: isize, | ||
| 3604 | idrss: isize, | ||
| 3605 | isrss: isize, | ||
| 3606 | minflt: isize, | ||
| 3607 | majflt: isize, | ||
| 3608 | nswap: isize, | ||
| 3609 | inblock: isize, | ||
| 3610 | oublock: isize, | ||
| 3611 | msgsnd: isize, | ||
| 3612 | msgrcv: isize, | ||
| 3613 | nsignals: isize, | ||
| 3614 | nvcsw: isize, | ||
| 3615 | nivcsw: isize, | ||
| 3616 | |||
| 3617 | pub const SELF = 0; | ||
| 3618 | pub const CHILDREN = -1; | ||
| 3619 | }, | ||
| 3620 | .solaris, .illumos => extern struct { | ||
| 3621 | utime: timeval, | ||
| 3622 | stime: timeval, | ||
| 3623 | maxrss: isize, | ||
| 3624 | ixrss: isize, | ||
| 3625 | idrss: isize, | ||
| 3626 | isrss: isize, | ||
| 3627 | minflt: isize, | ||
| 3628 | majflt: isize, | ||
| 3629 | nswap: isize, | ||
| 3630 | inblock: isize, | ||
| 3631 | oublock: isize, | ||
| 3632 | msgsnd: isize, | ||
| 3633 | msgrcv: isize, | ||
| 3634 | nsignals: isize, | ||
| 3635 | nvcsw: isize, | ||
| 3636 | nivcsw: isize, | ||
| 3637 | |||
| 3638 | pub const SELF = 0; | ||
| 3639 | pub const CHILDREN = -1; | ||
| 3640 | pub const THREAD = 1; | ||
| 3641 | }, | ||
| 3642 | else => void, | ||
| 3643 | }; | ||
| 3644 | |||
| 3645 | pub const siginfo_t = switch (native_os) { | ||
| 3646 | .linux => linux.siginfo_t, | ||
| 3647 | .emscripten => emscripten.siginfo_t, | ||
| 3648 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 3649 | signo: c_int, | ||
| 3650 | errno: c_int, | ||
| 3651 | code: c_int, | ||
| 3652 | pid: pid_t, | ||
| 3653 | uid: uid_t, | ||
| 3654 | status: c_int, | ||
| 3655 | addr: *allowzero anyopaque, | ||
| 3656 | value: extern union { | ||
| 3657 | int: c_int, | ||
| 3658 | ptr: *anyopaque, | ||
| 3659 | }, | ||
| 3660 | si_band: c_long, | ||
| 3661 | _pad: [7]c_ulong, | ||
| 3662 | }, | ||
| 3663 | .freebsd, .kfreebsd => extern struct { | ||
| 3664 | // Signal number. | ||
| 3665 | signo: c_int, | ||
| 3666 | // Errno association. | ||
| 3667 | errno: c_int, | ||
| 3668 | /// Signal code. | ||
| 3669 | /// | ||
| 3670 | /// Cause of signal, one of the SI_ macros or signal-specific values, i.e. | ||
| 3671 | /// one of the FPE_... values for SIGFPE. | ||
| 3672 | /// This value is equivalent to the second argument to an old-style FreeBSD | ||
| 3673 | /// signal handler. | ||
| 3674 | code: c_int, | ||
| 3675 | /// Sending process. | ||
| 3676 | pid: pid_t, | ||
| 3677 | /// Sender's ruid. | ||
| 3678 | uid: uid_t, | ||
| 3679 | /// Exit value. | ||
| 3680 | status: c_int, | ||
| 3681 | /// Faulting instruction. | ||
| 3682 | addr: *allowzero anyopaque, | ||
| 3683 | /// Signal value. | ||
| 3684 | value: sigval, | ||
| 3685 | reason: extern union { | ||
| 3686 | fault: extern struct { | ||
| 3687 | /// Machine specific trap code. | ||
| 3688 | trapno: c_int, | ||
| 3689 | }, | ||
| 3690 | timer: extern struct { | ||
| 3691 | timerid: c_int, | ||
| 3692 | overrun: c_int, | ||
| 3693 | }, | ||
| 3694 | mesgq: extern struct { | ||
| 3695 | mqd: c_int, | ||
| 3696 | }, | ||
| 3697 | poll: extern struct { | ||
| 3698 | /// Band event for SIGPOLL. UNUSED. | ||
| 3699 | band: c_long, | ||
| 3700 | }, | ||
| 3701 | spare: extern struct { | ||
| 3702 | spare1: c_long, | ||
| 3703 | spare2: [7]c_int, | ||
| 3704 | }, | ||
| 3705 | }, | ||
| 3706 | }, | ||
| 3707 | .solaris, .illumos => extern struct { | ||
| 3708 | signo: c_int, | ||
| 3709 | code: c_int, | ||
| 3710 | errno: c_int, | ||
| 3711 | // 64bit architectures insert 4bytes of padding here, this is done by | ||
| 3712 | // correctly aligning the reason field | ||
| 3713 | reason: extern union { | ||
| 3714 | proc: extern struct { | ||
| 3715 | pid: pid_t, | ||
| 3716 | pdata: extern union { | ||
| 3717 | kill: extern struct { | ||
| 3718 | uid: uid_t, | ||
| 3719 | value: sigval_t, | ||
| 3720 | }, | ||
| 3721 | cld: extern struct { | ||
| 3722 | utime: clock_t, | ||
| 3723 | status: c_int, | ||
| 3724 | stime: clock_t, | ||
| 3725 | }, | ||
| 3726 | }, | ||
| 3727 | contract: solaris.ctid_t, | ||
| 3728 | zone: solaris.zoneid_t, | ||
| 3729 | }, | ||
| 3730 | fault: extern struct { | ||
| 3731 | addr: *allowzero anyopaque, | ||
| 3732 | trapno: c_int, | ||
| 3733 | pc: ?*anyopaque, | ||
| 3734 | }, | ||
| 3735 | file: extern struct { | ||
| 3736 | // fd not currently available for SIGPOLL. | ||
| 3737 | fd: c_int, | ||
| 3738 | band: c_long, | ||
| 3739 | }, | ||
| 3740 | prof: extern struct { | ||
| 3741 | addr: ?*anyopaque, | ||
| 3742 | timestamp: timespec, | ||
| 3743 | syscall: c_short, | ||
| 3744 | sysarg: u8, | ||
| 3745 | fault: u8, | ||
| 3746 | args: [8]c_long, | ||
| 3747 | state: [10]c_int, | ||
| 3748 | }, | ||
| 3749 | rctl: extern struct { | ||
| 3750 | entity: i32, | ||
| 3751 | }, | ||
| 3752 | __pad: [256 - 4 * @sizeOf(c_int)]u8, | ||
| 3753 | } align(@sizeOf(usize)), | ||
| 3754 | |||
| 3755 | comptime { | ||
| 3756 | assert(@sizeOf(@This()) == 256); | ||
| 3757 | assert(@alignOf(@This()) == @sizeOf(usize)); | ||
| 3758 | } | ||
| 3759 | }, | ||
| 3760 | .netbsd => extern union { | ||
| 3761 | pad: [128]u8, | ||
| 3762 | info: netbsd._ksiginfo, | ||
| 3763 | }, | ||
| 3764 | .dragonfly => extern struct { | ||
| 3765 | signo: c_int, | ||
| 3766 | errno: c_int, | ||
| 3767 | code: c_int, | ||
| 3768 | pid: c_int, | ||
| 3769 | uid: uid_t, | ||
| 3770 | status: c_int, | ||
| 3771 | addr: *allowzero anyopaque, | ||
| 3772 | value: sigval, | ||
| 3773 | band: c_long, | ||
| 3774 | __spare__: [7]c_int, | ||
| 3775 | }, | ||
| 3776 | .haiku => extern struct { | ||
| 3777 | signo: i32, | ||
| 3778 | code: i32, | ||
| 3779 | errno: i32, | ||
| 3780 | |||
| 3781 | pid: pid_t, | ||
| 3782 | uid: uid_t, | ||
| 3783 | addr: *allowzero anyopaque, | ||
| 3784 | }, | ||
| 3785 | .openbsd => extern struct { | ||
| 3786 | signo: c_int, | ||
| 3787 | code: c_int, | ||
| 3788 | errno: c_int, | ||
| 3789 | data: extern union { | ||
| 3790 | proc: extern struct { | ||
| 3791 | pid: pid_t, | ||
| 3792 | pdata: extern union { | ||
| 3793 | kill: extern struct { | ||
| 3794 | uid: uid_t, | ||
| 3795 | value: sigval, | ||
| 3796 | }, | ||
| 3797 | cld: extern struct { | ||
| 3798 | utime: clock_t, | ||
| 3799 | stime: clock_t, | ||
| 3800 | status: c_int, | ||
| 3801 | }, | ||
| 3802 | }, | ||
| 3803 | }, | ||
| 3804 | fault: extern struct { | ||
| 3805 | addr: *allowzero anyopaque, | ||
| 3806 | trapno: c_int, | ||
| 3807 | }, | ||
| 3808 | __pad: [128 - 3 * @sizeOf(c_int)]u8, | ||
| 3809 | }, | ||
| 3810 | |||
| 3811 | comptime { | ||
| 3812 | if (@sizeOf(usize) == 4) | ||
| 3813 | assert(@sizeOf(@This()) == 128) | ||
| 3814 | else | ||
| 3815 | // Take into account the padding between errno and data fields. | ||
| 3816 | assert(@sizeOf(@This()) == 136); | ||
| 3817 | } | ||
| 3818 | }, | ||
| 3819 | else => void, | ||
| 3820 | }; | ||
| 3821 | pub const sigset_t = switch (native_os) { | ||
| 3822 | .linux => linux.sigset_t, | ||
| 3823 | .emscripten => emscripten.sigset_t, | ||
| 3824 | .openbsd, .macos, .ios, .tvos, .watchos, .visionos => u32, | ||
| 3825 | .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd => extern struct { | ||
| 3826 | __bits: [SIG.WORDS]u32, | ||
| 3827 | }, | ||
| 3828 | .haiku => u64, | ||
| 3829 | else => u0, | ||
| 3830 | }; | ||
| 3831 | pub const empty_sigset: sigset_t = switch (native_os) { | ||
| 3832 | .linux => linux.empty_sigset, | ||
| 3833 | .emscripten => emscripten.empty_sigset, | ||
| 3834 | .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .kfreebsd => .{ .__bits = [_]u32{0} ** SIG.WORDS }, | ||
| 3835 | else => 0, | ||
| 3836 | }; | ||
| 3837 | pub const filled_sigset = switch (native_os) { | ||
| 3838 | .linux => linux.filled_sigset, | ||
| 3839 | .haiku => ~@as(sigset_t, 0), | ||
| 3840 | else => 0, | ||
| 3841 | }; | ||
| 3842 | pub const sigval = switch (native_os) { | ||
| 3843 | .linux => linux.sigval, | ||
| 3844 | .openbsd, .dragonfly, .freebsd, .kfreebsd => extern union { | ||
| 3845 | int: c_int, | ||
| 3846 | ptr: ?*anyopaque, | ||
| 3847 | }, | ||
| 3848 | else => void, | ||
| 3849 | }; | ||
| 3850 | |||
| 3851 | pub const addrinfo = switch (native_os) { | ||
| 3852 | .linux, .emscripten => linux.addrinfo, | ||
| 3853 | .windows => ws2_32.addrinfo, | ||
| 3854 | .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 3855 | flags: AI, | ||
| 3856 | family: i32, | ||
| 3857 | socktype: i32, | ||
| 3858 | protocol: i32, | ||
| 3859 | addrlen: socklen_t, | ||
| 3860 | canonname: ?[*:0]u8, | ||
| 3861 | addr: ?*sockaddr, | ||
| 3862 | next: ?*addrinfo, | ||
| 3863 | }, | ||
| 3864 | .solaris, .illumos => extern struct { | ||
| 3865 | flags: AI, | ||
| 3866 | family: i32, | ||
| 3867 | socktype: i32, | ||
| 3868 | protocol: i32, | ||
| 3869 | addrlen: socklen_t, | ||
| 3870 | canonname: ?[*:0]u8, | ||
| 3871 | addr: ?*sockaddr, | ||
| 3872 | next: ?*addrinfo, | ||
| 3873 | }, | ||
| 3874 | .netbsd => extern struct { | ||
| 3875 | flags: AI, | ||
| 3876 | family: i32, | ||
| 3877 | socktype: i32, | ||
| 3878 | protocol: i32, | ||
| 3879 | addrlen: socklen_t, | ||
| 3880 | canonname: ?[*:0]u8, | ||
| 3881 | addr: ?*sockaddr, | ||
| 3882 | next: ?*addrinfo, | ||
| 3883 | }, | ||
| 3884 | .dragonfly => extern struct { | ||
| 3885 | flags: AI, | ||
| 3886 | family: i32, | ||
| 3887 | socktype: i32, | ||
| 3888 | protocol: i32, | ||
| 3889 | addrlen: socklen_t, | ||
| 3890 | canonname: ?[*:0]u8, | ||
| 3891 | addr: ?*sockaddr, | ||
| 3892 | next: ?*addrinfo, | ||
| 3893 | }, | ||
| 3894 | .haiku => extern struct { | ||
| 3895 | flags: AI, | ||
| 3896 | family: i32, | ||
| 3897 | socktype: i32, | ||
| 3898 | protocol: i32, | ||
| 3899 | addrlen: socklen_t, | ||
| 3900 | canonname: ?[*:0]u8, | ||
| 3901 | addr: ?*sockaddr, | ||
| 3902 | next: ?*addrinfo, | ||
| 3903 | }, | ||
| 3904 | .openbsd => extern struct { | ||
| 3905 | flags: AI, | ||
| 3906 | family: c_int, | ||
| 3907 | socktype: c_int, | ||
| 3908 | protocol: c_int, | ||
| 3909 | addrlen: socklen_t, | ||
| 3910 | addr: ?*sockaddr, | ||
| 3911 | canonname: ?[*:0]u8, | ||
| 3912 | next: ?*addrinfo, | ||
| 3913 | }, | ||
| 3914 | else => void, | ||
| 3915 | }; | ||
| 3916 | pub const sockaddr = switch (native_os) { | ||
| 3917 | .linux, .emscripten => linux.sockaddr, | ||
| 3918 | .windows => ws2_32.sockaddr, | ||
| 3919 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 3920 | len: u8, | ||
| 3921 | family: sa_family_t, | ||
| 3922 | data: [14]u8, | ||
| 3923 | |||
| 3924 | pub const SS_MAXSIZE = 128; | ||
| 3925 | pub const storage = extern struct { | ||
| 3926 | len: u8 align(8), | ||
| 3927 | family: sa_family_t, | ||
| 3928 | padding: [126]u8 = undefined, | ||
| 3929 | |||
| 3930 | comptime { | ||
| 3931 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 3932 | assert(@alignOf(storage) == 8); | ||
| 3933 | } | ||
| 3934 | }; | ||
| 3935 | pub const in = extern struct { | ||
| 3936 | len: u8 = @sizeOf(in), | ||
| 3937 | family: sa_family_t = AF.INET, | ||
| 3938 | port: in_port_t, | ||
| 3939 | addr: u32, | ||
| 3940 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 3941 | }; | ||
| 3942 | pub const in6 = extern struct { | ||
| 3943 | len: u8 = @sizeOf(in6), | ||
| 3944 | family: sa_family_t = AF.INET6, | ||
| 3945 | port: in_port_t, | ||
| 3946 | flowinfo: u32, | ||
| 3947 | addr: [16]u8, | ||
| 3948 | scope_id: u32, | ||
| 3949 | }; | ||
| 3950 | |||
| 3951 | /// UNIX domain socket | ||
| 3952 | pub const un = extern struct { | ||
| 3953 | len: u8 = @sizeOf(un), | ||
| 3954 | family: sa_family_t = AF.UNIX, | ||
| 3955 | path: [104]u8, | ||
| 3956 | }; | ||
| 3957 | }, | ||
| 3958 | .freebsd, .kfreebsd => extern struct { | ||
| 3959 | /// total length | ||
| 3960 | len: u8, | ||
| 3961 | /// address family | ||
| 3962 | family: sa_family_t, | ||
| 3963 | /// actually longer; address value | ||
| 3964 | data: [14]u8, | ||
| 3965 | |||
| 3966 | pub const SS_MAXSIZE = 128; | ||
| 3967 | pub const storage = extern struct { | ||
| 3968 | len: u8 align(8), | ||
| 3969 | family: sa_family_t, | ||
| 3970 | padding: [126]u8 = undefined, | ||
| 3971 | |||
| 3972 | comptime { | ||
| 3973 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 3974 | assert(@alignOf(storage) == 8); | ||
| 3975 | } | ||
| 3976 | }; | ||
| 3977 | |||
| 3978 | pub const in = extern struct { | ||
| 3979 | len: u8 = @sizeOf(in), | ||
| 3980 | family: sa_family_t = AF.INET, | ||
| 3981 | port: in_port_t, | ||
| 3982 | addr: u32, | ||
| 3983 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 3984 | }; | ||
| 3985 | |||
| 3986 | pub const in6 = extern struct { | ||
| 3987 | len: u8 = @sizeOf(in6), | ||
| 3988 | family: sa_family_t = AF.INET6, | ||
| 3989 | port: in_port_t, | ||
| 3990 | flowinfo: u32, | ||
| 3991 | addr: [16]u8, | ||
| 3992 | scope_id: u32, | ||
| 3993 | }; | ||
| 3994 | |||
| 3995 | pub const un = extern struct { | ||
| 3996 | len: u8 = @sizeOf(un), | ||
| 3997 | family: sa_family_t = AF.UNIX, | ||
| 3998 | path: [104]u8, | ||
| 3999 | }; | ||
| 4000 | }, | ||
| 4001 | .solaris, .illumos => extern struct { | ||
| 4002 | /// address family | ||
| 4003 | family: sa_family_t, | ||
| 4004 | |||
| 4005 | /// actually longer; address value | ||
| 4006 | data: [14]u8, | ||
| 4007 | |||
| 4008 | pub const SS_MAXSIZE = 256; | ||
| 4009 | pub const storage = extern struct { | ||
| 4010 | family: sa_family_t align(8), | ||
| 4011 | padding: [254]u8 = undefined, | ||
| 4012 | |||
| 4013 | comptime { | ||
| 4014 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 4015 | assert(@alignOf(storage) == 8); | ||
| 4016 | } | ||
| 4017 | }; | ||
| 4018 | |||
| 4019 | pub const in = extern struct { | ||
| 4020 | family: sa_family_t = AF.INET, | ||
| 4021 | port: in_port_t, | ||
| 4022 | addr: u32, | ||
| 4023 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 4024 | }; | ||
| 4025 | |||
| 4026 | pub const in6 = extern struct { | ||
| 4027 | family: sa_family_t = AF.INET6, | ||
| 4028 | port: in_port_t, | ||
| 4029 | flowinfo: u32, | ||
| 4030 | addr: [16]u8, | ||
| 4031 | scope_id: u32, | ||
| 4032 | __src_id: u32 = 0, | ||
| 4033 | }; | ||
| 4034 | |||
| 4035 | /// Definitions for UNIX IPC domain. | ||
| 4036 | pub const un = extern struct { | ||
| 4037 | family: sa_family_t = AF.UNIX, | ||
| 4038 | path: [108]u8, | ||
| 4039 | }; | ||
| 4040 | }, | ||
| 4041 | .netbsd => extern struct { | ||
| 4042 | /// total length | ||
| 4043 | len: u8, | ||
| 4044 | /// address family | ||
| 4045 | family: sa_family_t, | ||
| 4046 | /// actually longer; address value | ||
| 4047 | data: [14]u8, | ||
| 4048 | |||
| 4049 | pub const SS_MAXSIZE = 128; | ||
| 4050 | pub const storage = extern struct { | ||
| 4051 | len: u8 align(8), | ||
| 4052 | family: sa_family_t, | ||
| 4053 | padding: [126]u8 = undefined, | ||
| 4054 | |||
| 4055 | comptime { | ||
| 4056 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 4057 | assert(@alignOf(storage) == 8); | ||
| 4058 | } | ||
| 4059 | }; | ||
| 4060 | |||
| 4061 | pub const in = extern struct { | ||
| 4062 | len: u8 = @sizeOf(in), | ||
| 4063 | family: sa_family_t = AF.INET, | ||
| 4064 | port: in_port_t, | ||
| 4065 | addr: u32, | ||
| 4066 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 4067 | }; | ||
| 4068 | |||
| 4069 | pub const in6 = extern struct { | ||
| 4070 | len: u8 = @sizeOf(in6), | ||
| 4071 | family: sa_family_t = AF.INET6, | ||
| 4072 | port: in_port_t, | ||
| 4073 | flowinfo: u32, | ||
| 4074 | addr: [16]u8, | ||
| 4075 | scope_id: u32, | ||
| 4076 | }; | ||
| 4077 | |||
| 4078 | /// Definitions for UNIX IPC domain. | ||
| 4079 | pub const un = extern struct { | ||
| 4080 | /// total sockaddr length | ||
| 4081 | len: u8 = @sizeOf(un), | ||
| 4082 | |||
| 4083 | family: sa_family_t = AF.LOCAL, | ||
| 4084 | |||
| 4085 | /// path name | ||
| 4086 | path: [104]u8, | ||
| 4087 | }; | ||
| 4088 | }, | ||
| 4089 | .dragonfly => extern struct { | ||
| 4090 | len: u8, | ||
| 4091 | family: sa_family_t, | ||
| 4092 | data: [14]u8, | ||
| 4093 | |||
| 4094 | pub const SS_MAXSIZE = 128; | ||
| 4095 | pub const storage = extern struct { | ||
| 4096 | len: u8 align(8), | ||
| 4097 | family: sa_family_t, | ||
| 4098 | padding: [126]u8 = undefined, | ||
| 4099 | |||
| 4100 | comptime { | ||
| 4101 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 4102 | assert(@alignOf(storage) == 8); | ||
| 4103 | } | ||
| 4104 | }; | ||
| 4105 | |||
| 4106 | pub const in = extern struct { | ||
| 4107 | len: u8 = @sizeOf(in), | ||
| 4108 | family: sa_family_t = AF.INET, | ||
| 4109 | port: in_port_t, | ||
| 4110 | addr: u32, | ||
| 4111 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 4112 | }; | ||
| 4113 | |||
| 4114 | pub const in6 = extern struct { | ||
| 4115 | len: u8 = @sizeOf(in6), | ||
| 4116 | family: sa_family_t = AF.INET6, | ||
| 4117 | port: in_port_t, | ||
| 4118 | flowinfo: u32, | ||
| 4119 | addr: [16]u8, | ||
| 4120 | scope_id: u32, | ||
| 4121 | }; | ||
| 4122 | |||
| 4123 | pub const un = extern struct { | ||
| 4124 | len: u8 = @sizeOf(un), | ||
| 4125 | family: sa_family_t = AF.UNIX, | ||
| 4126 | path: [104]u8, | ||
| 4127 | }; | ||
| 4128 | }, | ||
| 4129 | .haiku => extern struct { | ||
| 4130 | /// total length | ||
| 4131 | len: u8, | ||
| 4132 | /// address family | ||
| 4133 | family: sa_family_t, | ||
| 4134 | /// actually longer; address value | ||
| 4135 | data: [14]u8, | ||
| 4136 | |||
| 4137 | pub const SS_MAXSIZE = 128; | ||
| 4138 | pub const storage = extern struct { | ||
| 4139 | len: u8 align(8), | ||
| 4140 | family: sa_family_t, | ||
| 4141 | padding: [126]u8 = undefined, | ||
| 4142 | |||
| 4143 | comptime { | ||
| 4144 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 4145 | assert(@alignOf(storage) == 8); | ||
| 4146 | } | ||
| 4147 | }; | ||
| 4148 | |||
| 4149 | pub const in = extern struct { | ||
| 4150 | len: u8 = @sizeOf(in), | ||
| 4151 | family: sa_family_t = AF.INET, | ||
| 4152 | port: in_port_t, | ||
| 4153 | addr: u32, | ||
| 4154 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 4155 | }; | ||
| 4156 | |||
| 4157 | pub const in6 = extern struct { | ||
| 4158 | len: u8 = @sizeOf(in6), | ||
| 4159 | family: sa_family_t = AF.INET6, | ||
| 4160 | port: in_port_t, | ||
| 4161 | flowinfo: u32, | ||
| 4162 | addr: [16]u8, | ||
| 4163 | scope_id: u32, | ||
| 4164 | }; | ||
| 4165 | |||
| 4166 | pub const un = extern struct { | ||
| 4167 | len: u8 = @sizeOf(un), | ||
| 4168 | family: sa_family_t = AF.UNIX, | ||
| 4169 | path: [104]u8, | ||
| 4170 | }; | ||
| 4171 | }, | ||
| 4172 | .openbsd => extern struct { | ||
| 4173 | /// total length | ||
| 4174 | len: u8, | ||
| 4175 | /// address family | ||
| 4176 | family: sa_family_t, | ||
| 4177 | /// actually longer; address value | ||
| 4178 | data: [14]u8, | ||
| 4179 | |||
| 4180 | pub const SS_MAXSIZE = 256; | ||
| 4181 | pub const storage = extern struct { | ||
| 4182 | len: u8 align(8), | ||
| 4183 | family: sa_family_t, | ||
| 4184 | padding: [254]u8 = undefined, | ||
| 4185 | |||
| 4186 | comptime { | ||
| 4187 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 4188 | assert(@alignOf(storage) == 8); | ||
| 4189 | } | ||
| 4190 | }; | ||
| 4191 | |||
| 4192 | pub const in = extern struct { | ||
| 4193 | len: u8 = @sizeOf(in), | ||
| 4194 | family: sa_family_t = AF.INET, | ||
| 4195 | port: in_port_t, | ||
| 4196 | addr: u32, | ||
| 4197 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 4198 | }; | ||
| 4199 | |||
| 4200 | pub const in6 = extern struct { | ||
| 4201 | len: u8 = @sizeOf(in6), | ||
| 4202 | family: sa_family_t = AF.INET6, | ||
| 4203 | port: in_port_t, | ||
| 4204 | flowinfo: u32, | ||
| 4205 | addr: [16]u8, | ||
| 4206 | scope_id: u32, | ||
| 4207 | }; | ||
| 4208 | |||
| 4209 | /// Definitions for UNIX IPC domain. | ||
| 4210 | pub const un = extern struct { | ||
| 4211 | /// total sockaddr length | ||
| 4212 | len: u8 = @sizeOf(un), | ||
| 4213 | |||
| 4214 | family: sa_family_t = AF.LOCAL, | ||
| 4215 | |||
| 4216 | /// path name | ||
| 4217 | path: [104]u8, | ||
| 4218 | }; | ||
| 4219 | }, | ||
| 4220 | else => void, | ||
| 4221 | }; | ||
| 4222 | pub const socklen_t = switch (native_os) { | ||
| 4223 | .linux, .emscripten => linux.socklen_t, | ||
| 4224 | .windows => ws2_32.socklen_t, | ||
| 4225 | else => u32, | ||
| 4226 | }; | ||
| 4227 | pub const in_port_t = u16; | ||
| 4228 | pub const sa_family_t = switch (native_os) { | ||
| 4229 | .linux, .emscripten => linux.sa_family_t, | ||
| 4230 | .windows => ws2_32.ADDRESS_FAMILY, | ||
| 4231 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => u8, | ||
| 4232 | .solaris, .illumos => u16, | ||
| 4233 | else => void, | ||
| 4234 | }; | ||
| 4235 | pub const AF = switch (native_os) { | ||
| 4236 | .linux, .emscripten => linux.AF, | ||
| 4237 | .windows => ws2_32.AF, | ||
| 4238 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 4239 | pub const UNSPEC = 0; | ||
| 4240 | pub const LOCAL = 1; | ||
| 4241 | pub const UNIX = LOCAL; | ||
| 4242 | pub const INET = 2; | ||
| 4243 | pub const SYS_CONTROL = 2; | ||
| 4244 | pub const IMPLINK = 3; | ||
| 4245 | pub const PUP = 4; | ||
| 4246 | pub const CHAOS = 5; | ||
| 4247 | pub const NS = 6; | ||
| 4248 | pub const ISO = 7; | ||
| 4249 | pub const OSI = ISO; | ||
| 4250 | pub const ECMA = 8; | ||
| 4251 | pub const DATAKIT = 9; | ||
| 4252 | pub const CCITT = 10; | ||
| 4253 | pub const SNA = 11; | ||
| 4254 | pub const DECnet = 12; | ||
| 4255 | pub const DLI = 13; | ||
| 4256 | pub const LAT = 14; | ||
| 4257 | pub const HYLINK = 15; | ||
| 4258 | pub const APPLETALK = 16; | ||
| 4259 | pub const ROUTE = 17; | ||
| 4260 | pub const LINK = 18; | ||
| 4261 | pub const XTP = 19; | ||
| 4262 | pub const COIP = 20; | ||
| 4263 | pub const CNT = 21; | ||
| 4264 | pub const RTIP = 22; | ||
| 4265 | pub const IPX = 23; | ||
| 4266 | pub const SIP = 24; | ||
| 4267 | pub const PIP = 25; | ||
| 4268 | pub const ISDN = 28; | ||
| 4269 | pub const E164 = ISDN; | ||
| 4270 | pub const KEY = 29; | ||
| 4271 | pub const INET6 = 30; | ||
| 4272 | pub const NATM = 31; | ||
| 4273 | pub const SYSTEM = 32; | ||
| 4274 | pub const NETBIOS = 33; | ||
| 4275 | pub const PPP = 34; | ||
| 4276 | pub const MAX = 40; | ||
| 4277 | }, | ||
| 4278 | .freebsd, .kfreebsd => struct { | ||
| 4279 | pub const UNSPEC = 0; | ||
| 4280 | pub const UNIX = 1; | ||
| 4281 | pub const LOCAL = UNIX; | ||
| 4282 | pub const FILE = LOCAL; | ||
| 4283 | pub const INET = 2; | ||
| 4284 | pub const IMPLINK = 3; | ||
| 4285 | pub const PUP = 4; | ||
| 4286 | pub const CHAOS = 5; | ||
| 4287 | pub const NETBIOS = 6; | ||
| 4288 | pub const ISO = 7; | ||
| 4289 | pub const OSI = ISO; | ||
| 4290 | pub const ECMA = 8; | ||
| 4291 | pub const DATAKIT = 9; | ||
| 4292 | pub const CCITT = 10; | ||
| 4293 | pub const SNA = 11; | ||
| 4294 | pub const DECnet = 12; | ||
| 4295 | pub const DLI = 13; | ||
| 4296 | pub const LAT = 14; | ||
| 4297 | pub const HYLINK = 15; | ||
| 4298 | pub const APPLETALK = 16; | ||
| 4299 | pub const ROUTE = 17; | ||
| 4300 | pub const LINK = 18; | ||
| 4301 | pub const pseudo_XTP = 19; | ||
| 4302 | pub const COIP = 20; | ||
| 4303 | pub const CNT = 21; | ||
| 4304 | pub const pseudo_RTIP = 22; | ||
| 4305 | pub const IPX = 23; | ||
| 4306 | pub const SIP = 24; | ||
| 4307 | pub const pseudo_PIP = 25; | ||
| 4308 | pub const ISDN = 26; | ||
| 4309 | pub const E164 = ISDN; | ||
| 4310 | pub const pseudo_KEY = 27; | ||
| 4311 | pub const INET6 = 28; | ||
| 4312 | pub const NATM = 29; | ||
| 4313 | pub const ATM = 30; | ||
| 4314 | pub const pseudo_HDRCMPLT = 31; | ||
| 4315 | pub const NETGRAPH = 32; | ||
| 4316 | pub const SLOW = 33; | ||
| 4317 | pub const SCLUSTER = 34; | ||
| 4318 | pub const ARP = 35; | ||
| 4319 | pub const BLUETOOTH = 36; | ||
| 4320 | pub const IEEE80211 = 37; | ||
| 4321 | pub const INET_SDP = 40; | ||
| 4322 | pub const INET6_SDP = 42; | ||
| 4323 | pub const MAX = 42; | ||
| 4324 | }, | ||
| 4325 | .solaris, .illumos => struct { | ||
| 4326 | pub const UNSPEC = 0; | ||
| 4327 | pub const UNIX = 1; | ||
| 4328 | pub const LOCAL = UNIX; | ||
| 4329 | pub const FILE = UNIX; | ||
| 4330 | pub const INET = 2; | ||
| 4331 | pub const IMPLINK = 3; | ||
| 4332 | pub const PUP = 4; | ||
| 4333 | pub const CHAOS = 5; | ||
| 4334 | pub const NS = 6; | ||
| 4335 | pub const NBS = 7; | ||
| 4336 | pub const ECMA = 8; | ||
| 4337 | pub const DATAKIT = 9; | ||
| 4338 | pub const CCITT = 10; | ||
| 4339 | pub const SNA = 11; | ||
| 4340 | pub const DECnet = 12; | ||
| 4341 | pub const DLI = 13; | ||
| 4342 | pub const LAT = 14; | ||
| 4343 | pub const HYLINK = 15; | ||
| 4344 | pub const APPLETALK = 16; | ||
| 4345 | pub const NIT = 17; | ||
| 4346 | pub const @"802" = 18; | ||
| 4347 | pub const OSI = 19; | ||
| 4348 | pub const X25 = 20; | ||
| 4349 | pub const OSINET = 21; | ||
| 4350 | pub const GOSIP = 22; | ||
| 4351 | pub const IPX = 23; | ||
| 4352 | pub const ROUTE = 24; | ||
| 4353 | pub const LINK = 25; | ||
| 4354 | pub const INET6 = 26; | ||
| 4355 | pub const KEY = 27; | ||
| 4356 | pub const NCA = 28; | ||
| 4357 | pub const POLICY = 29; | ||
| 4358 | pub const INET_OFFLOAD = 30; | ||
| 4359 | pub const TRILL = 31; | ||
| 4360 | pub const PACKET = 32; | ||
| 4361 | pub const LX_NETLINK = 33; | ||
| 4362 | pub const MAX = 33; | ||
| 4363 | }, | ||
| 4364 | .netbsd => struct { | ||
| 4365 | pub const UNSPEC = 0; | ||
| 4366 | pub const LOCAL = 1; | ||
| 4367 | pub const UNIX = LOCAL; | ||
| 4368 | pub const INET = 2; | ||
| 4369 | pub const IMPLINK = 3; | ||
| 4370 | pub const PUP = 4; | ||
| 4371 | pub const CHAOS = 5; | ||
| 4372 | pub const NS = 6; | ||
| 4373 | pub const ISO = 7; | ||
| 4374 | pub const OSI = ISO; | ||
| 4375 | pub const ECMA = 8; | ||
| 4376 | pub const DATAKIT = 9; | ||
| 4377 | pub const CCITT = 10; | ||
| 4378 | pub const SNA = 11; | ||
| 4379 | pub const DECnet = 12; | ||
| 4380 | pub const DLI = 13; | ||
| 4381 | pub const LAT = 14; | ||
| 4382 | pub const HYLINK = 15; | ||
| 4383 | pub const APPLETALK = 16; | ||
| 4384 | pub const OROUTE = 17; | ||
| 4385 | pub const LINK = 18; | ||
| 4386 | pub const COIP = 20; | ||
| 4387 | pub const CNT = 21; | ||
| 4388 | pub const IPX = 23; | ||
| 4389 | pub const INET6 = 24; | ||
| 4390 | pub const ISDN = 26; | ||
| 4391 | pub const E164 = ISDN; | ||
| 4392 | pub const NATM = 27; | ||
| 4393 | pub const ARP = 28; | ||
| 4394 | pub const BLUETOOTH = 31; | ||
| 4395 | pub const IEEE80211 = 32; | ||
| 4396 | pub const MPLS = 33; | ||
| 4397 | pub const ROUTE = 34; | ||
| 4398 | pub const CAN = 35; | ||
| 4399 | pub const ETHER = 36; | ||
| 4400 | pub const MAX = 37; | ||
| 4401 | }, | ||
| 4402 | .dragonfly => struct { | ||
| 4403 | pub const UNSPEC = 0; | ||
| 4404 | pub const OSI = ISO; | ||
| 4405 | pub const UNIX = LOCAL; | ||
| 4406 | pub const LOCAL = 1; | ||
| 4407 | pub const INET = 2; | ||
| 4408 | pub const IMPLINK = 3; | ||
| 4409 | pub const PUP = 4; | ||
| 4410 | pub const CHAOS = 5; | ||
| 4411 | pub const NETBIOS = 6; | ||
| 4412 | pub const ISO = 7; | ||
| 4413 | pub const ECMA = 8; | ||
| 4414 | pub const DATAKIT = 9; | ||
| 4415 | pub const CCITT = 10; | ||
| 4416 | pub const SNA = 11; | ||
| 4417 | pub const DLI = 13; | ||
| 4418 | pub const LAT = 14; | ||
| 4419 | pub const HYLINK = 15; | ||
| 4420 | pub const APPLETALK = 16; | ||
| 4421 | pub const ROUTE = 17; | ||
| 4422 | pub const LINK = 18; | ||
| 4423 | pub const COIP = 20; | ||
| 4424 | pub const CNT = 21; | ||
| 4425 | pub const IPX = 23; | ||
| 4426 | pub const SIP = 24; | ||
| 4427 | pub const ISDN = 26; | ||
| 4428 | pub const INET6 = 28; | ||
| 4429 | pub const NATM = 29; | ||
| 4430 | pub const ATM = 30; | ||
| 4431 | pub const NETGRAPH = 32; | ||
| 4432 | pub const BLUETOOTH = 33; | ||
| 4433 | pub const MPLS = 34; | ||
| 4434 | pub const MAX = 36; | ||
| 4435 | }, | ||
| 4436 | .haiku => struct { | ||
| 4437 | pub const UNSPEC = 0; | ||
| 4438 | pub const INET = 1; | ||
| 4439 | pub const APPLETALK = 2; | ||
| 4440 | pub const ROUTE = 3; | ||
| 4441 | pub const LINK = 4; | ||
| 4442 | pub const INET6 = 5; | ||
| 4443 | pub const DLI = 6; | ||
| 4444 | pub const IPX = 7; | ||
| 4445 | pub const NOTIFY = 8; | ||
| 4446 | pub const LOCAL = 9; | ||
| 4447 | pub const UNIX = LOCAL; | ||
| 4448 | pub const BLUETOOTH = 10; | ||
| 4449 | pub const MAX = 11; | ||
| 4450 | }, | ||
| 4451 | .openbsd => struct { | ||
| 4452 | pub const UNSPEC = 0; | ||
| 4453 | pub const UNIX = 1; | ||
| 4454 | pub const LOCAL = UNIX; | ||
| 4455 | pub const INET = 2; | ||
| 4456 | pub const APPLETALK = 16; | ||
| 4457 | pub const INET6 = 24; | ||
| 4458 | pub const KEY = 30; | ||
| 4459 | pub const ROUTE = 17; | ||
| 4460 | pub const SNA = 11; | ||
| 4461 | pub const MPLS = 33; | ||
| 4462 | pub const BLUETOOTH = 32; | ||
| 4463 | pub const ISDN = 26; | ||
| 4464 | pub const MAX = 36; | ||
| 4465 | }, | ||
| 4466 | else => void, | ||
| 4467 | }; | ||
| 4468 | pub const PF = switch (native_os) { | ||
| 4469 | .linux, .emscripten => linux.PF, | ||
| 4470 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 4471 | pub const UNSPEC = AF.UNSPEC; | ||
| 4472 | pub const LOCAL = AF.LOCAL; | ||
| 4473 | pub const UNIX = PF.LOCAL; | ||
| 4474 | pub const INET = AF.INET; | ||
| 4475 | pub const IMPLINK = AF.IMPLINK; | ||
| 4476 | pub const PUP = AF.PUP; | ||
| 4477 | pub const CHAOS = AF.CHAOS; | ||
| 4478 | pub const NS = AF.NS; | ||
| 4479 | pub const ISO = AF.ISO; | ||
| 4480 | pub const OSI = AF.ISO; | ||
| 4481 | pub const ECMA = AF.ECMA; | ||
| 4482 | pub const DATAKIT = AF.DATAKIT; | ||
| 4483 | pub const CCITT = AF.CCITT; | ||
| 4484 | pub const SNA = AF.SNA; | ||
| 4485 | pub const DECnet = AF.DECnet; | ||
| 4486 | pub const DLI = AF.DLI; | ||
| 4487 | pub const LAT = AF.LAT; | ||
| 4488 | pub const HYLINK = AF.HYLINK; | ||
| 4489 | pub const APPLETALK = AF.APPLETALK; | ||
| 4490 | pub const ROUTE = AF.ROUTE; | ||
| 4491 | pub const LINK = AF.LINK; | ||
| 4492 | pub const XTP = AF.XTP; | ||
| 4493 | pub const COIP = AF.COIP; | ||
| 4494 | pub const CNT = AF.CNT; | ||
| 4495 | pub const SIP = AF.SIP; | ||
| 4496 | pub const IPX = AF.IPX; | ||
| 4497 | pub const RTIP = AF.RTIP; | ||
| 4498 | pub const PIP = AF.PIP; | ||
| 4499 | pub const ISDN = AF.ISDN; | ||
| 4500 | pub const KEY = AF.KEY; | ||
| 4501 | pub const INET6 = AF.INET6; | ||
| 4502 | pub const NATM = AF.NATM; | ||
| 4503 | pub const SYSTEM = AF.SYSTEM; | ||
| 4504 | pub const NETBIOS = AF.NETBIOS; | ||
| 4505 | pub const PPP = AF.PPP; | ||
| 4506 | pub const MAX = AF.MAX; | ||
| 4507 | }, | ||
| 4508 | .freebsd, .kfreebsd => struct { | ||
| 4509 | pub const UNSPEC = AF.UNSPEC; | ||
| 4510 | pub const LOCAL = AF.LOCAL; | ||
| 4511 | pub const UNIX = PF.LOCAL; | ||
| 4512 | pub const INET = AF.INET; | ||
| 4513 | pub const IMPLINK = AF.IMPLINK; | ||
| 4514 | pub const PUP = AF.PUP; | ||
| 4515 | pub const CHAOS = AF.CHAOS; | ||
| 4516 | pub const NETBIOS = AF.NETBIOS; | ||
| 4517 | pub const ISO = AF.ISO; | ||
| 4518 | pub const OSI = AF.ISO; | ||
| 4519 | pub const ECMA = AF.ECMA; | ||
| 4520 | pub const DATAKIT = AF.DATAKIT; | ||
| 4521 | pub const CCITT = AF.CCITT; | ||
| 4522 | pub const DECnet = AF.DECnet; | ||
| 4523 | pub const DLI = AF.DLI; | ||
| 4524 | pub const LAT = AF.LAT; | ||
| 4525 | pub const HYLINK = AF.HYLINK; | ||
| 4526 | pub const APPLETALK = AF.APPLETALK; | ||
| 4527 | pub const ROUTE = AF.ROUTE; | ||
| 4528 | pub const LINK = AF.LINK; | ||
| 4529 | pub const XTP = AF.pseudo_XTP; | ||
| 4530 | pub const COIP = AF.COIP; | ||
| 4531 | pub const CNT = AF.CNT; | ||
| 4532 | pub const SIP = AF.SIP; | ||
| 4533 | pub const IPX = AF.IPX; | ||
| 4534 | pub const RTIP = AF.pseudo_RTIP; | ||
| 4535 | pub const PIP = AF.pseudo_PIP; | ||
| 4536 | pub const ISDN = AF.ISDN; | ||
| 4537 | pub const KEY = AF.pseudo_KEY; | ||
| 4538 | pub const INET6 = AF.pseudo_INET6; | ||
| 4539 | pub const NATM = AF.NATM; | ||
| 4540 | pub const ATM = AF.ATM; | ||
| 4541 | pub const NETGRAPH = AF.NETGRAPH; | ||
| 4542 | pub const SLOW = AF.SLOW; | ||
| 4543 | pub const SCLUSTER = AF.SCLUSTER; | ||
| 4544 | pub const ARP = AF.ARP; | ||
| 4545 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 4546 | pub const IEEE80211 = AF.IEEE80211; | ||
| 4547 | pub const INET_SDP = AF.INET_SDP; | ||
| 4548 | pub const INET6_SDP = AF.INET6_SDP; | ||
| 4549 | pub const MAX = AF.MAX; | ||
| 4550 | }, | ||
| 4551 | .solaris, .illumos => struct { | ||
| 4552 | pub const UNSPEC = AF.UNSPEC; | ||
| 4553 | pub const UNIX = AF.UNIX; | ||
| 4554 | pub const LOCAL = UNIX; | ||
| 4555 | pub const FILE = UNIX; | ||
| 4556 | pub const INET = AF.INET; | ||
| 4557 | pub const IMPLINK = AF.IMPLINK; | ||
| 4558 | pub const PUP = AF.PUP; | ||
| 4559 | pub const CHAOS = AF.CHAOS; | ||
| 4560 | pub const NS = AF.NS; | ||
| 4561 | pub const NBS = AF.NBS; | ||
| 4562 | pub const ECMA = AF.ECMA; | ||
| 4563 | pub const DATAKIT = AF.DATAKIT; | ||
| 4564 | pub const CCITT = AF.CCITT; | ||
| 4565 | pub const SNA = AF.SNA; | ||
| 4566 | pub const DECnet = AF.DECnet; | ||
| 4567 | pub const DLI = AF.DLI; | ||
| 4568 | pub const LAT = AF.LAT; | ||
| 4569 | pub const HYLINK = AF.HYLINK; | ||
| 4570 | pub const APPLETALK = AF.APPLETALK; | ||
| 4571 | pub const NIT = AF.NIT; | ||
| 4572 | pub const @"802" = AF.@"802"; | ||
| 4573 | pub const OSI = AF.OSI; | ||
| 4574 | pub const X25 = AF.X25; | ||
| 4575 | pub const OSINET = AF.OSINET; | ||
| 4576 | pub const GOSIP = AF.GOSIP; | ||
| 4577 | pub const IPX = AF.IPX; | ||
| 4578 | pub const ROUTE = AF.ROUTE; | ||
| 4579 | pub const LINK = AF.LINK; | ||
| 4580 | pub const INET6 = AF.INET6; | ||
| 4581 | pub const KEY = AF.KEY; | ||
| 4582 | pub const NCA = AF.NCA; | ||
| 4583 | pub const POLICY = AF.POLICY; | ||
| 4584 | pub const TRILL = AF.TRILL; | ||
| 4585 | pub const PACKET = AF.PACKET; | ||
| 4586 | pub const LX_NETLINK = AF.LX_NETLINK; | ||
| 4587 | pub const MAX = AF.MAX; | ||
| 4588 | }, | ||
| 4589 | .netbsd => struct { | ||
| 4590 | pub const UNSPEC = AF.UNSPEC; | ||
| 4591 | pub const LOCAL = AF.LOCAL; | ||
| 4592 | pub const UNIX = PF.LOCAL; | ||
| 4593 | pub const INET = AF.INET; | ||
| 4594 | pub const IMPLINK = AF.IMPLINK; | ||
| 4595 | pub const PUP = AF.PUP; | ||
| 4596 | pub const CHAOS = AF.CHAOS; | ||
| 4597 | pub const NS = AF.NS; | ||
| 4598 | pub const ISO = AF.ISO; | ||
| 4599 | pub const OSI = AF.ISO; | ||
| 4600 | pub const ECMA = AF.ECMA; | ||
| 4601 | pub const DATAKIT = AF.DATAKIT; | ||
| 4602 | pub const CCITT = AF.CCITT; | ||
| 4603 | pub const SNA = AF.SNA; | ||
| 4604 | pub const DECnet = AF.DECnet; | ||
| 4605 | pub const DLI = AF.DLI; | ||
| 4606 | pub const LAT = AF.LAT; | ||
| 4607 | pub const HYLINK = AF.HYLINK; | ||
| 4608 | pub const APPLETALK = AF.APPLETALK; | ||
| 4609 | pub const OROUTE = AF.OROUTE; | ||
| 4610 | pub const LINK = AF.LINK; | ||
| 4611 | pub const COIP = AF.COIP; | ||
| 4612 | pub const CNT = AF.CNT; | ||
| 4613 | pub const INET6 = AF.INET6; | ||
| 4614 | pub const IPX = AF.IPX; | ||
| 4615 | pub const ISDN = AF.ISDN; | ||
| 4616 | pub const E164 = AF.E164; | ||
| 4617 | pub const NATM = AF.NATM; | ||
| 4618 | pub const ARP = AF.ARP; | ||
| 4619 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 4620 | pub const MPLS = AF.MPLS; | ||
| 4621 | pub const ROUTE = AF.ROUTE; | ||
| 4622 | pub const CAN = AF.CAN; | ||
| 4623 | pub const ETHER = AF.ETHER; | ||
| 4624 | pub const MAX = AF.MAX; | ||
| 4625 | }, | ||
| 4626 | .dragonfly => struct { | ||
| 4627 | pub const INET6 = AF.INET6; | ||
| 4628 | pub const IMPLINK = AF.IMPLINK; | ||
| 4629 | pub const ROUTE = AF.ROUTE; | ||
| 4630 | pub const ISO = AF.ISO; | ||
| 4631 | pub const PIP = AF.pseudo_PIP; | ||
| 4632 | pub const CHAOS = AF.CHAOS; | ||
| 4633 | pub const DATAKIT = AF.DATAKIT; | ||
| 4634 | pub const INET = AF.INET; | ||
| 4635 | pub const APPLETALK = AF.APPLETALK; | ||
| 4636 | pub const SIP = AF.SIP; | ||
| 4637 | pub const OSI = AF.ISO; | ||
| 4638 | pub const CNT = AF.CNT; | ||
| 4639 | pub const LINK = AF.LINK; | ||
| 4640 | pub const HYLINK = AF.HYLINK; | ||
| 4641 | pub const MAX = AF.MAX; | ||
| 4642 | pub const KEY = AF.pseudo_KEY; | ||
| 4643 | pub const PUP = AF.PUP; | ||
| 4644 | pub const COIP = AF.COIP; | ||
| 4645 | pub const SNA = AF.SNA; | ||
| 4646 | pub const LOCAL = AF.LOCAL; | ||
| 4647 | pub const NETBIOS = AF.NETBIOS; | ||
| 4648 | pub const NATM = AF.NATM; | ||
| 4649 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 4650 | pub const UNSPEC = AF.UNSPEC; | ||
| 4651 | pub const NETGRAPH = AF.NETGRAPH; | ||
| 4652 | pub const ECMA = AF.ECMA; | ||
| 4653 | pub const IPX = AF.IPX; | ||
| 4654 | pub const DLI = AF.DLI; | ||
| 4655 | pub const ATM = AF.ATM; | ||
| 4656 | pub const CCITT = AF.CCITT; | ||
| 4657 | pub const ISDN = AF.ISDN; | ||
| 4658 | pub const RTIP = AF.pseudo_RTIP; | ||
| 4659 | pub const LAT = AF.LAT; | ||
| 4660 | pub const UNIX = PF.LOCAL; | ||
| 4661 | pub const XTP = AF.pseudo_XTP; | ||
| 4662 | pub const DECnet = AF.DECnet; | ||
| 4663 | }, | ||
| 4664 | .haiku => struct { | ||
| 4665 | pub const UNSPEC = AF.UNSPEC; | ||
| 4666 | pub const INET = AF.INET; | ||
| 4667 | pub const ROUTE = AF.ROUTE; | ||
| 4668 | pub const LINK = AF.LINK; | ||
| 4669 | pub const INET6 = AF.INET6; | ||
| 4670 | pub const LOCAL = AF.LOCAL; | ||
| 4671 | pub const UNIX = AF.UNIX; | ||
| 4672 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 4673 | }, | ||
| 4674 | .openbsd => struct { | ||
| 4675 | pub const UNSPEC = AF.UNSPEC; | ||
| 4676 | pub const LOCAL = AF.LOCAL; | ||
| 4677 | pub const UNIX = AF.UNIX; | ||
| 4678 | pub const INET = AF.INET; | ||
| 4679 | pub const APPLETALK = AF.APPLETALK; | ||
| 4680 | pub const INET6 = AF.INET6; | ||
| 4681 | pub const DECnet = AF.DECnet; | ||
| 4682 | pub const KEY = AF.KEY; | ||
| 4683 | pub const ROUTE = AF.ROUTE; | ||
| 4684 | pub const SNA = AF.SNA; | ||
| 4685 | pub const MPLS = AF.MPLS; | ||
| 4686 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 4687 | pub const ISDN = AF.ISDN; | ||
| 4688 | pub const MAX = AF.MAX; | ||
| 4689 | }, | ||
| 4690 | else => void, | ||
| 4691 | }; | ||
| 4692 | pub const DT = switch (native_os) { | ||
| 4693 | .linux => linux.DT, | ||
| 4694 | .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 4695 | pub const UNKNOWN = 0; | ||
| 4696 | pub const FIFO = 1; | ||
| 4697 | pub const CHR = 2; | ||
| 4698 | pub const DIR = 4; | ||
| 4699 | pub const BLK = 6; | ||
| 4700 | pub const REG = 8; | ||
| 4701 | pub const LNK = 10; | ||
| 4702 | pub const SOCK = 12; | ||
| 4703 | pub const WHT = 14; | ||
| 4704 | }, | ||
| 4705 | .dragonfly => struct { | ||
| 4706 | pub const UNKNOWN = 0; | ||
| 4707 | pub const FIFO = 1; | ||
| 4708 | pub const CHR = 2; | ||
| 4709 | pub const DIR = 4; | ||
| 4710 | pub const BLK = 6; | ||
| 4711 | pub const REG = 8; | ||
| 4712 | pub const LNK = 10; | ||
| 4713 | pub const SOCK = 12; | ||
| 4714 | pub const WHT = 14; | ||
| 4715 | pub const DBF = 15; | ||
| 4716 | }, | ||
| 4717 | .openbsd => struct { | ||
| 4718 | pub const UNKNOWN = 0; | ||
| 4719 | pub const FIFO = 1; | ||
| 4720 | pub const CHR = 2; | ||
| 4721 | pub const DIR = 4; | ||
| 4722 | pub const BLK = 6; | ||
| 4723 | pub const REG = 8; | ||
| 4724 | pub const LNK = 10; | ||
| 4725 | pub const SOCK = 12; | ||
| 4726 | pub const WHT = 14; // XXX | ||
| 4727 | }, | ||
| 4728 | else => void, | ||
| 4729 | }; | ||
| 4730 | pub const MSG = switch (native_os) { | ||
| 4731 | .linux => linux.MSG, | ||
| 4732 | .emscripten => emscripten.MSG, | ||
| 4733 | .windows => ws2_32.MSG, | ||
| 4734 | .haiku => struct { | ||
| 4735 | pub const OOB = 0x0001; | ||
| 4736 | pub const PEEK = 0x0002; | ||
| 4737 | pub const DONTROUTE = 0x0004; | ||
| 4738 | pub const EOR = 0x0008; | ||
| 4739 | pub const TRUNC = 0x0010; | ||
| 4740 | pub const CTRUNC = 0x0020; | ||
| 4741 | pub const WAITALL = 0x0040; | ||
| 4742 | pub const DONTWAIT = 0x0080; | ||
| 4743 | pub const BCAST = 0x0100; | ||
| 4744 | pub const MCAST = 0x0200; | ||
| 4745 | pub const EOF = 0x0400; | ||
| 4746 | pub const NOSIGNAL = 0x0800; | ||
| 4747 | }, | ||
| 4748 | else => void, | ||
| 4749 | }; | ||
| 4750 | pub const SOCK = switch (native_os) { | ||
| 4751 | .linux => linux.SOCK, | ||
| 4752 | .emscripten => emscripten.SOCK, | ||
| 4753 | .windows => ws2_32.SOCK, | ||
| 4754 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 4755 | pub const STREAM = 1; | ||
| 4756 | pub const DGRAM = 2; | ||
| 4757 | pub const RAW = 3; | ||
| 4758 | pub const RDM = 4; | ||
| 4759 | pub const SEQPACKET = 5; | ||
| 4760 | pub const MAXADDRLEN = 255; | ||
| 4761 | |||
| 4762 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 4763 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 4764 | /// with any other `SOCK` bits. | ||
| 4765 | pub const CLOEXEC = 1 << 15; | ||
| 4766 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 4767 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 4768 | /// with any other `SOCK` bits. | ||
| 4769 | pub const NONBLOCK = 1 << 16; | ||
| 4770 | }, | ||
| 4771 | .freebsd, .kfreebsd => struct { | ||
| 4772 | pub const STREAM = 1; | ||
| 4773 | pub const DGRAM = 2; | ||
| 4774 | pub const RAW = 3; | ||
| 4775 | pub const RDM = 4; | ||
| 4776 | pub const SEQPACKET = 5; | ||
| 4777 | |||
| 4778 | pub const CLOEXEC = 0x10000000; | ||
| 4779 | pub const NONBLOCK = 0x20000000; | ||
| 4780 | }, | ||
| 4781 | .solaris, .illumos => struct { | ||
| 4782 | /// Datagram. | ||
| 4783 | pub const DGRAM = 1; | ||
| 4784 | /// STREAM. | ||
| 4785 | pub const STREAM = 2; | ||
| 4786 | /// Raw-protocol interface. | ||
| 4787 | pub const RAW = 4; | ||
| 4788 | /// Reliably-delivered message. | ||
| 4789 | pub const RDM = 5; | ||
| 4790 | /// Sequenced packed stream. | ||
| 4791 | pub const SEQPACKET = 6; | ||
| 4792 | |||
| 4793 | pub const NONBLOCK = 0x100000; | ||
| 4794 | pub const NDELAY = 0x200000; | ||
| 4795 | pub const CLOEXEC = 0x080000; | ||
| 4796 | }, | ||
| 4797 | .netbsd => struct { | ||
| 4798 | pub const STREAM = 1; | ||
| 4799 | pub const DGRAM = 2; | ||
| 4800 | pub const RAW = 3; | ||
| 4801 | pub const RDM = 4; | ||
| 4802 | pub const SEQPACKET = 5; | ||
| 4803 | pub const CONN_DGRAM = 6; | ||
| 4804 | pub const DCCP = CONN_DGRAM; | ||
| 4805 | |||
| 4806 | pub const CLOEXEC = 0x10000000; | ||
| 4807 | pub const NONBLOCK = 0x20000000; | ||
| 4808 | pub const NOSIGPIPE = 0x40000000; | ||
| 4809 | pub const FLAGS_MASK = 0xf0000000; | ||
| 4810 | }, | ||
| 4811 | .dragonfly => struct { | ||
| 4812 | pub const STREAM = 1; | ||
| 4813 | pub const DGRAM = 2; | ||
| 4814 | pub const RAW = 3; | ||
| 4815 | pub const RDM = 4; | ||
| 4816 | pub const SEQPACKET = 5; | ||
| 4817 | pub const MAXADDRLEN = 255; | ||
| 4818 | pub const CLOEXEC = 0x10000000; | ||
| 4819 | pub const NONBLOCK = 0x20000000; | ||
| 4820 | }, | ||
| 4821 | .haiku => struct { | ||
| 4822 | pub const STREAM = 1; | ||
| 4823 | pub const DGRAM = 2; | ||
| 4824 | pub const RAW = 3; | ||
| 4825 | pub const SEQPACKET = 5; | ||
| 4826 | pub const MISC = 255; | ||
| 4827 | }, | ||
| 4828 | .openbsd => struct { | ||
| 4829 | pub const STREAM = 1; | ||
| 4830 | pub const DGRAM = 2; | ||
| 4831 | pub const RAW = 3; | ||
| 4832 | pub const RDM = 4; | ||
| 4833 | pub const SEQPACKET = 5; | ||
| 4834 | |||
| 4835 | pub const CLOEXEC = 0x8000; | ||
| 4836 | pub const NONBLOCK = 0x4000; | ||
| 4837 | }, | ||
| 4838 | else => void, | ||
| 4839 | }; | ||
| 4840 | pub const TCP = switch (native_os) { | ||
| 4841 | .linux => linux.TCP, | ||
| 4842 | .emscripten => emscripten.TCP, | ||
| 4843 | .windows => ws2_32.TCP, | ||
| 4844 | else => void, | ||
| 4845 | }; | ||
| 4846 | pub const IPPROTO = switch (native_os) { | ||
| 4847 | .linux, .emscripten => linux.IPPROTO, | ||
| 4848 | .windows => ws2_32.IPPROTO, | ||
| 4849 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 4850 | pub const ICMP = 1; | ||
| 4851 | pub const ICMPV6 = 58; | ||
| 4852 | pub const TCP = 6; | ||
| 4853 | pub const UDP = 17; | ||
| 4854 | pub const IP = 0; | ||
| 4855 | pub const IPV6 = 41; | ||
| 4856 | }, | ||
| 4857 | .freebsd, .kfreebsd => struct { | ||
| 4858 | /// dummy for IP | ||
| 4859 | pub const IP = 0; | ||
| 4860 | /// control message protocol | ||
| 4861 | pub const ICMP = 1; | ||
| 4862 | /// tcp | ||
| 4863 | pub const TCP = 6; | ||
| 4864 | /// user datagram protocol | ||
| 4865 | pub const UDP = 17; | ||
| 4866 | /// IP6 header | ||
| 4867 | pub const IPV6 = 41; | ||
| 4868 | /// raw IP packet | ||
| 4869 | pub const RAW = 255; | ||
| 4870 | /// IP6 hop-by-hop options | ||
| 4871 | pub const HOPOPTS = 0; | ||
| 4872 | /// group mgmt protocol | ||
| 4873 | pub const IGMP = 2; | ||
| 4874 | /// gateway^2 (deprecated) | ||
| 4875 | pub const GGP = 3; | ||
| 4876 | /// IPv4 encapsulation | ||
| 4877 | pub const IPV4 = 4; | ||
| 4878 | /// for compatibility | ||
| 4879 | pub const IPIP = IPV4; | ||
| 4880 | /// Stream protocol II | ||
| 4881 | pub const ST = 7; | ||
| 4882 | /// exterior gateway protocol | ||
| 4883 | pub const EGP = 8; | ||
| 4884 | /// private interior gateway | ||
| 4885 | pub const PIGP = 9; | ||
| 4886 | /// BBN RCC Monitoring | ||
| 4887 | pub const RCCMON = 10; | ||
| 4888 | /// network voice protocol | ||
| 4889 | pub const NVPII = 11; | ||
| 4890 | /// pup | ||
| 4891 | pub const PUP = 12; | ||
| 4892 | /// Argus | ||
| 4893 | pub const ARGUS = 13; | ||
| 4894 | /// EMCON | ||
| 4895 | pub const EMCON = 14; | ||
| 4896 | /// Cross Net Debugger | ||
| 4897 | pub const XNET = 15; | ||
| 4898 | /// Chaos | ||
| 4899 | pub const CHAOS = 16; | ||
| 4900 | /// Multiplexing | ||
| 4901 | pub const MUX = 18; | ||
| 4902 | /// DCN Measurement Subsystems | ||
| 4903 | pub const MEAS = 19; | ||
| 4904 | /// Host Monitoring | ||
| 4905 | pub const HMP = 20; | ||
| 4906 | /// Packet Radio Measurement | ||
| 4907 | pub const PRM = 21; | ||
| 4908 | /// xns idp | ||
| 4909 | pub const IDP = 22; | ||
| 4910 | /// Trunk-1 | ||
| 4911 | pub const TRUNK1 = 23; | ||
| 4912 | /// Trunk-2 | ||
| 4913 | pub const TRUNK2 = 24; | ||
| 4914 | /// Leaf-1 | ||
| 4915 | pub const LEAF1 = 25; | ||
| 4916 | /// Leaf-2 | ||
| 4917 | pub const LEAF2 = 26; | ||
| 4918 | /// Reliable Data | ||
| 4919 | pub const RDP = 27; | ||
| 4920 | /// Reliable Transaction | ||
| 4921 | pub const IRTP = 28; | ||
| 4922 | /// tp-4 w/ class negotiation | ||
| 4923 | pub const TP = 29; | ||
| 4924 | /// Bulk Data Transfer | ||
| 4925 | pub const BLT = 30; | ||
| 4926 | /// Network Services | ||
| 4927 | pub const NSP = 31; | ||
| 4928 | /// Merit Internodal | ||
| 4929 | pub const INP = 32; | ||
| 4930 | /// Datagram Congestion Control Protocol | ||
| 4931 | pub const DCCP = 33; | ||
| 4932 | /// Third Party Connect | ||
| 4933 | pub const @"3PC" = 34; | ||
| 4934 | /// InterDomain Policy Routing | ||
| 4935 | pub const IDPR = 35; | ||
| 4936 | /// XTP | ||
| 4937 | pub const XTP = 36; | ||
| 4938 | /// Datagram Delivery | ||
| 4939 | pub const DDP = 37; | ||
| 4940 | /// Control Message Transport | ||
| 4941 | pub const CMTP = 38; | ||
| 4942 | /// TP++ Transport | ||
| 4943 | pub const TPXX = 39; | ||
| 4944 | /// IL transport protocol | ||
| 4945 | pub const IL = 40; | ||
| 4946 | /// Source Demand Routing | ||
| 4947 | pub const SDRP = 42; | ||
| 4948 | /// IP6 routing header | ||
| 4949 | pub const ROUTING = 43; | ||
| 4950 | /// IP6 fragmentation header | ||
| 4951 | pub const FRAGMENT = 44; | ||
| 4952 | /// InterDomain Routing | ||
| 4953 | pub const IDRP = 45; | ||
| 4954 | /// resource reservation | ||
| 4955 | pub const RSVP = 46; | ||
| 4956 | /// General Routing Encap. | ||
| 4957 | pub const GRE = 47; | ||
| 4958 | /// Mobile Host Routing | ||
| 4959 | pub const MHRP = 48; | ||
| 4960 | /// BHA | ||
| 4961 | pub const BHA = 49; | ||
| 4962 | /// IP6 Encap Sec. Payload | ||
| 4963 | pub const ESP = 50; | ||
| 4964 | /// IP6 Auth Header | ||
| 4965 | pub const AH = 51; | ||
| 4966 | /// Integ. Net Layer Security | ||
| 4967 | pub const INLSP = 52; | ||
| 4968 | /// IP with encryption | ||
| 4969 | pub const SWIPE = 53; | ||
| 4970 | /// Next Hop Resolution | ||
| 4971 | pub const NHRP = 54; | ||
| 4972 | /// IP Mobility | ||
| 4973 | pub const MOBILE = 55; | ||
| 4974 | /// Transport Layer Security | ||
| 4975 | pub const TLSP = 56; | ||
| 4976 | /// SKIP | ||
| 4977 | pub const SKIP = 57; | ||
| 4978 | /// ICMP6 | ||
| 4979 | pub const ICMPV6 = 58; | ||
| 4980 | /// IP6 no next header | ||
| 4981 | pub const NONE = 59; | ||
| 4982 | /// IP6 destination option | ||
| 4983 | pub const DSTOPTS = 60; | ||
| 4984 | /// any host internal protocol | ||
| 4985 | pub const AHIP = 61; | ||
| 4986 | /// CFTP | ||
| 4987 | pub const CFTP = 62; | ||
| 4988 | /// "hello" routing protocol | ||
| 4989 | pub const HELLO = 63; | ||
| 4990 | /// SATNET/Backroom EXPAK | ||
| 4991 | pub const SATEXPAK = 64; | ||
| 4992 | /// Kryptolan | ||
| 4993 | pub const KRYPTOLAN = 65; | ||
| 4994 | /// Remote Virtual Disk | ||
| 4995 | pub const RVD = 66; | ||
| 4996 | /// Pluribus Packet Core | ||
| 4997 | pub const IPPC = 67; | ||
| 4998 | /// Any distributed FS | ||
| 4999 | pub const ADFS = 68; | ||
| 5000 | /// Satnet Monitoring | ||
| 5001 | pub const SATMON = 69; | ||
| 5002 | /// VISA Protocol | ||
| 5003 | pub const VISA = 70; | ||
| 5004 | /// Packet Core Utility | ||
| 5005 | pub const IPCV = 71; | ||
| 5006 | /// Comp. Prot. Net. Executive | ||
| 5007 | pub const CPNX = 72; | ||
| 5008 | /// Comp. Prot. HeartBeat | ||
| 5009 | pub const CPHB = 73; | ||
| 5010 | /// Wang Span Network | ||
| 5011 | pub const WSN = 74; | ||
| 5012 | /// Packet Video Protocol | ||
| 5013 | pub const PVP = 75; | ||
| 5014 | /// BackRoom SATNET Monitoring | ||
| 5015 | pub const BRSATMON = 76; | ||
| 5016 | /// Sun net disk proto (temp.) | ||
| 5017 | pub const ND = 77; | ||
| 5018 | /// WIDEBAND Monitoring | ||
| 5019 | pub const WBMON = 78; | ||
| 5020 | /// WIDEBAND EXPAK | ||
| 5021 | pub const WBEXPAK = 79; | ||
| 5022 | /// ISO cnlp | ||
| 5023 | pub const EON = 80; | ||
| 5024 | /// VMTP | ||
| 5025 | pub const VMTP = 81; | ||
| 5026 | /// Secure VMTP | ||
| 5027 | pub const SVMTP = 82; | ||
| 5028 | /// Banyon VINES | ||
| 5029 | pub const VINES = 83; | ||
| 5030 | /// TTP | ||
| 5031 | pub const TTP = 84; | ||
| 5032 | /// NSFNET-IGP | ||
| 5033 | pub const IGP = 85; | ||
| 5034 | /// dissimilar gateway prot. | ||
| 5035 | pub const DGP = 86; | ||
| 5036 | /// TCF | ||
| 5037 | pub const TCF = 87; | ||
| 5038 | /// Cisco/GXS IGRP | ||
| 5039 | pub const IGRP = 88; | ||
| 5040 | /// OSPFIGP | ||
| 5041 | pub const OSPFIGP = 89; | ||
| 5042 | /// Strite RPC protocol | ||
| 5043 | pub const SRPC = 90; | ||
| 5044 | /// Locus Address Resoloution | ||
| 5045 | pub const LARP = 91; | ||
| 5046 | /// Multicast Transport | ||
| 5047 | pub const MTP = 92; | ||
| 5048 | /// AX.25 Frames | ||
| 5049 | pub const AX25 = 93; | ||
| 5050 | /// IP encapsulated in IP | ||
| 5051 | pub const IPEIP = 94; | ||
| 5052 | /// Mobile Int.ing control | ||
| 5053 | pub const MICP = 95; | ||
| 5054 | /// Semaphore Comm. security | ||
| 5055 | pub const SCCSP = 96; | ||
| 5056 | /// Ethernet IP encapsulation | ||
| 5057 | pub const ETHERIP = 97; | ||
| 5058 | /// encapsulation header | ||
| 5059 | pub const ENCAP = 98; | ||
| 5060 | /// any private encr. scheme | ||
| 5061 | pub const APES = 99; | ||
| 5062 | /// GMTP | ||
| 5063 | pub const GMTP = 100; | ||
| 5064 | /// payload compression (IPComp) | ||
| 5065 | pub const IPCOMP = 108; | ||
| 5066 | /// SCTP | ||
| 5067 | pub const SCTP = 132; | ||
| 5068 | /// IPv6 Mobility Header | ||
| 5069 | pub const MH = 135; | ||
| 5070 | /// UDP-Lite | ||
| 5071 | pub const UDPLITE = 136; | ||
| 5072 | /// IP6 Host Identity Protocol | ||
| 5073 | pub const HIP = 139; | ||
| 5074 | /// IP6 Shim6 Protocol | ||
| 5075 | pub const SHIM6 = 140; | ||
| 5076 | /// Protocol Independent Mcast | ||
| 5077 | pub const PIM = 103; | ||
| 5078 | /// CARP | ||
| 5079 | pub const CARP = 112; | ||
| 5080 | /// PGM | ||
| 5081 | pub const PGM = 113; | ||
| 5082 | /// MPLS-in-IP | ||
| 5083 | pub const MPLS = 137; | ||
| 5084 | /// PFSYNC | ||
| 5085 | pub const PFSYNC = 240; | ||
| 5086 | /// Reserved | ||
| 5087 | pub const RESERVED_253 = 253; | ||
| 5088 | /// Reserved | ||
| 5089 | pub const RESERVED_254 = 254; | ||
| 5090 | }, | ||
| 5091 | .solaris, .illumos => struct { | ||
| 5092 | /// dummy for IP | ||
| 5093 | pub const IP = 0; | ||
| 5094 | /// Hop by hop header for IPv6 | ||
| 5095 | pub const HOPOPTS = 0; | ||
| 5096 | /// control message protocol | ||
| 5097 | pub const ICMP = 1; | ||
| 5098 | /// group control protocol | ||
| 5099 | pub const IGMP = 2; | ||
| 5100 | /// gateway^2 (deprecated) | ||
| 5101 | pub const GGP = 3; | ||
| 5102 | /// IP in IP encapsulation | ||
| 5103 | pub const ENCAP = 4; | ||
| 5104 | /// tcp | ||
| 5105 | pub const TCP = 6; | ||
| 5106 | /// exterior gateway protocol | ||
| 5107 | pub const EGP = 8; | ||
| 5108 | /// pup | ||
| 5109 | pub const PUP = 12; | ||
| 5110 | /// user datagram protocol | ||
| 5111 | pub const UDP = 17; | ||
| 5112 | /// xns idp | ||
| 5113 | pub const IDP = 22; | ||
| 5114 | /// IPv6 encapsulated in IP | ||
| 5115 | pub const IPV6 = 41; | ||
| 5116 | /// Routing header for IPv6 | ||
| 5117 | pub const ROUTING = 43; | ||
| 5118 | /// Fragment header for IPv6 | ||
| 5119 | pub const FRAGMENT = 44; | ||
| 5120 | /// rsvp | ||
| 5121 | pub const RSVP = 46; | ||
| 5122 | /// IPsec Encap. Sec. Payload | ||
| 5123 | pub const ESP = 50; | ||
| 5124 | /// IPsec Authentication Hdr. | ||
| 5125 | pub const AH = 51; | ||
| 5126 | /// ICMP for IPv6 | ||
| 5127 | pub const ICMPV6 = 58; | ||
| 5128 | /// No next header for IPv6 | ||
| 5129 | pub const NONE = 59; | ||
| 5130 | /// Destination options | ||
| 5131 | pub const DSTOPTS = 60; | ||
| 5132 | /// "hello" routing protocol | ||
| 5133 | pub const HELLO = 63; | ||
| 5134 | /// UNOFFICIAL net disk proto | ||
| 5135 | pub const ND = 77; | ||
| 5136 | /// ISO clnp | ||
| 5137 | pub const EON = 80; | ||
| 5138 | /// OSPF | ||
| 5139 | pub const OSPF = 89; | ||
| 5140 | /// PIM routing protocol | ||
| 5141 | pub const PIM = 103; | ||
| 5142 | /// Stream Control | ||
| 5143 | pub const SCTP = 132; | ||
| 5144 | /// raw IP packet | ||
| 5145 | pub const RAW = 255; | ||
| 5146 | /// Sockets Direct Protocol | ||
| 5147 | pub const PROTO_SDP = 257; | ||
| 5148 | }, | ||
| 5149 | .netbsd => struct { | ||
| 5150 | /// dummy for IP | ||
| 5151 | pub const IP = 0; | ||
| 5152 | /// IP6 hop-by-hop options | ||
| 5153 | pub const HOPOPTS = 0; | ||
| 5154 | /// control message protocol | ||
| 5155 | pub const ICMP = 1; | ||
| 5156 | /// group mgmt protocol | ||
| 5157 | pub const IGMP = 2; | ||
| 5158 | /// gateway^2 (deprecated) | ||
| 5159 | pub const GGP = 3; | ||
| 5160 | /// IP header | ||
| 5161 | pub const IPV4 = 4; | ||
| 5162 | /// IP inside IP | ||
| 5163 | pub const IPIP = 4; | ||
| 5164 | /// tcp | ||
| 5165 | pub const TCP = 6; | ||
| 5166 | /// exterior gateway protocol | ||
| 5167 | pub const EGP = 8; | ||
| 5168 | /// pup | ||
| 5169 | pub const PUP = 12; | ||
| 5170 | /// user datagram protocol | ||
| 5171 | pub const UDP = 17; | ||
| 5172 | /// xns idp | ||
| 5173 | pub const IDP = 22; | ||
| 5174 | /// tp-4 w/ class negotiation | ||
| 5175 | pub const TP = 29; | ||
| 5176 | /// DCCP | ||
| 5177 | pub const DCCP = 33; | ||
| 5178 | /// IP6 header | ||
| 5179 | pub const IPV6 = 41; | ||
| 5180 | /// IP6 routing header | ||
| 5181 | pub const ROUTING = 43; | ||
| 5182 | /// IP6 fragmentation header | ||
| 5183 | pub const FRAGMENT = 44; | ||
| 5184 | /// resource reservation | ||
| 5185 | pub const RSVP = 46; | ||
| 5186 | /// GRE encaps RFC 1701 | ||
| 5187 | pub const GRE = 47; | ||
| 5188 | /// encap. security payload | ||
| 5189 | pub const ESP = 50; | ||
| 5190 | /// authentication header | ||
| 5191 | pub const AH = 51; | ||
| 5192 | /// IP Mobility RFC 2004 | ||
| 5193 | pub const MOBILE = 55; | ||
| 5194 | /// IPv6 ICMP | ||
| 5195 | pub const IPV6_ICMP = 58; | ||
| 5196 | /// ICMP6 | ||
| 5197 | pub const ICMPV6 = 58; | ||
| 5198 | /// IP6 no next header | ||
| 5199 | pub const NONE = 59; | ||
| 5200 | /// IP6 destination option | ||
| 5201 | pub const DSTOPTS = 60; | ||
| 5202 | /// ISO cnlp | ||
| 5203 | pub const EON = 80; | ||
| 5204 | /// Ethernet-in-IP | ||
| 5205 | pub const ETHERIP = 97; | ||
| 5206 | /// encapsulation header | ||
| 5207 | pub const ENCAP = 98; | ||
| 5208 | /// Protocol indep. multicast | ||
| 5209 | pub const PIM = 103; | ||
| 5210 | /// IP Payload Comp. Protocol | ||
| 5211 | pub const IPCOMP = 108; | ||
| 5212 | /// VRRP RFC 2338 | ||
| 5213 | pub const VRRP = 112; | ||
| 5214 | /// Common Address Resolution Protocol | ||
| 5215 | pub const CARP = 112; | ||
| 5216 | /// L2TPv3 | ||
| 5217 | pub const L2TP = 115; | ||
| 5218 | /// SCTP | ||
| 5219 | pub const SCTP = 132; | ||
| 5220 | /// PFSYNC | ||
| 5221 | pub const PFSYNC = 240; | ||
| 5222 | /// raw IP packet | ||
| 5223 | pub const RAW = 255; | ||
| 5224 | }, | ||
| 5225 | .dragonfly => struct { | ||
| 5226 | pub const IP = 0; | ||
| 5227 | pub const ICMP = 1; | ||
| 5228 | pub const TCP = 6; | ||
| 5229 | pub const UDP = 17; | ||
| 5230 | pub const IPV6 = 41; | ||
| 5231 | pub const RAW = 255; | ||
| 5232 | pub const HOPOPTS = 0; | ||
| 5233 | pub const IGMP = 2; | ||
| 5234 | pub const GGP = 3; | ||
| 5235 | pub const IPV4 = 4; | ||
| 5236 | pub const IPIP = IPV4; | ||
| 5237 | pub const ST = 7; | ||
| 5238 | pub const EGP = 8; | ||
| 5239 | pub const PIGP = 9; | ||
| 5240 | pub const RCCMON = 10; | ||
| 5241 | pub const NVPII = 11; | ||
| 5242 | pub const PUP = 12; | ||
| 5243 | pub const ARGUS = 13; | ||
| 5244 | pub const EMCON = 14; | ||
| 5245 | pub const XNET = 15; | ||
| 5246 | pub const CHAOS = 16; | ||
| 5247 | pub const MUX = 18; | ||
| 5248 | pub const MEAS = 19; | ||
| 5249 | pub const HMP = 20; | ||
| 5250 | pub const PRM = 21; | ||
| 5251 | pub const IDP = 22; | ||
| 5252 | pub const TRUNK1 = 23; | ||
| 5253 | pub const TRUNK2 = 24; | ||
| 5254 | pub const LEAF1 = 25; | ||
| 5255 | pub const LEAF2 = 26; | ||
| 5256 | pub const RDP = 27; | ||
| 5257 | pub const IRTP = 28; | ||
| 5258 | pub const TP = 29; | ||
| 5259 | pub const BLT = 30; | ||
| 5260 | pub const NSP = 31; | ||
| 5261 | pub const INP = 32; | ||
| 5262 | pub const SEP = 33; | ||
| 5263 | pub const @"3PC" = 34; | ||
| 5264 | pub const IDPR = 35; | ||
| 5265 | pub const XTP = 36; | ||
| 5266 | pub const DDP = 37; | ||
| 5267 | pub const CMTP = 38; | ||
| 5268 | pub const TPXX = 39; | ||
| 5269 | pub const IL = 40; | ||
| 5270 | pub const SDRP = 42; | ||
| 5271 | pub const ROUTING = 43; | ||
| 5272 | pub const FRAGMENT = 44; | ||
| 5273 | pub const IDRP = 45; | ||
| 5274 | pub const RSVP = 46; | ||
| 5275 | pub const GRE = 47; | ||
| 5276 | pub const MHRP = 48; | ||
| 5277 | pub const BHA = 49; | ||
| 5278 | pub const ESP = 50; | ||
| 5279 | pub const AH = 51; | ||
| 5280 | pub const INLSP = 52; | ||
| 5281 | pub const SWIPE = 53; | ||
| 5282 | pub const NHRP = 54; | ||
| 5283 | pub const MOBILE = 55; | ||
| 5284 | pub const TLSP = 56; | ||
| 5285 | pub const SKIP = 57; | ||
| 5286 | pub const ICMPV6 = 58; | ||
| 5287 | pub const NONE = 59; | ||
| 5288 | pub const DSTOPTS = 60; | ||
| 5289 | pub const AHIP = 61; | ||
| 5290 | pub const CFTP = 62; | ||
| 5291 | pub const HELLO = 63; | ||
| 5292 | pub const SATEXPAK = 64; | ||
| 5293 | pub const KRYPTOLAN = 65; | ||
| 5294 | pub const RVD = 66; | ||
| 5295 | pub const IPPC = 67; | ||
| 5296 | pub const ADFS = 68; | ||
| 5297 | pub const SATMON = 69; | ||
| 5298 | pub const VISA = 70; | ||
| 5299 | pub const IPCV = 71; | ||
| 5300 | pub const CPNX = 72; | ||
| 5301 | pub const CPHB = 73; | ||
| 5302 | pub const WSN = 74; | ||
| 5303 | pub const PVP = 75; | ||
| 5304 | pub const BRSATMON = 76; | ||
| 5305 | pub const ND = 77; | ||
| 5306 | pub const WBMON = 78; | ||
| 5307 | pub const WBEXPAK = 79; | ||
| 5308 | pub const EON = 80; | ||
| 5309 | pub const VMTP = 81; | ||
| 5310 | pub const SVMTP = 82; | ||
| 5311 | pub const VINES = 83; | ||
| 5312 | pub const TTP = 84; | ||
| 5313 | pub const IGP = 85; | ||
| 5314 | pub const DGP = 86; | ||
| 5315 | pub const TCF = 87; | ||
| 5316 | pub const IGRP = 88; | ||
| 5317 | pub const OSPFIGP = 89; | ||
| 5318 | pub const SRPC = 90; | ||
| 5319 | pub const LARP = 91; | ||
| 5320 | pub const MTP = 92; | ||
| 5321 | pub const AX25 = 93; | ||
| 5322 | pub const IPEIP = 94; | ||
| 5323 | pub const MICP = 95; | ||
| 5324 | pub const SCCSP = 96; | ||
| 5325 | pub const ETHERIP = 97; | ||
| 5326 | pub const ENCAP = 98; | ||
| 5327 | pub const APES = 99; | ||
| 5328 | pub const GMTP = 100; | ||
| 5329 | pub const IPCOMP = 108; | ||
| 5330 | pub const PIM = 103; | ||
| 5331 | pub const CARP = 112; | ||
| 5332 | pub const PGM = 113; | ||
| 5333 | pub const PFSYNC = 240; | ||
| 5334 | pub const DIVERT = 254; | ||
| 5335 | pub const MAX = 256; | ||
| 5336 | pub const DONE = 257; | ||
| 5337 | pub const UNKNOWN = 258; | ||
| 5338 | }, | ||
| 5339 | .haiku => struct { | ||
| 5340 | pub const IP = 0; | ||
| 5341 | pub const HOPOPTS = 0; | ||
| 5342 | pub const ICMP = 1; | ||
| 5343 | pub const IGMP = 2; | ||
| 5344 | pub const TCP = 6; | ||
| 5345 | pub const UDP = 17; | ||
| 5346 | pub const IPV6 = 41; | ||
| 5347 | pub const ROUTING = 43; | ||
| 5348 | pub const FRAGMENT = 44; | ||
| 5349 | pub const ESP = 50; | ||
| 5350 | pub const AH = 51; | ||
| 5351 | pub const ICMPV6 = 58; | ||
| 5352 | pub const NONE = 59; | ||
| 5353 | pub const DSTOPTS = 60; | ||
| 5354 | pub const ETHERIP = 97; | ||
| 5355 | pub const RAW = 255; | ||
| 5356 | pub const MAX = 256; | ||
| 5357 | }, | ||
| 5358 | .openbsd => struct { | ||
| 5359 | /// dummy for IP | ||
| 5360 | pub const IP = 0; | ||
| 5361 | /// IP6 hop-by-hop options | ||
| 5362 | pub const HOPOPTS = IP; | ||
| 5363 | /// control message protocol | ||
| 5364 | pub const ICMP = 1; | ||
| 5365 | /// group mgmt protocol | ||
| 5366 | pub const IGMP = 2; | ||
| 5367 | /// gateway^2 (deprecated) | ||
| 5368 | pub const GGP = 3; | ||
| 5369 | /// IP header | ||
| 5370 | pub const IPV4 = IPIP; | ||
| 5371 | /// IP inside IP | ||
| 5372 | pub const IPIP = 4; | ||
| 5373 | /// tcp | ||
| 5374 | pub const TCP = 6; | ||
| 5375 | /// exterior gateway protocol | ||
| 5376 | pub const EGP = 8; | ||
| 5377 | /// pup | ||
| 5378 | pub const PUP = 12; | ||
| 5379 | /// user datagram protocol | ||
| 5380 | pub const UDP = 17; | ||
| 5381 | /// xns idp | ||
| 5382 | pub const IDP = 22; | ||
| 5383 | /// tp-4 w/ class negotiation | ||
| 5384 | pub const TP = 29; | ||
| 5385 | /// IP6 header | ||
| 5386 | pub const IPV6 = 41; | ||
| 5387 | /// IP6 routing header | ||
| 5388 | pub const ROUTING = 43; | ||
| 5389 | /// IP6 fragmentation header | ||
| 5390 | pub const FRAGMENT = 44; | ||
| 5391 | /// resource reservation | ||
| 5392 | pub const RSVP = 46; | ||
| 5393 | /// GRE encaps RFC 1701 | ||
| 5394 | pub const GRE = 47; | ||
| 5395 | /// encap. security payload | ||
| 5396 | pub const ESP = 50; | ||
| 5397 | /// authentication header | ||
| 5398 | pub const AH = 51; | ||
| 5399 | /// IP Mobility RFC 2004 | ||
| 5400 | pub const MOBILE = 55; | ||
| 5401 | /// IPv6 ICMP | ||
| 5402 | pub const IPV6_ICMP = 58; | ||
| 5403 | /// ICMP6 | ||
| 5404 | pub const ICMPV6 = 58; | ||
| 5405 | /// IP6 no next header | ||
| 5406 | pub const NONE = 59; | ||
| 5407 | /// IP6 destination option | ||
| 5408 | pub const DSTOPTS = 60; | ||
| 5409 | /// ISO cnlp | ||
| 5410 | pub const EON = 80; | ||
| 5411 | /// Ethernet-in-IP | ||
| 5412 | pub const ETHERIP = 97; | ||
| 5413 | /// encapsulation header | ||
| 5414 | pub const ENCAP = 98; | ||
| 5415 | /// Protocol indep. multicast | ||
| 5416 | pub const PIM = 103; | ||
| 5417 | /// IP Payload Comp. Protocol | ||
| 5418 | pub const IPCOMP = 108; | ||
| 5419 | /// VRRP RFC 2338 | ||
| 5420 | pub const VRRP = 112; | ||
| 5421 | /// Common Address Resolution Protocol | ||
| 5422 | pub const CARP = 112; | ||
| 5423 | /// PFSYNC | ||
| 5424 | pub const PFSYNC = 240; | ||
| 5425 | /// raw IP packet | ||
| 5426 | pub const RAW = 255; | ||
| 5427 | }, | ||
| 5428 | else => void, | ||
| 5429 | }; | ||
| 5430 | pub const SOL = switch (native_os) { | ||
| 5431 | .linux => linux.SOL, | ||
| 5432 | .emscripten => emscripten.SOL, | ||
| 5433 | .windows => ws2_32.SOL, | ||
| 5434 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 5435 | pub const SOCKET = 0xffff; | ||
| 5436 | }, | ||
| 5437 | .solaris, .illumos => struct { | ||
| 5438 | pub const SOCKET = 0xffff; | ||
| 5439 | pub const ROUTE = 0xfffe; | ||
| 5440 | pub const PACKET = 0xfffd; | ||
| 5441 | pub const FILTER = 0xfffc; | ||
| 5442 | }, | ||
| 5443 | else => void, | ||
| 5444 | }; | ||
| 5445 | pub const SO = switch (native_os) { | ||
| 5446 | .linux => linux.SO, | ||
| 5447 | .emscripten => emscripten.SO, | ||
| 5448 | .windows => ws2_32.SO, | ||
| 5449 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 5450 | pub const DEBUG = 0x0001; | ||
| 5451 | pub const ACCEPTCONN = 0x0002; | ||
| 5452 | pub const REUSEADDR = 0x0004; | ||
| 5453 | pub const KEEPALIVE = 0x0008; | ||
| 5454 | pub const DONTROUTE = 0x0010; | ||
| 5455 | pub const BROADCAST = 0x0020; | ||
| 5456 | pub const USELOOPBACK = 0x0040; | ||
| 5457 | pub const LINGER = 0x1080; | ||
| 5458 | pub const OOBINLINE = 0x0100; | ||
| 5459 | pub const REUSEPORT = 0x0200; | ||
| 5460 | pub const ACCEPTFILTER = 0x1000; | ||
| 5461 | pub const SNDBUF = 0x1001; | ||
| 5462 | pub const RCVBUF = 0x1002; | ||
| 5463 | pub const SNDLOWAT = 0x1003; | ||
| 5464 | pub const RCVLOWAT = 0x1004; | ||
| 5465 | pub const SNDTIMEO = 0x1005; | ||
| 5466 | pub const RCVTIMEO = 0x1006; | ||
| 5467 | pub const ERROR = 0x1007; | ||
| 5468 | pub const TYPE = 0x1008; | ||
| 5469 | |||
| 5470 | pub const NREAD = 0x1020; | ||
| 5471 | pub const NKE = 0x1021; | ||
| 5472 | pub const NOSIGPIPE = 0x1022; | ||
| 5473 | pub const NOADDRERR = 0x1023; | ||
| 5474 | pub const NWRITE = 0x1024; | ||
| 5475 | pub const REUSESHAREUID = 0x1025; | ||
| 5476 | }, | ||
| 5477 | .freebsd, .kfreebsd => struct { | ||
| 5478 | pub const DEBUG = 0x00000001; | ||
| 5479 | pub const ACCEPTCONN = 0x00000002; | ||
| 5480 | pub const REUSEADDR = 0x00000004; | ||
| 5481 | pub const KEEPALIVE = 0x00000008; | ||
| 5482 | pub const DONTROUTE = 0x00000010; | ||
| 5483 | pub const BROADCAST = 0x00000020; | ||
| 5484 | pub const USELOOPBACK = 0x00000040; | ||
| 5485 | pub const LINGER = 0x00000080; | ||
| 5486 | pub const OOBINLINE = 0x00000100; | ||
| 5487 | pub const REUSEPORT = 0x00000200; | ||
| 5488 | pub const TIMESTAMP = 0x00000400; | ||
| 5489 | pub const NOSIGPIPE = 0x00000800; | ||
| 5490 | pub const ACCEPTFILTER = 0x00001000; | ||
| 5491 | pub const BINTIME = 0x00002000; | ||
| 5492 | pub const NO_OFFLOAD = 0x00004000; | ||
| 5493 | pub const NO_DDP = 0x00008000; | ||
| 5494 | pub const REUSEPORT_LB = 0x00010000; | ||
| 5495 | |||
| 5496 | pub const SNDBUF = 0x1001; | ||
| 5497 | pub const RCVBUF = 0x1002; | ||
| 5498 | pub const SNDLOWAT = 0x1003; | ||
| 5499 | pub const RCVLOWAT = 0x1004; | ||
| 5500 | pub const SNDTIMEO = 0x1005; | ||
| 5501 | pub const RCVTIMEO = 0x1006; | ||
| 5502 | pub const ERROR = 0x1007; | ||
| 5503 | pub const TYPE = 0x1008; | ||
| 5504 | pub const LABEL = 0x1009; | ||
| 5505 | pub const PEERLABEL = 0x1010; | ||
| 5506 | pub const LISTENQLIMIT = 0x1011; | ||
| 5507 | pub const LISTENQLEN = 0x1012; | ||
| 5508 | pub const LISTENINCQLEN = 0x1013; | ||
| 5509 | pub const SETFIB = 0x1014; | ||
| 5510 | pub const USER_COOKIE = 0x1015; | ||
| 5511 | pub const PROTOCOL = 0x1016; | ||
| 5512 | pub const PROTOTYPE = PROTOCOL; | ||
| 5513 | pub const TS_CLOCK = 0x1017; | ||
| 5514 | pub const MAX_PACING_RATE = 0x1018; | ||
| 5515 | pub const DOMAIN = 0x1019; | ||
| 5516 | }, | ||
| 5517 | .solaris, .illumos => struct { | ||
| 5518 | pub const DEBUG = 0x0001; | ||
| 5519 | pub const ACCEPTCONN = 0x0002; | ||
| 5520 | pub const REUSEADDR = 0x0004; | ||
| 5521 | pub const KEEPALIVE = 0x0008; | ||
| 5522 | pub const DONTROUTE = 0x0010; | ||
| 5523 | pub const BROADCAST = 0x0020; | ||
| 5524 | pub const USELOOPBACK = 0x0040; | ||
| 5525 | pub const LINGER = 0x0080; | ||
| 5526 | pub const OOBINLINE = 0x0100; | ||
| 5527 | pub const DGRAM_ERRIND = 0x0200; | ||
| 5528 | pub const RECVUCRED = 0x0400; | ||
| 5529 | |||
| 5530 | pub const SNDBUF = 0x1001; | ||
| 5531 | pub const RCVBUF = 0x1002; | ||
| 5532 | pub const SNDLOWAT = 0x1003; | ||
| 5533 | pub const RCVLOWAT = 0x1004; | ||
| 5534 | pub const SNDTIMEO = 0x1005; | ||
| 5535 | pub const RCVTIMEO = 0x1006; | ||
| 5536 | pub const ERROR = 0x1007; | ||
| 5537 | pub const TYPE = 0x1008; | ||
| 5538 | pub const PROTOTYPE = 0x1009; | ||
| 5539 | pub const ANON_MLP = 0x100a; | ||
| 5540 | pub const MAC_EXEMPT = 0x100b; | ||
| 5541 | pub const DOMAIN = 0x100c; | ||
| 5542 | pub const RCVPSH = 0x100d; | ||
| 5543 | |||
| 5544 | pub const SECATTR = 0x1011; | ||
| 5545 | pub const TIMESTAMP = 0x1013; | ||
| 5546 | pub const ALLZONES = 0x1014; | ||
| 5547 | pub const EXCLBIND = 0x1015; | ||
| 5548 | pub const MAC_IMPLICIT = 0x1016; | ||
| 5549 | pub const VRRP = 0x1017; | ||
| 5550 | }, | ||
| 5551 | .netbsd => struct { | ||
| 5552 | pub const DEBUG = 0x0001; | ||
| 5553 | pub const ACCEPTCONN = 0x0002; | ||
| 5554 | pub const REUSEADDR = 0x0004; | ||
| 5555 | pub const KEEPALIVE = 0x0008; | ||
| 5556 | pub const DONTROUTE = 0x0010; | ||
| 5557 | pub const BROADCAST = 0x0020; | ||
| 5558 | pub const USELOOPBACK = 0x0040; | ||
| 5559 | pub const LINGER = 0x0080; | ||
| 5560 | pub const OOBINLINE = 0x0100; | ||
| 5561 | pub const REUSEPORT = 0x0200; | ||
| 5562 | pub const NOSIGPIPE = 0x0800; | ||
| 5563 | pub const ACCEPTFILTER = 0x1000; | ||
| 5564 | pub const TIMESTAMP = 0x2000; | ||
| 5565 | pub const RERROR = 0x4000; | ||
| 5566 | |||
| 5567 | pub const SNDBUF = 0x1001; | ||
| 5568 | pub const RCVBUF = 0x1002; | ||
| 5569 | pub const SNDLOWAT = 0x1003; | ||
| 5570 | pub const RCVLOWAT = 0x1004; | ||
| 5571 | pub const ERROR = 0x1007; | ||
| 5572 | pub const TYPE = 0x1008; | ||
| 5573 | pub const OVERFLOWED = 0x1009; | ||
| 5574 | |||
| 5575 | pub const NOHEADER = 0x100a; | ||
| 5576 | pub const SNDTIMEO = 0x100b; | ||
| 5577 | pub const RCVTIMEO = 0x100c; | ||
| 5578 | }, | ||
| 5579 | .dragonfly => struct { | ||
| 5580 | pub const DEBUG = 0x0001; | ||
| 5581 | pub const ACCEPTCONN = 0x0002; | ||
| 5582 | pub const REUSEADDR = 0x0004; | ||
| 5583 | pub const KEEPALIVE = 0x0008; | ||
| 5584 | pub const DONTROUTE = 0x0010; | ||
| 5585 | pub const BROADCAST = 0x0020; | ||
| 5586 | pub const USELOOPBACK = 0x0040; | ||
| 5587 | pub const LINGER = 0x0080; | ||
| 5588 | pub const OOBINLINE = 0x0100; | ||
| 5589 | pub const REUSEPORT = 0x0200; | ||
| 5590 | pub const TIMESTAMP = 0x0400; | ||
| 5591 | pub const NOSIGPIPE = 0x0800; | ||
| 5592 | pub const ACCEPTFILTER = 0x1000; | ||
| 5593 | pub const RERROR = 0x2000; | ||
| 5594 | pub const PASSCRED = 0x4000; | ||
| 5595 | |||
| 5596 | pub const SNDBUF = 0x1001; | ||
| 5597 | pub const RCVBUF = 0x1002; | ||
| 5598 | pub const SNDLOWAT = 0x1003; | ||
| 5599 | pub const RCVLOWAT = 0x1004; | ||
| 5600 | pub const SNDTIMEO = 0x1005; | ||
| 5601 | pub const RCVTIMEO = 0x1006; | ||
| 5602 | pub const ERROR = 0x1007; | ||
| 5603 | pub const TYPE = 0x1008; | ||
| 5604 | pub const SNDSPACE = 0x100a; | ||
| 5605 | pub const CPUHINT = 0x1030; | ||
| 5606 | }, | ||
| 5607 | .haiku => struct { | ||
| 5608 | pub const ACCEPTCONN = 0x00000001; | ||
| 5609 | pub const BROADCAST = 0x00000002; | ||
| 5610 | pub const DEBUG = 0x00000004; | ||
| 5611 | pub const DONTROUTE = 0x00000008; | ||
| 5612 | pub const KEEPALIVE = 0x00000010; | ||
| 5613 | pub const OOBINLINE = 0x00000020; | ||
| 5614 | pub const REUSEADDR = 0x00000040; | ||
| 5615 | pub const REUSEPORT = 0x00000080; | ||
| 5616 | pub const USELOOPBACK = 0x00000100; | ||
| 5617 | pub const LINGER = 0x00000200; | ||
| 5618 | |||
| 5619 | pub const SNDBUF = 0x40000001; | ||
| 5620 | pub const SNDLOWAT = 0x40000002; | ||
| 5621 | pub const SNDTIMEO = 0x40000003; | ||
| 5622 | pub const RCVBUF = 0x40000004; | ||
| 5623 | pub const RCVLOWAT = 0x40000005; | ||
| 5624 | pub const RCVTIMEO = 0x40000006; | ||
| 5625 | pub const ERROR = 0x40000007; | ||
| 5626 | pub const TYPE = 0x40000008; | ||
| 5627 | pub const NONBLOCK = 0x40000009; | ||
| 5628 | pub const BINDTODEVICE = 0x4000000a; | ||
| 5629 | pub const PEERCRED = 0x4000000b; | ||
| 5630 | }, | ||
| 5631 | .openbsd => struct { | ||
| 5632 | pub const DEBUG = 0x0001; | ||
| 5633 | pub const ACCEPTCONN = 0x0002; | ||
| 5634 | pub const REUSEADDR = 0x0004; | ||
| 5635 | pub const KEEPALIVE = 0x0008; | ||
| 5636 | pub const DONTROUTE = 0x0010; | ||
| 5637 | pub const BROADCAST = 0x0020; | ||
| 5638 | pub const USELOOPBACK = 0x0040; | ||
| 5639 | pub const LINGER = 0x0080; | ||
| 5640 | pub const OOBINLINE = 0x0100; | ||
| 5641 | pub const REUSEPORT = 0x0200; | ||
| 5642 | pub const TIMESTAMP = 0x0800; | ||
| 5643 | pub const BINDANY = 0x1000; | ||
| 5644 | pub const ZEROIZE = 0x2000; | ||
| 5645 | pub const SNDBUF = 0x1001; | ||
| 5646 | pub const RCVBUF = 0x1002; | ||
| 5647 | pub const SNDLOWAT = 0x1003; | ||
| 5648 | pub const RCVLOWAT = 0x1004; | ||
| 5649 | pub const SNDTIMEO = 0x1005; | ||
| 5650 | pub const RCVTIMEO = 0x1006; | ||
| 5651 | pub const ERROR = 0x1007; | ||
| 5652 | pub const TYPE = 0x1008; | ||
| 5653 | pub const NETPROC = 0x1020; | ||
| 5654 | pub const RTABLE = 0x1021; | ||
| 5655 | pub const PEERCRED = 0x1022; | ||
| 5656 | pub const SPLICE = 0x1023; | ||
| 5657 | pub const DOMAIN = 0x1024; | ||
| 5658 | pub const PROTOCOL = 0x1025; | ||
| 5659 | }, | ||
| 5660 | else => void, | ||
| 5661 | }; | ||
| 5662 | pub const SOMAXCONN = switch (native_os) { | ||
| 5663 | .linux => linux.SOMAXCONN, | ||
| 5664 | .windows => ws2_32.SOMAXCONN, | ||
| 5665 | .solaris, .illumos => 128, | ||
| 5666 | .openbsd => 28, | ||
| 5667 | else => void, | ||
| 5668 | }; | ||
| 5669 | pub const IFNAMESIZE = switch (native_os) { | ||
| 5670 | .linux => linux.IFNAMESIZE, | ||
| 5671 | .emscripten => emscripten.IFNAMESIZE, | ||
| 5672 | .windows => 30, | ||
| 5673 | .openbsd, .dragonfly, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => 16, | ||
| 5674 | .solaris, .illumos => 32, | ||
| 5675 | else => void, | ||
| 5676 | }; | ||
| 5677 | |||
| 5678 | pub const stack_t = switch (native_os) { | ||
| 5679 | .linux => linux.stack_t, | ||
| 5680 | .emscripten => emscripten.stack_t, | ||
| 5681 | .freebsd, .kfreebsd => extern struct { | ||
| 5682 | /// Signal stack base. | ||
| 5683 | sp: *anyopaque, | ||
| 5684 | /// Signal stack length. | ||
| 5685 | size: usize, | ||
| 5686 | /// SS_DISABLE and/or SS_ONSTACK. | ||
| 5687 | flags: i32, | ||
| 5688 | }, | ||
| 5689 | else => extern struct { | ||
| 5690 | sp: [*]u8, | ||
| 5691 | size: isize, | ||
| 5692 | flags: i32, | ||
| 5693 | }, | ||
| 5694 | }; | ||
| 5695 | pub const time_t = switch (native_os) { | ||
| 5696 | .linux => linux.time_t, | ||
| 5697 | .emscripten => emscripten.time_t, | ||
| 5698 | .haiku, .dragonfly => isize, | ||
| 5699 | else => i64, | ||
| 5700 | }; | ||
| 5701 | pub const suseconds_t = switch (native_os) { | ||
| 5702 | .solaris, .illumos => i64, | ||
| 5703 | .freebsd, .kfreebsd, .dragonfly => c_long, | ||
| 5704 | .netbsd => c_int, | ||
| 5705 | .haiku => i32, | ||
| 5706 | else => void, | ||
| 5707 | }; | ||
| 5708 | |||
| 5709 | pub const timeval = switch (native_os) { | ||
| 5710 | .linux => linux.timeval, | ||
| 5711 | .emscripten => emscripten.timeval, | ||
| 5712 | .windows => extern struct { | ||
| 5713 | sec: c_long, | ||
| 5714 | usec: c_long, | ||
| 5715 | }, | ||
| 5716 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 5717 | sec: c_long, | ||
| 5718 | usec: i32, | ||
| 5719 | }, | ||
| 5720 | .dragonfly, .netbsd, .freebsd, .kfreebsd, .solaris, .illumos => extern struct { | ||
| 5721 | /// seconds | ||
| 5722 | sec: time_t, | ||
| 5723 | /// microseconds | ||
| 5724 | usec: suseconds_t, | ||
| 5725 | }, | ||
| 5726 | .openbsd => extern struct { | ||
| 5727 | sec: time_t, | ||
| 5728 | usec: c_long, | ||
| 5729 | }, | ||
| 5730 | else => void, | ||
| 5731 | }; | ||
| 5732 | pub const timezone = switch (native_os) { | ||
| 5733 | .linux => linux.timezone, | ||
| 5734 | .emscripten => emscripten.timezone, | ||
| 5735 | .openbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 5736 | minuteswest: i32, | ||
| 5737 | dsttime: i32, | ||
| 5738 | }, | ||
| 5739 | else => void, | ||
| 5740 | }; | ||
| 5741 | |||
| 5742 | pub const ucontext_t = switch (native_os) { | ||
| 5743 | .linux => linux.ucontext_t, | ||
| 5744 | .emscripten => emscripten.ucontext_t, | ||
| 5745 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 5746 | onstack: c_int, | ||
| 5747 | sigmask: sigset_t, | ||
| 5748 | stack: stack_t, | ||
| 5749 | link: ?*ucontext_t, | ||
| 5750 | mcsize: u64, | ||
| 5751 | mcontext: *mcontext_t, | ||
| 5752 | __mcontext_data: mcontext_t, | ||
| 5753 | }, | ||
| 5754 | .freebsd, .kfreebsd => extern struct { | ||
| 5755 | sigmask: sigset_t, | ||
| 5756 | mcontext: mcontext_t, | ||
| 5757 | link: ?*ucontext_t, | ||
| 5758 | stack: stack_t, | ||
| 5759 | flags: c_int, | ||
| 5760 | __spare__: [4]c_int, | ||
| 5761 | }, | ||
| 5762 | .solaris, .illumos => extern struct { | ||
| 5763 | flags: u64, | ||
| 5764 | link: ?*ucontext_t, | ||
| 5765 | sigmask: sigset_t, | ||
| 5766 | stack: stack_t, | ||
| 5767 | mcontext: mcontext_t, | ||
| 5768 | brand_data: [3]?*anyopaque, | ||
| 5769 | filler: [2]i64, | ||
| 5770 | }, | ||
| 5771 | .netbsd => extern struct { | ||
| 5772 | flags: u32, | ||
| 5773 | link: ?*ucontext_t, | ||
| 5774 | sigmask: sigset_t, | ||
| 5775 | stack: stack_t, | ||
| 5776 | mcontext: mcontext_t, | ||
| 5777 | __pad: [ | ||
| 5778 | switch (builtin.cpu.arch) { | ||
| 5779 | .x86 => 4, | ||
| 5780 | .mips, .mipsel, .mips64, .mips64el => 14, | ||
| 5781 | .arm, .armeb, .thumb, .thumbeb => 1, | ||
| 5782 | .sparc, .sparcel, .sparc64 => if (@sizeOf(usize) == 4) 43 else 8, | ||
| 5783 | else => 0, | ||
| 5784 | } | ||
| 5785 | ]u32, | ||
| 5786 | }, | ||
| 5787 | .dragonfly => extern struct { | ||
| 5788 | sigmask: sigset_t, | ||
| 5789 | mcontext: mcontext_t, | ||
| 5790 | link: ?*ucontext_t, | ||
| 5791 | stack: stack_t, | ||
| 5792 | cofunc: ?*fn (?*ucontext_t, ?*anyopaque) void, | ||
| 5793 | arg: ?*void, | ||
| 5794 | _spare: [4]c_int, | ||
| 5795 | }, | ||
| 5796 | .haiku => extern struct { | ||
| 5797 | link: ?*ucontext_t, | ||
| 5798 | sigmask: sigset_t, | ||
| 5799 | stack: stack_t, | ||
| 5800 | mcontext: mcontext_t, | ||
| 5801 | }, | ||
| 5802 | .openbsd => openbsd.ucontext_t, | ||
| 5803 | else => void, | ||
| 5804 | }; | ||
| 5805 | pub const mcontext_t = switch (native_os) { | ||
| 5806 | .linux => linux.mcontext_t, | ||
| 5807 | .emscripten => emscripten.mcontext_t, | ||
| 5808 | .macos, .ios, .tvos, .watchos, .visionos => darwin.mcontext_t, | ||
| 5809 | .freebsd, .kfreebsd => switch (builtin.cpu.arch) { | ||
| 5810 | .x86_64 => extern struct { | ||
| 5811 | onstack: u64, | ||
| 5812 | rdi: u64, | ||
| 5813 | rsi: u64, | ||
| 5814 | rdx: u64, | ||
| 5815 | rcx: u64, | ||
| 5816 | r8: u64, | ||
| 5817 | r9: u64, | ||
| 5818 | rax: u64, | ||
| 5819 | rbx: u64, | ||
| 5820 | rbp: u64, | ||
| 5821 | r10: u64, | ||
| 5822 | r11: u64, | ||
| 5823 | r12: u64, | ||
| 5824 | r13: u64, | ||
| 5825 | r14: u64, | ||
| 5826 | r15: u64, | ||
| 5827 | trapno: u32, | ||
| 5828 | fs: u16, | ||
| 5829 | gs: u16, | ||
| 5830 | addr: u64, | ||
| 5831 | flags: u32, | ||
| 5832 | es: u16, | ||
| 5833 | ds: u16, | ||
| 5834 | err: u64, | ||
| 5835 | rip: u64, | ||
| 5836 | cs: u64, | ||
| 5837 | rflags: u64, | ||
| 5838 | rsp: u64, | ||
| 5839 | ss: u64, | ||
| 5840 | len: u64, | ||
| 5841 | fpformat: u64, | ||
| 5842 | ownedfp: u64, | ||
| 5843 | fpstate: [64]u64 align(16), | ||
| 5844 | fsbase: u64, | ||
| 5845 | gsbase: u64, | ||
| 5846 | xfpustate: u64, | ||
| 5847 | xfpustate_len: u64, | ||
| 5848 | spare: [4]u64, | ||
| 5849 | }, | ||
| 5850 | .aarch64 => extern struct { | ||
| 5851 | gpregs: extern struct { | ||
| 5852 | x: [30]u64, | ||
| 5853 | lr: u64, | ||
| 5854 | sp: u64, | ||
| 5855 | elr: u64, | ||
| 5856 | spsr: u32, | ||
| 5857 | _pad: u32, | ||
| 5858 | }, | ||
| 5859 | fpregs: extern struct { | ||
| 5860 | q: [32]u128, | ||
| 5861 | sr: u32, | ||
| 5862 | cr: u32, | ||
| 5863 | flags: u32, | ||
| 5864 | _pad: u32, | ||
| 5865 | }, | ||
| 5866 | flags: u32, | ||
| 5867 | _pad: u32, | ||
| 5868 | _spare: [8]u64, | ||
| 5869 | }, | ||
| 5870 | else => struct {}, | ||
| 5871 | }, | ||
| 5872 | .solaris, .illumos => extern struct { | ||
| 5873 | gregs: [28]u64, | ||
| 5874 | fpregs: solaris.fpregset_t, | ||
| 5875 | }, | ||
| 5876 | .netbsd => switch (builtin.cpu.arch) { | ||
| 5877 | .aarch64 => extern struct { | ||
| 5878 | gregs: [35]u64, | ||
| 5879 | fregs: [528]u8 align(16), | ||
| 5880 | spare: [8]u64, | ||
| 5881 | }, | ||
| 5882 | .x86_64 => extern struct { | ||
| 5883 | gregs: [26]u64, | ||
| 5884 | mc_tlsbase: u64, | ||
| 5885 | fpregs: [512]u8 align(8), | ||
| 5886 | }, | ||
| 5887 | else => struct {}, | ||
| 5888 | }, | ||
| 5889 | .dragonfly => dragonfly.mcontext_t, | ||
| 5890 | .haiku => haiku.mcontext_t, | ||
| 5891 | else => void, | ||
| 5892 | }; | ||
| 5893 | |||
| 5894 | pub const user_desc = switch (native_os) { | ||
| 5895 | .linux => linux.user_desc, | ||
| 5896 | else => void, | ||
| 5897 | }; | ||
| 5898 | pub const utsname = switch (native_os) { | ||
| 5899 | .linux => linux.utsname, | ||
| 5900 | .emscripten => emscripten.utsname, | ||
| 5901 | .solaris, .illumos => extern struct { | ||
| 5902 | sysname: [256:0]u8, | ||
| 5903 | nodename: [256:0]u8, | ||
| 5904 | release: [256:0]u8, | ||
| 5905 | version: [256:0]u8, | ||
| 5906 | machine: [256:0]u8, | ||
| 5907 | domainname: [256:0]u8, | ||
| 5908 | }, | ||
| 5909 | else => void, | ||
| 5910 | }; | ||
| 5911 | pub const PR = switch (native_os) { | ||
| 5912 | .linux => linux.PR, | ||
| 5913 | else => void, | ||
| 5914 | }; | ||
| 5915 | pub const _errno = switch (native_os) { | ||
| 5916 | .linux => switch (native_abi) { | ||
| 5917 | .android => private.__errno, | ||
| 5918 | else => private.__errno_location, | ||
| 5919 | }, | ||
| 5920 | .emscripten => private.__errno_location, | ||
| 5921 | .wasi, .dragonfly => private.errnoFromThreadLocal, | ||
| 5922 | .windows => private._errno, | ||
| 5923 | .macos, .ios, .tvos, .watchos, .visionos, .freebsd, .kfreebsd => private.__error, | ||
| 5924 | .solaris, .illumos => private.___errno, | ||
| 5925 | .openbsd, .netbsd => private.__errno, | ||
| 5926 | .haiku => haiku._errnop, | ||
| 5927 | else => {}, | ||
| 5928 | }; | ||
| 5929 | |||
| 5930 | pub const RTLD = switch (native_os) { | ||
| 5931 | .linux, .emscripten => packed struct(u32) { | ||
| 5932 | LAZY: bool = false, | ||
| 5933 | NOW: bool = false, | ||
| 5934 | NOLOAD: bool = false, | ||
| 5935 | _3: u5 = 0, | ||
| 5936 | GLOBAL: bool = false, | ||
| 5937 | _9: u3 = 0, | ||
| 5938 | NODELETE: bool = false, | ||
| 5939 | _: u19 = 0, | ||
| 5940 | }, | ||
| 5941 | .dragonfly, .freebsd, .kfreebsd => packed struct(u32) { | ||
| 5942 | LAZY: bool = false, | ||
| 5943 | NOW: bool = false, | ||
| 5944 | _2: u6 = 0, | ||
| 5945 | GLOBAL: bool = false, | ||
| 5946 | TRACE: bool = false, | ||
| 5947 | _10: u2 = 0, | ||
| 5948 | NODELETE: bool = false, | ||
| 5949 | NOLOAD: bool = false, | ||
| 5950 | _: u18 = 0, | ||
| 5951 | }, | ||
| 5952 | .haiku => packed struct(u32) { | ||
| 5953 | NOW: bool = false, | ||
| 5954 | GLOBAL: bool = false, | ||
| 5955 | _: u30 = 0, | ||
| 5956 | }, | ||
| 5957 | .netbsd => packed struct(u32) { | ||
| 5958 | LAZY: bool = false, | ||
| 5959 | NOW: bool = false, | ||
| 5960 | _2: u6 = 0, | ||
| 5961 | GLOBAL: bool = false, | ||
| 5962 | LOCAL: bool = false, | ||
| 5963 | _10: u2 = 0, | ||
| 5964 | NODELETE: bool = false, | ||
| 5965 | NOLOAD: bool = false, | ||
| 5966 | _: u18 = 0, | ||
| 5967 | }, | ||
| 5968 | .solaris, .illumos => packed struct(u32) { | ||
| 5969 | LAZY: bool = false, | ||
| 5970 | NOW: bool = false, | ||
| 5971 | NOLOAD: bool = false, | ||
| 5972 | _3: u5 = 0, | ||
| 5973 | GLOBAL: bool = false, | ||
| 5974 | PARENT: bool = false, | ||
| 5975 | GROUP: bool = false, | ||
| 5976 | WORLD: bool = false, | ||
| 5977 | NODELETE: bool = false, | ||
| 5978 | FIRST: bool = false, | ||
| 5979 | _14: u2 = 0, | ||
| 5980 | CONFGEN: bool = false, | ||
| 5981 | _: u15 = 0, | ||
| 5982 | }, | ||
| 5983 | .openbsd => packed struct(u32) { | ||
| 5984 | LAZY: bool = false, | ||
| 5985 | NOW: bool = false, | ||
| 5986 | _2: u6 = 0, | ||
| 5987 | GLOBAL: bool = false, | ||
| 5988 | TRACE: bool = false, | ||
| 5989 | _: u22 = 0, | ||
| 5990 | }, | ||
| 5991 | .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) { | ||
| 5992 | LAZY: bool = false, | ||
| 5993 | NOW: bool = false, | ||
| 5994 | LOCAL: bool = false, | ||
| 5995 | GLOBAL: bool = false, | ||
| 5996 | NOLOAD: bool = false, | ||
| 5997 | _5: u2 = 0, | ||
| 5998 | NODELETE: bool = false, | ||
| 5999 | FIRST: bool = false, | ||
| 6000 | _: u23 = 0, | ||
| 6001 | }, | ||
| 6002 | else => void, | ||
| 6003 | }; | ||
| 6004 | |||
| 6005 | pub const dirent = switch (native_os) { | ||
| 6006 | .linux, .emscripten => extern struct { | ||
| 6007 | ino: c_uint, | ||
| 6008 | off: c_uint, | ||
| 6009 | reclen: c_ushort, | ||
| 6010 | type: u8, | ||
| 6011 | name: [256]u8, | ||
| 6012 | }, | ||
| 6013 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 6014 | ino: u64, | ||
| 6015 | seekoff: u64, | ||
| 6016 | reclen: u16, | ||
| 6017 | namlen: u16, | ||
| 6018 | type: u8, | ||
| 6019 | name: [1024]u8, | ||
| 6020 | }, | ||
| 6021 | .freebsd, .kfreebsd => extern struct { | ||
| 6022 | /// File number of entry. | ||
| 6023 | fileno: ino_t, | ||
| 6024 | /// Directory offset of entry. | ||
| 6025 | off: off_t, | ||
| 6026 | /// Length of this record. | ||
| 6027 | reclen: u16, | ||
| 6028 | /// File type, one of DT_. | ||
| 6029 | type: u8, | ||
| 6030 | pad0: u8 = 0, | ||
| 6031 | /// Length of the name member. | ||
| 6032 | namlen: u16, | ||
| 6033 | pad1: u16 = 0, | ||
| 6034 | /// Name of entry. | ||
| 6035 | name: [255:0]u8, | ||
| 6036 | }, | ||
| 6037 | .solaris, .illumos => extern struct { | ||
| 6038 | /// Inode number of entry. | ||
| 6039 | ino: ino_t, | ||
| 6040 | /// Offset of this entry on disk. | ||
| 6041 | off: off_t, | ||
| 6042 | /// Length of this record. | ||
| 6043 | reclen: u16, | ||
| 6044 | /// File name. | ||
| 6045 | name: [MAXNAMLEN:0]u8, | ||
| 6046 | }, | ||
| 6047 | .netbsd => extern struct { | ||
| 6048 | fileno: ino_t, | ||
| 6049 | reclen: u16, | ||
| 6050 | namlen: u16, | ||
| 6051 | type: u8, | ||
| 6052 | name: [MAXNAMLEN:0]u8, | ||
| 6053 | }, | ||
| 6054 | .dragonfly => extern struct { | ||
| 6055 | fileno: c_ulong, | ||
| 6056 | namlen: u16, | ||
| 6057 | type: u8, | ||
| 6058 | unused1: u8, | ||
| 6059 | unused2: u32, | ||
| 6060 | name: [256]u8, | ||
| 6061 | |||
| 6062 | pub fn reclen(self: dirent) u16 { | ||
| 6063 | return (@offsetOf(dirent, "name") + self.namlen + 1 + 7) & ~@as(u16, 7); | ||
| 6064 | } | ||
| 6065 | }, | ||
| 6066 | .openbsd => extern struct { | ||
| 6067 | fileno: ino_t, | ||
| 6068 | off: off_t, | ||
| 6069 | reclen: u16, | ||
| 6070 | type: u8, | ||
| 6071 | namlen: u8, | ||
| 6072 | _: u32 align(1) = 0, | ||
| 6073 | name: [MAXNAMLEN:0]u8, | ||
| 6074 | }, | ||
| 6075 | else => void, | ||
| 6076 | }; | ||
| 6077 | pub const MAXNAMLEN = switch (native_os) { | ||
| 6078 | .netbsd, .solaris, .illumos => 511, | ||
| 6079 | .haiku => NAME_MAX, | ||
| 6080 | .openbsd => 255, | ||
| 6081 | else => {}, | ||
| 6082 | }; | ||
| 6083 | pub const dirent64 = switch (native_os) { | ||
| 6084 | .linux => extern struct { | ||
| 6085 | ino: c_ulong, | ||
| 6086 | off: c_ulong, | ||
| 6087 | reclen: c_ushort, | ||
| 6088 | type: u8, | ||
| 6089 | name: [256]u8, | ||
| 6090 | }, | ||
| 6091 | else => void, | ||
| 6092 | }; | ||
| 6093 | |||
| 6094 | pub const AI = switch (native_os) { | ||
| 6095 | .linux, .emscripten => linux.AI, | ||
| 6096 | .dragonfly, .haiku, .freebsd, .kfreebsd => packed struct(u32) { | ||
| 6097 | PASSIVE: bool = false, | ||
| 6098 | CANONNAME: bool = false, | ||
| 6099 | NUMERICHOST: bool = false, | ||
| 6100 | NUMERICSERV: bool = false, | ||
| 6101 | _4: u4 = 0, | ||
| 6102 | ALL: bool = false, | ||
| 6103 | V4MAPPED_CFG: bool = false, | ||
| 6104 | ADDRCONFIG: bool = false, | ||
| 6105 | V4MAPPED: bool = false, | ||
| 6106 | _: u20 = 0, | ||
| 6107 | }, | ||
| 6108 | .netbsd => packed struct(u32) { | ||
| 6109 | PASSIVE: bool = false, | ||
| 6110 | CANONNAME: bool = false, | ||
| 6111 | NUMERICHOST: bool = false, | ||
| 6112 | NUMERICSERV: bool = false, | ||
| 6113 | _4: u6 = 0, | ||
| 6114 | ADDRCONFIG: bool = false, | ||
| 6115 | _: u21 = 0, | ||
| 6116 | }, | ||
| 6117 | .solaris, .illumos => packed struct(u32) { | ||
| 6118 | V4MAPPED: bool = false, | ||
| 6119 | ALL: bool = false, | ||
| 6120 | ADDRCONFIG: bool = false, | ||
| 6121 | PASSIVE: bool = false, | ||
| 6122 | CANONNAME: bool = false, | ||
| 6123 | NUMERICHOST: bool = false, | ||
| 6124 | NUMERICSERV: bool = false, | ||
| 6125 | _: u25 = 0, | ||
| 6126 | }, | ||
| 6127 | .openbsd => packed struct(u32) { | ||
| 6128 | PASSIVE: bool = false, | ||
| 6129 | CANONNAME: bool = false, | ||
| 6130 | NUMERICHOST: bool = false, | ||
| 6131 | _3: u1 = 0, | ||
| 6132 | NUMERICSERV: bool = false, | ||
| 6133 | _5: u1 = 0, | ||
| 6134 | ADDRCONFIG: bool = false, | ||
| 6135 | _: u25 = 0, | ||
| 6136 | }, | ||
| 6137 | .macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) { | ||
| 6138 | PASSIVE: bool = false, | ||
| 6139 | CANONNAME: bool = false, | ||
| 6140 | NUMERICHOST: bool = false, | ||
| 6141 | _3: u9 = 0, | ||
| 6142 | NUMERICSERV: bool = false, | ||
| 6143 | _: u19 = 0, | ||
| 6144 | }, | ||
| 6145 | .windows => ws2_32.AI, | ||
| 6146 | else => void, | ||
| 6147 | }; | ||
| 6148 | |||
| 6149 | pub const NI = switch (native_os) { | ||
| 6150 | .linux, .emscripten => packed struct(u32) { | ||
| 6151 | NUMERICHOST: bool = false, | ||
| 6152 | NUMERICSERV: bool = false, | ||
| 6153 | NOFQDN: bool = false, | ||
| 6154 | NAMEREQD: bool = false, | ||
| 6155 | DGRAM: bool = false, | ||
| 6156 | _5: u3 = 0, | ||
| 6157 | NUMERICSCOPE: bool = false, | ||
| 6158 | _: u23 = 0, | ||
| 6159 | }, | ||
| 6160 | .solaris, .illumos => packed struct(u32) { | ||
| 6161 | NOFQDN: bool = false, | ||
| 6162 | NUMERICHOST: bool = false, | ||
| 6163 | NAMEREQD: bool = false, | ||
| 6164 | NUMERICSERV: bool = false, | ||
| 6165 | DGRAM: bool = false, | ||
| 6166 | WITHSCOPEID: bool = false, | ||
| 6167 | NUMERICSCOPE: bool = false, | ||
| 6168 | _: u25 = 0, | ||
| 6169 | }, | ||
| 6170 | else => void, | ||
| 6171 | }; | ||
| 6172 | |||
| 6173 | pub const EAI = switch (native_os) { | ||
| 6174 | .linux, .emscripten => enum(c_int) { | ||
| 6175 | BADFLAGS = -1, | ||
| 6176 | NONAME = -2, | ||
| 6177 | AGAIN = -3, | ||
| 6178 | FAIL = -4, | ||
| 6179 | FAMILY = -6, | ||
| 6180 | SOCKTYPE = -7, | ||
| 6181 | SERVICE = -8, | ||
| 6182 | MEMORY = -10, | ||
| 6183 | SYSTEM = -11, | ||
| 6184 | OVERFLOW = -12, | ||
| 6185 | |||
| 6186 | NODATA = -5, | ||
| 6187 | ADDRFAMILY = -9, | ||
| 6188 | INPROGRESS = -100, | ||
| 6189 | CANCELED = -101, | ||
| 6190 | NOTCANCELED = -102, | ||
| 6191 | ALLDONE = -103, | ||
| 6192 | INTR = -104, | ||
| 6193 | IDN_ENCODE = -105, | ||
| 6194 | |||
| 6195 | _, | ||
| 6196 | }, | ||
| 6197 | .haiku, .dragonfly, .netbsd, .freebsd, .kfreebsd, .macos, .ios, .tvos, .watchos, .visionos => enum(c_int) { | ||
| 6198 | /// address family for hostname not supported | ||
| 6199 | ADDRFAMILY = 1, | ||
| 6200 | /// temporary failure in name resolution | ||
| 6201 | AGAIN = 2, | ||
| 6202 | /// invalid value for ai_flags | ||
| 6203 | BADFLAGS = 3, | ||
| 6204 | /// non-recoverable failure in name resolution | ||
| 6205 | FAIL = 4, | ||
| 6206 | /// ai_family not supported | ||
| 6207 | FAMILY = 5, | ||
| 6208 | /// memory allocation failure | ||
| 6209 | MEMORY = 6, | ||
| 6210 | /// no address associated with hostname | ||
| 6211 | NODATA = 7, | ||
| 6212 | /// hostname nor servname provided, or not known | ||
| 6213 | NONAME = 8, | ||
| 6214 | /// servname not supported for ai_socktype | ||
| 6215 | SERVICE = 9, | ||
| 6216 | /// ai_socktype not supported | ||
| 6217 | SOCKTYPE = 10, | ||
| 6218 | /// system error returned in errno | ||
| 6219 | SYSTEM = 11, | ||
| 6220 | /// invalid value for hints | ||
| 6221 | BADHINTS = 12, | ||
| 6222 | /// resolved protocol is unknown | ||
| 6223 | PROTOCOL = 13, | ||
| 6224 | /// argument buffer overflow | ||
| 6225 | OVERFLOW = 14, | ||
| 6226 | _, | ||
| 6227 | }, | ||
| 6228 | .solaris, .illumos => enum(c_int) { | ||
| 6229 | /// address family for hostname not supported | ||
| 6230 | ADDRFAMILY = 1, | ||
| 6231 | /// name could not be resolved at this time | ||
| 6232 | AGAIN = 2, | ||
| 6233 | /// flags parameter had an invalid value | ||
| 6234 | BADFLAGS = 3, | ||
| 6235 | /// non-recoverable failure in name resolution | ||
| 6236 | FAIL = 4, | ||
| 6237 | /// address family not recognized | ||
| 6238 | FAMILY = 5, | ||
| 6239 | /// memory allocation failure | ||
| 6240 | MEMORY = 6, | ||
| 6241 | /// no address associated with hostname | ||
| 6242 | NODATA = 7, | ||
| 6243 | /// name does not resolve | ||
| 6244 | NONAME = 8, | ||
| 6245 | /// service not recognized for socket type | ||
| 6246 | SERVICE = 9, | ||
| 6247 | /// intended socket type was not recognized | ||
| 6248 | SOCKTYPE = 10, | ||
| 6249 | /// system error returned in errno | ||
| 6250 | SYSTEM = 11, | ||
| 6251 | /// argument buffer overflow | ||
| 6252 | OVERFLOW = 12, | ||
| 6253 | /// resolved protocol is unknown | ||
| 6254 | PROTOCOL = 13, | ||
| 6255 | |||
| 6256 | _, | ||
| 6257 | }, | ||
| 6258 | .openbsd => enum(c_int) { | ||
| 6259 | /// address family for hostname not supported | ||
| 6260 | ADDRFAMILY = -9, | ||
| 6261 | /// name could not be resolved at this time | ||
| 6262 | AGAIN = -3, | ||
| 6263 | /// flags parameter had an invalid value | ||
| 6264 | BADFLAGS = -1, | ||
| 6265 | /// non-recoverable failure in name resolution | ||
| 6266 | FAIL = -4, | ||
| 6267 | /// address family not recognized | ||
| 6268 | FAMILY = -6, | ||
| 6269 | /// memory allocation failure | ||
| 6270 | MEMORY = -10, | ||
| 6271 | /// no address associated with hostname | ||
| 6272 | NODATA = -5, | ||
| 6273 | /// name does not resolve | ||
| 6274 | NONAME = -2, | ||
| 6275 | /// service not recognized for socket type | ||
| 6276 | SERVICE = -8, | ||
| 6277 | /// intended socket type was not recognized | ||
| 6278 | SOCKTYPE = -7, | ||
| 6279 | /// system error returned in errno | ||
| 6280 | SYSTEM = -11, | ||
| 6281 | /// invalid value for hints | ||
| 6282 | BADHINTS = -12, | ||
| 6283 | /// resolved protocol is unknown | ||
| 6284 | PROTOCOL = -13, | ||
| 6285 | /// argument buffer overflow | ||
| 6286 | OVERFLOW = -14, | ||
| 6287 | _, | ||
| 6288 | }, | ||
| 6289 | else => void, | ||
| 6290 | }; | ||
| 6291 | |||
| 6292 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 6293 | |||
| 6294 | pub const Stat = switch (native_os) { | ||
| 6295 | .linux => switch (native_arch) { | ||
| 6296 | .sparc64 => extern struct { | ||
| 6297 | dev: u64, | ||
| 6298 | __pad1: u16, | ||
| 6299 | ino: ino_t, | ||
| 6300 | mode: u32, | ||
| 6301 | nlink: u32, | ||
| 6302 | |||
| 6303 | uid: u32, | ||
| 6304 | gid: u32, | ||
| 6305 | rdev: u64, | ||
| 6306 | __pad2: u16, | ||
| 6307 | |||
| 6308 | size: off_t, | ||
| 6309 | blksize: isize, | ||
| 6310 | blocks: i64, | ||
| 6311 | |||
| 6312 | atim: timespec, | ||
| 6313 | mtim: timespec, | ||
| 6314 | ctim: timespec, | ||
| 6315 | __reserved: [2]usize, | ||
| 6316 | |||
| 6317 | pub fn atime(self: @This()) timespec { | ||
| 6318 | return self.atim; | ||
| 6319 | } | ||
| 6320 | |||
| 6321 | pub fn mtime(self: @This()) timespec { | ||
| 6322 | return self.mtim; | ||
| 6323 | } | ||
| 6324 | |||
| 6325 | pub fn ctime(self: @This()) timespec { | ||
| 6326 | return self.ctim; | ||
| 6327 | } | ||
| 6328 | }, | ||
| 6329 | .mips, .mipsel => extern struct { | ||
| 6330 | dev: dev_t, | ||
| 6331 | __pad0: [2]u32, | ||
| 6332 | ino: ino_t, | ||
| 6333 | mode: mode_t, | ||
| 6334 | nlink: nlink_t, | ||
| 6335 | uid: uid_t, | ||
| 6336 | gid: gid_t, | ||
| 6337 | rdev: dev_t, | ||
| 6338 | __pad1: [2]u32, | ||
| 6339 | size: off_t, | ||
| 6340 | atim: timespec, | ||
| 6341 | mtim: timespec, | ||
| 6342 | ctim: timespec, | ||
| 6343 | blksize: blksize_t, | ||
| 6344 | __pad3: u32, | ||
| 6345 | blocks: blkcnt_t, | ||
| 6346 | __pad4: [14]u32, | ||
| 6347 | |||
| 6348 | pub fn atime(self: @This()) timespec { | ||
| 6349 | return self.atim; | ||
| 6350 | } | ||
| 6351 | |||
| 6352 | pub fn mtime(self: @This()) timespec { | ||
| 6353 | return self.mtim; | ||
| 6354 | } | ||
| 6355 | |||
| 6356 | pub fn ctime(self: @This()) timespec { | ||
| 6357 | return self.ctim; | ||
| 6358 | } | ||
| 6359 | }, | ||
| 6360 | |||
| 6361 | else => std.os.linux.Stat, // libc stat is the same as kernel stat. | ||
| 6362 | }, | ||
| 6363 | .emscripten => emscripten.Stat, | ||
| 6364 | .wasi => extern struct { | ||
| 6365 | dev: dev_t, | ||
| 6366 | ino: ino_t, | ||
| 6367 | nlink: nlink_t, | ||
| 6368 | mode: mode_t, | ||
| 6369 | uid: uid_t, | ||
| 6370 | gid: gid_t, | ||
| 6371 | __pad0: c_uint = 0, | ||
| 6372 | rdev: dev_t, | ||
| 6373 | size: off_t, | ||
| 6374 | blksize: blksize_t, | ||
| 6375 | blocks: blkcnt_t, | ||
| 6376 | atim: timespec, | ||
| 6377 | mtim: timespec, | ||
| 6378 | ctim: timespec, | ||
| 6379 | __reserved: [3]c_longlong = [3]c_longlong{ 0, 0, 0 }, | ||
| 6380 | |||
| 6381 | pub fn atime(self: @This()) timespec { | ||
| 6382 | return self.atim; | ||
| 6383 | } | ||
| 6384 | |||
| 6385 | pub fn mtime(self: @This()) timespec { | ||
| 6386 | return self.mtim; | ||
| 6387 | } | ||
| 6388 | |||
| 6389 | pub fn ctime(self: @This()) timespec { | ||
| 6390 | return self.ctim; | ||
| 6391 | } | ||
| 6392 | |||
| 6393 | pub fn fromFilestat(st: wasi.filestat_t) Stat { | ||
| 6394 | return .{ | ||
| 6395 | .dev = st.dev, | ||
| 6396 | .ino = st.ino, | ||
| 6397 | .mode = switch (st.filetype) { | ||
| 6398 | .UNKNOWN => 0, | ||
| 6399 | .BLOCK_DEVICE => S.IFBLK, | ||
| 6400 | .CHARACTER_DEVICE => S.IFCHR, | ||
| 6401 | .DIRECTORY => S.IFDIR, | ||
| 6402 | .REGULAR_FILE => S.IFREG, | ||
| 6403 | .SOCKET_DGRAM => S.IFSOCK, | ||
| 6404 | .SOCKET_STREAM => S.IFIFO, | ||
| 6405 | .SYMBOLIC_LINK => S.IFLNK, | ||
| 6406 | _ => 0, | ||
| 6407 | }, | ||
| 6408 | .nlink = st.nlink, | ||
| 6409 | .size = @intCast(st.size), | ||
| 6410 | .atim = timespec.fromTimestamp(st.atim), | ||
| 6411 | .mtim = timespec.fromTimestamp(st.mtim), | ||
| 6412 | .ctim = timespec.fromTimestamp(st.ctim), | ||
| 6413 | |||
| 6414 | .uid = 0, | ||
| 6415 | .gid = 0, | ||
| 6416 | .rdev = 0, | ||
| 6417 | .blksize = 0, | ||
| 6418 | .blocks = 0, | ||
| 6419 | }; | ||
| 31 | } | 6420 | } |
| 32 | }; | 6421 | }, |
| 33 | } | 6422 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { |
| 6423 | dev: i32, | ||
| 6424 | mode: u16, | ||
| 6425 | nlink: u16, | ||
| 6426 | ino: ino_t, | ||
| 6427 | uid: uid_t, | ||
| 6428 | gid: gid_t, | ||
| 6429 | rdev: i32, | ||
| 6430 | atimespec: timespec, | ||
| 6431 | mtimespec: timespec, | ||
| 6432 | ctimespec: timespec, | ||
| 6433 | birthtimespec: timespec, | ||
| 6434 | size: off_t, | ||
| 6435 | blocks: i64, | ||
| 6436 | blksize: i32, | ||
| 6437 | flags: u32, | ||
| 6438 | gen: u32, | ||
| 6439 | lspare: i32, | ||
| 6440 | qspare: [2]i64, | ||
| 34 | 6441 | ||
| 35 | pub usingnamespace switch (native_os) { | 6442 | pub fn atime(self: @This()) timespec { |
| 36 | .linux => @import("c/linux.zig"), | 6443 | return self.atimespec; |
| 37 | .windows => @import("c/windows.zig"), | 6444 | } |
| 38 | .macos, .ios, .tvos, .watchos, .visionos => @import("c/darwin.zig"), | 6445 | |
| 39 | .freebsd, .kfreebsd => @import("c/freebsd.zig"), | 6446 | pub fn mtime(self: @This()) timespec { |
| 40 | .netbsd => @import("c/netbsd.zig"), | 6447 | return self.mtimespec; |
| 41 | .dragonfly => @import("c/dragonfly.zig"), | 6448 | } |
| 42 | .openbsd => @import("c/openbsd.zig"), | 6449 | |
| 43 | .haiku => @import("c/haiku.zig"), | 6450 | pub fn ctime(self: @This()) timespec { |
| 44 | .solaris, .illumos => @import("c/solaris.zig"), | 6451 | return self.ctimespec; |
| 45 | .emscripten => @import("c/emscripten.zig"), | 6452 | } |
| 46 | .wasi => wasi, | 6453 | |
| 47 | else => struct {}, | 6454 | pub fn birthtime(self: @This()) timespec { |
| 6455 | return self.birthtimespec; | ||
| 6456 | } | ||
| 6457 | }, | ||
| 6458 | .freebsd, .kfreebsd => freebsd.Stat, | ||
| 6459 | .solaris, .illumos => extern struct { | ||
| 6460 | dev: dev_t, | ||
| 6461 | ino: ino_t, | ||
| 6462 | mode: mode_t, | ||
| 6463 | nlink: nlink_t, | ||
| 6464 | uid: uid_t, | ||
| 6465 | gid: gid_t, | ||
| 6466 | rdev: dev_t, | ||
| 6467 | size: off_t, | ||
| 6468 | atim: timespec, | ||
| 6469 | mtim: timespec, | ||
| 6470 | ctim: timespec, | ||
| 6471 | blksize: blksize_t, | ||
| 6472 | blocks: blkcnt_t, | ||
| 6473 | fstype: [16]u8, | ||
| 6474 | |||
| 6475 | pub fn atime(self: @This()) timespec { | ||
| 6476 | return self.atim; | ||
| 6477 | } | ||
| 6478 | |||
| 6479 | pub fn mtime(self: @This()) timespec { | ||
| 6480 | return self.mtim; | ||
| 6481 | } | ||
| 6482 | |||
| 6483 | pub fn ctime(self: @This()) timespec { | ||
| 6484 | return self.ctim; | ||
| 6485 | } | ||
| 6486 | }, | ||
| 6487 | .netbsd => extern struct { | ||
| 6488 | dev: dev_t, | ||
| 6489 | mode: mode_t, | ||
| 6490 | ino: ino_t, | ||
| 6491 | nlink: nlink_t, | ||
| 6492 | uid: uid_t, | ||
| 6493 | gid: gid_t, | ||
| 6494 | rdev: dev_t, | ||
| 6495 | atim: timespec, | ||
| 6496 | mtim: timespec, | ||
| 6497 | ctim: timespec, | ||
| 6498 | birthtim: timespec, | ||
| 6499 | size: off_t, | ||
| 6500 | blocks: blkcnt_t, | ||
| 6501 | blksize: blksize_t, | ||
| 6502 | flags: u32, | ||
| 6503 | gen: u32, | ||
| 6504 | __spare: [2]u32, | ||
| 6505 | |||
| 6506 | pub fn atime(self: @This()) timespec { | ||
| 6507 | return self.atim; | ||
| 6508 | } | ||
| 6509 | |||
| 6510 | pub fn mtime(self: @This()) timespec { | ||
| 6511 | return self.mtim; | ||
| 6512 | } | ||
| 6513 | |||
| 6514 | pub fn ctime(self: @This()) timespec { | ||
| 6515 | return self.ctim; | ||
| 6516 | } | ||
| 6517 | |||
| 6518 | pub fn birthtime(self: @This()) timespec { | ||
| 6519 | return self.birthtim; | ||
| 6520 | } | ||
| 6521 | }, | ||
| 6522 | .dragonfly => extern struct { | ||
| 6523 | ino: ino_t, | ||
| 6524 | nlink: c_uint, | ||
| 6525 | dev: c_uint, | ||
| 6526 | mode: c_ushort, | ||
| 6527 | padding1: u16, | ||
| 6528 | uid: uid_t, | ||
| 6529 | gid: gid_t, | ||
| 6530 | rdev: c_uint, | ||
| 6531 | atim: timespec, | ||
| 6532 | mtim: timespec, | ||
| 6533 | ctim: timespec, | ||
| 6534 | size: c_ulong, | ||
| 6535 | blocks: i64, | ||
| 6536 | blksize: u32, | ||
| 6537 | flags: u32, | ||
| 6538 | gen: u32, | ||
| 6539 | lspare: i32, | ||
| 6540 | qspare1: i64, | ||
| 6541 | qspare2: i64, | ||
| 6542 | pub fn atime(self: @This()) timespec { | ||
| 6543 | return self.atim; | ||
| 6544 | } | ||
| 6545 | |||
| 6546 | pub fn mtime(self: @This()) timespec { | ||
| 6547 | return self.mtim; | ||
| 6548 | } | ||
| 6549 | |||
| 6550 | pub fn ctime(self: @This()) timespec { | ||
| 6551 | return self.ctim; | ||
| 6552 | } | ||
| 6553 | }, | ||
| 6554 | .haiku => extern struct { | ||
| 6555 | dev: dev_t, | ||
| 6556 | ino: ino_t, | ||
| 6557 | mode: mode_t, | ||
| 6558 | nlink: nlink_t, | ||
| 6559 | uid: uid_t, | ||
| 6560 | gid: gid_t, | ||
| 6561 | size: off_t, | ||
| 6562 | rdev: dev_t, | ||
| 6563 | blksize: blksize_t, | ||
| 6564 | atim: timespec, | ||
| 6565 | mtim: timespec, | ||
| 6566 | ctim: timespec, | ||
| 6567 | crtim: timespec, | ||
| 6568 | type: u32, | ||
| 6569 | blocks: blkcnt_t, | ||
| 6570 | |||
| 6571 | pub fn atime(self: @This()) timespec { | ||
| 6572 | return self.atim; | ||
| 6573 | } | ||
| 6574 | pub fn mtime(self: @This()) timespec { | ||
| 6575 | return self.mtim; | ||
| 6576 | } | ||
| 6577 | pub fn ctime(self: @This()) timespec { | ||
| 6578 | return self.ctim; | ||
| 6579 | } | ||
| 6580 | pub fn birthtime(self: @This()) timespec { | ||
| 6581 | return self.crtim; | ||
| 6582 | } | ||
| 6583 | }, | ||
| 6584 | .openbsd => extern struct { | ||
| 6585 | mode: mode_t, | ||
| 6586 | dev: dev_t, | ||
| 6587 | ino: ino_t, | ||
| 6588 | nlink: nlink_t, | ||
| 6589 | uid: uid_t, | ||
| 6590 | gid: gid_t, | ||
| 6591 | rdev: dev_t, | ||
| 6592 | atim: timespec, | ||
| 6593 | mtim: timespec, | ||
| 6594 | ctim: timespec, | ||
| 6595 | size: off_t, | ||
| 6596 | blocks: blkcnt_t, | ||
| 6597 | blksize: blksize_t, | ||
| 6598 | flags: u32, | ||
| 6599 | gen: u32, | ||
| 6600 | birthtim: timespec, | ||
| 6601 | |||
| 6602 | pub fn atime(self: @This()) timespec { | ||
| 6603 | return self.atim; | ||
| 6604 | } | ||
| 6605 | |||
| 6606 | pub fn mtime(self: @This()) timespec { | ||
| 6607 | return self.mtim; | ||
| 6608 | } | ||
| 6609 | |||
| 6610 | pub fn ctime(self: @This()) timespec { | ||
| 6611 | return self.ctim; | ||
| 6612 | } | ||
| 6613 | |||
| 6614 | pub fn birthtime(self: @This()) timespec { | ||
| 6615 | return self.birthtim; | ||
| 6616 | } | ||
| 6617 | }, | ||
| 6618 | else => void, | ||
| 48 | }; | 6619 | }; |
| 49 | 6620 | ||
| 50 | pub const pthread_mutex_t = switch (native_os) { | 6621 | pub const pthread_mutex_t = switch (native_os) { |
| ... | @@ -73,12 +6644,12 @@ pub const pthread_mutex_t = switch (native_os) { | ... | @@ -73,12 +6644,12 @@ pub const pthread_mutex_t = switch (native_os) { |
| 73 | inner: ?*anyopaque = null, | 6644 | inner: ?*anyopaque = null, |
| 74 | }, | 6645 | }, |
| 75 | .hermit => extern struct { | 6646 | .hermit => extern struct { |
| 76 | ptr: usize = std.math.maxInt(usize), | 6647 | ptr: usize = maxInt(usize), |
| 77 | }, | 6648 | }, |
| 78 | .netbsd => extern struct { | 6649 | .netbsd => extern struct { |
| 79 | magic: u32 = 0x33330003, | 6650 | magic: u32 = 0x33330003, |
| 80 | errorcheck: c.padded_pthread_spin_t = 0, | 6651 | errorcheck: padded_pthread_spin_t = 0, |
| 81 | ceiling: c.padded_pthread_spin_t = 0, | 6652 | ceiling: padded_pthread_spin_t = 0, |
| 82 | owner: usize = 0, | 6653 | owner: usize = 0, |
| 83 | waiters: ?*u8 = null, | 6654 | waiters: ?*u8 = null, |
| 84 | recursed: u32 = 0, | 6655 | recursed: u32 = 0, |
| ... | @@ -106,7 +6677,7 @@ pub const pthread_mutex_t = switch (native_os) { | ... | @@ -106,7 +6677,7 @@ pub const pthread_mutex_t = switch (native_os) { |
| 106 | .emscripten => extern struct { | 6677 | .emscripten => extern struct { |
| 107 | data: [24]u8 align(4) = [_]u8{0} ** 24, | 6678 | data: [24]u8 align(4) = [_]u8{0} ** 24, |
| 108 | }, | 6679 | }, |
| 109 | else => @compileError("target libc does not have pthread_mutex_t"), | 6680 | else => void, |
| 110 | }; | 6681 | }; |
| 111 | 6682 | ||
| 112 | pub const pthread_cond_t = switch (native_os) { | 6683 | pub const pthread_cond_t = switch (native_os) { |
| ... | @@ -122,11 +6693,11 @@ pub const pthread_cond_t = switch (native_os) { | ... | @@ -122,11 +6693,11 @@ pub const pthread_cond_t = switch (native_os) { |
| 122 | inner: ?*anyopaque = null, | 6693 | inner: ?*anyopaque = null, |
| 123 | }, | 6694 | }, |
| 124 | .hermit => extern struct { | 6695 | .hermit => extern struct { |
| 125 | ptr: usize = std.math.maxInt(usize), | 6696 | ptr: usize = maxInt(usize), |
| 126 | }, | 6697 | }, |
| 127 | .netbsd => extern struct { | 6698 | .netbsd => extern struct { |
| 128 | magic: u32 = 0x55550005, | 6699 | magic: u32 = 0x55550005, |
| 129 | lock: c.pthread_spin_t = 0, | 6700 | lock: pthread_spin_t = 0, |
| 130 | waiters_first: ?*u8 = null, | 6701 | waiters_first: ?*u8 = null, |
| 131 | waiters_last: ?*u8 = null, | 6702 | waiters_last: ?*u8 = null, |
| 132 | mutex: ?*pthread_mutex_t = null, | 6703 | mutex: ?*pthread_mutex_t = null, |
| ... | @@ -148,7 +6719,7 @@ pub const pthread_cond_t = switch (native_os) { | ... | @@ -148,7 +6719,7 @@ pub const pthread_cond_t = switch (native_os) { |
| 148 | .fuchsia, .minix, .emscripten => extern struct { | 6719 | .fuchsia, .minix, .emscripten => extern struct { |
| 149 | data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48, | 6720 | data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48, |
| 150 | }, | 6721 | }, |
| 151 | else => @compileError("target libc does not have pthread_cond_t"), | 6722 | else => void, |
| 152 | }; | 6723 | }; |
| 153 | 6724 | ||
| 154 | pub const pthread_rwlock_t = switch (native_os) { | 6725 | pub const pthread_rwlock_t = switch (native_os) { |
| ... | @@ -174,7 +6745,7 @@ pub const pthread_rwlock_t = switch (native_os) { | ... | @@ -174,7 +6745,7 @@ pub const pthread_rwlock_t = switch (native_os) { |
| 174 | ptr: ?*anyopaque = null, | 6745 | ptr: ?*anyopaque = null, |
| 175 | }, | 6746 | }, |
| 176 | .hermit => extern struct { | 6747 | .hermit => extern struct { |
| 177 | ptr: usize = std.math.maxInt(usize), | 6748 | ptr: usize = maxInt(usize), |
| 178 | }, | 6749 | }, |
| 179 | .netbsd => extern struct { | 6750 | .netbsd => extern struct { |
| 180 | magic: c_uint = 0x99990009, | 6751 | magic: c_uint = 0x99990009, |
| ... | @@ -205,7 +6776,185 @@ pub const pthread_rwlock_t = switch (native_os) { | ... | @@ -205,7 +6776,185 @@ pub const pthread_rwlock_t = switch (native_os) { |
| 205 | .emscripten => extern struct { | 6776 | .emscripten => extern struct { |
| 206 | size: [32]u8 align(4) = [_]u8{0} ** 32, | 6777 | size: [32]u8 align(4) = [_]u8{0} ** 32, |
| 207 | }, | 6778 | }, |
| 208 | else => @compileError("target libc does not have pthread_rwlock_t"), | 6779 | else => void, |
| 6780 | }; | ||
| 6781 | |||
| 6782 | pub const pthread_attr_t = switch (native_os) { | ||
| 6783 | .linux, .emscripten, .dragonfly => extern struct { | ||
| 6784 | __size: [56]u8, | ||
| 6785 | __align: c_long, | ||
| 6786 | }, | ||
| 6787 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 6788 | __sig: c_long, | ||
| 6789 | __opaque: [56]u8, | ||
| 6790 | }, | ||
| 6791 | .freebsd, .kfreebsd => extern struct { | ||
| 6792 | inner: ?*anyopaque = null, | ||
| 6793 | }, | ||
| 6794 | .solaris, .illumos => extern struct { | ||
| 6795 | mutexattr: ?*anyopaque = null, | ||
| 6796 | }, | ||
| 6797 | .netbsd => extern struct { | ||
| 6798 | magic: u32, | ||
| 6799 | flags: i32, | ||
| 6800 | private: ?*anyopaque, | ||
| 6801 | }, | ||
| 6802 | .haiku => extern struct { | ||
| 6803 | detach_state: i32, | ||
| 6804 | sched_priority: i32, | ||
| 6805 | stack_size: i32, | ||
| 6806 | guard_size: i32, | ||
| 6807 | stack_address: ?*anyopaque, | ||
| 6808 | }, | ||
| 6809 | .openbsd => extern struct { | ||
| 6810 | inner: ?*anyopaque = null, | ||
| 6811 | }, | ||
| 6812 | else => void, | ||
| 6813 | }; | ||
| 6814 | |||
| 6815 | pub const pthread_key_t = switch (native_os) { | ||
| 6816 | .linux, .emscripten => c_uint, | ||
| 6817 | .openbsd, .solaris, .illumos => c_int, | ||
| 6818 | else => void, | ||
| 6819 | }; | ||
| 6820 | |||
| 6821 | pub const padded_pthread_spin_t = switch (native_os) { | ||
| 6822 | .netbsd => switch (builtin.cpu.arch) { | ||
| 6823 | .x86, .x86_64 => u32, | ||
| 6824 | .sparc, .sparcel, .sparc64 => u32, | ||
| 6825 | else => pthread_spin_t, | ||
| 6826 | }, | ||
| 6827 | else => void, | ||
| 6828 | }; | ||
| 6829 | |||
| 6830 | pub const pthread_spin_t = switch (native_os) { | ||
| 6831 | .netbsd => switch (builtin.cpu.arch) { | ||
| 6832 | .aarch64, .aarch64_be, .aarch64_32 => u8, | ||
| 6833 | .mips, .mipsel, .mips64, .mips64el => u32, | ||
| 6834 | .powerpc, .powerpc64, .powerpc64le => i32, | ||
| 6835 | .x86, .x86_64 => u8, | ||
| 6836 | .arm, .armeb, .thumb, .thumbeb => i32, | ||
| 6837 | .sparc, .sparcel, .sparc64 => u8, | ||
| 6838 | .riscv32, .riscv64 => u32, | ||
| 6839 | else => @compileError("undefined pthread_spin_t for this arch"), | ||
| 6840 | }, | ||
| 6841 | else => void, | ||
| 6842 | }; | ||
| 6843 | |||
| 6844 | pub const sem_t = switch (native_os) { | ||
| 6845 | .linux, .emscripten => extern struct { | ||
| 6846 | __size: [4 * @sizeOf(usize)]u8 align(@alignOf(usize)), | ||
| 6847 | }, | ||
| 6848 | .macos, .ios, .tvos, .watchos, .visionos => c_int, | ||
| 6849 | .freebsd, .kfreebsd => extern struct { | ||
| 6850 | _magic: u32, | ||
| 6851 | _kern: extern struct { | ||
| 6852 | _count: u32, | ||
| 6853 | _flags: u32, | ||
| 6854 | }, | ||
| 6855 | _padding: u32, | ||
| 6856 | }, | ||
| 6857 | .solaris, .illumos => extern struct { | ||
| 6858 | count: u32 = 0, | ||
| 6859 | type: u16 = 0, | ||
| 6860 | magic: u16 = 0x534d, | ||
| 6861 | __pad1: [3]u64 = [_]u64{0} ** 3, | ||
| 6862 | __pad2: [2]u64 = [_]u64{0} ** 2, | ||
| 6863 | }, | ||
| 6864 | .openbsd, .netbsd, .dragonfly => ?*opaque {}, | ||
| 6865 | .haiku => extern struct { | ||
| 6866 | type: i32, | ||
| 6867 | u: extern union { | ||
| 6868 | named_sem_id: i32, | ||
| 6869 | unnamed_sem: i32, | ||
| 6870 | }, | ||
| 6871 | padding: [2]i32, | ||
| 6872 | }, | ||
| 6873 | else => void, | ||
| 6874 | }; | ||
| 6875 | |||
| 6876 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 6877 | pub const Kevent = switch (native_os) { | ||
| 6878 | .netbsd => extern struct { | ||
| 6879 | ident: usize, | ||
| 6880 | filter: i32, | ||
| 6881 | flags: u32, | ||
| 6882 | fflags: u32, | ||
| 6883 | data: i64, | ||
| 6884 | udata: usize, | ||
| 6885 | }, | ||
| 6886 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 6887 | ident: usize, | ||
| 6888 | filter: i16, | ||
| 6889 | flags: u16, | ||
| 6890 | fflags: u32, | ||
| 6891 | data: isize, | ||
| 6892 | udata: usize, | ||
| 6893 | |||
| 6894 | // sys/types.h on macos uses #pragma pack(4) so these checks are | ||
| 6895 | // to make sure the struct is laid out the same. These values were | ||
| 6896 | // produced from C code using the offsetof macro. | ||
| 6897 | comptime { | ||
| 6898 | assert(@offsetOf(@This(), "ident") == 0); | ||
| 6899 | assert(@offsetOf(@This(), "filter") == 8); | ||
| 6900 | assert(@offsetOf(@This(), "flags") == 10); | ||
| 6901 | assert(@offsetOf(@This(), "fflags") == 12); | ||
| 6902 | assert(@offsetOf(@This(), "data") == 16); | ||
| 6903 | assert(@offsetOf(@This(), "udata") == 24); | ||
| 6904 | } | ||
| 6905 | }, | ||
| 6906 | .freebsd, .kfreebsd => extern struct { | ||
| 6907 | /// Identifier for this event. | ||
| 6908 | ident: usize, | ||
| 6909 | /// Filter for event. | ||
| 6910 | filter: i16, | ||
| 6911 | /// Action flags for kqueue. | ||
| 6912 | flags: u16, | ||
| 6913 | /// Filter flag value. | ||
| 6914 | fflags: u32, | ||
| 6915 | /// Filter data value. | ||
| 6916 | data: i64, | ||
| 6917 | /// Opaque user data identifier. | ||
| 6918 | udata: usize, | ||
| 6919 | /// Future extensions. | ||
| 6920 | _ext: [4]u64 = [_]u64{0} ** 4, | ||
| 6921 | }, | ||
| 6922 | .dragonfly => extern struct { | ||
| 6923 | ident: usize, | ||
| 6924 | filter: c_short, | ||
| 6925 | flags: c_ushort, | ||
| 6926 | fflags: c_uint, | ||
| 6927 | data: isize, | ||
| 6928 | udata: usize, | ||
| 6929 | }, | ||
| 6930 | .openbsd => extern struct { | ||
| 6931 | ident: usize, | ||
| 6932 | filter: c_short, | ||
| 6933 | flags: u16, | ||
| 6934 | fflags: c_uint, | ||
| 6935 | data: i64, | ||
| 6936 | udata: usize, | ||
| 6937 | }, | ||
| 6938 | else => void, | ||
| 6939 | }; | ||
| 6940 | |||
| 6941 | pub const port_t = switch (native_os) { | ||
| 6942 | .solaris, .illumos => c_int, | ||
| 6943 | else => void, | ||
| 6944 | }; | ||
| 6945 | |||
| 6946 | pub const port_event = switch (native_os) { | ||
| 6947 | .solaris, .illumos => extern struct { | ||
| 6948 | events: u32, | ||
| 6949 | /// Event source. | ||
| 6950 | source: u16, | ||
| 6951 | __pad: u16, | ||
| 6952 | /// Source-specific object. | ||
| 6953 | object: ?*anyopaque, | ||
| 6954 | /// User cookie. | ||
| 6955 | cookie: ?*anyopaque, | ||
| 6956 | }, | ||
| 6957 | else => void, | ||
| 209 | }; | 6958 | }; |
| 210 | 6959 | ||
| 211 | pub const AT = switch (native_os) { | 6960 | pub const AT = switch (native_os) { |
| ... | @@ -287,7 +7036,7 @@ pub const AT = switch (native_os) { | ... | @@ -287,7 +7036,7 @@ pub const AT = switch (native_os) { |
| 287 | /// Magic value that specify the use of the current working directory | 7036 | /// Magic value that specify the use of the current working directory |
| 288 | /// to determine the target of relative file paths in the openat() and | 7037 | /// to determine the target of relative file paths in the openat() and |
| 289 | /// similar syscalls. | 7038 | /// similar syscalls. |
| 290 | pub const FDCWD: c.fd_t = @bitCast(@as(u32, 0xffd19553)); | 7039 | pub const FDCWD: fd_t = @bitCast(@as(u32, 0xffd19553)); |
| 291 | /// Do not follow symbolic links | 7040 | /// Do not follow symbolic links |
| 292 | pub const SYMLINK_NOFOLLOW = 0x1000; | 7041 | pub const SYMLINK_NOFOLLOW = 0x1000; |
| 293 | /// Follow symbolic link | 7042 | /// Follow symbolic link |
| ... | @@ -320,10 +7069,10 @@ pub const AT = switch (native_os) { | ... | @@ -320,10 +7069,10 @@ pub const AT = switch (native_os) { |
| 320 | /// current working directory is the first preopen. This behavior can be | 7069 | /// current working directory is the first preopen. This behavior can be |
| 321 | /// overridden with a public function called `wasi_cwd` in the root source | 7070 | /// overridden with a public function called `wasi_cwd` in the root source |
| 322 | /// file. | 7071 | /// file. |
| 323 | pub const FDCWD: c.fd_t = if (builtin.link_libc) -2 else 3; | 7072 | pub const FDCWD: fd_t = if (builtin.link_libc) -2 else 3; |
| 324 | }, | 7073 | }, |
| 325 | 7074 | ||
| 326 | else => @compileError("target libc does not have AT"), | 7075 | else => void, |
| 327 | }; | 7076 | }; |
| 328 | 7077 | ||
| 329 | pub const O = switch (native_os) { | 7078 | pub const O = switch (native_os) { |
| ... | @@ -511,7 +7260,7 @@ pub const O = switch (native_os) { | ... | @@ -511,7 +7260,7 @@ pub const O = switch (native_os) { |
| 511 | DIRECTORY: bool = false, | 7260 | DIRECTORY: bool = false, |
| 512 | _: u4 = 0, | 7261 | _: u4 = 0, |
| 513 | }, | 7262 | }, |
| 514 | .freebsd => packed struct(u32) { | 7263 | .freebsd, .kfreebsd => packed struct(u32) { |
| 515 | ACCMODE: std.posix.ACCMODE = .RDONLY, | 7264 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 516 | NONBLOCK: bool = false, | 7265 | NONBLOCK: bool = false, |
| 517 | APPEND: bool = false, | 7266 | APPEND: bool = false, |
| ... | @@ -535,7 +7284,7 @@ pub const O = switch (native_os) { | ... | @@ -535,7 +7284,7 @@ pub const O = switch (native_os) { |
| 535 | TMPFILE: bool = false, | 7284 | TMPFILE: bool = false, |
| 536 | _: u9 = 0, | 7285 | _: u9 = 0, |
| 537 | }, | 7286 | }, |
| 538 | else => @compileError("target libc does not have O"), | 7287 | else => void, |
| 539 | }; | 7288 | }; |
| 540 | 7289 | ||
| 541 | pub const MAP = switch (native_os) { | 7290 | pub const MAP = switch (native_os) { |
| ... | @@ -656,7 +7405,7 @@ pub const MAP = switch (native_os) { | ... | @@ -656,7 +7405,7 @@ pub const MAP = switch (native_os) { |
| 656 | SIZEALIGN: bool = false, | 7405 | SIZEALIGN: bool = false, |
| 657 | _: u13 = 0, | 7406 | _: u13 = 0, |
| 658 | }, | 7407 | }, |
| 659 | .freebsd => packed struct(u32) { | 7408 | .freebsd, .kfreebsd => packed struct(u32) { |
| 660 | TYPE: enum(u4) { | 7409 | TYPE: enum(u4) { |
| 661 | SHARED = 0x01, | 7410 | SHARED = 0x01, |
| 662 | PRIVATE = 0x02, | 7411 | PRIVATE = 0x02, |
| ... | @@ -674,11 +7423,11 @@ pub const MAP = switch (native_os) { | ... | @@ -674,11 +7423,11 @@ pub const MAP = switch (native_os) { |
| 674 | @"32BIT": bool = false, | 7423 | @"32BIT": bool = false, |
| 675 | _: u12 = 0, | 7424 | _: u12 = 0, |
| 676 | }, | 7425 | }, |
| 677 | else => @compileError("target libc does not have MAP"), | 7426 | else => void, |
| 678 | }; | 7427 | }; |
| 679 | 7428 | ||
| 680 | /// Used by libc to communicate failure. Not actually part of the underlying syscall. | 7429 | /// Used by libc to communicate failure. Not actually part of the underlying syscall. |
| 681 | pub const MAP_FAILED: *anyopaque = @ptrFromInt(std.math.maxInt(usize)); | 7430 | pub const MAP_FAILED: *anyopaque = @ptrFromInt(maxInt(usize)); |
| 682 | 7431 | ||
| 683 | pub const cc_t = u8; | 7432 | pub const cc_t = u8; |
| 684 | 7433 | ||
| ... | @@ -779,7 +7528,7 @@ pub const V = switch (native_os) { | ... | @@ -779,7 +7528,7 @@ pub const V = switch (native_os) { |
| 779 | LNEXT, | 7528 | LNEXT, |
| 780 | EOL2, | 7529 | EOL2, |
| 781 | }, | 7530 | }, |
| 782 | else => @compileError("target libc does not have cc_t"), | 7531 | else => void, |
| 783 | }; | 7532 | }; |
| 784 | 7533 | ||
| 785 | pub const NCCS = switch (native_os) { | 7534 | pub const NCCS = switch (native_os) { |
| ... | @@ -788,7 +7537,7 @@ pub const NCCS = switch (native_os) { | ... | @@ -788,7 +7537,7 @@ pub const NCCS = switch (native_os) { |
| 788 | .haiku => 11, | 7537 | .haiku => 11, |
| 789 | .solaris, .illumos => 19, | 7538 | .solaris, .illumos => 19, |
| 790 | .emscripten, .wasi => 32, | 7539 | .emscripten, .wasi => 32, |
| 791 | else => @compileError("target libc does not have NCCS"), | 7540 | else => void, |
| 792 | }; | 7541 | }; |
| 793 | 7542 | ||
| 794 | pub const termios = switch (native_os) { | 7543 | pub const termios = switch (native_os) { |
| ... | @@ -833,12 +7582,12 @@ pub const termios = switch (native_os) { | ... | @@ -833,12 +7582,12 @@ pub const termios = switch (native_os) { |
| 833 | oflag: tc_oflag_t, | 7582 | oflag: tc_oflag_t, |
| 834 | cflag: tc_cflag_t, | 7583 | cflag: tc_cflag_t, |
| 835 | lflag: tc_lflag_t, | 7584 | lflag: tc_lflag_t, |
| 836 | line: std.c.cc_t, | 7585 | line: cc_t, |
| 837 | cc: [NCCS]cc_t, | 7586 | cc: [NCCS]cc_t, |
| 838 | ispeed: speed_t, | 7587 | ispeed: speed_t, |
| 839 | ospeed: speed_t, | 7588 | ospeed: speed_t, |
| 840 | }, | 7589 | }, |
| 841 | else => @compileError("target libc does not have termios"), | 7590 | else => void, |
| 842 | }; | 7591 | }; |
| 843 | 7592 | ||
| 844 | pub const tc_iflag_t = switch (native_os) { | 7593 | pub const tc_iflag_t = switch (native_os) { |
| ... | @@ -948,7 +7697,7 @@ pub const tc_iflag_t = switch (native_os) { | ... | @@ -948,7 +7697,7 @@ pub const tc_iflag_t = switch (native_os) { |
| 948 | IUTF8: bool = false, | 7697 | IUTF8: bool = false, |
| 949 | _: u17 = 0, | 7698 | _: u17 = 0, |
| 950 | }, | 7699 | }, |
| 951 | else => @compileError("target libc does not have tc_iflag_t"), | 7700 | else => void, |
| 952 | }; | 7701 | }; |
| 953 | 7702 | ||
| 954 | pub const tc_oflag_t = switch (native_os) { | 7703 | pub const tc_oflag_t = switch (native_os) { |
| ... | @@ -1039,7 +7788,7 @@ pub const tc_oflag_t = switch (native_os) { | ... | @@ -1039,7 +7788,7 @@ pub const tc_oflag_t = switch (native_os) { |
| 1039 | FFDLY: u1 = 0, | 7788 | FFDLY: u1 = 0, |
| 1040 | _: u16 = 0, | 7789 | _: u16 = 0, |
| 1041 | }, | 7790 | }, |
| 1042 | else => @compileError("target libc does not have tc_oflag_t"), | 7791 | else => void, |
| 1043 | }; | 7792 | }; |
| 1044 | 7793 | ||
| 1045 | pub const CSIZE = switch (native_os) { | 7794 | pub const CSIZE = switch (native_os) { |
| ... | @@ -1181,7 +7930,7 @@ pub const tc_cflag_t = switch (native_os) { | ... | @@ -1181,7 +7930,7 @@ pub const tc_cflag_t = switch (native_os) { |
| 1181 | CLOCAL: bool = false, | 7930 | CLOCAL: bool = false, |
| 1182 | _: u20 = 0, | 7931 | _: u20 = 0, |
| 1183 | }, | 7932 | }, |
| 1184 | else => @compileError("target libc does not have tc_cflag_t"), | 7933 | else => void, |
| 1185 | }; | 7934 | }; |
| 1186 | 7935 | ||
| 1187 | pub const tc_lflag_t = switch (native_os) { | 7936 | pub const tc_lflag_t = switch (native_os) { |
| ... | @@ -1307,7 +8056,7 @@ pub const tc_lflag_t = switch (native_os) { | ... | @@ -1307,7 +8056,7 @@ pub const tc_lflag_t = switch (native_os) { |
| 1307 | IEXTEN: bool = false, | 8056 | IEXTEN: bool = false, |
| 1308 | _: u16 = 0, | 8057 | _: u16 = 0, |
| 1309 | }, | 8058 | }, |
| 1310 | else => @compileError("target libc does not have tc_lflag_t"), | 8059 | else => void, |
| 1311 | }; | 8060 | }; |
| 1312 | 8061 | ||
| 1313 | pub const speed_t = switch (native_os) { | 8062 | pub const speed_t = switch (native_os) { |
| ... | @@ -1489,11 +8238,543 @@ pub const speed_t = switch (native_os) { | ... | @@ -1489,11 +8238,543 @@ pub const speed_t = switch (native_os) { |
| 1489 | B3500000 = 0o0010016, | 8238 | B3500000 = 0o0010016, |
| 1490 | B4000000 = 0o0010017, | 8239 | B4000000 = 0o0010017, |
| 1491 | }, | 8240 | }, |
| 1492 | else => @compileError("target libc does not have speed_t"), | 8241 | else => void, |
| 1493 | }; | 8242 | }; |
| 1494 | 8243 | ||
| 1495 | pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int; | 8244 | pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int; |
| 1496 | 8245 | ||
| 8246 | pub const sig_atomic_t = c_int; | ||
| 8247 | |||
| 8248 | /// maximum signal number + 1 | ||
| 8249 | pub const NSIG = switch (native_os) { | ||
| 8250 | .linux => linux.NSIG, | ||
| 8251 | .windows => 23, | ||
| 8252 | .haiku => 65, | ||
| 8253 | .netbsd, .freebsd, .kfreebsd => 32, | ||
| 8254 | .solaris, .illumos => 75, | ||
| 8255 | .openbsd => 33, | ||
| 8256 | else => {}, | ||
| 8257 | }; | ||
| 8258 | |||
| 8259 | pub const MINSIGSTKSZ = switch (native_os) { | ||
| 8260 | .macos, .ios, .tvos, .watchos, .visionos => 32768, | ||
| 8261 | .freebsd, .kfreebsd => switch (builtin.cpu.arch) { | ||
| 8262 | .x86, .x86_64 => 2048, | ||
| 8263 | .arm, .aarch64 => 4096, | ||
| 8264 | else => @compileError("unsupported arch"), | ||
| 8265 | }, | ||
| 8266 | .solaris, .illumos => 2048, | ||
| 8267 | .haiku, .netbsd => 8192, | ||
| 8268 | .openbsd => 1 << openbsd.MAX_PAGE_SHIFT, | ||
| 8269 | else => {}, | ||
| 8270 | }; | ||
| 8271 | pub const SIGSTKSZ = switch (native_os) { | ||
| 8272 | .macos, .ios, .tvos, .watchos, .visionos => 131072, | ||
| 8273 | .netbsd, .freebsd, .kfreebsd => MINSIGSTKSZ + 32768, | ||
| 8274 | .solaris, .illumos => 8192, | ||
| 8275 | .haiku => 16384, | ||
| 8276 | .openbsd => MINSIGSTKSZ + (1 << openbsd.MAX_PAGE_SHIFT) * 4, | ||
| 8277 | else => {}, | ||
| 8278 | }; | ||
| 8279 | pub const SS = switch (native_os) { | ||
| 8280 | .linux => linux.SS, | ||
| 8281 | .openbsd, .macos, .ios, .tvos, .watchos, .visionos, .netbsd, .freebsd, .kfreebsd => struct { | ||
| 8282 | pub const ONSTACK = 1; | ||
| 8283 | pub const DISABLE = 4; | ||
| 8284 | }, | ||
| 8285 | .haiku, .solaris, .illumos => struct { | ||
| 8286 | pub const ONSTACK = 0x1; | ||
| 8287 | pub const DISABLE = 0x2; | ||
| 8288 | }, | ||
| 8289 | else => void, | ||
| 8290 | }; | ||
| 8291 | |||
| 8292 | pub const EV = switch (native_os) { | ||
| 8293 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 8294 | /// add event to kq (implies enable) | ||
| 8295 | pub const ADD = 0x0001; | ||
| 8296 | /// delete event from kq | ||
| 8297 | pub const DELETE = 0x0002; | ||
| 8298 | /// enable event | ||
| 8299 | pub const ENABLE = 0x0004; | ||
| 8300 | /// disable event (not reported) | ||
| 8301 | pub const DISABLE = 0x0008; | ||
| 8302 | /// only report one occurrence | ||
| 8303 | pub const ONESHOT = 0x0010; | ||
| 8304 | /// clear event state after reporting | ||
| 8305 | pub const CLEAR = 0x0020; | ||
| 8306 | /// force immediate event output | ||
| 8307 | /// ... with or without ERROR | ||
| 8308 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 8309 | /// on syscalls supporting flags | ||
| 8310 | pub const RECEIPT = 0x0040; | ||
| 8311 | /// disable event after reporting | ||
| 8312 | pub const DISPATCH = 0x0080; | ||
| 8313 | /// unique kevent per udata value | ||
| 8314 | pub const UDATA_SPECIFIC = 0x0100; | ||
| 8315 | /// ... in combination with DELETE | ||
| 8316 | /// will defer delete until udata-specific | ||
| 8317 | /// event enabled. EINPROGRESS will be | ||
| 8318 | /// returned to indicate the deferral | ||
| 8319 | pub const DISPATCH2 = DISPATCH | UDATA_SPECIFIC; | ||
| 8320 | /// report that source has vanished | ||
| 8321 | /// ... only valid with DISPATCH2 | ||
| 8322 | pub const VANISHED = 0x0200; | ||
| 8323 | /// reserved by system | ||
| 8324 | pub const SYSFLAGS = 0xF000; | ||
| 8325 | /// filter-specific flag | ||
| 8326 | pub const FLAG0 = 0x1000; | ||
| 8327 | /// filter-specific flag | ||
| 8328 | pub const FLAG1 = 0x2000; | ||
| 8329 | /// EOF detected | ||
| 8330 | pub const EOF = 0x8000; | ||
| 8331 | /// error, data contains errno | ||
| 8332 | pub const ERROR = 0x4000; | ||
| 8333 | pub const POLL = FLAG0; | ||
| 8334 | pub const OOBAND = FLAG1; | ||
| 8335 | }, | ||
| 8336 | .dragonfly => struct { | ||
| 8337 | pub const ADD = 1; | ||
| 8338 | pub const DELETE = 2; | ||
| 8339 | pub const ENABLE = 4; | ||
| 8340 | pub const DISABLE = 8; | ||
| 8341 | pub const ONESHOT = 16; | ||
| 8342 | pub const CLEAR = 32; | ||
| 8343 | pub const RECEIPT = 64; | ||
| 8344 | pub const DISPATCH = 128; | ||
| 8345 | pub const NODATA = 4096; | ||
| 8346 | pub const FLAG1 = 8192; | ||
| 8347 | pub const ERROR = 16384; | ||
| 8348 | pub const EOF = 32768; | ||
| 8349 | pub const SYSFLAGS = 61440; | ||
| 8350 | }, | ||
| 8351 | .netbsd => struct { | ||
| 8352 | /// add event to kq (implies enable) | ||
| 8353 | pub const ADD = 0x0001; | ||
| 8354 | /// delete event from kq | ||
| 8355 | pub const DELETE = 0x0002; | ||
| 8356 | /// enable event | ||
| 8357 | pub const ENABLE = 0x0004; | ||
| 8358 | /// disable event (not reported) | ||
| 8359 | pub const DISABLE = 0x0008; | ||
| 8360 | /// only report one occurrence | ||
| 8361 | pub const ONESHOT = 0x0010; | ||
| 8362 | /// clear event state after reporting | ||
| 8363 | pub const CLEAR = 0x0020; | ||
| 8364 | /// force immediate event output | ||
| 8365 | /// ... with or without ERROR | ||
| 8366 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 8367 | /// on syscalls supporting flags | ||
| 8368 | pub const RECEIPT = 0x0040; | ||
| 8369 | /// disable event after reporting | ||
| 8370 | pub const DISPATCH = 0x0080; | ||
| 8371 | }, | ||
| 8372 | .freebsd => struct { | ||
| 8373 | /// add event to kq (implies enable) | ||
| 8374 | pub const ADD = 0x0001; | ||
| 8375 | /// delete event from kq | ||
| 8376 | pub const DELETE = 0x0002; | ||
| 8377 | /// enable event | ||
| 8378 | pub const ENABLE = 0x0004; | ||
| 8379 | /// disable event (not reported) | ||
| 8380 | pub const DISABLE = 0x0008; | ||
| 8381 | /// only report one occurrence | ||
| 8382 | pub const ONESHOT = 0x0010; | ||
| 8383 | /// clear event state after reporting | ||
| 8384 | pub const CLEAR = 0x0020; | ||
| 8385 | /// error, event data contains errno | ||
| 8386 | pub const ERROR = 0x4000; | ||
| 8387 | /// force immediate event output | ||
| 8388 | /// ... with or without ERROR | ||
| 8389 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 8390 | /// on syscalls supporting flags | ||
| 8391 | pub const RECEIPT = 0x0040; | ||
| 8392 | /// disable event after reporting | ||
| 8393 | pub const DISPATCH = 0x0080; | ||
| 8394 | }, | ||
| 8395 | .openbsd => struct { | ||
| 8396 | pub const ADD = 0x0001; | ||
| 8397 | pub const DELETE = 0x0002; | ||
| 8398 | pub const ENABLE = 0x0004; | ||
| 8399 | pub const DISABLE = 0x0008; | ||
| 8400 | pub const ONESHOT = 0x0010; | ||
| 8401 | pub const CLEAR = 0x0020; | ||
| 8402 | pub const RECEIPT = 0x0040; | ||
| 8403 | pub const DISPATCH = 0x0080; | ||
| 8404 | pub const FLAG1 = 0x2000; | ||
| 8405 | pub const ERROR = 0x4000; | ||
| 8406 | pub const EOF = 0x8000; | ||
| 8407 | }, | ||
| 8408 | .haiku => struct { | ||
| 8409 | /// add event to kq (implies enable) | ||
| 8410 | pub const ADD = 0x0001; | ||
| 8411 | /// delete event from kq | ||
| 8412 | pub const DELETE = 0x0002; | ||
| 8413 | /// enable event | ||
| 8414 | pub const ENABLE = 0x0004; | ||
| 8415 | /// disable event (not reported) | ||
| 8416 | pub const DISABLE = 0x0008; | ||
| 8417 | /// only report one occurrence | ||
| 8418 | pub const ONESHOT = 0x0010; | ||
| 8419 | /// clear event state after reporting | ||
| 8420 | pub const CLEAR = 0x0020; | ||
| 8421 | /// force immediate event output | ||
| 8422 | /// ... with or without ERROR | ||
| 8423 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 8424 | /// on syscalls supporting flags | ||
| 8425 | pub const RECEIPT = 0x0040; | ||
| 8426 | /// disable event after reporting | ||
| 8427 | pub const DISPATCH = 0x0080; | ||
| 8428 | }, | ||
| 8429 | else => void, | ||
| 8430 | }; | ||
| 8431 | |||
| 8432 | pub const EVFILT = switch (native_os) { | ||
| 8433 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 8434 | pub const READ = -1; | ||
| 8435 | pub const WRITE = -2; | ||
| 8436 | /// attached to aio requests | ||
| 8437 | pub const AIO = -3; | ||
| 8438 | /// attached to vnodes | ||
| 8439 | pub const VNODE = -4; | ||
| 8440 | /// attached to struct proc | ||
| 8441 | pub const PROC = -5; | ||
| 8442 | /// attached to struct proc | ||
| 8443 | pub const SIGNAL = -6; | ||
| 8444 | /// timers | ||
| 8445 | pub const TIMER = -7; | ||
| 8446 | /// Mach portsets | ||
| 8447 | pub const MACHPORT = -8; | ||
| 8448 | /// Filesystem events | ||
| 8449 | pub const FS = -9; | ||
| 8450 | /// User events | ||
| 8451 | pub const USER = -10; | ||
| 8452 | /// Virtual memory events | ||
| 8453 | pub const VM = -12; | ||
| 8454 | /// Exception events | ||
| 8455 | pub const EXCEPT = -15; | ||
| 8456 | pub const SYSCOUNT = 17; | ||
| 8457 | }, | ||
| 8458 | .haiku => struct { | ||
| 8459 | pub const READ = -1; | ||
| 8460 | pub const WRITE = -2; | ||
| 8461 | /// attached to aio requests | ||
| 8462 | pub const AIO = -3; | ||
| 8463 | /// attached to vnodes | ||
| 8464 | pub const VNODE = -4; | ||
| 8465 | /// attached to struct proc | ||
| 8466 | pub const PROC = -5; | ||
| 8467 | /// attached to struct proc | ||
| 8468 | pub const SIGNAL = -6; | ||
| 8469 | /// timers | ||
| 8470 | pub const TIMER = -7; | ||
| 8471 | /// Process descriptors | ||
| 8472 | pub const PROCDESC = -8; | ||
| 8473 | /// Filesystem events | ||
| 8474 | pub const FS = -9; | ||
| 8475 | pub const LIO = -10; | ||
| 8476 | /// User events | ||
| 8477 | pub const USER = -11; | ||
| 8478 | /// Sendfile events | ||
| 8479 | pub const SENDFILE = -12; | ||
| 8480 | pub const EMPTY = -13; | ||
| 8481 | }, | ||
| 8482 | .dragonfly => struct { | ||
| 8483 | pub const FS = -10; | ||
| 8484 | pub const USER = -9; | ||
| 8485 | pub const EXCEPT = -8; | ||
| 8486 | pub const TIMER = -7; | ||
| 8487 | pub const SIGNAL = -6; | ||
| 8488 | pub const PROC = -5; | ||
| 8489 | pub const VNODE = -4; | ||
| 8490 | pub const AIO = -3; | ||
| 8491 | pub const WRITE = -2; | ||
| 8492 | pub const READ = -1; | ||
| 8493 | pub const SYSCOUNT = 10; | ||
| 8494 | pub const MARKER = 15; | ||
| 8495 | }, | ||
| 8496 | .netbsd => struct { | ||
| 8497 | pub const READ = 0; | ||
| 8498 | pub const WRITE = 1; | ||
| 8499 | /// attached to aio requests | ||
| 8500 | pub const AIO = 2; | ||
| 8501 | /// attached to vnodes | ||
| 8502 | pub const VNODE = 3; | ||
| 8503 | /// attached to struct proc | ||
| 8504 | pub const PROC = 4; | ||
| 8505 | /// attached to struct proc | ||
| 8506 | pub const SIGNAL = 5; | ||
| 8507 | /// timers | ||
| 8508 | pub const TIMER = 6; | ||
| 8509 | /// Filesystem events | ||
| 8510 | pub const FS = 7; | ||
| 8511 | /// User events | ||
| 8512 | pub const USER = 1; | ||
| 8513 | }, | ||
| 8514 | .freebsd => struct { | ||
| 8515 | pub const READ = -1; | ||
| 8516 | pub const WRITE = -2; | ||
| 8517 | /// attached to aio requests | ||
| 8518 | pub const AIO = -3; | ||
| 8519 | /// attached to vnodes | ||
| 8520 | pub const VNODE = -4; | ||
| 8521 | /// attached to struct proc | ||
| 8522 | pub const PROC = -5; | ||
| 8523 | /// attached to struct proc | ||
| 8524 | pub const SIGNAL = -6; | ||
| 8525 | /// timers | ||
| 8526 | pub const TIMER = -7; | ||
| 8527 | /// Process descriptors | ||
| 8528 | pub const PROCDESC = -8; | ||
| 8529 | /// Filesystem events | ||
| 8530 | pub const FS = -9; | ||
| 8531 | pub const LIO = -10; | ||
| 8532 | /// User events | ||
| 8533 | pub const USER = -11; | ||
| 8534 | /// Sendfile events | ||
| 8535 | pub const SENDFILE = -12; | ||
| 8536 | pub const EMPTY = -13; | ||
| 8537 | }, | ||
| 8538 | .openbsd => struct { | ||
| 8539 | pub const READ = -1; | ||
| 8540 | pub const WRITE = -2; | ||
| 8541 | pub const AIO = -3; | ||
| 8542 | pub const VNODE = -4; | ||
| 8543 | pub const PROC = -5; | ||
| 8544 | pub const SIGNAL = -6; | ||
| 8545 | pub const TIMER = -7; | ||
| 8546 | pub const EXCEPT = -9; | ||
| 8547 | }, | ||
| 8548 | else => void, | ||
| 8549 | }; | ||
| 8550 | |||
| 8551 | pub const NOTE = switch (native_os) { | ||
| 8552 | .macos, .ios, .tvos, .watchos, .visionos => struct { | ||
| 8553 | /// On input, TRIGGER causes the event to be triggered for output. | ||
| 8554 | pub const TRIGGER = 0x01000000; | ||
| 8555 | /// ignore input fflags | ||
| 8556 | pub const FFNOP = 0x00000000; | ||
| 8557 | /// and fflags | ||
| 8558 | pub const FFAND = 0x40000000; | ||
| 8559 | /// or fflags | ||
| 8560 | pub const FFOR = 0x80000000; | ||
| 8561 | /// copy fflags | ||
| 8562 | pub const FFCOPY = 0xc0000000; | ||
| 8563 | /// mask for operations | ||
| 8564 | pub const FFCTRLMASK = 0xc0000000; | ||
| 8565 | pub const FFLAGSMASK = 0x00ffffff; | ||
| 8566 | /// low water mark | ||
| 8567 | pub const LOWAT = 0x00000001; | ||
| 8568 | /// OOB data | ||
| 8569 | pub const OOB = 0x00000002; | ||
| 8570 | /// vnode was removed | ||
| 8571 | pub const DELETE = 0x00000001; | ||
| 8572 | /// data contents changed | ||
| 8573 | pub const WRITE = 0x00000002; | ||
| 8574 | /// size increased | ||
| 8575 | pub const EXTEND = 0x00000004; | ||
| 8576 | /// attributes changed | ||
| 8577 | pub const ATTRIB = 0x00000008; | ||
| 8578 | /// link count changed | ||
| 8579 | pub const LINK = 0x00000010; | ||
| 8580 | /// vnode was renamed | ||
| 8581 | pub const RENAME = 0x00000020; | ||
| 8582 | /// vnode access was revoked | ||
| 8583 | pub const REVOKE = 0x00000040; | ||
| 8584 | /// No specific vnode event: to test for EVFILT_READ activation | ||
| 8585 | pub const NONE = 0x00000080; | ||
| 8586 | /// vnode was unlocked by flock(2) | ||
| 8587 | pub const FUNLOCK = 0x00000100; | ||
| 8588 | /// process exited | ||
| 8589 | pub const EXIT = 0x80000000; | ||
| 8590 | /// process forked | ||
| 8591 | pub const FORK = 0x40000000; | ||
| 8592 | /// process exec'd | ||
| 8593 | pub const EXEC = 0x20000000; | ||
| 8594 | /// shared with EVFILT_SIGNAL | ||
| 8595 | pub const SIGNAL = 0x08000000; | ||
| 8596 | /// exit status to be returned, valid for child process only | ||
| 8597 | pub const EXITSTATUS = 0x04000000; | ||
| 8598 | /// provide details on reasons for exit | ||
| 8599 | pub const EXIT_DETAIL = 0x02000000; | ||
| 8600 | /// mask for signal & exit status | ||
| 8601 | pub const PDATAMASK = 0x000fffff; | ||
| 8602 | pub const PCTRLMASK = (~PDATAMASK); | ||
| 8603 | pub const EXIT_DETAIL_MASK = 0x00070000; | ||
| 8604 | pub const EXIT_DECRYPTFAIL = 0x00010000; | ||
| 8605 | pub const EXIT_MEMORY = 0x00020000; | ||
| 8606 | pub const EXIT_CSERROR = 0x00040000; | ||
| 8607 | /// will react on memory pressure | ||
| 8608 | pub const VM_PRESSURE = 0x80000000; | ||
| 8609 | /// will quit on memory pressure, possibly after cleaning up dirty state | ||
| 8610 | pub const VM_PRESSURE_TERMINATE = 0x40000000; | ||
| 8611 | /// will quit immediately on memory pressure | ||
| 8612 | pub const VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; | ||
| 8613 | /// there was an error | ||
| 8614 | pub const VM_ERROR = 0x10000000; | ||
| 8615 | /// data is seconds | ||
| 8616 | pub const SECONDS = 0x00000001; | ||
| 8617 | /// data is microseconds | ||
| 8618 | pub const USECONDS = 0x00000002; | ||
| 8619 | /// data is nanoseconds | ||
| 8620 | pub const NSECONDS = 0x00000004; | ||
| 8621 | /// absolute timeout | ||
| 8622 | pub const ABSOLUTE = 0x00000008; | ||
| 8623 | /// ext[1] holds leeway for power aware timers | ||
| 8624 | pub const LEEWAY = 0x00000010; | ||
| 8625 | /// system does minimal timer coalescing | ||
| 8626 | pub const CRITICAL = 0x00000020; | ||
| 8627 | /// system does maximum timer coalescing | ||
| 8628 | pub const BACKGROUND = 0x00000040; | ||
| 8629 | pub const MACH_CONTINUOUS_TIME = 0x00000080; | ||
| 8630 | /// data is mach absolute time units | ||
| 8631 | pub const MACHTIME = 0x00000100; | ||
| 8632 | }, | ||
| 8633 | .dragonfly => struct { | ||
| 8634 | pub const FFNOP = 0; | ||
| 8635 | pub const TRACK = 1; | ||
| 8636 | pub const DELETE = 1; | ||
| 8637 | pub const LOWAT = 1; | ||
| 8638 | pub const TRACKERR = 2; | ||
| 8639 | pub const OOB = 2; | ||
| 8640 | pub const WRITE = 2; | ||
| 8641 | pub const EXTEND = 4; | ||
| 8642 | pub const CHILD = 4; | ||
| 8643 | pub const ATTRIB = 8; | ||
| 8644 | pub const LINK = 16; | ||
| 8645 | pub const RENAME = 32; | ||
| 8646 | pub const REVOKE = 64; | ||
| 8647 | pub const PDATAMASK = 1048575; | ||
| 8648 | pub const FFLAGSMASK = 16777215; | ||
| 8649 | pub const TRIGGER = 16777216; | ||
| 8650 | pub const EXEC = 536870912; | ||
| 8651 | pub const FFAND = 1073741824; | ||
| 8652 | pub const FORK = 1073741824; | ||
| 8653 | pub const EXIT = 2147483648; | ||
| 8654 | pub const FFOR = 2147483648; | ||
| 8655 | pub const FFCTRLMASK = 3221225472; | ||
| 8656 | pub const FFCOPY = 3221225472; | ||
| 8657 | pub const PCTRLMASK = 4026531840; | ||
| 8658 | }, | ||
| 8659 | .netbsd => struct { | ||
| 8660 | /// On input, TRIGGER causes the event to be triggered for output. | ||
| 8661 | pub const TRIGGER = 0x08000000; | ||
| 8662 | /// low water mark | ||
| 8663 | pub const LOWAT = 0x00000001; | ||
| 8664 | /// vnode was removed | ||
| 8665 | pub const DELETE = 0x00000001; | ||
| 8666 | /// data contents changed | ||
| 8667 | pub const WRITE = 0x00000002; | ||
| 8668 | /// size increased | ||
| 8669 | pub const EXTEND = 0x00000004; | ||
| 8670 | /// attributes changed | ||
| 8671 | pub const ATTRIB = 0x00000008; | ||
| 8672 | /// link count changed | ||
| 8673 | pub const LINK = 0x00000010; | ||
| 8674 | /// vnode was renamed | ||
| 8675 | pub const RENAME = 0x00000020; | ||
| 8676 | /// vnode access was revoked | ||
| 8677 | pub const REVOKE = 0x00000040; | ||
| 8678 | /// process exited | ||
| 8679 | pub const EXIT = 0x80000000; | ||
| 8680 | /// process forked | ||
| 8681 | pub const FORK = 0x40000000; | ||
| 8682 | /// process exec'd | ||
| 8683 | pub const EXEC = 0x20000000; | ||
| 8684 | /// mask for signal & exit status | ||
| 8685 | pub const PDATAMASK = 0x000fffff; | ||
| 8686 | pub const PCTRLMASK = 0xf0000000; | ||
| 8687 | }, | ||
| 8688 | .freebsd => struct { | ||
| 8689 | /// On input, TRIGGER causes the event to be triggered for output. | ||
| 8690 | pub const TRIGGER = 0x01000000; | ||
| 8691 | /// ignore input fflags | ||
| 8692 | pub const FFNOP = 0x00000000; | ||
| 8693 | /// and fflags | ||
| 8694 | pub const FFAND = 0x40000000; | ||
| 8695 | /// or fflags | ||
| 8696 | pub const FFOR = 0x80000000; | ||
| 8697 | /// copy fflags | ||
| 8698 | pub const FFCOPY = 0xc0000000; | ||
| 8699 | /// mask for operations | ||
| 8700 | pub const FFCTRLMASK = 0xc0000000; | ||
| 8701 | pub const FFLAGSMASK = 0x00ffffff; | ||
| 8702 | /// low water mark | ||
| 8703 | pub const LOWAT = 0x00000001; | ||
| 8704 | /// behave like poll() | ||
| 8705 | pub const FILE_POLL = 0x00000002; | ||
| 8706 | /// vnode was removed | ||
| 8707 | pub const DELETE = 0x00000001; | ||
| 8708 | /// data contents changed | ||
| 8709 | pub const WRITE = 0x00000002; | ||
| 8710 | /// size increased | ||
| 8711 | pub const EXTEND = 0x00000004; | ||
| 8712 | /// attributes changed | ||
| 8713 | pub const ATTRIB = 0x00000008; | ||
| 8714 | /// link count changed | ||
| 8715 | pub const LINK = 0x00000010; | ||
| 8716 | /// vnode was renamed | ||
| 8717 | pub const RENAME = 0x00000020; | ||
| 8718 | /// vnode access was revoked | ||
| 8719 | pub const REVOKE = 0x00000040; | ||
| 8720 | /// vnode was opened | ||
| 8721 | pub const OPEN = 0x00000080; | ||
| 8722 | /// file closed, fd did not allow write | ||
| 8723 | pub const CLOSE = 0x00000100; | ||
| 8724 | /// file closed, fd did allow write | ||
| 8725 | pub const CLOSE_WRITE = 0x00000200; | ||
| 8726 | /// file was read | ||
| 8727 | pub const READ = 0x00000400; | ||
| 8728 | /// process exited | ||
| 8729 | pub const EXIT = 0x80000000; | ||
| 8730 | /// process forked | ||
| 8731 | pub const FORK = 0x40000000; | ||
| 8732 | /// process exec'd | ||
| 8733 | pub const EXEC = 0x20000000; | ||
| 8734 | /// mask for signal & exit status | ||
| 8735 | pub const PDATAMASK = 0x000fffff; | ||
| 8736 | pub const PCTRLMASK = (~PDATAMASK); | ||
| 8737 | /// data is seconds | ||
| 8738 | pub const SECONDS = 0x00000001; | ||
| 8739 | /// data is milliseconds | ||
| 8740 | pub const MSECONDS = 0x00000002; | ||
| 8741 | /// data is microseconds | ||
| 8742 | pub const USECONDS = 0x00000004; | ||
| 8743 | /// data is nanoseconds | ||
| 8744 | pub const NSECONDS = 0x00000008; | ||
| 8745 | /// timeout is absolute | ||
| 8746 | pub const ABSTIME = 0x00000010; | ||
| 8747 | }, | ||
| 8748 | .openbsd => struct { | ||
| 8749 | // data/hint flags for EVFILT.{READ|WRITE} | ||
| 8750 | pub const LOWAT = 0x0001; | ||
| 8751 | pub const EOF = 0x0002; | ||
| 8752 | // data/hint flags for EVFILT.EXCEPT and EVFILT.{READ|WRITE} | ||
| 8753 | pub const OOB = 0x0004; | ||
| 8754 | // data/hint flags for EVFILT.VNODE | ||
| 8755 | pub const DELETE = 0x0001; | ||
| 8756 | pub const WRITE = 0x0002; | ||
| 8757 | pub const EXTEND = 0x0004; | ||
| 8758 | pub const ATTRIB = 0x0008; | ||
| 8759 | pub const LINK = 0x0010; | ||
| 8760 | pub const RENAME = 0x0020; | ||
| 8761 | pub const REVOKE = 0x0040; | ||
| 8762 | pub const TRUNCATE = 0x0080; | ||
| 8763 | // data/hint flags for EVFILT.PROC | ||
| 8764 | pub const EXIT = 0x80000000; | ||
| 8765 | pub const FORK = 0x40000000; | ||
| 8766 | pub const EXEC = 0x20000000; | ||
| 8767 | pub const PDATAMASK = 0x000fffff; | ||
| 8768 | pub const PCTRLMASK = 0xf0000000; | ||
| 8769 | pub const TRACK = 0x00000001; | ||
| 8770 | pub const TRACKERR = 0x00000002; | ||
| 8771 | pub const CHILD = 0x00000004; | ||
| 8772 | // data/hint flags for EVFILT.DEVICE | ||
| 8773 | pub const CHANGE = 0x00000001; | ||
| 8774 | }, | ||
| 8775 | else => void, | ||
| 8776 | }; | ||
| 8777 | |||
| 1497 | // Unix-like systems | 8778 | // Unix-like systems |
| 1498 | pub const DIR = opaque {}; | 8779 | pub const DIR = opaque {}; |
| 1499 | pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR; | 8780 | pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR; |
| ... | @@ -1503,10 +8784,15 @@ pub extern "c" fn closedir(dp: *DIR) c_int; | ... | @@ -1503,10 +8784,15 @@ pub extern "c" fn closedir(dp: *DIR) c_int; |
| 1503 | pub extern "c" fn telldir(dp: *DIR) c_long; | 8784 | pub extern "c" fn telldir(dp: *DIR) c_long; |
| 1504 | pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void; | 8785 | pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void; |
| 1505 | 8786 | ||
| 1506 | pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int; | 8787 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; |
| 1507 | 8788 | ||
| 1508 | pub extern "c" fn alarm(seconds: c_uint) c_uint; | 8789 | pub extern "c" fn alarm(seconds: c_uint) c_uint; |
| 1509 | 8790 | ||
| 8791 | pub const close = switch (native_os) { | ||
| 8792 | .macos, .ios, .tvos, .watchos, .visionos => darwin.@"close$NOCANCEL", | ||
| 8793 | else => private.close, | ||
| 8794 | }; | ||
| 8795 | |||
| 1510 | pub const clock_getres = switch (native_os) { | 8796 | pub const clock_getres = switch (native_os) { |
| 1511 | .netbsd => private.__clock_getres50, | 8797 | .netbsd => private.__clock_getres50, |
| 1512 | else => private.clock_getres, | 8798 | else => private.clock_getres, |
| ... | @@ -1534,11 +8820,119 @@ pub const fstatat = switch (native_os) { | ... | @@ -1534,11 +8820,119 @@ pub const fstatat = switch (native_os) { |
| 1534 | else => private.fstatat, | 8820 | else => private.fstatat, |
| 1535 | }; | 8821 | }; |
| 1536 | 8822 | ||
| 8823 | pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd; | ||
| 8824 | pub extern "c" fn getpwuid(uid: uid_t) ?*passwd; | ||
| 8825 | pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int; | ||
| 8826 | pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64; | ||
| 8827 | pub extern "c" fn mmap64(addr: ?*align(std.mem.page_size) anyopaque, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: i64) *anyopaque; | ||
| 8828 | pub extern "c" fn open64(path: [*:0]const u8, oflag: O, ...) c_int; | ||
| 8829 | pub extern "c" fn openat64(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; | ||
| 8830 | pub extern "c" fn pread64(fd: fd_t, buf: [*]u8, nbyte: usize, offset: i64) isize; | ||
| 8831 | pub extern "c" fn preadv64(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: i64) isize; | ||
| 8832 | pub extern "c" fn pwrite64(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: i64) isize; | ||
| 8833 | pub extern "c" fn pwritev64(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: i64) isize; | ||
| 8834 | pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: usize) isize; | ||
| 8835 | pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int; | ||
| 8836 | |||
| 8837 | pub const arc4random_buf = switch (native_os) { | ||
| 8838 | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf, | ||
| 8839 | else => {}, | ||
| 8840 | }; | ||
| 8841 | pub const getentropy = switch (native_os) { | ||
| 8842 | .emscripten => private.getentropy, | ||
| 8843 | else => {}, | ||
| 8844 | }; | ||
| 8845 | pub const getrandom = switch (native_os) { | ||
| 8846 | .freebsd => private.getrandom, | ||
| 8847 | .linux => if (versionCheck(.{ .major = 2, .minor = 25, .patch = 0 })) private.getrandom else {}, | ||
| 8848 | else => {}, | ||
| 8849 | }; | ||
| 8850 | |||
| 8851 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; | ||
| 8852 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; | ||
| 8853 | |||
| 8854 | pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int; | ||
| 8855 | pub extern "c" fn epoll_create1(flags: c_uint) c_int; | ||
| 8856 | pub extern "c" fn epoll_wait(epfd: fd_t, events: [*]epoll_event, maxevents: c_uint, timeout: c_int) c_int; | ||
| 8857 | pub extern "c" fn epoll_pwait( | ||
| 8858 | epfd: fd_t, | ||
| 8859 | events: [*]epoll_event, | ||
| 8860 | maxevents: c_int, | ||
| 8861 | timeout: c_int, | ||
| 8862 | sigmask: *const sigset_t, | ||
| 8863 | ) c_int; | ||
| 8864 | |||
| 8865 | pub extern "c" fn timerfd_create(clockid: clockid_t, flags: c_int) c_int; | ||
| 8866 | pub extern "c" fn timerfd_settime( | ||
| 8867 | fd: c_int, | ||
| 8868 | flags: c_int, | ||
| 8869 | new_value: *const itimerspec, | ||
| 8870 | old_value: ?*itimerspec, | ||
| 8871 | ) c_int; | ||
| 8872 | pub extern "c" fn timerfd_gettime(fd: c_int, curr_value: *itimerspec) c_int; | ||
| 8873 | |||
| 8874 | pub extern "c" fn inotify_init1(flags: c_uint) c_int; | ||
| 8875 | pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) c_int; | ||
| 8876 | pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int; | ||
| 8877 | |||
| 8878 | pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int; | ||
| 8879 | pub extern "c" fn fstatat64(dirfd: fd_t, noalias path: [*:0]const u8, noalias stat_buf: *Stat, flags: u32) c_int; | ||
| 8880 | pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; | ||
| 8881 | pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; | ||
| 8882 | pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int; | ||
| 8883 | pub extern "c" fn fallocate(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; | ||
| 8884 | pub const sendfile = switch (native_os) { | ||
| 8885 | .freebsd, .kfreebsd => freebsd.sendfile, | ||
| 8886 | .macos, .ios, .tvos, .watchos, .visionos => darwin.sendfile, | ||
| 8887 | .linux => private.sendfile, | ||
| 8888 | else => {}, | ||
| 8889 | }; | ||
| 8890 | /// See std.elf for constants for this | ||
| 8891 | pub extern "c" fn getauxval(__type: c_ulong) c_ulong; | ||
| 8892 | |||
| 8893 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 8894 | |||
| 8895 | pub const sigaltstack = switch (native_os) { | ||
| 8896 | .netbsd => private.__sigaltstack14, | ||
| 8897 | else => private.sigaltstack, | ||
| 8898 | }; | ||
| 8899 | |||
| 8900 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; | ||
| 8901 | pub const pipe2 = switch (native_os) { | ||
| 8902 | .dragonfly, .emscripten, .netbsd, .freebsd, .kfreebsd, .solaris, .illumos, .openbsd, .linux => private.pipe2, | ||
| 8903 | else => {}, | ||
| 8904 | }; | ||
| 8905 | pub const copy_file_range = switch (native_os) { | ||
| 8906 | .linux => private.copy_file_range, | ||
| 8907 | .freebsd, .kfreebsd => freebsd.copy_file_range, | ||
| 8908 | else => {}, | ||
| 8909 | }; | ||
| 8910 | |||
| 8911 | pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int; | ||
| 8912 | |||
| 8913 | pub extern "c" fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: *const rlimit, old_limit: *rlimit) c_int; | ||
| 8914 | pub extern "c" fn mincore( | ||
| 8915 | addr: *align(std.mem.page_size) anyopaque, | ||
| 8916 | length: usize, | ||
| 8917 | vec: [*]u8, | ||
| 8918 | ) c_int; | ||
| 8919 | |||
| 8920 | pub extern "c" fn madvise( | ||
| 8921 | addr: *align(std.mem.page_size) anyopaque, | ||
| 8922 | length: usize, | ||
| 8923 | advice: u32, | ||
| 8924 | ) c_int; | ||
| 8925 | |||
| 1537 | pub const getdirentries = switch (native_os) { | 8926 | pub const getdirentries = switch (native_os) { |
| 1538 | .macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64, | 8927 | .macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64, |
| 1539 | else => private.getdirentries, | 8928 | else => private.getdirentries, |
| 1540 | }; | 8929 | }; |
| 1541 | 8930 | ||
| 8931 | pub const getdents = switch (native_os) { | ||
| 8932 | .netbsd => private.__getdents30, | ||
| 8933 | else => private.getdents, | ||
| 8934 | }; | ||
| 8935 | |||
| 1542 | pub const getrusage = switch (native_os) { | 8936 | pub const getrusage = switch (native_os) { |
| 1543 | .netbsd => private.__getrusage50, | 8937 | .netbsd => private.__getrusage50, |
| 1544 | else => private.getrusage, | 8938 | else => private.getrusage, |
| ... | @@ -1564,7 +8958,7 @@ pub const readdir = switch (native_os) { | ... | @@ -1564,7 +8958,7 @@ pub const readdir = switch (native_os) { |
| 1564 | .x86_64 => private.@"readdir$INODE64", | 8958 | .x86_64 => private.@"readdir$INODE64", |
| 1565 | else => private.readdir, | 8959 | else => private.readdir, |
| 1566 | }, | 8960 | }, |
| 1567 | .windows => @compileError("not available"), | 8961 | .windows => {}, |
| 1568 | else => private.readdir, | 8962 | else => private.readdir, |
| 1569 | }; | 8963 | }; |
| 1570 | 8964 | ||
| ... | @@ -1606,6 +9000,38 @@ pub const stat = switch (native_os) { | ... | @@ -1606,6 +9000,38 @@ pub const stat = switch (native_os) { |
| 1606 | else => private.stat, | 9000 | else => private.stat, |
| 1607 | }; | 9001 | }; |
| 1608 | 9002 | ||
| 9003 | pub const _msize = switch (native_os) { | ||
| 9004 | .windows => private._msize, | ||
| 9005 | else => {}, | ||
| 9006 | }; | ||
| 9007 | pub const malloc_size = switch (native_os) { | ||
| 9008 | .macos, .ios, .tvos, .watchos, .visionos => private.malloc_size, | ||
| 9009 | else => {}, | ||
| 9010 | }; | ||
| 9011 | pub const malloc_usable_size = switch (native_os) { | ||
| 9012 | .freebsd, .linux => private.malloc_usable_size, | ||
| 9013 | else => {}, | ||
| 9014 | }; | ||
| 9015 | pub const posix_memalign = switch (native_os) { | ||
| 9016 | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .linux, .macos, .ios, .tvos, .watchos, .visionos => private.posix_memalign, | ||
| 9017 | else => {}, | ||
| 9018 | }; | ||
| 9019 | |||
| 9020 | pub const sf_hdtr = switch (native_os) { | ||
| 9021 | .freebsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | ||
| 9022 | headers: [*]const iovec_const, | ||
| 9023 | hdr_cnt: c_int, | ||
| 9024 | trailers: [*]const iovec_const, | ||
| 9025 | trl_cnt: c_int, | ||
| 9026 | }, | ||
| 9027 | else => void, | ||
| 9028 | }; | ||
| 9029 | |||
| 9030 | pub const flock = switch (native_os) { | ||
| 9031 | .windows, .wasi => {}, | ||
| 9032 | else => private.flock, | ||
| 9033 | }; | ||
| 9034 | |||
| 1609 | pub extern "c" var environ: [*:null]?[*:0]u8; | 9035 | pub extern "c" var environ: [*:null]?[*:0]u8; |
| 1610 | 9036 | ||
| 1611 | pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; | 9037 | pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; |
| ... | @@ -1617,228 +9043,257 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; | ... | @@ -1617,228 +9043,257 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; |
| 1617 | pub extern "c" fn abort() noreturn; | 9043 | pub extern "c" fn abort() noreturn; |
| 1618 | pub extern "c" fn exit(code: c_int) noreturn; | 9044 | pub extern "c" fn exit(code: c_int) noreturn; |
| 1619 | pub extern "c" fn _exit(code: c_int) noreturn; | 9045 | pub extern "c" fn _exit(code: c_int) noreturn; |
| 1620 | pub extern "c" fn isatty(fd: c.fd_t) c_int; | 9046 | pub extern "c" fn isatty(fd: fd_t) c_int; |
| 1621 | pub extern "c" fn close(fd: c.fd_t) c_int; | 9047 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; |
| 1622 | pub extern "c" fn lseek(fd: c.fd_t, offset: c.off_t, whence: whence_t) c.off_t; | ||
| 1623 | pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int; | 9048 | pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int; |
| 1624 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; | 9049 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; |
| 1625 | pub extern "c" fn ftruncate(fd: c_int, length: c.off_t) c_int; | 9050 | pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int; |
| 1626 | pub extern "c" fn raise(sig: c_int) c_int; | 9051 | pub extern "c" fn raise(sig: c_int) c_int; |
| 1627 | pub extern "c" fn read(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize; | 9052 | pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize; |
| 1628 | pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; | 9053 | pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; |
| 1629 | pub extern "c" fn pread(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize; | 9054 | pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize; |
| 1630 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: c.off_t) isize; | 9055 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize; |
| 1631 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; | 9056 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; |
| 1632 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: c.off_t) isize; | 9057 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize; |
| 1633 | pub extern "c" fn write(fd: c.fd_t, buf: [*]const u8, nbyte: usize) isize; | 9058 | pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; |
| 1634 | pub extern "c" fn pwrite(fd: c.fd_t, buf: [*]const u8, nbyte: usize, offset: c.off_t) isize; | 9059 | pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize; |
| 1635 | pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: c_uint, flags: MAP, fd: c.fd_t, offset: c.off_t) *anyopaque; | 9060 | pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: c_uint, flags: MAP, fd: fd_t, offset: off_t) *anyopaque; |
| 1636 | pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int; | 9061 | pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int; |
| 1637 | pub extern "c" fn mprotect(addr: *align(page_size) anyopaque, len: usize, prot: c_uint) c_int; | 9062 | pub extern "c" fn mprotect(addr: *align(page_size) anyopaque, len: usize, prot: c_uint) c_int; |
| 1638 | pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int; | 9063 | pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int; |
| 1639 | pub extern "c" fn linkat(oldfd: c.fd_t, oldpath: [*:0]const u8, newfd: c.fd_t, newpath: [*:0]const u8, flags: c_int) c_int; | 9064 | pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_int) c_int; |
| 1640 | pub extern "c" fn unlink(path: [*:0]const u8) c_int; | 9065 | pub extern "c" fn unlink(path: [*:0]const u8) c_int; |
| 1641 | pub extern "c" fn unlinkat(dirfd: c.fd_t, path: [*:0]const u8, flags: c_uint) c_int; | 9066 | pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int; |
| 1642 | pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8; | 9067 | pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8; |
| 1643 | pub extern "c" fn waitpid(pid: c.pid_t, status: ?*c_int, options: c_int) c.pid_t; | 9068 | pub extern "c" fn waitpid(pid: pid_t, status: ?*c_int, options: c_int) pid_t; |
| 1644 | pub extern "c" fn wait4(pid: c.pid_t, status: ?*c_int, options: c_int, ru: ?*c.rusage) c.pid_t; | 9069 | pub extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; |
| 1645 | pub extern "c" fn fork() c_int; | 9070 | pub const fork = switch (native_os) { |
| 9071 | .dragonfly, | ||
| 9072 | .freebsd, | ||
| 9073 | .ios, | ||
| 9074 | .kfreebsd, | ||
| 9075 | .linux, | ||
| 9076 | .macos, | ||
| 9077 | .netbsd, | ||
| 9078 | .openbsd, | ||
| 9079 | .solaris, | ||
| 9080 | .illumos, | ||
| 9081 | .tvos, | ||
| 9082 | .watchos, | ||
| 9083 | .visionos, | ||
| 9084 | .haiku, | ||
| 9085 | => private.fork, | ||
| 9086 | else => {}, | ||
| 9087 | }; | ||
| 1646 | pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int; | 9088 | pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int; |
| 1647 | pub extern "c" fn faccessat(dirfd: c.fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int; | 9089 | pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int; |
| 1648 | pub extern "c" fn pipe(fds: *[2]c.fd_t) c_int; | 9090 | pub extern "c" fn pipe(fds: *[2]fd_t) c_int; |
| 1649 | pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int; | 9091 | pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int; |
| 1650 | pub extern "c" fn mkdirat(dirfd: c.fd_t, path: [*:0]const u8, mode: u32) c_int; | 9092 | pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: u32) c_int; |
| 1651 | pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int; | 9093 | pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int; |
| 1652 | pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: c.fd_t, newpath: [*:0]const u8) c_int; | 9094 | pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int; |
| 1653 | pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int; | 9095 | pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int; |
| 1654 | pub extern "c" fn renameat(olddirfd: c.fd_t, old: [*:0]const u8, newdirfd: c.fd_t, new: [*:0]const u8) c_int; | 9096 | pub extern "c" fn renameat(olddirfd: fd_t, old: [*:0]const u8, newdirfd: fd_t, new: [*:0]const u8) c_int; |
| 1655 | pub extern "c" fn chdir(path: [*:0]const u8) c_int; | 9097 | pub extern "c" fn chdir(path: [*:0]const u8) c_int; |
| 1656 | pub extern "c" fn fchdir(fd: c.fd_t) c_int; | 9098 | pub extern "c" fn fchdir(fd: fd_t) c_int; |
| 1657 | pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; | 9099 | pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; |
| 1658 | pub extern "c" fn dup(fd: c.fd_t) c_int; | 9100 | pub extern "c" fn dup(fd: fd_t) c_int; |
| 1659 | pub extern "c" fn dup2(old_fd: c.fd_t, new_fd: c.fd_t) c_int; | 9101 | pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; |
| 9102 | pub extern "c" fn dup3(old: c_int, new: c_int, flags: c_uint) c_int; | ||
| 1660 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 9103 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 1661 | pub extern "c" fn readlinkat(dirfd: c.fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 9104 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 1662 | pub extern "c" fn chmod(path: [*:0]const u8, mode: c.mode_t) c_int; | 9105 | pub extern "c" fn chmod(path: [*:0]const u8, mode: mode_t) c_int; |
| 1663 | pub extern "c" fn fchmod(fd: c.fd_t, mode: c.mode_t) c_int; | 9106 | pub extern "c" fn fchmod(fd: fd_t, mode: mode_t) c_int; |
| 1664 | pub extern "c" fn fchmodat(fd: c.fd_t, path: [*:0]const u8, mode: c.mode_t, flags: c_uint) c_int; | 9107 | pub extern "c" fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: c_uint) c_int; |
| 1665 | pub extern "c" fn fchown(fd: c.fd_t, owner: c.uid_t, group: c.gid_t) c_int; | 9108 | pub extern "c" fn fchown(fd: fd_t, owner: uid_t, group: gid_t) c_int; |
| 1666 | pub extern "c" fn umask(mode: c.mode_t) c.mode_t; | 9109 | pub extern "c" fn umask(mode: mode_t) mode_t; |
| 1667 | 9110 | ||
| 1668 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; | 9111 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; |
| 1669 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; | 9112 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; |
| 1670 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int; | 9113 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int; |
| 1671 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int; | 9114 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int; |
| 1672 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; | 9115 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
| 1673 | pub extern "c" fn tcgetattr(fd: c.fd_t, termios_p: *c.termios) c_int; | 9116 | pub extern "c" fn tcgetattr(fd: fd_t, termios_p: *termios) c_int; |
| 1674 | pub extern "c" fn tcsetattr(fd: c.fd_t, optional_action: c.TCSA, termios_p: *const c.termios) c_int; | 9117 | pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int; |
| 1675 | pub extern "c" fn fcntl(fd: c.fd_t, cmd: c_int, ...) c_int; | 9118 | pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int; |
| 1676 | pub extern "c" fn flock(fd: c.fd_t, operation: c_int) c_int; | 9119 | pub extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int; |
| 1677 | pub extern "c" fn ioctl(fd: c.fd_t, request: c_int, ...) c_int; | 9120 | pub extern "c" fn uname(buf: *utsname) c_int; |
| 1678 | pub extern "c" fn uname(buf: *c.utsname) c_int; | ||
| 1679 | 9121 | ||
| 1680 | pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int; | 9122 | pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int; |
| 1681 | pub extern "c" fn shutdown(socket: c.fd_t, how: c_int) c_int; | 9123 | pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int; |
| 1682 | pub extern "c" fn bind(socket: c.fd_t, address: ?*const c.sockaddr, address_len: c.socklen_t) c_int; | 9124 | pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int; |
| 1683 | pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]c.fd_t) c_int; | 9125 | pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int; |
| 1684 | pub extern "c" fn listen(sockfd: c.fd_t, backlog: c_uint) c_int; | 9126 | pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int; |
| 1685 | pub extern "c" fn getsockname(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int; | 9127 | pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; |
| 1686 | pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int; | 9128 | pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; |
| 1687 | pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int; | 9129 | pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int; |
| 1688 | pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int; | 9130 | pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int; |
| 1689 | pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int; | 9131 | pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int; |
| 1690 | pub extern "c" fn getsockopt(sockfd: c.fd_t, level: i32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *c.socklen_t) c_int; | 9132 | pub extern "c" fn getsockopt(sockfd: fd_t, level: i32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *socklen_t) c_int; |
| 1691 | pub extern "c" fn setsockopt(sockfd: c.fd_t, level: i32, optname: u32, optval: ?*const anyopaque, optlen: c.socklen_t) c_int; | 9133 | pub extern "c" fn setsockopt(sockfd: fd_t, level: i32, optname: u32, optval: ?*const anyopaque, optlen: socklen_t) c_int; |
| 1692 | pub extern "c" fn send(sockfd: c.fd_t, buf: *const anyopaque, len: usize, flags: u32) isize; | 9134 | pub extern "c" fn send(sockfd: fd_t, buf: *const anyopaque, len: usize, flags: u32) isize; |
| 1693 | pub extern "c" fn sendto( | 9135 | pub extern "c" fn sendto( |
| 1694 | sockfd: c.fd_t, | 9136 | sockfd: fd_t, |
| 1695 | buf: *const anyopaque, | 9137 | buf: *const anyopaque, |
| 1696 | len: usize, | 9138 | len: usize, |
| 1697 | flags: u32, | 9139 | flags: u32, |
| 1698 | dest_addr: ?*const c.sockaddr, | 9140 | dest_addr: ?*const sockaddr, |
| 1699 | addrlen: c.socklen_t, | 9141 | addrlen: socklen_t, |
| 1700 | ) isize; | 9142 | ) isize; |
| 1701 | pub extern "c" fn sendmsg(sockfd: c.fd_t, msg: *const c.msghdr_const, flags: u32) isize; | 9143 | pub extern "c" fn sendmsg(sockfd: fd_t, msg: *const msghdr_const, flags: u32) isize; |
| 1702 | 9144 | ||
| 1703 | pub extern "c" fn recv( | 9145 | pub extern "c" fn recv( |
| 1704 | sockfd: c.fd_t, | 9146 | sockfd: fd_t, |
| 1705 | arg1: ?*anyopaque, | 9147 | arg1: ?*anyopaque, |
| 1706 | arg2: usize, | 9148 | arg2: usize, |
| 1707 | arg3: c_int, | 9149 | arg3: c_int, |
| 1708 | ) if (native_os == .windows) c_int else isize; | 9150 | ) if (native_os == .windows) c_int else isize; |
| 1709 | pub extern "c" fn recvfrom( | 9151 | pub extern "c" fn recvfrom( |
| 1710 | sockfd: c.fd_t, | 9152 | sockfd: fd_t, |
| 1711 | noalias buf: *anyopaque, | 9153 | noalias buf: *anyopaque, |
| 1712 | len: usize, | 9154 | len: usize, |
| 1713 | flags: u32, | 9155 | flags: u32, |
| 1714 | noalias src_addr: ?*c.sockaddr, | 9156 | noalias src_addr: ?*sockaddr, |
| 1715 | noalias addrlen: ?*c.socklen_t, | 9157 | noalias addrlen: ?*socklen_t, |
| 1716 | ) if (native_os == .windows) c_int else isize; | 9158 | ) if (native_os == .windows) c_int else isize; |
| 1717 | pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *c.msghdr, flags: u32) isize; | 9159 | pub extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize; |
| 1718 | 9160 | ||
| 1719 | pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int; | 9161 | pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int; |
| 1720 | 9162 | ||
| 1721 | pub extern "c" fn setuid(uid: c.uid_t) c_int; | 9163 | pub extern "c" fn setuid(uid: uid_t) c_int; |
| 1722 | pub extern "c" fn setgid(gid: c.gid_t) c_int; | 9164 | pub extern "c" fn setgid(gid: gid_t) c_int; |
| 1723 | pub extern "c" fn seteuid(euid: c.uid_t) c_int; | 9165 | pub extern "c" fn seteuid(euid: uid_t) c_int; |
| 1724 | pub extern "c" fn setegid(egid: c.gid_t) c_int; | 9166 | pub extern "c" fn setegid(egid: gid_t) c_int; |
| 1725 | pub extern "c" fn setreuid(ruid: c.uid_t, euid: c.uid_t) c_int; | 9167 | pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int; |
| 1726 | pub extern "c" fn setregid(rgid: c.gid_t, egid: c.gid_t) c_int; | 9168 | pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int; |
| 1727 | pub extern "c" fn setresuid(ruid: c.uid_t, euid: c.uid_t, suid: c.uid_t) c_int; | 9169 | pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int; |
| 1728 | pub extern "c" fn setresgid(rgid: c.gid_t, egid: c.gid_t, sgid: c.gid_t) c_int; | 9170 | pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int; |
| 1729 | 9171 | ||
| 1730 | pub extern "c" fn malloc(usize) ?*anyopaque; | 9172 | pub extern "c" fn malloc(usize) ?*anyopaque; |
| 1731 | pub extern "c" fn realloc(?*anyopaque, usize) ?*anyopaque; | 9173 | pub extern "c" fn realloc(?*anyopaque, usize) ?*anyopaque; |
| 1732 | pub extern "c" fn free(?*anyopaque) void; | 9174 | pub extern "c" fn free(?*anyopaque) void; |
| 1733 | 9175 | ||
| 1734 | pub extern "c" fn futimes(fd: c.fd_t, times: *[2]c.timeval) c_int; | 9176 | pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int; |
| 1735 | pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]c.timeval) c_int; | 9177 | pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int; |
| 1736 | 9178 | ||
| 1737 | pub extern "c" fn utimensat(dirfd: c.fd_t, pathname: [*:0]const u8, times: *[2]c.timespec, flags: u32) c_int; | 9179 | pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int; |
| 1738 | pub extern "c" fn futimens(fd: c.fd_t, times: *const [2]c.timespec) c_int; | 9180 | pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int; |
| 1739 | 9181 | ||
| 1740 | pub extern "c" fn pthread_create( | 9182 | pub extern "c" fn pthread_create( |
| 1741 | noalias newthread: *pthread_t, | 9183 | noalias newthread: *pthread_t, |
| 1742 | noalias attr: ?*const c.pthread_attr_t, | 9184 | noalias attr: ?*const pthread_attr_t, |
| 1743 | start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque, | 9185 | start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque, |
| 1744 | noalias arg: ?*anyopaque, | 9186 | noalias arg: ?*anyopaque, |
| 1745 | ) c.E; | 9187 | ) E; |
| 1746 | pub extern "c" fn pthread_attr_init(attr: *c.pthread_attr_t) c.E; | 9188 | pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E; |
| 1747 | pub extern "c" fn pthread_attr_setstack(attr: *c.pthread_attr_t, stackaddr: *anyopaque, stacksize: usize) c.E; | 9189 | pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *anyopaque, stacksize: usize) E; |
| 1748 | pub extern "c" fn pthread_attr_setstacksize(attr: *c.pthread_attr_t, stacksize: usize) c.E; | 9190 | pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E; |
| 1749 | pub extern "c" fn pthread_attr_setguardsize(attr: *c.pthread_attr_t, guardsize: usize) c.E; | 9191 | pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E; |
| 1750 | pub extern "c" fn pthread_attr_destroy(attr: *c.pthread_attr_t) c.E; | 9192 | pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E; |
| 1751 | pub extern "c" fn pthread_self() pthread_t; | 9193 | pub extern "c" fn pthread_self() pthread_t; |
| 1752 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) c.E; | 9194 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E; |
| 1753 | pub extern "c" fn pthread_detach(thread: pthread_t) c.E; | 9195 | pub extern "c" fn pthread_detach(thread: pthread_t) E; |
| 1754 | pub extern "c" fn pthread_atfork( | 9196 | pub extern "c" fn pthread_atfork( |
| 1755 | prepare: ?*const fn () callconv(.C) void, | 9197 | prepare: ?*const fn () callconv(.C) void, |
| 1756 | parent: ?*const fn () callconv(.C) void, | 9198 | parent: ?*const fn () callconv(.C) void, |
| 1757 | child: ?*const fn () callconv(.C) void, | 9199 | child: ?*const fn () callconv(.C) void, |
| 1758 | ) c_int; | 9200 | ) c_int; |
| 1759 | pub extern "c" fn pthread_key_create( | 9201 | pub extern "c" fn pthread_key_create( |
| 1760 | key: *c.pthread_key_t, | 9202 | key: *pthread_key_t, |
| 1761 | destructor: ?*const fn (value: *anyopaque) callconv(.C) void, | 9203 | destructor: ?*const fn (value: *anyopaque) callconv(.C) void, |
| 1762 | ) c.E; | 9204 | ) E; |
| 1763 | pub extern "c" fn pthread_key_delete(key: c.pthread_key_t) c.E; | 9205 | pub extern "c" fn pthread_key_delete(key: pthread_key_t) E; |
| 1764 | pub extern "c" fn pthread_getspecific(key: c.pthread_key_t) ?*anyopaque; | 9206 | pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque; |
| 1765 | pub extern "c" fn pthread_setspecific(key: c.pthread_key_t, value: ?*anyopaque) c_int; | 9207 | pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*anyopaque) c_int; |
| 1766 | pub extern "c" fn pthread_sigmask(how: c_int, set: *const c.sigset_t, oldset: *c.sigset_t) c_int; | 9208 | pub extern "c" fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *sigset_t) c_int; |
| 1767 | pub extern "c" fn sem_init(sem: *c.sem_t, pshared: c_int, value: c_uint) c_int; | 9209 | pub const pthread_setname_np = switch (native_os) { |
| 1768 | pub extern "c" fn sem_destroy(sem: *c.sem_t) c_int; | 9210 | .macos, .ios, .tvos, .watchos, .visionos => darwin.pthread_setname_np, |
| 1769 | pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: c.mode_t, value: c_uint) *c.sem_t; | 9211 | .solaris, .illumos => solaris.pthread_setname_np, |
| 1770 | pub extern "c" fn sem_close(sem: *c.sem_t) c_int; | 9212 | .netbsd => netbsd.pthread_setname_np, |
| 1771 | pub extern "c" fn sem_post(sem: *c.sem_t) c_int; | 9213 | else => private.pthread_setname_np, |
| 1772 | pub extern "c" fn sem_wait(sem: *c.sem_t) c_int; | 9214 | }; |
| 1773 | pub extern "c" fn sem_trywait(sem: *c.sem_t) c_int; | 9215 | |
| 1774 | pub extern "c" fn sem_timedwait(sem: *c.sem_t, abs_timeout: *const c.timespec) c_int; | 9216 | pub extern "c" fn pthread_getname_np(thread: pthread_t, name: [*:0]u8, len: usize) c_int; |
| 1775 | pub extern "c" fn sem_getvalue(sem: *c.sem_t, sval: *c_int) c_int; | 9217 | pub const pthread_threadid_np = switch (native_os) { |
| 1776 | 9218 | .macos, .ios, .tvos, .watchos, .visionos => private.pthread_threadid_np, | |
| 1777 | pub extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: c.mode_t) c_int; | 9219 | else => {}, |
| 9220 | }; | ||
| 9221 | |||
| 9222 | pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int; | ||
| 9223 | pub extern "c" fn sem_destroy(sem: *sem_t) c_int; | ||
| 9224 | pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: mode_t, value: c_uint) *sem_t; | ||
| 9225 | pub extern "c" fn sem_close(sem: *sem_t) c_int; | ||
| 9226 | pub extern "c" fn sem_post(sem: *sem_t) c_int; | ||
| 9227 | pub extern "c" fn sem_wait(sem: *sem_t) c_int; | ||
| 9228 | pub extern "c" fn sem_trywait(sem: *sem_t) c_int; | ||
| 9229 | pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int; | ||
| 9230 | pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int; | ||
| 9231 | |||
| 9232 | pub extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int; | ||
| 1778 | pub extern "c" fn shm_unlink(name: [*:0]const u8) c_int; | 9233 | pub extern "c" fn shm_unlink(name: [*:0]const u8) c_int; |
| 1779 | 9234 | ||
| 1780 | pub extern "c" fn kqueue() c_int; | 9235 | pub extern "c" fn kqueue() c_int; |
| 1781 | pub extern "c" fn kevent( | 9236 | pub extern "c" fn kevent( |
| 1782 | kq: c_int, | 9237 | kq: c_int, |
| 1783 | changelist: [*]const c.Kevent, | 9238 | changelist: [*]const Kevent, |
| 1784 | nchanges: c_int, | 9239 | nchanges: c_int, |
| 1785 | eventlist: [*]c.Kevent, | 9240 | eventlist: [*]Kevent, |
| 1786 | nevents: c_int, | 9241 | nevents: c_int, |
| 1787 | timeout: ?*const c.timespec, | 9242 | timeout: ?*const timespec, |
| 1788 | ) c_int; | 9243 | ) c_int; |
| 1789 | 9244 | ||
| 1790 | pub extern "c" fn port_create() c.port_t; | 9245 | pub extern "c" fn port_create() port_t; |
| 1791 | pub extern "c" fn port_associate( | 9246 | pub extern "c" fn port_associate( |
| 1792 | port: c.port_t, | 9247 | port: port_t, |
| 1793 | source: u32, | 9248 | source: u32, |
| 1794 | object: usize, | 9249 | object: usize, |
| 1795 | events: u32, | 9250 | events: u32, |
| 1796 | user_var: ?*anyopaque, | 9251 | user_var: ?*anyopaque, |
| 1797 | ) c_int; | 9252 | ) c_int; |
| 1798 | pub extern "c" fn port_dissociate(port: c.port_t, source: u32, object: usize) c_int; | 9253 | pub extern "c" fn port_dissociate(port: port_t, source: u32, object: usize) c_int; |
| 1799 | pub extern "c" fn port_send(port: c.port_t, events: u32, user_var: ?*anyopaque) c_int; | 9254 | pub extern "c" fn port_send(port: port_t, events: u32, user_var: ?*anyopaque) c_int; |
| 1800 | pub extern "c" fn port_sendn( | 9255 | pub extern "c" fn port_sendn( |
| 1801 | ports: [*]c.port_t, | 9256 | ports: [*]port_t, |
| 1802 | errors: []u32, | 9257 | errors: []u32, |
| 1803 | num_ports: u32, | 9258 | num_ports: u32, |
| 1804 | events: u32, | 9259 | events: u32, |
| 1805 | user_var: ?*anyopaque, | 9260 | user_var: ?*anyopaque, |
| 1806 | ) c_int; | 9261 | ) c_int; |
| 1807 | pub extern "c" fn port_get(port: c.port_t, event: *c.port_event, timeout: ?*c.timespec) c_int; | 9262 | pub extern "c" fn port_get(port: port_t, event: *port_event, timeout: ?*timespec) c_int; |
| 1808 | pub extern "c" fn port_getn( | 9263 | pub extern "c" fn port_getn( |
| 1809 | port: c.port_t, | 9264 | port: port_t, |
| 1810 | event_list: []c.port_event, | 9265 | event_list: []port_event, |
| 1811 | max_events: u32, | 9266 | max_events: u32, |
| 1812 | events_retrieved: *u32, | 9267 | events_retrieved: *u32, |
| 1813 | timeout: ?*c.timespec, | 9268 | timeout: ?*timespec, |
| 1814 | ) c_int; | 9269 | ) c_int; |
| 1815 | pub extern "c" fn port_alert(port: c.port_t, flags: u32, events: u32, user_var: ?*anyopaque) c_int; | 9270 | pub extern "c" fn port_alert(port: port_t, flags: u32, events: u32, user_var: ?*anyopaque) c_int; |
| 1816 | 9271 | ||
| 1817 | pub extern "c" fn getaddrinfo( | 9272 | pub extern "c" fn getaddrinfo( |
| 1818 | noalias node: ?[*:0]const u8, | 9273 | noalias node: ?[*:0]const u8, |
| 1819 | noalias service: ?[*:0]const u8, | 9274 | noalias service: ?[*:0]const u8, |
| 1820 | noalias hints: ?*const c.addrinfo, | 9275 | noalias hints: ?*const addrinfo, |
| 1821 | /// On Linux, `res` will not be modified on error and `freeaddrinfo` will | 9276 | /// On Linux, `res` will not be modified on error and `freeaddrinfo` will |
| 1822 | /// potentially crash if you pass it an undefined pointer | 9277 | /// potentially crash if you pass it an undefined pointer |
| 1823 | noalias res: *?*c.addrinfo, | 9278 | noalias res: *?*addrinfo, |
| 1824 | ) c.EAI; | 9279 | ) EAI; |
| 1825 | 9280 | ||
| 1826 | pub extern "c" fn freeaddrinfo(res: *c.addrinfo) void; | 9281 | pub extern "c" fn freeaddrinfo(res: *addrinfo) void; |
| 1827 | 9282 | ||
| 1828 | pub extern "c" fn getnameinfo( | 9283 | pub extern "c" fn getnameinfo( |
| 1829 | noalias addr: *const c.sockaddr, | 9284 | noalias addr: *const sockaddr, |
| 1830 | addrlen: c.socklen_t, | 9285 | addrlen: socklen_t, |
| 1831 | noalias host: [*]u8, | 9286 | noalias host: [*]u8, |
| 1832 | hostlen: c.socklen_t, | 9287 | hostlen: socklen_t, |
| 1833 | noalias serv: [*]u8, | 9288 | noalias serv: [*]u8, |
| 1834 | servlen: c.socklen_t, | 9289 | servlen: socklen_t, |
| 1835 | flags: u32, | 9290 | flags: u32, |
| 1836 | ) c.EAI; | 9291 | ) EAI; |
| 1837 | 9292 | ||
| 1838 | pub extern "c" fn gai_strerror(errcode: c.EAI) [*:0]const u8; | 9293 | pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8; |
| 1839 | 9294 | ||
| 1840 | pub extern "c" fn poll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: c_int) c_int; | 9295 | pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int; |
| 1841 | pub extern "c" fn ppoll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: ?*const c.timespec, sigmask: ?*const c.sigset_t) c_int; | 9296 | pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int; |
| 1842 | 9297 | ||
| 1843 | pub extern "c" fn dn_expand( | 9298 | pub extern "c" fn dn_expand( |
| 1844 | msg: [*:0]const u8, | 9299 | msg: [*:0]const u8, |
| ... | @@ -1849,29 +9304,29 @@ pub extern "c" fn dn_expand( | ... | @@ -1849,29 +9304,29 @@ pub extern "c" fn dn_expand( |
| 1849 | ) c_int; | 9304 | ) c_int; |
| 1850 | 9305 | ||
| 1851 | pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}; | 9306 | pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}; |
| 1852 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) c.E; | 9307 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E; |
| 1853 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c.E; | 9308 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E; |
| 1854 | pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) c.E; | 9309 | pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E; |
| 1855 | pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) c.E; | 9310 | pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E; |
| 1856 | 9311 | ||
| 1857 | pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{}; | 9312 | pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{}; |
| 1858 | pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) c.E; | 9313 | pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E; |
| 1859 | pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const c.timespec) c.E; | 9314 | pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E; |
| 1860 | pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) c.E; | 9315 | pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E; |
| 1861 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) c.E; | 9316 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E; |
| 1862 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) c.E; | 9317 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E; |
| 1863 | 9318 | ||
| 1864 | pub extern "c" fn pthread_rwlock_destroy(rwl: *c.pthread_rwlock_t) callconv(.C) c.E; | 9319 | pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E; |
| 1865 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E; | 9320 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E; |
| 1866 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E; | 9321 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E; |
| 1867 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E; | 9322 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E; |
| 1868 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E; | 9323 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E; |
| 1869 | pub extern "c" fn pthread_rwlock_unlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E; | 9324 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E; |
| 1870 | 9325 | ||
| 1871 | pub const pthread_t = *opaque {}; | 9326 | pub const pthread_t = *opaque {}; |
| 1872 | pub const FILE = opaque {}; | 9327 | pub const FILE = opaque {}; |
| 1873 | 9328 | ||
| 1874 | pub extern "c" fn dlopen(path: [*:0]const u8, mode: c_int) ?*anyopaque; | 9329 | pub extern "c" fn dlopen(path: [*:0]const u8, mode: RTLD) ?*anyopaque; |
| 1875 | pub extern "c" fn dlclose(handle: *anyopaque) c_int; | 9330 | pub extern "c" fn dlclose(handle: *anyopaque) c_int; |
| 1876 | pub extern "c" fn dlsym(handle: ?*anyopaque, symbol: [*:0]const u8) ?*anyopaque; | 9331 | pub extern "c" fn dlsym(handle: ?*anyopaque, symbol: [*:0]const u8) ?*anyopaque; |
| 1877 | pub extern "c" fn dlerror() ?[*:0]u8; | 9332 | pub extern "c" fn dlerror() ?[*:0]u8; |
| ... | @@ -1883,8 +9338,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int; | ... | @@ -1883,8 +9338,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int; |
| 1883 | 9338 | ||
| 1884 | pub extern "c" fn prctl(option: c_int, ...) c_int; | 9339 | pub extern "c" fn prctl(option: c_int, ...) c_int; |
| 1885 | 9340 | ||
| 1886 | pub extern "c" fn getrlimit(resource: c.rlimit_resource, rlim: *c.rlimit) c_int; | 9341 | pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int; |
| 1887 | pub extern "c" fn setrlimit(resource: c.rlimit_resource, rlim: *const c.rlimit) c_int; | 9342 | pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int; |
| 1888 | 9343 | ||
| 1889 | pub extern "c" fn fmemopen(noalias buf: ?*anyopaque, size: usize, noalias mode: [*:0]const u8) ?*FILE; | 9344 | pub extern "c" fn fmemopen(noalias buf: ?*anyopaque, size: usize, noalias mode: [*:0]const u8) ?*FILE; |
| 1890 | 9345 | ||
| ... | @@ -1895,6 +9350,8 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; | ... | @@ -1895,6 +9350,8 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; |
| 1895 | 9350 | ||
| 1896 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; | 9351 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; |
| 1897 | 9352 | ||
| 9353 | pub extern "c" fn getpid() pid_t; | ||
| 9354 | |||
| 1898 | /// These are implementation defined but share identical values in at least musl and glibc: | 9355 | /// These are implementation defined but share identical values in at least musl and glibc: |
| 1899 | /// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18 | 9356 | /// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18 |
| 1900 | /// - https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/bits/locale.h;h=0fcbb66114be5fef0577dc9047256eb508c45919;hb=c90cfce849d010474e8cccf3e5bff49a2c8b141f#l26 | 9357 | /// - https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/bits/locale.h;h=0fcbb66114be5fef0577dc9047256eb508c45919;hb=c90cfce849d010474e8cccf3e5bff49a2c8b141f#l26 |
| ... | @@ -1918,13 +9375,11 @@ pub const LC = enum(c_int) { | ... | @@ -1918,13 +9375,11 @@ pub const LC = enum(c_int) { |
| 1918 | pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8; | 9375 | pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8; |
| 1919 | 9376 | ||
| 1920 | pub const getcontext = if (builtin.target.isAndroid()) | 9377 | pub const getcontext = if (builtin.target.isAndroid()) |
| 1921 | @compileError("android bionic libc does not implement getcontext") | 9378 | {} // android bionic libc does not implement getcontext |
| 1922 | else if (native_os == .linux and builtin.target.isMusl()) | 9379 | else if (native_os == .linux and builtin.target.isMusl()) |
| 1923 | linux.getcontext | 9380 | linux.getcontext |
| 1924 | else | 9381 | else |
| 1925 | struct { | 9382 | private.getcontext; |
| 1926 | extern fn getcontext(ucp: *std.posix.ucontext_t) c_int; | ||
| 1927 | }.getcontext; | ||
| 1928 | 9383 | ||
| 1929 | pub const max_align_t = if (native_abi == .msvc) | 9384 | pub const max_align_t = if (native_abi == .msvc) |
| 1930 | f64 | 9385 | f64 |
| ... | @@ -1936,49 +9391,374 @@ else | ... | @@ -1936,49 +9391,374 @@ else |
| 1936 | b: c_longdouble, | 9391 | b: c_longdouble, |
| 1937 | }; | 9392 | }; |
| 1938 | 9393 | ||
| 9394 | pub extern "c" fn pthread_getthreadid_np() c_int; | ||
| 9395 | pub extern "c" fn pthread_set_name_np(thread: pthread_t, name: [*:0]const u8) void; | ||
| 9396 | pub extern "c" fn pthread_get_name_np(thread: pthread_t, name: [*:0]u8, len: usize) void; | ||
| 9397 | |||
| 9398 | // OS-specific bits. These are protected from being used on the wrong OS by | ||
| 9399 | // comptime assertions inside each OS-specific file. | ||
| 9400 | |||
| 9401 | pub const AF_SUN = solaris.AF_SUN; | ||
| 9402 | pub const AT_SUN = solaris.AT_SUN; | ||
| 9403 | pub const FILE_EVENT = solaris.FILE_EVENT; | ||
| 9404 | pub const GETCONTEXT = solaris.GETCONTEXT; | ||
| 9405 | pub const GETUSTACK = solaris.GETUSTACK; | ||
| 9406 | pub const PORT_ALERT = solaris.PORT_ALERT; | ||
| 9407 | pub const PORT_SOURCE = solaris.PORT_SOURCE; | ||
| 9408 | pub const POSIX_FADV = solaris.POSIX_FADV; | ||
| 9409 | pub const SCM = solaris.SCM; | ||
| 9410 | pub const SETCONTEXT = solaris.SETCONTEXT; | ||
| 9411 | pub const SETUSTACK = solaris.GETUSTACK; | ||
| 9412 | pub const SFD = solaris.SFD; | ||
| 9413 | pub const _SC = solaris._SC; | ||
| 9414 | pub const cmsghdr = solaris.cmsghdr; | ||
| 9415 | pub const ctid_t = solaris.ctid_t; | ||
| 9416 | pub const file_obj = solaris.file_obj; | ||
| 9417 | pub const fpregset_t = solaris.fpregset_t; | ||
| 9418 | pub const id_t = solaris.id_t; | ||
| 9419 | pub const lif_ifinfo_req = solaris.lif_ifinfo_req; | ||
| 9420 | pub const lif_nd_req = solaris.lif_nd_req; | ||
| 9421 | pub const lifreq = solaris.lifreq; | ||
| 9422 | pub const major_t = solaris.major_t; | ||
| 9423 | pub const minor_t = solaris.minor_t; | ||
| 9424 | pub const poolid_t = solaris.poolid_t; | ||
| 9425 | pub const port_notify = solaris.port_notify; | ||
| 9426 | pub const priority = solaris.priority; | ||
| 9427 | pub const procfs = solaris.procfs; | ||
| 9428 | pub const projid_t = solaris.projid_t; | ||
| 9429 | pub const signalfd_siginfo = solaris.signalfd_siginfo; | ||
| 9430 | pub const sysconf = solaris.sysconf; | ||
| 9431 | pub const taskid_t = solaris.taskid_t; | ||
| 9432 | pub const zoneid_t = solaris.zoneid_t; | ||
| 9433 | |||
| 9434 | pub const DirEnt = haiku.DirEnt; | ||
| 9435 | pub const _get_next_area_info = haiku._get_next_area_info; | ||
| 9436 | pub const _get_next_image_info = haiku._get_next_image_info; | ||
| 9437 | pub const _get_team_info = haiku._get_team_info; | ||
| 9438 | pub const _kern_get_current_team = haiku._kern_get_current_team; | ||
| 9439 | pub const _kern_open_dir = haiku._kern_open_dir; | ||
| 9440 | pub const _kern_read_dir = haiku._kern_read_dir; | ||
| 9441 | pub const _kern_read_stat = haiku._kern_read_stat; | ||
| 9442 | pub const _kern_rewind_dir = haiku._kern_rewind_dir; | ||
| 9443 | pub const area_id = haiku.area_id; | ||
| 9444 | pub const area_info = haiku.area_info; | ||
| 9445 | pub const directory_which = haiku.directory_which; | ||
| 9446 | pub const find_directory = haiku.find_directory; | ||
| 9447 | pub const find_thread = haiku.find_thread; | ||
| 9448 | pub const get_system_info = haiku.get_system_info; | ||
| 9449 | pub const image_info = haiku.image_info; | ||
| 9450 | pub const port_id = haiku.port_id; | ||
| 9451 | pub const sem_id = haiku.sem_id; | ||
| 9452 | pub const status_t = haiku.status_t; | ||
| 9453 | pub const system_info = haiku.system_info; | ||
| 9454 | pub const team_id = haiku.team_id; | ||
| 9455 | pub const team_info = haiku.team_info; | ||
| 9456 | pub const thread_id = haiku.thread_id; | ||
| 9457 | pub const vregs = haiku.vregs; | ||
| 9458 | |||
| 9459 | pub const AUTH = openbsd.AUTH; | ||
| 9460 | pub const BI = openbsd.BI; | ||
| 9461 | pub const FUTEX = openbsd.FUTEX; | ||
| 9462 | pub const HW = openbsd.HW; | ||
| 9463 | pub const PTHREAD_STACK_MIN = openbsd.PTHREAD_STACK_MIN; | ||
| 9464 | pub const TCFLUSH = openbsd.TCFLUSH; | ||
| 9465 | pub const TCIO = openbsd.TCIO; | ||
| 9466 | pub const auth_approval = openbsd.auth_approval; | ||
| 9467 | pub const auth_call = openbsd.auth_call; | ||
| 9468 | pub const auth_cat = openbsd.auth_cat; | ||
| 9469 | pub const auth_challenge = openbsd.auth_challenge; | ||
| 9470 | pub const auth_check_change = openbsd.auth_check_change; | ||
| 9471 | pub const auth_check_expire = openbsd.auth_check_expire; | ||
| 9472 | pub const auth_checknologin = openbsd.auth_checknologin; | ||
| 9473 | pub const auth_clean = openbsd.auth_clean; | ||
| 9474 | pub const auth_close = openbsd.auth_close; | ||
| 9475 | pub const auth_clrenv = openbsd.auth_clrenv; | ||
| 9476 | pub const auth_clroption = openbsd.auth_clroption; | ||
| 9477 | pub const auth_clroptions = openbsd.auth_clroptions; | ||
| 9478 | pub const auth_getitem = openbsd.auth_getitem; | ||
| 9479 | pub const auth_getpwd = openbsd.auth_getpwd; | ||
| 9480 | pub const auth_getstate = openbsd.auth_getstate; | ||
| 9481 | pub const auth_getvalue = openbsd.auth_getvalue; | ||
| 9482 | pub const auth_item_t = openbsd.auth_item_t; | ||
| 9483 | pub const auth_mkvalue = openbsd.auth_mkvalue; | ||
| 9484 | pub const auth_open = openbsd.auth_open; | ||
| 9485 | pub const auth_session_t = openbsd.auth_session_t; | ||
| 9486 | pub const auth_setdata = openbsd.auth_setdata; | ||
| 9487 | pub const auth_setenv = openbsd.auth_setenv; | ||
| 9488 | pub const auth_setitem = openbsd.auth_setitem; | ||
| 9489 | pub const auth_setoption = openbsd.auth_setoption; | ||
| 9490 | pub const auth_setpwd = openbsd.auth_setpwd; | ||
| 9491 | pub const auth_setstate = openbsd.auth_setstate; | ||
| 9492 | pub const auth_userchallenge = openbsd.auth_userchallenge; | ||
| 9493 | pub const auth_usercheck = openbsd.auth_usercheck; | ||
| 9494 | pub const auth_userokay = openbsd.auth_userokay; | ||
| 9495 | pub const auth_userresponse = openbsd.auth_userresponse; | ||
| 9496 | pub const auth_verify = openbsd.auth_verify; | ||
| 9497 | pub const bcrypt = openbsd.bcrypt; | ||
| 9498 | pub const bcrypt_checkpass = openbsd.bcrypt_checkpass; | ||
| 9499 | pub const bcrypt_gensalt = openbsd.bcrypt_gensalt; | ||
| 9500 | pub const bcrypt_newhash = openbsd.bcrypt_newhash; | ||
| 9501 | pub const endpwent = openbsd.endpwent; | ||
| 9502 | pub const futex = openbsd.futex; | ||
| 9503 | pub const getpwent = openbsd.getpwent; | ||
| 9504 | pub const getpwnam_r = openbsd.getpwnam_r; | ||
| 9505 | pub const getpwnam_shadow = openbsd.getpwnam_shadow; | ||
| 9506 | pub const getpwuid_r = openbsd.getpwuid_r; | ||
| 9507 | pub const getpwuid_shadow = openbsd.getpwuid_shadow; | ||
| 9508 | pub const getthrid = openbsd.getthrid; | ||
| 9509 | pub const login_cap_t = openbsd.login_cap_t; | ||
| 9510 | pub const login_close = openbsd.login_close; | ||
| 9511 | pub const login_getcapbool = openbsd.login_getcapbool; | ||
| 9512 | pub const login_getcapnum = openbsd.login_getcapnum; | ||
| 9513 | pub const login_getcapsize = openbsd.login_getcapsize; | ||
| 9514 | pub const login_getcapstr = openbsd.login_getcapstr; | ||
| 9515 | pub const login_getcaptime = openbsd.login_getcaptime; | ||
| 9516 | pub const login_getclass = openbsd.login_getclass; | ||
| 9517 | pub const login_getstyle = openbsd.login_getstyle; | ||
| 9518 | pub const pledge = openbsd.pledge; | ||
| 9519 | pub const pthread_spinlock_t = openbsd.pthread_spinlock_t; | ||
| 9520 | pub const pw_dup = openbsd.pw_dup; | ||
| 9521 | pub const setclasscontext = openbsd.setclasscontext; | ||
| 9522 | pub const setpassent = openbsd.setpassent; | ||
| 9523 | pub const setpwent = openbsd.setpwent; | ||
| 9524 | pub const setusercontext = openbsd.setusercontext; | ||
| 9525 | pub const uid_from_user = openbsd.uid_from_user; | ||
| 9526 | pub const unveil = openbsd.unveil; | ||
| 9527 | pub const user_from_uid = openbsd.user_from_uid; | ||
| 9528 | |||
| 9529 | pub const CAP_RIGHTS_VERSION = freebsd.CAP_RIGHTS_VERSION; | ||
| 9530 | pub const KINFO_FILE_SIZE = freebsd.KINFO_FILE_SIZE; | ||
| 9531 | pub const MFD = freebsd.MFD; | ||
| 9532 | pub const UMTX_ABSTIME = freebsd.UMTX_ABSTIME; | ||
| 9533 | pub const UMTX_OP = freebsd.UMTX_OP; | ||
| 9534 | pub const _umtx_op = freebsd._umtx_op; | ||
| 9535 | pub const _umtx_time = freebsd._umtx_time; | ||
| 9536 | pub const cap_rights = freebsd.cap_rights; | ||
| 9537 | pub const fflags_t = freebsd.fflags_t; | ||
| 9538 | pub const fsblkcnt_t = freebsd.fsblkcnt_t; | ||
| 9539 | pub const fsfilcnt_t = freebsd.fsfilcnt_t; | ||
| 9540 | pub const kinfo_file = freebsd.kinfo_file; | ||
| 9541 | pub const kinfo_getfile = freebsd.kinfo_getfile; | ||
| 9542 | |||
| 9543 | pub const COPYFILE = darwin.COPYFILE; | ||
| 9544 | pub const CPUFAMILY = darwin.CPUFAMILY; | ||
| 9545 | pub const DB_RECORDTYPE = darwin.DB_RECORDTYPE; | ||
| 9546 | pub const EXC = darwin.EXC; | ||
| 9547 | pub const EXCEPTION = darwin.EXCEPTION; | ||
| 9548 | pub const MACH_MSG_TYPE = darwin.MACH_MSG_TYPE; | ||
| 9549 | pub const MACH_PORT_RIGHT = darwin.MACH_PORT_RIGHT; | ||
| 9550 | pub const MACH_TASK_BASIC_INFO = darwin.MACH_TASK_BASIC_INFO; | ||
| 9551 | pub const MACH_TASK_BASIC_INFO_COUNT = darwin.MACH_TASK_BASIC_INFO_COUNT; | ||
| 9552 | pub const MATTR = darwin.MATTR; | ||
| 9553 | pub const NSVersionOfRunTimeLibrary = darwin.NSVersionOfRunTimeLibrary; | ||
| 9554 | pub const OPEN_MAX = darwin.OPEN_MAX; | ||
| 9555 | pub const POSIX_SPAWN = darwin.POSIX_SPAWN; | ||
| 9556 | pub const TASK_NULL = darwin.TASK_NULL; | ||
| 9557 | pub const TASK_VM_INFO = darwin.TASK_VM_INFO; | ||
| 9558 | pub const TASK_VM_INFO_COUNT = darwin.TASK_VM_INFO_COUNT; | ||
| 9559 | pub const THREAD_BASIC_INFO = darwin.THREAD_BASIC_INFO; | ||
| 9560 | pub const THREAD_BASIC_INFO_COUNT = darwin.THREAD_BASIC_INFO_COUNT; | ||
| 9561 | pub const THREAD_IDENTIFIER_INFO_COUNT = darwin.THREAD_IDENTIFIER_INFO_COUNT; | ||
| 9562 | pub const THREAD_NULL = darwin.THREAD_NULL; | ||
| 9563 | pub const THREAD_STATE_NONE = darwin.THREAD_STATE_NONE; | ||
| 9564 | pub const UL = darwin.UL; | ||
| 9565 | pub const VM = darwin.VM; | ||
| 9566 | pub const _NSGetExecutablePath = darwin._NSGetExecutablePath; | ||
| 9567 | pub const __getdirentries64 = darwin.__getdirentries64; | ||
| 9568 | pub const __ulock_wait = darwin.__ulock_wait; | ||
| 9569 | pub const __ulock_wait2 = darwin.__ulock_wait2; | ||
| 9570 | pub const __ulock_wake = darwin.__ulock_wake; | ||
| 9571 | pub const _dyld_get_image_header = darwin._dyld_get_image_header; | ||
| 9572 | pub const _dyld_get_image_name = darwin._dyld_get_image_name; | ||
| 9573 | pub const _dyld_get_image_vmaddr_slide = darwin._dyld_get_image_vmaddr_slide; | ||
| 9574 | pub const _dyld_image_count = darwin._dyld_image_count; | ||
| 9575 | pub const _host_page_size = darwin._host_page_size; | ||
| 9576 | pub const clock_get_time = darwin.clock_get_time; | ||
| 9577 | pub const dispatch_release = darwin.dispatch_release; | ||
| 9578 | pub const dispatch_semaphore_create = darwin.dispatch_semaphore_create; | ||
| 9579 | pub const dispatch_semaphore_signal = darwin.dispatch_semaphore_signal; | ||
| 9580 | pub const dispatch_semaphore_wait = darwin.dispatch_semaphore_wait; | ||
| 9581 | pub const dispatch_time = darwin.dispatch_time; | ||
| 9582 | pub const fcopyfile = darwin.fcopyfile; | ||
| 9583 | pub const kern_return_t = darwin.kern_return_t; | ||
| 9584 | pub const kevent64 = darwin.kevent64; | ||
| 9585 | pub const mach_absolute_time = darwin.mach_absolute_time; | ||
| 9586 | pub const mach_continuous_time = darwin.mach_continuous_time; | ||
| 9587 | pub const mach_hdr = darwin.mach_hdr; | ||
| 9588 | pub const mach_host_self = darwin.mach_host_self; | ||
| 9589 | pub const mach_msg = darwin.mach_msg; | ||
| 9590 | pub const mach_msg_type_number_t = darwin.mach_msg_type_number_t; | ||
| 9591 | pub const mach_port_allocate = darwin.mach_port_allocate; | ||
| 9592 | pub const mach_port_array_t = darwin.mach_port_array_t; | ||
| 9593 | pub const mach_port_deallocate = darwin.mach_port_deallocate; | ||
| 9594 | pub const mach_port_insert_right = darwin.mach_port_insert_right; | ||
| 9595 | pub const mach_port_name_t = darwin.mach_port_name_t; | ||
| 9596 | pub const mach_port_t = darwin.mach_port_t; | ||
| 9597 | pub const mach_task_basic_info = darwin.mach_task_basic_info; | ||
| 9598 | pub const mach_task_self = darwin.mach_task_self; | ||
| 9599 | pub const mach_timebase_info = darwin.mach_timebase_info; | ||
| 9600 | pub const mach_vm_protect = darwin.mach_vm_protect; | ||
| 9601 | pub const mach_vm_read = darwin.mach_vm_read; | ||
| 9602 | pub const mach_vm_region = darwin.mach_vm_region; | ||
| 9603 | pub const mach_vm_region_recurse = darwin.mach_vm_region_recurse; | ||
| 9604 | pub const mach_vm_write = darwin.mach_vm_write; | ||
| 9605 | pub const os_log_create = darwin.os_log_create; | ||
| 9606 | pub const os_log_type_enabled = darwin.os_log_type_enabled; | ||
| 9607 | pub const os_signpost_enabled = darwin.os_signpost_enabled; | ||
| 9608 | pub const os_signpost_id_generate = darwin.os_signpost_id_generate; | ||
| 9609 | pub const os_signpost_id_make_with_pointer = darwin.os_signpost_id_make_with_pointer; | ||
| 9610 | pub const os_signpost_interval_begin = darwin.os_signpost_interval_begin; | ||
| 9611 | pub const os_signpost_interval_end = darwin.os_signpost_interval_end; | ||
| 9612 | pub const os_unfair_lock = darwin.os_unfair_lock; | ||
| 9613 | pub const os_unfair_lock_assert_not_owner = darwin.os_unfair_lock_assert_not_owner; | ||
| 9614 | pub const os_unfair_lock_assert_owner = darwin.os_unfair_lock_assert_owner; | ||
| 9615 | pub const os_unfair_lock_lock = darwin.os_unfair_lock_lock; | ||
| 9616 | pub const os_unfair_lock_trylock = darwin.os_unfair_lock_trylock; | ||
| 9617 | pub const os_unfair_lock_unlock = darwin.os_unfair_lock_unlock; | ||
| 9618 | pub const pid_for_task = darwin.pid_for_task; | ||
| 9619 | pub const posix_spawn = darwin.posix_spawn; | ||
| 9620 | pub const posix_spawn_file_actions_addchdir_np = darwin.posix_spawn_file_actions_addchdir_np; | ||
| 9621 | pub const posix_spawn_file_actions_addclose = darwin.posix_spawn_file_actions_addclose; | ||
| 9622 | pub const posix_spawn_file_actions_adddup2 = darwin.posix_spawn_file_actions_adddup2; | ||
| 9623 | pub const posix_spawn_file_actions_addfchdir_np = darwin.posix_spawn_file_actions_addfchdir_np; | ||
| 9624 | pub const posix_spawn_file_actions_addinherit_np = darwin.posix_spawn_file_actions_addinherit_np; | ||
| 9625 | pub const posix_spawn_file_actions_addopen = darwin.posix_spawn_file_actions_addopen; | ||
| 9626 | pub const posix_spawn_file_actions_destroy = darwin.posix_spawn_file_actions_destroy; | ||
| 9627 | pub const posix_spawn_file_actions_init = darwin.posix_spawn_file_actions_init; | ||
| 9628 | pub const posix_spawn_file_actions_t = darwin.posix_spawn_file_actions_t; | ||
| 9629 | pub const posix_spawnattr_destroy = darwin.posix_spawnattr_destroy; | ||
| 9630 | pub const posix_spawnattr_getflags = darwin.posix_spawnattr_getflags; | ||
| 9631 | pub const posix_spawnattr_init = darwin.posix_spawnattr_init; | ||
| 9632 | pub const posix_spawnattr_setflags = darwin.posix_spawnattr_setflags; | ||
| 9633 | pub const posix_spawnattr_t = darwin.posix_spawnattr_t; | ||
| 9634 | pub const posix_spawnp = darwin.posix_spawnp; | ||
| 9635 | pub const pthread_attr_get_qos_class_np = darwin.pthread_attr_get_qos_class_np; | ||
| 9636 | pub const pthread_attr_set_qos_class_np = darwin.pthread_attr_set_qos_class_np; | ||
| 9637 | pub const pthread_get_qos_class_np = darwin.pthread_get_qos_class_np; | ||
| 9638 | pub const pthread_set_qos_class_self_np = darwin.pthread_set_qos_class_self_np; | ||
| 9639 | pub const ptrace = darwin.ptrace; | ||
| 9640 | pub const sigaddset = darwin.sigaddset; | ||
| 9641 | pub const task_for_pid = darwin.task_for_pid; | ||
| 9642 | pub const task_get_exception_ports = darwin.task_get_exception_ports; | ||
| 9643 | pub const task_info = darwin.task_info; | ||
| 9644 | pub const task_info_t = darwin.task_info_t; | ||
| 9645 | pub const task_resume = darwin.task_resume; | ||
| 9646 | pub const task_set_exception_ports = darwin.task_set_exception_ports; | ||
| 9647 | pub const task_suspend = darwin.task_suspend; | ||
| 9648 | pub const task_threads = darwin.task_threads; | ||
| 9649 | pub const task_vm_info_data_t = darwin.task_vm_info_data_t; | ||
| 9650 | pub const thread_basic_info = darwin.thread_basic_info; | ||
| 9651 | pub const thread_get_state = darwin.thread_get_state; | ||
| 9652 | pub const thread_identifier_info = darwin.thread_identifier_info; | ||
| 9653 | pub const thread_info = darwin.thread_info; | ||
| 9654 | pub const thread_info_t = darwin.thread_info_t; | ||
| 9655 | pub const thread_resume = darwin.thread_resume; | ||
| 9656 | pub const thread_set_state = darwin.thread_set_state; | ||
| 9657 | pub const vm_deallocate = darwin.vm_deallocate; | ||
| 9658 | pub const vm_machine_attribute = darwin.vm_machine_attribute; | ||
| 9659 | pub const vm_machine_attribute_val_t = darwin.vm_machine_attribute_val_t; | ||
| 9660 | pub const vm_offset_t = darwin.vm_offset_t; | ||
| 9661 | pub const vm_prot_t = darwin.vm_prot_t; | ||
| 9662 | pub const vm_region_basic_info_64 = darwin.vm_region_basic_info_64; | ||
| 9663 | pub const vm_region_extended_info = darwin.vm_region_extended_info; | ||
| 9664 | pub const vm_region_info_t = darwin.vm_region_info_t; | ||
| 9665 | pub const vm_region_recurse_info_t = darwin.vm_region_recurse_info_t; | ||
| 9666 | pub const vm_region_submap_info_64 = darwin.vm_region_submap_info_64; | ||
| 9667 | pub const vm_region_submap_short_info_64 = darwin.vm_region_submap_short_info_64; | ||
| 9668 | pub const vm_region_top_info = darwin.vm_region_top_info; | ||
| 9669 | |||
| 9670 | pub const _ksiginfo = netbsd._ksiginfo; | ||
| 9671 | pub const _lwp_self = netbsd._lwp_self; | ||
| 9672 | pub const lwpid_t = netbsd.lwpid_t; | ||
| 9673 | |||
| 9674 | /// External definitions shared by two or more operating systems. | ||
| 1939 | const private = struct { | 9675 | const private = struct { |
| 1940 | extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int; | 9676 | extern "c" fn close(fd: fd_t) c_int; |
| 1941 | extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int; | 9677 | extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int; |
| 1942 | extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int; | 9678 | extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int; |
| 1943 | extern "c" fn fstatat(dirfd: c.fd_t, path: [*:0]const u8, buf: *c.Stat, flag: u32) c_int; | 9679 | extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: c_uint) isize; |
| 1944 | extern "c" fn getdirentries(fd: c.fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; | 9680 | extern "c" fn flock(fd: fd_t, operation: c_int) c_int; |
| 1945 | extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int; | 9681 | extern "c" fn fork() c_int; |
| 1946 | extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int; | 9682 | extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; |
| 9683 | extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int; | ||
| 9684 | extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; | ||
| 9685 | extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) switch (native_os) { | ||
| 9686 | .freebsd, .kfreebsd => isize, | ||
| 9687 | .solaris, .illumos => usize, | ||
| 9688 | else => c_int, | ||
| 9689 | }; | ||
| 9690 | extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 9691 | extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | ||
| 1947 | extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; | 9692 | extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; |
| 1948 | extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int; | 9693 | extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 1949 | extern "c" fn readdir(dir: *c.DIR) ?*c.dirent; | 9694 | extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int; |
| 9695 | extern "c" fn readdir(dir: *DIR) ?*dirent; | ||
| 1950 | extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 9696 | extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 1951 | extern "c" fn sched_yield() c_int; | 9697 | extern "c" fn sched_yield() c_int; |
| 1952 | extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int; | 9698 | extern "c" fn sendfile(out_fd: fd_t, in_fd: fd_t, offset: ?*off_t, count: usize) isize; |
| 1953 | extern "c" fn sigfillset(set: ?*c.sigset_t) void; | 9699 | extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 1954 | extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int; | 9700 | extern "c" fn sigfillset(set: ?*sigset_t) void; |
| 9701 | extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | ||
| 1955 | extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | 9702 | extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 1956 | extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int; | 9703 | extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; |
| 9704 | extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 9705 | |||
| 9706 | extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int; | ||
| 9707 | extern "c" fn getcontext(ucp: *ucontext_t) c_int; | ||
| 9708 | |||
| 9709 | extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | ||
| 9710 | extern "c" fn getentropy(buffer: [*]u8, size: usize) c_int; | ||
| 9711 | extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ||
| 9712 | |||
| 9713 | extern "c" fn _msize(memblock: ?*anyopaque) usize; | ||
| 9714 | extern "c" fn malloc_size(?*const anyopaque) usize; | ||
| 9715 | extern "c" fn malloc_usable_size(?*const anyopaque) usize; | ||
| 9716 | extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 1957 | 9717 | ||
| 1958 | /// macos modernized symbols. | 9718 | /// macos modernized symbols. |
| 1959 | /// x86_64 links to $INODE64 suffix for 64-bit support. | 9719 | /// x86_64 links to $INODE64 suffix for 64-bit support. |
| 1960 | /// Note these are not necessary on aarch64. | 9720 | /// Note these are not necessary on aarch64. |
| 1961 | extern "c" fn @"fstat$INODE64"(fd: c.fd_t, buf: *c.Stat) c_int; | 9721 | extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int; |
| 1962 | extern "c" fn @"fstatat$INODE64"(dirfd: c.fd_t, path: [*:0]const u8, buf: *c.Stat, flag: u32) c_int; | 9722 | extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int; |
| 1963 | extern "c" fn @"readdir$INODE64"(dir: *c.DIR) ?*c.dirent; | 9723 | extern "c" fn @"readdir$INODE64"(dir: *DIR) ?*dirent; |
| 1964 | extern "c" fn @"stat$INODE64"(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int; | 9724 | extern "c" fn @"stat$INODE64"(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; |
| 1965 | 9725 | ||
| 1966 | /// macos modernized symbols. | 9726 | /// macos modernized symbols. |
| 1967 | extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 9727 | extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 1968 | extern "c" fn __getdirentries64(fd: c.fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; | 9728 | extern "c" fn __getdirentries64(fd: fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; |
| 9729 | |||
| 9730 | extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int; | ||
| 1969 | 9731 | ||
| 1970 | /// netbsd modernized symbols. | 9732 | /// netbsd modernized symbols. |
| 1971 | extern "c" fn __clock_getres50(clk_id: c_int, tp: *c.timespec) c_int; | 9733 | extern "c" fn __clock_getres50(clk_id: clockid_t, tp: *timespec) c_int; |
| 1972 | extern "c" fn __clock_gettime50(clk_id: c_int, tp: *c.timespec) c_int; | 9734 | extern "c" fn __clock_gettime50(clk_id: clockid_t, tp: *timespec) c_int; |
| 1973 | extern "c" fn __fstat50(fd: c.fd_t, buf: *c.Stat) c_int; | 9735 | extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int; |
| 1974 | extern "c" fn __getrusage50(who: c_int, usage: *c.rusage) c_int; | 9736 | extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int; |
| 1975 | extern "c" fn __gettimeofday50(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int; | 9737 | extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| 1976 | extern "c" fn __libc_thr_yield() c_int; | 9738 | extern "c" fn __libc_thr_yield() c_int; |
| 1977 | extern "c" fn __msync13(addr: *align(std.mem.page_size) const anyopaque, len: usize, flags: c_int) c_int; | 9739 | extern "c" fn __msync13(addr: *align(std.mem.page_size) const anyopaque, len: usize, flags: c_int) c_int; |
| 1978 | extern "c" fn __nanosleep50(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int; | 9740 | extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 1979 | extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int; | 9741 | extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 1980 | extern "c" fn __sigfillset14(set: ?*c.sigset_t) void; | 9742 | extern "c" fn __sigfillset14(set: ?*sigset_t) void; |
| 1981 | extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int; | 9743 | extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 1982 | extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | 9744 | extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 1983 | extern "c" fn __stat50(path: [*:0]const u8, buf: *c.Stat) c_int; | 9745 | extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int; |
| 9746 | extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | ||
| 9747 | extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 9748 | |||
| 9749 | // Don't forget to add another clown when an OS picks yet another unique | ||
| 9750 | // symbol name for errno location! | ||
| 9751 | // 🤡🤡🤡🤡🤡🤡 | ||
| 9752 | |||
| 9753 | extern "c" fn ___errno() *c_int; | ||
| 9754 | extern "c" fn __errno() *c_int; | ||
| 9755 | extern "c" fn __errno_location() *c_int; | ||
| 9756 | extern "c" fn __error() *c_int; | ||
| 9757 | extern "c" fn _errno() *c_int; | ||
| 9758 | |||
| 9759 | extern threadlocal var errno: c_int; | ||
| 9760 | |||
| 9761 | fn errnoFromThreadLocal() *c_int { | ||
| 9762 | return &errno; | ||
| 9763 | } | ||
| 1984 | }; | 9764 | }; |
lib/std/c/darwin.zig+558-2387| ... | @@ -1,24 +1,30 @@ | ... | @@ -1,24 +1,30 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const assert = std.debug.assert; | ||
| 4 | const macho = std.macho; | ||
| 5 | const native_arch = builtin.target.cpu.arch; | 3 | const native_arch = builtin.target.cpu.arch; |
| 6 | const maxInt = std.math.maxInt; | 4 | const assert = std.debug.assert; |
| 5 | const AF = std.c.AF; | ||
| 6 | const PROT = std.c.PROT; | ||
| 7 | const fd_t = std.c.fd_t; | ||
| 7 | const iovec_const = std.posix.iovec_const; | 8 | const iovec_const = std.posix.iovec_const; |
| 9 | const mode_t = std.c.mode_t; | ||
| 10 | const off_t = std.c.off_t; | ||
| 11 | const pid_t = std.c.pid_t; | ||
| 12 | const pthread_attr_t = std.c.pthread_attr_t; | ||
| 13 | const sigset_t = std.c.segset_t; | ||
| 14 | const timespec = std.c.timespec; | ||
| 15 | const sf_hdtr = std.c.sf_hdtr; | ||
| 16 | |||
| 17 | comptime { | ||
| 18 | assert(builtin.os.tag.isDarwin()); // Prevent access of std.c symbols on wrong OS. | ||
| 19 | } | ||
| 8 | 20 | ||
| 9 | pub const aarch64 = @import("darwin/aarch64.zig"); | 21 | pub const mach_port_t = c_uint; |
| 10 | pub const x86_64 = @import("darwin/x86_64.zig"); | ||
| 11 | pub const cssm = @import("darwin/cssm.zig"); | ||
| 12 | 22 | ||
| 13 | const arch_bits = switch (native_arch) { | 23 | pub const THREAD_STATE_NONE = switch (native_arch) { |
| 14 | .aarch64 => @import("darwin/aarch64.zig"), | 24 | .aarch64 => 5, |
| 15 | .x86_64 => @import("darwin/x86_64.zig"), | 25 | .x86_64 => 13, |
| 16 | else => struct {}, | ||
| 17 | }; | 26 | }; |
| 18 | 27 | ||
| 19 | pub const EXC_TYPES_COUNT = arch_bits.EXC_TYPES_COUNT; | ||
| 20 | pub const THREAD_STATE_NONE = arch_bits.THREAD_STATE_NONE; | ||
| 21 | |||
| 22 | pub const EXC = enum(exception_type_t) { | 28 | pub const EXC = enum(exception_type_t) { |
| 23 | NULL = 0, | 29 | NULL = 0, |
| 24 | /// Could not access memory | 30 | /// Could not access memory |
| ... | @@ -47,49 +53,61 @@ pub const EXC = enum(exception_type_t) { | ... | @@ -47,49 +53,61 @@ pub const EXC = enum(exception_type_t) { |
| 47 | GUARD = 12, | 53 | GUARD = 12, |
| 48 | /// Abnormal process exited to corpse state | 54 | /// Abnormal process exited to corpse state |
| 49 | CORPSE_NOTIFY = 13, | 55 | CORPSE_NOTIFY = 13, |
| 56 | |||
| 57 | pub const TYPES_COUNT = @typeInfo(EXC).Enum.fields.len; | ||
| 58 | pub const SOFT_SIGNAL = 0x10003; | ||
| 59 | |||
| 60 | pub const MASK = packed struct(u32) { | ||
| 61 | BAD_ACCESS: bool = false, | ||
| 62 | BAD_INSTRUCTION: bool = false, | ||
| 63 | ARITHMETIC: bool = false, | ||
| 64 | EMULATION: bool = false, | ||
| 65 | SOFTWARE: bool = false, | ||
| 66 | BREAKPOINT: bool = false, | ||
| 67 | SYSCALL: bool = false, | ||
| 68 | MACH_SYSCALL: bool = false, | ||
| 69 | RPC_ALERT: bool = false, | ||
| 70 | CRASH: bool = false, | ||
| 71 | RESOURCE: bool = false, | ||
| 72 | GUARD: bool = false, | ||
| 73 | CORPSE_NOTIFY: bool = false, | ||
| 74 | |||
| 75 | pub const MACHINE: MASK = @bitCast(@as(u32, 0)); | ||
| 76 | |||
| 77 | pub const ALL: MASK = .{ | ||
| 78 | .BAD_ACCESS = true, | ||
| 79 | .BAD_INSTRUCTION = true, | ||
| 80 | .ARITHMETIC = true, | ||
| 81 | .EMULATION = true, | ||
| 82 | .SOFTWARE = true, | ||
| 83 | .BREAKPOINT = true, | ||
| 84 | .SYSCALL = true, | ||
| 85 | .MACH_SYSCALL = true, | ||
| 86 | .RPC_ALERT = true, | ||
| 87 | .CRASH = true, | ||
| 88 | .RESOURCE = true, | ||
| 89 | .GUARD = true, | ||
| 90 | .CORPSE_NOTIFY = true, | ||
| 91 | }; | ||
| 92 | }; | ||
| 93 | }; | ||
| 94 | |||
| 95 | pub const EXCEPTION = enum(u32) { | ||
| 96 | /// Send a catch_exception_raise message including the identity. | ||
| 97 | DEFAULT = 1, | ||
| 98 | /// Send a catch_exception_raise_state message including the | ||
| 99 | /// thread state. | ||
| 100 | STATE = 2, | ||
| 101 | /// Send a catch_exception_raise_state_identity message including | ||
| 102 | /// the thread identity and state. | ||
| 103 | STATE_IDENTITY = 3, | ||
| 104 | /// Send a catch_exception_raise_identity_protected message including protected task | ||
| 105 | /// and thread identity. | ||
| 106 | IDENTITY_PROTECTED = 4, | ||
| 107 | |||
| 108 | _, | ||
| 50 | }; | 109 | }; |
| 51 | 110 | ||
| 52 | pub const EXC_SOFT_SIGNAL = 0x10003; | ||
| 53 | |||
| 54 | pub const EXC_MASK_BAD_ACCESS = 1 << @intFromEnum(EXC.BAD_ACCESS); | ||
| 55 | pub const EXC_MASK_BAD_INSTRUCTION = 1 << @intFromEnum(EXC.BAD_INSTRUCTION); | ||
| 56 | pub const EXC_MASK_ARITHMETIC = 1 << @intFromEnum(EXC.ARITHMETIC); | ||
| 57 | pub const EXC_MASK_EMULATION = 1 << @intFromEnum(EXC.EMULATION); | ||
| 58 | pub const EXC_MASK_SOFTWARE = 1 << @intFromEnum(EXC.SOFTWARE); | ||
| 59 | pub const EXC_MASK_BREAKPOINT = 1 << @intFromEnum(EXC.BREAKPOINT); | ||
| 60 | pub const EXC_MASK_SYSCALL = 1 << @intFromEnum(EXC.SYSCALL); | ||
| 61 | pub const EXC_MASK_MACH_SYSCALL = 1 << @intFromEnum(EXC.MACH_SYSCALL); | ||
| 62 | pub const EXC_MASK_RPC_ALERT = 1 << @intFromEnum(EXC.RPC_ALERT); | ||
| 63 | pub const EXC_MASK_CRASH = 1 << @intFromEnum(EXC.CRASH); | ||
| 64 | pub const EXC_MASK_RESOURCE = 1 << @intFromEnum(EXC.RESOURCE); | ||
| 65 | pub const EXC_MASK_GUARD = 1 << @intFromEnum(EXC.GUARD); | ||
| 66 | pub const EXC_MASK_CORPSE_NOTIFY = 1 << @intFromEnum(EXC.CORPSE_NOTIFY); | ||
| 67 | pub const EXC_MASK_MACHINE = arch_bits.EXC_MASK_MACHINE; | ||
| 68 | |||
| 69 | pub const EXC_MASK_ALL = EXC_MASK_BAD_ACCESS | | ||
| 70 | EXC_MASK_BAD_INSTRUCTION | | ||
| 71 | EXC_MASK_ARITHMETIC | | ||
| 72 | EXC_MASK_EMULATION | | ||
| 73 | EXC_MASK_SOFTWARE | | ||
| 74 | EXC_MASK_BREAKPOINT | | ||
| 75 | EXC_MASK_SYSCALL | | ||
| 76 | EXC_MASK_MACH_SYSCALL | | ||
| 77 | EXC_MASK_RPC_ALERT | | ||
| 78 | EXC_MASK_RESOURCE | | ||
| 79 | EXC_MASK_GUARD | | ||
| 80 | EXC_MASK_MACHINE; | ||
| 81 | |||
| 82 | /// Send a catch_exception_raise message including the identity. | ||
| 83 | pub const EXCEPTION_DEFAULT = 1; | ||
| 84 | /// Send a catch_exception_raise_state message including the | ||
| 85 | /// thread state. | ||
| 86 | pub const EXCEPTION_STATE = 2; | ||
| 87 | /// Send a catch_exception_raise_state_identity message including | ||
| 88 | /// the thread identity and state. | ||
| 89 | pub const EXCEPTION_STATE_IDENTITY = 3; | ||
| 90 | /// Send a catch_exception_raise_identity_protected message including protected task | ||
| 91 | /// and thread identity. | ||
| 92 | pub const EXCEPTION_IDENTITY_PROTECTED = 4; | ||
| 93 | /// Prefer sending a catch_exception_raice_backtrace message, if applicable. | 111 | /// Prefer sending a catch_exception_raice_backtrace message, if applicable. |
| 94 | pub const MACH_EXCEPTION_BACKTRACE_PREFERRED = 0x20000000; | 112 | pub const MACH_EXCEPTION_BACKTRACE_PREFERRED = 0x20000000; |
| 95 | /// include additional exception specific errors, not used yet. | 113 | /// include additional exception specific errors, not used yet. |
| ... | @@ -141,19 +159,109 @@ pub const MACH_RCV_SYNC_PEEK = 0x00008000; | ... | @@ -141,19 +159,109 @@ pub const MACH_RCV_SYNC_PEEK = 0x00008000; |
| 141 | 159 | ||
| 142 | pub const MACH_MSG_STRICT_REPLY = 0x00000200; | 160 | pub const MACH_MSG_STRICT_REPLY = 0x00000200; |
| 143 | 161 | ||
| 144 | pub const ucontext_t = extern struct { | 162 | pub const exception_type_t = c_int; |
| 145 | onstack: c_int, | 163 | |
| 146 | sigmask: sigset_t, | 164 | pub const mcontext_t = switch (native_arch) { |
| 147 | stack: stack_t, | 165 | .aarch64 => extern struct { |
| 148 | link: ?*ucontext_t, | 166 | es: exception_state, |
| 149 | mcsize: u64, | 167 | ss: thread_state, |
| 150 | mcontext: *mcontext_t, | 168 | ns: neon_state, |
| 151 | __mcontext_data: mcontext_t, | 169 | }, |
| 170 | .x86_64 => extern struct { | ||
| 171 | es: exception_state, | ||
| 172 | ss: thread_state, | ||
| 173 | fs: float_state, | ||
| 174 | }, | ||
| 175 | else => @compileError("unsupported arch"), | ||
| 152 | }; | 176 | }; |
| 153 | 177 | ||
| 154 | pub const mcontext_t = arch_bits.mcontext_t; | 178 | pub const exception_state = switch (native_arch) { |
| 179 | .aarch64 => extern struct { | ||
| 180 | far: u64, // Virtual Fault Address | ||
| 181 | esr: u32, // Exception syndrome | ||
| 182 | exception: u32, // Number of arm exception taken | ||
| 183 | }, | ||
| 184 | .x86_64 => extern struct { | ||
| 185 | trapno: u16, | ||
| 186 | cpu: u16, | ||
| 187 | err: u32, | ||
| 188 | faultvaddr: u64, | ||
| 189 | }, | ||
| 190 | else => @compileError("unsupported arch"), | ||
| 191 | }; | ||
| 192 | |||
| 193 | pub const thread_state = switch (native_arch) { | ||
| 194 | .aarch64 => extern struct { | ||
| 195 | /// General purpose registers | ||
| 196 | regs: [29]u64, | ||
| 197 | /// Frame pointer x29 | ||
| 198 | fp: u64, | ||
| 199 | /// Link register x30 | ||
| 200 | lr: u64, | ||
| 201 | /// Stack pointer x31 | ||
| 202 | sp: u64, | ||
| 203 | /// Program counter | ||
| 204 | pc: u64, | ||
| 205 | /// Current program status register | ||
| 206 | cpsr: u32, | ||
| 207 | __pad: u32, | ||
| 208 | }, | ||
| 209 | .x86_64 => extern struct { | ||
| 210 | rax: u64, | ||
| 211 | rbx: u64, | ||
| 212 | rcx: u64, | ||
| 213 | rdx: u64, | ||
| 214 | rdi: u64, | ||
| 215 | rsi: u64, | ||
| 216 | rbp: u64, | ||
| 217 | rsp: u64, | ||
| 218 | r8: u64, | ||
| 219 | r9: u64, | ||
| 220 | r10: u64, | ||
| 221 | r11: u64, | ||
| 222 | r12: u64, | ||
| 223 | r13: u64, | ||
| 224 | r14: u64, | ||
| 225 | r15: u64, | ||
| 226 | rip: u64, | ||
| 227 | rflags: u64, | ||
| 228 | cs: u64, | ||
| 229 | fs: u64, | ||
| 230 | gs: u64, | ||
| 231 | }, | ||
| 232 | else => @compileError("unsupported arch"), | ||
| 233 | }; | ||
| 234 | |||
| 235 | pub const neon_state = extern struct { | ||
| 236 | q: [32]u128, | ||
| 237 | fpsr: u32, | ||
| 238 | fpcr: u32, | ||
| 239 | }; | ||
| 240 | |||
| 241 | pub const float_state = extern struct { | ||
| 242 | reserved: [2]c_int, | ||
| 243 | fcw: u16, | ||
| 244 | fsw: u16, | ||
| 245 | ftw: u8, | ||
| 246 | rsrv1: u8, | ||
| 247 | fop: u16, | ||
| 248 | ip: u32, | ||
| 249 | cs: u16, | ||
| 250 | rsrv2: u16, | ||
| 251 | dp: u32, | ||
| 252 | ds: u16, | ||
| 253 | rsrv3: u16, | ||
| 254 | mxcsr: u32, | ||
| 255 | mxcsrmask: u32, | ||
| 256 | stmm: [8]stmm_reg, | ||
| 257 | xmm: [16]xmm_reg, | ||
| 258 | rsrv4: [96]u8, | ||
| 259 | reserved1: c_int, | ||
| 260 | }; | ||
| 261 | |||
| 262 | pub const stmm_reg = [16]u8; | ||
| 263 | pub const xmm_reg = [16]u8; | ||
| 155 | 264 | ||
| 156 | extern "c" fn __error() *c_int; | ||
| 157 | pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32; | 265 | pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32; |
| 158 | pub extern "c" fn _NSGetExecutablePath(buf: [*:0]u8, bufsize: *u32) c_int; | 266 | pub extern "c" fn _NSGetExecutablePath(buf: [*:0]u8, bufsize: *u32) c_int; |
| 159 | pub extern "c" fn _dyld_image_count() u32; | 267 | pub extern "c" fn _dyld_image_count() u32; |
| ... | @@ -161,23 +269,22 @@ pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header; | ... | @@ -161,23 +269,22 @@ pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header; |
| 161 | pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize; | 269 | pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize; |
| 162 | pub extern "c" fn _dyld_get_image_name(image_index: u32) [*:0]const u8; | 270 | pub extern "c" fn _dyld_get_image_name(image_index: u32) [*:0]const u8; |
| 163 | 271 | ||
| 164 | pub const COPYFILE_ACL = 1 << 0; | 272 | pub const COPYFILE = packed struct(u32) { |
| 165 | pub const COPYFILE_STAT = 1 << 1; | 273 | ACL: bool = false, |
| 166 | pub const COPYFILE_XATTR = 1 << 2; | 274 | STAT: bool = false, |
| 167 | pub const COPYFILE_DATA = 1 << 3; | 275 | XATTR: bool = false, |
| 276 | DATA: bool = false, | ||
| 277 | _: u28 = 0, | ||
| 278 | }; | ||
| 168 | 279 | ||
| 169 | pub const copyfile_state_t = *opaque {}; | 280 | pub const copyfile_state_t = *opaque {}; |
| 170 | pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int; | 281 | pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: COPYFILE) c_int; |
| 171 | |||
| 172 | pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; | 282 | pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; |
| 173 | 283 | ||
| 174 | pub extern "c" fn mach_absolute_time() u64; | 284 | pub extern "c" fn mach_absolute_time() u64; |
| 175 | pub extern "c" fn mach_continuous_time() u64; | 285 | pub extern "c" fn mach_continuous_time() u64; |
| 176 | pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) kern_return_t; | 286 | pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) kern_return_t; |
| 177 | 287 | ||
| 178 | pub extern "c" fn malloc_size(?*const anyopaque) usize; | ||
| 179 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 180 | |||
| 181 | pub extern "c" fn kevent64( | 288 | pub extern "c" fn kevent64( |
| 182 | kq: c_int, | 289 | kq: c_int, |
| 183 | changelist: [*]const kevent64_s, | 290 | changelist: [*]const kevent64_s, |
| ... | @@ -188,34 +295,15 @@ pub extern "c" fn kevent64( | ... | @@ -188,34 +295,15 @@ pub extern "c" fn kevent64( |
| 188 | timeout: ?*const timespec, | 295 | timeout: ?*const timespec, |
| 189 | ) c_int; | 296 | ) c_int; |
| 190 | 297 | ||
| 191 | const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header; | 298 | pub const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header; |
| 192 | |||
| 193 | /// The value of the link editor defined symbol _MH_EXECUTE_SYM is the address | ||
| 194 | /// of the mach header in a Mach-O executable file type. It does not appear in | ||
| 195 | /// any file type other than a MH_EXECUTE file type. The type of the symbol is | ||
| 196 | /// absolute as the header is not part of any section. | ||
| 197 | /// This symbol is populated when linking the system's libc, which is guaranteed | ||
| 198 | /// on this operating system. However when building object files or libraries, | ||
| 199 | /// the system libc won't be linked until the final executable. So we | ||
| 200 | /// export a weak symbol here, to be overridden by the real one. | ||
| 201 | var dummy_execute_header: mach_hdr = undefined; | ||
| 202 | pub extern var _mh_execute_header: mach_hdr; | ||
| 203 | comptime { | ||
| 204 | if (builtin.target.isDarwin()) { | ||
| 205 | @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | pub const mach_header_64 = macho.mach_header_64; | ||
| 210 | pub const mach_header = macho.mach_header; | ||
| 211 | 299 | ||
| 212 | pub const _errno = __error; | 300 | pub const mach_header_64 = std.macho.mach_header_64; |
| 301 | pub const mach_header = std.macho.mach_header; | ||
| 213 | 302 | ||
| 214 | pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int; | 303 | pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int; |
| 215 | pub extern "c" fn mach_host_self() mach_port_t; | 304 | pub extern "c" fn mach_host_self() mach_port_t; |
| 216 | pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t; | 305 | pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t; |
| 217 | 306 | ||
| 218 | pub const exception_type_t = c_int; | ||
| 219 | pub const exception_data_type_t = integer_t; | 307 | pub const exception_data_type_t = integer_t; |
| 220 | pub const exception_data_t = ?*mach_exception_data_type_t; | 308 | pub const exception_data_t = ?*mach_exception_data_type_t; |
| 221 | pub const mach_exception_data_type_t = i64; | 309 | pub const mach_exception_data_type_t = i64; |
| ... | @@ -267,31 +355,22 @@ pub const MACH_PORT_RIGHT = enum(mach_port_right_t) { | ... | @@ -267,31 +355,22 @@ pub const MACH_PORT_RIGHT = enum(mach_port_right_t) { |
| 267 | pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) { | 355 | pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) { |
| 268 | /// Must hold receive right | 356 | /// Must hold receive right |
| 269 | MOVE_RECEIVE = 16, | 357 | MOVE_RECEIVE = 16, |
| 270 | |||
| 271 | /// Must hold send right(s) | 358 | /// Must hold send right(s) |
| 272 | MOVE_SEND = 17, | 359 | MOVE_SEND = 17, |
| 273 | |||
| 274 | /// Must hold sendonce right | 360 | /// Must hold sendonce right |
| 275 | MOVE_SEND_ONCE = 18, | 361 | MOVE_SEND_ONCE = 18, |
| 276 | |||
| 277 | /// Must hold send right(s) | 362 | /// Must hold send right(s) |
| 278 | COPY_SEND = 19, | 363 | COPY_SEND = 19, |
| 279 | |||
| 280 | /// Must hold receive right | 364 | /// Must hold receive right |
| 281 | MAKE_SEND = 20, | 365 | MAKE_SEND = 20, |
| 282 | |||
| 283 | /// Must hold receive right | 366 | /// Must hold receive right |
| 284 | MAKE_SEND_ONCE = 21, | 367 | MAKE_SEND_ONCE = 21, |
| 285 | |||
| 286 | /// NOT VALID | 368 | /// NOT VALID |
| 287 | COPY_RECEIVE = 22, | 369 | COPY_RECEIVE = 22, |
| 288 | |||
| 289 | /// Must hold receive right | 370 | /// Must hold receive right |
| 290 | DISPOSE_RECEIVE = 24, | 371 | DISPOSE_RECEIVE = 24, |
| 291 | |||
| 292 | /// Must hold send right(s) | 372 | /// Must hold send right(s) |
| 293 | DISPOSE_SEND = 25, | 373 | DISPOSE_SEND = 25, |
| 294 | |||
| 295 | /// Must hold sendonce right | 374 | /// Must hold sendonce right |
| 296 | DISPOSE_SEND_ONCE = 26, | 375 | DISPOSE_SEND_ONCE = 26, |
| 297 | }; | 376 | }; |
| ... | @@ -381,38 +460,45 @@ pub const vm_behavior_t = i32; | ... | @@ -381,38 +460,45 @@ pub const vm_behavior_t = i32; |
| 381 | pub const vm32_object_id_t = u32; | 460 | pub const vm32_object_id_t = u32; |
| 382 | pub const vm_object_id_t = u64; | 461 | pub const vm_object_id_t = u64; |
| 383 | 462 | ||
| 384 | pub const VM_INHERIT_SHARE: vm_inherit_t = 0; | 463 | pub const VM = struct { |
| 385 | pub const VM_INHERIT_COPY: vm_inherit_t = 1; | 464 | pub const INHERIT = struct { |
| 386 | pub const VM_INHERIT_NONE: vm_inherit_t = 2; | 465 | pub const SHARE: vm_inherit_t = 0; |
| 387 | pub const VM_INHERIT_DONATE_COPY: vm_inherit_t = 3; | 466 | pub const COPY: vm_inherit_t = 1; |
| 388 | pub const VM_INHERIT_DEFAULT = VM_INHERIT_COPY; | 467 | pub const NONE: vm_inherit_t = 2; |
| 389 | 468 | pub const DONATE_COPY: vm_inherit_t = 3; | |
| 390 | pub const VM_BEHAVIOR_DEFAULT: vm_behavior_t = 0; | 469 | pub const DEFAULT = COPY; |
| 391 | pub const VM_BEHAVIOR_RANDOM: vm_behavior_t = 1; | 470 | }; |
| 392 | pub const VM_BEHAVIOR_SEQUENTIAL: vm_behavior_t = 2; | 471 | |
| 393 | pub const VM_BEHAVIOR_RSEQNTL: vm_behavior_t = 3; | 472 | pub const BEHAVIOR = struct { |
| 394 | 473 | pub const DEFAULT: vm_behavior_t = 0; | |
| 395 | pub const VM_BEHAVIOR_WILLNEED: vm_behavior_t = 4; | 474 | pub const RANDOM: vm_behavior_t = 1; |
| 396 | pub const VM_BEHAVIOR_DONTNEED: vm_behavior_t = 5; | 475 | pub const SEQUENTIAL: vm_behavior_t = 2; |
| 397 | pub const VM_BEHAVIOR_FREE: vm_behavior_t = 6; | 476 | pub const RSEQNTL: vm_behavior_t = 3; |
| 398 | pub const VM_BEHAVIOR_ZERO_WIRED_PAGES: vm_behavior_t = 7; | 477 | pub const WILLNEED: vm_behavior_t = 4; |
| 399 | pub const VM_BEHAVIOR_REUSABLE: vm_behavior_t = 8; | 478 | pub const DONTNEED: vm_behavior_t = 5; |
| 400 | pub const VM_BEHAVIOR_REUSE: vm_behavior_t = 9; | 479 | pub const FREE: vm_behavior_t = 6; |
| 401 | pub const VM_BEHAVIOR_CAN_REUSE: vm_behavior_t = 10; | 480 | pub const ZERO_WIRED_PAGES: vm_behavior_t = 7; |
| 402 | pub const VM_BEHAVIOR_PAGEOUT: vm_behavior_t = 11; | 481 | pub const REUSABLE: vm_behavior_t = 8; |
| 403 | 482 | pub const REUSE: vm_behavior_t = 9; | |
| 404 | pub const VM_REGION_BASIC_INFO_64 = 9; | 483 | pub const CAN_REUSE: vm_behavior_t = 10; |
| 405 | pub const VM_REGION_EXTENDED_INFO = 13; | 484 | pub const PAGEOUT: vm_behavior_t = 11; |
| 406 | pub const VM_REGION_TOP_INFO = 12; | 485 | }; |
| 407 | pub const VM_REGION_SUBMAP_INFO_COUNT_64: mach_msg_type_number_t = @sizeOf(vm_region_submap_info_64) / @sizeOf(natural_t); | 486 | |
| 408 | pub const VM_REGION_SUBMAP_SHORT_INFO_COUNT_64: mach_msg_type_number_t = @sizeOf(vm_region_submap_short_info_64) / @sizeOf(natural_t); | 487 | pub const REGION = struct { |
| 409 | pub const VM_REGION_BASIC_INFO_COUNT: mach_msg_type_number_t = @sizeOf(vm_region_basic_info_64) / @sizeOf(c_int); | 488 | pub const BASIC_INFO_64 = 9; |
| 410 | pub const VM_REGION_EXTENDED_INFO_COUNT: mach_msg_type_number_t = @sizeOf(vm_region_extended_info) / @sizeOf(natural_t); | 489 | pub const EXTENDED_INFO = 13; |
| 411 | pub const VM_REGION_TOP_INFO_COUNT: mach_msg_type_number_t = @sizeOf(vm_region_top_info) / @sizeOf(natural_t); | 490 | pub const TOP_INFO = 12; |
| 412 | 491 | pub const SUBMAP_INFO_COUNT_64: mach_msg_type_number_t = @sizeOf(vm_region_submap_info_64) / @sizeOf(natural_t); | |
| 413 | pub fn VM_MAKE_TAG(tag: u8) u32 { | 492 | pub const SUBMAP_SHORT_INFO_COUNT_64: mach_msg_type_number_t = @sizeOf(vm_region_submap_short_info_64) / @sizeOf(natural_t); |
| 414 | return @as(u32, tag) << 24; | 493 | pub const BASIC_INFO_COUNT: mach_msg_type_number_t = @sizeOf(vm_region_basic_info_64) / @sizeOf(c_int); |
| 415 | } | 494 | pub const EXTENDED_INFO_COUNT: mach_msg_type_number_t = @sizeOf(vm_region_extended_info) / @sizeOf(natural_t); |
| 495 | pub const TOP_INFO_COUNT: mach_msg_type_number_t = @sizeOf(vm_region_top_info) / @sizeOf(natural_t); | ||
| 496 | }; | ||
| 497 | |||
| 498 | pub fn MAKE_TAG(tag: u8) u32 { | ||
| 499 | return @as(u32, tag) << 24; | ||
| 500 | } | ||
| 501 | }; | ||
| 416 | 502 | ||
| 417 | pub const vm_region_basic_info_64 = extern struct { | 503 | pub const vm_region_basic_info_64 = extern struct { |
| 418 | protection: vm_prot_t, | 504 | protection: vm_prot_t, |
| ... | @@ -590,29 +676,30 @@ pub const thread_identifier_info = extern struct { | ... | @@ -590,29 +676,30 @@ pub const thread_identifier_info = extern struct { |
| 590 | dispatch_qaddr: u64, | 676 | dispatch_qaddr: u64, |
| 591 | }; | 677 | }; |
| 592 | 678 | ||
| 593 | /// Cachability | 679 | pub const MATTR = struct { |
| 594 | pub const MATTR_CACHE = 1; | 680 | /// Cachability |
| 595 | /// Migrability | 681 | pub const CACHE = 1; |
| 596 | pub const MATTR_MIGRATE = 2; | 682 | /// Migrability |
| 597 | /// Replicability | 683 | pub const MIGRATE = 2; |
| 598 | pub const MATTR_REPLICATE = 4; | 684 | /// Replicability |
| 599 | 685 | pub const REPLICATE = 4; | |
| 600 | /// (Generic) turn attribute off | 686 | /// (Generic) turn attribute off |
| 601 | pub const MATTR_VAL_OFF = 0; | 687 | pub const VAL_OFF = 0; |
| 602 | /// (Generic) turn attribute on | 688 | /// (Generic) turn attribute on |
| 603 | pub const MATTR_VAL_ON = 1; | 689 | pub const VAL_ON = 1; |
| 604 | /// (Generic) return current value | 690 | /// (Generic) return current value |
| 605 | pub const MATTR_VAL_GET = 2; | 691 | pub const VAL_GET = 2; |
| 606 | /// Flush from all caches | 692 | /// Flush from all caches |
| 607 | pub const MATTR_VAL_CACHE_FLUSH = 6; | 693 | pub const VAL_CACHE_FLUSH = 6; |
| 608 | /// Flush from data caches | 694 | /// Flush from data caches |
| 609 | pub const MATTR_VAL_DCACHE_FLUSH = 7; | 695 | pub const VAL_DCACHE_FLUSH = 7; |
| 610 | /// Flush from instruction caches | 696 | /// Flush from instruction caches |
| 611 | pub const MATTR_VAL_ICACHE_FLUSH = 8; | 697 | pub const VAL_ICACHE_FLUSH = 8; |
| 612 | /// Sync I+D caches | 698 | /// Sync I+D caches |
| 613 | pub const MATTR_VAL_CACHE_SYNC = 9; | 699 | pub const VAL_CACHE_SYNC = 9; |
| 614 | /// Get page info (stats) | 700 | /// Get page info (stats) |
| 615 | pub const MATTR_VAL_GET_INFO = 10; | 701 | pub const VAL_GET_INFO = 10; |
| 702 | }; | ||
| 616 | 703 | ||
| 617 | pub const TASK_VM_INFO = 22; | 704 | pub const TASK_VM_INFO = 22; |
| 618 | pub const TASK_VM_INFO_COUNT: mach_msg_type_number_t = @sizeOf(task_vm_info_data_t) / @sizeOf(natural_t); | 705 | pub const TASK_VM_INFO_COUNT: mach_msg_type_number_t = @sizeOf(task_vm_info_data_t) / @sizeOf(natural_t); |
| ... | @@ -679,6 +766,7 @@ pub const task_vm_info = extern struct { | ... | @@ -679,6 +766,7 @@ pub const task_vm_info = extern struct { |
| 679 | // added for rev5 | 766 | // added for rev5 |
| 680 | decompressions: integer_t, | 767 | decompressions: integer_t, |
| 681 | }; | 768 | }; |
| 769 | |||
| 682 | pub const task_vm_info_data_t = task_vm_info; | 770 | pub const task_vm_info_data_t = task_vm_info; |
| 683 | 771 | ||
| 684 | pub const vm_prot_t = c_int; | 772 | pub const vm_prot_t = c_int; |
| ... | @@ -715,19 +803,14 @@ pub extern "c" fn task_info( | ... | @@ -715,19 +803,14 @@ pub extern "c" fn task_info( |
| 715 | pub const mach_task_basic_info = extern struct { | 803 | pub const mach_task_basic_info = extern struct { |
| 716 | /// Virtual memory size (bytes) | 804 | /// Virtual memory size (bytes) |
| 717 | virtual_size: mach_vm_size_t, | 805 | virtual_size: mach_vm_size_t, |
| 718 | |||
| 719 | /// Resident memory size (bytes) | 806 | /// Resident memory size (bytes) |
| 720 | resident_size: mach_vm_size_t, | 807 | resident_size: mach_vm_size_t, |
| 721 | |||
| 722 | /// Total user run time for terminated threads | 808 | /// Total user run time for terminated threads |
| 723 | user_time: time_value_t, | 809 | user_time: time_value_t, |
| 724 | |||
| 725 | /// Total system run time for terminated threads | 810 | /// Total system run time for terminated threads |
| 726 | system_time: time_value_t, | 811 | system_time: time_value_t, |
| 727 | |||
| 728 | /// Default policy for new threads | 812 | /// Default policy for new threads |
| 729 | policy: policy_t, | 813 | policy: policy_t, |
| 730 | |||
| 731 | /// Suspend count for task | 814 | /// Suspend count for task |
| 732 | suspend_count: mach_vm_size_t, | 815 | suspend_count: mach_vm_size_t, |
| 733 | }; | 816 | }; |
| ... | @@ -745,13 +828,6 @@ pub extern "c" fn vm_machine_attribute( | ... | @@ -745,13 +828,6 @@ pub extern "c" fn vm_machine_attribute( |
| 745 | value: *vm_machine_attribute_val_t, | 828 | value: *vm_machine_attribute_val_t, |
| 746 | ) kern_return_t; | 829 | ) kern_return_t; |
| 747 | 830 | ||
| 748 | pub const sf_hdtr = extern struct { | ||
| 749 | headers: [*]const iovec_const, | ||
| 750 | hdr_cnt: c_int, | ||
| 751 | trailers: [*]const iovec_const, | ||
| 752 | trl_cnt: c_int, | ||
| 753 | }; | ||
| 754 | |||
| 755 | pub extern "c" fn sendfile( | 831 | pub extern "c" fn sendfile( |
| 756 | in_fd: fd_t, | 832 | in_fd: fd_t, |
| 757 | out_fd: fd_t, | 833 | out_fd: fd_t, |
| ... | @@ -765,69 +841,6 @@ pub fn sigaddset(set: *sigset_t, signo: u5) void { | ... | @@ -765,69 +841,6 @@ pub fn sigaddset(set: *sigset_t, signo: u5) void { |
| 765 | set.* |= @as(u32, 1) << (signo - 1); | 841 | set.* |= @as(u32, 1) << (signo - 1); |
| 766 | } | 842 | } |
| 767 | 843 | ||
| 768 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 769 | |||
| 770 | pub const IFNAMESIZE = 16; | ||
| 771 | |||
| 772 | pub const AI = struct { | ||
| 773 | /// get address to use bind() | ||
| 774 | pub const PASSIVE = 0x00000001; | ||
| 775 | /// fill ai_canonname | ||
| 776 | pub const CANONNAME = 0x00000002; | ||
| 777 | /// prevent host name resolution | ||
| 778 | pub const NUMERICHOST = 0x00000004; | ||
| 779 | /// prevent service name resolution | ||
| 780 | pub const NUMERICSERV = 0x00001000; | ||
| 781 | }; | ||
| 782 | |||
| 783 | pub const EAI = enum(c_int) { | ||
| 784 | /// address family for hostname not supported | ||
| 785 | ADDRFAMILY = 1, | ||
| 786 | |||
| 787 | /// temporary failure in name resolution | ||
| 788 | AGAIN = 2, | ||
| 789 | |||
| 790 | /// invalid value for ai_flags | ||
| 791 | BADFLAGS = 3, | ||
| 792 | |||
| 793 | /// non-recoverable failure in name resolution | ||
| 794 | FAIL = 4, | ||
| 795 | |||
| 796 | /// ai_family not supported | ||
| 797 | FAMILY = 5, | ||
| 798 | |||
| 799 | /// memory allocation failure | ||
| 800 | MEMORY = 6, | ||
| 801 | |||
| 802 | /// no address associated with hostname | ||
| 803 | NODATA = 7, | ||
| 804 | |||
| 805 | /// hostname nor servname provided, or not known | ||
| 806 | NONAME = 8, | ||
| 807 | |||
| 808 | /// servname not supported for ai_socktype | ||
| 809 | SERVICE = 9, | ||
| 810 | |||
| 811 | /// ai_socktype not supported | ||
| 812 | SOCKTYPE = 10, | ||
| 813 | |||
| 814 | /// system error returned in errno | ||
| 815 | SYSTEM = 11, | ||
| 816 | |||
| 817 | /// invalid value for hints | ||
| 818 | BADHINTS = 12, | ||
| 819 | |||
| 820 | /// resolved protocol is unknown | ||
| 821 | PROTOCOL = 13, | ||
| 822 | |||
| 823 | /// argument buffer overflow | ||
| 824 | OVERFLOW = 14, | ||
| 825 | |||
| 826 | _, | ||
| 827 | }; | ||
| 828 | |||
| 829 | pub const EAI_MAX = 15; | ||
| 830 | |||
| 831 | pub const qos_class_t = enum(c_uint) { | 844 | pub const qos_class_t = enum(c_uint) { |
| 832 | /// highest priority QOS class for critical tasks | 845 | /// highest priority QOS class for critical tasks |
| 833 | QOS_CLASS_USER_INTERACTIVE = 0x21, | 846 | QOS_CLASS_USER_INTERACTIVE = 0x21, |
| ... | @@ -843,23 +856,6 @@ pub const qos_class_t = enum(c_uint) { | ... | @@ -843,23 +856,6 @@ pub const qos_class_t = enum(c_uint) { |
| 843 | QOS_CLASS_UNSPECIFIED = 0x00, | 856 | QOS_CLASS_UNSPECIFIED = 0x00, |
| 844 | }; | 857 | }; |
| 845 | 858 | ||
| 846 | pub const sem_t = c_int; | ||
| 847 | |||
| 848 | pub const pthread_attr_t = extern struct { | ||
| 849 | __sig: c_long, | ||
| 850 | __opaque: [56]u8, | ||
| 851 | }; | ||
| 852 | |||
| 853 | pub extern "c" fn pthread_threadid_np(thread: ?std.c.pthread_t, thread_id: *u64) c_int; | ||
| 854 | pub extern "c" fn pthread_setname_np(name: [*:0]const u8) c_int; | ||
| 855 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | ||
| 856 | pub extern "c" fn pthread_attr_set_qos_class_np(attr: *pthread_attr_t, qos_class: qos_class_t, relative_priority: c_int) c_int; | ||
| 857 | pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; | ||
| 858 | pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int; | ||
| 859 | pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; | ||
| 860 | |||
| 861 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ||
| 862 | |||
| 863 | // Grand Central Dispatch is exposed by libSystem. | 859 | // Grand Central Dispatch is exposed by libSystem. |
| 864 | pub extern "c" fn dispatch_release(object: *anyopaque) void; | 860 | pub extern "c" fn dispatch_release(object: *anyopaque) void; |
| 865 | 861 | ||
| ... | @@ -881,38 +877,37 @@ pub extern fn dispatch_once_f( | ... | @@ -881,38 +877,37 @@ pub extern fn dispatch_once_f( |
| 881 | function: dispatch_function_t, | 877 | function: dispatch_function_t, |
| 882 | ) void; | 878 | ) void; |
| 883 | 879 | ||
| 884 | // Undocumented futex-like API available on darwin 16+ | 880 | /// Undocumented futex-like API available on darwin 16+ |
| 885 | // (macOS 10.12+, iOS 10.0+, tvOS 10.0+, watchOS 3.0+, catalyst 13.0+). | 881 | /// (macOS 10.12+, iOS 10.0+, tvOS 10.0+, watchOS 3.0+, catalyst 13.0+). |
| 886 | // | 882 | /// |
| 887 | // [ulock.h]: https://github.com/apple/darwin-xnu/blob/master/bsd/sys/ulock.h | 883 | /// [ulock.h]: https://github.com/apple/darwin-xnu/blob/master/bsd/sys/ulock.h |
| 888 | // [sys_ulock.c]: https://github.com/apple/darwin-xnu/blob/master/bsd/kern/sys_ulock.c | 884 | /// [sys_ulock.c]: https://github.com/apple/darwin-xnu/blob/master/bsd/kern/sys_ulock.c |
| 889 | 885 | pub const UL = packed struct(u32) { | |
| 890 | pub const UL_COMPARE_AND_WAIT = 1; | 886 | op: Op, |
| 891 | pub const UL_UNFAIR_LOCK = 2; | 887 | WAKE_ALL: bool = false, |
| 892 | 888 | WAKE_THREAD: bool = false, | |
| 893 | // Obsolete/deprecated | 889 | _10: u6 = 0, |
| 894 | pub const UL_OSSPINLOCK = UL_COMPARE_AND_WAIT; | 890 | WAIT_WORKQ_DATA_CONTENTION: bool = false, |
| 895 | pub const UL_HANDOFFLOCK = UL_UNFAIR_LOCK; | 891 | WAIT_CANCEL_POINT: bool = false, |
| 896 | 892 | WAIT_ADAPTIVE_SPIN: bool = false, | |
| 897 | pub const ULF_WAKE_ALL = 0x100; | 893 | _19: u5 = 0, |
| 898 | pub const ULF_WAKE_THREAD = 0x200; | 894 | NO_ERRNO: bool = false, |
| 899 | pub const ULF_WAIT_WORKQ_DATA_CONTENTION = 0x10000; | 895 | _: u7 = 0, |
| 900 | pub const ULF_WAIT_CANCEL_POINT = 0x20000; | 896 | |
| 901 | pub const ULF_NO_ERRNO = 0x1000000; | 897 | pub const Op = enum(u8) { |
| 902 | 898 | COMPARE_AND_WAIT = 1, | |
| 903 | // The following are only supported on darwin 19+ | 899 | UNFAIR_LOCK = 2, |
| 904 | // (macOS 10.15+, iOS 13.0+) | 900 | COMPARE_AND_WAIT_SHARED = 3, |
| 905 | pub const UL_COMPARE_AND_WAIT_SHARED = 3; | 901 | UNFAIR_LOCK64_SHARED = 4, |
| 906 | pub const UL_UNFAIR_LOCK64_SHARED = 4; | 902 | COMPARE_AND_WAIT64 = 5, |
| 907 | pub const UL_COMPARE_AND_WAIT64 = 5; | 903 | COMPARE_AND_WAIT64_SHARED = 6, |
| 908 | pub const UL_COMPARE_AND_WAIT64_SHARED = 6; | 904 | }; |
| 909 | pub const ULF_WAIT_ADAPTIVE_SPIN = 0x40000; | 905 | }; |
| 910 | 906 | ||
| 911 | pub extern "c" fn __ulock_wait2(op: u32, addr: ?*const anyopaque, val: u64, timeout_ns: u64, val2: u64) c_int; | 907 | pub extern "c" fn __ulock_wait2(op: UL, addr: ?*const anyopaque, val: u64, timeout_ns: u64, val2: u64) c_int; |
| 912 | pub extern "c" fn __ulock_wait(op: u32, addr: ?*const anyopaque, val: u64, timeout_us: u32) c_int; | 908 | pub extern "c" fn __ulock_wait(op: UL, addr: ?*const anyopaque, val: u64, timeout_us: u32) c_int; |
| 913 | pub extern "c" fn __ulock_wake(op: u32, addr: ?*const anyopaque, val: u64) c_int; | 909 | pub extern "c" fn __ulock_wake(op: UL, addr: ?*const anyopaque, val: u64) c_int; |
| 914 | 910 | ||
| 915 | pub const OS_UNFAIR_LOCK_INIT = os_unfair_lock{}; | ||
| 916 | pub const os_unfair_lock_t = *os_unfair_lock; | 911 | pub const os_unfair_lock_t = *os_unfair_lock; |
| 917 | pub const os_unfair_lock = extern struct { | 912 | pub const os_unfair_lock = extern struct { |
| 918 | _os_unfair_lock_opaque: u32 = 0, | 913 | _os_unfair_lock_opaque: u32 = 0, |
| ... | @@ -924,276 +919,49 @@ pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool; | ... | @@ -924,276 +919,49 @@ pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool; |
| 924 | pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void; | 919 | pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void; |
| 925 | pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void; | 920 | pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void; |
| 926 | 921 | ||
| 927 | // See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html | 922 | pub const os_signpost_id_t = u64; |
| 928 | // TODO: audit mode_t/pid_t, should likely be u16/i32 | ||
| 929 | pub const blkcnt_t = i64; | ||
| 930 | pub const blksize_t = i32; | ||
| 931 | pub const dev_t = i32; | ||
| 932 | pub const fd_t = c_int; | ||
| 933 | pub const pid_t = c_int; | ||
| 934 | pub const mode_t = c_uint; | ||
| 935 | pub const uid_t = u32; | ||
| 936 | pub const gid_t = u32; | ||
| 937 | |||
| 938 | // machine/_types.h | ||
| 939 | pub const clock_t = c_ulong; | ||
| 940 | pub const time_t = c_long; | ||
| 941 | |||
| 942 | pub const in_port_t = u16; | ||
| 943 | pub const sa_family_t = u8; | ||
| 944 | pub const socklen_t = u32; | ||
| 945 | pub const sockaddr = extern struct { | ||
| 946 | len: u8, | ||
| 947 | family: sa_family_t, | ||
| 948 | data: [14]u8, | ||
| 949 | |||
| 950 | pub const SS_MAXSIZE = 128; | ||
| 951 | pub const storage = extern struct { | ||
| 952 | len: u8 align(8), | ||
| 953 | family: sa_family_t, | ||
| 954 | padding: [126]u8 = undefined, | ||
| 955 | |||
| 956 | comptime { | ||
| 957 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 958 | assert(@alignOf(storage) == 8); | ||
| 959 | } | ||
| 960 | }; | ||
| 961 | pub const in = extern struct { | ||
| 962 | len: u8 = @sizeOf(in), | ||
| 963 | family: sa_family_t = AF.INET, | ||
| 964 | port: in_port_t, | ||
| 965 | addr: u32, | ||
| 966 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 967 | }; | ||
| 968 | pub const in6 = extern struct { | ||
| 969 | len: u8 = @sizeOf(in6), | ||
| 970 | family: sa_family_t = AF.INET6, | ||
| 971 | port: in_port_t, | ||
| 972 | flowinfo: u32, | ||
| 973 | addr: [16]u8, | ||
| 974 | scope_id: u32, | ||
| 975 | }; | ||
| 976 | |||
| 977 | /// UNIX domain socket | ||
| 978 | pub const un = extern struct { | ||
| 979 | len: u8 = @sizeOf(un), | ||
| 980 | family: sa_family_t = AF.UNIX, | ||
| 981 | path: [104]u8, | ||
| 982 | }; | ||
| 983 | }; | ||
| 984 | pub const timeval = extern struct { | ||
| 985 | tv_sec: c_long, | ||
| 986 | tv_usec: i32, | ||
| 987 | }; | ||
| 988 | |||
| 989 | pub const timezone = extern struct { | ||
| 990 | tz_minuteswest: i32, | ||
| 991 | tz_dsttime: i32, | ||
| 992 | }; | ||
| 993 | |||
| 994 | pub const mach_timebase_info_data = extern struct { | ||
| 995 | numer: u32, | ||
| 996 | denom: u32, | ||
| 997 | }; | ||
| 998 | |||
| 999 | pub const off_t = i64; | ||
| 1000 | pub const ino_t = u64; | ||
| 1001 | |||
| 1002 | pub const Flock = extern struct { | ||
| 1003 | start: off_t, | ||
| 1004 | len: off_t, | ||
| 1005 | pid: pid_t, | ||
| 1006 | type: i16, | ||
| 1007 | whence: i16, | ||
| 1008 | }; | ||
| 1009 | |||
| 1010 | pub const Stat = extern struct { | ||
| 1011 | dev: i32, | ||
| 1012 | mode: u16, | ||
| 1013 | nlink: u16, | ||
| 1014 | ino: ino_t, | ||
| 1015 | uid: uid_t, | ||
| 1016 | gid: gid_t, | ||
| 1017 | rdev: i32, | ||
| 1018 | atimespec: timespec, | ||
| 1019 | mtimespec: timespec, | ||
| 1020 | ctimespec: timespec, | ||
| 1021 | birthtimespec: timespec, | ||
| 1022 | size: off_t, | ||
| 1023 | blocks: i64, | ||
| 1024 | blksize: i32, | ||
| 1025 | flags: u32, | ||
| 1026 | gen: u32, | ||
| 1027 | lspare: i32, | ||
| 1028 | qspare: [2]i64, | ||
| 1029 | |||
| 1030 | pub fn atime(self: @This()) timespec { | ||
| 1031 | return self.atimespec; | ||
| 1032 | } | ||
| 1033 | |||
| 1034 | pub fn mtime(self: @This()) timespec { | ||
| 1035 | return self.mtimespec; | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | pub fn ctime(self: @This()) timespec { | ||
| 1039 | return self.ctimespec; | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | pub fn birthtime(self: @This()) timespec { | ||
| 1043 | return self.birthtimespec; | ||
| 1044 | } | ||
| 1045 | }; | ||
| 1046 | |||
| 1047 | pub const timespec = extern struct { | ||
| 1048 | tv_sec: isize, | ||
| 1049 | tv_nsec: isize, | ||
| 1050 | }; | ||
| 1051 | 923 | ||
| 1052 | pub const sigset_t = u32; | 924 | pub const OS_SIGNPOST_ID_NULL: os_signpost_id_t = 0; |
| 1053 | pub const empty_sigset: sigset_t = 0; | 925 | pub const OS_SIGNPOST_ID_INVALID: os_signpost_id_t = !0; |
| 1054 | 926 | pub const OS_SIGNPOST_ID_EXCLUSIVE: os_signpost_id_t = 0xeeeeb0b5b2b2eeee; | |
| 1055 | pub const SIG = struct { | ||
| 1056 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 1057 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 1058 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 1059 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(5); | ||
| 1060 | |||
| 1061 | /// block specified signal set | ||
| 1062 | pub const BLOCK = 1; | ||
| 1063 | /// unblock specified signal set | ||
| 1064 | pub const UNBLOCK = 2; | ||
| 1065 | /// set specified signal set | ||
| 1066 | pub const SETMASK = 3; | ||
| 1067 | /// hangup | ||
| 1068 | pub const HUP = 1; | ||
| 1069 | /// interrupt | ||
| 1070 | pub const INT = 2; | ||
| 1071 | /// quit | ||
| 1072 | pub const QUIT = 3; | ||
| 1073 | /// illegal instruction (not reset when caught) | ||
| 1074 | pub const ILL = 4; | ||
| 1075 | /// trace trap (not reset when caught) | ||
| 1076 | pub const TRAP = 5; | ||
| 1077 | /// abort() | ||
| 1078 | pub const ABRT = 6; | ||
| 1079 | /// pollable event ([XSR] generated, not supported) | ||
| 1080 | pub const POLL = 7; | ||
| 1081 | /// compatibility | ||
| 1082 | pub const IOT = ABRT; | ||
| 1083 | /// EMT instruction | ||
| 1084 | pub const EMT = 7; | ||
| 1085 | /// floating point exception | ||
| 1086 | pub const FPE = 8; | ||
| 1087 | /// kill (cannot be caught or ignored) | ||
| 1088 | pub const KILL = 9; | ||
| 1089 | /// bus error | ||
| 1090 | pub const BUS = 10; | ||
| 1091 | /// segmentation violation | ||
| 1092 | pub const SEGV = 11; | ||
| 1093 | /// bad argument to system call | ||
| 1094 | pub const SYS = 12; | ||
| 1095 | /// write on a pipe with no one to read it | ||
| 1096 | pub const PIPE = 13; | ||
| 1097 | /// alarm clock | ||
| 1098 | pub const ALRM = 14; | ||
| 1099 | /// software termination signal from kill | ||
| 1100 | pub const TERM = 15; | ||
| 1101 | /// urgent condition on IO channel | ||
| 1102 | pub const URG = 16; | ||
| 1103 | /// sendable stop signal not from tty | ||
| 1104 | pub const STOP = 17; | ||
| 1105 | /// stop signal from tty | ||
| 1106 | pub const TSTP = 18; | ||
| 1107 | /// continue a stopped process | ||
| 1108 | pub const CONT = 19; | ||
| 1109 | /// to parent on child stop or exit | ||
| 1110 | pub const CHLD = 20; | ||
| 1111 | /// to readers pgrp upon background tty read | ||
| 1112 | pub const TTIN = 21; | ||
| 1113 | /// like TTIN for output if (tp->t_local&LTOSTOP) | ||
| 1114 | pub const TTOU = 22; | ||
| 1115 | /// input/output possible signal | ||
| 1116 | pub const IO = 23; | ||
| 1117 | /// exceeded CPU time limit | ||
| 1118 | pub const XCPU = 24; | ||
| 1119 | /// exceeded file size limit | ||
| 1120 | pub const XFSZ = 25; | ||
| 1121 | /// virtual time alarm | ||
| 1122 | pub const VTALRM = 26; | ||
| 1123 | /// profiling time alarm | ||
| 1124 | pub const PROF = 27; | ||
| 1125 | /// window size changes | ||
| 1126 | pub const WINCH = 28; | ||
| 1127 | /// information request | ||
| 1128 | pub const INFO = 29; | ||
| 1129 | /// user defined signal 1 | ||
| 1130 | pub const USR1 = 30; | ||
| 1131 | /// user defined signal 2 | ||
| 1132 | pub const USR2 = 31; | ||
| 1133 | }; | ||
| 1134 | 927 | ||
| 1135 | pub const siginfo_t = extern struct { | 928 | pub const os_log_t = opaque {}; |
| 1136 | signo: c_int, | 929 | pub const os_log_type_t = enum(u8) { |
| 1137 | errno: c_int, | 930 | /// default messages always captures |
| 1138 | code: c_int, | 931 | OS_LOG_TYPE_DEFAULT = 0x00, |
| 1139 | pid: pid_t, | 932 | /// messages with additional infos |
| 1140 | uid: uid_t, | 933 | OS_LOG_TYPE_INFO = 0x01, |
| 1141 | status: c_int, | 934 | /// debug messages |
| 1142 | addr: *allowzero anyopaque, | 935 | OS_LOG_TYPE_DEBUG = 0x02, |
| 1143 | value: extern union { | 936 | /// error messages |
| 1144 | int: c_int, | 937 | OS_LOG_TYPE_ERROR = 0x10, |
| 1145 | ptr: *anyopaque, | 938 | /// unexpected conditions messages |
| 1146 | }, | 939 | OS_LOG_TYPE_FAULT = 0x11, |
| 1147 | si_band: c_long, | ||
| 1148 | _pad: [7]c_ulong, | ||
| 1149 | }; | 940 | }; |
| 1150 | 941 | ||
| 1151 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. | 942 | pub const OS_LOG_CATEGORY_POINTS_OF_INTEREST: *const u8 = "PointsOfInterest"; |
| 1152 | pub const Sigaction = extern struct { | 943 | pub const OS_LOG_CATEGORY_DYNAMIC_TRACING: *const u8 = "DynamicTracing"; |
| 1153 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | 944 | pub const OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING: *const u8 = "DynamicStackTracing"; |
| 1154 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 1155 | 945 | ||
| 1156 | handler: extern union { | 946 | pub extern "c" fn os_log_create(subsystem: [*]const u8, category: [*]const u8) os_log_t; |
| 1157 | handler: ?handler_fn, | 947 | pub extern "c" fn os_log_type_enabled(log: os_log_t, tpe: os_log_type_t) bool; |
| 1158 | sigaction: ?sigaction_fn, | 948 | pub extern "c" fn os_signpost_id_generate(log: os_log_t) os_signpost_id_t; |
| 1159 | }, | 949 | pub extern "c" fn os_signpost_interval_begin(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void; |
| 1160 | mask: sigset_t, | 950 | pub extern "c" fn os_signpost_interval_end(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void; |
| 1161 | flags: c_uint, | 951 | pub extern "c" fn os_signpost_id_make_with_pointer(log: os_log_t, ptr: ?*anyopaque) os_signpost_id_t; |
| 1162 | }; | 952 | pub extern "c" fn os_signpost_enabled(log: os_log_t) bool; |
| 1163 | 953 | ||
| 1164 | pub const dirent = extern struct { | 954 | pub extern "c" fn pthread_setname_np(name: [*:0]const u8) c_int; |
| 1165 | ino: u64, | 955 | pub extern "c" fn pthread_attr_set_qos_class_np(attr: *pthread_attr_t, qos_class: qos_class_t, relative_priority: c_int) c_int; |
| 1166 | seekoff: u64, | 956 | pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; |
| 1167 | reclen: u16, | 957 | pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int; |
| 1168 | namlen: u16, | 958 | pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; |
| 1169 | type: u8, | ||
| 1170 | name: [1024]u8, | ||
| 1171 | }; | ||
| 1172 | 959 | ||
| 1173 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | 960 | pub const mach_timebase_info_data = extern struct { |
| 1174 | pub const Kevent = extern struct { | 961 | numer: u32, |
| 1175 | ident: usize, | 962 | denom: u32, |
| 1176 | filter: i16, | ||
| 1177 | flags: u16, | ||
| 1178 | fflags: u32, | ||
| 1179 | data: isize, | ||
| 1180 | udata: usize, | ||
| 1181 | }; | 963 | }; |
| 1182 | 964 | ||
| 1183 | // sys/types.h on macos uses #pragma pack(4) so these checks are | ||
| 1184 | // to make sure the struct is laid out the same. These values were | ||
| 1185 | // produced from C code using the offsetof macro. | ||
| 1186 | comptime { | ||
| 1187 | if (builtin.target.isDarwin()) { | ||
| 1188 | assert(@offsetOf(Kevent, "ident") == 0); | ||
| 1189 | assert(@offsetOf(Kevent, "filter") == 8); | ||
| 1190 | assert(@offsetOf(Kevent, "flags") == 10); | ||
| 1191 | assert(@offsetOf(Kevent, "fflags") == 12); | ||
| 1192 | assert(@offsetOf(Kevent, "data") == 16); | ||
| 1193 | assert(@offsetOf(Kevent, "udata") == 24); | ||
| 1194 | } | ||
| 1195 | } | ||
| 1196 | |||
| 1197 | pub const kevent64_s = extern struct { | 965 | pub const kevent64_s = extern struct { |
| 1198 | ident: u64, | 966 | ident: u64, |
| 1199 | filter: i16, | 967 | filter: i16, |
| ... | @@ -1219,14 +987,13 @@ comptime { | ... | @@ -1219,14 +987,13 @@ comptime { |
| 1219 | } | 987 | } |
| 1220 | } | 988 | } |
| 1221 | 989 | ||
| 1222 | pub const mach_port_t = c_uint; | ||
| 1223 | pub const clock_serv_t = mach_port_t; | 990 | pub const clock_serv_t = mach_port_t; |
| 1224 | pub const clock_res_t = c_int; | 991 | pub const clock_res_t = c_int; |
| 1225 | pub const mach_port_name_t = natural_t; | 992 | pub const mach_port_name_t = natural_t; |
| 1226 | pub const natural_t = c_uint; | 993 | pub const natural_t = c_uint; |
| 1227 | pub const mach_timespec_t = extern struct { | 994 | pub const mach_timespec_t = extern struct { |
| 1228 | tv_sec: c_uint, | 995 | sec: c_uint, |
| 1229 | tv_nsec: clock_res_t, | 996 | nsec: clock_res_t, |
| 1230 | }; | 997 | }; |
| 1231 | pub const kern_return_t = c_int; | 998 | pub const kern_return_t = c_int; |
| 1232 | pub const host_t = mach_port_t; | 999 | pub const host_t = mach_port_t; |
| ... | @@ -1241,2099 +1008,503 @@ pub const vm_machine_attribute_val_t = isize; | ... | @@ -1241,2099 +1008,503 @@ pub const vm_machine_attribute_val_t = isize; |
| 1241 | 1008 | ||
| 1242 | pub const CALENDAR_CLOCK = 1; | 1009 | pub const CALENDAR_CLOCK = 1; |
| 1243 | 1010 | ||
| 1244 | pub const PATH_MAX = 1024; | ||
| 1245 | pub const NAME_MAX = 255; | ||
| 1246 | pub const IOV_MAX = 16; | ||
| 1247 | |||
| 1248 | pub const STDIN_FILENO = 0; | ||
| 1249 | pub const STDOUT_FILENO = 1; | ||
| 1250 | pub const STDERR_FILENO = 2; | ||
| 1251 | |||
| 1252 | pub const PROT = struct { | ||
| 1253 | /// [MC2] no permissions | ||
| 1254 | pub const NONE: vm_prot_t = 0x00; | ||
| 1255 | /// [MC2] pages can be read | ||
| 1256 | pub const READ: vm_prot_t = 0x01; | ||
| 1257 | /// [MC2] pages can be written | ||
| 1258 | pub const WRITE: vm_prot_t = 0x02; | ||
| 1259 | /// [MC2] pages can be executed | ||
| 1260 | pub const EXEC: vm_prot_t = 0x04; | ||
| 1261 | /// When a caller finds that they cannot obtain write permission on a | ||
| 1262 | /// mapped entry, the following flag can be used. The entry will be | ||
| 1263 | /// made "needs copy" effectively copying the object (using COW), | ||
| 1264 | /// and write permission will be added to the maximum protections for | ||
| 1265 | /// the associated entry. | ||
| 1266 | pub const COPY: vm_prot_t = 0x10; | ||
| 1267 | }; | ||
| 1268 | |||
| 1269 | pub const MSF = struct { | ||
| 1270 | pub const ASYNC = 0x1; | ||
| 1271 | pub const INVALIDATE = 0x2; | ||
| 1272 | // invalidate, leave mapped | ||
| 1273 | pub const KILLPAGES = 0x4; | ||
| 1274 | // deactivate, leave mapped | ||
| 1275 | pub const DEACTIVATE = 0x8; | ||
| 1276 | pub const SYNC = 0x10; | ||
| 1277 | }; | ||
| 1278 | |||
| 1279 | pub const SA = struct { | ||
| 1280 | /// take signal on signal stack | ||
| 1281 | pub const ONSTACK = 0x0001; | ||
| 1282 | /// restart system on signal return | ||
| 1283 | pub const RESTART = 0x0002; | ||
| 1284 | /// reset to SIG.DFL when taking signal | ||
| 1285 | pub const RESETHAND = 0x0004; | ||
| 1286 | /// do not generate SIG.CHLD on child stop | ||
| 1287 | pub const NOCLDSTOP = 0x0008; | ||
| 1288 | /// don't mask the signal we're delivering | ||
| 1289 | pub const NODEFER = 0x0010; | ||
| 1290 | /// don't keep zombies around | ||
| 1291 | pub const NOCLDWAIT = 0x0020; | ||
| 1292 | /// signal handler with SIGINFO args | ||
| 1293 | pub const SIGINFO = 0x0040; | ||
| 1294 | /// do not bounce off kernel's sigtramp | ||
| 1295 | pub const USERTRAMP = 0x0100; | ||
| 1296 | /// signal handler with SIGINFO args with 64bit regs information | ||
| 1297 | pub const @"64REGSET" = 0x0200; | ||
| 1298 | }; | ||
| 1299 | |||
| 1300 | pub const F_OK = 0; | ||
| 1301 | pub const X_OK = 1; | ||
| 1302 | pub const W_OK = 2; | ||
| 1303 | pub const R_OK = 4; | ||
| 1304 | |||
| 1305 | pub const SEEK = struct { | ||
| 1306 | pub const SET = 0x0; | ||
| 1307 | pub const CUR = 0x1; | ||
| 1308 | pub const END = 0x2; | ||
| 1309 | }; | ||
| 1310 | |||
| 1311 | pub const DT = struct { | ||
| 1312 | pub const UNKNOWN = 0; | ||
| 1313 | pub const FIFO = 1; | ||
| 1314 | pub const CHR = 2; | ||
| 1315 | pub const DIR = 4; | ||
| 1316 | pub const BLK = 6; | ||
| 1317 | pub const REG = 8; | ||
| 1318 | pub const LNK = 10; | ||
| 1319 | pub const SOCK = 12; | ||
| 1320 | pub const WHT = 14; | ||
| 1321 | }; | ||
| 1322 | |||
| 1323 | /// no flag value | 1011 | /// no flag value |
| 1324 | pub const KEVENT_FLAG_NONE = 0x000; | 1012 | pub const KEVENT_FLAG_NONE = 0x000; |
| 1325 | |||
| 1326 | /// immediate timeout | 1013 | /// immediate timeout |
| 1327 | pub const KEVENT_FLAG_IMMEDIATE = 0x001; | 1014 | pub const KEVENT_FLAG_IMMEDIATE = 0x001; |
| 1328 | |||
| 1329 | /// output events only include change | 1015 | /// output events only include change |
| 1330 | pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; | 1016 | pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; |
| 1331 | 1017 | ||
| 1332 | /// add event to kq (implies enable) | 1018 | pub const SYSPROTO_EVENT = 1; |
| 1333 | pub const EV_ADD = 0x0001; | 1019 | pub const SYSPROTO_CONTROL = 2; |
| 1334 | |||
| 1335 | /// delete event from kq | ||
| 1336 | pub const EV_DELETE = 0x0002; | ||
| 1337 | |||
| 1338 | /// enable event | ||
| 1339 | pub const EV_ENABLE = 0x0004; | ||
| 1340 | |||
| 1341 | /// disable event (not reported) | ||
| 1342 | pub const EV_DISABLE = 0x0008; | ||
| 1343 | |||
| 1344 | /// only report one occurrence | ||
| 1345 | pub const EV_ONESHOT = 0x0010; | ||
| 1346 | |||
| 1347 | /// clear event state after reporting | ||
| 1348 | pub const EV_CLEAR = 0x0020; | ||
| 1349 | |||
| 1350 | /// force immediate event output | ||
| 1351 | /// ... with or without EV_ERROR | ||
| 1352 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 1353 | /// on syscalls supporting flags | ||
| 1354 | pub const EV_RECEIPT = 0x0040; | ||
| 1355 | |||
| 1356 | /// disable event after reporting | ||
| 1357 | pub const EV_DISPATCH = 0x0080; | ||
| 1358 | |||
| 1359 | /// unique kevent per udata value | ||
| 1360 | pub const EV_UDATA_SPECIFIC = 0x0100; | ||
| 1361 | |||
| 1362 | /// ... in combination with EV_DELETE | ||
| 1363 | /// will defer delete until udata-specific | ||
| 1364 | /// event enabled. EINPROGRESS will be | ||
| 1365 | /// returned to indicate the deferral | ||
| 1366 | pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC; | ||
| 1367 | 1020 | ||
| 1368 | /// report that source has vanished | 1021 | pub const mach_msg_return_t = kern_return_t; |
| 1369 | /// ... only valid with EV_DISPATCH2 | ||
| 1370 | pub const EV_VANISHED = 0x0200; | ||
| 1371 | 1022 | ||
| 1372 | /// reserved by system | 1023 | pub fn getMachMsgError(err: mach_msg_return_t) MachMsgE { |
| 1373 | pub const EV_SYSFLAGS = 0xF000; | 1024 | return @as(MachMsgE, @enumFromInt(@as(u32, @truncate(@as(usize, @intCast(err)))))); |
| 1025 | } | ||
| 1374 | 1026 | ||
| 1375 | /// filter-specific flag | 1027 | /// All special error code bits defined below. |
| 1376 | pub const EV_FLAG0 = 0x1000; | 1028 | pub const MACH_MSG_MASK: u32 = 0x3e00; |
| 1029 | /// No room in IPC name space for another capability name. | ||
| 1030 | pub const MACH_MSG_IPC_SPACE: u32 = 0x2000; | ||
| 1031 | /// No room in VM address space for out-of-line memory. | ||
| 1032 | pub const MACH_MSG_VM_SPACE: u32 = 0x1000; | ||
| 1033 | /// Kernel resource shortage handling out-of-line memory. | ||
| 1034 | pub const MACH_MSG_IPC_KERNEL: u32 = 0x800; | ||
| 1035 | /// Kernel resource shortage handling an IPC capability. | ||
| 1036 | pub const MACH_MSG_VM_KERNEL: u32 = 0x400; | ||
| 1377 | 1037 | ||
| 1378 | /// filter-specific flag | 1038 | /// Mach msg return values |
| 1379 | pub const EV_FLAG1 = 0x2000; | 1039 | pub const MachMsgE = enum(u32) { |
| 1040 | SUCCESS = 0x00000000, | ||
| 1380 | 1041 | ||
| 1381 | /// EOF detected | 1042 | /// Thread is waiting to send. (Internal use only.) |
| 1382 | pub const EV_EOF = 0x8000; | 1043 | SEND_IN_PROGRESS = 0x10000001, |
| 1044 | /// Bogus in-line data. | ||
| 1045 | SEND_INVALID_DATA = 0x10000002, | ||
| 1046 | /// Bogus destination port. | ||
| 1047 | SEND_INVALID_DEST = 0x10000003, | ||
| 1048 | /// Message not sent before timeout expired. | ||
| 1049 | SEND_TIMED_OUT = 0x10000004, | ||
| 1050 | /// Bogus voucher port. | ||
| 1051 | SEND_INVALID_VOUCHER = 0x10000005, | ||
| 1052 | /// Software interrupt. | ||
| 1053 | SEND_INTERRUPTED = 0x10000007, | ||
| 1054 | /// Data doesn't contain a complete message. | ||
| 1055 | SEND_MSG_TOO_SMALL = 0x10000008, | ||
| 1056 | /// Bogus reply port. | ||
| 1057 | SEND_INVALID_REPLY = 0x10000009, | ||
| 1058 | /// Bogus port rights in the message body. | ||
| 1059 | SEND_INVALID_RIGHT = 0x1000000a, | ||
| 1060 | /// Bogus notify port argument. | ||
| 1061 | SEND_INVALID_NOTIFY = 0x1000000b, | ||
| 1062 | /// Invalid out-of-line memory pointer. | ||
| 1063 | SEND_INVALID_MEMORY = 0x1000000c, | ||
| 1064 | /// No message buffer is available. | ||
| 1065 | SEND_NO_BUFFER = 0x1000000d, | ||
| 1066 | /// Send is too large for port | ||
| 1067 | SEND_TOO_LARGE = 0x1000000e, | ||
| 1068 | /// Invalid msg-type specification. | ||
| 1069 | SEND_INVALID_TYPE = 0x1000000f, | ||
| 1070 | /// A field in the header had a bad value. | ||
| 1071 | SEND_INVALID_HEADER = 0x10000010, | ||
| 1072 | /// The trailer to be sent does not match kernel format. | ||
| 1073 | SEND_INVALID_TRAILER = 0x10000011, | ||
| 1074 | /// The sending thread context did not match the context on the dest port | ||
| 1075 | SEND_INVALID_CONTEXT = 0x10000012, | ||
| 1076 | /// compatibility: no longer a returned error | ||
| 1077 | SEND_INVALID_RT_OOL_SIZE = 0x10000015, | ||
| 1078 | /// The destination port doesn't accept ports in body | ||
| 1079 | SEND_NO_GRANT_DEST = 0x10000016, | ||
| 1080 | /// Message send was rejected by message filter | ||
| 1081 | SEND_MSG_FILTERED = 0x10000017, | ||
| 1383 | 1082 | ||
| 1384 | /// error, data contains errno | 1083 | /// Thread is waiting for receive. (Internal use only.) |
| 1385 | pub const EV_ERROR = 0x4000; | 1084 | RCV_IN_PROGRESS = 0x10004001, |
| 1386 | 1085 | /// Bogus name for receive port/port-set. | |
| 1387 | pub const EV_POLL = EV_FLAG0; | 1086 | RCV_INVALID_NAME = 0x10004002, |
| 1388 | pub const EV_OOBAND = EV_FLAG1; | 1087 | /// Didn't get a message within the timeout value. |
| 1389 | 1088 | RCV_TIMED_OUT = 0x10004003, | |
| 1390 | pub const EVFILT_READ = -1; | 1089 | /// Message buffer is not large enough for inline data. |
| 1391 | pub const EVFILT_WRITE = -2; | 1090 | RCV_TOO_LARGE = 0x10004004, |
| 1392 | 1091 | /// Software interrupt. | |
| 1393 | /// attached to aio requests | 1092 | RCV_INTERRUPTED = 0x10004005, |
| 1394 | pub const EVFILT_AIO = -3; | 1093 | /// compatibility: no longer a returned error |
| 1395 | 1094 | RCV_PORT_CHANGED = 0x10004006, | |
| 1396 | /// attached to vnodes | 1095 | /// Bogus notify port argument. |
| 1397 | pub const EVFILT_VNODE = -4; | 1096 | RCV_INVALID_NOTIFY = 0x10004007, |
| 1398 | 1097 | /// Bogus message buffer for inline data. | |
| 1399 | /// attached to struct proc | 1098 | RCV_INVALID_DATA = 0x10004008, |
| 1400 | pub const EVFILT_PROC = -5; | 1099 | /// Port/set was sent away/died during receive. |
| 1401 | 1100 | RCV_PORT_DIED = 0x10004009, | |
| 1402 | /// attached to struct proc | 1101 | /// compatibility: no longer a returned error |
| 1403 | pub const EVFILT_SIGNAL = -6; | 1102 | RCV_IN_SET = 0x1000400a, |
| 1404 | 1103 | /// Error receiving message header. See special bits. | |
| 1405 | /// timers | 1104 | RCV_HEADER_ERROR = 0x1000400b, |
| 1406 | pub const EVFILT_TIMER = -7; | 1105 | /// Error receiving message body. See special bits. |
| 1407 | 1106 | RCV_BODY_ERROR = 0x1000400c, | |
| 1408 | /// Mach portsets | 1107 | /// Invalid msg-type specification in scatter list. |
| 1409 | pub const EVFILT_MACHPORT = -8; | 1108 | RCV_INVALID_TYPE = 0x1000400d, |
| 1410 | 1109 | /// Out-of-line overwrite region is not large enough | |
| 1411 | /// Filesystem events | 1110 | RCV_SCATTER_SMALL = 0x1000400e, |
| 1412 | pub const EVFILT_FS = -9; | 1111 | /// trailer type or number of trailer elements not supported |
| 1413 | 1112 | RCV_INVALID_TRAILER = 0x1000400f, | |
| 1414 | /// User events | 1113 | /// Waiting for receive with timeout. (Internal use only.) |
| 1415 | pub const EVFILT_USER = -10; | 1114 | RCV_IN_PROGRESS_TIMED = 0x10004011, |
| 1416 | 1115 | /// invalid reply port used in a STRICT_REPLY message | |
| 1417 | /// Virtual memory events | 1116 | RCV_INVALID_REPLY = 0x10004012, |
| 1418 | pub const EVFILT_VM = -12; | ||
| 1419 | |||
| 1420 | /// Exception events | ||
| 1421 | pub const EVFILT_EXCEPT = -15; | ||
| 1422 | |||
| 1423 | pub const EVFILT_SYSCOUNT = 17; | ||
| 1424 | |||
| 1425 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 1426 | pub const NOTE_TRIGGER = 0x01000000; | ||
| 1427 | |||
| 1428 | /// ignore input fflags | ||
| 1429 | pub const NOTE_FFNOP = 0x00000000; | ||
| 1430 | |||
| 1431 | /// and fflags | ||
| 1432 | pub const NOTE_FFAND = 0x40000000; | ||
| 1433 | |||
| 1434 | /// or fflags | ||
| 1435 | pub const NOTE_FFOR = 0x80000000; | ||
| 1436 | |||
| 1437 | /// copy fflags | ||
| 1438 | pub const NOTE_FFCOPY = 0xc0000000; | ||
| 1439 | |||
| 1440 | /// mask for operations | ||
| 1441 | pub const NOTE_FFCTRLMASK = 0xc0000000; | ||
| 1442 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | ||
| 1443 | |||
| 1444 | /// low water mark | ||
| 1445 | pub const NOTE_LOWAT = 0x00000001; | ||
| 1446 | |||
| 1447 | /// OOB data | ||
| 1448 | pub const NOTE_OOB = 0x00000002; | ||
| 1449 | |||
| 1450 | /// vnode was removed | ||
| 1451 | pub const NOTE_DELETE = 0x00000001; | ||
| 1452 | |||
| 1453 | /// data contents changed | ||
| 1454 | pub const NOTE_WRITE = 0x00000002; | ||
| 1455 | |||
| 1456 | /// size increased | ||
| 1457 | pub const NOTE_EXTEND = 0x00000004; | ||
| 1458 | |||
| 1459 | /// attributes changed | ||
| 1460 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 1461 | |||
| 1462 | /// link count changed | ||
| 1463 | pub const NOTE_LINK = 0x00000010; | ||
| 1464 | |||
| 1465 | /// vnode was renamed | ||
| 1466 | pub const NOTE_RENAME = 0x00000020; | ||
| 1467 | |||
| 1468 | /// vnode access was revoked | ||
| 1469 | pub const NOTE_REVOKE = 0x00000040; | ||
| 1470 | |||
| 1471 | /// No specific vnode event: to test for EVFILT_READ activation | ||
| 1472 | pub const NOTE_NONE = 0x00000080; | ||
| 1473 | |||
| 1474 | /// vnode was unlocked by flock(2) | ||
| 1475 | pub const NOTE_FUNLOCK = 0x00000100; | ||
| 1476 | |||
| 1477 | /// process exited | ||
| 1478 | pub const NOTE_EXIT = 0x80000000; | ||
| 1479 | |||
| 1480 | /// process forked | ||
| 1481 | pub const NOTE_FORK = 0x40000000; | ||
| 1482 | |||
| 1483 | /// process exec'd | ||
| 1484 | pub const NOTE_EXEC = 0x20000000; | ||
| 1485 | |||
| 1486 | /// shared with EVFILT_SIGNAL | ||
| 1487 | pub const NOTE_SIGNAL = 0x08000000; | ||
| 1488 | |||
| 1489 | /// exit status to be returned, valid for child process only | ||
| 1490 | pub const NOTE_EXITSTATUS = 0x04000000; | ||
| 1491 | |||
| 1492 | /// provide details on reasons for exit | ||
| 1493 | pub const NOTE_EXIT_DETAIL = 0x02000000; | ||
| 1494 | |||
| 1495 | /// mask for signal & exit status | ||
| 1496 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 1497 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | ||
| 1498 | |||
| 1499 | pub const NOTE_EXIT_DETAIL_MASK = 0x00070000; | ||
| 1500 | pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000; | ||
| 1501 | pub const NOTE_EXIT_MEMORY = 0x00020000; | ||
| 1502 | pub const NOTE_EXIT_CSERROR = 0x00040000; | ||
| 1503 | |||
| 1504 | /// will react on memory pressure | ||
| 1505 | pub const NOTE_VM_PRESSURE = 0x80000000; | ||
| 1506 | |||
| 1507 | /// will quit on memory pressure, possibly after cleaning up dirty state | ||
| 1508 | pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; | ||
| 1509 | |||
| 1510 | /// will quit immediately on memory pressure | ||
| 1511 | pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; | ||
| 1512 | |||
| 1513 | /// there was an error | ||
| 1514 | pub const NOTE_VM_ERROR = 0x10000000; | ||
| 1515 | |||
| 1516 | /// data is seconds | ||
| 1517 | pub const NOTE_SECONDS = 0x00000001; | ||
| 1518 | |||
| 1519 | /// data is microseconds | ||
| 1520 | pub const NOTE_USECONDS = 0x00000002; | ||
| 1521 | |||
| 1522 | /// data is nanoseconds | ||
| 1523 | pub const NOTE_NSECONDS = 0x00000004; | ||
| 1524 | |||
| 1525 | /// absolute timeout | ||
| 1526 | pub const NOTE_ABSOLUTE = 0x00000008; | ||
| 1527 | |||
| 1528 | /// ext[1] holds leeway for power aware timers | ||
| 1529 | pub const NOTE_LEEWAY = 0x00000010; | ||
| 1530 | |||
| 1531 | /// system does minimal timer coalescing | ||
| 1532 | pub const NOTE_CRITICAL = 0x00000020; | ||
| 1533 | |||
| 1534 | /// system does maximum timer coalescing | ||
| 1535 | pub const NOTE_BACKGROUND = 0x00000040; | ||
| 1536 | pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080; | ||
| 1537 | |||
| 1538 | /// data is mach absolute time units | ||
| 1539 | pub const NOTE_MACHTIME = 0x00000100; | ||
| 1540 | |||
| 1541 | pub const AF = struct { | ||
| 1542 | pub const UNSPEC = 0; | ||
| 1543 | pub const LOCAL = 1; | ||
| 1544 | pub const UNIX = LOCAL; | ||
| 1545 | pub const INET = 2; | ||
| 1546 | pub const SYS_CONTROL = 2; | ||
| 1547 | pub const IMPLINK = 3; | ||
| 1548 | pub const PUP = 4; | ||
| 1549 | pub const CHAOS = 5; | ||
| 1550 | pub const NS = 6; | ||
| 1551 | pub const ISO = 7; | ||
| 1552 | pub const OSI = ISO; | ||
| 1553 | pub const ECMA = 8; | ||
| 1554 | pub const DATAKIT = 9; | ||
| 1555 | pub const CCITT = 10; | ||
| 1556 | pub const SNA = 11; | ||
| 1557 | pub const DECnet = 12; | ||
| 1558 | pub const DLI = 13; | ||
| 1559 | pub const LAT = 14; | ||
| 1560 | pub const HYLINK = 15; | ||
| 1561 | pub const APPLETALK = 16; | ||
| 1562 | pub const ROUTE = 17; | ||
| 1563 | pub const LINK = 18; | ||
| 1564 | pub const XTP = 19; | ||
| 1565 | pub const COIP = 20; | ||
| 1566 | pub const CNT = 21; | ||
| 1567 | pub const RTIP = 22; | ||
| 1568 | pub const IPX = 23; | ||
| 1569 | pub const SIP = 24; | ||
| 1570 | pub const PIP = 25; | ||
| 1571 | pub const ISDN = 28; | ||
| 1572 | pub const E164 = ISDN; | ||
| 1573 | pub const KEY = 29; | ||
| 1574 | pub const INET6 = 30; | ||
| 1575 | pub const NATM = 31; | ||
| 1576 | pub const SYSTEM = 32; | ||
| 1577 | pub const NETBIOS = 33; | ||
| 1578 | pub const PPP = 34; | ||
| 1579 | pub const MAX = 40; | ||
| 1580 | }; | ||
| 1581 | |||
| 1582 | pub const PF = struct { | ||
| 1583 | pub const UNSPEC = AF.UNSPEC; | ||
| 1584 | pub const LOCAL = AF.LOCAL; | ||
| 1585 | pub const UNIX = PF.LOCAL; | ||
| 1586 | pub const INET = AF.INET; | ||
| 1587 | pub const IMPLINK = AF.IMPLINK; | ||
| 1588 | pub const PUP = AF.PUP; | ||
| 1589 | pub const CHAOS = AF.CHAOS; | ||
| 1590 | pub const NS = AF.NS; | ||
| 1591 | pub const ISO = AF.ISO; | ||
| 1592 | pub const OSI = AF.ISO; | ||
| 1593 | pub const ECMA = AF.ECMA; | ||
| 1594 | pub const DATAKIT = AF.DATAKIT; | ||
| 1595 | pub const CCITT = AF.CCITT; | ||
| 1596 | pub const SNA = AF.SNA; | ||
| 1597 | pub const DECnet = AF.DECnet; | ||
| 1598 | pub const DLI = AF.DLI; | ||
| 1599 | pub const LAT = AF.LAT; | ||
| 1600 | pub const HYLINK = AF.HYLINK; | ||
| 1601 | pub const APPLETALK = AF.APPLETALK; | ||
| 1602 | pub const ROUTE = AF.ROUTE; | ||
| 1603 | pub const LINK = AF.LINK; | ||
| 1604 | pub const XTP = AF.XTP; | ||
| 1605 | pub const COIP = AF.COIP; | ||
| 1606 | pub const CNT = AF.CNT; | ||
| 1607 | pub const SIP = AF.SIP; | ||
| 1608 | pub const IPX = AF.IPX; | ||
| 1609 | pub const RTIP = AF.RTIP; | ||
| 1610 | pub const PIP = AF.PIP; | ||
| 1611 | pub const ISDN = AF.ISDN; | ||
| 1612 | pub const KEY = AF.KEY; | ||
| 1613 | pub const INET6 = AF.INET6; | ||
| 1614 | pub const NATM = AF.NATM; | ||
| 1615 | pub const SYSTEM = AF.SYSTEM; | ||
| 1616 | pub const NETBIOS = AF.NETBIOS; | ||
| 1617 | pub const PPP = AF.PPP; | ||
| 1618 | pub const MAX = AF.MAX; | ||
| 1619 | }; | 1117 | }; |
| 1620 | 1118 | ||
| 1621 | pub const SYSPROTO_EVENT = 1; | 1119 | pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000; |
| 1622 | pub const SYSPROTO_CONTROL = 2; | ||
| 1623 | |||
| 1624 | pub const SOCK = struct { | ||
| 1625 | pub const STREAM = 1; | ||
| 1626 | pub const DGRAM = 2; | ||
| 1627 | pub const RAW = 3; | ||
| 1628 | pub const RDM = 4; | ||
| 1629 | pub const SEQPACKET = 5; | ||
| 1630 | pub const MAXADDRLEN = 255; | ||
| 1631 | |||
| 1632 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 1633 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 1634 | /// with any other `SOCK` bits. | ||
| 1635 | pub const CLOEXEC = 1 << 15; | ||
| 1636 | /// Not actually supported by Darwin, but Zig supplies a shim. | ||
| 1637 | /// This numerical value is not ABI-stable. It need only not conflict | ||
| 1638 | /// with any other `SOCK` bits. | ||
| 1639 | pub const NONBLOCK = 1 << 16; | ||
| 1640 | }; | ||
| 1641 | 1120 | ||
| 1642 | pub const IPPROTO = struct { | 1121 | /// Max open files per process |
| 1643 | pub const ICMP = 1; | 1122 | /// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html |
| 1644 | pub const ICMPV6 = 58; | 1123 | pub const OPEN_MAX = 10240; |
| 1645 | pub const TCP = 6; | ||
| 1646 | pub const UDP = 17; | ||
| 1647 | pub const IP = 0; | ||
| 1648 | pub const IPV6 = 41; | ||
| 1649 | }; | ||
| 1650 | 1124 | ||
| 1651 | pub const SOL = struct { | 1125 | // CPU families mapping |
| 1652 | pub const SOCKET = 0xffff; | 1126 | pub const CPUFAMILY = enum(u32) { |
| 1127 | UNKNOWN = 0, | ||
| 1128 | POWERPC_G3 = 0xcee41549, | ||
| 1129 | POWERPC_G4 = 0x77c184ae, | ||
| 1130 | POWERPC_G5 = 0xed76d8aa, | ||
| 1131 | INTEL_6_13 = 0xaa33392b, | ||
| 1132 | INTEL_PENRYN = 0x78ea4fbc, | ||
| 1133 | INTEL_NEHALEM = 0x6b5a4cd2, | ||
| 1134 | INTEL_WESTMERE = 0x573b5eec, | ||
| 1135 | INTEL_SANDYBRIDGE = 0x5490b78c, | ||
| 1136 | INTEL_IVYBRIDGE = 0x1f65e835, | ||
| 1137 | INTEL_HASWELL = 0x10b282dc, | ||
| 1138 | INTEL_BROADWELL = 0x582ed09c, | ||
| 1139 | INTEL_SKYLAKE = 0x37fc219f, | ||
| 1140 | INTEL_KABYLAKE = 0x0f817246, | ||
| 1141 | ARM_9 = 0xe73283ae, | ||
| 1142 | ARM_11 = 0x8ff620d8, | ||
| 1143 | ARM_XSCALE = 0x53b005f5, | ||
| 1144 | ARM_12 = 0xbd1b0ae9, | ||
| 1145 | ARM_13 = 0x0cc90e64, | ||
| 1146 | ARM_14 = 0x96077ef1, | ||
| 1147 | ARM_15 = 0xa8511bca, | ||
| 1148 | ARM_SWIFT = 0x1e2d6381, | ||
| 1149 | ARM_CYCLONE = 0x37a09642, | ||
| 1150 | ARM_TYPHOON = 0x2c91a47e, | ||
| 1151 | ARM_TWISTER = 0x92fb37c8, | ||
| 1152 | ARM_HURRICANE = 0x67ceee93, | ||
| 1153 | ARM_MONSOON_MISTRAL = 0xe81e7ef6, | ||
| 1154 | ARM_VORTEX_TEMPEST = 0x07d34b9f, | ||
| 1155 | ARM_LIGHTNING_THUNDER = 0x462504d2, | ||
| 1156 | ARM_FIRESTORM_ICESTORM = 0x1b588bb3, | ||
| 1157 | ARM_BLIZZARD_AVALANCHE = 0xda33d83d, | ||
| 1158 | ARM_EVEREST_SAWTOOTH = 0x8765edea, | ||
| 1159 | _, | ||
| 1653 | }; | 1160 | }; |
| 1654 | 1161 | ||
| 1655 | pub const SO = struct { | 1162 | pub const PT = struct { |
| 1656 | pub const DEBUG = 0x0001; | 1163 | pub const TRACE_ME = 0; |
| 1657 | pub const ACCEPTCONN = 0x0002; | 1164 | pub const READ_I = 1; |
| 1658 | pub const REUSEADDR = 0x0004; | 1165 | pub const READ_D = 2; |
| 1659 | pub const KEEPALIVE = 0x0008; | 1166 | pub const READ_U = 3; |
| 1660 | pub const DONTROUTE = 0x0010; | 1167 | pub const WRITE_I = 4; |
| 1661 | pub const BROADCAST = 0x0020; | 1168 | pub const WRITE_D = 5; |
| 1662 | pub const USELOOPBACK = 0x0040; | 1169 | pub const WRITE_U = 6; |
| 1663 | pub const LINGER = 0x1080; | 1170 | pub const CONTINUE = 7; |
| 1664 | pub const OOBINLINE = 0x0100; | 1171 | pub const KILL = 8; |
| 1665 | pub const REUSEPORT = 0x0200; | 1172 | pub const STEP = 9; |
| 1666 | pub const ACCEPTFILTER = 0x1000; | 1173 | pub const DETACH = 11; |
| 1667 | pub const SNDBUF = 0x1001; | 1174 | pub const SIGEXC = 12; |
| 1668 | pub const RCVBUF = 0x1002; | 1175 | pub const THUPDATE = 13; |
| 1669 | pub const SNDLOWAT = 0x1003; | 1176 | pub const ATTACHEXC = 14; |
| 1670 | pub const RCVLOWAT = 0x1004; | 1177 | pub const FORCEQUOTA = 30; |
| 1671 | pub const SNDTIMEO = 0x1005; | 1178 | pub const DENY_ATTACH = 31; |
| 1672 | pub const RCVTIMEO = 0x1006; | ||
| 1673 | pub const ERROR = 0x1007; | ||
| 1674 | pub const TYPE = 0x1008; | ||
| 1675 | |||
| 1676 | pub const NREAD = 0x1020; | ||
| 1677 | pub const NKE = 0x1021; | ||
| 1678 | pub const NOSIGPIPE = 0x1022; | ||
| 1679 | pub const NOADDRERR = 0x1023; | ||
| 1680 | pub const NWRITE = 0x1024; | ||
| 1681 | pub const REUSESHAREUID = 0x1025; | ||
| 1682 | }; | 1179 | }; |
| 1683 | 1180 | ||
| 1684 | pub const W = struct { | 1181 | pub const caddr_t = ?[*]u8; |
| 1685 | /// [XSI] no hang in wait/no child to reap | ||
| 1686 | pub const NOHANG = 0x00000001; | ||
| 1687 | /// [XSI] notify on stop, untraced child | ||
| 1688 | pub const UNTRACED = 0x00000002; | ||
| 1689 | 1182 | ||
| 1690 | pub fn EXITSTATUS(x: u32) u8 { | 1183 | pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: caddr_t, data: c_int) c_int; |
| 1691 | return @as(u8, @intCast(x >> 8)); | ||
| 1692 | } | ||
| 1693 | pub fn TERMSIG(x: u32) u32 { | ||
| 1694 | return status(x); | ||
| 1695 | } | ||
| 1696 | pub fn STOPSIG(x: u32) u32 { | ||
| 1697 | return x >> 8; | ||
| 1698 | } | ||
| 1699 | pub fn IFEXITED(x: u32) bool { | ||
| 1700 | return status(x) == 0; | ||
| 1701 | } | ||
| 1702 | pub fn IFSTOPPED(x: u32) bool { | ||
| 1703 | return status(x) == stopped and STOPSIG(x) != 0x13; | ||
| 1704 | } | ||
| 1705 | pub fn IFSIGNALED(x: u32) bool { | ||
| 1706 | return status(x) != stopped and status(x) != 0; | ||
| 1707 | } | ||
| 1708 | 1184 | ||
| 1709 | fn status(x: u32) u32 { | 1185 | pub const POSIX_SPAWN = struct { |
| 1710 | return x & 0o177; | 1186 | pub const RESETIDS = 0x0001; |
| 1711 | } | 1187 | pub const SETPGROUP = 0x0002; |
| 1712 | const stopped = 0o177; | 1188 | pub const SETSIGDEF = 0x0004; |
| 1189 | pub const SETSIGMASK = 0x0008; | ||
| 1190 | pub const SETEXEC = 0x0040; | ||
| 1191 | pub const START_SUSPENDED = 0x0080; | ||
| 1192 | pub const DISABLE_ASLR = 0x0100; | ||
| 1193 | pub const SETSID = 0x0400; | ||
| 1194 | pub const RESLIDE = 0x0800; | ||
| 1195 | pub const CLOEXEC_DEFAULT = 0x4000; | ||
| 1713 | }; | 1196 | }; |
| 1714 | 1197 | ||
| 1198 | pub const posix_spawnattr_t = *opaque {}; | ||
| 1199 | pub const posix_spawn_file_actions_t = *opaque {}; | ||
| 1200 | pub extern "c" fn posix_spawnattr_init(attr: *posix_spawnattr_t) c_int; | ||
| 1201 | pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) c_int; | ||
| 1202 | pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int; | ||
| 1203 | pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int; | ||
| 1204 | pub extern "c" fn posix_spawn_file_actions_init(actions: *posix_spawn_file_actions_t) c_int; | ||
| 1205 | pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) c_int; | ||
| 1206 | pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int; | ||
| 1207 | pub extern "c" fn posix_spawn_file_actions_addopen( | ||
| 1208 | actions: *posix_spawn_file_actions_t, | ||
| 1209 | filedes: fd_t, | ||
| 1210 | path: [*:0]const u8, | ||
| 1211 | oflag: c_int, | ||
| 1212 | mode: mode_t, | ||
| 1213 | ) c_int; | ||
| 1214 | pub extern "c" fn posix_spawn_file_actions_adddup2( | ||
| 1215 | actions: *posix_spawn_file_actions_t, | ||
| 1216 | filedes: fd_t, | ||
| 1217 | newfiledes: fd_t, | ||
| 1218 | ) c_int; | ||
| 1219 | pub extern "c" fn posix_spawn_file_actions_addinherit_np(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int; | ||
| 1220 | pub extern "c" fn posix_spawn_file_actions_addchdir_np(actions: *posix_spawn_file_actions_t, path: [*:0]const u8) c_int; | ||
| 1221 | pub extern "c" fn posix_spawn_file_actions_addfchdir_np(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int; | ||
| 1222 | pub extern "c" fn posix_spawn( | ||
| 1223 | pid: *pid_t, | ||
| 1224 | path: [*:0]const u8, | ||
| 1225 | actions: ?*const posix_spawn_file_actions_t, | ||
| 1226 | attr: ?*const posix_spawnattr_t, | ||
| 1227 | argv: [*:null]?[*:0]const u8, | ||
| 1228 | env: [*:null]?[*:0]const u8, | ||
| 1229 | ) c_int; | ||
| 1230 | pub extern "c" fn posix_spawnp( | ||
| 1231 | pid: *pid_t, | ||
| 1232 | path: [*:0]const u8, | ||
| 1233 | actions: ?*const posix_spawn_file_actions_t, | ||
| 1234 | attr: ?*const posix_spawnattr_t, | ||
| 1235 | argv: [*:null]?[*:0]const u8, | ||
| 1236 | env: [*:null]?[*:0]const u8, | ||
| 1237 | ) c_int; | ||
| 1238 | |||
| 1715 | pub const E = enum(u16) { | 1239 | pub const E = enum(u16) { |
| 1716 | /// No error occurred. | 1240 | /// No error occurred. |
| 1717 | SUCCESS = 0, | 1241 | SUCCESS = 0, |
| 1718 | |||
| 1719 | /// Operation not permitted | 1242 | /// Operation not permitted |
| 1720 | PERM = 1, | 1243 | PERM = 1, |
| 1721 | |||
| 1722 | /// No such file or directory | 1244 | /// No such file or directory |
| 1723 | NOENT = 2, | 1245 | NOENT = 2, |
| 1724 | |||
| 1725 | /// No such process | 1246 | /// No such process |
| 1726 | SRCH = 3, | 1247 | SRCH = 3, |
| 1727 | |||
| 1728 | /// Interrupted system call | 1248 | /// Interrupted system call |
| 1729 | INTR = 4, | 1249 | INTR = 4, |
| 1730 | |||
| 1731 | /// Input/output error | 1250 | /// Input/output error |
| 1732 | IO = 5, | 1251 | IO = 5, |
| 1733 | |||
| 1734 | /// Device not configured | 1252 | /// Device not configured |
| 1735 | NXIO = 6, | 1253 | NXIO = 6, |
| 1736 | |||
| 1737 | /// Argument list too long | 1254 | /// Argument list too long |
| 1738 | @"2BIG" = 7, | 1255 | @"2BIG" = 7, |
| 1739 | |||
| 1740 | /// Exec format error | 1256 | /// Exec format error |
| 1741 | NOEXEC = 8, | 1257 | NOEXEC = 8, |
| 1742 | |||
| 1743 | /// Bad file descriptor | 1258 | /// Bad file descriptor |
| 1744 | BADF = 9, | 1259 | BADF = 9, |
| 1745 | |||
| 1746 | /// No child processes | 1260 | /// No child processes |
| 1747 | CHILD = 10, | 1261 | CHILD = 10, |
| 1748 | |||
| 1749 | /// Resource deadlock avoided | 1262 | /// Resource deadlock avoided |
| 1750 | DEADLK = 11, | 1263 | DEADLK = 11, |
| 1751 | |||
| 1752 | /// Cannot allocate memory | 1264 | /// Cannot allocate memory |
| 1753 | NOMEM = 12, | 1265 | NOMEM = 12, |
| 1754 | |||
| 1755 | /// Permission denied | 1266 | /// Permission denied |
| 1756 | ACCES = 13, | 1267 | ACCES = 13, |
| 1757 | |||
| 1758 | /// Bad address | 1268 | /// Bad address |
| 1759 | FAULT = 14, | 1269 | FAULT = 14, |
| 1760 | |||
| 1761 | /// Block device required | 1270 | /// Block device required |
| 1762 | NOTBLK = 15, | 1271 | NOTBLK = 15, |
| 1763 | |||
| 1764 | /// Device / Resource busy | 1272 | /// Device / Resource busy |
| 1765 | BUSY = 16, | 1273 | BUSY = 16, |
| 1766 | |||
| 1767 | /// File exists | 1274 | /// File exists |
| 1768 | EXIST = 17, | 1275 | EXIST = 17, |
| 1769 | |||
| 1770 | /// Cross-device link | 1276 | /// Cross-device link |
| 1771 | XDEV = 18, | 1277 | XDEV = 18, |
| 1772 | |||
| 1773 | /// Operation not supported by device | 1278 | /// Operation not supported by device |
| 1774 | NODEV = 19, | 1279 | NODEV = 19, |
| 1775 | |||
| 1776 | /// Not a directory | 1280 | /// Not a directory |
| 1777 | NOTDIR = 20, | 1281 | NOTDIR = 20, |
| 1778 | |||
| 1779 | /// Is a directory | 1282 | /// Is a directory |
| 1780 | ISDIR = 21, | 1283 | ISDIR = 21, |
| 1781 | |||
| 1782 | /// Invalid argument | 1284 | /// Invalid argument |
| 1783 | INVAL = 22, | 1285 | INVAL = 22, |
| 1784 | |||
| 1785 | /// Too many open files in system | 1286 | /// Too many open files in system |
| 1786 | NFILE = 23, | 1287 | NFILE = 23, |
| 1787 | |||
| 1788 | /// Too many open files | 1288 | /// Too many open files |
| 1789 | MFILE = 24, | 1289 | MFILE = 24, |
| 1790 | |||
| 1791 | /// Inappropriate ioctl for device | 1290 | /// Inappropriate ioctl for device |
| 1792 | NOTTY = 25, | 1291 | NOTTY = 25, |
| 1793 | |||
| 1794 | /// Text file busy | 1292 | /// Text file busy |
| 1795 | TXTBSY = 26, | 1293 | TXTBSY = 26, |
| 1796 | |||
| 1797 | /// File too large | 1294 | /// File too large |
| 1798 | FBIG = 27, | 1295 | FBIG = 27, |
| 1799 | |||
| 1800 | /// No space left on device | 1296 | /// No space left on device |
| 1801 | NOSPC = 28, | 1297 | NOSPC = 28, |
| 1802 | |||
| 1803 | /// Illegal seek | 1298 | /// Illegal seek |
| 1804 | SPIPE = 29, | 1299 | SPIPE = 29, |
| 1805 | |||
| 1806 | /// Read-only file system | 1300 | /// Read-only file system |
| 1807 | ROFS = 30, | 1301 | ROFS = 30, |
| 1808 | |||
| 1809 | /// Too many links | 1302 | /// Too many links |
| 1810 | MLINK = 31, | 1303 | MLINK = 31, |
| 1811 | |||
| 1812 | /// Broken pipe | 1304 | /// Broken pipe |
| 1813 | PIPE = 32, | 1305 | PIPE = 32, |
| 1814 | |||
| 1815 | // math software | 1306 | // math software |
| 1816 | |||
| 1817 | /// Numerical argument out of domain | 1307 | /// Numerical argument out of domain |
| 1818 | DOM = 33, | 1308 | DOM = 33, |
| 1819 | |||
| 1820 | /// Result too large | 1309 | /// Result too large |
| 1821 | RANGE = 34, | 1310 | RANGE = 34, |
| 1822 | |||
| 1823 | // non-blocking and interrupt i/o | 1311 | // non-blocking and interrupt i/o |
| 1824 | |||
| 1825 | /// Resource temporarily unavailable | 1312 | /// Resource temporarily unavailable |
| 1826 | /// This is the same code used for `WOULDBLOCK`. | 1313 | /// This is the same code used for `WOULDBLOCK`. |
| 1827 | AGAIN = 35, | 1314 | AGAIN = 35, |
| 1828 | |||
| 1829 | /// Operation now in progress | 1315 | /// Operation now in progress |
| 1830 | INPROGRESS = 36, | 1316 | INPROGRESS = 36, |
| 1831 | |||
| 1832 | /// Operation already in progress | 1317 | /// Operation already in progress |
| 1833 | ALREADY = 37, | 1318 | ALREADY = 37, |
| 1834 | |||
| 1835 | // ipc/network software -- argument errors | 1319 | // ipc/network software -- argument errors |
| 1836 | |||
| 1837 | /// Socket operation on non-socket | 1320 | /// Socket operation on non-socket |
| 1838 | NOTSOCK = 38, | 1321 | NOTSOCK = 38, |
| 1839 | |||
| 1840 | /// Destination address required | 1322 | /// Destination address required |
| 1841 | DESTADDRREQ = 39, | 1323 | DESTADDRREQ = 39, |
| 1842 | |||
| 1843 | /// Message too long | 1324 | /// Message too long |
| 1844 | MSGSIZE = 40, | 1325 | MSGSIZE = 40, |
| 1845 | |||
| 1846 | /// Protocol wrong type for socket | 1326 | /// Protocol wrong type for socket |
| 1847 | PROTOTYPE = 41, | 1327 | PROTOTYPE = 41, |
| 1848 | |||
| 1849 | /// Protocol not available | 1328 | /// Protocol not available |
| 1850 | NOPROTOOPT = 42, | 1329 | NOPROTOOPT = 42, |
| 1851 | |||
| 1852 | /// Protocol not supported | 1330 | /// Protocol not supported |
| 1853 | PROTONOSUPPORT = 43, | 1331 | PROTONOSUPPORT = 43, |
| 1854 | |||
| 1855 | /// Socket type not supported | 1332 | /// Socket type not supported |
| 1856 | SOCKTNOSUPPORT = 44, | 1333 | SOCKTNOSUPPORT = 44, |
| 1857 | |||
| 1858 | /// Operation not supported | 1334 | /// Operation not supported |
| 1859 | /// The same code is used for `NOTSUP`. | 1335 | /// The same code is used for `NOTSUP`. |
| 1860 | OPNOTSUPP = 45, | 1336 | OPNOTSUPP = 45, |
| 1861 | |||
| 1862 | /// Protocol family not supported | 1337 | /// Protocol family not supported |
| 1863 | PFNOSUPPORT = 46, | 1338 | PFNOSUPPORT = 46, |
| 1864 | |||
| 1865 | /// Address family not supported by protocol family | 1339 | /// Address family not supported by protocol family |
| 1866 | AFNOSUPPORT = 47, | 1340 | AFNOSUPPORT = 47, |
| 1867 | |||
| 1868 | /// Address already in use | 1341 | /// Address already in use |
| 1869 | ADDRINUSE = 48, | 1342 | ADDRINUSE = 48, |
| 1870 | /// Can't assign requested address | 1343 | /// Can't assign requested address |
| 1871 | |||
| 1872 | // ipc/network software -- operational errors | 1344 | // ipc/network software -- operational errors |
| 1873 | ADDRNOTAVAIL = 49, | 1345 | ADDRNOTAVAIL = 49, |
| 1874 | |||
| 1875 | /// Network is down | 1346 | /// Network is down |
| 1876 | NETDOWN = 50, | 1347 | NETDOWN = 50, |
| 1877 | |||
| 1878 | /// Network is unreachable | 1348 | /// Network is unreachable |
| 1879 | NETUNREACH = 51, | 1349 | NETUNREACH = 51, |
| 1880 | |||
| 1881 | /// Network dropped connection on reset | 1350 | /// Network dropped connection on reset |
| 1882 | NETRESET = 52, | 1351 | NETRESET = 52, |
| 1883 | |||
| 1884 | /// Software caused connection abort | 1352 | /// Software caused connection abort |
| 1885 | CONNABORTED = 53, | 1353 | CONNABORTED = 53, |
| 1886 | |||
| 1887 | /// Connection reset by peer | 1354 | /// Connection reset by peer |
| 1888 | CONNRESET = 54, | 1355 | CONNRESET = 54, |
| 1889 | |||
| 1890 | /// No buffer space available | 1356 | /// No buffer space available |
| 1891 | NOBUFS = 55, | 1357 | NOBUFS = 55, |
| 1892 | |||
| 1893 | /// Socket is already connected | 1358 | /// Socket is already connected |
| 1894 | ISCONN = 56, | 1359 | ISCONN = 56, |
| 1895 | |||
| 1896 | /// Socket is not connected | 1360 | /// Socket is not connected |
| 1897 | NOTCONN = 57, | 1361 | NOTCONN = 57, |
| 1898 | |||
| 1899 | /// Can't send after socket shutdown | 1362 | /// Can't send after socket shutdown |
| 1900 | SHUTDOWN = 58, | 1363 | SHUTDOWN = 58, |
| 1901 | |||
| 1902 | /// Too many references: can't splice | 1364 | /// Too many references: can't splice |
| 1903 | TOOMANYREFS = 59, | 1365 | TOOMANYREFS = 59, |
| 1904 | |||
| 1905 | /// Operation timed out | 1366 | /// Operation timed out |
| 1906 | TIMEDOUT = 60, | 1367 | TIMEDOUT = 60, |
| 1907 | |||
| 1908 | /// Connection refused | 1368 | /// Connection refused |
| 1909 | CONNREFUSED = 61, | 1369 | CONNREFUSED = 61, |
| 1910 | |||
| 1911 | /// Too many levels of symbolic links | 1370 | /// Too many levels of symbolic links |
| 1912 | LOOP = 62, | 1371 | LOOP = 62, |
| 1913 | |||
| 1914 | /// File name too long | 1372 | /// File name too long |
| 1915 | NAMETOOLONG = 63, | 1373 | NAMETOOLONG = 63, |
| 1916 | |||
| 1917 | /// Host is down | 1374 | /// Host is down |
| 1918 | HOSTDOWN = 64, | 1375 | HOSTDOWN = 64, |
| 1919 | |||
| 1920 | /// No route to host | 1376 | /// No route to host |
| 1921 | HOSTUNREACH = 65, | 1377 | HOSTUNREACH = 65, |
| 1922 | /// Directory not empty | 1378 | /// Directory not empty |
| 1923 | |||
| 1924 | // quotas & mush | 1379 | // quotas & mush |
| 1925 | NOTEMPTY = 66, | 1380 | NOTEMPTY = 66, |
| 1926 | |||
| 1927 | /// Too many processes | 1381 | /// Too many processes |
| 1928 | PROCLIM = 67, | 1382 | PROCLIM = 67, |
| 1929 | |||
| 1930 | /// Too many users | 1383 | /// Too many users |
| 1931 | USERS = 68, | 1384 | USERS = 68, |
| 1932 | /// Disc quota exceeded | 1385 | /// Disc quota exceeded |
| 1933 | |||
| 1934 | // Network File System | 1386 | // Network File System |
| 1935 | DQUOT = 69, | 1387 | DQUOT = 69, |
| 1936 | |||
| 1937 | /// Stale NFS file handle | 1388 | /// Stale NFS file handle |
| 1938 | STALE = 70, | 1389 | STALE = 70, |
| 1939 | |||
| 1940 | /// Too many levels of remote in path | 1390 | /// Too many levels of remote in path |
| 1941 | REMOTE = 71, | 1391 | REMOTE = 71, |
| 1942 | |||
| 1943 | /// RPC struct is bad | 1392 | /// RPC struct is bad |
| 1944 | BADRPC = 72, | 1393 | BADRPC = 72, |
| 1945 | |||
| 1946 | /// RPC version wrong | 1394 | /// RPC version wrong |
| 1947 | RPCMISMATCH = 73, | 1395 | RPCMISMATCH = 73, |
| 1948 | |||
| 1949 | /// RPC prog. not avail | 1396 | /// RPC prog. not avail |
| 1950 | PROGUNAVAIL = 74, | 1397 | PROGUNAVAIL = 74, |
| 1951 | |||
| 1952 | /// Program version wrong | 1398 | /// Program version wrong |
| 1953 | PROGMISMATCH = 75, | 1399 | PROGMISMATCH = 75, |
| 1954 | |||
| 1955 | /// Bad procedure for program | 1400 | /// Bad procedure for program |
| 1956 | PROCUNAVAIL = 76, | 1401 | PROCUNAVAIL = 76, |
| 1957 | |||
| 1958 | /// No locks available | 1402 | /// No locks available |
| 1959 | NOLCK = 77, | 1403 | NOLCK = 77, |
| 1960 | |||
| 1961 | /// Function not implemented | 1404 | /// Function not implemented |
| 1962 | NOSYS = 78, | 1405 | NOSYS = 78, |
| 1963 | |||
| 1964 | /// Inappropriate file type or format | 1406 | /// Inappropriate file type or format |
| 1965 | FTYPE = 79, | 1407 | FTYPE = 79, |
| 1966 | |||
| 1967 | /// Authentication error | 1408 | /// Authentication error |
| 1968 | AUTH = 80, | 1409 | AUTH = 80, |
| 1969 | |||
| 1970 | /// Need authenticator | 1410 | /// Need authenticator |
| 1971 | NEEDAUTH = 81, | 1411 | NEEDAUTH = 81, |
| 1972 | |||
| 1973 | // Intelligent device errors | 1412 | // Intelligent device errors |
| 1974 | |||
| 1975 | /// Device power is off | 1413 | /// Device power is off |
| 1976 | PWROFF = 82, | 1414 | PWROFF = 82, |
| 1977 | |||
| 1978 | /// Device error, e.g. paper out | 1415 | /// Device error, e.g. paper out |
| 1979 | DEVERR = 83, | 1416 | DEVERR = 83, |
| 1980 | |||
| 1981 | /// Value too large to be stored in data type | 1417 | /// Value too large to be stored in data type |
| 1982 | OVERFLOW = 84, | 1418 | OVERFLOW = 84, |
| 1983 | |||
| 1984 | // Program loading errors | 1419 | // Program loading errors |
| 1985 | |||
| 1986 | /// Bad executable | 1420 | /// Bad executable |
| 1987 | BADEXEC = 85, | 1421 | BADEXEC = 85, |
| 1988 | |||
| 1989 | /// Bad CPU type in executable | 1422 | /// Bad CPU type in executable |
| 1990 | BADARCH = 86, | 1423 | BADARCH = 86, |
| 1991 | |||
| 1992 | /// Shared library version mismatch | 1424 | /// Shared library version mismatch |
| 1993 | SHLIBVERS = 87, | 1425 | SHLIBVERS = 87, |
| 1994 | |||
| 1995 | /// Malformed Macho file | 1426 | /// Malformed Macho file |
| 1996 | BADMACHO = 88, | 1427 | BADMACHO = 88, |
| 1997 | |||
| 1998 | /// Operation canceled | 1428 | /// Operation canceled |
| 1999 | CANCELED = 89, | 1429 | CANCELED = 89, |
| 2000 | |||
| 2001 | /// Identifier removed | 1430 | /// Identifier removed |
| 2002 | IDRM = 90, | 1431 | IDRM = 90, |
| 2003 | |||
| 2004 | /// No message of desired type | 1432 | /// No message of desired type |
| 2005 | NOMSG = 91, | 1433 | NOMSG = 91, |
| 2006 | |||
| 2007 | /// Illegal byte sequence | 1434 | /// Illegal byte sequence |
| 2008 | ILSEQ = 92, | 1435 | ILSEQ = 92, |
| 2009 | |||
| 2010 | /// Attribute not found | 1436 | /// Attribute not found |
| 2011 | NOATTR = 93, | 1437 | NOATTR = 93, |
| 2012 | |||
| 2013 | /// Bad message | 1438 | /// Bad message |
| 2014 | BADMSG = 94, | 1439 | BADMSG = 94, |
| 2015 | |||
| 2016 | /// Reserved | 1440 | /// Reserved |
| 2017 | MULTIHOP = 95, | 1441 | MULTIHOP = 95, |
| 2018 | |||
| 2019 | /// No message available on STREAM | 1442 | /// No message available on STREAM |
| 2020 | NODATA = 96, | 1443 | NODATA = 96, |
| 2021 | |||
| 2022 | /// Reserved | 1444 | /// Reserved |
| 2023 | NOLINK = 97, | 1445 | NOLINK = 97, |
| 2024 | |||
| 2025 | /// No STREAM resources | 1446 | /// No STREAM resources |
| 2026 | NOSR = 98, | 1447 | NOSR = 98, |
| 2027 | |||
| 2028 | /// Not a STREAM | 1448 | /// Not a STREAM |
| 2029 | NOSTR = 99, | 1449 | NOSTR = 99, |
| 2030 | |||
| 2031 | /// Protocol error | 1450 | /// Protocol error |
| 2032 | PROTO = 100, | 1451 | PROTO = 100, |
| 2033 | |||
| 2034 | /// STREAM ioctl timeout | 1452 | /// STREAM ioctl timeout |
| 2035 | TIME = 101, | 1453 | TIME = 101, |
| 2036 | |||
| 2037 | /// No such policy registered | 1454 | /// No such policy registered |
| 2038 | NOPOLICY = 103, | 1455 | NOPOLICY = 103, |
| 2039 | |||
| 2040 | /// State not recoverable | 1456 | /// State not recoverable |
| 2041 | NOTRECOVERABLE = 104, | 1457 | NOTRECOVERABLE = 104, |
| 2042 | |||
| 2043 | /// Previous owner died | 1458 | /// Previous owner died |
| 2044 | OWNERDEAD = 105, | 1459 | OWNERDEAD = 105, |
| 2045 | |||
| 2046 | /// Interface output queue is full | 1460 | /// Interface output queue is full |
| 2047 | QFULL = 106, | 1461 | QFULL = 106, |
| 2048 | |||
| 2049 | _, | ||
| 2050 | }; | ||
| 2051 | |||
| 2052 | /// Kernel return values | ||
| 2053 | pub const KernE = enum(u32) { | ||
| 2054 | SUCCESS = 0, | ||
| 2055 | |||
| 2056 | /// Specified address is not currently valid | ||
| 2057 | INVALID_ADDRESS = 1, | ||
| 2058 | |||
| 2059 | /// Specified memory is valid, but does not permit the | ||
| 2060 | /// required forms of access. | ||
| 2061 | PROTECTION_FAILURE = 2, | ||
| 2062 | |||
| 2063 | /// The address range specified is already in use, or | ||
| 2064 | /// no address range of the size specified could be | ||
| 2065 | /// found. | ||
| 2066 | NO_SPACE = 3, | ||
| 2067 | |||
| 2068 | /// The function requested was not applicable to this | ||
| 2069 | /// type of argument, or an argument is invalid | ||
| 2070 | INVALID_ARGUMENT = 4, | ||
| 2071 | |||
| 2072 | /// The function could not be performed. A catch-all. | ||
| 2073 | FAILURE = 5, | ||
| 2074 | |||
| 2075 | /// A system resource could not be allocated to fulfill | ||
| 2076 | /// this request. This failure may not be permanent. | ||
| 2077 | RESOURCE_SHORTAGE = 6, | ||
| 2078 | |||
| 2079 | /// The task in question does not hold receive rights | ||
| 2080 | /// for the port argument. | ||
| 2081 | NOT_RECEIVER = 7, | ||
| 2082 | |||
| 2083 | /// Bogus access restriction. | ||
| 2084 | NO_ACCESS = 8, | ||
| 2085 | |||
| 2086 | /// During a page fault, the target address refers to a | ||
| 2087 | /// memory object that has been destroyed. This | ||
| 2088 | /// failure is permanent. | ||
| 2089 | MEMORY_FAILURE = 9, | ||
| 2090 | |||
| 2091 | /// During a page fault, the memory object indicated | ||
| 2092 | /// that the data could not be returned. This failure | ||
| 2093 | /// may be temporary; future attempts to access this | ||
| 2094 | /// same data may succeed, as defined by the memory | ||
| 2095 | /// object. | ||
| 2096 | MEMORY_ERROR = 10, | ||
| 2097 | |||
| 2098 | /// The receive right is already a member of the portset. | ||
| 2099 | ALREADY_IN_SET = 11, | ||
| 2100 | |||
| 2101 | /// The receive right is not a member of a port set. | ||
| 2102 | NOT_IN_SET = 12, | ||
| 2103 | |||
| 2104 | /// The name already denotes a right in the task. | ||
| 2105 | NAME_EXISTS = 13, | ||
| 2106 | |||
| 2107 | /// The operation was aborted. Ipc code will | ||
| 2108 | /// catch this and reflect it as a message error. | ||
| 2109 | ABORTED = 14, | ||
| 2110 | |||
| 2111 | /// The name doesn't denote a right in the task. | ||
| 2112 | INVALID_NAME = 15, | ||
| 2113 | |||
| 2114 | /// Target task isn't an active task. | ||
| 2115 | INVALID_TASK = 16, | ||
| 2116 | |||
| 2117 | /// The name denotes a right, but not an appropriate right. | ||
| 2118 | INVALID_RIGHT = 17, | ||
| 2119 | |||
| 2120 | /// A blatant range error. | ||
| 2121 | INVALID_VALUE = 18, | ||
| 2122 | |||
| 2123 | /// Operation would overflow limit on user-references. | ||
| 2124 | UREFS_OVERFLOW = 19, | ||
| 2125 | |||
| 2126 | /// The supplied (port) capability is improper. | ||
| 2127 | INVALID_CAPABILITY = 20, | ||
| 2128 | |||
| 2129 | /// The task already has send or receive rights | ||
| 2130 | /// for the port under another name. | ||
| 2131 | RIGHT_EXISTS = 21, | ||
| 2132 | |||
| 2133 | /// Target host isn't actually a host. | ||
| 2134 | INVALID_HOST = 22, | ||
| 2135 | |||
| 2136 | /// An attempt was made to supply "precious" data | ||
| 2137 | /// for memory that is already present in a | ||
| 2138 | /// memory object. | ||
| 2139 | MEMORY_PRESENT = 23, | ||
| 2140 | |||
| 2141 | /// A page was requested of a memory manager via | ||
| 2142 | /// memory_object_data_request for an object using | ||
| 2143 | /// a MEMORY_OBJECT_COPY_CALL strategy, with the | ||
| 2144 | /// VM_PROT_WANTS_COPY flag being used to specify | ||
| 2145 | /// that the page desired is for a copy of the | ||
| 2146 | /// object, and the memory manager has detected | ||
| 2147 | /// the page was pushed into a copy of the object | ||
| 2148 | /// while the kernel was walking the shadow chain | ||
| 2149 | /// from the copy to the object. This error code | ||
| 2150 | /// is delivered via memory_object_data_error | ||
| 2151 | /// and is handled by the kernel (it forces the | ||
| 2152 | /// kernel to restart the fault). It will not be | ||
| 2153 | /// seen by users. | ||
| 2154 | MEMORY_DATA_MOVED = 24, | ||
| 2155 | |||
| 2156 | /// A strategic copy was attempted of an object | ||
| 2157 | /// upon which a quicker copy is now possible. | ||
| 2158 | /// The caller should retry the copy using | ||
| 2159 | /// vm_object_copy_quickly. This error code | ||
| 2160 | /// is seen only by the kernel. | ||
| 2161 | MEMORY_RESTART_COPY = 25, | ||
| 2162 | |||
| 2163 | /// An argument applied to assert processor set privilege | ||
| 2164 | /// was not a processor set control port. | ||
| 2165 | INVALID_PROCESSOR_SET = 26, | ||
| 2166 | |||
| 2167 | /// The specified scheduling attributes exceed the thread's | ||
| 2168 | /// limits. | ||
| 2169 | POLICY_LIMIT = 27, | ||
| 2170 | |||
| 2171 | /// The specified scheduling policy is not currently | ||
| 2172 | /// enabled for the processor set. | ||
| 2173 | INVALID_POLICY = 28, | ||
| 2174 | |||
| 2175 | /// The external memory manager failed to initialize the | ||
| 2176 | /// memory object. | ||
| 2177 | INVALID_OBJECT = 29, | ||
| 2178 | |||
| 2179 | /// A thread is attempting to wait for an event for which | ||
| 2180 | /// there is already a waiting thread. | ||
| 2181 | ALREADY_WAITING = 30, | ||
| 2182 | |||
| 2183 | /// An attempt was made to destroy the default processor | ||
| 2184 | /// set. | ||
| 2185 | DEFAULT_SET = 31, | ||
| 2186 | |||
| 2187 | /// An attempt was made to fetch an exception port that is | ||
| 2188 | /// protected, or to abort a thread while processing a | ||
| 2189 | /// protected exception. | ||
| 2190 | EXCEPTION_PROTECTED = 32, | ||
| 2191 | |||
| 2192 | /// A ledger was required but not supplied. | ||
| 2193 | INVALID_LEDGER = 33, | ||
| 2194 | |||
| 2195 | /// The port was not a memory cache control port. | ||
| 2196 | INVALID_MEMORY_CONTROL = 34, | ||
| 2197 | |||
| 2198 | /// An argument supplied to assert security privilege | ||
| 2199 | /// was not a host security port. | ||
| 2200 | INVALID_SECURITY = 35, | ||
| 2201 | |||
| 2202 | /// thread_depress_abort was called on a thread which | ||
| 2203 | /// was not currently depressed. | ||
| 2204 | NOT_DEPRESSED = 36, | ||
| 2205 | |||
| 2206 | /// Object has been terminated and is no longer available | ||
| 2207 | TERMINATED = 37, | ||
| 2208 | |||
| 2209 | /// Lock set has been destroyed and is no longer available. | ||
| 2210 | LOCK_SET_DESTROYED = 38, | ||
| 2211 | |||
| 2212 | /// The thread holding the lock terminated before releasing | ||
| 2213 | /// the lock | ||
| 2214 | LOCK_UNSTABLE = 39, | ||
| 2215 | |||
| 2216 | /// The lock is already owned by another thread | ||
| 2217 | LOCK_OWNED = 40, | ||
| 2218 | |||
| 2219 | /// The lock is already owned by the calling thread | ||
| 2220 | LOCK_OWNED_SELF = 41, | ||
| 2221 | |||
| 2222 | /// Semaphore has been destroyed and is no longer available. | ||
| 2223 | SEMAPHORE_DESTROYED = 42, | ||
| 2224 | |||
| 2225 | /// Return from RPC indicating the target server was | ||
| 2226 | /// terminated before it successfully replied | ||
| 2227 | RPC_SERVER_TERMINATED = 43, | ||
| 2228 | |||
| 2229 | /// Terminate an orphaned activation. | ||
| 2230 | RPC_TERMINATE_ORPHAN = 44, | ||
| 2231 | |||
| 2232 | /// Allow an orphaned activation to continue executing. | ||
| 2233 | RPC_CONTINUE_ORPHAN = 45, | ||
| 2234 | |||
| 2235 | /// Empty thread activation (No thread linked to it) | ||
| 2236 | NOT_SUPPORTED = 46, | ||
| 2237 | |||
| 2238 | /// Remote node down or inaccessible. | ||
| 2239 | NODE_DOWN = 47, | ||
| 2240 | |||
| 2241 | /// A signalled thread was not actually waiting. | ||
| 2242 | NOT_WAITING = 48, | ||
| 2243 | |||
| 2244 | /// Some thread-oriented operation (semaphore_wait) timed out | ||
| 2245 | OPERATION_TIMED_OUT = 49, | ||
| 2246 | |||
| 2247 | /// During a page fault, indicates that the page was rejected | ||
| 2248 | /// as a result of a signature check. | ||
| 2249 | CODESIGN_ERROR = 50, | ||
| 2250 | |||
| 2251 | /// The requested property cannot be changed at this time. | ||
| 2252 | POLICY_STATIC = 51, | ||
| 2253 | |||
| 2254 | /// The provided buffer is of insufficient size for the requested data. | ||
| 2255 | INSUFFICIENT_BUFFER_SIZE = 52, | ||
| 2256 | |||
| 2257 | /// Denied by security policy | ||
| 2258 | DENIED = 53, | ||
| 2259 | |||
| 2260 | /// The KC on which the function is operating is missing | ||
| 2261 | MISSING_KC = 54, | ||
| 2262 | |||
| 2263 | /// The KC on which the function is operating is invalid | ||
| 2264 | INVALID_KC = 55, | ||
| 2265 | |||
| 2266 | /// A search or query operation did not return a result | ||
| 2267 | NOT_FOUND = 56, | ||
| 2268 | |||
| 2269 | _, | ||
| 2270 | }; | ||
| 2271 | |||
| 2272 | pub const mach_msg_return_t = kern_return_t; | ||
| 2273 | |||
| 2274 | pub fn getMachMsgError(err: mach_msg_return_t) MachMsgE { | ||
| 2275 | return @as(MachMsgE, @enumFromInt(@as(u32, @truncate(@as(usize, @intCast(err)))))); | ||
| 2276 | } | ||
| 2277 | |||
| 2278 | /// All special error code bits defined below. | ||
| 2279 | pub const MACH_MSG_MASK: u32 = 0x3e00; | ||
| 2280 | /// No room in IPC name space for another capability name. | ||
| 2281 | pub const MACH_MSG_IPC_SPACE: u32 = 0x2000; | ||
| 2282 | /// No room in VM address space for out-of-line memory. | ||
| 2283 | pub const MACH_MSG_VM_SPACE: u32 = 0x1000; | ||
| 2284 | /// Kernel resource shortage handling out-of-line memory. | ||
| 2285 | pub const MACH_MSG_IPC_KERNEL: u32 = 0x800; | ||
| 2286 | /// Kernel resource shortage handling an IPC capability. | ||
| 2287 | pub const MACH_MSG_VM_KERNEL: u32 = 0x400; | ||
| 2288 | |||
| 2289 | /// Mach msg return values | ||
| 2290 | pub const MachMsgE = enum(u32) { | ||
| 2291 | SUCCESS = 0x00000000, | ||
| 2292 | |||
| 2293 | /// Thread is waiting to send. (Internal use only.) | ||
| 2294 | SEND_IN_PROGRESS = 0x10000001, | ||
| 2295 | /// Bogus in-line data. | ||
| 2296 | SEND_INVALID_DATA = 0x10000002, | ||
| 2297 | /// Bogus destination port. | ||
| 2298 | SEND_INVALID_DEST = 0x10000003, | ||
| 2299 | /// Message not sent before timeout expired. | ||
| 2300 | SEND_TIMED_OUT = 0x10000004, | ||
| 2301 | /// Bogus voucher port. | ||
| 2302 | SEND_INVALID_VOUCHER = 0x10000005, | ||
| 2303 | /// Software interrupt. | ||
| 2304 | SEND_INTERRUPTED = 0x10000007, | ||
| 2305 | /// Data doesn't contain a complete message. | ||
| 2306 | SEND_MSG_TOO_SMALL = 0x10000008, | ||
| 2307 | /// Bogus reply port. | ||
| 2308 | SEND_INVALID_REPLY = 0x10000009, | ||
| 2309 | /// Bogus port rights in the message body. | ||
| 2310 | SEND_INVALID_RIGHT = 0x1000000a, | ||
| 2311 | /// Bogus notify port argument. | ||
| 2312 | SEND_INVALID_NOTIFY = 0x1000000b, | ||
| 2313 | /// Invalid out-of-line memory pointer. | ||
| 2314 | SEND_INVALID_MEMORY = 0x1000000c, | ||
| 2315 | /// No message buffer is available. | ||
| 2316 | SEND_NO_BUFFER = 0x1000000d, | ||
| 2317 | /// Send is too large for port | ||
| 2318 | SEND_TOO_LARGE = 0x1000000e, | ||
| 2319 | /// Invalid msg-type specification. | ||
| 2320 | SEND_INVALID_TYPE = 0x1000000f, | ||
| 2321 | /// A field in the header had a bad value. | ||
| 2322 | SEND_INVALID_HEADER = 0x10000010, | ||
| 2323 | /// The trailer to be sent does not match kernel format. | ||
| 2324 | SEND_INVALID_TRAILER = 0x10000011, | ||
| 2325 | /// The sending thread context did not match the context on the dest port | ||
| 2326 | SEND_INVALID_CONTEXT = 0x10000012, | ||
| 2327 | /// compatibility: no longer a returned error | ||
| 2328 | SEND_INVALID_RT_OOL_SIZE = 0x10000015, | ||
| 2329 | /// The destination port doesn't accept ports in body | ||
| 2330 | SEND_NO_GRANT_DEST = 0x10000016, | ||
| 2331 | /// Message send was rejected by message filter | ||
| 2332 | SEND_MSG_FILTERED = 0x10000017, | ||
| 2333 | |||
| 2334 | /// Thread is waiting for receive. (Internal use only.) | ||
| 2335 | RCV_IN_PROGRESS = 0x10004001, | ||
| 2336 | /// Bogus name for receive port/port-set. | ||
| 2337 | RCV_INVALID_NAME = 0x10004002, | ||
| 2338 | /// Didn't get a message within the timeout value. | ||
| 2339 | RCV_TIMED_OUT = 0x10004003, | ||
| 2340 | /// Message buffer is not large enough for inline data. | ||
| 2341 | RCV_TOO_LARGE = 0x10004004, | ||
| 2342 | /// Software interrupt. | ||
| 2343 | RCV_INTERRUPTED = 0x10004005, | ||
| 2344 | /// compatibility: no longer a returned error | ||
| 2345 | RCV_PORT_CHANGED = 0x10004006, | ||
| 2346 | /// Bogus notify port argument. | ||
| 2347 | RCV_INVALID_NOTIFY = 0x10004007, | ||
| 2348 | /// Bogus message buffer for inline data. | ||
| 2349 | RCV_INVALID_DATA = 0x10004008, | ||
| 2350 | /// Port/set was sent away/died during receive. | ||
| 2351 | RCV_PORT_DIED = 0x10004009, | ||
| 2352 | /// compatibility: no longer a returned error | ||
| 2353 | RCV_IN_SET = 0x1000400a, | ||
| 2354 | /// Error receiving message header. See special bits. | ||
| 2355 | RCV_HEADER_ERROR = 0x1000400b, | ||
| 2356 | /// Error receiving message body. See special bits. | ||
| 2357 | RCV_BODY_ERROR = 0x1000400c, | ||
| 2358 | /// Invalid msg-type specification in scatter list. | ||
| 2359 | RCV_INVALID_TYPE = 0x1000400d, | ||
| 2360 | /// Out-of-line overwrite region is not large enough | ||
| 2361 | RCV_SCATTER_SMALL = 0x1000400e, | ||
| 2362 | /// trailer type or number of trailer elements not supported | ||
| 2363 | RCV_INVALID_TRAILER = 0x1000400f, | ||
| 2364 | /// Waiting for receive with timeout. (Internal use only.) | ||
| 2365 | RCV_IN_PROGRESS_TIMED = 0x10004011, | ||
| 2366 | /// invalid reply port used in a STRICT_REPLY message | ||
| 2367 | RCV_INVALID_REPLY = 0x10004012, | ||
| 2368 | }; | ||
| 2369 | |||
| 2370 | pub const SIGSTKSZ = 131072; | ||
| 2371 | pub const MINSIGSTKSZ = 32768; | ||
| 2372 | |||
| 2373 | pub const SS_ONSTACK = 1; | ||
| 2374 | pub const SS_DISABLE = 4; | ||
| 2375 | |||
| 2376 | pub const stack_t = extern struct { | ||
| 2377 | sp: [*]u8, | ||
| 2378 | size: isize, | ||
| 2379 | flags: i32, | ||
| 2380 | }; | ||
| 2381 | |||
| 2382 | pub const S = struct { | ||
| 2383 | pub const IFMT = 0o170000; | ||
| 2384 | |||
| 2385 | pub const IFIFO = 0o010000; | ||
| 2386 | pub const IFCHR = 0o020000; | ||
| 2387 | pub const IFDIR = 0o040000; | ||
| 2388 | pub const IFBLK = 0o060000; | ||
| 2389 | pub const IFREG = 0o100000; | ||
| 2390 | pub const IFLNK = 0o120000; | ||
| 2391 | pub const IFSOCK = 0o140000; | ||
| 2392 | pub const IFWHT = 0o160000; | ||
| 2393 | |||
| 2394 | pub const ISUID = 0o4000; | ||
| 2395 | pub const ISGID = 0o2000; | ||
| 2396 | pub const ISVTX = 0o1000; | ||
| 2397 | pub const IRWXU = 0o700; | ||
| 2398 | pub const IRUSR = 0o400; | ||
| 2399 | pub const IWUSR = 0o200; | ||
| 2400 | pub const IXUSR = 0o100; | ||
| 2401 | pub const IRWXG = 0o070; | ||
| 2402 | pub const IRGRP = 0o040; | ||
| 2403 | pub const IWGRP = 0o020; | ||
| 2404 | pub const IXGRP = 0o010; | ||
| 2405 | pub const IRWXO = 0o007; | ||
| 2406 | pub const IROTH = 0o004; | ||
| 2407 | pub const IWOTH = 0o002; | ||
| 2408 | pub const IXOTH = 0o001; | ||
| 2409 | |||
| 2410 | pub fn ISFIFO(m: u32) bool { | ||
| 2411 | return m & IFMT == IFIFO; | ||
| 2412 | } | ||
| 2413 | |||
| 2414 | pub fn ISCHR(m: u32) bool { | ||
| 2415 | return m & IFMT == IFCHR; | ||
| 2416 | } | ||
| 2417 | |||
| 2418 | pub fn ISDIR(m: u32) bool { | ||
| 2419 | return m & IFMT == IFDIR; | ||
| 2420 | } | ||
| 2421 | |||
| 2422 | pub fn ISBLK(m: u32) bool { | ||
| 2423 | return m & IFMT == IFBLK; | ||
| 2424 | } | ||
| 2425 | |||
| 2426 | pub fn ISREG(m: u32) bool { | ||
| 2427 | return m & IFMT == IFREG; | ||
| 2428 | } | ||
| 2429 | |||
| 2430 | pub fn ISLNK(m: u32) bool { | ||
| 2431 | return m & IFMT == IFLNK; | ||
| 2432 | } | ||
| 2433 | |||
| 2434 | pub fn ISSOCK(m: u32) bool { | ||
| 2435 | return m & IFMT == IFSOCK; | ||
| 2436 | } | ||
| 2437 | |||
| 2438 | pub fn IWHT(m: u32) bool { | ||
| 2439 | return m & IFMT == IFWHT; | ||
| 2440 | } | ||
| 2441 | }; | ||
| 2442 | |||
| 2443 | pub const HOST_NAME_MAX = 72; | ||
| 2444 | |||
| 2445 | pub const addrinfo = extern struct { | ||
| 2446 | flags: i32, | ||
| 2447 | family: i32, | ||
| 2448 | socktype: i32, | ||
| 2449 | protocol: i32, | ||
| 2450 | addrlen: socklen_t, | ||
| 2451 | canonname: ?[*:0]u8, | ||
| 2452 | addr: ?*sockaddr, | ||
| 2453 | next: ?*addrinfo, | ||
| 2454 | }; | ||
| 2455 | |||
| 2456 | pub const RTLD = struct { | ||
| 2457 | pub const LAZY = 0x1; | ||
| 2458 | pub const NOW = 0x2; | ||
| 2459 | pub const LOCAL = 0x4; | ||
| 2460 | pub const GLOBAL = 0x8; | ||
| 2461 | pub const NOLOAD = 0x10; | ||
| 2462 | pub const NODELETE = 0x80; | ||
| 2463 | pub const FIRST = 0x100; | ||
| 2464 | |||
| 2465 | pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); | ||
| 2466 | pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); | ||
| 2467 | pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); | ||
| 2468 | pub const MAIN_ONLY = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -5))))); | ||
| 2469 | }; | ||
| 2470 | |||
| 2471 | pub const F = struct { | ||
| 2472 | /// duplicate file descriptor | ||
| 2473 | pub const DUPFD = 0; | ||
| 2474 | /// get file descriptor flags | ||
| 2475 | pub const GETFD = 1; | ||
| 2476 | /// set file descriptor flags | ||
| 2477 | pub const SETFD = 2; | ||
| 2478 | /// get file status flags | ||
| 2479 | pub const GETFL = 3; | ||
| 2480 | /// set file status flags | ||
| 2481 | pub const SETFL = 4; | ||
| 2482 | /// get SIGIO/SIGURG proc/pgrp | ||
| 2483 | pub const GETOWN = 5; | ||
| 2484 | /// set SIGIO/SIGURG proc/pgrp | ||
| 2485 | pub const SETOWN = 6; | ||
| 2486 | /// get record locking information | ||
| 2487 | pub const GETLK = 7; | ||
| 2488 | /// set record locking information | ||
| 2489 | pub const SETLK = 8; | ||
| 2490 | /// F.SETLK; wait if blocked | ||
| 2491 | pub const SETLKW = 9; | ||
| 2492 | /// F.SETLK; wait if blocked, return on timeout | ||
| 2493 | pub const SETLKWTIMEOUT = 10; | ||
| 2494 | pub const FLUSH_DATA = 40; | ||
| 2495 | /// Used for regression test | ||
| 2496 | pub const CHKCLEAN = 41; | ||
| 2497 | /// Preallocate storage | ||
| 2498 | pub const PREALLOCATE = 42; | ||
| 2499 | /// Truncate a file without zeroing space | ||
| 2500 | pub const SETSIZE = 43; | ||
| 2501 | /// Issue an advisory read async with no copy to user | ||
| 2502 | pub const RDADVISE = 44; | ||
| 2503 | /// turn read ahead off/on for this fd | ||
| 2504 | pub const RDAHEAD = 45; | ||
| 2505 | /// turn data caching off/on for this fd | ||
| 2506 | pub const NOCACHE = 48; | ||
| 2507 | /// file offset to device offset | ||
| 2508 | pub const LOG2PHYS = 49; | ||
| 2509 | /// return the full path of the fd | ||
| 2510 | pub const GETPATH = 50; | ||
| 2511 | /// fsync + ask the drive to flush to the media | ||
| 2512 | pub const FULLFSYNC = 51; | ||
| 2513 | /// find which component (if any) is a package | ||
| 2514 | pub const PATHPKG_CHECK = 52; | ||
| 2515 | /// "freeze" all fs operations | ||
| 2516 | pub const FREEZE_FS = 53; | ||
| 2517 | /// "thaw" all fs operations | ||
| 2518 | pub const THAW_FS = 54; | ||
| 2519 | /// turn data caching off/on (globally) for this file | ||
| 2520 | pub const GLOBAL_NOCACHE = 55; | ||
| 2521 | /// add detached signatures | ||
| 2522 | pub const ADDSIGS = 59; | ||
| 2523 | /// add signature from same file (used by dyld for shared libs) | ||
| 2524 | pub const ADDFILESIGS = 61; | ||
| 2525 | /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchronous writes | ||
| 2526 | /// should not be used (i.e. its ok to temporarily create cached pages) | ||
| 2527 | pub const NODIRECT = 62; | ||
| 2528 | ///Get the protection class of a file from the EA, returns int | ||
| 2529 | pub const GETPROTECTIONCLASS = 63; | ||
| 2530 | ///Set the protection class of a file for the EA, requires int | ||
| 2531 | pub const SETPROTECTIONCLASS = 64; | ||
| 2532 | ///file offset to device offset, extended | ||
| 2533 | pub const LOG2PHYS_EXT = 65; | ||
| 2534 | ///get record locking information, per-process | ||
| 2535 | pub const GETLKPID = 66; | ||
| 2536 | ///Mark the file as being the backing store for another filesystem | ||
| 2537 | pub const SETBACKINGSTORE = 70; | ||
| 2538 | ///return the full path of the FD, but error in specific mtmd circumstances | ||
| 2539 | pub const GETPATH_MTMINFO = 71; | ||
| 2540 | ///Returns the code directory, with associated hashes, to the caller | ||
| 2541 | pub const GETCODEDIR = 72; | ||
| 2542 | ///No SIGPIPE generated on EPIPE | ||
| 2543 | pub const SETNOSIGPIPE = 73; | ||
| 2544 | ///Status of SIGPIPE for this fd | ||
| 2545 | pub const GETNOSIGPIPE = 74; | ||
| 2546 | ///For some cases, we need to rewrap the key for AKS/MKB | ||
| 2547 | pub const TRANSCODEKEY = 75; | ||
| 2548 | ///file being written to a by single writer... if throttling enabled, writes | ||
| 2549 | ///may be broken into smaller chunks with throttling in between | ||
| 2550 | pub const SINGLE_WRITER = 76; | ||
| 2551 | ///Get the protection version number for this filesystem | ||
| 2552 | pub const GETPROTECTIONLEVEL = 77; | ||
| 2553 | ///Add detached code signatures (used by dyld for shared libs) | ||
| 2554 | pub const FINDSIGS = 78; | ||
| 2555 | ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator) | ||
| 2556 | pub const ADDFILESIGS_FOR_DYLD_SIM = 83; | ||
| 2557 | ///fsync + issue barrier to drive | ||
| 2558 | pub const BARRIERFSYNC = 85; | ||
| 2559 | ///Add signature from same file, return end offset in structure on success | ||
| 2560 | pub const ADDFILESIGS_RETURN = 97; | ||
| 2561 | ///Check if Library Validation allows this Mach-O file to be mapped into the calling process | ||
| 2562 | pub const CHECK_LV = 98; | ||
| 2563 | ///Deallocate a range of the file | ||
| 2564 | pub const PUNCHHOLE = 99; | ||
| 2565 | ///Trim an active file | ||
| 2566 | pub const TRIM_ACTIVE_FILE = 100; | ||
| 2567 | ///mark the dup with FD_CLOEXEC | ||
| 2568 | pub const DUPFD_CLOEXEC = 67; | ||
| 2569 | /// shared or read lock | ||
| 2570 | pub const RDLCK = 1; | ||
| 2571 | /// unlock | ||
| 2572 | pub const UNLCK = 2; | ||
| 2573 | /// exclusive or write lock | ||
| 2574 | pub const WRLCK = 3; | ||
| 2575 | }; | ||
| 2576 | |||
| 2577 | pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000; | ||
| 2578 | |||
| 2579 | ///close-on-exec flag | ||
| 2580 | pub const FD_CLOEXEC = 1; | ||
| 2581 | |||
| 2582 | pub const LOCK = struct { | ||
| 2583 | pub const SH = 1; | ||
| 2584 | pub const EX = 2; | ||
| 2585 | pub const UN = 8; | ||
| 2586 | pub const NB = 4; | ||
| 2587 | }; | ||
| 2588 | |||
| 2589 | pub const nfds_t = u32; | ||
| 2590 | pub const pollfd = extern struct { | ||
| 2591 | fd: fd_t, | ||
| 2592 | events: i16, | ||
| 2593 | revents: i16, | ||
| 2594 | }; | ||
| 2595 | |||
| 2596 | pub const POLL = struct { | ||
| 2597 | pub const IN = 0x001; | ||
| 2598 | pub const PRI = 0x002; | ||
| 2599 | pub const OUT = 0x004; | ||
| 2600 | pub const RDNORM = 0x040; | ||
| 2601 | pub const WRNORM = OUT; | ||
| 2602 | pub const RDBAND = 0x080; | ||
| 2603 | pub const WRBAND = 0x100; | ||
| 2604 | |||
| 2605 | pub const EXTEND = 0x0200; | ||
| 2606 | pub const ATTRIB = 0x0400; | ||
| 2607 | pub const NLINK = 0x0800; | ||
| 2608 | pub const WRITE = 0x1000; | ||
| 2609 | |||
| 2610 | pub const ERR = 0x008; | ||
| 2611 | pub const HUP = 0x010; | ||
| 2612 | pub const NVAL = 0x020; | ||
| 2613 | |||
| 2614 | pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL; | ||
| 2615 | }; | ||
| 2616 | |||
| 2617 | pub const CLOCK = struct { | ||
| 2618 | pub const REALTIME = 0; | ||
| 2619 | pub const MONOTONIC = 6; | ||
| 2620 | pub const MONOTONIC_RAW = 4; | ||
| 2621 | pub const MONOTONIC_RAW_APPROX = 5; | ||
| 2622 | pub const UPTIME_RAW = 8; | ||
| 2623 | pub const UPTIME_RAW_APPROX = 9; | ||
| 2624 | pub const PROCESS_CPUTIME_ID = 12; | ||
| 2625 | pub const THREAD_CPUTIME_ID = 16; | ||
| 2626 | }; | ||
| 2627 | |||
| 2628 | /// Max open files per process | ||
| 2629 | /// https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/sys/syslimits.h.auto.html | ||
| 2630 | pub const OPEN_MAX = 10240; | ||
| 2631 | |||
| 2632 | pub const rusage = extern struct { | ||
| 2633 | utime: timeval, | ||
| 2634 | stime: timeval, | ||
| 2635 | maxrss: isize, | ||
| 2636 | ixrss: isize, | ||
| 2637 | idrss: isize, | ||
| 2638 | isrss: isize, | ||
| 2639 | minflt: isize, | ||
| 2640 | majflt: isize, | ||
| 2641 | nswap: isize, | ||
| 2642 | inblock: isize, | ||
| 2643 | oublock: isize, | ||
| 2644 | msgsnd: isize, | ||
| 2645 | msgrcv: isize, | ||
| 2646 | nsignals: isize, | ||
| 2647 | nvcsw: isize, | ||
| 2648 | nivcsw: isize, | ||
| 2649 | |||
| 2650 | pub const SELF = 0; | ||
| 2651 | pub const CHILDREN = -1; | ||
| 2652 | }; | ||
| 2653 | |||
| 2654 | pub const rlimit_resource = enum(c_int) { | ||
| 2655 | CPU = 0, | ||
| 2656 | FSIZE = 1, | ||
| 2657 | DATA = 2, | ||
| 2658 | STACK = 3, | ||
| 2659 | CORE = 4, | ||
| 2660 | RSS = 5, | ||
| 2661 | MEMLOCK = 6, | ||
| 2662 | NPROC = 7, | ||
| 2663 | NOFILE = 8, | ||
| 2664 | _, | 1462 | _, |
| 2665 | |||
| 2666 | pub const AS: rlimit_resource = .RSS; | ||
| 2667 | }; | ||
| 2668 | |||
| 2669 | pub const rlim_t = u64; | ||
| 2670 | |||
| 2671 | pub const RLIM = struct { | ||
| 2672 | /// No limit | ||
| 2673 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 2674 | |||
| 2675 | pub const SAVED_MAX = INFINITY; | ||
| 2676 | pub const SAVED_CUR = INFINITY; | ||
| 2677 | }; | ||
| 2678 | |||
| 2679 | pub const rlimit = extern struct { | ||
| 2680 | /// Soft limit | ||
| 2681 | cur: rlim_t, | ||
| 2682 | /// Hard limit | ||
| 2683 | max: rlim_t, | ||
| 2684 | }; | 1463 | }; |
| 2685 | 1464 | ||
| 2686 | pub const SHUT = struct { | 1465 | /// From Common Security Services Manager |
| 2687 | pub const RD = 0; | 1466 | /// Security.framework/Headers/cssm*.h |
| 2688 | pub const WR = 1; | 1467 | pub const DB_RECORDTYPE = enum(u32) { |
| 2689 | pub const RDWR = 2; | 1468 | // Record Types defined in the Schema Management Name Space |
| 2690 | }; | 1469 | SCHEMA_INFO = SCHEMA_START + 0, |
| 1470 | SCHEMA_INDEXES = SCHEMA_START + 1, | ||
| 1471 | SCHEMA_ATTRIBUTES = SCHEMA_START + 2, | ||
| 1472 | SCHEMA_PARSING_MODULE = SCHEMA_START + 3, | ||
| 1473 | |||
| 1474 | // Record Types defined in the Open Group Application Name Space | ||
| 1475 | ANY = OPEN_GROUP_START + 0, | ||
| 1476 | CERT = OPEN_GROUP_START + 1, | ||
| 1477 | CRL = OPEN_GROUP_START + 2, | ||
| 1478 | POLICY = OPEN_GROUP_START + 3, | ||
| 1479 | GENERIC = OPEN_GROUP_START + 4, | ||
| 1480 | PUBLIC_KEY = OPEN_GROUP_START + 5, | ||
| 1481 | PRIVATE_KEY = OPEN_GROUP_START + 6, | ||
| 1482 | SYMMETRIC_KEY = OPEN_GROUP_START + 7, | ||
| 1483 | ALL_KEYS = OPEN_GROUP_START + 8, | ||
| 1484 | |||
| 1485 | // AppleFileDL record types | ||
| 1486 | GENERIC_PASSWORD = APP_DEFINED_START + 0, | ||
| 1487 | INTERNET_PASSWORD = APP_DEFINED_START + 1, | ||
| 1488 | APPLESHARE_PASSWORD = APP_DEFINED_START + 2, | ||
| 1489 | |||
| 1490 | X509_CERTIFICATE = APP_DEFINED_START + 0x1000, | ||
| 1491 | USER_TRUST, | ||
| 1492 | X509_CRL, | ||
| 1493 | UNLOCK_REFERRAL, | ||
| 1494 | EXTENDED_ATTRIBUTE, | ||
| 1495 | METADATA = APP_DEFINED_START + 0x8000, | ||
| 2691 | 1496 | ||
| 2692 | pub const TCSA = enum(c_uint) { | ||
| 2693 | NOW, | ||
| 2694 | DRAIN, | ||
| 2695 | FLUSH, | ||
| 2696 | _, | 1497 | _, |
| 2697 | }; | ||
| 2698 | 1498 | ||
| 2699 | pub const winsize = extern struct { | 1499 | // Schema Management Name Space Range Definition |
| 2700 | ws_row: u16, | 1500 | pub const SCHEMA_START = 0x00000000; |
| 2701 | ws_col: u16, | 1501 | pub const SCHEMA_END = SCHEMA_START + 4; |
| 2702 | ws_xpixel: u16, | ||
| 2703 | ws_ypixel: u16, | ||
| 2704 | }; | ||
| 2705 | 1502 | ||
| 2706 | pub const T = struct { | 1503 | // Open Group Application Name Space Range Definition |
| 2707 | pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); | 1504 | pub const OPEN_GROUP_START = 0x0000000A; |
| 2708 | }; | 1505 | pub const OPEN_GROUP_END = OPEN_GROUP_START + 8; |
| 2709 | pub const IOCPARM_MASK = 0x1fff; | ||
| 2710 | |||
| 2711 | fn ior(inout: u32, group: usize, num: usize, len: usize) usize { | ||
| 2712 | return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)); | ||
| 2713 | } | ||
| 2714 | 1506 | ||
| 2715 | // CPU families mapping | 1507 | // Industry At Large Application Name Space Range Definition |
| 2716 | pub const CPUFAMILY = enum(u32) { | 1508 | pub const APP_DEFINED_START = 0x80000000; |
| 2717 | UNKNOWN = 0, | 1509 | pub const APP_DEFINED_END = 0xffffffff; |
| 2718 | POWERPC_G3 = 0xcee41549, | ||
| 2719 | POWERPC_G4 = 0x77c184ae, | ||
| 2720 | POWERPC_G5 = 0xed76d8aa, | ||
| 2721 | INTEL_6_13 = 0xaa33392b, | ||
| 2722 | INTEL_PENRYN = 0x78ea4fbc, | ||
| 2723 | INTEL_NEHALEM = 0x6b5a4cd2, | ||
| 2724 | INTEL_WESTMERE = 0x573b5eec, | ||
| 2725 | INTEL_SANDYBRIDGE = 0x5490b78c, | ||
| 2726 | INTEL_IVYBRIDGE = 0x1f65e835, | ||
| 2727 | INTEL_HASWELL = 0x10b282dc, | ||
| 2728 | INTEL_BROADWELL = 0x582ed09c, | ||
| 2729 | INTEL_SKYLAKE = 0x37fc219f, | ||
| 2730 | INTEL_KABYLAKE = 0x0f817246, | ||
| 2731 | ARM_9 = 0xe73283ae, | ||
| 2732 | ARM_11 = 0x8ff620d8, | ||
| 2733 | ARM_XSCALE = 0x53b005f5, | ||
| 2734 | ARM_12 = 0xbd1b0ae9, | ||
| 2735 | ARM_13 = 0x0cc90e64, | ||
| 2736 | ARM_14 = 0x96077ef1, | ||
| 2737 | ARM_15 = 0xa8511bca, | ||
| 2738 | ARM_SWIFT = 0x1e2d6381, | ||
| 2739 | ARM_CYCLONE = 0x37a09642, | ||
| 2740 | ARM_TYPHOON = 0x2c91a47e, | ||
| 2741 | ARM_TWISTER = 0x92fb37c8, | ||
| 2742 | ARM_HURRICANE = 0x67ceee93, | ||
| 2743 | ARM_MONSOON_MISTRAL = 0xe81e7ef6, | ||
| 2744 | ARM_VORTEX_TEMPEST = 0x07d34b9f, | ||
| 2745 | ARM_LIGHTNING_THUNDER = 0x462504d2, | ||
| 2746 | ARM_FIRESTORM_ICESTORM = 0x1b588bb3, | ||
| 2747 | ARM_BLIZZARD_AVALANCHE = 0xda33d83d, | ||
| 2748 | ARM_EVEREST_SAWTOOTH = 0x8765edea, | ||
| 2749 | _, | ||
| 2750 | }; | 1510 | }; |
| 2751 | |||
| 2752 | pub const PT = struct { | ||
| 2753 | pub const TRACE_ME = 0; | ||
| 2754 | pub const READ_I = 1; | ||
| 2755 | pub const READ_D = 2; | ||
| 2756 | pub const READ_U = 3; | ||
| 2757 | pub const WRITE_I = 4; | ||
| 2758 | pub const WRITE_D = 5; | ||
| 2759 | pub const WRITE_U = 6; | ||
| 2760 | pub const CONTINUE = 7; | ||
| 2761 | pub const KILL = 8; | ||
| 2762 | pub const STEP = 9; | ||
| 2763 | pub const DETACH = 11; | ||
| 2764 | pub const SIGEXC = 12; | ||
| 2765 | pub const THUPDATE = 13; | ||
| 2766 | pub const ATTACHEXC = 14; | ||
| 2767 | pub const FORCEQUOTA = 30; | ||
| 2768 | pub const DENY_ATTACH = 31; | ||
| 2769 | }; | ||
| 2770 | |||
| 2771 | pub const caddr_t = ?[*]u8; | ||
| 2772 | |||
| 2773 | pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: caddr_t, data: c_int) c_int; | ||
| 2774 | |||
| 2775 | pub const POSIX_SPAWN = struct { | ||
| 2776 | pub const RESETIDS = 0x0001; | ||
| 2777 | pub const SETPGROUP = 0x0002; | ||
| 2778 | pub const SETSIGDEF = 0x0004; | ||
| 2779 | pub const SETSIGMASK = 0x0008; | ||
| 2780 | pub const SETEXEC = 0x0040; | ||
| 2781 | pub const START_SUSPENDED = 0x0080; | ||
| 2782 | pub const DISABLE_ASLR = 0x0100; | ||
| 2783 | pub const SETSID = 0x0400; | ||
| 2784 | pub const RESLIDE = 0x0800; | ||
| 2785 | pub const CLOEXEC_DEFAULT = 0x4000; | ||
| 2786 | }; | ||
| 2787 | |||
| 2788 | pub const posix_spawnattr_t = *opaque {}; | ||
| 2789 | pub const posix_spawn_file_actions_t = *opaque {}; | ||
| 2790 | pub extern "c" fn posix_spawnattr_init(attr: *posix_spawnattr_t) c_int; | ||
| 2791 | pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) c_int; | ||
| 2792 | pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int; | ||
| 2793 | pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int; | ||
| 2794 | pub extern "c" fn posix_spawn_file_actions_init(actions: *posix_spawn_file_actions_t) c_int; | ||
| 2795 | pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) c_int; | ||
| 2796 | pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int; | ||
| 2797 | pub extern "c" fn posix_spawn_file_actions_addopen( | ||
| 2798 | actions: *posix_spawn_file_actions_t, | ||
| 2799 | filedes: fd_t, | ||
| 2800 | path: [*:0]const u8, | ||
| 2801 | oflag: c_int, | ||
| 2802 | mode: mode_t, | ||
| 2803 | ) c_int; | ||
| 2804 | pub extern "c" fn posix_spawn_file_actions_adddup2( | ||
| 2805 | actions: *posix_spawn_file_actions_t, | ||
| 2806 | filedes: fd_t, | ||
| 2807 | newfiledes: fd_t, | ||
| 2808 | ) c_int; | ||
| 2809 | pub extern "c" fn posix_spawn_file_actions_addinherit_np(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int; | ||
| 2810 | pub extern "c" fn posix_spawn_file_actions_addchdir_np(actions: *posix_spawn_file_actions_t, path: [*:0]const u8) c_int; | ||
| 2811 | pub extern "c" fn posix_spawn_file_actions_addfchdir_np(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int; | ||
| 2812 | pub extern "c" fn posix_spawn( | ||
| 2813 | pid: *pid_t, | ||
| 2814 | path: [*:0]const u8, | ||
| 2815 | actions: ?*const posix_spawn_file_actions_t, | ||
| 2816 | attr: ?*const posix_spawnattr_t, | ||
| 2817 | argv: [*:null]?[*:0]const u8, | ||
| 2818 | env: [*:null]?[*:0]const u8, | ||
| 2819 | ) c_int; | ||
| 2820 | pub extern "c" fn posix_spawnp( | ||
| 2821 | pid: *pid_t, | ||
| 2822 | path: [*:0]const u8, | ||
| 2823 | actions: ?*const posix_spawn_file_actions_t, | ||
| 2824 | attr: ?*const posix_spawnattr_t, | ||
| 2825 | argv: [*:null]?[*:0]const u8, | ||
| 2826 | env: [*:null]?[*:0]const u8, | ||
| 2827 | ) c_int; | ||
| 2828 | |||
| 2829 | pub fn getKernError(err: kern_return_t) KernE { | ||
| 2830 | return @as(KernE, @enumFromInt(@as(u32, @truncate(@as(usize, @intCast(err)))))); | ||
| 2831 | } | ||
| 2832 | |||
| 2833 | pub fn unexpectedKernError(err: KernE) std.posix.UnexpectedError { | ||
| 2834 | if (std.posix.unexpected_error_tracing) { | ||
| 2835 | std.debug.print("unexpected error: {d}\n", .{@intFromEnum(err)}); | ||
| 2836 | std.debug.dumpCurrentStackTrace(null); | ||
| 2837 | } | ||
| 2838 | return error.Unexpected; | ||
| 2839 | } | ||
| 2840 | |||
| 2841 | pub const MachError = error{ | ||
| 2842 | /// Not enough permissions held to perform the requested kernel | ||
| 2843 | /// call. | ||
| 2844 | PermissionDenied, | ||
| 2845 | } || std.posix.UnexpectedError; | ||
| 2846 | |||
| 2847 | pub const MachTask = extern struct { | ||
| 2848 | port: mach_port_name_t, | ||
| 2849 | |||
| 2850 | pub fn isValid(self: MachTask) bool { | ||
| 2851 | return self.port != TASK_NULL; | ||
| 2852 | } | ||
| 2853 | |||
| 2854 | pub fn pidForTask(self: MachTask) MachError!std.c.pid_t { | ||
| 2855 | var pid: std.c.pid_t = undefined; | ||
| 2856 | switch (getKernError(pid_for_task(self.port, &pid))) { | ||
| 2857 | .SUCCESS => return pid, | ||
| 2858 | .FAILURE => return error.PermissionDenied, | ||
| 2859 | else => |err| return unexpectedKernError(err), | ||
| 2860 | } | ||
| 2861 | } | ||
| 2862 | |||
| 2863 | pub fn allocatePort(self: MachTask, right: MACH_PORT_RIGHT) MachError!MachTask { | ||
| 2864 | var out_port: mach_port_name_t = undefined; | ||
| 2865 | switch (getKernError(mach_port_allocate( | ||
| 2866 | self.port, | ||
| 2867 | @intFromEnum(right), | ||
| 2868 | &out_port, | ||
| 2869 | ))) { | ||
| 2870 | .SUCCESS => return .{ .port = out_port }, | ||
| 2871 | .FAILURE => return error.PermissionDenied, | ||
| 2872 | else => |err| return unexpectedKernError(err), | ||
| 2873 | } | ||
| 2874 | } | ||
| 2875 | |||
| 2876 | pub fn deallocatePort(self: MachTask, port: MachTask) void { | ||
| 2877 | _ = getKernError(mach_port_deallocate(self.port, port.port)); | ||
| 2878 | } | ||
| 2879 | |||
| 2880 | pub fn insertRight(self: MachTask, port: MachTask, msg: MACH_MSG_TYPE) !void { | ||
| 2881 | switch (getKernError(mach_port_insert_right( | ||
| 2882 | self.port, | ||
| 2883 | port.port, | ||
| 2884 | port.port, | ||
| 2885 | @intFromEnum(msg), | ||
| 2886 | ))) { | ||
| 2887 | .SUCCESS => return, | ||
| 2888 | .FAILURE => return error.PermissionDenied, | ||
| 2889 | else => |err| return unexpectedKernError(err), | ||
| 2890 | } | ||
| 2891 | } | ||
| 2892 | |||
| 2893 | pub const PortInfo = struct { | ||
| 2894 | mask: exception_mask_t, | ||
| 2895 | masks: [EXC_TYPES_COUNT]exception_mask_t, | ||
| 2896 | ports: [EXC_TYPES_COUNT]mach_port_t, | ||
| 2897 | behaviors: [EXC_TYPES_COUNT]exception_behavior_t, | ||
| 2898 | flavors: [EXC_TYPES_COUNT]thread_state_flavor_t, | ||
| 2899 | count: mach_msg_type_number_t, | ||
| 2900 | }; | ||
| 2901 | |||
| 2902 | pub fn getExceptionPorts(self: MachTask, mask: exception_mask_t) !PortInfo { | ||
| 2903 | var info = PortInfo{ | ||
| 2904 | .mask = mask, | ||
| 2905 | .masks = undefined, | ||
| 2906 | .ports = undefined, | ||
| 2907 | .behaviors = undefined, | ||
| 2908 | .flavors = undefined, | ||
| 2909 | .count = 0, | ||
| 2910 | }; | ||
| 2911 | info.count = info.ports.len / @sizeOf(mach_port_t); | ||
| 2912 | |||
| 2913 | switch (getKernError(task_get_exception_ports( | ||
| 2914 | self.port, | ||
| 2915 | info.mask, | ||
| 2916 | &info.masks, | ||
| 2917 | &info.count, | ||
| 2918 | &info.ports, | ||
| 2919 | &info.behaviors, | ||
| 2920 | &info.flavors, | ||
| 2921 | ))) { | ||
| 2922 | .SUCCESS => return info, | ||
| 2923 | .FAILURE => return error.PermissionDenied, | ||
| 2924 | else => |err| return unexpectedKernError(err), | ||
| 2925 | } | ||
| 2926 | } | ||
| 2927 | |||
| 2928 | pub fn setExceptionPorts( | ||
| 2929 | self: MachTask, | ||
| 2930 | mask: exception_mask_t, | ||
| 2931 | new_port: MachTask, | ||
| 2932 | behavior: exception_behavior_t, | ||
| 2933 | new_flavor: thread_state_flavor_t, | ||
| 2934 | ) !void { | ||
| 2935 | switch (getKernError(task_set_exception_ports( | ||
| 2936 | self.port, | ||
| 2937 | mask, | ||
| 2938 | new_port.port, | ||
| 2939 | behavior, | ||
| 2940 | new_flavor, | ||
| 2941 | ))) { | ||
| 2942 | .SUCCESS => return, | ||
| 2943 | .FAILURE => return error.PermissionDenied, | ||
| 2944 | else => |err| return unexpectedKernError(err), | ||
| 2945 | } | ||
| 2946 | } | ||
| 2947 | |||
| 2948 | pub const RegionInfo = struct { | ||
| 2949 | pub const Tag = enum { | ||
| 2950 | basic, | ||
| 2951 | extended, | ||
| 2952 | top, | ||
| 2953 | }; | ||
| 2954 | |||
| 2955 | base_addr: u64, | ||
| 2956 | tag: Tag, | ||
| 2957 | info: union { | ||
| 2958 | basic: vm_region_basic_info_64, | ||
| 2959 | extended: vm_region_extended_info, | ||
| 2960 | top: vm_region_top_info, | ||
| 2961 | }, | ||
| 2962 | }; | ||
| 2963 | |||
| 2964 | pub fn getRegionInfo( | ||
| 2965 | task: MachTask, | ||
| 2966 | address: u64, | ||
| 2967 | len: usize, | ||
| 2968 | tag: RegionInfo.Tag, | ||
| 2969 | ) MachError!RegionInfo { | ||
| 2970 | var info: RegionInfo = .{ | ||
| 2971 | .base_addr = address, | ||
| 2972 | .tag = tag, | ||
| 2973 | .info = undefined, | ||
| 2974 | }; | ||
| 2975 | switch (tag) { | ||
| 2976 | .basic => info.info = .{ .basic = undefined }, | ||
| 2977 | .extended => info.info = .{ .extended = undefined }, | ||
| 2978 | .top => info.info = .{ .top = undefined }, | ||
| 2979 | } | ||
| 2980 | var base_len: mach_vm_size_t = if (len == 1) 2 else len; | ||
| 2981 | var objname: mach_port_t = undefined; | ||
| 2982 | var count: mach_msg_type_number_t = switch (tag) { | ||
| 2983 | .basic => VM_REGION_BASIC_INFO_COUNT, | ||
| 2984 | .extended => VM_REGION_EXTENDED_INFO_COUNT, | ||
| 2985 | .top => VM_REGION_TOP_INFO_COUNT, | ||
| 2986 | }; | ||
| 2987 | switch (getKernError(mach_vm_region( | ||
| 2988 | task.port, | ||
| 2989 | &info.base_addr, | ||
| 2990 | &base_len, | ||
| 2991 | switch (tag) { | ||
| 2992 | .basic => VM_REGION_BASIC_INFO_64, | ||
| 2993 | .extended => VM_REGION_EXTENDED_INFO, | ||
| 2994 | .top => VM_REGION_TOP_INFO, | ||
| 2995 | }, | ||
| 2996 | switch (tag) { | ||
| 2997 | .basic => @as(vm_region_info_t, @ptrCast(&info.info.basic)), | ||
| 2998 | .extended => @as(vm_region_info_t, @ptrCast(&info.info.extended)), | ||
| 2999 | .top => @as(vm_region_info_t, @ptrCast(&info.info.top)), | ||
| 3000 | }, | ||
| 3001 | &count, | ||
| 3002 | &objname, | ||
| 3003 | ))) { | ||
| 3004 | .SUCCESS => return info, | ||
| 3005 | .FAILURE => return error.PermissionDenied, | ||
| 3006 | else => |err| return unexpectedKernError(err), | ||
| 3007 | } | ||
| 3008 | } | ||
| 3009 | |||
| 3010 | pub const RegionSubmapInfo = struct { | ||
| 3011 | pub const Tag = enum { | ||
| 3012 | short, | ||
| 3013 | full, | ||
| 3014 | }; | ||
| 3015 | |||
| 3016 | tag: Tag, | ||
| 3017 | base_addr: u64, | ||
| 3018 | info: union { | ||
| 3019 | short: vm_region_submap_short_info_64, | ||
| 3020 | full: vm_region_submap_info_64, | ||
| 3021 | }, | ||
| 3022 | }; | ||
| 3023 | |||
| 3024 | pub fn getRegionSubmapInfo( | ||
| 3025 | task: MachTask, | ||
| 3026 | address: u64, | ||
| 3027 | len: usize, | ||
| 3028 | nesting_depth: u32, | ||
| 3029 | tag: RegionSubmapInfo.Tag, | ||
| 3030 | ) MachError!RegionSubmapInfo { | ||
| 3031 | var info: RegionSubmapInfo = .{ | ||
| 3032 | .base_addr = address, | ||
| 3033 | .tag = tag, | ||
| 3034 | .info = undefined, | ||
| 3035 | }; | ||
| 3036 | switch (tag) { | ||
| 3037 | .short => info.info = .{ .short = undefined }, | ||
| 3038 | .full => info.info = .{ .full = undefined }, | ||
| 3039 | } | ||
| 3040 | var nesting = nesting_depth; | ||
| 3041 | var base_len: mach_vm_size_t = if (len == 1) 2 else len; | ||
| 3042 | var count: mach_msg_type_number_t = switch (tag) { | ||
| 3043 | .short => VM_REGION_SUBMAP_SHORT_INFO_COUNT_64, | ||
| 3044 | .full => VM_REGION_SUBMAP_INFO_COUNT_64, | ||
| 3045 | }; | ||
| 3046 | switch (getKernError(mach_vm_region_recurse( | ||
| 3047 | task.port, | ||
| 3048 | &info.base_addr, | ||
| 3049 | &base_len, | ||
| 3050 | &nesting, | ||
| 3051 | switch (tag) { | ||
| 3052 | .short => @as(vm_region_recurse_info_t, @ptrCast(&info.info.short)), | ||
| 3053 | .full => @as(vm_region_recurse_info_t, @ptrCast(&info.info.full)), | ||
| 3054 | }, | ||
| 3055 | &count, | ||
| 3056 | ))) { | ||
| 3057 | .SUCCESS => return info, | ||
| 3058 | .FAILURE => return error.PermissionDenied, | ||
| 3059 | else => |err| return unexpectedKernError(err), | ||
| 3060 | } | ||
| 3061 | } | ||
| 3062 | |||
| 3063 | pub fn getCurrProtection(task: MachTask, address: u64, len: usize) MachError!vm_prot_t { | ||
| 3064 | const info = try task.getRegionSubmapInfo(address, len, 0, .short); | ||
| 3065 | return info.info.short.protection; | ||
| 3066 | } | ||
| 3067 | |||
| 3068 | pub fn setMaxProtection(task: MachTask, address: u64, len: usize, prot: vm_prot_t) MachError!void { | ||
| 3069 | return task.setProtectionImpl(address, len, true, prot); | ||
| 3070 | } | ||
| 3071 | |||
| 3072 | pub fn setCurrProtection(task: MachTask, address: u64, len: usize, prot: vm_prot_t) MachError!void { | ||
| 3073 | return task.setProtectionImpl(address, len, false, prot); | ||
| 3074 | } | ||
| 3075 | |||
| 3076 | fn setProtectionImpl(task: MachTask, address: u64, len: usize, set_max: bool, prot: vm_prot_t) MachError!void { | ||
| 3077 | switch (getKernError(mach_vm_protect(task.port, address, len, @intFromBool(set_max), prot))) { | ||
| 3078 | .SUCCESS => return, | ||
| 3079 | .FAILURE => return error.PermissionDenied, | ||
| 3080 | else => |err| return unexpectedKernError(err), | ||
| 3081 | } | ||
| 3082 | } | ||
| 3083 | |||
| 3084 | /// Will write to VM even if current protection attributes specifically prohibit | ||
| 3085 | /// us from doing so, by temporarily setting protection level to a level with VM_PROT_COPY | ||
| 3086 | /// variant, and resetting after a successful or unsuccessful write. | ||
| 3087 | pub fn writeMemProtected(task: MachTask, address: u64, buf: []const u8, arch: std.Target.Cpu.Arch) MachError!usize { | ||
| 3088 | const curr_prot = try task.getCurrProtection(address, buf.len); | ||
| 3089 | try task.setCurrProtection( | ||
| 3090 | address, | ||
| 3091 | buf.len, | ||
| 3092 | PROT.READ | PROT.WRITE | PROT.COPY, | ||
| 3093 | ); | ||
| 3094 | defer { | ||
| 3095 | task.setCurrProtection(address, buf.len, curr_prot) catch {}; | ||
| 3096 | } | ||
| 3097 | return task.writeMem(address, buf, arch); | ||
| 3098 | } | ||
| 3099 | |||
| 3100 | pub fn writeMem(task: MachTask, address: u64, buf: []const u8, arch: std.Target.Cpu.Arch) MachError!usize { | ||
| 3101 | const count = buf.len; | ||
| 3102 | var total_written: usize = 0; | ||
| 3103 | var curr_addr = address; | ||
| 3104 | const page_size = try getPageSize(task); // TODO we probably can assume value here | ||
| 3105 | var out_buf = buf[0..]; | ||
| 3106 | |||
| 3107 | while (total_written < count) { | ||
| 3108 | const curr_size = maxBytesLeftInPage(page_size, curr_addr, count - total_written); | ||
| 3109 | switch (getKernError(mach_vm_write( | ||
| 3110 | task.port, | ||
| 3111 | curr_addr, | ||
| 3112 | @intFromPtr(out_buf.ptr), | ||
| 3113 | @as(mach_msg_type_number_t, @intCast(curr_size)), | ||
| 3114 | ))) { | ||
| 3115 | .SUCCESS => {}, | ||
| 3116 | .FAILURE => return error.PermissionDenied, | ||
| 3117 | else => |err| return unexpectedKernError(err), | ||
| 3118 | } | ||
| 3119 | |||
| 3120 | switch (arch) { | ||
| 3121 | .aarch64 => { | ||
| 3122 | var mattr_value: vm_machine_attribute_val_t = MATTR_VAL_CACHE_FLUSH; | ||
| 3123 | switch (getKernError(vm_machine_attribute( | ||
| 3124 | task.port, | ||
| 3125 | curr_addr, | ||
| 3126 | curr_size, | ||
| 3127 | MATTR_CACHE, | ||
| 3128 | &mattr_value, | ||
| 3129 | ))) { | ||
| 3130 | .SUCCESS => {}, | ||
| 3131 | .FAILURE => return error.PermissionDenied, | ||
| 3132 | else => |err| return unexpectedKernError(err), | ||
| 3133 | } | ||
| 3134 | }, | ||
| 3135 | .x86_64 => {}, | ||
| 3136 | else => unreachable, | ||
| 3137 | } | ||
| 3138 | |||
| 3139 | out_buf = out_buf[curr_size..]; | ||
| 3140 | total_written += curr_size; | ||
| 3141 | curr_addr += curr_size; | ||
| 3142 | } | ||
| 3143 | |||
| 3144 | return total_written; | ||
| 3145 | } | ||
| 3146 | |||
| 3147 | pub fn readMem(task: MachTask, address: u64, buf: []u8) MachError!usize { | ||
| 3148 | const count = buf.len; | ||
| 3149 | var total_read: usize = 0; | ||
| 3150 | var curr_addr = address; | ||
| 3151 | const page_size = try getPageSize(task); // TODO we probably can assume value here | ||
| 3152 | var out_buf = buf[0..]; | ||
| 3153 | |||
| 3154 | while (total_read < count) { | ||
| 3155 | const curr_size = maxBytesLeftInPage(page_size, curr_addr, count - total_read); | ||
| 3156 | var curr_bytes_read: mach_msg_type_number_t = 0; | ||
| 3157 | var vm_memory: vm_offset_t = undefined; | ||
| 3158 | switch (getKernError(mach_vm_read(task.port, curr_addr, curr_size, &vm_memory, &curr_bytes_read))) { | ||
| 3159 | .SUCCESS => {}, | ||
| 3160 | .FAILURE => return error.PermissionDenied, | ||
| 3161 | else => |err| return unexpectedKernError(err), | ||
| 3162 | } | ||
| 3163 | |||
| 3164 | @memcpy(out_buf[0..curr_bytes_read], @as([*]const u8, @ptrFromInt(vm_memory))); | ||
| 3165 | _ = vm_deallocate(mach_task_self(), vm_memory, curr_bytes_read); | ||
| 3166 | |||
| 3167 | out_buf = out_buf[curr_bytes_read..]; | ||
| 3168 | curr_addr += curr_bytes_read; | ||
| 3169 | total_read += curr_bytes_read; | ||
| 3170 | } | ||
| 3171 | |||
| 3172 | return total_read; | ||
| 3173 | } | ||
| 3174 | |||
| 3175 | fn maxBytesLeftInPage(page_size: usize, address: u64, count: usize) usize { | ||
| 3176 | var left = count; | ||
| 3177 | if (page_size > 0) { | ||
| 3178 | const page_offset = address % page_size; | ||
| 3179 | const bytes_left_in_page = page_size - page_offset; | ||
| 3180 | if (count > bytes_left_in_page) { | ||
| 3181 | left = bytes_left_in_page; | ||
| 3182 | } | ||
| 3183 | } | ||
| 3184 | return left; | ||
| 3185 | } | ||
| 3186 | |||
| 3187 | fn getPageSize(task: MachTask) MachError!usize { | ||
| 3188 | if (task.isValid()) { | ||
| 3189 | var info_count = TASK_VM_INFO_COUNT; | ||
| 3190 | var vm_info: task_vm_info_data_t = undefined; | ||
| 3191 | switch (getKernError(task_info( | ||
| 3192 | task.port, | ||
| 3193 | TASK_VM_INFO, | ||
| 3194 | @as(task_info_t, @ptrCast(&vm_info)), | ||
| 3195 | &info_count, | ||
| 3196 | ))) { | ||
| 3197 | .SUCCESS => return @as(usize, @intCast(vm_info.page_size)), | ||
| 3198 | else => {}, | ||
| 3199 | } | ||
| 3200 | } | ||
| 3201 | var page_size: vm_size_t = undefined; | ||
| 3202 | switch (getKernError(_host_page_size(mach_host_self(), &page_size))) { | ||
| 3203 | .SUCCESS => return page_size, | ||
| 3204 | else => |err| return unexpectedKernError(err), | ||
| 3205 | } | ||
| 3206 | } | ||
| 3207 | |||
| 3208 | pub fn basicTaskInfo(task: MachTask) MachError!mach_task_basic_info { | ||
| 3209 | var info: mach_task_basic_info = undefined; | ||
| 3210 | var count = MACH_TASK_BASIC_INFO_COUNT; | ||
| 3211 | switch (getKernError(task_info( | ||
| 3212 | task.port, | ||
| 3213 | MACH_TASK_BASIC_INFO, | ||
| 3214 | @as(task_info_t, @ptrCast(&info)), | ||
| 3215 | &count, | ||
| 3216 | ))) { | ||
| 3217 | .SUCCESS => return info, | ||
| 3218 | else => |err| return unexpectedKernError(err), | ||
| 3219 | } | ||
| 3220 | } | ||
| 3221 | |||
| 3222 | pub fn @"resume"(task: MachTask) MachError!void { | ||
| 3223 | switch (getKernError(task_resume(task.port))) { | ||
| 3224 | .SUCCESS => {}, | ||
| 3225 | else => |err| return unexpectedKernError(err), | ||
| 3226 | } | ||
| 3227 | } | ||
| 3228 | |||
| 3229 | pub fn @"suspend"(task: MachTask) MachError!void { | ||
| 3230 | switch (getKernError(task_suspend(task.port))) { | ||
| 3231 | .SUCCESS => {}, | ||
| 3232 | else => |err| return unexpectedKernError(err), | ||
| 3233 | } | ||
| 3234 | } | ||
| 3235 | |||
| 3236 | const ThreadList = struct { | ||
| 3237 | buf: []MachThread, | ||
| 3238 | |||
| 3239 | pub fn deinit(list: ThreadList) void { | ||
| 3240 | const self_task = machTaskForSelf(); | ||
| 3241 | _ = vm_deallocate( | ||
| 3242 | self_task.port, | ||
| 3243 | @intFromPtr(list.buf.ptr), | ||
| 3244 | @as(vm_size_t, @intCast(list.buf.len * @sizeOf(mach_port_t))), | ||
| 3245 | ); | ||
| 3246 | } | ||
| 3247 | }; | ||
| 3248 | |||
| 3249 | pub fn getThreads(task: MachTask) MachError!ThreadList { | ||
| 3250 | var thread_list: mach_port_array_t = undefined; | ||
| 3251 | var thread_count: mach_msg_type_number_t = undefined; | ||
| 3252 | switch (getKernError(task_threads(task.port, &thread_list, &thread_count))) { | ||
| 3253 | .SUCCESS => return ThreadList{ .buf = @as([*]MachThread, @ptrCast(thread_list))[0..thread_count] }, | ||
| 3254 | else => |err| return unexpectedKernError(err), | ||
| 3255 | } | ||
| 3256 | } | ||
| 3257 | }; | ||
| 3258 | |||
| 3259 | pub const MachThread = extern struct { | ||
| 3260 | port: mach_port_t, | ||
| 3261 | |||
| 3262 | pub fn isValid(thread: MachThread) bool { | ||
| 3263 | return thread.port != THREAD_NULL; | ||
| 3264 | } | ||
| 3265 | |||
| 3266 | pub fn getBasicInfo(thread: MachThread) MachError!thread_basic_info { | ||
| 3267 | var info: thread_basic_info = undefined; | ||
| 3268 | var count = THREAD_BASIC_INFO_COUNT; | ||
| 3269 | switch (getKernError(thread_info( | ||
| 3270 | thread.port, | ||
| 3271 | THREAD_BASIC_INFO, | ||
| 3272 | @as(thread_info_t, @ptrCast(&info)), | ||
| 3273 | &count, | ||
| 3274 | ))) { | ||
| 3275 | .SUCCESS => return info, | ||
| 3276 | else => |err| return unexpectedKernError(err), | ||
| 3277 | } | ||
| 3278 | } | ||
| 3279 | |||
| 3280 | pub fn getIdentifierInfo(thread: MachThread) MachError!thread_identifier_info { | ||
| 3281 | var info: thread_identifier_info = undefined; | ||
| 3282 | var count = THREAD_IDENTIFIER_INFO_COUNT; | ||
| 3283 | switch (getKernError(thread_info( | ||
| 3284 | thread.port, | ||
| 3285 | THREAD_IDENTIFIER_INFO, | ||
| 3286 | @as(thread_info_t, @ptrCast(&info)), | ||
| 3287 | &count, | ||
| 3288 | ))) { | ||
| 3289 | .SUCCESS => return info, | ||
| 3290 | else => |err| return unexpectedKernError(err), | ||
| 3291 | } | ||
| 3292 | } | ||
| 3293 | }; | ||
| 3294 | |||
| 3295 | pub fn machTaskForPid(pid: std.c.pid_t) MachError!MachTask { | ||
| 3296 | var port: mach_port_name_t = undefined; | ||
| 3297 | switch (getKernError(task_for_pid(mach_task_self(), pid, &port))) { | ||
| 3298 | .SUCCESS => {}, | ||
| 3299 | .FAILURE => return error.PermissionDenied, | ||
| 3300 | else => |err| return unexpectedKernError(err), | ||
| 3301 | } | ||
| 3302 | return MachTask{ .port = port }; | ||
| 3303 | } | ||
| 3304 | |||
| 3305 | pub fn machTaskForSelf() MachTask { | ||
| 3306 | return .{ .port = mach_task_self() }; | ||
| 3307 | } | ||
| 3308 | |||
| 3309 | pub const os_signpost_id_t = u64; | ||
| 3310 | |||
| 3311 | pub const OS_SIGNPOST_ID_NULL: os_signpost_id_t = 0; | ||
| 3312 | pub const OS_SIGNPOST_ID_INVALID: os_signpost_id_t = !0; | ||
| 3313 | pub const OS_SIGNPOST_ID_EXCLUSIVE: os_signpost_id_t = 0xeeeeb0b5b2b2eeee; | ||
| 3314 | |||
| 3315 | pub const os_log_t = opaque {}; | ||
| 3316 | pub const os_log_type_t = enum(u8) { | ||
| 3317 | /// default messages always captures | ||
| 3318 | OS_LOG_TYPE_DEFAULT = 0x00, | ||
| 3319 | /// messages with additional infos | ||
| 3320 | OS_LOG_TYPE_INFO = 0x01, | ||
| 3321 | /// debug messages | ||
| 3322 | OS_LOG_TYPE_DEBUG = 0x02, | ||
| 3323 | /// error messages | ||
| 3324 | OS_LOG_TYPE_ERROR = 0x10, | ||
| 3325 | /// unexpected conditions messages | ||
| 3326 | OS_LOG_TYPE_FAULT = 0x11, | ||
| 3327 | }; | ||
| 3328 | |||
| 3329 | pub const OS_LOG_CATEGORY_POINTS_OF_INTEREST: *const u8 = "PointsOfInterest"; | ||
| 3330 | pub const OS_LOG_CATEGORY_DYNAMIC_TRACING: *const u8 = "DynamicTracing"; | ||
| 3331 | pub const OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING: *const u8 = "DynamicStackTracing"; | ||
| 3332 | |||
| 3333 | pub extern "c" fn os_log_create(subsystem: [*]const u8, category: [*]const u8) os_log_t; | ||
| 3334 | pub extern "c" fn os_log_type_enabled(log: os_log_t, tpe: os_log_type_t) bool; | ||
| 3335 | pub extern "c" fn os_signpost_id_generate(log: os_log_t) os_signpost_id_t; | ||
| 3336 | pub extern "c" fn os_signpost_interval_begin(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void; | ||
| 3337 | pub extern "c" fn os_signpost_interval_end(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void; | ||
| 3338 | pub extern "c" fn os_signpost_id_make_with_pointer(log: os_log_t, ptr: ?*anyopaque) os_signpost_id_t; | ||
| 3339 | pub extern "c" fn os_signpost_enabled(log: os_log_t) bool; |
lib/std/c/darwin/aarch64.zig deleted-51| ... | @@ -1,51 +0,0 @@ | ||
| 1 | // See C headers in | ||
| 2 | // lib/libc/include/aarch64-macos.12-gnu/mach/arm/_structs.h | ||
| 3 | // lib/libc/include/aarch64-macos.13-none/arm/_mcontext.h | ||
| 4 | |||
| 5 | pub const mcontext_t = extern struct { | ||
| 6 | es: exception_state, | ||
| 7 | ss: thread_state, | ||
| 8 | ns: neon_state, | ||
| 9 | }; | ||
| 10 | |||
| 11 | pub const exception_state = extern struct { | ||
| 12 | far: u64, // Virtual Fault Address | ||
| 13 | esr: u32, // Exception syndrome | ||
| 14 | exception: u32, // Number of arm exception taken | ||
| 15 | }; | ||
| 16 | |||
| 17 | pub const thread_state = extern struct { | ||
| 18 | regs: [29]u64, // General purpose registers | ||
| 19 | fp: u64, // Frame pointer x29 | ||
| 20 | lr: u64, // Link register x30 | ||
| 21 | sp: u64, // Stack pointer x31 | ||
| 22 | pc: u64, // Program counter | ||
| 23 | cpsr: u32, // Current program status register | ||
| 24 | __pad: u32, | ||
| 25 | }; | ||
| 26 | |||
| 27 | pub const neon_state = extern struct { | ||
| 28 | q: [32]u128, | ||
| 29 | fpsr: u32, | ||
| 30 | fpcr: u32, | ||
| 31 | }; | ||
| 32 | |||
| 33 | pub const EXC_TYPES_COUNT = 14; | ||
| 34 | pub const EXC_MASK_MACHINE = 0; | ||
| 35 | |||
| 36 | pub const ARM_THREAD_STATE = 1; | ||
| 37 | pub const ARM_UNIFIED_THREAD_STATE = ARM_THREAD_STATE; | ||
| 38 | pub const ARM_VFP_STATE = 2; | ||
| 39 | pub const ARM_EXCEPTION_STATE = 3; | ||
| 40 | pub const ARM_DEBUG_STATE = 4; | ||
| 41 | pub const THREAD_STATE_NONE = 5; | ||
| 42 | pub const ARM_THREAD_STATE64 = 6; | ||
| 43 | pub const ARM_EXCEPTION_STATE64 = 7; | ||
| 44 | pub const ARM_THREAD_STATE_LAST = 8; | ||
| 45 | pub const ARM_THREAD_STATE32 = 9; | ||
| 46 | pub const ARM_DEBUG_STATE32 = 14; | ||
| 47 | pub const ARM_DEBUG_STATE64 = 15; | ||
| 48 | pub const ARM_NEON_STATE = 16; | ||
| 49 | pub const ARM_NEON_STATE64 = 17; | ||
| 50 | pub const ARM_CPMU_STATE64 = 18; | ||
| 51 | pub const ARM_PAGEIN_STATE = 27; | ||
lib/std/c/darwin/cssm.zig deleted-47| ... | @@ -1,47 +0,0 @@ | ||
| 1 | // Common Security Services Manager | ||
| 2 | // Security.framework/Headers/cssm*.h | ||
| 3 | |||
| 4 | // Schema Management Name Space Range Definition | ||
| 5 | pub const DB_RECORDTYPE_SCHEMA_START = 0x00000000; | ||
| 6 | pub const DB_RECORDTYPE_SCHEMA_END = DB_RECORDTYPE_SCHEMA_START + 4; | ||
| 7 | |||
| 8 | // Open Group Application Name Space Range Definition | ||
| 9 | pub const DB_RECORDTYPE_OPEN_GROUP_START = 0x0000000A; | ||
| 10 | pub const DB_RECORDTYPE_OPEN_GROUP_END = DB_RECORDTYPE_OPEN_GROUP_START + 8; | ||
| 11 | |||
| 12 | // Industry At Large Application Name Space Range Definition | ||
| 13 | pub const DB_RECORDTYPE_APP_DEFINED_START = 0x80000000; | ||
| 14 | pub const DB_RECORDTYPE_APP_DEFINED_END = 0xffffffff; | ||
| 15 | |||
| 16 | pub const DB_RECORDTYPE = enum(u32) { | ||
| 17 | // Record Types defined in the Schema Management Name Space | ||
| 18 | SCHEMA_INFO = DB_RECORDTYPE_SCHEMA_START + 0, | ||
| 19 | SCHEMA_INDEXES = DB_RECORDTYPE_SCHEMA_START + 1, | ||
| 20 | SCHEMA_ATTRIBUTES = DB_RECORDTYPE_SCHEMA_START + 2, | ||
| 21 | SCHEMA_PARSING_MODULE = DB_RECORDTYPE_SCHEMA_START + 3, | ||
| 22 | |||
| 23 | // Record Types defined in the Open Group Application Name Space | ||
| 24 | ANY = DB_RECORDTYPE_OPEN_GROUP_START + 0, | ||
| 25 | CERT = DB_RECORDTYPE_OPEN_GROUP_START + 1, | ||
| 26 | CRL = DB_RECORDTYPE_OPEN_GROUP_START + 2, | ||
| 27 | POLICY = DB_RECORDTYPE_OPEN_GROUP_START + 3, | ||
| 28 | GENERIC = DB_RECORDTYPE_OPEN_GROUP_START + 4, | ||
| 29 | PUBLIC_KEY = DB_RECORDTYPE_OPEN_GROUP_START + 5, | ||
| 30 | PRIVATE_KEY = DB_RECORDTYPE_OPEN_GROUP_START + 6, | ||
| 31 | SYMMETRIC_KEY = DB_RECORDTYPE_OPEN_GROUP_START + 7, | ||
| 32 | ALL_KEYS = DB_RECORDTYPE_OPEN_GROUP_START + 8, | ||
| 33 | |||
| 34 | // AppleFileDL record types | ||
| 35 | GENERIC_PASSWORD = DB_RECORDTYPE_APP_DEFINED_START + 0, | ||
| 36 | INTERNET_PASSWORD = DB_RECORDTYPE_APP_DEFINED_START + 1, | ||
| 37 | APPLESHARE_PASSWORD = DB_RECORDTYPE_APP_DEFINED_START + 2, | ||
| 38 | |||
| 39 | X509_CERTIFICATE = DB_RECORDTYPE_APP_DEFINED_START + 0x1000, | ||
| 40 | USER_TRUST, | ||
| 41 | X509_CRL, | ||
| 42 | UNLOCK_REFERRAL, | ||
| 43 | EXTENDED_ATTRIBUTE, | ||
| 44 | METADATA = DB_RECORDTYPE_APP_DEFINED_START + 0x8000, | ||
| 45 | |||
| 46 | _, | ||
| 47 | }; | ||
lib/std/c/darwin/x86_64.zig deleted-91| ... | @@ -1,91 +0,0 @@ | ||
| 1 | const c = @import("../darwin.zig"); | ||
| 2 | |||
| 3 | pub const mcontext_t = extern struct { | ||
| 4 | es: exception_state, | ||
| 5 | ss: thread_state, | ||
| 6 | fs: float_state, | ||
| 7 | }; | ||
| 8 | |||
| 9 | pub const exception_state = extern struct { | ||
| 10 | trapno: u16, | ||
| 11 | cpu: u16, | ||
| 12 | err: u32, | ||
| 13 | faultvaddr: u64, | ||
| 14 | }; | ||
| 15 | |||
| 16 | pub const thread_state = extern struct { | ||
| 17 | rax: u64, | ||
| 18 | rbx: u64, | ||
| 19 | rcx: u64, | ||
| 20 | rdx: u64, | ||
| 21 | rdi: u64, | ||
| 22 | rsi: u64, | ||
| 23 | rbp: u64, | ||
| 24 | rsp: u64, | ||
| 25 | r8: u64, | ||
| 26 | r9: u64, | ||
| 27 | r10: u64, | ||
| 28 | r11: u64, | ||
| 29 | r12: u64, | ||
| 30 | r13: u64, | ||
| 31 | r14: u64, | ||
| 32 | r15: u64, | ||
| 33 | rip: u64, | ||
| 34 | rflags: u64, | ||
| 35 | cs: u64, | ||
| 36 | fs: u64, | ||
| 37 | gs: u64, | ||
| 38 | }; | ||
| 39 | |||
| 40 | const stmm_reg = [16]u8; | ||
| 41 | const xmm_reg = [16]u8; | ||
| 42 | pub const float_state = extern struct { | ||
| 43 | reserved: [2]c_int, | ||
| 44 | fcw: u16, | ||
| 45 | fsw: u16, | ||
| 46 | ftw: u8, | ||
| 47 | rsrv1: u8, | ||
| 48 | fop: u16, | ||
| 49 | ip: u32, | ||
| 50 | cs: u16, | ||
| 51 | rsrv2: u16, | ||
| 52 | dp: u32, | ||
| 53 | ds: u16, | ||
| 54 | rsrv3: u16, | ||
| 55 | mxcsr: u32, | ||
| 56 | mxcsrmask: u32, | ||
| 57 | stmm: [8]stmm_reg, | ||
| 58 | xmm: [16]xmm_reg, | ||
| 59 | rsrv4: [96]u8, | ||
| 60 | reserved1: c_int, | ||
| 61 | }; | ||
| 62 | |||
| 63 | pub const THREAD_STATE = 4; | ||
| 64 | pub const THREAD_STATE_COUNT: c.mach_msg_type_number_t = @sizeOf(thread_state) / @sizeOf(c_int); | ||
| 65 | |||
| 66 | pub const EXC_TYPES_COUNT = 14; | ||
| 67 | pub const EXC_MASK_MACHINE = 0; | ||
| 68 | |||
| 69 | pub const x86_THREAD_STATE32 = 1; | ||
| 70 | pub const x86_FLOAT_STATE32 = 2; | ||
| 71 | pub const x86_EXCEPTION_STATE32 = 3; | ||
| 72 | pub const x86_THREAD_STATE64 = 4; | ||
| 73 | pub const x86_FLOAT_STATE64 = 5; | ||
| 74 | pub const x86_EXCEPTION_STATE64 = 6; | ||
| 75 | pub const x86_THREAD_STATE = 7; | ||
| 76 | pub const x86_FLOAT_STATE = 8; | ||
| 77 | pub const x86_EXCEPTION_STATE = 9; | ||
| 78 | pub const x86_DEBUG_STATE32 = 10; | ||
| 79 | pub const x86_DEBUG_STATE64 = 11; | ||
| 80 | pub const x86_DEBUG_STATE = 12; | ||
| 81 | pub const THREAD_STATE_NONE = 13; | ||
| 82 | pub const x86_AVX_STATE32 = 16; | ||
| 83 | pub const x86_AVX_STATE64 = (x86_AVX_STATE32 + 1); | ||
| 84 | pub const x86_AVX_STATE = (x86_AVX_STATE32 + 2); | ||
| 85 | pub const x86_AVX512_STATE32 = 19; | ||
| 86 | pub const x86_AVX512_STATE64 = (x86_AVX512_STATE32 + 1); | ||
| 87 | pub const x86_AVX512_STATE = (x86_AVX512_STATE32 + 2); | ||
| 88 | pub const x86_PAGEIN_STATE = 22; | ||
| 89 | pub const x86_THREAD_FULL_STATE64 = 23; | ||
| 90 | pub const x86_INSTRUCTION_STATE = 24; | ||
| 91 | pub const x86_LAST_BRANCH_STATE = 25; | ||
lib/std/c/dragonfly.zig+16-970| ... | @@ -1,63 +1,16 @@ | ... | @@ -1,63 +1,16 @@ |
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 3 | const assert = std.debug.assert; | ||
| 4 | const maxInt = std.math.maxInt; | ||
| 5 | const iovec = std.posix.iovec; | ||
| 6 | 2 | ||
| 7 | extern "c" threadlocal var errno: c_int; | 3 | const SIG = std.c.SIG; |
| 8 | pub fn _errno() *c_int { | 4 | const gid_t = std.c.gid_t; |
| 9 | return &errno; | 5 | const iovec = std.c.iovec; |
| 10 | } | 6 | const pid_t = std.c.pid_t; |
| 11 | 7 | const socklen_t = std.c.socklen_t; | |
| 12 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | 8 | const uid_t = std.c.uid_t; |
| 13 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 14 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | ||
| 15 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int; | ||
| 16 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ||
| 17 | |||
| 18 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 19 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 20 | 9 | ||
| 21 | pub extern "c" fn lwp_gettid() c_int; | 10 | pub extern "c" fn lwp_gettid() c_int; |
| 22 | |||
| 23 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 24 | |||
| 25 | pub const pthread_attr_t = extern struct { // copied from freebsd | ||
| 26 | __size: [56]u8, | ||
| 27 | __align: c_long, | ||
| 28 | }; | ||
| 29 | |||
| 30 | pub const sem_t = ?*opaque {}; | ||
| 31 | |||
| 32 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) c_int; | ||
| 33 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | ||
| 34 | |||
| 35 | pub extern "c" fn umtx_sleep(ptr: *const volatile c_int, value: c_int, timeout: c_int) c_int; | 11 | pub extern "c" fn umtx_sleep(ptr: *const volatile c_int, value: c_int, timeout: c_int) c_int; |
| 36 | pub extern "c" fn umtx_wakeup(ptr: *const volatile c_int, count: c_int) c_int; | 12 | pub extern "c" fn umtx_wakeup(ptr: *const volatile c_int, count: c_int) c_int; |
| 37 | 13 | ||
| 38 | // See: | ||
| 39 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h | ||
| 40 | // - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h | ||
| 41 | // TODO: mode_t should probably be changed to a u16, audit pid_t/off_t as well | ||
| 42 | pub const fd_t = c_int; | ||
| 43 | pub const pid_t = c_int; | ||
| 44 | pub const off_t = c_long; | ||
| 45 | pub const mode_t = c_uint; | ||
| 46 | pub const uid_t = u32; | ||
| 47 | pub const gid_t = u32; | ||
| 48 | pub const time_t = isize; | ||
| 49 | pub const suseconds_t = c_long; | ||
| 50 | |||
| 51 | pub const ucontext_t = extern struct { | ||
| 52 | sigmask: sigset_t, | ||
| 53 | mcontext: mcontext_t, | ||
| 54 | link: ?*ucontext_t, | ||
| 55 | stack: stack_t, | ||
| 56 | cofunc: ?*fn (?*ucontext_t, ?*anyopaque) void, | ||
| 57 | arg: ?*void, | ||
| 58 | _spare: [4]c_int, | ||
| 59 | }; | ||
| 60 | |||
| 61 | pub const mcontext_t = extern struct { | 14 | pub const mcontext_t = extern struct { |
| 62 | onstack: register_t, // XXX - sigcontext compat. | 15 | onstack: register_t, // XXX - sigcontext compat. |
| 63 | rdi: register_t, | 16 | rdi: register_t, |
| ... | @@ -201,707 +154,23 @@ pub const E = enum(u16) { | ... | @@ -201,707 +154,23 @@ pub const E = enum(u16) { |
| 201 | _, | 154 | _, |
| 202 | }; | 155 | }; |
| 203 | 156 | ||
| 204 | pub const STDIN_FILENO = 0; | ||
| 205 | pub const STDOUT_FILENO = 1; | ||
| 206 | pub const STDERR_FILENO = 2; | ||
| 207 | |||
| 208 | pub const PROT = struct { | ||
| 209 | pub const NONE = 0; | ||
| 210 | pub const READ = 1; | ||
| 211 | pub const WRITE = 2; | ||
| 212 | pub const EXEC = 4; | ||
| 213 | }; | ||
| 214 | |||
| 215 | pub const MSF = struct { | ||
| 216 | pub const ASYNC = 1; | ||
| 217 | pub const INVALIDATE = 2; | ||
| 218 | pub const SYNC = 4; | ||
| 219 | }; | ||
| 220 | |||
| 221 | pub const W = struct { | ||
| 222 | pub const NOHANG = 0x0001; | ||
| 223 | pub const UNTRACED = 0x0002; | ||
| 224 | pub const CONTINUED = 0x0004; | ||
| 225 | pub const STOPPED = UNTRACED; | ||
| 226 | pub const NOWAIT = 0x0008; | ||
| 227 | pub const EXITED = 0x0010; | ||
| 228 | pub const TRAPPED = 0x0020; | ||
| 229 | |||
| 230 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 231 | return @as(u8, @intCast((s & 0xff00) >> 8)); | ||
| 232 | } | ||
| 233 | pub fn TERMSIG(s: u32) u32 { | ||
| 234 | return s & 0x7f; | ||
| 235 | } | ||
| 236 | pub fn STOPSIG(s: u32) u32 { | ||
| 237 | return EXITSTATUS(s); | ||
| 238 | } | ||
| 239 | pub fn IFEXITED(s: u32) bool { | ||
| 240 | return TERMSIG(s) == 0; | ||
| 241 | } | ||
| 242 | pub fn IFSTOPPED(s: u32) bool { | ||
| 243 | return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; | ||
| 244 | } | ||
| 245 | pub fn IFSIGNALED(s: u32) bool { | ||
| 246 | return (s & 0xffff) -% 1 < 0xff; | ||
| 247 | } | ||
| 248 | }; | ||
| 249 | |||
| 250 | pub const SA = struct { | ||
| 251 | pub const ONSTACK = 0x0001; | ||
| 252 | pub const RESTART = 0x0002; | ||
| 253 | pub const RESETHAND = 0x0004; | ||
| 254 | pub const NODEFER = 0x0010; | ||
| 255 | pub const NOCLDWAIT = 0x0020; | ||
| 256 | pub const SIGINFO = 0x0040; | ||
| 257 | }; | ||
| 258 | |||
| 259 | pub const PATH_MAX = 1024; | ||
| 260 | pub const NAME_MAX = 255; | ||
| 261 | pub const IOV_MAX = KERN.IOV_MAX; | ||
| 262 | |||
| 263 | pub const ino_t = c_ulong; | ||
| 264 | |||
| 265 | pub const Stat = extern struct { | ||
| 266 | ino: ino_t, | ||
| 267 | nlink: c_uint, | ||
| 268 | dev: c_uint, | ||
| 269 | mode: c_ushort, | ||
| 270 | padding1: u16, | ||
| 271 | uid: uid_t, | ||
| 272 | gid: gid_t, | ||
| 273 | rdev: c_uint, | ||
| 274 | atim: timespec, | ||
| 275 | mtim: timespec, | ||
| 276 | ctim: timespec, | ||
| 277 | size: c_ulong, | ||
| 278 | blocks: i64, | ||
| 279 | blksize: u32, | ||
| 280 | flags: u32, | ||
| 281 | gen: u32, | ||
| 282 | lspare: i32, | ||
| 283 | qspare1: i64, | ||
| 284 | qspare2: i64, | ||
| 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: c_long, | ||
| 300 | tv_nsec: c_long, | ||
| 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 CTL = struct { | ||
| 311 | pub const UNSPEC = 0; | ||
| 312 | pub const KERN = 1; | ||
| 313 | pub const VM = 2; | ||
| 314 | pub const VFS = 3; | ||
| 315 | pub const NET = 4; | ||
| 316 | pub const DEBUG = 5; | ||
| 317 | pub const HW = 6; | ||
| 318 | pub const MACHDEP = 7; | ||
| 319 | pub const USER = 8; | ||
| 320 | pub const LWKT = 10; | ||
| 321 | pub const MAXID = 11; | ||
| 322 | pub const MAXNAME = 12; | ||
| 323 | }; | ||
| 324 | |||
| 325 | pub const KERN = struct { | ||
| 326 | pub const PROC_ALL = 0; | ||
| 327 | pub const OSTYPE = 1; | ||
| 328 | pub const PROC_PID = 1; | ||
| 329 | pub const OSRELEASE = 2; | ||
| 330 | pub const PROC_PGRP = 2; | ||
| 331 | pub const OSREV = 3; | ||
| 332 | pub const PROC_SESSION = 3; | ||
| 333 | pub const VERSION = 4; | ||
| 334 | pub const PROC_TTY = 4; | ||
| 335 | pub const MAXVNODES = 5; | ||
| 336 | pub const PROC_UID = 5; | ||
| 337 | pub const MAXPROC = 6; | ||
| 338 | pub const PROC_RUID = 6; | ||
| 339 | pub const MAXFILES = 7; | ||
| 340 | pub const PROC_ARGS = 7; | ||
| 341 | pub const ARGMAX = 8; | ||
| 342 | pub const PROC_CWD = 8; | ||
| 343 | pub const PROC_PATHNAME = 9; | ||
| 344 | pub const SECURELVL = 9; | ||
| 345 | pub const PROC_SIGTRAMP = 10; | ||
| 346 | pub const HOSTNAME = 10; | ||
| 347 | pub const HOSTID = 11; | ||
| 348 | pub const CLOCKRATE = 12; | ||
| 349 | pub const VNODE = 13; | ||
| 350 | pub const PROC = 14; | ||
| 351 | pub const FILE = 15; | ||
| 352 | pub const PROC_FLAGMASK = 16; | ||
| 353 | pub const PROF = 16; | ||
| 354 | pub const PROC_FLAG_LWP = 16; | ||
| 355 | pub const POSIX1 = 17; | ||
| 356 | pub const NGROUPS = 18; | ||
| 357 | pub const JOB_CONTROL = 19; | ||
| 358 | pub const SAVED_IDS = 20; | ||
| 359 | pub const BOOTTIME = 21; | ||
| 360 | pub const NISDOMAINNAME = 22; | ||
| 361 | pub const UPDATEINTERVAL = 23; | ||
| 362 | pub const OSRELDATE = 24; | ||
| 363 | pub const NTP_PLL = 25; | ||
| 364 | pub const BOOTFILE = 26; | ||
| 365 | pub const MAXFILESPERPROC = 27; | ||
| 366 | pub const MAXPROCPERUID = 28; | ||
| 367 | pub const DUMPDEV = 29; | ||
| 368 | pub const IPC = 30; | ||
| 369 | pub const DUMMY = 31; | ||
| 370 | pub const PS_STRINGS = 32; | ||
| 371 | pub const USRSTACK = 33; | ||
| 372 | pub const LOGSIGEXIT = 34; | ||
| 373 | pub const IOV_MAX = 35; | ||
| 374 | pub const MAXPOSIXLOCKSPERUID = 36; | ||
| 375 | pub const MAXID = 37; | ||
| 376 | }; | ||
| 377 | |||
| 378 | pub const HOST_NAME_MAX = 255; | ||
| 379 | |||
| 380 | // access function | ||
| 381 | pub const F_OK = 0; // test for existence of file | ||
| 382 | pub const X_OK = 1; // test for execute or search permission | ||
| 383 | pub const W_OK = 2; // test for write permission | ||
| 384 | pub const R_OK = 4; // test for read permission | ||
| 385 | |||
| 386 | pub const SEEK = struct { | ||
| 387 | pub const SET = 0; | ||
| 388 | pub const CUR = 1; | ||
| 389 | pub const END = 2; | ||
| 390 | pub const DATA = 3; | ||
| 391 | pub const HOLE = 4; | ||
| 392 | }; | ||
| 393 | |||
| 394 | pub const F = struct { | ||
| 395 | pub const ULOCK = 0; | ||
| 396 | pub const LOCK = 1; | ||
| 397 | pub const TLOCK = 2; | ||
| 398 | pub const TEST = 3; | ||
| 399 | |||
| 400 | pub const DUPFD = 0; | ||
| 401 | pub const GETFD = 1; | ||
| 402 | pub const RDLCK = 1; | ||
| 403 | pub const SETFD = 2; | ||
| 404 | pub const UNLCK = 2; | ||
| 405 | pub const WRLCK = 3; | ||
| 406 | pub const GETFL = 3; | ||
| 407 | pub const SETFL = 4; | ||
| 408 | pub const GETOWN = 5; | ||
| 409 | pub const SETOWN = 6; | ||
| 410 | pub const GETLK = 7; | ||
| 411 | pub const SETLK = 8; | ||
| 412 | pub const SETLKW = 9; | ||
| 413 | pub const DUP2FD = 10; | ||
| 414 | pub const DUPFD_CLOEXEC = 17; | ||
| 415 | pub const DUP2FD_CLOEXEC = 18; | ||
| 416 | pub const GETPATH = 19; | ||
| 417 | }; | ||
| 418 | |||
| 419 | pub const FD_CLOEXEC = 1; | ||
| 420 | |||
| 421 | pub const dirent = extern struct { | ||
| 422 | fileno: c_ulong, | ||
| 423 | namlen: u16, | ||
| 424 | type: u8, | ||
| 425 | unused1: u8, | ||
| 426 | unused2: u32, | ||
| 427 | name: [256]u8, | ||
| 428 | |||
| 429 | pub fn reclen(self: dirent) u16 { | ||
| 430 | return (@offsetOf(dirent, "name") + self.namlen + 1 + 7) & ~@as(u16, 7); | ||
| 431 | } | ||
| 432 | }; | ||
| 433 | |||
| 434 | pub const DT = struct { | ||
| 435 | pub const UNKNOWN = 0; | ||
| 436 | pub const FIFO = 1; | ||
| 437 | pub const CHR = 2; | ||
| 438 | pub const DIR = 4; | ||
| 439 | pub const BLK = 6; | ||
| 440 | pub const REG = 8; | ||
| 441 | pub const LNK = 10; | ||
| 442 | pub const SOCK = 12; | ||
| 443 | pub const WHT = 14; | ||
| 444 | pub const DBF = 15; | ||
| 445 | }; | ||
| 446 | |||
| 447 | pub const CLOCK = struct { | ||
| 448 | pub const REALTIME = 0; | ||
| 449 | pub const VIRTUAL = 1; | ||
| 450 | pub const PROF = 2; | ||
| 451 | pub const MONOTONIC = 4; | ||
| 452 | pub const UPTIME = 5; | ||
| 453 | pub const UPTIME_PRECISE = 7; | ||
| 454 | pub const UPTIME_FAST = 8; | ||
| 455 | pub const REALTIME_PRECISE = 9; | ||
| 456 | pub const REALTIME_FAST = 10; | ||
| 457 | pub const MONOTONIC_PRECISE = 11; | ||
| 458 | pub const MONOTONIC_FAST = 12; | ||
| 459 | pub const SECOND = 13; | ||
| 460 | pub const THREAD_CPUTIME_ID = 14; | ||
| 461 | pub const PROCESS_CPUTIME_ID = 15; | ||
| 462 | }; | ||
| 463 | |||
| 464 | pub const sockaddr = extern struct { | ||
| 465 | len: u8, | ||
| 466 | family: sa_family_t, | ||
| 467 | data: [14]u8, | ||
| 468 | |||
| 469 | pub const SS_MAXSIZE = 128; | ||
| 470 | pub const storage = extern struct { | ||
| 471 | len: u8 align(8), | ||
| 472 | family: sa_family_t, | ||
| 473 | padding: [126]u8 = undefined, | ||
| 474 | |||
| 475 | comptime { | ||
| 476 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 477 | assert(@alignOf(storage) == 8); | ||
| 478 | } | ||
| 479 | }; | ||
| 480 | |||
| 481 | pub const in = extern struct { | ||
| 482 | len: u8 = @sizeOf(in), | ||
| 483 | family: sa_family_t = AF.INET, | ||
| 484 | port: in_port_t, | ||
| 485 | addr: u32, | ||
| 486 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 487 | }; | ||
| 488 | |||
| 489 | pub const in6 = extern struct { | ||
| 490 | len: u8 = @sizeOf(in6), | ||
| 491 | family: sa_family_t = AF.INET6, | ||
| 492 | port: in_port_t, | ||
| 493 | flowinfo: u32, | ||
| 494 | addr: [16]u8, | ||
| 495 | scope_id: u32, | ||
| 496 | }; | ||
| 497 | |||
| 498 | pub const un = extern struct { | ||
| 499 | len: u8 = @sizeOf(un), | ||
| 500 | family: sa_family_t = AF.UNIX, | ||
| 501 | path: [104]u8, | ||
| 502 | }; | ||
| 503 | }; | ||
| 504 | |||
| 505 | pub const Kevent = extern struct { | ||
| 506 | ident: usize, | ||
| 507 | filter: c_short, | ||
| 508 | flags: c_ushort, | ||
| 509 | fflags: c_uint, | ||
| 510 | data: isize, | ||
| 511 | udata: usize, | ||
| 512 | }; | ||
| 513 | |||
| 514 | pub const EVFILT_FS = -10; | ||
| 515 | pub const EVFILT_USER = -9; | ||
| 516 | pub const EVFILT_EXCEPT = -8; | ||
| 517 | pub const EVFILT_TIMER = -7; | ||
| 518 | pub const EVFILT_SIGNAL = -6; | ||
| 519 | pub const EVFILT_PROC = -5; | ||
| 520 | pub const EVFILT_VNODE = -4; | ||
| 521 | pub const EVFILT_AIO = -3; | ||
| 522 | pub const EVFILT_WRITE = -2; | ||
| 523 | pub const EVFILT_READ = -1; | ||
| 524 | pub const EVFILT_SYSCOUNT = 10; | ||
| 525 | pub const EVFILT_MARKER = 15; | ||
| 526 | |||
| 527 | pub const EV_ADD = 1; | ||
| 528 | pub const EV_DELETE = 2; | ||
| 529 | pub const EV_ENABLE = 4; | ||
| 530 | pub const EV_DISABLE = 8; | ||
| 531 | pub const EV_ONESHOT = 16; | ||
| 532 | pub const EV_CLEAR = 32; | ||
| 533 | pub const EV_RECEIPT = 64; | ||
| 534 | pub const EV_DISPATCH = 128; | ||
| 535 | pub const EV_NODATA = 4096; | ||
| 536 | pub const EV_FLAG1 = 8192; | ||
| 537 | pub const EV_ERROR = 16384; | ||
| 538 | pub const EV_EOF = 32768; | ||
| 539 | pub const EV_SYSFLAGS = 61440; | ||
| 540 | |||
| 541 | pub const NOTE_FFNOP = 0; | ||
| 542 | pub const NOTE_TRACK = 1; | ||
| 543 | pub const NOTE_DELETE = 1; | ||
| 544 | pub const NOTE_LOWAT = 1; | ||
| 545 | pub const NOTE_TRACKERR = 2; | ||
| 546 | pub const NOTE_OOB = 2; | ||
| 547 | pub const NOTE_WRITE = 2; | ||
| 548 | pub const NOTE_EXTEND = 4; | ||
| 549 | pub const NOTE_CHILD = 4; | ||
| 550 | pub const NOTE_ATTRIB = 8; | ||
| 551 | pub const NOTE_LINK = 16; | ||
| 552 | pub const NOTE_RENAME = 32; | ||
| 553 | pub const NOTE_REVOKE = 64; | ||
| 554 | pub const NOTE_PDATAMASK = 1048575; | ||
| 555 | pub const NOTE_FFLAGSMASK = 16777215; | ||
| 556 | pub const NOTE_TRIGGER = 16777216; | ||
| 557 | pub const NOTE_EXEC = 536870912; | ||
| 558 | pub const NOTE_FFAND = 1073741824; | ||
| 559 | pub const NOTE_FORK = 1073741824; | ||
| 560 | pub const NOTE_EXIT = 2147483648; | ||
| 561 | pub const NOTE_FFOR = 2147483648; | ||
| 562 | pub const NOTE_FFCTRLMASK = 3221225472; | ||
| 563 | pub const NOTE_FFCOPY = 3221225472; | ||
| 564 | pub const NOTE_PCTRLMASK = 4026531840; | ||
| 565 | |||
| 566 | pub const TCSA = enum(c_uint) { | ||
| 567 | NOW, | ||
| 568 | DRAIN, | ||
| 569 | FLUSH, | ||
| 570 | _, | ||
| 571 | }; | ||
| 572 | |||
| 573 | pub const stack_t = extern struct { | ||
| 574 | sp: [*]u8, | ||
| 575 | size: isize, | ||
| 576 | flags: i32, | ||
| 577 | }; | ||
| 578 | |||
| 579 | pub const S = struct { | ||
| 580 | pub const IREAD = IRUSR; | ||
| 581 | pub const IEXEC = IXUSR; | ||
| 582 | pub const IWRITE = IWUSR; | ||
| 583 | pub const IXOTH = 1; | ||
| 584 | pub const IWOTH = 2; | ||
| 585 | pub const IROTH = 4; | ||
| 586 | pub const IRWXO = 7; | ||
| 587 | pub const IXGRP = 8; | ||
| 588 | pub const IWGRP = 16; | ||
| 589 | pub const IRGRP = 32; | ||
| 590 | pub const IRWXG = 56; | ||
| 591 | pub const IXUSR = 64; | ||
| 592 | pub const IWUSR = 128; | ||
| 593 | pub const IRUSR = 256; | ||
| 594 | pub const IRWXU = 448; | ||
| 595 | pub const ISTXT = 512; | ||
| 596 | pub const BLKSIZE = 512; | ||
| 597 | pub const ISVTX = 512; | ||
| 598 | pub const ISGID = 1024; | ||
| 599 | pub const ISUID = 2048; | ||
| 600 | pub const IFIFO = 4096; | ||
| 601 | pub const IFCHR = 8192; | ||
| 602 | pub const IFDIR = 16384; | ||
| 603 | pub const IFBLK = 24576; | ||
| 604 | pub const IFREG = 32768; | ||
| 605 | pub const IFDB = 36864; | ||
| 606 | pub const IFLNK = 40960; | ||
| 607 | pub const IFSOCK = 49152; | ||
| 608 | pub const IFWHT = 57344; | ||
| 609 | pub const IFMT = 61440; | ||
| 610 | |||
| 611 | pub fn ISCHR(m: u32) bool { | ||
| 612 | return m & IFMT == IFCHR; | ||
| 613 | } | ||
| 614 | }; | ||
| 615 | |||
| 616 | pub const BADSIG = SIG.ERR; | 157 | pub const BADSIG = SIG.ERR; |
| 617 | 158 | ||
| 618 | pub const SIG = struct { | ||
| 619 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 620 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 621 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 622 | |||
| 623 | pub const BLOCK = 1; | ||
| 624 | pub const UNBLOCK = 2; | ||
| 625 | pub const SETMASK = 3; | ||
| 626 | |||
| 627 | pub const IOT = ABRT; | ||
| 628 | pub const HUP = 1; | ||
| 629 | pub const INT = 2; | ||
| 630 | pub const QUIT = 3; | ||
| 631 | pub const ILL = 4; | ||
| 632 | pub const TRAP = 5; | ||
| 633 | pub const ABRT = 6; | ||
| 634 | pub const EMT = 7; | ||
| 635 | pub const FPE = 8; | ||
| 636 | pub const KILL = 9; | ||
| 637 | pub const BUS = 10; | ||
| 638 | pub const SEGV = 11; | ||
| 639 | pub const SYS = 12; | ||
| 640 | pub const PIPE = 13; | ||
| 641 | pub const ALRM = 14; | ||
| 642 | pub const TERM = 15; | ||
| 643 | pub const URG = 16; | ||
| 644 | pub const STOP = 17; | ||
| 645 | pub const TSTP = 18; | ||
| 646 | pub const CONT = 19; | ||
| 647 | pub const CHLD = 20; | ||
| 648 | pub const TTIN = 21; | ||
| 649 | pub const TTOU = 22; | ||
| 650 | pub const IO = 23; | ||
| 651 | pub const XCPU = 24; | ||
| 652 | pub const XFSZ = 25; | ||
| 653 | pub const VTALRM = 26; | ||
| 654 | pub const PROF = 27; | ||
| 655 | pub const WINCH = 28; | ||
| 656 | pub const INFO = 29; | ||
| 657 | pub const USR1 = 30; | ||
| 658 | pub const USR2 = 31; | ||
| 659 | pub const THR = 32; | ||
| 660 | pub const CKPT = 33; | ||
| 661 | pub const CKPTEXIT = 34; | ||
| 662 | }; | ||
| 663 | |||
| 664 | pub const siginfo_t = extern struct { | ||
| 665 | signo: c_int, | ||
| 666 | errno: c_int, | ||
| 667 | code: c_int, | ||
| 668 | pid: c_int, | ||
| 669 | uid: uid_t, | ||
| 670 | status: c_int, | ||
| 671 | addr: *allowzero anyopaque, | ||
| 672 | value: sigval, | ||
| 673 | band: c_long, | ||
| 674 | __spare__: [7]c_int, | ||
| 675 | }; | ||
| 676 | |||
| 677 | pub const sigval = extern union { | ||
| 678 | sival_int: c_int, | ||
| 679 | sival_ptr: ?*anyopaque, | ||
| 680 | }; | ||
| 681 | |||
| 682 | pub const _SIG_WORDS = 4; | ||
| 683 | |||
| 684 | pub const sigset_t = extern struct { | ||
| 685 | __bits: [_SIG_WORDS]c_uint, | ||
| 686 | }; | ||
| 687 | |||
| 688 | pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS }; | ||
| 689 | |||
| 690 | pub const sig_atomic_t = c_int; | ||
| 691 | |||
| 692 | pub const Sigaction = extern struct { | ||
| 693 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 694 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 695 | |||
| 696 | /// signal handler | ||
| 697 | handler: extern union { | ||
| 698 | handler: ?handler_fn, | ||
| 699 | sigaction: ?sigaction_fn, | ||
| 700 | }, | ||
| 701 | flags: c_uint, | ||
| 702 | mask: sigset_t, | ||
| 703 | }; | ||
| 704 | |||
| 705 | pub const sig_t = *const fn (i32) callconv(.C) void; | 159 | pub const sig_t = *const fn (i32) callconv(.C) void; |
| 706 | 160 | ||
| 707 | pub const SOCK = struct { | ||
| 708 | pub const STREAM = 1; | ||
| 709 | pub const DGRAM = 2; | ||
| 710 | pub const RAW = 3; | ||
| 711 | pub const RDM = 4; | ||
| 712 | pub const SEQPACKET = 5; | ||
| 713 | pub const MAXADDRLEN = 255; | ||
| 714 | pub const CLOEXEC = 0x10000000; | ||
| 715 | pub const NONBLOCK = 0x20000000; | ||
| 716 | }; | ||
| 717 | |||
| 718 | pub const SO = struct { | ||
| 719 | pub const DEBUG = 0x0001; | ||
| 720 | pub const ACCEPTCONN = 0x0002; | ||
| 721 | pub const REUSEADDR = 0x0004; | ||
| 722 | pub const KEEPALIVE = 0x0008; | ||
| 723 | pub const DONTROUTE = 0x0010; | ||
| 724 | pub const BROADCAST = 0x0020; | ||
| 725 | pub const USELOOPBACK = 0x0040; | ||
| 726 | pub const LINGER = 0x0080; | ||
| 727 | pub const OOBINLINE = 0x0100; | ||
| 728 | pub const REUSEPORT = 0x0200; | ||
| 729 | pub const TIMESTAMP = 0x0400; | ||
| 730 | pub const NOSIGPIPE = 0x0800; | ||
| 731 | pub const ACCEPTFILTER = 0x1000; | ||
| 732 | pub const RERROR = 0x2000; | ||
| 733 | pub const PASSCRED = 0x4000; | ||
| 734 | |||
| 735 | pub const SNDBUF = 0x1001; | ||
| 736 | pub const RCVBUF = 0x1002; | ||
| 737 | pub const SNDLOWAT = 0x1003; | ||
| 738 | pub const RCVLOWAT = 0x1004; | ||
| 739 | pub const SNDTIMEO = 0x1005; | ||
| 740 | pub const RCVTIMEO = 0x1006; | ||
| 741 | pub const ERROR = 0x1007; | ||
| 742 | pub const TYPE = 0x1008; | ||
| 743 | pub const SNDSPACE = 0x100a; | ||
| 744 | pub const CPUHINT = 0x1030; | ||
| 745 | }; | ||
| 746 | |||
| 747 | pub const SOL = struct { | ||
| 748 | pub const SOCKET = 0xffff; | ||
| 749 | }; | ||
| 750 | |||
| 751 | pub const PF = struct { | ||
| 752 | pub const INET6 = AF.INET6; | ||
| 753 | pub const IMPLINK = AF.IMPLINK; | ||
| 754 | pub const ROUTE = AF.ROUTE; | ||
| 755 | pub const ISO = AF.ISO; | ||
| 756 | pub const PIP = AF.pseudo_PIP; | ||
| 757 | pub const CHAOS = AF.CHAOS; | ||
| 758 | pub const DATAKIT = AF.DATAKIT; | ||
| 759 | pub const INET = AF.INET; | ||
| 760 | pub const APPLETALK = AF.APPLETALK; | ||
| 761 | pub const SIP = AF.SIP; | ||
| 762 | pub const OSI = AF.ISO; | ||
| 763 | pub const CNT = AF.CNT; | ||
| 764 | pub const LINK = AF.LINK; | ||
| 765 | pub const HYLINK = AF.HYLINK; | ||
| 766 | pub const MAX = AF.MAX; | ||
| 767 | pub const KEY = AF.pseudo_KEY; | ||
| 768 | pub const PUP = AF.PUP; | ||
| 769 | pub const COIP = AF.COIP; | ||
| 770 | pub const SNA = AF.SNA; | ||
| 771 | pub const LOCAL = AF.LOCAL; | ||
| 772 | pub const NETBIOS = AF.NETBIOS; | ||
| 773 | pub const NATM = AF.NATM; | ||
| 774 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 775 | pub const UNSPEC = AF.UNSPEC; | ||
| 776 | pub const NETGRAPH = AF.NETGRAPH; | ||
| 777 | pub const ECMA = AF.ECMA; | ||
| 778 | pub const IPX = AF.IPX; | ||
| 779 | pub const DLI = AF.DLI; | ||
| 780 | pub const ATM = AF.ATM; | ||
| 781 | pub const CCITT = AF.CCITT; | ||
| 782 | pub const ISDN = AF.ISDN; | ||
| 783 | pub const RTIP = AF.pseudo_RTIP; | ||
| 784 | pub const LAT = AF.LAT; | ||
| 785 | pub const UNIX = PF.LOCAL; | ||
| 786 | pub const XTP = AF.pseudo_XTP; | ||
| 787 | pub const DECnet = AF.DECnet; | ||
| 788 | }; | ||
| 789 | |||
| 790 | pub const AF = struct { | ||
| 791 | pub const UNSPEC = 0; | ||
| 792 | pub const OSI = ISO; | ||
| 793 | pub const UNIX = LOCAL; | ||
| 794 | pub const LOCAL = 1; | ||
| 795 | pub const INET = 2; | ||
| 796 | pub const IMPLINK = 3; | ||
| 797 | pub const PUP = 4; | ||
| 798 | pub const CHAOS = 5; | ||
| 799 | pub const NETBIOS = 6; | ||
| 800 | pub const ISO = 7; | ||
| 801 | pub const ECMA = 8; | ||
| 802 | pub const DATAKIT = 9; | ||
| 803 | pub const CCITT = 10; | ||
| 804 | pub const SNA = 11; | ||
| 805 | pub const DLI = 13; | ||
| 806 | pub const LAT = 14; | ||
| 807 | pub const HYLINK = 15; | ||
| 808 | pub const APPLETALK = 16; | ||
| 809 | pub const ROUTE = 17; | ||
| 810 | pub const LINK = 18; | ||
| 811 | pub const COIP = 20; | ||
| 812 | pub const CNT = 21; | ||
| 813 | pub const IPX = 23; | ||
| 814 | pub const SIP = 24; | ||
| 815 | pub const ISDN = 26; | ||
| 816 | pub const INET6 = 28; | ||
| 817 | pub const NATM = 29; | ||
| 818 | pub const ATM = 30; | ||
| 819 | pub const NETGRAPH = 32; | ||
| 820 | pub const BLUETOOTH = 33; | ||
| 821 | pub const MPLS = 34; | ||
| 822 | pub const MAX = 36; | ||
| 823 | }; | ||
| 824 | |||
| 825 | pub const in_port_t = u16; | ||
| 826 | pub const sa_family_t = u8; | ||
| 827 | pub const socklen_t = u32; | ||
| 828 | |||
| 829 | pub const EAI = enum(c_int) { | ||
| 830 | ADDRFAMILY = 1, | ||
| 831 | AGAIN = 2, | ||
| 832 | BADFLAGS = 3, | ||
| 833 | FAIL = 4, | ||
| 834 | FAMILY = 5, | ||
| 835 | MEMORY = 6, | ||
| 836 | NODATA = 7, | ||
| 837 | NONAME = 8, | ||
| 838 | SERVICE = 9, | ||
| 839 | SOCKTYPE = 10, | ||
| 840 | SYSTEM = 11, | ||
| 841 | BADHINTS = 12, | ||
| 842 | PROTOCOL = 13, | ||
| 843 | OVERFLOW = 14, | ||
| 844 | _, | ||
| 845 | }; | ||
| 846 | |||
| 847 | pub const IFNAMESIZE = 16; | ||
| 848 | |||
| 849 | pub const AI = struct { | ||
| 850 | pub const PASSIVE = 0x00000001; | ||
| 851 | pub const CANONNAME = 0x00000002; | ||
| 852 | pub const NUMERICHOST = 0x00000004; | ||
| 853 | pub const NUMERICSERV = 0x00000008; | ||
| 854 | pub const MASK = PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG; | ||
| 855 | pub const ALL = 0x00000100; | ||
| 856 | pub const V4MAPPED_CFG = 0x00000200; | ||
| 857 | pub const ADDRCONFIG = 0x00000400; | ||
| 858 | pub const V4MAPPED = 0x00000800; | ||
| 859 | pub const DEFAULT = V4MAPPED_CFG | ADDRCONFIG; | ||
| 860 | }; | ||
| 861 | |||
| 862 | pub const RTLD = struct { | ||
| 863 | pub const LAZY = 1; | ||
| 864 | pub const NOW = 2; | ||
| 865 | pub const MODEMASK = 0x3; | ||
| 866 | pub const GLOBAL = 0x100; | ||
| 867 | pub const LOCAL = 0; | ||
| 868 | pub const TRACE = 0x200; | ||
| 869 | pub const NODELETE = 0x01000; | ||
| 870 | pub const NOLOAD = 0x02000; | ||
| 871 | |||
| 872 | pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); | ||
| 873 | pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); | ||
| 874 | pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); | ||
| 875 | pub const ALL = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -4))))); | ||
| 876 | }; | ||
| 877 | |||
| 878 | pub const dl_phdr_info = extern struct { | ||
| 879 | dlpi_addr: usize, | ||
| 880 | dlpi_name: ?[*:0]const u8, | ||
| 881 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 882 | dlpi_phnum: u16, | ||
| 883 | }; | ||
| 884 | pub const cmsghdr = extern struct { | 161 | pub const cmsghdr = extern struct { |
| 885 | cmsg_len: socklen_t, | 162 | len: socklen_t, |
| 886 | cmsg_level: c_int, | 163 | level: c_int, |
| 887 | cmsg_type: c_int, | 164 | type: c_int, |
| 888 | }; | ||
| 889 | pub const msghdr = extern struct { | ||
| 890 | msg_name: ?*anyopaque, | ||
| 891 | msg_namelen: socklen_t, | ||
| 892 | msg_iov: [*]iovec, | ||
| 893 | msg_iovlen: c_int, | ||
| 894 | msg_control: ?*anyopaque, | ||
| 895 | msg_controllen: socklen_t, | ||
| 896 | msg_flags: c_int, | ||
| 897 | }; | 165 | }; |
| 166 | |||
| 898 | pub const cmsgcred = extern struct { | 167 | pub const cmsgcred = extern struct { |
| 899 | cmcred_pid: pid_t, | 168 | pid: pid_t, |
| 900 | cmcred_uid: uid_t, | 169 | uid: uid_t, |
| 901 | cmcred_euid: uid_t, | 170 | euid: uid_t, |
| 902 | cmcred_gid: gid_t, | 171 | gid: gid_t, |
| 903 | cmcred_ngroups: c_short, | 172 | ngroups: c_short, |
| 904 | cmcred_groups: [16]gid_t, | 173 | groups: [16]gid_t, |
| 905 | }; | 174 | }; |
| 906 | pub const sf_hdtr = extern struct { | 175 | pub const sf_hdtr = extern struct { |
| 907 | headers: [*]iovec, | 176 | headers: [*]iovec, |
| ... | @@ -919,226 +188,3 @@ pub const POSIX_MADV_RANDOM = 1; | ... | @@ -919,226 +188,3 @@ pub const POSIX_MADV_RANDOM = 1; |
| 919 | pub const POSIX_MADV_DONTNEED = 4; | 188 | pub const POSIX_MADV_DONTNEED = 4; |
| 920 | pub const POSIX_MADV_NORMAL = 0; | 189 | pub const POSIX_MADV_NORMAL = 0; |
| 921 | pub const POSIX_MADV_WILLNEED = 3; | 190 | pub const POSIX_MADV_WILLNEED = 3; |
| 922 | |||
| 923 | pub const MADV = struct { | ||
| 924 | pub const SEQUENTIAL = 2; | ||
| 925 | pub const CONTROL_END = SETMAP; | ||
| 926 | pub const DONTNEED = 4; | ||
| 927 | pub const RANDOM = 1; | ||
| 928 | pub const WILLNEED = 3; | ||
| 929 | pub const NORMAL = 0; | ||
| 930 | pub const CONTROL_START = INVAL; | ||
| 931 | pub const FREE = 5; | ||
| 932 | pub const NOSYNC = 6; | ||
| 933 | pub const AUTOSYNC = 7; | ||
| 934 | pub const NOCORE = 8; | ||
| 935 | pub const CORE = 9; | ||
| 936 | pub const INVAL = 10; | ||
| 937 | pub const SETMAP = 11; | ||
| 938 | }; | ||
| 939 | |||
| 940 | pub const LOCK = struct { | ||
| 941 | pub const SH = 1; | ||
| 942 | pub const EX = 2; | ||
| 943 | pub const UN = 8; | ||
| 944 | pub const NB = 4; | ||
| 945 | }; | ||
| 946 | |||
| 947 | pub const Flock = extern struct { | ||
| 948 | start: off_t, | ||
| 949 | len: off_t, | ||
| 950 | pid: pid_t, | ||
| 951 | type: c_short, | ||
| 952 | whence: c_short, | ||
| 953 | }; | ||
| 954 | |||
| 955 | pub const addrinfo = extern struct { | ||
| 956 | flags: i32, | ||
| 957 | family: i32, | ||
| 958 | socktype: i32, | ||
| 959 | protocol: i32, | ||
| 960 | addrlen: socklen_t, | ||
| 961 | canonname: ?[*:0]u8, | ||
| 962 | addr: ?*sockaddr, | ||
| 963 | next: ?*addrinfo, | ||
| 964 | }; | ||
| 965 | |||
| 966 | pub const IPPROTO = struct { | ||
| 967 | pub const IP = 0; | ||
| 968 | pub const ICMP = 1; | ||
| 969 | pub const TCP = 6; | ||
| 970 | pub const UDP = 17; | ||
| 971 | pub const IPV6 = 41; | ||
| 972 | pub const RAW = 255; | ||
| 973 | pub const HOPOPTS = 0; | ||
| 974 | pub const IGMP = 2; | ||
| 975 | pub const GGP = 3; | ||
| 976 | pub const IPV4 = 4; | ||
| 977 | pub const IPIP = IPV4; | ||
| 978 | pub const ST = 7; | ||
| 979 | pub const EGP = 8; | ||
| 980 | pub const PIGP = 9; | ||
| 981 | pub const RCCMON = 10; | ||
| 982 | pub const NVPII = 11; | ||
| 983 | pub const PUP = 12; | ||
| 984 | pub const ARGUS = 13; | ||
| 985 | pub const EMCON = 14; | ||
| 986 | pub const XNET = 15; | ||
| 987 | pub const CHAOS = 16; | ||
| 988 | pub const MUX = 18; | ||
| 989 | pub const MEAS = 19; | ||
| 990 | pub const HMP = 20; | ||
| 991 | pub const PRM = 21; | ||
| 992 | pub const IDP = 22; | ||
| 993 | pub const TRUNK1 = 23; | ||
| 994 | pub const TRUNK2 = 24; | ||
| 995 | pub const LEAF1 = 25; | ||
| 996 | pub const LEAF2 = 26; | ||
| 997 | pub const RDP = 27; | ||
| 998 | pub const IRTP = 28; | ||
| 999 | pub const TP = 29; | ||
| 1000 | pub const BLT = 30; | ||
| 1001 | pub const NSP = 31; | ||
| 1002 | pub const INP = 32; | ||
| 1003 | pub const SEP = 33; | ||
| 1004 | pub const @"3PC" = 34; | ||
| 1005 | pub const IDPR = 35; | ||
| 1006 | pub const XTP = 36; | ||
| 1007 | pub const DDP = 37; | ||
| 1008 | pub const CMTP = 38; | ||
| 1009 | pub const TPXX = 39; | ||
| 1010 | pub const IL = 40; | ||
| 1011 | pub const SDRP = 42; | ||
| 1012 | pub const ROUTING = 43; | ||
| 1013 | pub const FRAGMENT = 44; | ||
| 1014 | pub const IDRP = 45; | ||
| 1015 | pub const RSVP = 46; | ||
| 1016 | pub const GRE = 47; | ||
| 1017 | pub const MHRP = 48; | ||
| 1018 | pub const BHA = 49; | ||
| 1019 | pub const ESP = 50; | ||
| 1020 | pub const AH = 51; | ||
| 1021 | pub const INLSP = 52; | ||
| 1022 | pub const SWIPE = 53; | ||
| 1023 | pub const NHRP = 54; | ||
| 1024 | pub const MOBILE = 55; | ||
| 1025 | pub const TLSP = 56; | ||
| 1026 | pub const SKIP = 57; | ||
| 1027 | pub const ICMPV6 = 58; | ||
| 1028 | pub const NONE = 59; | ||
| 1029 | pub const DSTOPTS = 60; | ||
| 1030 | pub const AHIP = 61; | ||
| 1031 | pub const CFTP = 62; | ||
| 1032 | pub const HELLO = 63; | ||
| 1033 | pub const SATEXPAK = 64; | ||
| 1034 | pub const KRYPTOLAN = 65; | ||
| 1035 | pub const RVD = 66; | ||
| 1036 | pub const IPPC = 67; | ||
| 1037 | pub const ADFS = 68; | ||
| 1038 | pub const SATMON = 69; | ||
| 1039 | pub const VISA = 70; | ||
| 1040 | pub const IPCV = 71; | ||
| 1041 | pub const CPNX = 72; | ||
| 1042 | pub const CPHB = 73; | ||
| 1043 | pub const WSN = 74; | ||
| 1044 | pub const PVP = 75; | ||
| 1045 | pub const BRSATMON = 76; | ||
| 1046 | pub const ND = 77; | ||
| 1047 | pub const WBMON = 78; | ||
| 1048 | pub const WBEXPAK = 79; | ||
| 1049 | pub const EON = 80; | ||
| 1050 | pub const VMTP = 81; | ||
| 1051 | pub const SVMTP = 82; | ||
| 1052 | pub const VINES = 83; | ||
| 1053 | pub const TTP = 84; | ||
| 1054 | pub const IGP = 85; | ||
| 1055 | pub const DGP = 86; | ||
| 1056 | pub const TCF = 87; | ||
| 1057 | pub const IGRP = 88; | ||
| 1058 | pub const OSPFIGP = 89; | ||
| 1059 | pub const SRPC = 90; | ||
| 1060 | pub const LARP = 91; | ||
| 1061 | pub const MTP = 92; | ||
| 1062 | pub const AX25 = 93; | ||
| 1063 | pub const IPEIP = 94; | ||
| 1064 | pub const MICP = 95; | ||
| 1065 | pub const SCCSP = 96; | ||
| 1066 | pub const ETHERIP = 97; | ||
| 1067 | pub const ENCAP = 98; | ||
| 1068 | pub const APES = 99; | ||
| 1069 | pub const GMTP = 100; | ||
| 1070 | pub const IPCOMP = 108; | ||
| 1071 | pub const PIM = 103; | ||
| 1072 | pub const CARP = 112; | ||
| 1073 | pub const PGM = 113; | ||
| 1074 | pub const PFSYNC = 240; | ||
| 1075 | pub const DIVERT = 254; | ||
| 1076 | pub const MAX = 256; | ||
| 1077 | pub const DONE = 257; | ||
| 1078 | pub const UNKNOWN = 258; | ||
| 1079 | }; | ||
| 1080 | |||
| 1081 | pub const rlimit_resource = enum(c_int) { | ||
| 1082 | CPU = 0, | ||
| 1083 | FSIZE = 1, | ||
| 1084 | DATA = 2, | ||
| 1085 | STACK = 3, | ||
| 1086 | CORE = 4, | ||
| 1087 | RSS = 5, | ||
| 1088 | MEMLOCK = 6, | ||
| 1089 | NPROC = 7, | ||
| 1090 | NOFILE = 8, | ||
| 1091 | SBSIZE = 9, | ||
| 1092 | VMEM = 10, | ||
| 1093 | POSIXLOCKS = 11, | ||
| 1094 | _, | ||
| 1095 | |||
| 1096 | pub const AS: rlimit_resource = .VMEM; | ||
| 1097 | }; | ||
| 1098 | |||
| 1099 | pub const rlim_t = i64; | ||
| 1100 | |||
| 1101 | pub const RLIM = struct { | ||
| 1102 | /// No limit | ||
| 1103 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1104 | |||
| 1105 | pub const SAVED_MAX = INFINITY; | ||
| 1106 | pub const SAVED_CUR = INFINITY; | ||
| 1107 | }; | ||
| 1108 | |||
| 1109 | pub const rlimit = extern struct { | ||
| 1110 | /// Soft limit | ||
| 1111 | cur: rlim_t, | ||
| 1112 | /// Hard limit | ||
| 1113 | max: rlim_t, | ||
| 1114 | }; | ||
| 1115 | |||
| 1116 | pub const SHUT = struct { | ||
| 1117 | pub const RD = 0; | ||
| 1118 | pub const WR = 1; | ||
| 1119 | pub const RDWR = 2; | ||
| 1120 | }; | ||
| 1121 | |||
| 1122 | pub const nfds_t = u32; | ||
| 1123 | |||
| 1124 | pub const pollfd = extern struct { | ||
| 1125 | fd: fd_t, | ||
| 1126 | events: i16, | ||
| 1127 | revents: i16, | ||
| 1128 | }; | ||
| 1129 | |||
| 1130 | pub const POLL = struct { | ||
| 1131 | /// Requestable events. | ||
| 1132 | pub const IN = 0x0001; | ||
| 1133 | pub const PRI = 0x0002; | ||
| 1134 | pub const OUT = 0x0004; | ||
| 1135 | pub const RDNORM = 0x0040; | ||
| 1136 | pub const WRNORM = OUT; | ||
| 1137 | pub const RDBAND = 0x0080; | ||
| 1138 | pub const WRBAND = 0x0100; | ||
| 1139 | |||
| 1140 | /// These events are set if they occur regardless of whether they were requested. | ||
| 1141 | pub const ERR = 0x0008; | ||
| 1142 | pub const HUP = 0x0010; | ||
| 1143 | pub const NVAL = 0x0020; | ||
| 1144 | }; |
lib/std/c/emscripten.zig deleted-180| ... | @@ -1,180 +0,0 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | const maxInt = std.math.maxInt; | ||
| 3 | const emscripten = std.os.emscripten; | ||
| 4 | |||
| 5 | pub const AF = emscripten.AF; | ||
| 6 | pub const CLOCK = emscripten.CLOCK; | ||
| 7 | pub const CPU_COUNT = emscripten.CPU_COUNT; | ||
| 8 | pub const E = emscripten.E; | ||
| 9 | pub const F = emscripten.F; | ||
| 10 | pub const FD_CLOEXEC = emscripten.FD_CLOEXEC; | ||
| 11 | pub const F_OK = emscripten.F_OK; | ||
| 12 | pub const Flock = emscripten.Flock; | ||
| 13 | pub const IFNAMESIZE = emscripten.IFNAMESIZE; | ||
| 14 | pub const IOV_MAX = emscripten.IOV_MAX; | ||
| 15 | pub const IPPROTO = emscripten.IPPROTO; | ||
| 16 | pub const LOCK = emscripten.LOCK; | ||
| 17 | pub const MADV = emscripten.MADV; | ||
| 18 | pub const MSF = emscripten.MSF; | ||
| 19 | pub const MSG = emscripten.MSG; | ||
| 20 | pub const NAME_MAX = emscripten.NAME_MAX; | ||
| 21 | pub const PATH_MAX = emscripten.PATH_MAX; | ||
| 22 | pub const POLL = emscripten.POLL; | ||
| 23 | pub const PROT = emscripten.PROT; | ||
| 24 | pub const REG = emscripten.REG; | ||
| 25 | pub const RLIM = emscripten.RLIM; | ||
| 26 | pub const R_OK = emscripten.R_OK; | ||
| 27 | pub const S = emscripten.S; | ||
| 28 | pub const SA = emscripten.SA; | ||
| 29 | pub const SEEK = emscripten.SEEK; | ||
| 30 | pub const SHUT = emscripten.SHUT; | ||
| 31 | pub const SIG = emscripten.SIG; | ||
| 32 | pub const SIOCGIFINDEX = emscripten.SIOCGIFINDEX; | ||
| 33 | pub const SO = emscripten.SO; | ||
| 34 | pub const SOCK = emscripten.SOCK; | ||
| 35 | pub const SOL = emscripten.SOL; | ||
| 36 | pub const STDERR_FILENO = emscripten.STDERR_FILENO; | ||
| 37 | pub const STDIN_FILENO = emscripten.STDIN_FILENO; | ||
| 38 | pub const STDOUT_FILENO = emscripten.STDOUT_FILENO; | ||
| 39 | pub const Sigaction = emscripten.Sigaction; | ||
| 40 | pub const TCP = emscripten.TCP; | ||
| 41 | pub const TCSA = emscripten.TCSA; | ||
| 42 | pub const W = emscripten.W; | ||
| 43 | pub const W_OK = emscripten.W_OK; | ||
| 44 | pub const X_OK = emscripten.X_OK; | ||
| 45 | pub const addrinfo = emscripten.addrinfo; | ||
| 46 | pub const blkcnt_t = emscripten.blkcnt_t; | ||
| 47 | pub const blksize_t = emscripten.blksize_t; | ||
| 48 | pub const clock_t = emscripten.clock_t; | ||
| 49 | pub const cpu_set_t = emscripten.cpu_set_t; | ||
| 50 | pub const dev_t = emscripten.dev_t; | ||
| 51 | pub const dl_phdr_info = emscripten.dl_phdr_info; | ||
| 52 | pub const empty_sigset = emscripten.empty_sigset; | ||
| 53 | pub const fd_t = emscripten.fd_t; | ||
| 54 | pub const gid_t = emscripten.gid_t; | ||
| 55 | pub const ifreq = emscripten.ifreq; | ||
| 56 | pub const ino_t = emscripten.ino_t; | ||
| 57 | pub const mcontext_t = emscripten.mcontext_t; | ||
| 58 | pub const mode_t = emscripten.mode_t; | ||
| 59 | pub const msghdr = emscripten.msghdr; | ||
| 60 | pub const msghdr_const = emscripten.msghdr_const; | ||
| 61 | pub const nfds_t = emscripten.nfds_t; | ||
| 62 | pub const nlink_t = emscripten.nlink_t; | ||
| 63 | pub const off_t = emscripten.off_t; | ||
| 64 | pub const pid_t = emscripten.pid_t; | ||
| 65 | pub const pollfd = emscripten.pollfd; | ||
| 66 | pub const rlim_t = emscripten.rlim_t; | ||
| 67 | pub const rlimit = emscripten.rlimit; | ||
| 68 | pub const rlimit_resource = emscripten.rlimit_resource; | ||
| 69 | pub const rusage = emscripten.rusage; | ||
| 70 | pub const siginfo_t = emscripten.siginfo_t; | ||
| 71 | pub const sigset_t = emscripten.sigset_t; | ||
| 72 | pub const sockaddr = emscripten.sockaddr; | ||
| 73 | pub const socklen_t = emscripten.socklen_t; | ||
| 74 | pub const stack_t = emscripten.stack_t; | ||
| 75 | pub const time_t = emscripten.time_t; | ||
| 76 | pub const timespec = emscripten.timespec; | ||
| 77 | pub const timeval = emscripten.timeval; | ||
| 78 | pub const timezone = emscripten.timezone; | ||
| 79 | pub const ucontext_t = emscripten.ucontext_t; | ||
| 80 | pub const uid_t = emscripten.uid_t; | ||
| 81 | pub const utsname = emscripten.utsname; | ||
| 82 | |||
| 83 | pub const _errno = struct { | ||
| 84 | extern "c" fn __errno_location() *c_int; | ||
| 85 | }.__errno_location; | ||
| 86 | |||
| 87 | pub const Stat = emscripten.Stat; | ||
| 88 | |||
| 89 | pub const AI = struct { | ||
| 90 | pub const PASSIVE = 0x01; | ||
| 91 | pub const CANONNAME = 0x02; | ||
| 92 | pub const NUMERICHOST = 0x04; | ||
| 93 | pub const V4MAPPED = 0x08; | ||
| 94 | pub const ALL = 0x10; | ||
| 95 | pub const ADDRCONFIG = 0x20; | ||
| 96 | pub const NUMERICSERV = 0x400; | ||
| 97 | }; | ||
| 98 | |||
| 99 | pub const NI = struct { | ||
| 100 | pub const NUMERICHOST = 0x01; | ||
| 101 | pub const NUMERICSERV = 0x02; | ||
| 102 | pub const NOFQDN = 0x04; | ||
| 103 | pub const NAMEREQD = 0x08; | ||
| 104 | pub const DGRAM = 0x10; | ||
| 105 | pub const NUMERICSCOPE = 0x100; | ||
| 106 | pub const MAXHOST = 255; | ||
| 107 | pub const MAXSERV = 32; | ||
| 108 | }; | ||
| 109 | |||
| 110 | pub const EAI = enum(c_int) { | ||
| 111 | BADFLAGS = -1, | ||
| 112 | NONAME = -2, | ||
| 113 | AGAIN = -3, | ||
| 114 | FAIL = -4, | ||
| 115 | FAMILY = -6, | ||
| 116 | SOCKTYPE = -7, | ||
| 117 | SERVICE = -8, | ||
| 118 | MEMORY = -10, | ||
| 119 | SYSTEM = -11, | ||
| 120 | OVERFLOW = -12, | ||
| 121 | |||
| 122 | NODATA = -5, | ||
| 123 | ADDRFAMILY = -9, | ||
| 124 | INPROGRESS = -100, | ||
| 125 | CANCELED = -101, | ||
| 126 | NOTCANCELED = -102, | ||
| 127 | ALLDONE = -103, | ||
| 128 | INTR = -104, | ||
| 129 | IDN_ENCODE = -105, | ||
| 130 | |||
| 131 | _, | ||
| 132 | }; | ||
| 133 | |||
| 134 | pub const fopen64 = std.c.fopen; | ||
| 135 | pub const fstat64 = std.c.fstat; | ||
| 136 | pub const fstatat64 = std.c.fstatat; | ||
| 137 | pub const ftruncate64 = std.c.ftruncate; | ||
| 138 | pub const getrlimit64 = std.c.getrlimit; | ||
| 139 | pub const lseek64 = std.c.lseek; | ||
| 140 | pub const mmap64 = std.c.mmap; | ||
| 141 | pub const open64 = std.c.open; | ||
| 142 | pub const openat64 = std.c.openat; | ||
| 143 | pub const pread64 = std.c.pread; | ||
| 144 | pub const preadv64 = std.c.preadv; | ||
| 145 | pub const pwrite64 = std.c.pwrite; | ||
| 146 | pub const pwritev64 = std.c.pwritev; | ||
| 147 | pub const setrlimit64 = std.c.setrlimit; | ||
| 148 | |||
| 149 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 150 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int; | ||
| 151 | pub extern "c" fn getentropy(buffer: [*]u8, size: usize) c_int; | ||
| 152 | |||
| 153 | pub const pthread_attr_t = extern struct { | ||
| 154 | __size: [56]u8, | ||
| 155 | __align: c_long, | ||
| 156 | }; | ||
| 157 | |||
| 158 | pub const pthread_key_t = c_uint; | ||
| 159 | pub const sem_t = extern struct { | ||
| 160 | __size: [__SIZEOF_SEM_T]u8 align(@alignOf(usize)), | ||
| 161 | }; | ||
| 162 | |||
| 163 | const __SIZEOF_SEM_T = 4 * @sizeOf(usize); | ||
| 164 | |||
| 165 | pub const RTLD = struct { | ||
| 166 | pub const LAZY = 1; | ||
| 167 | pub const NOW = 2; | ||
| 168 | pub const NOLOAD = 4; | ||
| 169 | pub const NODELETE = 4096; | ||
| 170 | pub const GLOBAL = 256; | ||
| 171 | pub const LOCAL = 0; | ||
| 172 | }; | ||
| 173 | |||
| 174 | pub const dirent = extern struct { | ||
| 175 | ino: c_uint, | ||
| 176 | off: c_uint, | ||
| 177 | reclen: c_ushort, | ||
| 178 | type: u8, | ||
| 179 | name: [256]u8, | ||
| 180 | }; | ||
lib/std/c/freebsd.zig+35-1516| ... | @@ -1,36 +1,33 @@ | ... | @@ -1,36 +1,33 @@ |
| 1 | const builtin = @import("builtin"); | ||
| 1 | const std = @import("../std.zig"); | 2 | const std = @import("../std.zig"); |
| 2 | const assert = std.debug.assert; | 3 | const assert = std.debug.assert; |
| 3 | const builtin = @import("builtin"); | ||
| 4 | const maxInt = std.math.maxInt; | ||
| 5 | const iovec = std.posix.iovec; | ||
| 6 | const iovec_const = std.posix.iovec_const; | ||
| 7 | |||
| 8 | extern "c" fn __error() *c_int; | ||
| 9 | pub const _errno = __error; | ||
| 10 | |||
| 11 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) isize; | ||
| 12 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 13 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | ||
| 14 | 4 | ||
| 15 | pub extern "c" fn pthread_getthreadid_np() c_int; | 5 | const PATH_MAX = std.c.PATH_MAX; |
| 16 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; | 6 | const blkcnt_t = std.c.blkcnt_t; |
| 17 | pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void; | 7 | const blksize_t = std.c.blksize_t; |
| 18 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int; | 8 | const dev_t = std.c.dev_t; |
| 19 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | 9 | const fd_t = std.c.fd_t; |
| 20 | 10 | const gid_t = std.c.gid_t; | |
| 21 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | 11 | const ino_t = std.c.ino_t; |
| 22 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; | 12 | const iovec_const = std.posix.iovec_const; |
| 13 | const mode_t = std.c.mode_t; | ||
| 14 | const nlink_t = std.c.nlink_t; | ||
| 15 | const off_t = std.c.off_t; | ||
| 16 | const pid_t = std.c.pid_t; | ||
| 17 | const sockaddr = std.c.sockaddr; | ||
| 18 | const time_t = std.c.time_t; | ||
| 19 | const timespec = std.c.timespec; | ||
| 20 | const uid_t = std.c.uid_t; | ||
| 21 | const sf_hdtr = std.c.sf_hdtr; | ||
| 22 | const clockid_t = std.c.clockid_t; | ||
| 23 | 23 | ||
| 24 | pub extern "c" fn getpid() pid_t; | 24 | comptime { |
| 25 | assert(builtin.os.tag == .freebsd or builtin.os.tag == .kfreebsd); // Prevent access of std.c symbols on wrong OS. | ||
| 26 | } | ||
| 25 | 27 | ||
| 26 | pub extern "c" fn kinfo_getfile(pid: pid_t, cntp: *c_int) ?[*]kinfo_file; | 28 | pub extern "c" fn kinfo_getfile(pid: pid_t, cntp: *c_int) ?[*]kinfo_file; |
| 29 | pub extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize; | ||
| 27 | 30 | ||
| 28 | pub const sf_hdtr = extern struct { | ||
| 29 | headers: [*]const iovec_const, | ||
| 30 | hdr_cnt: c_int, | ||
| 31 | trailers: [*]const iovec_const, | ||
| 32 | trl_cnt: c_int, | ||
| 33 | }; | ||
| 34 | pub extern "c" fn sendfile( | 31 | pub extern "c" fn sendfile( |
| 35 | in_fd: fd_t, | 32 | in_fd: fd_t, |
| 36 | out_fd: fd_t, | 33 | out_fd: fd_t, |
| ... | @@ -41,23 +38,6 @@ pub extern "c" fn sendfile( | ... | @@ -41,23 +38,6 @@ pub extern "c" fn sendfile( |
| 41 | flags: u32, | 38 | flags: u32, |
| 42 | ) c_int; | 39 | ) c_int; |
| 43 | 40 | ||
| 44 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 45 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 46 | |||
| 47 | pub const pthread_attr_t = extern struct { | ||
| 48 | inner: ?*anyopaque = null, | ||
| 49 | }; | ||
| 50 | |||
| 51 | pub const sem_t = extern struct { | ||
| 52 | _magic: u32, | ||
| 53 | _kern: extern struct { | ||
| 54 | _count: u32, | ||
| 55 | _flags: u32, | ||
| 56 | }, | ||
| 57 | _padding: u32, | ||
| 58 | }; | ||
| 59 | |||
| 60 | // https://github.com/freebsd/freebsd-src/blob/main/sys/sys/umtx.h | ||
| 61 | pub const UMTX_OP = enum(c_int) { | 41 | pub const UMTX_OP = enum(c_int) { |
| 62 | LOCK = 0, | 42 | LOCK = 0, |
| 63 | UNLOCK = 1, | 43 | UNLOCK = 1, |
| ... | @@ -90,213 +70,14 @@ pub const UMTX_OP = enum(c_int) { | ... | @@ -90,213 +70,14 @@ pub const UMTX_OP = enum(c_int) { |
| 90 | 70 | ||
| 91 | pub const UMTX_ABSTIME = 0x01; | 71 | pub const UMTX_ABSTIME = 0x01; |
| 92 | pub const _umtx_time = extern struct { | 72 | pub const _umtx_time = extern struct { |
| 93 | _timeout: timespec, | 73 | timeout: timespec, |
| 94 | _flags: u32, | 74 | flags: u32, |
| 95 | _clockid: u32, | 75 | clockid: clockid_t, |
| 96 | }; | 76 | }; |
| 97 | 77 | ||
| 98 | pub extern "c" fn _umtx_op(obj: usize, op: c_int, val: c_ulong, uaddr: usize, uaddr2: usize) c_int; | 78 | pub extern "c" fn _umtx_op(obj: usize, op: c_int, val: c_ulong, uaddr: usize, uaddr2: usize) c_int; |
| 99 | 79 | ||
| 100 | pub const EAI = enum(c_int) { | ||
| 101 | /// address family for hostname not supported | ||
| 102 | ADDRFAMILY = 1, | ||
| 103 | |||
| 104 | /// name could not be resolved at this time | ||
| 105 | AGAIN = 2, | ||
| 106 | |||
| 107 | /// flags parameter had an invalid value | ||
| 108 | BADFLAGS = 3, | ||
| 109 | |||
| 110 | /// non-recoverable failure in name resolution | ||
| 111 | FAIL = 4, | ||
| 112 | |||
| 113 | /// address family not recognized | ||
| 114 | FAMILY = 5, | ||
| 115 | |||
| 116 | /// memory allocation failure | ||
| 117 | MEMORY = 6, | ||
| 118 | |||
| 119 | /// no address associated with hostname | ||
| 120 | NODATA = 7, | ||
| 121 | |||
| 122 | /// name does not resolve | ||
| 123 | NONAME = 8, | ||
| 124 | |||
| 125 | /// service not recognized for socket type | ||
| 126 | SERVICE = 9, | ||
| 127 | |||
| 128 | /// intended socket type was not recognized | ||
| 129 | SOCKTYPE = 10, | ||
| 130 | |||
| 131 | /// system error returned in errno | ||
| 132 | SYSTEM = 11, | ||
| 133 | |||
| 134 | /// invalid value for hints | ||
| 135 | BADHINTS = 12, | ||
| 136 | |||
| 137 | /// resolved protocol is unknown | ||
| 138 | PROTOCOL = 13, | ||
| 139 | |||
| 140 | /// argument buffer overflow | ||
| 141 | OVERFLOW = 14, | ||
| 142 | |||
| 143 | _, | ||
| 144 | }; | ||
| 145 | |||
| 146 | pub const EAI_MAX = 15; | ||
| 147 | |||
| 148 | pub const IFNAMESIZE = 16; | ||
| 149 | |||
| 150 | pub const AI = struct { | ||
| 151 | /// get address to use bind() | ||
| 152 | pub const PASSIVE = 0x00000001; | ||
| 153 | /// fill ai_canonname | ||
| 154 | pub const CANONNAME = 0x00000002; | ||
| 155 | /// prevent host name resolution | ||
| 156 | pub const NUMERICHOST = 0x00000004; | ||
| 157 | /// prevent service name resolution | ||
| 158 | pub const NUMERICSERV = 0x00000008; | ||
| 159 | /// valid flags for addrinfo (not a standard def, apps should not use it) | ||
| 160 | pub const MASK = (PASSIVE | CANONNAME | NUMERICHOST | NUMERICSERV | ADDRCONFIG | ALL | V4MAPPED); | ||
| 161 | /// IPv6 and IPv4-mapped (with V4MAPPED) | ||
| 162 | pub const ALL = 0x00000100; | ||
| 163 | /// accept IPv4-mapped if kernel supports | ||
| 164 | pub const V4MAPPED_CFG = 0x00000200; | ||
| 165 | /// only if any address is assigned | ||
| 166 | pub const ADDRCONFIG = 0x00000400; | ||
| 167 | /// accept IPv4-mapped IPv6 address | ||
| 168 | pub const V4MAPPED = 0x00000800; | ||
| 169 | /// special recommended flags for getipnodebyname | ||
| 170 | pub const DEFAULT = (V4MAPPED_CFG | ADDRCONFIG); | ||
| 171 | }; | ||
| 172 | |||
| 173 | pub const blksize_t = i32; | ||
| 174 | pub const blkcnt_t = i64; | ||
| 175 | pub const clockid_t = i32; | ||
| 176 | pub const fflags_t = u32; | 80 | pub const fflags_t = u32; |
| 177 | pub const fsblkcnt_t = u64; | ||
| 178 | pub const fsfilcnt_t = u64; | ||
| 179 | pub const nlink_t = u64; | ||
| 180 | pub const fd_t = i32; | ||
| 181 | pub const pid_t = i32; | ||
| 182 | pub const uid_t = u32; | ||
| 183 | pub const gid_t = u32; | ||
| 184 | pub const mode_t = u16; | ||
| 185 | pub const off_t = i64; | ||
| 186 | pub const ino_t = u64; | ||
| 187 | pub const dev_t = u64; | ||
| 188 | pub const time_t = i64; | ||
| 189 | // The signedness is not constant across different architectures. | ||
| 190 | pub const clock_t = isize; | ||
| 191 | |||
| 192 | pub const socklen_t = u32; | ||
| 193 | pub const suseconds_t = c_long; | ||
| 194 | |||
| 195 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 196 | pub const Kevent = extern struct { | ||
| 197 | /// Identifier for this event. | ||
| 198 | ident: usize, | ||
| 199 | /// Filter for event. | ||
| 200 | filter: i16, | ||
| 201 | /// Action flags for kqueue. | ||
| 202 | flags: u16, | ||
| 203 | /// Filter flag value. | ||
| 204 | fflags: u32, | ||
| 205 | /// Filter data value. | ||
| 206 | data: i64, | ||
| 207 | /// Opaque user data identifier. | ||
| 208 | udata: usize, | ||
| 209 | /// Future extensions. | ||
| 210 | _ext: [4]u64 = [_]u64{0} ** 4, | ||
| 211 | }; | ||
| 212 | |||
| 213 | // Modes and flags for dlopen() | ||
| 214 | // include/dlfcn.h | ||
| 215 | |||
| 216 | pub const RTLD = struct { | ||
| 217 | /// Bind function calls lazily. | ||
| 218 | pub const LAZY = 1; | ||
| 219 | /// Bind function calls immediately. | ||
| 220 | pub const NOW = 2; | ||
| 221 | pub const MODEMASK = 0x3; | ||
| 222 | /// Make symbols globally available. | ||
| 223 | pub const GLOBAL = 0x100; | ||
| 224 | /// Opposite of GLOBAL, and the default. | ||
| 225 | pub const LOCAL = 0; | ||
| 226 | /// Trace loaded objects and exit. | ||
| 227 | pub const TRACE = 0x200; | ||
| 228 | /// Do not remove members. | ||
| 229 | pub const NODELETE = 0x01000; | ||
| 230 | /// Do not load if not already loaded. | ||
| 231 | pub const NOLOAD = 0x02000; | ||
| 232 | }; | ||
| 233 | |||
| 234 | pub const dl_phdr_info = extern struct { | ||
| 235 | /// Module relocation base. | ||
| 236 | dlpi_addr: if (builtin.target.ptrBitWidth() == 32) std.elf.Elf32_Addr else std.elf.Elf64_Addr, | ||
| 237 | /// Module name. | ||
| 238 | dlpi_name: ?[*:0]const u8, | ||
| 239 | /// Pointer to module's phdr. | ||
| 240 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 241 | /// Number of entries in phdr. | ||
| 242 | dlpi_phnum: u16, | ||
| 243 | /// Total number of loads. | ||
| 244 | dlpi_adds: u64, | ||
| 245 | /// Total number of unloads. | ||
| 246 | dlpi_subs: u64, | ||
| 247 | dlpi_tls_modid: usize, | ||
| 248 | dlpi_tls_data: ?*anyopaque, | ||
| 249 | }; | ||
| 250 | |||
| 251 | pub const Flock = extern struct { | ||
| 252 | /// Starting offset. | ||
| 253 | start: off_t, | ||
| 254 | /// Number of consecutive bytes to be locked. | ||
| 255 | /// A value of 0 means to the end of the file. | ||
| 256 | len: off_t, | ||
| 257 | /// Lock owner. | ||
| 258 | pid: pid_t, | ||
| 259 | /// Lock type. | ||
| 260 | type: i16, | ||
| 261 | /// Type of the start member. | ||
| 262 | whence: i16, | ||
| 263 | /// Remote system id or zero for local. | ||
| 264 | sysid: i32, | ||
| 265 | }; | ||
| 266 | |||
| 267 | pub const msghdr = extern struct { | ||
| 268 | /// Optional address. | ||
| 269 | msg_name: ?*sockaddr, | ||
| 270 | /// Size of address. | ||
| 271 | msg_namelen: socklen_t, | ||
| 272 | /// Scatter/gather array. | ||
| 273 | msg_iov: [*]iovec, | ||
| 274 | /// Number of elements in msg_iov. | ||
| 275 | msg_iovlen: i32, | ||
| 276 | /// Ancillary data. | ||
| 277 | msg_control: ?*anyopaque, | ||
| 278 | /// Ancillary data buffer length. | ||
| 279 | msg_controllen: socklen_t, | ||
| 280 | /// Flags on received message. | ||
| 281 | msg_flags: i32, | ||
| 282 | }; | ||
| 283 | |||
| 284 | pub const msghdr_const = extern struct { | ||
| 285 | /// Optional address. | ||
| 286 | msg_name: ?*const sockaddr, | ||
| 287 | /// Size of address. | ||
| 288 | msg_namelen: socklen_t, | ||
| 289 | /// Scatter/gather array. | ||
| 290 | msg_iov: [*]iovec_const, | ||
| 291 | /// Number of elements in msg_iov. | ||
| 292 | msg_iovlen: i32, | ||
| 293 | /// Ancillary data. | ||
| 294 | msg_control: ?*anyopaque, | ||
| 295 | /// Ancillary data buffer length. | ||
| 296 | msg_controllen: socklen_t, | ||
| 297 | /// Flags on received message. | ||
| 298 | msg_flags: i32, | ||
| 299 | }; | ||
| 300 | 81 | ||
| 301 | pub const Stat = extern struct { | 82 | pub const Stat = extern struct { |
| 302 | /// The inode's device. | 83 | /// The inode's device. |
| ... | @@ -352,81 +133,8 @@ pub const Stat = extern struct { | ... | @@ -352,81 +133,8 @@ pub const Stat = extern struct { |
| 352 | } | 133 | } |
| 353 | }; | 134 | }; |
| 354 | 135 | ||
| 355 | pub const timespec = extern struct { | 136 | pub const fsblkcnt_t = u64; |
| 356 | tv_sec: isize, | 137 | pub const fsfilcnt_t = u64; |
| 357 | tv_nsec: isize, | ||
| 358 | }; | ||
| 359 | |||
| 360 | pub const timeval = extern struct { | ||
| 361 | /// seconds | ||
| 362 | tv_sec: time_t, | ||
| 363 | /// microseconds | ||
| 364 | tv_usec: suseconds_t, | ||
| 365 | }; | ||
| 366 | |||
| 367 | pub const dirent = extern struct { | ||
| 368 | /// File number of entry. | ||
| 369 | fileno: ino_t, | ||
| 370 | /// Directory offset of entry. | ||
| 371 | off: off_t, | ||
| 372 | /// Length of this record. | ||
| 373 | reclen: u16, | ||
| 374 | /// File type, one of DT_. | ||
| 375 | type: u8, | ||
| 376 | pad0: u8 = 0, | ||
| 377 | /// Length of the name member. | ||
| 378 | namlen: u16, | ||
| 379 | pad1: u16 = 0, | ||
| 380 | /// Name of entry. | ||
| 381 | name: [255:0]u8, | ||
| 382 | }; | ||
| 383 | |||
| 384 | pub const in_port_t = u16; | ||
| 385 | pub const sa_family_t = u8; | ||
| 386 | |||
| 387 | pub const sockaddr = extern struct { | ||
| 388 | /// total length | ||
| 389 | len: u8, | ||
| 390 | /// address family | ||
| 391 | family: sa_family_t, | ||
| 392 | /// actually longer; address value | ||
| 393 | data: [14]u8, | ||
| 394 | |||
| 395 | pub const SS_MAXSIZE = 128; | ||
| 396 | pub const storage = extern struct { | ||
| 397 | len: u8 align(8), | ||
| 398 | family: sa_family_t, | ||
| 399 | padding: [126]u8 = undefined, | ||
| 400 | |||
| 401 | comptime { | ||
| 402 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 403 | assert(@alignOf(storage) == 8); | ||
| 404 | } | ||
| 405 | }; | ||
| 406 | |||
| 407 | pub const in = extern struct { | ||
| 408 | len: u8 = @sizeOf(in), | ||
| 409 | family: sa_family_t = AF.INET, | ||
| 410 | port: in_port_t, | ||
| 411 | addr: u32, | ||
| 412 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 413 | }; | ||
| 414 | |||
| 415 | pub const in6 = extern struct { | ||
| 416 | len: u8 = @sizeOf(in6), | ||
| 417 | family: sa_family_t = AF.INET6, | ||
| 418 | port: in_port_t, | ||
| 419 | flowinfo: u32, | ||
| 420 | addr: [16]u8, | ||
| 421 | scope_id: u32, | ||
| 422 | }; | ||
| 423 | |||
| 424 | pub const un = extern struct { | ||
| 425 | len: u8 = @sizeOf(un), | ||
| 426 | family: sa_family_t = AF.UNIX, | ||
| 427 | path: [104]u8, | ||
| 428 | }; | ||
| 429 | }; | ||
| 430 | 138 | ||
| 431 | pub const CAP_RIGHTS_VERSION = 0; | 139 | pub const CAP_RIGHTS_VERSION = 0; |
| 432 | 140 | ||
| ... | @@ -540,788 +248,18 @@ pub const kinfo_file = extern struct { | ... | @@ -540,788 +248,18 @@ pub const kinfo_file = extern struct { |
| 540 | _cap_spare: u64, | 248 | _cap_spare: u64, |
| 541 | /// Path to file, if any. | 249 | /// Path to file, if any. |
| 542 | path: [PATH_MAX - 1:0]u8, | 250 | path: [PATH_MAX - 1:0]u8, |
| 543 | }; | ||
| 544 | |||
| 545 | pub const KINFO_FILE_SIZE = 1392; | ||
| 546 | 251 | ||
| 547 | comptime { | 252 | comptime { |
| 548 | std.debug.assert(@sizeOf(kinfo_file) == KINFO_FILE_SIZE); | 253 | assert(@sizeOf(@This()) == KINFO_FILE_SIZE); |
| 549 | std.debug.assert(@alignOf(kinfo_file) == @sizeOf(u64)); | 254 | assert(@alignOf(@This()) == @sizeOf(u64)); |
| 550 | } | ||
| 551 | |||
| 552 | pub const CTL = struct { | ||
| 553 | pub const KERN = 1; | ||
| 554 | pub const DEBUG = 5; | ||
| 555 | }; | ||
| 556 | |||
| 557 | pub const KERN = struct { | ||
| 558 | pub const PROC = 14; // struct: process entries | ||
| 559 | pub const PROC_PATHNAME = 12; // path to executable | ||
| 560 | pub const PROC_FILEDESC = 33; // file descriptors for process | ||
| 561 | pub const IOV_MAX = 35; | ||
| 562 | }; | ||
| 563 | |||
| 564 | pub const PATH_MAX = 1024; | ||
| 565 | pub const IOV_MAX = KERN.IOV_MAX; | ||
| 566 | |||
| 567 | pub const STDIN_FILENO = 0; | ||
| 568 | pub const STDOUT_FILENO = 1; | ||
| 569 | pub const STDERR_FILENO = 2; | ||
| 570 | |||
| 571 | pub const PROT = struct { | ||
| 572 | pub const NONE = 0; | ||
| 573 | pub const READ = 1; | ||
| 574 | pub const WRITE = 2; | ||
| 575 | pub const EXEC = 4; | ||
| 576 | }; | ||
| 577 | |||
| 578 | pub const CLOCK = struct { | ||
| 579 | pub const REALTIME = 0; | ||
| 580 | pub const VIRTUAL = 1; | ||
| 581 | pub const PROF = 2; | ||
| 582 | pub const MONOTONIC = 4; | ||
| 583 | pub const UPTIME = 5; | ||
| 584 | pub const UPTIME_PRECISE = 7; | ||
| 585 | pub const UPTIME_FAST = 8; | ||
| 586 | pub const REALTIME_PRECISE = 9; | ||
| 587 | pub const REALTIME_FAST = 10; | ||
| 588 | pub const MONOTONIC_PRECISE = 11; | ||
| 589 | pub const MONOTONIC_FAST = 12; | ||
| 590 | pub const SECOND = 13; | ||
| 591 | pub const THREAD_CPUTIME_ID = 14; | ||
| 592 | pub const PROCESS_CPUTIME_ID = 15; | ||
| 593 | }; | ||
| 594 | |||
| 595 | pub const MADV = struct { | ||
| 596 | pub const NORMAL = 0; | ||
| 597 | pub const RANDOM = 1; | ||
| 598 | pub const SEQUENTIAL = 2; | ||
| 599 | pub const WILLNEED = 3; | ||
| 600 | pub const DONTNEED = 4; | ||
| 601 | pub const FREE = 5; | ||
| 602 | pub const NOSYNC = 6; | ||
| 603 | pub const AUTOSYNC = 7; | ||
| 604 | pub const NOCORE = 8; | ||
| 605 | pub const CORE = 9; | ||
| 606 | pub const PROTECT = 10; | ||
| 607 | }; | ||
| 608 | |||
| 609 | pub const MSF = struct { | ||
| 610 | pub const ASYNC = 1; | ||
| 611 | pub const INVALIDATE = 2; | ||
| 612 | pub const SYNC = 4; | ||
| 613 | }; | ||
| 614 | |||
| 615 | pub const W = struct { | ||
| 616 | pub const NOHANG = 1; | ||
| 617 | pub const UNTRACED = 2; | ||
| 618 | pub const STOPPED = UNTRACED; | ||
| 619 | pub const CONTINUED = 4; | ||
| 620 | pub const NOWAIT = 8; | ||
| 621 | pub const EXITED = 16; | ||
| 622 | pub const TRAPPED = 32; | ||
| 623 | |||
| 624 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 625 | return @as(u8, @intCast((s & 0xff00) >> 8)); | ||
| 626 | } | ||
| 627 | pub fn TERMSIG(s: u32) u32 { | ||
| 628 | return s & 0x7f; | ||
| 629 | } | ||
| 630 | pub fn STOPSIG(s: u32) u32 { | ||
| 631 | return EXITSTATUS(s); | ||
| 632 | } | ||
| 633 | pub fn IFEXITED(s: u32) bool { | ||
| 634 | return TERMSIG(s) == 0; | ||
| 635 | } | ||
| 636 | pub fn IFSTOPPED(s: u32) bool { | ||
| 637 | return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; | ||
| 638 | } | ||
| 639 | pub fn IFSIGNALED(s: u32) bool { | ||
| 640 | return (s & 0xffff) -% 1 < 0xff; | ||
| 641 | } | ||
| 642 | }; | ||
| 643 | |||
| 644 | pub const SA = struct { | ||
| 645 | pub const ONSTACK = 0x0001; | ||
| 646 | pub const RESTART = 0x0002; | ||
| 647 | pub const RESETHAND = 0x0004; | ||
| 648 | pub const NOCLDSTOP = 0x0008; | ||
| 649 | pub const NODEFER = 0x0010; | ||
| 650 | pub const NOCLDWAIT = 0x0020; | ||
| 651 | pub const SIGINFO = 0x0040; | ||
| 652 | }; | ||
| 653 | |||
| 654 | pub const SIG = struct { | ||
| 655 | pub const HUP = 1; | ||
| 656 | pub const INT = 2; | ||
| 657 | pub const QUIT = 3; | ||
| 658 | pub const ILL = 4; | ||
| 659 | pub const TRAP = 5; | ||
| 660 | pub const ABRT = 6; | ||
| 661 | pub const IOT = ABRT; | ||
| 662 | pub const EMT = 7; | ||
| 663 | pub const FPE = 8; | ||
| 664 | pub const KILL = 9; | ||
| 665 | pub const BUS = 10; | ||
| 666 | pub const SEGV = 11; | ||
| 667 | pub const SYS = 12; | ||
| 668 | pub const PIPE = 13; | ||
| 669 | pub const ALRM = 14; | ||
| 670 | pub const TERM = 15; | ||
| 671 | pub const URG = 16; | ||
| 672 | pub const STOP = 17; | ||
| 673 | pub const TSTP = 18; | ||
| 674 | pub const CONT = 19; | ||
| 675 | pub const CHLD = 20; | ||
| 676 | pub const TTIN = 21; | ||
| 677 | pub const TTOU = 22; | ||
| 678 | pub const IO = 23; | ||
| 679 | pub const XCPU = 24; | ||
| 680 | pub const XFSZ = 25; | ||
| 681 | pub const VTALRM = 26; | ||
| 682 | pub const PROF = 27; | ||
| 683 | pub const WINCH = 28; | ||
| 684 | pub const INFO = 29; | ||
| 685 | pub const USR1 = 30; | ||
| 686 | pub const USR2 = 31; | ||
| 687 | pub const THR = 32; | ||
| 688 | pub const LWP = THR; | ||
| 689 | pub const LIBRT = 33; | ||
| 690 | |||
| 691 | pub const RTMIN = 65; | ||
| 692 | pub const RTMAX = 126; | ||
| 693 | |||
| 694 | pub const BLOCK = 1; | ||
| 695 | pub const UNBLOCK = 2; | ||
| 696 | pub const SETMASK = 3; | ||
| 697 | |||
| 698 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 699 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 700 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 701 | |||
| 702 | pub const WORDS = 4; | ||
| 703 | pub const MAXSIG = 128; | ||
| 704 | |||
| 705 | pub inline fn IDX(sig: usize) usize { | ||
| 706 | return sig - 1; | ||
| 707 | } | ||
| 708 | pub inline fn WORD(sig: usize) usize { | ||
| 709 | return IDX(sig) >> 5; | ||
| 710 | } | ||
| 711 | pub inline fn BIT(sig: usize) usize { | ||
| 712 | return 1 << (IDX(sig) & 31); | ||
| 713 | } | ||
| 714 | pub inline fn VALID(sig: usize) usize { | ||
| 715 | return sig <= MAXSIG and sig > 0; | ||
| 716 | } | 255 | } |
| 717 | }; | 256 | }; |
| 718 | pub const sigval = extern union { | ||
| 719 | int: c_int, | ||
| 720 | ptr: ?*anyopaque, | ||
| 721 | }; | ||
| 722 | |||
| 723 | pub const sigset_t = extern struct { | ||
| 724 | __bits: [SIG.WORDS]u32, | ||
| 725 | }; | ||
| 726 | |||
| 727 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS }; | ||
| 728 | |||
| 729 | // access function | ||
| 730 | pub const F_OK = 0; // test for existence of file | ||
| 731 | pub const X_OK = 1; // test for execute or search permission | ||
| 732 | pub const W_OK = 2; // test for write permission | ||
| 733 | pub const R_OK = 4; // test for read permission | ||
| 734 | |||
| 735 | /// Command flags for fcntl(2). | ||
| 736 | pub const F = struct { | ||
| 737 | /// Duplicate file descriptor. | ||
| 738 | pub const DUPFD = 0; | ||
| 739 | /// Get file descriptor flags. | ||
| 740 | pub const GETFD = 1; | ||
| 741 | /// Set file descriptor flags. | ||
| 742 | pub const SETFD = 2; | ||
| 743 | /// Get file status flags. | ||
| 744 | pub const GETFL = 3; | ||
| 745 | /// Set file status flags. | ||
| 746 | pub const SETFL = 4; | ||
| 747 | |||
| 748 | /// Get SIGIO/SIGURG proc/pgrrp. | ||
| 749 | pub const GETOWN = 5; | ||
| 750 | /// Set SIGIO/SIGURG proc/pgrrp. | ||
| 751 | pub const SETOWN = 6; | ||
| 752 | |||
| 753 | /// Get record locking information. | ||
| 754 | pub const GETLK = 11; | ||
| 755 | /// Set record locking information. | ||
| 756 | pub const SETLK = 12; | ||
| 757 | /// Set record locking information and wait if blocked. | ||
| 758 | pub const SETLKW = 13; | ||
| 759 | |||
| 760 | /// Debugging support for remote locks. | ||
| 761 | pub const SETLK_REMOTE = 14; | ||
| 762 | /// Read ahead. | ||
| 763 | pub const READAHEAD = 15; | ||
| 764 | |||
| 765 | /// DUPFD with FD_CLOEXEC set. | ||
| 766 | pub const DUPFD_CLOEXEC = 17; | ||
| 767 | /// DUP2FD with FD_CLOEXEC set. | ||
| 768 | pub const DUP2FD_CLOEXEC = 18; | ||
| 769 | |||
| 770 | pub const ADD_SEALS = 19; | ||
| 771 | pub const GET_SEALS = 20; | ||
| 772 | /// Return `kinfo_file` for a file descriptor. | ||
| 773 | pub const KINFO = 22; | ||
| 774 | |||
| 775 | // Seals (ADD_SEALS, GET_SEALS) | ||
| 776 | /// Prevent adding sealings. | ||
| 777 | pub const SEAL_SEAL = 0x0001; | ||
| 778 | /// May not shrink | ||
| 779 | pub const SEAL_SHRINK = 0x0002; | ||
| 780 | /// May not grow. | ||
| 781 | pub const SEAL_GROW = 0x0004; | ||
| 782 | /// May not write. | ||
| 783 | pub const SEAL_WRITE = 0x0008; | ||
| 784 | |||
| 785 | // Record locking flags (GETLK, SETLK, SETLKW). | ||
| 786 | /// Shared or read lock. | ||
| 787 | pub const RDLCK = 1; | ||
| 788 | /// Unlock. | ||
| 789 | pub const UNLCK = 2; | ||
| 790 | /// Exclusive or write lock. | ||
| 791 | pub const WRLCK = 3; | ||
| 792 | /// Purge locks for a given system ID. | ||
| 793 | pub const UNLCKSYS = 4; | ||
| 794 | /// Cancel an async lock request. | ||
| 795 | pub const CANCEL = 5; | ||
| 796 | |||
| 797 | pub const SETOWN_EX = 15; | ||
| 798 | pub const GETOWN_EX = 16; | ||
| 799 | |||
| 800 | pub const GETOWNER_UIDS = 17; | ||
| 801 | }; | ||
| 802 | |||
| 803 | pub const LOCK = struct { | ||
| 804 | pub const SH = 1; | ||
| 805 | pub const EX = 2; | ||
| 806 | pub const UN = 8; | ||
| 807 | pub const NB = 4; | ||
| 808 | }; | ||
| 809 | |||
| 810 | pub const FD_CLOEXEC = 1; | ||
| 811 | |||
| 812 | pub const SEEK = struct { | ||
| 813 | pub const SET = 0; | ||
| 814 | pub const CUR = 1; | ||
| 815 | pub const END = 2; | ||
| 816 | }; | ||
| 817 | |||
| 818 | pub const SOCK = struct { | ||
| 819 | pub const STREAM = 1; | ||
| 820 | pub const DGRAM = 2; | ||
| 821 | pub const RAW = 3; | ||
| 822 | pub const RDM = 4; | ||
| 823 | pub const SEQPACKET = 5; | ||
| 824 | |||
| 825 | pub const CLOEXEC = 0x10000000; | ||
| 826 | pub const NONBLOCK = 0x20000000; | ||
| 827 | }; | ||
| 828 | |||
| 829 | pub const SO = struct { | ||
| 830 | pub const DEBUG = 0x00000001; | ||
| 831 | pub const ACCEPTCONN = 0x00000002; | ||
| 832 | pub const REUSEADDR = 0x00000004; | ||
| 833 | pub const KEEPALIVE = 0x00000008; | ||
| 834 | pub const DONTROUTE = 0x00000010; | ||
| 835 | pub const BROADCAST = 0x00000020; | ||
| 836 | pub const USELOOPBACK = 0x00000040; | ||
| 837 | pub const LINGER = 0x00000080; | ||
| 838 | pub const OOBINLINE = 0x00000100; | ||
| 839 | pub const REUSEPORT = 0x00000200; | ||
| 840 | pub const TIMESTAMP = 0x00000400; | ||
| 841 | pub const NOSIGPIPE = 0x00000800; | ||
| 842 | pub const ACCEPTFILTER = 0x00001000; | ||
| 843 | pub const BINTIME = 0x00002000; | ||
| 844 | pub const NO_OFFLOAD = 0x00004000; | ||
| 845 | pub const NO_DDP = 0x00008000; | ||
| 846 | pub const REUSEPORT_LB = 0x00010000; | ||
| 847 | |||
| 848 | pub const SNDBUF = 0x1001; | ||
| 849 | pub const RCVBUF = 0x1002; | ||
| 850 | pub const SNDLOWAT = 0x1003; | ||
| 851 | pub const RCVLOWAT = 0x1004; | ||
| 852 | pub const SNDTIMEO = 0x1005; | ||
| 853 | pub const RCVTIMEO = 0x1006; | ||
| 854 | pub const ERROR = 0x1007; | ||
| 855 | pub const TYPE = 0x1008; | ||
| 856 | pub const LABEL = 0x1009; | ||
| 857 | pub const PEERLABEL = 0x1010; | ||
| 858 | pub const LISTENQLIMIT = 0x1011; | ||
| 859 | pub const LISTENQLEN = 0x1012; | ||
| 860 | pub const LISTENINCQLEN = 0x1013; | ||
| 861 | pub const SETFIB = 0x1014; | ||
| 862 | pub const USER_COOKIE = 0x1015; | ||
| 863 | pub const PROTOCOL = 0x1016; | ||
| 864 | pub const PROTOTYPE = PROTOCOL; | ||
| 865 | pub const TS_CLOCK = 0x1017; | ||
| 866 | pub const MAX_PACING_RATE = 0x1018; | ||
| 867 | pub const DOMAIN = 0x1019; | ||
| 868 | }; | ||
| 869 | |||
| 870 | pub const SOL = struct { | ||
| 871 | pub const SOCKET = 0xffff; | ||
| 872 | }; | ||
| 873 | |||
| 874 | pub const PF = struct { | ||
| 875 | pub const UNSPEC = AF.UNSPEC; | ||
| 876 | pub const LOCAL = AF.LOCAL; | ||
| 877 | pub const UNIX = PF.LOCAL; | ||
| 878 | pub const INET = AF.INET; | ||
| 879 | pub const IMPLINK = AF.IMPLINK; | ||
| 880 | pub const PUP = AF.PUP; | ||
| 881 | pub const CHAOS = AF.CHAOS; | ||
| 882 | pub const NETBIOS = AF.NETBIOS; | ||
| 883 | pub const ISO = AF.ISO; | ||
| 884 | pub const OSI = AF.ISO; | ||
| 885 | pub const ECMA = AF.ECMA; | ||
| 886 | pub const DATAKIT = AF.DATAKIT; | ||
| 887 | pub const CCITT = AF.CCITT; | ||
| 888 | pub const DECnet = AF.DECnet; | ||
| 889 | pub const DLI = AF.DLI; | ||
| 890 | pub const LAT = AF.LAT; | ||
| 891 | pub const HYLINK = AF.HYLINK; | ||
| 892 | pub const APPLETALK = AF.APPLETALK; | ||
| 893 | pub const ROUTE = AF.ROUTE; | ||
| 894 | pub const LINK = AF.LINK; | ||
| 895 | pub const XTP = AF.pseudo_XTP; | ||
| 896 | pub const COIP = AF.COIP; | ||
| 897 | pub const CNT = AF.CNT; | ||
| 898 | pub const SIP = AF.SIP; | ||
| 899 | pub const IPX = AF.IPX; | ||
| 900 | pub const RTIP = AF.pseudo_RTIP; | ||
| 901 | pub const PIP = AF.pseudo_PIP; | ||
| 902 | pub const ISDN = AF.ISDN; | ||
| 903 | pub const KEY = AF.pseudo_KEY; | ||
| 904 | pub const INET6 = AF.pseudo_INET6; | ||
| 905 | pub const NATM = AF.NATM; | ||
| 906 | pub const ATM = AF.ATM; | ||
| 907 | pub const NETGRAPH = AF.NETGRAPH; | ||
| 908 | pub const SLOW = AF.SLOW; | ||
| 909 | pub const SCLUSTER = AF.SCLUSTER; | ||
| 910 | pub const ARP = AF.ARP; | ||
| 911 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 912 | pub const IEEE80211 = AF.IEEE80211; | ||
| 913 | pub const INET_SDP = AF.INET_SDP; | ||
| 914 | pub const INET6_SDP = AF.INET6_SDP; | ||
| 915 | pub const MAX = AF.MAX; | ||
| 916 | }; | ||
| 917 | |||
| 918 | pub const AF = struct { | ||
| 919 | pub const UNSPEC = 0; | ||
| 920 | pub const UNIX = 1; | ||
| 921 | pub const LOCAL = UNIX; | ||
| 922 | pub const FILE = LOCAL; | ||
| 923 | pub const INET = 2; | ||
| 924 | pub const IMPLINK = 3; | ||
| 925 | pub const PUP = 4; | ||
| 926 | pub const CHAOS = 5; | ||
| 927 | pub const NETBIOS = 6; | ||
| 928 | pub const ISO = 7; | ||
| 929 | pub const OSI = ISO; | ||
| 930 | pub const ECMA = 8; | ||
| 931 | pub const DATAKIT = 9; | ||
| 932 | pub const CCITT = 10; | ||
| 933 | pub const SNA = 11; | ||
| 934 | pub const DECnet = 12; | ||
| 935 | pub const DLI = 13; | ||
| 936 | pub const LAT = 14; | ||
| 937 | pub const HYLINK = 15; | ||
| 938 | pub const APPLETALK = 16; | ||
| 939 | pub const ROUTE = 17; | ||
| 940 | pub const LINK = 18; | ||
| 941 | pub const pseudo_XTP = 19; | ||
| 942 | pub const COIP = 20; | ||
| 943 | pub const CNT = 21; | ||
| 944 | pub const pseudo_RTIP = 22; | ||
| 945 | pub const IPX = 23; | ||
| 946 | pub const SIP = 24; | ||
| 947 | pub const pseudo_PIP = 25; | ||
| 948 | pub const ISDN = 26; | ||
| 949 | pub const E164 = ISDN; | ||
| 950 | pub const pseudo_KEY = 27; | ||
| 951 | pub const INET6 = 28; | ||
| 952 | pub const NATM = 29; | ||
| 953 | pub const ATM = 30; | ||
| 954 | pub const pseudo_HDRCMPLT = 31; | ||
| 955 | pub const NETGRAPH = 32; | ||
| 956 | pub const SLOW = 33; | ||
| 957 | pub const SCLUSTER = 34; | ||
| 958 | pub const ARP = 35; | ||
| 959 | pub const BLUETOOTH = 36; | ||
| 960 | pub const IEEE80211 = 37; | ||
| 961 | pub const INET_SDP = 40; | ||
| 962 | pub const INET6_SDP = 42; | ||
| 963 | pub const MAX = 42; | ||
| 964 | }; | ||
| 965 | |||
| 966 | pub const DT = struct { | ||
| 967 | pub const UNKNOWN = 0; | ||
| 968 | pub const FIFO = 1; | ||
| 969 | pub const CHR = 2; | ||
| 970 | pub const DIR = 4; | ||
| 971 | pub const BLK = 6; | ||
| 972 | pub const REG = 8; | ||
| 973 | pub const LNK = 10; | ||
| 974 | pub const SOCK = 12; | ||
| 975 | pub const WHT = 14; | ||
| 976 | }; | ||
| 977 | |||
| 978 | /// add event to kq (implies enable) | ||
| 979 | pub const EV_ADD = 0x0001; | ||
| 980 | 257 | ||
| 981 | /// delete event from kq | 258 | pub const KINFO_FILE_SIZE = 1392; |
| 982 | pub const EV_DELETE = 0x0002; | ||
| 983 | |||
| 984 | /// enable event | ||
| 985 | pub const EV_ENABLE = 0x0004; | ||
| 986 | |||
| 987 | /// disable event (not reported) | ||
| 988 | pub const EV_DISABLE = 0x0008; | ||
| 989 | |||
| 990 | /// only report one occurrence | ||
| 991 | pub const EV_ONESHOT = 0x0010; | ||
| 992 | |||
| 993 | /// clear event state after reporting | ||
| 994 | pub const EV_CLEAR = 0x0020; | ||
| 995 | |||
| 996 | /// error, event data contains errno | ||
| 997 | pub const EV_ERROR = 0x4000; | ||
| 998 | |||
| 999 | /// force immediate event output | ||
| 1000 | /// ... with or without EV_ERROR | ||
| 1001 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 1002 | /// on syscalls supporting flags | ||
| 1003 | pub const EV_RECEIPT = 0x0040; | ||
| 1004 | |||
| 1005 | /// disable event after reporting | ||
| 1006 | pub const EV_DISPATCH = 0x0080; | ||
| 1007 | |||
| 1008 | pub const EVFILT_READ = -1; | ||
| 1009 | pub const EVFILT_WRITE = -2; | ||
| 1010 | |||
| 1011 | /// attached to aio requests | ||
| 1012 | pub const EVFILT_AIO = -3; | ||
| 1013 | |||
| 1014 | /// attached to vnodes | ||
| 1015 | pub const EVFILT_VNODE = -4; | ||
| 1016 | |||
| 1017 | /// attached to struct proc | ||
| 1018 | pub const EVFILT_PROC = -5; | ||
| 1019 | |||
| 1020 | /// attached to struct proc | ||
| 1021 | pub const EVFILT_SIGNAL = -6; | ||
| 1022 | |||
| 1023 | /// timers | ||
| 1024 | pub const EVFILT_TIMER = -7; | ||
| 1025 | |||
| 1026 | /// Process descriptors | ||
| 1027 | pub const EVFILT_PROCDESC = -8; | ||
| 1028 | |||
| 1029 | /// Filesystem events | ||
| 1030 | pub const EVFILT_FS = -9; | ||
| 1031 | |||
| 1032 | pub const EVFILT_LIO = -10; | ||
| 1033 | |||
| 1034 | /// User events | ||
| 1035 | pub const EVFILT_USER = -11; | ||
| 1036 | |||
| 1037 | /// Sendfile events | ||
| 1038 | pub const EVFILT_SENDFILE = -12; | ||
| 1039 | |||
| 1040 | pub const EVFILT_EMPTY = -13; | ||
| 1041 | |||
| 1042 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 1043 | pub const NOTE_TRIGGER = 0x01000000; | ||
| 1044 | |||
| 1045 | /// ignore input fflags | ||
| 1046 | pub const NOTE_FFNOP = 0x00000000; | ||
| 1047 | |||
| 1048 | /// and fflags | ||
| 1049 | pub const NOTE_FFAND = 0x40000000; | ||
| 1050 | |||
| 1051 | /// or fflags | ||
| 1052 | pub const NOTE_FFOR = 0x80000000; | ||
| 1053 | |||
| 1054 | /// copy fflags | ||
| 1055 | pub const NOTE_FFCOPY = 0xc0000000; | ||
| 1056 | |||
| 1057 | /// mask for operations | ||
| 1058 | pub const NOTE_FFCTRLMASK = 0xc0000000; | ||
| 1059 | pub const NOTE_FFLAGSMASK = 0x00ffffff; | ||
| 1060 | |||
| 1061 | /// low water mark | ||
| 1062 | pub const NOTE_LOWAT = 0x00000001; | ||
| 1063 | |||
| 1064 | /// behave like poll() | ||
| 1065 | pub const NOTE_FILE_POLL = 0x00000002; | ||
| 1066 | |||
| 1067 | /// vnode was removed | ||
| 1068 | pub const NOTE_DELETE = 0x00000001; | ||
| 1069 | |||
| 1070 | /// data contents changed | ||
| 1071 | pub const NOTE_WRITE = 0x00000002; | ||
| 1072 | |||
| 1073 | /// size increased | ||
| 1074 | pub const NOTE_EXTEND = 0x00000004; | ||
| 1075 | |||
| 1076 | /// attributes changed | ||
| 1077 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 1078 | |||
| 1079 | /// link count changed | ||
| 1080 | pub const NOTE_LINK = 0x00000010; | ||
| 1081 | |||
| 1082 | /// vnode was renamed | ||
| 1083 | pub const NOTE_RENAME = 0x00000020; | ||
| 1084 | |||
| 1085 | /// vnode access was revoked | ||
| 1086 | pub const NOTE_REVOKE = 0x00000040; | ||
| 1087 | |||
| 1088 | /// vnode was opened | ||
| 1089 | pub const NOTE_OPEN = 0x00000080; | ||
| 1090 | |||
| 1091 | /// file closed, fd did not allow write | ||
| 1092 | pub const NOTE_CLOSE = 0x00000100; | ||
| 1093 | |||
| 1094 | /// file closed, fd did allow write | ||
| 1095 | pub const NOTE_CLOSE_WRITE = 0x00000200; | ||
| 1096 | |||
| 1097 | /// file was read | ||
| 1098 | pub const NOTE_READ = 0x00000400; | ||
| 1099 | |||
| 1100 | /// process exited | ||
| 1101 | pub const NOTE_EXIT = 0x80000000; | ||
| 1102 | |||
| 1103 | /// process forked | ||
| 1104 | pub const NOTE_FORK = 0x40000000; | ||
| 1105 | |||
| 1106 | /// process exec'd | ||
| 1107 | pub const NOTE_EXEC = 0x20000000; | ||
| 1108 | |||
| 1109 | /// mask for signal & exit status | ||
| 1110 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 1111 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); | ||
| 1112 | |||
| 1113 | /// data is seconds | ||
| 1114 | pub const NOTE_SECONDS = 0x00000001; | ||
| 1115 | |||
| 1116 | /// data is milliseconds | ||
| 1117 | pub const NOTE_MSECONDS = 0x00000002; | ||
| 1118 | |||
| 1119 | /// data is microseconds | ||
| 1120 | pub const NOTE_USECONDS = 0x00000004; | ||
| 1121 | |||
| 1122 | /// data is nanoseconds | ||
| 1123 | pub const NOTE_NSECONDS = 0x00000008; | ||
| 1124 | |||
| 1125 | /// timeout is absolute | ||
| 1126 | pub const NOTE_ABSTIME = 0x00000010; | ||
| 1127 | |||
| 1128 | pub const T = struct { | ||
| 1129 | pub const IOCEXCL = 0x2000740d; | ||
| 1130 | pub const IOCNXCL = 0x2000740e; | ||
| 1131 | pub const IOCSCTTY = 0x20007461; | ||
| 1132 | pub const IOCGPGRP = 0x40047477; | ||
| 1133 | pub const IOCSPGRP = 0x80047476; | ||
| 1134 | pub const IOCOUTQ = 0x40047473; | ||
| 1135 | pub const IOCSTI = 0x80017472; | ||
| 1136 | pub const IOCGWINSZ = 0x40087468; | ||
| 1137 | pub const IOCSWINSZ = 0x80087467; | ||
| 1138 | pub const IOCMGET = 0x4004746a; | ||
| 1139 | pub const IOCMBIS = 0x8004746c; | ||
| 1140 | pub const IOCMBIC = 0x8004746b; | ||
| 1141 | pub const IOCMSET = 0x8004746d; | ||
| 1142 | pub const FIONREAD = 0x4004667f; | ||
| 1143 | pub const IOCCONS = 0x80047462; | ||
| 1144 | pub const IOCPKT = 0x80047470; | ||
| 1145 | pub const FIONBIO = 0x8004667e; | ||
| 1146 | pub const IOCNOTTY = 0x20007471; | ||
| 1147 | pub const IOCSETD = 0x8004741b; | ||
| 1148 | pub const IOCGETD = 0x4004741a; | ||
| 1149 | pub const IOCSBRK = 0x2000747b; | ||
| 1150 | pub const IOCCBRK = 0x2000747a; | ||
| 1151 | pub const IOCGSID = 0x40047463; | ||
| 1152 | pub const IOCGPTN = 0x4004740f; | ||
| 1153 | pub const IOCSIG = 0x2004745f; | ||
| 1154 | }; | ||
| 1155 | |||
| 1156 | pub const TCSA = enum(c_uint) { | ||
| 1157 | NOW, | ||
| 1158 | DRAIN, | ||
| 1159 | FLUSH, | ||
| 1160 | _, | ||
| 1161 | }; | ||
| 1162 | |||
| 1163 | pub const winsize = extern struct { | ||
| 1164 | ws_row: u16, | ||
| 1165 | ws_col: u16, | ||
| 1166 | ws_xpixel: u16, | ||
| 1167 | ws_ypixel: u16, | ||
| 1168 | }; | ||
| 1169 | |||
| 1170 | const NSIG = 32; | ||
| 1171 | |||
| 1172 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 1173 | pub const Sigaction = extern struct { | ||
| 1174 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 1175 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 1176 | |||
| 1177 | /// signal handler | ||
| 1178 | handler: extern union { | ||
| 1179 | handler: ?handler_fn, | ||
| 1180 | sigaction: ?sigaction_fn, | ||
| 1181 | }, | ||
| 1182 | |||
| 1183 | /// see signal options | ||
| 1184 | flags: c_uint, | ||
| 1185 | |||
| 1186 | /// signal mask to apply | ||
| 1187 | mask: sigset_t, | ||
| 1188 | }; | ||
| 1189 | |||
| 1190 | pub const siginfo_t = extern struct { | ||
| 1191 | // Signal number. | ||
| 1192 | signo: c_int, | ||
| 1193 | // Errno association. | ||
| 1194 | errno: c_int, | ||
| 1195 | /// Signal code. | ||
| 1196 | /// | ||
| 1197 | /// Cause of signal, one of the SI_ macros or signal-specific values, i.e. | ||
| 1198 | /// one of the FPE_... values for SIGFPE. | ||
| 1199 | /// This value is equivalent to the second argument to an old-style FreeBSD | ||
| 1200 | /// signal handler. | ||
| 1201 | code: c_int, | ||
| 1202 | /// Sending process. | ||
| 1203 | pid: pid_t, | ||
| 1204 | /// Sender's ruid. | ||
| 1205 | uid: uid_t, | ||
| 1206 | /// Exit value. | ||
| 1207 | status: c_int, | ||
| 1208 | /// Faulting instruction. | ||
| 1209 | addr: *allowzero anyopaque, | ||
| 1210 | /// Signal value. | ||
| 1211 | value: sigval, | ||
| 1212 | reason: extern union { | ||
| 1213 | fault: extern struct { | ||
| 1214 | /// Machine specific trap code. | ||
| 1215 | trapno: c_int, | ||
| 1216 | }, | ||
| 1217 | timer: extern struct { | ||
| 1218 | timerid: c_int, | ||
| 1219 | overrun: c_int, | ||
| 1220 | }, | ||
| 1221 | mesgq: extern struct { | ||
| 1222 | mqd: c_int, | ||
| 1223 | }, | ||
| 1224 | poll: extern struct { | ||
| 1225 | /// Band event for SIGPOLL. UNUSED. | ||
| 1226 | band: c_long, | ||
| 1227 | }, | ||
| 1228 | spare: extern struct { | ||
| 1229 | spare1: c_long, | ||
| 1230 | spare2: [7]c_int, | ||
| 1231 | }, | ||
| 1232 | }, | ||
| 1233 | }; | ||
| 1234 | |||
| 1235 | pub const mcontext_t = switch (builtin.cpu.arch) { | ||
| 1236 | .x86_64 => extern struct { | ||
| 1237 | onstack: u64, | ||
| 1238 | rdi: u64, | ||
| 1239 | rsi: u64, | ||
| 1240 | rdx: u64, | ||
| 1241 | rcx: u64, | ||
| 1242 | r8: u64, | ||
| 1243 | r9: u64, | ||
| 1244 | rax: u64, | ||
| 1245 | rbx: u64, | ||
| 1246 | rbp: u64, | ||
| 1247 | r10: u64, | ||
| 1248 | r11: u64, | ||
| 1249 | r12: u64, | ||
| 1250 | r13: u64, | ||
| 1251 | r14: u64, | ||
| 1252 | r15: u64, | ||
| 1253 | trapno: u32, | ||
| 1254 | fs: u16, | ||
| 1255 | gs: u16, | ||
| 1256 | addr: u64, | ||
| 1257 | flags: u32, | ||
| 1258 | es: u16, | ||
| 1259 | ds: u16, | ||
| 1260 | err: u64, | ||
| 1261 | rip: u64, | ||
| 1262 | cs: u64, | ||
| 1263 | rflags: u64, | ||
| 1264 | rsp: u64, | ||
| 1265 | ss: u64, | ||
| 1266 | len: u64, | ||
| 1267 | fpformat: u64, | ||
| 1268 | ownedfp: u64, | ||
| 1269 | fpstate: [64]u64 align(16), | ||
| 1270 | fsbase: u64, | ||
| 1271 | gsbase: u64, | ||
| 1272 | xfpustate: u64, | ||
| 1273 | xfpustate_len: u64, | ||
| 1274 | spare: [4]u64, | ||
| 1275 | }, | ||
| 1276 | .aarch64 => extern struct { | ||
| 1277 | gpregs: extern struct { | ||
| 1278 | x: [30]u64, | ||
| 1279 | lr: u64, | ||
| 1280 | sp: u64, | ||
| 1281 | elr: u64, | ||
| 1282 | spsr: u32, | ||
| 1283 | _pad: u32, | ||
| 1284 | }, | ||
| 1285 | fpregs: extern struct { | ||
| 1286 | q: [32]u128, | ||
| 1287 | sr: u32, | ||
| 1288 | cr: u32, | ||
| 1289 | flags: u32, | ||
| 1290 | _pad: u32, | ||
| 1291 | }, | ||
| 1292 | flags: u32, | ||
| 1293 | _pad: u32, | ||
| 1294 | _spare: [8]u64, | ||
| 1295 | }, | ||
| 1296 | else => struct {}, | ||
| 1297 | }; | ||
| 1298 | |||
| 1299 | pub const REG = switch (builtin.cpu.arch) { | ||
| 1300 | .aarch64 => struct { | ||
| 1301 | pub const FP = 29; | ||
| 1302 | pub const SP = 31; | ||
| 1303 | pub const PC = 32; | ||
| 1304 | }, | ||
| 1305 | .arm => struct { | ||
| 1306 | pub const FP = 11; | ||
| 1307 | pub const SP = 13; | ||
| 1308 | pub const PC = 15; | ||
| 1309 | }, | ||
| 1310 | .x86_64 => struct { | ||
| 1311 | pub const RBP = 12; | ||
| 1312 | pub const RIP = 21; | ||
| 1313 | pub const RSP = 24; | ||
| 1314 | }, | ||
| 1315 | else => struct {}, | ||
| 1316 | }; | ||
| 1317 | 259 | ||
| 1318 | pub const ucontext_t = extern struct { | 260 | pub const MFD = struct { |
| 1319 | sigmask: sigset_t, | 261 | pub const CLOEXEC = 0x0001; |
| 1320 | mcontext: mcontext_t, | 262 | pub const ALLOW_SEALING = 0x0002; |
| 1321 | link: ?*ucontext_t, | ||
| 1322 | stack: stack_t, | ||
| 1323 | flags: c_int, | ||
| 1324 | __spare__: [4]c_int, | ||
| 1325 | }; | 263 | }; |
| 1326 | 264 | ||
| 1327 | pub const E = enum(u16) { | 265 | pub const E = enum(u16) { |
| ... | @@ -1453,422 +391,3 @@ pub const E = enum(u16) { | ... | @@ -1453,422 +391,3 @@ pub const E = enum(u16) { |
| 1453 | INTEGRITY = 97, // Integrity check failed | 391 | INTEGRITY = 97, // Integrity check failed |
| 1454 | _, | 392 | _, |
| 1455 | }; | 393 | }; |
| 1456 | |||
| 1457 | pub const MINSIGSTKSZ = switch (builtin.cpu.arch) { | ||
| 1458 | .x86, .x86_64 => 2048, | ||
| 1459 | .arm, .aarch64 => 4096, | ||
| 1460 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), | ||
| 1461 | }; | ||
| 1462 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 1463 | |||
| 1464 | pub const SS_ONSTACK = 1; | ||
| 1465 | pub const SS_DISABLE = 4; | ||
| 1466 | |||
| 1467 | pub const stack_t = extern struct { | ||
| 1468 | /// Signal stack base. | ||
| 1469 | sp: *anyopaque, | ||
| 1470 | /// Signal stack length. | ||
| 1471 | size: usize, | ||
| 1472 | /// SS_DISABLE and/or SS_ONSTACK. | ||
| 1473 | flags: i32, | ||
| 1474 | }; | ||
| 1475 | |||
| 1476 | pub const S = struct { | ||
| 1477 | pub const IFMT = 0o170000; | ||
| 1478 | |||
| 1479 | pub const IFIFO = 0o010000; | ||
| 1480 | pub const IFCHR = 0o020000; | ||
| 1481 | pub const IFDIR = 0o040000; | ||
| 1482 | pub const IFBLK = 0o060000; | ||
| 1483 | pub const IFREG = 0o100000; | ||
| 1484 | pub const IFLNK = 0o120000; | ||
| 1485 | pub const IFSOCK = 0o140000; | ||
| 1486 | pub const IFWHT = 0o160000; | ||
| 1487 | |||
| 1488 | pub const ISUID = 0o4000; | ||
| 1489 | pub const ISGID = 0o2000; | ||
| 1490 | pub const ISVTX = 0o1000; | ||
| 1491 | pub const IRWXU = 0o700; | ||
| 1492 | pub const IRUSR = 0o400; | ||
| 1493 | pub const IWUSR = 0o200; | ||
| 1494 | pub const IXUSR = 0o100; | ||
| 1495 | pub const IRWXG = 0o070; | ||
| 1496 | pub const IRGRP = 0o040; | ||
| 1497 | pub const IWGRP = 0o020; | ||
| 1498 | pub const IXGRP = 0o010; | ||
| 1499 | pub const IRWXO = 0o007; | ||
| 1500 | pub const IROTH = 0o004; | ||
| 1501 | pub const IWOTH = 0o002; | ||
| 1502 | pub const IXOTH = 0o001; | ||
| 1503 | |||
| 1504 | pub fn ISFIFO(m: u32) bool { | ||
| 1505 | return m & IFMT == IFIFO; | ||
| 1506 | } | ||
| 1507 | |||
| 1508 | pub fn ISCHR(m: u32) bool { | ||
| 1509 | return m & IFMT == IFCHR; | ||
| 1510 | } | ||
| 1511 | |||
| 1512 | pub fn ISDIR(m: u32) bool { | ||
| 1513 | return m & IFMT == IFDIR; | ||
| 1514 | } | ||
| 1515 | |||
| 1516 | pub fn ISBLK(m: u32) bool { | ||
| 1517 | return m & IFMT == IFBLK; | ||
| 1518 | } | ||
| 1519 | |||
| 1520 | pub fn ISREG(m: u32) bool { | ||
| 1521 | return m & IFMT == IFREG; | ||
| 1522 | } | ||
| 1523 | |||
| 1524 | pub fn ISLNK(m: u32) bool { | ||
| 1525 | return m & IFMT == IFLNK; | ||
| 1526 | } | ||
| 1527 | |||
| 1528 | pub fn ISSOCK(m: u32) bool { | ||
| 1529 | return m & IFMT == IFSOCK; | ||
| 1530 | } | ||
| 1531 | |||
| 1532 | pub fn IWHT(m: u32) bool { | ||
| 1533 | return m & IFMT == IFWHT; | ||
| 1534 | } | ||
| 1535 | }; | ||
| 1536 | |||
| 1537 | pub const HOST_NAME_MAX = 255; | ||
| 1538 | |||
| 1539 | pub const addrinfo = extern struct { | ||
| 1540 | flags: i32, | ||
| 1541 | family: i32, | ||
| 1542 | socktype: i32, | ||
| 1543 | protocol: i32, | ||
| 1544 | addrlen: socklen_t, | ||
| 1545 | canonname: ?[*:0]u8, | ||
| 1546 | addr: ?*sockaddr, | ||
| 1547 | next: ?*addrinfo, | ||
| 1548 | }; | ||
| 1549 | |||
| 1550 | pub const IPPROTO = struct { | ||
| 1551 | /// dummy for IP | ||
| 1552 | pub const IP = 0; | ||
| 1553 | /// control message protocol | ||
| 1554 | pub const ICMP = 1; | ||
| 1555 | /// tcp | ||
| 1556 | pub const TCP = 6; | ||
| 1557 | /// user datagram protocol | ||
| 1558 | pub const UDP = 17; | ||
| 1559 | /// IP6 header | ||
| 1560 | pub const IPV6 = 41; | ||
| 1561 | /// raw IP packet | ||
| 1562 | pub const RAW = 255; | ||
| 1563 | /// IP6 hop-by-hop options | ||
| 1564 | pub const HOPOPTS = 0; | ||
| 1565 | /// group mgmt protocol | ||
| 1566 | pub const IGMP = 2; | ||
| 1567 | /// gateway^2 (deprecated) | ||
| 1568 | pub const GGP = 3; | ||
| 1569 | /// IPv4 encapsulation | ||
| 1570 | pub const IPV4 = 4; | ||
| 1571 | /// for compatibility | ||
| 1572 | pub const IPIP = IPV4; | ||
| 1573 | /// Stream protocol II | ||
| 1574 | pub const ST = 7; | ||
| 1575 | /// exterior gateway protocol | ||
| 1576 | pub const EGP = 8; | ||
| 1577 | /// private interior gateway | ||
| 1578 | pub const PIGP = 9; | ||
| 1579 | /// BBN RCC Monitoring | ||
| 1580 | pub const RCCMON = 10; | ||
| 1581 | /// network voice protocol | ||
| 1582 | pub const NVPII = 11; | ||
| 1583 | /// pup | ||
| 1584 | pub const PUP = 12; | ||
| 1585 | /// Argus | ||
| 1586 | pub const ARGUS = 13; | ||
| 1587 | /// EMCON | ||
| 1588 | pub const EMCON = 14; | ||
| 1589 | /// Cross Net Debugger | ||
| 1590 | pub const XNET = 15; | ||
| 1591 | /// Chaos | ||
| 1592 | pub const CHAOS = 16; | ||
| 1593 | /// Multiplexing | ||
| 1594 | pub const MUX = 18; | ||
| 1595 | /// DCN Measurement Subsystems | ||
| 1596 | pub const MEAS = 19; | ||
| 1597 | /// Host Monitoring | ||
| 1598 | pub const HMP = 20; | ||
| 1599 | /// Packet Radio Measurement | ||
| 1600 | pub const PRM = 21; | ||
| 1601 | /// xns idp | ||
| 1602 | pub const IDP = 22; | ||
| 1603 | /// Trunk-1 | ||
| 1604 | pub const TRUNK1 = 23; | ||
| 1605 | /// Trunk-2 | ||
| 1606 | pub const TRUNK2 = 24; | ||
| 1607 | /// Leaf-1 | ||
| 1608 | pub const LEAF1 = 25; | ||
| 1609 | /// Leaf-2 | ||
| 1610 | pub const LEAF2 = 26; | ||
| 1611 | /// Reliable Data | ||
| 1612 | pub const RDP = 27; | ||
| 1613 | /// Reliable Transaction | ||
| 1614 | pub const IRTP = 28; | ||
| 1615 | /// tp-4 w/ class negotiation | ||
| 1616 | pub const TP = 29; | ||
| 1617 | /// Bulk Data Transfer | ||
| 1618 | pub const BLT = 30; | ||
| 1619 | /// Network Services | ||
| 1620 | pub const NSP = 31; | ||
| 1621 | /// Merit Internodal | ||
| 1622 | pub const INP = 32; | ||
| 1623 | /// Datagram Congestion Control Protocol | ||
| 1624 | pub const DCCP = 33; | ||
| 1625 | /// Third Party Connect | ||
| 1626 | pub const @"3PC" = 34; | ||
| 1627 | /// InterDomain Policy Routing | ||
| 1628 | pub const IDPR = 35; | ||
| 1629 | /// XTP | ||
| 1630 | pub const XTP = 36; | ||
| 1631 | /// Datagram Delivery | ||
| 1632 | pub const DDP = 37; | ||
| 1633 | /// Control Message Transport | ||
| 1634 | pub const CMTP = 38; | ||
| 1635 | /// TP++ Transport | ||
| 1636 | pub const TPXX = 39; | ||
| 1637 | /// IL transport protocol | ||
| 1638 | pub const IL = 40; | ||
| 1639 | /// Source Demand Routing | ||
| 1640 | pub const SDRP = 42; | ||
| 1641 | /// IP6 routing header | ||
| 1642 | pub const ROUTING = 43; | ||
| 1643 | /// IP6 fragmentation header | ||
| 1644 | pub const FRAGMENT = 44; | ||
| 1645 | /// InterDomain Routing | ||
| 1646 | pub const IDRP = 45; | ||
| 1647 | /// resource reservation | ||
| 1648 | pub const RSVP = 46; | ||
| 1649 | /// General Routing Encap. | ||
| 1650 | pub const GRE = 47; | ||
| 1651 | /// Mobile Host Routing | ||
| 1652 | pub const MHRP = 48; | ||
| 1653 | /// BHA | ||
| 1654 | pub const BHA = 49; | ||
| 1655 | /// IP6 Encap Sec. Payload | ||
| 1656 | pub const ESP = 50; | ||
| 1657 | /// IP6 Auth Header | ||
| 1658 | pub const AH = 51; | ||
| 1659 | /// Integ. Net Layer Security | ||
| 1660 | pub const INLSP = 52; | ||
| 1661 | /// IP with encryption | ||
| 1662 | pub const SWIPE = 53; | ||
| 1663 | /// Next Hop Resolution | ||
| 1664 | pub const NHRP = 54; | ||
| 1665 | /// IP Mobility | ||
| 1666 | pub const MOBILE = 55; | ||
| 1667 | /// Transport Layer Security | ||
| 1668 | pub const TLSP = 56; | ||
| 1669 | /// SKIP | ||
| 1670 | pub const SKIP = 57; | ||
| 1671 | /// ICMP6 | ||
| 1672 | pub const ICMPV6 = 58; | ||
| 1673 | /// IP6 no next header | ||
| 1674 | pub const NONE = 59; | ||
| 1675 | /// IP6 destination option | ||
| 1676 | pub const DSTOPTS = 60; | ||
| 1677 | /// any host internal protocol | ||
| 1678 | pub const AHIP = 61; | ||
| 1679 | /// CFTP | ||
| 1680 | pub const CFTP = 62; | ||
| 1681 | /// "hello" routing protocol | ||
| 1682 | pub const HELLO = 63; | ||
| 1683 | /// SATNET/Backroom EXPAK | ||
| 1684 | pub const SATEXPAK = 64; | ||
| 1685 | /// Kryptolan | ||
| 1686 | pub const KRYPTOLAN = 65; | ||
| 1687 | /// Remote Virtual Disk | ||
| 1688 | pub const RVD = 66; | ||
| 1689 | /// Pluribus Packet Core | ||
| 1690 | pub const IPPC = 67; | ||
| 1691 | /// Any distributed FS | ||
| 1692 | pub const ADFS = 68; | ||
| 1693 | /// Satnet Monitoring | ||
| 1694 | pub const SATMON = 69; | ||
| 1695 | /// VISA Protocol | ||
| 1696 | pub const VISA = 70; | ||
| 1697 | /// Packet Core Utility | ||
| 1698 | pub const IPCV = 71; | ||
| 1699 | /// Comp. Prot. Net. Executive | ||
| 1700 | pub const CPNX = 72; | ||
| 1701 | /// Comp. Prot. HeartBeat | ||
| 1702 | pub const CPHB = 73; | ||
| 1703 | /// Wang Span Network | ||
| 1704 | pub const WSN = 74; | ||
| 1705 | /// Packet Video Protocol | ||
| 1706 | pub const PVP = 75; | ||
| 1707 | /// BackRoom SATNET Monitoring | ||
| 1708 | pub const BRSATMON = 76; | ||
| 1709 | /// Sun net disk proto (temp.) | ||
| 1710 | pub const ND = 77; | ||
| 1711 | /// WIDEBAND Monitoring | ||
| 1712 | pub const WBMON = 78; | ||
| 1713 | /// WIDEBAND EXPAK | ||
| 1714 | pub const WBEXPAK = 79; | ||
| 1715 | /// ISO cnlp | ||
| 1716 | pub const EON = 80; | ||
| 1717 | /// VMTP | ||
| 1718 | pub const VMTP = 81; | ||
| 1719 | /// Secure VMTP | ||
| 1720 | pub const SVMTP = 82; | ||
| 1721 | /// Banyon VINES | ||
| 1722 | pub const VINES = 83; | ||
| 1723 | /// TTP | ||
| 1724 | pub const TTP = 84; | ||
| 1725 | /// NSFNET-IGP | ||
| 1726 | pub const IGP = 85; | ||
| 1727 | /// dissimilar gateway prot. | ||
| 1728 | pub const DGP = 86; | ||
| 1729 | /// TCF | ||
| 1730 | pub const TCF = 87; | ||
| 1731 | /// Cisco/GXS IGRP | ||
| 1732 | pub const IGRP = 88; | ||
| 1733 | /// OSPFIGP | ||
| 1734 | pub const OSPFIGP = 89; | ||
| 1735 | /// Strite RPC protocol | ||
| 1736 | pub const SRPC = 90; | ||
| 1737 | /// Locus Address Resoloution | ||
| 1738 | pub const LARP = 91; | ||
| 1739 | /// Multicast Transport | ||
| 1740 | pub const MTP = 92; | ||
| 1741 | /// AX.25 Frames | ||
| 1742 | pub const AX25 = 93; | ||
| 1743 | /// IP encapsulated in IP | ||
| 1744 | pub const IPEIP = 94; | ||
| 1745 | /// Mobile Int.ing control | ||
| 1746 | pub const MICP = 95; | ||
| 1747 | /// Semaphore Comm. security | ||
| 1748 | pub const SCCSP = 96; | ||
| 1749 | /// Ethernet IP encapsulation | ||
| 1750 | pub const ETHERIP = 97; | ||
| 1751 | /// encapsulation header | ||
| 1752 | pub const ENCAP = 98; | ||
| 1753 | /// any private encr. scheme | ||
| 1754 | pub const APES = 99; | ||
| 1755 | /// GMTP | ||
| 1756 | pub const GMTP = 100; | ||
| 1757 | /// payload compression (IPComp) | ||
| 1758 | pub const IPCOMP = 108; | ||
| 1759 | /// SCTP | ||
| 1760 | pub const SCTP = 132; | ||
| 1761 | /// IPv6 Mobility Header | ||
| 1762 | pub const MH = 135; | ||
| 1763 | /// UDP-Lite | ||
| 1764 | pub const UDPLITE = 136; | ||
| 1765 | /// IP6 Host Identity Protocol | ||
| 1766 | pub const HIP = 139; | ||
| 1767 | /// IP6 Shim6 Protocol | ||
| 1768 | pub const SHIM6 = 140; | ||
| 1769 | /// Protocol Independent Mcast | ||
| 1770 | pub const PIM = 103; | ||
| 1771 | /// CARP | ||
| 1772 | pub const CARP = 112; | ||
| 1773 | /// PGM | ||
| 1774 | pub const PGM = 113; | ||
| 1775 | /// MPLS-in-IP | ||
| 1776 | pub const MPLS = 137; | ||
| 1777 | /// PFSYNC | ||
| 1778 | pub const PFSYNC = 240; | ||
| 1779 | /// Reserved | ||
| 1780 | pub const RESERVED_253 = 253; | ||
| 1781 | /// Reserved | ||
| 1782 | pub const RESERVED_254 = 254; | ||
| 1783 | }; | ||
| 1784 | |||
| 1785 | pub const rlimit_resource = enum(c_int) { | ||
| 1786 | CPU = 0, | ||
| 1787 | FSIZE = 1, | ||
| 1788 | DATA = 2, | ||
| 1789 | STACK = 3, | ||
| 1790 | CORE = 4, | ||
| 1791 | RSS = 5, | ||
| 1792 | MEMLOCK = 6, | ||
| 1793 | NPROC = 7, | ||
| 1794 | NOFILE = 8, | ||
| 1795 | SBSIZE = 9, | ||
| 1796 | VMEM = 10, | ||
| 1797 | NPTS = 11, | ||
| 1798 | SWAP = 12, | ||
| 1799 | KQUEUES = 13, | ||
| 1800 | UMTXP = 14, | ||
| 1801 | _, | ||
| 1802 | |||
| 1803 | pub const AS: rlimit_resource = .VMEM; | ||
| 1804 | }; | ||
| 1805 | |||
| 1806 | pub const rlim_t = i64; | ||
| 1807 | |||
| 1808 | pub const RLIM = struct { | ||
| 1809 | /// No limit | ||
| 1810 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1811 | |||
| 1812 | pub const SAVED_MAX = INFINITY; | ||
| 1813 | pub const SAVED_CUR = INFINITY; | ||
| 1814 | }; | ||
| 1815 | |||
| 1816 | pub const rlimit = extern struct { | ||
| 1817 | /// Soft limit | ||
| 1818 | cur: rlim_t, | ||
| 1819 | /// Hard limit | ||
| 1820 | max: rlim_t, | ||
| 1821 | }; | ||
| 1822 | |||
| 1823 | pub const SHUT = struct { | ||
| 1824 | pub const RD = 0; | ||
| 1825 | pub const WR = 1; | ||
| 1826 | pub const RDWR = 2; | ||
| 1827 | }; | ||
| 1828 | |||
| 1829 | pub const nfds_t = u32; | ||
| 1830 | |||
| 1831 | pub const pollfd = extern struct { | ||
| 1832 | fd: fd_t, | ||
| 1833 | events: i16, | ||
| 1834 | revents: i16, | ||
| 1835 | }; | ||
| 1836 | |||
| 1837 | pub const POLL = struct { | ||
| 1838 | /// any readable data available. | ||
| 1839 | pub const IN = 0x0001; | ||
| 1840 | /// OOB/Urgent readable data. | ||
| 1841 | pub const PRI = 0x0002; | ||
| 1842 | /// file descriptor is writeable. | ||
| 1843 | pub const OUT = 0x0004; | ||
| 1844 | /// non-OOB/URG data available. | ||
| 1845 | pub const RDNORM = 0x0040; | ||
| 1846 | /// no write type differentiation. | ||
| 1847 | pub const WRNORM = OUT; | ||
| 1848 | /// OOB/Urgent readable data. | ||
| 1849 | pub const RDBAND = 0x0080; | ||
| 1850 | /// OOB/Urgent data can be written. | ||
| 1851 | pub const WRBAND = 0x0100; | ||
| 1852 | /// like IN, except ignore EOF. | ||
| 1853 | pub const INIGNEOF = 0x2000; | ||
| 1854 | /// some poll error occurred. | ||
| 1855 | pub const ERR = 0x0008; | ||
| 1856 | /// file descriptor was "hung up". | ||
| 1857 | pub const HUP = 0x0010; | ||
| 1858 | /// requested events "invalid". | ||
| 1859 | pub const NVAL = 0x0020; | ||
| 1860 | |||
| 1861 | pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL; | ||
| 1862 | }; | ||
| 1863 | |||
| 1864 | pub const NAME_MAX = 255; | ||
| 1865 | |||
| 1866 | pub const MFD = struct { | ||
| 1867 | pub const CLOEXEC = 0x0001; | ||
| 1868 | pub const ALLOW_SEALING = 0x0002; | ||
| 1869 | }; | ||
| 1870 | |||
| 1871 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; | ||
| 1872 | pub extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize; | ||
| 1873 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; | ||
| 1874 | pub extern "c" fn dup3(old: c_int, new: c_int, flags: c_uint) c_int; |
lib/std/c/haiku.zig+16-859| ... | @@ -4,152 +4,29 @@ const builtin = @import("builtin"); | ... | @@ -4,152 +4,29 @@ const builtin = @import("builtin"); |
| 4 | const maxInt = std.math.maxInt; | 4 | const maxInt = std.math.maxInt; |
| 5 | const iovec = std.posix.iovec; | 5 | const iovec = std.posix.iovec; |
| 6 | const iovec_const = std.posix.iovec_const; | 6 | const iovec_const = std.posix.iovec_const; |
| 7 | 7 | const socklen_t = std.c.socklen_t; | |
| 8 | const fd_t = std.c.fd_t; | ||
| 9 | const PATH_MAX = std.c.PATH_MAX; | ||
| 10 | const uid_t = std.c.uid_t; | ||
| 11 | const gid_t = std.c.gid_t; | ||
| 12 | const dev_t = std.c.dev_t; | ||
| 13 | const ino_t = std.c.ino_t; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | assert(builtin.os.tag == .haiku); // Prevent access of std.c symbols on wrong OS. | ||
| 17 | } | ||
| 18 | |||
| 19 | pub extern "root" fn _errnop() *i32; | ||
| 8 | pub extern "root" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64; | 20 | pub extern "root" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64; |
| 9 | |||
| 10 | pub extern "root" fn find_thread(thread_name: ?*anyopaque) i32; | 21 | pub extern "root" fn find_thread(thread_name: ?*anyopaque) i32; |
| 11 | |||
| 12 | pub extern "root" fn get_system_info(system_info: *system_info) usize; | 22 | pub extern "root" fn get_system_info(system_info: *system_info) usize; |
| 13 | |||
| 14 | pub extern "root" fn _get_team_info(team: i32, team_info: *team_info, size: usize) i32; | 23 | pub extern "root" fn _get_team_info(team: i32, team_info: *team_info, size: usize) i32; |
| 15 | |||
| 16 | pub extern "root" fn _get_next_area_info(team: i32, cookie: *i64, area_info: *area_info, size: usize) i32; | 24 | pub extern "root" fn _get_next_area_info(team: i32, cookie: *i64, area_info: *area_info, size: usize) i32; |
| 17 | |||
| 18 | // TODO revisit if abi changes or better option becomes apparent | ||
| 19 | pub extern "root" fn _get_next_image_info(team: i32, cookie: *i32, image_info: *image_info, size: usize) i32; | 25 | pub extern "root" fn _get_next_image_info(team: i32, cookie: *i32, image_info: *image_info, size: usize) i32; |
| 20 | 26 | ||
| 21 | pub const sem_t = extern struct { | ||
| 22 | type: i32, | ||
| 23 | u: extern union { | ||
| 24 | named_sem_id: i32, | ||
| 25 | unnamed_sem: i32, | ||
| 26 | }, | ||
| 27 | padding: [2]i32, | ||
| 28 | }; | ||
| 29 | |||
| 30 | pub const pthread_attr_t = extern struct { | ||
| 31 | __detach_state: i32, | ||
| 32 | __sched_priority: i32, | ||
| 33 | __stack_size: i32, | ||
| 34 | __guard_size: i32, | ||
| 35 | __stack_address: ?*anyopaque, | ||
| 36 | }; | ||
| 37 | |||
| 38 | pub const EAI = enum(i32) { | ||
| 39 | /// address family for hostname not supported | ||
| 40 | ADDRFAMILY = 1, | ||
| 41 | |||
| 42 | /// name could not be resolved at this time | ||
| 43 | AGAIN = 2, | ||
| 44 | |||
| 45 | /// flags parameter had an invalid value | ||
| 46 | BADFLAGS = 3, | ||
| 47 | |||
| 48 | /// non-recoverable failure in name resolution | ||
| 49 | FAIL = 4, | ||
| 50 | |||
| 51 | /// address family not recognized | ||
| 52 | FAMILY = 5, | ||
| 53 | |||
| 54 | /// memory allocation failure | ||
| 55 | MEMORY = 6, | ||
| 56 | |||
| 57 | /// no address associated with hostname | ||
| 58 | NODATA = 7, | ||
| 59 | |||
| 60 | /// name does not resolve | ||
| 61 | NONAME = 8, | ||
| 62 | |||
| 63 | /// service not recognized for socket type | ||
| 64 | SERVICE = 9, | ||
| 65 | |||
| 66 | /// intended socket type was not recognized | ||
| 67 | SOCKTYPE = 10, | ||
| 68 | |||
| 69 | /// system error returned in errno | ||
| 70 | SYSTEM = 11, | ||
| 71 | |||
| 72 | /// invalid value for hints | ||
| 73 | BADHINTS = 12, | ||
| 74 | |||
| 75 | /// resolved protocol is unknown | ||
| 76 | PROTOCOL = 13, | ||
| 77 | |||
| 78 | /// argument buffer overflow | ||
| 79 | OVERFLOW = 14, | ||
| 80 | |||
| 81 | _, | ||
| 82 | }; | ||
| 83 | |||
| 84 | pub const EAI_MAX = 15; | ||
| 85 | |||
| 86 | pub const AI = struct { | ||
| 87 | pub const NUMERICSERV = 0x00000008; | ||
| 88 | }; | ||
| 89 | |||
| 90 | pub const AI_NUMERICSERV = AI.NUMERICSERV; | ||
| 91 | |||
| 92 | pub const fd_t = i32; | ||
| 93 | |||
| 94 | pub const socklen_t = u32; | ||
| 95 | |||
| 96 | // Modes and flags for dlopen() | ||
| 97 | // include/dlfcn.h | ||
| 98 | |||
| 99 | pub const RTLD = struct { | ||
| 100 | /// relocations are performed as needed | ||
| 101 | pub const LAZY = 0; | ||
| 102 | /// the file gets relocated at load time | ||
| 103 | pub const NOW = 1; | ||
| 104 | /// all symbols are available | ||
| 105 | pub const GLOBAL = 2; | ||
| 106 | /// symbols are not available for relocating any other object | ||
| 107 | pub const LOCAL = 0; | ||
| 108 | }; | ||
| 109 | |||
| 110 | pub const dl_phdr_info = extern struct { | ||
| 111 | dlpi_addr: usize, | ||
| 112 | dlpi_name: ?[*:0]const u8, | ||
| 113 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 114 | dlpi_phnum: u16, | ||
| 115 | }; | ||
| 116 | |||
| 117 | pub const Flock = extern struct { | ||
| 118 | type: i16, | ||
| 119 | whence: i16, | ||
| 120 | start: off_t, | ||
| 121 | len: off_t, | ||
| 122 | pid: pid_t, | ||
| 123 | }; | ||
| 124 | |||
| 125 | pub const msghdr = extern struct { | ||
| 126 | /// optional address | ||
| 127 | msg_name: ?*sockaddr, | ||
| 128 | |||
| 129 | /// size of address | ||
| 130 | msg_namelen: socklen_t, | ||
| 131 | |||
| 132 | /// scatter/gather array | ||
| 133 | msg_iov: [*]iovec, | ||
| 134 | |||
| 135 | /// # elements in msg_iov | ||
| 136 | msg_iovlen: i32, | ||
| 137 | |||
| 138 | /// ancillary data | ||
| 139 | msg_control: ?*anyopaque, | ||
| 140 | |||
| 141 | /// ancillary data buffer len | ||
| 142 | msg_controllen: socklen_t, | ||
| 143 | |||
| 144 | /// flags on received message | ||
| 145 | msg_flags: i32, | ||
| 146 | }; | ||
| 147 | |||
| 148 | pub const B_OS_NAME_LENGTH = 32; // OS.h | ||
| 149 | |||
| 150 | pub const area_info = extern struct { | 27 | pub const area_info = extern struct { |
| 151 | area: u32, | 28 | area: u32, |
| 152 | name: [B_OS_NAME_LENGTH]u8, | 29 | name: [32]u8, |
| 153 | size: usize, | 30 | size: usize, |
| 154 | lock: u32, | 31 | lock: u32, |
| 155 | protection: u32, | 32 | protection: u32, |
| ... | @@ -161,9 +38,6 @@ pub const area_info = extern struct { | ... | @@ -161,9 +38,6 @@ pub const area_info = extern struct { |
| 161 | address: *anyopaque, | 38 | address: *anyopaque, |
| 162 | }; | 39 | }; |
| 163 | 40 | ||
| 164 | pub const MAXPATHLEN = PATH_MAX; | ||
| 165 | pub const MAXNAMLEN = NAME_MAX; | ||
| 166 | |||
| 167 | pub const image_info = extern struct { | 41 | pub const image_info = extern struct { |
| 168 | id: u32, | 42 | id: u32, |
| 169 | image_type: u32, | 43 | image_type: u32, |
| ... | @@ -173,7 +47,7 @@ pub const image_info = extern struct { | ... | @@ -173,7 +47,7 @@ pub const image_info = extern struct { |
| 173 | term_routine: *anyopaque, | 47 | term_routine: *anyopaque, |
| 174 | device: i32, | 48 | device: i32, |
| 175 | node: i64, | 49 | node: i64, |
| 176 | name: [MAXPATHLEN]u8, | 50 | name: [PATH_MAX]u8, |
| 177 | text: *anyopaque, | 51 | text: *anyopaque, |
| 178 | data: *anyopaque, | 52 | data: *anyopaque, |
| 179 | text_size: i32, | 53 | text_size: i32, |
| ... | @@ -223,473 +97,18 @@ pub const team_info = extern struct { | ... | @@ -223,473 +97,18 @@ pub const team_info = extern struct { |
| 223 | gid: gid_t, | 97 | gid: gid_t, |
| 224 | }; | 98 | }; |
| 225 | 99 | ||
| 226 | pub const in_port_t = u16; | ||
| 227 | pub const sa_family_t = u8; | ||
| 228 | |||
| 229 | pub const sockaddr = extern struct { | ||
| 230 | /// total length | ||
| 231 | len: u8, | ||
| 232 | /// address family | ||
| 233 | family: sa_family_t, | ||
| 234 | /// actually longer; address value | ||
| 235 | data: [14]u8, | ||
| 236 | |||
| 237 | pub const SS_MAXSIZE = 128; | ||
| 238 | pub const storage = extern struct { | ||
| 239 | len: u8 align(8), | ||
| 240 | family: sa_family_t, | ||
| 241 | padding: [126]u8 = undefined, | ||
| 242 | |||
| 243 | comptime { | ||
| 244 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 245 | assert(@alignOf(storage) == 8); | ||
| 246 | } | ||
| 247 | }; | ||
| 248 | |||
| 249 | pub const in = extern struct { | ||
| 250 | len: u8 = @sizeOf(in), | ||
| 251 | family: sa_family_t = AF.INET, | ||
| 252 | port: in_port_t, | ||
| 253 | addr: u32, | ||
| 254 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 255 | }; | ||
| 256 | |||
| 257 | pub const in6 = extern struct { | ||
| 258 | len: u8 = @sizeOf(in6), | ||
| 259 | family: sa_family_t = AF.INET6, | ||
| 260 | port: in_port_t, | ||
| 261 | flowinfo: u32, | ||
| 262 | addr: [16]u8, | ||
| 263 | scope_id: u32, | ||
| 264 | }; | ||
| 265 | |||
| 266 | pub const un = extern struct { | ||
| 267 | len: u8 = @sizeOf(un), | ||
| 268 | family: sa_family_t = AF.UNIX, | ||
| 269 | path: [104]u8, | ||
| 270 | }; | ||
| 271 | }; | ||
| 272 | |||
| 273 | pub const CTL = struct {}; | ||
| 274 | |||
| 275 | pub const KERN = struct {}; | ||
| 276 | |||
| 277 | pub const IOV_MAX = 1024; | ||
| 278 | |||
| 279 | pub const PATH_MAX = 1024; | ||
| 280 | /// NOTE: Contains room for the terminating null character (despite the POSIX | ||
| 281 | /// definition saying that NAME_MAX does not include the terminating null). | ||
| 282 | pub const NAME_MAX = 256; // limits.h | ||
| 283 | |||
| 284 | pub const STDIN_FILENO = 0; | ||
| 285 | pub const STDOUT_FILENO = 1; | ||
| 286 | pub const STDERR_FILENO = 2; | ||
| 287 | |||
| 288 | pub const PROT = struct { | ||
| 289 | pub const READ = 0x01; | ||
| 290 | pub const WRITE = 0x02; | ||
| 291 | pub const EXEC = 0x04; | ||
| 292 | pub const NONE = 0x00; | ||
| 293 | }; | ||
| 294 | |||
| 295 | pub const MSF = struct { | ||
| 296 | pub const ASYNC = 1; | ||
| 297 | pub const INVALIDATE = 2; | ||
| 298 | pub const SYNC = 4; | ||
| 299 | }; | ||
| 300 | |||
| 301 | pub const W = struct { | ||
| 302 | pub const NOHANG = 0x1; | ||
| 303 | pub const UNTRACED = 0x2; | ||
| 304 | pub const CONTINUED = 0x4; | ||
| 305 | pub const EXITED = 0x08; | ||
| 306 | pub const STOPPED = 0x10; | ||
| 307 | pub const NOWAIT = 0x20; | ||
| 308 | |||
| 309 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 310 | return @as(u8, @intCast(s & 0xff)); | ||
| 311 | } | ||
| 312 | |||
| 313 | pub fn TERMSIG(s: u32) u32 { | ||
| 314 | return (s >> 8) & 0xff; | ||
| 315 | } | ||
| 316 | |||
| 317 | pub fn STOPSIG(s: u32) u32 { | ||
| 318 | return (s >> 16) & 0xff; | ||
| 319 | } | ||
| 320 | |||
| 321 | pub fn IFEXITED(s: u32) bool { | ||
| 322 | return (s & ~@as(u32, 0xff)) == 0; | ||
| 323 | } | ||
| 324 | |||
| 325 | pub fn IFSTOPPED(s: u32) bool { | ||
| 326 | return ((s >> 16) & 0xff) != 0; | ||
| 327 | } | ||
| 328 | |||
| 329 | pub fn IFSIGNALED(s: u32) bool { | ||
| 330 | return ((s >> 8) & 0xff) != 0; | ||
| 331 | } | ||
| 332 | }; | ||
| 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 F = struct { | ||
| 341 | pub const DUPFD = 0x0001; | ||
| 342 | pub const GETFD = 0x0002; | ||
| 343 | pub const SETFD = 0x0004; | ||
| 344 | pub const GETFL = 0x0008; | ||
| 345 | pub const SETFL = 0x0010; | ||
| 346 | |||
| 347 | pub const GETLK = 0x0020; | ||
| 348 | pub const SETLK = 0x0080; | ||
| 349 | pub const SETLKW = 0x0100; | ||
| 350 | pub const DUPFD_CLOEXEC = 0x0200; | ||
| 351 | |||
| 352 | pub const RDLCK = 0x0040; | ||
| 353 | pub const UNLCK = 0x0200; | ||
| 354 | pub const WRLCK = 0x0400; | ||
| 355 | }; | ||
| 356 | |||
| 357 | pub const LOCK = struct { | ||
| 358 | pub const SH = 0x01; | ||
| 359 | pub const EX = 0x02; | ||
| 360 | pub const NB = 0x04; | ||
| 361 | pub const UN = 0x08; | ||
| 362 | }; | ||
| 363 | |||
| 364 | pub const FD_CLOEXEC = 1; | ||
| 365 | |||
| 366 | pub const SEEK = struct { | ||
| 367 | pub const SET = 0; | ||
| 368 | pub const CUR = 1; | ||
| 369 | pub const END = 2; | ||
| 370 | }; | ||
| 371 | |||
| 372 | pub const SOCK = struct { | ||
| 373 | pub const STREAM = 1; | ||
| 374 | pub const DGRAM = 2; | ||
| 375 | pub const RAW = 3; | ||
| 376 | pub const SEQPACKET = 5; | ||
| 377 | |||
| 378 | /// WARNING: this flag is not supported by windows socket functions directly, | ||
| 379 | /// it is only supported by std.os.socket. Be sure that this value does | ||
| 380 | /// not share any bits with any of the `SOCK` values. | ||
| 381 | pub const CLOEXEC = 0x10000; | ||
| 382 | /// WARNING: this flag is not supported by windows socket functions directly, | ||
| 383 | /// it is only supported by std.os.socket. Be sure that this value does | ||
| 384 | /// not share any bits with any of the `SOCK` values. | ||
| 385 | pub const NONBLOCK = 0x20000; | ||
| 386 | }; | ||
| 387 | |||
| 388 | pub const SO = struct { | ||
| 389 | pub const ACCEPTCONN = 0x00000001; | ||
| 390 | pub const BROADCAST = 0x00000002; | ||
| 391 | pub const DEBUG = 0x00000004; | ||
| 392 | pub const DONTROUTE = 0x00000008; | ||
| 393 | pub const KEEPALIVE = 0x00000010; | ||
| 394 | pub const OOBINLINE = 0x00000020; | ||
| 395 | pub const REUSEADDR = 0x00000040; | ||
| 396 | pub const REUSEPORT = 0x00000080; | ||
| 397 | pub const USELOOPBACK = 0x00000100; | ||
| 398 | pub const LINGER = 0x00000200; | ||
| 399 | |||
| 400 | pub const SNDBUF = 0x40000001; | ||
| 401 | pub const SNDLOWAT = 0x40000002; | ||
| 402 | pub const SNDTIMEO = 0x40000003; | ||
| 403 | pub const RCVBUF = 0x40000004; | ||
| 404 | pub const RCVLOWAT = 0x40000005; | ||
| 405 | pub const RCVTIMEO = 0x40000006; | ||
| 406 | pub const ERROR = 0x40000007; | ||
| 407 | pub const TYPE = 0x40000008; | ||
| 408 | pub const NONBLOCK = 0x40000009; | ||
| 409 | pub const BINDTODEVICE = 0x4000000a; | ||
| 410 | pub const PEERCRED = 0x4000000b; | ||
| 411 | }; | ||
| 412 | |||
| 413 | pub const SOL = struct { | ||
| 414 | pub const SOCKET = -1; | ||
| 415 | }; | ||
| 416 | |||
| 417 | pub const PF = struct { | ||
| 418 | pub const UNSPEC = AF.UNSPEC; | ||
| 419 | pub const INET = AF.INET; | ||
| 420 | pub const ROUTE = AF.ROUTE; | ||
| 421 | pub const LINK = AF.LINK; | ||
| 422 | pub const INET6 = AF.INET6; | ||
| 423 | pub const LOCAL = AF.LOCAL; | ||
| 424 | pub const UNIX = AF.UNIX; | ||
| 425 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 426 | }; | ||
| 427 | |||
| 428 | pub const AF = struct { | ||
| 429 | pub const UNSPEC = 0; | ||
| 430 | pub const INET = 1; | ||
| 431 | pub const APPLETALK = 2; | ||
| 432 | pub const ROUTE = 3; | ||
| 433 | pub const LINK = 4; | ||
| 434 | pub const INET6 = 5; | ||
| 435 | pub const DLI = 6; | ||
| 436 | pub const IPX = 7; | ||
| 437 | pub const NOTIFY = 8; | ||
| 438 | pub const LOCAL = 9; | ||
| 439 | pub const UNIX = LOCAL; | ||
| 440 | pub const BLUETOOTH = 10; | ||
| 441 | pub const MAX = 11; | ||
| 442 | }; | ||
| 443 | |||
| 444 | pub const DT = struct {}; | ||
| 445 | |||
| 446 | /// add event to kq (implies enable) | ||
| 447 | pub const EV_ADD = 0x0001; | ||
| 448 | |||
| 449 | /// delete event from kq | ||
| 450 | pub const EV_DELETE = 0x0002; | ||
| 451 | |||
| 452 | /// enable event | ||
| 453 | pub const EV_ENABLE = 0x0004; | ||
| 454 | |||
| 455 | /// disable event (not reported) | ||
| 456 | pub const EV_DISABLE = 0x0008; | ||
| 457 | |||
| 458 | /// only report one occurrence | ||
| 459 | pub const EV_ONESHOT = 0x0010; | ||
| 460 | |||
| 461 | /// clear event state after reporting | ||
| 462 | pub const EV_CLEAR = 0x0020; | ||
| 463 | |||
| 464 | /// force immediate event output | ||
| 465 | /// ... with or without EV_ERROR | ||
| 466 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 467 | /// on syscalls supporting flags | ||
| 468 | pub const EV_RECEIPT = 0x0040; | ||
| 469 | |||
| 470 | /// disable event after reporting | ||
| 471 | pub const EV_DISPATCH = 0x0080; | ||
| 472 | |||
| 473 | pub const EVFILT_READ = -1; | ||
| 474 | pub const EVFILT_WRITE = -2; | ||
| 475 | |||
| 476 | /// attached to aio requests | ||
| 477 | pub const EVFILT_AIO = -3; | ||
| 478 | |||
| 479 | /// attached to vnodes | ||
| 480 | pub const EVFILT_VNODE = -4; | ||
| 481 | |||
| 482 | /// attached to struct proc | ||
| 483 | pub const EVFILT_PROC = -5; | ||
| 484 | |||
| 485 | /// attached to struct proc | ||
| 486 | pub const EVFILT_SIGNAL = -6; | ||
| 487 | |||
| 488 | /// timers | ||
| 489 | pub const EVFILT_TIMER = -7; | ||
| 490 | |||
| 491 | /// Process descriptors | ||
| 492 | pub const EVFILT_PROCDESC = -8; | ||
| 493 | |||
| 494 | /// Filesystem events | ||
| 495 | pub const EVFILT_FS = -9; | ||
| 496 | |||
| 497 | pub const EVFILT_LIO = -10; | ||
| 498 | |||
| 499 | /// User events | ||
| 500 | pub const EVFILT_USER = -11; | ||
| 501 | |||
| 502 | /// Sendfile events | ||
| 503 | pub const EVFILT_SENDFILE = -12; | ||
| 504 | |||
| 505 | pub const EVFILT_EMPTY = -13; | ||
| 506 | |||
| 507 | pub const T = struct { | ||
| 508 | pub const CGETA = 0x8000; | ||
| 509 | pub const CSETA = 0x8001; | ||
| 510 | pub const CSETAF = 0x8002; | ||
| 511 | pub const CSETAW = 0x8003; | ||
| 512 | pub const CWAITEVENT = 0x8004; | ||
| 513 | pub const CSBRK = 0x8005; | ||
| 514 | pub const CFLSH = 0x8006; | ||
| 515 | pub const CXONC = 0x8007; | ||
| 516 | pub const CQUERYCONNECTED = 0x8008; | ||
| 517 | pub const CGETBITS = 0x8009; | ||
| 518 | pub const CSETDTR = 0x8010; | ||
| 519 | pub const CSETRTS = 0x8011; | ||
| 520 | pub const IOCGWINSZ = 0x8012; | ||
| 521 | pub const IOCSWINSZ = 0x8013; | ||
| 522 | pub const CVTIME = 0x8014; | ||
| 523 | pub const IOCGPGRP = 0x8015; | ||
| 524 | pub const IOCSPGRP = 0x8016; | ||
| 525 | pub const IOCSCTTY = 0x8017; | ||
| 526 | pub const IOCMGET = 0x8018; | ||
| 527 | pub const IOCMSET = 0x8019; | ||
| 528 | pub const IOCSBRK = 0x8020; | ||
| 529 | pub const IOCCBRK = 0x8021; | ||
| 530 | pub const IOCMBIS = 0x8022; | ||
| 531 | pub const IOCMBIC = 0x8023; | ||
| 532 | pub const IOCGSID = 0x8024; | ||
| 533 | |||
| 534 | pub const FIONREAD = 0xbe000001; | ||
| 535 | pub const FIONBIO = 0xbe000000; | ||
| 536 | }; | ||
| 537 | |||
| 538 | pub const winsize = extern struct { | ||
| 539 | ws_row: u16, | ||
| 540 | ws_col: u16, | ||
| 541 | ws_xpixel: u16, | ||
| 542 | ws_ypixel: u16, | ||
| 543 | }; | ||
| 544 | |||
| 545 | pub const S = struct { | ||
| 546 | pub const IFMT = 0o170000; | ||
| 547 | pub const IFSOCK = 0o140000; | ||
| 548 | pub const IFLNK = 0o120000; | ||
| 549 | pub const IFREG = 0o100000; | ||
| 550 | pub const IFBLK = 0o060000; | ||
| 551 | pub const IFDIR = 0o040000; | ||
| 552 | pub const IFCHR = 0o020000; | ||
| 553 | pub const IFIFO = 0o010000; | ||
| 554 | pub const INDEX_DIR = 0o4000000000; | ||
| 555 | |||
| 556 | pub const IUMSK = 0o7777; | ||
| 557 | pub const ISUID = 0o4000; | ||
| 558 | pub const ISGID = 0o2000; | ||
| 559 | pub const ISVTX = 0o1000; | ||
| 560 | pub const IRWXU = 0o700; | ||
| 561 | pub const IRUSR = 0o400; | ||
| 562 | pub const IWUSR = 0o200; | ||
| 563 | pub const IXUSR = 0o100; | ||
| 564 | pub const IRWXG = 0o070; | ||
| 565 | pub const IRGRP = 0o040; | ||
| 566 | pub const IWGRP = 0o020; | ||
| 567 | pub const IXGRP = 0o010; | ||
| 568 | pub const IRWXO = 0o007; | ||
| 569 | pub const IROTH = 0o004; | ||
| 570 | pub const IWOTH = 0o002; | ||
| 571 | pub const IXOTH = 0o001; | ||
| 572 | |||
| 573 | pub fn ISREG(m: u32) bool { | ||
| 574 | return m & IFMT == IFREG; | ||
| 575 | } | ||
| 576 | |||
| 577 | pub fn ISLNK(m: u32) bool { | ||
| 578 | return m & IFMT == IFLNK; | ||
| 579 | } | ||
| 580 | |||
| 581 | pub fn ISBLK(m: u32) bool { | ||
| 582 | return m & IFMT == IFBLK; | ||
| 583 | } | ||
| 584 | |||
| 585 | pub fn ISDIR(m: u32) bool { | ||
| 586 | return m & IFMT == IFDIR; | ||
| 587 | } | ||
| 588 | |||
| 589 | pub fn ISCHR(m: u32) bool { | ||
| 590 | return m & IFMT == IFCHR; | ||
| 591 | } | ||
| 592 | |||
| 593 | pub fn ISFIFO(m: u32) bool { | ||
| 594 | return m & IFMT == IFIFO; | ||
| 595 | } | ||
| 596 | |||
| 597 | pub fn ISSOCK(m: u32) bool { | ||
| 598 | return m & IFMT == IFSOCK; | ||
| 599 | } | ||
| 600 | |||
| 601 | pub fn ISINDEX(m: u32) bool { | ||
| 602 | return m & INDEX_DIR == INDEX_DIR; | ||
| 603 | } | ||
| 604 | }; | ||
| 605 | |||
| 606 | pub const HOST_NAME_MAX = 255; | ||
| 607 | |||
| 608 | pub const addrinfo = extern struct { | ||
| 609 | flags: i32, | ||
| 610 | family: i32, | ||
| 611 | socktype: i32, | ||
| 612 | protocol: i32, | ||
| 613 | addrlen: socklen_t, | ||
| 614 | canonname: ?[*:0]u8, | ||
| 615 | addr: ?*sockaddr, | ||
| 616 | next: ?*addrinfo, | ||
| 617 | }; | ||
| 618 | |||
| 619 | pub const IPPROTO = struct { | ||
| 620 | pub const IP = 0; | ||
| 621 | pub const HOPOPTS = 0; | ||
| 622 | pub const ICMP = 1; | ||
| 623 | pub const IGMP = 2; | ||
| 624 | pub const TCP = 6; | ||
| 625 | pub const UDP = 17; | ||
| 626 | pub const IPV6 = 41; | ||
| 627 | pub const ROUTING = 43; | ||
| 628 | pub const FRAGMENT = 44; | ||
| 629 | pub const ESP = 50; | ||
| 630 | pub const AH = 51; | ||
| 631 | pub const ICMPV6 = 58; | ||
| 632 | pub const NONE = 59; | ||
| 633 | pub const DSTOPTS = 60; | ||
| 634 | pub const ETHERIP = 97; | ||
| 635 | pub const RAW = 255; | ||
| 636 | pub const MAX = 256; | ||
| 637 | }; | ||
| 638 | |||
| 639 | pub const rlimit_resource = enum(i32) { | ||
| 640 | CORE = 0, | ||
| 641 | CPU = 1, | ||
| 642 | DATA = 2, | ||
| 643 | FSIZE = 3, | ||
| 644 | NOFILE = 4, | ||
| 645 | STACK = 5, | ||
| 646 | AS = 6, | ||
| 647 | NOVMON = 7, | ||
| 648 | _, | ||
| 649 | }; | ||
| 650 | |||
| 651 | pub const rlim_t = i64; | ||
| 652 | |||
| 653 | pub const RLIM = struct { | ||
| 654 | /// No limit | ||
| 655 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 656 | |||
| 657 | pub const SAVED_MAX = INFINITY; | ||
| 658 | pub const SAVED_CUR = INFINITY; | ||
| 659 | }; | ||
| 660 | |||
| 661 | pub const rlimit = extern struct { | ||
| 662 | /// Soft limit | ||
| 663 | cur: rlim_t, | ||
| 664 | /// Hard limit | ||
| 665 | max: rlim_t, | ||
| 666 | }; | ||
| 667 | |||
| 668 | pub const SHUT = struct { | ||
| 669 | pub const RD = 0; | ||
| 670 | pub const WR = 1; | ||
| 671 | pub const RDWR = 2; | ||
| 672 | }; | ||
| 673 | |||
| 674 | // TODO fill out if needed | ||
| 675 | pub const directory_which = enum(i32) { | 100 | pub const directory_which = enum(i32) { |
| 676 | B_USER_SETTINGS_DIRECTORY = 0xbbe, | 101 | B_USER_SETTINGS_DIRECTORY = 0xbbe, |
| 677 | 102 | ||
| 678 | _, | 103 | _, |
| 679 | }; | 104 | }; |
| 680 | 105 | ||
| 681 | pub const MSG_NOSIGNAL = 0x0800; | ||
| 682 | |||
| 683 | // /system/develop/headers/os/kernel/OS.h | ||
| 684 | |||
| 685 | pub const area_id = i32; | 106 | pub const area_id = i32; |
| 686 | pub const port_id = i32; | 107 | pub const port_id = i32; |
| 687 | pub const sem_id = i32; | 108 | pub const sem_id = i32; |
| 688 | pub const team_id = i32; | 109 | pub const team_id = i32; |
| 689 | pub const thread_id = i32; | 110 | pub const thread_id = i32; |
| 690 | 111 | ||
| 691 | // /system/develop/headers/os/support/Errors.h | ||
| 692 | |||
| 693 | pub const E = enum(i32) { | 112 | pub const E = enum(i32) { |
| 694 | pub const B_GENERAL_ERROR_BASE: i32 = std.math.minInt(i32); | 113 | pub const B_GENERAL_ERROR_BASE: i32 = std.math.minInt(i32); |
| 695 | pub const B_OS_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x1000; | 114 | pub const B_OS_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x1000; |
| ... | @@ -847,13 +266,9 @@ pub const E = enum(i32) { | ... | @@ -847,13 +266,9 @@ pub const E = enum(i32) { |
| 847 | _, | 266 | _, |
| 848 | }; | 267 | }; |
| 849 | 268 | ||
| 850 | // /system/develop/headers/os/support/SupportDefs.h | ||
| 851 | |||
| 852 | pub const status_t = i32; | 269 | pub const status_t = i32; |
| 853 | 270 | ||
| 854 | // /system/develop/headers/posix/arch/*/signal.h | 271 | pub const mcontext_t = switch (builtin.cpu.arch) { |
| 855 | |||
| 856 | pub const vregs = switch (builtin.cpu.arch) { | ||
| 857 | .arm, .thumb => extern struct { | 272 | .arm, .thumb => extern struct { |
| 858 | r0: u32, | 273 | r0: u32, |
| 859 | r1: u32, | 274 | r1: u32, |
| ... | @@ -1116,8 +531,6 @@ pub const vregs = switch (builtin.cpu.arch) { | ... | @@ -1116,8 +531,6 @@ pub const vregs = switch (builtin.cpu.arch) { |
| 1116 | else => void, | 531 | else => void, |
| 1117 | }; | 532 | }; |
| 1118 | 533 | ||
| 1119 | // /system/develop/headers/posix/dirent.h | ||
| 1120 | |||
| 1121 | pub const DirEnt = extern struct { | 534 | pub const DirEnt = extern struct { |
| 1122 | /// device | 535 | /// device |
| 1123 | dev: dev_t, | 536 | dev: dev_t, |
| ... | @@ -1135,259 +548,3 @@ pub const DirEnt = extern struct { | ... | @@ -1135,259 +548,3 @@ pub const DirEnt = extern struct { |
| 1135 | return @ptrCast(&dirent.name); | 548 | return @ptrCast(&dirent.name); |
| 1136 | } | 549 | } |
| 1137 | }; | 550 | }; |
| 1138 | |||
| 1139 | // /system/develop/headers/posix/errno.h | ||
| 1140 | |||
| 1141 | extern "root" fn _errnop() *i32; | ||
| 1142 | pub const _errno = _errnop; | ||
| 1143 | |||
| 1144 | // /system/develop/headers/posix/poll.h | ||
| 1145 | |||
| 1146 | pub const nfds_t = usize; | ||
| 1147 | |||
| 1148 | pub const pollfd = extern struct { | ||
| 1149 | fd: i32, | ||
| 1150 | events: i16, | ||
| 1151 | revents: i16, | ||
| 1152 | }; | ||
| 1153 | |||
| 1154 | pub const POLL = struct { | ||
| 1155 | /// any readable data available | ||
| 1156 | pub const IN = 0x0001; | ||
| 1157 | /// file descriptor is writeable | ||
| 1158 | pub const OUT = 0x0002; | ||
| 1159 | pub const RDNORM = IN; | ||
| 1160 | pub const WRNORM = OUT; | ||
| 1161 | /// priority readable data | ||
| 1162 | pub const RDBAND = 0x0008; | ||
| 1163 | /// priority data can be written | ||
| 1164 | pub const WRBAND = 0x0010; | ||
| 1165 | /// high priority readable data | ||
| 1166 | pub const PRI = 0x0020; | ||
| 1167 | |||
| 1168 | /// errors pending | ||
| 1169 | pub const ERR = 0x0004; | ||
| 1170 | /// disconnected | ||
| 1171 | pub const HUP = 0x0080; | ||
| 1172 | /// invalid file descriptor | ||
| 1173 | pub const NVAL = 0x1000; | ||
| 1174 | }; | ||
| 1175 | |||
| 1176 | // /system/develop/headers/posix/signal.h | ||
| 1177 | |||
| 1178 | pub const sigset_t = u64; | ||
| 1179 | pub const empty_sigset: sigset_t = 0; | ||
| 1180 | pub const filled_sigset = ~@as(sigset_t, 0); | ||
| 1181 | |||
| 1182 | pub const SIG = struct { | ||
| 1183 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 1184 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 1185 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 1186 | |||
| 1187 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); | ||
| 1188 | |||
| 1189 | pub const HUP = 1; | ||
| 1190 | pub const INT = 2; | ||
| 1191 | pub const QUIT = 3; | ||
| 1192 | pub const ILL = 4; | ||
| 1193 | pub const CHLD = 5; | ||
| 1194 | pub const ABRT = 6; | ||
| 1195 | pub const IOT = ABRT; | ||
| 1196 | pub const PIPE = 7; | ||
| 1197 | pub const FPE = 8; | ||
| 1198 | pub const KILL = 9; | ||
| 1199 | pub const STOP = 10; | ||
| 1200 | pub const SEGV = 11; | ||
| 1201 | pub const CONT = 12; | ||
| 1202 | pub const TSTP = 13; | ||
| 1203 | pub const ALRM = 14; | ||
| 1204 | pub const TERM = 15; | ||
| 1205 | pub const TTIN = 16; | ||
| 1206 | pub const TTOU = 17; | ||
| 1207 | pub const USR1 = 18; | ||
| 1208 | pub const USR2 = 19; | ||
| 1209 | pub const WINCH = 20; | ||
| 1210 | pub const KILLTHR = 21; | ||
| 1211 | pub const TRAP = 22; | ||
| 1212 | pub const POLL = 23; | ||
| 1213 | pub const PROF = 24; | ||
| 1214 | pub const SYS = 25; | ||
| 1215 | pub const URG = 26; | ||
| 1216 | pub const VTALRM = 27; | ||
| 1217 | pub const XCPU = 28; | ||
| 1218 | pub const XFSZ = 29; | ||
| 1219 | pub const BUS = 30; | ||
| 1220 | pub const RESERVED1 = 31; | ||
| 1221 | pub const RESERVED2 = 32; | ||
| 1222 | |||
| 1223 | pub const BLOCK = 1; | ||
| 1224 | pub const UNBLOCK = 2; | ||
| 1225 | pub const SETMASK = 3; | ||
| 1226 | }; | ||
| 1227 | |||
| 1228 | pub const siginfo_t = extern struct { | ||
| 1229 | signo: i32, | ||
| 1230 | code: i32, | ||
| 1231 | errno: i32, | ||
| 1232 | |||
| 1233 | pid: pid_t, | ||
| 1234 | uid: uid_t, | ||
| 1235 | addr: *allowzero anyopaque, | ||
| 1236 | }; | ||
| 1237 | |||
| 1238 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 1239 | pub const Sigaction = extern struct { | ||
| 1240 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 1241 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 1242 | |||
| 1243 | /// signal handler | ||
| 1244 | handler: extern union { | ||
| 1245 | handler: handler_fn, | ||
| 1246 | sigaction: sigaction_fn, | ||
| 1247 | }, | ||
| 1248 | |||
| 1249 | /// signal mask to apply | ||
| 1250 | mask: sigset_t, | ||
| 1251 | |||
| 1252 | /// see signal options | ||
| 1253 | flags: i32, | ||
| 1254 | |||
| 1255 | /// will be passed to the signal handler, BeOS extension | ||
| 1256 | userdata: *allowzero anyopaque = undefined, | ||
| 1257 | }; | ||
| 1258 | |||
| 1259 | pub const SA = struct { | ||
| 1260 | pub const NOCLDSTOP = 0x01; | ||
| 1261 | pub const NOCLDWAIT = 0x02; | ||
| 1262 | pub const RESETHAND = 0x04; | ||
| 1263 | pub const NODEFER = 0x08; | ||
| 1264 | pub const RESTART = 0x10; | ||
| 1265 | pub const ONSTACK = 0x20; | ||
| 1266 | pub const SIGINFO = 0x40; | ||
| 1267 | pub const NOMASK = NODEFER; | ||
| 1268 | pub const STACK = ONSTACK; | ||
| 1269 | pub const ONESHOT = RESETHAND; | ||
| 1270 | }; | ||
| 1271 | |||
| 1272 | pub const SS = struct { | ||
| 1273 | pub const ONSTACK = 0x1; | ||
| 1274 | pub const DISABLE = 0x2; | ||
| 1275 | }; | ||
| 1276 | |||
| 1277 | pub const MINSIGSTKSZ = 8192; | ||
| 1278 | pub const SIGSTKSZ = 16384; | ||
| 1279 | |||
| 1280 | pub const stack_t = extern struct { | ||
| 1281 | sp: [*]u8, | ||
| 1282 | size: isize, | ||
| 1283 | flags: i32, | ||
| 1284 | }; | ||
| 1285 | |||
| 1286 | pub const NSIG = 65; | ||
| 1287 | |||
| 1288 | pub const mcontext_t = vregs; | ||
| 1289 | |||
| 1290 | pub const ucontext_t = extern struct { | ||
| 1291 | link: ?*ucontext_t, | ||
| 1292 | sigmask: sigset_t, | ||
| 1293 | stack: stack_t, | ||
| 1294 | mcontext: mcontext_t, | ||
| 1295 | }; | ||
| 1296 | |||
| 1297 | // /system/develop/headers/posix/sys/stat.h | ||
| 1298 | |||
| 1299 | pub const Stat = extern struct { | ||
| 1300 | dev: dev_t, | ||
| 1301 | ino: ino_t, | ||
| 1302 | mode: mode_t, | ||
| 1303 | nlink: nlink_t, | ||
| 1304 | uid: uid_t, | ||
| 1305 | gid: gid_t, | ||
| 1306 | size: off_t, | ||
| 1307 | rdev: dev_t, | ||
| 1308 | blksize: blksize_t, | ||
| 1309 | atim: timespec, | ||
| 1310 | mtim: timespec, | ||
| 1311 | ctim: timespec, | ||
| 1312 | crtim: timespec, | ||
| 1313 | type: u32, | ||
| 1314 | blocks: blkcnt_t, | ||
| 1315 | |||
| 1316 | pub fn atime(self: @This()) timespec { | ||
| 1317 | return self.atim; | ||
| 1318 | } | ||
| 1319 | pub fn mtime(self: @This()) timespec { | ||
| 1320 | return self.mtim; | ||
| 1321 | } | ||
| 1322 | pub fn ctime(self: @This()) timespec { | ||
| 1323 | return self.ctim; | ||
| 1324 | } | ||
| 1325 | pub fn birthtime(self: @This()) timespec { | ||
| 1326 | return self.crtim; | ||
| 1327 | } | ||
| 1328 | }; | ||
| 1329 | |||
| 1330 | // /system/develop/headers/posix/sys/types.h | ||
| 1331 | |||
| 1332 | pub const blkcnt_t = i64; | ||
| 1333 | pub const blksize_t = i32; | ||
| 1334 | pub const fsblkcnt_t = i64; | ||
| 1335 | pub const fsfilcnt_t = i64; | ||
| 1336 | pub const off_t = i64; | ||
| 1337 | pub const ino_t = i64; | ||
| 1338 | pub const cnt_t = i32; | ||
| 1339 | pub const dev_t = i32; | ||
| 1340 | pub const pid_t = i32; | ||
| 1341 | pub const id_t = i32; | ||
| 1342 | |||
| 1343 | pub const uid_t = u32; | ||
| 1344 | pub const gid_t = u32; | ||
| 1345 | pub const mode_t = u32; | ||
| 1346 | pub const umode_t = u32; | ||
| 1347 | pub const nlink_t = i32; | ||
| 1348 | |||
| 1349 | pub const clockid_t = i32; | ||
| 1350 | pub const timer_t = *opaque {}; | ||
| 1351 | |||
| 1352 | // /system/develop/headers/posix/time.h | ||
| 1353 | |||
| 1354 | pub const clock_t = i32; | ||
| 1355 | pub const suseconds_t = i32; | ||
| 1356 | pub const useconds_t = u32; | ||
| 1357 | |||
| 1358 | pub const time_t = isize; | ||
| 1359 | |||
| 1360 | pub const CLOCKS_PER_SEC = 1_000_000; | ||
| 1361 | pub const CLK_TCK = CLOCKS_PER_SEC; | ||
| 1362 | pub const TIME_UTC = 1; | ||
| 1363 | |||
| 1364 | pub const CLOCK = struct { | ||
| 1365 | /// system-wide monotonic clock (aka system time) | ||
| 1366 | pub const MONOTONIC: clockid_t = 0; | ||
| 1367 | /// system-wide real time clock | ||
| 1368 | pub const REALTIME: clockid_t = -1; | ||
| 1369 | /// clock measuring the used CPU time of the current process | ||
| 1370 | pub const PROCESS_CPUTIME_ID: clockid_t = -2; | ||
| 1371 | /// clock measuring the used CPU time of the current thread | ||
| 1372 | pub const THREAD_CPUTIME_ID: clockid_t = -3; | ||
| 1373 | }; | ||
| 1374 | |||
| 1375 | pub const timespec = extern struct { | ||
| 1376 | /// seconds | ||
| 1377 | tv_sec: time_t, | ||
| 1378 | /// and nanoseconds | ||
| 1379 | tv_nsec: isize, | ||
| 1380 | }; | ||
| 1381 | |||
| 1382 | pub const itimerspec = extern struct { | ||
| 1383 | interval: timespec, | ||
| 1384 | value: timespec, | ||
| 1385 | }; | ||
| 1386 | |||
| 1387 | // /system/develop/headers/private/system/syscalls.h | ||
| 1388 | |||
| 1389 | pub extern "root" fn _kern_get_current_team() team_id; | ||
| 1390 | pub extern "root" fn _kern_open_dir(fd: fd_t, path: [*:0]const u8) fd_t; | ||
| 1391 | pub extern "root" fn _kern_read_dir(fd: fd_t, buffer: [*]u8, bufferSize: usize, maxCount: u32) isize; | ||
| 1392 | pub extern "root" fn _kern_rewind_dir(fd: fd_t) status_t; | ||
| 1393 | pub extern "root" fn _kern_read_stat(fd: fd_t, path: [*:0]const u8, traverseLink: bool, stat: *Stat, statSize: usize) status_t; |
lib/std/c/linux.zig deleted-358| ... | @@ -1,358 +0,0 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const native_abi = builtin.abi; | ||
| 4 | const native_arch = builtin.cpu.arch; | ||
| 5 | const linux = std.os.linux; | ||
| 6 | const iovec = std.posix.iovec; | ||
| 7 | const iovec_const = std.posix.iovec_const; | ||
| 8 | const FILE = std.c.FILE; | ||
| 9 | |||
| 10 | pub const AF = linux.AF; | ||
| 11 | pub const ARCH = linux.ARCH; | ||
| 12 | pub const CLOCK = linux.CLOCK; | ||
| 13 | pub const CPU_COUNT = linux.CPU_COUNT; | ||
| 14 | pub const E = linux.E; | ||
| 15 | pub const Elf_Symndx = linux.Elf_Symndx; | ||
| 16 | pub const F = linux.F; | ||
| 17 | pub const FD_CLOEXEC = linux.FD_CLOEXEC; | ||
| 18 | pub const F_OK = linux.F_OK; | ||
| 19 | pub const Flock = linux.Flock; | ||
| 20 | pub const HOST_NAME_MAX = linux.HOST_NAME_MAX; | ||
| 21 | pub const IFNAMESIZE = linux.IFNAMESIZE; | ||
| 22 | pub const IOV_MAX = linux.IOV_MAX; | ||
| 23 | pub const IPPROTO = linux.IPPROTO; | ||
| 24 | pub const LOCK = linux.LOCK; | ||
| 25 | pub const MADV = linux.MADV; | ||
| 26 | pub const MSF = linux.MSF; | ||
| 27 | pub const MMAP2_UNIT = linux.MMAP2_UNIT; | ||
| 28 | pub const MSG = linux.MSG; | ||
| 29 | pub const NAME_MAX = linux.NAME_MAX; | ||
| 30 | pub const PATH_MAX = linux.PATH_MAX; | ||
| 31 | pub const POLL = linux.POLL; | ||
| 32 | pub const PROT = linux.PROT; | ||
| 33 | pub const REG = linux.REG; | ||
| 34 | pub const RLIM = linux.RLIM; | ||
| 35 | pub const R_OK = linux.R_OK; | ||
| 36 | pub const S = linux.S; | ||
| 37 | pub const SA = linux.SA; | ||
| 38 | pub const SC = linux.SC; | ||
| 39 | pub const SEEK = linux.SEEK; | ||
| 40 | pub const SHUT = linux.SHUT; | ||
| 41 | pub const SIG = linux.SIG; | ||
| 42 | pub const SIOCGIFINDEX = linux.SIOCGIFINDEX; | ||
| 43 | pub const SO = linux.SO; | ||
| 44 | pub const SOCK = linux.SOCK; | ||
| 45 | pub const SOL = linux.SOL; | ||
| 46 | pub const STDERR_FILENO = linux.STDERR_FILENO; | ||
| 47 | pub const STDIN_FILENO = linux.STDIN_FILENO; | ||
| 48 | pub const STDOUT_FILENO = linux.STDOUT_FILENO; | ||
| 49 | pub const SYS = linux.SYS; | ||
| 50 | pub const Sigaction = linux.Sigaction; | ||
| 51 | pub const T = linux.T; | ||
| 52 | pub const TCP = linux.TCP; | ||
| 53 | pub const TCSA = linux.TCSA; | ||
| 54 | pub const TFD = linux.TFD; | ||
| 55 | pub const VDSO = linux.VDSO; | ||
| 56 | pub const W = linux.W; | ||
| 57 | pub const W_OK = linux.W_OK; | ||
| 58 | pub const X_OK = linux.X_OK; | ||
| 59 | pub const addrinfo = linux.addrinfo; | ||
| 60 | pub const blkcnt_t = linux.blkcnt_t; | ||
| 61 | pub const blksize_t = linux.blksize_t; | ||
| 62 | pub const clock_t = linux.clock_t; | ||
| 63 | pub const cpu_set_t = linux.cpu_set_t; | ||
| 64 | pub const dev_t = linux.dev_t; | ||
| 65 | pub const dl_phdr_info = linux.dl_phdr_info; | ||
| 66 | pub const empty_sigset = linux.empty_sigset; | ||
| 67 | pub const epoll_event = linux.epoll_event; | ||
| 68 | pub const fd_t = linux.fd_t; | ||
| 69 | pub const gid_t = linux.gid_t; | ||
| 70 | pub const ifreq = linux.ifreq; | ||
| 71 | pub const ino_t = linux.ino_t; | ||
| 72 | pub const itimerspec = linux.itimerspec; | ||
| 73 | pub const mcontext_t = linux.mcontext_t; | ||
| 74 | pub const mode_t = linux.mode_t; | ||
| 75 | pub const msghdr = linux.msghdr; | ||
| 76 | pub const msghdr_const = linux.msghdr_const; | ||
| 77 | pub const nfds_t = linux.nfds_t; | ||
| 78 | pub const nlink_t = linux.nlink_t; | ||
| 79 | pub const off_t = linux.off_t; | ||
| 80 | pub const perf_event_attr = linux.perf_event_attr; | ||
| 81 | pub const pid_t = linux.pid_t; | ||
| 82 | pub const pollfd = linux.pollfd; | ||
| 83 | pub const rlim_t = linux.rlim_t; | ||
| 84 | pub const rlimit = linux.rlimit; | ||
| 85 | pub const rlimit_resource = linux.rlimit_resource; | ||
| 86 | pub const rusage = linux.rusage; | ||
| 87 | pub const siginfo_t = linux.siginfo_t; | ||
| 88 | pub const sigset_t = linux.sigset_t; | ||
| 89 | pub const sockaddr = linux.sockaddr; | ||
| 90 | pub const socklen_t = linux.socklen_t; | ||
| 91 | pub const stack_t = linux.stack_t; | ||
| 92 | pub const time_t = linux.time_t; | ||
| 93 | pub const timespec = linux.timespec; | ||
| 94 | pub const timeval = linux.timeval; | ||
| 95 | pub const timezone = linux.timezone; | ||
| 96 | pub const ucontext_t = linux.ucontext_t; | ||
| 97 | pub const uid_t = linux.uid_t; | ||
| 98 | pub const user_desc = linux.user_desc; | ||
| 99 | pub const utsname = linux.utsname; | ||
| 100 | pub const winsize = linux.winsize; | ||
| 101 | pub const PR = linux.PR; | ||
| 102 | |||
| 103 | pub const _errno = switch (native_abi) { | ||
| 104 | .android => struct { | ||
| 105 | extern fn __errno() *c_int; | ||
| 106 | }.__errno, | ||
| 107 | else => struct { | ||
| 108 | extern "c" fn __errno_location() *c_int; | ||
| 109 | }.__errno_location, | ||
| 110 | }; | ||
| 111 | |||
| 112 | pub const Stat = switch (native_arch) { | ||
| 113 | .sparc64 => extern struct { | ||
| 114 | dev: u64, | ||
| 115 | __pad1: u16, | ||
| 116 | ino: ino_t, | ||
| 117 | mode: u32, | ||
| 118 | nlink: u32, | ||
| 119 | |||
| 120 | uid: u32, | ||
| 121 | gid: u32, | ||
| 122 | rdev: u64, | ||
| 123 | __pad2: u16, | ||
| 124 | |||
| 125 | size: off_t, | ||
| 126 | blksize: isize, | ||
| 127 | blocks: i64, | ||
| 128 | |||
| 129 | atim: timespec, | ||
| 130 | mtim: timespec, | ||
| 131 | ctim: timespec, | ||
| 132 | __reserved: [2]usize, | ||
| 133 | |||
| 134 | pub fn atime(self: @This()) timespec { | ||
| 135 | return self.atim; | ||
| 136 | } | ||
| 137 | |||
| 138 | pub fn mtime(self: @This()) timespec { | ||
| 139 | return self.mtim; | ||
| 140 | } | ||
| 141 | |||
| 142 | pub fn ctime(self: @This()) timespec { | ||
| 143 | return self.ctim; | ||
| 144 | } | ||
| 145 | }, | ||
| 146 | .mips, .mipsel => extern struct { | ||
| 147 | dev: dev_t, | ||
| 148 | __pad0: [2]u32, | ||
| 149 | ino: ino_t, | ||
| 150 | mode: mode_t, | ||
| 151 | nlink: nlink_t, | ||
| 152 | uid: uid_t, | ||
| 153 | gid: gid_t, | ||
| 154 | rdev: dev_t, | ||
| 155 | __pad1: [2]u32, | ||
| 156 | size: off_t, | ||
| 157 | atim: timespec, | ||
| 158 | mtim: timespec, | ||
| 159 | ctim: timespec, | ||
| 160 | blksize: blksize_t, | ||
| 161 | __pad3: u32, | ||
| 162 | blocks: blkcnt_t, | ||
| 163 | __pad4: [14]u32, | ||
| 164 | |||
| 165 | pub fn atime(self: @This()) timespec { | ||
| 166 | return self.atim; | ||
| 167 | } | ||
| 168 | |||
| 169 | pub fn mtime(self: @This()) timespec { | ||
| 170 | return self.mtim; | ||
| 171 | } | ||
| 172 | |||
| 173 | pub fn ctime(self: @This()) timespec { | ||
| 174 | return self.ctim; | ||
| 175 | } | ||
| 176 | }, | ||
| 177 | |||
| 178 | else => std.os.linux.Stat, // libc stat is the same as kernel stat. | ||
| 179 | }; | ||
| 180 | |||
| 181 | pub const AI = struct { | ||
| 182 | pub const PASSIVE = 0x01; | ||
| 183 | pub const CANONNAME = 0x02; | ||
| 184 | pub const NUMERICHOST = 0x04; | ||
| 185 | pub const V4MAPPED = 0x08; | ||
| 186 | pub const ALL = 0x10; | ||
| 187 | pub const ADDRCONFIG = 0x20; | ||
| 188 | pub const NUMERICSERV = 0x400; | ||
| 189 | }; | ||
| 190 | |||
| 191 | pub const NI = struct { | ||
| 192 | pub const NUMERICHOST = 0x01; | ||
| 193 | pub const NUMERICSERV = 0x02; | ||
| 194 | pub const NOFQDN = 0x04; | ||
| 195 | pub const NAMEREQD = 0x08; | ||
| 196 | pub const DGRAM = 0x10; | ||
| 197 | pub const NUMERICSCOPE = 0x100; | ||
| 198 | }; | ||
| 199 | |||
| 200 | pub const EAI = enum(c_int) { | ||
| 201 | BADFLAGS = -1, | ||
| 202 | NONAME = -2, | ||
| 203 | AGAIN = -3, | ||
| 204 | FAIL = -4, | ||
| 205 | FAMILY = -6, | ||
| 206 | SOCKTYPE = -7, | ||
| 207 | SERVICE = -8, | ||
| 208 | MEMORY = -10, | ||
| 209 | SYSTEM = -11, | ||
| 210 | OVERFLOW = -12, | ||
| 211 | |||
| 212 | NODATA = -5, | ||
| 213 | ADDRFAMILY = -9, | ||
| 214 | INPROGRESS = -100, | ||
| 215 | CANCELED = -101, | ||
| 216 | NOTCANCELED = -102, | ||
| 217 | ALLDONE = -103, | ||
| 218 | INTR = -104, | ||
| 219 | IDN_ENCODE = -105, | ||
| 220 | |||
| 221 | _, | ||
| 222 | }; | ||
| 223 | |||
| 224 | pub const passwd = extern struct { | ||
| 225 | pw_name: ?[*:0]const u8, // username | ||
| 226 | pw_passwd: ?[*:0]const u8, // user password | ||
| 227 | pw_uid: uid_t, // user ID | ||
| 228 | pw_gid: gid_t, // group ID | ||
| 229 | pw_gecos: ?[*:0]const u8, // user information | ||
| 230 | pw_dir: ?[*:0]const u8, // home directory | ||
| 231 | pw_shell: ?[*:0]const u8, // shell program | ||
| 232 | }; | ||
| 233 | |||
| 234 | pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd; | ||
| 235 | pub extern "c" fn getpwuid(uid: uid_t) ?*passwd; | ||
| 236 | |||
| 237 | pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; | ||
| 238 | pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; | ||
| 239 | pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int; | ||
| 240 | pub extern "c" fn fstatat64(dirfd: fd_t, noalias path: [*:0]const u8, noalias stat_buf: *Stat, flags: u32) c_int; | ||
| 241 | pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int; | ||
| 242 | pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int; | ||
| 243 | pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64; | ||
| 244 | pub extern "c" fn mmap64(addr: ?*align(std.mem.page_size) anyopaque, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: i64) *anyopaque; | ||
| 245 | pub extern "c" fn open64(path: [*:0]const u8, oflag: linux.O, ...) c_int; | ||
| 246 | pub extern "c" fn openat64(fd: c_int, path: [*:0]const u8, oflag: linux.O, ...) c_int; | ||
| 247 | pub extern "c" fn pread64(fd: fd_t, buf: [*]u8, nbyte: usize, offset: i64) isize; | ||
| 248 | pub extern "c" fn preadv64(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: i64) isize; | ||
| 249 | pub extern "c" fn pwrite64(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: i64) isize; | ||
| 250 | pub extern "c" fn pwritev64(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: i64) isize; | ||
| 251 | pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: usize) isize; | ||
| 252 | pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int; | ||
| 253 | |||
| 254 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | ||
| 255 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; | ||
| 256 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; | ||
| 257 | pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int; | ||
| 258 | pub extern "c" fn epoll_create1(flags: c_uint) c_int; | ||
| 259 | pub extern "c" fn epoll_wait(epfd: fd_t, events: [*]epoll_event, maxevents: c_uint, timeout: c_int) c_int; | ||
| 260 | pub extern "c" fn epoll_pwait( | ||
| 261 | epfd: fd_t, | ||
| 262 | events: [*]epoll_event, | ||
| 263 | maxevents: c_int, | ||
| 264 | timeout: c_int, | ||
| 265 | sigmask: *const sigset_t, | ||
| 266 | ) c_int; | ||
| 267 | pub extern "c" fn inotify_init1(flags: c_uint) c_int; | ||
| 268 | pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) c_int; | ||
| 269 | pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int; | ||
| 270 | |||
| 271 | /// See std.elf for constants for this | ||
| 272 | pub extern "c" fn getauxval(__type: c_ulong) c_ulong; | ||
| 273 | |||
| 274 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 275 | |||
| 276 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 277 | |||
| 278 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 279 | |||
| 280 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; | ||
| 281 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: linux.O) c_int; | ||
| 282 | |||
| 283 | pub extern "c" fn fallocate(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; | ||
| 284 | |||
| 285 | pub extern "c" fn sendfile( | ||
| 286 | out_fd: fd_t, | ||
| 287 | in_fd: fd_t, | ||
| 288 | offset: ?*off_t, | ||
| 289 | count: usize, | ||
| 290 | ) isize; | ||
| 291 | |||
| 292 | pub extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: c_uint) isize; | ||
| 293 | |||
| 294 | pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: c_uint) c_int; | ||
| 295 | |||
| 296 | pub extern "c" fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: *const rlimit, old_limit: *rlimit) c_int; | ||
| 297 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 298 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; | ||
| 299 | |||
| 300 | pub extern "c" fn mincore( | ||
| 301 | addr: *align(std.mem.page_size) anyopaque, | ||
| 302 | length: usize, | ||
| 303 | vec: [*]u8, | ||
| 304 | ) c_int; | ||
| 305 | |||
| 306 | pub extern "c" fn madvise( | ||
| 307 | addr: *align(std.mem.page_size) anyopaque, | ||
| 308 | length: usize, | ||
| 309 | advice: c_uint, | ||
| 310 | ) c_int; | ||
| 311 | |||
| 312 | pub const pthread_attr_t = extern struct { | ||
| 313 | __size: [56]u8, | ||
| 314 | __align: c_long, | ||
| 315 | }; | ||
| 316 | |||
| 317 | pub const pthread_key_t = c_uint; | ||
| 318 | pub const sem_t = extern struct { | ||
| 319 | __size: [__SIZEOF_SEM_T]u8 align(@alignOf(usize)), | ||
| 320 | }; | ||
| 321 | |||
| 322 | const __SIZEOF_SEM_T = 4 * @sizeOf(usize); | ||
| 323 | |||
| 324 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) c_int; | ||
| 325 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | ||
| 326 | |||
| 327 | pub const RTLD = struct { | ||
| 328 | pub const LAZY = 1; | ||
| 329 | pub const NOW = 2; | ||
| 330 | pub const NOLOAD = 4; | ||
| 331 | pub const NODELETE = 4096; | ||
| 332 | pub const GLOBAL = 256; | ||
| 333 | pub const LOCAL = 0; | ||
| 334 | }; | ||
| 335 | |||
| 336 | pub const dirent = extern struct { | ||
| 337 | ino: c_uint, | ||
| 338 | off: c_uint, | ||
| 339 | reclen: c_ushort, | ||
| 340 | type: u8, | ||
| 341 | name: [256]u8, | ||
| 342 | }; | ||
| 343 | pub const dirent64 = extern struct { | ||
| 344 | ino: c_ulong, | ||
| 345 | off: c_ulong, | ||
| 346 | reclen: c_ushort, | ||
| 347 | type: u8, | ||
| 348 | name: [256]u8, | ||
| 349 | }; | ||
| 350 | |||
| 351 | pub extern "c" fn timerfd_create(clockid: c_int, flags: c_int) c_int; | ||
| 352 | pub extern "c" fn timerfd_settime( | ||
| 353 | fd: c_int, | ||
| 354 | flags: c_int, | ||
| 355 | new_value: *const itimerspec, | ||
| 356 | old_value: ?*itimerspec, | ||
| 357 | ) c_int; | ||
| 358 | pub extern "c" fn timerfd_gettime(fd: c_int, curr_value: *itimerspec) c_int; | ||
lib/std/c/netbsd.zig+7-1173| ... | @@ -1,786 +1,14 @@ | ... | @@ -1,786 +1,14 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const assert = std.debug.assert; | 2 | const clock_t = std.c.clock_t; |
| 3 | const builtin = @import("builtin"); | 3 | const pid_t = std.c.pid_t; |
| 4 | const maxInt = std.math.maxInt; | 4 | const pthread_t = std.c.pthread_t; |
| 5 | const iovec = std.posix.iovec; | 5 | const sigval_t = std.c.sigval_t; |
| 6 | const iovec_const = std.posix.iovec_const; | 6 | const uid_t = std.c.uid_t; |
| 7 | const timezone = std.c.timezone; | ||
| 8 | const rusage = std.c.rusage; | ||
| 9 | 7 | ||
| 10 | extern "c" fn __errno() *c_int; | ||
| 11 | pub const _errno = __errno; | ||
| 12 | |||
| 13 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 14 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 15 | |||
| 16 | pub extern "c" fn _lwp_self() lwpid_t; | ||
| 17 | |||
| 18 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int; | ||
| 19 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ||
| 20 | |||
| 21 | pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | ||
| 22 | pub const getdents = __getdents30; | ||
| 23 | |||
| 24 | pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 25 | pub const sigaltstack = __sigaltstack14; | ||
| 26 | |||
| 27 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 28 | |||
| 29 | pub const pthread_spin_t = switch (builtin.cpu.arch) { | ||
| 30 | .aarch64, .aarch64_be, .aarch64_32 => u8, | ||
| 31 | .mips, .mipsel, .mips64, .mips64el => u32, | ||
| 32 | .powerpc, .powerpc64, .powerpc64le => i32, | ||
| 33 | .x86, .x86_64 => u8, | ||
| 34 | .arm, .armeb, .thumb, .thumbeb => i32, | ||
| 35 | .sparc, .sparcel, .sparc64 => u8, | ||
| 36 | .riscv32, .riscv64 => u32, | ||
| 37 | else => @compileError("undefined pthread_spin_t for this arch"), | ||
| 38 | }; | ||
| 39 | |||
| 40 | pub const padded_pthread_spin_t = switch (builtin.cpu.arch) { | ||
| 41 | .x86, .x86_64 => u32, | ||
| 42 | .sparc, .sparcel, .sparc64 => u32, | ||
| 43 | else => pthread_spin_t, | ||
| 44 | }; | ||
| 45 | |||
| 46 | pub const pthread_attr_t = extern struct { | ||
| 47 | pta_magic: u32, | ||
| 48 | pta_flags: i32, | ||
| 49 | pta_private: ?*anyopaque, | ||
| 50 | }; | ||
| 51 | |||
| 52 | pub const sem_t = ?*opaque {}; | ||
| 53 | |||
| 54 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int; | ||
| 55 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | ||
| 56 | |||
| 57 | pub const blkcnt_t = i64; | ||
| 58 | pub const blksize_t = i32; | ||
| 59 | pub const clock_t = u32; | ||
| 60 | pub const dev_t = u64; | ||
| 61 | pub const fd_t = i32; | ||
| 62 | pub const gid_t = u32; | ||
| 63 | pub const ino_t = u64; | ||
| 64 | pub const mode_t = u32; | ||
| 65 | pub const nlink_t = u32; | ||
| 66 | pub const off_t = i64; | ||
| 67 | pub const pid_t = i32; | ||
| 68 | pub const socklen_t = u32; | ||
| 69 | pub const time_t = i64; | ||
| 70 | pub const uid_t = u32; | ||
| 71 | pub const lwpid_t = i32; | 8 | pub const lwpid_t = i32; |
| 72 | pub const suseconds_t = c_int; | ||
| 73 | |||
| 74 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 75 | pub const Kevent = extern struct { | ||
| 76 | ident: usize, | ||
| 77 | filter: i32, | ||
| 78 | flags: u32, | ||
| 79 | fflags: u32, | ||
| 80 | data: i64, | ||
| 81 | udata: usize, | ||
| 82 | }; | ||
| 83 | |||
| 84 | pub const RTLD = struct { | ||
| 85 | pub const LAZY = 1; | ||
| 86 | pub const NOW = 2; | ||
| 87 | pub const GLOBAL = 0x100; | ||
| 88 | pub const LOCAL = 0x200; | ||
| 89 | pub const NODELETE = 0x01000; | ||
| 90 | pub const NOLOAD = 0x02000; | ||
| 91 | |||
| 92 | pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); | ||
| 93 | pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); | ||
| 94 | pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); | ||
| 95 | }; | ||
| 96 | |||
| 97 | pub const dl_phdr_info = extern struct { | ||
| 98 | dlpi_addr: usize, | ||
| 99 | dlpi_name: ?[*:0]const u8, | ||
| 100 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 101 | dlpi_phnum: u16, | ||
| 102 | }; | ||
| 103 | |||
| 104 | pub const Flock = extern struct { | ||
| 105 | start: off_t, | ||
| 106 | len: off_t, | ||
| 107 | pid: pid_t, | ||
| 108 | type: i16, | ||
| 109 | whence: i16, | ||
| 110 | }; | ||
| 111 | |||
| 112 | pub const addrinfo = extern struct { | ||
| 113 | flags: i32, | ||
| 114 | family: i32, | ||
| 115 | socktype: i32, | ||
| 116 | protocol: i32, | ||
| 117 | addrlen: socklen_t, | ||
| 118 | canonname: ?[*:0]u8, | ||
| 119 | addr: ?*sockaddr, | ||
| 120 | next: ?*addrinfo, | ||
| 121 | }; | ||
| 122 | |||
| 123 | pub const EAI = enum(c_int) { | ||
| 124 | /// address family for hostname not supported | ||
| 125 | ADDRFAMILY = 1, | ||
| 126 | |||
| 127 | /// name could not be resolved at this time | ||
| 128 | AGAIN = 2, | ||
| 129 | |||
| 130 | /// flags parameter had an invalid value | ||
| 131 | BADFLAGS = 3, | ||
| 132 | |||
| 133 | /// non-recoverable failure in name resolution | ||
| 134 | FAIL = 4, | ||
| 135 | |||
| 136 | /// address family not recognized | ||
| 137 | FAMILY = 5, | ||
| 138 | |||
| 139 | /// memory allocation failure | ||
| 140 | MEMORY = 6, | ||
| 141 | |||
| 142 | /// no address associated with hostname | ||
| 143 | NODATA = 7, | ||
| 144 | |||
| 145 | /// name does not resolve | ||
| 146 | NONAME = 8, | ||
| 147 | |||
| 148 | /// service not recognized for socket type | ||
| 149 | SERVICE = 9, | ||
| 150 | |||
| 151 | /// intended socket type was not recognized | ||
| 152 | SOCKTYPE = 10, | ||
| 153 | |||
| 154 | /// system error returned in errno | ||
| 155 | SYSTEM = 11, | ||
| 156 | |||
| 157 | /// invalid value for hints | ||
| 158 | BADHINTS = 12, | ||
| 159 | |||
| 160 | /// resolved protocol is unknown | ||
| 161 | PROTOCOL = 13, | ||
| 162 | |||
| 163 | /// argument buffer overflow | ||
| 164 | OVERFLOW = 14, | ||
| 165 | |||
| 166 | _, | ||
| 167 | }; | ||
| 168 | |||
| 169 | pub const EAI_MAX = 15; | ||
| 170 | |||
| 171 | pub const msghdr = extern struct { | ||
| 172 | /// optional address | ||
| 173 | msg_name: ?*sockaddr, | ||
| 174 | |||
| 175 | /// size of address | ||
| 176 | msg_namelen: socklen_t, | ||
| 177 | |||
| 178 | /// scatter/gather array | ||
| 179 | msg_iov: [*]iovec, | ||
| 180 | |||
| 181 | /// # elements in msg_iov | ||
| 182 | msg_iovlen: i32, | ||
| 183 | |||
| 184 | /// ancillary data | ||
| 185 | msg_control: ?*anyopaque, | ||
| 186 | |||
| 187 | /// ancillary data buffer len | ||
| 188 | msg_controllen: socklen_t, | ||
| 189 | |||
| 190 | /// flags on received message | ||
| 191 | msg_flags: i32, | ||
| 192 | }; | ||
| 193 | |||
| 194 | pub const msghdr_const = extern struct { | ||
| 195 | /// optional address | ||
| 196 | msg_name: ?*const sockaddr, | ||
| 197 | |||
| 198 | /// size of address | ||
| 199 | msg_namelen: socklen_t, | ||
| 200 | |||
| 201 | /// scatter/gather array | ||
| 202 | msg_iov: [*]const iovec_const, | ||
| 203 | |||
| 204 | /// # elements in msg_iov | ||
| 205 | msg_iovlen: i32, | ||
| 206 | |||
| 207 | /// ancillary data | ||
| 208 | msg_control: ?*const anyopaque, | ||
| 209 | |||
| 210 | /// ancillary data buffer len | ||
| 211 | msg_controllen: socklen_t, | ||
| 212 | |||
| 213 | /// flags on received message | ||
| 214 | msg_flags: i32, | ||
| 215 | }; | ||
| 216 | |||
| 217 | /// The stat structure used by libc. | ||
| 218 | pub const Stat = extern struct { | ||
| 219 | dev: dev_t, | ||
| 220 | mode: mode_t, | ||
| 221 | ino: ino_t, | ||
| 222 | nlink: nlink_t, | ||
| 223 | uid: uid_t, | ||
| 224 | gid: gid_t, | ||
| 225 | rdev: dev_t, | ||
| 226 | atim: timespec, | ||
| 227 | mtim: timespec, | ||
| 228 | ctim: timespec, | ||
| 229 | birthtim: timespec, | ||
| 230 | size: off_t, | ||
| 231 | blocks: blkcnt_t, | ||
| 232 | blksize: blksize_t, | ||
| 233 | flags: u32, | ||
| 234 | gen: u32, | ||
| 235 | __spare: [2]u32, | ||
| 236 | |||
| 237 | pub fn atime(self: @This()) timespec { | ||
| 238 | return self.atim; | ||
| 239 | } | ||
| 240 | |||
| 241 | pub fn mtime(self: @This()) timespec { | ||
| 242 | return self.mtim; | ||
| 243 | } | ||
| 244 | |||
| 245 | pub fn ctime(self: @This()) timespec { | ||
| 246 | return self.ctim; | ||
| 247 | } | ||
| 248 | |||
| 249 | pub fn birthtime(self: @This()) timespec { | ||
| 250 | return self.birthtim; | ||
| 251 | } | ||
| 252 | }; | ||
| 253 | |||
| 254 | pub const timespec = extern struct { | ||
| 255 | tv_sec: i64, | ||
| 256 | tv_nsec: isize, | ||
| 257 | }; | ||
| 258 | |||
| 259 | pub const timeval = extern struct { | ||
| 260 | /// seconds | ||
| 261 | tv_sec: time_t, | ||
| 262 | /// microseconds | ||
| 263 | tv_usec: suseconds_t, | ||
| 264 | }; | ||
| 265 | |||
| 266 | pub const MAXNAMLEN = 511; | ||
| 267 | |||
| 268 | pub const dirent = extern struct { | ||
| 269 | fileno: ino_t, | ||
| 270 | reclen: u16, | ||
| 271 | namlen: u16, | ||
| 272 | type: u8, | ||
| 273 | name: [MAXNAMLEN + 1]u8, | ||
| 274 | }; | ||
| 275 | |||
| 276 | pub const SOCK = struct { | ||
| 277 | pub const STREAM = 1; | ||
| 278 | pub const DGRAM = 2; | ||
| 279 | pub const RAW = 3; | ||
| 280 | pub const RDM = 4; | ||
| 281 | pub const SEQPACKET = 5; | ||
| 282 | pub const CONN_DGRAM = 6; | ||
| 283 | pub const DCCP = CONN_DGRAM; | ||
| 284 | |||
| 285 | pub const CLOEXEC = 0x10000000; | ||
| 286 | pub const NONBLOCK = 0x20000000; | ||
| 287 | pub const NOSIGPIPE = 0x40000000; | ||
| 288 | pub const FLAGS_MASK = 0xf0000000; | ||
| 289 | }; | ||
| 290 | |||
| 291 | pub const SO = struct { | ||
| 292 | pub const DEBUG = 0x0001; | ||
| 293 | pub const ACCEPTCONN = 0x0002; | ||
| 294 | pub const REUSEADDR = 0x0004; | ||
| 295 | pub const KEEPALIVE = 0x0008; | ||
| 296 | pub const DONTROUTE = 0x0010; | ||
| 297 | pub const BROADCAST = 0x0020; | ||
| 298 | pub const USELOOPBACK = 0x0040; | ||
| 299 | pub const LINGER = 0x0080; | ||
| 300 | pub const OOBINLINE = 0x0100; | ||
| 301 | pub const REUSEPORT = 0x0200; | ||
| 302 | pub const NOSIGPIPE = 0x0800; | ||
| 303 | pub const ACCEPTFILTER = 0x1000; | ||
| 304 | pub const TIMESTAMP = 0x2000; | ||
| 305 | pub const RERROR = 0x4000; | ||
| 306 | |||
| 307 | pub const SNDBUF = 0x1001; | ||
| 308 | pub const RCVBUF = 0x1002; | ||
| 309 | pub const SNDLOWAT = 0x1003; | ||
| 310 | pub const RCVLOWAT = 0x1004; | ||
| 311 | pub const ERROR = 0x1007; | ||
| 312 | pub const TYPE = 0x1008; | ||
| 313 | pub const OVERFLOWED = 0x1009; | ||
| 314 | |||
| 315 | pub const NOHEADER = 0x100a; | ||
| 316 | pub const SNDTIMEO = 0x100b; | ||
| 317 | pub const RCVTIMEO = 0x100c; | ||
| 318 | }; | ||
| 319 | |||
| 320 | pub const SOL = struct { | ||
| 321 | pub const SOCKET = 0xffff; | ||
| 322 | }; | ||
| 323 | |||
| 324 | pub const PF = struct { | ||
| 325 | pub const UNSPEC = AF.UNSPEC; | ||
| 326 | pub const LOCAL = AF.LOCAL; | ||
| 327 | pub const UNIX = PF.LOCAL; | ||
| 328 | pub const INET = AF.INET; | ||
| 329 | pub const IMPLINK = AF.IMPLINK; | ||
| 330 | pub const PUP = AF.PUP; | ||
| 331 | pub const CHAOS = AF.CHAOS; | ||
| 332 | pub const NS = AF.NS; | ||
| 333 | pub const ISO = AF.ISO; | ||
| 334 | pub const OSI = AF.ISO; | ||
| 335 | pub const ECMA = AF.ECMA; | ||
| 336 | pub const DATAKIT = AF.DATAKIT; | ||
| 337 | pub const CCITT = AF.CCITT; | ||
| 338 | pub const SNA = AF.SNA; | ||
| 339 | pub const DECnet = AF.DECnet; | ||
| 340 | pub const DLI = AF.DLI; | ||
| 341 | pub const LAT = AF.LAT; | ||
| 342 | pub const HYLINK = AF.HYLINK; | ||
| 343 | pub const APPLETALK = AF.APPLETALK; | ||
| 344 | pub const OROUTE = AF.OROUTE; | ||
| 345 | pub const LINK = AF.LINK; | ||
| 346 | pub const COIP = AF.COIP; | ||
| 347 | pub const CNT = AF.CNT; | ||
| 348 | pub const INET6 = AF.INET6; | ||
| 349 | pub const IPX = AF.IPX; | ||
| 350 | pub const ISDN = AF.ISDN; | ||
| 351 | pub const E164 = AF.E164; | ||
| 352 | pub const NATM = AF.NATM; | ||
| 353 | pub const ARP = AF.ARP; | ||
| 354 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 355 | pub const MPLS = AF.MPLS; | ||
| 356 | pub const ROUTE = AF.ROUTE; | ||
| 357 | pub const CAN = AF.CAN; | ||
| 358 | pub const ETHER = AF.ETHER; | ||
| 359 | pub const MAX = AF.MAX; | ||
| 360 | }; | ||
| 361 | |||
| 362 | pub const AF = struct { | ||
| 363 | pub const UNSPEC = 0; | ||
| 364 | pub const LOCAL = 1; | ||
| 365 | pub const UNIX = LOCAL; | ||
| 366 | pub const INET = 2; | ||
| 367 | pub const IMPLINK = 3; | ||
| 368 | pub const PUP = 4; | ||
| 369 | pub const CHAOS = 5; | ||
| 370 | pub const NS = 6; | ||
| 371 | pub const ISO = 7; | ||
| 372 | pub const OSI = ISO; | ||
| 373 | pub const ECMA = 8; | ||
| 374 | pub const DATAKIT = 9; | ||
| 375 | pub const CCITT = 10; | ||
| 376 | pub const SNA = 11; | ||
| 377 | pub const DECnet = 12; | ||
| 378 | pub const DLI = 13; | ||
| 379 | pub const LAT = 14; | ||
| 380 | pub const HYLINK = 15; | ||
| 381 | pub const APPLETALK = 16; | ||
| 382 | pub const OROUTE = 17; | ||
| 383 | pub const LINK = 18; | ||
| 384 | pub const COIP = 20; | ||
| 385 | pub const CNT = 21; | ||
| 386 | pub const IPX = 23; | ||
| 387 | pub const INET6 = 24; | ||
| 388 | pub const ISDN = 26; | ||
| 389 | pub const E164 = ISDN; | ||
| 390 | pub const NATM = 27; | ||
| 391 | pub const ARP = 28; | ||
| 392 | pub const BLUETOOTH = 31; | ||
| 393 | pub const IEEE80211 = 32; | ||
| 394 | pub const MPLS = 33; | ||
| 395 | pub const ROUTE = 34; | ||
| 396 | pub const CAN = 35; | ||
| 397 | pub const ETHER = 36; | ||
| 398 | pub const MAX = 37; | ||
| 399 | }; | ||
| 400 | |||
| 401 | pub const in_port_t = u16; | ||
| 402 | pub const sa_family_t = u8; | ||
| 403 | |||
| 404 | pub const sockaddr = extern struct { | ||
| 405 | /// total length | ||
| 406 | len: u8, | ||
| 407 | /// address family | ||
| 408 | family: sa_family_t, | ||
| 409 | /// actually longer; address value | ||
| 410 | data: [14]u8, | ||
| 411 | |||
| 412 | pub const SS_MAXSIZE = 128; | ||
| 413 | pub const storage = extern struct { | ||
| 414 | len: u8 align(8), | ||
| 415 | family: sa_family_t, | ||
| 416 | padding: [126]u8 = undefined, | ||
| 417 | |||
| 418 | comptime { | ||
| 419 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 420 | assert(@alignOf(storage) == 8); | ||
| 421 | } | ||
| 422 | }; | ||
| 423 | |||
| 424 | pub const in = extern struct { | ||
| 425 | len: u8 = @sizeOf(in), | ||
| 426 | family: sa_family_t = AF.INET, | ||
| 427 | port: in_port_t, | ||
| 428 | addr: u32, | ||
| 429 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 430 | }; | ||
| 431 | |||
| 432 | pub const in6 = extern struct { | ||
| 433 | len: u8 = @sizeOf(in6), | ||
| 434 | family: sa_family_t = AF.INET6, | ||
| 435 | port: in_port_t, | ||
| 436 | flowinfo: u32, | ||
| 437 | addr: [16]u8, | ||
| 438 | scope_id: u32, | ||
| 439 | }; | ||
| 440 | |||
| 441 | /// Definitions for UNIX IPC domain. | ||
| 442 | pub const un = extern struct { | ||
| 443 | /// total sockaddr length | ||
| 444 | len: u8 = @sizeOf(un), | ||
| 445 | |||
| 446 | family: sa_family_t = AF.LOCAL, | ||
| 447 | |||
| 448 | /// path name | ||
| 449 | path: [104]u8, | ||
| 450 | }; | ||
| 451 | }; | ||
| 452 | |||
| 453 | pub const IFNAMESIZE = 16; | ||
| 454 | |||
| 455 | pub const AI = struct { | ||
| 456 | /// get address to use bind() | ||
| 457 | pub const PASSIVE = 0x00000001; | ||
| 458 | /// fill ai_canonname | ||
| 459 | pub const CANONNAME = 0x00000002; | ||
| 460 | /// prevent host name resolution | ||
| 461 | pub const NUMERICHOST = 0x00000004; | ||
| 462 | /// prevent service name resolution | ||
| 463 | pub const NUMERICSERV = 0x00000008; | ||
| 464 | /// only if any address is assigned | ||
| 465 | pub const ADDRCONFIG = 0x00000400; | ||
| 466 | }; | ||
| 467 | |||
| 468 | pub const CTL = struct { | ||
| 469 | pub const KERN = 1; | ||
| 470 | pub const DEBUG = 5; | ||
| 471 | }; | ||
| 472 | |||
| 473 | pub const KERN = struct { | ||
| 474 | pub const PROC_ARGS = 48; // struct: process argv/env | ||
| 475 | pub const PROC_PATHNAME = 5; // path to executable | ||
| 476 | pub const IOV_MAX = 38; | ||
| 477 | }; | ||
| 478 | |||
| 479 | pub const PATH_MAX = 1024; | ||
| 480 | pub const NAME_MAX = 255; | ||
| 481 | pub const IOV_MAX = KERN.IOV_MAX; | ||
| 482 | |||
| 483 | pub const STDIN_FILENO = 0; | ||
| 484 | pub const STDOUT_FILENO = 1; | ||
| 485 | pub const STDERR_FILENO = 2; | ||
| 486 | |||
| 487 | pub const PROT = struct { | ||
| 488 | pub const NONE = 0; | ||
| 489 | pub const READ = 1; | ||
| 490 | pub const WRITE = 2; | ||
| 491 | pub const EXEC = 4; | ||
| 492 | }; | ||
| 493 | |||
| 494 | pub const CLOCK = struct { | ||
| 495 | pub const REALTIME = 0; | ||
| 496 | pub const VIRTUAL = 1; | ||
| 497 | pub const PROF = 2; | ||
| 498 | pub const MONOTONIC = 3; | ||
| 499 | pub const THREAD_CPUTIME_ID = 0x20000000; | ||
| 500 | pub const PROCESS_CPUTIME_ID = 0x40000000; | ||
| 501 | }; | ||
| 502 | |||
| 503 | pub const MSF = struct { | ||
| 504 | pub const ASYNC = 1; | ||
| 505 | pub const INVALIDATE = 2; | ||
| 506 | pub const SYNC = 4; | ||
| 507 | }; | ||
| 508 | |||
| 509 | pub const W = struct { | ||
| 510 | pub const NOHANG = 0x00000001; | ||
| 511 | pub const UNTRACED = 0x00000002; | ||
| 512 | pub const STOPPED = UNTRACED; | ||
| 513 | pub const CONTINUED = 0x00000010; | ||
| 514 | pub const NOWAIT = 0x00010000; | ||
| 515 | pub const EXITED = 0x00000020; | ||
| 516 | pub const TRAPPED = 0x00000040; | ||
| 517 | |||
| 518 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 519 | return @as(u8, @intCast((s >> 8) & 0xff)); | ||
| 520 | } | ||
| 521 | pub fn TERMSIG(s: u32) u32 { | ||
| 522 | return s & 0x7f; | ||
| 523 | } | ||
| 524 | pub fn STOPSIG(s: u32) u32 { | ||
| 525 | return EXITSTATUS(s); | ||
| 526 | } | ||
| 527 | pub fn IFEXITED(s: u32) bool { | ||
| 528 | return TERMSIG(s) == 0; | ||
| 529 | } | ||
| 530 | 9 | ||
| 531 | pub fn IFCONTINUED(s: u32) bool { | 10 | pub extern "c" fn _lwp_self() lwpid_t; |
| 532 | return ((s & 0x7f) == 0xffff); | 11 | pub extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int; |
| 533 | } | ||
| 534 | |||
| 535 | pub fn IFSTOPPED(s: u32) bool { | ||
| 536 | return ((s & 0x7f != 0x7f) and !IFCONTINUED(s)); | ||
| 537 | } | ||
| 538 | |||
| 539 | pub fn IFSIGNALED(s: u32) bool { | ||
| 540 | return !IFSTOPPED(s) and !IFCONTINUED(s) and !IFEXITED(s); | ||
| 541 | } | ||
| 542 | }; | ||
| 543 | |||
| 544 | pub const SA = struct { | ||
| 545 | pub const ONSTACK = 0x0001; | ||
| 546 | pub const RESTART = 0x0002; | ||
| 547 | pub const RESETHAND = 0x0004; | ||
| 548 | pub const NOCLDSTOP = 0x0008; | ||
| 549 | pub const NODEFER = 0x0010; | ||
| 550 | pub const NOCLDWAIT = 0x0020; | ||
| 551 | pub const SIGINFO = 0x0040; | ||
| 552 | }; | ||
| 553 | |||
| 554 | // access function | ||
| 555 | pub const F_OK = 0; // test for existence of file | ||
| 556 | pub const X_OK = 1; // test for execute or search permission | ||
| 557 | pub const W_OK = 2; // test for write permission | ||
| 558 | pub const R_OK = 4; // test for read permission | ||
| 559 | |||
| 560 | pub const F = struct { | ||
| 561 | pub const DUPFD = 0; | ||
| 562 | pub const GETFD = 1; | ||
| 563 | pub const SETFD = 2; | ||
| 564 | pub const GETFL = 3; | ||
| 565 | pub const SETFL = 4; | ||
| 566 | pub const GETOWN = 5; | ||
| 567 | pub const SETOWN = 6; | ||
| 568 | pub const GETLK = 7; | ||
| 569 | pub const SETLK = 8; | ||
| 570 | pub const SETLKW = 9; | ||
| 571 | pub const CLOSEM = 10; | ||
| 572 | pub const MAXFD = 11; | ||
| 573 | pub const DUPFD_CLOEXEC = 12; | ||
| 574 | pub const GETNOSIGPIPE = 13; | ||
| 575 | pub const SETNOSIGPIPE = 14; | ||
| 576 | pub const GETPATH = 15; | ||
| 577 | |||
| 578 | pub const RDLCK = 1; | ||
| 579 | pub const WRLCK = 3; | ||
| 580 | pub const UNLCK = 2; | ||
| 581 | }; | ||
| 582 | |||
| 583 | pub const LOCK = struct { | ||
| 584 | pub const SH = 1; | ||
| 585 | pub const EX = 2; | ||
| 586 | pub const UN = 8; | ||
| 587 | pub const NB = 4; | ||
| 588 | }; | ||
| 589 | |||
| 590 | pub const FD_CLOEXEC = 1; | ||
| 591 | |||
| 592 | pub const SEEK = struct { | ||
| 593 | pub const SET = 0; | ||
| 594 | pub const CUR = 1; | ||
| 595 | pub const END = 2; | ||
| 596 | }; | ||
| 597 | |||
| 598 | pub const DT = struct { | ||
| 599 | pub const UNKNOWN = 0; | ||
| 600 | pub const FIFO = 1; | ||
| 601 | pub const CHR = 2; | ||
| 602 | pub const DIR = 4; | ||
| 603 | pub const BLK = 6; | ||
| 604 | pub const REG = 8; | ||
| 605 | pub const LNK = 10; | ||
| 606 | pub const SOCK = 12; | ||
| 607 | pub const WHT = 14; | ||
| 608 | }; | ||
| 609 | |||
| 610 | /// add event to kq (implies enable) | ||
| 611 | pub const EV_ADD = 0x0001; | ||
| 612 | |||
| 613 | /// delete event from kq | ||
| 614 | pub const EV_DELETE = 0x0002; | ||
| 615 | |||
| 616 | /// enable event | ||
| 617 | pub const EV_ENABLE = 0x0004; | ||
| 618 | |||
| 619 | /// disable event (not reported) | ||
| 620 | pub const EV_DISABLE = 0x0008; | ||
| 621 | |||
| 622 | /// only report one occurrence | ||
| 623 | pub const EV_ONESHOT = 0x0010; | ||
| 624 | |||
| 625 | /// clear event state after reporting | ||
| 626 | pub const EV_CLEAR = 0x0020; | ||
| 627 | |||
| 628 | /// force immediate event output | ||
| 629 | /// ... with or without EV_ERROR | ||
| 630 | /// ... use KEVENT_FLAG_ERROR_EVENTS | ||
| 631 | /// on syscalls supporting flags | ||
| 632 | pub const EV_RECEIPT = 0x0040; | ||
| 633 | |||
| 634 | /// disable event after reporting | ||
| 635 | pub const EV_DISPATCH = 0x0080; | ||
| 636 | |||
| 637 | pub const EVFILT_READ = 0; | ||
| 638 | pub const EVFILT_WRITE = 1; | ||
| 639 | |||
| 640 | /// attached to aio requests | ||
| 641 | pub const EVFILT_AIO = 2; | ||
| 642 | |||
| 643 | /// attached to vnodes | ||
| 644 | pub const EVFILT_VNODE = 3; | ||
| 645 | |||
| 646 | /// attached to struct proc | ||
| 647 | pub const EVFILT_PROC = 4; | ||
| 648 | |||
| 649 | /// attached to struct proc | ||
| 650 | pub const EVFILT_SIGNAL = 5; | ||
| 651 | |||
| 652 | /// timers | ||
| 653 | pub const EVFILT_TIMER = 6; | ||
| 654 | |||
| 655 | /// Filesystem events | ||
| 656 | pub const EVFILT_FS = 7; | ||
| 657 | |||
| 658 | /// User events | ||
| 659 | pub const EVFILT_USER = 1; | ||
| 660 | |||
| 661 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. | ||
| 662 | pub const NOTE_TRIGGER = 0x08000000; | ||
| 663 | |||
| 664 | /// low water mark | ||
| 665 | pub const NOTE_LOWAT = 0x00000001; | ||
| 666 | |||
| 667 | /// vnode was removed | ||
| 668 | pub const NOTE_DELETE = 0x00000001; | ||
| 669 | |||
| 670 | /// data contents changed | ||
| 671 | pub const NOTE_WRITE = 0x00000002; | ||
| 672 | |||
| 673 | /// size increased | ||
| 674 | pub const NOTE_EXTEND = 0x00000004; | ||
| 675 | |||
| 676 | /// attributes changed | ||
| 677 | pub const NOTE_ATTRIB = 0x00000008; | ||
| 678 | |||
| 679 | /// link count changed | ||
| 680 | pub const NOTE_LINK = 0x00000010; | ||
| 681 | |||
| 682 | /// vnode was renamed | ||
| 683 | pub const NOTE_RENAME = 0x00000020; | ||
| 684 | |||
| 685 | /// vnode access was revoked | ||
| 686 | pub const NOTE_REVOKE = 0x00000040; | ||
| 687 | |||
| 688 | /// process exited | ||
| 689 | pub const NOTE_EXIT = 0x80000000; | ||
| 690 | |||
| 691 | /// process forked | ||
| 692 | pub const NOTE_FORK = 0x40000000; | ||
| 693 | |||
| 694 | /// process exec'd | ||
| 695 | pub const NOTE_EXEC = 0x20000000; | ||
| 696 | |||
| 697 | /// mask for signal & exit status | ||
| 698 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 699 | pub const NOTE_PCTRLMASK = 0xf0000000; | ||
| 700 | |||
| 701 | pub const T = struct { | ||
| 702 | pub const IOCCBRK = 0x2000747a; | ||
| 703 | pub const IOCCDTR = 0x20007478; | ||
| 704 | pub const IOCCONS = 0x80047462; | ||
| 705 | pub const IOCDCDTIMESTAMP = 0x40107458; | ||
| 706 | pub const IOCDRAIN = 0x2000745e; | ||
| 707 | pub const IOCEXCL = 0x2000740d; | ||
| 708 | pub const IOCEXT = 0x80047460; | ||
| 709 | pub const IOCFLAG_CDTRCTS = 0x10; | ||
| 710 | pub const IOCFLAG_CLOCAL = 0x2; | ||
| 711 | pub const IOCFLAG_CRTSCTS = 0x4; | ||
| 712 | pub const IOCFLAG_MDMBUF = 0x8; | ||
| 713 | pub const IOCFLAG_SOFTCAR = 0x1; | ||
| 714 | pub const IOCFLUSH = 0x80047410; | ||
| 715 | pub const IOCGETA = 0x402c7413; | ||
| 716 | pub const IOCGETD = 0x4004741a; | ||
| 717 | pub const IOCGFLAGS = 0x4004745d; | ||
| 718 | pub const IOCGLINED = 0x40207442; | ||
| 719 | pub const IOCGPGRP = 0x40047477; | ||
| 720 | pub const IOCGQSIZE = 0x40047481; | ||
| 721 | pub const IOCGRANTPT = 0x20007447; | ||
| 722 | pub const IOCGSID = 0x40047463; | ||
| 723 | pub const IOCGSIZE = 0x40087468; | ||
| 724 | pub const IOCGWINSZ = 0x40087468; | ||
| 725 | pub const IOCMBIC = 0x8004746b; | ||
| 726 | pub const IOCMBIS = 0x8004746c; | ||
| 727 | pub const IOCMGET = 0x4004746a; | ||
| 728 | pub const IOCMSET = 0x8004746d; | ||
| 729 | pub const IOCM_CAR = 0x40; | ||
| 730 | pub const IOCM_CD = 0x40; | ||
| 731 | pub const IOCM_CTS = 0x20; | ||
| 732 | pub const IOCM_DSR = 0x100; | ||
| 733 | pub const IOCM_DTR = 0x2; | ||
| 734 | pub const IOCM_LE = 0x1; | ||
| 735 | pub const IOCM_RI = 0x80; | ||
| 736 | pub const IOCM_RNG = 0x80; | ||
| 737 | pub const IOCM_RTS = 0x4; | ||
| 738 | pub const IOCM_SR = 0x10; | ||
| 739 | pub const IOCM_ST = 0x8; | ||
| 740 | pub const IOCNOTTY = 0x20007471; | ||
| 741 | pub const IOCNXCL = 0x2000740e; | ||
| 742 | pub const IOCOUTQ = 0x40047473; | ||
| 743 | pub const IOCPKT = 0x80047470; | ||
| 744 | pub const IOCPKT_DATA = 0x0; | ||
| 745 | pub const IOCPKT_DOSTOP = 0x20; | ||
| 746 | pub const IOCPKT_FLUSHREAD = 0x1; | ||
| 747 | pub const IOCPKT_FLUSHWRITE = 0x2; | ||
| 748 | pub const IOCPKT_IOCTL = 0x40; | ||
| 749 | pub const IOCPKT_NOSTOP = 0x10; | ||
| 750 | pub const IOCPKT_START = 0x8; | ||
| 751 | pub const IOCPKT_STOP = 0x4; | ||
| 752 | pub const IOCPTMGET = 0x40287446; | ||
| 753 | pub const IOCPTSNAME = 0x40287448; | ||
| 754 | pub const IOCRCVFRAME = 0x80087445; | ||
| 755 | pub const IOCREMOTE = 0x80047469; | ||
| 756 | pub const IOCSBRK = 0x2000747b; | ||
| 757 | pub const IOCSCTTY = 0x20007461; | ||
| 758 | pub const IOCSDTR = 0x20007479; | ||
| 759 | pub const IOCSETA = 0x802c7414; | ||
| 760 | pub const IOCSETAF = 0x802c7416; | ||
| 761 | pub const IOCSETAW = 0x802c7415; | ||
| 762 | pub const IOCSETD = 0x8004741b; | ||
| 763 | pub const IOCSFLAGS = 0x8004745c; | ||
| 764 | pub const IOCSIG = 0x2000745f; | ||
| 765 | pub const IOCSLINED = 0x80207443; | ||
| 766 | pub const IOCSPGRP = 0x80047476; | ||
| 767 | pub const IOCSQSIZE = 0x80047480; | ||
| 768 | pub const IOCSSIZE = 0x80087467; | ||
| 769 | pub const IOCSTART = 0x2000746e; | ||
| 770 | pub const IOCSTAT = 0x80047465; | ||
| 771 | pub const IOCSTI = 0x80017472; | ||
| 772 | pub const IOCSTOP = 0x2000746f; | ||
| 773 | pub const IOCSWINSZ = 0x80087467; | ||
| 774 | pub const IOCUCNTL = 0x80047466; | ||
| 775 | pub const IOCXMTFRAME = 0x80087444; | ||
| 776 | }; | ||
| 777 | |||
| 778 | pub const TCSA = enum(c_uint) { | ||
| 779 | NOW, | ||
| 780 | DRAIN, | ||
| 781 | FLUSH, | ||
| 782 | _, | ||
| 783 | }; | ||
| 784 | 12 | ||
| 785 | pub const TCIFLUSH = 1; | 13 | pub const TCIFLUSH = 1; |
| 786 | pub const TCOFLUSH = 2; | 14 | pub const TCOFLUSH = 2; |
| ... | @@ -790,104 +18,6 @@ pub const TCOON = 2; | ... | @@ -790,104 +18,6 @@ pub const TCOON = 2; |
| 790 | pub const TCIOFF = 3; | 18 | pub const TCIOFF = 3; |
| 791 | pub const TCION = 4; | 19 | pub const TCION = 4; |
| 792 | 20 | ||
| 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 = struct { | ||
| 803 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 804 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 805 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 806 | |||
| 807 | pub const WORDS = 4; | ||
| 808 | pub const MAXSIG = 128; | ||
| 809 | |||
| 810 | pub const BLOCK = 1; | ||
| 811 | pub const UNBLOCK = 2; | ||
| 812 | pub const SETMASK = 3; | ||
| 813 | |||
| 814 | pub const HUP = 1; | ||
| 815 | pub const INT = 2; | ||
| 816 | pub const QUIT = 3; | ||
| 817 | pub const ILL = 4; | ||
| 818 | pub const TRAP = 5; | ||
| 819 | pub const ABRT = 6; | ||
| 820 | pub const IOT = ABRT; | ||
| 821 | pub const EMT = 7; | ||
| 822 | pub const FPE = 8; | ||
| 823 | pub const KILL = 9; | ||
| 824 | pub const BUS = 10; | ||
| 825 | pub const SEGV = 11; | ||
| 826 | pub const SYS = 12; | ||
| 827 | pub const PIPE = 13; | ||
| 828 | pub const ALRM = 14; | ||
| 829 | pub const TERM = 15; | ||
| 830 | pub const URG = 16; | ||
| 831 | pub const STOP = 17; | ||
| 832 | pub const TSTP = 18; | ||
| 833 | pub const CONT = 19; | ||
| 834 | pub const CHLD = 20; | ||
| 835 | pub const TTIN = 21; | ||
| 836 | pub const TTOU = 22; | ||
| 837 | pub const IO = 23; | ||
| 838 | pub const XCPU = 24; | ||
| 839 | pub const XFSZ = 25; | ||
| 840 | pub const VTALRM = 26; | ||
| 841 | pub const PROF = 27; | ||
| 842 | pub const WINCH = 28; | ||
| 843 | pub const INFO = 29; | ||
| 844 | pub const USR1 = 30; | ||
| 845 | pub const USR2 = 31; | ||
| 846 | pub const PWR = 32; | ||
| 847 | |||
| 848 | pub const RTMIN = 33; | ||
| 849 | pub const RTMAX = 63; | ||
| 850 | |||
| 851 | pub inline fn IDX(sig: usize) usize { | ||
| 852 | return sig - 1; | ||
| 853 | } | ||
| 854 | pub inline fn WORD(sig: usize) usize { | ||
| 855 | return IDX(sig) >> 5; | ||
| 856 | } | ||
| 857 | pub inline fn BIT(sig: usize) usize { | ||
| 858 | return 1 << (IDX(sig) & 31); | ||
| 859 | } | ||
| 860 | pub inline fn VALID(sig: usize) usize { | ||
| 861 | return sig <= MAXSIG and sig > 0; | ||
| 862 | } | ||
| 863 | }; | ||
| 864 | |||
| 865 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 866 | pub const Sigaction = extern struct { | ||
| 867 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 868 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 869 | |||
| 870 | /// signal handler | ||
| 871 | handler: extern union { | ||
| 872 | handler: ?handler_fn, | ||
| 873 | sigaction: ?sigaction_fn, | ||
| 874 | }, | ||
| 875 | /// signal mask to apply | ||
| 876 | mask: sigset_t, | ||
| 877 | /// signal options | ||
| 878 | flags: c_uint, | ||
| 879 | }; | ||
| 880 | |||
| 881 | pub const sigval_t = extern union { | ||
| 882 | int: i32, | ||
| 883 | ptr: ?*anyopaque, | ||
| 884 | }; | ||
| 885 | |||
| 886 | pub const siginfo_t = extern union { | ||
| 887 | pad: [128]u8, | ||
| 888 | info: _ksiginfo, | ||
| 889 | }; | ||
| 890 | |||
| 891 | pub const _ksiginfo = extern struct { | 21 | pub const _ksiginfo = extern struct { |
| 892 | signo: i32, | 22 | signo: i32, |
| 893 | code: i32, | 23 | code: i32, |
| ... | @@ -933,85 +63,6 @@ pub const _ksiginfo = extern struct { | ... | @@ -933,85 +63,6 @@ pub const _ksiginfo = extern struct { |
| 933 | } align(@sizeOf(usize)), | 63 | } align(@sizeOf(usize)), |
| 934 | }; | 64 | }; |
| 935 | 65 | ||
| 936 | pub const sigset_t = extern struct { | ||
| 937 | __bits: [SIG.WORDS]u32, | ||
| 938 | }; | ||
| 939 | |||
| 940 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS }; | ||
| 941 | |||
| 942 | pub const mcontext_t = switch (builtin.cpu.arch) { | ||
| 943 | .aarch64 => extern struct { | ||
| 944 | gregs: [35]u64, | ||
| 945 | fregs: [528]u8 align(16), | ||
| 946 | spare: [8]u64, | ||
| 947 | }, | ||
| 948 | .x86_64 => extern struct { | ||
| 949 | gregs: [26]u64, | ||
| 950 | mc_tlsbase: u64, | ||
| 951 | fpregs: [512]u8 align(8), | ||
| 952 | }, | ||
| 953 | else => struct {}, | ||
| 954 | }; | ||
| 955 | |||
| 956 | pub const REG = switch (builtin.cpu.arch) { | ||
| 957 | .aarch64 => struct { | ||
| 958 | pub const FP = 29; | ||
| 959 | pub const SP = 31; | ||
| 960 | pub const PC = 32; | ||
| 961 | }, | ||
| 962 | .arm => struct { | ||
| 963 | pub const FP = 11; | ||
| 964 | pub const SP = 13; | ||
| 965 | pub const PC = 15; | ||
| 966 | }, | ||
| 967 | .x86_64 => struct { | ||
| 968 | pub const RDI = 0; | ||
| 969 | pub const RSI = 1; | ||
| 970 | pub const RDX = 2; | ||
| 971 | pub const RCX = 3; | ||
| 972 | pub const R8 = 4; | ||
| 973 | pub const R9 = 5; | ||
| 974 | pub const R10 = 6; | ||
| 975 | pub const R11 = 7; | ||
| 976 | pub const R12 = 8; | ||
| 977 | pub const R13 = 9; | ||
| 978 | pub const R14 = 10; | ||
| 979 | pub const R15 = 11; | ||
| 980 | pub const RBP = 12; | ||
| 981 | pub const RBX = 13; | ||
| 982 | pub const RAX = 14; | ||
| 983 | pub const GS = 15; | ||
| 984 | pub const FS = 16; | ||
| 985 | pub const ES = 17; | ||
| 986 | pub const DS = 18; | ||
| 987 | pub const TRAPNO = 19; | ||
| 988 | pub const ERR = 20; | ||
| 989 | pub const RIP = 21; | ||
| 990 | pub const CS = 22; | ||
| 991 | pub const RFLAGS = 23; | ||
| 992 | pub const RSP = 24; | ||
| 993 | pub const SS = 25; | ||
| 994 | }, | ||
| 995 | else => struct {}, | ||
| 996 | }; | ||
| 997 | |||
| 998 | pub const ucontext_t = extern struct { | ||
| 999 | flags: u32, | ||
| 1000 | link: ?*ucontext_t, | ||
| 1001 | sigmask: sigset_t, | ||
| 1002 | stack: stack_t, | ||
| 1003 | mcontext: mcontext_t, | ||
| 1004 | __pad: [ | ||
| 1005 | switch (builtin.cpu.arch) { | ||
| 1006 | .x86 => 4, | ||
| 1007 | .mips, .mipsel, .mips64, .mips64el => 14, | ||
| 1008 | .arm, .armeb, .thumb, .thumbeb => 1, | ||
| 1009 | .sparc, .sparcel, .sparc64 => if (@sizeOf(usize) == 4) 43 else 8, | ||
| 1010 | else => 0, | ||
| 1011 | } | ||
| 1012 | ]u32, | ||
| 1013 | }; | ||
| 1014 | |||
| 1015 | pub const E = enum(u16) { | 66 | pub const E = enum(u16) { |
| 1016 | /// No error occurred. | 67 | /// No error occurred. |
| 1017 | SUCCESS = 0, | 68 | SUCCESS = 0, |
| ... | @@ -1150,220 +201,3 @@ pub const E = enum(u16) { | ... | @@ -1150,220 +201,3 @@ pub const E = enum(u16) { |
| 1150 | 201 | ||
| 1151 | _, | 202 | _, |
| 1152 | }; | 203 | }; |
| 1153 | |||
| 1154 | pub const MINSIGSTKSZ = 8192; | ||
| 1155 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; | ||
| 1156 | |||
| 1157 | pub const SS_ONSTACK = 1; | ||
| 1158 | pub const SS_DISABLE = 4; | ||
| 1159 | |||
| 1160 | pub const stack_t = extern struct { | ||
| 1161 | sp: [*]u8, | ||
| 1162 | size: isize, | ||
| 1163 | flags: i32, | ||
| 1164 | }; | ||
| 1165 | |||
| 1166 | pub const S = struct { | ||
| 1167 | pub const IFMT = 0o170000; | ||
| 1168 | |||
| 1169 | pub const IFIFO = 0o010000; | ||
| 1170 | pub const IFCHR = 0o020000; | ||
| 1171 | pub const IFDIR = 0o040000; | ||
| 1172 | pub const IFBLK = 0o060000; | ||
| 1173 | pub const IFREG = 0o100000; | ||
| 1174 | pub const IFLNK = 0o120000; | ||
| 1175 | pub const IFSOCK = 0o140000; | ||
| 1176 | pub const IFWHT = 0o160000; | ||
| 1177 | |||
| 1178 | pub const ISUID = 0o4000; | ||
| 1179 | pub const ISGID = 0o2000; | ||
| 1180 | pub const ISVTX = 0o1000; | ||
| 1181 | pub const IRWXU = 0o700; | ||
| 1182 | pub const IRUSR = 0o400; | ||
| 1183 | pub const IWUSR = 0o200; | ||
| 1184 | pub const IXUSR = 0o100; | ||
| 1185 | pub const IRWXG = 0o070; | ||
| 1186 | pub const IRGRP = 0o040; | ||
| 1187 | pub const IWGRP = 0o020; | ||
| 1188 | pub const IXGRP = 0o010; | ||
| 1189 | pub const IRWXO = 0o007; | ||
| 1190 | pub const IROTH = 0o004; | ||
| 1191 | pub const IWOTH = 0o002; | ||
| 1192 | pub const IXOTH = 0o001; | ||
| 1193 | |||
| 1194 | pub fn ISFIFO(m: u32) bool { | ||
| 1195 | return m & IFMT == IFIFO; | ||
| 1196 | } | ||
| 1197 | |||
| 1198 | pub fn ISCHR(m: u32) bool { | ||
| 1199 | return m & IFMT == IFCHR; | ||
| 1200 | } | ||
| 1201 | |||
| 1202 | pub fn ISDIR(m: u32) bool { | ||
| 1203 | return m & IFMT == IFDIR; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | pub fn ISBLK(m: u32) bool { | ||
| 1207 | return m & IFMT == IFBLK; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | pub fn ISREG(m: u32) bool { | ||
| 1211 | return m & IFMT == IFREG; | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | pub fn ISLNK(m: u32) bool { | ||
| 1215 | return m & IFMT == IFLNK; | ||
| 1216 | } | ||
| 1217 | |||
| 1218 | pub fn ISSOCK(m: u32) bool { | ||
| 1219 | return m & IFMT == IFSOCK; | ||
| 1220 | } | ||
| 1221 | |||
| 1222 | pub fn IWHT(m: u32) bool { | ||
| 1223 | return m & IFMT == IFWHT; | ||
| 1224 | } | ||
| 1225 | }; | ||
| 1226 | |||
| 1227 | pub const HOST_NAME_MAX = 255; | ||
| 1228 | |||
| 1229 | pub const IPPROTO = struct { | ||
| 1230 | /// dummy for IP | ||
| 1231 | pub const IP = 0; | ||
| 1232 | /// IP6 hop-by-hop options | ||
| 1233 | pub const HOPOPTS = 0; | ||
| 1234 | /// control message protocol | ||
| 1235 | pub const ICMP = 1; | ||
| 1236 | /// group mgmt protocol | ||
| 1237 | pub const IGMP = 2; | ||
| 1238 | /// gateway^2 (deprecated) | ||
| 1239 | pub const GGP = 3; | ||
| 1240 | /// IP header | ||
| 1241 | pub const IPV4 = 4; | ||
| 1242 | /// IP inside IP | ||
| 1243 | pub const IPIP = 4; | ||
| 1244 | /// tcp | ||
| 1245 | pub const TCP = 6; | ||
| 1246 | /// exterior gateway protocol | ||
| 1247 | pub const EGP = 8; | ||
| 1248 | /// pup | ||
| 1249 | pub const PUP = 12; | ||
| 1250 | /// user datagram protocol | ||
| 1251 | pub const UDP = 17; | ||
| 1252 | /// xns idp | ||
| 1253 | pub const IDP = 22; | ||
| 1254 | /// tp-4 w/ class negotiation | ||
| 1255 | pub const TP = 29; | ||
| 1256 | /// DCCP | ||
| 1257 | pub const DCCP = 33; | ||
| 1258 | /// IP6 header | ||
| 1259 | pub const IPV6 = 41; | ||
| 1260 | /// IP6 routing header | ||
| 1261 | pub const ROUTING = 43; | ||
| 1262 | /// IP6 fragmentation header | ||
| 1263 | pub const FRAGMENT = 44; | ||
| 1264 | /// resource reservation | ||
| 1265 | pub const RSVP = 46; | ||
| 1266 | /// GRE encaps RFC 1701 | ||
| 1267 | pub const GRE = 47; | ||
| 1268 | /// encap. security payload | ||
| 1269 | pub const ESP = 50; | ||
| 1270 | /// authentication header | ||
| 1271 | pub const AH = 51; | ||
| 1272 | /// IP Mobility RFC 2004 | ||
| 1273 | pub const MOBILE = 55; | ||
| 1274 | /// IPv6 ICMP | ||
| 1275 | pub const IPV6_ICMP = 58; | ||
| 1276 | /// ICMP6 | ||
| 1277 | pub const ICMPV6 = 58; | ||
| 1278 | /// IP6 no next header | ||
| 1279 | pub const NONE = 59; | ||
| 1280 | /// IP6 destination option | ||
| 1281 | pub const DSTOPTS = 60; | ||
| 1282 | /// ISO cnlp | ||
| 1283 | pub const EON = 80; | ||
| 1284 | /// Ethernet-in-IP | ||
| 1285 | pub const ETHERIP = 97; | ||
| 1286 | /// encapsulation header | ||
| 1287 | pub const ENCAP = 98; | ||
| 1288 | /// Protocol indep. multicast | ||
| 1289 | pub const PIM = 103; | ||
| 1290 | /// IP Payload Comp. Protocol | ||
| 1291 | pub const IPCOMP = 108; | ||
| 1292 | /// VRRP RFC 2338 | ||
| 1293 | pub const VRRP = 112; | ||
| 1294 | /// Common Address Resolution Protocol | ||
| 1295 | pub const CARP = 112; | ||
| 1296 | /// L2TPv3 | ||
| 1297 | pub const L2TP = 115; | ||
| 1298 | /// SCTP | ||
| 1299 | pub const SCTP = 132; | ||
| 1300 | /// PFSYNC | ||
| 1301 | pub const PFSYNC = 240; | ||
| 1302 | /// raw IP packet | ||
| 1303 | pub const RAW = 255; | ||
| 1304 | }; | ||
| 1305 | |||
| 1306 | pub const rlimit_resource = enum(c_int) { | ||
| 1307 | CPU = 0, | ||
| 1308 | FSIZE = 1, | ||
| 1309 | DATA = 2, | ||
| 1310 | STACK = 3, | ||
| 1311 | CORE = 4, | ||
| 1312 | RSS = 5, | ||
| 1313 | MEMLOCK = 6, | ||
| 1314 | NPROC = 7, | ||
| 1315 | NOFILE = 8, | ||
| 1316 | SBSIZE = 9, | ||
| 1317 | VMEM = 10, | ||
| 1318 | NTHR = 11, | ||
| 1319 | _, | ||
| 1320 | |||
| 1321 | pub const AS: rlimit_resource = .VMEM; | ||
| 1322 | }; | ||
| 1323 | |||
| 1324 | pub const rlim_t = u64; | ||
| 1325 | |||
| 1326 | pub const RLIM = struct { | ||
| 1327 | /// No limit | ||
| 1328 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1329 | |||
| 1330 | pub const SAVED_MAX = INFINITY; | ||
| 1331 | pub const SAVED_CUR = INFINITY; | ||
| 1332 | }; | ||
| 1333 | |||
| 1334 | pub const rlimit = extern struct { | ||
| 1335 | /// Soft limit | ||
| 1336 | cur: rlim_t, | ||
| 1337 | /// Hard limit | ||
| 1338 | max: rlim_t, | ||
| 1339 | }; | ||
| 1340 | |||
| 1341 | pub const SHUT = struct { | ||
| 1342 | pub const RD = 0; | ||
| 1343 | pub const WR = 1; | ||
| 1344 | pub const RDWR = 2; | ||
| 1345 | }; | ||
| 1346 | |||
| 1347 | pub const nfds_t = u32; | ||
| 1348 | |||
| 1349 | pub const pollfd = extern struct { | ||
| 1350 | fd: fd_t, | ||
| 1351 | events: i16, | ||
| 1352 | revents: i16, | ||
| 1353 | }; | ||
| 1354 | |||
| 1355 | pub const POLL = struct { | ||
| 1356 | /// Testable events (may be specified in events field). | ||
| 1357 | pub const IN = 0x0001; | ||
| 1358 | pub const PRI = 0x0002; | ||
| 1359 | pub const OUT = 0x0004; | ||
| 1360 | pub const RDNORM = 0x0040; | ||
| 1361 | pub const WRNORM = OUT; | ||
| 1362 | pub const RDBAND = 0x0080; | ||
| 1363 | pub const WRBAND = 0x0100; | ||
| 1364 | |||
| 1365 | /// Non-testable events (may not be specified in events field). | ||
| 1366 | pub const ERR = 0x0008; | ||
| 1367 | pub const HUP = 0x0010; | ||
| 1368 | pub const NVAL = 0x0020; | ||
| 1369 | }; |
lib/std/c/openbsd.zig+36-1106| ... | @@ -4,50 +4,35 @@ const maxInt = std.math.maxInt; | ... | @@ -4,50 +4,35 @@ const maxInt = std.math.maxInt; |
| 4 | const builtin = @import("builtin"); | 4 | const builtin = @import("builtin"); |
| 5 | const iovec = std.posix.iovec; | 5 | const iovec = std.posix.iovec; |
| 6 | const iovec_const = std.posix.iovec_const; | 6 | const iovec_const = std.posix.iovec_const; |
| 7 | const passwd = std.c.passwd; | ||
| 8 | const timespec = std.c.timespec; | ||
| 9 | const uid_t = std.c.uid_t; | ||
| 10 | const pid_t = std.c.pid_t; | ||
| 7 | 11 | ||
| 8 | extern "c" fn __errno() *c_int; | 12 | comptime { |
| 9 | pub const _errno = __errno; | 13 | assert(builtin.os.tag == .openbsd); // Prevent access of std.c symbols on wrong OS. |
| 10 | 14 | } | |
| 11 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 12 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 13 | |||
| 14 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ||
| 15 | |||
| 16 | pub extern "c" fn getthrid() pid_t; | ||
| 17 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int; | ||
| 18 | |||
| 19 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | ||
| 20 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 21 | 15 | ||
| 22 | pub const pthread_spinlock_t = extern struct { | 16 | pub const pthread_spinlock_t = extern struct { |
| 23 | inner: ?*anyopaque = null, | 17 | inner: ?*anyopaque = null, |
| 24 | }; | 18 | }; |
| 25 | pub const pthread_attr_t = extern struct { | ||
| 26 | inner: ?*anyopaque = null, | ||
| 27 | }; | ||
| 28 | pub const pthread_key_t = c_int; | ||
| 29 | |||
| 30 | pub const sem_t = ?*opaque {}; | ||
| 31 | |||
| 32 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 33 | 19 | ||
| 34 | pub extern "c" fn pledge(promises: ?[*:0]const u8, execpromises: ?[*:0]const u8) c_int; | 20 | pub extern "c" fn pledge(promises: ?[*:0]const u8, execpromises: ?[*:0]const u8) c_int; |
| 35 | pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_int; | 21 | pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_int; |
| 22 | pub extern "c" fn getthrid() pid_t; | ||
| 36 | 23 | ||
| 37 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; | 24 | pub const FUTEX = struct { |
| 38 | pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void; | 25 | pub const WAIT = 1; |
| 39 | 26 | pub const WAKE = 2; | |
| 40 | // https://github.com/openbsd/src/blob/2207c4325726fdc5c4bcd0011af0fdf7d3dab137/sys/sys/futex.h | 27 | pub const REQUEUE = 3; |
| 41 | pub const FUTEX_WAIT = 1; | 28 | pub const PRIVATE_FLAG = 128; |
| 42 | pub const FUTEX_WAKE = 2; | 29 | }; |
| 43 | pub const FUTEX_REQUEUE = 3; | ||
| 44 | pub const FUTEX_PRIVATE_FLAG = 128; | ||
| 45 | pub extern "c" fn futex(uaddr: ?*const volatile u32, op: c_int, val: c_int, timeout: ?*const timespec, uaddr2: ?*const volatile u32) c_int; | 30 | pub extern "c" fn futex(uaddr: ?*const volatile u32, op: c_int, val: c_int, timeout: ?*const timespec, uaddr2: ?*const volatile u32) c_int; |
| 46 | 31 | ||
| 47 | pub const login_cap_t = extern struct { | 32 | pub const login_cap_t = extern struct { |
| 48 | lc_class: ?[*:0]const u8, | 33 | class: ?[*:0]const u8, |
| 49 | lc_cap: ?[*:0]const u8, | 34 | cap: ?[*:0]const u8, |
| 50 | lc_style: ?[*:0]const u8, | 35 | style: ?[*:0]const u8, |
| 51 | }; | 36 | }; |
| 52 | 37 | ||
| 53 | pub extern "c" fn login_getclass(class: ?[*:0]const u8) ?*login_cap_t; | 38 | pub extern "c" fn login_getclass(class: ?[*:0]const u8) ?*login_cap_t; |
| ... | @@ -94,21 +79,6 @@ pub extern "c" fn auth_cat(file: [*:0]const u8) c_int; | ... | @@ -94,21 +79,6 @@ pub extern "c" fn auth_cat(file: [*:0]const u8) c_int; |
| 94 | pub extern "c" fn auth_checknologin(lc: *login_cap_t) void; | 79 | pub extern "c" fn auth_checknologin(lc: *login_cap_t) void; |
| 95 | // TODO: auth_set_va_list requires zig support for va_list type (#515) | 80 | // TODO: auth_set_va_list requires zig support for va_list type (#515) |
| 96 | 81 | ||
| 97 | pub const passwd = extern struct { | ||
| 98 | pw_name: ?[*:0]const u8, // user name | ||
| 99 | pw_passwd: ?[*:0]const u8, // encrypted password | ||
| 100 | pw_uid: uid_t, // user uid | ||
| 101 | pw_gid: gid_t, // user gid | ||
| 102 | pw_change: time_t, // password change time | ||
| 103 | pw_class: ?[*:0]const u8, // user access class | ||
| 104 | pw_gecos: ?[*:0]const u8, // Honeywell login info | ||
| 105 | pw_dir: ?[*:0]const u8, // home directory | ||
| 106 | pw_shell: ?[*:0]const u8, // default shell | ||
| 107 | pw_expire: time_t, // account expiration | ||
| 108 | }; | ||
| 109 | |||
| 110 | pub extern "c" fn getpwuid(uid: uid_t) ?*passwd; | ||
| 111 | pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd; | ||
| 112 | pub extern "c" fn getpwuid_shadow(uid: uid_t) ?*passwd; | 82 | pub extern "c" fn getpwuid_shadow(uid: uid_t) ?*passwd; |
| 113 | pub extern "c" fn getpwnam_shadow(name: [*:0]const u8) ?*passwd; | 83 | pub extern "c" fn getpwnam_shadow(name: [*:0]const u8) ?*passwd; |
| 114 | pub extern "c" fn getpwnam_r(name: [*:0]const u8, pw: *passwd, buf: [*]u8, buflen: usize, pwretp: *?*passwd) c_int; | 84 | pub extern "c" fn getpwnam_r(name: [*:0]const u8, pw: *passwd, buf: [*]u8, buflen: usize, pwretp: *?*passwd) c_int; |
| ... | @@ -125,622 +95,14 @@ pub extern "c" fn bcrypt_newhash(pass: [*:0]const u8, log_rounds: c_int, hash: [ | ... | @@ -125,622 +95,14 @@ pub extern "c" fn bcrypt_newhash(pass: [*:0]const u8, log_rounds: c_int, hash: [ |
| 125 | pub extern "c" fn bcrypt_checkpass(pass: [*:0]const u8, goodhash: [*:0]const u8) c_int; | 95 | pub extern "c" fn bcrypt_checkpass(pass: [*:0]const u8, goodhash: [*:0]const u8) c_int; |
| 126 | pub extern "c" fn pw_dup(pw: *const passwd) ?*passwd; | 96 | pub extern "c" fn pw_dup(pw: *const passwd) ?*passwd; |
| 127 | 97 | ||
| 128 | pub const blkcnt_t = i64; | 98 | pub const auth_item_t = enum(c_int) { |
| 129 | pub const blksize_t = i32; | 99 | ALL = 0, |
| 130 | pub const clock_t = i64; | 100 | CHALLENGE = 1, |
| 131 | pub const dev_t = i32; | 101 | CLASS = 2, |
| 132 | pub const fd_t = c_int; | 102 | NAME = 3, |
| 133 | pub const gid_t = u32; | 103 | SERVICE = 4, |
| 134 | pub const ino_t = u64; | 104 | STYLE = 5, |
| 135 | pub const mode_t = u32; | 105 | INTERACTIVE = 6, |
| 136 | pub const nlink_t = u32; | ||
| 137 | pub const off_t = i64; | ||
| 138 | pub const pid_t = i32; | ||
| 139 | pub const socklen_t = u32; | ||
| 140 | pub const time_t = i64; | ||
| 141 | pub const uid_t = u32; | ||
| 142 | |||
| 143 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | ||
| 144 | pub const Kevent = extern struct { | ||
| 145 | ident: usize, | ||
| 146 | filter: c_short, | ||
| 147 | flags: u16, | ||
| 148 | fflags: c_uint, | ||
| 149 | data: i64, | ||
| 150 | udata: usize, | ||
| 151 | }; | ||
| 152 | |||
| 153 | // Modes and flags for dlopen() | ||
| 154 | // include/dlfcn.h | ||
| 155 | |||
| 156 | pub const RTLD = struct { | ||
| 157 | /// Bind function calls lazily. | ||
| 158 | pub const LAZY = 1; | ||
| 159 | /// Bind function calls immediately. | ||
| 160 | pub const NOW = 2; | ||
| 161 | /// Make symbols globally available. | ||
| 162 | pub const GLOBAL = 0x100; | ||
| 163 | /// Opposite of GLOBAL, and the default. | ||
| 164 | pub const LOCAL = 0x000; | ||
| 165 | /// Trace loaded objects and exit. | ||
| 166 | pub const TRACE = 0x200; | ||
| 167 | }; | ||
| 168 | |||
| 169 | pub const dl_phdr_info = extern struct { | ||
| 170 | dlpi_addr: std.elf.Addr, | ||
| 171 | dlpi_name: ?[*:0]const u8, | ||
| 172 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 173 | dlpi_phnum: std.elf.Half, | ||
| 174 | }; | ||
| 175 | |||
| 176 | pub const Flock = extern struct { | ||
| 177 | start: off_t, | ||
| 178 | len: off_t, | ||
| 179 | pid: pid_t, | ||
| 180 | type: c_short, | ||
| 181 | whence: c_short, | ||
| 182 | }; | ||
| 183 | |||
| 184 | pub const addrinfo = extern struct { | ||
| 185 | flags: c_int, | ||
| 186 | family: c_int, | ||
| 187 | socktype: c_int, | ||
| 188 | protocol: c_int, | ||
| 189 | addrlen: socklen_t, | ||
| 190 | addr: ?*sockaddr, | ||
| 191 | canonname: ?[*:0]u8, | ||
| 192 | next: ?*addrinfo, | ||
| 193 | }; | ||
| 194 | |||
| 195 | pub const EAI = enum(c_int) { | ||
| 196 | /// address family for hostname not supported | ||
| 197 | ADDRFAMILY = -9, | ||
| 198 | |||
| 199 | /// name could not be resolved at this time | ||
| 200 | AGAIN = -3, | ||
| 201 | |||
| 202 | /// flags parameter had an invalid value | ||
| 203 | BADFLAGS = -1, | ||
| 204 | |||
| 205 | /// non-recoverable failure in name resolution | ||
| 206 | FAIL = -4, | ||
| 207 | |||
| 208 | /// address family not recognized | ||
| 209 | FAMILY = -6, | ||
| 210 | |||
| 211 | /// memory allocation failure | ||
| 212 | MEMORY = -10, | ||
| 213 | |||
| 214 | /// no address associated with hostname | ||
| 215 | NODATA = -5, | ||
| 216 | |||
| 217 | /// name does not resolve | ||
| 218 | NONAME = -2, | ||
| 219 | |||
| 220 | /// service not recognized for socket type | ||
| 221 | SERVICE = -8, | ||
| 222 | |||
| 223 | /// intended socket type was not recognized | ||
| 224 | SOCKTYPE = -7, | ||
| 225 | |||
| 226 | /// system error returned in errno | ||
| 227 | SYSTEM = -11, | ||
| 228 | |||
| 229 | /// invalid value for hints | ||
| 230 | BADHINTS = -12, | ||
| 231 | |||
| 232 | /// resolved protocol is unknown | ||
| 233 | PROTOCOL = -13, | ||
| 234 | |||
| 235 | /// argument buffer overflow | ||
| 236 | OVERFLOW = -14, | ||
| 237 | |||
| 238 | _, | ||
| 239 | }; | ||
| 240 | |||
| 241 | pub const EAI_MAX = 15; | ||
| 242 | |||
| 243 | pub const msghdr = extern struct { | ||
| 244 | /// optional address | ||
| 245 | name: ?*sockaddr, | ||
| 246 | /// size of address | ||
| 247 | namelen: socklen_t, | ||
| 248 | /// scatter/gather array | ||
| 249 | iov: [*]iovec, | ||
| 250 | /// # elements in iov | ||
| 251 | iovlen: c_uint, | ||
| 252 | /// ancillary data | ||
| 253 | control: ?*anyopaque, | ||
| 254 | /// ancillary data buffer len | ||
| 255 | controllen: socklen_t, | ||
| 256 | /// flags on received message | ||
| 257 | flags: c_int, | ||
| 258 | }; | ||
| 259 | |||
| 260 | pub const msghdr_const = extern struct { | ||
| 261 | /// optional address | ||
| 262 | name: ?*const sockaddr, | ||
| 263 | /// size of address | ||
| 264 | namelen: socklen_t, | ||
| 265 | /// scatter/gather array | ||
| 266 | iov: [*]const iovec_const, | ||
| 267 | /// # elements in iov | ||
| 268 | iovlen: c_uint, | ||
| 269 | /// ancillary data | ||
| 270 | control: ?*const anyopaque, | ||
| 271 | /// ancillary data buffer len | ||
| 272 | controllen: socklen_t, | ||
| 273 | /// flags on received message | ||
| 274 | flags: c_int, | ||
| 275 | }; | ||
| 276 | |||
| 277 | pub const Stat = extern struct { | ||
| 278 | mode: mode_t, | ||
| 279 | dev: dev_t, | ||
| 280 | ino: ino_t, | ||
| 281 | nlink: nlink_t, | ||
| 282 | uid: uid_t, | ||
| 283 | gid: gid_t, | ||
| 284 | rdev: dev_t, | ||
| 285 | atim: timespec, | ||
| 286 | mtim: timespec, | ||
| 287 | ctim: timespec, | ||
| 288 | size: off_t, | ||
| 289 | blocks: blkcnt_t, | ||
| 290 | blksize: blksize_t, | ||
| 291 | flags: u32, | ||
| 292 | gen: u32, | ||
| 293 | birthtim: timespec, | ||
| 294 | |||
| 295 | pub fn atime(self: @This()) timespec { | ||
| 296 | return self.atim; | ||
| 297 | } | ||
| 298 | |||
| 299 | pub fn mtime(self: @This()) timespec { | ||
| 300 | return self.mtim; | ||
| 301 | } | ||
| 302 | |||
| 303 | pub fn ctime(self: @This()) timespec { | ||
| 304 | return self.ctim; | ||
| 305 | } | ||
| 306 | |||
| 307 | pub fn birthtime(self: @This()) timespec { | ||
| 308 | return self.birthtim; | ||
| 309 | } | ||
| 310 | }; | ||
| 311 | |||
| 312 | pub const timespec = extern struct { | ||
| 313 | tv_sec: time_t, | ||
| 314 | tv_nsec: c_long, | ||
| 315 | }; | ||
| 316 | |||
| 317 | pub const timeval = extern struct { | ||
| 318 | tv_sec: time_t, | ||
| 319 | tv_usec: c_long, | ||
| 320 | }; | ||
| 321 | |||
| 322 | pub const timezone = extern struct { | ||
| 323 | tz_minuteswest: c_int, | ||
| 324 | tz_dsttime: c_int, | ||
| 325 | }; | ||
| 326 | |||
| 327 | pub const MAXNAMLEN = 255; | ||
| 328 | |||
| 329 | pub const dirent = extern struct { | ||
| 330 | fileno: ino_t, | ||
| 331 | off: off_t, | ||
| 332 | reclen: u16, | ||
| 333 | type: u8, | ||
| 334 | namlen: u8, | ||
| 335 | _: u32 align(1) = 0, | ||
| 336 | name: [MAXNAMLEN + 1]u8, | ||
| 337 | }; | ||
| 338 | |||
| 339 | pub const in_port_t = u16; | ||
| 340 | pub const sa_family_t = u8; | ||
| 341 | |||
| 342 | pub const sockaddr = extern struct { | ||
| 343 | /// total length | ||
| 344 | len: u8, | ||
| 345 | /// address family | ||
| 346 | family: sa_family_t, | ||
| 347 | /// actually longer; address value | ||
| 348 | data: [14]u8, | ||
| 349 | |||
| 350 | pub const SS_MAXSIZE = 256; | ||
| 351 | pub const storage = extern struct { | ||
| 352 | len: u8 align(8), | ||
| 353 | family: sa_family_t, | ||
| 354 | padding: [254]u8 = undefined, | ||
| 355 | |||
| 356 | comptime { | ||
| 357 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 358 | assert(@alignOf(storage) == 8); | ||
| 359 | } | ||
| 360 | }; | ||
| 361 | |||
| 362 | pub const in = extern struct { | ||
| 363 | len: u8 = @sizeOf(in), | ||
| 364 | family: sa_family_t = AF.INET, | ||
| 365 | port: in_port_t, | ||
| 366 | addr: u32, | ||
| 367 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 368 | }; | ||
| 369 | |||
| 370 | pub const in6 = extern struct { | ||
| 371 | len: u8 = @sizeOf(in6), | ||
| 372 | family: sa_family_t = AF.INET6, | ||
| 373 | port: in_port_t, | ||
| 374 | flowinfo: u32, | ||
| 375 | addr: [16]u8, | ||
| 376 | scope_id: u32, | ||
| 377 | }; | ||
| 378 | |||
| 379 | /// Definitions for UNIX IPC domain. | ||
| 380 | pub const un = extern struct { | ||
| 381 | /// total sockaddr length | ||
| 382 | len: u8 = @sizeOf(un), | ||
| 383 | |||
| 384 | family: sa_family_t = AF.LOCAL, | ||
| 385 | |||
| 386 | /// path name | ||
| 387 | path: [104]u8, | ||
| 388 | }; | ||
| 389 | }; | ||
| 390 | |||
| 391 | pub const IFNAMESIZE = 16; | ||
| 392 | |||
| 393 | pub const AI = struct { | ||
| 394 | /// get address to use bind() | ||
| 395 | pub const PASSIVE = 1; | ||
| 396 | /// fill ai_canonname | ||
| 397 | pub const CANONNAME = 2; | ||
| 398 | /// prevent host name resolution | ||
| 399 | pub const NUMERICHOST = 4; | ||
| 400 | /// prevent service name resolution | ||
| 401 | pub const NUMERICSERV = 16; | ||
| 402 | /// only if any address is assigned | ||
| 403 | pub const ADDRCONFIG = 64; | ||
| 404 | }; | ||
| 405 | |||
| 406 | pub const PATH_MAX = 1024; | ||
| 407 | pub const NAME_MAX = 255; | ||
| 408 | pub const IOV_MAX = 1024; | ||
| 409 | |||
| 410 | pub const STDIN_FILENO = 0; | ||
| 411 | pub const STDOUT_FILENO = 1; | ||
| 412 | pub const STDERR_FILENO = 2; | ||
| 413 | |||
| 414 | pub const PROT = struct { | ||
| 415 | pub const NONE = 0; | ||
| 416 | pub const READ = 1; | ||
| 417 | pub const WRITE = 2; | ||
| 418 | pub const EXEC = 4; | ||
| 419 | }; | ||
| 420 | |||
| 421 | pub const CLOCK = struct { | ||
| 422 | pub const REALTIME = 0; | ||
| 423 | pub const PROCESS_CPUTIME_ID = 2; | ||
| 424 | pub const MONOTONIC = 3; | ||
| 425 | pub const THREAD_CPUTIME_ID = 4; | ||
| 426 | }; | ||
| 427 | |||
| 428 | pub const MSF = struct { | ||
| 429 | pub const ASYNC = 1; | ||
| 430 | pub const INVALIDATE = 2; | ||
| 431 | pub const SYNC = 4; | ||
| 432 | }; | ||
| 433 | |||
| 434 | pub const W = struct { | ||
| 435 | pub const NOHANG = 1; | ||
| 436 | pub const UNTRACED = 2; | ||
| 437 | pub const CONTINUED = 8; | ||
| 438 | |||
| 439 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 440 | return @as(u8, @intCast((s >> 8) & 0xff)); | ||
| 441 | } | ||
| 442 | pub fn TERMSIG(s: u32) u32 { | ||
| 443 | return (s & 0x7f); | ||
| 444 | } | ||
| 445 | pub fn STOPSIG(s: u32) u32 { | ||
| 446 | return EXITSTATUS(s); | ||
| 447 | } | ||
| 448 | pub fn IFEXITED(s: u32) bool { | ||
| 449 | return TERMSIG(s) == 0; | ||
| 450 | } | ||
| 451 | |||
| 452 | pub fn IFCONTINUED(s: u32) bool { | ||
| 453 | return ((s & 0o177777) == 0o177777); | ||
| 454 | } | ||
| 455 | |||
| 456 | pub fn IFSTOPPED(s: u32) bool { | ||
| 457 | return (s & 0xff == 0o177); | ||
| 458 | } | ||
| 459 | |||
| 460 | pub fn IFSIGNALED(s: u32) bool { | ||
| 461 | return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); | ||
| 462 | } | ||
| 463 | }; | ||
| 464 | |||
| 465 | pub const SA = struct { | ||
| 466 | pub const ONSTACK = 0x0001; | ||
| 467 | pub const RESTART = 0x0002; | ||
| 468 | pub const RESETHAND = 0x0004; | ||
| 469 | pub const NOCLDSTOP = 0x0008; | ||
| 470 | pub const NODEFER = 0x0010; | ||
| 471 | pub const NOCLDWAIT = 0x0020; | ||
| 472 | pub const SIGINFO = 0x0040; | ||
| 473 | }; | ||
| 474 | |||
| 475 | // access function | ||
| 476 | pub const F_OK = 0; // test for existence of file | ||
| 477 | pub const X_OK = 1; // test for execute or search permission | ||
| 478 | pub const W_OK = 2; // test for write permission | ||
| 479 | pub const R_OK = 4; // test for read permission | ||
| 480 | |||
| 481 | pub const F = struct { | ||
| 482 | pub const DUPFD = 0; | ||
| 483 | pub const GETFD = 1; | ||
| 484 | pub const SETFD = 2; | ||
| 485 | pub const GETFL = 3; | ||
| 486 | pub const SETFL = 4; | ||
| 487 | |||
| 488 | pub const GETOWN = 5; | ||
| 489 | pub const SETOWN = 6; | ||
| 490 | |||
| 491 | pub const GETLK = 7; | ||
| 492 | pub const SETLK = 8; | ||
| 493 | pub const SETLKW = 9; | ||
| 494 | |||
| 495 | pub const RDLCK = 1; | ||
| 496 | pub const UNLCK = 2; | ||
| 497 | pub const WRLCK = 3; | ||
| 498 | }; | ||
| 499 | |||
| 500 | pub const LOCK = struct { | ||
| 501 | pub const SH = 0x01; | ||
| 502 | pub const EX = 0x02; | ||
| 503 | pub const NB = 0x04; | ||
| 504 | pub const UN = 0x08; | ||
| 505 | }; | ||
| 506 | |||
| 507 | pub const FD_CLOEXEC = 1; | ||
| 508 | |||
| 509 | pub const SEEK = struct { | ||
| 510 | pub const SET = 0; | ||
| 511 | pub const CUR = 1; | ||
| 512 | pub const END = 2; | ||
| 513 | }; | ||
| 514 | |||
| 515 | pub const SOCK = struct { | ||
| 516 | pub const STREAM = 1; | ||
| 517 | pub const DGRAM = 2; | ||
| 518 | pub const RAW = 3; | ||
| 519 | pub const RDM = 4; | ||
| 520 | pub const SEQPACKET = 5; | ||
| 521 | |||
| 522 | pub const CLOEXEC = 0x8000; | ||
| 523 | pub const NONBLOCK = 0x4000; | ||
| 524 | }; | ||
| 525 | |||
| 526 | pub const SO = struct { | ||
| 527 | pub const DEBUG = 0x0001; | ||
| 528 | pub const ACCEPTCONN = 0x0002; | ||
| 529 | pub const REUSEADDR = 0x0004; | ||
| 530 | pub const KEEPALIVE = 0x0008; | ||
| 531 | pub const DONTROUTE = 0x0010; | ||
| 532 | pub const BROADCAST = 0x0020; | ||
| 533 | pub const USELOOPBACK = 0x0040; | ||
| 534 | pub const LINGER = 0x0080; | ||
| 535 | pub const OOBINLINE = 0x0100; | ||
| 536 | pub const REUSEPORT = 0x0200; | ||
| 537 | pub const TIMESTAMP = 0x0800; | ||
| 538 | pub const BINDANY = 0x1000; | ||
| 539 | pub const ZEROIZE = 0x2000; | ||
| 540 | pub const SNDBUF = 0x1001; | ||
| 541 | pub const RCVBUF = 0x1002; | ||
| 542 | pub const SNDLOWAT = 0x1003; | ||
| 543 | pub const RCVLOWAT = 0x1004; | ||
| 544 | pub const SNDTIMEO = 0x1005; | ||
| 545 | pub const RCVTIMEO = 0x1006; | ||
| 546 | pub const ERROR = 0x1007; | ||
| 547 | pub const TYPE = 0x1008; | ||
| 548 | pub const NETPROC = 0x1020; | ||
| 549 | pub const RTABLE = 0x1021; | ||
| 550 | pub const PEERCRED = 0x1022; | ||
| 551 | pub const SPLICE = 0x1023; | ||
| 552 | pub const DOMAIN = 0x1024; | ||
| 553 | pub const PROTOCOL = 0x1025; | ||
| 554 | }; | ||
| 555 | |||
| 556 | pub const SOL = struct { | ||
| 557 | pub const SOCKET = 0xffff; | ||
| 558 | }; | ||
| 559 | |||
| 560 | pub const PF = struct { | ||
| 561 | pub const UNSPEC = AF.UNSPEC; | ||
| 562 | pub const LOCAL = AF.LOCAL; | ||
| 563 | pub const UNIX = AF.UNIX; | ||
| 564 | pub const INET = AF.INET; | ||
| 565 | pub const APPLETALK = AF.APPLETALK; | ||
| 566 | pub const INET6 = AF.INET6; | ||
| 567 | pub const DECnet = AF.DECnet; | ||
| 568 | pub const KEY = AF.KEY; | ||
| 569 | pub const ROUTE = AF.ROUTE; | ||
| 570 | pub const SNA = AF.SNA; | ||
| 571 | pub const MPLS = AF.MPLS; | ||
| 572 | pub const BLUETOOTH = AF.BLUETOOTH; | ||
| 573 | pub const ISDN = AF.ISDN; | ||
| 574 | pub const MAX = AF.MAX; | ||
| 575 | }; | ||
| 576 | |||
| 577 | pub const AF = struct { | ||
| 578 | pub const UNSPEC = 0; | ||
| 579 | pub const UNIX = 1; | ||
| 580 | pub const LOCAL = UNIX; | ||
| 581 | pub const INET = 2; | ||
| 582 | pub const APPLETALK = 16; | ||
| 583 | pub const INET6 = 24; | ||
| 584 | pub const KEY = 30; | ||
| 585 | pub const ROUTE = 17; | ||
| 586 | pub const SNA = 11; | ||
| 587 | pub const MPLS = 33; | ||
| 588 | pub const BLUETOOTH = 32; | ||
| 589 | pub const ISDN = 26; | ||
| 590 | pub const MAX = 36; | ||
| 591 | }; | ||
| 592 | |||
| 593 | pub const DT = struct { | ||
| 594 | pub const UNKNOWN = 0; | ||
| 595 | pub const FIFO = 1; | ||
| 596 | pub const CHR = 2; | ||
| 597 | pub const DIR = 4; | ||
| 598 | pub const BLK = 6; | ||
| 599 | pub const REG = 8; | ||
| 600 | pub const LNK = 10; | ||
| 601 | pub const SOCK = 12; | ||
| 602 | pub const WHT = 14; // XXX | ||
| 603 | }; | ||
| 604 | |||
| 605 | pub const EV_ADD = 0x0001; | ||
| 606 | pub const EV_DELETE = 0x0002; | ||
| 607 | pub const EV_ENABLE = 0x0004; | ||
| 608 | pub const EV_DISABLE = 0x0008; | ||
| 609 | pub const EV_ONESHOT = 0x0010; | ||
| 610 | pub const EV_CLEAR = 0x0020; | ||
| 611 | pub const EV_RECEIPT = 0x0040; | ||
| 612 | pub const EV_DISPATCH = 0x0080; | ||
| 613 | pub const EV_FLAG1 = 0x2000; | ||
| 614 | pub const EV_ERROR = 0x4000; | ||
| 615 | pub const EV_EOF = 0x8000; | ||
| 616 | |||
| 617 | pub const EVFILT_READ = -1; | ||
| 618 | pub const EVFILT_WRITE = -2; | ||
| 619 | pub const EVFILT_AIO = -3; | ||
| 620 | pub const EVFILT_VNODE = -4; | ||
| 621 | pub const EVFILT_PROC = -5; | ||
| 622 | pub const EVFILT_SIGNAL = -6; | ||
| 623 | pub const EVFILT_TIMER = -7; | ||
| 624 | pub const EVFILT_EXCEPT = -9; | ||
| 625 | |||
| 626 | // data/hint flags for EVFILT_{READ|WRITE} | ||
| 627 | pub const NOTE_LOWAT = 0x0001; | ||
| 628 | pub const NOTE_EOF = 0x0002; | ||
| 629 | |||
| 630 | // data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE} | ||
| 631 | pub const NOTE_OOB = 0x0004; | ||
| 632 | |||
| 633 | // data/hint flags for EVFILT_VNODE | ||
| 634 | pub const NOTE_DELETE = 0x0001; | ||
| 635 | pub const NOTE_WRITE = 0x0002; | ||
| 636 | pub const NOTE_EXTEND = 0x0004; | ||
| 637 | pub const NOTE_ATTRIB = 0x0008; | ||
| 638 | pub const NOTE_LINK = 0x0010; | ||
| 639 | pub const NOTE_RENAME = 0x0020; | ||
| 640 | pub const NOTE_REVOKE = 0x0040; | ||
| 641 | pub const NOTE_TRUNCATE = 0x0080; | ||
| 642 | |||
| 643 | // data/hint flags for EVFILT_PROC | ||
| 644 | pub const NOTE_EXIT = 0x80000000; | ||
| 645 | pub const NOTE_FORK = 0x40000000; | ||
| 646 | pub const NOTE_EXEC = 0x20000000; | ||
| 647 | pub const NOTE_PDATAMASK = 0x000fffff; | ||
| 648 | pub const NOTE_PCTRLMASK = 0xf0000000; | ||
| 649 | pub const NOTE_TRACK = 0x00000001; | ||
| 650 | pub const NOTE_TRACKERR = 0x00000002; | ||
| 651 | pub const NOTE_CHILD = 0x00000004; | ||
| 652 | |||
| 653 | // data/hint flags for EVFILT_DEVICE | ||
| 654 | pub const NOTE_CHANGE = 0x00000001; | ||
| 655 | |||
| 656 | pub const T = struct { | ||
| 657 | pub const IOCCBRK = 0x2000747a; | ||
| 658 | pub const IOCCDTR = 0x20007478; | ||
| 659 | pub const IOCCONS = 0x80047462; | ||
| 660 | pub const IOCDCDTIMESTAMP = 0x40107458; | ||
| 661 | pub const IOCDRAIN = 0x2000745e; | ||
| 662 | pub const IOCEXCL = 0x2000740d; | ||
| 663 | pub const IOCEXT = 0x80047460; | ||
| 664 | pub const IOCFLAG_CDTRCTS = 0x10; | ||
| 665 | pub const IOCFLAG_CLOCAL = 0x2; | ||
| 666 | pub const IOCFLAG_CRTSCTS = 0x4; | ||
| 667 | pub const IOCFLAG_MDMBUF = 0x8; | ||
| 668 | pub const IOCFLAG_SOFTCAR = 0x1; | ||
| 669 | pub const IOCFLUSH = 0x80047410; | ||
| 670 | pub const IOCGETA = 0x402c7413; | ||
| 671 | pub const IOCGETD = 0x4004741a; | ||
| 672 | pub const IOCGFLAGS = 0x4004745d; | ||
| 673 | pub const IOCGLINED = 0x40207442; | ||
| 674 | pub const IOCGPGRP = 0x40047477; | ||
| 675 | pub const IOCGQSIZE = 0x40047481; | ||
| 676 | pub const IOCGRANTPT = 0x20007447; | ||
| 677 | pub const IOCGSID = 0x40047463; | ||
| 678 | pub const IOCGSIZE = 0x40087468; | ||
| 679 | pub const IOCGWINSZ = 0x40087468; | ||
| 680 | pub const IOCMBIC = 0x8004746b; | ||
| 681 | pub const IOCMBIS = 0x8004746c; | ||
| 682 | pub const IOCMGET = 0x4004746a; | ||
| 683 | pub const IOCMSET = 0x8004746d; | ||
| 684 | pub const IOCM_CAR = 0x40; | ||
| 685 | pub const IOCM_CD = 0x40; | ||
| 686 | pub const IOCM_CTS = 0x20; | ||
| 687 | pub const IOCM_DSR = 0x100; | ||
| 688 | pub const IOCM_DTR = 0x2; | ||
| 689 | pub const IOCM_LE = 0x1; | ||
| 690 | pub const IOCM_RI = 0x80; | ||
| 691 | pub const IOCM_RNG = 0x80; | ||
| 692 | pub const IOCM_RTS = 0x4; | ||
| 693 | pub const IOCM_SR = 0x10; | ||
| 694 | pub const IOCM_ST = 0x8; | ||
| 695 | pub const IOCNOTTY = 0x20007471; | ||
| 696 | pub const IOCNXCL = 0x2000740e; | ||
| 697 | pub const IOCOUTQ = 0x40047473; | ||
| 698 | pub const IOCPKT = 0x80047470; | ||
| 699 | pub const IOCPKT_DATA = 0x0; | ||
| 700 | pub const IOCPKT_DOSTOP = 0x20; | ||
| 701 | pub const IOCPKT_FLUSHREAD = 0x1; | ||
| 702 | pub const IOCPKT_FLUSHWRITE = 0x2; | ||
| 703 | pub const IOCPKT_IOCTL = 0x40; | ||
| 704 | pub const IOCPKT_NOSTOP = 0x10; | ||
| 705 | pub const IOCPKT_START = 0x8; | ||
| 706 | pub const IOCPKT_STOP = 0x4; | ||
| 707 | pub const IOCPTMGET = 0x40287446; | ||
| 708 | pub const IOCPTSNAME = 0x40287448; | ||
| 709 | pub const IOCRCVFRAME = 0x80087445; | ||
| 710 | pub const IOCREMOTE = 0x80047469; | ||
| 711 | pub const IOCSBRK = 0x2000747b; | ||
| 712 | pub const IOCSCTTY = 0x20007461; | ||
| 713 | pub const IOCSDTR = 0x20007479; | ||
| 714 | pub const IOCSETA = 0x802c7414; | ||
| 715 | pub const IOCSETAF = 0x802c7416; | ||
| 716 | pub const IOCSETAW = 0x802c7415; | ||
| 717 | pub const IOCSETD = 0x8004741b; | ||
| 718 | pub const IOCSFLAGS = 0x8004745c; | ||
| 719 | pub const IOCSIG = 0x2000745f; | ||
| 720 | pub const IOCSLINED = 0x80207443; | ||
| 721 | pub const IOCSPGRP = 0x80047476; | ||
| 722 | pub const IOCSQSIZE = 0x80047480; | ||
| 723 | pub const IOCSSIZE = 0x80087467; | ||
| 724 | pub const IOCSTART = 0x2000746e; | ||
| 725 | pub const IOCSTAT = 0x80047465; | ||
| 726 | pub const IOCSTI = 0x80017472; | ||
| 727 | pub const IOCSTOP = 0x2000746f; | ||
| 728 | pub const IOCSWINSZ = 0x80087467; | ||
| 729 | pub const IOCUCNTL = 0x80047466; | ||
| 730 | pub const IOCXMTFRAME = 0x80087444; | ||
| 731 | }; | ||
| 732 | |||
| 733 | // BSD Authentication | ||
| 734 | pub const auth_item_t = c_int; | ||
| 735 | |||
| 736 | pub const AUTHV = struct { | ||
| 737 | pub const ALL: auth_item_t = 0; | ||
| 738 | pub const CHALLENGE: auth_item_t = 1; | ||
| 739 | pub const CLASS: auth_item_t = 2; | ||
| 740 | pub const NAME: auth_item_t = 3; | ||
| 741 | pub const SERVICE: auth_item_t = 4; | ||
| 742 | pub const STYLE: auth_item_t = 5; | ||
| 743 | pub const INTERACTIVE: auth_item_t = 6; | ||
| 744 | }; | 106 | }; |
| 745 | 107 | ||
| 746 | pub const BI = struct { | 108 | pub const BI = struct { |
| ... | @@ -770,132 +132,20 @@ pub const AUTH = struct { | ... | @@ -770,132 +132,20 @@ pub const AUTH = struct { |
| 770 | pub const ALLOW: c_int = (OKAY | ROOTOKAY | SECURE); | 132 | pub const ALLOW: c_int = (OKAY | ROOTOKAY | SECURE); |
| 771 | }; | 133 | }; |
| 772 | 134 | ||
| 773 | pub const TCSA = enum(c_uint) { | 135 | pub const TCFLUSH = enum(u32) { |
| 774 | NOW, | 136 | none = 0, |
| 775 | DRAIN, | 137 | I = 1, |
| 776 | FLUSH, | 138 | O = 2, |
| 777 | _, | 139 | IO = 3, |
| 778 | }; | ||
| 779 | |||
| 780 | pub const TCIFLUSH = 1; | ||
| 781 | pub const TCOFLUSH = 2; | ||
| 782 | pub const TCIOFLUSH = 3; | ||
| 783 | pub const TCOOFF = 1; | ||
| 784 | pub const TCOON = 2; | ||
| 785 | pub const TCIOFF = 3; | ||
| 786 | pub const TCION = 4; | ||
| 787 | |||
| 788 | pub const winsize = extern struct { | ||
| 789 | ws_row: c_ushort, | ||
| 790 | ws_col: c_ushort, | ||
| 791 | ws_xpixel: c_ushort, | ||
| 792 | ws_ypixel: c_ushort, | ||
| 793 | }; | ||
| 794 | |||
| 795 | const NSIG = 33; | ||
| 796 | |||
| 797 | pub const SIG = struct { | ||
| 798 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 799 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 800 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 801 | pub const CATCH: ?Sigaction.handler_fn = @ptrFromInt(2); | ||
| 802 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); | ||
| 803 | |||
| 804 | pub const HUP = 1; | ||
| 805 | pub const INT = 2; | ||
| 806 | pub const QUIT = 3; | ||
| 807 | pub const ILL = 4; | ||
| 808 | pub const TRAP = 5; | ||
| 809 | pub const ABRT = 6; | ||
| 810 | pub const IOT = ABRT; | ||
| 811 | pub const EMT = 7; | ||
| 812 | pub const FPE = 8; | ||
| 813 | pub const KILL = 9; | ||
| 814 | pub const BUS = 10; | ||
| 815 | pub const SEGV = 11; | ||
| 816 | pub const SYS = 12; | ||
| 817 | pub const PIPE = 13; | ||
| 818 | pub const ALRM = 14; | ||
| 819 | pub const TERM = 15; | ||
| 820 | pub const URG = 16; | ||
| 821 | pub const STOP = 17; | ||
| 822 | pub const TSTP = 18; | ||
| 823 | pub const CONT = 19; | ||
| 824 | pub const CHLD = 20; | ||
| 825 | pub const TTIN = 21; | ||
| 826 | pub const TTOU = 22; | ||
| 827 | pub const IO = 23; | ||
| 828 | pub const XCPU = 24; | ||
| 829 | pub const XFSZ = 25; | ||
| 830 | pub const VTALRM = 26; | ||
| 831 | pub const PROF = 27; | ||
| 832 | pub const WINCH = 28; | ||
| 833 | pub const INFO = 29; | ||
| 834 | pub const USR1 = 30; | ||
| 835 | pub const USR2 = 31; | ||
| 836 | pub const PWR = 32; | ||
| 837 | |||
| 838 | pub const BLOCK = 1; | ||
| 839 | pub const UNBLOCK = 2; | ||
| 840 | pub const SETMASK = 3; | ||
| 841 | }; | ||
| 842 | |||
| 843 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 844 | pub const Sigaction = extern struct { | ||
| 845 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 846 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 847 | |||
| 848 | /// signal handler | ||
| 849 | handler: extern union { | ||
| 850 | handler: ?handler_fn, | ||
| 851 | sigaction: ?sigaction_fn, | ||
| 852 | }, | ||
| 853 | /// signal mask to apply | ||
| 854 | mask: sigset_t, | ||
| 855 | /// signal options | ||
| 856 | flags: c_uint, | ||
| 857 | }; | ||
| 858 | |||
| 859 | pub const sigval = extern union { | ||
| 860 | int: c_int, | ||
| 861 | ptr: ?*anyopaque, | ||
| 862 | }; | 140 | }; |
| 863 | 141 | ||
| 864 | pub const siginfo_t = extern struct { | 142 | pub const TCIO = enum(u32) { |
| 865 | signo: c_int, | 143 | OOFF = 1, |
| 866 | code: c_int, | 144 | OON = 2, |
| 867 | errno: c_int, | 145 | IOFF = 3, |
| 868 | data: extern union { | 146 | ION = 4, |
| 869 | proc: extern struct { | ||
| 870 | pid: pid_t, | ||
| 871 | pdata: extern union { | ||
| 872 | kill: extern struct { | ||
| 873 | uid: uid_t, | ||
| 874 | value: sigval, | ||
| 875 | }, | ||
| 876 | cld: extern struct { | ||
| 877 | utime: clock_t, | ||
| 878 | stime: clock_t, | ||
| 879 | status: c_int, | ||
| 880 | }, | ||
| 881 | }, | ||
| 882 | }, | ||
| 883 | fault: extern struct { | ||
| 884 | addr: *allowzero anyopaque, | ||
| 885 | trapno: c_int, | ||
| 886 | }, | ||
| 887 | __pad: [128 - 3 * @sizeOf(c_int)]u8, | ||
| 888 | }, | ||
| 889 | }; | 147 | }; |
| 890 | 148 | ||
| 891 | comptime { | ||
| 892 | if (@sizeOf(usize) == 4) | ||
| 893 | std.debug.assert(@sizeOf(siginfo_t) == 128) | ||
| 894 | else | ||
| 895 | // Take into account the padding between errno and data fields. | ||
| 896 | std.debug.assert(@sizeOf(siginfo_t) == 136); | ||
| 897 | } | ||
| 898 | |||
| 899 | pub const ucontext_t = switch (builtin.cpu.arch) { | 149 | pub const ucontext_t = switch (builtin.cpu.arch) { |
| 900 | .x86_64 => extern struct { | 150 | .x86_64 => extern struct { |
| 901 | sc_rdi: c_long, | 151 | sc_rdi: c_long, |
| ... | @@ -943,9 +193,6 @@ pub const ucontext_t = switch (builtin.cpu.arch) { | ... | @@ -943,9 +193,6 @@ pub const ucontext_t = switch (builtin.cpu.arch) { |
| 943 | else => @compileError("missing ucontext_t type definition"), | 193 | else => @compileError("missing ucontext_t type definition"), |
| 944 | }; | 194 | }; |
| 945 | 195 | ||
| 946 | pub const sigset_t = c_uint; | ||
| 947 | pub const empty_sigset: sigset_t = 0; | ||
| 948 | |||
| 949 | pub const E = enum(u16) { | 196 | pub const E = enum(u16) { |
| 950 | /// No error occurred. | 197 | /// No error occurred. |
| 951 | SUCCESS = 0, | 198 | SUCCESS = 0, |
| ... | @@ -1070,327 +317,10 @@ pub const E = enum(u16) { | ... | @@ -1070,327 +317,10 @@ pub const E = enum(u16) { |
| 1070 | _, | 317 | _, |
| 1071 | }; | 318 | }; |
| 1072 | 319 | ||
| 1073 | const _MAX_PAGE_SHIFT = switch (builtin.cpu.arch) { | 320 | pub const MAX_PAGE_SHIFT = switch (builtin.cpu.arch) { |
| 1074 | .x86 => 12, | 321 | .x86 => 12, |
| 1075 | .sparc64 => 13, | 322 | .sparc64 => 13, |
| 1076 | }; | 323 | }; |
| 1077 | pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT; | ||
| 1078 | pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4; | ||
| 1079 | |||
| 1080 | pub const SS_ONSTACK = 0x0001; | ||
| 1081 | pub const SS_DISABLE = 0x0004; | ||
| 1082 | |||
| 1083 | pub const stack_t = extern struct { | ||
| 1084 | sp: [*]u8, | ||
| 1085 | size: usize, | ||
| 1086 | flags: c_int, | ||
| 1087 | }; | ||
| 1088 | |||
| 1089 | pub const S = struct { | ||
| 1090 | pub const IFMT = 0o170000; | ||
| 1091 | |||
| 1092 | pub const IFIFO = 0o010000; | ||
| 1093 | pub const IFCHR = 0o020000; | ||
| 1094 | pub const IFDIR = 0o040000; | ||
| 1095 | pub const IFBLK = 0o060000; | ||
| 1096 | pub const IFREG = 0o100000; | ||
| 1097 | pub const IFLNK = 0o120000; | ||
| 1098 | pub const IFSOCK = 0o140000; | ||
| 1099 | |||
| 1100 | pub const ISUID = 0o4000; | ||
| 1101 | pub const ISGID = 0o2000; | ||
| 1102 | pub const ISVTX = 0o1000; | ||
| 1103 | pub const IRWXU = 0o700; | ||
| 1104 | pub const IRUSR = 0o400; | ||
| 1105 | pub const IWUSR = 0o200; | ||
| 1106 | pub const IXUSR = 0o100; | ||
| 1107 | pub const IRWXG = 0o070; | ||
| 1108 | pub const IRGRP = 0o040; | ||
| 1109 | pub const IWGRP = 0o020; | ||
| 1110 | pub const IXGRP = 0o010; | ||
| 1111 | pub const IRWXO = 0o007; | ||
| 1112 | pub const IROTH = 0o004; | ||
| 1113 | pub const IWOTH = 0o002; | ||
| 1114 | pub const IXOTH = 0o001; | ||
| 1115 | |||
| 1116 | pub fn ISFIFO(m: u32) bool { | ||
| 1117 | return m & IFMT == IFIFO; | ||
| 1118 | } | ||
| 1119 | |||
| 1120 | pub fn ISCHR(m: u32) bool { | ||
| 1121 | return m & IFMT == IFCHR; | ||
| 1122 | } | ||
| 1123 | |||
| 1124 | pub fn ISDIR(m: u32) bool { | ||
| 1125 | return m & IFMT == IFDIR; | ||
| 1126 | } | ||
| 1127 | |||
| 1128 | pub fn ISBLK(m: u32) bool { | ||
| 1129 | return m & IFMT == IFBLK; | ||
| 1130 | } | ||
| 1131 | |||
| 1132 | pub fn ISREG(m: u32) bool { | ||
| 1133 | return m & IFMT == IFREG; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | pub fn ISLNK(m: u32) bool { | ||
| 1137 | return m & IFMT == IFLNK; | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | pub fn ISSOCK(m: u32) bool { | ||
| 1141 | return m & IFMT == IFSOCK; | ||
| 1142 | } | ||
| 1143 | }; | ||
| 1144 | |||
| 1145 | pub const HOST_NAME_MAX = 255; | ||
| 1146 | |||
| 1147 | pub const IPPROTO = struct { | ||
| 1148 | /// dummy for IP | ||
| 1149 | pub const IP = 0; | ||
| 1150 | /// IP6 hop-by-hop options | ||
| 1151 | pub const HOPOPTS = IP; | ||
| 1152 | /// control message protocol | ||
| 1153 | pub const ICMP = 1; | ||
| 1154 | /// group mgmt protocol | ||
| 1155 | pub const IGMP = 2; | ||
| 1156 | /// gateway^2 (deprecated) | ||
| 1157 | pub const GGP = 3; | ||
| 1158 | /// IP header | ||
| 1159 | pub const IPV4 = IPIP; | ||
| 1160 | /// IP inside IP | ||
| 1161 | pub const IPIP = 4; | ||
| 1162 | /// tcp | ||
| 1163 | pub const TCP = 6; | ||
| 1164 | /// exterior gateway protocol | ||
| 1165 | pub const EGP = 8; | ||
| 1166 | /// pup | ||
| 1167 | pub const PUP = 12; | ||
| 1168 | /// user datagram protocol | ||
| 1169 | pub const UDP = 17; | ||
| 1170 | /// xns idp | ||
| 1171 | pub const IDP = 22; | ||
| 1172 | /// tp-4 w/ class negotiation | ||
| 1173 | pub const TP = 29; | ||
| 1174 | /// IP6 header | ||
| 1175 | pub const IPV6 = 41; | ||
| 1176 | /// IP6 routing header | ||
| 1177 | pub const ROUTING = 43; | ||
| 1178 | /// IP6 fragmentation header | ||
| 1179 | pub const FRAGMENT = 44; | ||
| 1180 | /// resource reservation | ||
| 1181 | pub const RSVP = 46; | ||
| 1182 | /// GRE encaps RFC 1701 | ||
| 1183 | pub const GRE = 47; | ||
| 1184 | /// encap. security payload | ||
| 1185 | pub const ESP = 50; | ||
| 1186 | /// authentication header | ||
| 1187 | pub const AH = 51; | ||
| 1188 | /// IP Mobility RFC 2004 | ||
| 1189 | pub const MOBILE = 55; | ||
| 1190 | /// IPv6 ICMP | ||
| 1191 | pub const IPV6_ICMP = 58; | ||
| 1192 | /// ICMP6 | ||
| 1193 | pub const ICMPV6 = 58; | ||
| 1194 | /// IP6 no next header | ||
| 1195 | pub const NONE = 59; | ||
| 1196 | /// IP6 destination option | ||
| 1197 | pub const DSTOPTS = 60; | ||
| 1198 | /// ISO cnlp | ||
| 1199 | pub const EON = 80; | ||
| 1200 | /// Ethernet-in-IP | ||
| 1201 | pub const ETHERIP = 97; | ||
| 1202 | /// encapsulation header | ||
| 1203 | pub const ENCAP = 98; | ||
| 1204 | /// Protocol indep. multicast | ||
| 1205 | pub const PIM = 103; | ||
| 1206 | /// IP Payload Comp. Protocol | ||
| 1207 | pub const IPCOMP = 108; | ||
| 1208 | /// VRRP RFC 2338 | ||
| 1209 | pub const VRRP = 112; | ||
| 1210 | /// Common Address Resolution Protocol | ||
| 1211 | pub const CARP = 112; | ||
| 1212 | /// PFSYNC | ||
| 1213 | pub const PFSYNC = 240; | ||
| 1214 | /// raw IP packet | ||
| 1215 | pub const RAW = 255; | ||
| 1216 | }; | ||
| 1217 | |||
| 1218 | pub const rlimit_resource = enum(c_int) { | ||
| 1219 | CPU, | ||
| 1220 | FSIZE, | ||
| 1221 | DATA, | ||
| 1222 | STACK, | ||
| 1223 | CORE, | ||
| 1224 | RSS, | ||
| 1225 | MEMLOCK, | ||
| 1226 | NPROC, | ||
| 1227 | NOFILE, | ||
| 1228 | |||
| 1229 | _, | ||
| 1230 | }; | ||
| 1231 | |||
| 1232 | pub const rlim_t = u64; | ||
| 1233 | |||
| 1234 | pub const RLIM = struct { | ||
| 1235 | /// No limit | ||
| 1236 | pub const INFINITY: rlim_t = (1 << 63) - 1; | ||
| 1237 | |||
| 1238 | pub const SAVED_MAX = INFINITY; | ||
| 1239 | pub const SAVED_CUR = INFINITY; | ||
| 1240 | }; | ||
| 1241 | |||
| 1242 | pub const rlimit = extern struct { | ||
| 1243 | /// Soft limit | ||
| 1244 | cur: rlim_t, | ||
| 1245 | /// Hard limit | ||
| 1246 | max: rlim_t, | ||
| 1247 | }; | ||
| 1248 | |||
| 1249 | pub const SHUT = struct { | ||
| 1250 | pub const RD = 0; | ||
| 1251 | pub const WR = 1; | ||
| 1252 | pub const RDWR = 2; | ||
| 1253 | }; | ||
| 1254 | |||
| 1255 | pub const nfds_t = c_uint; | ||
| 1256 | |||
| 1257 | pub const pollfd = extern struct { | ||
| 1258 | fd: fd_t, | ||
| 1259 | events: c_short, | ||
| 1260 | revents: c_short, | ||
| 1261 | }; | ||
| 1262 | |||
| 1263 | pub const POLL = struct { | ||
| 1264 | pub const IN = 0x0001; | ||
| 1265 | pub const PRI = 0x0002; | ||
| 1266 | pub const OUT = 0x0004; | ||
| 1267 | pub const ERR = 0x0008; | ||
| 1268 | pub const HUP = 0x0010; | ||
| 1269 | pub const NVAL = 0x0020; | ||
| 1270 | pub const RDNORM = 0x0040; | ||
| 1271 | pub const NORM = RDNORM; | ||
| 1272 | pub const WRNORM = OUT; | ||
| 1273 | pub const RDBAND = 0x0080; | ||
| 1274 | pub const WRBAND = 0x0100; | ||
| 1275 | }; | ||
| 1276 | |||
| 1277 | pub const CTL = struct { | ||
| 1278 | pub const UNSPEC = 0; | ||
| 1279 | pub const KERN = 1; | ||
| 1280 | pub const VM = 2; | ||
| 1281 | pub const FS = 3; | ||
| 1282 | pub const NET = 4; | ||
| 1283 | pub const DEBUG = 5; | ||
| 1284 | pub const HW = 6; | ||
| 1285 | pub const MACHDEP = 7; | ||
| 1286 | |||
| 1287 | pub const DDB = 9; | ||
| 1288 | pub const VFS = 10; | ||
| 1289 | }; | ||
| 1290 | |||
| 1291 | pub const KERN = struct { | ||
| 1292 | pub const OSTYPE = 1; | ||
| 1293 | pub const OSRELEASE = 2; | ||
| 1294 | pub const OSREV = 3; | ||
| 1295 | pub const VERSION = 4; | ||
| 1296 | pub const MAXVNODES = 5; | ||
| 1297 | pub const MAXPROC = 6; | ||
| 1298 | pub const MAXFILES = 7; | ||
| 1299 | pub const ARGMAX = 8; | ||
| 1300 | pub const SECURELVL = 9; | ||
| 1301 | pub const HOSTNAME = 10; | ||
| 1302 | pub const HOSTID = 11; | ||
| 1303 | pub const CLOCKRATE = 12; | ||
| 1304 | |||
| 1305 | pub const PROF = 16; | ||
| 1306 | pub const POSIX1 = 17; | ||
| 1307 | pub const NGROUPS = 18; | ||
| 1308 | pub const JOB_CONTROL = 19; | ||
| 1309 | pub const SAVED_IDS = 20; | ||
| 1310 | pub const BOOTTIME = 21; | ||
| 1311 | pub const DOMAINNAME = 22; | ||
| 1312 | pub const MAXPARTITIONS = 23; | ||
| 1313 | pub const RAWPARTITION = 24; | ||
| 1314 | pub const MAXTHREAD = 25; | ||
| 1315 | pub const NTHREADS = 26; | ||
| 1316 | pub const OSVERSION = 27; | ||
| 1317 | pub const SOMAXCONN = 28; | ||
| 1318 | pub const SOMINCONN = 29; | ||
| 1319 | |||
| 1320 | pub const NOSUIDCOREDUMP = 32; | ||
| 1321 | pub const FSYNC = 33; | ||
| 1322 | pub const SYSVMSG = 34; | ||
| 1323 | pub const SYSVSEM = 35; | ||
| 1324 | pub const SYSVSHM = 36; | ||
| 1325 | |||
| 1326 | pub const MSGBUFSIZE = 38; | ||
| 1327 | pub const MALLOCSTATS = 39; | ||
| 1328 | pub const CPTIME = 40; | ||
| 1329 | pub const NCHSTATS = 41; | ||
| 1330 | pub const FORKSTAT = 42; | ||
| 1331 | pub const NSELCOLL = 43; | ||
| 1332 | pub const TTY = 44; | ||
| 1333 | pub const CCPU = 45; | ||
| 1334 | pub const FSCALE = 46; | ||
| 1335 | pub const NPROCS = 47; | ||
| 1336 | pub const MSGBUF = 48; | ||
| 1337 | pub const POOL = 49; | ||
| 1338 | pub const STACKGAPRANDOM = 50; | ||
| 1339 | pub const SYSVIPC_INFO = 51; | ||
| 1340 | pub const ALLOWKMEM = 52; | ||
| 1341 | pub const WITNESSWATCH = 53; | ||
| 1342 | pub const SPLASSERT = 54; | ||
| 1343 | pub const PROC_ARGS = 55; | ||
| 1344 | pub const NFILES = 56; | ||
| 1345 | pub const TTYCOUNT = 57; | ||
| 1346 | pub const NUMVNODES = 58; | ||
| 1347 | pub const MBSTAT = 59; | ||
| 1348 | pub const WITNESS = 60; | ||
| 1349 | pub const SEMINFO = 61; | ||
| 1350 | pub const SHMINFO = 62; | ||
| 1351 | pub const INTRCNT = 63; | ||
| 1352 | pub const WATCHDOG = 64; | ||
| 1353 | pub const ALLOWDT = 65; | ||
| 1354 | pub const PROC = 66; | ||
| 1355 | pub const MAXCLUSTERS = 67; | ||
| 1356 | pub const EVCOUNT = 68; | ||
| 1357 | pub const TIMECOUNTER = 69; | ||
| 1358 | pub const MAXLOCKSPERUID = 70; | ||
| 1359 | pub const CPTIME2 = 71; | ||
| 1360 | pub const CACHEPCT = 72; | ||
| 1361 | pub const FILE = 73; | ||
| 1362 | pub const WXABORT = 74; | ||
| 1363 | pub const CONSDEV = 75; | ||
| 1364 | pub const NETLIVELOCKS = 76; | ||
| 1365 | pub const POOL_DEBUG = 77; | ||
| 1366 | pub const PROC_CWD = 78; | ||
| 1367 | pub const PROC_NOBROADCASTKILL = 79; | ||
| 1368 | pub const PROC_VMMAP = 80; | ||
| 1369 | pub const GLOBAL_PTRACE = 81; | ||
| 1370 | pub const CONSBUFSIZE = 82; | ||
| 1371 | pub const CONSBUF = 83; | ||
| 1372 | pub const AUDIO = 84; | ||
| 1373 | pub const CPUSTATS = 85; | ||
| 1374 | pub const PFSTATUS = 86; | ||
| 1375 | pub const TIMEOUT_STATS = 87; | ||
| 1376 | pub const UTC_OFFSET = 88; | ||
| 1377 | pub const VIDEO = 89; | ||
| 1378 | |||
| 1379 | pub const PROC_ALL = 0; | ||
| 1380 | pub const PROC_PID = 1; | ||
| 1381 | pub const PROC_PGRP = 2; | ||
| 1382 | pub const PROC_SESSION = 3; | ||
| 1383 | pub const PROC_TTY = 4; | ||
| 1384 | pub const PROC_UID = 5; | ||
| 1385 | pub const PROC_RUID = 6; | ||
| 1386 | pub const PROC_KTHREAD = 7; | ||
| 1387 | pub const PROC_SHOW_THREADS = 0x40000000; | ||
| 1388 | |||
| 1389 | pub const PROC_ARGV = 1; | ||
| 1390 | pub const PROC_NARGV = 2; | ||
| 1391 | pub const PROC_ENV = 3; | ||
| 1392 | pub const PROC_NENV = 4; | ||
| 1393 | }; | ||
| 1394 | 324 | ||
| 1395 | pub const HW = struct { | 325 | pub const HW = struct { |
| 1396 | pub const MACHINE = 1; | 326 | pub const MACHINE = 1; |
lib/std/c/solaris.zig+22-1479| ... | @@ -1,61 +1,29 @@ | ... | @@ -1,61 +1,29 @@ |
| 1 | const builtin = @import("builtin"); | ||
| 1 | const std = @import("../std.zig"); | 2 | const std = @import("../std.zig"); |
| 2 | const assert = std.debug.assert; | 3 | const assert = std.debug.assert; |
| 3 | const builtin = @import("builtin"); | 4 | const SO = std.c.SO; |
| 4 | const maxInt = std.math.maxInt; | 5 | const fd_t = std.c.fd_t; |
| 5 | const iovec = std.posix.iovec; | 6 | const gid_t = std.c.gid_t; |
| 6 | const iovec_const = std.posix.iovec_const; | 7 | const ino_t = std.c.ino_t; |
| 7 | const timezone = std.c.timezone; | 8 | const mode_t = std.c.mode_t; |
| 9 | const off_t = std.c.off_t; | ||
| 10 | const pid_t = std.c.pid_t; | ||
| 11 | const pthread_t = std.c.pthread_t; | ||
| 12 | const sockaddr = std.c.sockaddr; | ||
| 13 | const socklen_t = std.c.socklen_t; | ||
| 14 | const timespec = std.c.timespec; | ||
| 15 | const uid_t = std.c.uid_t; | ||
| 16 | const IFNAMESIZE = std.c.IFNAMESIZE; | ||
| 8 | 17 | ||
| 9 | extern "c" fn ___errno() *c_int; | 18 | comptime { |
| 10 | pub const _errno = ___errno; | 19 | assert(builtin.os.tag == .solaris or builtin.os.tag == .illumos); // Prevent access of std.c symbols on wrong OS. |
| 11 | 20 | } | |
| 12 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int; | ||
| 13 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; | ||
| 14 | 21 | ||
| 15 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | 22 | pub extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int; |
| 16 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 17 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: std.c.O) c_int; | ||
| 18 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ||
| 19 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | ||
| 20 | pub extern "c" fn sysconf(sc: c_int) i64; | 23 | pub extern "c" fn sysconf(sc: c_int) i64; |
| 21 | pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int; | ||
| 22 | pub extern "c" fn madvise(address: [*]u8, len: usize, advise: u32) c_int; | ||
| 23 | |||
| 24 | pub const pthread_attr_t = extern struct { | ||
| 25 | mutexattr: ?*anyopaque = null, | ||
| 26 | }; | ||
| 27 | pub const pthread_key_t = c_int; | ||
| 28 | 24 | ||
| 29 | pub const sem_t = extern struct { | ||
| 30 | count: u32 = 0, | ||
| 31 | type: u16 = 0, | ||
| 32 | magic: u16 = 0x534d, | ||
| 33 | __pad1: [3]u64 = [_]u64{0} ** 3, | ||
| 34 | __pad2: [2]u64 = [_]u64{0} ** 2, | ||
| 35 | }; | ||
| 36 | |||
| 37 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int; | ||
| 38 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int; | ||
| 39 | |||
| 40 | pub const blkcnt_t = i64; | ||
| 41 | pub const blksize_t = i32; | ||
| 42 | pub const clock_t = i64; | ||
| 43 | pub const dev_t = i32; | ||
| 44 | pub const fd_t = c_int; | ||
| 45 | pub const gid_t = u32; | ||
| 46 | pub const ino_t = u64; | ||
| 47 | pub const mode_t = u32; | ||
| 48 | pub const nlink_t = u32; | ||
| 49 | pub const off_t = i64; | ||
| 50 | pub const pid_t = i32; | ||
| 51 | pub const socklen_t = u32; | ||
| 52 | pub const time_t = i64; | ||
| 53 | pub const suseconds_t = i64; | ||
| 54 | pub const uid_t = u32; | ||
| 55 | pub const major_t = u32; | 25 | pub const major_t = u32; |
| 56 | pub const minor_t = u32; | 26 | pub const minor_t = u32; |
| 57 | pub const port_t = c_int; | ||
| 58 | pub const nfds_t = usize; | ||
| 59 | pub const id_t = i32; | 27 | pub const id_t = i32; |
| 60 | pub const taskid_t = id_t; | 28 | pub const taskid_t = id_t; |
| 61 | pub const projid_t = id_t; | 29 | pub const projid_t = id_t; |
| ... | @@ -63,896 +31,18 @@ pub const poolid_t = id_t; | ... | @@ -63,896 +31,18 @@ pub const poolid_t = id_t; |
| 63 | pub const zoneid_t = id_t; | 31 | pub const zoneid_t = id_t; |
| 64 | pub const ctid_t = id_t; | 32 | pub const ctid_t = id_t; |
| 65 | 33 | ||
| 66 | pub const dl_phdr_info = extern struct { | ||
| 67 | dlpi_addr: std.elf.Addr, | ||
| 68 | dlpi_name: ?[*:0]const u8, | ||
| 69 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 70 | dlpi_phnum: std.elf.Half, | ||
| 71 | /// Incremented when a new object is mapped into the process. | ||
| 72 | dlpi_adds: u64, | ||
| 73 | /// Incremented when an object is unmapped from the process. | ||
| 74 | dlpi_subs: u64, | ||
| 75 | }; | ||
| 76 | |||
| 77 | pub const RTLD = struct { | ||
| 78 | pub const LAZY = 0x00001; | ||
| 79 | pub const NOW = 0x00002; | ||
| 80 | pub const NOLOAD = 0x00004; | ||
| 81 | pub const GLOBAL = 0x00100; | ||
| 82 | pub const LOCAL = 0x00000; | ||
| 83 | pub const PARENT = 0x00200; | ||
| 84 | pub const GROUP = 0x00400; | ||
| 85 | pub const WORLD = 0x00800; | ||
| 86 | pub const NODELETE = 0x01000; | ||
| 87 | pub const FIRST = 0x02000; | ||
| 88 | pub const CONFGEN = 0x10000; | ||
| 89 | |||
| 90 | pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); | ||
| 91 | pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); | ||
| 92 | pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); | ||
| 93 | pub const PROBE = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -4))))); | ||
| 94 | }; | ||
| 95 | |||
| 96 | pub const Flock = extern struct { | ||
| 97 | type: c_short, | ||
| 98 | whence: c_short, | ||
| 99 | start: off_t, | ||
| 100 | // len == 0 means until end of file. | ||
| 101 | len: off_t, | ||
| 102 | sysid: c_int, | ||
| 103 | pid: pid_t, | ||
| 104 | __pad: [4]c_long, | ||
| 105 | }; | ||
| 106 | |||
| 107 | pub const utsname = extern struct { | ||
| 108 | sysname: [256:0]u8, | ||
| 109 | nodename: [256:0]u8, | ||
| 110 | release: [256:0]u8, | ||
| 111 | version: [256:0]u8, | ||
| 112 | machine: [256:0]u8, | ||
| 113 | domainname: [256:0]u8, | ||
| 114 | }; | ||
| 115 | |||
| 116 | pub const addrinfo = extern struct { | ||
| 117 | flags: i32, | ||
| 118 | family: i32, | ||
| 119 | socktype: i32, | ||
| 120 | protocol: i32, | ||
| 121 | addrlen: socklen_t, | ||
| 122 | canonname: ?[*:0]u8, | ||
| 123 | addr: ?*sockaddr, | ||
| 124 | next: ?*addrinfo, | ||
| 125 | }; | ||
| 126 | |||
| 127 | pub const EAI = enum(c_int) { | ||
| 128 | /// address family for hostname not supported | ||
| 129 | ADDRFAMILY = 1, | ||
| 130 | /// name could not be resolved at this time | ||
| 131 | AGAIN = 2, | ||
| 132 | /// flags parameter had an invalid value | ||
| 133 | BADFLAGS = 3, | ||
| 134 | /// non-recoverable failure in name resolution | ||
| 135 | FAIL = 4, | ||
| 136 | /// address family not recognized | ||
| 137 | FAMILY = 5, | ||
| 138 | /// memory allocation failure | ||
| 139 | MEMORY = 6, | ||
| 140 | /// no address associated with hostname | ||
| 141 | NODATA = 7, | ||
| 142 | /// name does not resolve | ||
| 143 | NONAME = 8, | ||
| 144 | /// service not recognized for socket type | ||
| 145 | SERVICE = 9, | ||
| 146 | /// intended socket type was not recognized | ||
| 147 | SOCKTYPE = 10, | ||
| 148 | /// system error returned in errno | ||
| 149 | SYSTEM = 11, | ||
| 150 | /// argument buffer overflow | ||
| 151 | OVERFLOW = 12, | ||
| 152 | /// resolved protocol is unknown | ||
| 153 | PROTOCOL = 13, | ||
| 154 | |||
| 155 | _, | ||
| 156 | }; | ||
| 157 | |||
| 158 | pub const EAI_MAX = 14; | ||
| 159 | |||
| 160 | pub const msghdr = extern struct { | ||
| 161 | /// optional address | ||
| 162 | msg_name: ?*sockaddr, | ||
| 163 | /// size of address | ||
| 164 | msg_namelen: socklen_t, | ||
| 165 | /// scatter/gather array | ||
| 166 | msg_iov: [*]iovec, | ||
| 167 | /// # elements in msg_iov | ||
| 168 | msg_iovlen: i32, | ||
| 169 | /// ancillary data | ||
| 170 | msg_control: ?*anyopaque, | ||
| 171 | /// ancillary data buffer len | ||
| 172 | msg_controllen: socklen_t, | ||
| 173 | /// flags on received message | ||
| 174 | msg_flags: i32, | ||
| 175 | }; | ||
| 176 | |||
| 177 | pub const msghdr_const = extern struct { | ||
| 178 | /// optional address | ||
| 179 | msg_name: ?*const sockaddr, | ||
| 180 | /// size of address | ||
| 181 | msg_namelen: socklen_t, | ||
| 182 | /// scatter/gather array | ||
| 183 | msg_iov: [*]const iovec_const, | ||
| 184 | /// # elements in msg_iov | ||
| 185 | msg_iovlen: i32, | ||
| 186 | /// ancillary data | ||
| 187 | msg_control: ?*const anyopaque, | ||
| 188 | /// ancillary data buffer len | ||
| 189 | msg_controllen: socklen_t, | ||
| 190 | /// flags on received message | ||
| 191 | msg_flags: i32, | ||
| 192 | }; | ||
| 193 | |||
| 194 | pub const cmsghdr = extern struct { | 34 | pub const cmsghdr = extern struct { |
| 195 | cmsg_len: socklen_t, | 35 | len: socklen_t, |
| 196 | cmsg_level: i32, | 36 | level: i32, |
| 197 | cmsg_type: i32, | 37 | type: i32, |
| 198 | }; | 38 | }; |
| 199 | 39 | ||
| 200 | /// The stat structure used by libc. | ||
| 201 | pub const Stat = extern struct { | ||
| 202 | dev: dev_t, | ||
| 203 | ino: ino_t, | ||
| 204 | mode: mode_t, | ||
| 205 | nlink: nlink_t, | ||
| 206 | uid: uid_t, | ||
| 207 | gid: gid_t, | ||
| 208 | rdev: dev_t, | ||
| 209 | size: off_t, | ||
| 210 | atim: timespec, | ||
| 211 | mtim: timespec, | ||
| 212 | ctim: timespec, | ||
| 213 | blksize: blksize_t, | ||
| 214 | blocks: blkcnt_t, | ||
| 215 | fstype: [16]u8, | ||
| 216 | |||
| 217 | pub fn atime(self: @This()) timespec { | ||
| 218 | return self.atim; | ||
| 219 | } | ||
| 220 | |||
| 221 | pub fn mtime(self: @This()) timespec { | ||
| 222 | return self.mtim; | ||
| 223 | } | ||
| 224 | |||
| 225 | pub fn ctime(self: @This()) timespec { | ||
| 226 | return self.ctim; | ||
| 227 | } | ||
| 228 | }; | ||
| 229 | |||
| 230 | pub const timespec = extern struct { | ||
| 231 | tv_sec: i64, | ||
| 232 | tv_nsec: isize, | ||
| 233 | }; | ||
| 234 | |||
| 235 | pub const timeval = extern struct { | ||
| 236 | /// seconds | ||
| 237 | tv_sec: time_t, | ||
| 238 | /// microseconds | ||
| 239 | tv_usec: suseconds_t, | ||
| 240 | }; | ||
| 241 | |||
| 242 | pub const MAXNAMLEN = 511; | ||
| 243 | |||
| 244 | pub const dirent = extern struct { | ||
| 245 | /// Inode number of entry. | ||
| 246 | ino: ino_t, | ||
| 247 | /// Offset of this entry on disk. | ||
| 248 | off: off_t, | ||
| 249 | /// Length of this record. | ||
| 250 | reclen: u16, | ||
| 251 | /// File name. | ||
| 252 | name: [MAXNAMLEN:0]u8, | ||
| 253 | }; | ||
| 254 | |||
| 255 | pub const SOCK = struct { | ||
| 256 | /// Datagram. | ||
| 257 | pub const DGRAM = 1; | ||
| 258 | /// STREAM. | ||
| 259 | pub const STREAM = 2; | ||
| 260 | /// Raw-protocol interface. | ||
| 261 | pub const RAW = 4; | ||
| 262 | /// Reliably-delivered message. | ||
| 263 | pub const RDM = 5; | ||
| 264 | /// Sequenced packed stream. | ||
| 265 | pub const SEQPACKET = 6; | ||
| 266 | |||
| 267 | pub const NONBLOCK = 0x100000; | ||
| 268 | pub const NDELAY = 0x200000; | ||
| 269 | pub const CLOEXEC = 0x080000; | ||
| 270 | }; | ||
| 271 | |||
| 272 | pub const SO = struct { | ||
| 273 | pub const DEBUG = 0x0001; | ||
| 274 | pub const ACCEPTCONN = 0x0002; | ||
| 275 | pub const REUSEADDR = 0x0004; | ||
| 276 | pub const KEEPALIVE = 0x0008; | ||
| 277 | pub const DONTROUTE = 0x0010; | ||
| 278 | pub const BROADCAST = 0x0020; | ||
| 279 | pub const USELOOPBACK = 0x0040; | ||
| 280 | pub const LINGER = 0x0080; | ||
| 281 | pub const OOBINLINE = 0x0100; | ||
| 282 | pub const DGRAM_ERRIND = 0x0200; | ||
| 283 | pub const RECVUCRED = 0x0400; | ||
| 284 | |||
| 285 | pub const SNDBUF = 0x1001; | ||
| 286 | pub const RCVBUF = 0x1002; | ||
| 287 | pub const SNDLOWAT = 0x1003; | ||
| 288 | pub const RCVLOWAT = 0x1004; | ||
| 289 | pub const SNDTIMEO = 0x1005; | ||
| 290 | pub const RCVTIMEO = 0x1006; | ||
| 291 | pub const ERROR = 0x1007; | ||
| 292 | pub const TYPE = 0x1008; | ||
| 293 | pub const PROTOTYPE = 0x1009; | ||
| 294 | pub const ANON_MLP = 0x100a; | ||
| 295 | pub const MAC_EXEMPT = 0x100b; | ||
| 296 | pub const DOMAIN = 0x100c; | ||
| 297 | pub const RCVPSH = 0x100d; | ||
| 298 | |||
| 299 | pub const SECATTR = 0x1011; | ||
| 300 | pub const TIMESTAMP = 0x1013; | ||
| 301 | pub const ALLZONES = 0x1014; | ||
| 302 | pub const EXCLBIND = 0x1015; | ||
| 303 | pub const MAC_IMPLICIT = 0x1016; | ||
| 304 | pub const VRRP = 0x1017; | ||
| 305 | }; | ||
| 306 | |||
| 307 | pub const SOMAXCONN = 128; | ||
| 308 | |||
| 309 | pub const SCM = struct { | 40 | pub const SCM = struct { |
| 310 | pub const UCRED = 0x1012; | 41 | pub const UCRED = 0x1012; |
| 311 | pub const RIGHTS = 0x1010; | 42 | pub const RIGHTS = 0x1010; |
| 312 | pub const TIMESTAMP = SO.TIMESTAMP; | 43 | pub const TIMESTAMP = SO.TIMESTAMP; |
| 313 | }; | 44 | }; |
| 314 | 45 | ||
| 315 | pub const AF = struct { | ||
| 316 | pub const UNSPEC = 0; | ||
| 317 | pub const UNIX = 1; | ||
| 318 | pub const LOCAL = UNIX; | ||
| 319 | pub const FILE = UNIX; | ||
| 320 | pub const INET = 2; | ||
| 321 | pub const IMPLINK = 3; | ||
| 322 | pub const PUP = 4; | ||
| 323 | pub const CHAOS = 5; | ||
| 324 | pub const NS = 6; | ||
| 325 | pub const NBS = 7; | ||
| 326 | pub const ECMA = 8; | ||
| 327 | pub const DATAKIT = 9; | ||
| 328 | pub const CCITT = 10; | ||
| 329 | pub const SNA = 11; | ||
| 330 | pub const DECnet = 12; | ||
| 331 | pub const DLI = 13; | ||
| 332 | pub const LAT = 14; | ||
| 333 | pub const HYLINK = 15; | ||
| 334 | pub const APPLETALK = 16; | ||
| 335 | pub const NIT = 17; | ||
| 336 | pub const @"802" = 18; | ||
| 337 | pub const OSI = 19; | ||
| 338 | pub const X25 = 20; | ||
| 339 | pub const OSINET = 21; | ||
| 340 | pub const GOSIP = 22; | ||
| 341 | pub const IPX = 23; | ||
| 342 | pub const ROUTE = 24; | ||
| 343 | pub const LINK = 25; | ||
| 344 | pub const INET6 = 26; | ||
| 345 | pub const KEY = 27; | ||
| 346 | pub const NCA = 28; | ||
| 347 | pub const POLICY = 29; | ||
| 348 | pub const INET_OFFLOAD = 30; | ||
| 349 | pub const TRILL = 31; | ||
| 350 | pub const PACKET = 32; | ||
| 351 | pub const LX_NETLINK = 33; | ||
| 352 | pub const MAX = 33; | ||
| 353 | }; | ||
| 354 | |||
| 355 | pub const SOL = struct { | ||
| 356 | pub const SOCKET = 0xffff; | ||
| 357 | pub const ROUTE = 0xfffe; | ||
| 358 | pub const PACKET = 0xfffd; | ||
| 359 | pub const FILTER = 0xfffc; | ||
| 360 | }; | ||
| 361 | |||
| 362 | pub const PF = struct { | ||
| 363 | pub const UNSPEC = AF.UNSPEC; | ||
| 364 | pub const UNIX = AF.UNIX; | ||
| 365 | pub const LOCAL = UNIX; | ||
| 366 | pub const FILE = UNIX; | ||
| 367 | pub const INET = AF.INET; | ||
| 368 | pub const IMPLINK = AF.IMPLINK; | ||
| 369 | pub const PUP = AF.PUP; | ||
| 370 | pub const CHAOS = AF.CHAOS; | ||
| 371 | pub const NS = AF.NS; | ||
| 372 | pub const NBS = AF.NBS; | ||
| 373 | pub const ECMA = AF.ECMA; | ||
| 374 | pub const DATAKIT = AF.DATAKIT; | ||
| 375 | pub const CCITT = AF.CCITT; | ||
| 376 | pub const SNA = AF.SNA; | ||
| 377 | pub const DECnet = AF.DECnet; | ||
| 378 | pub const DLI = AF.DLI; | ||
| 379 | pub const LAT = AF.LAT; | ||
| 380 | pub const HYLINK = AF.HYLINK; | ||
| 381 | pub const APPLETALK = AF.APPLETALK; | ||
| 382 | pub const NIT = AF.NIT; | ||
| 383 | pub const @"802" = AF.@"802"; | ||
| 384 | pub const OSI = AF.OSI; | ||
| 385 | pub const X25 = AF.X25; | ||
| 386 | pub const OSINET = AF.OSINET; | ||
| 387 | pub const GOSIP = AF.GOSIP; | ||
| 388 | pub const IPX = AF.IPX; | ||
| 389 | pub const ROUTE = AF.ROUTE; | ||
| 390 | pub const LINK = AF.LINK; | ||
| 391 | pub const INET6 = AF.INET6; | ||
| 392 | pub const KEY = AF.KEY; | ||
| 393 | pub const NCA = AF.NCA; | ||
| 394 | pub const POLICY = AF.POLICY; | ||
| 395 | pub const TRILL = AF.TRILL; | ||
| 396 | pub const PACKET = AF.PACKET; | ||
| 397 | pub const LX_NETLINK = AF.LX_NETLINK; | ||
| 398 | pub const MAX = AF.MAX; | ||
| 399 | }; | ||
| 400 | |||
| 401 | pub const in_port_t = u16; | ||
| 402 | pub const sa_family_t = u16; | ||
| 403 | |||
| 404 | pub const sockaddr = extern struct { | ||
| 405 | /// address family | ||
| 406 | family: sa_family_t, | ||
| 407 | |||
| 408 | /// actually longer; address value | ||
| 409 | data: [14]u8, | ||
| 410 | |||
| 411 | pub const SS_MAXSIZE = 256; | ||
| 412 | pub const storage = extern struct { | ||
| 413 | family: sa_family_t align(8), | ||
| 414 | padding: [254]u8 = undefined, | ||
| 415 | |||
| 416 | comptime { | ||
| 417 | assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 418 | assert(@alignOf(storage) == 8); | ||
| 419 | } | ||
| 420 | }; | ||
| 421 | |||
| 422 | pub const in = extern struct { | ||
| 423 | family: sa_family_t = AF.INET, | ||
| 424 | port: in_port_t, | ||
| 425 | addr: u32, | ||
| 426 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 427 | }; | ||
| 428 | |||
| 429 | pub const in6 = extern struct { | ||
| 430 | family: sa_family_t = AF.INET6, | ||
| 431 | port: in_port_t, | ||
| 432 | flowinfo: u32, | ||
| 433 | addr: [16]u8, | ||
| 434 | scope_id: u32, | ||
| 435 | __src_id: u32 = 0, | ||
| 436 | }; | ||
| 437 | |||
| 438 | /// Definitions for UNIX IPC domain. | ||
| 439 | pub const un = extern struct { | ||
| 440 | family: sa_family_t = AF.UNIX, | ||
| 441 | path: [108]u8, | ||
| 442 | }; | ||
| 443 | }; | ||
| 444 | |||
| 445 | pub const AI = struct { | ||
| 446 | /// IPv4-mapped IPv6 address | ||
| 447 | pub const V4MAPPED = 0x0001; | ||
| 448 | pub const ALL = 0x0002; | ||
| 449 | /// only if any address is assigned | ||
| 450 | pub const ADDRCONFIG = 0x0004; | ||
| 451 | /// get address to use bind() | ||
| 452 | pub const PASSIVE = 0x0008; | ||
| 453 | /// fill ai_canonname | ||
| 454 | pub const CANONNAME = 0x0010; | ||
| 455 | /// prevent host name resolution | ||
| 456 | pub const NUMERICHOST = 0x0020; | ||
| 457 | /// prevent service name resolution | ||
| 458 | pub const NUMERICSERV = 0x0040; | ||
| 459 | }; | ||
| 460 | |||
| 461 | pub const NI = struct { | ||
| 462 | pub const NOFQDN = 0x0001; | ||
| 463 | pub const NUMERICHOST = 0x0002; | ||
| 464 | pub const NAMEREQD = 0x0004; | ||
| 465 | pub const NUMERICSERV = 0x0008; | ||
| 466 | pub const DGRAM = 0x0010; | ||
| 467 | pub const WITHSCOPEID = 0x0020; | ||
| 468 | pub const NUMERICSCOPE = 0x0040; | ||
| 469 | |||
| 470 | pub const MAXHOST = 1025; | ||
| 471 | pub const MAXSERV = 32; | ||
| 472 | }; | ||
| 473 | |||
| 474 | pub const NAME_MAX = 255; | ||
| 475 | pub const PATH_MAX = 1024; | ||
| 476 | pub const IOV_MAX = 1024; | ||
| 477 | |||
| 478 | pub const STDIN_FILENO = 0; | ||
| 479 | pub const STDOUT_FILENO = 1; | ||
| 480 | pub const STDERR_FILENO = 2; | ||
| 481 | |||
| 482 | pub const PROT = struct { | ||
| 483 | pub const NONE = 0; | ||
| 484 | pub const READ = 1; | ||
| 485 | pub const WRITE = 2; | ||
| 486 | pub const EXEC = 4; | ||
| 487 | }; | ||
| 488 | |||
| 489 | pub const CLOCK = struct { | ||
| 490 | pub const VIRTUAL = 1; | ||
| 491 | pub const THREAD_CPUTIME_ID = 2; | ||
| 492 | pub const REALTIME = 3; | ||
| 493 | pub const MONOTONIC = 4; | ||
| 494 | pub const PROCESS_CPUTIME_ID = 5; | ||
| 495 | pub const HIGHRES = MONOTONIC; | ||
| 496 | pub const PROF = THREAD_CPUTIME_ID; | ||
| 497 | }; | ||
| 498 | |||
| 499 | pub const MSF = struct { | ||
| 500 | pub const ASYNC = 1; | ||
| 501 | pub const INVALIDATE = 2; | ||
| 502 | pub const SYNC = 4; | ||
| 503 | }; | ||
| 504 | |||
| 505 | pub const MADV = struct { | ||
| 506 | /// no further special treatment | ||
| 507 | pub const NORMAL = 0; | ||
| 508 | /// expect random page references | ||
| 509 | pub const RANDOM = 1; | ||
| 510 | /// expect sequential page references | ||
| 511 | pub const SEQUENTIAL = 2; | ||
| 512 | /// will need these pages | ||
| 513 | pub const WILLNEED = 3; | ||
| 514 | /// don't need these pages | ||
| 515 | pub const DONTNEED = 4; | ||
| 516 | /// contents can be freed | ||
| 517 | pub const FREE = 5; | ||
| 518 | /// default access | ||
| 519 | pub const ACCESS_DEFAULT = 6; | ||
| 520 | /// next LWP to access heavily | ||
| 521 | pub const ACCESS_LWP = 7; | ||
| 522 | /// many processes to access heavily | ||
| 523 | pub const ACCESS_MANY = 8; | ||
| 524 | /// contents will be purged | ||
| 525 | pub const PURGE = 9; | ||
| 526 | }; | ||
| 527 | |||
| 528 | pub const W = struct { | ||
| 529 | pub const EXITED = 0o001; | ||
| 530 | pub const TRAPPED = 0o002; | ||
| 531 | pub const UNTRACED = 0o004; | ||
| 532 | pub const STOPPED = UNTRACED; | ||
| 533 | pub const CONTINUED = 0o010; | ||
| 534 | pub const NOHANG = 0o100; | ||
| 535 | pub const NOWAIT = 0o200; | ||
| 536 | |||
| 537 | pub fn EXITSTATUS(s: u32) u8 { | ||
| 538 | return @as(u8, @intCast((s >> 8) & 0xff)); | ||
| 539 | } | ||
| 540 | pub fn TERMSIG(s: u32) u32 { | ||
| 541 | return s & 0x7f; | ||
| 542 | } | ||
| 543 | pub fn STOPSIG(s: u32) u32 { | ||
| 544 | return EXITSTATUS(s); | ||
| 545 | } | ||
| 546 | pub fn IFEXITED(s: u32) bool { | ||
| 547 | return TERMSIG(s) == 0; | ||
| 548 | } | ||
| 549 | |||
| 550 | pub fn IFCONTINUED(s: u32) bool { | ||
| 551 | return ((s & 0o177777) == 0o177777); | ||
| 552 | } | ||
| 553 | |||
| 554 | pub fn IFSTOPPED(s: u32) bool { | ||
| 555 | return (s & 0x00ff != 0o177) and !(s & 0xff00 != 0); | ||
| 556 | } | ||
| 557 | |||
| 558 | pub fn IFSIGNALED(s: u32) bool { | ||
| 559 | return s & 0x00ff > 0 and s & 0xff00 == 0; | ||
| 560 | } | ||
| 561 | }; | ||
| 562 | |||
| 563 | pub const SA = struct { | ||
| 564 | pub const ONSTACK = 0x00000001; | ||
| 565 | pub const RESETHAND = 0x00000002; | ||
| 566 | pub const RESTART = 0x00000004; | ||
| 567 | pub const SIGINFO = 0x00000008; | ||
| 568 | pub const NODEFER = 0x00000010; | ||
| 569 | pub const NOCLDWAIT = 0x00010000; | ||
| 570 | }; | ||
| 571 | |||
| 572 | // access function | ||
| 573 | pub const F_OK = 0; // test for existence of file | ||
| 574 | pub const X_OK = 1; // test for execute or search permission | ||
| 575 | pub const W_OK = 2; // test for write permission | ||
| 576 | pub const R_OK = 4; // test for read permission | ||
| 577 | |||
| 578 | pub const F = struct { | ||
| 579 | /// Unlock a previously locked region | ||
| 580 | pub const ULOCK = 0; | ||
| 581 | /// Lock a region for exclusive use | ||
| 582 | pub const LOCK = 1; | ||
| 583 | /// Test and lock a region for exclusive use | ||
| 584 | pub const TLOCK = 2; | ||
| 585 | /// Test a region for other processes locks | ||
| 586 | pub const TEST = 3; | ||
| 587 | |||
| 588 | /// Duplicate fildes | ||
| 589 | pub const DUPFD = 0; | ||
| 590 | /// Get fildes flags | ||
| 591 | pub const GETFD = 1; | ||
| 592 | /// Set fildes flags | ||
| 593 | pub const SETFD = 2; | ||
| 594 | /// Get file flags | ||
| 595 | pub const GETFL = 3; | ||
| 596 | /// Get file flags including open-only flags | ||
| 597 | pub const GETXFL = 45; | ||
| 598 | /// Set file flags | ||
| 599 | pub const SETFL = 4; | ||
| 600 | |||
| 601 | /// Unused | ||
| 602 | pub const CHKFL = 8; | ||
| 603 | /// Duplicate fildes at third arg | ||
| 604 | pub const DUP2FD = 9; | ||
| 605 | /// Like DUP2FD with O_CLOEXEC set EINVAL is fildes matches arg1 | ||
| 606 | pub const DUP2FD_CLOEXEC = 36; | ||
| 607 | /// Like DUPFD with O_CLOEXEC set | ||
| 608 | pub const DUPFD_CLOEXEC = 37; | ||
| 609 | |||
| 610 | /// Is the file desc. a stream ? | ||
| 611 | pub const ISSTREAM = 13; | ||
| 612 | /// Turn on private access to file | ||
| 613 | pub const PRIV = 15; | ||
| 614 | /// Turn off private access to file | ||
| 615 | pub const NPRIV = 16; | ||
| 616 | /// UFS quota call | ||
| 617 | pub const QUOTACTL = 17; | ||
| 618 | /// Get number of BLKSIZE blocks allocated | ||
| 619 | pub const BLOCKS = 18; | ||
| 620 | /// Get optimal I/O block size | ||
| 621 | pub const BLKSIZE = 19; | ||
| 622 | /// Get owner (socket emulation) | ||
| 623 | pub const GETOWN = 23; | ||
| 624 | /// Set owner (socket emulation) | ||
| 625 | pub const SETOWN = 24; | ||
| 626 | /// Object reuse revoke access to file desc. | ||
| 627 | pub const REVOKE = 25; | ||
| 628 | /// Does vp have NFS locks private to lock manager | ||
| 629 | pub const HASREMOTELOCKS = 26; | ||
| 630 | |||
| 631 | /// Set file lock | ||
| 632 | pub const SETLK = 6; | ||
| 633 | /// Set file lock and wait | ||
| 634 | pub const SETLKW = 7; | ||
| 635 | /// Allocate file space | ||
| 636 | pub const ALLOCSP = 10; | ||
| 637 | /// Free file space | ||
| 638 | pub const FREESP = 11; | ||
| 639 | /// Get file lock | ||
| 640 | pub const GETLK = 14; | ||
| 641 | /// Get file lock owned by file | ||
| 642 | pub const OFD_GETLK = 47; | ||
| 643 | /// Set file lock owned by file | ||
| 644 | pub const OFD_SETLK = 48; | ||
| 645 | /// Set file lock owned by file and wait | ||
| 646 | pub const OFD_SETLKW = 49; | ||
| 647 | /// Set a file share reservation | ||
| 648 | pub const SHARE = 40; | ||
| 649 | /// Remove a file share reservation | ||
| 650 | pub const UNSHARE = 41; | ||
| 651 | /// Create Poison FD | ||
| 652 | pub const BADFD = 46; | ||
| 653 | |||
| 654 | /// Read lock | ||
| 655 | pub const RDLCK = 1; | ||
| 656 | /// Write lock | ||
| 657 | pub const WRLCK = 2; | ||
| 658 | /// Remove lock(s) | ||
| 659 | pub const UNLCK = 3; | ||
| 660 | /// remove remote locks for a given system | ||
| 661 | pub const UNLKSYS = 4; | ||
| 662 | |||
| 663 | // f_access values | ||
| 664 | /// Read-only share access | ||
| 665 | pub const RDACC = 0x1; | ||
| 666 | /// Write-only share access | ||
| 667 | pub const WRACC = 0x2; | ||
| 668 | /// Read-Write share access | ||
| 669 | pub const RWACC = 0x3; | ||
| 670 | |||
| 671 | // f_deny values | ||
| 672 | /// Don't deny others access | ||
| 673 | pub const NODNY = 0x0; | ||
| 674 | /// Deny others read share access | ||
| 675 | pub const RDDNY = 0x1; | ||
| 676 | /// Deny others write share access | ||
| 677 | pub const WRDNY = 0x2; | ||
| 678 | /// Deny others read or write share access | ||
| 679 | pub const RWDNY = 0x3; | ||
| 680 | /// private flag: Deny delete share access | ||
| 681 | pub const RMDNY = 0x4; | ||
| 682 | }; | ||
| 683 | |||
| 684 | pub const LOCK = struct { | ||
| 685 | pub const SH = 1; | ||
| 686 | pub const EX = 2; | ||
| 687 | pub const NB = 4; | ||
| 688 | pub const UN = 8; | ||
| 689 | }; | ||
| 690 | |||
| 691 | pub const FD_CLOEXEC = 1; | ||
| 692 | |||
| 693 | pub const SEEK = struct { | ||
| 694 | pub const SET = 0; | ||
| 695 | pub const CUR = 1; | ||
| 696 | pub const END = 2; | ||
| 697 | pub const DATA = 3; | ||
| 698 | pub const HOLE = 4; | ||
| 699 | }; | ||
| 700 | |||
| 701 | fn tioc(t: u16, num: u8) u16 { | ||
| 702 | return (t << 8) | num; | ||
| 703 | } | ||
| 704 | |||
| 705 | pub const T = struct { | ||
| 706 | pub const CGETA = tioc('T', 1); | ||
| 707 | pub const CSETA = tioc('T', 2); | ||
| 708 | pub const CSETAW = tioc('T', 3); | ||
| 709 | pub const CSETAF = tioc('T', 4); | ||
| 710 | pub const CSBRK = tioc('T', 5); | ||
| 711 | pub const CXONC = tioc('T', 6); | ||
| 712 | pub const CFLSH = tioc('T', 7); | ||
| 713 | pub const IOCGWINSZ = tioc('T', 104); | ||
| 714 | pub const IOCSWINSZ = tioc('T', 103); | ||
| 715 | // Softcarrier ioctls | ||
| 716 | pub const IOCGSOFTCAR = tioc('T', 105); | ||
| 717 | pub const IOCSSOFTCAR = tioc('T', 106); | ||
| 718 | // termios ioctls | ||
| 719 | pub const CGETS = tioc('T', 13); | ||
| 720 | pub const CSETS = tioc('T', 14); | ||
| 721 | pub const CSANOW = tioc('T', 14); | ||
| 722 | pub const CSETSW = tioc('T', 15); | ||
| 723 | pub const CSADRAIN = tioc('T', 15); | ||
| 724 | pub const CSETSF = tioc('T', 16); | ||
| 725 | pub const IOCSETLD = tioc('T', 123); | ||
| 726 | pub const IOCGETLD = tioc('T', 124); | ||
| 727 | // NTP PPS ioctls | ||
| 728 | pub const IOCGPPS = tioc('T', 125); | ||
| 729 | pub const IOCSPPS = tioc('T', 126); | ||
| 730 | pub const IOCGPPSEV = tioc('T', 127); | ||
| 731 | |||
| 732 | pub const IOCGETD = tioc('t', 0); | ||
| 733 | pub const IOCSETD = tioc('t', 1); | ||
| 734 | pub const IOCHPCL = tioc('t', 2); | ||
| 735 | pub const IOCGETP = tioc('t', 8); | ||
| 736 | pub const IOCSETP = tioc('t', 9); | ||
| 737 | pub const IOCSETN = tioc('t', 10); | ||
| 738 | pub const IOCEXCL = tioc('t', 13); | ||
| 739 | pub const IOCNXCL = tioc('t', 14); | ||
| 740 | pub const IOCFLUSH = tioc('t', 16); | ||
| 741 | pub const IOCSETC = tioc('t', 17); | ||
| 742 | pub const IOCGETC = tioc('t', 18); | ||
| 743 | /// bis local mode bits | ||
| 744 | pub const IOCLBIS = tioc('t', 127); | ||
| 745 | /// bic local mode bits | ||
| 746 | pub const IOCLBIC = tioc('t', 126); | ||
| 747 | /// set entire local mode word | ||
| 748 | pub const IOCLSET = tioc('t', 125); | ||
| 749 | /// get local modes | ||
| 750 | pub const IOCLGET = tioc('t', 124); | ||
| 751 | /// set break bit | ||
| 752 | pub const IOCSBRK = tioc('t', 123); | ||
| 753 | /// clear break bit | ||
| 754 | pub const IOCCBRK = tioc('t', 122); | ||
| 755 | /// set data terminal ready | ||
| 756 | pub const IOCSDTR = tioc('t', 121); | ||
| 757 | /// clear data terminal ready | ||
| 758 | pub const IOCCDTR = tioc('t', 120); | ||
| 759 | /// set local special chars | ||
| 760 | pub const IOCSLTC = tioc('t', 117); | ||
| 761 | /// get local special chars | ||
| 762 | pub const IOCGLTC = tioc('t', 116); | ||
| 763 | /// driver output queue size | ||
| 764 | pub const IOCOUTQ = tioc('t', 115); | ||
| 765 | /// void tty association | ||
| 766 | pub const IOCNOTTY = tioc('t', 113); | ||
| 767 | /// get a ctty | ||
| 768 | pub const IOCSCTTY = tioc('t', 132); | ||
| 769 | /// stop output, like ^S | ||
| 770 | pub const IOCSTOP = tioc('t', 111); | ||
| 771 | /// start output, like ^Q | ||
| 772 | pub const IOCSTART = tioc('t', 110); | ||
| 773 | /// get pgrp of tty | ||
| 774 | pub const IOCGPGRP = tioc('t', 20); | ||
| 775 | /// set pgrp of tty | ||
| 776 | pub const IOCSPGRP = tioc('t', 21); | ||
| 777 | /// get session id on ctty | ||
| 778 | pub const IOCGSID = tioc('t', 22); | ||
| 779 | /// simulate terminal input | ||
| 780 | pub const IOCSTI = tioc('t', 23); | ||
| 781 | /// set all modem bits | ||
| 782 | pub const IOCMSET = tioc('t', 26); | ||
| 783 | /// bis modem bits | ||
| 784 | pub const IOCMBIS = tioc('t', 27); | ||
| 785 | /// bic modem bits | ||
| 786 | pub const IOCMBIC = tioc('t', 28); | ||
| 787 | /// get all modem bits | ||
| 788 | pub const IOCMGET = tioc('t', 29); | ||
| 789 | }; | ||
| 790 | |||
| 791 | pub const winsize = extern struct { | ||
| 792 | ws_row: u16, | ||
| 793 | ws_col: u16, | ||
| 794 | ws_xpixel: u16, | ||
| 795 | ws_ypixel: u16, | ||
| 796 | }; | ||
| 797 | |||
| 798 | const NSIG = 75; | ||
| 799 | |||
| 800 | pub const SIG = struct { | ||
| 801 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | ||
| 802 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); | ||
| 803 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | ||
| 804 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(2); | ||
| 805 | |||
| 806 | pub const WORDS = 4; | ||
| 807 | pub const MAXSIG = 75; | ||
| 808 | |||
| 809 | pub const SIG_BLOCK = 1; | ||
| 810 | pub const SIG_UNBLOCK = 2; | ||
| 811 | pub const SIG_SETMASK = 3; | ||
| 812 | |||
| 813 | pub const HUP = 1; | ||
| 814 | pub const INT = 2; | ||
| 815 | pub const QUIT = 3; | ||
| 816 | pub const ILL = 4; | ||
| 817 | pub const TRAP = 5; | ||
| 818 | pub const IOT = 6; | ||
| 819 | pub const ABRT = 6; | ||
| 820 | pub const EMT = 7; | ||
| 821 | pub const FPE = 8; | ||
| 822 | pub const KILL = 9; | ||
| 823 | pub const BUS = 10; | ||
| 824 | pub const SEGV = 11; | ||
| 825 | pub const SYS = 12; | ||
| 826 | pub const PIPE = 13; | ||
| 827 | pub const ALRM = 14; | ||
| 828 | pub const TERM = 15; | ||
| 829 | pub const USR1 = 16; | ||
| 830 | pub const USR2 = 17; | ||
| 831 | pub const CLD = 18; | ||
| 832 | pub const CHLD = 18; | ||
| 833 | pub const PWR = 19; | ||
| 834 | pub const WINCH = 20; | ||
| 835 | pub const URG = 21; | ||
| 836 | pub const POLL = 22; | ||
| 837 | pub const IO = .POLL; | ||
| 838 | pub const STOP = 23; | ||
| 839 | pub const TSTP = 24; | ||
| 840 | pub const CONT = 25; | ||
| 841 | pub const TTIN = 26; | ||
| 842 | pub const TTOU = 27; | ||
| 843 | pub const VTALRM = 28; | ||
| 844 | pub const PROF = 29; | ||
| 845 | pub const XCPU = 30; | ||
| 846 | pub const XFSZ = 31; | ||
| 847 | pub const WAITING = 32; | ||
| 848 | pub const LWP = 33; | ||
| 849 | pub const FREEZE = 34; | ||
| 850 | pub const THAW = 35; | ||
| 851 | pub const CANCEL = 36; | ||
| 852 | pub const LOST = 37; | ||
| 853 | pub const XRES = 38; | ||
| 854 | pub const JVM1 = 39; | ||
| 855 | pub const JVM2 = 40; | ||
| 856 | pub const INFO = 41; | ||
| 857 | |||
| 858 | pub const RTMIN = 42; | ||
| 859 | pub const RTMAX = 74; | ||
| 860 | |||
| 861 | pub inline fn IDX(sig: usize) usize { | ||
| 862 | return sig - 1; | ||
| 863 | } | ||
| 864 | pub inline fn WORD(sig: usize) usize { | ||
| 865 | return IDX(sig) >> 5; | ||
| 866 | } | ||
| 867 | pub inline fn BIT(sig: usize) usize { | ||
| 868 | return 1 << (IDX(sig) & 31); | ||
| 869 | } | ||
| 870 | pub inline fn VALID(sig: usize) usize { | ||
| 871 | return sig <= MAXSIG and sig > 0; | ||
| 872 | } | ||
| 873 | }; | ||
| 874 | |||
| 875 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. | ||
| 876 | pub const Sigaction = extern struct { | ||
| 877 | pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; | ||
| 878 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; | ||
| 879 | |||
| 880 | /// signal options | ||
| 881 | flags: c_uint, | ||
| 882 | /// signal handler | ||
| 883 | handler: extern union { | ||
| 884 | handler: ?handler_fn, | ||
| 885 | sigaction: ?sigaction_fn, | ||
| 886 | }, | ||
| 887 | /// signal mask to apply | ||
| 888 | mask: sigset_t, | ||
| 889 | }; | ||
| 890 | |||
| 891 | pub const sigval_t = extern union { | ||
| 892 | int: c_int, | ||
| 893 | ptr: ?*anyopaque, | ||
| 894 | }; | ||
| 895 | |||
| 896 | pub const siginfo_t = extern struct { | ||
| 897 | signo: c_int, | ||
| 898 | code: c_int, | ||
| 899 | errno: c_int, | ||
| 900 | // 64bit architectures insert 4bytes of padding here, this is done by | ||
| 901 | // correctly aligning the reason field | ||
| 902 | reason: extern union { | ||
| 903 | proc: extern struct { | ||
| 904 | pid: pid_t, | ||
| 905 | pdata: extern union { | ||
| 906 | kill: extern struct { | ||
| 907 | uid: uid_t, | ||
| 908 | value: sigval_t, | ||
| 909 | }, | ||
| 910 | cld: extern struct { | ||
| 911 | utime: clock_t, | ||
| 912 | status: c_int, | ||
| 913 | stime: clock_t, | ||
| 914 | }, | ||
| 915 | }, | ||
| 916 | contract: ctid_t, | ||
| 917 | zone: zoneid_t, | ||
| 918 | }, | ||
| 919 | fault: extern struct { | ||
| 920 | addr: *allowzero anyopaque, | ||
| 921 | trapno: c_int, | ||
| 922 | pc: ?*anyopaque, | ||
| 923 | }, | ||
| 924 | file: extern struct { | ||
| 925 | // fd not currently available for SIGPOLL. | ||
| 926 | fd: c_int, | ||
| 927 | band: c_long, | ||
| 928 | }, | ||
| 929 | prof: extern struct { | ||
| 930 | addr: ?*anyopaque, | ||
| 931 | timestamp: timespec, | ||
| 932 | syscall: c_short, | ||
| 933 | sysarg: u8, | ||
| 934 | fault: u8, | ||
| 935 | args: [8]c_long, | ||
| 936 | state: [10]c_int, | ||
| 937 | }, | ||
| 938 | rctl: extern struct { | ||
| 939 | entity: i32, | ||
| 940 | }, | ||
| 941 | __pad: [256 - 4 * @sizeOf(c_int)]u8, | ||
| 942 | } align(@sizeOf(usize)), | ||
| 943 | }; | ||
| 944 | |||
| 945 | comptime { | ||
| 946 | std.debug.assert(@sizeOf(siginfo_t) == 256); | ||
| 947 | std.debug.assert(@alignOf(siginfo_t) == @sizeOf(usize)); | ||
| 948 | } | ||
| 949 | |||
| 950 | pub const sigset_t = extern struct { | ||
| 951 | __bits: [SIG.WORDS]u32, | ||
| 952 | }; | ||
| 953 | |||
| 954 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS }; | ||
| 955 | |||
| 956 | pub const fpregset_t = extern union { | 46 | pub const fpregset_t = extern union { |
| 957 | regs: [130]u32, | 47 | regs: [130]u32, |
| 958 | chip_state: extern struct { | 48 | chip_state: extern struct { |
| ... | @@ -976,393 +66,11 @@ pub const fpregset_t = extern union { | ... | @@ -976,393 +66,11 @@ pub const fpregset_t = extern union { |
| 976 | }, | 66 | }, |
| 977 | }; | 67 | }; |
| 978 | 68 | ||
| 979 | pub const mcontext_t = extern struct { | ||
| 980 | gregs: [28]u64, | ||
| 981 | fpregs: fpregset_t, | ||
| 982 | }; | ||
| 983 | |||
| 984 | pub const REG = struct { | ||
| 985 | pub const R15 = 0; | ||
| 986 | pub const R14 = 1; | ||
| 987 | pub const R13 = 2; | ||
| 988 | pub const R12 = 3; | ||
| 989 | pub const R11 = 4; | ||
| 990 | pub const R10 = 5; | ||
| 991 | pub const R9 = 6; | ||
| 992 | pub const R8 = 7; | ||
| 993 | pub const RDI = 8; | ||
| 994 | pub const RSI = 9; | ||
| 995 | pub const RBP = 10; | ||
| 996 | pub const RBX = 11; | ||
| 997 | pub const RDX = 12; | ||
| 998 | pub const RCX = 13; | ||
| 999 | pub const RAX = 14; | ||
| 1000 | pub const RIP = 17; | ||
| 1001 | pub const RSP = 20; | ||
| 1002 | }; | ||
| 1003 | |||
| 1004 | pub const ucontext_t = extern struct { | ||
| 1005 | flags: u64, | ||
| 1006 | link: ?*ucontext_t, | ||
| 1007 | sigmask: sigset_t, | ||
| 1008 | stack: stack_t, | ||
| 1009 | mcontext: mcontext_t, | ||
| 1010 | brand_data: [3]?*anyopaque, | ||
| 1011 | filler: [2]i64, | ||
| 1012 | }; | ||
| 1013 | |||
| 1014 | pub const GETCONTEXT = 0; | 69 | pub const GETCONTEXT = 0; |
| 1015 | pub const SETCONTEXT = 1; | 70 | pub const SETCONTEXT = 1; |
| 1016 | pub const GETUSTACK = 2; | 71 | pub const GETUSTACK = 2; |
| 1017 | pub const SETUSTACK = 3; | 72 | pub const SETUSTACK = 3; |
| 1018 | 73 | ||
| 1019 | pub const E = enum(u16) { | ||
| 1020 | /// No error occurred. | ||
| 1021 | SUCCESS = 0, | ||
| 1022 | /// Not super-user | ||
| 1023 | PERM = 1, | ||
| 1024 | /// No such file or directory | ||
| 1025 | NOENT = 2, | ||
| 1026 | /// No such process | ||
| 1027 | SRCH = 3, | ||
| 1028 | /// interrupted system call | ||
| 1029 | INTR = 4, | ||
| 1030 | /// I/O error | ||
| 1031 | IO = 5, | ||
| 1032 | /// No such device or address | ||
| 1033 | NXIO = 6, | ||
| 1034 | /// Arg list too long | ||
| 1035 | @"2BIG" = 7, | ||
| 1036 | /// Exec format error | ||
| 1037 | NOEXEC = 8, | ||
| 1038 | /// Bad file number | ||
| 1039 | BADF = 9, | ||
| 1040 | /// No children | ||
| 1041 | CHILD = 10, | ||
| 1042 | /// Resource temporarily unavailable. | ||
| 1043 | /// also: WOULDBLOCK: Operation would block. | ||
| 1044 | AGAIN = 11, | ||
| 1045 | /// Not enough core | ||
| 1046 | NOMEM = 12, | ||
| 1047 | /// Permission denied | ||
| 1048 | ACCES = 13, | ||
| 1049 | /// Bad address | ||
| 1050 | FAULT = 14, | ||
| 1051 | /// Block device required | ||
| 1052 | NOTBLK = 15, | ||
| 1053 | /// Mount device busy | ||
| 1054 | BUSY = 16, | ||
| 1055 | /// File exists | ||
| 1056 | EXIST = 17, | ||
| 1057 | /// Cross-device link | ||
| 1058 | XDEV = 18, | ||
| 1059 | /// No such device | ||
| 1060 | NODEV = 19, | ||
| 1061 | /// Not a directory | ||
| 1062 | NOTDIR = 20, | ||
| 1063 | /// Is a directory | ||
| 1064 | ISDIR = 21, | ||
| 1065 | /// Invalid argument | ||
| 1066 | INVAL = 22, | ||
| 1067 | /// File table overflow | ||
| 1068 | NFILE = 23, | ||
| 1069 | /// Too many open files | ||
| 1070 | MFILE = 24, | ||
| 1071 | /// Inappropriate ioctl for device | ||
| 1072 | NOTTY = 25, | ||
| 1073 | /// Text file busy | ||
| 1074 | TXTBSY = 26, | ||
| 1075 | /// File too large | ||
| 1076 | FBIG = 27, | ||
| 1077 | /// No space left on device | ||
| 1078 | NOSPC = 28, | ||
| 1079 | /// Illegal seek | ||
| 1080 | SPIPE = 29, | ||
| 1081 | /// Read only file system | ||
| 1082 | ROFS = 30, | ||
| 1083 | /// Too many links | ||
| 1084 | MLINK = 31, | ||
| 1085 | /// Broken pipe | ||
| 1086 | PIPE = 32, | ||
| 1087 | /// Math arg out of domain of func | ||
| 1088 | DOM = 33, | ||
| 1089 | /// Math result not representable | ||
| 1090 | RANGE = 34, | ||
| 1091 | /// No message of desired type | ||
| 1092 | NOMSG = 35, | ||
| 1093 | /// Identifier removed | ||
| 1094 | IDRM = 36, | ||
| 1095 | /// Channel number out of range | ||
| 1096 | CHRNG = 37, | ||
| 1097 | /// Level 2 not synchronized | ||
| 1098 | L2NSYNC = 38, | ||
| 1099 | /// Level 3 halted | ||
| 1100 | L3HLT = 39, | ||
| 1101 | /// Level 3 reset | ||
| 1102 | L3RST = 40, | ||
| 1103 | /// Link number out of range | ||
| 1104 | LNRNG = 41, | ||
| 1105 | /// Protocol driver not attached | ||
| 1106 | UNATCH = 42, | ||
| 1107 | /// No CSI structure available | ||
| 1108 | NOCSI = 43, | ||
| 1109 | /// Level 2 halted | ||
| 1110 | L2HLT = 44, | ||
| 1111 | /// Deadlock condition. | ||
| 1112 | DEADLK = 45, | ||
| 1113 | /// No record locks available. | ||
| 1114 | NOLCK = 46, | ||
| 1115 | /// Operation canceled | ||
| 1116 | CANCELED = 47, | ||
| 1117 | /// Operation not supported | ||
| 1118 | NOTSUP = 48, | ||
| 1119 | |||
| 1120 | // Filesystem Quotas | ||
| 1121 | /// Disc quota exceeded | ||
| 1122 | DQUOT = 49, | ||
| 1123 | |||
| 1124 | // Convergent Error Returns | ||
| 1125 | /// invalid exchange | ||
| 1126 | BADE = 50, | ||
| 1127 | /// invalid request descriptor | ||
| 1128 | BADR = 51, | ||
| 1129 | /// exchange full | ||
| 1130 | XFULL = 52, | ||
| 1131 | /// no anode | ||
| 1132 | NOANO = 53, | ||
| 1133 | /// invalid request code | ||
| 1134 | BADRQC = 54, | ||
| 1135 | /// invalid slot | ||
| 1136 | BADSLT = 55, | ||
| 1137 | /// file locking deadlock error | ||
| 1138 | DEADLOCK = 56, | ||
| 1139 | /// bad font file fmt | ||
| 1140 | BFONT = 57, | ||
| 1141 | |||
| 1142 | // Interprocess Robust Locks | ||
| 1143 | /// process died with the lock | ||
| 1144 | OWNERDEAD = 58, | ||
| 1145 | /// lock is not recoverable | ||
| 1146 | NOTRECOVERABLE = 59, | ||
| 1147 | /// locked lock was unmapped | ||
| 1148 | LOCKUNMAPPED = 72, | ||
| 1149 | /// Facility is not active | ||
| 1150 | NOTACTIVE = 73, | ||
| 1151 | /// multihop attempted | ||
| 1152 | MULTIHOP = 74, | ||
| 1153 | /// trying to read unreadable message | ||
| 1154 | BADMSG = 77, | ||
| 1155 | /// path name is too long | ||
| 1156 | NAMETOOLONG = 78, | ||
| 1157 | /// value too large to be stored in data type | ||
| 1158 | OVERFLOW = 79, | ||
| 1159 | /// given log. name not unique | ||
| 1160 | NOTUNIQ = 80, | ||
| 1161 | /// f.d. invalid for this operation | ||
| 1162 | BADFD = 81, | ||
| 1163 | /// Remote address changed | ||
| 1164 | REMCHG = 82, | ||
| 1165 | |||
| 1166 | // Stream Problems | ||
| 1167 | /// Device not a stream | ||
| 1168 | NOSTR = 60, | ||
| 1169 | /// no data (for no delay io) | ||
| 1170 | NODATA = 61, | ||
| 1171 | /// timer expired | ||
| 1172 | TIME = 62, | ||
| 1173 | /// out of streams resources | ||
| 1174 | NOSR = 63, | ||
| 1175 | /// Machine is not on the network | ||
| 1176 | NONET = 64, | ||
| 1177 | /// Package not installed | ||
| 1178 | NOPKG = 65, | ||
| 1179 | /// The object is remote | ||
| 1180 | REMOTE = 66, | ||
| 1181 | /// the link has been severed | ||
| 1182 | NOLINK = 67, | ||
| 1183 | /// advertise error | ||
| 1184 | ADV = 68, | ||
| 1185 | /// srmount error | ||
| 1186 | SRMNT = 69, | ||
| 1187 | /// Communication error on send | ||
| 1188 | COMM = 70, | ||
| 1189 | /// Protocol error | ||
| 1190 | PROTO = 71, | ||
| 1191 | |||
| 1192 | // Shared Library Problems | ||
| 1193 | /// Can't access a needed shared lib. | ||
| 1194 | LIBACC = 83, | ||
| 1195 | /// Accessing a corrupted shared lib. | ||
| 1196 | LIBBAD = 84, | ||
| 1197 | /// .lib section in a.out corrupted. | ||
| 1198 | LIBSCN = 85, | ||
| 1199 | /// Attempting to link in too many libs. | ||
| 1200 | LIBMAX = 86, | ||
| 1201 | /// Attempting to exec a shared library. | ||
| 1202 | LIBEXEC = 87, | ||
| 1203 | /// Illegal byte sequence. | ||
| 1204 | ILSEQ = 88, | ||
| 1205 | /// Unsupported file system operation | ||
| 1206 | NOSYS = 89, | ||
| 1207 | /// Symbolic link loop | ||
| 1208 | LOOP = 90, | ||
| 1209 | /// Restartable system call | ||
| 1210 | RESTART = 91, | ||
| 1211 | /// if pipe/FIFO, don't sleep in stream head | ||
| 1212 | STRPIPE = 92, | ||
| 1213 | /// directory not empty | ||
| 1214 | NOTEMPTY = 93, | ||
| 1215 | /// Too many users (for UFS) | ||
| 1216 | USERS = 94, | ||
| 1217 | |||
| 1218 | // BSD Networking Software | ||
| 1219 | // Argument Errors | ||
| 1220 | /// Socket operation on non-socket | ||
| 1221 | NOTSOCK = 95, | ||
| 1222 | /// Destination address required | ||
| 1223 | DESTADDRREQ = 96, | ||
| 1224 | /// Message too long | ||
| 1225 | MSGSIZE = 97, | ||
| 1226 | /// Protocol wrong type for socket | ||
| 1227 | PROTOTYPE = 98, | ||
| 1228 | /// Protocol not available | ||
| 1229 | NOPROTOOPT = 99, | ||
| 1230 | /// Protocol not supported | ||
| 1231 | PROTONOSUPPORT = 120, | ||
| 1232 | /// Socket type not supported | ||
| 1233 | SOCKTNOSUPPORT = 121, | ||
| 1234 | /// Operation not supported on socket | ||
| 1235 | OPNOTSUPP = 122, | ||
| 1236 | /// Protocol family not supported | ||
| 1237 | PFNOSUPPORT = 123, | ||
| 1238 | /// Address family not supported by | ||
| 1239 | AFNOSUPPORT = 124, | ||
| 1240 | /// Address already in use | ||
| 1241 | ADDRINUSE = 125, | ||
| 1242 | /// Can't assign requested address | ||
| 1243 | ADDRNOTAVAIL = 126, | ||
| 1244 | |||
| 1245 | // Operational Errors | ||
| 1246 | /// Network is down | ||
| 1247 | NETDOWN = 127, | ||
| 1248 | /// Network is unreachable | ||
| 1249 | NETUNREACH = 128, | ||
| 1250 | /// Network dropped connection because | ||
| 1251 | NETRESET = 129, | ||
| 1252 | /// Software caused connection abort | ||
| 1253 | CONNABORTED = 130, | ||
| 1254 | /// Connection reset by peer | ||
| 1255 | CONNRESET = 131, | ||
| 1256 | /// No buffer space available | ||
| 1257 | NOBUFS = 132, | ||
| 1258 | /// Socket is already connected | ||
| 1259 | ISCONN = 133, | ||
| 1260 | /// Socket is not connected | ||
| 1261 | NOTCONN = 134, | ||
| 1262 | /// Can't send after socket shutdown | ||
| 1263 | SHUTDOWN = 143, | ||
| 1264 | /// Too many references: can't splice | ||
| 1265 | TOOMANYREFS = 144, | ||
| 1266 | /// Connection timed out | ||
| 1267 | TIMEDOUT = 145, | ||
| 1268 | /// Connection refused | ||
| 1269 | CONNREFUSED = 146, | ||
| 1270 | /// Host is down | ||
| 1271 | HOSTDOWN = 147, | ||
| 1272 | /// No route to host | ||
| 1273 | HOSTUNREACH = 148, | ||
| 1274 | /// operation already in progress | ||
| 1275 | ALREADY = 149, | ||
| 1276 | /// operation now in progress | ||
| 1277 | INPROGRESS = 150, | ||
| 1278 | |||
| 1279 | // SUN Network File System | ||
| 1280 | /// Stale NFS file handle | ||
| 1281 | STALE = 151, | ||
| 1282 | |||
| 1283 | _, | ||
| 1284 | }; | ||
| 1285 | |||
| 1286 | pub const MINSIGSTKSZ = 2048; | ||
| 1287 | pub const SIGSTKSZ = 8192; | ||
| 1288 | |||
| 1289 | pub const SS_ONSTACK = 0x1; | ||
| 1290 | pub const SS_DISABLE = 0x2; | ||
| 1291 | |||
| 1292 | pub const stack_t = extern struct { | ||
| 1293 | sp: [*]u8, | ||
| 1294 | size: isize, | ||
| 1295 | flags: i32, | ||
| 1296 | }; | ||
| 1297 | |||
| 1298 | pub const S = struct { | ||
| 1299 | pub const IFMT = 0o170000; | ||
| 1300 | |||
| 1301 | pub const IFIFO = 0o010000; | ||
| 1302 | pub const IFCHR = 0o020000; | ||
| 1303 | pub const IFDIR = 0o040000; | ||
| 1304 | pub const IFBLK = 0o060000; | ||
| 1305 | pub const IFREG = 0o100000; | ||
| 1306 | pub const IFLNK = 0o120000; | ||
| 1307 | pub const IFSOCK = 0o140000; | ||
| 1308 | /// SunOS 2.6 Door | ||
| 1309 | pub const IFDOOR = 0o150000; | ||
| 1310 | /// Solaris 10 Event Port | ||
| 1311 | pub const IFPORT = 0o160000; | ||
| 1312 | |||
| 1313 | pub const ISUID = 0o4000; | ||
| 1314 | pub const ISGID = 0o2000; | ||
| 1315 | pub const ISVTX = 0o1000; | ||
| 1316 | pub const IRWXU = 0o700; | ||
| 1317 | pub const IRUSR = 0o400; | ||
| 1318 | pub const IWUSR = 0o200; | ||
| 1319 | pub const IXUSR = 0o100; | ||
| 1320 | pub const IRWXG = 0o070; | ||
| 1321 | pub const IRGRP = 0o040; | ||
| 1322 | pub const IWGRP = 0o020; | ||
| 1323 | pub const IXGRP = 0o010; | ||
| 1324 | pub const IRWXO = 0o007; | ||
| 1325 | pub const IROTH = 0o004; | ||
| 1326 | pub const IWOTH = 0o002; | ||
| 1327 | pub const IXOTH = 0o001; | ||
| 1328 | |||
| 1329 | pub fn ISFIFO(m: u32) bool { | ||
| 1330 | return m & IFMT == IFIFO; | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | pub fn ISCHR(m: u32) bool { | ||
| 1334 | return m & IFMT == IFCHR; | ||
| 1335 | } | ||
| 1336 | |||
| 1337 | pub fn ISDIR(m: u32) bool { | ||
| 1338 | return m & IFMT == IFDIR; | ||
| 1339 | } | ||
| 1340 | |||
| 1341 | pub fn ISBLK(m: u32) bool { | ||
| 1342 | return m & IFMT == IFBLK; | ||
| 1343 | } | ||
| 1344 | |||
| 1345 | pub fn ISREG(m: u32) bool { | ||
| 1346 | return m & IFMT == IFREG; | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | pub fn ISLNK(m: u32) bool { | ||
| 1350 | return m & IFMT == IFLNK; | ||
| 1351 | } | ||
| 1352 | |||
| 1353 | pub fn ISSOCK(m: u32) bool { | ||
| 1354 | return m & IFMT == IFSOCK; | ||
| 1355 | } | ||
| 1356 | |||
| 1357 | pub fn ISDOOR(m: u32) bool { | ||
| 1358 | return m & IFMT == IFDOOR; | ||
| 1359 | } | ||
| 1360 | |||
| 1361 | pub fn ISPORT(m: u32) bool { | ||
| 1362 | return m & IFMT == IFPORT; | ||
| 1363 | } | ||
| 1364 | }; | ||
| 1365 | |||
| 1366 | pub const POSIX_FADV = struct { | 74 | pub const POSIX_FADV = struct { |
| 1367 | pub const NORMAL = 0; | 75 | pub const NORMAL = 0; |
| 1368 | pub const RANDOM = 1; | 76 | pub const RANDOM = 1; |
| ... | @@ -1372,67 +80,6 @@ pub const POSIX_FADV = struct { | ... | @@ -1372,67 +80,6 @@ pub const POSIX_FADV = struct { |
| 1372 | pub const NOREUSE = 5; | 80 | pub const NOREUSE = 5; |
| 1373 | }; | 81 | }; |
| 1374 | 82 | ||
| 1375 | pub const HOST_NAME_MAX = 255; | ||
| 1376 | |||
| 1377 | pub const IPPROTO = struct { | ||
| 1378 | /// dummy for IP | ||
| 1379 | pub const IP = 0; | ||
| 1380 | /// Hop by hop header for IPv6 | ||
| 1381 | pub const HOPOPTS = 0; | ||
| 1382 | /// control message protocol | ||
| 1383 | pub const ICMP = 1; | ||
| 1384 | /// group control protocol | ||
| 1385 | pub const IGMP = 2; | ||
| 1386 | /// gateway^2 (deprecated) | ||
| 1387 | pub const GGP = 3; | ||
| 1388 | /// IP in IP encapsulation | ||
| 1389 | pub const ENCAP = 4; | ||
| 1390 | /// tcp | ||
| 1391 | pub const TCP = 6; | ||
| 1392 | /// exterior gateway protocol | ||
| 1393 | pub const EGP = 8; | ||
| 1394 | /// pup | ||
| 1395 | pub const PUP = 12; | ||
| 1396 | /// user datagram protocol | ||
| 1397 | pub const UDP = 17; | ||
| 1398 | /// xns idp | ||
| 1399 | pub const IDP = 22; | ||
| 1400 | /// IPv6 encapsulated in IP | ||
| 1401 | pub const IPV6 = 41; | ||
| 1402 | /// Routing header for IPv6 | ||
| 1403 | pub const ROUTING = 43; | ||
| 1404 | /// Fragment header for IPv6 | ||
| 1405 | pub const FRAGMENT = 44; | ||
| 1406 | /// rsvp | ||
| 1407 | pub const RSVP = 46; | ||
| 1408 | /// IPsec Encap. Sec. Payload | ||
| 1409 | pub const ESP = 50; | ||
| 1410 | /// IPsec Authentication Hdr. | ||
| 1411 | pub const AH = 51; | ||
| 1412 | /// ICMP for IPv6 | ||
| 1413 | pub const ICMPV6 = 58; | ||
| 1414 | /// No next header for IPv6 | ||
| 1415 | pub const NONE = 59; | ||
| 1416 | /// Destination options | ||
| 1417 | pub const DSTOPTS = 60; | ||
| 1418 | /// "hello" routing protocol | ||
| 1419 | pub const HELLO = 63; | ||
| 1420 | /// UNOFFICIAL net disk proto | ||
| 1421 | pub const ND = 77; | ||
| 1422 | /// ISO clnp | ||
| 1423 | pub const EON = 80; | ||
| 1424 | /// OSPF | ||
| 1425 | pub const OSPF = 89; | ||
| 1426 | /// PIM routing protocol | ||
| 1427 | pub const PIM = 103; | ||
| 1428 | /// Stream Control | ||
| 1429 | pub const SCTP = 132; | ||
| 1430 | /// raw IP packet | ||
| 1431 | pub const RAW = 255; | ||
| 1432 | /// Sockets Direct Protocol | ||
| 1433 | pub const PROTO_SDP = 257; | ||
| 1434 | }; | ||
| 1435 | |||
| 1436 | pub const priority = enum(c_int) { | 83 | pub const priority = enum(c_int) { |
| 1437 | PROCESS = 0, | 84 | PROCESS = 0, |
| 1438 | PGRP = 1, | 85 | PGRP = 1, |
| ... | @@ -1446,93 +93,6 @@ pub const priority = enum(c_int) { | ... | @@ -1446,93 +93,6 @@ pub const priority = enum(c_int) { |
| 1446 | CONTRACT = 9, | 93 | CONTRACT = 9, |
| 1447 | }; | 94 | }; |
| 1448 | 95 | ||
| 1449 | pub const rlimit_resource = enum(c_int) { | ||
| 1450 | CPU = 0, | ||
| 1451 | FSIZE = 1, | ||
| 1452 | DATA = 2, | ||
| 1453 | STACK = 3, | ||
| 1454 | CORE = 4, | ||
| 1455 | NOFILE = 5, | ||
| 1456 | VMEM = 6, | ||
| 1457 | _, | ||
| 1458 | |||
| 1459 | pub const AS: rlimit_resource = .VMEM; | ||
| 1460 | }; | ||
| 1461 | |||
| 1462 | pub const rlim_t = u64; | ||
| 1463 | |||
| 1464 | pub const RLIM = struct { | ||
| 1465 | /// No limit | ||
| 1466 | pub const INFINITY: rlim_t = (1 << 63) - 3; | ||
| 1467 | pub const SAVED_MAX: rlim_t = (1 << 63) - 2; | ||
| 1468 | pub const SAVED_CUR: rlim_t = (1 << 63) - 1; | ||
| 1469 | }; | ||
| 1470 | |||
| 1471 | pub const rlimit = extern struct { | ||
| 1472 | /// Soft limit | ||
| 1473 | cur: rlim_t, | ||
| 1474 | /// Hard limit | ||
| 1475 | max: rlim_t, | ||
| 1476 | }; | ||
| 1477 | |||
| 1478 | pub const rusage = extern struct { | ||
| 1479 | utime: timeval, | ||
| 1480 | stime: timeval, | ||
| 1481 | maxrss: isize, | ||
| 1482 | ixrss: isize, | ||
| 1483 | idrss: isize, | ||
| 1484 | isrss: isize, | ||
| 1485 | minflt: isize, | ||
| 1486 | majflt: isize, | ||
| 1487 | nswap: isize, | ||
| 1488 | inblock: isize, | ||
| 1489 | oublock: isize, | ||
| 1490 | msgsnd: isize, | ||
| 1491 | msgrcv: isize, | ||
| 1492 | nsignals: isize, | ||
| 1493 | nvcsw: isize, | ||
| 1494 | nivcsw: isize, | ||
| 1495 | |||
| 1496 | pub const SELF = 0; | ||
| 1497 | pub const CHILDREN = -1; | ||
| 1498 | pub const THREAD = 1; | ||
| 1499 | }; | ||
| 1500 | |||
| 1501 | pub const SHUT = struct { | ||
| 1502 | pub const RD = 0; | ||
| 1503 | pub const WR = 1; | ||
| 1504 | pub const RDWR = 2; | ||
| 1505 | }; | ||
| 1506 | |||
| 1507 | pub const pollfd = extern struct { | ||
| 1508 | fd: fd_t, | ||
| 1509 | events: i16, | ||
| 1510 | revents: i16, | ||
| 1511 | }; | ||
| 1512 | |||
| 1513 | /// Testable events (may be specified in ::pollfd::events). | ||
| 1514 | pub const POLL = struct { | ||
| 1515 | pub const IN = 0x0001; | ||
| 1516 | pub const PRI = 0x0002; | ||
| 1517 | pub const OUT = 0x0004; | ||
| 1518 | pub const RDNORM = 0x0040; | ||
| 1519 | pub const WRNORM = .OUT; | ||
| 1520 | pub const RDBAND = 0x0080; | ||
| 1521 | pub const WRBAND = 0x0100; | ||
| 1522 | /// Read-side hangup. | ||
| 1523 | pub const RDHUP = 0x4000; | ||
| 1524 | |||
| 1525 | /// Non-testable events (may not be specified in events). | ||
| 1526 | pub const ERR = 0x0008; | ||
| 1527 | pub const HUP = 0x0010; | ||
| 1528 | pub const NVAL = 0x0020; | ||
| 1529 | |||
| 1530 | /// Events to control `/dev/poll` (not specified in revents) | ||
| 1531 | pub const REMOVE = 0x0800; | ||
| 1532 | pub const ONESHOT = 0x1000; | ||
| 1533 | pub const ET = 0x2000; | ||
| 1534 | }; | ||
| 1535 | |||
| 1536 | /// Extensions to the ELF auxiliary vector. | 96 | /// Extensions to the ELF auxiliary vector. |
| 1537 | pub const AT_SUN = struct { | 97 | pub const AT_SUN = struct { |
| 1538 | /// effective user id | 98 | /// effective user id |
| ... | @@ -1594,7 +154,6 @@ pub const AF_SUN = struct { | ... | @@ -1594,7 +154,6 @@ pub const AF_SUN = struct { |
| 1594 | pub const NOPLM = 0x00000004; | 154 | pub const NOPLM = 0x00000004; |
| 1595 | }; | 155 | }; |
| 1596 | 156 | ||
| 1597 | // TODO: Add sysconf numbers when the other OSs do. | ||
| 1598 | pub const _SC = struct { | 157 | pub const _SC = struct { |
| 1599 | pub const NPROCESSORS_ONLN = 15; | 158 | pub const NPROCESSORS_ONLN = 15; |
| 1600 | }; | 159 | }; |
| ... | @@ -1702,17 +261,6 @@ pub const FILE_EVENT = struct { | ... | @@ -1702,17 +261,6 @@ pub const FILE_EVENT = struct { |
| 1702 | } | 261 | } |
| 1703 | }; | 262 | }; |
| 1704 | 263 | ||
| 1705 | pub const port_event = extern struct { | ||
| 1706 | events: u32, | ||
| 1707 | /// Event source. | ||
| 1708 | source: u16, | ||
| 1709 | __pad: u16, | ||
| 1710 | /// Source-specific object. | ||
| 1711 | object: ?*anyopaque, | ||
| 1712 | /// User cookie. | ||
| 1713 | cookie: ?*anyopaque, | ||
| 1714 | }; | ||
| 1715 | |||
| 1716 | pub const port_notify = extern struct { | 264 | pub const port_notify = extern struct { |
| 1717 | /// Bind request(s) to port. | 265 | /// Bind request(s) to port. |
| 1718 | port: u32, | 266 | port: u32, |
| ... | @@ -1734,9 +282,6 @@ pub const file_obj = extern struct { | ... | @@ -1734,9 +282,6 @@ pub const file_obj = extern struct { |
| 1734 | // struct ifreq is marked obsolete, with struct lifreq preferred for interface requests. | 282 | // struct ifreq is marked obsolete, with struct lifreq preferred for interface requests. |
| 1735 | // Here we alias lifreq to ifreq to avoid chainging existing code in os and x.os.IPv6. | 283 | // Here we alias lifreq to ifreq to avoid chainging existing code in os and x.os.IPv6. |
| 1736 | pub const SIOCGLIFINDEX = IOWR('i', 133, lifreq); | 284 | pub const SIOCGLIFINDEX = IOWR('i', 133, lifreq); |
| 1737 | pub const SIOCGIFINDEX = SIOCGLIFINDEX; | ||
| 1738 | pub const MAX_HDW_LEN = 64; | ||
| 1739 | pub const IFNAMESIZE = 32; | ||
| 1740 | 285 | ||
| 1741 | pub const lif_nd_req = extern struct { | 286 | pub const lif_nd_req = extern struct { |
| 1742 | addr: sockaddr.storage, | 287 | addr: sockaddr.storage, |
| ... | @@ -1746,7 +291,7 @@ pub const lif_nd_req = extern struct { | ... | @@ -1746,7 +291,7 @@ pub const lif_nd_req = extern struct { |
| 1746 | hdw_len: i32, | 291 | hdw_len: i32, |
| 1747 | flags: i32, | 292 | flags: i32, |
| 1748 | __pad: i32, | 293 | __pad: i32, |
| 1749 | hdw_addr: [MAX_HDW_LEN]u8, | 294 | hdw_addr: [64]u8, |
| 1750 | }; | 295 | }; |
| 1751 | 296 | ||
| 1752 | pub const lif_ifinfo_req = extern struct { | 297 | pub const lif_ifinfo_req = extern struct { |
| ... | @@ -1806,8 +351,6 @@ pub const lifreq = extern struct { | ... | @@ -1806,8 +351,6 @@ pub const lifreq = extern struct { |
| 1806 | }, | 351 | }, |
| 1807 | }; | 352 | }; |
| 1808 | 353 | ||
| 1809 | pub const ifreq = lifreq; | ||
| 1810 | |||
| 1811 | const IoCtlCommand = enum(u32) { | 354 | const IoCtlCommand = enum(u32) { |
| 1812 | none = 0x20000000, // no parameters | 355 | none = 0x20000000, // no parameters |
| 1813 | write = 0x40000000, // copy out parameters | 356 | write = 0x40000000, // copy out parameters |
lib/std/c/wasi.zig deleted-162| ... | @@ -1,162 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("../std.zig"); | ||
| 3 | const wasi = std.os.wasi; | ||
| 4 | |||
| 5 | extern threadlocal var errno: c_int; | ||
| 6 | |||
| 7 | pub fn _errno() *c_int { | ||
| 8 | return &errno; | ||
| 9 | } | ||
| 10 | |||
| 11 | pub const PATH_MAX = 4096; | ||
| 12 | |||
| 13 | pub const mode_t = u32; | ||
| 14 | pub const time_t = i64; | ||
| 15 | |||
| 16 | pub const timespec = extern struct { | ||
| 17 | tv_sec: time_t, | ||
| 18 | tv_nsec: isize, | ||
| 19 | |||
| 20 | pub fn fromTimestamp(tm: wasi.timestamp_t) timespec { | ||
| 21 | const tv_sec: wasi.timestamp_t = tm / 1_000_000_000; | ||
| 22 | const tv_nsec = tm - tv_sec * 1_000_000_000; | ||
| 23 | return .{ | ||
| 24 | .tv_sec = @as(time_t, @intCast(tv_sec)), | ||
| 25 | .tv_nsec = @as(isize, @intCast(tv_nsec)), | ||
| 26 | }; | ||
| 27 | } | ||
| 28 | |||
| 29 | pub fn toTimestamp(ts: timespec) wasi.timestamp_t { | ||
| 30 | return @as(wasi.timestamp_t, @intCast(ts.tv_sec * 1_000_000_000)) + | ||
| 31 | @as(wasi.timestamp_t, @intCast(ts.tv_nsec)); | ||
| 32 | } | ||
| 33 | }; | ||
| 34 | |||
| 35 | pub const STDIN_FILENO = 0; | ||
| 36 | pub const STDOUT_FILENO = 1; | ||
| 37 | pub const STDERR_FILENO = 2; | ||
| 38 | |||
| 39 | pub const E = wasi.errno_t; | ||
| 40 | |||
| 41 | pub const CLOCK = wasi.clockid_t; | ||
| 42 | pub const IOV_MAX = 1024; | ||
| 43 | pub const S = struct { | ||
| 44 | pub const IEXEC = @compileError("TODO audit this"); | ||
| 45 | pub const IFBLK = 0x6000; | ||
| 46 | pub const IFCHR = 0x2000; | ||
| 47 | pub const IFDIR = 0x4000; | ||
| 48 | pub const IFIFO = 0xc000; | ||
| 49 | pub const IFLNK = 0xa000; | ||
| 50 | pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK; | ||
| 51 | pub const IFREG = 0x8000; | ||
| 52 | /// There's no concept of UNIX domain socket but we define this value here | ||
| 53 | /// in order to line with other OSes. | ||
| 54 | pub const IFSOCK = 0x1; | ||
| 55 | }; | ||
| 56 | pub const fd_t = wasi.fd_t; | ||
| 57 | pub const pid_t = c_int; | ||
| 58 | pub const uid_t = u32; | ||
| 59 | pub const gid_t = u32; | ||
| 60 | pub const off_t = i64; | ||
| 61 | pub const ino_t = wasi.inode_t; | ||
| 62 | pub const dev_t = wasi.device_t; | ||
| 63 | pub const nlink_t = c_ulonglong; | ||
| 64 | pub const blksize_t = c_long; | ||
| 65 | pub const blkcnt_t = c_longlong; | ||
| 66 | |||
| 67 | pub const Stat = extern struct { | ||
| 68 | dev: dev_t, | ||
| 69 | ino: ino_t, | ||
| 70 | nlink: nlink_t, | ||
| 71 | mode: mode_t, | ||
| 72 | uid: uid_t, | ||
| 73 | gid: gid_t, | ||
| 74 | __pad0: c_uint = 0, | ||
| 75 | rdev: dev_t, | ||
| 76 | size: off_t, | ||
| 77 | blksize: blksize_t, | ||
| 78 | blocks: blkcnt_t, | ||
| 79 | atim: timespec, | ||
| 80 | mtim: timespec, | ||
| 81 | ctim: timespec, | ||
| 82 | __reserved: [3]c_longlong = [3]c_longlong{ 0, 0, 0 }, | ||
| 83 | |||
| 84 | pub fn atime(self: @This()) timespec { | ||
| 85 | return self.atim; | ||
| 86 | } | ||
| 87 | |||
| 88 | pub fn mtime(self: @This()) timespec { | ||
| 89 | return self.mtim; | ||
| 90 | } | ||
| 91 | |||
| 92 | pub fn ctime(self: @This()) timespec { | ||
| 93 | return self.ctim; | ||
| 94 | } | ||
| 95 | |||
| 96 | pub fn fromFilestat(stat: wasi.filestat_t) Stat { | ||
| 97 | return .{ | ||
| 98 | .dev = stat.dev, | ||
| 99 | .ino = stat.ino, | ||
| 100 | .mode = switch (stat.filetype) { | ||
| 101 | .UNKNOWN => 0, | ||
| 102 | .BLOCK_DEVICE => S.IFBLK, | ||
| 103 | .CHARACTER_DEVICE => S.IFCHR, | ||
| 104 | .DIRECTORY => S.IFDIR, | ||
| 105 | .REGULAR_FILE => S.IFREG, | ||
| 106 | .SOCKET_DGRAM => S.IFSOCK, | ||
| 107 | .SOCKET_STREAM => S.IFIFO, | ||
| 108 | .SYMBOLIC_LINK => S.IFLNK, | ||
| 109 | _ => 0, | ||
| 110 | }, | ||
| 111 | .nlink = stat.nlink, | ||
| 112 | .size = @intCast(stat.size), | ||
| 113 | .atim = timespec.fromTimestamp(stat.atim), | ||
| 114 | .mtim = timespec.fromTimestamp(stat.mtim), | ||
| 115 | .ctim = timespec.fromTimestamp(stat.ctim), | ||
| 116 | |||
| 117 | .uid = 0, | ||
| 118 | .gid = 0, | ||
| 119 | .rdev = 0, | ||
| 120 | .blksize = 0, | ||
| 121 | .blocks = 0, | ||
| 122 | }; | ||
| 123 | } | ||
| 124 | }; | ||
| 125 | |||
| 126 | pub const F = struct { | ||
| 127 | pub const GETFD = 1; | ||
| 128 | pub const SETFD = 2; | ||
| 129 | pub const GETFL = 3; | ||
| 130 | pub const SETFL = 4; | ||
| 131 | }; | ||
| 132 | |||
| 133 | pub const FD_CLOEXEC = 1; | ||
| 134 | |||
| 135 | pub const F_OK = 0; | ||
| 136 | pub const X_OK = 1; | ||
| 137 | pub const W_OK = 2; | ||
| 138 | pub const R_OK = 4; | ||
| 139 | |||
| 140 | pub const SEEK = struct { | ||
| 141 | pub const SET: wasi.whence_t = .SET; | ||
| 142 | pub const CUR: wasi.whence_t = .CUR; | ||
| 143 | pub const END: wasi.whence_t = .END; | ||
| 144 | }; | ||
| 145 | |||
| 146 | pub const nfds_t = usize; | ||
| 147 | |||
| 148 | pub const pollfd = extern struct { | ||
| 149 | fd: fd_t, | ||
| 150 | events: i16, | ||
| 151 | revents: i16, | ||
| 152 | }; | ||
| 153 | |||
| 154 | pub const POLL = struct { | ||
| 155 | pub const RDNORM = 0x1; | ||
| 156 | pub const WRNORM = 0x2; | ||
| 157 | pub const IN = RDNORM; | ||
| 158 | pub const OUT = WRNORM; | ||
| 159 | pub const ERR = 0x1000; | ||
| 160 | pub const HUP = 0x2000; | ||
| 161 | pub const NVAL = 0x4000; | ||
| 162 | }; | ||
lib/std/c/windows.zig deleted-226| ... | @@ -1,226 +0,0 @@ | ||
| 1 | //! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime). | ||
| 2 | const std = @import("../std.zig"); | ||
| 3 | const ws2_32 = std.os.windows.ws2_32; | ||
| 4 | const windows = std.os.windows; | ||
| 5 | |||
| 6 | pub extern "c" fn _errno() *c_int; | ||
| 7 | |||
| 8 | pub extern "c" fn _msize(memblock: ?*anyopaque) usize; | ||
| 9 | |||
| 10 | // TODO: copied the else case and removed the socket function (because its in ws2_32) | ||
| 11 | // need to verify which of these is actually supported on windows | ||
| 12 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | ||
| 13 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) 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 = windows.HANDLE; | ||
| 26 | pub const ino_t = windows.LARGE_INTEGER; | ||
| 27 | pub const pid_t = windows.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 Stat = @compileError("TODO windows Stat definition"); | ||
| 45 | |||
| 46 | pub const sig_atomic_t = c_int; | ||
| 47 | |||
| 48 | pub const sigset_t = @compileError("TODO windows sigset_t definition"); | ||
| 49 | pub const Sigaction = @compileError("TODO windows Sigaction definition"); | ||
| 50 | pub const timezone = @compileError("TODO windows timezone definition"); | ||
| 51 | pub const rusage = @compileError("TODO windows rusage definition"); | ||
| 52 | |||
| 53 | /// maximum signal number + 1 | ||
| 54 | pub const NSIG = 23; | ||
| 55 | |||
| 56 | /// Signal types | ||
| 57 | pub const SIG = struct { | ||
| 58 | /// interrupt | ||
| 59 | pub const INT = 2; | ||
| 60 | /// illegal instruction - invalid function image | ||
| 61 | pub const ILL = 4; | ||
| 62 | /// floating point exception | ||
| 63 | pub const FPE = 8; | ||
| 64 | /// segment violation | ||
| 65 | pub const SEGV = 11; | ||
| 66 | /// Software termination signal from kill | ||
| 67 | pub const TERM = 15; | ||
| 68 | /// Ctrl-Break sequence | ||
| 69 | pub const BREAK = 21; | ||
| 70 | /// abnormal termination triggered by abort call | ||
| 71 | pub const ABRT = 22; | ||
| 72 | /// SIGABRT compatible with other platforms, same as SIGABRT | ||
| 73 | pub const ABRT_COMPAT = 6; | ||
| 74 | |||
| 75 | // Signal action codes | ||
| 76 | /// default signal action | ||
| 77 | pub const DFL = 0; | ||
| 78 | /// ignore signal | ||
| 79 | pub const IGN = 1; | ||
| 80 | /// return current value | ||
| 81 | pub const GET = 2; | ||
| 82 | /// signal gets error | ||
| 83 | pub const SGE = 3; | ||
| 84 | /// acknowledge | ||
| 85 | pub const ACK = 4; | ||
| 86 | /// Signal error value (returned by signal call on error) | ||
| 87 | pub const ERR = -1; | ||
| 88 | }; | ||
| 89 | |||
| 90 | pub const SEEK = struct { | ||
| 91 | pub const SET = 0; | ||
| 92 | pub const CUR = 1; | ||
| 93 | pub const END = 2; | ||
| 94 | }; | ||
| 95 | |||
| 96 | /// Basic memory protection flags | ||
| 97 | pub const PROT = struct { | ||
| 98 | /// page can not be accessed | ||
| 99 | pub const NONE = 0x0; | ||
| 100 | /// page can be read | ||
| 101 | pub const READ = 0x1; | ||
| 102 | /// page can be written | ||
| 103 | pub const WRITE = 0x2; | ||
| 104 | /// page can be executed | ||
| 105 | pub const EXEC = 0x4; | ||
| 106 | }; | ||
| 107 | |||
| 108 | pub const E = enum(u16) { | ||
| 109 | /// No error occurred. | ||
| 110 | SUCCESS = 0, | ||
| 111 | PERM = 1, | ||
| 112 | NOENT = 2, | ||
| 113 | SRCH = 3, | ||
| 114 | INTR = 4, | ||
| 115 | IO = 5, | ||
| 116 | NXIO = 6, | ||
| 117 | @"2BIG" = 7, | ||
| 118 | NOEXEC = 8, | ||
| 119 | BADF = 9, | ||
| 120 | CHILD = 10, | ||
| 121 | AGAIN = 11, | ||
| 122 | NOMEM = 12, | ||
| 123 | ACCES = 13, | ||
| 124 | FAULT = 14, | ||
| 125 | BUSY = 16, | ||
| 126 | EXIST = 17, | ||
| 127 | XDEV = 18, | ||
| 128 | NODEV = 19, | ||
| 129 | NOTDIR = 20, | ||
| 130 | ISDIR = 21, | ||
| 131 | NFILE = 23, | ||
| 132 | MFILE = 24, | ||
| 133 | NOTTY = 25, | ||
| 134 | FBIG = 27, | ||
| 135 | NOSPC = 28, | ||
| 136 | SPIPE = 29, | ||
| 137 | ROFS = 30, | ||
| 138 | MLINK = 31, | ||
| 139 | PIPE = 32, | ||
| 140 | DOM = 33, | ||
| 141 | /// Also means `DEADLOCK`. | ||
| 142 | DEADLK = 36, | ||
| 143 | NAMETOOLONG = 38, | ||
| 144 | NOLCK = 39, | ||
| 145 | NOSYS = 40, | ||
| 146 | NOTEMPTY = 41, | ||
| 147 | |||
| 148 | INVAL = 22, | ||
| 149 | RANGE = 34, | ||
| 150 | ILSEQ = 42, | ||
| 151 | |||
| 152 | // POSIX Supplement | ||
| 153 | ADDRINUSE = 100, | ||
| 154 | ADDRNOTAVAIL = 101, | ||
| 155 | AFNOSUPPORT = 102, | ||
| 156 | ALREADY = 103, | ||
| 157 | BADMSG = 104, | ||
| 158 | CANCELED = 105, | ||
| 159 | CONNABORTED = 106, | ||
| 160 | CONNREFUSED = 107, | ||
| 161 | CONNRESET = 108, | ||
| 162 | DESTADDRREQ = 109, | ||
| 163 | HOSTUNREACH = 110, | ||
| 164 | IDRM = 111, | ||
| 165 | INPROGRESS = 112, | ||
| 166 | ISCONN = 113, | ||
| 167 | LOOP = 114, | ||
| 168 | MSGSIZE = 115, | ||
| 169 | NETDOWN = 116, | ||
| 170 | NETRESET = 117, | ||
| 171 | NETUNREACH = 118, | ||
| 172 | NOBUFS = 119, | ||
| 173 | NODATA = 120, | ||
| 174 | NOLINK = 121, | ||
| 175 | NOMSG = 122, | ||
| 176 | NOPROTOOPT = 123, | ||
| 177 | NOSR = 124, | ||
| 178 | NOSTR = 125, | ||
| 179 | NOTCONN = 126, | ||
| 180 | NOTRECOVERABLE = 127, | ||
| 181 | NOTSOCK = 128, | ||
| 182 | NOTSUP = 129, | ||
| 183 | OPNOTSUPP = 130, | ||
| 184 | OTHER = 131, | ||
| 185 | OVERFLOW = 132, | ||
| 186 | OWNERDEAD = 133, | ||
| 187 | PROTO = 134, | ||
| 188 | PROTONOSUPPORT = 135, | ||
| 189 | PROTOTYPE = 136, | ||
| 190 | TIME = 137, | ||
| 191 | TIMEDOUT = 138, | ||
| 192 | TXTBSY = 139, | ||
| 193 | WOULDBLOCK = 140, | ||
| 194 | DQUOT = 10069, | ||
| 195 | _, | ||
| 196 | }; | ||
| 197 | |||
| 198 | pub const STRUNCATE = 80; | ||
| 199 | |||
| 200 | pub const F_OK = 0; | ||
| 201 | |||
| 202 | pub const in_port_t = u16; | ||
| 203 | pub const sa_family_t = ws2_32.ADDRESS_FAMILY; | ||
| 204 | pub const socklen_t = ws2_32.socklen_t; | ||
| 205 | |||
| 206 | pub const sockaddr = ws2_32.sockaddr; | ||
| 207 | |||
| 208 | pub const in6_addr = [16]u8; | ||
| 209 | pub const in_addr = u32; | ||
| 210 | |||
| 211 | pub const addrinfo = ws2_32.addrinfo; | ||
| 212 | pub const AF = ws2_32.AF; | ||
| 213 | pub const MSG = ws2_32.MSG; | ||
| 214 | pub const SOCK = ws2_32.SOCK; | ||
| 215 | pub const TCP = ws2_32.TCP; | ||
| 216 | pub const IPPROTO = ws2_32.IPPROTO; | ||
| 217 | pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM; | ||
| 218 | |||
| 219 | pub const nfds_t = c_ulong; | ||
| 220 | pub const pollfd = ws2_32.pollfd; | ||
| 221 | pub const POLL = ws2_32.POLL; | ||
| 222 | pub const SOL = ws2_32.SOL; | ||
| 223 | pub const SO = ws2_32.SO; | ||
| 224 | pub const PVD_CONFIG = ws2_32.PVD_CONFIG; | ||
| 225 | |||
| 226 | pub const IFNAMESIZE = 30; | ||
lib/std/crypto/Certificate/Bundle/macos.zig+1-1| ... | @@ -42,7 +42,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { | ... | @@ -42,7 +42,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 42 | 42 | ||
| 43 | const table_header = try reader.readStructEndian(TableHeader, .big); | 43 | const table_header = try reader.readStructEndian(TableHeader, .big); |
| 44 | 44 | ||
| 45 | if (@as(std.c.cssm.DB_RECORDTYPE, @enumFromInt(table_header.table_id)) != .X509_CERTIFICATE) { | 45 | if (@as(std.c.DB_RECORDTYPE, @enumFromInt(table_header.table_id)) != .X509_CERTIFICATE) { |
| 46 | continue; | 46 | continue; |
| 47 | } | 47 | } |
| 48 | 48 |
lib/std/crypto/tlcsprng.zig+6-26| ... | @@ -11,39 +11,19 @@ const posix = std.posix; | ... | @@ -11,39 +11,19 @@ const posix = std.posix; |
| 11 | 11 | ||
| 12 | /// We use this as a layer of indirection because global const pointers cannot | 12 | /// We use this as a layer of indirection because global const pointers cannot |
| 13 | /// point to thread-local variables. | 13 | /// point to thread-local variables. |
| 14 | pub const interface = std.Random{ | 14 | pub const interface: std.Random = .{ |
| 15 | .ptr = undefined, | 15 | .ptr = undefined, |
| 16 | .fillFn = tlsCsprngFill, | 16 | .fillFn = tlsCsprngFill, |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | const os_has_fork = switch (native_os) { | 19 | const os_has_fork = @TypeOf(posix.fork) != void; |
| 20 | .dragonfly, | 20 | const os_has_arc4random = builtin.link_libc and (@TypeOf(std.c.arc4random_buf) != void); |
| 21 | .freebsd, | 21 | const want_fork_safety = os_has_fork and !os_has_arc4random and std.options.crypto_fork_safety; |
| 22 | .ios, | ||
| 23 | .kfreebsd, | ||
| 24 | .linux, | ||
| 25 | .macos, | ||
| 26 | .netbsd, | ||
| 27 | .openbsd, | ||
| 28 | .solaris, | ||
| 29 | .illumos, | ||
| 30 | .tvos, | ||
| 31 | .watchos, | ||
| 32 | .visionos, | ||
| 33 | .haiku, | ||
| 34 | => true, | ||
| 35 | |||
| 36 | else => false, | ||
| 37 | }; | ||
| 38 | const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); | ||
| 39 | const want_fork_safety = os_has_fork and !os_has_arc4random and | ||
| 40 | std.options.crypto_fork_safety; | ||
| 41 | const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{ | 22 | const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{ |
| 42 | .major = 4, | 23 | .major = 4, |
| 43 | .minor = 14, | 24 | .minor = 14, |
| 44 | .patch = 0, | 25 | .patch = 0, |
| 45 | }) orelse true; | 26 | }) orelse true; |
| 46 | const is_haiku = native_os == .haiku; | ||
| 47 | 27 | ||
| 48 | const Rng = std.Random.DefaultCsprng; | 28 | const Rng = std.Random.DefaultCsprng; |
| 49 | 29 | ||
| ... | @@ -65,7 +45,7 @@ var install_atfork_handler = std.once(struct { | ... | @@ -65,7 +45,7 @@ var install_atfork_handler = std.once(struct { |
| 65 | threadlocal var wipe_mem: []align(mem.page_size) u8 = &[_]u8{}; | 45 | threadlocal var wipe_mem: []align(mem.page_size) u8 = &[_]u8{}; |
| 66 | 46 | ||
| 67 | fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void { | 47 | fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void { |
| 68 | if (builtin.link_libc and @hasDecl(std.c, "arc4random_buf")) { | 48 | if (os_has_arc4random) { |
| 69 | // arc4random is already a thread-local CSPRNG. | 49 | // arc4random is already a thread-local CSPRNG. |
| 70 | return std.c.arc4random_buf(buffer.ptr, buffer.len); | 50 | return std.c.arc4random_buf(buffer.ptr, buffer.len); |
| 71 | } | 51 | } |
| ... | @@ -78,7 +58,7 @@ fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void { | ... | @@ -78,7 +58,7 @@ fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void { |
| 78 | 58 | ||
| 79 | if (wipe_mem.len == 0) { | 59 | if (wipe_mem.len == 0) { |
| 80 | // Not initialized yet. | 60 | // Not initialized yet. |
| 81 | if (want_fork_safety and maybe_have_wipe_on_fork or is_haiku) { | 61 | if (want_fork_safety and maybe_have_wipe_on_fork) { |
| 82 | // Allocate a per-process page, madvise operates with page | 62 | // Allocate a per-process page, madvise operates with page |
| 83 | // granularity. | 63 | // granularity. |
| 84 | wipe_mem = posix.mmap( | 64 | wipe_mem = posix.mmap( |
lib/std/debug.zig+22-28| ... | @@ -201,11 +201,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { | ... | @@ -201,11 +201,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | pub const have_ucontext = @hasDecl(posix.system, "ucontext_t") and | 204 | pub const have_ucontext = posix.ucontext_t != void; |
| 205 | (native_os != .linux or switch (builtin.cpu.arch) { | ||
| 206 | .mips, .mipsel, .mips64, .mips64el, .riscv64 => false, | ||
| 207 | else => true, | ||
| 208 | }); | ||
| 209 | 205 | ||
| 210 | /// Platform-specific thread state. This contains register state, and on some platforms | 206 | /// Platform-specific thread state. This contains register state, and on some platforms |
| 211 | /// information about the stack. This is not safe to trivially copy, because some platforms | 207 | /// information about the stack. This is not safe to trivially copy, because some platforms |
| ... | @@ -237,14 +233,7 @@ pub fn relocateContext(context: *ThreadContext) void { | ... | @@ -237,14 +233,7 @@ pub fn relocateContext(context: *ThreadContext) void { |
| 237 | }; | 233 | }; |
| 238 | } | 234 | } |
| 239 | 235 | ||
| 240 | pub const have_getcontext = native_os != .openbsd and native_os != .haiku and | 236 | pub const have_getcontext = @TypeOf(posix.system.getcontext) != void; |
| 241 | !builtin.target.isAndroid() and | ||
| 242 | (native_os != .linux or switch (builtin.cpu.arch) { | ||
| 243 | .x86, | ||
| 244 | .x86_64, | ||
| 245 | => true, | ||
| 246 | else => builtin.link_libc and !builtin.target.isMusl(), | ||
| 247 | }); | ||
| 248 | 237 | ||
| 249 | /// Capture the current context. The register values in the context will reflect the | 238 | /// Capture the current context. The register values in the context will reflect the |
| 250 | /// state after the platform `getcontext` function returns. | 239 | /// state after the platform `getcontext` function returns. |
| ... | @@ -704,7 +693,7 @@ pub const StackIterator = struct { | ... | @@ -704,7 +693,7 @@ pub const StackIterator = struct { |
| 704 | } | 693 | } |
| 705 | 694 | ||
| 706 | return true; | 695 | return true; |
| 707 | } else if (@hasDecl(posix.system, "msync") and native_os != .wasi and native_os != .emscripten) { | 696 | } else if (have_msync) { |
| 708 | posix.msync(aligned_memory, posix.MSF.ASYNC) catch |err| { | 697 | posix.msync(aligned_memory, posix.MSF.ASYNC) catch |err| { |
| 709 | switch (err) { | 698 | switch (err) { |
| 710 | error.UnmappedMemory => return false, | 699 | error.UnmappedMemory => return false, |
| ... | @@ -853,6 +842,11 @@ pub const StackIterator = struct { | ... | @@ -853,6 +842,11 @@ pub const StackIterator = struct { |
| 853 | } | 842 | } |
| 854 | }; | 843 | }; |
| 855 | 844 | ||
| 845 | const have_msync = switch (native_os) { | ||
| 846 | .wasi, .emscripten, .windows => false, | ||
| 847 | else => true, | ||
| 848 | }; | ||
| 849 | |||
| 856 | pub fn writeCurrentStackTrace( | 850 | pub fn writeCurrentStackTrace( |
| 857 | out_stream: anytype, | 851 | out_stream: anytype, |
| 858 | debug_info: *DebugInfo, | 852 | debug_info: *DebugInfo, |
| ... | @@ -2078,15 +2072,15 @@ pub const DebugInfo = struct { | ... | @@ -2078,15 +2072,15 @@ pub const DebugInfo = struct { |
| 2078 | if (posix.dl_iterate_phdr(&ctx, error{Found}, struct { | 2072 | if (posix.dl_iterate_phdr(&ctx, error{Found}, struct { |
| 2079 | fn callback(info: *posix.dl_phdr_info, size: usize, context: *CtxTy) !void { | 2073 | fn callback(info: *posix.dl_phdr_info, size: usize, context: *CtxTy) !void { |
| 2080 | _ = size; | 2074 | _ = size; |
| 2081 | if (context.address < info.dlpi_addr) return; | 2075 | if (context.address < info.addr) return; |
| 2082 | const phdrs = info.dlpi_phdr[0..info.dlpi_phnum]; | 2076 | const phdrs = info.phdr[0..info.phnum]; |
| 2083 | for (phdrs) |*phdr| { | 2077 | for (phdrs) |*phdr| { |
| 2084 | if (phdr.p_type != elf.PT_LOAD) continue; | 2078 | if (phdr.p_type != elf.PT_LOAD) continue; |
| 2085 | 2079 | ||
| 2086 | const seg_start = info.dlpi_addr +% phdr.p_vaddr; | 2080 | const seg_start = info.addr +% phdr.p_vaddr; |
| 2087 | const seg_end = seg_start + phdr.p_memsz; | 2081 | const seg_end = seg_start + phdr.p_memsz; |
| 2088 | if (context.address >= seg_start and context.address < seg_end) { | 2082 | if (context.address >= seg_start and context.address < seg_end) { |
| 2089 | context.name = mem.sliceTo(info.dlpi_name, 0) orelse ""; | 2083 | context.name = mem.sliceTo(info.name, 0) orelse ""; |
| 2090 | break; | 2084 | break; |
| 2091 | } | 2085 | } |
| 2092 | } else return; | 2086 | } else return; |
| ... | @@ -2118,30 +2112,30 @@ pub const DebugInfo = struct { | ... | @@ -2118,30 +2112,30 @@ pub const DebugInfo = struct { |
| 2118 | fn callback(info: *posix.dl_phdr_info, size: usize, context: *CtxTy) !void { | 2112 | fn callback(info: *posix.dl_phdr_info, size: usize, context: *CtxTy) !void { |
| 2119 | _ = size; | 2113 | _ = size; |
| 2120 | // The base address is too high | 2114 | // The base address is too high |
| 2121 | if (context.address < info.dlpi_addr) | 2115 | if (context.address < info.addr) |
| 2122 | return; | 2116 | return; |
| 2123 | 2117 | ||
| 2124 | const phdrs = info.dlpi_phdr[0..info.dlpi_phnum]; | 2118 | const phdrs = info.phdr[0..info.phnum]; |
| 2125 | for (phdrs) |*phdr| { | 2119 | for (phdrs) |*phdr| { |
| 2126 | if (phdr.p_type != elf.PT_LOAD) continue; | 2120 | if (phdr.p_type != elf.PT_LOAD) continue; |
| 2127 | 2121 | ||
| 2128 | // Overflowing addition is used to handle the case of VSDOs having a p_vaddr = 0xffffffffff700000 | 2122 | // Overflowing addition is used to handle the case of VSDOs having a p_vaddr = 0xffffffffff700000 |
| 2129 | const seg_start = info.dlpi_addr +% phdr.p_vaddr; | 2123 | const seg_start = info.addr +% phdr.p_vaddr; |
| 2130 | const seg_end = seg_start + phdr.p_memsz; | 2124 | const seg_end = seg_start + phdr.p_memsz; |
| 2131 | if (context.address >= seg_start and context.address < seg_end) { | 2125 | if (context.address >= seg_start and context.address < seg_end) { |
| 2132 | // Android libc uses NULL instead of an empty string to mark the | 2126 | // Android libc uses NULL instead of an empty string to mark the |
| 2133 | // main program | 2127 | // main program |
| 2134 | context.name = mem.sliceTo(info.dlpi_name, 0) orelse ""; | 2128 | context.name = mem.sliceTo(info.name, 0) orelse ""; |
| 2135 | context.base_address = info.dlpi_addr; | 2129 | context.base_address = info.addr; |
| 2136 | break; | 2130 | break; |
| 2137 | } | 2131 | } |
| 2138 | } else return; | 2132 | } else return; |
| 2139 | 2133 | ||
| 2140 | for (info.dlpi_phdr[0..info.dlpi_phnum]) |phdr| { | 2134 | for (info.phdr[0..info.phnum]) |phdr| { |
| 2141 | switch (phdr.p_type) { | 2135 | switch (phdr.p_type) { |
| 2142 | elf.PT_NOTE => { | 2136 | elf.PT_NOTE => { |
| 2143 | // Look for .note.gnu.build-id | 2137 | // Look for .note.gnu.build-id |
| 2144 | const note_bytes = @as([*]const u8, @ptrFromInt(info.dlpi_addr + phdr.p_vaddr))[0..phdr.p_memsz]; | 2138 | const note_bytes = @as([*]const u8, @ptrFromInt(info.addr + phdr.p_vaddr))[0..phdr.p_memsz]; |
| 2145 | const name_size = mem.readInt(u32, note_bytes[0..4], native_endian); | 2139 | const name_size = mem.readInt(u32, note_bytes[0..4], native_endian); |
| 2146 | if (name_size != 4) continue; | 2140 | if (name_size != 4) continue; |
| 2147 | const desc_size = mem.readInt(u32, note_bytes[4..8], native_endian); | 2141 | const desc_size = mem.readInt(u32, note_bytes[4..8], native_endian); |
| ... | @@ -2151,7 +2145,7 @@ pub const DebugInfo = struct { | ... | @@ -2151,7 +2145,7 @@ pub const DebugInfo = struct { |
| 2151 | context.build_id = note_bytes[16..][0..desc_size]; | 2145 | context.build_id = note_bytes[16..][0..desc_size]; |
| 2152 | }, | 2146 | }, |
| 2153 | elf.PT_GNU_EH_FRAME => { | 2147 | elf.PT_GNU_EH_FRAME => { |
| 2154 | context.gnu_eh_frame = @as([*]const u8, @ptrFromInt(info.dlpi_addr + phdr.p_vaddr))[0..phdr.p_memsz]; | 2148 | context.gnu_eh_frame = @as([*]const u8, @ptrFromInt(info.addr + phdr.p_vaddr))[0..phdr.p_memsz]; |
| 2155 | }, | 2149 | }, |
| 2156 | else => {}, | 2150 | else => {}, |
| 2157 | } | 2151 | } |
| ... | @@ -2592,7 +2586,7 @@ pub const have_segfault_handling_support = switch (native_os) { | ... | @@ -2592,7 +2586,7 @@ pub const have_segfault_handling_support = switch (native_os) { |
| 2592 | .windows, | 2586 | .windows, |
| 2593 | => true, | 2587 | => true, |
| 2594 | 2588 | ||
| 2595 | .freebsd, .openbsd => @hasDecl(std.c, "ucontext_t"), | 2589 | .freebsd, .openbsd => have_ucontext, |
| 2596 | else => false, | 2590 | else => false, |
| 2597 | }; | 2591 | }; |
| 2598 | 2592 | ||
| ... | @@ -2742,7 +2736,7 @@ fn handleSegfaultWindowsExtra( | ... | @@ -2742,7 +2736,7 @@ fn handleSegfaultWindowsExtra( |
| 2742 | label: ?[]const u8, | 2736 | label: ?[]const u8, |
| 2743 | ) noreturn { | 2737 | ) noreturn { |
| 2744 | const exception_address = @intFromPtr(info.ExceptionRecord.ExceptionAddress); | 2738 | const exception_address = @intFromPtr(info.ExceptionRecord.ExceptionAddress); |
| 2745 | if (@hasDecl(windows, "CONTEXT")) { | 2739 | if (windows.CONTEXT != void) { |
| 2746 | nosuspend switch (panic_stage) { | 2740 | nosuspend switch (panic_stage) { |
| 2747 | 0 => { | 2741 | 0 => { |
| 2748 | panic_stage = 1; | 2742 | panic_stage = 1; |
lib/std/dynamic_library.zig+1-1| ... | @@ -440,7 +440,7 @@ pub const DlDynLib = struct { | ... | @@ -440,7 +440,7 @@ pub const DlDynLib = struct { |
| 440 | 440 | ||
| 441 | pub fn openZ(path_c: [*:0]const u8) Error!DlDynLib { | 441 | pub fn openZ(path_c: [*:0]const u8) Error!DlDynLib { |
| 442 | return .{ | 442 | return .{ |
| 443 | .handle = std.c.dlopen(path_c, std.c.RTLD.LAZY) orelse { | 443 | .handle = std.c.dlopen(path_c, .{ .LAZY = true }) orelse { |
| 444 | return error.FileNotFound; | 444 | return error.FileNotFound; |
| 445 | }, | 445 | }, |
| 446 | }; | 446 | }; |
lib/std/elf.zig+1-5| ... | @@ -1082,11 +1082,7 @@ pub const Addr = switch (@sizeOf(usize)) { | ... | @@ -1082,11 +1082,7 @@ pub const Addr = switch (@sizeOf(usize)) { |
| 1082 | 8 => Elf64_Addr, | 1082 | 8 => Elf64_Addr, |
| 1083 | else => @compileError("expected pointer size of 32 or 64"), | 1083 | else => @compileError("expected pointer size of 32 or 64"), |
| 1084 | }; | 1084 | }; |
| 1085 | pub const Half = switch (@sizeOf(usize)) { | 1085 | pub const Half = u16; |
| 1086 | 4 => Elf32_Half, | ||
| 1087 | 8 => Elf64_Half, | ||
| 1088 | else => @compileError("expected pointer size of 32 or 64"), | ||
| 1089 | }; | ||
| 1090 | 1086 | ||
| 1091 | /// Machine architectures. | 1087 | /// Machine architectures. |
| 1092 | /// | 1088 | /// |
lib/std/fs/Dir.zig+14-14| ... | @@ -178,7 +178,8 @@ pub const Iterator = switch (native_os) { | ... | @@ -178,7 +178,8 @@ pub const Iterator = switch (native_os) { |
| 178 | self.end_index = @as(usize, @intCast(rc)); | 178 | self.end_index = @as(usize, @intCast(rc)); |
| 179 | } | 179 | } |
| 180 | const bsd_entry = @as(*align(1) posix.system.dirent, @ptrCast(&self.buf[self.index])); | 180 | const bsd_entry = @as(*align(1) posix.system.dirent, @ptrCast(&self.buf[self.index])); |
| 181 | const next_index = self.index + if (@hasDecl(posix.system.dirent, "reclen")) bsd_entry.reclen() else bsd_entry.reclen; | 181 | const next_index = self.index + |
| 182 | if (@hasField(posix.system.dirent, "reclen")) bsd_entry.reclen else bsd_entry.reclen(); | ||
| 182 | self.index = next_index; | 183 | self.index = next_index; |
| 183 | 184 | ||
| 184 | const name = @as([*]u8, @ptrCast(&bsd_entry.name))[0..bsd_entry.namlen]; | 185 | const name = @as([*]u8, @ptrCast(&bsd_entry.name))[0..bsd_entry.namlen]; |
| ... | @@ -880,16 +881,14 @@ pub fn openFileZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) File | ... | @@ -880,16 +881,14 @@ pub fn openFileZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) File |
| 880 | const fd = try posix.openatZ(self.fd, sub_path, os_flags, 0); | 881 | const fd = try posix.openatZ(self.fd, sub_path, os_flags, 0); |
| 881 | errdefer posix.close(fd); | 882 | errdefer posix.close(fd); |
| 882 | 883 | ||
| 883 | if (@hasDecl(posix.system, "LOCK")) { | 884 | if (have_flock and !has_flock_open_flags and flags.lock != .none) { |
| 884 | if (!has_flock_open_flags and flags.lock != .none) { | 885 | // TODO: integrate async I/O |
| 885 | // TODO: integrate async I/O | 886 | const lock_nonblocking: i32 = if (flags.lock_nonblocking) posix.LOCK.NB else 0; |
| 886 | const lock_nonblocking: i32 = if (flags.lock_nonblocking) posix.LOCK.NB else 0; | 887 | try posix.flock(fd, switch (flags.lock) { |
| 887 | try posix.flock(fd, switch (flags.lock) { | 888 | .none => unreachable, |
| 888 | .none => unreachable, | 889 | .shared => posix.LOCK.SH | lock_nonblocking, |
| 889 | .shared => posix.LOCK.SH | lock_nonblocking, | 890 | .exclusive => posix.LOCK.EX | lock_nonblocking, |
| 890 | .exclusive => posix.LOCK.EX | lock_nonblocking, | 891 | }); |
| 891 | }); | ||
| 892 | } | ||
| 893 | } | 892 | } |
| 894 | 893 | ||
| 895 | if (has_flock_open_flags and flags.lock_nonblocking) { | 894 | if (has_flock_open_flags and flags.lock_nonblocking) { |
| ... | @@ -1030,7 +1029,7 @@ pub fn createFileZ(self: Dir, sub_path_c: [*:0]const u8, flags: File.CreateFlags | ... | @@ -1030,7 +1029,7 @@ pub fn createFileZ(self: Dir, sub_path_c: [*:0]const u8, flags: File.CreateFlags |
| 1030 | const fd = try posix.openatZ(self.fd, sub_path_c, os_flags, flags.mode); | 1029 | const fd = try posix.openatZ(self.fd, sub_path_c, os_flags, flags.mode); |
| 1031 | errdefer posix.close(fd); | 1030 | errdefer posix.close(fd); |
| 1032 | 1031 | ||
| 1033 | if (!has_flock_open_flags and flags.lock != .none) { | 1032 | if (have_flock and !has_flock_open_flags and flags.lock != .none) { |
| 1034 | // TODO: integrate async I/O | 1033 | // TODO: integrate async I/O |
| 1035 | const lock_nonblocking: i32 = if (flags.lock_nonblocking) posix.LOCK.NB else 0; | 1034 | const lock_nonblocking: i32 = if (flags.lock_nonblocking) posix.LOCK.NB else 0; |
| 1036 | try posix.flock(fd, switch (flags.lock) { | 1035 | try posix.flock(fd, switch (flags.lock) { |
| ... | @@ -2539,8 +2538,8 @@ const CopyFileRawError = error{SystemResources} || posix.CopyFileRangeError || p | ... | @@ -2539,8 +2538,8 @@ const CopyFileRawError = error{SystemResources} || posix.CopyFileRangeError || p |
| 2539 | // The copy starts at offset 0, the initial offsets are preserved. | 2538 | // The copy starts at offset 0, the initial offsets are preserved. |
| 2540 | // No metadata is transferred over. | 2539 | // No metadata is transferred over. |
| 2541 | fn copy_file(fd_in: posix.fd_t, fd_out: posix.fd_t, maybe_size: ?u64) CopyFileRawError!void { | 2540 | fn copy_file(fd_in: posix.fd_t, fd_out: posix.fd_t, maybe_size: ?u64) CopyFileRawError!void { |
| 2542 | if (comptime builtin.target.isDarwin()) { | 2541 | if (builtin.target.isDarwin()) { |
| 2543 | const rc = posix.system.fcopyfile(fd_in, fd_out, null, posix.system.COPYFILE_DATA); | 2542 | const rc = posix.system.fcopyfile(fd_in, fd_out, null, .{ .DATA = true }); |
| 2544 | switch (posix.errno(rc)) { | 2543 | switch (posix.errno(rc)) { |
| 2545 | .SUCCESS => return, | 2544 | .SUCCESS => return, |
| 2546 | .INVAL => unreachable, | 2545 | .INVAL => unreachable, |
| ... | @@ -2703,3 +2702,4 @@ const Allocator = std.mem.Allocator; | ... | @@ -2703,3 +2702,4 @@ const Allocator = std.mem.Allocator; |
| 2703 | const assert = std.debug.assert; | 2702 | const assert = std.debug.assert; |
| 2704 | const windows = std.os.windows; | 2703 | const windows = std.os.windows; |
| 2705 | const native_os = builtin.os.tag; | 2704 | const native_os = builtin.os.tag; |
| 2705 | const have_flock = @TypeOf(posix.system.flock) != void; |
lib/std/fs/File.zig+21-21| ... | @@ -420,9 +420,9 @@ pub const Stat = struct { | ... | @@ -420,9 +420,9 @@ pub const Stat = struct { |
| 420 | 420 | ||
| 421 | break :k .unknown; | 421 | break :k .unknown; |
| 422 | }, | 422 | }, |
| 423 | .atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, | 423 | .atime = @as(i128, atime.sec) * std.time.ns_per_s + atime.nsec, |
| 424 | .mtime = @as(i128, mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec, | 424 | .mtime = @as(i128, mtime.sec) * std.time.ns_per_s + mtime.nsec, |
| 425 | .ctime = @as(i128, ctime.tv_sec) * std.time.ns_per_s + ctime.tv_nsec, | 425 | .ctime = @as(i128, ctime.sec) * std.time.ns_per_s + ctime.nsec, |
| 426 | }; | 426 | }; |
| 427 | } | 427 | } |
| 428 | 428 | ||
| ... | @@ -791,13 +791,13 @@ pub const MetadataUnix = struct { | ... | @@ -791,13 +791,13 @@ pub const MetadataUnix = struct { |
| 791 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 | 791 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| 792 | pub fn accessed(self: Self) i128 { | 792 | pub fn accessed(self: Self) i128 { |
| 793 | const atime = self.stat.atime(); | 793 | const atime = self.stat.atime(); |
| 794 | return @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec; | 794 | return @as(i128, atime.sec) * std.time.ns_per_s + atime.nsec; |
| 795 | } | 795 | } |
| 796 | 796 | ||
| 797 | /// Returns the last time the file was modified in nanoseconds since UTC 1970-01-01 | 797 | /// Returns the last time the file was modified in nanoseconds since UTC 1970-01-01 |
| 798 | pub fn modified(self: Self) i128 { | 798 | pub fn modified(self: Self) i128 { |
| 799 | const mtime = self.stat.mtime(); | 799 | const mtime = self.stat.mtime(); |
| 800 | return @as(i128, mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec; | 800 | return @as(i128, mtime.sec) * std.time.ns_per_s + mtime.nsec; |
| 801 | } | 801 | } |
| 802 | 802 | ||
| 803 | /// Returns the time the file was created in nanoseconds since UTC 1970-01-01. | 803 | /// Returns the time the file was created in nanoseconds since UTC 1970-01-01. |
| ... | @@ -807,17 +807,17 @@ pub const MetadataUnix = struct { | ... | @@ -807,17 +807,17 @@ pub const MetadataUnix = struct { |
| 807 | const birthtime = self.stat.birthtime(); | 807 | const birthtime = self.stat.birthtime(); |
| 808 | 808 | ||
| 809 | // If the filesystem doesn't support this the value *should* be: | 809 | // If the filesystem doesn't support this the value *should* be: |
| 810 | // On FreeBSD: tv_nsec = 0, tv_sec = -1 | 810 | // On FreeBSD: nsec = 0, sec = -1 |
| 811 | // On NetBSD and OpenBSD: tv_nsec = 0, tv_sec = 0 | 811 | // On NetBSD and OpenBSD: nsec = 0, sec = 0 |
| 812 | // On MacOS, it is set to ctime -- we cannot detect this!! | 812 | // On MacOS, it is set to ctime -- we cannot detect this!! |
| 813 | switch (builtin.os.tag) { | 813 | switch (builtin.os.tag) { |
| 814 | .freebsd => if (birthtime.tv_sec == -1 and birthtime.tv_nsec == 0) return null, | 814 | .freebsd => if (birthtime.sec == -1 and birthtime.nsec == 0) return null, |
| 815 | .netbsd, .openbsd => if (birthtime.tv_sec == 0 and birthtime.tv_nsec == 0) return null, | 815 | .netbsd, .openbsd => if (birthtime.sec == 0 and birthtime.nsec == 0) return null, |
| 816 | .macos => {}, | 816 | .macos => {}, |
| 817 | else => @compileError("Creation time detection not implemented for OS"), | 817 | else => @compileError("Creation time detection not implemented for OS"), |
| 818 | } | 818 | } |
| 819 | 819 | ||
| 820 | return @as(i128, birthtime.tv_sec) * std.time.ns_per_s + birthtime.tv_nsec; | 820 | return @as(i128, birthtime.sec) * std.time.ns_per_s + birthtime.nsec; |
| 821 | } | 821 | } |
| 822 | }; | 822 | }; |
| 823 | 823 | ||
| ... | @@ -858,19 +858,19 @@ pub const MetadataLinux = struct { | ... | @@ -858,19 +858,19 @@ pub const MetadataLinux = struct { |
| 858 | 858 | ||
| 859 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 | 859 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| 860 | pub fn accessed(self: Self) i128 { | 860 | pub fn accessed(self: Self) i128 { |
| 861 | return @as(i128, self.statx.atime.tv_sec) * std.time.ns_per_s + self.statx.atime.tv_nsec; | 861 | return @as(i128, self.statx.atime.sec) * std.time.ns_per_s + self.statx.atime.nsec; |
| 862 | } | 862 | } |
| 863 | 863 | ||
| 864 | /// Returns the last time the file was modified in nanoseconds since UTC 1970-01-01 | 864 | /// Returns the last time the file was modified in nanoseconds since UTC 1970-01-01 |
| 865 | pub fn modified(self: Self) i128 { | 865 | pub fn modified(self: Self) i128 { |
| 866 | return @as(i128, self.statx.mtime.tv_sec) * std.time.ns_per_s + self.statx.mtime.tv_nsec; | 866 | return @as(i128, self.statx.mtime.sec) * std.time.ns_per_s + self.statx.mtime.nsec; |
| 867 | } | 867 | } |
| 868 | 868 | ||
| 869 | /// Returns the time the file was created in nanoseconds since UTC 1970-01-01. | 869 | /// Returns the time the file was created in nanoseconds since UTC 1970-01-01. |
| 870 | /// Returns null if this is not supported by the filesystem, or on kernels before than version 4.11 | 870 | /// Returns null if this is not supported by the filesystem, or on kernels before than version 4.11 |
| 871 | pub fn created(self: Self) ?i128 { | 871 | pub fn created(self: Self) ?i128 { |
| 872 | if (self.statx.mask & std.os.linux.STATX_BTIME == 0) return null; | 872 | if (self.statx.mask & std.os.linux.STATX_BTIME == 0) return null; |
| 873 | return @as(i128, self.statx.btime.tv_sec) * std.time.ns_per_s + self.statx.btime.tv_nsec; | 873 | return @as(i128, self.statx.btime.sec) * std.time.ns_per_s + self.statx.btime.nsec; |
| 874 | } | 874 | } |
| 875 | }; | 875 | }; |
| 876 | 876 | ||
| ... | @@ -1026,12 +1026,12 @@ pub fn metadata(self: File) MetadataError!Metadata { | ... | @@ -1026,12 +1026,12 @@ pub fn metadata(self: File) MetadataError!Metadata { |
| 1026 | 1026 | ||
| 1027 | // Hacky conversion from timespec to statx_timestamp | 1027 | // Hacky conversion from timespec to statx_timestamp |
| 1028 | stx.atime = std.mem.zeroes(l.statx_timestamp); | 1028 | stx.atime = std.mem.zeroes(l.statx_timestamp); |
| 1029 | stx.atime.tv_sec = st.atim.tv_sec; | 1029 | stx.atime.sec = st.atim.sec; |
| 1030 | stx.atime.tv_nsec = @as(u32, @intCast(st.atim.tv_nsec)); // Guaranteed to succeed (tv_nsec is always below 10^9) | 1030 | stx.atime.nsec = @as(u32, @intCast(st.atim.nsec)); // Guaranteed to succeed (nsec is always below 10^9) |
| 1031 | 1031 | ||
| 1032 | stx.mtime = std.mem.zeroes(l.statx_timestamp); | 1032 | stx.mtime = std.mem.zeroes(l.statx_timestamp); |
| 1033 | stx.mtime.tv_sec = st.mtim.tv_sec; | 1033 | stx.mtime.sec = st.mtim.sec; |
| 1034 | stx.mtime.tv_nsec = @as(u32, @intCast(st.mtim.tv_nsec)); | 1034 | stx.mtime.nsec = @as(u32, @intCast(st.mtim.nsec)); |
| 1035 | 1035 | ||
| 1036 | stx.mask = l.STATX_BASIC_STATS | l.STATX_MTIME; | 1036 | stx.mask = l.STATX_BASIC_STATS | l.STATX_MTIME; |
| 1037 | }, | 1037 | }, |
| ... | @@ -1072,12 +1072,12 @@ pub fn updateTimes( | ... | @@ -1072,12 +1072,12 @@ pub fn updateTimes( |
| 1072 | } | 1072 | } |
| 1073 | const times = [2]posix.timespec{ | 1073 | const times = [2]posix.timespec{ |
| 1074 | posix.timespec{ | 1074 | posix.timespec{ |
| 1075 | .tv_sec = math.cast(isize, @divFloor(atime, std.time.ns_per_s)) orelse maxInt(isize), | 1075 | .sec = math.cast(isize, @divFloor(atime, std.time.ns_per_s)) orelse maxInt(isize), |
| 1076 | .tv_nsec = math.cast(isize, @mod(atime, std.time.ns_per_s)) orelse maxInt(isize), | 1076 | .nsec = math.cast(isize, @mod(atime, std.time.ns_per_s)) orelse maxInt(isize), |
| 1077 | }, | 1077 | }, |
| 1078 | posix.timespec{ | 1078 | posix.timespec{ |
| 1079 | .tv_sec = math.cast(isize, @divFloor(mtime, std.time.ns_per_s)) orelse maxInt(isize), | 1079 | .sec = math.cast(isize, @divFloor(mtime, std.time.ns_per_s)) orelse maxInt(isize), |
| 1080 | .tv_nsec = math.cast(isize, @mod(mtime, std.time.ns_per_s)) orelse maxInt(isize), | 1080 | .nsec = math.cast(isize, @mod(mtime, std.time.ns_per_s)) orelse maxInt(isize), |
| 1081 | }, | 1081 | }, |
| 1082 | }; | 1082 | }; |
| 1083 | try posix.futimens(self.handle, &times); | 1083 | try posix.futimens(self.handle, &times); |
lib/std/heap.zig+7-4| ... | @@ -40,15 +40,18 @@ const CAllocator = struct { | ... | @@ -40,15 +40,18 @@ const CAllocator = struct { |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | pub const supports_malloc_size = @TypeOf(malloc_size) != void; | 42 | pub const supports_malloc_size = @TypeOf(malloc_size) != void; |
| 43 | pub const malloc_size = if (@hasDecl(c, "malloc_size")) | 43 | pub const malloc_size = if (@TypeOf(c.malloc_size) != void) |
| 44 | c.malloc_size | 44 | c.malloc_size |
| 45 | else if (@hasDecl(c, "malloc_usable_size")) | 45 | else if (@TypeOf(c.malloc_usable_size) != void) |
| 46 | c.malloc_usable_size | 46 | c.malloc_usable_size |
| 47 | else if (@hasDecl(c, "_msize")) | 47 | else if (@TypeOf(c._msize) != void) |
| 48 | c._msize | 48 | c._msize |
| 49 | else {}; | 49 | else {}; |
| 50 | 50 | ||
| 51 | pub const supports_posix_memalign = @hasDecl(c, "posix_memalign"); | 51 | pub const supports_posix_memalign = switch (builtin.os.tag) { |
| 52 | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .linux, .macos, .ios, .tvos, .watchos, .visionos => true, | ||
| 53 | else => false, | ||
| 54 | }; | ||
| 52 | 55 | ||
| 53 | fn getHeader(ptr: [*]u8) *[*]u8 { | 56 | fn getHeader(ptr: [*]u8) *[*]u8 { |
| 54 | return @as(*[*]u8, @ptrFromInt(@intFromPtr(ptr) - @sizeOf(usize))); | 57 | return @as(*[*]u8, @ptrFromInt(@intFromPtr(ptr) - @sizeOf(usize))); |
lib/std/net.zig+12-14| ... | @@ -248,14 +248,13 @@ pub const Address = extern union { | ... | @@ -248,14 +248,13 @@ pub const Address = extern union { |
| 248 | posix.SO.REUSEADDR, | 248 | posix.SO.REUSEADDR, |
| 249 | &mem.toBytes(@as(c_int, 1)), | 249 | &mem.toBytes(@as(c_int, 1)), |
| 250 | ); | 250 | ); |
| 251 | switch (native_os) { | 251 | if (@hasDecl(posix.SO, "REUSEPORT")) { |
| 252 | .windows => {}, | 252 | try posix.setsockopt( |
| 253 | else => try posix.setsockopt( | ||
| 254 | sockfd, | 253 | sockfd, |
| 255 | posix.SOL.SOCKET, | 254 | posix.SOL.SOCKET, |
| 256 | posix.SO.REUSEPORT, | 255 | posix.SO.REUSEPORT, |
| 257 | &mem.toBytes(@as(c_int, 1)), | 256 | &mem.toBytes(@as(c_int, 1)), |
| 258 | ), | 257 | ); |
| 259 | } | 258 | } |
| 260 | } | 259 | } |
| 261 | 260 | ||
| ... | @@ -853,8 +852,8 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get | ... | @@ -853,8 +852,8 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get |
| 853 | defer allocator.free(port_c); | 852 | defer allocator.free(port_c); |
| 854 | 853 | ||
| 855 | const ws2_32 = windows.ws2_32; | 854 | const ws2_32 = windows.ws2_32; |
| 856 | const hints = posix.addrinfo{ | 855 | const hints: posix.addrinfo = .{ |
| 857 | .flags = ws2_32.AI.NUMERICSERV, | 856 | .flags = .{ .NUMERICSERV = true }, |
| 858 | .family = posix.AF.UNSPEC, | 857 | .family = posix.AF.UNSPEC, |
| 859 | .socktype = posix.SOCK.STREAM, | 858 | .socktype = posix.SOCK.STREAM, |
| 860 | .protocol = posix.IPPROTO.TCP, | 859 | .protocol = posix.IPPROTO.TCP, |
| ... | @@ -925,8 +924,8 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get | ... | @@ -925,8 +924,8 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get |
| 925 | defer allocator.free(port_c); | 924 | defer allocator.free(port_c); |
| 926 | 925 | ||
| 927 | const sys = if (native_os == .windows) windows.ws2_32 else posix.system; | 926 | const sys = if (native_os == .windows) windows.ws2_32 else posix.system; |
| 928 | const hints = posix.addrinfo{ | 927 | const hints: posix.addrinfo = .{ |
| 929 | .flags = sys.AI.NUMERICSERV, | 928 | .flags = .{ .NUMERICSERV = true }, |
| 930 | .family = posix.AF.UNSPEC, | 929 | .family = posix.AF.UNSPEC, |
| 931 | .socktype = posix.SOCK.STREAM, | 930 | .socktype = posix.SOCK.STREAM, |
| 932 | .protocol = posix.IPPROTO.TCP, | 931 | .protocol = posix.IPPROTO.TCP, |
| ... | @@ -985,7 +984,6 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get | ... | @@ -985,7 +984,6 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get |
| 985 | } | 984 | } |
| 986 | 985 | ||
| 987 | if (native_os == .linux) { | 986 | if (native_os == .linux) { |
| 988 | const flags = std.c.AI.NUMERICSERV; | ||
| 989 | const family = posix.AF.UNSPEC; | 987 | const family = posix.AF.UNSPEC; |
| 990 | var lookup_addrs = std.ArrayList(LookupAddr).init(allocator); | 988 | var lookup_addrs = std.ArrayList(LookupAddr).init(allocator); |
| 991 | defer lookup_addrs.deinit(); | 989 | defer lookup_addrs.deinit(); |
| ... | @@ -993,7 +991,7 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get | ... | @@ -993,7 +991,7 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get |
| 993 | var canon = std.ArrayList(u8).init(arena); | 991 | var canon = std.ArrayList(u8).init(arena); |
| 994 | defer canon.deinit(); | 992 | defer canon.deinit(); |
| 995 | 993 | ||
| 996 | try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port); | 994 | try linuxLookupName(&lookup_addrs, &canon, name, family, .{ .NUMERICSERV = true }, port); |
| 997 | 995 | ||
| 998 | result.addrs = try arena.alloc(Address, lookup_addrs.items.len); | 996 | result.addrs = try arena.alloc(Address, lookup_addrs.items.len); |
| 999 | if (canon.items.len != 0) { | 997 | if (canon.items.len != 0) { |
| ... | @@ -1028,7 +1026,7 @@ fn linuxLookupName( | ... | @@ -1028,7 +1026,7 @@ fn linuxLookupName( |
| 1028 | canon: *std.ArrayList(u8), | 1026 | canon: *std.ArrayList(u8), |
| 1029 | opt_name: ?[]const u8, | 1027 | opt_name: ?[]const u8, |
| 1030 | family: posix.sa_family_t, | 1028 | family: posix.sa_family_t, |
| 1031 | flags: u32, | 1029 | flags: posix.AI, |
| 1032 | port: u16, | 1030 | port: u16, |
| 1033 | ) !void { | 1031 | ) !void { |
| 1034 | if (opt_name) |name| { | 1032 | if (opt_name) |name| { |
| ... | @@ -1037,7 +1035,7 @@ fn linuxLookupName( | ... | @@ -1037,7 +1035,7 @@ fn linuxLookupName( |
| 1037 | try canon.appendSlice(name); | 1035 | try canon.appendSlice(name); |
| 1038 | if (Address.parseExpectingFamily(name, family, port)) |addr| { | 1036 | if (Address.parseExpectingFamily(name, family, port)) |addr| { |
| 1039 | try addrs.append(LookupAddr{ .addr = addr }); | 1037 | try addrs.append(LookupAddr{ .addr = addr }); |
| 1040 | } else |name_err| if ((flags & std.c.AI.NUMERICHOST) != 0) { | 1038 | } else |name_err| if (flags.NUMERICHOST) { |
| 1041 | return name_err; | 1039 | return name_err; |
| 1042 | } else { | 1040 | } else { |
| 1043 | try linuxLookupNameFromHosts(addrs, canon, name, family, port); | 1041 | try linuxLookupNameFromHosts(addrs, canon, name, family, port); |
| ... | @@ -1269,10 +1267,10 @@ fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool { | ... | @@ -1269,10 +1267,10 @@ fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool { |
| 1269 | fn linuxLookupNameFromNull( | 1267 | fn linuxLookupNameFromNull( |
| 1270 | addrs: *std.ArrayList(LookupAddr), | 1268 | addrs: *std.ArrayList(LookupAddr), |
| 1271 | family: posix.sa_family_t, | 1269 | family: posix.sa_family_t, |
| 1272 | flags: u32, | 1270 | flags: posix.AI, |
| 1273 | port: u16, | 1271 | port: u16, |
| 1274 | ) !void { | 1272 | ) !void { |
| 1275 | if ((flags & std.c.AI.PASSIVE) != 0) { | 1273 | if (flags.PASSIVE) { |
| 1276 | if (family != posix.AF.INET6) { | 1274 | if (family != posix.AF.INET6) { |
| 1277 | (try addrs.addOne()).* = LookupAddr{ | 1275 | (try addrs.addOne()).* = LookupAddr{ |
| 1278 | .addr = Address.initIp4([1]u8{0} ** 4, port), | 1276 | .addr = Address.initIp4([1]u8{0} ** 4, port), |
lib/std/os.zig+5-3| ... | @@ -23,6 +23,7 @@ const fs = std.fs; | ... | @@ -23,6 +23,7 @@ const fs = std.fs; |
| 23 | const dl = @import("dynamic_library.zig"); | 23 | const dl = @import("dynamic_library.zig"); |
| 24 | const max_path_bytes = std.fs.max_path_bytes; | 24 | const max_path_bytes = std.fs.max_path_bytes; |
| 25 | const posix = std.posix; | 25 | const posix = std.posix; |
| 26 | const native_os = builtin.os.tag; | ||
| 26 | 27 | ||
| 27 | pub const linux = @import("os/linux.zig"); | 28 | pub const linux = @import("os/linux.zig"); |
| 28 | pub const plan9 = @import("os/plan9.zig"); | 29 | pub const plan9 = @import("os/plan9.zig"); |
| ... | @@ -33,7 +34,7 @@ pub const windows = @import("os/windows.zig"); | ... | @@ -33,7 +34,7 @@ pub const windows = @import("os/windows.zig"); |
| 33 | 34 | ||
| 34 | test { | 35 | test { |
| 35 | _ = linux; | 36 | _ = linux; |
| 36 | if (builtin.os.tag == .uefi) { | 37 | if (native_os == .uefi) { |
| 37 | _ = uefi; | 38 | _ = uefi; |
| 38 | } | 39 | } |
| 39 | _ = wasi; | 40 | _ = wasi; |
| ... | @@ -48,7 +49,7 @@ pub var environ: [][*:0]u8 = undefined; | ... | @@ -48,7 +49,7 @@ pub var environ: [][*:0]u8 = undefined; |
| 48 | /// Populated by startup code before main(). | 49 | /// Populated by startup code before main(). |
| 49 | /// Not available on WASI or Windows without libc. See `std.process.argsAlloc` | 50 | /// Not available on WASI or Windows without libc. See `std.process.argsAlloc` |
| 50 | /// or `std.process.argsWithAllocator` for a cross-platform alternative. | 51 | /// or `std.process.argsWithAllocator` for a cross-platform alternative. |
| 51 | pub var argv: [][*:0]u8 = if (builtin.link_libc) undefined else switch (builtin.os.tag) { | 52 | pub var argv: [][*:0]u8 = if (builtin.link_libc) undefined else switch (native_os) { |
| 52 | .windows => @compileError("argv isn't supported on Windows: use std.process.argsAlloc instead"), | 53 | .windows => @compileError("argv isn't supported on Windows: use std.process.argsAlloc instead"), |
| 53 | .wasi => @compileError("argv isn't supported on WASI: use std.process.argsAlloc instead"), | 54 | .wasi => @compileError("argv isn't supported on WASI: use std.process.argsAlloc instead"), |
| 54 | else => undefined, | 55 | else => undefined, |
| ... | @@ -103,7 +104,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. | ... | @@ -103,7 +104,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. |
| 103 | if (!comptime isGetFdPathSupportedOnTarget(builtin.os)) { | 104 | if (!comptime isGetFdPathSupportedOnTarget(builtin.os)) { |
| 104 | @compileError("querying for canonical path of a handle is unsupported on this host"); | 105 | @compileError("querying for canonical path of a handle is unsupported on this host"); |
| 105 | } | 106 | } |
| 106 | switch (builtin.os.tag) { | 107 | switch (native_os) { |
| 107 | .windows => { | 108 | .windows => { |
| 108 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; | 109 | var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined; |
| 109 | const wide_slice = try windows.GetFinalPathNameByHandle(fd, .{}, wide_buf[0..]); | 110 | const wide_slice = try windows.GetFinalPathNameByHandle(fd, .{}, wide_buf[0..]); |
| ... | @@ -150,6 +151,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. | ... | @@ -150,6 +151,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. |
| 150 | const target = posix.readlinkZ(proc_path, out_buffer) catch |err| switch (err) { | 151 | const target = posix.readlinkZ(proc_path, out_buffer) catch |err| switch (err) { |
| 151 | error.UnsupportedReparsePointType => unreachable, | 152 | error.UnsupportedReparsePointType => unreachable, |
| 152 | error.NotLink => unreachable, | 153 | error.NotLink => unreachable, |
| 154 | error.InvalidUtf8 => unreachable, // WASI-only | ||
| 153 | else => |e| return e, | 155 | else => |e| return e, |
| 154 | }; | 156 | }; |
| 155 | return target; | 157 | return target; |
lib/std/os/emscripten.zig+28-292| ... | @@ -1,10 +1,14 @@ | ... | @@ -1,10 +1,14 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const wasi = std.os.wasi; | 3 | const wasi = std.os.wasi; |
| 4 | const linux = std.os.linux; | ||
| 4 | const iovec = std.posix.iovec; | 5 | const iovec = std.posix.iovec; |
| 5 | const iovec_const = std.posix.iovec_const; | 6 | const iovec_const = std.posix.iovec_const; |
| 6 | const c = std.c; | 7 | const c = std.c; |
| 7 | 8 | ||
| 9 | // TODO: go through this file and delete all the bits that are identical to linux because they can | ||
| 10 | // be merged in the std.c namespace. | ||
| 11 | |||
| 8 | pub const FILE = c.FILE; | 12 | pub const FILE = c.FILE; |
| 9 | 13 | ||
| 10 | var __stack_chk_guard: usize = 0; | 14 | var __stack_chk_guard: usize = 0; |
| ... | @@ -23,124 +27,9 @@ comptime { | ... | @@ -23,124 +27,9 @@ comptime { |
| 23 | } | 27 | } |
| 24 | } | 28 | } |
| 25 | 29 | ||
| 26 | pub const PF = struct { | 30 | pub const PF = linux.PF; |
| 27 | pub const UNSPEC = 0; | 31 | pub const AF = linux.AF; |
| 28 | pub const LOCAL = 1; | 32 | pub const CLOCK = linux.CLOCK; |
| 29 | pub const UNIX = LOCAL; | ||
| 30 | pub const FILE = LOCAL; | ||
| 31 | pub const INET = 2; | ||
| 32 | pub const AX25 = 3; | ||
| 33 | pub const IPX = 4; | ||
| 34 | pub const APPLETALK = 5; | ||
| 35 | pub const NETROM = 6; | ||
| 36 | pub const BRIDGE = 7; | ||
| 37 | pub const ATMPVC = 8; | ||
| 38 | pub const X25 = 9; | ||
| 39 | pub const INET6 = 10; | ||
| 40 | pub const ROSE = 11; | ||
| 41 | pub const DECnet = 12; | ||
| 42 | pub const NETBEUI = 13; | ||
| 43 | pub const SECURITY = 14; | ||
| 44 | pub const KEY = 15; | ||
| 45 | pub const NETLINK = 16; | ||
| 46 | pub const ROUTE = PF.NETLINK; | ||
| 47 | pub const PACKET = 17; | ||
| 48 | pub const ASH = 18; | ||
| 49 | pub const ECONET = 19; | ||
| 50 | pub const ATMSVC = 20; | ||
| 51 | pub const RDS = 21; | ||
| 52 | pub const SNA = 22; | ||
| 53 | pub const IRDA = 23; | ||
| 54 | pub const PPPOX = 24; | ||
| 55 | pub const WANPIPE = 25; | ||
| 56 | pub const LLC = 26; | ||
| 57 | pub const IB = 27; | ||
| 58 | pub const MPLS = 28; | ||
| 59 | pub const CAN = 29; | ||
| 60 | pub const TIPC = 30; | ||
| 61 | pub const BLUETOOTH = 31; | ||
| 62 | pub const IUCV = 32; | ||
| 63 | pub const RXRPC = 33; | ||
| 64 | pub const ISDN = 34; | ||
| 65 | pub const PHONET = 35; | ||
| 66 | pub const IEEE802154 = 36; | ||
| 67 | pub const CAIF = 37; | ||
| 68 | pub const ALG = 38; | ||
| 69 | pub const NFC = 39; | ||
| 70 | pub const VSOCK = 40; | ||
| 71 | pub const KCM = 41; | ||
| 72 | pub const QIPCRTR = 42; | ||
| 73 | pub const SMC = 43; | ||
| 74 | pub const XDP = 44; | ||
| 75 | pub const MAX = 45; | ||
| 76 | }; | ||
| 77 | |||
| 78 | pub const AF = struct { | ||
| 79 | pub const UNSPEC = PF.UNSPEC; | ||
| 80 | pub const LOCAL = PF.LOCAL; | ||
| 81 | pub const UNIX = AF.LOCAL; | ||
| 82 | pub const FILE = AF.LOCAL; | ||
| 83 | pub const INET = PF.INET; | ||
| 84 | pub const AX25 = PF.AX25; | ||
| 85 | pub const IPX = PF.IPX; | ||
| 86 | pub const APPLETALK = PF.APPLETALK; | ||
| 87 | pub const NETROM = PF.NETROM; | ||
| 88 | pub const BRIDGE = PF.BRIDGE; | ||
| 89 | pub const ATMPVC = PF.ATMPVC; | ||
| 90 | pub const X25 = PF.X25; | ||
| 91 | pub const INET6 = PF.INET6; | ||
| 92 | pub const ROSE = PF.ROSE; | ||
| 93 | pub const DECnet = PF.DECnet; | ||
| 94 | pub const NETBEUI = PF.NETBEUI; | ||
| 95 | pub const SECURITY = PF.SECURITY; | ||
| 96 | pub const KEY = PF.KEY; | ||
| 97 | pub const NETLINK = PF.NETLINK; | ||
| 98 | pub const ROUTE = PF.ROUTE; | ||
| 99 | pub const PACKET = PF.PACKET; | ||
| 100 | pub const ASH = PF.ASH; | ||
| 101 | pub const ECONET = PF.ECONET; | ||
| 102 | pub const ATMSVC = PF.ATMSVC; | ||
| 103 | pub const RDS = PF.RDS; | ||
| 104 | pub const SNA = PF.SNA; | ||
| 105 | pub const IRDA = PF.IRDA; | ||
| 106 | pub const PPPOX = PF.PPPOX; | ||
| 107 | pub const WANPIPE = PF.WANPIPE; | ||
| 108 | pub const LLC = PF.LLC; | ||
| 109 | pub const IB = PF.IB; | ||
| 110 | pub const MPLS = PF.MPLS; | ||
| 111 | pub const CAN = PF.CAN; | ||
| 112 | pub const TIPC = PF.TIPC; | ||
| 113 | pub const BLUETOOTH = PF.BLUETOOTH; | ||
| 114 | pub const IUCV = PF.IUCV; | ||
| 115 | pub const RXRPC = PF.RXRPC; | ||
| 116 | pub const ISDN = PF.ISDN; | ||
| 117 | pub const PHONET = PF.PHONET; | ||
| 118 | pub const IEEE802154 = PF.IEEE802154; | ||
| 119 | pub const CAIF = PF.CAIF; | ||
| 120 | pub const ALG = PF.ALG; | ||
| 121 | pub const NFC = PF.NFC; | ||
| 122 | pub const VSOCK = PF.VSOCK; | ||
| 123 | pub const KCM = PF.KCM; | ||
| 124 | pub const QIPCRTR = PF.QIPCRTR; | ||
| 125 | pub const SMC = PF.SMC; | ||
| 126 | pub const XDP = PF.XDP; | ||
| 127 | pub const MAX = PF.MAX; | ||
| 128 | }; | ||
| 129 | |||
| 130 | pub const CLOCK = struct { | ||
| 131 | pub const REALTIME = 0; | ||
| 132 | pub const MONOTONIC = 1; | ||
| 133 | pub const PROCESS_CPUTIME_ID = 2; | ||
| 134 | pub const THREAD_CPUTIME_ID = 3; | ||
| 135 | pub const MONOTONIC_RAW = 4; | ||
| 136 | pub const REALTIME_COARSE = 5; | ||
| 137 | pub const MONOTONIC_COARSE = 6; | ||
| 138 | pub const BOOTTIME = 7; | ||
| 139 | pub const REALTIME_ALARM = 8; | ||
| 140 | pub const BOOTTIME_ALARM = 9; | ||
| 141 | pub const SGI_CYCLE = 10; | ||
| 142 | pub const TAI = 11; | ||
| 143 | }; | ||
| 144 | 33 | ||
| 145 | pub const CPU_SETSIZE = 128; | 34 | pub const CPU_SETSIZE = 128; |
| 146 | pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; | 35 | pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; |
| ... | @@ -368,41 +257,7 @@ pub const IOV_MAX = 1024; | ... | @@ -368,41 +257,7 @@ pub const IOV_MAX = 1024; |
| 368 | 257 | ||
| 369 | pub const IPPORT_RESERVED = 1024; | 258 | pub const IPPORT_RESERVED = 1024; |
| 370 | 259 | ||
| 371 | pub const IPPROTO = struct { | 260 | pub const IPPROTO = linux.IPPROTO; |
| 372 | pub const IP = 0; | ||
| 373 | pub const HOPOPTS = 0; | ||
| 374 | pub const ICMP = 1; | ||
| 375 | pub const IGMP = 2; | ||
| 376 | pub const IPIP = 4; | ||
| 377 | pub const TCP = 6; | ||
| 378 | pub const EGP = 8; | ||
| 379 | pub const PUP = 12; | ||
| 380 | pub const UDP = 17; | ||
| 381 | pub const IDP = 22; | ||
| 382 | pub const TP = 29; | ||
| 383 | pub const DCCP = 33; | ||
| 384 | pub const IPV6 = 41; | ||
| 385 | pub const ROUTING = 43; | ||
| 386 | pub const FRAGMENT = 44; | ||
| 387 | pub const RSVP = 46; | ||
| 388 | pub const GRE = 47; | ||
| 389 | pub const ESP = 50; | ||
| 390 | pub const AH = 51; | ||
| 391 | pub const ICMPV6 = 58; | ||
| 392 | pub const NONE = 59; | ||
| 393 | pub const DSTOPTS = 60; | ||
| 394 | pub const MTP = 92; | ||
| 395 | pub const BEETPH = 94; | ||
| 396 | pub const ENCAP = 98; | ||
| 397 | pub const PIM = 103; | ||
| 398 | pub const COMP = 108; | ||
| 399 | pub const SCTP = 132; | ||
| 400 | pub const MH = 135; | ||
| 401 | pub const UDPLITE = 136; | ||
| 402 | pub const MPLS = 137; | ||
| 403 | pub const RAW = 255; | ||
| 404 | pub const MAX = 256; | ||
| 405 | }; | ||
| 406 | 261 | ||
| 407 | pub const LOCK = struct { | 262 | pub const LOCK = struct { |
| 408 | pub const SH = 1; | 263 | pub const SH = 1; |
| ... | @@ -494,10 +349,7 @@ pub const RLIM = struct { | ... | @@ -494,10 +349,7 @@ pub const RLIM = struct { |
| 494 | pub const SAVED_CUR = INFINITY; | 349 | pub const SAVED_CUR = INFINITY; |
| 495 | }; | 350 | }; |
| 496 | 351 | ||
| 497 | pub const rlimit = extern struct { | 352 | pub const rlimit = c.rlimit; |
| 498 | cur: rlim_t, | ||
| 499 | max: rlim_t, | ||
| 500 | }; | ||
| 501 | 353 | ||
| 502 | pub const rlimit_resource = enum(c_int) { | 354 | pub const rlimit_resource = enum(c_int) { |
| 503 | CPU, | 355 | CPU, |
| ... | @@ -544,8 +396,8 @@ pub const rusage = extern struct { | ... | @@ -544,8 +396,8 @@ pub const rusage = extern struct { |
| 544 | }; | 396 | }; |
| 545 | 397 | ||
| 546 | pub const timeval = extern struct { | 398 | pub const timeval = extern struct { |
| 547 | tv_sec: i64, | 399 | sec: i64, |
| 548 | tv_usec: i32, | 400 | usec: i32, |
| 549 | }; | 401 | }; |
| 550 | 402 | ||
| 551 | pub const REG = struct { | 403 | pub const REG = struct { |
| ... | @@ -929,112 +781,13 @@ pub const TCP = struct { | ... | @@ -929,112 +781,13 @@ pub const TCP = struct { |
| 929 | pub const REPAIR_OFF_NO_WP = -1; | 781 | pub const REPAIR_OFF_NO_WP = -1; |
| 930 | }; | 782 | }; |
| 931 | 783 | ||
| 932 | pub const TCSA = enum(c_uint) { | 784 | pub const TCSA = std.posix.TCSA; |
| 933 | NOW, | 785 | pub const addrinfo = c.addrinfo; |
| 934 | DRAIN, | ||
| 935 | FLUSH, | ||
| 936 | _, | ||
| 937 | }; | ||
| 938 | |||
| 939 | pub const addrinfo = extern struct { | ||
| 940 | flags: i32, | ||
| 941 | family: i32, | ||
| 942 | socktype: i32, | ||
| 943 | protocol: i32, | ||
| 944 | addrlen: socklen_t, | ||
| 945 | addr: ?*sockaddr, | ||
| 946 | canonname: ?[*:0]u8, | ||
| 947 | next: ?*addrinfo, | ||
| 948 | }; | ||
| 949 | |||
| 950 | pub const in_port_t = u16; | ||
| 951 | pub const sa_family_t = u16; | ||
| 952 | pub const socklen_t = u32; | ||
| 953 | 786 | ||
| 954 | pub const sockaddr = extern struct { | 787 | pub const in_port_t = c.in_port_t; |
| 955 | family: sa_family_t, | 788 | pub const sa_family_t = c.sa_family_t; |
| 956 | data: [14]u8, | 789 | pub const socklen_t = c.socklen_t; |
| 957 | 790 | pub const sockaddr = c.sockaddr; | |
| 958 | pub const SS_MAXSIZE = 128; | ||
| 959 | pub const storage = extern struct { | ||
| 960 | family: sa_family_t align(8), | ||
| 961 | padding: [SS_MAXSIZE - @sizeOf(sa_family_t)]u8 = undefined, | ||
| 962 | |||
| 963 | comptime { | ||
| 964 | std.debug.assert(@sizeOf(storage) == SS_MAXSIZE); | ||
| 965 | std.debug.assert(@alignOf(storage) == 8); | ||
| 966 | } | ||
| 967 | }; | ||
| 968 | |||
| 969 | /// IPv4 socket address | ||
| 970 | pub const in = extern struct { | ||
| 971 | family: sa_family_t = AF.INET, | ||
| 972 | port: in_port_t, | ||
| 973 | addr: u32, | ||
| 974 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, | ||
| 975 | }; | ||
| 976 | |||
| 977 | /// IPv6 socket address | ||
| 978 | pub const in6 = extern struct { | ||
| 979 | family: sa_family_t = AF.INET6, | ||
| 980 | port: in_port_t, | ||
| 981 | flowinfo: u32, | ||
| 982 | addr: [16]u8, | ||
| 983 | scope_id: u32, | ||
| 984 | }; | ||
| 985 | |||
| 986 | /// UNIX domain socket address | ||
| 987 | pub const un = extern struct { | ||
| 988 | family: sa_family_t = AF.UNIX, | ||
| 989 | path: [108]u8, | ||
| 990 | }; | ||
| 991 | |||
| 992 | /// Packet socket address | ||
| 993 | pub const ll = extern struct { | ||
| 994 | family: sa_family_t = AF.PACKET, | ||
| 995 | protocol: u16, | ||
| 996 | ifindex: i32, | ||
| 997 | hatype: u16, | ||
| 998 | pkttype: u8, | ||
| 999 | halen: u8, | ||
| 1000 | addr: [8]u8, | ||
| 1001 | }; | ||
| 1002 | |||
| 1003 | /// Netlink socket address | ||
| 1004 | pub const nl = extern struct { | ||
| 1005 | family: sa_family_t = AF.NETLINK, | ||
| 1006 | __pad1: c_ushort = 0, | ||
| 1007 | |||
| 1008 | /// port ID | ||
| 1009 | pid: u32, | ||
| 1010 | |||
| 1011 | /// multicast groups mask | ||
| 1012 | groups: u32, | ||
| 1013 | }; | ||
| 1014 | |||
| 1015 | pub const xdp = extern struct { | ||
| 1016 | family: u16 = AF.XDP, | ||
| 1017 | flags: u16, | ||
| 1018 | ifindex: u32, | ||
| 1019 | queue_id: u32, | ||
| 1020 | shared_umem_fd: u32, | ||
| 1021 | }; | ||
| 1022 | |||
| 1023 | /// Address structure for vSockets | ||
| 1024 | pub const vm = extern struct { | ||
| 1025 | family: sa_family_t = AF.VSOCK, | ||
| 1026 | reserved1: u16 = 0, | ||
| 1027 | port: u32, | ||
| 1028 | cid: u32, | ||
| 1029 | flags: u8, | ||
| 1030 | |||
| 1031 | /// The total size of this structure should be exactly the same as that of struct sockaddr. | ||
| 1032 | zero: [3]u8 = [_]u8{0} ** 3, | ||
| 1033 | comptime { | ||
| 1034 | std.debug.assert(@sizeOf(vm) == @sizeOf(sockaddr)); | ||
| 1035 | } | ||
| 1036 | }; | ||
| 1037 | }; | ||
| 1038 | 791 | ||
| 1039 | pub const blksize_t = i32; | 792 | pub const blksize_t = i32; |
| 1040 | pub const nlink_t = u32; | 793 | pub const nlink_t = u32; |
| ... | @@ -1046,16 +799,16 @@ pub const dev_t = u32; | ... | @@ -1046,16 +799,16 @@ pub const dev_t = u32; |
| 1046 | pub const blkcnt_t = i32; | 799 | pub const blkcnt_t = i32; |
| 1047 | 800 | ||
| 1048 | pub const pid_t = i32; | 801 | pub const pid_t = i32; |
| 1049 | pub const fd_t = i32; | 802 | pub const fd_t = c.fd_t; |
| 1050 | pub const uid_t = u32; | 803 | pub const uid_t = u32; |
| 1051 | pub const gid_t = u32; | 804 | pub const gid_t = u32; |
| 1052 | pub const clock_t = i32; | 805 | pub const clock_t = i32; |
| 1053 | 806 | ||
| 1054 | pub const dl_phdr_info = extern struct { | 807 | pub const dl_phdr_info = extern struct { |
| 1055 | dlpi_addr: usize, | 808 | addr: usize, |
| 1056 | dlpi_name: ?[*:0]const u8, | 809 | name: ?[*:0]const u8, |
| 1057 | dlpi_phdr: [*]std.elf.Phdr, | 810 | phdr: [*]std.elf.Phdr, |
| 1058 | dlpi_phnum: u16, | 811 | phnum: u16, |
| 1059 | }; | 812 | }; |
| 1060 | 813 | ||
| 1061 | pub const mcontext_t = extern struct { | 814 | pub const mcontext_t = extern struct { |
| ... | @@ -1065,25 +818,8 @@ pub const mcontext_t = extern struct { | ... | @@ -1065,25 +818,8 @@ pub const mcontext_t = extern struct { |
| 1065 | cr2: usize, | 818 | cr2: usize, |
| 1066 | }; | 819 | }; |
| 1067 | 820 | ||
| 1068 | pub const msghdr = extern struct { | 821 | pub const msghdr = std.c.msghdr; |
| 1069 | name: ?*sockaddr, | 822 | pub const msghdr_const = std.c.msghdr; |
| 1070 | namelen: socklen_t, | ||
| 1071 | iov: [*]iovec, | ||
| 1072 | iovlen: i32, | ||
| 1073 | control: ?*anyopaque, | ||
| 1074 | controllen: socklen_t, | ||
| 1075 | flags: i32, | ||
| 1076 | }; | ||
| 1077 | |||
| 1078 | pub const msghdr_const = extern struct { | ||
| 1079 | name: ?*const sockaddr, | ||
| 1080 | namelen: socklen_t, | ||
| 1081 | iov: [*]const iovec_const, | ||
| 1082 | iovlen: i32, | ||
| 1083 | control: ?*const anyopaque, | ||
| 1084 | controllen: socklen_t, | ||
| 1085 | flags: i32, | ||
| 1086 | }; | ||
| 1087 | 823 | ||
| 1088 | pub const nfds_t = usize; | 824 | pub const nfds_t = usize; |
| 1089 | pub const pollfd = extern struct { | 825 | pub const pollfd = extern struct { |
| ... | @@ -1099,13 +835,13 @@ pub const stack_t = extern struct { | ... | @@ -1099,13 +835,13 @@ pub const stack_t = extern struct { |
| 1099 | }; | 835 | }; |
| 1100 | 836 | ||
| 1101 | pub const timespec = extern struct { | 837 | pub const timespec = extern struct { |
| 1102 | tv_sec: time_t, | 838 | sec: time_t, |
| 1103 | tv_nsec: isize, | 839 | nsec: isize, |
| 1104 | }; | 840 | }; |
| 1105 | 841 | ||
| 1106 | pub const timezone = extern struct { | 842 | pub const timezone = extern struct { |
| 1107 | tz_minuteswest: i32, | 843 | minuteswest: i32, |
| 1108 | tz_dsttime: i32, | 844 | dsttime: i32, |
| 1109 | }; | 845 | }; |
| 1110 | 846 | ||
| 1111 | pub const ucontext_t = extern struct { | 847 | pub const ucontext_t = extern struct { |
lib/std/os/linux.zig+69-72| ... | @@ -20,6 +20,7 @@ const is_ppc64 = native_arch.isPPC64(); | ... | @@ -20,6 +20,7 @@ const is_ppc64 = native_arch.isPPC64(); |
| 20 | const is_sparc = native_arch.isSPARC(); | 20 | const is_sparc = native_arch.isSPARC(); |
| 21 | const iovec = std.posix.iovec; | 21 | const iovec = std.posix.iovec; |
| 22 | const iovec_const = std.posix.iovec_const; | 22 | const iovec_const = std.posix.iovec_const; |
| 23 | const winsize = std.posix.winsize; | ||
| 23 | const ACCMODE = std.posix.ACCMODE; | 24 | const ACCMODE = std.posix.ACCMODE; |
| 24 | 25 | ||
| 25 | test { | 26 | test { |
| ... | @@ -44,7 +45,10 @@ const arch_bits = switch (native_arch) { | ... | @@ -44,7 +45,10 @@ const arch_bits = switch (native_arch) { |
| 44 | .mips64, .mips64el => @import("linux/mips64.zig"), | 45 | .mips64, .mips64el => @import("linux/mips64.zig"), |
| 45 | .powerpc, .powerpcle => @import("linux/powerpc.zig"), | 46 | .powerpc, .powerpcle => @import("linux/powerpc.zig"), |
| 46 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), | 47 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), |
| 47 | else => struct {}, | 48 | else => struct { |
| 49 | pub const ucontext_t = void; | ||
| 50 | pub const getcontext = {}; | ||
| 51 | }, | ||
| 48 | }; | 52 | }; |
| 49 | pub const syscall0 = syscall_bits.syscall0; | 53 | pub const syscall0 = syscall_bits.syscall0; |
| 50 | pub const syscall1 = syscall_bits.syscall1; | 54 | pub const syscall1 = syscall_bits.syscall1; |
| ... | @@ -65,7 +69,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx; | ... | @@ -65,7 +69,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx; |
| 65 | pub const F = arch_bits.F; | 69 | pub const F = arch_bits.F; |
| 66 | pub const Flock = arch_bits.Flock; | 70 | pub const Flock = arch_bits.Flock; |
| 67 | pub const HWCAP = arch_bits.HWCAP; | 71 | pub const HWCAP = arch_bits.HWCAP; |
| 68 | pub const LOCK = arch_bits.LOCK; | ||
| 69 | pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT; | 72 | pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT; |
| 70 | pub const REG = arch_bits.REG; | 73 | pub const REG = arch_bits.REG; |
| 71 | pub const SC = arch_bits.SC; | 74 | pub const SC = arch_bits.SC; |
| ... | @@ -586,7 +589,7 @@ pub fn futex2_waitv( | ... | @@ -586,7 +589,7 @@ pub fn futex2_waitv( |
| 586 | /// Optional absolute timeout. | 589 | /// Optional absolute timeout. |
| 587 | timeout: ?*const timespec, | 590 | timeout: ?*const timespec, |
| 588 | /// Clock to be used for the timeout, realtime or monotonic. | 591 | /// Clock to be used for the timeout, realtime or monotonic. |
| 589 | clockid: i32, | 592 | clockid: clockid_t, |
| 590 | ) usize { | 593 | ) usize { |
| 591 | return syscall5( | 594 | return syscall5( |
| 592 | .futex_waitv, | 595 | .futex_waitv, |
| ... | @@ -612,7 +615,7 @@ pub fn futex2_wait( | ... | @@ -612,7 +615,7 @@ pub fn futex2_wait( |
| 612 | /// Optional absolute timeout. | 615 | /// Optional absolute timeout. |
| 613 | timeout: *const timespec, | 616 | timeout: *const timespec, |
| 614 | /// Clock to be used for the timeout, realtime or monotonic. | 617 | /// Clock to be used for the timeout, realtime or monotonic. |
| 615 | clockid: i32, | 618 | clockid: clockid_t, |
| 616 | ) usize { | 619 | ) usize { |
| 617 | return syscall6( | 620 | return syscall6( |
| 618 | .futex_wait, | 621 | .futex_wait, |
| ... | @@ -856,8 +859,8 @@ pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize { | ... | @@ -856,8 +859,8 @@ pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize { |
| 856 | n, | 859 | n, |
| 857 | @intFromPtr(if (timeout >= 0) | 860 | @intFromPtr(if (timeout >= 0) |
| 858 | &timespec{ | 861 | &timespec{ |
| 859 | .tv_sec = @divTrunc(timeout, 1000), | 862 | .sec = @divTrunc(timeout, 1000), |
| 860 | .tv_nsec = @rem(timeout, 1000) * 1000000, | 863 | .nsec = @rem(timeout, 1000) * 1000000, |
| 861 | } | 864 | } |
| 862 | else | 865 | else |
| 863 | null), | 866 | null), |
| ... | @@ -1375,10 +1378,10 @@ pub fn flock(fd: fd_t, operation: i32) usize { | ... | @@ -1375,10 +1378,10 @@ pub fn flock(fd: fd_t, operation: i32) usize { |
| 1375 | } | 1378 | } |
| 1376 | 1379 | ||
| 1377 | // We must follow the C calling convention when we call into the VDSO | 1380 | // We must follow the C calling convention when we call into the VDSO |
| 1378 | const VdsoClockGettime = *align(1) const fn (i32, *timespec) callconv(.C) usize; | 1381 | const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C) usize; |
| 1379 | var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; | 1382 | var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; |
| 1380 | 1383 | ||
| 1381 | pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { | 1384 | pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { |
| 1382 | if (@hasDecl(VDSO, "CGT_SYM")) { | 1385 | if (@hasDecl(VDSO, "CGT_SYM")) { |
| 1383 | const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered); | 1386 | const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered); |
| 1384 | if (ptr) |f| { | 1387 | if (ptr) |f| { |
| ... | @@ -1389,10 +1392,10 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { | ... | @@ -1389,10 +1392,10 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { |
| 1389 | } | 1392 | } |
| 1390 | } | 1393 | } |
| 1391 | } | 1394 | } |
| 1392 | return syscall2(.clock_gettime, @as(usize, @bitCast(@as(isize, clk_id))), @intFromPtr(tp)); | 1395 | return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp)); |
| 1393 | } | 1396 | } |
| 1394 | 1397 | ||
| 1395 | fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize { | 1398 | fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.C) usize { |
| 1396 | const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); | 1399 | const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); |
| 1397 | // Note that we may not have a VDSO at all, update the stub address anyway | 1400 | // Note that we may not have a VDSO at all, update the stub address anyway |
| 1398 | // so that clock_gettime will fall back on the good old (and slow) syscall | 1401 | // so that clock_gettime will fall back on the good old (and slow) syscall |
| ... | @@ -1975,8 +1978,12 @@ pub fn eventfd(count: u32, flags: u32) usize { | ... | @@ -1975,8 +1978,12 @@ pub fn eventfd(count: u32, flags: u32) usize { |
| 1975 | return syscall2(.eventfd2, count, flags); | 1978 | return syscall2(.eventfd2, count, flags); |
| 1976 | } | 1979 | } |
| 1977 | 1980 | ||
| 1978 | pub fn timerfd_create(clockid: i32, flags: TFD) usize { | 1981 | pub fn timerfd_create(clockid: clockid_t, flags: TFD) usize { |
| 1979 | return syscall2(.timerfd_create, @bitCast(@as(isize, clockid)), @as(u32, @bitCast(flags))); | 1982 | return syscall2( |
| 1983 | .timerfd_create, | ||
| 1984 | @intFromEnum(clockid), | ||
| 1985 | @as(u32, @bitCast(flags)), | ||
| 1986 | ); | ||
| 1980 | } | 1987 | } |
| 1981 | 1988 | ||
| 1982 | pub const itimerspec = extern struct { | 1989 | pub const itimerspec = extern struct { |
| ... | @@ -4042,19 +4049,22 @@ pub const EPOLL = struct { | ... | @@ -4042,19 +4049,22 @@ pub const EPOLL = struct { |
| 4042 | pub const ET = (@as(u32, 1) << 31); | 4049 | pub const ET = (@as(u32, 1) << 31); |
| 4043 | }; | 4050 | }; |
| 4044 | 4051 | ||
| 4045 | pub const CLOCK = struct { | 4052 | pub const CLOCK = clockid_t; |
| 4046 | pub const REALTIME = 0; | 4053 | |
| 4047 | pub const MONOTONIC = 1; | 4054 | pub const clockid_t = enum(u32) { |
| 4048 | pub const PROCESS_CPUTIME_ID = 2; | 4055 | REALTIME = 0, |
| 4049 | pub const THREAD_CPUTIME_ID = 3; | 4056 | MONOTONIC = 1, |
| 4050 | pub const MONOTONIC_RAW = 4; | 4057 | PROCESS_CPUTIME_ID = 2, |
| 4051 | pub const REALTIME_COARSE = 5; | 4058 | THREAD_CPUTIME_ID = 3, |
| 4052 | pub const MONOTONIC_COARSE = 6; | 4059 | MONOTONIC_RAW = 4, |
| 4053 | pub const BOOTTIME = 7; | 4060 | REALTIME_COARSE = 5, |
| 4054 | pub const REALTIME_ALARM = 8; | 4061 | MONOTONIC_COARSE = 6, |
| 4055 | pub const BOOTTIME_ALARM = 9; | 4062 | BOOTTIME = 7, |
| 4056 | pub const SGI_CYCLE = 10; | 4063 | REALTIME_ALARM = 8, |
| 4057 | pub const TAI = 11; | 4064 | BOOTTIME_ALARM = 9, |
| 4065 | SGI_CYCLE = 10, | ||
| 4066 | TAI = 11, | ||
| 4067 | _, | ||
| 4058 | }; | 4068 | }; |
| 4059 | 4069 | ||
| 4060 | pub const CSIGNAL = 0x000000ff; | 4070 | pub const CSIGNAL = 0x000000ff; |
| ... | @@ -4430,13 +4440,6 @@ pub const TFD = switch (native_arch) { | ... | @@ -4430,13 +4440,6 @@ pub const TFD = switch (native_arch) { |
| 4430 | }, | 4440 | }, |
| 4431 | }; | 4441 | }; |
| 4432 | 4442 | ||
| 4433 | pub const winsize = extern struct { | ||
| 4434 | ws_row: u16, | ||
| 4435 | ws_col: u16, | ||
| 4436 | ws_xpixel: u16, | ||
| 4437 | ws_ypixel: u16, | ||
| 4438 | }; | ||
| 4439 | |||
| 4440 | /// NSIG is the total number of signals defined. | 4443 | /// NSIG is the total number of signals defined. |
| 4441 | /// As signal numbers are sequential, NSIG is one greater than the largest defined signal number. | 4444 | /// As signal numbers are sequential, NSIG is one greater than the largest defined signal number. |
| 4442 | pub const NSIG = if (is_mips) 128 else 65; | 4445 | pub const NSIG = if (is_mips) 128 else 65; |
| ... | @@ -4610,13 +4613,13 @@ pub const sockaddr = extern struct { | ... | @@ -4610,13 +4613,13 @@ pub const sockaddr = extern struct { |
| 4610 | }; | 4613 | }; |
| 4611 | 4614 | ||
| 4612 | pub const mmsghdr = extern struct { | 4615 | pub const mmsghdr = extern struct { |
| 4613 | msg_hdr: msghdr, | 4616 | hdr: msghdr, |
| 4614 | msg_len: u32, | 4617 | len: u32, |
| 4615 | }; | 4618 | }; |
| 4616 | 4619 | ||
| 4617 | pub const mmsghdr_const = extern struct { | 4620 | pub const mmsghdr_const = extern struct { |
| 4618 | msg_hdr: msghdr_const, | 4621 | hdr: msghdr_const, |
| 4619 | msg_len: u32, | 4622 | len: u32, |
| 4620 | }; | 4623 | }; |
| 4621 | 4624 | ||
| 4622 | pub const epoll_data = extern union { | 4625 | pub const epoll_data = extern union { |
| ... | @@ -4761,10 +4764,10 @@ pub const dirent64 = extern struct { | ... | @@ -4761,10 +4764,10 @@ pub const dirent64 = extern struct { |
| 4761 | }; | 4764 | }; |
| 4762 | 4765 | ||
| 4763 | pub const dl_phdr_info = extern struct { | 4766 | pub const dl_phdr_info = extern struct { |
| 4764 | dlpi_addr: usize, | 4767 | addr: usize, |
| 4765 | dlpi_name: ?[*:0]const u8, | 4768 | name: ?[*:0]const u8, |
| 4766 | dlpi_phdr: [*]std.elf.Phdr, | 4769 | phdr: [*]std.elf.Phdr, |
| 4767 | dlpi_phnum: u16, | 4770 | phnum: u16, |
| 4768 | }; | 4771 | }; |
| 4769 | 4772 | ||
| 4770 | pub const CPU_SETSIZE = 128; | 4773 | pub const CPU_SETSIZE = 128; |
| ... | @@ -4790,9 +4793,11 @@ pub const SIGSTKSZ = switch (native_arch) { | ... | @@ -4790,9 +4793,11 @@ pub const SIGSTKSZ = switch (native_arch) { |
| 4790 | else => @compileError("SIGSTKSZ not defined for this architecture"), | 4793 | else => @compileError("SIGSTKSZ not defined for this architecture"), |
| 4791 | }; | 4794 | }; |
| 4792 | 4795 | ||
| 4793 | pub const SS_ONSTACK = 1; | 4796 | pub const SS = struct { |
| 4794 | pub const SS_DISABLE = 2; | 4797 | pub const ONSTACK = 1; |
| 4795 | pub const SS_AUTODISARM = 1 << 31; | 4798 | pub const DISABLE = 2; |
| 4799 | pub const AUTODISARM = 1 << 31; | ||
| 4800 | }; | ||
| 4796 | 4801 | ||
| 4797 | pub const stack_t = if (is_mips) | 4802 | pub const stack_t = if (is_mips) |
| 4798 | // IRIX compatible stack_t | 4803 | // IRIX compatible stack_t |
| ... | @@ -5506,8 +5511,8 @@ pub const STATX_ATTR_ENCRYPTED = 0x0800; | ... | @@ -5506,8 +5511,8 @@ pub const STATX_ATTR_ENCRYPTED = 0x0800; |
| 5506 | pub const STATX_ATTR_AUTOMOUNT = 0x1000; | 5511 | pub const STATX_ATTR_AUTOMOUNT = 0x1000; |
| 5507 | 5512 | ||
| 5508 | pub const statx_timestamp = extern struct { | 5513 | pub const statx_timestamp = extern struct { |
| 5509 | tv_sec: i64, | 5514 | sec: i64, |
| 5510 | tv_nsec: u32, | 5515 | nsec: u32, |
| 5511 | __pad1: u32, | 5516 | __pad1: u32, |
| 5512 | }; | 5517 | }; |
| 5513 | 5518 | ||
| ... | @@ -5575,7 +5580,7 @@ pub const Statx = extern struct { | ... | @@ -5575,7 +5580,7 @@ pub const Statx = extern struct { |
| 5575 | }; | 5580 | }; |
| 5576 | 5581 | ||
| 5577 | pub const addrinfo = extern struct { | 5582 | pub const addrinfo = extern struct { |
| 5578 | flags: i32, | 5583 | flags: AI, |
| 5579 | family: i32, | 5584 | family: i32, |
| 5580 | socktype: i32, | 5585 | socktype: i32, |
| 5581 | protocol: i32, | 5586 | protocol: i32, |
| ... | @@ -5585,6 +5590,18 @@ pub const addrinfo = extern struct { | ... | @@ -5585,6 +5590,18 @@ pub const addrinfo = extern struct { |
| 5585 | next: ?*addrinfo, | 5590 | next: ?*addrinfo, |
| 5586 | }; | 5591 | }; |
| 5587 | 5592 | ||
| 5593 | pub const AI = packed struct(u32) { | ||
| 5594 | PASSIVE: bool = false, | ||
| 5595 | CANONNAME: bool = false, | ||
| 5596 | NUMERICHOST: bool = false, | ||
| 5597 | V4MAPPED: bool = false, | ||
| 5598 | ALL: bool = false, | ||
| 5599 | ADDRCONFIG: bool = false, | ||
| 5600 | _6: u4 = 0, | ||
| 5601 | NUMERICSERV: bool = false, | ||
| 5602 | _: u21 = 0, | ||
| 5603 | }; | ||
| 5604 | |||
| 5588 | pub const IPPORT_RESERVED = 1024; | 5605 | pub const IPPORT_RESERVED = 1024; |
| 5589 | 5606 | ||
| 5590 | pub const IPPROTO = struct { | 5607 | pub const IPPROTO = struct { |
| ... | @@ -6041,12 +6058,7 @@ pub const V = switch (native_arch) { | ... | @@ -6041,12 +6058,7 @@ pub const V = switch (native_arch) { |
| 6041 | }, | 6058 | }, |
| 6042 | }; | 6059 | }; |
| 6043 | 6060 | ||
| 6044 | pub const TCSA = enum(c_uint) { | 6061 | pub const TCSA = std.posix.TCSA; |
| 6045 | NOW, | ||
| 6046 | DRAIN, | ||
| 6047 | FLUSH, | ||
| 6048 | _, | ||
| 6049 | }; | ||
| 6050 | 6062 | ||
| 6051 | pub const termios = switch (native_arch) { | 6063 | pub const termios = switch (native_arch) { |
| 6052 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => extern struct { | 6064 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => extern struct { |
| ... | @@ -6110,55 +6122,40 @@ else | ... | @@ -6110,55 +6122,40 @@ else |
| 6110 | enum(c_int) { | 6122 | enum(c_int) { |
| 6111 | /// Per-process CPU limit, in seconds. | 6123 | /// Per-process CPU limit, in seconds. |
| 6112 | CPU, | 6124 | CPU, |
| 6113 | |||
| 6114 | /// Largest file that can be created, in bytes. | 6125 | /// Largest file that can be created, in bytes. |
| 6115 | FSIZE, | 6126 | FSIZE, |
| 6116 | |||
| 6117 | /// Maximum size of data segment, in bytes. | 6127 | /// Maximum size of data segment, in bytes. |
| 6118 | DATA, | 6128 | DATA, |
| 6119 | |||
| 6120 | /// Maximum size of stack segment, in bytes. | 6129 | /// Maximum size of stack segment, in bytes. |
| 6121 | STACK, | 6130 | STACK, |
| 6122 | |||
| 6123 | /// Largest core file that can be created, in bytes. | 6131 | /// Largest core file that can be created, in bytes. |
| 6124 | CORE, | 6132 | CORE, |
| 6125 | |||
| 6126 | /// Largest resident set size, in bytes. | 6133 | /// Largest resident set size, in bytes. |
| 6127 | /// This affects swapping; processes that are exceeding their | 6134 | /// This affects swapping; processes that are exceeding their |
| 6128 | /// resident set size will be more likely to have physical memory | 6135 | /// resident set size will be more likely to have physical memory |
| 6129 | /// taken from them. | 6136 | /// taken from them. |
| 6130 | RSS, | 6137 | RSS, |
| 6131 | |||
| 6132 | /// Number of processes. | 6138 | /// Number of processes. |
| 6133 | NPROC, | 6139 | NPROC, |
| 6134 | |||
| 6135 | /// Number of open files. | 6140 | /// Number of open files. |
| 6136 | NOFILE, | 6141 | NOFILE, |
| 6137 | |||
| 6138 | /// Locked-in-memory address space. | 6142 | /// Locked-in-memory address space. |
| 6139 | MEMLOCK, | 6143 | MEMLOCK, |
| 6140 | |||
| 6141 | /// Address space limit. | 6144 | /// Address space limit. |
| 6142 | AS, | 6145 | AS, |
| 6143 | |||
| 6144 | /// Maximum number of file locks. | 6146 | /// Maximum number of file locks. |
| 6145 | LOCKS, | 6147 | LOCKS, |
| 6146 | |||
| 6147 | /// Maximum number of pending signals. | 6148 | /// Maximum number of pending signals. |
| 6148 | SIGPENDING, | 6149 | SIGPENDING, |
| 6149 | |||
| 6150 | /// Maximum bytes in POSIX message queues. | 6150 | /// Maximum bytes in POSIX message queues. |
| 6151 | MSGQUEUE, | 6151 | MSGQUEUE, |
| 6152 | |||
| 6153 | /// Maximum nice priority allowed to raise to. | 6152 | /// Maximum nice priority allowed to raise to. |
| 6154 | /// Nice levels 19 .. -20 correspond to 0 .. 39 | 6153 | /// Nice levels 19 .. -20 correspond to 0 .. 39 |
| 6155 | /// values of this resource limit. | 6154 | /// values of this resource limit. |
| 6156 | NICE, | 6155 | NICE, |
| 6157 | |||
| 6158 | /// Maximum realtime priority allowed for non-privileged | 6156 | /// Maximum realtime priority allowed for non-privileged |
| 6159 | /// processes. | 6157 | /// processes. |
| 6160 | RTPRIO, | 6158 | RTPRIO, |
| 6161 | |||
| 6162 | /// Maximum CPU time in µs that a process scheduled under a real-time | 6159 | /// Maximum CPU time in µs that a process scheduled under a real-time |
| 6163 | /// scheduling policy may consume without making a blocking system | 6160 | /// scheduling policy may consume without making a blocking system |
| 6164 | /// call before being forcibly descheduled. | 6161 | /// call before being forcibly descheduled. |
| ... | @@ -6236,13 +6233,13 @@ pub const POSIX_FADV = switch (native_arch) { | ... | @@ -6236,13 +6233,13 @@ pub const POSIX_FADV = switch (native_arch) { |
| 6236 | 6233 | ||
| 6237 | /// The timespec struct used by the kernel. | 6234 | /// The timespec struct used by the kernel. |
| 6238 | pub const kernel_timespec = if (@sizeOf(usize) >= 8) timespec else extern struct { | 6235 | pub const kernel_timespec = if (@sizeOf(usize) >= 8) timespec else extern struct { |
| 6239 | tv_sec: i64, | 6236 | sec: i64, |
| 6240 | tv_nsec: i64, | 6237 | nsec: i64, |
| 6241 | }; | 6238 | }; |
| 6242 | 6239 | ||
| 6243 | pub const timespec = extern struct { | 6240 | pub const timespec = extern struct { |
| 6244 | tv_sec: isize, | 6241 | sec: isize, |
| 6245 | tv_nsec: isize, | 6242 | nsec: isize, |
| 6246 | }; | 6243 | }; |
| 6247 | 6244 | ||
| 6248 | pub const XDP = struct { | 6245 | pub const XDP = struct { |
| ... | @@ -7115,7 +7112,7 @@ pub const perf_event_attr = extern struct { | ... | @@ -7115,7 +7112,7 @@ pub const perf_event_attr = extern struct { |
| 7115 | /// Defines size of the user stack to dump on samples. | 7112 | /// Defines size of the user stack to dump on samples. |
| 7116 | sample_stack_user: u32 = 0, | 7113 | sample_stack_user: u32 = 0, |
| 7117 | 7114 | ||
| 7118 | clockid: i32 = 0, | 7115 | clockid: clockid_t = 0, |
| 7119 | /// Defines set of regs to dump for each sample | 7116 | /// Defines set of regs to dump for each sample |
| 7120 | /// state captured on: | 7117 | /// state captured on: |
| 7121 | /// - precise = 0: PMU interrupt | 7118 | /// - precise = 0: PMU interrupt |
lib/std/os/linux/IoUring.zig+6-6| ... | @@ -2261,7 +2261,7 @@ test "timeout (after a relative time)" { | ... | @@ -2261,7 +2261,7 @@ test "timeout (after a relative time)" { |
| 2261 | 2261 | ||
| 2262 | const ms = 10; | 2262 | const ms = 10; |
| 2263 | const margin = 5; | 2263 | const margin = 5; |
| 2264 | const ts: linux.kernel_timespec = .{ .tv_sec = 0, .tv_nsec = ms * 1000000 }; | 2264 | const ts: linux.kernel_timespec = .{ .sec = 0, .nsec = ms * 1000000 }; |
| 2265 | 2265 | ||
| 2266 | const started = std.time.milliTimestamp(); | 2266 | const started = std.time.milliTimestamp(); |
| 2267 | const sqe = try ring.timeout(0x55555555, &ts, 0, 0); | 2267 | const sqe = try ring.timeout(0x55555555, &ts, 0, 0); |
| ... | @@ -2290,7 +2290,7 @@ test "timeout (after a number of completions)" { | ... | @@ -2290,7 +2290,7 @@ test "timeout (after a number of completions)" { |
| 2290 | }; | 2290 | }; |
| 2291 | defer ring.deinit(); | 2291 | defer ring.deinit(); |
| 2292 | 2292 | ||
| 2293 | const ts: linux.kernel_timespec = .{ .tv_sec = 3, .tv_nsec = 0 }; | 2293 | const ts: linux.kernel_timespec = .{ .sec = 3, .nsec = 0 }; |
| 2294 | const count_completions: u64 = 1; | 2294 | const count_completions: u64 = 1; |
| 2295 | const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0); | 2295 | const sqe_timeout = try ring.timeout(0x66666666, &ts, count_completions, 0); |
| 2296 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); | 2296 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); |
| ... | @@ -2323,7 +2323,7 @@ test "timeout_remove" { | ... | @@ -2323,7 +2323,7 @@ test "timeout_remove" { |
| 2323 | }; | 2323 | }; |
| 2324 | defer ring.deinit(); | 2324 | defer ring.deinit(); |
| 2325 | 2325 | ||
| 2326 | const ts: linux.kernel_timespec = .{ .tv_sec = 3, .tv_nsec = 0 }; | 2326 | const ts: linux.kernel_timespec = .{ .sec = 3, .nsec = 0 }; |
| 2327 | const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0); | 2327 | const sqe_timeout = try ring.timeout(0x88888888, &ts, 0, 0); |
| 2328 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); | 2328 | try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe_timeout.opcode); |
| 2329 | try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data); | 2329 | try testing.expectEqual(@as(u64, 0x88888888), sqe_timeout.user_data); |
| ... | @@ -2391,7 +2391,7 @@ test "accept/connect/recv/link_timeout" { | ... | @@ -2391,7 +2391,7 @@ test "accept/connect/recv/link_timeout" { |
| 2391 | const sqe_recv = try ring.recv(0xffffffff, socket_test_harness.server, .{ .buffer = buffer_recv[0..] }, 0); | 2391 | const sqe_recv = try ring.recv(0xffffffff, socket_test_harness.server, .{ .buffer = buffer_recv[0..] }, 0); |
| 2392 | sqe_recv.flags |= linux.IOSQE_IO_LINK; | 2392 | sqe_recv.flags |= linux.IOSQE_IO_LINK; |
| 2393 | 2393 | ||
| 2394 | const ts = linux.kernel_timespec{ .tv_sec = 0, .tv_nsec = 1000000 }; | 2394 | const ts = linux.kernel_timespec{ .sec = 0, .nsec = 1000000 }; |
| 2395 | _ = try ring.link_timeout(0x22222222, &ts, 0); | 2395 | _ = try ring.link_timeout(0x22222222, &ts, 0); |
| 2396 | 2396 | ||
| 2397 | const nr_wait = try ring.submit(); | 2397 | const nr_wait = try ring.submit(); |
| ... | @@ -4248,7 +4248,7 @@ test "copy_cqes with wrapping sq.cqes buffer" { | ... | @@ -4248,7 +4248,7 @@ test "copy_cqes with wrapping sq.cqes buffer" { |
| 4248 | { | 4248 | { |
| 4249 | for (0..2) |_| { | 4249 | for (0..2) |_| { |
| 4250 | const sqe = try ring.get_sqe(); | 4250 | const sqe = try ring.get_sqe(); |
| 4251 | sqe.prep_timeout(&.{ .tv_sec = 0, .tv_nsec = 10000 }, 0, 0); | 4251 | sqe.prep_timeout(&.{ .sec = 0, .nsec = 10000 }, 0, 0); |
| 4252 | try testing.expect(try ring.submit() == 1); | 4252 | try testing.expect(try ring.submit() == 1); |
| 4253 | } | 4253 | } |
| 4254 | var cqe_count: u32 = 0; | 4254 | var cqe_count: u32 = 0; |
| ... | @@ -4265,7 +4265,7 @@ test "copy_cqes with wrapping sq.cqes buffer" { | ... | @@ -4265,7 +4265,7 @@ test "copy_cqes with wrapping sq.cqes buffer" { |
| 4265 | for (1..1024) |i| { | 4265 | for (1..1024) |i| { |
| 4266 | for (0..4) |_| { | 4266 | for (0..4) |_| { |
| 4267 | const sqe = try ring.get_sqe(); | 4267 | const sqe = try ring.get_sqe(); |
| 4268 | sqe.prep_timeout(&.{ .tv_sec = 0, .tv_nsec = 10000 }, 0, 0); | 4268 | sqe.prep_timeout(&.{ .sec = 0, .nsec = 10000 }, 0, 0); |
| 4269 | try testing.expect(try ring.submit() == 1); | 4269 | try testing.expect(try ring.submit() == 1); |
| 4270 | } | 4270 | } |
| 4271 | var cqe_count: u32 = 0; | 4271 | var cqe_count: u32 = 0; |
lib/std/os/linux/arm-eabi.zig+7-11| ... | @@ -167,13 +167,6 @@ pub const F = struct { | ... | @@ -167,13 +167,6 @@ pub const F = struct { |
| 167 | pub const GETOWNER_UIDS = 17; | 167 | pub const GETOWNER_UIDS = 17; |
| 168 | }; | 168 | }; |
| 169 | 169 | ||
| 170 | pub const LOCK = struct { | ||
| 171 | pub const SH = 1; | ||
| 172 | pub const EX = 2; | ||
| 173 | pub const UN = 8; | ||
| 174 | pub const NB = 4; | ||
| 175 | }; | ||
| 176 | |||
| 177 | pub const VDSO = struct { | 170 | pub const VDSO = struct { |
| 178 | pub const CGT_SYM = "__vdso_clock_gettime"; | 171 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 179 | pub const CGT_VER = "LINUX_2.6"; | 172 | pub const CGT_VER = "LINUX_2.6"; |
| ... | @@ -277,13 +270,13 @@ pub const Stat = extern struct { | ... | @@ -277,13 +270,13 @@ pub const Stat = extern struct { |
| 277 | }; | 270 | }; |
| 278 | 271 | ||
| 279 | pub const timeval = extern struct { | 272 | pub const timeval = extern struct { |
| 280 | tv_sec: i32, | 273 | sec: i32, |
| 281 | tv_usec: i32, | 274 | usec: i32, |
| 282 | }; | 275 | }; |
| 283 | 276 | ||
| 284 | pub const timezone = extern struct { | 277 | pub const timezone = extern struct { |
| 285 | tz_minuteswest: i32, | 278 | minuteswest: i32, |
| 286 | tz_dsttime: i32, | 279 | dsttime: i32, |
| 287 | }; | 280 | }; |
| 288 | 281 | ||
| 289 | pub const mcontext_t = extern struct { | 282 | pub const mcontext_t = extern struct { |
| ... | @@ -319,4 +312,7 @@ pub const ucontext_t = extern struct { | ... | @@ -319,4 +312,7 @@ pub const ucontext_t = extern struct { |
| 319 | regspace: [64]u64, | 312 | regspace: [64]u64, |
| 320 | }; | 313 | }; |
| 321 | 314 | ||
| 315 | /// TODO | ||
| 316 | pub const getcontext = {}; | ||
| 317 | |||
| 322 | pub const Elf_Symndx = u32; | 318 | pub const Elf_Symndx = u32; |
lib/std/os/linux/arm64.zig+7-11| ... | @@ -149,13 +149,6 @@ pub const F = struct { | ... | @@ -149,13 +149,6 @@ pub const F = struct { |
| 149 | pub const GETOWNER_UIDS = 17; | 149 | pub const GETOWNER_UIDS = 17; |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | pub const LOCK = struct { | ||
| 153 | pub const SH = 1; | ||
| 154 | pub const EX = 2; | ||
| 155 | pub const UN = 8; | ||
| 156 | pub const NB = 4; | ||
| 157 | }; | ||
| 158 | |||
| 159 | pub const VDSO = struct { | 152 | pub const VDSO = struct { |
| 160 | pub const CGT_SYM = "__kernel_clock_gettime"; | 153 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 161 | pub const CGT_VER = "LINUX_2.6.39"; | 154 | pub const CGT_VER = "LINUX_2.6.39"; |
| ... | @@ -236,13 +229,13 @@ pub const Stat = extern struct { | ... | @@ -236,13 +229,13 @@ pub const Stat = extern struct { |
| 236 | }; | 229 | }; |
| 237 | 230 | ||
| 238 | pub const timeval = extern struct { | 231 | pub const timeval = extern struct { |
| 239 | tv_sec: isize, | 232 | sec: isize, |
| 240 | tv_usec: isize, | 233 | usec: isize, |
| 241 | }; | 234 | }; |
| 242 | 235 | ||
| 243 | pub const timezone = extern struct { | 236 | pub const timezone = extern struct { |
| 244 | tz_minuteswest: i32, | 237 | minuteswest: i32, |
| 245 | tz_dsttime: i32, | 238 | dsttime: i32, |
| 246 | }; | 239 | }; |
| 247 | 240 | ||
| 248 | pub const mcontext_t = extern struct { | 241 | pub const mcontext_t = extern struct { |
| ... | @@ -264,4 +257,7 @@ pub const ucontext_t = extern struct { | ... | @@ -264,4 +257,7 @@ pub const ucontext_t = extern struct { |
| 264 | mcontext: mcontext_t, | 257 | mcontext: mcontext_t, |
| 265 | }; | 258 | }; |
| 266 | 259 | ||
| 260 | /// TODO | ||
| 261 | pub const getcontext = {}; | ||
| 262 | |||
| 267 | pub const Elf_Symndx = u32; | 263 | pub const Elf_Symndx = u32; |
lib/std/os/linux/mips.zig+10-11| ... | @@ -239,13 +239,6 @@ pub const F = struct { | ... | @@ -239,13 +239,6 @@ pub const F = struct { |
| 239 | pub const GETOWNER_UIDS = 17; | 239 | pub const GETOWNER_UIDS = 17; |
| 240 | }; | 240 | }; |
| 241 | 241 | ||
| 242 | pub const LOCK = struct { | ||
| 243 | pub const SH = 1; | ||
| 244 | pub const EX = 2; | ||
| 245 | pub const UN = 8; | ||
| 246 | pub const NB = 4; | ||
| 247 | }; | ||
| 248 | |||
| 249 | pub const MMAP2_UNIT = 4096; | 242 | pub const MMAP2_UNIT = 4096; |
| 250 | 243 | ||
| 251 | pub const VDSO = struct { | 244 | pub const VDSO = struct { |
| ... | @@ -326,13 +319,13 @@ pub const Stat = extern struct { | ... | @@ -326,13 +319,13 @@ pub const Stat = extern struct { |
| 326 | }; | 319 | }; |
| 327 | 320 | ||
| 328 | pub const timeval = extern struct { | 321 | pub const timeval = extern struct { |
| 329 | tv_sec: isize, | 322 | sec: isize, |
| 330 | tv_usec: isize, | 323 | usec: isize, |
| 331 | }; | 324 | }; |
| 332 | 325 | ||
| 333 | pub const timezone = extern struct { | 326 | pub const timezone = extern struct { |
| 334 | tz_minuteswest: i32, | 327 | minuteswest: i32, |
| 335 | tz_dsttime: i32, | 328 | dsttime: i32, |
| 336 | }; | 329 | }; |
| 337 | 330 | ||
| 338 | pub const Elf_Symndx = u32; | 331 | pub const Elf_Symndx = u32; |
| ... | @@ -396,3 +389,9 @@ pub const rlimit_resource = enum(c_int) { | ... | @@ -396,3 +389,9 @@ pub const rlimit_resource = enum(c_int) { |
| 396 | 389 | ||
| 397 | _, | 390 | _, |
| 398 | }; | 391 | }; |
| 392 | |||
| 393 | /// TODO | ||
| 394 | pub const ucontext_t = void; | ||
| 395 | |||
| 396 | /// TODO | ||
| 397 | pub const getcontext = {}; |
lib/std/os/linux/mips64.zig+10-11| ... | @@ -224,13 +224,6 @@ pub const F = struct { | ... | @@ -224,13 +224,6 @@ pub const F = struct { |
| 224 | pub const GETOWNER_UIDS = 17; | 224 | pub const GETOWNER_UIDS = 17; |
| 225 | }; | 225 | }; |
| 226 | 226 | ||
| 227 | pub const LOCK = struct { | ||
| 228 | pub const SH = 1; | ||
| 229 | pub const EX = 2; | ||
| 230 | pub const UN = 8; | ||
| 231 | pub const NB = 4; | ||
| 232 | }; | ||
| 233 | |||
| 234 | pub const MMAP2_UNIT = 4096; | 227 | pub const MMAP2_UNIT = 4096; |
| 235 | 228 | ||
| 236 | pub const VDSO = struct { | 229 | pub const VDSO = struct { |
| ... | @@ -311,13 +304,13 @@ pub const Stat = extern struct { | ... | @@ -311,13 +304,13 @@ pub const Stat = extern struct { |
| 311 | }; | 304 | }; |
| 312 | 305 | ||
| 313 | pub const timeval = extern struct { | 306 | pub const timeval = extern struct { |
| 314 | tv_sec: isize, | 307 | sec: isize, |
| 315 | tv_usec: isize, | 308 | usec: isize, |
| 316 | }; | 309 | }; |
| 317 | 310 | ||
| 318 | pub const timezone = extern struct { | 311 | pub const timezone = extern struct { |
| 319 | tz_minuteswest: i32, | 312 | minuteswest: i32, |
| 320 | tz_dsttime: i32, | 313 | dsttime: i32, |
| 321 | }; | 314 | }; |
| 322 | 315 | ||
| 323 | pub const Elf_Symndx = u32; | 316 | pub const Elf_Symndx = u32; |
| ... | @@ -381,3 +374,9 @@ pub const rlimit_resource = enum(c_int) { | ... | @@ -381,3 +374,9 @@ pub const rlimit_resource = enum(c_int) { |
| 381 | 374 | ||
| 382 | _, | 375 | _, |
| 383 | }; | 376 | }; |
| 377 | |||
| 378 | /// TODO | ||
| 379 | pub const ucontext_t = void; | ||
| 380 | |||
| 381 | /// TODO | ||
| 382 | pub const getcontext = {}; |
lib/std/os/linux/powerpc.zig+7-11| ... | @@ -168,13 +168,6 @@ pub const F = struct { | ... | @@ -168,13 +168,6 @@ pub const F = struct { |
| 168 | pub const UNLCK = 2; | 168 | pub const UNLCK = 2; |
| 169 | }; | 169 | }; |
| 170 | 170 | ||
| 171 | pub const LOCK = struct { | ||
| 172 | pub const SH = 1; | ||
| 173 | pub const EX = 2; | ||
| 174 | pub const UN = 8; | ||
| 175 | pub const NB = 4; | ||
| 176 | }; | ||
| 177 | |||
| 178 | pub const VDSO = struct { | 171 | pub const VDSO = struct { |
| 179 | pub const CGT_SYM = "__kernel_clock_gettime"; | 172 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 180 | pub const CGT_VER = "LINUX_2.6.15"; | 173 | pub const CGT_VER = "LINUX_2.6.15"; |
| ... | @@ -249,13 +242,13 @@ pub const Stat = extern struct { | ... | @@ -249,13 +242,13 @@ pub const Stat = extern struct { |
| 249 | }; | 242 | }; |
| 250 | 243 | ||
| 251 | pub const timeval = extern struct { | 244 | pub const timeval = extern struct { |
| 252 | tv_sec: time_t, | 245 | sec: time_t, |
| 253 | tv_usec: isize, | 246 | usec: isize, |
| 254 | }; | 247 | }; |
| 255 | 248 | ||
| 256 | pub const timezone = extern struct { | 249 | pub const timezone = extern struct { |
| 257 | tz_minuteswest: i32, | 250 | minuteswest: i32, |
| 258 | tz_dsttime: i32, | 251 | dsttime: i32, |
| 259 | }; | 252 | }; |
| 260 | 253 | ||
| 261 | pub const greg_t = u32; | 254 | pub const greg_t = u32; |
| ... | @@ -290,3 +283,6 @@ pub const ucontext_t = extern struct { | ... | @@ -290,3 +283,6 @@ pub const ucontext_t = extern struct { |
| 290 | pub const Elf_Symndx = u32; | 283 | pub const Elf_Symndx = u32; |
| 291 | 284 | ||
| 292 | pub const MMAP2_UNIT = 4096; | 285 | pub const MMAP2_UNIT = 4096; |
| 286 | |||
| 287 | /// TODO | ||
| 288 | pub const getcontext = {}; |
lib/std/os/linux/powerpc64.zig+7-11| ... | @@ -168,13 +168,6 @@ pub const F = struct { | ... | @@ -168,13 +168,6 @@ pub const F = struct { |
| 168 | pub const GETOWNER_UIDS = 17; | 168 | pub const GETOWNER_UIDS = 17; |
| 169 | }; | 169 | }; |
| 170 | 170 | ||
| 171 | pub const LOCK = struct { | ||
| 172 | pub const SH = 1; | ||
| 173 | pub const EX = 2; | ||
| 174 | pub const UN = 8; | ||
| 175 | pub const NB = 4; | ||
| 176 | }; | ||
| 177 | |||
| 178 | pub const VDSO = struct { | 171 | pub const VDSO = struct { |
| 179 | pub const CGT_SYM = "__kernel_clock_gettime"; | 172 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 180 | pub const CGT_VER = "LINUX_2.6.15"; | 173 | pub const CGT_VER = "LINUX_2.6.15"; |
| ... | @@ -249,13 +242,13 @@ pub const Stat = extern struct { | ... | @@ -249,13 +242,13 @@ pub const Stat = extern struct { |
| 249 | }; | 242 | }; |
| 250 | 243 | ||
| 251 | pub const timeval = extern struct { | 244 | pub const timeval = extern struct { |
| 252 | tv_sec: isize, | 245 | sec: isize, |
| 253 | tv_usec: isize, | 246 | usec: isize, |
| 254 | }; | 247 | }; |
| 255 | 248 | ||
| 256 | pub const timezone = extern struct { | 249 | pub const timezone = extern struct { |
| 257 | tz_minuteswest: i32, | 250 | minuteswest: i32, |
| 258 | tz_dsttime: i32, | 251 | dsttime: i32, |
| 259 | }; | 252 | }; |
| 260 | 253 | ||
| 261 | pub const greg_t = u64; | 254 | pub const greg_t = u64; |
| ... | @@ -298,3 +291,6 @@ pub const ucontext_t = extern struct { | ... | @@ -298,3 +291,6 @@ pub const ucontext_t = extern struct { |
| 298 | }; | 291 | }; |
| 299 | 292 | ||
| 300 | pub const Elf_Symndx = u32; | 293 | pub const Elf_Symndx = u32; |
| 294 | |||
| 295 | /// TODO | ||
| 296 | pub const getcontext = {}; |
lib/std/os/linux/riscv64.zig+8-9| ... | @@ -134,13 +134,6 @@ pub const F = struct { | ... | @@ -134,13 +134,6 @@ pub const F = struct { |
| 134 | pub const GETOWNER_UIDS = 17; | 134 | pub const GETOWNER_UIDS = 17; |
| 135 | }; | 135 | }; |
| 136 | 136 | ||
| 137 | pub const LOCK = struct { | ||
| 138 | pub const SH = 1; | ||
| 139 | pub const EX = 2; | ||
| 140 | pub const UN = 8; | ||
| 141 | pub const NB = 4; | ||
| 142 | }; | ||
| 143 | |||
| 144 | pub const blksize_t = i32; | 137 | pub const blksize_t = i32; |
| 145 | pub const nlink_t = u32; | 138 | pub const nlink_t = u32; |
| 146 | pub const time_t = isize; | 139 | pub const time_t = isize; |
| ... | @@ -151,8 +144,8 @@ pub const dev_t = usize; | ... | @@ -151,8 +144,8 @@ pub const dev_t = usize; |
| 151 | pub const blkcnt_t = isize; | 144 | pub const blkcnt_t = isize; |
| 152 | 145 | ||
| 153 | pub const timeval = extern struct { | 146 | pub const timeval = extern struct { |
| 154 | tv_sec: time_t, | 147 | sec: time_t, |
| 155 | tv_usec: i64, | 148 | usec: i64, |
| 156 | }; | 149 | }; |
| 157 | 150 | ||
| 158 | pub const Flock = extern struct { | 151 | pub const Flock = extern struct { |
| ... | @@ -223,3 +216,9 @@ pub const Stat = extern struct { | ... | @@ -223,3 +216,9 @@ pub const Stat = extern struct { |
| 223 | pub const Elf_Symndx = u32; | 216 | pub const Elf_Symndx = u32; |
| 224 | 217 | ||
| 225 | pub const VDSO = struct {}; | 218 | pub const VDSO = struct {}; |
| 219 | |||
| 220 | /// TODO | ||
| 221 | pub const ucontext_t = void; | ||
| 222 | |||
| 223 | /// TODO | ||
| 224 | pub const getcontext = {}; |
lib/std/os/linux/sparc64.zig+7-11| ... | @@ -218,13 +218,6 @@ pub const F = struct { | ... | @@ -218,13 +218,6 @@ pub const F = struct { |
| 218 | pub const GETOWNER_UIDS = 17; | 218 | pub const GETOWNER_UIDS = 17; |
| 219 | }; | 219 | }; |
| 220 | 220 | ||
| 221 | pub const LOCK = struct { | ||
| 222 | pub const SH = 1; | ||
| 223 | pub const EX = 2; | ||
| 224 | pub const NB = 4; | ||
| 225 | pub const UN = 8; | ||
| 226 | }; | ||
| 227 | |||
| 228 | pub const VDSO = struct { | 221 | pub const VDSO = struct { |
| 229 | pub const CGT_SYM = "__vdso_clock_gettime"; | 222 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 230 | pub const CGT_VER = "LINUX_2.6"; | 223 | pub const CGT_VER = "LINUX_2.6"; |
| ... | @@ -301,13 +294,13 @@ pub const Stat = extern struct { | ... | @@ -301,13 +294,13 @@ pub const Stat = extern struct { |
| 301 | }; | 294 | }; |
| 302 | 295 | ||
| 303 | pub const timeval = extern struct { | 296 | pub const timeval = extern struct { |
| 304 | tv_sec: isize, | 297 | sec: isize, |
| 305 | tv_usec: i32, | 298 | usec: i32, |
| 306 | }; | 299 | }; |
| 307 | 300 | ||
| 308 | pub const timezone = extern struct { | 301 | pub const timezone = extern struct { |
| 309 | tz_minuteswest: i32, | 302 | minuteswest: i32, |
| 310 | tz_dsttime: i32, | 303 | dsttime: i32, |
| 311 | }; | 304 | }; |
| 312 | 305 | ||
| 313 | // TODO I'm not sure if the code below is correct, need someone with more | 306 | // TODO I'm not sure if the code below is correct, need someone with more |
| ... | @@ -412,6 +405,9 @@ pub const ucontext_t = extern struct { | ... | @@ -412,6 +405,9 @@ pub const ucontext_t = extern struct { |
| 412 | sigset: sigset_t, | 405 | sigset: sigset_t, |
| 413 | }; | 406 | }; |
| 414 | 407 | ||
| 408 | /// TODO | ||
| 409 | pub const getcontext = {}; | ||
| 410 | |||
| 415 | pub const rlimit_resource = enum(c_int) { | 411 | pub const rlimit_resource = enum(c_int) { |
| 416 | /// Per-process CPU limit, in seconds. | 412 | /// Per-process CPU limit, in seconds. |
| 417 | CPU, | 413 | CPU, |
lib/std/os/linux/test.zig+2-2| ... | @@ -41,8 +41,8 @@ test "timer" { | ... | @@ -41,8 +41,8 @@ test "timer" { |
| 41 | try expect(linux.E.init(timer_fd) == .SUCCESS); | 41 | try expect(linux.E.init(timer_fd) == .SUCCESS); |
| 42 | 42 | ||
| 43 | const time_interval = linux.timespec{ | 43 | const time_interval = linux.timespec{ |
| 44 | .tv_sec = 0, | 44 | .sec = 0, |
| 45 | .tv_nsec = 2000000, | 45 | .nsec = 2000000, |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | const new_time = linux.itimerspec{ | 48 | const new_time = linux.itimerspec{ |
lib/std/os/linux/x86.zig+4-11| ... | @@ -181,13 +181,6 @@ pub const F = struct { | ... | @@ -181,13 +181,6 @@ pub const F = struct { |
| 181 | pub const UNLCK = 2; | 181 | pub const UNLCK = 2; |
| 182 | }; | 182 | }; |
| 183 | 183 | ||
| 184 | pub const LOCK = struct { | ||
| 185 | pub const SH = 1; | ||
| 186 | pub const EX = 2; | ||
| 187 | pub const NB = 4; | ||
| 188 | pub const UN = 8; | ||
| 189 | }; | ||
| 190 | |||
| 191 | pub const MMAP2_UNIT = 4096; | 184 | pub const MMAP2_UNIT = 4096; |
| 192 | 185 | ||
| 193 | pub const VDSO = struct { | 186 | pub const VDSO = struct { |
| ... | @@ -267,13 +260,13 @@ pub const Stat = extern struct { | ... | @@ -267,13 +260,13 @@ pub const Stat = extern struct { |
| 267 | }; | 260 | }; |
| 268 | 261 | ||
| 269 | pub const timeval = extern struct { | 262 | pub const timeval = extern struct { |
| 270 | tv_sec: i32, | 263 | sec: i32, |
| 271 | tv_usec: i32, | 264 | usec: i32, |
| 272 | }; | 265 | }; |
| 273 | 266 | ||
| 274 | pub const timezone = extern struct { | 267 | pub const timezone = extern struct { |
| 275 | tz_minuteswest: i32, | 268 | minuteswest: i32, |
| 276 | tz_dsttime: i32, | 269 | dsttime: i32, |
| 277 | }; | 270 | }; |
| 278 | 271 | ||
| 279 | pub const mcontext_t = extern struct { | 272 | pub const mcontext_t = extern struct { |
lib/std/os/linux/x86_64.zig+4-11| ... | @@ -195,13 +195,6 @@ pub const REG = struct { | ... | @@ -195,13 +195,6 @@ pub const REG = struct { |
| 195 | pub const CR2 = 22; | 195 | pub const CR2 = 22; |
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | pub const LOCK = struct { | ||
| 199 | pub const SH = 1; | ||
| 200 | pub const EX = 2; | ||
| 201 | pub const NB = 4; | ||
| 202 | pub const UN = 8; | ||
| 203 | }; | ||
| 204 | |||
| 205 | pub const Flock = extern struct { | 198 | pub const Flock = extern struct { |
| 206 | type: i16, | 199 | type: i16, |
| 207 | whence: i16, | 200 | whence: i16, |
| ... | @@ -272,13 +265,13 @@ pub const Stat = extern struct { | ... | @@ -272,13 +265,13 @@ pub const Stat = extern struct { |
| 272 | }; | 265 | }; |
| 273 | 266 | ||
| 274 | pub const timeval = extern struct { | 267 | pub const timeval = extern struct { |
| 275 | tv_sec: isize, | 268 | sec: isize, |
| 276 | tv_usec: isize, | 269 | usec: isize, |
| 277 | }; | 270 | }; |
| 278 | 271 | ||
| 279 | pub const timezone = extern struct { | 272 | pub const timezone = extern struct { |
| 280 | tz_minuteswest: i32, | 273 | minuteswest: i32, |
| 281 | tz_dsttime: i32, | 274 | dsttime: i32, |
| 282 | }; | 275 | }; |
| 283 | 276 | ||
| 284 | pub const Elf_Symndx = u32; | 277 | pub const Elf_Symndx = u32; |
lib/std/os/windows/ws2_32.zig+37-33| ... | @@ -676,23 +676,27 @@ pub const MSG = struct { | ... | @@ -676,23 +676,27 @@ pub const MSG = struct { |
| 676 | pub const MAXIOVLEN = 16; | 676 | pub const MAXIOVLEN = 16; |
| 677 | }; | 677 | }; |
| 678 | 678 | ||
| 679 | pub const AI = struct { | 679 | pub const AI = packed struct(u32) { |
| 680 | pub const PASSIVE = 1; | 680 | PASSIVE: bool = false, |
| 681 | pub const CANONNAME = 2; | 681 | CANONNAME: bool = false, |
| 682 | pub const NUMERICHOST = 4; | 682 | NUMERICHOST: bool = false, |
| 683 | pub const NUMERICSERV = 8; | 683 | NUMERICSERV: bool = false, |
| 684 | pub const DNS_ONLY = 16; | 684 | DNS_ONLY: bool = false, |
| 685 | pub const ALL = 256; | 685 | _5: u3 = 0, |
| 686 | pub const ADDRCONFIG = 1024; | 686 | ALL: bool = false, |
| 687 | pub const V4MAPPED = 2048; | 687 | _9: u1 = 0, |
| 688 | pub const NON_AUTHORITATIVE = 16384; | 688 | ADDRCONFIG: bool = false, |
| 689 | pub const SECURE = 32768; | 689 | V4MAPPED: bool = false, |
| 690 | pub const RETURN_PREFERRED_NAMES = 65536; | 690 | _12: u2 = 0, |
| 691 | pub const FQDN = 131072; | 691 | NON_AUTHORITATIVE: bool = false, |
| 692 | pub const FILESERVER = 262144; | 692 | SECURE: bool = false, |
| 693 | pub const DISABLE_IDN_ENCODING = 524288; | 693 | RETURN_PREFERRED_NAMES: bool = false, |
| 694 | pub const EXTENDED = 2147483648; | 694 | FQDN: bool = false, |
| 695 | pub const RESOLUTION_HANDLE = 1073741824; | 695 | FILESERVER: bool = false, |
| 696 | DISABLE_IDN_ENCODING: bool = false, | ||
| 697 | _20: u10 = 0, | ||
| 698 | RESOLUTION_HANDLE: bool = false, | ||
| 699 | EXTENDED: bool = false, | ||
| 696 | }; | 700 | }; |
| 697 | 701 | ||
| 698 | pub const FIONBIO = -2147195266; | 702 | pub const FIONBIO = -2147195266; |
| ... | @@ -1068,8 +1072,8 @@ pub const sockproto = extern struct { | ... | @@ -1068,8 +1072,8 @@ pub const sockproto = extern struct { |
| 1068 | }; | 1072 | }; |
| 1069 | 1073 | ||
| 1070 | pub const linger = extern struct { | 1074 | pub const linger = extern struct { |
| 1071 | l_onoff: u16, | 1075 | onoff: u16, |
| 1072 | l_linger: u16, | 1076 | linger: u16, |
| 1073 | }; | 1077 | }; |
| 1074 | 1078 | ||
| 1075 | pub const WSANETWORKEVENTS = extern struct { | 1079 | pub const WSANETWORKEVENTS = extern struct { |
| ... | @@ -1080,7 +1084,7 @@ pub const WSANETWORKEVENTS = extern struct { | ... | @@ -1080,7 +1084,7 @@ pub const WSANETWORKEVENTS = extern struct { |
| 1080 | pub const addrinfo = addrinfoa; | 1084 | pub const addrinfo = addrinfoa; |
| 1081 | 1085 | ||
| 1082 | pub const addrinfoa = extern struct { | 1086 | pub const addrinfoa = extern struct { |
| 1083 | flags: i32, | 1087 | flags: AI, |
| 1084 | family: i32, | 1088 | family: i32, |
| 1085 | socktype: i32, | 1089 | socktype: i32, |
| 1086 | protocol: i32, | 1090 | protocol: i32, |
| ... | @@ -1091,17 +1095,17 @@ pub const addrinfoa = extern struct { | ... | @@ -1091,17 +1095,17 @@ pub const addrinfoa = extern struct { |
| 1091 | }; | 1095 | }; |
| 1092 | 1096 | ||
| 1093 | pub const addrinfoexA = extern struct { | 1097 | pub const addrinfoexA = extern struct { |
| 1094 | ai_flags: i32, | 1098 | flags: AI, |
| 1095 | ai_family: i32, | 1099 | family: i32, |
| 1096 | ai_socktype: i32, | 1100 | socktype: i32, |
| 1097 | ai_protocol: i32, | 1101 | protocol: i32, |
| 1098 | ai_addrlen: usize, | 1102 | addrlen: usize, |
| 1099 | ai_canonname: [*:0]u8, | 1103 | canonname: [*:0]u8, |
| 1100 | ai_addr: *sockaddr, | 1104 | addr: *sockaddr, |
| 1101 | ai_blob: *anyopaque, | 1105 | blob: *anyopaque, |
| 1102 | ai_bloblen: usize, | 1106 | bloblen: usize, |
| 1103 | ai_provider: *GUID, | 1107 | provider: *GUID, |
| 1104 | ai_next: *addrinfoexA, | 1108 | next: *addrinfoexA, |
| 1105 | }; | 1109 | }; |
| 1106 | 1110 | ||
| 1107 | pub const sockaddr = extern struct { | 1111 | pub const sockaddr = extern struct { |
| ... | @@ -1264,8 +1268,8 @@ pub const hostent = extern struct { | ... | @@ -1264,8 +1268,8 @@ pub const hostent = extern struct { |
| 1264 | }; | 1268 | }; |
| 1265 | 1269 | ||
| 1266 | pub const timeval = extern struct { | 1270 | pub const timeval = extern struct { |
| 1267 | tv_sec: LONG, | 1271 | sec: LONG, |
| 1268 | tv_usec: LONG, | 1272 | usec: LONG, |
| 1269 | }; | 1273 | }; |
| 1270 | 1274 | ||
| 1271 | // https://docs.microsoft.com/en-au/windows/win32/winsock/windows-sockets-error-codes-2 | 1275 | // https://docs.microsoft.com/en-au/windows/win32/winsock/windows-sockets-error-codes-2 |
lib/std/posix.zig+79-68| ... | @@ -50,6 +50,7 @@ else switch (native_os) { | ... | @@ -50,6 +50,7 @@ else switch (native_os) { |
| 50 | 50 | ||
| 51 | pub const AF = system.AF; | 51 | pub const AF = system.AF; |
| 52 | pub const AF_SUN = system.AF_SUN; | 52 | pub const AF_SUN = system.AF_SUN; |
| 53 | pub const AI = system.AI; | ||
| 53 | pub const ARCH = system.ARCH; | 54 | pub const ARCH = system.ARCH; |
| 54 | pub const AT = system.AT; | 55 | pub const AT = system.AT; |
| 55 | pub const AT_SUN = system.AT_SUN; | 56 | pub const AT_SUN = system.AT_SUN; |
| ... | @@ -69,13 +70,12 @@ pub const IOV_MAX = system.IOV_MAX; | ... | @@ -69,13 +70,12 @@ pub const IOV_MAX = system.IOV_MAX; |
| 69 | pub const IPPROTO = system.IPPROTO; | 70 | pub const IPPROTO = system.IPPROTO; |
| 70 | pub const KERN = system.KERN; | 71 | pub const KERN = system.KERN; |
| 71 | pub const Kevent = system.Kevent; | 72 | pub const Kevent = system.Kevent; |
| 72 | pub const LOCK = system.LOCK; | ||
| 73 | pub const MADV = system.MADV; | 73 | pub const MADV = system.MADV; |
| 74 | pub const MAP = system.MAP; | 74 | pub const MAP = system.MAP; |
| 75 | pub const MSF = system.MSF; | ||
| 76 | pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN; | 75 | pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN; |
| 77 | pub const MFD = system.MFD; | 76 | pub const MFD = system.MFD; |
| 78 | pub const MMAP2_UNIT = system.MMAP2_UNIT; | 77 | pub const MMAP2_UNIT = system.MMAP2_UNIT; |
| 78 | pub const MSF = system.MSF; | ||
| 79 | pub const MSG = system.MSG; | 79 | pub const MSG = system.MSG; |
| 80 | pub const NAME_MAX = system.NAME_MAX; | 80 | pub const NAME_MAX = system.NAME_MAX; |
| 81 | pub const O = system.O; | 81 | pub const O = system.O; |
| ... | @@ -90,7 +90,6 @@ pub const RR = system.RR; | ... | @@ -90,7 +90,6 @@ pub const RR = system.RR; |
| 90 | pub const S = system.S; | 90 | pub const S = system.S; |
| 91 | pub const SA = system.SA; | 91 | pub const SA = system.SA; |
| 92 | pub const SC = system.SC; | 92 | pub const SC = system.SC; |
| 93 | pub const _SC = system._SC; | ||
| 94 | pub const SEEK = system.SEEK; | 93 | pub const SEEK = system.SEEK; |
| 95 | pub const SHUT = system.SHUT; | 94 | pub const SHUT = system.SHUT; |
| 96 | pub const SIG = system.SIG; | 95 | pub const SIG = system.SIG; |
| ... | @@ -105,20 +104,22 @@ pub const SYS = system.SYS; | ... | @@ -105,20 +104,22 @@ pub const SYS = system.SYS; |
| 105 | pub const Sigaction = system.Sigaction; | 104 | pub const Sigaction = system.Sigaction; |
| 106 | pub const Stat = system.Stat; | 105 | pub const Stat = system.Stat; |
| 107 | pub const T = system.T; | 106 | pub const T = system.T; |
| 108 | pub const TCSA = system.TCSA; | ||
| 109 | pub const TCP = system.TCP; | 107 | pub const TCP = system.TCP; |
| 110 | pub const VDSO = system.VDSO; | 108 | pub const VDSO = system.VDSO; |
| 111 | pub const W = system.W; | 109 | pub const W = system.W; |
| 110 | pub const _SC = system._SC; | ||
| 112 | pub const addrinfo = system.addrinfo; | 111 | pub const addrinfo = system.addrinfo; |
| 113 | pub const blkcnt_t = system.blkcnt_t; | 112 | pub const blkcnt_t = system.blkcnt_t; |
| 114 | pub const blksize_t = system.blksize_t; | 113 | pub const blksize_t = system.blksize_t; |
| 115 | pub const clock_t = system.clock_t; | 114 | pub const clock_t = system.clock_t; |
| 115 | pub const clockid_t = system.clockid_t; | ||
| 116 | pub const cpu_set_t = system.cpu_set_t; | 116 | pub const cpu_set_t = system.cpu_set_t; |
| 117 | pub const dev_t = system.dev_t; | 117 | pub const dev_t = system.dev_t; |
| 118 | pub const dl_phdr_info = system.dl_phdr_info; | 118 | pub const dl_phdr_info = system.dl_phdr_info; |
| 119 | pub const empty_sigset = system.empty_sigset; | 119 | pub const empty_sigset = system.empty_sigset; |
| 120 | pub const filled_sigset = system.filled_sigset; | ||
| 121 | pub const fd_t = system.fd_t; | 120 | pub const fd_t = system.fd_t; |
| 121 | pub const file_obj = system.file_obj; | ||
| 122 | pub const filled_sigset = system.filled_sigset; | ||
| 122 | pub const gid_t = system.gid_t; | 123 | pub const gid_t = system.gid_t; |
| 123 | pub const ifreq = system.ifreq; | 124 | pub const ifreq = system.ifreq; |
| 124 | pub const ino_t = system.ino_t; | 125 | pub const ino_t = system.ino_t; |
| ... | @@ -131,10 +132,9 @@ pub const nlink_t = system.nlink_t; | ... | @@ -131,10 +132,9 @@ pub const nlink_t = system.nlink_t; |
| 131 | pub const off_t = system.off_t; | 132 | pub const off_t = system.off_t; |
| 132 | pub const pid_t = system.pid_t; | 133 | pub const pid_t = system.pid_t; |
| 133 | pub const pollfd = system.pollfd; | 134 | pub const pollfd = system.pollfd; |
| 134 | pub const port_t = system.port_t; | ||
| 135 | pub const port_event = system.port_event; | 135 | pub const port_event = system.port_event; |
| 136 | pub const port_notify = system.port_notify; | 136 | pub const port_notify = system.port_notify; |
| 137 | pub const file_obj = system.file_obj; | 137 | pub const port_t = system.port_t; |
| 138 | pub const rlim_t = system.rlim_t; | 138 | pub const rlim_t = system.rlim_t; |
| 139 | pub const rlimit = system.rlimit; | 139 | pub const rlimit = system.rlimit; |
| 140 | pub const rlimit_resource = system.rlimit_resource; | 140 | pub const rlimit_resource = system.rlimit_resource; |
| ... | @@ -154,7 +154,6 @@ pub const ucontext_t = system.ucontext_t; | ... | @@ -154,7 +154,6 @@ pub const ucontext_t = system.ucontext_t; |
| 154 | pub const uid_t = system.uid_t; | 154 | pub const uid_t = system.uid_t; |
| 155 | pub const user_desc = system.user_desc; | 155 | pub const user_desc = system.user_desc; |
| 156 | pub const utsname = system.utsname; | 156 | pub const utsname = system.utsname; |
| 157 | pub const winsize = system.winsize; | ||
| 158 | 157 | ||
| 159 | pub const termios = system.termios; | 158 | pub const termios = system.termios; |
| 160 | pub const CSIZE = system.CSIZE; | 159 | pub const CSIZE = system.CSIZE; |
| ... | @@ -188,6 +187,27 @@ pub const ACCMODE = enum(u2) { | ... | @@ -188,6 +187,27 @@ pub const ACCMODE = enum(u2) { |
| 188 | RDWR = 2, | 187 | RDWR = 2, |
| 189 | }; | 188 | }; |
| 190 | 189 | ||
| 190 | pub const TCSA = enum(c_uint) { | ||
| 191 | NOW, | ||
| 192 | DRAIN, | ||
| 193 | FLUSH, | ||
| 194 | _, | ||
| 195 | }; | ||
| 196 | |||
| 197 | pub const winsize = extern struct { | ||
| 198 | row: u16, | ||
| 199 | col: u16, | ||
| 200 | xpixel: u16, | ||
| 201 | ypixel: u16, | ||
| 202 | }; | ||
| 203 | |||
| 204 | pub const LOCK = struct { | ||
| 205 | pub const SH = 1; | ||
| 206 | pub const EX = 2; | ||
| 207 | pub const NB = 4; | ||
| 208 | pub const UN = 8; | ||
| 209 | }; | ||
| 210 | |||
| 191 | pub const LOG = struct { | 211 | pub const LOG = struct { |
| 192 | /// system is unusable | 212 | /// system is unusable |
| 193 | pub const EMERG = 0; | 213 | pub const EMERG = 0; |
| ... | @@ -226,6 +246,8 @@ pub fn errno(rc: anytype) E { | ... | @@ -226,6 +246,8 @@ pub fn errno(rc: anytype) E { |
| 226 | 246 | ||
| 227 | /// Closes the file descriptor. | 247 | /// Closes the file descriptor. |
| 228 | /// | 248 | /// |
| 249 | /// Asserts the file descriptor is open. | ||
| 250 | /// | ||
| 229 | /// This function is not capable of returning any indication of failure. An | 251 | /// This function is not capable of returning any indication of failure. An |
| 230 | /// application which wants to ensure writes have succeeded before closing must | 252 | /// application which wants to ensure writes have succeeded before closing must |
| 231 | /// call `fsync` before `close`. | 253 | /// call `fsync` before `close`. |
| ... | @@ -239,13 +261,6 @@ pub fn close(fd: fd_t) void { | ... | @@ -239,13 +261,6 @@ pub fn close(fd: fd_t) void { |
| 239 | _ = std.os.wasi.fd_close(fd); | 261 | _ = std.os.wasi.fd_close(fd); |
| 240 | return; | 262 | return; |
| 241 | } | 263 | } |
| 242 | if (builtin.target.isDarwin()) { | ||
| 243 | // This avoids the EINTR problem. | ||
| 244 | switch (errno(std.c.@"close$NOCANCEL"(fd))) { | ||
| 245 | .BADF => unreachable, // Always a race condition. | ||
| 246 | else => return, | ||
| 247 | } | ||
| 248 | } | ||
| 249 | switch (errno(system.close(fd))) { | 264 | switch (errno(system.close(fd))) { |
| 250 | .BADF => unreachable, // Always a race condition. | 265 | .BADF => unreachable, // Always a race condition. |
| 251 | .INTR => return, // This is still a success. See https://github.com/ziglang/zig/issues/2425 | 266 | .INTR => return, // This is still a success. See https://github.com/ziglang/zig/issues/2425 |
| ... | @@ -571,7 +586,15 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { | ... | @@ -571,7 +586,15 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { |
| 571 | if (native_os == .windows) { | 586 | if (native_os == .windows) { |
| 572 | return windows.RtlGenRandom(buffer); | 587 | return windows.RtlGenRandom(buffer); |
| 573 | } | 588 | } |
| 574 | if (native_os == .linux or native_os == .freebsd) { | 589 | if (builtin.link_libc and @TypeOf(system.arc4random_buf) != void) { |
| 590 | system.arc4random_buf(buffer.ptr, buffer.len); | ||
| 591 | return; | ||
| 592 | } | ||
| 593 | if (native_os == .wasi) switch (wasi.random_get(buffer.ptr, buffer.len)) { | ||
| 594 | .SUCCESS => return, | ||
| 595 | else => |err| return unexpectedErrno(err), | ||
| 596 | }; | ||
| 597 | if (@TypeOf(system.getrandom) != void) { | ||
| 575 | var buf = buffer; | 598 | var buf = buffer; |
| 576 | const use_c = native_os != .linux or | 599 | const use_c = native_os != .linux or |
| 577 | std.c.versionCheck(std.SemanticVersion{ .major = 2, .minor = 25, .patch = 0 }); | 600 | std.c.versionCheck(std.SemanticVersion{ .major = 2, .minor = 25, .patch = 0 }); |
| ... | @@ -603,17 +626,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { | ... | @@ -603,17 +626,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { |
| 603 | else => return unexpectedErrno(err), | 626 | else => return unexpectedErrno(err), |
| 604 | } | 627 | } |
| 605 | } | 628 | } |
| 606 | switch (native_os) { | 629 | return getRandomBytesDevURandom(buffer); |
| 607 | .netbsd, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => { | ||
| 608 | system.arc4random_buf(buffer.ptr, buffer.len); | ||
| 609 | return; | ||
| 610 | }, | ||
| 611 | .wasi => switch (wasi.random_get(buffer.ptr, buffer.len)) { | ||
| 612 | .SUCCESS => return, | ||
| 613 | else => |err| return unexpectedErrno(err), | ||
| 614 | }, | ||
| 615 | else => return getRandomBytesDevURandom(buffer), | ||
| 616 | } | ||
| 617 | } | 630 | } |
| 618 | 631 | ||
| 619 | fn getRandomBytesDevURandom(buf: []u8) !void { | 632 | fn getRandomBytesDevURandom(buf: []u8) !void { |
| ... | @@ -3430,7 +3443,7 @@ pub fn isatty(handle: fd_t) bool { | ... | @@ -3430,7 +3443,7 @@ pub fn isatty(handle: fd_t) bool { |
| 3430 | } | 3443 | } |
| 3431 | if (native_os == .linux) { | 3444 | if (native_os == .linux) { |
| 3432 | while (true) { | 3445 | while (true) { |
| 3433 | var wsz: linux.winsize = undefined; | 3446 | var wsz: winsize = undefined; |
| 3434 | const fd: usize = @bitCast(@as(isize, handle)); | 3447 | const fd: usize = @bitCast(@as(isize, handle)); |
| 3435 | const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @intFromPtr(&wsz)); | 3448 | const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @intFromPtr(&wsz)); |
| 3436 | switch (linux.E.init(rc)) { | 3449 | switch (linux.E.init(rc)) { |
| ... | @@ -4929,8 +4942,7 @@ pub fn pipe() PipeError![2]fd_t { | ... | @@ -4929,8 +4942,7 @@ pub fn pipe() PipeError![2]fd_t { |
| 4929 | } | 4942 | } |
| 4930 | 4943 | ||
| 4931 | pub fn pipe2(flags: O) PipeError![2]fd_t { | 4944 | pub fn pipe2(flags: O) PipeError![2]fd_t { |
| 4932 | // https://github.com/ziglang/zig/issues/19352 | 4945 | if (@TypeOf(system.pipe2) != void) { |
| 4933 | if (@hasDecl(system, "pipe2")) { | ||
| 4934 | var fds: [2]fd_t = undefined; | 4946 | var fds: [2]fd_t = undefined; |
| 4935 | switch (errno(system.pipe2(&fds, flags))) { | 4947 | switch (errno(system.pipe2(&fds, flags))) { |
| 4936 | .SUCCESS => return fds, | 4948 | .SUCCESS => return fds, |
| ... | @@ -5438,8 +5450,8 @@ pub fn realpathW(pathname: []const u16, out_buffer: *[max_path_bytes]u8) RealPat | ... | @@ -5438,8 +5450,8 @@ pub fn realpathW(pathname: []const u16, out_buffer: *[max_path_bytes]u8) RealPat |
| 5438 | /// Spurious wakeups are possible and no precision of timing is guaranteed. | 5450 | /// Spurious wakeups are possible and no precision of timing is guaranteed. |
| 5439 | pub fn nanosleep(seconds: u64, nanoseconds: u64) void { | 5451 | pub fn nanosleep(seconds: u64, nanoseconds: u64) void { |
| 5440 | var req = timespec{ | 5452 | var req = timespec{ |
| 5441 | .tv_sec = cast(isize, seconds) orelse maxInt(isize), | 5453 | .sec = cast(isize, seconds) orelse maxInt(isize), |
| 5442 | .tv_nsec = cast(isize, nanoseconds) orelse maxInt(isize), | 5454 | .nsec = cast(isize, nanoseconds) orelse maxInt(isize), |
| 5443 | }; | 5455 | }; |
| 5444 | var rem: timespec = undefined; | 5456 | var rem: timespec = undefined; |
| 5445 | while (true) { | 5457 | while (true) { |
| ... | @@ -5511,10 +5523,10 @@ pub fn dl_iterate_phdr( | ... | @@ -5511,10 +5523,10 @@ pub fn dl_iterate_phdr( |
| 5511 | } else unreachable; | 5523 | } else unreachable; |
| 5512 | 5524 | ||
| 5513 | var info = dl_phdr_info{ | 5525 | var info = dl_phdr_info{ |
| 5514 | .dlpi_addr = base_address, | 5526 | .addr = base_address, |
| 5515 | .dlpi_name = "/proc/self/exe", | 5527 | .name = "/proc/self/exe", |
| 5516 | .dlpi_phdr = phdrs.ptr, | 5528 | .phdr = phdrs.ptr, |
| 5517 | .dlpi_phnum = ehdr.e_phnum, | 5529 | .phnum = ehdr.e_phnum, |
| 5518 | }; | 5530 | }; |
| 5519 | 5531 | ||
| 5520 | return callback(&info, @sizeOf(dl_phdr_info), context); | 5532 | return callback(&info, @sizeOf(dl_phdr_info), context); |
| ... | @@ -5522,24 +5534,24 @@ pub fn dl_iterate_phdr( | ... | @@ -5522,24 +5534,24 @@ pub fn dl_iterate_phdr( |
| 5522 | 5534 | ||
| 5523 | // Last return value from the callback function. | 5535 | // Last return value from the callback function. |
| 5524 | while (it.next()) |entry| { | 5536 | while (it.next()) |entry| { |
| 5525 | var dlpi_phdr: [*]elf.Phdr = undefined; | 5537 | var phdr: [*]elf.Phdr = undefined; |
| 5526 | var dlpi_phnum: u16 = undefined; | 5538 | var phnum: u16 = undefined; |
| 5527 | 5539 | ||
| 5528 | if (entry.l_addr != 0) { | 5540 | if (entry.l_addr != 0) { |
| 5529 | const elf_header: *elf.Ehdr = @ptrFromInt(entry.l_addr); | 5541 | const elf_header: *elf.Ehdr = @ptrFromInt(entry.l_addr); |
| 5530 | dlpi_phdr = @ptrFromInt(entry.l_addr + elf_header.e_phoff); | 5542 | phdr = @ptrFromInt(entry.l_addr + elf_header.e_phoff); |
| 5531 | dlpi_phnum = elf_header.e_phnum; | 5543 | phnum = elf_header.e_phnum; |
| 5532 | } else { | 5544 | } else { |
| 5533 | // This is the running ELF image | 5545 | // This is the running ELF image |
| 5534 | dlpi_phdr = @ptrFromInt(elf_base + ehdr.e_phoff); | 5546 | phdr = @ptrFromInt(elf_base + ehdr.e_phoff); |
| 5535 | dlpi_phnum = ehdr.e_phnum; | 5547 | phnum = ehdr.e_phnum; |
| 5536 | } | 5548 | } |
| 5537 | 5549 | ||
| 5538 | var info = dl_phdr_info{ | 5550 | var info = dl_phdr_info{ |
| 5539 | .dlpi_addr = entry.l_addr, | 5551 | .addr = entry.l_addr, |
| 5540 | .dlpi_name = entry.l_name, | 5552 | .name = entry.l_name, |
| 5541 | .dlpi_phdr = dlpi_phdr, | 5553 | .phdr = phdr, |
| 5542 | .dlpi_phnum = dlpi_phnum, | 5554 | .phnum = phnum, |
| 5543 | }; | 5555 | }; |
| 5544 | 5556 | ||
| 5545 | try callback(&info, @sizeOf(dl_phdr_info), context); | 5557 | try callback(&info, @sizeOf(dl_phdr_info), context); |
| ... | @@ -5549,15 +5561,14 @@ pub fn dl_iterate_phdr( | ... | @@ -5549,15 +5561,14 @@ pub fn dl_iterate_phdr( |
| 5549 | pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError; | 5561 | pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError; |
| 5550 | 5562 | ||
| 5551 | /// TODO: change this to return the timespec as a return value | 5563 | /// TODO: change this to return the timespec as a return value |
| 5552 | /// TODO: look into making clk_id an enum | 5564 | pub fn clock_gettime(clock_id: clockid_t, tp: *timespec) ClockGetTimeError!void { |
| 5553 | pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { | ||
| 5554 | if (native_os == .wasi and !builtin.link_libc) { | 5565 | if (native_os == .wasi and !builtin.link_libc) { |
| 5555 | var ts: timestamp_t = undefined; | 5566 | var ts: timestamp_t = undefined; |
| 5556 | switch (system.clock_time_get(@bitCast(clk_id), 1, &ts)) { | 5567 | switch (system.clock_time_get(clock_id, 1, &ts)) { |
| 5557 | .SUCCESS => { | 5568 | .SUCCESS => { |
| 5558 | tp.* = .{ | 5569 | tp.* = .{ |
| 5559 | .tv_sec = @intCast(ts / std.time.ns_per_s), | 5570 | .sec = @intCast(ts / std.time.ns_per_s), |
| 5560 | .tv_nsec = @intCast(ts % std.time.ns_per_s), | 5571 | .nsec = @intCast(ts % std.time.ns_per_s), |
| 5561 | }; | 5572 | }; |
| 5562 | }, | 5573 | }, |
| 5563 | .INVAL => return error.UnsupportedClock, | 5574 | .INVAL => return error.UnsupportedClock, |
| ... | @@ -5566,15 +5577,15 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { | ... | @@ -5566,15 +5577,15 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 5566 | return; | 5577 | return; |
| 5567 | } | 5578 | } |
| 5568 | if (native_os == .windows) { | 5579 | if (native_os == .windows) { |
| 5569 | if (clk_id == CLOCK.REALTIME) { | 5580 | if (clock_id == .REALTIME) { |
| 5570 | var ft: windows.FILETIME = undefined; | 5581 | var ft: windows.FILETIME = undefined; |
| 5571 | windows.kernel32.GetSystemTimeAsFileTime(&ft); | 5582 | windows.kernel32.GetSystemTimeAsFileTime(&ft); |
| 5572 | // FileTime has a granularity of 100 nanoseconds and uses the NTFS/Windows epoch. | 5583 | // FileTime has a granularity of 100 nanoseconds and uses the NTFS/Windows epoch. |
| 5573 | const ft64 = (@as(u64, ft.dwHighDateTime) << 32) | ft.dwLowDateTime; | 5584 | const ft64 = (@as(u64, ft.dwHighDateTime) << 32) | ft.dwLowDateTime; |
| 5574 | const ft_per_s = std.time.ns_per_s / 100; | 5585 | const ft_per_s = std.time.ns_per_s / 100; |
| 5575 | tp.* = .{ | 5586 | tp.* = .{ |
| 5576 | .tv_sec = @as(i64, @intCast(ft64 / ft_per_s)) + std.time.epoch.windows, | 5587 | .sec = @as(i64, @intCast(ft64 / ft_per_s)) + std.time.epoch.windows, |
| 5577 | .tv_nsec = @as(c_long, @intCast(ft64 % ft_per_s)) * 100, | 5588 | .nsec = @as(c_long, @intCast(ft64 % ft_per_s)) * 100, |
| 5578 | }; | 5589 | }; |
| 5579 | return; | 5590 | return; |
| 5580 | } else { | 5591 | } else { |
| ... | @@ -5583,7 +5594,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { | ... | @@ -5583,7 +5594,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 5583 | } | 5594 | } |
| 5584 | } | 5595 | } |
| 5585 | 5596 | ||
| 5586 | switch (errno(system.clock_gettime(clk_id, tp))) { | 5597 | switch (errno(system.clock_gettime(clock_id, tp))) { |
| 5587 | .SUCCESS => return, | 5598 | .SUCCESS => return, |
| 5588 | .FAULT => unreachable, | 5599 | .FAULT => unreachable, |
| 5589 | .INVAL => return error.UnsupportedClock, | 5600 | .INVAL => return error.UnsupportedClock, |
| ... | @@ -5591,13 +5602,13 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { | ... | @@ -5591,13 +5602,13 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 5591 | } | 5602 | } |
| 5592 | } | 5603 | } |
| 5593 | 5604 | ||
| 5594 | pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { | 5605 | pub fn clock_getres(clock_id: clockid_t, res: *timespec) ClockGetTimeError!void { |
| 5595 | if (native_os == .wasi and !builtin.link_libc) { | 5606 | if (native_os == .wasi and !builtin.link_libc) { |
| 5596 | var ts: timestamp_t = undefined; | 5607 | var ts: timestamp_t = undefined; |
| 5597 | switch (system.clock_res_get(@bitCast(clk_id), &ts)) { | 5608 | switch (system.clock_res_get(@bitCast(clock_id), &ts)) { |
| 5598 | .SUCCESS => res.* = .{ | 5609 | .SUCCESS => res.* = .{ |
| 5599 | .tv_sec = @intCast(ts / std.time.ns_per_s), | 5610 | .sec = @intCast(ts / std.time.ns_per_s), |
| 5600 | .tv_nsec = @intCast(ts % std.time.ns_per_s), | 5611 | .nsec = @intCast(ts % std.time.ns_per_s), |
| 5601 | }, | 5612 | }, |
| 5602 | .INVAL => return error.UnsupportedClock, | 5613 | .INVAL => return error.UnsupportedClock, |
| 5603 | else => |err| return unexpectedErrno(err), | 5614 | else => |err| return unexpectedErrno(err), |
| ... | @@ -5605,7 +5616,7 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { | ... | @@ -5605,7 +5616,7 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { |
| 5605 | return; | 5616 | return; |
| 5606 | } | 5617 | } |
| 5607 | 5618 | ||
| 5608 | switch (errno(system.clock_getres(clk_id, res))) { | 5619 | switch (errno(system.clock_getres(clock_id, res))) { |
| 5609 | .SUCCESS => return, | 5620 | .SUCCESS => return, |
| 5610 | .FAULT => unreachable, | 5621 | .FAULT => unreachable, |
| 5611 | .INVAL => return error.UnsupportedClock, | 5622 | .INVAL => return error.UnsupportedClock, |
| ... | @@ -5666,7 +5677,7 @@ pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?* | ... | @@ -5666,7 +5677,7 @@ pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?* |
| 5666 | } | 5677 | } |
| 5667 | 5678 | ||
| 5668 | pub const FutimensError = error{ | 5679 | pub const FutimensError = error{ |
| 5669 | /// times is NULL, or both tv_nsec values are UTIME_NOW, and either: | 5680 | /// times is NULL, or both nsec values are UTIME_NOW, and either: |
| 5670 | /// * the effective user ID of the caller does not match the owner | 5681 | /// * the effective user ID of the caller does not match the owner |
| 5671 | /// of the file, the caller does not have write access to the | 5682 | /// of the file, the caller does not have write access to the |
| 5672 | /// file, and the caller is not privileged (Linux: does not have | 5683 | /// file, and the caller is not privileged (Linux: does not have |
| ... | @@ -5678,8 +5689,8 @@ pub const FutimensError = error{ | ... | @@ -5678,8 +5689,8 @@ pub const FutimensError = error{ |
| 5678 | /// The caller attempted to change one or both timestamps to a value | 5689 | /// The caller attempted to change one or both timestamps to a value |
| 5679 | /// other than the current time, or to change one of the timestamps | 5690 | /// other than the current time, or to change one of the timestamps |
| 5680 | /// to the current time while leaving the other timestamp unchanged, | 5691 | /// to the current time while leaving the other timestamp unchanged, |
| 5681 | /// (i.e., times is not NULL, neither tv_nsec field is UTIME_NOW, | 5692 | /// (i.e., times is not NULL, neither nsec field is UTIME_NOW, |
| 5682 | /// and neither tv_nsec field is UTIME_OMIT) and either: | 5693 | /// and neither nsec field is UTIME_OMIT) and either: |
| 5683 | /// * the caller's effective user ID does not match the owner of | 5694 | /// * the caller's effective user ID does not match the owner of |
| 5684 | /// file, and the caller is not privileged (Linux: does not have | 5695 | /// file, and the caller is not privileged (Linux: does not have |
| 5685 | /// the CAP_FOWNER capability); or, | 5696 | /// the CAP_FOWNER capability); or, |
| ... | @@ -5794,9 +5805,9 @@ pub fn res_mkquery( | ... | @@ -5794,9 +5805,9 @@ pub fn res_mkquery( |
| 5794 | 5805 | ||
| 5795 | // Make a reasonably unpredictable id | 5806 | // Make a reasonably unpredictable id |
| 5796 | var ts: timespec = undefined; | 5807 | var ts: timespec = undefined; |
| 5797 | clock_gettime(CLOCK.REALTIME, &ts) catch {}; | 5808 | clock_gettime(.REALTIME, &ts) catch {}; |
| 5798 | const UInt = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(ts.tv_nsec))); | 5809 | const UInt = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(ts.nsec))); |
| 5799 | const unsec: UInt = @bitCast(ts.tv_nsec); | 5810 | const unsec: UInt = @bitCast(ts.nsec); |
| 5800 | const id: u32 = @truncate(unsec + unsec / 65536); | 5811 | const id: u32 = @truncate(unsec + unsec / 65536); |
| 5801 | q[0] = @truncate(id / 256); | 5812 | q[0] = @truncate(id / 256); |
| 5802 | q[1] = @truncate(id); | 5813 | q[1] = @truncate(id); |
| ... | @@ -7195,8 +7206,8 @@ pub const TimerFdCreateError = error{ | ... | @@ -7195,8 +7206,8 @@ pub const TimerFdCreateError = error{ |
| 7195 | pub const TimerFdGetError = error{InvalidHandle} || UnexpectedError; | 7206 | pub const TimerFdGetError = error{InvalidHandle} || UnexpectedError; |
| 7196 | pub const TimerFdSetError = TimerFdGetError || error{Canceled}; | 7207 | pub const TimerFdSetError = TimerFdGetError || error{Canceled}; |
| 7197 | 7208 | ||
| 7198 | pub fn timerfd_create(clokid: i32, flags: system.TFD) TimerFdCreateError!fd_t { | 7209 | pub fn timerfd_create(clock_id: clockid_t, flags: system.TFD) TimerFdCreateError!fd_t { |
| 7199 | const rc = system.timerfd_create(clokid, @bitCast(flags)); | 7210 | const rc = system.timerfd_create(clock_id, @bitCast(flags)); |
| 7200 | return switch (errno(rc)) { | 7211 | return switch (errno(rc)) { |
| 7201 | .SUCCESS => @intCast(rc), | 7212 | .SUCCESS => @intCast(rc), |
| 7202 | .INVAL => unreachable, | 7213 | .INVAL => unreachable, |
lib/std/posix/test.zig+13-14| ... | @@ -483,7 +483,8 @@ test "sigaltstack" { | ... | @@ -483,7 +483,8 @@ test "sigaltstack" { |
| 483 | 483 | ||
| 484 | // If the type is not available use void to avoid erroring out when `iter_fn` is | 484 | // If the type is not available use void to avoid erroring out when `iter_fn` is |
| 485 | // analyzed | 485 | // analyzed |
| 486 | const dl_phdr_info = if (@hasDecl(posix.system, "dl_phdr_info")) posix.dl_phdr_info else anyopaque; | 486 | const have_dl_phdr_info = posix.system.dl_phdr_info != void; |
| 487 | const dl_phdr_info = if (have_dl_phdr_info) posix.dl_phdr_info else anyopaque; | ||
| 487 | 488 | ||
| 488 | const IterFnError = error{ | 489 | const IterFnError = error{ |
| 489 | MissingPtLoadSegment, | 490 | MissingPtLoadSegment, |
| ... | @@ -498,24 +499,24 @@ fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void { | ... | @@ -498,24 +499,24 @@ fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void { |
| 498 | counter.* += @as(usize, 1); | 499 | counter.* += @as(usize, 1); |
| 499 | 500 | ||
| 500 | // The image should contain at least a PT_LOAD segment | 501 | // The image should contain at least a PT_LOAD segment |
| 501 | if (info.dlpi_phnum < 1) return error.MissingPtLoadSegment; | 502 | if (info.phnum < 1) return error.MissingPtLoadSegment; |
| 502 | 503 | ||
| 503 | // Quick & dirty validation of the phdr pointers, make sure we're not | 504 | // Quick & dirty validation of the phdr pointers, make sure we're not |
| 504 | // pointing to some random gibberish | 505 | // pointing to some random gibberish |
| 505 | var i: usize = 0; | 506 | var i: usize = 0; |
| 506 | var found_load = false; | 507 | var found_load = false; |
| 507 | while (i < info.dlpi_phnum) : (i += 1) { | 508 | while (i < info.phnum) : (i += 1) { |
| 508 | const phdr = info.dlpi_phdr[i]; | 509 | const phdr = info.phdr[i]; |
| 509 | 510 | ||
| 510 | if (phdr.p_type != elf.PT_LOAD) continue; | 511 | if (phdr.p_type != elf.PT_LOAD) continue; |
| 511 | 512 | ||
| 512 | const reloc_addr = info.dlpi_addr + phdr.p_vaddr; | 513 | const reloc_addr = info.addr + phdr.p_vaddr; |
| 513 | // Find the ELF header | 514 | // Find the ELF header |
| 514 | const elf_header = @as(*elf.Ehdr, @ptrFromInt(reloc_addr - phdr.p_offset)); | 515 | const elf_header = @as(*elf.Ehdr, @ptrFromInt(reloc_addr - phdr.p_offset)); |
| 515 | // Validate the magic | 516 | // Validate the magic |
| 516 | if (!mem.eql(u8, elf_header.e_ident[0..4], elf.MAGIC)) return error.BadElfMagic; | 517 | if (!mem.eql(u8, elf_header.e_ident[0..4], elf.MAGIC)) return error.BadElfMagic; |
| 517 | // Consistency check | 518 | // Consistency check |
| 518 | if (elf_header.e_phnum != info.dlpi_phnum) return error.FailedConsistencyCheck; | 519 | if (elf_header.e_phnum != info.phnum) return error.FailedConsistencyCheck; |
| 519 | 520 | ||
| 520 | found_load = true; | 521 | found_load = true; |
| 521 | break; | 522 | break; |
| ... | @@ -774,12 +775,10 @@ test "fsync" { | ... | @@ -774,12 +775,10 @@ test "fsync" { |
| 774 | } | 775 | } |
| 775 | 776 | ||
| 776 | test "getrlimit and setrlimit" { | 777 | test "getrlimit and setrlimit" { |
| 777 | if (!@hasDecl(posix.system, "rlimit")) { | 778 | if (posix.system.rlimit_resource == void) return error.SkipZigTest; |
| 778 | return error.SkipZigTest; | ||
| 779 | } | ||
| 780 | 779 | ||
| 781 | inline for (std.meta.fields(posix.rlimit_resource)) |field| { | 780 | inline for (@typeInfo(posix.rlimit_resource).Enum.fields) |field| { |
| 782 | const resource = @as(posix.rlimit_resource, @enumFromInt(field.value)); | 781 | const resource: posix.rlimit_resource = @enumFromInt(field.value); |
| 783 | const limit = try posix.getrlimit(resource); | 782 | const limit = try posix.getrlimit(resource); |
| 784 | 783 | ||
| 785 | // XNU kernel does not support RLIMIT_STACK if a custom stack is active, | 784 | // XNU kernel does not support RLIMIT_STACK if a custom stack is active, |
| ... | @@ -1116,18 +1115,18 @@ test "access smoke test" { | ... | @@ -1116,18 +1115,18 @@ test "access smoke test" { |
| 1116 | test "timerfd" { | 1115 | test "timerfd" { |
| 1117 | if (native_os != .linux) return error.SkipZigTest; | 1116 | if (native_os != .linux) return error.SkipZigTest; |
| 1118 | 1117 | ||
| 1119 | const tfd = try posix.timerfd_create(linux.CLOCK.MONOTONIC, .{ .CLOEXEC = true }); | 1118 | const tfd = try posix.timerfd_create(.MONOTONIC, .{ .CLOEXEC = true }); |
| 1120 | defer posix.close(tfd); | 1119 | defer posix.close(tfd); |
| 1121 | 1120 | ||
| 1122 | // Fire event 10_000_000ns = 10ms after the posix.timerfd_settime call. | 1121 | // Fire event 10_000_000ns = 10ms after the posix.timerfd_settime call. |
| 1123 | var sit: linux.itimerspec = .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 10 * (1000 * 1000) } }; | 1122 | var sit: linux.itimerspec = .{ .it_interval = .{ .sec = 0, .nsec = 0 }, .it_value = .{ .sec = 0, .nsec = 10 * (1000 * 1000) } }; |
| 1124 | try posix.timerfd_settime(tfd, .{}, &sit, null); | 1123 | try posix.timerfd_settime(tfd, .{}, &sit, null); |
| 1125 | 1124 | ||
| 1126 | var fds: [1]posix.pollfd = .{.{ .fd = tfd, .events = linux.POLL.IN, .revents = 0 }}; | 1125 | var fds: [1]posix.pollfd = .{.{ .fd = tfd, .events = linux.POLL.IN, .revents = 0 }}; |
| 1127 | try expectEqual(@as(usize, 1), try posix.poll(&fds, -1)); // -1 => infinite waiting | 1126 | try expectEqual(@as(usize, 1), try posix.poll(&fds, -1)); // -1 => infinite waiting |
| 1128 | 1127 | ||
| 1129 | const git = try posix.timerfd_gettime(tfd); | 1128 | const git = try posix.timerfd_gettime(tfd); |
| 1130 | const expect_disarmed_timer: linux.itimerspec = .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 0 } }; | 1129 | const expect_disarmed_timer: linux.itimerspec = .{ .it_interval = .{ .sec = 0, .nsec = 0 }, .it_value = .{ .sec = 0, .nsec = 0 } }; |
| 1131 | try expectEqual(expect_disarmed_timer, git); | 1130 | try expectEqual(expect_disarmed_timer, git); |
| 1132 | } | 1131 | } |
| 1133 | 1132 |
lib/std/process.zig+1-4| ... | @@ -1789,10 +1789,7 @@ pub fn cleanExit() void { | ... | @@ -1789,10 +1789,7 @@ pub fn cleanExit() void { |
| 1789 | /// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded | 1789 | /// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded |
| 1790 | /// errors. On other systems, this does nothing. | 1790 | /// errors. On other systems, this does nothing. |
| 1791 | pub fn raiseFileDescriptorLimit() void { | 1791 | pub fn raiseFileDescriptorLimit() void { |
| 1792 | const have_rlimit = switch (native_os) { | 1792 | const have_rlimit = posix.rlimit_resource != void; |
| 1793 | .windows, .wasi => false, | ||
| 1794 | else => true, | ||
| 1795 | }; | ||
| 1796 | if (!have_rlimit) return; | 1793 | if (!have_rlimit) return; |
| 1797 | 1794 | ||
| 1798 | var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried. | 1795 | var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried. |
lib/std/time.zig+7-7| ... | @@ -115,10 +115,10 @@ pub fn nanoTimestamp() i128 { | ... | @@ -115,10 +115,10 @@ pub fn nanoTimestamp() i128 { |
| 115 | }, | 115 | }, |
| 116 | else => { | 116 | else => { |
| 117 | var ts: posix.timespec = undefined; | 117 | var ts: posix.timespec = undefined; |
| 118 | posix.clock_gettime(posix.CLOCK.REALTIME, &ts) catch |err| switch (err) { | 118 | posix.clock_gettime(.REALTIME, &ts) catch |err| switch (err) { |
| 119 | error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS". | 119 | error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS". |
| 120 | }; | 120 | }; |
| 121 | return (@as(i128, ts.tv_sec) * ns_per_s) + ts.tv_nsec; | 121 | return (@as(i128, ts.sec) * ns_per_s) + ts.nsec; |
| 122 | }, | 122 | }, |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| ... | @@ -229,9 +229,9 @@ pub const Instant = struct { | ... | @@ -229,9 +229,9 @@ pub const Instant = struct { |
| 229 | return std.math.order(self.timestamp, other.timestamp); | 229 | return std.math.order(self.timestamp, other.timestamp); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | var ord = std.math.order(self.timestamp.tv_sec, other.timestamp.tv_sec); | 232 | var ord = std.math.order(self.timestamp.sec, other.timestamp.sec); |
| 233 | if (ord == .eq) { | 233 | if (ord == .eq) { |
| 234 | ord = std.math.order(self.timestamp.tv_nsec, other.timestamp.tv_nsec); | 234 | ord = std.math.order(self.timestamp.nsec, other.timestamp.nsec); |
| 235 | } | 235 | } |
| 236 | return ord; | 236 | return ord; |
| 237 | } | 237 | } |
| ... | @@ -267,9 +267,9 @@ pub const Instant = struct { | ... | @@ -267,9 +267,9 @@ pub const Instant = struct { |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | // Convert timespec diff to ns | 269 | // Convert timespec diff to ns |
| 270 | const seconds = @as(u64, @intCast(self.timestamp.tv_sec - earlier.timestamp.tv_sec)); | 270 | const seconds = @as(u64, @intCast(self.timestamp.sec - earlier.timestamp.sec)); |
| 271 | const elapsed = (seconds * ns_per_s) + @as(u32, @intCast(self.timestamp.tv_nsec)); | 271 | const elapsed = (seconds * ns_per_s) + @as(u32, @intCast(self.timestamp.nsec)); |
| 272 | return elapsed - @as(u32, @intCast(earlier.timestamp.tv_nsec)); | 272 | return elapsed - @as(u32, @intCast(earlier.timestamp.nsec)); |
| 273 | } | 273 | } |
| 274 | }; | 274 | }; |
| 275 | 275 |
src/link/MachO.zig+645-2| ... | @@ -3779,7 +3779,7 @@ pub fn getDebugSymbols(self: *MachO) ?*DebugSymbols { | ... | @@ -3779,7 +3779,7 @@ pub fn getDebugSymbols(self: *MachO) ?*DebugSymbols { |
| 3779 | pub fn ptraceAttach(self: *MachO, pid: std.posix.pid_t) !void { | 3779 | pub fn ptraceAttach(self: *MachO, pid: std.posix.pid_t) !void { |
| 3780 | if (!is_hot_update_compatible) return; | 3780 | if (!is_hot_update_compatible) return; |
| 3781 | 3781 | ||
| 3782 | const mach_task = try std.c.machTaskForPid(pid); | 3782 | const mach_task = try machTaskForPid(pid); |
| 3783 | log.debug("Mach task for pid {d}: {any}", .{ pid, mach_task }); | 3783 | log.debug("Mach task for pid {d}: {any}", .{ pid, mach_task }); |
| 3784 | self.hot_state.mach_task = mach_task; | 3784 | self.hot_state.mach_task = mach_task; |
| 3785 | 3785 | ||
| ... | @@ -4058,7 +4058,7 @@ pub const LiteralPool = struct { | ... | @@ -4058,7 +4058,7 @@ pub const LiteralPool = struct { |
| 4058 | }; | 4058 | }; |
| 4059 | 4059 | ||
| 4060 | const HotUpdateState = struct { | 4060 | const HotUpdateState = struct { |
| 4061 | mach_task: ?std.c.MachTask = null, | 4061 | mach_task: ?MachTask = null, |
| 4062 | }; | 4062 | }; |
| 4063 | 4063 | ||
| 4064 | pub const SymtabCtx = struct { | 4064 | pub const SymtabCtx = struct { |
| ... | @@ -4562,3 +4562,646 @@ const UnwindInfo = @import("MachO/UnwindInfo.zig"); | ... | @@ -4562,3 +4562,646 @@ const UnwindInfo = @import("MachO/UnwindInfo.zig"); |
| 4562 | const WeakBind = bind.WeakBind; | 4562 | const WeakBind = bind.WeakBind; |
| 4563 | const ZigGotSection = synthetic.ZigGotSection; | 4563 | const ZigGotSection = synthetic.ZigGotSection; |
| 4564 | const ZigObject = @import("MachO/ZigObject.zig"); | 4564 | const ZigObject = @import("MachO/ZigObject.zig"); |
| 4565 | |||
| 4566 | pub const MachError = error{ | ||
| 4567 | /// Not enough permissions held to perform the requested kernel | ||
| 4568 | /// call. | ||
| 4569 | PermissionDenied, | ||
| 4570 | } || std.posix.UnexpectedError; | ||
| 4571 | |||
| 4572 | pub const MachTask = extern struct { | ||
| 4573 | port: std.c.mach_port_name_t, | ||
| 4574 | |||
| 4575 | pub fn isValid(self: MachTask) bool { | ||
| 4576 | return self.port != std.c.TASK_NULL; | ||
| 4577 | } | ||
| 4578 | |||
| 4579 | pub fn pidForTask(self: MachTask) MachError!std.c.pid_t { | ||
| 4580 | var pid: std.c.pid_t = undefined; | ||
| 4581 | switch (getKernError(std.c.pid_for_task(self.port, &pid))) { | ||
| 4582 | .SUCCESS => return pid, | ||
| 4583 | .FAILURE => return error.PermissionDenied, | ||
| 4584 | else => |err| return unexpectedKernError(err), | ||
| 4585 | } | ||
| 4586 | } | ||
| 4587 | |||
| 4588 | pub fn allocatePort(self: MachTask, right: std.c.MACH_PORT_RIGHT) MachError!MachTask { | ||
| 4589 | var out_port: std.c.mach_port_name_t = undefined; | ||
| 4590 | switch (getKernError(std.c.mach_port_allocate( | ||
| 4591 | self.port, | ||
| 4592 | @intFromEnum(right), | ||
| 4593 | &out_port, | ||
| 4594 | ))) { | ||
| 4595 | .SUCCESS => return .{ .port = out_port }, | ||
| 4596 | .FAILURE => return error.PermissionDenied, | ||
| 4597 | else => |err| return unexpectedKernError(err), | ||
| 4598 | } | ||
| 4599 | } | ||
| 4600 | |||
| 4601 | pub fn deallocatePort(self: MachTask, port: MachTask) void { | ||
| 4602 | _ = getKernError(std.c.mach_port_deallocate(self.port, port.port)); | ||
| 4603 | } | ||
| 4604 | |||
| 4605 | pub fn insertRight(self: MachTask, port: MachTask, msg: std.c.MACH_MSG_TYPE) !void { | ||
| 4606 | switch (getKernError(std.c.mach_port_insert_right( | ||
| 4607 | self.port, | ||
| 4608 | port.port, | ||
| 4609 | port.port, | ||
| 4610 | @intFromEnum(msg), | ||
| 4611 | ))) { | ||
| 4612 | .SUCCESS => return, | ||
| 4613 | .FAILURE => return error.PermissionDenied, | ||
| 4614 | else => |err| return unexpectedKernError(err), | ||
| 4615 | } | ||
| 4616 | } | ||
| 4617 | |||
| 4618 | pub const PortInfo = struct { | ||
| 4619 | mask: std.c.exception_mask_t, | ||
| 4620 | masks: [std.c.EXC.TYPES_COUNT]std.c.exception_mask_t, | ||
| 4621 | ports: [std.c.EXC.TYPES_COUNT]std.c.mach_port_t, | ||
| 4622 | behaviors: [std.c.EXC.TYPES_COUNT]std.c.exception_behavior_t, | ||
| 4623 | flavors: [std.c.EXC.TYPES_COUNT]std.c.thread_state_flavor_t, | ||
| 4624 | count: std.c.mach_msg_type_number_t, | ||
| 4625 | }; | ||
| 4626 | |||
| 4627 | pub fn getExceptionPorts(self: MachTask, mask: std.c.exception_mask_t) !PortInfo { | ||
| 4628 | var info: PortInfo = .{ | ||
| 4629 | .mask = mask, | ||
| 4630 | .masks = undefined, | ||
| 4631 | .ports = undefined, | ||
| 4632 | .behaviors = undefined, | ||
| 4633 | .flavors = undefined, | ||
| 4634 | .count = 0, | ||
| 4635 | }; | ||
| 4636 | info.count = info.ports.len / @sizeOf(std.c.mach_port_t); | ||
| 4637 | |||
| 4638 | switch (getKernError(std.c.task_get_exception_ports( | ||
| 4639 | self.port, | ||
| 4640 | info.mask, | ||
| 4641 | &info.masks, | ||
| 4642 | &info.count, | ||
| 4643 | &info.ports, | ||
| 4644 | &info.behaviors, | ||
| 4645 | &info.flavors, | ||
| 4646 | ))) { | ||
| 4647 | .SUCCESS => return info, | ||
| 4648 | .FAILURE => return error.PermissionDenied, | ||
| 4649 | else => |err| return unexpectedKernError(err), | ||
| 4650 | } | ||
| 4651 | } | ||
| 4652 | |||
| 4653 | pub fn setExceptionPorts( | ||
| 4654 | self: MachTask, | ||
| 4655 | mask: std.c.exception_mask_t, | ||
| 4656 | new_port: MachTask, | ||
| 4657 | behavior: std.c.exception_behavior_t, | ||
| 4658 | new_flavor: std.c.thread_state_flavor_t, | ||
| 4659 | ) !void { | ||
| 4660 | switch (getKernError(std.c.task_set_exception_ports( | ||
| 4661 | self.port, | ||
| 4662 | mask, | ||
| 4663 | new_port.port, | ||
| 4664 | behavior, | ||
| 4665 | new_flavor, | ||
| 4666 | ))) { | ||
| 4667 | .SUCCESS => return, | ||
| 4668 | .FAILURE => return error.PermissionDenied, | ||
| 4669 | else => |err| return unexpectedKernError(err), | ||
| 4670 | } | ||
| 4671 | } | ||
| 4672 | |||
| 4673 | pub const RegionInfo = struct { | ||
| 4674 | pub const Tag = enum { | ||
| 4675 | basic, | ||
| 4676 | extended, | ||
| 4677 | top, | ||
| 4678 | }; | ||
| 4679 | |||
| 4680 | base_addr: u64, | ||
| 4681 | tag: Tag, | ||
| 4682 | info: union { | ||
| 4683 | basic: std.c.vm_region_basic_info_64, | ||
| 4684 | extended: std.c.vm_region_extended_info, | ||
| 4685 | top: std.c.vm_region_top_info, | ||
| 4686 | }, | ||
| 4687 | }; | ||
| 4688 | |||
| 4689 | pub fn getRegionInfo( | ||
| 4690 | task: MachTask, | ||
| 4691 | address: u64, | ||
| 4692 | len: usize, | ||
| 4693 | tag: RegionInfo.Tag, | ||
| 4694 | ) MachError!RegionInfo { | ||
| 4695 | var info: RegionInfo = .{ | ||
| 4696 | .base_addr = address, | ||
| 4697 | .tag = tag, | ||
| 4698 | .info = undefined, | ||
| 4699 | }; | ||
| 4700 | switch (tag) { | ||
| 4701 | .basic => info.info = .{ .basic = undefined }, | ||
| 4702 | .extended => info.info = .{ .extended = undefined }, | ||
| 4703 | .top => info.info = .{ .top = undefined }, | ||
| 4704 | } | ||
| 4705 | var base_len: std.c.mach_vm_size_t = if (len == 1) 2 else len; | ||
| 4706 | var objname: std.c.mach_port_t = undefined; | ||
| 4707 | var count: std.c.mach_msg_type_number_t = switch (tag) { | ||
| 4708 | .basic => std.c.VM.REGION.BASIC_INFO_COUNT, | ||
| 4709 | .extended => std.c.VM.REGION.EXTENDED_INFO_COUNT, | ||
| 4710 | .top => std.c.VM.REGION.TOP_INFO_COUNT, | ||
| 4711 | }; | ||
| 4712 | switch (getKernError(std.c.mach_vm_region( | ||
| 4713 | task.port, | ||
| 4714 | &info.base_addr, | ||
| 4715 | &base_len, | ||
| 4716 | switch (tag) { | ||
| 4717 | .basic => std.c.VM.REGION.BASIC_INFO_64, | ||
| 4718 | .extended => std.c.VM.REGION.EXTENDED_INFO, | ||
| 4719 | .top => std.c.VM.REGION.TOP_INFO, | ||
| 4720 | }, | ||
| 4721 | switch (tag) { | ||
| 4722 | .basic => @as(std.c.vm_region_info_t, @ptrCast(&info.info.basic)), | ||
| 4723 | .extended => @as(std.c.vm_region_info_t, @ptrCast(&info.info.extended)), | ||
| 4724 | .top => @as(std.c.vm_region_info_t, @ptrCast(&info.info.top)), | ||
| 4725 | }, | ||
| 4726 | &count, | ||
| 4727 | &objname, | ||
| 4728 | ))) { | ||
| 4729 | .SUCCESS => return info, | ||
| 4730 | .FAILURE => return error.PermissionDenied, | ||
| 4731 | else => |err| return unexpectedKernError(err), | ||
| 4732 | } | ||
| 4733 | } | ||
| 4734 | |||
| 4735 | pub const RegionSubmapInfo = struct { | ||
| 4736 | pub const Tag = enum { | ||
| 4737 | short, | ||
| 4738 | full, | ||
| 4739 | }; | ||
| 4740 | |||
| 4741 | tag: Tag, | ||
| 4742 | base_addr: u64, | ||
| 4743 | info: union { | ||
| 4744 | short: std.c.vm_region_submap_short_info_64, | ||
| 4745 | full: std.c.vm_region_submap_info_64, | ||
| 4746 | }, | ||
| 4747 | }; | ||
| 4748 | |||
| 4749 | pub fn getRegionSubmapInfo( | ||
| 4750 | task: MachTask, | ||
| 4751 | address: u64, | ||
| 4752 | len: usize, | ||
| 4753 | nesting_depth: u32, | ||
| 4754 | tag: RegionSubmapInfo.Tag, | ||
| 4755 | ) MachError!RegionSubmapInfo { | ||
| 4756 | var info: RegionSubmapInfo = .{ | ||
| 4757 | .base_addr = address, | ||
| 4758 | .tag = tag, | ||
| 4759 | .info = undefined, | ||
| 4760 | }; | ||
| 4761 | switch (tag) { | ||
| 4762 | .short => info.info = .{ .short = undefined }, | ||
| 4763 | .full => info.info = .{ .full = undefined }, | ||
| 4764 | } | ||
| 4765 | var nesting = nesting_depth; | ||
| 4766 | var base_len: std.c.mach_vm_size_t = if (len == 1) 2 else len; | ||
| 4767 | var count: std.c.mach_msg_type_number_t = switch (tag) { | ||
| 4768 | .short => std.c.VM.REGION.SUBMAP_SHORT_INFO_COUNT_64, | ||
| 4769 | .full => std.c.VM.REGION.SUBMAP_INFO_COUNT_64, | ||
| 4770 | }; | ||
| 4771 | switch (getKernError(std.c.mach_vm_region_recurse( | ||
| 4772 | task.port, | ||
| 4773 | &info.base_addr, | ||
| 4774 | &base_len, | ||
| 4775 | &nesting, | ||
| 4776 | switch (tag) { | ||
| 4777 | .short => @as(std.c.vm_region_recurse_info_t, @ptrCast(&info.info.short)), | ||
| 4778 | .full => @as(std.c.vm_region_recurse_info_t, @ptrCast(&info.info.full)), | ||
| 4779 | }, | ||
| 4780 | &count, | ||
| 4781 | ))) { | ||
| 4782 | .SUCCESS => return info, | ||
| 4783 | .FAILURE => return error.PermissionDenied, | ||
| 4784 | else => |err| return unexpectedKernError(err), | ||
| 4785 | } | ||
| 4786 | } | ||
| 4787 | |||
| 4788 | pub fn getCurrProtection(task: MachTask, address: u64, len: usize) MachError!std.c.vm_prot_t { | ||
| 4789 | const info = try task.getRegionSubmapInfo(address, len, 0, .short); | ||
| 4790 | return info.info.short.protection; | ||
| 4791 | } | ||
| 4792 | |||
| 4793 | pub fn setMaxProtection(task: MachTask, address: u64, len: usize, prot: std.c.vm_prot_t) MachError!void { | ||
| 4794 | return task.setProtectionImpl(address, len, true, prot); | ||
| 4795 | } | ||
| 4796 | |||
| 4797 | pub fn setCurrProtection(task: MachTask, address: u64, len: usize, prot: std.c.vm_prot_t) MachError!void { | ||
| 4798 | return task.setProtectionImpl(address, len, false, prot); | ||
| 4799 | } | ||
| 4800 | |||
| 4801 | fn setProtectionImpl(task: MachTask, address: u64, len: usize, set_max: bool, prot: std.c.vm_prot_t) MachError!void { | ||
| 4802 | switch (getKernError(std.c.mach_vm_protect(task.port, address, len, @intFromBool(set_max), prot))) { | ||
| 4803 | .SUCCESS => return, | ||
| 4804 | .FAILURE => return error.PermissionDenied, | ||
| 4805 | else => |err| return unexpectedKernError(err), | ||
| 4806 | } | ||
| 4807 | } | ||
| 4808 | |||
| 4809 | /// Will write to VM even if current protection attributes specifically prohibit | ||
| 4810 | /// us from doing so, by temporarily setting protection level to a level with VM_PROT_COPY | ||
| 4811 | /// variant, and resetting after a successful or unsuccessful write. | ||
| 4812 | pub fn writeMemProtected(task: MachTask, address: u64, buf: []const u8, arch: std.Target.Cpu.Arch) MachError!usize { | ||
| 4813 | const curr_prot = try task.getCurrProtection(address, buf.len); | ||
| 4814 | try task.setCurrProtection( | ||
| 4815 | address, | ||
| 4816 | buf.len, | ||
| 4817 | std.c.PROT.READ | std.c.PROT.WRITE | std.c.PROT.COPY, | ||
| 4818 | ); | ||
| 4819 | defer { | ||
| 4820 | task.setCurrProtection(address, buf.len, curr_prot) catch {}; | ||
| 4821 | } | ||
| 4822 | return task.writeMem(address, buf, arch); | ||
| 4823 | } | ||
| 4824 | |||
| 4825 | pub fn writeMem(task: MachTask, address: u64, buf: []const u8, arch: std.Target.Cpu.Arch) MachError!usize { | ||
| 4826 | const count = buf.len; | ||
| 4827 | var total_written: usize = 0; | ||
| 4828 | var curr_addr = address; | ||
| 4829 | const page_size = try MachTask.getPageSize(task); // TODO we probably can assume value here | ||
| 4830 | var out_buf = buf[0..]; | ||
| 4831 | |||
| 4832 | while (total_written < count) { | ||
| 4833 | const curr_size = maxBytesLeftInPage(page_size, curr_addr, count - total_written); | ||
| 4834 | switch (getKernError(std.c.mach_vm_write( | ||
| 4835 | task.port, | ||
| 4836 | curr_addr, | ||
| 4837 | @intFromPtr(out_buf.ptr), | ||
| 4838 | @as(std.c.mach_msg_type_number_t, @intCast(curr_size)), | ||
| 4839 | ))) { | ||
| 4840 | .SUCCESS => {}, | ||
| 4841 | .FAILURE => return error.PermissionDenied, | ||
| 4842 | else => |err| return unexpectedKernError(err), | ||
| 4843 | } | ||
| 4844 | |||
| 4845 | switch (arch) { | ||
| 4846 | .aarch64 => { | ||
| 4847 | var mattr_value: std.c.vm_machine_attribute_val_t = std.c.MATTR.VAL_CACHE_FLUSH; | ||
| 4848 | switch (getKernError(std.c.vm_machine_attribute( | ||
| 4849 | task.port, | ||
| 4850 | curr_addr, | ||
| 4851 | curr_size, | ||
| 4852 | std.c.MATTR.CACHE, | ||
| 4853 | &mattr_value, | ||
| 4854 | ))) { | ||
| 4855 | .SUCCESS => {}, | ||
| 4856 | .FAILURE => return error.PermissionDenied, | ||
| 4857 | else => |err| return unexpectedKernError(err), | ||
| 4858 | } | ||
| 4859 | }, | ||
| 4860 | .x86_64 => {}, | ||
| 4861 | else => unreachable, | ||
| 4862 | } | ||
| 4863 | |||
| 4864 | out_buf = out_buf[curr_size..]; | ||
| 4865 | total_written += curr_size; | ||
| 4866 | curr_addr += curr_size; | ||
| 4867 | } | ||
| 4868 | |||
| 4869 | return total_written; | ||
| 4870 | } | ||
| 4871 | |||
| 4872 | pub fn readMem(task: MachTask, address: u64, buf: []u8) MachError!usize { | ||
| 4873 | const count = buf.len; | ||
| 4874 | var total_read: usize = 0; | ||
| 4875 | var curr_addr = address; | ||
| 4876 | const page_size = try MachTask.getPageSize(task); // TODO we probably can assume value here | ||
| 4877 | var out_buf = buf[0..]; | ||
| 4878 | |||
| 4879 | while (total_read < count) { | ||
| 4880 | const curr_size = maxBytesLeftInPage(page_size, curr_addr, count - total_read); | ||
| 4881 | var curr_bytes_read: std.c.mach_msg_type_number_t = 0; | ||
| 4882 | var vm_memory: std.c.vm_offset_t = undefined; | ||
| 4883 | switch (getKernError(std.c.mach_vm_read(task.port, curr_addr, curr_size, &vm_memory, &curr_bytes_read))) { | ||
| 4884 | .SUCCESS => {}, | ||
| 4885 | .FAILURE => return error.PermissionDenied, | ||
| 4886 | else => |err| return unexpectedKernError(err), | ||
| 4887 | } | ||
| 4888 | |||
| 4889 | @memcpy(out_buf[0..curr_bytes_read], @as([*]const u8, @ptrFromInt(vm_memory))); | ||
| 4890 | _ = std.c.vm_deallocate(std.c.mach_task_self(), vm_memory, curr_bytes_read); | ||
| 4891 | |||
| 4892 | out_buf = out_buf[curr_bytes_read..]; | ||
| 4893 | curr_addr += curr_bytes_read; | ||
| 4894 | total_read += curr_bytes_read; | ||
| 4895 | } | ||
| 4896 | |||
| 4897 | return total_read; | ||
| 4898 | } | ||
| 4899 | |||
| 4900 | fn maxBytesLeftInPage(page_size: usize, address: u64, count: usize) usize { | ||
| 4901 | var left = count; | ||
| 4902 | if (page_size > 0) { | ||
| 4903 | const page_offset = address % page_size; | ||
| 4904 | const bytes_left_in_page = page_size - page_offset; | ||
| 4905 | if (count > bytes_left_in_page) { | ||
| 4906 | left = bytes_left_in_page; | ||
| 4907 | } | ||
| 4908 | } | ||
| 4909 | return left; | ||
| 4910 | } | ||
| 4911 | |||
| 4912 | fn getPageSize(task: MachTask) MachError!usize { | ||
| 4913 | if (task.isValid()) { | ||
| 4914 | var info_count = std.c.TASK_VM_INFO_COUNT; | ||
| 4915 | var vm_info: std.c.task_vm_info_data_t = undefined; | ||
| 4916 | switch (getKernError(std.c.task_info( | ||
| 4917 | task.port, | ||
| 4918 | std.c.TASK_VM_INFO, | ||
| 4919 | @as(std.c.task_info_t, @ptrCast(&vm_info)), | ||
| 4920 | &info_count, | ||
| 4921 | ))) { | ||
| 4922 | .SUCCESS => return @as(usize, @intCast(vm_info.page_size)), | ||
| 4923 | else => {}, | ||
| 4924 | } | ||
| 4925 | } | ||
| 4926 | var page_size: std.c.vm_size_t = undefined; | ||
| 4927 | switch (getKernError(std.c._host_page_size(std.c.mach_host_self(), &page_size))) { | ||
| 4928 | .SUCCESS => return page_size, | ||
| 4929 | else => |err| return unexpectedKernError(err), | ||
| 4930 | } | ||
| 4931 | } | ||
| 4932 | |||
| 4933 | pub fn basicTaskInfo(task: MachTask) MachError!std.c.mach_task_basic_info { | ||
| 4934 | var info: std.c.mach_task_basic_info = undefined; | ||
| 4935 | var count = std.c.MACH_TASK_BASIC_INFO_COUNT; | ||
| 4936 | switch (getKernError(std.c.task_info( | ||
| 4937 | task.port, | ||
| 4938 | std.c.MACH_TASK_BASIC_INFO, | ||
| 4939 | @as(std.c.task_info_t, @ptrCast(&info)), | ||
| 4940 | &count, | ||
| 4941 | ))) { | ||
| 4942 | .SUCCESS => return info, | ||
| 4943 | else => |err| return unexpectedKernError(err), | ||
| 4944 | } | ||
| 4945 | } | ||
| 4946 | |||
| 4947 | pub fn @"resume"(task: MachTask) MachError!void { | ||
| 4948 | switch (getKernError(std.c.task_resume(task.port))) { | ||
| 4949 | .SUCCESS => {}, | ||
| 4950 | else => |err| return unexpectedKernError(err), | ||
| 4951 | } | ||
| 4952 | } | ||
| 4953 | |||
| 4954 | pub fn @"suspend"(task: MachTask) MachError!void { | ||
| 4955 | switch (getKernError(std.c.task_suspend(task.port))) { | ||
| 4956 | .SUCCESS => {}, | ||
| 4957 | else => |err| return unexpectedKernError(err), | ||
| 4958 | } | ||
| 4959 | } | ||
| 4960 | |||
| 4961 | const ThreadList = struct { | ||
| 4962 | buf: []MachThread, | ||
| 4963 | |||
| 4964 | pub fn deinit(list: ThreadList) void { | ||
| 4965 | const self_task = machTaskForSelf(); | ||
| 4966 | _ = std.c.vm_deallocate( | ||
| 4967 | self_task.port, | ||
| 4968 | @intFromPtr(list.buf.ptr), | ||
| 4969 | @as(std.c.vm_size_t, @intCast(list.buf.len * @sizeOf(std.c.mach_port_t))), | ||
| 4970 | ); | ||
| 4971 | } | ||
| 4972 | }; | ||
| 4973 | |||
| 4974 | pub fn getThreads(task: MachTask) MachError!ThreadList { | ||
| 4975 | var thread_list: std.c.mach_port_array_t = undefined; | ||
| 4976 | var thread_count: std.c.mach_msg_type_number_t = undefined; | ||
| 4977 | switch (getKernError(std.c.task_threads(task.port, &thread_list, &thread_count))) { | ||
| 4978 | .SUCCESS => return ThreadList{ .buf = @as([*]MachThread, @ptrCast(thread_list))[0..thread_count] }, | ||
| 4979 | else => |err| return unexpectedKernError(err), | ||
| 4980 | } | ||
| 4981 | } | ||
| 4982 | }; | ||
| 4983 | |||
| 4984 | pub const MachThread = extern struct { | ||
| 4985 | port: std.c.mach_port_t, | ||
| 4986 | |||
| 4987 | pub fn isValid(thread: MachThread) bool { | ||
| 4988 | return thread.port != std.c.THREAD_NULL; | ||
| 4989 | } | ||
| 4990 | |||
| 4991 | pub fn getBasicInfo(thread: MachThread) MachError!std.c.thread_basic_info { | ||
| 4992 | var info: std.c.thread_basic_info = undefined; | ||
| 4993 | var count = std.c.THREAD_BASIC_INFO_COUNT; | ||
| 4994 | switch (getKernError(std.c.thread_info( | ||
| 4995 | thread.port, | ||
| 4996 | std.c.THREAD_BASIC_INFO, | ||
| 4997 | @as(std.c.thread_info_t, @ptrCast(&info)), | ||
| 4998 | &count, | ||
| 4999 | ))) { | ||
| 5000 | .SUCCESS => return info, | ||
| 5001 | else => |err| return unexpectedKernError(err), | ||
| 5002 | } | ||
| 5003 | } | ||
| 5004 | |||
| 5005 | pub fn getIdentifierInfo(thread: MachThread) MachError!std.c.thread_identifier_info { | ||
| 5006 | var info: std.c.thread_identifier_info = undefined; | ||
| 5007 | var count = std.c.THREAD_IDENTIFIER_INFO_COUNT; | ||
| 5008 | switch (getKernError(std.c.thread_info( | ||
| 5009 | thread.port, | ||
| 5010 | std.c.THREAD_IDENTIFIER_INFO, | ||
| 5011 | @as(std.c.thread_info_t, @ptrCast(&info)), | ||
| 5012 | &count, | ||
| 5013 | ))) { | ||
| 5014 | .SUCCESS => return info, | ||
| 5015 | else => |err| return unexpectedKernError(err), | ||
| 5016 | } | ||
| 5017 | } | ||
| 5018 | }; | ||
| 5019 | |||
| 5020 | pub fn machTaskForPid(pid: std.c.pid_t) MachError!MachTask { | ||
| 5021 | var port: std.c.mach_port_name_t = undefined; | ||
| 5022 | switch (getKernError(std.c.task_for_pid(std.c.mach_task_self(), pid, &port))) { | ||
| 5023 | .SUCCESS => {}, | ||
| 5024 | .FAILURE => return error.PermissionDenied, | ||
| 5025 | else => |err| return unexpectedKernError(err), | ||
| 5026 | } | ||
| 5027 | return MachTask{ .port = port }; | ||
| 5028 | } | ||
| 5029 | |||
| 5030 | pub fn machTaskForSelf() MachTask { | ||
| 5031 | return .{ .port = std.c.mach_task_self() }; | ||
| 5032 | } | ||
| 5033 | |||
| 5034 | pub fn getKernError(err: std.c.kern_return_t) KernE { | ||
| 5035 | return @as(KernE, @enumFromInt(@as(u32, @truncate(@as(usize, @intCast(err)))))); | ||
| 5036 | } | ||
| 5037 | |||
| 5038 | pub fn unexpectedKernError(err: KernE) std.posix.UnexpectedError { | ||
| 5039 | if (std.posix.unexpected_error_tracing) { | ||
| 5040 | std.debug.print("unexpected error: {d}\n", .{@intFromEnum(err)}); | ||
| 5041 | std.debug.dumpCurrentStackTrace(null); | ||
| 5042 | } | ||
| 5043 | return error.Unexpected; | ||
| 5044 | } | ||
| 5045 | |||
| 5046 | /// Kernel return values | ||
| 5047 | pub const KernE = enum(u32) { | ||
| 5048 | SUCCESS = 0, | ||
| 5049 | /// Specified address is not currently valid | ||
| 5050 | INVALID_ADDRESS = 1, | ||
| 5051 | /// Specified memory is valid, but does not permit the | ||
| 5052 | /// required forms of access. | ||
| 5053 | PROTECTION_FAILURE = 2, | ||
| 5054 | /// The address range specified is already in use, or | ||
| 5055 | /// no address range of the size specified could be | ||
| 5056 | /// found. | ||
| 5057 | NO_SPACE = 3, | ||
| 5058 | /// The function requested was not applicable to this | ||
| 5059 | /// type of argument, or an argument is invalid | ||
| 5060 | INVALID_ARGUMENT = 4, | ||
| 5061 | /// The function could not be performed. A catch-all. | ||
| 5062 | FAILURE = 5, | ||
| 5063 | /// A system resource could not be allocated to fulfill | ||
| 5064 | /// this request. This failure may not be permanent. | ||
| 5065 | RESOURCE_SHORTAGE = 6, | ||
| 5066 | /// The task in question does not hold receive rights | ||
| 5067 | /// for the port argument. | ||
| 5068 | NOT_RECEIVER = 7, | ||
| 5069 | /// Bogus access restriction. | ||
| 5070 | NO_ACCESS = 8, | ||
| 5071 | /// During a page fault, the target address refers to a | ||
| 5072 | /// memory object that has been destroyed. This | ||
| 5073 | /// failure is permanent. | ||
| 5074 | MEMORY_FAILURE = 9, | ||
| 5075 | /// During a page fault, the memory object indicated | ||
| 5076 | /// that the data could not be returned. This failure | ||
| 5077 | /// may be temporary; future attempts to access this | ||
| 5078 | /// same data may succeed, as defined by the memory | ||
| 5079 | /// object. | ||
| 5080 | MEMORY_ERROR = 10, | ||
| 5081 | /// The receive right is already a member of the portset. | ||
| 5082 | ALREADY_IN_SET = 11, | ||
| 5083 | /// The receive right is not a member of a port set. | ||
| 5084 | NOT_IN_SET = 12, | ||
| 5085 | /// The name already denotes a right in the task. | ||
| 5086 | NAME_EXISTS = 13, | ||
| 5087 | /// The operation was aborted. Ipc code will | ||
| 5088 | /// catch this and reflect it as a message error. | ||
| 5089 | ABORTED = 14, | ||
| 5090 | /// The name doesn't denote a right in the task. | ||
| 5091 | INVALID_NAME = 15, | ||
| 5092 | /// Target task isn't an active task. | ||
| 5093 | INVALID_TASK = 16, | ||
| 5094 | /// The name denotes a right, but not an appropriate right. | ||
| 5095 | INVALID_RIGHT = 17, | ||
| 5096 | /// A blatant range error. | ||
| 5097 | INVALID_VALUE = 18, | ||
| 5098 | /// Operation would overflow limit on user-references. | ||
| 5099 | UREFS_OVERFLOW = 19, | ||
| 5100 | /// The supplied (port) capability is improper. | ||
| 5101 | INVALID_CAPABILITY = 20, | ||
| 5102 | /// The task already has send or receive rights | ||
| 5103 | /// for the port under another name. | ||
| 5104 | RIGHT_EXISTS = 21, | ||
| 5105 | /// Target host isn't actually a host. | ||
| 5106 | INVALID_HOST = 22, | ||
| 5107 | /// An attempt was made to supply "precious" data | ||
| 5108 | /// for memory that is already present in a | ||
| 5109 | /// memory object. | ||
| 5110 | MEMORY_PRESENT = 23, | ||
| 5111 | /// A page was requested of a memory manager via | ||
| 5112 | /// memory_object_data_request for an object using | ||
| 5113 | /// a MEMORY_OBJECT_COPY_CALL strategy, with the | ||
| 5114 | /// VM_PROT_WANTS_COPY flag being used to specify | ||
| 5115 | /// that the page desired is for a copy of the | ||
| 5116 | /// object, and the memory manager has detected | ||
| 5117 | /// the page was pushed into a copy of the object | ||
| 5118 | /// while the kernel was walking the shadow chain | ||
| 5119 | /// from the copy to the object. This error code | ||
| 5120 | /// is delivered via memory_object_data_error | ||
| 5121 | /// and is handled by the kernel (it forces the | ||
| 5122 | /// kernel to restart the fault). It will not be | ||
| 5123 | /// seen by users. | ||
| 5124 | MEMORY_DATA_MOVED = 24, | ||
| 5125 | /// A strategic copy was attempted of an object | ||
| 5126 | /// upon which a quicker copy is now possible. | ||
| 5127 | /// The caller should retry the copy using | ||
| 5128 | /// vm_object_copy_quickly. This error code | ||
| 5129 | /// is seen only by the kernel. | ||
| 5130 | MEMORY_RESTART_COPY = 25, | ||
| 5131 | /// An argument applied to assert processor set privilege | ||
| 5132 | /// was not a processor set control port. | ||
| 5133 | INVALID_PROCESSOR_SET = 26, | ||
| 5134 | /// The specified scheduling attributes exceed the thread's | ||
| 5135 | /// limits. | ||
| 5136 | POLICY_LIMIT = 27, | ||
| 5137 | /// The specified scheduling policy is not currently | ||
| 5138 | /// enabled for the processor set. | ||
| 5139 | INVALID_POLICY = 28, | ||
| 5140 | /// The external memory manager failed to initialize the | ||
| 5141 | /// memory object. | ||
| 5142 | INVALID_OBJECT = 29, | ||
| 5143 | /// A thread is attempting to wait for an event for which | ||
| 5144 | /// there is already a waiting thread. | ||
| 5145 | ALREADY_WAITING = 30, | ||
| 5146 | /// An attempt was made to destroy the default processor | ||
| 5147 | /// set. | ||
| 5148 | DEFAULT_SET = 31, | ||
| 5149 | /// An attempt was made to fetch an exception port that is | ||
| 5150 | /// protected, or to abort a thread while processing a | ||
| 5151 | /// protected exception. | ||
| 5152 | EXCEPTION_PROTECTED = 32, | ||
| 5153 | /// A ledger was required but not supplied. | ||
| 5154 | INVALID_LEDGER = 33, | ||
| 5155 | /// The port was not a memory cache control port. | ||
| 5156 | INVALID_MEMORY_CONTROL = 34, | ||
| 5157 | /// An argument supplied to assert security privilege | ||
| 5158 | /// was not a host security port. | ||
| 5159 | INVALID_SECURITY = 35, | ||
| 5160 | /// thread_depress_abort was called on a thread which | ||
| 5161 | /// was not currently depressed. | ||
| 5162 | NOT_DEPRESSED = 36, | ||
| 5163 | /// Object has been terminated and is no longer available | ||
| 5164 | TERMINATED = 37, | ||
| 5165 | /// Lock set has been destroyed and is no longer available. | ||
| 5166 | LOCK_SET_DESTROYED = 38, | ||
| 5167 | /// The thread holding the lock terminated before releasing | ||
| 5168 | /// the lock | ||
| 5169 | LOCK_UNSTABLE = 39, | ||
| 5170 | /// The lock is already owned by another thread | ||
| 5171 | LOCK_OWNED = 40, | ||
| 5172 | /// The lock is already owned by the calling thread | ||
| 5173 | LOCK_OWNED_SELF = 41, | ||
| 5174 | /// Semaphore has been destroyed and is no longer available. | ||
| 5175 | SEMAPHORE_DESTROYED = 42, | ||
| 5176 | /// Return from RPC indicating the target server was | ||
| 5177 | /// terminated before it successfully replied | ||
| 5178 | RPC_SERVER_TERMINATED = 43, | ||
| 5179 | /// Terminate an orphaned activation. | ||
| 5180 | RPC_TERMINATE_ORPHAN = 44, | ||
| 5181 | /// Allow an orphaned activation to continue executing. | ||
| 5182 | RPC_CONTINUE_ORPHAN = 45, | ||
| 5183 | /// Empty thread activation (No thread linked to it) | ||
| 5184 | NOT_SUPPORTED = 46, | ||
| 5185 | /// Remote node down or inaccessible. | ||
| 5186 | NODE_DOWN = 47, | ||
| 5187 | /// A signalled thread was not actually waiting. | ||
| 5188 | NOT_WAITING = 48, | ||
| 5189 | /// Some thread-oriented operation (semaphore_wait) timed out | ||
| 5190 | OPERATION_TIMED_OUT = 49, | ||
| 5191 | /// During a page fault, indicates that the page was rejected | ||
| 5192 | /// as a result of a signature check. | ||
| 5193 | CODESIGN_ERROR = 50, | ||
| 5194 | /// The requested property cannot be changed at this time. | ||
| 5195 | POLICY_STATIC = 51, | ||
| 5196 | /// The provided buffer is of insufficient size for the requested data. | ||
| 5197 | INSUFFICIENT_BUFFER_SIZE = 52, | ||
| 5198 | /// Denied by security policy | ||
| 5199 | DENIED = 53, | ||
| 5200 | /// The KC on which the function is operating is missing | ||
| 5201 | MISSING_KC = 54, | ||
| 5202 | /// The KC on which the function is operating is invalid | ||
| 5203 | INVALID_KC = 55, | ||
| 5204 | /// A search or query operation did not return a result | ||
| 5205 | NOT_FOUND = 56, | ||
| 5206 | _, | ||
| 5207 | }; |