| 1 | const builtin = @import("builtin"); |
| 2 | const native_abi = builtin.abi; |
| 3 | const native_arch = builtin.cpu.arch; |
| 4 | const native_os = builtin.os.tag; |
| 5 | const native_endian = builtin.cpu.arch.endian(); |
| 6 | |
| 7 | const std = @import("std"); |
| 8 | const c = @This(); |
| 9 | const maxInt = std.math.maxInt; |
| 10 | const assert = std.debug.assert; |
| 11 | const page_size = std.heap.page_size_min; |
| 12 | const linux = std.os.linux; |
| 13 | const emscripten = std.os.emscripten; |
| 14 | const wasi = std.os.wasi; |
| 15 | const windows = std.os.windows; |
| 16 | const ws2_32 = std.os.windows.ws2_32; |
| 17 | const darwin = @import("c/darwin.zig"); |
| 18 | const freebsd = @import("c/freebsd.zig"); |
| 19 | const illumos = @import("c/illumos.zig"); |
| 20 | const netbsd = @import("c/netbsd.zig"); |
| 21 | const dragonfly = @import("c/dragonfly.zig"); |
| 22 | const haiku = @import("c/haiku.zig"); |
| 23 | const openbsd = @import("c/openbsd.zig"); |
| 24 | const serenity = @import("c/serenity.zig"); |
| 25 | |
| 26 | // These constants are shared among all operating systems even when not linking |
| 27 | // libc. |
| 28 | |
| 29 | pub const iovec = std.posix.iovec; |
| 30 | pub const iovec_const = std.posix.iovec_const; |
| 31 | pub const LOCK = std.posix.LOCK; |
| 32 | pub const winsize = std.posix.winsize; |
| 33 | |
| 34 | /// The value of the link editor defined symbol _MH_EXECUTE_SYM is the address |
| 35 | /// of the mach header in a Mach-O executable file type. It does not appear in |
| 36 | /// any file type other than a MH_EXECUTE file type. The type of the symbol is |
| 37 | /// absolute as the header is not part of any section. |
| 38 | /// This symbol is populated when linking the system's libc, which is guaranteed |
| 39 | /// on this operating system. However when building object files or libraries, |
| 40 | /// the system libc won't be linked until the final executable. So we |
| 41 | /// export a weak symbol here, to be overridden by the real one. |
| 42 | pub extern var _mh_execute_header: mach_hdr; |
| 43 | var dummy_execute_header: mach_hdr = undefined; |
| 44 | comptime { |
| 45 | if (native_os.isDarwin()) { |
| 46 | @export(&dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// * If not linking libc, returns `false`. |
| 51 | /// * If linking musl libc, returns `true`. |
| 52 | /// * If linking GNU libc (glibc), returns `true` if the target version is greater than or equal to |
| 53 | /// `version`. |
| 54 | /// * If linking Android libc (bionic), returns `true` if the target API level is greater than or |
| 55 | /// equal to `version.major`, ignoring other components. |
| 56 | /// * If linking a libc other than these, returns `false`. |
| 57 | pub inline fn versionCheck(comptime version: std.SemanticVersion) bool { |
| 58 | return comptime blk: { |
| 59 | if (!builtin.link_libc) break :blk false; |
| 60 | if (native_abi.isMusl()) break :blk true; |
| 61 | if (builtin.target.isGnuLibC()) { |
| 62 | const ver = builtin.os.versionRange().gnuLibCVersion().?; |
| 63 | break :blk switch (ver.order(version)) { |
| 64 | .gt, .eq => true, |
| 65 | .lt => false, |
| 66 | }; |
| 67 | } else if (builtin.abi.isAndroid()) { |
| 68 | break :blk builtin.os.version_range.linux.android >= version.major; |
| 69 | } else { |
| 70 | break :blk false; |
| 71 | } |
| 72 | }; |
| 73 | } |
| 74 | |
| 75 | /// Get the errno if rc is -1 and SUCCESS if rc is not -1. |
| 76 | pub fn errno(rc: anytype) E { |
| 77 | return if (rc == -1) @fromBackingInt(@intCast(_errno().*)) else .SUCCESS; |
| 78 | } |
| 79 | |
| 80 | pub const ino_t = switch (native_os) { |
| 81 | .linux => linux.ino_t, |
| 82 | .emscripten => emscripten.ino_t, |
| 83 | .wasi => wasi.inode_t, |
| 84 | .windows => windows.LARGE_INTEGER, |
| 85 | .haiku => i64, |
| 86 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L38 |
| 87 | else => u64, |
| 88 | }; |
| 89 | |
| 90 | pub const off_t = switch (native_os) { |
| 91 | .linux => linux.off_t, |
| 92 | .emscripten => emscripten.off_t, |
| 93 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L39 |
| 94 | else => i64, |
| 95 | }; |
| 96 | |
| 97 | /// For use with `utimensat` and `futimens`. |
| 98 | pub const UTIME = switch (native_os) { |
| 99 | .dragonfly, .freebsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .wasi => struct { |
| 100 | pub const NOW: timespec = .{ .sec = 0, .nsec = -1 }; |
| 101 | pub const OMIT: timespec = .{ .sec = 0, .nsec = -2 }; |
| 102 | }, |
| 103 | .emscripten => emscripten.UTIME, |
| 104 | .haiku => struct { |
| 105 | pub const NOW: timespec = .{ .sec = 0, .nsec = 1000000000 }; |
| 106 | pub const OMIT: timespec = .{ .sec = 0, .nsec = 1000000001 }; |
| 107 | }, |
| 108 | .linux => linux.UTIME, |
| 109 | .netbsd => struct { |
| 110 | pub const NOW: timespec = .{ .sec = 0, .nsec = 0x3fffffff }; |
| 111 | pub const OMIT: timespec = .{ .sec = 0, .nsec = 0x3ffffffe }; |
| 112 | }, |
| 113 | .openbsd, .serenity => struct { |
| 114 | pub const NOW: timespec = .{ .sec = 0, .nsec = -2 }; |
| 115 | pub const OMIT: timespec = .{ .sec = 0, .nsec = -1 }; |
| 116 | }, |
| 117 | else => void, |
| 118 | }; |
| 119 | |
| 120 | pub const timespec = switch (native_os) { |
| 121 | .linux => linux.timespec, |
| 122 | .emscripten => emscripten.timespec, |
| 123 | // lib/libc/include/wasm-wasi-musl/__struct_timespec.h |
| 124 | .wasi => extern struct { |
| 125 | sec: time_t, |
| 126 | nsec: c_long, |
| 127 | |
| 128 | pub fn fromTimestamp(tm: wasi.timestamp_t) timespec { |
| 129 | const sec: wasi.timestamp_t = tm / 1_000_000_000; |
| 130 | const nsec = tm - sec * 1_000_000_000; |
| 131 | return .{ |
| 132 | .sec = @as(time_t, @intCast(sec)), |
| 133 | .nsec = @as(isize, @intCast(nsec)), |
| 134 | }; |
| 135 | } |
| 136 | |
| 137 | pub fn toTimestamp(ts: timespec) wasi.timestamp_t { |
| 138 | return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) + |
| 139 | @as(wasi.timestamp_t, @intCast(ts.nsec)); |
| 140 | } |
| 141 | }, |
| 142 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20 |
| 143 | .dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .haiku, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows => extern struct { |
| 144 | sec: time_t, |
| 145 | nsec: c_long, |
| 146 | }, |
| 147 | else => void, |
| 148 | }; |
| 149 | |
| 150 | pub const dev_t = switch (native_os) { |
| 151 | .emscripten => emscripten.dev_t, |
| 152 | .wasi => wasi.device_t, |
| 153 | .openbsd, .haiku, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => i32, |
| 154 | // glibc and musl define dev_t as u64, while in Linux kernel it is u32. |
| 155 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L43 |
| 156 | .linux, .netbsd, .freebsd, .serenity => u64, |
| 157 | else => void, |
| 158 | }; |
| 159 | |
| 160 | pub const mode_t = switch (native_os) { |
| 161 | .linux => linux.mode_t, |
| 162 | .emscripten => emscripten.mode_t, |
| 163 | .openbsd, .haiku, .netbsd, .illumos, .windows => u32, |
| 164 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L44 |
| 165 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .dragonfly, .serenity => u16, |
| 166 | .wasi => if (builtin.link_libc) u32 else u0, // WASI libc emulates mode. |
| 167 | else => u0, |
| 168 | }; |
| 169 | |
| 170 | pub const nlink_t = switch (native_os) { |
| 171 | .linux => linux.nlink_t, |
| 172 | .emscripten => emscripten.nlink_t, |
| 173 | .wasi => c_ulonglong, |
| 174 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L45 |
| 175 | .freebsd, .serenity => u64, |
| 176 | .openbsd, .netbsd, .dragonfly, .illumos, .windows => u32, |
| 177 | .haiku => i32, |
| 178 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u16, |
| 179 | else => u0, |
| 180 | }; |
| 181 | |
| 182 | pub const uid_t = switch (native_os) { |
| 183 | .linux => linux.uid_t, |
| 184 | .emscripten => emscripten.uid_t, |
| 185 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L28 |
| 186 | else => u32, |
| 187 | }; |
| 188 | |
| 189 | pub const gid_t = switch (native_os) { |
| 190 | .linux => linux.gid_t, |
| 191 | .emscripten => emscripten.gid_t, |
| 192 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L29 |
| 193 | else => u32, |
| 194 | }; |
| 195 | |
| 196 | pub const blksize_t = switch (native_os) { |
| 197 | .linux => linux.blksize_t, |
| 198 | .emscripten => emscripten.blksize_t, |
| 199 | .wasi => c_long, |
| 200 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L42 |
| 201 | .serenity => u64, |
| 202 | else => i32, |
| 203 | }; |
| 204 | |
| 205 | pub const passwd = switch (native_os) { |
| 206 | // https://github.com/SerenityOS/serenity/blob/7442cfb5072b74a62c0e061e6e9ff44fda08780d/Userland/Libraries/LibC/pwd.h#L15-L23 |
| 207 | .linux, .serenity => extern struct { |
| 208 | name: ?[*:0]const u8, // username |
| 209 | passwd: ?[*:0]const u8, // user password |
| 210 | uid: uid_t, // user ID |
| 211 | gid: gid_t, // group ID |
| 212 | gecos: ?[*:0]const u8, // user information |
| 213 | dir: ?[*:0]const u8, // home directory |
| 214 | shell: ?[*:0]const u8, // shell program |
| 215 | }, |
| 216 | .netbsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 217 | name: ?[*:0]const u8, // user name |
| 218 | passwd: ?[*:0]const u8, // encrypted password |
| 219 | uid: uid_t, // user uid |
| 220 | gid: gid_t, // user gid |
| 221 | change: time_t, // password change time |
| 222 | class: ?[*:0]const u8, // user access class |
| 223 | gecos: ?[*:0]const u8, // Honeywell login info |
| 224 | dir: ?[*:0]const u8, // home directory |
| 225 | shell: ?[*:0]const u8, // default shell |
| 226 | expire: time_t, // account expiration |
| 227 | }, |
| 228 | .dragonfly, .freebsd => extern struct { |
| 229 | name: ?[*:0]const u8, // user name |
| 230 | passwd: ?[*:0]const u8, // encrypted password |
| 231 | uid: uid_t, // user uid |
| 232 | gid: gid_t, // user gid |
| 233 | change: time_t, // password change time |
| 234 | class: ?[*:0]const u8, // user access class |
| 235 | gecos: ?[*:0]const u8, // Honeywell login info |
| 236 | dir: ?[*:0]const u8, // home directory |
| 237 | shell: ?[*:0]const u8, // default shell |
| 238 | expire: time_t, // account expiration |
| 239 | fields: c_int, // internal |
| 240 | }, |
| 241 | else => void, |
| 242 | }; |
| 243 | |
| 244 | pub const group = switch (native_os) { |
| 245 | .linux, .freebsd, .openbsd, .dragonfly, .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 246 | name: ?[*:0]const u8, |
| 247 | passwd: ?[*:0]const u8, |
| 248 | gid: gid_t, |
| 249 | mem: [*:null]?[*:0]const u8, |
| 250 | }, |
| 251 | else => void, |
| 252 | }; |
| 253 | |
| 254 | pub const blkcnt_t = switch (native_os) { |
| 255 | .linux => linux.blkcnt_t, |
| 256 | .emscripten => emscripten.blkcnt_t, |
| 257 | .wasi => c_longlong, |
| 258 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L41 |
| 259 | .serenity => u64, |
| 260 | else => i64, |
| 261 | }; |
| 262 | |
| 263 | pub const fd_t = switch (native_os) { |
| 264 | .linux => linux.fd_t, |
| 265 | .wasi => wasi.fd_t, |
| 266 | .windows => windows.HANDLE, |
| 267 | .serenity => c_int, |
| 268 | else => i32, |
| 269 | }; |
| 270 | |
| 271 | pub const ARCH = switch (native_os) { |
| 272 | .linux => linux.ARCH, |
| 273 | else => void, |
| 274 | }; |
| 275 | |
| 276 | // For use with posix.timerfd_create() |
| 277 | // Actually, the parameter for the timerfd_create() function is an integer, |
| 278 | // which means that the developer has to figure out which value is appropriate. |
| 279 | // To make this easier and, above all, safer, because an incorrect value leads |
| 280 | // to a panic, an enum is introduced which only allows the values |
| 281 | // that actually work. |
| 282 | pub const TIMERFD_CLOCK = timerfd_clockid_t; |
| 283 | pub const timerfd_clockid_t = switch (native_os) { |
| 284 | .freebsd => enum(u32) { |
| 285 | REALTIME = 0, |
| 286 | MONOTONIC = 4, |
| 287 | _, |
| 288 | }, |
| 289 | .linux => linux.timerfd_clockid_t, |
| 290 | else => clockid_t, |
| 291 | }; |
| 292 | |
| 293 | pub const CLOCK = clockid_t; |
| 294 | pub const clockid_t = switch (native_os) { |
| 295 | .linux, .emscripten => linux.clockid_t, |
| 296 | .wasi => wasi.clockid_t, |
| 297 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(u32) { |
| 298 | REALTIME = 0, |
| 299 | MONOTONIC = 6, |
| 300 | MONOTONIC_RAW = 4, |
| 301 | MONOTONIC_RAW_APPROX = 5, |
| 302 | UPTIME_RAW = 8, |
| 303 | UPTIME_RAW_APPROX = 9, |
| 304 | PROCESS_CPUTIME_ID = 12, |
| 305 | THREAD_CPUTIME_ID = 16, |
| 306 | _, |
| 307 | }, |
| 308 | .haiku => enum(i32) { |
| 309 | /// system-wide monotonic clock (aka system time) |
| 310 | MONOTONIC = 0, |
| 311 | /// system-wide real time clock |
| 312 | REALTIME = -1, |
| 313 | /// clock measuring the used CPU time of the current process |
| 314 | PROCESS_CPUTIME_ID = -2, |
| 315 | /// clock measuring the used CPU time of the current thread |
| 316 | THREAD_CPUTIME_ID = -3, |
| 317 | }, |
| 318 | .freebsd => enum(u32) { |
| 319 | REALTIME = 0, |
| 320 | VIRTUAL = 1, |
| 321 | PROF = 2, |
| 322 | MONOTONIC = 4, |
| 323 | UPTIME = 5, |
| 324 | UPTIME_PRECISE = 7, |
| 325 | UPTIME_FAST = 8, |
| 326 | REALTIME_PRECISE = 9, |
| 327 | REALTIME_FAST = 10, |
| 328 | MONOTONIC_PRECISE = 11, |
| 329 | MONOTONIC_FAST = 12, |
| 330 | SECOND = 13, |
| 331 | THREAD_CPUTIME_ID = 14, |
| 332 | PROCESS_CPUTIME_ID = 15, |
| 333 | }, |
| 334 | .illumos => enum(u32) { |
| 335 | VIRTUAL = 1, |
| 336 | THREAD_CPUTIME_ID = 2, |
| 337 | REALTIME = 3, |
| 338 | MONOTONIC = 4, |
| 339 | PROCESS_CPUTIME_ID = 5, |
| 340 | }, |
| 341 | .netbsd => enum(u32) { |
| 342 | REALTIME = 0, |
| 343 | VIRTUAL = 1, |
| 344 | PROF = 2, |
| 345 | MONOTONIC = 3, |
| 346 | THREAD_CPUTIME_ID = 0x20000000, |
| 347 | PROCESS_CPUTIME_ID = 0x40000000, |
| 348 | }, |
| 349 | .dragonfly => enum(u32) { |
| 350 | REALTIME = 0, |
| 351 | VIRTUAL = 1, |
| 352 | PROF = 2, |
| 353 | MONOTONIC = 4, |
| 354 | UPTIME = 5, |
| 355 | UPTIME_PRECISE = 7, |
| 356 | UPTIME_FAST = 8, |
| 357 | REALTIME_PRECISE = 9, |
| 358 | REALTIME_FAST = 10, |
| 359 | MONOTONIC_PRECISE = 11, |
| 360 | MONOTONIC_FAST = 12, |
| 361 | SECOND = 13, |
| 362 | THREAD_CPUTIME_ID = 14, |
| 363 | PROCESS_CPUTIME_ID = 15, |
| 364 | }, |
| 365 | .openbsd => enum(u32) { |
| 366 | REALTIME = 0, |
| 367 | PROCESS_CPUTIME_ID = 2, |
| 368 | MONOTONIC = 3, |
| 369 | THREAD_CPUTIME_ID = 4, |
| 370 | }, |
| 371 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L24-L36 |
| 372 | .serenity => enum(c_int) { |
| 373 | REALTIME = 0, |
| 374 | MONOTONIC = 1, |
| 375 | MONOTONIC_RAW = 2, |
| 376 | REALTIME_COARSE = 3, |
| 377 | MONOTONIC_COARSE = 4, |
| 378 | }, |
| 379 | else => void, |
| 380 | }; |
| 381 | pub const CPU_COUNT = switch (native_os) { |
| 382 | .linux => linux.CPU_COUNT, |
| 383 | .emscripten => emscripten.CPU_COUNT, |
| 384 | else => void, |
| 385 | }; |
| 386 | pub const E = switch (native_os) { |
| 387 | .linux => linux.E, |
| 388 | .emscripten => emscripten.E, |
| 389 | .wasi => wasi.errno_t, |
| 390 | .windows => enum(u16) { |
| 391 | /// No error occurred. |
| 392 | SUCCESS = 0, |
| 393 | PERM = 1, |
| 394 | NOENT = 2, |
| 395 | SRCH = 3, |
| 396 | INTR = 4, |
| 397 | IO = 5, |
| 398 | NXIO = 6, |
| 399 | @"2BIG" = 7, |
| 400 | NOEXEC = 8, |
| 401 | BADF = 9, |
| 402 | CHILD = 10, |
| 403 | AGAIN = 11, |
| 404 | NOMEM = 12, |
| 405 | ACCES = 13, |
| 406 | FAULT = 14, |
| 407 | BUSY = 16, |
| 408 | EXIST = 17, |
| 409 | XDEV = 18, |
| 410 | NODEV = 19, |
| 411 | NOTDIR = 20, |
| 412 | ISDIR = 21, |
| 413 | NFILE = 23, |
| 414 | MFILE = 24, |
| 415 | NOTTY = 25, |
| 416 | FBIG = 27, |
| 417 | NOSPC = 28, |
| 418 | SPIPE = 29, |
| 419 | ROFS = 30, |
| 420 | MLINK = 31, |
| 421 | PIPE = 32, |
| 422 | DOM = 33, |
| 423 | /// Also means `DEADLOCK`. |
| 424 | DEADLK = 36, |
| 425 | NAMETOOLONG = 38, |
| 426 | NOLCK = 39, |
| 427 | NOSYS = 40, |
| 428 | NOTEMPTY = 41, |
| 429 | |
| 430 | INVAL = 22, |
| 431 | RANGE = 34, |
| 432 | ILSEQ = 42, |
| 433 | |
| 434 | // POSIX Supplement |
| 435 | ADDRINUSE = 100, |
| 436 | ADDRNOTAVAIL = 101, |
| 437 | AFNOSUPPORT = 102, |
| 438 | ALREADY = 103, |
| 439 | BADMSG = 104, |
| 440 | CANCELED = 105, |
| 441 | CONNABORTED = 106, |
| 442 | CONNREFUSED = 107, |
| 443 | CONNRESET = 108, |
| 444 | DESTADDRREQ = 109, |
| 445 | HOSTUNREACH = 110, |
| 446 | IDRM = 111, |
| 447 | INPROGRESS = 112, |
| 448 | ISCONN = 113, |
| 449 | LOOP = 114, |
| 450 | MSGSIZE = 115, |
| 451 | NETDOWN = 116, |
| 452 | NETRESET = 117, |
| 453 | NETUNREACH = 118, |
| 454 | NOBUFS = 119, |
| 455 | NODATA = 120, |
| 456 | NOLINK = 121, |
| 457 | NOMSG = 122, |
| 458 | NOPROTOOPT = 123, |
| 459 | NOSR = 124, |
| 460 | NOSTR = 125, |
| 461 | NOTCONN = 126, |
| 462 | NOTRECOVERABLE = 127, |
| 463 | NOTSOCK = 128, |
| 464 | NOTSUP = 129, |
| 465 | OPNOTSUPP = 130, |
| 466 | OTHER = 131, |
| 467 | OVERFLOW = 132, |
| 468 | OWNERDEAD = 133, |
| 469 | PROTO = 134, |
| 470 | PROTONOSUPPORT = 135, |
| 471 | PROTOTYPE = 136, |
| 472 | TIME = 137, |
| 473 | TIMEDOUT = 138, |
| 474 | TXTBSY = 139, |
| 475 | WOULDBLOCK = 140, |
| 476 | DQUOT = 10069, |
| 477 | _, |
| 478 | }, |
| 479 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.E, |
| 480 | .freebsd => freebsd.E, |
| 481 | .illumos => enum(u16) { |
| 482 | /// No error occurred. |
| 483 | SUCCESS = 0, |
| 484 | /// Not super-user |
| 485 | PERM = 1, |
| 486 | /// No such file or directory |
| 487 | NOENT = 2, |
| 488 | /// No such process |
| 489 | SRCH = 3, |
| 490 | /// interrupted system call |
| 491 | INTR = 4, |
| 492 | /// I/O error |
| 493 | IO = 5, |
| 494 | /// No such device or address |
| 495 | NXIO = 6, |
| 496 | /// Arg list too long |
| 497 | @"2BIG" = 7, |
| 498 | /// Exec format error |
| 499 | NOEXEC = 8, |
| 500 | /// Bad file number |
| 501 | BADF = 9, |
| 502 | /// No children |
| 503 | CHILD = 10, |
| 504 | /// Resource temporarily unavailable. |
| 505 | /// also: WOULDBLOCK: Operation would block. |
| 506 | AGAIN = 11, |
| 507 | /// Not enough core |
| 508 | NOMEM = 12, |
| 509 | /// Permission denied |
| 510 | ACCES = 13, |
| 511 | /// Bad address |
| 512 | FAULT = 14, |
| 513 | /// Block device required |
| 514 | NOTBLK = 15, |
| 515 | /// Mount device busy |
| 516 | BUSY = 16, |
| 517 | /// File exists |
| 518 | EXIST = 17, |
| 519 | /// Cross-device link |
| 520 | XDEV = 18, |
| 521 | /// No such device |
| 522 | NODEV = 19, |
| 523 | /// Not a directory |
| 524 | NOTDIR = 20, |
| 525 | /// Is a directory |
| 526 | ISDIR = 21, |
| 527 | /// Invalid argument |
| 528 | INVAL = 22, |
| 529 | /// File table overflow |
| 530 | NFILE = 23, |
| 531 | /// Too many open files |
| 532 | MFILE = 24, |
| 533 | /// Inappropriate ioctl for device |
| 534 | NOTTY = 25, |
| 535 | /// Text file busy |
| 536 | TXTBSY = 26, |
| 537 | /// File too large |
| 538 | FBIG = 27, |
| 539 | /// No space left on device |
| 540 | NOSPC = 28, |
| 541 | /// Illegal seek |
| 542 | SPIPE = 29, |
| 543 | /// Read only file system |
| 544 | ROFS = 30, |
| 545 | /// Too many links |
| 546 | MLINK = 31, |
| 547 | /// Broken pipe |
| 548 | PIPE = 32, |
| 549 | /// Math arg out of domain of func |
| 550 | DOM = 33, |
| 551 | /// Math result not representable |
| 552 | RANGE = 34, |
| 553 | /// No message of desired type |
| 554 | NOMSG = 35, |
| 555 | /// Identifier removed |
| 556 | IDRM = 36, |
| 557 | /// Channel number out of range |
| 558 | CHRNG = 37, |
| 559 | /// Level 2 not synchronized |
| 560 | L2NSYNC = 38, |
| 561 | /// Level 3 halted |
| 562 | L3HLT = 39, |
| 563 | /// Level 3 reset |
| 564 | L3RST = 40, |
| 565 | /// Link number out of range |
| 566 | LNRNG = 41, |
| 567 | /// Protocol driver not attached |
| 568 | UNATCH = 42, |
| 569 | /// No CSI structure available |
| 570 | NOCSI = 43, |
| 571 | /// Level 2 halted |
| 572 | L2HLT = 44, |
| 573 | /// Deadlock condition. |
| 574 | DEADLK = 45, |
| 575 | /// No record locks available. |
| 576 | NOLCK = 46, |
| 577 | /// Operation canceled |
| 578 | CANCELED = 47, |
| 579 | /// Operation not supported |
| 580 | NOTSUP = 48, |
| 581 | |
| 582 | // Filesystem Quotas |
| 583 | /// Disc quota exceeded |
| 584 | DQUOT = 49, |
| 585 | |
| 586 | // Convergent Error Returns |
| 587 | /// invalid exchange |
| 588 | BADE = 50, |
| 589 | /// invalid request descriptor |
| 590 | BADR = 51, |
| 591 | /// exchange full |
| 592 | XFULL = 52, |
| 593 | /// no anode |
| 594 | NOANO = 53, |
| 595 | /// invalid request code |
| 596 | BADRQC = 54, |
| 597 | /// invalid slot |
| 598 | BADSLT = 55, |
| 599 | /// file locking deadlock error |
| 600 | DEADLOCK = 56, |
| 601 | /// bad font file fmt |
| 602 | BFONT = 57, |
| 603 | |
| 604 | // Interprocess Robust Locks |
| 605 | /// process died with the lock |
| 606 | OWNERDEAD = 58, |
| 607 | /// lock is not recoverable |
| 608 | NOTRECOVERABLE = 59, |
| 609 | /// locked lock was unmapped |
| 610 | LOCKUNMAPPED = 72, |
| 611 | /// Facility is not active |
| 612 | NOTACTIVE = 73, |
| 613 | /// multihop attempted |
| 614 | MULTIHOP = 74, |
| 615 | /// trying to read unreadable message |
| 616 | BADMSG = 77, |
| 617 | /// path name is too long |
| 618 | NAMETOOLONG = 78, |
| 619 | /// value too large to be stored in data type |
| 620 | OVERFLOW = 79, |
| 621 | /// given log. name not unique |
| 622 | NOTUNIQ = 80, |
| 623 | /// f.d. invalid for this operation |
| 624 | BADFD = 81, |
| 625 | /// Remote address changed |
| 626 | REMCHG = 82, |
| 627 | |
| 628 | // Stream Problems |
| 629 | /// Device not a stream |
| 630 | NOSTR = 60, |
| 631 | /// no data (for no delay io) |
| 632 | NODATA = 61, |
| 633 | /// timer expired |
| 634 | TIME = 62, |
| 635 | /// out of streams resources |
| 636 | NOSR = 63, |
| 637 | /// Machine is not on the network |
| 638 | NONET = 64, |
| 639 | /// Package not installed |
| 640 | NOPKG = 65, |
| 641 | /// The object is remote |
| 642 | REMOTE = 66, |
| 643 | /// the link has been severed |
| 644 | NOLINK = 67, |
| 645 | /// advertise error |
| 646 | ADV = 68, |
| 647 | /// srmount error |
| 648 | SRMNT = 69, |
| 649 | /// Communication error on send |
| 650 | COMM = 70, |
| 651 | /// Protocol error |
| 652 | PROTO = 71, |
| 653 | |
| 654 | // Shared Library Problems |
| 655 | /// Can't access a needed shared lib. |
| 656 | LIBACC = 83, |
| 657 | /// Accessing a corrupted shared lib. |
| 658 | LIBBAD = 84, |
| 659 | /// .lib section in a.out corrupted. |
| 660 | LIBSCN = 85, |
| 661 | /// Attempting to link in too many libs. |
| 662 | LIBMAX = 86, |
| 663 | /// Attempting to exec a shared library. |
| 664 | LIBEXEC = 87, |
| 665 | /// Illegal byte sequence. |
| 666 | ILSEQ = 88, |
| 667 | /// Unsupported file system operation |
| 668 | NOSYS = 89, |
| 669 | /// Symbolic link loop |
| 670 | LOOP = 90, |
| 671 | /// Restartable system call |
| 672 | RESTART = 91, |
| 673 | /// if pipe/FIFO, don't sleep in stream head |
| 674 | STRPIPE = 92, |
| 675 | /// directory not empty |
| 676 | NOTEMPTY = 93, |
| 677 | /// Too many users (for UFS) |
| 678 | USERS = 94, |
| 679 | |
| 680 | // BSD Networking Software |
| 681 | // Argument Errors |
| 682 | /// Socket operation on non-socket |
| 683 | NOTSOCK = 95, |
| 684 | /// Destination address required |
| 685 | DESTADDRREQ = 96, |
| 686 | /// Message too long |
| 687 | MSGSIZE = 97, |
| 688 | /// Protocol wrong type for socket |
| 689 | PROTOTYPE = 98, |
| 690 | /// Protocol not available |
| 691 | NOPROTOOPT = 99, |
| 692 | /// Protocol not supported |
| 693 | PROTONOSUPPORT = 120, |
| 694 | /// Socket type not supported |
| 695 | SOCKTNOSUPPORT = 121, |
| 696 | /// Operation not supported on socket |
| 697 | OPNOTSUPP = 122, |
| 698 | /// Protocol family not supported |
| 699 | PFNOSUPPORT = 123, |
| 700 | /// Address family not supported by |
| 701 | AFNOSUPPORT = 124, |
| 702 | /// Address already in use |
| 703 | ADDRINUSE = 125, |
| 704 | /// Can't assign requested address |
| 705 | ADDRNOTAVAIL = 126, |
| 706 | |
| 707 | // Operational Errors |
| 708 | /// Network is down |
| 709 | NETDOWN = 127, |
| 710 | /// Network is unreachable |
| 711 | NETUNREACH = 128, |
| 712 | /// Network dropped connection because |
| 713 | NETRESET = 129, |
| 714 | /// Software caused connection abort |
| 715 | CONNABORTED = 130, |
| 716 | /// Connection reset by peer |
| 717 | CONNRESET = 131, |
| 718 | /// No buffer space available |
| 719 | NOBUFS = 132, |
| 720 | /// Socket is already connected |
| 721 | ISCONN = 133, |
| 722 | /// Socket is not connected |
| 723 | NOTCONN = 134, |
| 724 | /// Can't send after socket shutdown |
| 725 | SHUTDOWN = 143, |
| 726 | /// Too many references: can't splice |
| 727 | TOOMANYREFS = 144, |
| 728 | /// Connection timed out |
| 729 | TIMEDOUT = 145, |
| 730 | /// Connection refused |
| 731 | CONNREFUSED = 146, |
| 732 | /// Host is down |
| 733 | HOSTDOWN = 147, |
| 734 | /// No route to host |
| 735 | HOSTUNREACH = 148, |
| 736 | /// operation already in progress |
| 737 | ALREADY = 149, |
| 738 | /// operation now in progress |
| 739 | INPROGRESS = 150, |
| 740 | |
| 741 | // SUN Network File System |
| 742 | /// Stale NFS file handle |
| 743 | STALE = 151, |
| 744 | |
| 745 | _, |
| 746 | }, |
| 747 | .netbsd => netbsd.E, |
| 748 | .dragonfly => dragonfly.E, |
| 749 | .haiku => haiku.E, |
| 750 | .openbsd => openbsd.E, |
| 751 | // https://github.com/SerenityOS/serenity/blob/dd59fe35c7e5bbaf6b6b3acb3f9edc56619d4b66/Kernel/API/POSIX/errno.h |
| 752 | .serenity => enum(c_int) { |
| 753 | SUCCESS = 0, |
| 754 | PERM = 1, |
| 755 | NOENT = 2, |
| 756 | SRCH = 3, |
| 757 | INTR = 4, |
| 758 | IO = 5, |
| 759 | NXIO = 6, |
| 760 | @"2BIG" = 7, |
| 761 | NOEXEC = 8, |
| 762 | BADF = 9, |
| 763 | CHILD = 10, |
| 764 | AGAIN = 11, |
| 765 | NOMEM = 12, |
| 766 | ACCES = 13, |
| 767 | FAULT = 14, |
| 768 | NOTBLK = 15, |
| 769 | BUSY = 16, |
| 770 | EXIST = 17, |
| 771 | XDEV = 18, |
| 772 | NODEV = 19, |
| 773 | NOTDIR = 20, |
| 774 | ISDIR = 21, |
| 775 | INVAL = 22, |
| 776 | NFILE = 23, |
| 777 | MFILE = 24, |
| 778 | NOTTY = 25, |
| 779 | TXTBSY = 26, |
| 780 | FBIG = 27, |
| 781 | NOSPC = 28, |
| 782 | SPIPE = 29, |
| 783 | ROFS = 30, |
| 784 | MLINK = 31, |
| 785 | PIPE = 32, |
| 786 | RANGE = 33, |
| 787 | NAMETOOLONG = 34, |
| 788 | LOOP = 35, |
| 789 | OVERFLOW = 36, |
| 790 | OPNOTSUPP = 37, |
| 791 | NOSYS = 38, |
| 792 | NOTIMPL = 39, |
| 793 | AFNOSUPPORT = 40, |
| 794 | NOTSOCK = 41, |
| 795 | ADDRINUSE = 42, |
| 796 | NOTEMPTY = 43, |
| 797 | DOM = 44, |
| 798 | CONNREFUSED = 45, |
| 799 | HOSTDOWN = 46, |
| 800 | ADDRNOTAVAIL = 47, |
| 801 | ISCONN = 48, |
| 802 | CONNABORTED = 49, |
| 803 | ALREADY = 50, |
| 804 | CONNRESET = 51, |
| 805 | DESTADDRREQ = 52, |
| 806 | HOSTUNREACH = 53, |
| 807 | ILSEQ = 54, |
| 808 | MSGSIZE = 55, |
| 809 | NETDOWN = 56, |
| 810 | NETUNREACH = 57, |
| 811 | NETRESET = 58, |
| 812 | NOBUFS = 59, |
| 813 | NOLCK = 60, |
| 814 | NOMSG = 61, |
| 815 | NOPROTOOPT = 62, |
| 816 | NOTCONN = 63, |
| 817 | SHUTDOWN = 64, |
| 818 | TOOMANYREFS = 65, |
| 819 | SOCKTNOSUPPORT = 66, |
| 820 | PROTONOSUPPORT = 67, |
| 821 | DEADLK = 68, |
| 822 | TIMEDOUT = 69, |
| 823 | PROTOTYPE = 70, |
| 824 | INPROGRESS = 71, |
| 825 | NOTHREAD = 72, |
| 826 | PROTO = 73, |
| 827 | NOTSUP = 74, |
| 828 | PFNOSUPPORT = 75, |
| 829 | DIRINTOSELF = 76, |
| 830 | DQUOT = 77, |
| 831 | NOTRECOVERABLE = 78, |
| 832 | CANCELED = 79, |
| 833 | PROMISEVIOLATION = 80, |
| 834 | STALE = 81, |
| 835 | SRCNOTFOUND = 82, |
| 836 | _, |
| 837 | }, |
| 838 | else => void, |
| 839 | }; |
| 840 | pub const Elf_Symndx = switch (native_os) { |
| 841 | .linux => linux.Elf_Symndx, |
| 842 | else => void, |
| 843 | }; |
| 844 | /// Command flags for fcntl(2). |
| 845 | pub const F = switch (native_os) { |
| 846 | .linux => linux.F, |
| 847 | .emscripten => emscripten.F, |
| 848 | .wasi => struct { |
| 849 | // Match `F_*` constants from lib/libc/include/wasm-wasi-musl/__header_fcntl.h |
| 850 | pub const GETFD = 1; |
| 851 | pub const SETFD = 2; |
| 852 | pub const GETFL = 3; |
| 853 | pub const SETFL = 4; |
| 854 | }, |
| 855 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 856 | /// duplicate file descriptor |
| 857 | pub const DUPFD = 0; |
| 858 | /// get file descriptor flags |
| 859 | pub const GETFD = 1; |
| 860 | /// set file descriptor flags |
| 861 | pub const SETFD = 2; |
| 862 | /// get file status flags |
| 863 | pub const GETFL = 3; |
| 864 | /// set file status flags |
| 865 | pub const SETFL = 4; |
| 866 | /// get SIGIO/SIGURG proc/pgrp |
| 867 | pub const GETOWN = 5; |
| 868 | /// set SIGIO/SIGURG proc/pgrp |
| 869 | pub const SETOWN = 6; |
| 870 | /// get record locking information |
| 871 | pub const GETLK = 7; |
| 872 | /// set record locking information |
| 873 | pub const SETLK = 8; |
| 874 | /// F.SETLK; wait if blocked |
| 875 | pub const SETLKW = 9; |
| 876 | /// F.SETLK; wait if blocked, return on timeout |
| 877 | pub const SETLKWTIMEOUT = 10; |
| 878 | pub const FLUSH_DATA = 40; |
| 879 | /// Used for regression test |
| 880 | pub const CHKCLEAN = 41; |
| 881 | /// Preallocate storage |
| 882 | pub const PREALLOCATE = 42; |
| 883 | /// Truncate a file without zeroing space |
| 884 | pub const SETSIZE = 43; |
| 885 | /// Issue an advisory read async with no copy to user |
| 886 | pub const RDADVISE = 44; |
| 887 | /// turn read ahead off/on for this fd |
| 888 | pub const RDAHEAD = 45; |
| 889 | /// turn data caching off/on for this fd |
| 890 | pub const NOCACHE = 48; |
| 891 | /// file offset to device offset |
| 892 | pub const LOG2PHYS = 49; |
| 893 | /// return the full path of the fd |
| 894 | pub const GETPATH = 50; |
| 895 | /// fsync + ask the drive to flush to the media |
| 896 | pub const FULLFSYNC = 51; |
| 897 | /// find which component (if any) is a package |
| 898 | pub const PATHPKG_CHECK = 52; |
| 899 | /// "freeze" all fs operations |
| 900 | pub const FREEZE_FS = 53; |
| 901 | /// "thaw" all fs operations |
| 902 | pub const THAW_FS = 54; |
| 903 | /// turn data caching off/on (globally) for this file |
| 904 | pub const GLOBAL_NOCACHE = 55; |
| 905 | /// add detached signatures |
| 906 | pub const ADDSIGS = 59; |
| 907 | /// add signature from same file (used by dyld for shared libs) |
| 908 | pub const ADDFILESIGS = 61; |
| 909 | /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchronous writes |
| 910 | /// should not be used (i.e. its ok to temporarily create cached pages) |
| 911 | pub const NODIRECT = 62; |
| 912 | /// Get the protection class of a file from the EA, returns int |
| 913 | pub const GETPROTECTIONCLASS = 63; |
| 914 | /// Set the protection class of a file for the EA, requires int |
| 915 | pub const SETPROTECTIONCLASS = 64; |
| 916 | /// file offset to device offset, extended |
| 917 | pub const LOG2PHYS_EXT = 65; |
| 918 | /// get record locking information, per-process |
| 919 | pub const GETLKPID = 66; |
| 920 | /// Mark the file as being the backing store for another filesystem |
| 921 | pub const SETBACKINGSTORE = 70; |
| 922 | /// return the full path of the FD, but error in specific mtmd circumstances |
| 923 | pub const GETPATH_MTMINFO = 71; |
| 924 | /// Returns the code directory, with associated hashes, to the caller |
| 925 | pub const GETCODEDIR = 72; |
| 926 | /// No SIGPIPE generated on EPIPE |
| 927 | pub const SETNOSIGPIPE = 73; |
| 928 | /// Status of SIGPIPE for this fd |
| 929 | pub const GETNOSIGPIPE = 74; |
| 930 | /// For some cases, we need to rewrap the key for AKS/MKB |
| 931 | pub const TRANSCODEKEY = 75; |
| 932 | /// file being written to a by single writer... if throttling enabled, writes |
| 933 | /// may be broken into smaller chunks with throttling in between |
| 934 | pub const SINGLE_WRITER = 76; |
| 935 | /// Get the protection version number for this filesystem |
| 936 | pub const GETPROTECTIONLEVEL = 77; |
| 937 | /// Add detached code signatures (used by dyld for shared libs) |
| 938 | pub const FINDSIGS = 78; |
| 939 | /// Add signature from same file, only if it is signed by Apple (used by dyld for simulator) |
| 940 | pub const ADDFILESIGS_FOR_DYLD_SIM = 83; |
| 941 | /// fsync + issue barrier to drive |
| 942 | pub const BARRIERFSYNC = 85; |
| 943 | /// Add signature from same file, return end offset in structure on success |
| 944 | pub const ADDFILESIGS_RETURN = 97; |
| 945 | /// Check if Library Validation allows this Mach-O file to be mapped into the calling process |
| 946 | pub const CHECK_LV = 98; |
| 947 | /// Deallocate a range of the file |
| 948 | pub const PUNCHHOLE = 99; |
| 949 | /// Trim an active file |
| 950 | pub const TRIM_ACTIVE_FILE = 100; |
| 951 | /// mark the dup with FD_CLOEXEC |
| 952 | pub const DUPFD_CLOEXEC = 67; |
| 953 | /// shared or read lock |
| 954 | pub const RDLCK = 1; |
| 955 | /// unlock |
| 956 | pub const UNLCK = 2; |
| 957 | /// exclusive or write lock |
| 958 | pub const WRLCK = 3; |
| 959 | }, |
| 960 | .freebsd => struct { |
| 961 | /// Duplicate file descriptor. |
| 962 | pub const DUPFD = 0; |
| 963 | /// Get file descriptor flags. |
| 964 | pub const GETFD = 1; |
| 965 | /// Set file descriptor flags. |
| 966 | pub const SETFD = 2; |
| 967 | /// Get file status flags. |
| 968 | pub const GETFL = 3; |
| 969 | /// Set file status flags. |
| 970 | pub const SETFL = 4; |
| 971 | |
| 972 | /// Get SIGIO/SIGURG proc/pgrrp. |
| 973 | pub const GETOWN = 5; |
| 974 | /// Set SIGIO/SIGURG proc/pgrrp. |
| 975 | pub const SETOWN = 6; |
| 976 | |
| 977 | /// Get record locking information. |
| 978 | pub const GETLK = 11; |
| 979 | /// Set record locking information. |
| 980 | pub const SETLK = 12; |
| 981 | /// Set record locking information and wait if blocked. |
| 982 | pub const SETLKW = 13; |
| 983 | |
| 984 | /// Debugging support for remote locks. |
| 985 | pub const SETLK_REMOTE = 14; |
| 986 | /// Read ahead. |
| 987 | pub const READAHEAD = 15; |
| 988 | |
| 989 | /// DUPFD with FD_CLOEXEC set. |
| 990 | pub const DUPFD_CLOEXEC = 17; |
| 991 | /// DUP2FD with FD_CLOEXEC set. |
| 992 | pub const DUP2FD_CLOEXEC = 18; |
| 993 | |
| 994 | pub const ADD_SEALS = 19; |
| 995 | pub const GET_SEALS = 20; |
| 996 | /// Return `kinfo_file` for a file descriptor. |
| 997 | pub const KINFO = 22; |
| 998 | |
| 999 | // Seals (ADD_SEALS, GET_SEALS) |
| 1000 | /// Prevent adding sealings. |
| 1001 | pub const SEAL_SEAL = 0x0001; |
| 1002 | /// May not shrink |
| 1003 | pub const SEAL_SHRINK = 0x0002; |
| 1004 | /// May not grow. |
| 1005 | pub const SEAL_GROW = 0x0004; |
| 1006 | /// May not write. |
| 1007 | pub const SEAL_WRITE = 0x0008; |
| 1008 | |
| 1009 | // Record locking flags (GETLK, SETLK, SETLKW). |
| 1010 | /// Shared or read lock. |
| 1011 | pub const RDLCK = 1; |
| 1012 | /// Unlock. |
| 1013 | pub const UNLCK = 2; |
| 1014 | /// Exclusive or write lock. |
| 1015 | pub const WRLCK = 3; |
| 1016 | /// Purge locks for a given system ID. |
| 1017 | pub const UNLCKSYS = 4; |
| 1018 | /// Cancel an async lock request. |
| 1019 | pub const CANCEL = 5; |
| 1020 | |
| 1021 | pub const SETOWN_EX = 15; |
| 1022 | pub const GETOWN_EX = 16; |
| 1023 | |
| 1024 | pub const GETOWNER_UIDS = 17; |
| 1025 | }, |
| 1026 | .illumos => struct { |
| 1027 | /// Unlock a previously locked region |
| 1028 | pub const ULOCK = 0; |
| 1029 | /// Lock a region for exclusive use |
| 1030 | pub const LOCK = 1; |
| 1031 | /// Test and lock a region for exclusive use |
| 1032 | pub const TLOCK = 2; |
| 1033 | /// Test a region for other processes locks |
| 1034 | pub const TEST = 3; |
| 1035 | |
| 1036 | /// Duplicate fildes |
| 1037 | pub const DUPFD = 0; |
| 1038 | /// Get fildes flags |
| 1039 | pub const GETFD = 1; |
| 1040 | /// Set fildes flags |
| 1041 | pub const SETFD = 2; |
| 1042 | /// Get file flags |
| 1043 | pub const GETFL = 3; |
| 1044 | /// Get file flags including open-only flags |
| 1045 | pub const GETXFL = 45; |
| 1046 | /// Set file flags |
| 1047 | pub const SETFL = 4; |
| 1048 | |
| 1049 | /// Unused |
| 1050 | pub const CHKFL = 8; |
| 1051 | /// Duplicate fildes at third arg |
| 1052 | pub const DUP2FD = 9; |
| 1053 | /// Like DUP2FD with O_CLOEXEC set EINVAL is fildes matches arg1 |
| 1054 | pub const DUP2FD_CLOEXEC = 36; |
| 1055 | /// Like DUPFD with O_CLOEXEC set |
| 1056 | pub const DUPFD_CLOEXEC = 37; |
| 1057 | |
| 1058 | /// Is the file desc. a stream ? |
| 1059 | pub const ISSTREAM = 13; |
| 1060 | /// Turn on private access to file |
| 1061 | pub const PRIV = 15; |
| 1062 | /// Turn off private access to file |
| 1063 | pub const NPRIV = 16; |
| 1064 | /// UFS quota call |
| 1065 | pub const QUOTACTL = 17; |
| 1066 | /// Get number of BLKSIZE blocks allocated |
| 1067 | pub const BLOCKS = 18; |
| 1068 | /// Get optimal I/O block size |
| 1069 | pub const BLKSIZE = 19; |
| 1070 | /// Get owner (socket emulation) |
| 1071 | pub const GETOWN = 23; |
| 1072 | /// Set owner (socket emulation) |
| 1073 | pub const SETOWN = 24; |
| 1074 | /// Object reuse revoke access to file desc. |
| 1075 | pub const REVOKE = 25; |
| 1076 | /// Does vp have NFS locks private to lock manager |
| 1077 | pub const HASREMOTELOCKS = 26; |
| 1078 | |
| 1079 | /// Set file lock |
| 1080 | pub const SETLK = 6; |
| 1081 | /// Set file lock and wait |
| 1082 | pub const SETLKW = 7; |
| 1083 | /// Allocate file space |
| 1084 | pub const ALLOCSP = 10; |
| 1085 | /// Free file space |
| 1086 | pub const FREESP = 11; |
| 1087 | /// Get file lock |
| 1088 | pub const GETLK = 14; |
| 1089 | /// Get file lock owned by file |
| 1090 | pub const OFD_GETLK = 47; |
| 1091 | /// Set file lock owned by file |
| 1092 | pub const OFD_SETLK = 48; |
| 1093 | /// Set file lock owned by file and wait |
| 1094 | pub const OFD_SETLKW = 49; |
| 1095 | /// Set a file share reservation |
| 1096 | pub const SHARE = 40; |
| 1097 | /// Remove a file share reservation |
| 1098 | pub const UNSHARE = 41; |
| 1099 | /// Create Poison FD |
| 1100 | pub const BADFD = 46; |
| 1101 | |
| 1102 | /// Read lock |
| 1103 | pub const RDLCK = 1; |
| 1104 | /// Write lock |
| 1105 | pub const WRLCK = 2; |
| 1106 | /// Remove lock(s) |
| 1107 | pub const UNLCK = 3; |
| 1108 | /// remove remote locks for a given system |
| 1109 | pub const UNLKSYS = 4; |
| 1110 | |
| 1111 | // f_access values |
| 1112 | /// Read-only share access |
| 1113 | pub const RDACC = 0x1; |
| 1114 | /// Write-only share access |
| 1115 | pub const WRACC = 0x2; |
| 1116 | /// Read-Write share access |
| 1117 | pub const RWACC = 0x3; |
| 1118 | |
| 1119 | // f_deny values |
| 1120 | /// Don't deny others access |
| 1121 | pub const NODNY = 0x0; |
| 1122 | /// Deny others read share access |
| 1123 | pub const RDDNY = 0x1; |
| 1124 | /// Deny others write share access |
| 1125 | pub const WRDNY = 0x2; |
| 1126 | /// Deny others read or write share access |
| 1127 | pub const RWDNY = 0x3; |
| 1128 | /// private flag: Deny delete share access |
| 1129 | pub const RMDNY = 0x4; |
| 1130 | }, |
| 1131 | .netbsd => struct { |
| 1132 | pub const DUPFD = 0; |
| 1133 | pub const GETFD = 1; |
| 1134 | pub const SETFD = 2; |
| 1135 | pub const GETFL = 3; |
| 1136 | pub const SETFL = 4; |
| 1137 | pub const GETOWN = 5; |
| 1138 | pub const SETOWN = 6; |
| 1139 | pub const GETLK = 7; |
| 1140 | pub const SETLK = 8; |
| 1141 | pub const SETLKW = 9; |
| 1142 | pub const CLOSEM = 10; |
| 1143 | pub const MAXFD = 11; |
| 1144 | pub const DUPFD_CLOEXEC = 12; |
| 1145 | pub const GETNOSIGPIPE = 13; |
| 1146 | pub const SETNOSIGPIPE = 14; |
| 1147 | pub const GETPATH = 15; |
| 1148 | |
| 1149 | pub const RDLCK = 1; |
| 1150 | pub const WRLCK = 3; |
| 1151 | pub const UNLCK = 2; |
| 1152 | }, |
| 1153 | .dragonfly => struct { |
| 1154 | pub const ULOCK = 0; |
| 1155 | pub const LOCK = 1; |
| 1156 | pub const TLOCK = 2; |
| 1157 | pub const TEST = 3; |
| 1158 | |
| 1159 | pub const DUPFD = 0; |
| 1160 | pub const GETFD = 1; |
| 1161 | pub const RDLCK = 1; |
| 1162 | pub const SETFD = 2; |
| 1163 | pub const UNLCK = 2; |
| 1164 | pub const WRLCK = 3; |
| 1165 | pub const GETFL = 3; |
| 1166 | pub const SETFL = 4; |
| 1167 | pub const GETOWN = 5; |
| 1168 | pub const SETOWN = 6; |
| 1169 | pub const GETLK = 7; |
| 1170 | pub const SETLK = 8; |
| 1171 | pub const SETLKW = 9; |
| 1172 | pub const DUP2FD = 10; |
| 1173 | pub const DUPFD_CLOEXEC = 17; |
| 1174 | pub const DUP2FD_CLOEXEC = 18; |
| 1175 | pub const GETPATH = 19; |
| 1176 | }, |
| 1177 | .haiku => struct { |
| 1178 | pub const DUPFD = 0x0001; |
| 1179 | pub const GETFD = 0x0002; |
| 1180 | pub const SETFD = 0x0004; |
| 1181 | pub const GETFL = 0x0008; |
| 1182 | pub const SETFL = 0x0010; |
| 1183 | |
| 1184 | pub const GETLK = 0x0020; |
| 1185 | pub const SETLK = 0x0080; |
| 1186 | pub const SETLKW = 0x0100; |
| 1187 | pub const DUPFD_CLOEXEC = 0x0200; |
| 1188 | |
| 1189 | pub const RDLCK = 0x0040; |
| 1190 | pub const UNLCK = 0x0200; |
| 1191 | pub const WRLCK = 0x0400; |
| 1192 | }, |
| 1193 | .openbsd => struct { |
| 1194 | pub const DUPFD = 0; |
| 1195 | pub const GETFD = 1; |
| 1196 | pub const SETFD = 2; |
| 1197 | pub const GETFL = 3; |
| 1198 | pub const SETFL = 4; |
| 1199 | |
| 1200 | pub const GETOWN = 5; |
| 1201 | pub const SETOWN = 6; |
| 1202 | |
| 1203 | pub const GETLK = 7; |
| 1204 | pub const SETLK = 8; |
| 1205 | pub const SETLKW = 9; |
| 1206 | |
| 1207 | pub const RDLCK = 1; |
| 1208 | pub const UNLCK = 2; |
| 1209 | pub const WRLCK = 3; |
| 1210 | }, |
| 1211 | .serenity => struct { |
| 1212 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L15-L24 |
| 1213 | pub const DUPFD = 0; |
| 1214 | pub const GETFD = 1; |
| 1215 | pub const SETFD = 2; |
| 1216 | pub const GETFL = 3; |
| 1217 | pub const SETFL = 4; |
| 1218 | pub const ISTTY = 5; |
| 1219 | pub const GETLK = 6; |
| 1220 | pub const SETLK = 7; |
| 1221 | pub const SETLKW = 8; |
| 1222 | pub const DUPFD_CLOEXEC = 9; |
| 1223 | |
| 1224 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L45-L47 |
| 1225 | pub const RDLCK = 0; |
| 1226 | pub const WRLCK = 1; |
| 1227 | pub const UNLCK = 2; |
| 1228 | }, |
| 1229 | else => void, |
| 1230 | }; |
| 1231 | pub const FD_CLOEXEC = switch (native_os) { |
| 1232 | .linux => linux.FD_CLOEXEC, |
| 1233 | .emscripten => emscripten.FD_CLOEXEC, |
| 1234 | else => 1, |
| 1235 | }; |
| 1236 | |
| 1237 | /// Test for existence of file. |
| 1238 | pub const F_OK = switch (native_os) { |
| 1239 | .linux => linux.F_OK, |
| 1240 | .emscripten => emscripten.F_OK, |
| 1241 | else => 0, |
| 1242 | }; |
| 1243 | /// Test for execute or search permission. |
| 1244 | pub const X_OK = switch (native_os) { |
| 1245 | .linux => linux.X_OK, |
| 1246 | .emscripten => emscripten.X_OK, |
| 1247 | else => 1, |
| 1248 | }; |
| 1249 | /// Test for write permission. |
| 1250 | pub const W_OK = switch (native_os) { |
| 1251 | .linux => linux.W_OK, |
| 1252 | .emscripten => emscripten.W_OK, |
| 1253 | else => 2, |
| 1254 | }; |
| 1255 | /// Test for read permission. |
| 1256 | pub const R_OK = switch (native_os) { |
| 1257 | .linux => linux.R_OK, |
| 1258 | .emscripten => emscripten.R_OK, |
| 1259 | else => 4, |
| 1260 | }; |
| 1261 | |
| 1262 | pub const Flock = switch (native_os) { |
| 1263 | .linux => linux.Flock, |
| 1264 | .emscripten => emscripten.Flock, |
| 1265 | .openbsd, .dragonfly, .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 1266 | start: off_t, |
| 1267 | len: off_t, |
| 1268 | pid: pid_t, |
| 1269 | type: i16, |
| 1270 | whence: i16, |
| 1271 | }, |
| 1272 | .freebsd => extern struct { |
| 1273 | /// Starting offset. |
| 1274 | start: off_t, |
| 1275 | /// Number of consecutive bytes to be locked. |
| 1276 | /// A value of 0 means to the end of the file. |
| 1277 | len: off_t, |
| 1278 | /// Lock owner. |
| 1279 | pid: pid_t, |
| 1280 | /// Lock type. |
| 1281 | type: i16, |
| 1282 | /// Type of the start member. |
| 1283 | whence: i16, |
| 1284 | /// Remote system id or zero for local. |
| 1285 | sysid: i32, |
| 1286 | }, |
| 1287 | .illumos => extern struct { |
| 1288 | type: c_short, |
| 1289 | whence: c_short, |
| 1290 | start: off_t, |
| 1291 | // len == 0 means until end of file. |
| 1292 | len: off_t, |
| 1293 | sysid: c_int, |
| 1294 | pid: pid_t, |
| 1295 | __pad: [4]c_long, |
| 1296 | }, |
| 1297 | .haiku => extern struct { |
| 1298 | type: i16, |
| 1299 | whence: i16, |
| 1300 | start: off_t, |
| 1301 | len: off_t, |
| 1302 | pid: pid_t, |
| 1303 | }, |
| 1304 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L54-L60 |
| 1305 | .serenity => extern struct { |
| 1306 | type: c_short, |
| 1307 | whence: c_short, |
| 1308 | start: off_t, |
| 1309 | len: off_t, |
| 1310 | pid: pid_t, |
| 1311 | }, |
| 1312 | else => void, |
| 1313 | }; |
| 1314 | pub const HOST_NAME_MAX = switch (native_os) { |
| 1315 | .linux => linux.HOST_NAME_MAX, |
| 1316 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 72, |
| 1317 | .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd => 255, |
| 1318 | // https://github.com/SerenityOS/serenity/blob/c87557e9c1865fa1a6440de34ff6ce6fc858a2b7/Kernel/API/POSIX/sys/limits.h#L22 |
| 1319 | .serenity => 64, |
| 1320 | else => {}, |
| 1321 | }; |
| 1322 | pub const IOV_MAX = switch (native_os) { |
| 1323 | .linux => linux.IOV_MAX, |
| 1324 | .emscripten => emscripten.IOV_MAX, |
| 1325 | // https://github.com/SerenityOS/serenity/blob/098af0f846a87b651731780ff48420205fd33754/Kernel/API/POSIX/sys/uio.h#L16 |
| 1326 | .openbsd, .haiku, .illumos, .wasi, .serenity => 1024, |
| 1327 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 16, |
| 1328 | .dragonfly, .netbsd, .freebsd => KERN.IOV_MAX, |
| 1329 | else => {}, |
| 1330 | }; |
| 1331 | pub const CTL = switch (native_os) { |
| 1332 | .freebsd => struct { |
| 1333 | pub const KERN = 1; |
| 1334 | pub const DEBUG = 5; |
| 1335 | }, |
| 1336 | .netbsd => struct { |
| 1337 | pub const KERN = 1; |
| 1338 | pub const DEBUG = 5; |
| 1339 | }, |
| 1340 | .dragonfly => struct { |
| 1341 | pub const UNSPEC = 0; |
| 1342 | pub const KERN = 1; |
| 1343 | pub const VM = 2; |
| 1344 | pub const VFS = 3; |
| 1345 | pub const NET = 4; |
| 1346 | pub const DEBUG = 5; |
| 1347 | pub const HW = 6; |
| 1348 | pub const MACHDEP = 7; |
| 1349 | pub const USER = 8; |
| 1350 | pub const LWKT = 10; |
| 1351 | pub const MAXID = 11; |
| 1352 | pub const MAXNAME = 12; |
| 1353 | }, |
| 1354 | .openbsd => struct { |
| 1355 | pub const UNSPEC = 0; |
| 1356 | pub const KERN = 1; |
| 1357 | pub const VM = 2; |
| 1358 | pub const FS = 3; |
| 1359 | pub const NET = 4; |
| 1360 | pub const DEBUG = 5; |
| 1361 | pub const HW = 6; |
| 1362 | pub const MACHDEP = 7; |
| 1363 | |
| 1364 | pub const DDB = 9; |
| 1365 | pub const VFS = 10; |
| 1366 | }, |
| 1367 | else => void, |
| 1368 | }; |
| 1369 | pub const CPU = switch (native_os) { |
| 1370 | .openbsd => switch (native_arch) { |
| 1371 | .aarch64, .aarch64_be => struct { |
| 1372 | pub const COMPATIBLE = 1; |
| 1373 | pub const ID_AA64ISAR0 = 2; |
| 1374 | pub const ID_AA64ISAR1 = 3; |
| 1375 | pub const ID_AA64ISAR2 = 4; |
| 1376 | pub const ID_AA64MMFR0 = 5; |
| 1377 | pub const ID_AA64MMFR1 = 6; |
| 1378 | pub const ID_AA64MMFR2 = 7; |
| 1379 | pub const AA64PFR0 = 8; |
| 1380 | pub const AA64PFR1 = 9; |
| 1381 | pub const AA64SMFR0 = 10; |
| 1382 | pub const AA64ZFR0 = 11; |
| 1383 | pub const LIDACTION = 12; |
| 1384 | pub const LED_BLINK = 13; |
| 1385 | }, |
| 1386 | else => void, |
| 1387 | }, |
| 1388 | else => void, |
| 1389 | }; |
| 1390 | pub const KERN = switch (native_os) { |
| 1391 | .freebsd => struct { |
| 1392 | /// struct: process entries |
| 1393 | pub const PROC = 14; |
| 1394 | /// path to executable |
| 1395 | pub const PROC_PATHNAME = 12; |
| 1396 | /// file descriptors for process |
| 1397 | pub const PROC_FILEDESC = 33; |
| 1398 | pub const IOV_MAX = 35; |
| 1399 | }, |
| 1400 | .netbsd => struct { |
| 1401 | /// struct: process argv/env |
| 1402 | pub const PROC_ARGS = 48; |
| 1403 | /// path to executable |
| 1404 | pub const PROC_PATHNAME = 5; |
| 1405 | pub const IOV_MAX = 38; |
| 1406 | }, |
| 1407 | .dragonfly => struct { |
| 1408 | pub const PROC_ALL = 0; |
| 1409 | pub const OSTYPE = 1; |
| 1410 | pub const PROC_PID = 1; |
| 1411 | pub const OSRELEASE = 2; |
| 1412 | pub const PROC_PGRP = 2; |
| 1413 | pub const OSREV = 3; |
| 1414 | pub const PROC_SESSION = 3; |
| 1415 | pub const VERSION = 4; |
| 1416 | pub const PROC_TTY = 4; |
| 1417 | pub const MAXVNODES = 5; |
| 1418 | pub const PROC_UID = 5; |
| 1419 | pub const MAXPROC = 6; |
| 1420 | pub const PROC_RUID = 6; |
| 1421 | pub const MAXFILES = 7; |
| 1422 | pub const PROC_ARGS = 7; |
| 1423 | pub const ARGMAX = 8; |
| 1424 | pub const PROC_CWD = 8; |
| 1425 | pub const PROC_PATHNAME = 9; |
| 1426 | pub const SECURELVL = 9; |
| 1427 | pub const PROC_SIGTRAMP = 10; |
| 1428 | pub const HOSTNAME = 10; |
| 1429 | pub const HOSTID = 11; |
| 1430 | pub const CLOCKRATE = 12; |
| 1431 | pub const VNODE = 13; |
| 1432 | pub const PROC = 14; |
| 1433 | pub const FILE = 15; |
| 1434 | pub const PROC_FLAGMASK = 16; |
| 1435 | pub const PROF = 16; |
| 1436 | pub const PROC_FLAG_LWP = 16; |
| 1437 | pub const POSIX1 = 17; |
| 1438 | pub const NGROUPS = 18; |
| 1439 | pub const JOB_CONTROL = 19; |
| 1440 | pub const SAVED_IDS = 20; |
| 1441 | pub const BOOTTIME = 21; |
| 1442 | pub const NISDOMAINNAME = 22; |
| 1443 | pub const UPDATEINTERVAL = 23; |
| 1444 | pub const OSRELDATE = 24; |
| 1445 | pub const NTP_PLL = 25; |
| 1446 | pub const BOOTFILE = 26; |
| 1447 | pub const MAXFILESPERPROC = 27; |
| 1448 | pub const MAXPROCPERUID = 28; |
| 1449 | pub const DUMPDEV = 29; |
| 1450 | pub const IPC = 30; |
| 1451 | pub const DUMMY = 31; |
| 1452 | pub const PS_STRINGS = 32; |
| 1453 | pub const USRSTACK = 33; |
| 1454 | pub const LOGSIGEXIT = 34; |
| 1455 | pub const IOV_MAX = 35; |
| 1456 | pub const MAXPOSIXLOCKSPERUID = 36; |
| 1457 | pub const MAXID = 37; |
| 1458 | }, |
| 1459 | .openbsd => struct { |
| 1460 | pub const OSTYPE = 1; |
| 1461 | pub const OSRELEASE = 2; |
| 1462 | pub const OSREV = 3; |
| 1463 | pub const VERSION = 4; |
| 1464 | pub const MAXVNODES = 5; |
| 1465 | pub const MAXPROC = 6; |
| 1466 | pub const MAXFILES = 7; |
| 1467 | pub const ARGMAX = 8; |
| 1468 | pub const SECURELVL = 9; |
| 1469 | pub const HOSTNAME = 10; |
| 1470 | pub const HOSTID = 11; |
| 1471 | pub const CLOCKRATE = 12; |
| 1472 | |
| 1473 | pub const PROF = 16; |
| 1474 | pub const POSIX1 = 17; |
| 1475 | pub const NGROUPS = 18; |
| 1476 | pub const JOB_CONTROL = 19; |
| 1477 | pub const SAVED_IDS = 20; |
| 1478 | pub const BOOTTIME = 21; |
| 1479 | pub const DOMAINNAME = 22; |
| 1480 | pub const MAXPARTITIONS = 23; |
| 1481 | pub const RAWPARTITION = 24; |
| 1482 | pub const MAXTHREAD = 25; |
| 1483 | pub const NTHREADS = 26; |
| 1484 | pub const OSVERSION = 27; |
| 1485 | pub const SOMAXCONN = 28; |
| 1486 | pub const SOMINCONN = 29; |
| 1487 | |
| 1488 | pub const NOSUIDCOREDUMP = 32; |
| 1489 | pub const FSYNC = 33; |
| 1490 | pub const SYSVMSG = 34; |
| 1491 | pub const SYSVSEM = 35; |
| 1492 | pub const SYSVSHM = 36; |
| 1493 | |
| 1494 | pub const MSGBUFSIZE = 38; |
| 1495 | pub const MALLOCSTATS = 39; |
| 1496 | pub const CPTIME = 40; |
| 1497 | pub const NCHSTATS = 41; |
| 1498 | pub const FORKSTAT = 42; |
| 1499 | pub const NSELCOLL = 43; |
| 1500 | pub const TTY = 44; |
| 1501 | pub const CCPU = 45; |
| 1502 | pub const FSCALE = 46; |
| 1503 | pub const NPROCS = 47; |
| 1504 | pub const MSGBUF = 48; |
| 1505 | pub const POOL = 49; |
| 1506 | pub const STACKGAPRANDOM = 50; |
| 1507 | pub const SYSVIPC_INFO = 51; |
| 1508 | pub const ALLOWKMEM = 52; |
| 1509 | pub const WITNESSWATCH = 53; |
| 1510 | pub const SPLASSERT = 54; |
| 1511 | pub const PROC_ARGS = 55; |
| 1512 | pub const NFILES = 56; |
| 1513 | pub const TTYCOUNT = 57; |
| 1514 | pub const NUMVNODES = 58; |
| 1515 | pub const MBSTAT = 59; |
| 1516 | pub const WITNESS = 60; |
| 1517 | pub const SEMINFO = 61; |
| 1518 | pub const SHMINFO = 62; |
| 1519 | pub const INTRCNT = 63; |
| 1520 | pub const WATCHDOG = 64; |
| 1521 | pub const ALLOWDT = 65; |
| 1522 | pub const PROC = 66; |
| 1523 | pub const MAXCLUSTERS = 67; |
| 1524 | pub const EVCOUNT = 68; |
| 1525 | pub const TIMECOUNTER = 69; |
| 1526 | pub const MAXLOCKSPERUID = 70; |
| 1527 | pub const CPTIME2 = 71; |
| 1528 | pub const CACHEPCT = 72; |
| 1529 | pub const FILE = 73; |
| 1530 | pub const WXABORT = 74; |
| 1531 | pub const CONSDEV = 75; |
| 1532 | pub const NETLIVELOCKS = 76; |
| 1533 | pub const POOL_DEBUG = 77; |
| 1534 | pub const PROC_CWD = 78; |
| 1535 | pub const PROC_NOBROADCASTKILL = 79; |
| 1536 | pub const PROC_VMMAP = 80; |
| 1537 | pub const GLOBAL_PTRACE = 81; |
| 1538 | pub const CONSBUFSIZE = 82; |
| 1539 | pub const CONSBUF = 83; |
| 1540 | pub const AUDIO = 84; |
| 1541 | pub const CPUSTATS = 85; |
| 1542 | pub const PFSTATUS = 86; |
| 1543 | pub const TIMEOUT_STATS = 87; |
| 1544 | pub const UTC_OFFSET = 88; |
| 1545 | pub const VIDEO = 89; |
| 1546 | |
| 1547 | pub const PROC_ALL = 0; |
| 1548 | pub const PROC_PID = 1; |
| 1549 | pub const PROC_PGRP = 2; |
| 1550 | pub const PROC_SESSION = 3; |
| 1551 | pub const PROC_TTY = 4; |
| 1552 | pub const PROC_UID = 5; |
| 1553 | pub const PROC_RUID = 6; |
| 1554 | pub const PROC_KTHREAD = 7; |
| 1555 | pub const PROC_SHOW_THREADS = 0x40000000; |
| 1556 | |
| 1557 | pub const PROC_ARGV = 1; |
| 1558 | pub const PROC_NARGV = 2; |
| 1559 | pub const PROC_ENV = 3; |
| 1560 | pub const PROC_NENV = 4; |
| 1561 | }, |
| 1562 | else => void, |
| 1563 | }; |
| 1564 | pub const MADV = switch (native_os) { |
| 1565 | .linux => linux.MADV, |
| 1566 | .emscripten => emscripten.MADV, |
| 1567 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 1568 | pub const NORMAL = 0; |
| 1569 | pub const RANDOM = 1; |
| 1570 | pub const SEQUENTIAL = 2; |
| 1571 | pub const WILLNEED = 3; |
| 1572 | pub const DONTNEED = 4; |
| 1573 | pub const FREE = 5; |
| 1574 | pub const ZERO_WIRED_PAGES = 6; |
| 1575 | pub const FREE_REUSABLE = 7; |
| 1576 | pub const FREE_REUSE = 8; |
| 1577 | pub const CAN_REUSE = 9; |
| 1578 | pub const PAGEOUT = 10; |
| 1579 | pub const ZERO = 11; |
| 1580 | }, |
| 1581 | .freebsd => struct { |
| 1582 | pub const NORMAL = 0; |
| 1583 | pub const RANDOM = 1; |
| 1584 | pub const SEQUENTIAL = 2; |
| 1585 | pub const WILLNEED = 3; |
| 1586 | pub const DONTNEED = 4; |
| 1587 | pub const FREE = 5; |
| 1588 | pub const NOSYNC = 6; |
| 1589 | pub const AUTOSYNC = 7; |
| 1590 | pub const NOCORE = 8; |
| 1591 | pub const CORE = 9; |
| 1592 | pub const PROTECT = 10; |
| 1593 | }, |
| 1594 | .illumos => struct { |
| 1595 | /// no further special treatment |
| 1596 | pub const NORMAL = 0; |
| 1597 | /// expect random page references |
| 1598 | pub const RANDOM = 1; |
| 1599 | /// expect sequential page references |
| 1600 | pub const SEQUENTIAL = 2; |
| 1601 | /// will need these pages |
| 1602 | pub const WILLNEED = 3; |
| 1603 | /// don't need these pages |
| 1604 | pub const DONTNEED = 4; |
| 1605 | /// contents can be freed |
| 1606 | pub const FREE = 5; |
| 1607 | /// default access |
| 1608 | pub const ACCESS_DEFAULT = 6; |
| 1609 | /// next LWP to access heavily |
| 1610 | pub const ACCESS_LWP = 7; |
| 1611 | /// many processes to access heavily |
| 1612 | pub const ACCESS_MANY = 8; |
| 1613 | /// contents will be purged |
| 1614 | pub const PURGE = 9; |
| 1615 | }, |
| 1616 | .dragonfly => struct { |
| 1617 | pub const SEQUENTIAL = 2; |
| 1618 | pub const CONTROL_END = SETMAP; |
| 1619 | pub const DONTNEED = 4; |
| 1620 | pub const RANDOM = 1; |
| 1621 | pub const WILLNEED = 3; |
| 1622 | pub const NORMAL = 0; |
| 1623 | pub const CONTROL_START = INVAL; |
| 1624 | pub const FREE = 5; |
| 1625 | pub const NOSYNC = 6; |
| 1626 | pub const AUTOSYNC = 7; |
| 1627 | pub const NOCORE = 8; |
| 1628 | pub const CORE = 9; |
| 1629 | pub const INVAL = 10; |
| 1630 | pub const SETMAP = 11; |
| 1631 | }, |
| 1632 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L35-L41 |
| 1633 | .serenity => struct { |
| 1634 | pub const NORMAL = 0x0; |
| 1635 | pub const SET_VOLATILE = 0x1; |
| 1636 | pub const SET_NONVOLATILE = 0x2; |
| 1637 | pub const DONTNEED = 0x3; |
| 1638 | pub const WILLNEED = 0x4; |
| 1639 | pub const SEQUENTIAL = 0x5; |
| 1640 | pub const RANDOM = 0x6; |
| 1641 | }, |
| 1642 | .netbsd, .openbsd => struct { |
| 1643 | pub const NORMAL = 0; |
| 1644 | pub const RANDOM = 1; |
| 1645 | pub const SEQUENTIAL = 2; |
| 1646 | pub const WILLNEED = 3; |
| 1647 | pub const DONTNEED = 4; |
| 1648 | pub const SPACEAVAIL = 5; |
| 1649 | pub const FREE = 6; |
| 1650 | }, |
| 1651 | else => void, |
| 1652 | }; |
| 1653 | pub const MCL = switch (native_os) { |
| 1654 | .linux => linux.MCL, |
| 1655 | // https://github.com/freebsd/freebsd-src/blob/39fea5c8dc598021e900c4feaf0e18111fda57b2/sys/sys/mman.h#L133 |
| 1656 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/088552723935447397400336f5ddb7aa5f5de660/sys/sys/mman.h#L118 |
| 1657 | // https://github.com/NetBSD/src/blob/fd2741deca927c18e3ba15acdf78b8b14b2abe36/sys/sys/mman.h#L179 |
| 1658 | // https://github.com/openbsd/src/blob/39404228f6d36c0ca4be5f04ab5385568ebd6aa3/sys/sys/mman.h#L129 |
| 1659 | // https://github.com/illumos/illumos-gate/blob/5280477614f83fea20fc938729df6adb3e44340d/usr/src/uts/common/sys/mman.h#L343 |
| 1660 | .freebsd, .dragonfly, .netbsd, .openbsd, .illumos => packed struct(u32) { |
| 1661 | CURRENT: bool = false, |
| 1662 | FUTURE: bool = false, |
| 1663 | _: u30 = 0, |
| 1664 | }, |
| 1665 | else => void, |
| 1666 | }; |
| 1667 | pub const MLOCK = switch (native_os) { |
| 1668 | .linux => linux.MLOCK, |
| 1669 | else => void, |
| 1670 | }; |
| 1671 | pub const MSF = switch (native_os) { |
| 1672 | .linux => linux.MSF, |
| 1673 | .emscripten => emscripten.MSF, |
| 1674 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 1675 | pub const ASYNC = 0x1; |
| 1676 | pub const INVALIDATE = 0x2; |
| 1677 | /// invalidate, leave mapped |
| 1678 | pub const KILLPAGES = 0x4; |
| 1679 | /// deactivate, leave mapped |
| 1680 | pub const DEACTIVATE = 0x8; |
| 1681 | pub const SYNC = 0x10; |
| 1682 | }, |
| 1683 | .freebsd, .dragonfly => struct { |
| 1684 | pub const SYNC = 0; |
| 1685 | pub const ASYNC = 1; |
| 1686 | pub const INVALIDATE = 2; |
| 1687 | }, |
| 1688 | .openbsd, .haiku => struct { |
| 1689 | pub const ASYNC = 1; |
| 1690 | pub const SYNC = 2; |
| 1691 | pub const INVALIDATE = 4; |
| 1692 | }, |
| 1693 | .netbsd, .illumos => struct { |
| 1694 | pub const ASYNC = 1; |
| 1695 | pub const INVALIDATE = 2; |
| 1696 | pub const SYNC = 4; |
| 1697 | }, |
| 1698 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L50-L52 |
| 1699 | .serenity => struct { |
| 1700 | pub const SYNC = 1; |
| 1701 | pub const ASYNC = 2; |
| 1702 | pub const INVALIDATE = 4; |
| 1703 | }, |
| 1704 | else => void, |
| 1705 | }; |
| 1706 | pub const NAME_MAX = switch (native_os) { |
| 1707 | .linux => linux.NAME_MAX, |
| 1708 | .emscripten => emscripten.NAME_MAX, |
| 1709 | // Haiku's headers make this 256, to contain room for the terminating null |
| 1710 | // character, but POSIX definition says that NAME_MAX does not include the |
| 1711 | // terminating null. |
| 1712 | // https://github.com/SerenityOS/serenity/blob/c87557e9c1865fa1a6440de34ff6ce6fc858a2b7/Kernel/API/POSIX/sys/limits.h#L20 |
| 1713 | .haiku, .openbsd, .dragonfly, .netbsd, .illumos, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 255, |
| 1714 | else => {}, |
| 1715 | }; |
| 1716 | pub const PATH_MAX = switch (native_os) { |
| 1717 | .linux => linux.PATH_MAX, |
| 1718 | .emscripten => emscripten.PATH_MAX, |
| 1719 | .wasi => 4096, |
| 1720 | .windows => 260, |
| 1721 | .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 1024, |
| 1722 | else => {}, |
| 1723 | }; |
| 1724 | |
| 1725 | pub const POLL = switch (native_os) { |
| 1726 | .linux => linux.POLL, |
| 1727 | .emscripten => emscripten.POLL, |
| 1728 | .wasi => struct { |
| 1729 | pub const RDNORM = 0x1; |
| 1730 | pub const WRNORM = 0x2; |
| 1731 | pub const IN = RDNORM; |
| 1732 | pub const OUT = WRNORM; |
| 1733 | pub const ERR = 0x1000; |
| 1734 | pub const HUP = 0x2000; |
| 1735 | pub const NVAL = 0x4000; |
| 1736 | }, |
| 1737 | .windows => ws2_32.POLL, |
| 1738 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 1739 | pub const IN = 0x001; |
| 1740 | pub const PRI = 0x002; |
| 1741 | pub const OUT = 0x004; |
| 1742 | pub const RDNORM = 0x040; |
| 1743 | pub const WRNORM = OUT; |
| 1744 | pub const RDBAND = 0x080; |
| 1745 | pub const WRBAND = 0x100; |
| 1746 | |
| 1747 | pub const EXTEND = 0x0200; |
| 1748 | pub const ATTRIB = 0x0400; |
| 1749 | pub const NLINK = 0x0800; |
| 1750 | pub const WRITE = 0x1000; |
| 1751 | |
| 1752 | pub const ERR = 0x008; |
| 1753 | pub const HUP = 0x010; |
| 1754 | pub const NVAL = 0x020; |
| 1755 | |
| 1756 | pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL; |
| 1757 | }, |
| 1758 | .freebsd => struct { |
| 1759 | /// any readable data available. |
| 1760 | pub const IN = 0x0001; |
| 1761 | /// OOB/Urgent readable data. |
| 1762 | pub const PRI = 0x0002; |
| 1763 | /// file descriptor is writeable. |
| 1764 | pub const OUT = 0x0004; |
| 1765 | /// non-OOB/URG data available. |
| 1766 | pub const RDNORM = 0x0040; |
| 1767 | /// no write type differentiation. |
| 1768 | pub const WRNORM = OUT; |
| 1769 | /// OOB/Urgent readable data. |
| 1770 | pub const RDBAND = 0x0080; |
| 1771 | /// OOB/Urgent data can be written. |
| 1772 | pub const WRBAND = 0x0100; |
| 1773 | /// like IN, except ignore EOF. |
| 1774 | pub const INIGNEOF = 0x2000; |
| 1775 | /// some poll error occurred. |
| 1776 | pub const ERR = 0x0008; |
| 1777 | /// file descriptor was "hung up". |
| 1778 | pub const HUP = 0x0010; |
| 1779 | /// requested events "invalid". |
| 1780 | pub const NVAL = 0x0020; |
| 1781 | |
| 1782 | pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL; |
| 1783 | }, |
| 1784 | .illumos => struct { |
| 1785 | pub const IN = 0x0001; |
| 1786 | pub const PRI = 0x0002; |
| 1787 | pub const OUT = 0x0004; |
| 1788 | pub const RDNORM = 0x0040; |
| 1789 | pub const WRNORM = .OUT; |
| 1790 | pub const RDBAND = 0x0080; |
| 1791 | pub const WRBAND = 0x0100; |
| 1792 | /// Read-side hangup. |
| 1793 | pub const RDHUP = 0x4000; |
| 1794 | |
| 1795 | /// Non-testable events (may not be specified in events). |
| 1796 | pub const ERR = 0x0008; |
| 1797 | pub const HUP = 0x0010; |
| 1798 | pub const NVAL = 0x0020; |
| 1799 | |
| 1800 | /// Events to control `/dev/poll` (not specified in revents) |
| 1801 | pub const REMOVE = 0x0800; |
| 1802 | pub const ONESHOT = 0x1000; |
| 1803 | pub const ET = 0x2000; |
| 1804 | }, |
| 1805 | .dragonfly, .netbsd => struct { |
| 1806 | /// Testable events (may be specified in events field). |
| 1807 | pub const IN = 0x0001; |
| 1808 | pub const PRI = 0x0002; |
| 1809 | pub const OUT = 0x0004; |
| 1810 | pub const RDNORM = 0x0040; |
| 1811 | pub const WRNORM = OUT; |
| 1812 | pub const RDBAND = 0x0080; |
| 1813 | pub const WRBAND = 0x0100; |
| 1814 | |
| 1815 | /// Non-testable events (may not be specified in events field). |
| 1816 | pub const ERR = 0x0008; |
| 1817 | pub const HUP = 0x0010; |
| 1818 | pub const NVAL = 0x0020; |
| 1819 | }, |
| 1820 | .haiku => struct { |
| 1821 | /// any readable data available |
| 1822 | pub const IN = 0x0001; |
| 1823 | /// file descriptor is writeable |
| 1824 | pub const OUT = 0x0002; |
| 1825 | pub const RDNORM = IN; |
| 1826 | pub const WRNORM = OUT; |
| 1827 | /// priority readable data |
| 1828 | pub const RDBAND = 0x0008; |
| 1829 | /// priority data can be written |
| 1830 | pub const WRBAND = 0x0010; |
| 1831 | /// high priority readable data |
| 1832 | pub const PRI = 0x0020; |
| 1833 | |
| 1834 | /// errors pending |
| 1835 | pub const ERR = 0x0004; |
| 1836 | /// disconnected |
| 1837 | pub const HUP = 0x0080; |
| 1838 | /// invalid file descriptor |
| 1839 | pub const NVAL = 0x1000; |
| 1840 | }, |
| 1841 | .openbsd => struct { |
| 1842 | pub const IN = 0x0001; |
| 1843 | pub const PRI = 0x0002; |
| 1844 | pub const OUT = 0x0004; |
| 1845 | pub const ERR = 0x0008; |
| 1846 | pub const HUP = 0x0010; |
| 1847 | pub const NVAL = 0x0020; |
| 1848 | pub const RDNORM = 0x0040; |
| 1849 | pub const NORM = RDNORM; |
| 1850 | pub const WRNORM = OUT; |
| 1851 | pub const RDBAND = 0x0080; |
| 1852 | pub const WRBAND = 0x0100; |
| 1853 | }, |
| 1854 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L15-L24 |
| 1855 | .serenity => struct { |
| 1856 | pub const IN = 0x0001; |
| 1857 | pub const PRI = 0x0002; |
| 1858 | pub const OUT = 0x0004; |
| 1859 | pub const ERR = 0x0008; |
| 1860 | pub const HUP = 0x0010; |
| 1861 | pub const NVAL = 0x0020; |
| 1862 | pub const RDNORM = IN; |
| 1863 | pub const WRNORM = OUT; |
| 1864 | pub const WRBAND = 0x1000; |
| 1865 | pub const RDHUP = 0x2000; |
| 1866 | }, |
| 1867 | else => void, |
| 1868 | }; |
| 1869 | |
| 1870 | /// Basic memory protection flags |
| 1871 | pub const PROT = switch (native_os) { |
| 1872 | .linux => linux.PROT, |
| 1873 | .emscripten => emscripten.PROT, |
| 1874 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L28-L31 |
| 1875 | .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd, .windows, .serenity => packed struct(u32) { |
| 1876 | READ: bool = false, |
| 1877 | WRITE: bool = false, |
| 1878 | EXEC: bool = false, |
| 1879 | _: u29 = 0, |
| 1880 | }, |
| 1881 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => vm_prot_t, |
| 1882 | else => void, |
| 1883 | }; |
| 1884 | |
| 1885 | pub const RLIM = switch (native_os) { |
| 1886 | .linux => linux.RLIM, |
| 1887 | .emscripten => emscripten.RLIM, |
| 1888 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L52 |
| 1889 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => struct { |
| 1890 | /// No limit |
| 1891 | pub const INFINITY: rlim_t = (1 << 63) - 1; |
| 1892 | |
| 1893 | pub const SAVED_MAX = INFINITY; |
| 1894 | pub const SAVED_CUR = INFINITY; |
| 1895 | }, |
| 1896 | .illumos => struct { |
| 1897 | /// No limit |
| 1898 | pub const INFINITY: rlim_t = (1 << 63) - 3; |
| 1899 | pub const SAVED_MAX: rlim_t = (1 << 63) - 2; |
| 1900 | pub const SAVED_CUR: rlim_t = (1 << 63) - 1; |
| 1901 | }, |
| 1902 | else => void, |
| 1903 | }; |
| 1904 | pub const S = switch (native_os) { |
| 1905 | .linux => linux.S, |
| 1906 | .emscripten => emscripten.S, |
| 1907 | .wasi => struct { |
| 1908 | // Match `S_*` constants from lib/libc/include/wasm-wasi-musl/__mode_t.h |
| 1909 | pub const IFBLK = 0x6000; |
| 1910 | pub const IFCHR = 0x2000; |
| 1911 | pub const IFDIR = 0x4000; |
| 1912 | pub const IFIFO = 0x1000; |
| 1913 | pub const IFLNK = 0xa000; |
| 1914 | pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK; |
| 1915 | pub const IFREG = 0x8000; |
| 1916 | pub const IFSOCK = 0xc000; |
| 1917 | |
| 1918 | pub fn ISBLK(m: u32) bool { |
| 1919 | return m & IFMT == IFBLK; |
| 1920 | } |
| 1921 | |
| 1922 | pub fn ISCHR(m: u32) bool { |
| 1923 | return m & IFMT == IFCHR; |
| 1924 | } |
| 1925 | |
| 1926 | pub fn ISDIR(m: u32) bool { |
| 1927 | return m & IFMT == IFDIR; |
| 1928 | } |
| 1929 | |
| 1930 | pub fn ISFIFO(m: u32) bool { |
| 1931 | return m & IFMT == IFIFO; |
| 1932 | } |
| 1933 | |
| 1934 | pub fn ISLNK(m: u32) bool { |
| 1935 | return m & IFMT == IFLNK; |
| 1936 | } |
| 1937 | |
| 1938 | pub fn ISREG(m: u32) bool { |
| 1939 | return m & IFMT == IFREG; |
| 1940 | } |
| 1941 | |
| 1942 | pub fn ISSOCK(m: u32) bool { |
| 1943 | return m & IFMT == IFSOCK; |
| 1944 | } |
| 1945 | }, |
| 1946 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 1947 | pub const IFMT = 0o170000; |
| 1948 | |
| 1949 | pub const IFIFO = 0o010000; |
| 1950 | pub const IFCHR = 0o020000; |
| 1951 | pub const IFDIR = 0o040000; |
| 1952 | pub const IFBLK = 0o060000; |
| 1953 | pub const IFREG = 0o100000; |
| 1954 | pub const IFLNK = 0o120000; |
| 1955 | pub const IFSOCK = 0o140000; |
| 1956 | pub const IFWHT = 0o160000; |
| 1957 | |
| 1958 | pub const ISUID = 0o4000; |
| 1959 | pub const ISGID = 0o2000; |
| 1960 | pub const ISVTX = 0o1000; |
| 1961 | pub const IRWXU = 0o700; |
| 1962 | pub const IRUSR = 0o400; |
| 1963 | pub const IWUSR = 0o200; |
| 1964 | pub const IXUSR = 0o100; |
| 1965 | pub const IRWXG = 0o070; |
| 1966 | pub const IRGRP = 0o040; |
| 1967 | pub const IWGRP = 0o020; |
| 1968 | pub const IXGRP = 0o010; |
| 1969 | pub const IRWXO = 0o007; |
| 1970 | pub const IROTH = 0o004; |
| 1971 | pub const IWOTH = 0o002; |
| 1972 | pub const IXOTH = 0o001; |
| 1973 | |
| 1974 | pub fn ISFIFO(m: u32) bool { |
| 1975 | return m & IFMT == IFIFO; |
| 1976 | } |
| 1977 | |
| 1978 | pub fn ISCHR(m: u32) bool { |
| 1979 | return m & IFMT == IFCHR; |
| 1980 | } |
| 1981 | |
| 1982 | pub fn ISDIR(m: u32) bool { |
| 1983 | return m & IFMT == IFDIR; |
| 1984 | } |
| 1985 | |
| 1986 | pub fn ISBLK(m: u32) bool { |
| 1987 | return m & IFMT == IFBLK; |
| 1988 | } |
| 1989 | |
| 1990 | pub fn ISREG(m: u32) bool { |
| 1991 | return m & IFMT == IFREG; |
| 1992 | } |
| 1993 | |
| 1994 | pub fn ISLNK(m: u32) bool { |
| 1995 | return m & IFMT == IFLNK; |
| 1996 | } |
| 1997 | |
| 1998 | pub fn ISSOCK(m: u32) bool { |
| 1999 | return m & IFMT == IFSOCK; |
| 2000 | } |
| 2001 | |
| 2002 | pub fn IWHT(m: u32) bool { |
| 2003 | return m & IFMT == IFWHT; |
| 2004 | } |
| 2005 | }, |
| 2006 | .freebsd => struct { |
| 2007 | pub const IFMT = 0o170000; |
| 2008 | |
| 2009 | pub const IFIFO = 0o010000; |
| 2010 | pub const IFCHR = 0o020000; |
| 2011 | pub const IFDIR = 0o040000; |
| 2012 | pub const IFBLK = 0o060000; |
| 2013 | pub const IFREG = 0o100000; |
| 2014 | pub const IFLNK = 0o120000; |
| 2015 | pub const IFSOCK = 0o140000; |
| 2016 | pub const IFWHT = 0o160000; |
| 2017 | |
| 2018 | pub const ISUID = 0o4000; |
| 2019 | pub const ISGID = 0o2000; |
| 2020 | pub const ISVTX = 0o1000; |
| 2021 | pub const IRWXU = 0o700; |
| 2022 | pub const IRUSR = 0o400; |
| 2023 | pub const IWUSR = 0o200; |
| 2024 | pub const IXUSR = 0o100; |
| 2025 | pub const IRWXG = 0o070; |
| 2026 | pub const IRGRP = 0o040; |
| 2027 | pub const IWGRP = 0o020; |
| 2028 | pub const IXGRP = 0o010; |
| 2029 | pub const IRWXO = 0o007; |
| 2030 | pub const IROTH = 0o004; |
| 2031 | pub const IWOTH = 0o002; |
| 2032 | pub const IXOTH = 0o001; |
| 2033 | |
| 2034 | pub fn ISFIFO(m: u32) bool { |
| 2035 | return m & IFMT == IFIFO; |
| 2036 | } |
| 2037 | |
| 2038 | pub fn ISCHR(m: u32) bool { |
| 2039 | return m & IFMT == IFCHR; |
| 2040 | } |
| 2041 | |
| 2042 | pub fn ISDIR(m: u32) bool { |
| 2043 | return m & IFMT == IFDIR; |
| 2044 | } |
| 2045 | |
| 2046 | pub fn ISBLK(m: u32) bool { |
| 2047 | return m & IFMT == IFBLK; |
| 2048 | } |
| 2049 | |
| 2050 | pub fn ISREG(m: u32) bool { |
| 2051 | return m & IFMT == IFREG; |
| 2052 | } |
| 2053 | |
| 2054 | pub fn ISLNK(m: u32) bool { |
| 2055 | return m & IFMT == IFLNK; |
| 2056 | } |
| 2057 | |
| 2058 | pub fn ISSOCK(m: u32) bool { |
| 2059 | return m & IFMT == IFSOCK; |
| 2060 | } |
| 2061 | |
| 2062 | pub fn IWHT(m: u32) bool { |
| 2063 | return m & IFMT == IFWHT; |
| 2064 | } |
| 2065 | }, |
| 2066 | .illumos => struct { |
| 2067 | pub const IFMT = 0o170000; |
| 2068 | |
| 2069 | pub const IFIFO = 0o010000; |
| 2070 | pub const IFCHR = 0o020000; |
| 2071 | pub const IFDIR = 0o040000; |
| 2072 | pub const IFBLK = 0o060000; |
| 2073 | pub const IFREG = 0o100000; |
| 2074 | pub const IFLNK = 0o120000; |
| 2075 | pub const IFSOCK = 0o140000; |
| 2076 | /// SunOS 2.6 Door |
| 2077 | pub const IFDOOR = 0o150000; |
| 2078 | /// Solaris 10 Event Port |
| 2079 | pub const IFPORT = 0o160000; |
| 2080 | |
| 2081 | pub const ISUID = 0o4000; |
| 2082 | pub const ISGID = 0o2000; |
| 2083 | pub const ISVTX = 0o1000; |
| 2084 | pub const IRWXU = 0o700; |
| 2085 | pub const IRUSR = 0o400; |
| 2086 | pub const IWUSR = 0o200; |
| 2087 | pub const IXUSR = 0o100; |
| 2088 | pub const IRWXG = 0o070; |
| 2089 | pub const IRGRP = 0o040; |
| 2090 | pub const IWGRP = 0o020; |
| 2091 | pub const IXGRP = 0o010; |
| 2092 | pub const IRWXO = 0o007; |
| 2093 | pub const IROTH = 0o004; |
| 2094 | pub const IWOTH = 0o002; |
| 2095 | pub const IXOTH = 0o001; |
| 2096 | |
| 2097 | pub fn ISFIFO(m: u32) bool { |
| 2098 | return m & IFMT == IFIFO; |
| 2099 | } |
| 2100 | |
| 2101 | pub fn ISCHR(m: u32) bool { |
| 2102 | return m & IFMT == IFCHR; |
| 2103 | } |
| 2104 | |
| 2105 | pub fn ISDIR(m: u32) bool { |
| 2106 | return m & IFMT == IFDIR; |
| 2107 | } |
| 2108 | |
| 2109 | pub fn ISBLK(m: u32) bool { |
| 2110 | return m & IFMT == IFBLK; |
| 2111 | } |
| 2112 | |
| 2113 | pub fn ISREG(m: u32) bool { |
| 2114 | return m & IFMT == IFREG; |
| 2115 | } |
| 2116 | |
| 2117 | pub fn ISLNK(m: u32) bool { |
| 2118 | return m & IFMT == IFLNK; |
| 2119 | } |
| 2120 | |
| 2121 | pub fn ISSOCK(m: u32) bool { |
| 2122 | return m & IFMT == IFSOCK; |
| 2123 | } |
| 2124 | |
| 2125 | pub fn ISDOOR(m: u32) bool { |
| 2126 | return m & IFMT == IFDOOR; |
| 2127 | } |
| 2128 | |
| 2129 | pub fn ISPORT(m: u32) bool { |
| 2130 | return m & IFMT == IFPORT; |
| 2131 | } |
| 2132 | }, |
| 2133 | .netbsd => struct { |
| 2134 | pub const IFMT = 0o170000; |
| 2135 | |
| 2136 | pub const IFIFO = 0o010000; |
| 2137 | pub const IFCHR = 0o020000; |
| 2138 | pub const IFDIR = 0o040000; |
| 2139 | pub const IFBLK = 0o060000; |
| 2140 | pub const IFREG = 0o100000; |
| 2141 | pub const IFLNK = 0o120000; |
| 2142 | pub const IFSOCK = 0o140000; |
| 2143 | pub const IFWHT = 0o160000; |
| 2144 | |
| 2145 | pub const ISUID = 0o4000; |
| 2146 | pub const ISGID = 0o2000; |
| 2147 | pub const ISVTX = 0o1000; |
| 2148 | pub const IRWXU = 0o700; |
| 2149 | pub const IRUSR = 0o400; |
| 2150 | pub const IWUSR = 0o200; |
| 2151 | pub const IXUSR = 0o100; |
| 2152 | pub const IRWXG = 0o070; |
| 2153 | pub const IRGRP = 0o040; |
| 2154 | pub const IWGRP = 0o020; |
| 2155 | pub const IXGRP = 0o010; |
| 2156 | pub const IRWXO = 0o007; |
| 2157 | pub const IROTH = 0o004; |
| 2158 | pub const IWOTH = 0o002; |
| 2159 | pub const IXOTH = 0o001; |
| 2160 | |
| 2161 | pub fn ISFIFO(m: u32) bool { |
| 2162 | return m & IFMT == IFIFO; |
| 2163 | } |
| 2164 | |
| 2165 | pub fn ISCHR(m: u32) bool { |
| 2166 | return m & IFMT == IFCHR; |
| 2167 | } |
| 2168 | |
| 2169 | pub fn ISDIR(m: u32) bool { |
| 2170 | return m & IFMT == IFDIR; |
| 2171 | } |
| 2172 | |
| 2173 | pub fn ISBLK(m: u32) bool { |
| 2174 | return m & IFMT == IFBLK; |
| 2175 | } |
| 2176 | |
| 2177 | pub fn ISREG(m: u32) bool { |
| 2178 | return m & IFMT == IFREG; |
| 2179 | } |
| 2180 | |
| 2181 | pub fn ISLNK(m: u32) bool { |
| 2182 | return m & IFMT == IFLNK; |
| 2183 | } |
| 2184 | |
| 2185 | pub fn ISSOCK(m: u32) bool { |
| 2186 | return m & IFMT == IFSOCK; |
| 2187 | } |
| 2188 | |
| 2189 | pub fn IWHT(m: u32) bool { |
| 2190 | return m & IFMT == IFWHT; |
| 2191 | } |
| 2192 | }, |
| 2193 | .dragonfly => struct { |
| 2194 | pub const IFMT = 0o170000; |
| 2195 | |
| 2196 | pub const IFIFO = 0o010000; |
| 2197 | pub const IFCHR = 0o020000; |
| 2198 | pub const IFDIR = 0o040000; |
| 2199 | pub const IFBLK = 0o060000; |
| 2200 | pub const IFREG = 0o100000; |
| 2201 | pub const IFLNK = 0o120000; |
| 2202 | pub const IFSOCK = 0o140000; |
| 2203 | pub const IFWHT = 0o160000; |
| 2204 | |
| 2205 | pub const ISUID = 0o4000; |
| 2206 | pub const ISGID = 0o2000; |
| 2207 | pub const ISVTX = 0o1000; |
| 2208 | pub const IRWXU = 0o700; |
| 2209 | pub const IRUSR = 0o400; |
| 2210 | pub const IWUSR = 0o200; |
| 2211 | pub const IXUSR = 0o100; |
| 2212 | pub const IRWXG = 0o070; |
| 2213 | pub const IRGRP = 0o040; |
| 2214 | pub const IWGRP = 0o020; |
| 2215 | pub const IXGRP = 0o010; |
| 2216 | pub const IRWXO = 0o007; |
| 2217 | pub const IROTH = 0o004; |
| 2218 | pub const IWOTH = 0o002; |
| 2219 | pub const IXOTH = 0o001; |
| 2220 | |
| 2221 | pub const IREAD = IRUSR; |
| 2222 | pub const IEXEC = IXUSR; |
| 2223 | pub const IWRITE = IWUSR; |
| 2224 | pub const ISTXT = 512; |
| 2225 | pub const BLKSIZE = 512; |
| 2226 | |
| 2227 | pub fn ISFIFO(m: u32) bool { |
| 2228 | return m & IFMT == IFIFO; |
| 2229 | } |
| 2230 | |
| 2231 | pub fn ISCHR(m: u32) bool { |
| 2232 | return m & IFMT == IFCHR; |
| 2233 | } |
| 2234 | |
| 2235 | pub fn ISDIR(m: u32) bool { |
| 2236 | return m & IFMT == IFDIR; |
| 2237 | } |
| 2238 | |
| 2239 | pub fn ISBLK(m: u32) bool { |
| 2240 | return m & IFMT == IFBLK; |
| 2241 | } |
| 2242 | |
| 2243 | pub fn ISREG(m: u32) bool { |
| 2244 | return m & IFMT == IFREG; |
| 2245 | } |
| 2246 | |
| 2247 | pub fn ISLNK(m: u32) bool { |
| 2248 | return m & IFMT == IFLNK; |
| 2249 | } |
| 2250 | |
| 2251 | pub fn ISSOCK(m: u32) bool { |
| 2252 | return m & IFMT == IFSOCK; |
| 2253 | } |
| 2254 | |
| 2255 | pub fn IWHT(m: u32) bool { |
| 2256 | return m & IFMT == IFWHT; |
| 2257 | } |
| 2258 | }, |
| 2259 | .haiku => struct { |
| 2260 | pub const IFMT = 0o170000; |
| 2261 | pub const IFSOCK = 0o140000; |
| 2262 | pub const IFLNK = 0o120000; |
| 2263 | pub const IFREG = 0o100000; |
| 2264 | pub const IFBLK = 0o060000; |
| 2265 | pub const IFDIR = 0o040000; |
| 2266 | pub const IFCHR = 0o020000; |
| 2267 | pub const IFIFO = 0o010000; |
| 2268 | pub const INDEX_DIR = 0o4000000000; |
| 2269 | |
| 2270 | pub const IUMSK = 0o7777; |
| 2271 | pub const ISUID = 0o4000; |
| 2272 | pub const ISGID = 0o2000; |
| 2273 | pub const ISVTX = 0o1000; |
| 2274 | pub const IRWXU = 0o700; |
| 2275 | pub const IRUSR = 0o400; |
| 2276 | pub const IWUSR = 0o200; |
| 2277 | pub const IXUSR = 0o100; |
| 2278 | pub const IRWXG = 0o070; |
| 2279 | pub const IRGRP = 0o040; |
| 2280 | pub const IWGRP = 0o020; |
| 2281 | pub const IXGRP = 0o010; |
| 2282 | pub const IRWXO = 0o007; |
| 2283 | pub const IROTH = 0o004; |
| 2284 | pub const IWOTH = 0o002; |
| 2285 | pub const IXOTH = 0o001; |
| 2286 | |
| 2287 | pub fn ISREG(m: u32) bool { |
| 2288 | return m & IFMT == IFREG; |
| 2289 | } |
| 2290 | |
| 2291 | pub fn ISLNK(m: u32) bool { |
| 2292 | return m & IFMT == IFLNK; |
| 2293 | } |
| 2294 | |
| 2295 | pub fn ISBLK(m: u32) bool { |
| 2296 | return m & IFMT == IFBLK; |
| 2297 | } |
| 2298 | |
| 2299 | pub fn ISDIR(m: u32) bool { |
| 2300 | return m & IFMT == IFDIR; |
| 2301 | } |
| 2302 | |
| 2303 | pub fn ISCHR(m: u32) bool { |
| 2304 | return m & IFMT == IFCHR; |
| 2305 | } |
| 2306 | |
| 2307 | pub fn ISFIFO(m: u32) bool { |
| 2308 | return m & IFMT == IFIFO; |
| 2309 | } |
| 2310 | |
| 2311 | pub fn ISSOCK(m: u32) bool { |
| 2312 | return m & IFMT == IFSOCK; |
| 2313 | } |
| 2314 | |
| 2315 | pub fn ISINDEX(m: u32) bool { |
| 2316 | return m & INDEX_DIR == INDEX_DIR; |
| 2317 | } |
| 2318 | }, |
| 2319 | .openbsd => struct { |
| 2320 | pub const IFMT = 0o170000; |
| 2321 | |
| 2322 | pub const IFIFO = 0o010000; |
| 2323 | pub const IFCHR = 0o020000; |
| 2324 | pub const IFDIR = 0o040000; |
| 2325 | pub const IFBLK = 0o060000; |
| 2326 | pub const IFREG = 0o100000; |
| 2327 | pub const IFLNK = 0o120000; |
| 2328 | pub const IFSOCK = 0o140000; |
| 2329 | |
| 2330 | pub const ISUID = 0o4000; |
| 2331 | pub const ISGID = 0o2000; |
| 2332 | pub const ISVTX = 0o1000; |
| 2333 | pub const IRWXU = 0o700; |
| 2334 | pub const IRUSR = 0o400; |
| 2335 | pub const IWUSR = 0o200; |
| 2336 | pub const IXUSR = 0o100; |
| 2337 | pub const IRWXG = 0o070; |
| 2338 | pub const IRGRP = 0o040; |
| 2339 | pub const IWGRP = 0o020; |
| 2340 | pub const IXGRP = 0o010; |
| 2341 | pub const IRWXO = 0o007; |
| 2342 | pub const IROTH = 0o004; |
| 2343 | pub const IWOTH = 0o002; |
| 2344 | pub const IXOTH = 0o001; |
| 2345 | |
| 2346 | pub const BLKSIZE = 512; |
| 2347 | |
| 2348 | pub fn ISFIFO(m: u32) bool { |
| 2349 | return m & IFMT == IFIFO; |
| 2350 | } |
| 2351 | |
| 2352 | pub fn ISCHR(m: u32) bool { |
| 2353 | return m & IFMT == IFCHR; |
| 2354 | } |
| 2355 | |
| 2356 | pub fn ISDIR(m: u32) bool { |
| 2357 | return m & IFMT == IFDIR; |
| 2358 | } |
| 2359 | |
| 2360 | pub fn ISBLK(m: u32) bool { |
| 2361 | return m & IFMT == IFBLK; |
| 2362 | } |
| 2363 | |
| 2364 | pub fn ISREG(m: u32) bool { |
| 2365 | return m & IFMT == IFREG; |
| 2366 | } |
| 2367 | |
| 2368 | pub fn ISLNK(m: u32) bool { |
| 2369 | return m & IFMT == IFLNK; |
| 2370 | } |
| 2371 | |
| 2372 | pub fn ISSOCK(m: u32) bool { |
| 2373 | return m & IFMT == IFSOCK; |
| 2374 | } |
| 2375 | }, |
| 2376 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L16-L51 |
| 2377 | .serenity => struct { |
| 2378 | pub const IFMT = 0o170000; |
| 2379 | pub const IFDIR = 0o040000; |
| 2380 | pub const IFCHR = 0o020000; |
| 2381 | pub const IFBLK = 0o060000; |
| 2382 | pub const IFREG = 0o100000; |
| 2383 | pub const IFIFO = 0o010000; |
| 2384 | pub const IFLNK = 0o120000; |
| 2385 | pub const IFSOCK = 0o140000; |
| 2386 | |
| 2387 | pub const ISUID = 0o4000; |
| 2388 | pub const ISGID = 0o2000; |
| 2389 | pub const ISVTX = 0o1000; |
| 2390 | pub const IRUSR = 0o400; |
| 2391 | pub const IWUSR = 0o200; |
| 2392 | pub const IXUSR = 0o100; |
| 2393 | pub const IREAD = IRUSR; |
| 2394 | pub const IWRITE = IWUSR; |
| 2395 | pub const IEXEC = IXUSR; |
| 2396 | pub const IRGRP = 0o040; |
| 2397 | pub const IWGRP = 0o020; |
| 2398 | pub const IXGRP = 0o010; |
| 2399 | pub const IROTH = 0o004; |
| 2400 | pub const IWOTH = 0o002; |
| 2401 | pub const IXOTH = 0o001; |
| 2402 | |
| 2403 | pub const IRWXU = IRUSR | IWUSR | IXUSR; |
| 2404 | |
| 2405 | pub const IRWXG = IRWXU >> 3; |
| 2406 | pub const IRWXO = IRWXG >> 3; |
| 2407 | |
| 2408 | pub fn ISDIR(m: u32) bool { |
| 2409 | return m & IFMT == IFDIR; |
| 2410 | } |
| 2411 | |
| 2412 | pub fn ISCHR(m: u32) bool { |
| 2413 | return m & IFMT == IFCHR; |
| 2414 | } |
| 2415 | |
| 2416 | pub fn ISBLK(m: u32) bool { |
| 2417 | return m & IFMT == IFBLK; |
| 2418 | } |
| 2419 | |
| 2420 | pub fn ISREG(m: u32) bool { |
| 2421 | return m & IFMT == IFREG; |
| 2422 | } |
| 2423 | |
| 2424 | pub fn ISFIFO(m: u32) bool { |
| 2425 | return m & IFMT == IFIFO; |
| 2426 | } |
| 2427 | |
| 2428 | pub fn ISLNK(m: u32) bool { |
| 2429 | return m & IFMT == IFLNK; |
| 2430 | } |
| 2431 | |
| 2432 | pub fn ISSOCK(m: u32) bool { |
| 2433 | return m & IFMT == IFSOCK; |
| 2434 | } |
| 2435 | }, |
| 2436 | else => void, |
| 2437 | }; |
| 2438 | pub const SA = switch (native_os) { |
| 2439 | .linux => linux.SA, |
| 2440 | .emscripten => emscripten.SA, |
| 2441 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 2442 | /// take signal on signal stack |
| 2443 | pub const ONSTACK = 0x0001; |
| 2444 | /// restart system on signal return |
| 2445 | pub const RESTART = 0x0002; |
| 2446 | /// reset to SIG.DFL when taking signal |
| 2447 | pub const RESETHAND = 0x0004; |
| 2448 | /// do not generate SIG.CHLD on child stop |
| 2449 | pub const NOCLDSTOP = 0x0008; |
| 2450 | /// don't mask the signal we're delivering |
| 2451 | pub const NODEFER = 0x0010; |
| 2452 | /// don't keep zombies around |
| 2453 | pub const NOCLDWAIT = 0x0020; |
| 2454 | /// signal handler with SIGINFO args |
| 2455 | pub const SIGINFO = 0x0040; |
| 2456 | /// do not bounce off kernel's sigtramp |
| 2457 | pub const USERTRAMP = 0x0100; |
| 2458 | /// signal handler with SIGINFO args with 64bit regs information |
| 2459 | pub const @"64REGSET" = 0x0200; |
| 2460 | }, |
| 2461 | .freebsd => struct { |
| 2462 | pub const ONSTACK = 0x0001; |
| 2463 | pub const RESTART = 0x0002; |
| 2464 | pub const RESETHAND = 0x0004; |
| 2465 | pub const NOCLDSTOP = 0x0008; |
| 2466 | pub const NODEFER = 0x0010; |
| 2467 | pub const NOCLDWAIT = 0x0020; |
| 2468 | pub const SIGINFO = 0x0040; |
| 2469 | }, |
| 2470 | .illumos => struct { |
| 2471 | pub const ONSTACK = 0x00000001; |
| 2472 | pub const RESETHAND = 0x00000002; |
| 2473 | pub const RESTART = 0x00000004; |
| 2474 | pub const SIGINFO = 0x00000008; |
| 2475 | pub const NODEFER = 0x00000010; |
| 2476 | pub const NOCLDWAIT = 0x00010000; |
| 2477 | }, |
| 2478 | .netbsd => struct { |
| 2479 | pub const ONSTACK = 0x0001; |
| 2480 | pub const RESTART = 0x0002; |
| 2481 | pub const RESETHAND = 0x0004; |
| 2482 | pub const NOCLDSTOP = 0x0008; |
| 2483 | pub const NODEFER = 0x0010; |
| 2484 | pub const NOCLDWAIT = 0x0020; |
| 2485 | pub const SIGINFO = 0x0040; |
| 2486 | }, |
| 2487 | .dragonfly => struct { |
| 2488 | pub const ONSTACK = 0x0001; |
| 2489 | pub const RESTART = 0x0002; |
| 2490 | pub const RESETHAND = 0x0004; |
| 2491 | pub const NODEFER = 0x0010; |
| 2492 | pub const NOCLDWAIT = 0x0020; |
| 2493 | pub const SIGINFO = 0x0040; |
| 2494 | }, |
| 2495 | .haiku => struct { |
| 2496 | pub const NOCLDSTOP = 0x01; |
| 2497 | pub const NOCLDWAIT = 0x02; |
| 2498 | pub const RESETHAND = 0x04; |
| 2499 | pub const NODEFER = 0x08; |
| 2500 | pub const RESTART = 0x10; |
| 2501 | pub const ONSTACK = 0x20; |
| 2502 | pub const SIGINFO = 0x40; |
| 2503 | pub const NOMASK = NODEFER; |
| 2504 | pub const STACK = ONSTACK; |
| 2505 | pub const ONESHOT = RESETHAND; |
| 2506 | }, |
| 2507 | .openbsd => struct { |
| 2508 | pub const ONSTACK = 0x0001; |
| 2509 | pub const RESTART = 0x0002; |
| 2510 | pub const RESETHAND = 0x0004; |
| 2511 | pub const NOCLDSTOP = 0x0008; |
| 2512 | pub const NODEFER = 0x0010; |
| 2513 | pub const NOCLDWAIT = 0x0020; |
| 2514 | pub const SIGINFO = 0x0040; |
| 2515 | }, |
| 2516 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L65-L71 |
| 2517 | .serenity => struct { |
| 2518 | pub const NOCLDSTOP = 1; |
| 2519 | pub const NOCLDWAIT = 2; |
| 2520 | pub const SIGINFO = 4; |
| 2521 | pub const ONSTACK = 0x08000000; |
| 2522 | pub const RESTART = 0x10000000; |
| 2523 | pub const NODEFER = 0x40000000; |
| 2524 | pub const RESETHAND = 0x80000000; |
| 2525 | pub const NOMASK = NODEFER; |
| 2526 | pub const ONESHOT = RESETHAND; |
| 2527 | }, |
| 2528 | else => void, |
| 2529 | }; |
| 2530 | pub const sigval_t = switch (native_os) { |
| 2531 | .netbsd, .illumos => extern union { |
| 2532 | int: i32, |
| 2533 | ptr: ?*anyopaque, |
| 2534 | }, |
| 2535 | else => void, |
| 2536 | }; |
| 2537 | |
| 2538 | pub const SC = switch (native_os) { |
| 2539 | .linux => linux.SC, |
| 2540 | else => void, |
| 2541 | }; |
| 2542 | |
| 2543 | pub const _SC = if (builtin.abi.isAndroid()) enum(c_int) { |
| 2544 | PAGESIZE = 39, |
| 2545 | NPROCESSORS_ONLN = 97, |
| 2546 | } else switch (native_os) { |
| 2547 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) { |
| 2548 | PAGESIZE = 29, |
| 2549 | }, |
| 2550 | .dragonfly => enum(c_int) { |
| 2551 | PAGESIZE = 47, |
| 2552 | }, |
| 2553 | .freebsd => enum(c_int) { |
| 2554 | PAGESIZE = 47, |
| 2555 | }, |
| 2556 | .fuchsia => enum(c_int) { |
| 2557 | PAGESIZE = 30, |
| 2558 | }, |
| 2559 | .haiku => enum(c_int) { |
| 2560 | PAGESIZE = 27, |
| 2561 | }, |
| 2562 | .linux => enum(c_int) { |
| 2563 | PAGESIZE = 30, |
| 2564 | }, |
| 2565 | .netbsd => enum(c_int) { |
| 2566 | PAGESIZE = 28, |
| 2567 | }, |
| 2568 | .openbsd => enum(c_int) { |
| 2569 | PAGESIZE = 28, |
| 2570 | }, |
| 2571 | .illumos => enum(c_int) { |
| 2572 | PAGESIZE = 11, |
| 2573 | NPROCESSORS_ONLN = 15, |
| 2574 | SIGRT_MIN = 40, |
| 2575 | SIGRT_MAX = 41, |
| 2576 | }, |
| 2577 | // https://github.com/SerenityOS/serenity/blob/1dfc9e2df39dd23f1de92530677c845aae4345f2/Kernel/API/POSIX/unistd.h#L36-L52 |
| 2578 | .serenity => enum(c_int) { |
| 2579 | MONOTONIC_CLOCK = 0, |
| 2580 | NPROCESSORS_CONF = 1, |
| 2581 | NPROCESSORS_ONLN = 2, |
| 2582 | OPEN_MAX = 3, |
| 2583 | HOST_NAME_MAX = 4, |
| 2584 | TTY_NAME_MAX = 5, |
| 2585 | PAGESIZE = 6, |
| 2586 | GETPW_R_SIZE_MAX = 7, |
| 2587 | GETGR_R_SIZE_MAX = 8, |
| 2588 | CLK_TCK = 9, |
| 2589 | SYMLOOP_MAX = 10, |
| 2590 | MAPPED_FILES = 11, |
| 2591 | ARG_MAX = 12, |
| 2592 | IOV_MAX = 13, |
| 2593 | PHYS_PAGES = 14, |
| 2594 | }, |
| 2595 | else => void, |
| 2596 | }; |
| 2597 | |
| 2598 | pub const SEEK = switch (native_os) { |
| 2599 | .linux => linux.SEEK, |
| 2600 | .emscripten => emscripten.SEEK, |
| 2601 | .wasi => struct { |
| 2602 | pub const SET: wasi.whence_t = .SET; |
| 2603 | pub const CUR: wasi.whence_t = .CUR; |
| 2604 | pub const END: wasi.whence_t = .END; |
| 2605 | }, |
| 2606 | // https://github.com/SerenityOS/serenity/blob/808ce594db1f2190e5212a250e900bde2ffe710b/Kernel/API/POSIX/stdio.h#L15-L17 |
| 2607 | .openbsd, .haiku, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows, .serenity => struct { |
| 2608 | pub const SET = 0; |
| 2609 | pub const CUR = 1; |
| 2610 | pub const END = 2; |
| 2611 | }, |
| 2612 | .dragonfly, .illumos => struct { |
| 2613 | pub const SET = 0; |
| 2614 | pub const CUR = 1; |
| 2615 | pub const END = 2; |
| 2616 | pub const DATA = 3; |
| 2617 | pub const HOLE = 4; |
| 2618 | }, |
| 2619 | else => void, |
| 2620 | }; |
| 2621 | pub const SHUT = switch (native_os) { |
| 2622 | .linux => linux.SHUT, |
| 2623 | .emscripten => emscripten.SHUT, |
| 2624 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L40-L42 |
| 2625 | else => struct { |
| 2626 | pub const RD = 0; |
| 2627 | pub const WR = 1; |
| 2628 | pub const RDWR = 2; |
| 2629 | }, |
| 2630 | }; |
| 2631 | |
| 2632 | /// Signal types |
| 2633 | pub const SIG = switch (native_os) { |
| 2634 | .linux => linux.SIG, |
| 2635 | .emscripten => emscripten.SIG, |
| 2636 | .windows => enum(u32) { |
| 2637 | /// interrupt |
| 2638 | INT = 2, |
| 2639 | /// illegal instruction - invalid function image |
| 2640 | ILL = 4, |
| 2641 | /// floating point exception |
| 2642 | FPE = 8, |
| 2643 | /// segment violation |
| 2644 | SEGV = 11, |
| 2645 | /// Software termination signal from kill |
| 2646 | TERM = 15, |
| 2647 | /// Ctrl-Break sequence |
| 2648 | BREAK = 21, |
| 2649 | /// abnormal termination triggered by abort call |
| 2650 | ABRT = 22, |
| 2651 | /// SIGABRT compatible with other platforms, same as SIGABRT |
| 2652 | ABRT_COMPAT = 6, |
| 2653 | _, |
| 2654 | |
| 2655 | // Signal action codes |
| 2656 | /// default signal action |
| 2657 | pub const DFL = 0; |
| 2658 | /// ignore signal |
| 2659 | pub const IGN = 1; |
| 2660 | /// return current value |
| 2661 | pub const GET = 2; |
| 2662 | /// signal gets error |
| 2663 | pub const SGE = 3; |
| 2664 | /// acknowledge |
| 2665 | pub const ACK = 4; |
| 2666 | /// Signal error value (returned by signal call on error) |
| 2667 | pub const ERR = -1; |
| 2668 | }, |
| 2669 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(u32) { |
| 2670 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2671 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2672 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2673 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(5); |
| 2674 | |
| 2675 | /// block specified signal set |
| 2676 | pub const BLOCK = 1; |
| 2677 | /// unblock specified signal set |
| 2678 | pub const UNBLOCK = 2; |
| 2679 | /// set specified signal set |
| 2680 | pub const SETMASK = 3; |
| 2681 | |
| 2682 | pub const IOT: SIG = .ABRT; |
| 2683 | pub const POLL: SIG = .EMT; |
| 2684 | |
| 2685 | /// hangup |
| 2686 | HUP = 1, |
| 2687 | /// interrupt |
| 2688 | INT = 2, |
| 2689 | /// quit |
| 2690 | QUIT = 3, |
| 2691 | /// illegal instruction (not reset when caught) |
| 2692 | ILL = 4, |
| 2693 | /// trace trap (not reset when caught) |
| 2694 | TRAP = 5, |
| 2695 | /// abort() |
| 2696 | ABRT = 6, |
| 2697 | /// EMT instruction |
| 2698 | EMT = 7, |
| 2699 | /// floating point exception |
| 2700 | FPE = 8, |
| 2701 | /// kill (cannot be caught or ignored) |
| 2702 | KILL = 9, |
| 2703 | /// bus error |
| 2704 | BUS = 10, |
| 2705 | /// segmentation violation |
| 2706 | SEGV = 11, |
| 2707 | /// bad argument to system call |
| 2708 | SYS = 12, |
| 2709 | /// write on a pipe with no one to read it |
| 2710 | PIPE = 13, |
| 2711 | /// alarm clock |
| 2712 | ALRM = 14, |
| 2713 | /// software termination signal from kill |
| 2714 | TERM = 15, |
| 2715 | /// urgent condition on IO channel |
| 2716 | URG = 16, |
| 2717 | /// sendable stop signal not from tty |
| 2718 | STOP = 17, |
| 2719 | /// stop signal from tty |
| 2720 | TSTP = 18, |
| 2721 | /// continue a stopped process |
| 2722 | CONT = 19, |
| 2723 | /// to parent on child stop or exit |
| 2724 | CHLD = 20, |
| 2725 | /// to readers pgrp upon background tty read |
| 2726 | TTIN = 21, |
| 2727 | /// like TTIN for output if (tp->t_local&LTOSTOP) |
| 2728 | TTOU = 22, |
| 2729 | /// input/output possible signal |
| 2730 | IO = 23, |
| 2731 | /// exceeded CPU time limit |
| 2732 | XCPU = 24, |
| 2733 | /// exceeded file size limit |
| 2734 | XFSZ = 25, |
| 2735 | /// virtual time alarm |
| 2736 | VTALRM = 26, |
| 2737 | /// profiling time alarm |
| 2738 | PROF = 27, |
| 2739 | /// window size changes |
| 2740 | WINCH = 28, |
| 2741 | /// information request |
| 2742 | INFO = 29, |
| 2743 | /// user defined signal 1 |
| 2744 | USR1 = 30, |
| 2745 | /// user defined signal 2 |
| 2746 | USR2 = 31, |
| 2747 | _, |
| 2748 | }, |
| 2749 | .freebsd => enum(u32) { |
| 2750 | pub const BLOCK = 1; |
| 2751 | pub const UNBLOCK = 2; |
| 2752 | pub const SETMASK = 3; |
| 2753 | |
| 2754 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2755 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2756 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2757 | |
| 2758 | pub const WORDS = 4; |
| 2759 | pub const MAXSIG = 128; |
| 2760 | |
| 2761 | pub inline fn IDX(sig: usize) usize { |
| 2762 | return sig - 1; |
| 2763 | } |
| 2764 | pub inline fn WORD(sig: usize) usize { |
| 2765 | return IDX(sig) >> 5; |
| 2766 | } |
| 2767 | pub inline fn BIT(sig: usize) usize { |
| 2768 | return 1 << (IDX(sig) & 31); |
| 2769 | } |
| 2770 | pub inline fn VALID(sig: usize) usize { |
| 2771 | return sig <= MAXSIG and sig > 0; |
| 2772 | } |
| 2773 | |
| 2774 | pub const IOT: SIG = .ABRT; |
| 2775 | pub const LWP: SIG = .THR; |
| 2776 | |
| 2777 | pub const RTMIN = 65; |
| 2778 | pub const RTMAX = 126; |
| 2779 | |
| 2780 | HUP = 1, |
| 2781 | INT = 2, |
| 2782 | QUIT = 3, |
| 2783 | ILL = 4, |
| 2784 | TRAP = 5, |
| 2785 | ABRT = 6, |
| 2786 | EMT = 7, |
| 2787 | FPE = 8, |
| 2788 | KILL = 9, |
| 2789 | BUS = 10, |
| 2790 | SEGV = 11, |
| 2791 | SYS = 12, |
| 2792 | PIPE = 13, |
| 2793 | ALRM = 14, |
| 2794 | TERM = 15, |
| 2795 | URG = 16, |
| 2796 | STOP = 17, |
| 2797 | TSTP = 18, |
| 2798 | CONT = 19, |
| 2799 | CHLD = 20, |
| 2800 | TTIN = 21, |
| 2801 | TTOU = 22, |
| 2802 | IO = 23, |
| 2803 | XCPU = 24, |
| 2804 | XFSZ = 25, |
| 2805 | VTALRM = 26, |
| 2806 | PROF = 27, |
| 2807 | WINCH = 28, |
| 2808 | INFO = 29, |
| 2809 | USR1 = 30, |
| 2810 | USR2 = 31, |
| 2811 | THR = 32, |
| 2812 | LIBRT = 33, |
| 2813 | _, |
| 2814 | }, |
| 2815 | .illumos => enum(u32) { |
| 2816 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2817 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2818 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2819 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(2); |
| 2820 | |
| 2821 | pub const WORDS = 4; |
| 2822 | pub const MAXSIG = 75; |
| 2823 | |
| 2824 | pub const BLOCK = 1; |
| 2825 | pub const UNBLOCK = 2; |
| 2826 | pub const SETMASK = 3; |
| 2827 | |
| 2828 | pub const RTMIN = 42; |
| 2829 | pub const RTMAX = 74; |
| 2830 | |
| 2831 | pub inline fn IDX(sig: usize) usize { |
| 2832 | return sig - 1; |
| 2833 | } |
| 2834 | pub inline fn WORD(sig: usize) usize { |
| 2835 | return IDX(sig) >> 5; |
| 2836 | } |
| 2837 | pub inline fn BIT(sig: usize) usize { |
| 2838 | return 1 << (IDX(sig) & 31); |
| 2839 | } |
| 2840 | pub inline fn VALID(sig: usize) usize { |
| 2841 | return sig <= MAXSIG and sig > 0; |
| 2842 | } |
| 2843 | |
| 2844 | pub const POLL: SIG = .IO; |
| 2845 | pub const IOT: SIG = .ABRT; |
| 2846 | pub const CLD: SIG = .CHLD; |
| 2847 | |
| 2848 | HUP = 1, |
| 2849 | INT = 2, |
| 2850 | QUIT = 3, |
| 2851 | ILL = 4, |
| 2852 | TRAP = 5, |
| 2853 | ABRT = 6, |
| 2854 | EMT = 7, |
| 2855 | FPE = 8, |
| 2856 | KILL = 9, |
| 2857 | BUS = 10, |
| 2858 | SEGV = 11, |
| 2859 | SYS = 12, |
| 2860 | PIPE = 13, |
| 2861 | ALRM = 14, |
| 2862 | TERM = 15, |
| 2863 | USR1 = 16, |
| 2864 | USR2 = 17, |
| 2865 | CHLD = 18, |
| 2866 | PWR = 19, |
| 2867 | WINCH = 20, |
| 2868 | URG = 21, |
| 2869 | IO = 22, |
| 2870 | STOP = 23, |
| 2871 | TSTP = 24, |
| 2872 | CONT = 25, |
| 2873 | TTIN = 26, |
| 2874 | TTOU = 27, |
| 2875 | VTALRM = 28, |
| 2876 | PROF = 29, |
| 2877 | XCPU = 30, |
| 2878 | XFSZ = 31, |
| 2879 | WAITING = 32, |
| 2880 | LWP = 33, |
| 2881 | FREEZE = 34, |
| 2882 | THAW = 35, |
| 2883 | CANCEL = 36, |
| 2884 | LOST = 37, |
| 2885 | XRES = 38, |
| 2886 | JVM1 = 39, |
| 2887 | JVM2 = 40, |
| 2888 | INFO = 41, |
| 2889 | _, |
| 2890 | }, |
| 2891 | .netbsd => enum(u32) { |
| 2892 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2893 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2894 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2895 | |
| 2896 | pub const WORDS = 4; |
| 2897 | pub const MAXSIG = 128; |
| 2898 | |
| 2899 | pub const BLOCK = 1; |
| 2900 | pub const UNBLOCK = 2; |
| 2901 | pub const SETMASK = 3; |
| 2902 | |
| 2903 | pub const RTMIN = 33; |
| 2904 | pub const RTMAX = 63; |
| 2905 | |
| 2906 | pub inline fn IDX(sig: usize) usize { |
| 2907 | return sig - 1; |
| 2908 | } |
| 2909 | pub inline fn WORD(sig: usize) usize { |
| 2910 | return IDX(sig) >> 5; |
| 2911 | } |
| 2912 | pub inline fn BIT(sig: usize) usize { |
| 2913 | return 1 << (IDX(sig) & 31); |
| 2914 | } |
| 2915 | pub inline fn VALID(sig: usize) usize { |
| 2916 | return sig <= MAXSIG and sig > 0; |
| 2917 | } |
| 2918 | |
| 2919 | pub const IOT: SIG = .ABRT; |
| 2920 | |
| 2921 | HUP = 1, |
| 2922 | INT = 2, |
| 2923 | QUIT = 3, |
| 2924 | ILL = 4, |
| 2925 | TRAP = 5, |
| 2926 | ABRT = 6, |
| 2927 | EMT = 7, |
| 2928 | FPE = 8, |
| 2929 | KILL = 9, |
| 2930 | BUS = 10, |
| 2931 | SEGV = 11, |
| 2932 | SYS = 12, |
| 2933 | PIPE = 13, |
| 2934 | ALRM = 14, |
| 2935 | TERM = 15, |
| 2936 | URG = 16, |
| 2937 | STOP = 17, |
| 2938 | TSTP = 18, |
| 2939 | CONT = 19, |
| 2940 | CHLD = 20, |
| 2941 | TTIN = 21, |
| 2942 | TTOU = 22, |
| 2943 | IO = 23, |
| 2944 | XCPU = 24, |
| 2945 | XFSZ = 25, |
| 2946 | VTALRM = 26, |
| 2947 | PROF = 27, |
| 2948 | WINCH = 28, |
| 2949 | INFO = 29, |
| 2950 | USR1 = 30, |
| 2951 | USR2 = 31, |
| 2952 | PWR = 32, |
| 2953 | _, |
| 2954 | }, |
| 2955 | .dragonfly => enum(u32) { |
| 2956 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2957 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2958 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2959 | |
| 2960 | pub const BLOCK = 1; |
| 2961 | pub const UNBLOCK = 2; |
| 2962 | pub const SETMASK = 3; |
| 2963 | |
| 2964 | pub const WORDS = 4; |
| 2965 | |
| 2966 | pub const IOT: SIG = .ABRT; |
| 2967 | |
| 2968 | HUP = 1, |
| 2969 | INT = 2, |
| 2970 | QUIT = 3, |
| 2971 | ILL = 4, |
| 2972 | TRAP = 5, |
| 2973 | ABRT = 6, |
| 2974 | EMT = 7, |
| 2975 | FPE = 8, |
| 2976 | KILL = 9, |
| 2977 | BUS = 10, |
| 2978 | SEGV = 11, |
| 2979 | SYS = 12, |
| 2980 | PIPE = 13, |
| 2981 | ALRM = 14, |
| 2982 | TERM = 15, |
| 2983 | URG = 16, |
| 2984 | STOP = 17, |
| 2985 | TSTP = 18, |
| 2986 | CONT = 19, |
| 2987 | CHLD = 20, |
| 2988 | TTIN = 21, |
| 2989 | TTOU = 22, |
| 2990 | IO = 23, |
| 2991 | XCPU = 24, |
| 2992 | XFSZ = 25, |
| 2993 | VTALRM = 26, |
| 2994 | PROF = 27, |
| 2995 | WINCH = 28, |
| 2996 | INFO = 29, |
| 2997 | USR1 = 30, |
| 2998 | USR2 = 31, |
| 2999 | THR = 32, |
| 3000 | CKPT = 33, |
| 3001 | CKPTEXIT = 34, |
| 3002 | _, |
| 3003 | }, |
| 3004 | .haiku => enum(u32) { |
| 3005 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3006 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 3007 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3008 | |
| 3009 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); |
| 3010 | |
| 3011 | pub const BLOCK = 1; |
| 3012 | pub const UNBLOCK = 2; |
| 3013 | pub const SETMASK = 3; |
| 3014 | |
| 3015 | pub const IO: SIG = .POLL; |
| 3016 | pub const IOT: SIG = .ABRT; |
| 3017 | |
| 3018 | HUP = 1, |
| 3019 | INT = 2, |
| 3020 | QUIT = 3, |
| 3021 | ILL = 4, |
| 3022 | CHLD = 5, |
| 3023 | ABRT = 6, |
| 3024 | PIPE = 7, |
| 3025 | FPE = 8, |
| 3026 | KILL = 9, |
| 3027 | STOP = 10, |
| 3028 | SEGV = 11, |
| 3029 | CONT = 12, |
| 3030 | TSTP = 13, |
| 3031 | ALRM = 14, |
| 3032 | TERM = 15, |
| 3033 | TTIN = 16, |
| 3034 | TTOU = 17, |
| 3035 | USR1 = 18, |
| 3036 | USR2 = 19, |
| 3037 | WINCH = 20, |
| 3038 | KILLTHR = 21, |
| 3039 | TRAP = 22, |
| 3040 | POLL = 23, |
| 3041 | PROF = 24, |
| 3042 | SYS = 25, |
| 3043 | URG = 26, |
| 3044 | VTALRM = 27, |
| 3045 | XCPU = 28, |
| 3046 | XFSZ = 29, |
| 3047 | BUS = 30, |
| 3048 | RESERVED1 = 31, |
| 3049 | RESERVED2 = 32, |
| 3050 | _, |
| 3051 | }, |
| 3052 | .openbsd => enum(u32) { |
| 3053 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3054 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 3055 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3056 | pub const CATCH: ?Sigaction.handler_fn = @ptrFromInt(2); |
| 3057 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); |
| 3058 | |
| 3059 | pub const BLOCK = 1; |
| 3060 | pub const UNBLOCK = 2; |
| 3061 | pub const SETMASK = 3; |
| 3062 | |
| 3063 | pub const IOT: SIG = .ABRT; |
| 3064 | |
| 3065 | HUP = 1, |
| 3066 | INT = 2, |
| 3067 | QUIT = 3, |
| 3068 | ILL = 4, |
| 3069 | TRAP = 5, |
| 3070 | ABRT = 6, |
| 3071 | EMT = 7, |
| 3072 | FPE = 8, |
| 3073 | KILL = 9, |
| 3074 | BUS = 10, |
| 3075 | SEGV = 11, |
| 3076 | SYS = 12, |
| 3077 | PIPE = 13, |
| 3078 | ALRM = 14, |
| 3079 | TERM = 15, |
| 3080 | URG = 16, |
| 3081 | STOP = 17, |
| 3082 | TSTP = 18, |
| 3083 | CONT = 19, |
| 3084 | CHLD = 20, |
| 3085 | TTIN = 21, |
| 3086 | TTOU = 22, |
| 3087 | IO = 23, |
| 3088 | XCPU = 24, |
| 3089 | XFSZ = 25, |
| 3090 | VTALRM = 26, |
| 3091 | PROF = 27, |
| 3092 | WINCH = 28, |
| 3093 | INFO = 29, |
| 3094 | USR1 = 30, |
| 3095 | USR2 = 31, |
| 3096 | PWR = 32, |
| 3097 | _, |
| 3098 | }, |
| 3099 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal.h |
| 3100 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h |
| 3101 | .serenity => enum(u32) { |
| 3102 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3103 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3104 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 3105 | |
| 3106 | pub const BLOCK = 1; |
| 3107 | pub const UNBLOCK = 2; |
| 3108 | pub const SETMASK = 3; |
| 3109 | |
| 3110 | INVAL = 0, |
| 3111 | HUP = 1, |
| 3112 | INT = 2, |
| 3113 | QUIT = 3, |
| 3114 | ILL = 4, |
| 3115 | TRAP = 5, |
| 3116 | ABRT = 6, |
| 3117 | BUS = 7, |
| 3118 | FPE = 8, |
| 3119 | KILL = 9, |
| 3120 | USR1 = 10, |
| 3121 | SEGV = 11, |
| 3122 | USR2 = 12, |
| 3123 | PIPE = 13, |
| 3124 | ALRM = 14, |
| 3125 | TERM = 15, |
| 3126 | STKFLT = 16, |
| 3127 | CHLD = 17, |
| 3128 | CONT = 18, |
| 3129 | STOP = 19, |
| 3130 | TSTP = 20, |
| 3131 | TTIN = 21, |
| 3132 | TTOU = 22, |
| 3133 | URG = 23, |
| 3134 | XCPU = 24, |
| 3135 | XFSZ = 25, |
| 3136 | VTALRM = 26, |
| 3137 | PROF = 27, |
| 3138 | WINCH = 28, |
| 3139 | IO = 29, |
| 3140 | INFO = 30, |
| 3141 | SYS = 31, |
| 3142 | CANCEL = 32, |
| 3143 | _, |
| 3144 | }, |
| 3145 | else => void, |
| 3146 | }; |
| 3147 | |
| 3148 | pub const SIOCGIFINDEX = switch (native_os) { |
| 3149 | .linux => linux.SIOCGIFINDEX, |
| 3150 | .emscripten => emscripten.SIOCGIFINDEX, |
| 3151 | .illumos => illumos.SIOCGLIFINDEX, |
| 3152 | // https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L118 |
| 3153 | .serenity => 34, |
| 3154 | else => void, |
| 3155 | }; |
| 3156 | |
| 3157 | pub const STDIN_FILENO = switch (native_os) { |
| 3158 | .linux => linux.STDIN_FILENO, |
| 3159 | .emscripten => emscripten.STDIN_FILENO, |
| 3160 | else => 0, |
| 3161 | }; |
| 3162 | pub const STDOUT_FILENO = switch (native_os) { |
| 3163 | .linux => linux.STDOUT_FILENO, |
| 3164 | .emscripten => emscripten.STDOUT_FILENO, |
| 3165 | else => 1, |
| 3166 | }; |
| 3167 | pub const STDERR_FILENO = switch (native_os) { |
| 3168 | .linux => linux.STDERR_FILENO, |
| 3169 | .emscripten => emscripten.STDERR_FILENO, |
| 3170 | else => 2, |
| 3171 | }; |
| 3172 | |
| 3173 | pub const SYS = switch (native_os) { |
| 3174 | .linux => linux.SYS, |
| 3175 | else => void, |
| 3176 | }; |
| 3177 | |
| 3178 | /// A common format for the Sigaction struct across a variety of Linux flavors. |
| 3179 | const common_linux_Sigaction = extern struct { |
| 3180 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3181 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3182 | |
| 3183 | handler: extern union { |
| 3184 | handler: ?handler_fn, |
| 3185 | sigaction: ?sigaction_fn, |
| 3186 | }, |
| 3187 | mask: sigset_t, |
| 3188 | flags: c_uint, |
| 3189 | restorer: ?*const fn () callconv(.c) void = null, // C library will fill this in |
| 3190 | }; |
| 3191 | |
| 3192 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. |
| 3193 | pub const Sigaction = switch (native_os) { |
| 3194 | .linux => switch (native_arch) { |
| 3195 | .mips, |
| 3196 | .mipsel, |
| 3197 | .mips64, |
| 3198 | .mips64el, |
| 3199 | => if (builtin.target.abi.isMusl()) |
| 3200 | common_linux_Sigaction |
| 3201 | else if (builtin.target.ptrBitWidth() == 64) extern struct { |
| 3202 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3203 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3204 | |
| 3205 | flags: c_uint, |
| 3206 | handler: extern union { |
| 3207 | handler: ?handler_fn, |
| 3208 | sigaction: ?sigaction_fn, |
| 3209 | }, |
| 3210 | mask: sigset_t, |
| 3211 | restorer: ?*const fn () callconv(.c) void = null, |
| 3212 | } else extern struct { |
| 3213 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3214 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3215 | |
| 3216 | flags: c_uint, |
| 3217 | handler: extern union { |
| 3218 | handler: ?handler_fn, |
| 3219 | sigaction: ?sigaction_fn, |
| 3220 | }, |
| 3221 | mask: sigset_t, |
| 3222 | restorer: ?*const fn () callconv(.c) void = null, |
| 3223 | __resv: [1]c_int = .{0}, |
| 3224 | }, |
| 3225 | .s390x => if (builtin.abi == .gnu) extern struct { |
| 3226 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3227 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3228 | |
| 3229 | handler: extern union { |
| 3230 | handler: ?handler_fn, |
| 3231 | sigaction: ?sigaction_fn, |
| 3232 | }, |
| 3233 | __glibc_reserved0: c_int = 0, |
| 3234 | flags: c_uint, |
| 3235 | restorer: ?*const fn () callconv(.c) void = null, |
| 3236 | mask: sigset_t, |
| 3237 | } else common_linux_Sigaction, |
| 3238 | else => common_linux_Sigaction, |
| 3239 | }, |
| 3240 | .emscripten => emscripten.Sigaction, |
| 3241 | .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 3242 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3243 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3244 | |
| 3245 | handler: extern union { |
| 3246 | handler: ?handler_fn, |
| 3247 | sigaction: ?sigaction_fn, |
| 3248 | }, |
| 3249 | mask: sigset_t, |
| 3250 | flags: c_uint, |
| 3251 | }, |
| 3252 | .dragonfly, .freebsd => extern struct { |
| 3253 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3254 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3255 | |
| 3256 | /// signal handler |
| 3257 | handler: extern union { |
| 3258 | handler: ?handler_fn, |
| 3259 | sigaction: ?sigaction_fn, |
| 3260 | }, |
| 3261 | /// see signal options |
| 3262 | flags: c_uint, |
| 3263 | /// signal mask to apply |
| 3264 | mask: sigset_t, |
| 3265 | }, |
| 3266 | .illumos => extern struct { |
| 3267 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3268 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3269 | |
| 3270 | /// signal options |
| 3271 | flags: c_uint, |
| 3272 | /// signal handler |
| 3273 | handler: extern union { |
| 3274 | handler: ?handler_fn, |
| 3275 | sigaction: ?sigaction_fn, |
| 3276 | }, |
| 3277 | /// signal mask to apply |
| 3278 | mask: sigset_t, |
| 3279 | }, |
| 3280 | .haiku => extern struct { |
| 3281 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3282 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3283 | |
| 3284 | /// signal handler |
| 3285 | handler: extern union { |
| 3286 | handler: ?handler_fn, |
| 3287 | sigaction: ?sigaction_fn, |
| 3288 | }, |
| 3289 | |
| 3290 | /// signal mask to apply |
| 3291 | mask: sigset_t, |
| 3292 | |
| 3293 | /// see signal options |
| 3294 | flags: i32, |
| 3295 | |
| 3296 | /// will be passed to the signal handler, BeOS extension |
| 3297 | userdata: *allowzero anyopaque = undefined, |
| 3298 | }, |
| 3299 | .openbsd => extern struct { |
| 3300 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3301 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3302 | |
| 3303 | /// signal handler |
| 3304 | handler: extern union { |
| 3305 | handler: ?handler_fn, |
| 3306 | sigaction: ?sigaction_fn, |
| 3307 | }, |
| 3308 | /// signal mask to apply |
| 3309 | mask: sigset_t, |
| 3310 | /// signal options |
| 3311 | flags: c_uint, |
| 3312 | }, |
| 3313 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L39-L46 |
| 3314 | .serenity => extern struct { |
| 3315 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; |
| 3316 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3317 | |
| 3318 | handler: extern union { |
| 3319 | handler: ?handler_fn, |
| 3320 | sigaction: ?sigaction_fn, |
| 3321 | }, |
| 3322 | mask: sigset_t, |
| 3323 | flags: c_uint, |
| 3324 | }, |
| 3325 | else => void, |
| 3326 | }; |
| 3327 | pub const T = switch (native_os) { |
| 3328 | .linux => linux.T, |
| 3329 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 3330 | pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); |
| 3331 | |
| 3332 | fn ior(inout: u32, group_arg: usize, num: usize, len: usize) usize { |
| 3333 | return (inout | ((len & IOCPARM_MASK) << 16) | ((group_arg) << 8) | (num)); |
| 3334 | } |
| 3335 | }, |
| 3336 | .freebsd => struct { |
| 3337 | pub const IOCEXCL = 0x2000740d; |
| 3338 | pub const IOCNXCL = 0x2000740e; |
| 3339 | pub const IOCSCTTY = 0x20007461; |
| 3340 | pub const IOCGPGRP = 0x40047477; |
| 3341 | pub const IOCSPGRP = 0x80047476; |
| 3342 | pub const IOCOUTQ = 0x40047473; |
| 3343 | pub const IOCSTI = 0x80017472; |
| 3344 | pub const IOCGWINSZ = 0x40087468; |
| 3345 | pub const IOCSWINSZ = 0x80087467; |
| 3346 | pub const IOCMGET = 0x4004746a; |
| 3347 | pub const IOCMBIS = 0x8004746c; |
| 3348 | pub const IOCMBIC = 0x8004746b; |
| 3349 | pub const IOCMSET = 0x8004746d; |
| 3350 | pub const FIONREAD = 0x4004667f; |
| 3351 | pub const IOCCONS = 0x80047462; |
| 3352 | pub const IOCPKT = 0x80047470; |
| 3353 | pub const FIONBIO = 0x8004667e; |
| 3354 | pub const IOCNOTTY = 0x20007471; |
| 3355 | pub const IOCSETD = 0x8004741b; |
| 3356 | pub const IOCGETD = 0x4004741a; |
| 3357 | pub const IOCSBRK = 0x2000747b; |
| 3358 | pub const IOCCBRK = 0x2000747a; |
| 3359 | pub const IOCGSID = 0x40047463; |
| 3360 | pub const IOCGPTN = 0x4004740f; |
| 3361 | pub const IOCSIG = 0x2004745f; |
| 3362 | }, |
| 3363 | .illumos => struct { |
| 3364 | pub const CGETA = tioc('T', 1); |
| 3365 | pub const CSETA = tioc('T', 2); |
| 3366 | pub const CSETAW = tioc('T', 3); |
| 3367 | pub const CSETAF = tioc('T', 4); |
| 3368 | pub const CSBRK = tioc('T', 5); |
| 3369 | pub const CXONC = tioc('T', 6); |
| 3370 | pub const CFLSH = tioc('T', 7); |
| 3371 | pub const IOCGWINSZ = tioc('T', 104); |
| 3372 | pub const IOCSWINSZ = tioc('T', 103); |
| 3373 | // Softcarrier ioctls |
| 3374 | pub const IOCGSOFTCAR = tioc('T', 105); |
| 3375 | pub const IOCSSOFTCAR = tioc('T', 106); |
| 3376 | // termios ioctls |
| 3377 | pub const CGETS = tioc('T', 13); |
| 3378 | pub const CSETS = tioc('T', 14); |
| 3379 | pub const CSANOW = tioc('T', 14); |
| 3380 | pub const CSETSW = tioc('T', 15); |
| 3381 | pub const CSADRAIN = tioc('T', 15); |
| 3382 | pub const CSETSF = tioc('T', 16); |
| 3383 | pub const IOCSETLD = tioc('T', 123); |
| 3384 | pub const IOCGETLD = tioc('T', 124); |
| 3385 | // NTP PPS ioctls |
| 3386 | pub const IOCGPPS = tioc('T', 125); |
| 3387 | pub const IOCSPPS = tioc('T', 126); |
| 3388 | pub const IOCGPPSEV = tioc('T', 127); |
| 3389 | |
| 3390 | pub const IOCGETD = tioc('t', 0); |
| 3391 | pub const IOCSETD = tioc('t', 1); |
| 3392 | pub const IOCHPCL = tioc('t', 2); |
| 3393 | pub const IOCGETP = tioc('t', 8); |
| 3394 | pub const IOCSETP = tioc('t', 9); |
| 3395 | pub const IOCSETN = tioc('t', 10); |
| 3396 | pub const IOCEXCL = tioc('t', 13); |
| 3397 | pub const IOCNXCL = tioc('t', 14); |
| 3398 | pub const IOCFLUSH = tioc('t', 16); |
| 3399 | pub const IOCSETC = tioc('t', 17); |
| 3400 | pub const IOCGETC = tioc('t', 18); |
| 3401 | /// bis local mode bits |
| 3402 | pub const IOCLBIS = tioc('t', 127); |
| 3403 | /// bic local mode bits |
| 3404 | pub const IOCLBIC = tioc('t', 126); |
| 3405 | /// set entire local mode word |
| 3406 | pub const IOCLSET = tioc('t', 125); |
| 3407 | /// get local modes |
| 3408 | pub const IOCLGET = tioc('t', 124); |
| 3409 | /// set break bit |
| 3410 | pub const IOCSBRK = tioc('t', 123); |
| 3411 | /// clear break bit |
| 3412 | pub const IOCCBRK = tioc('t', 122); |
| 3413 | /// set data terminal ready |
| 3414 | pub const IOCSDTR = tioc('t', 121); |
| 3415 | /// clear data terminal ready |
| 3416 | pub const IOCCDTR = tioc('t', 120); |
| 3417 | /// set local special chars |
| 3418 | pub const IOCSLTC = tioc('t', 117); |
| 3419 | /// get local special chars |
| 3420 | pub const IOCGLTC = tioc('t', 116); |
| 3421 | /// driver output queue size |
| 3422 | pub const IOCOUTQ = tioc('t', 115); |
| 3423 | /// void tty association |
| 3424 | pub const IOCNOTTY = tioc('t', 113); |
| 3425 | /// get a ctty |
| 3426 | pub const IOCSCTTY = tioc('t', 132); |
| 3427 | /// stop output, like ^S |
| 3428 | pub const IOCSTOP = tioc('t', 111); |
| 3429 | /// start output, like ^Q |
| 3430 | pub const IOCSTART = tioc('t', 110); |
| 3431 | /// get pgrp of tty |
| 3432 | pub const IOCGPGRP = tioc('t', 20); |
| 3433 | /// set pgrp of tty |
| 3434 | pub const IOCSPGRP = tioc('t', 21); |
| 3435 | /// get session id on ctty |
| 3436 | pub const IOCGSID = tioc('t', 22); |
| 3437 | /// simulate terminal input |
| 3438 | pub const IOCSTI = tioc('t', 23); |
| 3439 | /// set all modem bits |
| 3440 | pub const IOCMSET = tioc('t', 26); |
| 3441 | /// bis modem bits |
| 3442 | pub const IOCMBIS = tioc('t', 27); |
| 3443 | /// bic modem bits |
| 3444 | pub const IOCMBIC = tioc('t', 28); |
| 3445 | /// get all modem bits |
| 3446 | pub const IOCMGET = tioc('t', 29); |
| 3447 | |
| 3448 | fn tioc(t: u16, num: u8) u16 { |
| 3449 | return (t << 8) | num; |
| 3450 | } |
| 3451 | }, |
| 3452 | .netbsd => struct { |
| 3453 | pub const IOCCBRK = 0x2000747a; |
| 3454 | pub const IOCCDTR = 0x20007478; |
| 3455 | pub const IOCCONS = 0x80047462; |
| 3456 | pub const IOCDCDTIMESTAMP = 0x40107458; |
| 3457 | pub const IOCDRAIN = 0x2000745e; |
| 3458 | pub const IOCEXCL = 0x2000740d; |
| 3459 | pub const IOCEXT = 0x80047460; |
| 3460 | pub const IOCFLAG_CDTRCTS = 0x10; |
| 3461 | pub const IOCFLAG_CLOCAL = 0x2; |
| 3462 | pub const IOCFLAG_CRTSCTS = 0x4; |
| 3463 | pub const IOCFLAG_MDMBUF = 0x8; |
| 3464 | pub const IOCFLAG_SOFTCAR = 0x1; |
| 3465 | pub const IOCFLUSH = 0x80047410; |
| 3466 | pub const IOCGETA = 0x402c7413; |
| 3467 | pub const IOCGETD = 0x4004741a; |
| 3468 | pub const IOCGFLAGS = 0x4004745d; |
| 3469 | pub const IOCGLINED = 0x40207442; |
| 3470 | pub const IOCGPGRP = 0x40047477; |
| 3471 | pub const IOCGQSIZE = 0x40047481; |
| 3472 | pub const IOCGRANTPT = 0x20007447; |
| 3473 | pub const IOCGSID = 0x40047463; |
| 3474 | pub const IOCGSIZE = 0x40087468; |
| 3475 | pub const IOCGWINSZ = 0x40087468; |
| 3476 | pub const IOCMBIC = 0x8004746b; |
| 3477 | pub const IOCMBIS = 0x8004746c; |
| 3478 | pub const IOCMGET = 0x4004746a; |
| 3479 | pub const IOCMSET = 0x8004746d; |
| 3480 | pub const IOCM_CAR = 0x40; |
| 3481 | pub const IOCM_CD = 0x40; |
| 3482 | pub const IOCM_CTS = 0x20; |
| 3483 | pub const IOCM_DSR = 0x100; |
| 3484 | pub const IOCM_DTR = 0x2; |
| 3485 | pub const IOCM_LE = 0x1; |
| 3486 | pub const IOCM_RI = 0x80; |
| 3487 | pub const IOCM_RNG = 0x80; |
| 3488 | pub const IOCM_RTS = 0x4; |
| 3489 | pub const IOCM_SR = 0x10; |
| 3490 | pub const IOCM_ST = 0x8; |
| 3491 | pub const IOCNOTTY = 0x20007471; |
| 3492 | pub const IOCNXCL = 0x2000740e; |
| 3493 | pub const IOCOUTQ = 0x40047473; |
| 3494 | pub const IOCPKT = 0x80047470; |
| 3495 | pub const IOCPKT_DATA = 0x0; |
| 3496 | pub const IOCPKT_DOSTOP = 0x20; |
| 3497 | pub const IOCPKT_FLUSHREAD = 0x1; |
| 3498 | pub const IOCPKT_FLUSHWRITE = 0x2; |
| 3499 | pub const IOCPKT_IOCTL = 0x40; |
| 3500 | pub const IOCPKT_NOSTOP = 0x10; |
| 3501 | pub const IOCPKT_START = 0x8; |
| 3502 | pub const IOCPKT_STOP = 0x4; |
| 3503 | pub const IOCPTMGET = 0x40287446; |
| 3504 | pub const IOCPTSNAME = 0x40287448; |
| 3505 | pub const IOCRCVFRAME = 0x80087445; |
| 3506 | pub const IOCREMOTE = 0x80047469; |
| 3507 | pub const IOCSBRK = 0x2000747b; |
| 3508 | pub const IOCSCTTY = 0x20007461; |
| 3509 | pub const IOCSDTR = 0x20007479; |
| 3510 | pub const IOCSETA = 0x802c7414; |
| 3511 | pub const IOCSETAF = 0x802c7416; |
| 3512 | pub const IOCSETAW = 0x802c7415; |
| 3513 | pub const IOCSETD = 0x8004741b; |
| 3514 | pub const IOCSFLAGS = 0x8004745c; |
| 3515 | pub const IOCSIG = 0x2000745f; |
| 3516 | pub const IOCSLINED = 0x80207443; |
| 3517 | pub const IOCSPGRP = 0x80047476; |
| 3518 | pub const IOCSQSIZE = 0x80047480; |
| 3519 | pub const IOCSSIZE = 0x80087467; |
| 3520 | pub const IOCSTART = 0x2000746e; |
| 3521 | pub const IOCSTAT = 0x80047465; |
| 3522 | pub const IOCSTI = 0x80017472; |
| 3523 | pub const IOCSTOP = 0x2000746f; |
| 3524 | pub const IOCSWINSZ = 0x80087467; |
| 3525 | pub const IOCUCNTL = 0x80047466; |
| 3526 | pub const IOCXMTFRAME = 0x80087444; |
| 3527 | }, |
| 3528 | .haiku => struct { |
| 3529 | pub const CGETA = 0x8000; |
| 3530 | pub const CSETA = 0x8001; |
| 3531 | pub const CSETAF = 0x8002; |
| 3532 | pub const CSETAW = 0x8003; |
| 3533 | pub const CWAITEVENT = 0x8004; |
| 3534 | pub const CSBRK = 0x8005; |
| 3535 | pub const CFLSH = 0x8006; |
| 3536 | pub const CXONC = 0x8007; |
| 3537 | pub const CQUERYCONNECTED = 0x8008; |
| 3538 | pub const CGETBITS = 0x8009; |
| 3539 | pub const CSETDTR = 0x8010; |
| 3540 | pub const CSETRTS = 0x8011; |
| 3541 | pub const IOCGWINSZ = 0x8012; |
| 3542 | pub const IOCSWINSZ = 0x8013; |
| 3543 | pub const CVTIME = 0x8014; |
| 3544 | pub const IOCGPGRP = 0x8015; |
| 3545 | pub const IOCSPGRP = 0x8016; |
| 3546 | pub const IOCSCTTY = 0x8017; |
| 3547 | pub const IOCMGET = 0x8018; |
| 3548 | pub const IOCMSET = 0x8019; |
| 3549 | pub const IOCSBRK = 0x8020; |
| 3550 | pub const IOCCBRK = 0x8021; |
| 3551 | pub const IOCMBIS = 0x8022; |
| 3552 | pub const IOCMBIC = 0x8023; |
| 3553 | pub const IOCGSID = 0x8024; |
| 3554 | |
| 3555 | pub const FIONREAD = 0xbe000001; |
| 3556 | pub const FIONBIO = 0xbe000000; |
| 3557 | }, |
| 3558 | .openbsd => struct { |
| 3559 | pub const IOCCBRK = 0x2000747a; |
| 3560 | pub const IOCCDTR = 0x20007478; |
| 3561 | pub const IOCCONS = 0x80047462; |
| 3562 | pub const IOCDCDTIMESTAMP = 0x40107458; |
| 3563 | pub const IOCDRAIN = 0x2000745e; |
| 3564 | pub const IOCEXCL = 0x2000740d; |
| 3565 | pub const IOCEXT = 0x80047460; |
| 3566 | pub const IOCFLAG_CDTRCTS = 0x10; |
| 3567 | pub const IOCFLAG_CLOCAL = 0x2; |
| 3568 | pub const IOCFLAG_CRTSCTS = 0x4; |
| 3569 | pub const IOCFLAG_MDMBUF = 0x8; |
| 3570 | pub const IOCFLAG_SOFTCAR = 0x1; |
| 3571 | pub const IOCFLUSH = 0x80047410; |
| 3572 | pub const IOCGETA = 0x402c7413; |
| 3573 | pub const IOCGETD = 0x4004741a; |
| 3574 | pub const IOCGFLAGS = 0x4004745d; |
| 3575 | pub const IOCGLINED = 0x40207442; |
| 3576 | pub const IOCGPGRP = 0x40047477; |
| 3577 | pub const IOCGQSIZE = 0x40047481; |
| 3578 | pub const IOCGRANTPT = 0x20007447; |
| 3579 | pub const IOCGSID = 0x40047463; |
| 3580 | pub const IOCGSIZE = 0x40087468; |
| 3581 | pub const IOCGWINSZ = 0x40087468; |
| 3582 | pub const IOCMBIC = 0x8004746b; |
| 3583 | pub const IOCMBIS = 0x8004746c; |
| 3584 | pub const IOCMGET = 0x4004746a; |
| 3585 | pub const IOCMSET = 0x8004746d; |
| 3586 | pub const IOCM_CAR = 0x40; |
| 3587 | pub const IOCM_CD = 0x40; |
| 3588 | pub const IOCM_CTS = 0x20; |
| 3589 | pub const IOCM_DSR = 0x100; |
| 3590 | pub const IOCM_DTR = 0x2; |
| 3591 | pub const IOCM_LE = 0x1; |
| 3592 | pub const IOCM_RI = 0x80; |
| 3593 | pub const IOCM_RNG = 0x80; |
| 3594 | pub const IOCM_RTS = 0x4; |
| 3595 | pub const IOCM_SR = 0x10; |
| 3596 | pub const IOCM_ST = 0x8; |
| 3597 | pub const IOCNOTTY = 0x20007471; |
| 3598 | pub const IOCNXCL = 0x2000740e; |
| 3599 | pub const IOCOUTQ = 0x40047473; |
| 3600 | pub const IOCPKT = 0x80047470; |
| 3601 | pub const IOCPKT_DATA = 0x0; |
| 3602 | pub const IOCPKT_DOSTOP = 0x20; |
| 3603 | pub const IOCPKT_FLUSHREAD = 0x1; |
| 3604 | pub const IOCPKT_FLUSHWRITE = 0x2; |
| 3605 | pub const IOCPKT_IOCTL = 0x40; |
| 3606 | pub const IOCPKT_NOSTOP = 0x10; |
| 3607 | pub const IOCPKT_START = 0x8; |
| 3608 | pub const IOCPKT_STOP = 0x4; |
| 3609 | pub const IOCPTMGET = 0x40287446; |
| 3610 | pub const IOCPTSNAME = 0x40287448; |
| 3611 | pub const IOCRCVFRAME = 0x80087445; |
| 3612 | pub const IOCREMOTE = 0x80047469; |
| 3613 | pub const IOCSBRK = 0x2000747b; |
| 3614 | pub const IOCSCTTY = 0x20007461; |
| 3615 | pub const IOCSDTR = 0x20007479; |
| 3616 | pub const IOCSETA = 0x802c7414; |
| 3617 | pub const IOCSETAF = 0x802c7416; |
| 3618 | pub const IOCSETAW = 0x802c7415; |
| 3619 | pub const IOCSETD = 0x8004741b; |
| 3620 | pub const IOCSFLAGS = 0x8004745c; |
| 3621 | pub const IOCSIG = 0x2000745f; |
| 3622 | pub const IOCSLINED = 0x80207443; |
| 3623 | pub const IOCSPGRP = 0x80047476; |
| 3624 | pub const IOCSQSIZE = 0x80047480; |
| 3625 | pub const IOCSSIZE = 0x80087467; |
| 3626 | pub const IOCSTART = 0x2000746e; |
| 3627 | pub const IOCSTAT = 0x80047465; |
| 3628 | pub const IOCSTI = 0x80017472; |
| 3629 | pub const IOCSTOP = 0x2000746f; |
| 3630 | pub const IOCSWINSZ = 0x80087467; |
| 3631 | pub const IOCUCNTL = 0x80047466; |
| 3632 | pub const IOCXMTFRAME = 0x80087444; |
| 3633 | }, |
| 3634 | .dragonfly => struct { |
| 3635 | pub const IOCMODG = 0x40047403; |
| 3636 | pub const IOCMODS = 0x80047404; |
| 3637 | pub const IOCM_LE = 0x00000001; |
| 3638 | pub const IOCM_DTR = 0x00000002; |
| 3639 | pub const IOCM_RTS = 0x00000004; |
| 3640 | pub const IOCM_ST = 0x00000008; |
| 3641 | pub const IOCM_SR = 0x00000010; |
| 3642 | pub const IOCM_CTS = 0x00000020; |
| 3643 | pub const IOCM_CAR = 0x00000040; |
| 3644 | pub const IOCM_CD = 0x00000040; |
| 3645 | pub const IOCM_RNG = 0x00000080; |
| 3646 | pub const IOCM_RI = 0x00000080; |
| 3647 | pub const IOCM_DSR = 0x00000100; |
| 3648 | pub const IOCEXCL = 0x2000740d; |
| 3649 | pub const IOCNXCL = 0x2000740e; |
| 3650 | pub const IOCFLUSH = 0x80047410; |
| 3651 | pub const IOCGETA = 0x402c7413; |
| 3652 | pub const IOCSETA = 0x802c7414; |
| 3653 | pub const IOCSETAW = 0x802c7415; |
| 3654 | pub const IOCSETAF = 0x802c7416; |
| 3655 | pub const IOCGETD = 0x4004741a; |
| 3656 | pub const IOCSETD = 0x8004741b; |
| 3657 | pub const IOCSBRK = 0x2000747b; |
| 3658 | pub const IOCCBRK = 0x2000747a; |
| 3659 | pub const IOCSDTR = 0x20007479; |
| 3660 | pub const IOCCDTR = 0x20007478; |
| 3661 | pub const IOCGPGRP = 0x40047477; |
| 3662 | pub const IOCSPGRP = 0x80047476; |
| 3663 | pub const IOCOUTQ = 0x40047473; |
| 3664 | pub const IOCSTI = 0x80017472; |
| 3665 | pub const IOCNOTTY = 0x20007471; |
| 3666 | pub const IOCPKT = 0x80047470; |
| 3667 | pub const IOCPKT_DATA = 0x00000000; |
| 3668 | pub const IOCPKT_FLUSHREAD = 0x00000001; |
| 3669 | pub const IOCPKT_FLUSHWRITE = 0x00000002; |
| 3670 | pub const IOCPKT_STOP = 0x00000004; |
| 3671 | pub const IOCPKT_START = 0x00000008; |
| 3672 | pub const IOCPKT_NOSTOP = 0x00000010; |
| 3673 | pub const IOCPKT_DOSTOP = 0x00000020; |
| 3674 | pub const IOCPKT_IOCTL = 0x00000040; |
| 3675 | pub const IOCSTOP = 0x2000746f; |
| 3676 | pub const IOCSTART = 0x2000746e; |
| 3677 | pub const IOCMSET = 0x8004746d; |
| 3678 | pub const IOCMBIS = 0x8004746c; |
| 3679 | pub const IOCMBIC = 0x8004746b; |
| 3680 | pub const IOCMGET = 0x4004746a; |
| 3681 | pub const IOCREMOTE = 0x80047469; |
| 3682 | pub const IOCGWINSZ = 0x40087468; |
| 3683 | pub const IOCSWINSZ = 0x80087467; |
| 3684 | pub const IOCUCNTL = 0x80047466; |
| 3685 | pub const IOCSTAT = 0x20007465; |
| 3686 | pub const IOCGSID = 0x40047463; |
| 3687 | pub const IOCCONS = 0x80047462; |
| 3688 | pub const IOCSCTTY = 0x20007461; |
| 3689 | pub const IOCEXT = 0x80047460; |
| 3690 | pub const IOCSIG = 0x2000745f; |
| 3691 | pub const IOCDRAIN = 0x2000745e; |
| 3692 | pub const IOCMSDTRWAIT = 0x8004745b; |
| 3693 | pub const IOCMGDTRWAIT = 0x4004745a; |
| 3694 | pub const IOCTIMESTAMP = 0x40107459; |
| 3695 | pub const IOCDCDTIMESTAMP = 0x40107458; |
| 3696 | pub const IOCSDRAINWAIT = 0x80047457; |
| 3697 | pub const IOCGDRAINWAIT = 0x40047456; |
| 3698 | pub const IOCISPTMASTER = 0x20007455; |
| 3699 | }, |
| 3700 | // https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L84-L96 |
| 3701 | .serenity => struct { |
| 3702 | pub const IOCGPGRP = 0; |
| 3703 | pub const IOCSPGRP = 1; |
| 3704 | pub const CGETS = 2; |
| 3705 | pub const CSETS = 3; |
| 3706 | pub const CSETSW = 4; |
| 3707 | pub const CSETSF = 5; |
| 3708 | pub const CFLSH = 6; |
| 3709 | pub const IOCGWINSZ = 7; |
| 3710 | pub const IOCSCTTY = 8; |
| 3711 | pub const IOCSTI = 9; |
| 3712 | pub const IOCNOTTY = 10; |
| 3713 | pub const IOCSWINSZ = 11; |
| 3714 | pub const IOCGPTN = 12; |
| 3715 | }, |
| 3716 | else => void, |
| 3717 | }; |
| 3718 | pub const IOCPARM_MASK = switch (native_os) { |
| 3719 | .windows => ws2_32.IOCPARM_MASK, |
| 3720 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 0x1fff, |
| 3721 | else => void, |
| 3722 | }; |
| 3723 | pub const TCSA = std.posix.TCSA; |
| 3724 | pub const TFD = switch (native_os) { |
| 3725 | .linux => linux.TFD, |
| 3726 | else => void, |
| 3727 | }; |
| 3728 | pub const VDSO = switch (native_os) { |
| 3729 | .linux => linux.VDSO, |
| 3730 | else => void, |
| 3731 | }; |
| 3732 | pub const W = switch (native_os) { |
| 3733 | .linux => linux.W, |
| 3734 | .emscripten => emscripten.W, |
| 3735 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 3736 | /// [XSI] no hang in wait/no child to reap |
| 3737 | pub const NOHANG = 0x00000001; |
| 3738 | /// [XSI] notify on stop, untraced child |
| 3739 | pub const UNTRACED = 0x00000002; |
| 3740 | |
| 3741 | pub fn EXITSTATUS(x: u32) u8 { |
| 3742 | return @as(u8, @intCast(x >> 8)); |
| 3743 | } |
| 3744 | pub fn TERMSIG(x: u32) SIG { |
| 3745 | return @fromBackingInt(@intCast(status(x))); |
| 3746 | } |
| 3747 | pub fn STOPSIG(x: u32) SIG { |
| 3748 | return @fromBackingInt(@intCast(x >> 8)); |
| 3749 | } |
| 3750 | pub fn IFEXITED(x: u32) bool { |
| 3751 | return status(x) == 0; |
| 3752 | } |
| 3753 | pub fn IFSTOPPED(x: u32) bool { |
| 3754 | return status(x) == stopped and @as(u32, @backingInt(STOPSIG(x))) != 0x13; |
| 3755 | } |
| 3756 | pub fn IFSIGNALED(x: u32) bool { |
| 3757 | return status(x) != stopped and status(x) != 0; |
| 3758 | } |
| 3759 | |
| 3760 | fn status(x: u32) u32 { |
| 3761 | return x & 0o177; |
| 3762 | } |
| 3763 | const stopped = 0o177; |
| 3764 | }, |
| 3765 | .freebsd => struct { |
| 3766 | pub const NOHANG = 1; |
| 3767 | pub const UNTRACED = 2; |
| 3768 | pub const STOPPED = UNTRACED; |
| 3769 | pub const CONTINUED = 4; |
| 3770 | pub const NOWAIT = 8; |
| 3771 | pub const EXITED = 16; |
| 3772 | pub const TRAPPED = 32; |
| 3773 | |
| 3774 | pub fn EXITSTATUS(s: u32) u8 { |
| 3775 | return @as(u8, @intCast((s & 0xff00) >> 8)); |
| 3776 | } |
| 3777 | pub fn TERMSIG(s: u32) SIG { |
| 3778 | return @fromBackingInt(@intCast(s & 0x7f)); |
| 3779 | } |
| 3780 | pub fn STOPSIG(s: u32) SIG { |
| 3781 | return @fromBackingInt(@intCast(EXITSTATUS(s))); |
| 3782 | } |
| 3783 | pub fn IFEXITED(s: u32) bool { |
| 3784 | return (s & 0x7f) == 0; |
| 3785 | } |
| 3786 | pub fn IFSTOPPED(s: u32) bool { |
| 3787 | return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; |
| 3788 | } |
| 3789 | pub fn IFSIGNALED(s: u32) bool { |
| 3790 | return (s & 0xffff) -% 1 < 0xff; |
| 3791 | } |
| 3792 | }, |
| 3793 | .illumos => struct { |
| 3794 | pub const EXITED = 0o001; |
| 3795 | pub const TRAPPED = 0o002; |
| 3796 | pub const UNTRACED = 0o004; |
| 3797 | pub const STOPPED = UNTRACED; |
| 3798 | pub const CONTINUED = 0o010; |
| 3799 | pub const NOHANG = 0o100; |
| 3800 | pub const NOWAIT = 0o200; |
| 3801 | |
| 3802 | pub fn EXITSTATUS(s: u32) u8 { |
| 3803 | return @as(u8, @intCast((s >> 8) & 0xff)); |
| 3804 | } |
| 3805 | pub fn TERMSIG(s: u32) SIG { |
| 3806 | return @fromBackingInt(@intCast(s & 0x7f)); |
| 3807 | } |
| 3808 | pub fn STOPSIG(s: u32) SIG { |
| 3809 | return @fromBackingInt(@intCast(EXITSTATUS(s))); |
| 3810 | } |
| 3811 | pub fn IFEXITED(s: u32) bool { |
| 3812 | return (s & 0x7f) == 0; |
| 3813 | } |
| 3814 | |
| 3815 | pub fn IFCONTINUED(s: u32) bool { |
| 3816 | return ((s & 0o177777) == 0o177777); |
| 3817 | } |
| 3818 | |
| 3819 | pub fn IFSTOPPED(s: u32) bool { |
| 3820 | return (s & 0x00ff != 0o177) and !(s & 0xff00 != 0); |
| 3821 | } |
| 3822 | |
| 3823 | pub fn IFSIGNALED(s: u32) bool { |
| 3824 | return s & 0x00ff > 0 and s & 0xff00 == 0; |
| 3825 | } |
| 3826 | }, |
| 3827 | .netbsd => struct { |
| 3828 | pub const NOHANG = 0x00000001; |
| 3829 | pub const UNTRACED = 0x00000002; |
| 3830 | pub const STOPPED = UNTRACED; |
| 3831 | pub const CONTINUED = 0x00000010; |
| 3832 | pub const NOWAIT = 0x00010000; |
| 3833 | pub const EXITED = 0x00000020; |
| 3834 | pub const TRAPPED = 0x00000040; |
| 3835 | |
| 3836 | pub fn EXITSTATUS(s: u32) u8 { |
| 3837 | return @as(u8, @intCast((s >> 8) & 0xff)); |
| 3838 | } |
| 3839 | pub fn TERMSIG(s: u32) SIG { |
| 3840 | return @fromBackingInt(@intCast(s & 0x7f)); |
| 3841 | } |
| 3842 | pub fn STOPSIG(s: u32) SIG { |
| 3843 | return @fromBackingInt(@intCast(EXITSTATUS(s))); |
| 3844 | } |
| 3845 | pub fn IFEXITED(s: u32) bool { |
| 3846 | return (s & 0x7f) == 0; |
| 3847 | } |
| 3848 | |
| 3849 | pub fn IFCONTINUED(s: u32) bool { |
| 3850 | return (s == CONTINUED); |
| 3851 | } |
| 3852 | |
| 3853 | pub fn IFSTOPPED(s: u32) bool { |
| 3854 | return (((s & 0x7f) == STOPPED) and !IFCONTINUED(s)); |
| 3855 | } |
| 3856 | |
| 3857 | pub fn IFSIGNALED(s: u32) bool { |
| 3858 | return !IFSTOPPED(s) and !IFCONTINUED(s) and !IFEXITED(s); |
| 3859 | } |
| 3860 | }, |
| 3861 | .dragonfly => struct { |
| 3862 | pub const NOHANG = 0x0001; |
| 3863 | pub const UNTRACED = 0x0002; |
| 3864 | pub const CONTINUED = 0x0004; |
| 3865 | pub const STOPPED = UNTRACED; |
| 3866 | pub const NOWAIT = 0x0008; |
| 3867 | pub const EXITED = 0x0010; |
| 3868 | pub const TRAPPED = 0x0020; |
| 3869 | |
| 3870 | pub fn EXITSTATUS(s: u32) u8 { |
| 3871 | return @as(u8, @intCast((s & 0xff00) >> 8)); |
| 3872 | } |
| 3873 | pub fn TERMSIG(s: u32) SIG { |
| 3874 | return @fromBackingInt(@intCast(s & 0x7f)); |
| 3875 | } |
| 3876 | pub fn STOPSIG(s: u32) SIG { |
| 3877 | return @fromBackingInt(@intCast(EXITSTATUS(s))); |
| 3878 | } |
| 3879 | pub fn IFEXITED(s: u32) bool { |
| 3880 | return (s & 0x7f) == 0; |
| 3881 | } |
| 3882 | pub fn IFSTOPPED(s: u32) bool { |
| 3883 | return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; |
| 3884 | } |
| 3885 | pub fn IFSIGNALED(s: u32) bool { |
| 3886 | return (s & 0xffff) -% 1 < 0xff; |
| 3887 | } |
| 3888 | }, |
| 3889 | .haiku => struct { |
| 3890 | pub const NOHANG = 0x1; |
| 3891 | pub const UNTRACED = 0x2; |
| 3892 | pub const CONTINUED = 0x4; |
| 3893 | pub const EXITED = 0x08; |
| 3894 | pub const STOPPED = 0x10; |
| 3895 | pub const NOWAIT = 0x20; |
| 3896 | |
| 3897 | pub fn EXITSTATUS(s: u32) u8 { |
| 3898 | return @as(u8, @intCast(s & 0xff)); |
| 3899 | } |
| 3900 | |
| 3901 | pub fn TERMSIG(s: u32) SIG { |
| 3902 | return @fromBackingInt(@intCast((s >> 8) & 0xff)); |
| 3903 | } |
| 3904 | |
| 3905 | pub fn STOPSIG(s: u32) SIG { |
| 3906 | return @fromBackingInt(@intCast((s >> 16) & 0xff)); |
| 3907 | } |
| 3908 | |
| 3909 | pub fn IFEXITED(s: u32) bool { |
| 3910 | return (s & ~@as(u32, 0xff)) == 0; |
| 3911 | } |
| 3912 | |
| 3913 | pub fn IFSTOPPED(s: u32) bool { |
| 3914 | return ((s >> 16) & 0xff) != 0; |
| 3915 | } |
| 3916 | |
| 3917 | pub fn IFSIGNALED(s: u32) bool { |
| 3918 | return ((s >> 8) & 0xff) != 0; |
| 3919 | } |
| 3920 | }, |
| 3921 | .openbsd => struct { |
| 3922 | pub const NOHANG = 1; |
| 3923 | pub const UNTRACED = 2; |
| 3924 | pub const CONTINUED = 8; |
| 3925 | |
| 3926 | pub fn EXITSTATUS(s: u32) u8 { |
| 3927 | return @as(u8, @intCast((s >> 8) & 0xff)); |
| 3928 | } |
| 3929 | pub fn TERMSIG(s: u32) SIG { |
| 3930 | return @fromBackingInt(@intCast(s & 0x7f)); |
| 3931 | } |
| 3932 | pub fn STOPSIG(s: u32) SIG { |
| 3933 | return @fromBackingInt(@intCast(EXITSTATUS(s))); |
| 3934 | } |
| 3935 | pub fn IFEXITED(s: u32) bool { |
| 3936 | return (s & 0x7f) == 0; |
| 3937 | } |
| 3938 | |
| 3939 | pub fn IFCONTINUED(s: u32) bool { |
| 3940 | return ((s & 0o177777) == 0o177777); |
| 3941 | } |
| 3942 | |
| 3943 | pub fn IFSTOPPED(s: u32) bool { |
| 3944 | return (s & 0xff == 0o177); |
| 3945 | } |
| 3946 | |
| 3947 | pub fn IFSIGNALED(s: u32) bool { |
| 3948 | return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); |
| 3949 | } |
| 3950 | }, |
| 3951 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/wait.h |
| 3952 | .serenity => struct { |
| 3953 | pub const NOHANG = 1; |
| 3954 | pub const UNTRACED = 2; |
| 3955 | pub const STOPPED = UNTRACED; |
| 3956 | pub const EXITED = 4; |
| 3957 | pub const CONTINUED = 8; |
| 3958 | pub const NOWAIT = 0x1000000; |
| 3959 | |
| 3960 | pub fn EXITSTATUS(s: u32) u8 { |
| 3961 | return @intCast((s & 0xff00) >> 8); |
| 3962 | } |
| 3963 | |
| 3964 | pub fn STOPSIG(s: u32) SIG { |
| 3965 | return @fromBackingInt(@intCast(EXITSTATUS(s))); |
| 3966 | } |
| 3967 | |
| 3968 | pub fn TERMSIG(s: u32) SIG { |
| 3969 | return @fromBackingInt(@intCast(s & 0x7f)); |
| 3970 | } |
| 3971 | |
| 3972 | pub fn IFEXITED(s: u32) bool { |
| 3973 | return (s & 0x7f) == 0; |
| 3974 | } |
| 3975 | |
| 3976 | pub fn IFSTOPPED(s: u32) bool { |
| 3977 | return (s & 0xff) == 0x7f; |
| 3978 | } |
| 3979 | |
| 3980 | pub fn IFSIGNALED(s: u32) bool { |
| 3981 | return (((s & 0x7f) + 1) >> 1) > 0; |
| 3982 | } |
| 3983 | |
| 3984 | pub fn IFCONTINUED(s: u32) bool { |
| 3985 | return s == 0xffff; |
| 3986 | } |
| 3987 | }, |
| 3988 | else => void, |
| 3989 | }; |
| 3990 | pub const accept_filter_arg = switch (native_os) { |
| 3991 | // https://github.com/freebsd/freebsd-src/blob/2024887abc7d1b931e00fbb0697658e98adf048d/sys/sys/socket.h#L205 |
| 3992 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L164 |
| 3993 | // https://github.com/NetBSD/src/blob/cad5c68a8524927f65e22ad651de3905382be6e0/sys/sys/socket.h#L188 |
| 3994 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L504 |
| 3995 | .freebsd, .dragonfly, .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 3996 | name: [16]u8, |
| 3997 | arg: [240]u8, |
| 3998 | }, |
| 3999 | else => void, |
| 4000 | }; |
| 4001 | pub const clock_t = switch (native_os) { |
| 4002 | .linux => linux.clock_t, |
| 4003 | .emscripten => emscripten.clock_t, |
| 4004 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_ulong, |
| 4005 | .freebsd => isize, |
| 4006 | .openbsd, .illumos => i64, |
| 4007 | .netbsd => u32, |
| 4008 | .haiku => i32, |
| 4009 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L50 |
| 4010 | .serenity => u64, |
| 4011 | else => void, |
| 4012 | }; |
| 4013 | pub const cpu_set_t = switch (native_os) { |
| 4014 | .linux => linux.cpu_set_t, |
| 4015 | .emscripten => emscripten.cpu_set_t, |
| 4016 | else => void, |
| 4017 | }; |
| 4018 | pub const dl_phdr_info = switch (native_os) { |
| 4019 | .linux => linux.dl_phdr_info, |
| 4020 | .emscripten => emscripten.dl_phdr_info, |
| 4021 | .freebsd => extern struct { |
| 4022 | /// Module relocation base. |
| 4023 | addr: std.elf.Addr, |
| 4024 | /// Module name. |
| 4025 | name: ?[*:0]const u8, |
| 4026 | /// Pointer to module's phdr. |
| 4027 | phdr: [*]std.elf.ElfN.Phdr, |
| 4028 | /// Number of entries in phdr. |
| 4029 | phnum: u16, |
| 4030 | /// Total number of loads. |
| 4031 | adds: u64, |
| 4032 | /// Total number of unloads. |
| 4033 | subs: u64, |
| 4034 | tls_modid: usize, |
| 4035 | tls_data: ?*anyopaque, |
| 4036 | }, |
| 4037 | .illumos => extern struct { |
| 4038 | addr: std.elf.Addr, |
| 4039 | name: ?[*:0]const u8, |
| 4040 | phdr: [*]std.elf.ElfN.Phdr, |
| 4041 | phnum: std.elf.Half, |
| 4042 | /// Incremented when a new object is mapped into the process. |
| 4043 | adds: u64, |
| 4044 | /// Incremented when an object is unmapped from the process. |
| 4045 | subs: u64, |
| 4046 | }, |
| 4047 | // https://github.com/SerenityOS/serenity/blob/45d81dceed81df0c8ef75b440b20cc0938195faa/Userland/Libraries/LibC/link.h#L15-L20 |
| 4048 | .openbsd, .haiku, .dragonfly, .netbsd, .serenity => extern struct { |
| 4049 | addr: usize, |
| 4050 | name: ?[*:0]const u8, |
| 4051 | phdr: [*]std.elf.ElfN.Phdr, |
| 4052 | phnum: std.elf.Half, |
| 4053 | }, |
| 4054 | else => void, |
| 4055 | }; |
| 4056 | pub const epoll_event = switch (native_os) { |
| 4057 | .linux => linux.epoll_event, |
| 4058 | else => void, |
| 4059 | }; |
| 4060 | pub const ifreq = switch (native_os) { |
| 4061 | .linux => linux.ifreq, |
| 4062 | .emscripten => emscripten.ifreq, |
| 4063 | .illumos => lifreq, |
| 4064 | // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L49-L82 |
| 4065 | .serenity => extern struct { |
| 4066 | // Not actually in a union, but the stdlib expects one for ifreq |
| 4067 | ifrn: extern union { |
| 4068 | name: [IFNAMESIZE]u8, |
| 4069 | }, |
| 4070 | ifru: extern union { |
| 4071 | addr: sockaddr, |
| 4072 | dstaddr: sockaddr, |
| 4073 | broadaddr: sockaddr, |
| 4074 | netmask: sockaddr, |
| 4075 | hwaddr: sockaddr, |
| 4076 | flags: c_short, |
| 4077 | metric: c_int, |
| 4078 | vnetid: i64, |
| 4079 | media: u64, |
| 4080 | data: ?*anyopaque, |
| 4081 | index: c_uint, |
| 4082 | }, |
| 4083 | }, |
| 4084 | else => void, |
| 4085 | }; |
| 4086 | pub const in_pktinfo = switch (native_os) { |
| 4087 | .linux => linux.in_pktinfo, |
| 4088 | // https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1132 |
| 4089 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L696 |
| 4090 | .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 4091 | ifindex: u32, |
| 4092 | spec_dst: u32, |
| 4093 | addr: u32, |
| 4094 | }, |
| 4095 | else => void, |
| 4096 | }; |
| 4097 | pub const in6_pktinfo = switch (native_os) { |
| 4098 | .linux => linux.in6_pktinfo, |
| 4099 | // https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet6/in6.h#L547 |
| 4100 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet6/in6.h#L575 |
| 4101 | // https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet6/in6.h#L468 |
| 4102 | // https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet6/in6.h#L365 |
| 4103 | // https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L114IP1 |
| 4104 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L737 |
| 4105 | // https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet6/in6.h#L63 |
| 4106 | // https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122 |
| 4107 | .freebsd, .dragonfly, .netbsd, .openbsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .haiku, .serenity => extern struct { |
| 4108 | addr: [16]u8, |
| 4109 | ifindex: u32, |
| 4110 | }, |
| 4111 | else => void, |
| 4112 | }; |
| 4113 | pub const itimerspec = switch (native_os) { |
| 4114 | .linux => linux.itimerspec, |
| 4115 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .windows, .wasi => extern struct { |
| 4116 | interval: timespec, |
| 4117 | value: timespec, |
| 4118 | }, |
| 4119 | else => void, |
| 4120 | }; |
| 4121 | pub const linger = switch (native_os) { |
| 4122 | .linux => linux.linger, |
| 4123 | // https://github.com/freebsd/freebsd-src/blob/46347b3619757e3d683a87ca03efaf2ae242335f/sys/sys/socket.h#L200 |
| 4124 | .freebsd, |
| 4125 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L158 |
| 4126 | .dragonfly, |
| 4127 | // https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/sys/socket.h#L183 |
| 4128 | .netbsd, |
| 4129 | // https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/sys/socket.h#L126 |
| 4130 | .openbsd, |
| 4131 | // https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/sys/socket.h#L250 |
| 4132 | .illumos, |
| 4133 | // https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/sys/socket.h#L87 |
| 4134 | .haiku, |
| 4135 | // https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122 |
| 4136 | .serenity, |
| 4137 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L498 |
| 4138 | .driverkit, |
| 4139 | .ios, |
| 4140 | .maccatalyst, |
| 4141 | .macos, |
| 4142 | .tvos, |
| 4143 | .visionos, |
| 4144 | .watchos, |
| 4145 | => extern struct { |
| 4146 | onoff: i32, // non-zero to linger on close |
| 4147 | linger: i32, // time to linger in seconds |
| 4148 | }, |
| 4149 | else => void, |
| 4150 | }; |
| 4151 | |
| 4152 | pub const msghdr = switch (native_os) { |
| 4153 | .linux => if (@bitSizeOf(usize) > @bitSizeOf(i32) and builtin.abi.isMusl()) posix_msghdr else linux.msghdr, |
| 4154 | .openbsd, |
| 4155 | .emscripten, |
| 4156 | .dragonfly, |
| 4157 | .freebsd, |
| 4158 | .netbsd, |
| 4159 | .haiku, |
| 4160 | .illumos, |
| 4161 | .driverkit, |
| 4162 | .ios, |
| 4163 | .maccatalyst, |
| 4164 | .macos, |
| 4165 | .tvos, |
| 4166 | .visionos, |
| 4167 | .watchos, |
| 4168 | .serenity, // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L74-L82 |
| 4169 | => posix_msghdr, |
| 4170 | else => void, |
| 4171 | }; |
| 4172 | |
| 4173 | /// There are several instances of struct fields that POSIX defines as either int or socklen_t, but |
| 4174 | /// on Linux are size_t. glibc ignores POSIX, and uses the Linux kernel's definitions. musl on the |
| 4175 | /// other hand aims to be POSIX-ly correct, and defines those fields in a manner aligning with |
| 4176 | /// POSIX. |
| 4177 | /// |
| 4178 | /// musl works around this incompatibility between the 64-bit Linux ABI and the POSIX specification |
| 4179 | /// by adding padding fields on either side depending on host endianness: |
| 4180 | /// |
| 4181 | /// #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN |
| 4182 | /// int __pad2; |
| 4183 | /// #endif |
| 4184 | /// socklen_t msg_controllen; |
| 4185 | /// #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN |
| 4186 | /// int __pad2; |
| 4187 | /// #endif |
| 4188 | /// |
| 4189 | /// To emulate this quirk of musl, the MuslOnlyPadding field is used in these structs |
| 4190 | /// |
| 4191 | /// pad0: MuslOnlyPadding(.big) = 0, |
| 4192 | /// msg_controllen: socklen_t, |
| 4193 | /// pad1: MuslOnlyPadding(.little) = 0, |
| 4194 | /// |
| 4195 | /// On 32-bit and non-musl systems, these fields will be zero sized, and ignored. |
| 4196 | fn MuslOnlyPadding(endian: std.builtin.Endian) type { |
| 4197 | return if (builtin.abi.isMusl() and @sizeOf(usize) == 8 and native_endian == endian) u32 else u0; |
| 4198 | } |
| 4199 | |
| 4200 | /// https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html |
| 4201 | const posix_msghdr = extern struct { |
| 4202 | name: ?*sockaddr, |
| 4203 | namelen: socklen_t, |
| 4204 | iov: [*]iovec, |
| 4205 | pad0: MuslOnlyPadding(.big) = 0, |
| 4206 | iovlen: u32, |
| 4207 | pad1: MuslOnlyPadding(.little) = 0, |
| 4208 | control: ?*anyopaque, |
| 4209 | pad2: MuslOnlyPadding(.big) = 0, |
| 4210 | controllen: socklen_t, |
| 4211 | pad3: MuslOnlyPadding(.little) = 0, |
| 4212 | flags: u32, |
| 4213 | }; |
| 4214 | |
| 4215 | pub const msghdr_const = switch (native_os) { |
| 4216 | .linux => if (@bitSizeOf(usize) > @bitSizeOf(i32) and builtin.abi.isMusl()) posix_msghdr_const else linux.msghdr_const, |
| 4217 | .openbsd, |
| 4218 | .emscripten, |
| 4219 | .dragonfly, |
| 4220 | .freebsd, |
| 4221 | .netbsd, |
| 4222 | .haiku, |
| 4223 | .illumos, |
| 4224 | .driverkit, |
| 4225 | .ios, |
| 4226 | .maccatalyst, |
| 4227 | .macos, |
| 4228 | .tvos, |
| 4229 | .visionos, |
| 4230 | .watchos, |
| 4231 | .serenity, |
| 4232 | => posix_msghdr_const, |
| 4233 | else => void, |
| 4234 | }; |
| 4235 | |
| 4236 | const posix_msghdr_const = extern struct { |
| 4237 | name: ?*const sockaddr, |
| 4238 | namelen: socklen_t, |
| 4239 | iov: [*]const iovec_const, |
| 4240 | pad0: MuslOnlyPadding(.big) = 0, |
| 4241 | iovlen: u32, |
| 4242 | pad1: MuslOnlyPadding(.little) = 0, |
| 4243 | control: ?*const anyopaque, |
| 4244 | pad2: MuslOnlyPadding(.big) = 0, |
| 4245 | controllen: socklen_t, |
| 4246 | pad3: MuslOnlyPadding(.little) = 0, |
| 4247 | flags: u32, |
| 4248 | }; |
| 4249 | |
| 4250 | pub const mmsghdr = switch (native_os) { |
| 4251 | .linux => linux.mmsghdr, |
| 4252 | else => extern struct { |
| 4253 | hdr: msghdr, |
| 4254 | len: u32, |
| 4255 | }, |
| 4256 | }; |
| 4257 | |
| 4258 | pub const cmsghdr = switch (native_os) { |
| 4259 | .linux => if (@bitSizeOf(usize) > @bitSizeOf(i32) and builtin.abi.isMusl()) posix_cmsghdr else linux.cmsghdr, |
| 4260 | // https://github.com/emscripten-core/emscripten/blob/96371ed7888fc78c040179f4d4faa82a6a07a116/system/lib/libc/musl/include/sys/socket.h#L44 |
| 4261 | .emscripten => linux.cmsghdr, |
| 4262 | // https://github.com/freebsd/freebsd-src/blob/b197d2abcb6895d78bc9df8404e374397aa44748/sys/sys/socket.h#L492 |
| 4263 | .freebsd, |
| 4264 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/107c0518337ba90e7fa49e74845d8d44320c9a6d/sys/sys/socket.h#L452 |
| 4265 | .dragonfly, |
| 4266 | // https://github.com/NetBSD/src/blob/ba8e1774fd9c0c26ecca461c07bc95d9ebb69579/sys/sys/socket.h#L528 |
| 4267 | .netbsd, |
| 4268 | // https://github.com/openbsd/src/blob/master/sys/sys/socket.h#L527 |
| 4269 | .openbsd, |
| 4270 | // https://github.com/illumos/illumos-gate/blob/afdf2e523873cb523df379676067bf9785a0f456/usr/src/uts/common/sys/socket.h#L460 |
| 4271 | .illumos, |
| 4272 | // https://github.com/SerenityOS/serenity/blob/4ee360a348a5e2490eeaeeabb3eb19e70dd450eb/Kernel/API/POSIX/sys/socket.h#L68 |
| 4273 | .serenity, |
| 4274 | // https://github.com/haiku/haiku/blob/b54f586058fd6623645512e4631468cede9933b9/headers/posix/sys/socket.h#L132 |
| 4275 | .haiku, |
| 4276 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1041 |
| 4277 | .driverkit, |
| 4278 | .ios, |
| 4279 | .maccatalyst, |
| 4280 | .macos, |
| 4281 | .tvos, |
| 4282 | .visionos, |
| 4283 | .watchos, |
| 4284 | => posix_cmsghdr, |
| 4285 | |
| 4286 | else => void, |
| 4287 | }; |
| 4288 | |
| 4289 | const posix_cmsghdr = extern struct { |
| 4290 | pad0: MuslOnlyPadding(.big) = 0, |
| 4291 | len: socklen_t, |
| 4292 | pad1: MuslOnlyPadding(.little) = 0, |
| 4293 | level: c_int, |
| 4294 | type: c_int, |
| 4295 | }; |
| 4296 | |
| 4297 | pub const nfds_t = switch (native_os) { |
| 4298 | .linux => linux.nfds_t, |
| 4299 | .emscripten => emscripten.nfds_t, |
| 4300 | .haiku, .illumos, .wasi => usize, |
| 4301 | .windows => c_ulong, |
| 4302 | .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u32, |
| 4303 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L32 |
| 4304 | .serenity => c_uint, |
| 4305 | else => void, |
| 4306 | }; |
| 4307 | pub const perf_event_attr = switch (native_os) { |
| 4308 | .linux => linux.perf_event_attr, |
| 4309 | else => void, |
| 4310 | }; |
| 4311 | pub const pid_t = switch (native_os) { |
| 4312 | .linux => linux.pid_t, |
| 4313 | .emscripten => emscripten.pid_t, |
| 4314 | .windows => windows.HANDLE, |
| 4315 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L31-L32 |
| 4316 | .serenity => c_int, |
| 4317 | else => i32, |
| 4318 | }; |
| 4319 | pub const pollfd = switch (native_os) { |
| 4320 | .linux => linux.pollfd, |
| 4321 | .emscripten => emscripten.pollfd, |
| 4322 | .windows => ws2_32.pollfd, |
| 4323 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L26-L30 |
| 4324 | .serenity => extern struct { |
| 4325 | fd: fd_t, |
| 4326 | events: c_short, |
| 4327 | revents: c_short = undefined, |
| 4328 | }, |
| 4329 | else => extern struct { |
| 4330 | fd: fd_t, |
| 4331 | events: i16, |
| 4332 | revents: i16 = undefined, |
| 4333 | }, |
| 4334 | }; |
| 4335 | pub const rlim_t = switch (native_os) { |
| 4336 | .linux => linux.rlim_t, |
| 4337 | .emscripten => emscripten.rlim_t, |
| 4338 | .openbsd, .netbsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u64, |
| 4339 | .haiku, .dragonfly, .freebsd => i64, |
| 4340 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L54 |
| 4341 | .serenity => usize, |
| 4342 | else => void, |
| 4343 | }; |
| 4344 | pub const rlimit = switch (native_os) { |
| 4345 | .linux, .emscripten => linux.rlimit, |
| 4346 | .windows => void, |
| 4347 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L56-L59 |
| 4348 | else => extern struct { |
| 4349 | /// Soft limit |
| 4350 | cur: rlim_t, |
| 4351 | /// Hard limit |
| 4352 | max: rlim_t, |
| 4353 | }, |
| 4354 | }; |
| 4355 | pub const rlimit_resource = switch (native_os) { |
| 4356 | .linux => linux.rlimit_resource, |
| 4357 | .emscripten => emscripten.rlimit_resource, |
| 4358 | .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) { |
| 4359 | CPU = 0, |
| 4360 | FSIZE = 1, |
| 4361 | DATA = 2, |
| 4362 | STACK = 3, |
| 4363 | CORE = 4, |
| 4364 | RSS = 5, |
| 4365 | MEMLOCK = 6, |
| 4366 | NPROC = 7, |
| 4367 | NOFILE = 8, |
| 4368 | _, |
| 4369 | |
| 4370 | pub const AS: rlimit_resource = .RSS; |
| 4371 | }, |
| 4372 | .freebsd => enum(c_int) { |
| 4373 | CPU = 0, |
| 4374 | FSIZE = 1, |
| 4375 | DATA = 2, |
| 4376 | STACK = 3, |
| 4377 | CORE = 4, |
| 4378 | RSS = 5, |
| 4379 | MEMLOCK = 6, |
| 4380 | NPROC = 7, |
| 4381 | NOFILE = 8, |
| 4382 | SBSIZE = 9, |
| 4383 | VMEM = 10, |
| 4384 | NPTS = 11, |
| 4385 | SWAP = 12, |
| 4386 | KQUEUES = 13, |
| 4387 | UMTXP = 14, |
| 4388 | _, |
| 4389 | |
| 4390 | pub const AS: rlimit_resource = .VMEM; |
| 4391 | }, |
| 4392 | .illumos => enum(c_int) { |
| 4393 | CPU = 0, |
| 4394 | FSIZE = 1, |
| 4395 | DATA = 2, |
| 4396 | STACK = 3, |
| 4397 | CORE = 4, |
| 4398 | NOFILE = 5, |
| 4399 | VMEM = 6, |
| 4400 | _, |
| 4401 | |
| 4402 | pub const AS: rlimit_resource = .VMEM; |
| 4403 | }, |
| 4404 | .netbsd => enum(c_int) { |
| 4405 | CPU = 0, |
| 4406 | FSIZE = 1, |
| 4407 | DATA = 2, |
| 4408 | STACK = 3, |
| 4409 | CORE = 4, |
| 4410 | RSS = 5, |
| 4411 | MEMLOCK = 6, |
| 4412 | NPROC = 7, |
| 4413 | NOFILE = 8, |
| 4414 | SBSIZE = 9, |
| 4415 | VMEM = 10, |
| 4416 | NTHR = 11, |
| 4417 | _, |
| 4418 | |
| 4419 | pub const AS: rlimit_resource = .VMEM; |
| 4420 | }, |
| 4421 | .dragonfly => enum(c_int) { |
| 4422 | CPU = 0, |
| 4423 | FSIZE = 1, |
| 4424 | DATA = 2, |
| 4425 | STACK = 3, |
| 4426 | CORE = 4, |
| 4427 | RSS = 5, |
| 4428 | MEMLOCK = 6, |
| 4429 | NPROC = 7, |
| 4430 | NOFILE = 8, |
| 4431 | SBSIZE = 9, |
| 4432 | VMEM = 10, |
| 4433 | POSIXLOCKS = 11, |
| 4434 | _, |
| 4435 | |
| 4436 | pub const AS: rlimit_resource = .VMEM; |
| 4437 | }, |
| 4438 | .haiku => enum(i32) { |
| 4439 | CORE = 0, |
| 4440 | CPU = 1, |
| 4441 | DATA = 2, |
| 4442 | FSIZE = 3, |
| 4443 | NOFILE = 4, |
| 4444 | STACK = 5, |
| 4445 | AS = 6, |
| 4446 | NOVMON = 7, |
| 4447 | _, |
| 4448 | }, |
| 4449 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L42-L48 |
| 4450 | .serenity => enum(c_int) { |
| 4451 | CORE = 1, |
| 4452 | CPU = 2, |
| 4453 | DATA = 3, |
| 4454 | FSIZE = 4, |
| 4455 | NOFILE = 5, |
| 4456 | STACK = 6, |
| 4457 | AS = 7, |
| 4458 | _, |
| 4459 | }, |
| 4460 | else => void, |
| 4461 | }; |
| 4462 | pub const rusage = switch (native_os) { |
| 4463 | .linux => linux.rusage, |
| 4464 | .emscripten => emscripten.rusage, |
| 4465 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 4466 | utime: timeval, |
| 4467 | stime: timeval, |
| 4468 | maxrss: isize, |
| 4469 | ixrss: isize, |
| 4470 | idrss: isize, |
| 4471 | isrss: isize, |
| 4472 | minflt: isize, |
| 4473 | majflt: isize, |
| 4474 | nswap: isize, |
| 4475 | inblock: isize, |
| 4476 | oublock: isize, |
| 4477 | msgsnd: isize, |
| 4478 | msgrcv: isize, |
| 4479 | nsignals: isize, |
| 4480 | nvcsw: isize, |
| 4481 | nivcsw: isize, |
| 4482 | |
| 4483 | pub const SELF = 0; |
| 4484 | pub const CHILDREN = -1; |
| 4485 | }, |
| 4486 | .illumos => extern struct { |
| 4487 | utime: timeval, |
| 4488 | stime: timeval, |
| 4489 | maxrss: isize, |
| 4490 | ixrss: isize, |
| 4491 | idrss: isize, |
| 4492 | isrss: isize, |
| 4493 | minflt: isize, |
| 4494 | majflt: isize, |
| 4495 | nswap: isize, |
| 4496 | inblock: isize, |
| 4497 | oublock: isize, |
| 4498 | msgsnd: isize, |
| 4499 | msgrcv: isize, |
| 4500 | nsignals: isize, |
| 4501 | nvcsw: isize, |
| 4502 | nivcsw: isize, |
| 4503 | |
| 4504 | pub const SELF = 0; |
| 4505 | pub const CHILDREN = -1; |
| 4506 | pub const THREAD = 1; |
| 4507 | }, |
| 4508 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L18-L38 |
| 4509 | .serenity => extern struct { |
| 4510 | utime: timeval, |
| 4511 | stime: timeval, |
| 4512 | maxrss: c_long, |
| 4513 | ixrss: c_long, |
| 4514 | idrss: c_long, |
| 4515 | isrss: c_long, |
| 4516 | minflt: c_long, |
| 4517 | majflt: c_long, |
| 4518 | nswap: c_long, |
| 4519 | inblock: c_long, |
| 4520 | oublock: c_long, |
| 4521 | msgsnd: c_long, |
| 4522 | msgrcv: c_long, |
| 4523 | nsignals: c_long, |
| 4524 | nvcsw: c_long, |
| 4525 | nivcsw: c_long, |
| 4526 | |
| 4527 | pub const SELF = 1; |
| 4528 | pub const CHILDREN = 2; |
| 4529 | }, |
| 4530 | .freebsd, .openbsd => extern struct { |
| 4531 | utime: timeval, |
| 4532 | stime: timeval, |
| 4533 | maxrss: c_long, |
| 4534 | ixrss: c_long, |
| 4535 | idrss: c_long, |
| 4536 | isrss: c_long, |
| 4537 | minflt: c_long, |
| 4538 | majflt: c_long, |
| 4539 | nswap: c_long, |
| 4540 | inblock: c_long, |
| 4541 | oublock: c_long, |
| 4542 | msgsnd: c_long, |
| 4543 | msgrcv: c_long, |
| 4544 | nsignals: c_long, |
| 4545 | nvcsw: c_long, |
| 4546 | nivcsw: c_long, |
| 4547 | |
| 4548 | pub const SELF = 0; |
| 4549 | pub const CHILDREN = -1; |
| 4550 | pub const THREAD = 1; |
| 4551 | }, |
| 4552 | .dragonfly, .netbsd => extern struct { |
| 4553 | utime: timeval, |
| 4554 | stime: timeval, |
| 4555 | maxrss: c_long, |
| 4556 | ixrss: c_long, |
| 4557 | idrss: c_long, |
| 4558 | isrss: c_long, |
| 4559 | minflt: c_long, |
| 4560 | majflt: c_long, |
| 4561 | nswap: c_long, |
| 4562 | inblock: c_long, |
| 4563 | oublock: c_long, |
| 4564 | msgsnd: c_long, |
| 4565 | msgrcv: c_long, |
| 4566 | nsignals: c_long, |
| 4567 | nvcsw: c_long, |
| 4568 | nivcsw: c_long, |
| 4569 | |
| 4570 | pub const SELF = 0; |
| 4571 | pub const CHILDREN = -1; |
| 4572 | }, |
| 4573 | else => void, |
| 4574 | }; |
| 4575 | |
| 4576 | pub const siginfo_t = switch (native_os) { |
| 4577 | .linux => linux.siginfo_t, |
| 4578 | .emscripten => emscripten.siginfo_t, |
| 4579 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 4580 | signo: SIG, |
| 4581 | errno: c_int, |
| 4582 | code: c_int, |
| 4583 | pid: pid_t, |
| 4584 | uid: uid_t, |
| 4585 | status: c_int, |
| 4586 | addr: *allowzero anyopaque, |
| 4587 | value: extern union { |
| 4588 | int: c_int, |
| 4589 | ptr: *anyopaque, |
| 4590 | }, |
| 4591 | si_band: c_long, |
| 4592 | _pad: [7]c_ulong, |
| 4593 | }, |
| 4594 | .freebsd => extern struct { |
| 4595 | // Signal number. |
| 4596 | signo: SIG, |
| 4597 | // Errno association. |
| 4598 | errno: c_int, |
| 4599 | /// Signal code. |
| 4600 | /// |
| 4601 | /// Cause of signal, one of the SI_ macros or signal-specific values, i.e. |
| 4602 | /// one of the FPE_... values for SIGFPE. |
| 4603 | /// This value is equivalent to the second argument to an old-style FreeBSD |
| 4604 | /// signal handler. |
| 4605 | code: c_int, |
| 4606 | /// Sending process. |
| 4607 | pid: pid_t, |
| 4608 | /// Sender's ruid. |
| 4609 | uid: uid_t, |
| 4610 | /// Exit value. |
| 4611 | status: c_int, |
| 4612 | /// Faulting instruction. |
| 4613 | addr: *allowzero anyopaque, |
| 4614 | /// Signal value. |
| 4615 | value: sigval, |
| 4616 | reason: extern union { |
| 4617 | fault: extern struct { |
| 4618 | /// Machine specific trap code. |
| 4619 | trapno: c_int, |
| 4620 | }, |
| 4621 | timer: extern struct { |
| 4622 | timerid: c_int, |
| 4623 | overrun: c_int, |
| 4624 | }, |
| 4625 | mesgq: extern struct { |
| 4626 | mqd: c_int, |
| 4627 | }, |
| 4628 | poll: extern struct { |
| 4629 | /// Band event for SIGPOLL. UNUSED. |
| 4630 | band: c_long, |
| 4631 | }, |
| 4632 | spare: extern struct { |
| 4633 | spare1: c_long, |
| 4634 | spare2: [7]c_int, |
| 4635 | }, |
| 4636 | }, |
| 4637 | }, |
| 4638 | .illumos => extern struct { |
| 4639 | signo: SIG, |
| 4640 | code: c_int, |
| 4641 | errno: c_int, |
| 4642 | // 64bit architectures insert 4bytes of padding here, this is done by |
| 4643 | // correctly aligning the reason field |
| 4644 | reason: extern union { |
| 4645 | proc: extern struct { |
| 4646 | pid: pid_t, |
| 4647 | pdata: extern union { |
| 4648 | kill: extern struct { |
| 4649 | uid: uid_t, |
| 4650 | value: sigval_t, |
| 4651 | }, |
| 4652 | cld: extern struct { |
| 4653 | utime: clock_t, |
| 4654 | status: c_int, |
| 4655 | stime: clock_t, |
| 4656 | }, |
| 4657 | }, |
| 4658 | contract: illumos.ctid_t, |
| 4659 | zone: illumos.zoneid_t, |
| 4660 | }, |
| 4661 | fault: extern struct { |
| 4662 | addr: *allowzero anyopaque, |
| 4663 | trapno: c_int, |
| 4664 | pc: ?*anyopaque, |
| 4665 | }, |
| 4666 | file: extern struct { |
| 4667 | // fd not currently available for SIGPOLL. |
| 4668 | fd: c_int, |
| 4669 | band: c_long, |
| 4670 | }, |
| 4671 | prof: extern struct { |
| 4672 | addr: ?*anyopaque, |
| 4673 | timestamp: timespec, |
| 4674 | syscall: c_short, |
| 4675 | sysarg: u8, |
| 4676 | fault: u8, |
| 4677 | args: [8]c_long, |
| 4678 | state: [10]c_int, |
| 4679 | }, |
| 4680 | rctl: extern struct { |
| 4681 | entity: i32, |
| 4682 | }, |
| 4683 | __pad: [256 - 4 * @sizeOf(c_int)]u8, |
| 4684 | } align(@sizeOf(usize)), |
| 4685 | |
| 4686 | comptime { |
| 4687 | assert(@sizeOf(@This()) == 256); |
| 4688 | assert(@alignOf(@This()) == @sizeOf(usize)); |
| 4689 | } |
| 4690 | }, |
| 4691 | .netbsd => extern union { |
| 4692 | pad: [128]u8, |
| 4693 | info: netbsd._ksiginfo, |
| 4694 | }, |
| 4695 | .dragonfly => extern struct { |
| 4696 | signo: SIG, |
| 4697 | errno: c_int, |
| 4698 | code: c_int, |
| 4699 | pid: c_int, |
| 4700 | uid: uid_t, |
| 4701 | status: c_int, |
| 4702 | addr: *allowzero anyopaque, |
| 4703 | value: sigval, |
| 4704 | band: c_long, |
| 4705 | __spare__: [7]c_int, |
| 4706 | }, |
| 4707 | .haiku => extern struct { |
| 4708 | signo: SIG, |
| 4709 | code: i32, |
| 4710 | errno: i32, |
| 4711 | |
| 4712 | pid: pid_t, |
| 4713 | uid: uid_t, |
| 4714 | addr: *allowzero anyopaque, |
| 4715 | }, |
| 4716 | .openbsd => extern struct { |
| 4717 | signo: SIG, |
| 4718 | code: c_int, |
| 4719 | errno: c_int, |
| 4720 | data: extern union { |
| 4721 | proc: extern struct { |
| 4722 | pid: pid_t, |
| 4723 | pdata: extern union { |
| 4724 | kill: extern struct { |
| 4725 | uid: uid_t, |
| 4726 | value: sigval, |
| 4727 | }, |
| 4728 | cld: extern struct { |
| 4729 | utime: clock_t, |
| 4730 | stime: clock_t, |
| 4731 | status: c_int, |
| 4732 | }, |
| 4733 | }, |
| 4734 | }, |
| 4735 | fault: extern struct { |
| 4736 | addr: *allowzero anyopaque, |
| 4737 | trapno: c_int, |
| 4738 | }, |
| 4739 | __pad: [128 - 3 * @sizeOf(c_int)]u8, |
| 4740 | }, |
| 4741 | }, |
| 4742 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L27-L37 |
| 4743 | .serenity => extern struct { |
| 4744 | signo: SIG, |
| 4745 | code: c_int, |
| 4746 | errno: c_int, |
| 4747 | pid: pid_t, |
| 4748 | uid: uid_t, |
| 4749 | addr: ?*anyopaque, |
| 4750 | status: c_int, |
| 4751 | band: c_int, |
| 4752 | value: sigval, |
| 4753 | }, |
| 4754 | else => void, |
| 4755 | }; |
| 4756 | pub const sigset_t = switch (native_os) { |
| 4757 | .linux => [1024 / @bitSizeOf(c_ulong)]c_ulong, // glibc and musl present a 1024-bit sigset_t, while kernel's is 128-bit or less. |
| 4758 | .emscripten => emscripten.sigset_t, |
| 4759 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L19 |
| 4760 | .openbsd, .serenity => u32, |
| 4761 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.sigset_t, |
| 4762 | .dragonfly, .netbsd, .illumos, .freebsd => extern struct { |
| 4763 | __bits: [SIG.WORDS]u32, |
| 4764 | }, |
| 4765 | .haiku => u64, |
| 4766 | else => u0, |
| 4767 | }; |
| 4768 | |
| 4769 | pub const sigval = switch (native_os) { |
| 4770 | .linux => linux.sigval, |
| 4771 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L22-L25 |
| 4772 | .openbsd, .dragonfly, .freebsd, .serenity => extern union { |
| 4773 | int: c_int, |
| 4774 | ptr: ?*anyopaque, |
| 4775 | }, |
| 4776 | else => void, |
| 4777 | }; |
| 4778 | |
| 4779 | pub const addrinfo = if (builtin.abi.isAndroid()) extern struct { |
| 4780 | flags: AI, |
| 4781 | family: i32, |
| 4782 | socktype: i32, |
| 4783 | protocol: i32, |
| 4784 | addrlen: socklen_t, |
| 4785 | canonname: ?[*:0]u8, |
| 4786 | addr: ?*sockaddr, |
| 4787 | next: ?*addrinfo, |
| 4788 | } else switch (native_os) { |
| 4789 | .linux, .emscripten => linux.addrinfo, |
| 4790 | .windows => ws2_32.addrinfo, |
| 4791 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 4792 | flags: AI, |
| 4793 | family: i32, |
| 4794 | socktype: i32, |
| 4795 | protocol: i32, |
| 4796 | addrlen: socklen_t, |
| 4797 | canonname: ?[*:0]u8, |
| 4798 | addr: ?*sockaddr, |
| 4799 | next: ?*addrinfo, |
| 4800 | }, |
| 4801 | .illumos => extern struct { |
| 4802 | flags: AI, |
| 4803 | family: i32, |
| 4804 | socktype: i32, |
| 4805 | protocol: i32, |
| 4806 | addrlen: socklen_t, |
| 4807 | canonname: ?[*:0]u8, |
| 4808 | addr: ?*sockaddr, |
| 4809 | next: ?*addrinfo, |
| 4810 | }, |
| 4811 | .netbsd => extern struct { |
| 4812 | flags: AI, |
| 4813 | family: i32, |
| 4814 | socktype: i32, |
| 4815 | protocol: i32, |
| 4816 | addrlen: socklen_t, |
| 4817 | canonname: ?[*:0]u8, |
| 4818 | addr: ?*sockaddr, |
| 4819 | next: ?*addrinfo, |
| 4820 | }, |
| 4821 | .dragonfly => extern struct { |
| 4822 | flags: AI, |
| 4823 | family: i32, |
| 4824 | socktype: i32, |
| 4825 | protocol: i32, |
| 4826 | addrlen: socklen_t, |
| 4827 | canonname: ?[*:0]u8, |
| 4828 | addr: ?*sockaddr, |
| 4829 | next: ?*addrinfo, |
| 4830 | }, |
| 4831 | .haiku => extern struct { |
| 4832 | flags: AI, |
| 4833 | family: i32, |
| 4834 | socktype: i32, |
| 4835 | protocol: i32, |
| 4836 | addrlen: socklen_t, |
| 4837 | canonname: ?[*:0]u8, |
| 4838 | addr: ?*sockaddr, |
| 4839 | next: ?*addrinfo, |
| 4840 | }, |
| 4841 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L66-L75 |
| 4842 | .openbsd, .serenity => extern struct { |
| 4843 | flags: AI, |
| 4844 | family: c_int, |
| 4845 | socktype: c_int, |
| 4846 | protocol: c_int, |
| 4847 | addrlen: socklen_t, |
| 4848 | addr: ?*sockaddr, |
| 4849 | canonname: ?[*:0]u8, |
| 4850 | next: ?*addrinfo, |
| 4851 | }, |
| 4852 | else => void, |
| 4853 | }; |
| 4854 | pub const sockaddr = switch (native_os) { |
| 4855 | .linux, .emscripten => linux.sockaddr, |
| 4856 | .windows => ws2_32.sockaddr, |
| 4857 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 4858 | len: u8, |
| 4859 | family: sa_family_t, |
| 4860 | data: [14]u8, |
| 4861 | |
| 4862 | pub const SS_MAXSIZE = 128; |
| 4863 | pub const storage = extern struct { |
| 4864 | len: u8 align(8), |
| 4865 | family: sa_family_t, |
| 4866 | padding: [126]u8 = undefined, |
| 4867 | |
| 4868 | comptime { |
| 4869 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 4870 | assert(@alignOf(storage) == 8); |
| 4871 | } |
| 4872 | }; |
| 4873 | pub const in = extern struct { |
| 4874 | len: u8 = @sizeOf(in), |
| 4875 | family: sa_family_t = AF.INET, |
| 4876 | port: in_port_t, |
| 4877 | addr: u32, |
| 4878 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 4879 | }; |
| 4880 | pub const in6 = extern struct { |
| 4881 | len: u8 = @sizeOf(in6), |
| 4882 | family: sa_family_t = AF.INET6, |
| 4883 | port: in_port_t, |
| 4884 | flowinfo: u32, |
| 4885 | addr: [16]u8, |
| 4886 | scope_id: u32, |
| 4887 | }; |
| 4888 | |
| 4889 | /// UNIX domain socket |
| 4890 | pub const un = extern struct { |
| 4891 | len: u8 = @sizeOf(un), |
| 4892 | family: sa_family_t = AF.UNIX, |
| 4893 | path: [104]u8, |
| 4894 | }; |
| 4895 | }, |
| 4896 | .freebsd => extern struct { |
| 4897 | /// total length |
| 4898 | len: u8, |
| 4899 | /// address family |
| 4900 | family: sa_family_t, |
| 4901 | /// actually longer; address value |
| 4902 | data: [14]u8, |
| 4903 | |
| 4904 | pub const SS_MAXSIZE = 128; |
| 4905 | pub const storage = extern struct { |
| 4906 | len: u8 align(8), |
| 4907 | family: sa_family_t, |
| 4908 | padding: [126]u8 = undefined, |
| 4909 | |
| 4910 | comptime { |
| 4911 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 4912 | assert(@alignOf(storage) == 8); |
| 4913 | } |
| 4914 | }; |
| 4915 | |
| 4916 | pub const in = extern struct { |
| 4917 | len: u8 = @sizeOf(in), |
| 4918 | family: sa_family_t = AF.INET, |
| 4919 | port: in_port_t, |
| 4920 | addr: u32, |
| 4921 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 4922 | }; |
| 4923 | |
| 4924 | pub const in6 = extern struct { |
| 4925 | len: u8 = @sizeOf(in6), |
| 4926 | family: sa_family_t = AF.INET6, |
| 4927 | port: in_port_t, |
| 4928 | flowinfo: u32, |
| 4929 | addr: [16]u8, |
| 4930 | scope_id: u32, |
| 4931 | }; |
| 4932 | |
| 4933 | pub const un = extern struct { |
| 4934 | len: u8 = @sizeOf(un), |
| 4935 | family: sa_family_t = AF.UNIX, |
| 4936 | path: [104]u8, |
| 4937 | }; |
| 4938 | }, |
| 4939 | .illumos => extern struct { |
| 4940 | /// address family |
| 4941 | family: sa_family_t, |
| 4942 | |
| 4943 | /// actually longer; address value |
| 4944 | data: [14]u8, |
| 4945 | |
| 4946 | pub const SS_MAXSIZE = 256; |
| 4947 | pub const storage = extern struct { |
| 4948 | family: sa_family_t align(8), |
| 4949 | padding: [254]u8 = undefined, |
| 4950 | |
| 4951 | comptime { |
| 4952 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 4953 | assert(@alignOf(storage) == 8); |
| 4954 | } |
| 4955 | }; |
| 4956 | |
| 4957 | pub const in = extern struct { |
| 4958 | family: sa_family_t = AF.INET, |
| 4959 | port: in_port_t, |
| 4960 | addr: u32, |
| 4961 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 4962 | }; |
| 4963 | |
| 4964 | pub const in6 = extern struct { |
| 4965 | family: sa_family_t = AF.INET6, |
| 4966 | port: in_port_t, |
| 4967 | flowinfo: u32, |
| 4968 | addr: [16]u8, |
| 4969 | scope_id: u32, |
| 4970 | __src_id: u32 = 0, |
| 4971 | }; |
| 4972 | |
| 4973 | /// Definitions for UNIX IPC domain. |
| 4974 | pub const un = extern struct { |
| 4975 | family: sa_family_t = AF.UNIX, |
| 4976 | path: [108]u8, |
| 4977 | }; |
| 4978 | }, |
| 4979 | .netbsd => extern struct { |
| 4980 | /// total length |
| 4981 | len: u8, |
| 4982 | /// address family |
| 4983 | family: sa_family_t, |
| 4984 | /// actually longer; address value |
| 4985 | data: [14]u8, |
| 4986 | |
| 4987 | pub const SS_MAXSIZE = 128; |
| 4988 | pub const storage = extern struct { |
| 4989 | len: u8 align(8), |
| 4990 | family: sa_family_t, |
| 4991 | padding: [126]u8 = undefined, |
| 4992 | |
| 4993 | comptime { |
| 4994 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 4995 | assert(@alignOf(storage) == 8); |
| 4996 | } |
| 4997 | }; |
| 4998 | |
| 4999 | pub const in = extern struct { |
| 5000 | len: u8 = @sizeOf(in), |
| 5001 | family: sa_family_t = AF.INET, |
| 5002 | port: in_port_t, |
| 5003 | addr: u32, |
| 5004 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 5005 | }; |
| 5006 | |
| 5007 | pub const in6 = extern struct { |
| 5008 | len: u8 = @sizeOf(in6), |
| 5009 | family: sa_family_t = AF.INET6, |
| 5010 | port: in_port_t, |
| 5011 | flowinfo: u32, |
| 5012 | addr: [16]u8, |
| 5013 | scope_id: u32, |
| 5014 | }; |
| 5015 | |
| 5016 | /// Definitions for UNIX IPC domain. |
| 5017 | pub const un = extern struct { |
| 5018 | /// total sockaddr length |
| 5019 | len: u8 = @sizeOf(un), |
| 5020 | |
| 5021 | family: sa_family_t = AF.LOCAL, |
| 5022 | |
| 5023 | /// path name |
| 5024 | path: [104]u8, |
| 5025 | }; |
| 5026 | }, |
| 5027 | .dragonfly => extern struct { |
| 5028 | len: u8, |
| 5029 | family: sa_family_t, |
| 5030 | data: [14]u8, |
| 5031 | |
| 5032 | pub const SS_MAXSIZE = 128; |
| 5033 | pub const storage = extern struct { |
| 5034 | len: u8 align(8), |
| 5035 | family: sa_family_t, |
| 5036 | padding: [126]u8 = undefined, |
| 5037 | |
| 5038 | comptime { |
| 5039 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 5040 | assert(@alignOf(storage) == 8); |
| 5041 | } |
| 5042 | }; |
| 5043 | |
| 5044 | pub const in = extern struct { |
| 5045 | len: u8 = @sizeOf(in), |
| 5046 | family: sa_family_t = AF.INET, |
| 5047 | port: in_port_t, |
| 5048 | addr: u32, |
| 5049 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 5050 | }; |
| 5051 | |
| 5052 | pub const in6 = extern struct { |
| 5053 | len: u8 = @sizeOf(in6), |
| 5054 | family: sa_family_t = AF.INET6, |
| 5055 | port: in_port_t, |
| 5056 | flowinfo: u32, |
| 5057 | addr: [16]u8, |
| 5058 | scope_id: u32, |
| 5059 | }; |
| 5060 | |
| 5061 | pub const un = extern struct { |
| 5062 | len: u8 = @sizeOf(un), |
| 5063 | family: sa_family_t = AF.UNIX, |
| 5064 | path: [104]u8, |
| 5065 | }; |
| 5066 | }, |
| 5067 | .haiku => extern struct { |
| 5068 | /// total length |
| 5069 | len: u8, |
| 5070 | /// address family |
| 5071 | family: sa_family_t, |
| 5072 | /// actually longer; address value |
| 5073 | data: [14]u8, |
| 5074 | |
| 5075 | pub const SS_MAXSIZE = 128; |
| 5076 | pub const storage = extern struct { |
| 5077 | len: u8 align(8), |
| 5078 | family: sa_family_t, |
| 5079 | padding: [126]u8 = undefined, |
| 5080 | |
| 5081 | comptime { |
| 5082 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 5083 | assert(@alignOf(storage) == 8); |
| 5084 | } |
| 5085 | }; |
| 5086 | |
| 5087 | pub const in = extern struct { |
| 5088 | len: u8 = @sizeOf(in), |
| 5089 | family: sa_family_t = AF.INET, |
| 5090 | port: in_port_t, |
| 5091 | addr: u32, |
| 5092 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 5093 | }; |
| 5094 | |
| 5095 | pub const in6 = extern struct { |
| 5096 | len: u8 = @sizeOf(in6), |
| 5097 | family: sa_family_t = AF.INET6, |
| 5098 | port: in_port_t, |
| 5099 | flowinfo: u32, |
| 5100 | addr: [16]u8, |
| 5101 | scope_id: u32, |
| 5102 | }; |
| 5103 | |
| 5104 | pub const un = extern struct { |
| 5105 | len: u8 = @sizeOf(un), |
| 5106 | family: sa_family_t = AF.UNIX, |
| 5107 | path: [104]u8, |
| 5108 | }; |
| 5109 | }, |
| 5110 | .openbsd => extern struct { |
| 5111 | /// total length |
| 5112 | len: u8, |
| 5113 | /// address family |
| 5114 | family: sa_family_t, |
| 5115 | /// actually longer; address value |
| 5116 | data: [14]u8, |
| 5117 | |
| 5118 | pub const SS_MAXSIZE = 256; |
| 5119 | pub const storage = extern struct { |
| 5120 | len: u8 align(8), |
| 5121 | family: sa_family_t, |
| 5122 | padding: [254]u8 = undefined, |
| 5123 | |
| 5124 | comptime { |
| 5125 | assert(@sizeOf(storage) == SS_MAXSIZE); |
| 5126 | assert(@alignOf(storage) == 8); |
| 5127 | } |
| 5128 | }; |
| 5129 | |
| 5130 | pub const in = extern struct { |
| 5131 | len: u8 = @sizeOf(in), |
| 5132 | family: sa_family_t = AF.INET, |
| 5133 | port: in_port_t, |
| 5134 | addr: u32, |
| 5135 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 5136 | }; |
| 5137 | |
| 5138 | pub const in6 = extern struct { |
| 5139 | len: u8 = @sizeOf(in6), |
| 5140 | family: sa_family_t = AF.INET6, |
| 5141 | port: in_port_t, |
| 5142 | flowinfo: u32, |
| 5143 | addr: [16]u8, |
| 5144 | scope_id: u32, |
| 5145 | }; |
| 5146 | |
| 5147 | /// Definitions for UNIX IPC domain. |
| 5148 | pub const un = extern struct { |
| 5149 | /// total sockaddr length |
| 5150 | len: u8 = @sizeOf(un), |
| 5151 | |
| 5152 | family: sa_family_t = AF.LOCAL, |
| 5153 | |
| 5154 | /// path name |
| 5155 | path: [104]u8, |
| 5156 | }; |
| 5157 | }, |
| 5158 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L110-L114 |
| 5159 | .serenity => extern struct { |
| 5160 | family: sa_family_t, |
| 5161 | data: [26]u8, |
| 5162 | |
| 5163 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/netinet/in.h |
| 5164 | const in_addr = u32; |
| 5165 | const in6_addr = [16]u8; |
| 5166 | pub const in = extern struct { |
| 5167 | family: sa_family_t = AF.INET, |
| 5168 | port: in_port_t, |
| 5169 | addr: in_addr, |
| 5170 | zero: [8]u8 = @splat(0), |
| 5171 | }; |
| 5172 | pub const in6 = extern struct { |
| 5173 | family: sa_family_t = AF.INET6, |
| 5174 | port: in_port_t, |
| 5175 | flowinfo: u32, |
| 5176 | addr: in6_addr, |
| 5177 | scope_id: u32, |
| 5178 | }; |
| 5179 | |
| 5180 | // https://github.com/SerenityOS/serenity/blob/b92e6b02e53b2927732f31b1442cad420b62d1ef/Kernel/API/POSIX/sys/un.h |
| 5181 | const UNIX_PATH_MAX = 108; |
| 5182 | pub const un = extern struct { |
| 5183 | family: sa_family_t = AF.LOCAL, |
| 5184 | path: [UNIX_PATH_MAX]u8, |
| 5185 | }; |
| 5186 | }, |
| 5187 | else => void, |
| 5188 | }; |
| 5189 | pub const socklen_t = switch (native_os) { |
| 5190 | .linux, .emscripten => linux.socklen_t, |
| 5191 | .windows => ws2_32.socklen_t, |
| 5192 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L57 |
| 5193 | else => u32, |
| 5194 | }; |
| 5195 | pub const in_port_t = u16; |
| 5196 | pub const sa_family_t = switch (native_os) { |
| 5197 | .linux, .emscripten => linux.sa_family_t, |
| 5198 | .windows => ws2_32.ADDRESS_FAMILY, |
| 5199 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u8, |
| 5200 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L66 |
| 5201 | .illumos, .serenity => u16, |
| 5202 | else => void, |
| 5203 | }; |
| 5204 | pub const AF = if (builtin.abi.isAndroid()) struct { |
| 5205 | pub const UNSPEC = 0; |
| 5206 | pub const UNIX = 1; |
| 5207 | pub const LOCAL = 1; |
| 5208 | pub const INET = 2; |
| 5209 | pub const AX25 = 3; |
| 5210 | pub const IPX = 4; |
| 5211 | pub const APPLETALK = 5; |
| 5212 | pub const NETROM = 6; |
| 5213 | pub const BRIDGE = 7; |
| 5214 | pub const ATMPVC = 8; |
| 5215 | pub const X25 = 9; |
| 5216 | pub const INET6 = 10; |
| 5217 | pub const ROSE = 11; |
| 5218 | pub const DECnet = 12; |
| 5219 | pub const NETBEUI = 13; |
| 5220 | pub const SECURITY = 14; |
| 5221 | pub const KEY = 15; |
| 5222 | pub const NETLINK = 16; |
| 5223 | pub const ROUTE = NETLINK; |
| 5224 | pub const PACKET = 17; |
| 5225 | pub const ASH = 18; |
| 5226 | pub const ECONET = 19; |
| 5227 | pub const ATMSVC = 20; |
| 5228 | pub const RDS = 21; |
| 5229 | pub const SNA = 22; |
| 5230 | pub const IRDA = 23; |
| 5231 | pub const PPPOX = 24; |
| 5232 | pub const WANPIPE = 25; |
| 5233 | pub const LLC = 26; |
| 5234 | pub const CAN = 29; |
| 5235 | pub const TIPC = 30; |
| 5236 | pub const BLUETOOTH = 31; |
| 5237 | pub const IUCV = 32; |
| 5238 | pub const RXRPC = 33; |
| 5239 | pub const ISDN = 34; |
| 5240 | pub const PHONET = 35; |
| 5241 | pub const IEEE802154 = 36; |
| 5242 | pub const CAIF = 37; |
| 5243 | pub const ALG = 38; |
| 5244 | pub const NFC = 39; |
| 5245 | pub const VSOCK = 40; |
| 5246 | pub const KCM = 41; |
| 5247 | pub const QIPCRTR = 42; |
| 5248 | pub const MAX = 43; |
| 5249 | } else switch (native_os) { |
| 5250 | .linux, .emscripten => linux.AF, |
| 5251 | .windows => ws2_32.AF, |
| 5252 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 5253 | pub const UNSPEC = 0; |
| 5254 | pub const LOCAL = 1; |
| 5255 | pub const UNIX = LOCAL; |
| 5256 | pub const INET = 2; |
| 5257 | pub const SYS_CONTROL = 2; |
| 5258 | pub const IMPLINK = 3; |
| 5259 | pub const PUP = 4; |
| 5260 | pub const CHAOS = 5; |
| 5261 | pub const NS = 6; |
| 5262 | pub const ISO = 7; |
| 5263 | pub const OSI = ISO; |
| 5264 | pub const ECMA = 8; |
| 5265 | pub const DATAKIT = 9; |
| 5266 | pub const CCITT = 10; |
| 5267 | pub const SNA = 11; |
| 5268 | pub const DECnet = 12; |
| 5269 | pub const DLI = 13; |
| 5270 | pub const LAT = 14; |
| 5271 | pub const HYLINK = 15; |
| 5272 | pub const APPLETALK = 16; |
| 5273 | pub const ROUTE = 17; |
| 5274 | pub const LINK = 18; |
| 5275 | pub const XTP = 19; |
| 5276 | pub const COIP = 20; |
| 5277 | pub const CNT = 21; |
| 5278 | pub const RTIP = 22; |
| 5279 | pub const IPX = 23; |
| 5280 | pub const SIP = 24; |
| 5281 | pub const PIP = 25; |
| 5282 | pub const ISDN = 28; |
| 5283 | pub const E164 = ISDN; |
| 5284 | pub const KEY = 29; |
| 5285 | pub const INET6 = 30; |
| 5286 | pub const NATM = 31; |
| 5287 | pub const SYSTEM = 32; |
| 5288 | pub const NETBIOS = 33; |
| 5289 | pub const PPP = 34; |
| 5290 | pub const MAX = 40; |
| 5291 | }, |
| 5292 | .freebsd => struct { |
| 5293 | pub const UNSPEC = 0; |
| 5294 | pub const UNIX = 1; |
| 5295 | pub const LOCAL = UNIX; |
| 5296 | pub const FILE = LOCAL; |
| 5297 | pub const INET = 2; |
| 5298 | pub const IMPLINK = 3; |
| 5299 | pub const PUP = 4; |
| 5300 | pub const CHAOS = 5; |
| 5301 | pub const NETBIOS = 6; |
| 5302 | pub const ISO = 7; |
| 5303 | pub const OSI = ISO; |
| 5304 | pub const ECMA = 8; |
| 5305 | pub const DATAKIT = 9; |
| 5306 | pub const CCITT = 10; |
| 5307 | pub const SNA = 11; |
| 5308 | pub const DECnet = 12; |
| 5309 | pub const DLI = 13; |
| 5310 | pub const LAT = 14; |
| 5311 | pub const HYLINK = 15; |
| 5312 | pub const APPLETALK = 16; |
| 5313 | pub const ROUTE = 17; |
| 5314 | pub const LINK = 18; |
| 5315 | pub const pseudo_XTP = 19; |
| 5316 | pub const COIP = 20; |
| 5317 | pub const CNT = 21; |
| 5318 | pub const pseudo_RTIP = 22; |
| 5319 | pub const IPX = 23; |
| 5320 | pub const SIP = 24; |
| 5321 | pub const pseudo_PIP = 25; |
| 5322 | pub const ISDN = 26; |
| 5323 | pub const E164 = ISDN; |
| 5324 | pub const pseudo_KEY = 27; |
| 5325 | pub const INET6 = 28; |
| 5326 | pub const NATM = 29; |
| 5327 | pub const ATM = 30; |
| 5328 | pub const pseudo_HDRCMPLT = 31; |
| 5329 | pub const NETGRAPH = 32; |
| 5330 | pub const SLOW = 33; |
| 5331 | pub const SCLUSTER = 34; |
| 5332 | pub const ARP = 35; |
| 5333 | pub const BLUETOOTH = 36; |
| 5334 | pub const IEEE80211 = 37; |
| 5335 | pub const INET_SDP = 40; |
| 5336 | pub const INET6_SDP = 42; |
| 5337 | pub const MAX = 42; |
| 5338 | }, |
| 5339 | .illumos => struct { |
| 5340 | pub const UNSPEC = 0; |
| 5341 | pub const UNIX = 1; |
| 5342 | pub const LOCAL = UNIX; |
| 5343 | pub const FILE = UNIX; |
| 5344 | pub const INET = 2; |
| 5345 | pub const IMPLINK = 3; |
| 5346 | pub const PUP = 4; |
| 5347 | pub const CHAOS = 5; |
| 5348 | pub const NS = 6; |
| 5349 | pub const NBS = 7; |
| 5350 | pub const ECMA = 8; |
| 5351 | pub const DATAKIT = 9; |
| 5352 | pub const CCITT = 10; |
| 5353 | pub const SNA = 11; |
| 5354 | pub const DECnet = 12; |
| 5355 | pub const DLI = 13; |
| 5356 | pub const LAT = 14; |
| 5357 | pub const HYLINK = 15; |
| 5358 | pub const APPLETALK = 16; |
| 5359 | pub const NIT = 17; |
| 5360 | pub const @"802" = 18; |
| 5361 | pub const OSI = 19; |
| 5362 | pub const X25 = 20; |
| 5363 | pub const OSINET = 21; |
| 5364 | pub const GOSIP = 22; |
| 5365 | pub const IPX = 23; |
| 5366 | pub const ROUTE = 24; |
| 5367 | pub const LINK = 25; |
| 5368 | pub const INET6 = 26; |
| 5369 | pub const KEY = 27; |
| 5370 | pub const NCA = 28; |
| 5371 | pub const POLICY = 29; |
| 5372 | pub const INET_OFFLOAD = 30; |
| 5373 | pub const TRILL = 31; |
| 5374 | pub const PACKET = 32; |
| 5375 | pub const LX_NETLINK = 33; |
| 5376 | pub const MAX = 33; |
| 5377 | }, |
| 5378 | .netbsd => struct { |
| 5379 | pub const UNSPEC = 0; |
| 5380 | pub const LOCAL = 1; |
| 5381 | pub const UNIX = LOCAL; |
| 5382 | pub const INET = 2; |
| 5383 | pub const IMPLINK = 3; |
| 5384 | pub const PUP = 4; |
| 5385 | pub const CHAOS = 5; |
| 5386 | pub const NS = 6; |
| 5387 | pub const ISO = 7; |
| 5388 | pub const OSI = ISO; |
| 5389 | pub const ECMA = 8; |
| 5390 | pub const DATAKIT = 9; |
| 5391 | pub const CCITT = 10; |
| 5392 | pub const SNA = 11; |
| 5393 | pub const DECnet = 12; |
| 5394 | pub const DLI = 13; |
| 5395 | pub const LAT = 14; |
| 5396 | pub const HYLINK = 15; |
| 5397 | pub const APPLETALK = 16; |
| 5398 | pub const OROUTE = 17; |
| 5399 | pub const LINK = 18; |
| 5400 | pub const COIP = 20; |
| 5401 | pub const CNT = 21; |
| 5402 | pub const IPX = 23; |
| 5403 | pub const INET6 = 24; |
| 5404 | pub const ISDN = 26; |
| 5405 | pub const E164 = ISDN; |
| 5406 | pub const NATM = 27; |
| 5407 | pub const ARP = 28; |
| 5408 | pub const BLUETOOTH = 31; |
| 5409 | pub const IEEE80211 = 32; |
| 5410 | pub const MPLS = 33; |
| 5411 | pub const ROUTE = 34; |
| 5412 | pub const CAN = 35; |
| 5413 | pub const ETHER = 36; |
| 5414 | pub const MAX = 37; |
| 5415 | }, |
| 5416 | .dragonfly => struct { |
| 5417 | pub const UNSPEC = 0; |
| 5418 | pub const OSI = ISO; |
| 5419 | pub const UNIX = LOCAL; |
| 5420 | pub const LOCAL = 1; |
| 5421 | pub const INET = 2; |
| 5422 | pub const IMPLINK = 3; |
| 5423 | pub const PUP = 4; |
| 5424 | pub const CHAOS = 5; |
| 5425 | pub const NETBIOS = 6; |
| 5426 | pub const ISO = 7; |
| 5427 | pub const ECMA = 8; |
| 5428 | pub const DATAKIT = 9; |
| 5429 | pub const CCITT = 10; |
| 5430 | pub const SNA = 11; |
| 5431 | pub const DLI = 13; |
| 5432 | pub const LAT = 14; |
| 5433 | pub const HYLINK = 15; |
| 5434 | pub const APPLETALK = 16; |
| 5435 | pub const ROUTE = 17; |
| 5436 | pub const LINK = 18; |
| 5437 | pub const COIP = 20; |
| 5438 | pub const CNT = 21; |
| 5439 | pub const IPX = 23; |
| 5440 | pub const SIP = 24; |
| 5441 | pub const ISDN = 26; |
| 5442 | pub const INET6 = 28; |
| 5443 | pub const NATM = 29; |
| 5444 | pub const ATM = 30; |
| 5445 | pub const NETGRAPH = 32; |
| 5446 | pub const BLUETOOTH = 33; |
| 5447 | pub const MPLS = 34; |
| 5448 | pub const MAX = 36; |
| 5449 | }, |
| 5450 | .haiku => struct { |
| 5451 | pub const UNSPEC = 0; |
| 5452 | pub const INET = 1; |
| 5453 | pub const APPLETALK = 2; |
| 5454 | pub const ROUTE = 3; |
| 5455 | pub const LINK = 4; |
| 5456 | pub const INET6 = 5; |
| 5457 | pub const DLI = 6; |
| 5458 | pub const IPX = 7; |
| 5459 | pub const NOTIFY = 8; |
| 5460 | pub const LOCAL = 9; |
| 5461 | pub const UNIX = LOCAL; |
| 5462 | pub const BLUETOOTH = 10; |
| 5463 | pub const MAX = 11; |
| 5464 | }, |
| 5465 | .openbsd => struct { |
| 5466 | pub const UNSPEC = 0; |
| 5467 | pub const UNIX = 1; |
| 5468 | pub const LOCAL = UNIX; |
| 5469 | pub const INET = 2; |
| 5470 | pub const APPLETALK = 16; |
| 5471 | pub const INET6 = 24; |
| 5472 | pub const KEY = 30; |
| 5473 | pub const ROUTE = 17; |
| 5474 | pub const SNA = 11; |
| 5475 | pub const MPLS = 33; |
| 5476 | pub const BLUETOOTH = 32; |
| 5477 | pub const ISDN = 26; |
| 5478 | pub const MAX = 36; |
| 5479 | }, |
| 5480 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L17-L22 |
| 5481 | .serenity => struct { |
| 5482 | pub const UNSPEC = 0; |
| 5483 | pub const LOCAL = 1; |
| 5484 | pub const UNIX = LOCAL; |
| 5485 | pub const INET = 2; |
| 5486 | pub const INET6 = 3; |
| 5487 | pub const MAX = 4; |
| 5488 | }, |
| 5489 | else => void, |
| 5490 | }; |
| 5491 | pub const PF = if (builtin.abi.isAndroid()) struct { |
| 5492 | pub const UNSPEC = AF.UNSPEC; |
| 5493 | pub const UNIX = AF.UNIX; |
| 5494 | pub const LOCAL = AF.LOCAL; |
| 5495 | pub const INET = AF.INET; |
| 5496 | pub const AX25 = AF.AX25; |
| 5497 | pub const IPX = AF.IPX; |
| 5498 | pub const APPLETALK = AF.APPLETALK; |
| 5499 | pub const NETROM = AF.NETROM; |
| 5500 | pub const BRIDGE = AF.BRIDGE; |
| 5501 | pub const ATMPVC = AF.ATMPVC; |
| 5502 | pub const X25 = AF.X25; |
| 5503 | pub const PF_INET6 = AF.INET6; |
| 5504 | pub const PF_ROSE = AF.ROSE; |
| 5505 | pub const PF_DECnet = AF.DECnet; |
| 5506 | pub const PF_NETBEUI = AF.NETBEUI; |
| 5507 | pub const PF_SECURITY = AF.SECURITY; |
| 5508 | pub const PF_KEY = AF.KEY; |
| 5509 | pub const PF_NETLINK = AF.NETLINK; |
| 5510 | pub const PF_ROUTE = AF.ROUTE; |
| 5511 | pub const PF_PACKET = AF.PACKET; |
| 5512 | pub const PF_ASH = AF.ASH; |
| 5513 | pub const PF_ECONET = AF.ECONET; |
| 5514 | pub const PF_ATMSVC = AF.ATMSVC; |
| 5515 | pub const PF_RDS = AF.RDS; |
| 5516 | pub const PF_SNA = AF.SNA; |
| 5517 | pub const PF_IRDA = AF.IRDA; |
| 5518 | pub const PF_PPPOX = AF.PPPOX; |
| 5519 | pub const PF_WANPIPE = AF.WANPIPE; |
| 5520 | pub const PF_LLC = AF.LLC; |
| 5521 | pub const PF_CAN = AF.CAN; |
| 5522 | pub const PF_TIPC = AF.TIPC; |
| 5523 | pub const PF_BLUETOOTH = AF.BLUETOOTH; |
| 5524 | pub const PF_IUCV = AF.IUCV; |
| 5525 | pub const PF_RXRPC = AF.RXRPC; |
| 5526 | pub const PF_ISDN = AF.ISDN; |
| 5527 | pub const PF_PHONET = AF.PHONET; |
| 5528 | pub const PF_IEEE802154 = AF.IEEE802154; |
| 5529 | pub const PF_CAIF = AF.CAIF; |
| 5530 | pub const PF_ALG = AF.ALG; |
| 5531 | pub const PF_NFC = AF.NFC; |
| 5532 | pub const PF_VSOCK = AF.VSOCK; |
| 5533 | pub const PF_KCM = AF.KCM; |
| 5534 | pub const PF_QIPCRTR = AF.QIPCRTR; |
| 5535 | pub const PF_MAX = AF.MAX; |
| 5536 | } else switch (native_os) { |
| 5537 | .linux, .emscripten => linux.PF, |
| 5538 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 5539 | pub const UNSPEC = AF.UNSPEC; |
| 5540 | pub const LOCAL = AF.LOCAL; |
| 5541 | pub const UNIX = PF.LOCAL; |
| 5542 | pub const INET = AF.INET; |
| 5543 | pub const IMPLINK = AF.IMPLINK; |
| 5544 | pub const PUP = AF.PUP; |
| 5545 | pub const CHAOS = AF.CHAOS; |
| 5546 | pub const NS = AF.NS; |
| 5547 | pub const ISO = AF.ISO; |
| 5548 | pub const OSI = AF.ISO; |
| 5549 | pub const ECMA = AF.ECMA; |
| 5550 | pub const DATAKIT = AF.DATAKIT; |
| 5551 | pub const CCITT = AF.CCITT; |
| 5552 | pub const SNA = AF.SNA; |
| 5553 | pub const DECnet = AF.DECnet; |
| 5554 | pub const DLI = AF.DLI; |
| 5555 | pub const LAT = AF.LAT; |
| 5556 | pub const HYLINK = AF.HYLINK; |
| 5557 | pub const APPLETALK = AF.APPLETALK; |
| 5558 | pub const ROUTE = AF.ROUTE; |
| 5559 | pub const LINK = AF.LINK; |
| 5560 | pub const XTP = AF.XTP; |
| 5561 | pub const COIP = AF.COIP; |
| 5562 | pub const CNT = AF.CNT; |
| 5563 | pub const SIP = AF.SIP; |
| 5564 | pub const IPX = AF.IPX; |
| 5565 | pub const RTIP = AF.RTIP; |
| 5566 | pub const PIP = AF.PIP; |
| 5567 | pub const ISDN = AF.ISDN; |
| 5568 | pub const KEY = AF.KEY; |
| 5569 | pub const INET6 = AF.INET6; |
| 5570 | pub const NATM = AF.NATM; |
| 5571 | pub const SYSTEM = AF.SYSTEM; |
| 5572 | pub const NETBIOS = AF.NETBIOS; |
| 5573 | pub const PPP = AF.PPP; |
| 5574 | pub const MAX = AF.MAX; |
| 5575 | }, |
| 5576 | .freebsd => struct { |
| 5577 | pub const UNSPEC = AF.UNSPEC; |
| 5578 | pub const LOCAL = AF.LOCAL; |
| 5579 | pub const UNIX = PF.LOCAL; |
| 5580 | pub const INET = AF.INET; |
| 5581 | pub const IMPLINK = AF.IMPLINK; |
| 5582 | pub const PUP = AF.PUP; |
| 5583 | pub const CHAOS = AF.CHAOS; |
| 5584 | pub const NETBIOS = AF.NETBIOS; |
| 5585 | pub const ISO = AF.ISO; |
| 5586 | pub const OSI = AF.ISO; |
| 5587 | pub const ECMA = AF.ECMA; |
| 5588 | pub const DATAKIT = AF.DATAKIT; |
| 5589 | pub const CCITT = AF.CCITT; |
| 5590 | pub const DECnet = AF.DECnet; |
| 5591 | pub const DLI = AF.DLI; |
| 5592 | pub const LAT = AF.LAT; |
| 5593 | pub const HYLINK = AF.HYLINK; |
| 5594 | pub const APPLETALK = AF.APPLETALK; |
| 5595 | pub const ROUTE = AF.ROUTE; |
| 5596 | pub const LINK = AF.LINK; |
| 5597 | pub const XTP = AF.pseudo_XTP; |
| 5598 | pub const COIP = AF.COIP; |
| 5599 | pub const CNT = AF.CNT; |
| 5600 | pub const SIP = AF.SIP; |
| 5601 | pub const IPX = AF.IPX; |
| 5602 | pub const RTIP = AF.pseudo_RTIP; |
| 5603 | pub const PIP = AF.pseudo_PIP; |
| 5604 | pub const ISDN = AF.ISDN; |
| 5605 | pub const KEY = AF.pseudo_KEY; |
| 5606 | pub const INET6 = AF.pseudo_INET6; |
| 5607 | pub const NATM = AF.NATM; |
| 5608 | pub const ATM = AF.ATM; |
| 5609 | pub const NETGRAPH = AF.NETGRAPH; |
| 5610 | pub const SLOW = AF.SLOW; |
| 5611 | pub const SCLUSTER = AF.SCLUSTER; |
| 5612 | pub const ARP = AF.ARP; |
| 5613 | pub const BLUETOOTH = AF.BLUETOOTH; |
| 5614 | pub const IEEE80211 = AF.IEEE80211; |
| 5615 | pub const INET_SDP = AF.INET_SDP; |
| 5616 | pub const INET6_SDP = AF.INET6_SDP; |
| 5617 | pub const MAX = AF.MAX; |
| 5618 | }, |
| 5619 | .illumos => struct { |
| 5620 | pub const UNSPEC = AF.UNSPEC; |
| 5621 | pub const UNIX = AF.UNIX; |
| 5622 | pub const LOCAL = UNIX; |
| 5623 | pub const FILE = UNIX; |
| 5624 | pub const INET = AF.INET; |
| 5625 | pub const IMPLINK = AF.IMPLINK; |
| 5626 | pub const PUP = AF.PUP; |
| 5627 | pub const CHAOS = AF.CHAOS; |
| 5628 | pub const NS = AF.NS; |
| 5629 | pub const NBS = AF.NBS; |
| 5630 | pub const ECMA = AF.ECMA; |
| 5631 | pub const DATAKIT = AF.DATAKIT; |
| 5632 | pub const CCITT = AF.CCITT; |
| 5633 | pub const SNA = AF.SNA; |
| 5634 | pub const DECnet = AF.DECnet; |
| 5635 | pub const DLI = AF.DLI; |
| 5636 | pub const LAT = AF.LAT; |
| 5637 | pub const HYLINK = AF.HYLINK; |
| 5638 | pub const APPLETALK = AF.APPLETALK; |
| 5639 | pub const NIT = AF.NIT; |
| 5640 | pub const @"802" = AF.@"802"; |
| 5641 | pub const OSI = AF.OSI; |
| 5642 | pub const X25 = AF.X25; |
| 5643 | pub const OSINET = AF.OSINET; |
| 5644 | pub const GOSIP = AF.GOSIP; |
| 5645 | pub const IPX = AF.IPX; |
| 5646 | pub const ROUTE = AF.ROUTE; |
| 5647 | pub const LINK = AF.LINK; |
| 5648 | pub const INET6 = AF.INET6; |
| 5649 | pub const KEY = AF.KEY; |
| 5650 | pub const NCA = AF.NCA; |
| 5651 | pub const POLICY = AF.POLICY; |
| 5652 | pub const TRILL = AF.TRILL; |
| 5653 | pub const PACKET = AF.PACKET; |
| 5654 | pub const LX_NETLINK = AF.LX_NETLINK; |
| 5655 | pub const MAX = AF.MAX; |
| 5656 | }, |
| 5657 | .netbsd => struct { |
| 5658 | pub const UNSPEC = AF.UNSPEC; |
| 5659 | pub const LOCAL = AF.LOCAL; |
| 5660 | pub const UNIX = PF.LOCAL; |
| 5661 | pub const INET = AF.INET; |
| 5662 | pub const IMPLINK = AF.IMPLINK; |
| 5663 | pub const PUP = AF.PUP; |
| 5664 | pub const CHAOS = AF.CHAOS; |
| 5665 | pub const NS = AF.NS; |
| 5666 | pub const ISO = AF.ISO; |
| 5667 | pub const OSI = AF.ISO; |
| 5668 | pub const ECMA = AF.ECMA; |
| 5669 | pub const DATAKIT = AF.DATAKIT; |
| 5670 | pub const CCITT = AF.CCITT; |
| 5671 | pub const SNA = AF.SNA; |
| 5672 | pub const DECnet = AF.DECnet; |
| 5673 | pub const DLI = AF.DLI; |
| 5674 | pub const LAT = AF.LAT; |
| 5675 | pub const HYLINK = AF.HYLINK; |
| 5676 | pub const APPLETALK = AF.APPLETALK; |
| 5677 | pub const OROUTE = AF.OROUTE; |
| 5678 | pub const LINK = AF.LINK; |
| 5679 | pub const COIP = AF.COIP; |
| 5680 | pub const CNT = AF.CNT; |
| 5681 | pub const INET6 = AF.INET6; |
| 5682 | pub const IPX = AF.IPX; |
| 5683 | pub const ISDN = AF.ISDN; |
| 5684 | pub const E164 = AF.E164; |
| 5685 | pub const NATM = AF.NATM; |
| 5686 | pub const ARP = AF.ARP; |
| 5687 | pub const BLUETOOTH = AF.BLUETOOTH; |
| 5688 | pub const MPLS = AF.MPLS; |
| 5689 | pub const ROUTE = AF.ROUTE; |
| 5690 | pub const CAN = AF.CAN; |
| 5691 | pub const ETHER = AF.ETHER; |
| 5692 | pub const MAX = AF.MAX; |
| 5693 | }, |
| 5694 | .dragonfly => struct { |
| 5695 | pub const INET6 = AF.INET6; |
| 5696 | pub const IMPLINK = AF.IMPLINK; |
| 5697 | pub const ROUTE = AF.ROUTE; |
| 5698 | pub const ISO = AF.ISO; |
| 5699 | pub const PIP = AF.pseudo_PIP; |
| 5700 | pub const CHAOS = AF.CHAOS; |
| 5701 | pub const DATAKIT = AF.DATAKIT; |
| 5702 | pub const INET = AF.INET; |
| 5703 | pub const APPLETALK = AF.APPLETALK; |
| 5704 | pub const SIP = AF.SIP; |
| 5705 | pub const OSI = AF.ISO; |
| 5706 | pub const CNT = AF.CNT; |
| 5707 | pub const LINK = AF.LINK; |
| 5708 | pub const HYLINK = AF.HYLINK; |
| 5709 | pub const MAX = AF.MAX; |
| 5710 | pub const KEY = AF.pseudo_KEY; |
| 5711 | pub const PUP = AF.PUP; |
| 5712 | pub const COIP = AF.COIP; |
| 5713 | pub const SNA = AF.SNA; |
| 5714 | pub const LOCAL = AF.LOCAL; |
| 5715 | pub const NETBIOS = AF.NETBIOS; |
| 5716 | pub const NATM = AF.NATM; |
| 5717 | pub const BLUETOOTH = AF.BLUETOOTH; |
| 5718 | pub const UNSPEC = AF.UNSPEC; |
| 5719 | pub const NETGRAPH = AF.NETGRAPH; |
| 5720 | pub const ECMA = AF.ECMA; |
| 5721 | pub const IPX = AF.IPX; |
| 5722 | pub const DLI = AF.DLI; |
| 5723 | pub const ATM = AF.ATM; |
| 5724 | pub const CCITT = AF.CCITT; |
| 5725 | pub const ISDN = AF.ISDN; |
| 5726 | pub const RTIP = AF.pseudo_RTIP; |
| 5727 | pub const LAT = AF.LAT; |
| 5728 | pub const UNIX = PF.LOCAL; |
| 5729 | pub const XTP = AF.pseudo_XTP; |
| 5730 | pub const DECnet = AF.DECnet; |
| 5731 | }, |
| 5732 | .haiku => struct { |
| 5733 | pub const UNSPEC = AF.UNSPEC; |
| 5734 | pub const INET = AF.INET; |
| 5735 | pub const ROUTE = AF.ROUTE; |
| 5736 | pub const LINK = AF.LINK; |
| 5737 | pub const INET6 = AF.INET6; |
| 5738 | pub const LOCAL = AF.LOCAL; |
| 5739 | pub const UNIX = AF.UNIX; |
| 5740 | pub const BLUETOOTH = AF.BLUETOOTH; |
| 5741 | }, |
| 5742 | .openbsd => struct { |
| 5743 | pub const UNSPEC = AF.UNSPEC; |
| 5744 | pub const LOCAL = AF.LOCAL; |
| 5745 | pub const UNIX = AF.UNIX; |
| 5746 | pub const INET = AF.INET; |
| 5747 | pub const APPLETALK = AF.APPLETALK; |
| 5748 | pub const INET6 = AF.INET6; |
| 5749 | pub const DECnet = AF.DECnet; |
| 5750 | pub const KEY = AF.KEY; |
| 5751 | pub const ROUTE = AF.ROUTE; |
| 5752 | pub const SNA = AF.SNA; |
| 5753 | pub const MPLS = AF.MPLS; |
| 5754 | pub const BLUETOOTH = AF.BLUETOOTH; |
| 5755 | pub const ISDN = AF.ISDN; |
| 5756 | pub const MAX = AF.MAX; |
| 5757 | }, |
| 5758 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L24-L29 |
| 5759 | .serenity => struct { |
| 5760 | pub const LOCAL = AF.LOCAL; |
| 5761 | pub const UNIX = AF.LOCAL; |
| 5762 | pub const INET = AF.INET; |
| 5763 | pub const INET6 = AF.INET6; |
| 5764 | pub const UNSPEC = AF.UNSPEC; |
| 5765 | pub const MAX = AF.MAX; |
| 5766 | }, |
| 5767 | else => void, |
| 5768 | }; |
| 5769 | pub const DT = switch (native_os) { |
| 5770 | .linux => linux.DT, |
| 5771 | // https://github.com/SerenityOS/serenity/blob/1262a7d1424d0d2e89d80644409721cbf056ab17/Kernel/API/POSIX/dirent.h#L16-L35 |
| 5772 | .netbsd, .freebsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => struct { |
| 5773 | pub const UNKNOWN = 0; |
| 5774 | pub const FIFO = 1; |
| 5775 | pub const CHR = 2; |
| 5776 | pub const DIR = 4; |
| 5777 | pub const BLK = 6; |
| 5778 | pub const REG = 8; |
| 5779 | pub const LNK = 10; |
| 5780 | pub const SOCK = 12; |
| 5781 | pub const WHT = 14; |
| 5782 | }, |
| 5783 | .dragonfly => struct { |
| 5784 | pub const UNKNOWN = 0; |
| 5785 | pub const FIFO = 1; |
| 5786 | pub const CHR = 2; |
| 5787 | pub const DIR = 4; |
| 5788 | pub const BLK = 6; |
| 5789 | pub const REG = 8; |
| 5790 | pub const LNK = 10; |
| 5791 | pub const SOCK = 12; |
| 5792 | pub const WHT = 14; |
| 5793 | pub const DBF = 15; |
| 5794 | }, |
| 5795 | else => void, |
| 5796 | }; |
| 5797 | pub const MSG = switch (native_os) { |
| 5798 | .linux => linux.MSG, |
| 5799 | .emscripten => emscripten.MSG, |
| 5800 | .windows => ws2_32.MSG, |
| 5801 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.MSG, |
| 5802 | .haiku => struct { |
| 5803 | pub const OOB = 0x0001; |
| 5804 | pub const PEEK = 0x0002; |
| 5805 | pub const DONTROUTE = 0x0004; |
| 5806 | pub const EOR = 0x0008; |
| 5807 | pub const TRUNC = 0x0010; |
| 5808 | pub const CTRUNC = 0x0020; |
| 5809 | pub const WAITALL = 0x0040; |
| 5810 | pub const DONTWAIT = 0x0080; |
| 5811 | pub const BCAST = 0x0100; |
| 5812 | pub const MCAST = 0x0200; |
| 5813 | pub const EOF = 0x0400; |
| 5814 | pub const NOSIGNAL = 0x0800; |
| 5815 | }, |
| 5816 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L56-L64 |
| 5817 | .serenity => struct { |
| 5818 | pub const TRUNC = 0x1; |
| 5819 | pub const CTRUNC = 0x2; |
| 5820 | pub const PEEK = 0x4; |
| 5821 | pub const OOB = 0x8; |
| 5822 | pub const DONTROUTE = 0x10; |
| 5823 | pub const WAITALL = 0x20; |
| 5824 | pub const DONTWAIT = 0x40; |
| 5825 | pub const NOSIGNAL = 0x80; |
| 5826 | pub const EOR = 0x100; |
| 5827 | }, |
| 5828 | .freebsd => struct { |
| 5829 | pub const OOB = 0x00000001; |
| 5830 | pub const PEEK = 0x00000002; |
| 5831 | pub const DONTROUTE = 0x00000004; |
| 5832 | pub const EOR = 0x00000008; |
| 5833 | pub const TRUNC = 0x00000010; |
| 5834 | pub const CTRUNC = 0x00000020; |
| 5835 | pub const WAITALL = 0x00000040; |
| 5836 | pub const DONTWAIT = 0x00000080; |
| 5837 | pub const EOF = 0x00000100; |
| 5838 | pub const NOTIFICATION = 0x00002000; |
| 5839 | pub const NBIO = 0x00004000; |
| 5840 | pub const COMPAT = 0x00008000; |
| 5841 | pub const SOCALLBCK = 0x00010000; |
| 5842 | pub const NOSIGNAL = 0x00020000; |
| 5843 | pub const CMSG_CLOEXEC = 0x00040000; |
| 5844 | pub const WAITFORONE = 0x00080000; |
| 5845 | pub const MORETOCOME = 0x00100000; |
| 5846 | pub const TLSAPPDATA = 0x00200000; |
| 5847 | }, |
| 5848 | .netbsd => struct { |
| 5849 | pub const OOB = 0x0001; |
| 5850 | pub const PEEK = 0x0002; |
| 5851 | pub const DONTROUTE = 0x0004; |
| 5852 | pub const EOR = 0x0008; |
| 5853 | pub const TRUNC = 0x0010; |
| 5854 | pub const CTRUNC = 0x0020; |
| 5855 | pub const WAITALL = 0x0040; |
| 5856 | pub const DONTWAIT = 0x0080; |
| 5857 | pub const BCAST = 0x0100; |
| 5858 | pub const MCAST = 0x0200; |
| 5859 | pub const NOSIGNAL = 0x0400; |
| 5860 | pub const CMSG_CLOEXEC = 0x0800; |
| 5861 | pub const NBIO = 0x1000; |
| 5862 | pub const WAITFORONE = 0x2000; |
| 5863 | pub const NOTIFICATION = 0x4000; |
| 5864 | }, |
| 5865 | // https://github.com/openbsd/src/blob/42a7be81bef70c04732f45ec573622effe56b563/sys/sys/socket.h#L506 |
| 5866 | .openbsd => struct { |
| 5867 | pub const OOB = 0x1; |
| 5868 | pub const PEEK = 0x2; |
| 5869 | pub const DONTROUTE = 0x4; |
| 5870 | pub const EOR = 0x8; |
| 5871 | pub const TRUNC = 0x10; |
| 5872 | pub const CTRUNC = 0x20; |
| 5873 | pub const WAITALL = 0x40; |
| 5874 | pub const DONTWAIT = 0x80; |
| 5875 | pub const BCAST = 0x100; |
| 5876 | pub const MCAST = 0x200; |
| 5877 | pub const NOSIGNAL = 0x400; |
| 5878 | pub const CMSG_CLOEXEC = 0x800; |
| 5879 | pub const WAITFORONE = 0x1000; |
| 5880 | pub const CMSG_CLOFORK = 0x2000; |
| 5881 | }, |
| 5882 | .dragonfly => struct { |
| 5883 | pub const OOB = 0x0001; |
| 5884 | pub const PEEK = 0x0002; |
| 5885 | pub const DONTROUTE = 0x0004; |
| 5886 | pub const EOR = 0x0008; |
| 5887 | pub const TRUNC = 0x0010; |
| 5888 | pub const CTRUNC = 0x0020; |
| 5889 | pub const WAITALL = 0x0040; |
| 5890 | pub const DONTWAIT = 0x0080; |
| 5891 | pub const NOSIGNAL = 0x0400; |
| 5892 | pub const SYNC = 0x0800; |
| 5893 | pub const CMSG_CLOEXEC = 0x1000; |
| 5894 | pub const CMSG_CLOFORK = 0x2000; |
| 5895 | pub const FBLOCKING = 0x10000; |
| 5896 | pub const FNONBLOCKING = 0x20000; |
| 5897 | }, |
| 5898 | .illumos => struct { |
| 5899 | pub const OOB = 0x0001; |
| 5900 | pub const PEEK = 0x0002; |
| 5901 | pub const DONTROUTE = 0x0004; |
| 5902 | pub const EOR = 0x0008; |
| 5903 | pub const CTRUNC = 0x0010; |
| 5904 | pub const TRUNC = 0x0020; |
| 5905 | pub const WAITALL = 0x0040; |
| 5906 | pub const DONTWAIT = 0x0080; |
| 5907 | pub const NOTIFICATION = 0x0100; |
| 5908 | pub const NOSIGNAL = 0x0200; |
| 5909 | pub const CMSG_CLOEXEC = 0x1000; |
| 5910 | pub const CMSG_CLOFORK = 0x2000; |
| 5911 | }, |
| 5912 | else => void, |
| 5913 | }; |
| 5914 | pub const SOCK = switch (native_os) { |
| 5915 | .linux => linux.SOCK, |
| 5916 | .emscripten => emscripten.SOCK, |
| 5917 | .windows => ws2_32.SOCK, |
| 5918 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 5919 | pub const STREAM = 1; |
| 5920 | pub const DGRAM = 2; |
| 5921 | pub const RAW = 3; |
| 5922 | pub const RDM = 4; |
| 5923 | pub const SEQPACKET = 5; |
| 5924 | pub const MAXADDRLEN = 255; |
| 5925 | |
| 5926 | /// Not actually supported by Darwin, but Zig supplies a shim. |
| 5927 | /// This numerical value is not ABI-stable. It need only not conflict |
| 5928 | /// with any other `SOCK` bits. |
| 5929 | pub const CLOEXEC = 1 << 15; |
| 5930 | /// Not actually supported by Darwin, but Zig supplies a shim. |
| 5931 | /// This numerical value is not ABI-stable. It need only not conflict |
| 5932 | /// with any other `SOCK` bits. |
| 5933 | pub const NONBLOCK = 1 << 16; |
| 5934 | }, |
| 5935 | .freebsd => struct { |
| 5936 | pub const STREAM = 1; |
| 5937 | pub const DGRAM = 2; |
| 5938 | pub const RAW = 3; |
| 5939 | pub const RDM = 4; |
| 5940 | pub const SEQPACKET = 5; |
| 5941 | |
| 5942 | pub const CLOEXEC = 0x10000000; |
| 5943 | pub const NONBLOCK = 0x20000000; |
| 5944 | }, |
| 5945 | .illumos => struct { |
| 5946 | /// Datagram. |
| 5947 | pub const DGRAM = 1; |
| 5948 | /// STREAM. |
| 5949 | pub const STREAM = 2; |
| 5950 | /// Raw-protocol interface. |
| 5951 | pub const RAW = 4; |
| 5952 | /// Reliably-delivered message. |
| 5953 | pub const RDM = 5; |
| 5954 | /// Sequenced packed stream. |
| 5955 | pub const SEQPACKET = 6; |
| 5956 | |
| 5957 | pub const NONBLOCK = 0x100000; |
| 5958 | pub const NDELAY = 0x200000; |
| 5959 | pub const CLOEXEC = 0x080000; |
| 5960 | }, |
| 5961 | .netbsd => struct { |
| 5962 | pub const STREAM = 1; |
| 5963 | pub const DGRAM = 2; |
| 5964 | pub const RAW = 3; |
| 5965 | pub const RDM = 4; |
| 5966 | pub const SEQPACKET = 5; |
| 5967 | pub const CONN_DGRAM = 6; |
| 5968 | pub const DCCP = CONN_DGRAM; |
| 5969 | |
| 5970 | pub const CLOEXEC = 0x10000000; |
| 5971 | pub const NONBLOCK = 0x20000000; |
| 5972 | pub const NOSIGPIPE = 0x40000000; |
| 5973 | pub const FLAGS_MASK = 0xf0000000; |
| 5974 | }, |
| 5975 | .dragonfly => struct { |
| 5976 | pub const STREAM = 1; |
| 5977 | pub const DGRAM = 2; |
| 5978 | pub const RAW = 3; |
| 5979 | pub const RDM = 4; |
| 5980 | pub const SEQPACKET = 5; |
| 5981 | pub const MAXADDRLEN = 255; |
| 5982 | pub const CLOEXEC = 0x10000000; |
| 5983 | pub const NONBLOCK = 0x20000000; |
| 5984 | }, |
| 5985 | .haiku => struct { |
| 5986 | pub const STREAM = 1; |
| 5987 | pub const DGRAM = 2; |
| 5988 | pub const RAW = 3; |
| 5989 | pub const SEQPACKET = 5; |
| 5990 | pub const MISC = 255; |
| 5991 | |
| 5992 | pub const NONBLOCK = 0x40000; |
| 5993 | pub const CLOEXEC = 0x80000; |
| 5994 | }, |
| 5995 | .openbsd => struct { |
| 5996 | pub const STREAM = 1; |
| 5997 | pub const DGRAM = 2; |
| 5998 | pub const RAW = 3; |
| 5999 | pub const RDM = 4; |
| 6000 | pub const SEQPACKET = 5; |
| 6001 | |
| 6002 | pub const CLOEXEC = 0x8000; |
| 6003 | pub const NONBLOCK = 0x4000; |
| 6004 | }, |
| 6005 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L31-L38 |
| 6006 | .serenity => struct { |
| 6007 | pub const STREAM = 1; |
| 6008 | pub const DGRAM = 2; |
| 6009 | pub const RAW = 3; |
| 6010 | pub const RDM = 4; |
| 6011 | pub const SEQPACKET = 5; |
| 6012 | |
| 6013 | pub const NONBLOCK = 0o4000; |
| 6014 | pub const CLOEXEC = 0o2000000; |
| 6015 | }, |
| 6016 | else => void, |
| 6017 | }; |
| 6018 | pub const TCP = switch (native_os) { |
| 6019 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.TCP, |
| 6020 | .linux => linux.TCP, |
| 6021 | .freebsd => freebsd.TCP, |
| 6022 | .netbsd => netbsd.TCP, |
| 6023 | .openbsd => openbsd.TCP, |
| 6024 | .dragonfly => dragonfly.TCP, |
| 6025 | .emscripten => emscripten.TCP, |
| 6026 | .windows => ws2_32.TCP, |
| 6027 | .illumos => illumos.TCP, |
| 6028 | .haiku => haiku.TCP, |
| 6029 | // https://github.com/SerenityOS/serenity/blob/61ac554a3403838f79ca746bd1c65ded6f97d124/Kernel/API/POSIX/netinet/tcp.h#L13-L14 |
| 6030 | .serenity => struct { |
| 6031 | pub const NODELAY = 10; |
| 6032 | pub const MAXSEG = 11; |
| 6033 | }, |
| 6034 | else => void, |
| 6035 | }; |
| 6036 | pub const IPPROTO = switch (native_os) { |
| 6037 | .linux, .emscripten => linux.IPPROTO, |
| 6038 | .windows => ws2_32.IPPROTO, |
| 6039 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6040 | pub const ICMP = 1; |
| 6041 | pub const ICMPV6 = 58; |
| 6042 | pub const TCP = 6; |
| 6043 | pub const UDP = 17; |
| 6044 | pub const IP = 0; |
| 6045 | pub const IPV6 = 41; |
| 6046 | pub const RAW = 255; |
| 6047 | }, |
| 6048 | .freebsd => struct { |
| 6049 | /// dummy for IP |
| 6050 | pub const IP = 0; |
| 6051 | /// control message protocol |
| 6052 | pub const ICMP = 1; |
| 6053 | /// tcp |
| 6054 | pub const TCP = 6; |
| 6055 | /// user datagram protocol |
| 6056 | pub const UDP = 17; |
| 6057 | /// IP6 header |
| 6058 | pub const IPV6 = 41; |
| 6059 | /// raw IP packet |
| 6060 | pub const RAW = 255; |
| 6061 | /// IP6 hop-by-hop options |
| 6062 | pub const HOPOPTS = 0; |
| 6063 | /// group mgmt protocol |
| 6064 | pub const IGMP = 2; |
| 6065 | /// gateway^2 (deprecated) |
| 6066 | pub const GGP = 3; |
| 6067 | /// IPv4 encapsulation |
| 6068 | pub const IPV4 = 4; |
| 6069 | /// for compatibility |
| 6070 | pub const IPIP = IPV4; |
| 6071 | /// Stream protocol II |
| 6072 | pub const ST = 7; |
| 6073 | /// exterior gateway protocol |
| 6074 | pub const EGP = 8; |
| 6075 | /// private interior gateway |
| 6076 | pub const PIGP = 9; |
| 6077 | /// BBN RCC Monitoring |
| 6078 | pub const RCCMON = 10; |
| 6079 | /// network voice protocol |
| 6080 | pub const NVPII = 11; |
| 6081 | /// pup |
| 6082 | pub const PUP = 12; |
| 6083 | /// Argus |
| 6084 | pub const ARGUS = 13; |
| 6085 | /// EMCON |
| 6086 | pub const EMCON = 14; |
| 6087 | /// Cross Net Debugger |
| 6088 | pub const XNET = 15; |
| 6089 | /// Chaos |
| 6090 | pub const CHAOS = 16; |
| 6091 | /// Multiplexing |
| 6092 | pub const MUX = 18; |
| 6093 | /// DCN Measurement Subsystems |
| 6094 | pub const MEAS = 19; |
| 6095 | /// Host Monitoring |
| 6096 | pub const HMP = 20; |
| 6097 | /// Packet Radio Measurement |
| 6098 | pub const PRM = 21; |
| 6099 | /// xns idp |
| 6100 | pub const IDP = 22; |
| 6101 | /// Trunk-1 |
| 6102 | pub const TRUNK1 = 23; |
| 6103 | /// Trunk-2 |
| 6104 | pub const TRUNK2 = 24; |
| 6105 | /// Leaf-1 |
| 6106 | pub const LEAF1 = 25; |
| 6107 | /// Leaf-2 |
| 6108 | pub const LEAF2 = 26; |
| 6109 | /// Reliable Data |
| 6110 | pub const RDP = 27; |
| 6111 | /// Reliable Transaction |
| 6112 | pub const IRTP = 28; |
| 6113 | /// tp-4 w/ class negotiation |
| 6114 | pub const TP = 29; |
| 6115 | /// Bulk Data Transfer |
| 6116 | pub const BLT = 30; |
| 6117 | /// Network Services |
| 6118 | pub const NSP = 31; |
| 6119 | /// Merit Internodal |
| 6120 | pub const INP = 32; |
| 6121 | /// Datagram Congestion Control Protocol |
| 6122 | pub const DCCP = 33; |
| 6123 | /// Third Party Connect |
| 6124 | pub const @"3PC" = 34; |
| 6125 | /// InterDomain Policy Routing |
| 6126 | pub const IDPR = 35; |
| 6127 | /// XTP |
| 6128 | pub const XTP = 36; |
| 6129 | /// Datagram Delivery |
| 6130 | pub const DDP = 37; |
| 6131 | /// Control Message Transport |
| 6132 | pub const CMTP = 38; |
| 6133 | /// TP++ Transport |
| 6134 | pub const TPXX = 39; |
| 6135 | /// IL transport protocol |
| 6136 | pub const IL = 40; |
| 6137 | /// Source Demand Routing |
| 6138 | pub const SDRP = 42; |
| 6139 | /// IP6 routing header |
| 6140 | pub const ROUTING = 43; |
| 6141 | /// IP6 fragmentation header |
| 6142 | pub const FRAGMENT = 44; |
| 6143 | /// InterDomain Routing |
| 6144 | pub const IDRP = 45; |
| 6145 | /// resource reservation |
| 6146 | pub const RSVP = 46; |
| 6147 | /// General Routing Encap. |
| 6148 | pub const GRE = 47; |
| 6149 | /// Mobile Host Routing |
| 6150 | pub const MHRP = 48; |
| 6151 | /// BHA |
| 6152 | pub const BHA = 49; |
| 6153 | /// IP6 Encap Sec. Payload |
| 6154 | pub const ESP = 50; |
| 6155 | /// IP6 Auth Header |
| 6156 | pub const AH = 51; |
| 6157 | /// Integ. Net Layer Security |
| 6158 | pub const INLSP = 52; |
| 6159 | /// IP with encryption |
| 6160 | pub const SWIPE = 53; |
| 6161 | /// Next Hop Resolution |
| 6162 | pub const NHRP = 54; |
| 6163 | /// IP Mobility |
| 6164 | pub const MOBILE = 55; |
| 6165 | /// Transport Layer Security |
| 6166 | pub const TLSP = 56; |
| 6167 | /// SKIP |
| 6168 | pub const SKIP = 57; |
| 6169 | /// ICMP6 |
| 6170 | pub const ICMPV6 = 58; |
| 6171 | /// IP6 no next header |
| 6172 | pub const NONE = 59; |
| 6173 | /// IP6 destination option |
| 6174 | pub const DSTOPTS = 60; |
| 6175 | /// any host internal protocol |
| 6176 | pub const AHIP = 61; |
| 6177 | /// CFTP |
| 6178 | pub const CFTP = 62; |
| 6179 | /// "hello" routing protocol |
| 6180 | pub const HELLO = 63; |
| 6181 | /// SATNET/Backroom EXPAK |
| 6182 | pub const SATEXPAK = 64; |
| 6183 | /// Kryptolan |
| 6184 | pub const KRYPTOLAN = 65; |
| 6185 | /// Remote Virtual Disk |
| 6186 | pub const RVD = 66; |
| 6187 | /// Pluribus Packet Core |
| 6188 | pub const IPPC = 67; |
| 6189 | /// Any distributed FS |
| 6190 | pub const ADFS = 68; |
| 6191 | /// Satnet Monitoring |
| 6192 | pub const SATMON = 69; |
| 6193 | /// VISA Protocol |
| 6194 | pub const VISA = 70; |
| 6195 | /// Packet Core Utility |
| 6196 | pub const IPCV = 71; |
| 6197 | /// Comp. Prot. Net. Executive |
| 6198 | pub const CPNX = 72; |
| 6199 | /// Comp. Prot. HeartBeat |
| 6200 | pub const CPHB = 73; |
| 6201 | /// Wang Span Network |
| 6202 | pub const WSN = 74; |
| 6203 | /// Packet Video Protocol |
| 6204 | pub const PVP = 75; |
| 6205 | /// BackRoom SATNET Monitoring |
| 6206 | pub const BRSATMON = 76; |
| 6207 | /// Sun net disk proto (temp.) |
| 6208 | pub const ND = 77; |
| 6209 | /// WIDEBAND Monitoring |
| 6210 | pub const WBMON = 78; |
| 6211 | /// WIDEBAND EXPAK |
| 6212 | pub const WBEXPAK = 79; |
| 6213 | /// ISO cnlp |
| 6214 | pub const EON = 80; |
| 6215 | /// VMTP |
| 6216 | pub const VMTP = 81; |
| 6217 | /// Secure VMTP |
| 6218 | pub const SVMTP = 82; |
| 6219 | /// Banyon VINES |
| 6220 | pub const VINES = 83; |
| 6221 | /// TTP |
| 6222 | pub const TTP = 84; |
| 6223 | /// NSFNET-IGP |
| 6224 | pub const IGP = 85; |
| 6225 | /// dissimilar gateway prot. |
| 6226 | pub const DGP = 86; |
| 6227 | /// TCF |
| 6228 | pub const TCF = 87; |
| 6229 | /// Cisco/GXS IGRP |
| 6230 | pub const IGRP = 88; |
| 6231 | /// OSPFIGP |
| 6232 | pub const OSPFIGP = 89; |
| 6233 | /// Strite RPC protocol |
| 6234 | pub const SRPC = 90; |
| 6235 | /// Locus Address Resoloution |
| 6236 | pub const LARP = 91; |
| 6237 | /// Multicast Transport |
| 6238 | pub const MTP = 92; |
| 6239 | /// AX.25 Frames |
| 6240 | pub const AX25 = 93; |
| 6241 | /// IP encapsulated in IP |
| 6242 | pub const IPEIP = 94; |
| 6243 | /// Mobile Int.ing control |
| 6244 | pub const MICP = 95; |
| 6245 | /// Semaphore Comm. security |
| 6246 | pub const SCCSP = 96; |
| 6247 | /// Ethernet IP encapsulation |
| 6248 | pub const ETHERIP = 97; |
| 6249 | /// encapsulation header |
| 6250 | pub const ENCAP = 98; |
| 6251 | /// any private encr. scheme |
| 6252 | pub const APES = 99; |
| 6253 | /// GMTP |
| 6254 | pub const GMTP = 100; |
| 6255 | /// payload compression (IPComp) |
| 6256 | pub const IPCOMP = 108; |
| 6257 | /// SCTP |
| 6258 | pub const SCTP = 132; |
| 6259 | /// IPv6 Mobility Header |
| 6260 | pub const MH = 135; |
| 6261 | /// UDP-Lite |
| 6262 | pub const UDPLITE = 136; |
| 6263 | /// IP6 Host Identity Protocol |
| 6264 | pub const HIP = 139; |
| 6265 | /// IP6 Shim6 Protocol |
| 6266 | pub const SHIM6 = 140; |
| 6267 | /// Protocol Independent Mcast |
| 6268 | pub const PIM = 103; |
| 6269 | /// CARP |
| 6270 | pub const CARP = 112; |
| 6271 | /// PGM |
| 6272 | pub const PGM = 113; |
| 6273 | /// MPLS-in-IP |
| 6274 | pub const MPLS = 137; |
| 6275 | /// PFSYNC |
| 6276 | pub const PFSYNC = 240; |
| 6277 | /// Reserved |
| 6278 | pub const RESERVED_253 = 253; |
| 6279 | /// Reserved |
| 6280 | pub const RESERVED_254 = 254; |
| 6281 | }, |
| 6282 | .illumos => struct { |
| 6283 | /// dummy for IP |
| 6284 | pub const IP = 0; |
| 6285 | /// Hop by hop header for IPv6 |
| 6286 | pub const HOPOPTS = 0; |
| 6287 | /// control message protocol |
| 6288 | pub const ICMP = 1; |
| 6289 | /// group control protocol |
| 6290 | pub const IGMP = 2; |
| 6291 | /// gateway^2 (deprecated) |
| 6292 | pub const GGP = 3; |
| 6293 | /// IP in IP encapsulation |
| 6294 | pub const ENCAP = 4; |
| 6295 | /// tcp |
| 6296 | pub const TCP = 6; |
| 6297 | /// exterior gateway protocol |
| 6298 | pub const EGP = 8; |
| 6299 | /// pup |
| 6300 | pub const PUP = 12; |
| 6301 | /// user datagram protocol |
| 6302 | pub const UDP = 17; |
| 6303 | /// xns idp |
| 6304 | pub const IDP = 22; |
| 6305 | /// IPv6 encapsulated in IP |
| 6306 | pub const IPV6 = 41; |
| 6307 | /// Routing header for IPv6 |
| 6308 | pub const ROUTING = 43; |
| 6309 | /// Fragment header for IPv6 |
| 6310 | pub const FRAGMENT = 44; |
| 6311 | /// rsvp |
| 6312 | pub const RSVP = 46; |
| 6313 | /// IPsec Encap. Sec. Payload |
| 6314 | pub const ESP = 50; |
| 6315 | /// IPsec Authentication Hdr. |
| 6316 | pub const AH = 51; |
| 6317 | /// ICMP for IPv6 |
| 6318 | pub const ICMPV6 = 58; |
| 6319 | /// No next header for IPv6 |
| 6320 | pub const NONE = 59; |
| 6321 | /// Destination options |
| 6322 | pub const DSTOPTS = 60; |
| 6323 | /// "hello" routing protocol |
| 6324 | pub const HELLO = 63; |
| 6325 | /// UNOFFICIAL net disk proto |
| 6326 | pub const ND = 77; |
| 6327 | /// ISO clnp |
| 6328 | pub const EON = 80; |
| 6329 | /// OSPF |
| 6330 | pub const OSPF = 89; |
| 6331 | /// PIM routing protocol |
| 6332 | pub const PIM = 103; |
| 6333 | /// Stream Control |
| 6334 | pub const SCTP = 132; |
| 6335 | /// raw IP packet |
| 6336 | pub const RAW = 255; |
| 6337 | /// Sockets Direct Protocol |
| 6338 | pub const PROTO_SDP = 257; |
| 6339 | }, |
| 6340 | .netbsd => struct { |
| 6341 | /// dummy for IP |
| 6342 | pub const IP = 0; |
| 6343 | /// IP6 hop-by-hop options |
| 6344 | pub const HOPOPTS = 0; |
| 6345 | /// control message protocol |
| 6346 | pub const ICMP = 1; |
| 6347 | /// group mgmt protocol |
| 6348 | pub const IGMP = 2; |
| 6349 | /// gateway^2 (deprecated) |
| 6350 | pub const GGP = 3; |
| 6351 | /// IP header |
| 6352 | pub const IPV4 = 4; |
| 6353 | /// IP inside IP |
| 6354 | pub const IPIP = 4; |
| 6355 | /// tcp |
| 6356 | pub const TCP = 6; |
| 6357 | /// exterior gateway protocol |
| 6358 | pub const EGP = 8; |
| 6359 | /// pup |
| 6360 | pub const PUP = 12; |
| 6361 | /// user datagram protocol |
| 6362 | pub const UDP = 17; |
| 6363 | /// xns idp |
| 6364 | pub const IDP = 22; |
| 6365 | /// tp-4 w/ class negotiation |
| 6366 | pub const TP = 29; |
| 6367 | /// DCCP |
| 6368 | pub const DCCP = 33; |
| 6369 | /// IP6 header |
| 6370 | pub const IPV6 = 41; |
| 6371 | /// IP6 routing header |
| 6372 | pub const ROUTING = 43; |
| 6373 | /// IP6 fragmentation header |
| 6374 | pub const FRAGMENT = 44; |
| 6375 | /// resource reservation |
| 6376 | pub const RSVP = 46; |
| 6377 | /// GRE encaps RFC 1701 |
| 6378 | pub const GRE = 47; |
| 6379 | /// encap. security payload |
| 6380 | pub const ESP = 50; |
| 6381 | /// authentication header |
| 6382 | pub const AH = 51; |
| 6383 | /// IP Mobility RFC 2004 |
| 6384 | pub const MOBILE = 55; |
| 6385 | /// IPv6 ICMP |
| 6386 | pub const IPV6_ICMP = 58; |
| 6387 | /// ICMP6 |
| 6388 | pub const ICMPV6 = 58; |
| 6389 | /// IP6 no next header |
| 6390 | pub const NONE = 59; |
| 6391 | /// IP6 destination option |
| 6392 | pub const DSTOPTS = 60; |
| 6393 | /// ISO cnlp |
| 6394 | pub const EON = 80; |
| 6395 | /// Ethernet-in-IP |
| 6396 | pub const ETHERIP = 97; |
| 6397 | /// encapsulation header |
| 6398 | pub const ENCAP = 98; |
| 6399 | /// Protocol indep. multicast |
| 6400 | pub const PIM = 103; |
| 6401 | /// IP Payload Comp. Protocol |
| 6402 | pub const IPCOMP = 108; |
| 6403 | /// VRRP RFC 2338 |
| 6404 | pub const VRRP = 112; |
| 6405 | /// Common Address Resolution Protocol |
| 6406 | pub const CARP = 112; |
| 6407 | /// L2TPv3 |
| 6408 | pub const L2TP = 115; |
| 6409 | /// SCTP |
| 6410 | pub const SCTP = 132; |
| 6411 | /// PFSYNC |
| 6412 | pub const PFSYNC = 240; |
| 6413 | /// raw IP packet |
| 6414 | pub const RAW = 255; |
| 6415 | }, |
| 6416 | .dragonfly => struct { |
| 6417 | pub const IP = 0; |
| 6418 | pub const ICMP = 1; |
| 6419 | pub const TCP = 6; |
| 6420 | pub const UDP = 17; |
| 6421 | pub const IPV6 = 41; |
| 6422 | pub const RAW = 255; |
| 6423 | pub const HOPOPTS = 0; |
| 6424 | pub const IGMP = 2; |
| 6425 | pub const GGP = 3; |
| 6426 | pub const IPV4 = 4; |
| 6427 | pub const IPIP = IPV4; |
| 6428 | pub const ST = 7; |
| 6429 | pub const EGP = 8; |
| 6430 | pub const PIGP = 9; |
| 6431 | pub const RCCMON = 10; |
| 6432 | pub const NVPII = 11; |
| 6433 | pub const PUP = 12; |
| 6434 | pub const ARGUS = 13; |
| 6435 | pub const EMCON = 14; |
| 6436 | pub const XNET = 15; |
| 6437 | pub const CHAOS = 16; |
| 6438 | pub const MUX = 18; |
| 6439 | pub const MEAS = 19; |
| 6440 | pub const HMP = 20; |
| 6441 | pub const PRM = 21; |
| 6442 | pub const IDP = 22; |
| 6443 | pub const TRUNK1 = 23; |
| 6444 | pub const TRUNK2 = 24; |
| 6445 | pub const LEAF1 = 25; |
| 6446 | pub const LEAF2 = 26; |
| 6447 | pub const RDP = 27; |
| 6448 | pub const IRTP = 28; |
| 6449 | pub const TP = 29; |
| 6450 | pub const BLT = 30; |
| 6451 | pub const NSP = 31; |
| 6452 | pub const INP = 32; |
| 6453 | pub const SEP = 33; |
| 6454 | pub const @"3PC" = 34; |
| 6455 | pub const IDPR = 35; |
| 6456 | pub const XTP = 36; |
| 6457 | pub const DDP = 37; |
| 6458 | pub const CMTP = 38; |
| 6459 | pub const TPXX = 39; |
| 6460 | pub const IL = 40; |
| 6461 | pub const SDRP = 42; |
| 6462 | pub const ROUTING = 43; |
| 6463 | pub const FRAGMENT = 44; |
| 6464 | pub const IDRP = 45; |
| 6465 | pub const RSVP = 46; |
| 6466 | pub const GRE = 47; |
| 6467 | pub const MHRP = 48; |
| 6468 | pub const BHA = 49; |
| 6469 | pub const ESP = 50; |
| 6470 | pub const AH = 51; |
| 6471 | pub const INLSP = 52; |
| 6472 | pub const SWIPE = 53; |
| 6473 | pub const NHRP = 54; |
| 6474 | pub const MOBILE = 55; |
| 6475 | pub const TLSP = 56; |
| 6476 | pub const SKIP = 57; |
| 6477 | pub const ICMPV6 = 58; |
| 6478 | pub const NONE = 59; |
| 6479 | pub const DSTOPTS = 60; |
| 6480 | pub const AHIP = 61; |
| 6481 | pub const CFTP = 62; |
| 6482 | pub const HELLO = 63; |
| 6483 | pub const SATEXPAK = 64; |
| 6484 | pub const KRYPTOLAN = 65; |
| 6485 | pub const RVD = 66; |
| 6486 | pub const IPPC = 67; |
| 6487 | pub const ADFS = 68; |
| 6488 | pub const SATMON = 69; |
| 6489 | pub const VISA = 70; |
| 6490 | pub const IPCV = 71; |
| 6491 | pub const CPNX = 72; |
| 6492 | pub const CPHB = 73; |
| 6493 | pub const WSN = 74; |
| 6494 | pub const PVP = 75; |
| 6495 | pub const BRSATMON = 76; |
| 6496 | pub const ND = 77; |
| 6497 | pub const WBMON = 78; |
| 6498 | pub const WBEXPAK = 79; |
| 6499 | pub const EON = 80; |
| 6500 | pub const VMTP = 81; |
| 6501 | pub const SVMTP = 82; |
| 6502 | pub const VINES = 83; |
| 6503 | pub const TTP = 84; |
| 6504 | pub const IGP = 85; |
| 6505 | pub const DGP = 86; |
| 6506 | pub const TCF = 87; |
| 6507 | pub const IGRP = 88; |
| 6508 | pub const OSPFIGP = 89; |
| 6509 | pub const SRPC = 90; |
| 6510 | pub const LARP = 91; |
| 6511 | pub const MTP = 92; |
| 6512 | pub const AX25 = 93; |
| 6513 | pub const IPEIP = 94; |
| 6514 | pub const MICP = 95; |
| 6515 | pub const SCCSP = 96; |
| 6516 | pub const ETHERIP = 97; |
| 6517 | pub const ENCAP = 98; |
| 6518 | pub const APES = 99; |
| 6519 | pub const GMTP = 100; |
| 6520 | pub const IPCOMP = 108; |
| 6521 | pub const PIM = 103; |
| 6522 | pub const CARP = 112; |
| 6523 | pub const PGM = 113; |
| 6524 | pub const PFSYNC = 240; |
| 6525 | pub const DIVERT = 254; |
| 6526 | pub const MAX = 256; |
| 6527 | pub const DONE = 257; |
| 6528 | pub const UNKNOWN = 258; |
| 6529 | }, |
| 6530 | .haiku => struct { |
| 6531 | pub const IP = 0; |
| 6532 | pub const HOPOPTS = 0; |
| 6533 | pub const ICMP = 1; |
| 6534 | pub const IGMP = 2; |
| 6535 | pub const TCP = 6; |
| 6536 | pub const UDP = 17; |
| 6537 | pub const IPV6 = 41; |
| 6538 | pub const ROUTING = 43; |
| 6539 | pub const FRAGMENT = 44; |
| 6540 | pub const ESP = 50; |
| 6541 | pub const AH = 51; |
| 6542 | pub const ICMPV6 = 58; |
| 6543 | pub const NONE = 59; |
| 6544 | pub const DSTOPTS = 60; |
| 6545 | pub const ETHERIP = 97; |
| 6546 | pub const RAW = 255; |
| 6547 | pub const MAX = 256; |
| 6548 | }, |
| 6549 | .openbsd => struct { |
| 6550 | /// dummy for IP |
| 6551 | pub const IP = 0; |
| 6552 | /// IP6 hop-by-hop options |
| 6553 | pub const HOPOPTS = IPPROTO.IP; |
| 6554 | /// control message protocol |
| 6555 | pub const ICMP = 1; |
| 6556 | /// group mgmt protocol |
| 6557 | pub const IGMP = 2; |
| 6558 | /// gateway^2 (deprecated) |
| 6559 | pub const GGP = 3; |
| 6560 | /// IP header |
| 6561 | pub const IPV4 = IPIP; |
| 6562 | /// IP inside IP |
| 6563 | pub const IPIP = 4; |
| 6564 | /// tcp |
| 6565 | pub const TCP = 6; |
| 6566 | /// exterior gateway protocol |
| 6567 | pub const EGP = 8; |
| 6568 | /// pup |
| 6569 | pub const PUP = 12; |
| 6570 | /// user datagram protocol |
| 6571 | pub const UDP = 17; |
| 6572 | /// xns idp |
| 6573 | pub const IDP = 22; |
| 6574 | /// tp-4 w/ class negotiation |
| 6575 | pub const TP = 29; |
| 6576 | /// IP6 header |
| 6577 | pub const IPV6 = 41; |
| 6578 | /// IP6 routing header |
| 6579 | pub const ROUTING = 43; |
| 6580 | /// IP6 fragmentation header |
| 6581 | pub const FRAGMENT = 44; |
| 6582 | /// resource reservation |
| 6583 | pub const RSVP = 46; |
| 6584 | /// GRE encaps RFC 1701 |
| 6585 | pub const GRE = 47; |
| 6586 | /// encap. security payload |
| 6587 | pub const ESP = 50; |
| 6588 | /// authentication header |
| 6589 | pub const AH = 51; |
| 6590 | /// IP Mobility RFC 2004 |
| 6591 | pub const MOBILE = 55; |
| 6592 | /// IPv6 ICMP |
| 6593 | pub const IPV6_ICMP = 58; |
| 6594 | /// ICMP6 |
| 6595 | pub const ICMPV6 = 58; |
| 6596 | /// IP6 no next header |
| 6597 | pub const NONE = 59; |
| 6598 | /// IP6 destination option |
| 6599 | pub const DSTOPTS = 60; |
| 6600 | /// ISO cnlp |
| 6601 | pub const EON = 80; |
| 6602 | /// Ethernet-in-IP |
| 6603 | pub const ETHERIP = 97; |
| 6604 | /// encapsulation header |
| 6605 | pub const ENCAP = 98; |
| 6606 | /// Protocol indep. multicast |
| 6607 | pub const PIM = 103; |
| 6608 | /// IP Payload Comp. Protocol |
| 6609 | pub const IPCOMP = 108; |
| 6610 | /// VRRP RFC 2338 |
| 6611 | pub const VRRP = 112; |
| 6612 | /// Common Address Resolution Protocol |
| 6613 | pub const CARP = 112; |
| 6614 | /// PFSYNC |
| 6615 | pub const PFSYNC = 240; |
| 6616 | /// raw IP packet |
| 6617 | pub const RAW = 255; |
| 6618 | }, |
| 6619 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L44-L54 |
| 6620 | .serenity => struct { |
| 6621 | pub const IP = 0; |
| 6622 | pub const ICMP = 1; |
| 6623 | pub const IGMP = 2; |
| 6624 | pub const IPIP = 4; |
| 6625 | pub const TCP = 6; |
| 6626 | pub const UDP = 17; |
| 6627 | pub const IPV6 = 41; |
| 6628 | pub const ESP = 50; |
| 6629 | pub const AH = 51; |
| 6630 | pub const ICMPV6 = 58; |
| 6631 | pub const RAW = 255; |
| 6632 | }, |
| 6633 | else => void, |
| 6634 | }; |
| 6635 | pub const IP = switch (native_os) { |
| 6636 | .linux => linux.IP, |
| 6637 | .freebsd => freebsd.IP, |
| 6638 | .dragonfly => dragonfly.IP, |
| 6639 | .netbsd => netbsd.IP, |
| 6640 | .openbsd => openbsd.IP, |
| 6641 | .illumos => illumos.IP, |
| 6642 | .haiku => haiku.IP, |
| 6643 | .serenity => serenity.IP, |
| 6644 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.IP, |
| 6645 | else => void, |
| 6646 | }; |
| 6647 | pub const IPV6 = switch (native_os) { |
| 6648 | .linux => linux.IPV6, |
| 6649 | .freebsd => freebsd.IPV6, |
| 6650 | .dragonfly => dragonfly.IPV6, |
| 6651 | .netbsd => netbsd.IPV6, |
| 6652 | .openbsd => openbsd.IPV6, |
| 6653 | .illumos => illumos.IPV6, |
| 6654 | .haiku => haiku.IPV6, |
| 6655 | .serenity => serenity.IPV6, |
| 6656 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.IPV6, |
| 6657 | else => void, |
| 6658 | }; |
| 6659 | pub const IPTOS = switch (native_os) { |
| 6660 | .linux => linux.IPTOS, |
| 6661 | .freebsd => freebsd.IPTOS, |
| 6662 | .dragonfly => dragonfly.IPTOS, |
| 6663 | .netbsd => netbsd.IPTOS, |
| 6664 | .openbsd => openbsd.IPTOS, |
| 6665 | .illumos => illumos.IPTOS, |
| 6666 | .haiku => haiku.IPTOS, |
| 6667 | .serenity => serenity.IPTOS, |
| 6668 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.IPTOS, |
| 6669 | else => void, |
| 6670 | }; |
| 6671 | pub const SOL = switch (native_os) { |
| 6672 | .linux => linux.SOL, |
| 6673 | .emscripten => emscripten.SOL, |
| 6674 | .windows => ws2_32.SOL, |
| 6675 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6676 | pub const SOCKET = 0xffff; |
| 6677 | }, |
| 6678 | .illumos => struct { |
| 6679 | pub const SOCKET = 0xffff; |
| 6680 | pub const ROUTE = 0xfffe; |
| 6681 | pub const PACKET = 0xfffd; |
| 6682 | pub const FILTER = 0xfffc; |
| 6683 | }, |
| 6684 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L127 |
| 6685 | .serenity => struct { |
| 6686 | pub const SOCKET = 1; |
| 6687 | }, |
| 6688 | else => void, |
| 6689 | }; |
| 6690 | pub const SO = switch (native_os) { |
| 6691 | .linux => linux.SO, |
| 6692 | .emscripten => emscripten.SO, |
| 6693 | .windows => ws2_32.SO, |
| 6694 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6695 | pub const DEBUG = 0x0001; |
| 6696 | pub const ACCEPTCONN = 0x0002; |
| 6697 | pub const REUSEADDR = 0x0004; |
| 6698 | pub const KEEPALIVE = 0x0008; |
| 6699 | pub const DONTROUTE = 0x0010; |
| 6700 | pub const BROADCAST = 0x0020; |
| 6701 | pub const USELOOPBACK = 0x0040; |
| 6702 | pub const LINGER = 0x0080; |
| 6703 | pub const OOBINLINE = 0x0100; |
| 6704 | pub const REUSEPORT = 0x0200; |
| 6705 | pub const ACCEPTFILTER = 0x1000; |
| 6706 | pub const SNDBUF = 0x1001; |
| 6707 | pub const RCVBUF = 0x1002; |
| 6708 | pub const SNDLOWAT = 0x1003; |
| 6709 | pub const RCVLOWAT = 0x1004; |
| 6710 | pub const SNDTIMEO = 0x1005; |
| 6711 | pub const RCVTIMEO = 0x1006; |
| 6712 | pub const ERROR = 0x1007; |
| 6713 | pub const TYPE = 0x1008; |
| 6714 | |
| 6715 | pub const NREAD = 0x1020; |
| 6716 | pub const NKE = 0x1021; |
| 6717 | pub const NOSIGPIPE = 0x1022; |
| 6718 | pub const NOADDRERR = 0x1023; |
| 6719 | pub const NWRITE = 0x1024; |
| 6720 | pub const REUSESHAREUID = 0x1025; |
| 6721 | pub const LINGER_SEC = 0x1080; |
| 6722 | }, |
| 6723 | .freebsd => struct { |
| 6724 | pub const DEBUG = 0x00000001; |
| 6725 | pub const ACCEPTCONN = 0x00000002; |
| 6726 | pub const REUSEADDR = 0x00000004; |
| 6727 | pub const KEEPALIVE = 0x00000008; |
| 6728 | pub const DONTROUTE = 0x00000010; |
| 6729 | pub const BROADCAST = 0x00000020; |
| 6730 | pub const USELOOPBACK = 0x00000040; |
| 6731 | pub const LINGER = 0x00000080; |
| 6732 | pub const OOBINLINE = 0x00000100; |
| 6733 | pub const REUSEPORT = 0x00000200; |
| 6734 | pub const TIMESTAMP = 0x00000400; |
| 6735 | pub const NOSIGPIPE = 0x00000800; |
| 6736 | pub const ACCEPTFILTER = 0x00001000; |
| 6737 | pub const BINTIME = 0x00002000; |
| 6738 | pub const NO_OFFLOAD = 0x00004000; |
| 6739 | pub const NO_DDP = 0x00008000; |
| 6740 | pub const REUSEPORT_LB = 0x00010000; |
| 6741 | |
| 6742 | pub const SNDBUF = 0x1001; |
| 6743 | pub const RCVBUF = 0x1002; |
| 6744 | pub const SNDLOWAT = 0x1003; |
| 6745 | pub const RCVLOWAT = 0x1004; |
| 6746 | pub const SNDTIMEO = 0x1005; |
| 6747 | pub const RCVTIMEO = 0x1006; |
| 6748 | pub const ERROR = 0x1007; |
| 6749 | pub const TYPE = 0x1008; |
| 6750 | pub const LABEL = 0x1009; |
| 6751 | pub const PEERLABEL = 0x1010; |
| 6752 | pub const LISTENQLIMIT = 0x1011; |
| 6753 | pub const LISTENQLEN = 0x1012; |
| 6754 | pub const LISTENINCQLEN = 0x1013; |
| 6755 | pub const SETFIB = 0x1014; |
| 6756 | pub const USER_COOKIE = 0x1015; |
| 6757 | pub const PROTOCOL = 0x1016; |
| 6758 | pub const PROTOTYPE = PROTOCOL; |
| 6759 | pub const TS_CLOCK = 0x1017; |
| 6760 | pub const MAX_PACING_RATE = 0x1018; |
| 6761 | pub const DOMAIN = 0x1019; |
| 6762 | }, |
| 6763 | .illumos => struct { |
| 6764 | pub const DEBUG = 0x0001; |
| 6765 | pub const ACCEPTCONN = 0x0002; |
| 6766 | pub const REUSEADDR = 0x0004; |
| 6767 | pub const KEEPALIVE = 0x0008; |
| 6768 | pub const DONTROUTE = 0x0010; |
| 6769 | pub const BROADCAST = 0x0020; |
| 6770 | pub const USELOOPBACK = 0x0040; |
| 6771 | pub const LINGER = 0x0080; |
| 6772 | pub const OOBINLINE = 0x0100; |
| 6773 | pub const DGRAM_ERRIND = 0x0200; |
| 6774 | pub const RECVUCRED = 0x0400; |
| 6775 | |
| 6776 | pub const SNDBUF = 0x1001; |
| 6777 | pub const RCVBUF = 0x1002; |
| 6778 | pub const SNDLOWAT = 0x1003; |
| 6779 | pub const RCVLOWAT = 0x1004; |
| 6780 | pub const SNDTIMEO = 0x1005; |
| 6781 | pub const RCVTIMEO = 0x1006; |
| 6782 | pub const ERROR = 0x1007; |
| 6783 | pub const TYPE = 0x1008; |
| 6784 | pub const PROTOTYPE = 0x1009; |
| 6785 | pub const ANON_MLP = 0x100a; |
| 6786 | pub const MAC_EXEMPT = 0x100b; |
| 6787 | pub const DOMAIN = 0x100c; |
| 6788 | pub const RCVPSH = 0x100d; |
| 6789 | |
| 6790 | pub const SECATTR = 0x1011; |
| 6791 | pub const TIMESTAMP = 0x1013; |
| 6792 | pub const ALLZONES = 0x1014; |
| 6793 | pub const EXCLBIND = 0x1015; |
| 6794 | pub const MAC_IMPLICIT = 0x1016; |
| 6795 | pub const VRRP = 0x1017; |
| 6796 | }, |
| 6797 | .netbsd => struct { |
| 6798 | pub const DEBUG = 0x0001; |
| 6799 | pub const ACCEPTCONN = 0x0002; |
| 6800 | pub const REUSEADDR = 0x0004; |
| 6801 | pub const KEEPALIVE = 0x0008; |
| 6802 | pub const DONTROUTE = 0x0010; |
| 6803 | pub const BROADCAST = 0x0020; |
| 6804 | pub const USELOOPBACK = 0x0040; |
| 6805 | pub const LINGER = 0x0080; |
| 6806 | pub const OOBINLINE = 0x0100; |
| 6807 | pub const REUSEPORT = 0x0200; |
| 6808 | pub const NOSIGPIPE = 0x0800; |
| 6809 | pub const ACCEPTFILTER = 0x1000; |
| 6810 | pub const TIMESTAMP = 0x2000; |
| 6811 | pub const RERROR = 0x4000; |
| 6812 | |
| 6813 | pub const SNDBUF = 0x1001; |
| 6814 | pub const RCVBUF = 0x1002; |
| 6815 | pub const SNDLOWAT = 0x1003; |
| 6816 | pub const RCVLOWAT = 0x1004; |
| 6817 | pub const ERROR = 0x1007; |
| 6818 | pub const TYPE = 0x1008; |
| 6819 | pub const OVERFLOWED = 0x1009; |
| 6820 | |
| 6821 | pub const NOHEADER = 0x100a; |
| 6822 | pub const SNDTIMEO = 0x100b; |
| 6823 | pub const RCVTIMEO = 0x100c; |
| 6824 | }, |
| 6825 | .dragonfly => struct { |
| 6826 | pub const DEBUG = 0x0001; |
| 6827 | pub const ACCEPTCONN = 0x0002; |
| 6828 | pub const REUSEADDR = 0x0004; |
| 6829 | pub const KEEPALIVE = 0x0008; |
| 6830 | pub const DONTROUTE = 0x0010; |
| 6831 | pub const BROADCAST = 0x0020; |
| 6832 | pub const USELOOPBACK = 0x0040; |
| 6833 | pub const LINGER = 0x0080; |
| 6834 | pub const OOBINLINE = 0x0100; |
| 6835 | pub const REUSEPORT = 0x0200; |
| 6836 | pub const TIMESTAMP = 0x0400; |
| 6837 | pub const NOSIGPIPE = 0x0800; |
| 6838 | pub const ACCEPTFILTER = 0x1000; |
| 6839 | pub const RERROR = 0x2000; |
| 6840 | pub const PASSCRED = 0x4000; |
| 6841 | |
| 6842 | pub const SNDBUF = 0x1001; |
| 6843 | pub const RCVBUF = 0x1002; |
| 6844 | pub const SNDLOWAT = 0x1003; |
| 6845 | pub const RCVLOWAT = 0x1004; |
| 6846 | pub const SNDTIMEO = 0x1005; |
| 6847 | pub const RCVTIMEO = 0x1006; |
| 6848 | pub const ERROR = 0x1007; |
| 6849 | pub const TYPE = 0x1008; |
| 6850 | pub const SNDSPACE = 0x100a; |
| 6851 | pub const CPUHINT = 0x1030; |
| 6852 | }, |
| 6853 | .haiku => struct { |
| 6854 | pub const ACCEPTCONN = 0x00000001; |
| 6855 | pub const BROADCAST = 0x00000002; |
| 6856 | pub const DEBUG = 0x00000004; |
| 6857 | pub const DONTROUTE = 0x00000008; |
| 6858 | pub const KEEPALIVE = 0x00000010; |
| 6859 | pub const OOBINLINE = 0x00000020; |
| 6860 | pub const REUSEADDR = 0x00000040; |
| 6861 | pub const REUSEPORT = 0x00000080; |
| 6862 | pub const USELOOPBACK = 0x00000100; |
| 6863 | pub const LINGER = 0x00000200; |
| 6864 | |
| 6865 | pub const SNDBUF = 0x40000001; |
| 6866 | pub const SNDLOWAT = 0x40000002; |
| 6867 | pub const SNDTIMEO = 0x40000003; |
| 6868 | pub const RCVBUF = 0x40000004; |
| 6869 | pub const RCVLOWAT = 0x40000005; |
| 6870 | pub const RCVTIMEO = 0x40000006; |
| 6871 | pub const ERROR = 0x40000007; |
| 6872 | pub const TYPE = 0x40000008; |
| 6873 | pub const NONBLOCK = 0x40000009; |
| 6874 | pub const BINDTODEVICE = 0x4000000a; |
| 6875 | pub const PEERCRED = 0x4000000b; |
| 6876 | }, |
| 6877 | .openbsd => struct { |
| 6878 | pub const DEBUG = 0x0001; |
| 6879 | pub const ACCEPTCONN = 0x0002; |
| 6880 | pub const REUSEADDR = 0x0004; |
| 6881 | pub const KEEPALIVE = 0x0008; |
| 6882 | pub const DONTROUTE = 0x0010; |
| 6883 | pub const BROADCAST = 0x0020; |
| 6884 | pub const USELOOPBACK = 0x0040; |
| 6885 | pub const LINGER = 0x0080; |
| 6886 | pub const OOBINLINE = 0x0100; |
| 6887 | pub const REUSEPORT = 0x0200; |
| 6888 | pub const TIMESTAMP = 0x0800; |
| 6889 | pub const BINDANY = 0x1000; |
| 6890 | pub const ZEROIZE = 0x2000; |
| 6891 | pub const SNDBUF = 0x1001; |
| 6892 | pub const RCVBUF = 0x1002; |
| 6893 | pub const SNDLOWAT = 0x1003; |
| 6894 | pub const RCVLOWAT = 0x1004; |
| 6895 | pub const SNDTIMEO = 0x1005; |
| 6896 | pub const RCVTIMEO = 0x1006; |
| 6897 | pub const ERROR = 0x1007; |
| 6898 | pub const TYPE = 0x1008; |
| 6899 | pub const NETPROC = 0x1020; |
| 6900 | pub const RTABLE = 0x1021; |
| 6901 | pub const PEERCRED = 0x1022; |
| 6902 | pub const SPLICE = 0x1023; |
| 6903 | pub const DOMAIN = 0x1024; |
| 6904 | pub const PROTOCOL = 0x1025; |
| 6905 | }, |
| 6906 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L130-L150 |
| 6907 | .serenity => struct { |
| 6908 | pub const RCVTIMEO = 0; |
| 6909 | pub const SNDTIMEO = 1; |
| 6910 | pub const TYPE = 2; |
| 6911 | pub const ERROR = 3; |
| 6912 | pub const PEERCRED = 4; |
| 6913 | pub const RCVBUF = 5; |
| 6914 | pub const SNDBUF = 6; |
| 6915 | pub const DEBUG = 7; |
| 6916 | pub const REUSEADDR = 8; |
| 6917 | pub const BINDTODEVICE = 9; |
| 6918 | pub const KEEPALIVE = 10; |
| 6919 | pub const TIMESTAMP = 11; |
| 6920 | pub const BROADCAST = 12; |
| 6921 | pub const LINGER = 13; |
| 6922 | pub const ACCEPTCONN = 14; |
| 6923 | pub const DONTROUTE = 15; |
| 6924 | pub const OOBINLINE = 16; |
| 6925 | pub const SNDLOWAT = 17; |
| 6926 | pub const RCVLOWAT = 18; |
| 6927 | }, |
| 6928 | else => void, |
| 6929 | }; |
| 6930 | pub const SOMAXCONN = switch (native_os) { |
| 6931 | .linux => linux.SOMAXCONN, |
| 6932 | .windows => ws2_32.SOMAXCONN, |
| 6933 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L128 |
| 6934 | .illumos, .serenity => 128, |
| 6935 | // https://github.com/freebsd/freebsd-src/blob/9ab31f821ad1c6bad474510447387c50bef2c24c/sys/sys/socket.h#L434 |
| 6936 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/fd3d1949d526ffa646e57037770acd6f2f3bb617/sys/sys/socket.h#L393 |
| 6937 | // https://github.com/NetBSD/src/blob/a673fb3f8487e974c669216064f7588207229fea/sys/sys/socket.h#L472 |
| 6938 | // https://github.com/openbsd/src/blob/8ba9cd88f10123fef7af805b8e5ccc2463ad8fa4/sys/sys/socket.h#L483 |
| 6939 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L815 |
| 6940 | .freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 128, |
| 6941 | else => void, |
| 6942 | }; |
| 6943 | pub const SCM = switch (native_os) { |
| 6944 | .linux, .emscripten => linux.SCM, |
| 6945 | // https://github.com/illumos/illumos-gate/blob/489f6310fe8952e87fc1dce8af87990fcfd90f18/usr/src/uts/common/sys/socket.h#L196 |
| 6946 | .illumos => struct { |
| 6947 | pub const RIGHTS = 0x1010; |
| 6948 | pub const UCRED = 0x1012; |
| 6949 | pub const TIMESTAMP = SO.TIMESTAMP; |
| 6950 | }, |
| 6951 | // https://github.com/haiku/haiku/blob/e3d01e53a25446d5ba4999d0ff6dff29a2418657/headers/posix/sys/socket.h#L156 |
| 6952 | .haiku => struct { |
| 6953 | pub const RIGHTS = 1; |
| 6954 | }, |
| 6955 | // https://github.com/SerenityOS/serenity/blob/c6618f36bf0949bd76177f202659b1f3079e0792/Kernel/API/POSIX/sys/socket.h#L171 |
| 6956 | .serenity => struct { |
| 6957 | pub const TIMESTAMP = 0; |
| 6958 | pub const RIGHTS = 1; |
| 6959 | }, |
| 6960 | // https://github.com/freebsd/freebsd-src/blob/614e9b33bf5594d9d09b5d296afa4f3aa6971823/sys/sys/socket.h#L593 |
| 6961 | .freebsd => struct { |
| 6962 | pub const RIGHTS = 1; |
| 6963 | pub const TIMESTAMP = 2; |
| 6964 | pub const CREDS = 3; |
| 6965 | pub const BINTIME = 4; |
| 6966 | pub const REALTIME = 5; |
| 6967 | pub const MONOTONIC = 6; |
| 6968 | pub const TIME_INFO = 7; |
| 6969 | pub const CREDS2 = 8; |
| 6970 | }, |
| 6971 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L520 |
| 6972 | .dragonfly => struct { |
| 6973 | pub const RIGHTS = 1; |
| 6974 | pub const TIMESTAMP = 2; |
| 6975 | pub const CREDS = 3; |
| 6976 | }, |
| 6977 | // https://github.com/NetBSD/src/blob/3311177ea898ab8322292ba0e48faa9b2e834cb6/sys/sys/socket.h#L578 |
| 6978 | .netbsd => struct { |
| 6979 | pub const RIGHTS = 0x01; |
| 6980 | pub const TIMESTAMP = 0x08; |
| 6981 | pub const CREDS = 0x10; |
| 6982 | }, |
| 6983 | // https://github.com/openbsd/src/blob/1b1dd04c9634112eb763374379af99a68ace4328/sys/sys/socket.h#L566 |
| 6984 | .openbsd => struct { |
| 6985 | pub const RIGHTS = 0x01; |
| 6986 | pub const TIMESTAMP = 0x04; |
| 6987 | }, |
| 6988 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1114 |
| 6989 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6990 | pub const RIGHTS = 1; |
| 6991 | pub const TIMESTAMP = 2; |
| 6992 | pub const CREDS = 3; |
| 6993 | pub const TIMESTAMP_MONOTONIC = 4; |
| 6994 | }, |
| 6995 | else => void, |
| 6996 | }; |
| 6997 | |
| 6998 | pub const IFNAMESIZE = switch (native_os) { |
| 6999 | .linux => linux.IFNAMESIZE, |
| 7000 | .emscripten => emscripten.IFNAMESIZE, |
| 7001 | .windows => 30, |
| 7002 | // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L50 |
| 7003 | .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 16, |
| 7004 | .illumos => 32, |
| 7005 | else => {}, |
| 7006 | }; |
| 7007 | |
| 7008 | pub const stack_t = switch (native_os) { |
| 7009 | .linux => linux.stack_t, |
| 7010 | .emscripten => emscripten.stack_t, |
| 7011 | .freebsd, .openbsd => extern struct { |
| 7012 | /// Signal stack base. |
| 7013 | sp: *anyopaque, |
| 7014 | /// Signal stack length. |
| 7015 | size: usize, |
| 7016 | /// SS_DISABLE and/or SS_ONSTACK. |
| 7017 | flags: i32, |
| 7018 | }, |
| 7019 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L48-L52 |
| 7020 | .serenity => extern struct { |
| 7021 | sp: *anyopaque, |
| 7022 | flags: c_int, |
| 7023 | size: usize, |
| 7024 | }, |
| 7025 | else => extern struct { |
| 7026 | sp: [*]u8, |
| 7027 | size: isize, |
| 7028 | flags: i32, |
| 7029 | }, |
| 7030 | }; |
| 7031 | pub const time_t = switch (native_os) { |
| 7032 | .linux => linux.time_t, |
| 7033 | .dragonfly, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_long, |
| 7034 | .emscripten => emscripten.time_t, |
| 7035 | .freebsd, .haiku => if (native_arch == .x86) c_int else c_longlong, |
| 7036 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47 |
| 7037 | // lib/libc/include/wasm-wasi-musl/__typedef_time_t.h |
| 7038 | .netbsd, .openbsd, .serenity, .wasi => c_longlong, |
| 7039 | else => void, |
| 7040 | }; |
| 7041 | pub const suseconds_t = switch (native_os) { |
| 7042 | .dragonfly, .freebsd, .openbsd, .illumos => c_long, |
| 7043 | .netbsd, .haiku, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_int, |
| 7044 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L49 |
| 7045 | .serenity, .wasi => c_longlong, |
| 7046 | else => void, |
| 7047 | }; |
| 7048 | |
| 7049 | pub const timeval = switch (native_os) { |
| 7050 | .linux => linux.timeval, |
| 7051 | .emscripten => emscripten.timeval, |
| 7052 | .windows => extern struct { |
| 7053 | sec: c_long, |
| 7054 | usec: c_long, |
| 7055 | }, |
| 7056 | // https://github.com/SerenityOS/serenity/blob/6b6eca0631c893c5f8cfb8274cdfe18e2d0637c0/Kernel/API/POSIX/sys/time.h#L15-L18 |
| 7057 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .wasi => extern struct { |
| 7058 | /// seconds |
| 7059 | sec: time_t, |
| 7060 | /// microseconds |
| 7061 | usec: suseconds_t, |
| 7062 | }, |
| 7063 | else => void, |
| 7064 | }; |
| 7065 | pub const timezone = switch (native_os) { |
| 7066 | .linux => linux.timezone, |
| 7067 | .emscripten => emscripten.timezone, |
| 7068 | // https://github.com/SerenityOS/serenity/blob/ba776390b5878ec0be1a9e595a3471a6cfe0a0cf/Userland/Libraries/LibC/sys/time.h#L19-L22 |
| 7069 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows, .wasi => extern struct { |
| 7070 | minuteswest: c_int, |
| 7071 | dsttime: c_int, |
| 7072 | }, |
| 7073 | else => void, |
| 7074 | }; |
| 7075 | |
| 7076 | pub const user_desc = switch (native_os) { |
| 7077 | .linux => linux.user_desc, |
| 7078 | else => void, |
| 7079 | }; |
| 7080 | pub const utsname = switch (native_os) { |
| 7081 | .linux => linux.utsname, |
| 7082 | .emscripten => emscripten.utsname, |
| 7083 | .wasi => extern struct { |
| 7084 | sysname: [64:0]u8, |
| 7085 | nodename: [64:0]u8, |
| 7086 | release: [64:0]u8, |
| 7087 | version: [64:0]u8, |
| 7088 | machine: [64:0]u8, |
| 7089 | domainname: [64:0]u8, |
| 7090 | }, |
| 7091 | .illumos => extern struct { |
| 7092 | sysname: [256:0]u8, |
| 7093 | nodename: [256:0]u8, |
| 7094 | release: [256:0]u8, |
| 7095 | version: [256:0]u8, |
| 7096 | machine: [256:0]u8, |
| 7097 | domainname: [256:0]u8, |
| 7098 | }, |
| 7099 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 7100 | sysname: [255:0]u8, |
| 7101 | nodename: [255:0]u8, |
| 7102 | release: [255:0]u8, |
| 7103 | version: [255:0]u8, |
| 7104 | machine: [255:0]u8, |
| 7105 | }, |
| 7106 | // https://github.com/SerenityOS/serenity/blob/d794ed1de7a46482272683f8dc4c858806390f29/Kernel/API/POSIX/sys/utsname.h#L17-L23 |
| 7107 | .serenity => extern struct { |
| 7108 | sysname: [UTSNAME_ENTRY_LEN:0]u8, |
| 7109 | nodename: [UTSNAME_ENTRY_LEN:0]u8, |
| 7110 | release: [UTSNAME_ENTRY_LEN:0]u8, |
| 7111 | version: [UTSNAME_ENTRY_LEN:0]u8, |
| 7112 | machine: [UTSNAME_ENTRY_LEN:0]u8, |
| 7113 | |
| 7114 | const UTSNAME_ENTRY_LEN = 64; |
| 7115 | }, |
| 7116 | else => void, |
| 7117 | }; |
| 7118 | pub const PR = switch (native_os) { |
| 7119 | .linux => linux.PR, |
| 7120 | else => void, |
| 7121 | }; |
| 7122 | pub const _errno = switch (native_os) { |
| 7123 | .linux => switch (native_abi) { |
| 7124 | .android, .androideabi => private.__errno, |
| 7125 | else => private.__errno_location, |
| 7126 | }, |
| 7127 | .emscripten => private.__errno_location, |
| 7128 | .wasi, .dragonfly => private.errnoFromThreadLocal, |
| 7129 | .windows => private._errno, |
| 7130 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .freebsd => private.__error, |
| 7131 | .illumos => private.___errno, |
| 7132 | .openbsd, .netbsd => private.__errno, |
| 7133 | .haiku => haiku._errnop, |
| 7134 | // https://github.com/SerenityOS/serenity/blob/a353ceecf13b6f156a078e32f1ddf1d21366934c/Userland/Libraries/LibC/errno.h#L33 |
| 7135 | .serenity => private.__errno_location, |
| 7136 | else => {}, |
| 7137 | }; |
| 7138 | |
| 7139 | pub const RTLD = switch (native_os) { |
| 7140 | .linux, .emscripten => packed struct(u32) { |
| 7141 | LAZY: bool = false, |
| 7142 | NOW: bool = false, |
| 7143 | NOLOAD: bool = false, |
| 7144 | DEEPBIND: bool = false, |
| 7145 | _4: u4 = 0, |
| 7146 | GLOBAL: bool = false, |
| 7147 | _9: u3 = 0, |
| 7148 | NODELETE: bool = false, |
| 7149 | _: u19 = 0, |
| 7150 | }, |
| 7151 | .dragonfly, .freebsd => packed struct(u32) { |
| 7152 | LAZY: bool = false, |
| 7153 | NOW: bool = false, |
| 7154 | _2: u6 = 0, |
| 7155 | GLOBAL: bool = false, |
| 7156 | TRACE: bool = false, |
| 7157 | _10: u2 = 0, |
| 7158 | NODELETE: bool = false, |
| 7159 | NOLOAD: bool = false, |
| 7160 | _: u18 = 0, |
| 7161 | }, |
| 7162 | .haiku => packed struct(u32) { |
| 7163 | NOW: bool = false, |
| 7164 | GLOBAL: bool = false, |
| 7165 | _: u30 = 0, |
| 7166 | }, |
| 7167 | .netbsd => packed struct(u32) { |
| 7168 | LAZY: bool = false, |
| 7169 | NOW: bool = false, |
| 7170 | _2: u6 = 0, |
| 7171 | GLOBAL: bool = false, |
| 7172 | LOCAL: bool = false, |
| 7173 | _10: u2 = 0, |
| 7174 | NODELETE: bool = false, |
| 7175 | NOLOAD: bool = false, |
| 7176 | _: u18 = 0, |
| 7177 | }, |
| 7178 | .illumos => packed struct(u32) { |
| 7179 | LAZY: bool = false, |
| 7180 | NOW: bool = false, |
| 7181 | NOLOAD: bool = false, |
| 7182 | _3: u5 = 0, |
| 7183 | GLOBAL: bool = false, |
| 7184 | PARENT: bool = false, |
| 7185 | GROUP: bool = false, |
| 7186 | WORLD: bool = false, |
| 7187 | NODELETE: bool = false, |
| 7188 | FIRST: bool = false, |
| 7189 | _14: u2 = 0, |
| 7190 | CONFGEN: bool = false, |
| 7191 | _: u15 = 0, |
| 7192 | }, |
| 7193 | .openbsd => packed struct(u32) { |
| 7194 | LAZY: bool = false, |
| 7195 | NOW: bool = false, |
| 7196 | _2: u6 = 0, |
| 7197 | GLOBAL: bool = false, |
| 7198 | TRACE: bool = false, |
| 7199 | _: u22 = 0, |
| 7200 | }, |
| 7201 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) { |
| 7202 | LAZY: bool = false, |
| 7203 | NOW: bool = false, |
| 7204 | LOCAL: bool = false, |
| 7205 | GLOBAL: bool = false, |
| 7206 | NOLOAD: bool = false, |
| 7207 | _5: u2 = 0, |
| 7208 | NODELETE: bool = false, |
| 7209 | FIRST: bool = false, |
| 7210 | _: u23 = 0, |
| 7211 | }, |
| 7212 | // https://github.com/SerenityOS/serenity/blob/36a26d7fa80bc9c72b19442912d8967f448368ff/Userland/Libraries/LibC/dlfcn.h#L13-L17 |
| 7213 | .serenity => packed struct(c_int) { |
| 7214 | DEFAULT: bool = false, |
| 7215 | _1: u1, |
| 7216 | LAZY: bool = false, |
| 7217 | NOW: bool = false, |
| 7218 | GLOBAL: bool = false, |
| 7219 | LOCAL: bool = false, |
| 7220 | _: @Int(.unsigned, @bitSizeOf(c_int) - 6) = 0, |
| 7221 | }, |
| 7222 | else => void, |
| 7223 | }; |
| 7224 | |
| 7225 | pub const dirent = switch (native_os) { |
| 7226 | .linux, .emscripten => extern struct { |
| 7227 | ino: ino_t, |
| 7228 | off: off_t, |
| 7229 | reclen: c_ushort, |
| 7230 | type: u8, |
| 7231 | name: [256]u8, |
| 7232 | }, |
| 7233 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 7234 | ino: u64, |
| 7235 | seekoff: u64, |
| 7236 | reclen: u16, |
| 7237 | namlen: u16, |
| 7238 | type: u8, |
| 7239 | name: [1024]u8, |
| 7240 | }, |
| 7241 | .freebsd => extern struct { |
| 7242 | /// File number of entry. |
| 7243 | fileno: ino_t, |
| 7244 | /// Directory offset of entry. |
| 7245 | off: off_t, |
| 7246 | /// Length of this record. |
| 7247 | reclen: u16, |
| 7248 | /// File type, one of DT_. |
| 7249 | type: u8, |
| 7250 | pad0: u8 = 0, |
| 7251 | /// Length of the name member. |
| 7252 | namlen: u16, |
| 7253 | pad1: u16 = 0, |
| 7254 | /// Name of entry. |
| 7255 | name: [255:0]u8, |
| 7256 | }, |
| 7257 | .illumos => extern struct { |
| 7258 | /// Inode number of entry. |
| 7259 | ino: ino_t, |
| 7260 | /// Offset of this entry on disk. |
| 7261 | off: off_t, |
| 7262 | /// Length of this record. |
| 7263 | reclen: u16, |
| 7264 | /// File name. |
| 7265 | name: [MAXNAMLEN:0]u8, |
| 7266 | }, |
| 7267 | .netbsd => extern struct { |
| 7268 | fileno: ino_t, |
| 7269 | reclen: u16, |
| 7270 | namlen: u16, |
| 7271 | type: u8, |
| 7272 | name: [MAXNAMLEN:0]u8, |
| 7273 | }, |
| 7274 | .dragonfly => extern struct { |
| 7275 | fileno: c_ulong, |
| 7276 | namlen: u16, |
| 7277 | type: u8, |
| 7278 | unused1: u8, |
| 7279 | unused2: u32, |
| 7280 | name: [256]u8, |
| 7281 | |
| 7282 | pub fn reclen(self: dirent) u16 { |
| 7283 | return (@offsetOf(dirent, "name") + self.namlen + 1 + 7) & ~@as(u16, 7); |
| 7284 | } |
| 7285 | }, |
| 7286 | .openbsd => extern struct { |
| 7287 | fileno: ino_t, |
| 7288 | off: off_t, |
| 7289 | reclen: u16, |
| 7290 | type: u8, |
| 7291 | namlen: u8, |
| 7292 | _: u32 align(1) = 0, |
| 7293 | name: [MAXNAMLEN:0]u8, |
| 7294 | }, |
| 7295 | // https://github.com/SerenityOS/serenity/blob/abc150085f532f123b598949218893cb272ccc4c/Userland/Libraries/LibC/dirent.h#L14-L20 |
| 7296 | .serenity => extern struct { |
| 7297 | ino: ino_t, |
| 7298 | off: off_t, |
| 7299 | reclen: c_ushort, |
| 7300 | type: u8, |
| 7301 | name: [255:0]u8, |
| 7302 | }, |
| 7303 | else => void, |
| 7304 | }; |
| 7305 | pub const MAXNAMLEN = switch (native_os) { |
| 7306 | .netbsd, .illumos => 511, |
| 7307 | // https://github.com/SerenityOS/serenity/blob/1262a7d1424d0d2e89d80644409721cbf056ab17/Kernel/API/POSIX/dirent.h#L37 |
| 7308 | .haiku, .serenity => NAME_MAX, |
| 7309 | .openbsd => 255, |
| 7310 | else => {}, |
| 7311 | }; |
| 7312 | pub const dirent64 = switch (native_os) { |
| 7313 | .linux => extern struct { |
| 7314 | ino: c_ulong, |
| 7315 | off: c_ulong, |
| 7316 | reclen: c_ushort, |
| 7317 | type: u8, |
| 7318 | name: [256]u8, |
| 7319 | }, |
| 7320 | else => void, |
| 7321 | }; |
| 7322 | |
| 7323 | pub const AI = if (builtin.abi.isAndroid()) packed struct(u32) { |
| 7324 | PASSIVE: bool = false, |
| 7325 | CANONNAME: bool = false, |
| 7326 | NUMERICHOST: bool = false, |
| 7327 | NUMERICSERV: bool = false, |
| 7328 | _4: u4 = 0, |
| 7329 | ALL: bool = false, |
| 7330 | V4MAPPED_CFG: bool = false, |
| 7331 | ADDRCONFIG: bool = false, |
| 7332 | V4MAPPED: bool = false, |
| 7333 | _: u20 = 0, |
| 7334 | } else switch (native_os) { |
| 7335 | .linux, .emscripten => linux.AI, |
| 7336 | .dragonfly, .haiku, .freebsd => packed struct(u32) { |
| 7337 | PASSIVE: bool = false, |
| 7338 | CANONNAME: bool = false, |
| 7339 | NUMERICHOST: bool = false, |
| 7340 | NUMERICSERV: bool = false, |
| 7341 | _4: u4 = 0, |
| 7342 | ALL: bool = false, |
| 7343 | V4MAPPED_CFG: bool = false, |
| 7344 | ADDRCONFIG: bool = false, |
| 7345 | V4MAPPED: bool = false, |
| 7346 | _: u20 = 0, |
| 7347 | }, |
| 7348 | .netbsd => packed struct(u32) { |
| 7349 | PASSIVE: bool = false, |
| 7350 | CANONNAME: bool = false, |
| 7351 | NUMERICHOST: bool = false, |
| 7352 | NUMERICSERV: bool = false, |
| 7353 | _4: u6 = 0, |
| 7354 | ADDRCONFIG: bool = false, |
| 7355 | SRV: bool = false, |
| 7356 | _: u20 = 0, |
| 7357 | }, |
| 7358 | .illumos => packed struct(u32) { |
| 7359 | V4MAPPED: bool = false, |
| 7360 | ALL: bool = false, |
| 7361 | ADDRCONFIG: bool = false, |
| 7362 | PASSIVE: bool = false, |
| 7363 | CANONNAME: bool = false, |
| 7364 | NUMERICHOST: bool = false, |
| 7365 | NUMERICSERV: bool = false, |
| 7366 | _: u25 = 0, |
| 7367 | }, |
| 7368 | .openbsd => packed struct(u32) { |
| 7369 | PASSIVE: bool = false, |
| 7370 | CANONNAME: bool = false, |
| 7371 | NUMERICHOST: bool = false, |
| 7372 | EXT: bool = false, |
| 7373 | NUMERICSERV: bool = false, |
| 7374 | FQDN: bool = false, |
| 7375 | ADDRCONFIG: bool = false, |
| 7376 | _: u25 = 0, |
| 7377 | }, |
| 7378 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) { |
| 7379 | PASSIVE: bool = false, |
| 7380 | CANONNAME: bool = false, |
| 7381 | NUMERICHOST: bool = false, |
| 7382 | _3: u5 = 0, |
| 7383 | ALL: bool = false, |
| 7384 | V4MAPPED_CFG: bool = false, |
| 7385 | ADDRCONFIG: bool = false, |
| 7386 | V4MAPPED: bool = false, |
| 7387 | NUMERICSERV: bool = false, |
| 7388 | _: u19 = 0, |
| 7389 | }, |
| 7390 | .windows => ws2_32.AI, |
| 7391 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L90-L96 |
| 7392 | .serenity => packed struct(c_int) { |
| 7393 | PASSIVE: bool = false, |
| 7394 | CANONNAME: bool = false, |
| 7395 | NUMERICHOST: bool = false, |
| 7396 | NUMERICSERV: bool = false, |
| 7397 | V4MAPPED: bool = false, |
| 7398 | ALL: bool = false, |
| 7399 | ADDRCONFIG: bool = false, |
| 7400 | _: @Int(.unsigned, @bitSizeOf(c_int) - 7) = 0, |
| 7401 | }, |
| 7402 | else => void, |
| 7403 | }; |
| 7404 | |
| 7405 | pub const NI = switch (native_os) { |
| 7406 | .linux, .emscripten => packed struct(u32) { |
| 7407 | NUMERICHOST: bool = false, |
| 7408 | NUMERICSERV: bool = false, |
| 7409 | NOFQDN: bool = false, |
| 7410 | NAMEREQD: bool = false, |
| 7411 | DGRAM: bool = false, |
| 7412 | _5: u3 = 0, |
| 7413 | NUMERICSCOPE: bool = false, |
| 7414 | _: u23 = 0, |
| 7415 | }, |
| 7416 | .illumos => packed struct(u32) { |
| 7417 | NOFQDN: bool = false, |
| 7418 | NUMERICHOST: bool = false, |
| 7419 | NAMEREQD: bool = false, |
| 7420 | NUMERICSERV: bool = false, |
| 7421 | DGRAM: bool = false, |
| 7422 | WITHSCOPEID: bool = false, |
| 7423 | NUMERICSCOPE: bool = false, |
| 7424 | _: u25 = 0, |
| 7425 | }, |
| 7426 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L101-L105 |
| 7427 | .serenity => packed struct(c_int) { |
| 7428 | NUMERICHOST: bool = false, |
| 7429 | NUMERICSERV: bool = false, |
| 7430 | NAMEREQD: bool = false, |
| 7431 | NOFQDN: bool = false, |
| 7432 | DGRAM: bool = false, |
| 7433 | _: @Int(.unsigned, @bitSizeOf(c_int) - 5) = 0, |
| 7434 | }, |
| 7435 | .freebsd, .haiku => packed struct(u32) { |
| 7436 | NOFQDN: bool = false, |
| 7437 | NUMERICHOST: bool = false, |
| 7438 | NAMEREQD: bool = false, |
| 7439 | NUMERICSERV: bool = false, |
| 7440 | DGRAM: bool = false, |
| 7441 | NUMERICSCOPE: bool = false, |
| 7442 | _: u26 = 0, |
| 7443 | }, |
| 7444 | .dragonfly, .netbsd => packed struct(u32) { |
| 7445 | NOFQDN: bool = false, |
| 7446 | NUMERICHOST: bool = false, |
| 7447 | NAMEREQD: bool = false, |
| 7448 | NUMERICSERV: bool = false, |
| 7449 | DGRAM: bool = false, |
| 7450 | _5: u1 = 0, |
| 7451 | NUMERICSCOPE: bool = false, |
| 7452 | _: u25 = 0, |
| 7453 | }, |
| 7454 | .openbsd => packed struct(u32) { |
| 7455 | NUMERICHOST: bool = false, |
| 7456 | NUMERICSERV: bool = false, |
| 7457 | NOFQDN: bool = false, |
| 7458 | NAMEREQD: bool = false, |
| 7459 | DGRAM: bool = false, |
| 7460 | _: u27 = 0, |
| 7461 | }, |
| 7462 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) { |
| 7463 | NOFQDN: bool = false, |
| 7464 | NUMERICHOST: bool = false, |
| 7465 | NAMEREQD: bool = false, |
| 7466 | NUMERICSERV: bool = false, |
| 7467 | DGRAM: bool = false, |
| 7468 | _5: u3 = 0, |
| 7469 | NUMERICSCOPE: bool = false, |
| 7470 | _: u23 = 0, |
| 7471 | }, |
| 7472 | else => void, |
| 7473 | }; |
| 7474 | |
| 7475 | pub const EAI = if (builtin.abi.isAndroid()) enum(c_int) { |
| 7476 | /// address family for hostname not supported |
| 7477 | ADDRFAMILY = 1, |
| 7478 | /// temporary failure in name resolution |
| 7479 | AGAIN = 2, |
| 7480 | /// invalid value for ai_flags |
| 7481 | BADFLAGS = 3, |
| 7482 | /// non-recoverable failure in name resolution |
| 7483 | FAIL = 4, |
| 7484 | /// ai_family not supported |
| 7485 | FAMILY = 5, |
| 7486 | /// memory allocation failure |
| 7487 | MEMORY = 6, |
| 7488 | /// no address associated with hostname |
| 7489 | NODATA = 7, |
| 7490 | /// hostname nor servname provided, or not known |
| 7491 | NONAME = 8, |
| 7492 | /// servname not supported for ai_socktype |
| 7493 | SERVICE = 9, |
| 7494 | /// ai_socktype not supported |
| 7495 | SOCKTYPE = 10, |
| 7496 | /// system error returned in errno |
| 7497 | SYSTEM = 11, |
| 7498 | /// invalid value for hints |
| 7499 | BADHINTS = 12, |
| 7500 | /// resolved protocol is unknown |
| 7501 | PROTOCOL = 13, |
| 7502 | /// argument buffer overflow |
| 7503 | OVERFLOW = 14, |
| 7504 | |
| 7505 | MAX = 15, |
| 7506 | |
| 7507 | _, |
| 7508 | } else switch (native_os) { |
| 7509 | .linux, .emscripten => enum(c_int) { |
| 7510 | BADFLAGS = -1, |
| 7511 | NONAME = -2, |
| 7512 | AGAIN = -3, |
| 7513 | FAIL = -4, |
| 7514 | FAMILY = -6, |
| 7515 | SOCKTYPE = -7, |
| 7516 | SERVICE = -8, |
| 7517 | MEMORY = -10, |
| 7518 | SYSTEM = -11, |
| 7519 | OVERFLOW = -12, |
| 7520 | |
| 7521 | NODATA = -5, |
| 7522 | ADDRFAMILY = -9, |
| 7523 | INPROGRESS = -100, |
| 7524 | CANCELED = -101, |
| 7525 | NOTCANCELED = -102, |
| 7526 | ALLDONE = -103, |
| 7527 | INTR = -104, |
| 7528 | IDN_ENCODE = -105, |
| 7529 | |
| 7530 | _, |
| 7531 | }, |
| 7532 | .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) { |
| 7533 | /// address family for hostname not supported |
| 7534 | ADDRFAMILY = 1, |
| 7535 | /// temporary failure in name resolution |
| 7536 | AGAIN = 2, |
| 7537 | /// invalid value for ai_flags |
| 7538 | BADFLAGS = 3, |
| 7539 | /// non-recoverable failure in name resolution |
| 7540 | FAIL = 4, |
| 7541 | /// ai_family not supported |
| 7542 | FAMILY = 5, |
| 7543 | /// memory allocation failure |
| 7544 | MEMORY = 6, |
| 7545 | /// no address associated with hostname |
| 7546 | NODATA = 7, |
| 7547 | /// hostname nor servname provided, or not known |
| 7548 | NONAME = 8, |
| 7549 | /// servname not supported for ai_socktype |
| 7550 | SERVICE = 9, |
| 7551 | /// ai_socktype not supported |
| 7552 | SOCKTYPE = 10, |
| 7553 | /// system error returned in errno |
| 7554 | SYSTEM = 11, |
| 7555 | /// invalid value for hints |
| 7556 | BADHINTS = 12, |
| 7557 | /// resolved protocol is unknown |
| 7558 | PROTOCOL = 13, |
| 7559 | /// argument buffer overflow |
| 7560 | OVERFLOW = 14, |
| 7561 | _, |
| 7562 | }, |
| 7563 | .illumos => enum(c_int) { |
| 7564 | /// address family for hostname not supported |
| 7565 | ADDRFAMILY = 1, |
| 7566 | /// name could not be resolved at this time |
| 7567 | AGAIN = 2, |
| 7568 | /// flags parameter had an invalid value |
| 7569 | BADFLAGS = 3, |
| 7570 | /// non-recoverable failure in name resolution |
| 7571 | FAIL = 4, |
| 7572 | /// address family not recognized |
| 7573 | FAMILY = 5, |
| 7574 | /// memory allocation failure |
| 7575 | MEMORY = 6, |
| 7576 | /// no address associated with hostname |
| 7577 | NODATA = 7, |
| 7578 | /// name does not resolve |
| 7579 | NONAME = 8, |
| 7580 | /// service not recognized for socket type |
| 7581 | SERVICE = 9, |
| 7582 | /// intended socket type was not recognized |
| 7583 | SOCKTYPE = 10, |
| 7584 | /// system error returned in errno |
| 7585 | SYSTEM = 11, |
| 7586 | /// argument buffer overflow |
| 7587 | OVERFLOW = 12, |
| 7588 | /// resolved protocol is unknown |
| 7589 | PROTOCOL = 13, |
| 7590 | |
| 7591 | _, |
| 7592 | }, |
| 7593 | .openbsd => enum(c_int) { |
| 7594 | /// address family for hostname not supported |
| 7595 | ADDRFAMILY = -9, |
| 7596 | /// name could not be resolved at this time |
| 7597 | AGAIN = -3, |
| 7598 | /// flags parameter had an invalid value |
| 7599 | BADFLAGS = -1, |
| 7600 | /// non-recoverable failure in name resolution |
| 7601 | FAIL = -4, |
| 7602 | /// address family not recognized |
| 7603 | FAMILY = -6, |
| 7604 | /// memory allocation failure |
| 7605 | MEMORY = -10, |
| 7606 | /// no address associated with hostname |
| 7607 | NODATA = -5, |
| 7608 | /// name does not resolve |
| 7609 | NONAME = -2, |
| 7610 | /// service not recognized for socket type |
| 7611 | SERVICE = -8, |
| 7612 | /// intended socket type was not recognized |
| 7613 | SOCKTYPE = -7, |
| 7614 | /// system error returned in errno |
| 7615 | SYSTEM = -11, |
| 7616 | /// invalid value for hints |
| 7617 | BADHINTS = -12, |
| 7618 | /// resolved protocol is unknown |
| 7619 | PROTOCOL = -13, |
| 7620 | /// argument buffer overflow |
| 7621 | OVERFLOW = -14, |
| 7622 | _, |
| 7623 | }, |
| 7624 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L77-L88 |
| 7625 | .serenity => enum(c_int) { |
| 7626 | ADDRFAMILY = 1, |
| 7627 | AGAIN = 2, |
| 7628 | BADFLAGS = 3, |
| 7629 | FAIL = 4, |
| 7630 | FAMILY = 5, |
| 7631 | MEMORY = 6, |
| 7632 | NODATA = 7, |
| 7633 | NONAME = 8, |
| 7634 | SERVICE = 9, |
| 7635 | SOCKTYPE = 10, |
| 7636 | SYSTEM = 11, |
| 7637 | OVERFLOW = 12, |
| 7638 | _, |
| 7639 | }, |
| 7640 | else => void, |
| 7641 | }; |
| 7642 | |
| 7643 | pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int; |
| 7644 | |
| 7645 | pub const Stat = switch (native_os) { |
| 7646 | .emscripten => emscripten.Stat, |
| 7647 | .wasi => extern struct { |
| 7648 | // Match wasi-libc's `struct stat` in lib/libc/include/wasm-wasi-musl/__struct_stat.h |
| 7649 | dev: dev_t, |
| 7650 | ino: ino_t, |
| 7651 | nlink: nlink_t, |
| 7652 | mode: mode_t, |
| 7653 | uid: uid_t, |
| 7654 | gid: gid_t, |
| 7655 | __pad0: c_uint = 0, |
| 7656 | rdev: dev_t, |
| 7657 | size: off_t, |
| 7658 | blksize: blksize_t, |
| 7659 | blocks: blkcnt_t, |
| 7660 | atim: timespec, |
| 7661 | mtim: timespec, |
| 7662 | ctim: timespec, |
| 7663 | __reserved: [3]c_longlong = [3]c_longlong{ 0, 0, 0 }, |
| 7664 | |
| 7665 | pub fn atime(self: @This()) timespec { |
| 7666 | return self.atim; |
| 7667 | } |
| 7668 | |
| 7669 | pub fn mtime(self: @This()) timespec { |
| 7670 | return self.mtim; |
| 7671 | } |
| 7672 | |
| 7673 | pub fn ctime(self: @This()) timespec { |
| 7674 | return self.ctim; |
| 7675 | } |
| 7676 | |
| 7677 | pub fn fromFilestat(st: wasi.filestat_t) Stat { |
| 7678 | return .{ |
| 7679 | .dev = st.dev, |
| 7680 | .ino = st.ino, |
| 7681 | .mode = switch (st.filetype) { |
| 7682 | .UNKNOWN => 0, |
| 7683 | .BLOCK_DEVICE => S.IFBLK, |
| 7684 | .CHARACTER_DEVICE => S.IFCHR, |
| 7685 | .DIRECTORY => S.IFDIR, |
| 7686 | .REGULAR_FILE => S.IFREG, |
| 7687 | .SOCKET_DGRAM => S.IFSOCK, |
| 7688 | .SOCKET_STREAM => S.IFIFO, |
| 7689 | .SYMBOLIC_LINK => S.IFLNK, |
| 7690 | _ => 0, |
| 7691 | }, |
| 7692 | .nlink = st.nlink, |
| 7693 | .size = @intCast(st.size), |
| 7694 | .atim = timespec.fromTimestamp(st.atim), |
| 7695 | .mtim = timespec.fromTimestamp(st.mtim), |
| 7696 | .ctim = timespec.fromTimestamp(st.ctim), |
| 7697 | |
| 7698 | .uid = 0, |
| 7699 | .gid = 0, |
| 7700 | .rdev = 0, |
| 7701 | .blksize = 0, |
| 7702 | .blocks = 0, |
| 7703 | }; |
| 7704 | } |
| 7705 | }, |
| 7706 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 7707 | dev: i32, |
| 7708 | mode: u16, |
| 7709 | nlink: u16, |
| 7710 | ino: ino_t, |
| 7711 | uid: uid_t, |
| 7712 | gid: gid_t, |
| 7713 | rdev: i32, |
| 7714 | atimespec: timespec, |
| 7715 | mtimespec: timespec, |
| 7716 | ctimespec: timespec, |
| 7717 | birthtimespec: timespec, |
| 7718 | size: off_t, |
| 7719 | blocks: i64, |
| 7720 | blksize: i32, |
| 7721 | flags: u32, |
| 7722 | gen: u32, |
| 7723 | lspare: i32, |
| 7724 | qspare: [2]i64, |
| 7725 | |
| 7726 | pub fn atime(self: @This()) timespec { |
| 7727 | return self.atimespec; |
| 7728 | } |
| 7729 | |
| 7730 | pub fn mtime(self: @This()) timespec { |
| 7731 | return self.mtimespec; |
| 7732 | } |
| 7733 | |
| 7734 | pub fn ctime(self: @This()) timespec { |
| 7735 | return self.ctimespec; |
| 7736 | } |
| 7737 | |
| 7738 | pub fn birthtime(self: @This()) timespec { |
| 7739 | return self.birthtimespec; |
| 7740 | } |
| 7741 | }, |
| 7742 | .freebsd => freebsd.Stat, |
| 7743 | .illumos => extern struct { |
| 7744 | dev: dev_t, |
| 7745 | ino: ino_t, |
| 7746 | mode: mode_t, |
| 7747 | nlink: nlink_t, |
| 7748 | uid: uid_t, |
| 7749 | gid: gid_t, |
| 7750 | rdev: dev_t, |
| 7751 | size: off_t, |
| 7752 | atim: timespec, |
| 7753 | mtim: timespec, |
| 7754 | ctim: timespec, |
| 7755 | blksize: blksize_t, |
| 7756 | blocks: blkcnt_t, |
| 7757 | fstype: [16]u8, |
| 7758 | |
| 7759 | pub fn atime(self: @This()) timespec { |
| 7760 | return self.atim; |
| 7761 | } |
| 7762 | |
| 7763 | pub fn mtime(self: @This()) timespec { |
| 7764 | return self.mtim; |
| 7765 | } |
| 7766 | |
| 7767 | pub fn ctime(self: @This()) timespec { |
| 7768 | return self.ctim; |
| 7769 | } |
| 7770 | }, |
| 7771 | .netbsd => extern struct { |
| 7772 | dev: dev_t, |
| 7773 | mode: mode_t, |
| 7774 | ino: ino_t, |
| 7775 | nlink: nlink_t, |
| 7776 | uid: uid_t, |
| 7777 | gid: gid_t, |
| 7778 | rdev: dev_t, |
| 7779 | atim: timespec, |
| 7780 | mtim: timespec, |
| 7781 | ctim: timespec, |
| 7782 | birthtim: timespec, |
| 7783 | size: off_t, |
| 7784 | blocks: blkcnt_t, |
| 7785 | blksize: blksize_t, |
| 7786 | flags: u32, |
| 7787 | gen: u32, |
| 7788 | __spare: [2]u32, |
| 7789 | |
| 7790 | pub fn atime(self: @This()) timespec { |
| 7791 | return self.atim; |
| 7792 | } |
| 7793 | |
| 7794 | pub fn mtime(self: @This()) timespec { |
| 7795 | return self.mtim; |
| 7796 | } |
| 7797 | |
| 7798 | pub fn ctime(self: @This()) timespec { |
| 7799 | return self.ctim; |
| 7800 | } |
| 7801 | |
| 7802 | pub fn birthtime(self: @This()) timespec { |
| 7803 | return self.birthtim; |
| 7804 | } |
| 7805 | }, |
| 7806 | .dragonfly => extern struct { |
| 7807 | ino: ino_t, |
| 7808 | nlink: c_uint, |
| 7809 | dev: c_uint, |
| 7810 | mode: c_ushort, |
| 7811 | padding1: u16, |
| 7812 | uid: uid_t, |
| 7813 | gid: gid_t, |
| 7814 | rdev: c_uint, |
| 7815 | atim: timespec, |
| 7816 | mtim: timespec, |
| 7817 | ctim: timespec, |
| 7818 | size: c_ulong, |
| 7819 | blocks: i64, |
| 7820 | blksize: u32, |
| 7821 | flags: u32, |
| 7822 | gen: u32, |
| 7823 | lspare: i32, |
| 7824 | qspare1: i64, |
| 7825 | qspare2: i64, |
| 7826 | pub fn atime(self: @This()) timespec { |
| 7827 | return self.atim; |
| 7828 | } |
| 7829 | |
| 7830 | pub fn mtime(self: @This()) timespec { |
| 7831 | return self.mtim; |
| 7832 | } |
| 7833 | |
| 7834 | pub fn ctime(self: @This()) timespec { |
| 7835 | return self.ctim; |
| 7836 | } |
| 7837 | }, |
| 7838 | .haiku => extern struct { |
| 7839 | dev: dev_t, |
| 7840 | ino: ino_t, |
| 7841 | mode: mode_t, |
| 7842 | nlink: nlink_t, |
| 7843 | uid: uid_t, |
| 7844 | gid: gid_t, |
| 7845 | size: off_t, |
| 7846 | rdev: dev_t, |
| 7847 | blksize: blksize_t, |
| 7848 | atim: timespec, |
| 7849 | mtim: timespec, |
| 7850 | ctim: timespec, |
| 7851 | crtim: timespec, |
| 7852 | type: u32, |
| 7853 | blocks: blkcnt_t, |
| 7854 | |
| 7855 | pub fn atime(self: @This()) timespec { |
| 7856 | return self.atim; |
| 7857 | } |
| 7858 | pub fn mtime(self: @This()) timespec { |
| 7859 | return self.mtim; |
| 7860 | } |
| 7861 | pub fn ctime(self: @This()) timespec { |
| 7862 | return self.ctim; |
| 7863 | } |
| 7864 | pub fn birthtime(self: @This()) timespec { |
| 7865 | return self.crtim; |
| 7866 | } |
| 7867 | }, |
| 7868 | .openbsd => extern struct { |
| 7869 | mode: mode_t, |
| 7870 | dev: dev_t, |
| 7871 | ino: ino_t, |
| 7872 | nlink: nlink_t, |
| 7873 | uid: uid_t, |
| 7874 | gid: gid_t, |
| 7875 | rdev: dev_t, |
| 7876 | atim: timespec, |
| 7877 | mtim: timespec, |
| 7878 | ctim: timespec, |
| 7879 | size: off_t, |
| 7880 | blocks: blkcnt_t, |
| 7881 | blksize: blksize_t, |
| 7882 | flags: u32, |
| 7883 | gen: u32, |
| 7884 | birthtim: timespec, |
| 7885 | |
| 7886 | pub fn atime(self: @This()) timespec { |
| 7887 | return self.atim; |
| 7888 | } |
| 7889 | |
| 7890 | pub fn mtime(self: @This()) timespec { |
| 7891 | return self.mtim; |
| 7892 | } |
| 7893 | |
| 7894 | pub fn ctime(self: @This()) timespec { |
| 7895 | return self.ctim; |
| 7896 | } |
| 7897 | |
| 7898 | pub fn birthtime(self: @This()) timespec { |
| 7899 | return self.birthtim; |
| 7900 | } |
| 7901 | }, |
| 7902 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L53-L67 |
| 7903 | .serenity => extern struct { |
| 7904 | dev: dev_t, |
| 7905 | ino: ino_t, |
| 7906 | mode: mode_t, |
| 7907 | nlink: nlink_t, |
| 7908 | uid: uid_t, |
| 7909 | gid: gid_t, |
| 7910 | rdev: dev_t, |
| 7911 | size: off_t, |
| 7912 | blksize: blksize_t, |
| 7913 | blocks: blkcnt_t, |
| 7914 | atim: timespec, |
| 7915 | mtim: timespec, |
| 7916 | ctim: timespec, |
| 7917 | |
| 7918 | pub fn atime(self: @This()) timespec { |
| 7919 | return self.atim; |
| 7920 | } |
| 7921 | |
| 7922 | pub fn mtime(self: @This()) timespec { |
| 7923 | return self.mtim; |
| 7924 | } |
| 7925 | |
| 7926 | pub fn ctime(self: @This()) timespec { |
| 7927 | return self.ctim; |
| 7928 | } |
| 7929 | }, |
| 7930 | else => void, |
| 7931 | }; |
| 7932 | |
| 7933 | pub const pthread_spinlock_t = switch (native_os) { |
| 7934 | .openbsd => openbsd.pthread_spinlock_t, |
| 7935 | .freebsd => extern struct { |
| 7936 | inner: ?*anyopaque = null, |
| 7937 | }, |
| 7938 | .netbsd => extern struct { |
| 7939 | pts_magic: c_uint, |
| 7940 | spin: pthread_spin_t, |
| 7941 | pts_flags: c_int, |
| 7942 | }, |
| 7943 | .windows => isize, |
| 7944 | else => c_int, |
| 7945 | }; |
| 7946 | |
| 7947 | pub const pthread_mutex_t = switch (native_os) { |
| 7948 | .linux => extern struct { |
| 7949 | data: [data_len]u8 align(@alignOf(usize)) = @splat(0), |
| 7950 | |
| 7951 | const data_len = switch (native_abi) { |
| 7952 | .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, |
| 7953 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) { |
| 7954 | .aarch64 => 48, |
| 7955 | .x86_64 => if (native_abi == .gnux32) 32 else 40, |
| 7956 | .mips64, .powerpc64, .powerpc64le, .sparc64 => 40, |
| 7957 | else => if (@sizeOf(usize) == 8) 40 else 24, |
| 7958 | }, |
| 7959 | .android, .androideabi => if (@sizeOf(usize) == 8) 40 else 4, |
| 7960 | else => @compileError("unsupported ABI"), |
| 7961 | }; |
| 7962 | }, |
| 7963 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 7964 | sig: c_long = 0x32AAABA7, |
| 7965 | data: [data_len]u8 = @splat(0), |
| 7966 | |
| 7967 | const data_len = if (@sizeOf(usize) == 8) 56 else 40; |
| 7968 | }, |
| 7969 | .freebsd, .dragonfly, .openbsd => extern struct { |
| 7970 | inner: ?*anyopaque = null, |
| 7971 | }, |
| 7972 | .hermit => extern struct { |
| 7973 | ptr: usize = maxInt(usize), |
| 7974 | }, |
| 7975 | .netbsd => extern struct { |
| 7976 | magic: u32 = 0x33330003, |
| 7977 | errorcheck: padded_pthread_spin_t = 0, |
| 7978 | ceiling: padded_pthread_spin_t = 0, |
| 7979 | owner: usize = 0, |
| 7980 | waiters: ?*u8 = null, |
| 7981 | recursed: u32 = 0, |
| 7982 | spare2: ?*anyopaque = null, |
| 7983 | }, |
| 7984 | .haiku => extern struct { |
| 7985 | flags: u32 = 0, |
| 7986 | lock: i32 = 0, |
| 7987 | unused: i32 = -42, |
| 7988 | owner: i32 = -1, |
| 7989 | owner_count: i32 = 0, |
| 7990 | }, |
| 7991 | .illumos => extern struct { |
| 7992 | flag1: u16 = 0, |
| 7993 | flag2: u8 = 0, |
| 7994 | ceiling: u8 = 0, |
| 7995 | type: u16 = 0, |
| 7996 | magic: u16 = 0x4d58, |
| 7997 | lock: u64 = 0, |
| 7998 | data: u64 = 0, |
| 7999 | }, |
| 8000 | .fuchsia => extern struct { |
| 8001 | data: [40]u8 align(@alignOf(usize)) = @splat(0), |
| 8002 | }, |
| 8003 | .emscripten => extern struct { |
| 8004 | data: [24]u8 align(4) = @splat(0), |
| 8005 | }, |
| 8006 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L68-L73 |
| 8007 | .serenity => extern struct { |
| 8008 | lock: u32 = 0, |
| 8009 | owner: pthread_t = 0, |
| 8010 | level: c_int = 0, |
| 8011 | type: c_int = 0, |
| 8012 | }, |
| 8013 | else => void, |
| 8014 | }; |
| 8015 | |
| 8016 | pub const pthread_cond_t = switch (native_os) { |
| 8017 | .linux => extern struct { |
| 8018 | data: [48]u8 align(@alignOf(usize)) = @splat(0), |
| 8019 | }, |
| 8020 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 8021 | sig: c_long = 0x3CB0B1BB, |
| 8022 | data: [data_len]u8 = @splat(0), |
| 8023 | const data_len = if (@sizeOf(usize) == 8) 40 else 24; |
| 8024 | }, |
| 8025 | .freebsd, .dragonfly, .openbsd => extern struct { |
| 8026 | inner: ?*anyopaque = null, |
| 8027 | }, |
| 8028 | .hermit => extern struct { |
| 8029 | ptr: usize = maxInt(usize), |
| 8030 | }, |
| 8031 | .netbsd => extern struct { |
| 8032 | magic: u32 = 0x55550005, |
| 8033 | lock: pthread_spin_t = 0, |
| 8034 | waiters_first: ?*u8 = null, |
| 8035 | waiters_last: ?*u8 = null, |
| 8036 | mutex: ?*pthread_mutex_t = null, |
| 8037 | private: ?*anyopaque = null, |
| 8038 | }, |
| 8039 | .haiku => extern struct { |
| 8040 | flags: u32 = 0, |
| 8041 | unused: i32 = -42, |
| 8042 | mutex: ?*anyopaque = null, |
| 8043 | waiter_count: i32 = 0, |
| 8044 | lock: i32 = 0, |
| 8045 | }, |
| 8046 | .illumos => extern struct { |
| 8047 | flag: [4]u8 = @splat(0), |
| 8048 | type: u16 = 0, |
| 8049 | magic: u16 = 0x4356, |
| 8050 | data: u64 = 0, |
| 8051 | }, |
| 8052 | .fuchsia, .emscripten => extern struct { |
| 8053 | data: [48]u8 align(@alignOf(usize)) = @splat(0), |
| 8054 | }, |
| 8055 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L80-L84 |
| 8056 | .serenity => extern struct { |
| 8057 | mutex: ?*pthread_mutex_t = null, |
| 8058 | value: u32 = 0, |
| 8059 | clockid: clockid_t = .REALTIME_COARSE, |
| 8060 | }, |
| 8061 | else => void, |
| 8062 | }; |
| 8063 | |
| 8064 | pub const pthread_rwlock_t = switch (native_os) { |
| 8065 | .linux => switch (native_abi) { |
| 8066 | .android, .androideabi => switch (@sizeOf(usize)) { |
| 8067 | 4 => extern struct { |
| 8068 | data: [40]u8 align(@alignOf(usize)) = @splat(0), |
| 8069 | }, |
| 8070 | 8 => extern struct { |
| 8071 | data: [56]u8 align(@alignOf(usize)) = @splat(0), |
| 8072 | }, |
| 8073 | else => @compileError("impossible pointer size"), |
| 8074 | }, |
| 8075 | else => extern struct { |
| 8076 | data: [56]u8 align(@alignOf(usize)) = @splat(0), |
| 8077 | }, |
| 8078 | }, |
| 8079 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 8080 | sig: c_long = 0x2DA8B3B4, |
| 8081 | data: [192]u8 = @splat(0), |
| 8082 | }, |
| 8083 | .freebsd, .dragonfly, .openbsd => extern struct { |
| 8084 | ptr: ?*anyopaque = null, |
| 8085 | }, |
| 8086 | .hermit => extern struct { |
| 8087 | ptr: usize = maxInt(usize), |
| 8088 | }, |
| 8089 | .netbsd => extern struct { |
| 8090 | magic: c_uint = 0x99990009, |
| 8091 | interlock: switch (builtin.cpu.arch) { |
| 8092 | .aarch64, .aarch64_be, .m68k, .sparc, .sparc64, .x86, .x86_64 => u8, |
| 8093 | .arm, .armeb, .powerpc => c_int, |
| 8094 | .mips, .mipsel, .mips64, .mips64el => c_uint, |
| 8095 | else => unreachable, |
| 8096 | } = 0, |
| 8097 | rblocked_first: ?*u8 = null, |
| 8098 | rblocked_last: ?*u8 = null, |
| 8099 | wblocked_first: ?*u8 = null, |
| 8100 | wblocked_last: ?*u8 = null, |
| 8101 | nreaders: c_uint = 0, |
| 8102 | owner: ?pthread_t = null, |
| 8103 | private: ?*anyopaque = null, |
| 8104 | }, |
| 8105 | .illumos => extern struct { |
| 8106 | readers: i32 = 0, |
| 8107 | type: u16 = 0, |
| 8108 | magic: u16 = 0x5257, |
| 8109 | mutex: pthread_mutex_t = .{}, |
| 8110 | readercv: pthread_cond_t = .{}, |
| 8111 | writercv: pthread_cond_t = .{}, |
| 8112 | }, |
| 8113 | .fuchsia => extern struct { |
| 8114 | size: [56]u8 align(@alignOf(usize)) = @splat(0), |
| 8115 | }, |
| 8116 | .emscripten => extern struct { |
| 8117 | size: [32]u8 align(4) = @splat(0), |
| 8118 | }, |
| 8119 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L86 |
| 8120 | .serenity => extern struct { |
| 8121 | inner: u64 = 0, |
| 8122 | }, |
| 8123 | else => void, |
| 8124 | }; |
| 8125 | |
| 8126 | pub const pthread_attr_t = switch (native_os) { |
| 8127 | .linux, .emscripten, .dragonfly => extern struct { |
| 8128 | __size: [56]u8, |
| 8129 | __align: c_long, |
| 8130 | }, |
| 8131 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 8132 | __sig: c_long, |
| 8133 | __opaque: [56]u8, |
| 8134 | }, |
| 8135 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L75 |
| 8136 | .freebsd, .openbsd, .serenity => extern struct { |
| 8137 | inner: ?*anyopaque = null, |
| 8138 | }, |
| 8139 | .illumos => extern struct { |
| 8140 | mutexattr: ?*anyopaque = null, |
| 8141 | }, |
| 8142 | .netbsd => extern struct { |
| 8143 | magic: u32, |
| 8144 | flags: i32, |
| 8145 | private: ?*anyopaque, |
| 8146 | }, |
| 8147 | .haiku => extern struct { |
| 8148 | detach_state: i32, |
| 8149 | sched_priority: i32, |
| 8150 | stack_size: i32, |
| 8151 | guard_size: i32, |
| 8152 | stack_address: ?*anyopaque, |
| 8153 | }, |
| 8154 | else => void, |
| 8155 | }; |
| 8156 | |
| 8157 | pub const pthread_key_t = switch (native_os) { |
| 8158 | .linux, .emscripten => c_uint, |
| 8159 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_ulong, |
| 8160 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L65 |
| 8161 | .openbsd, .illumos, .serenity => c_int, |
| 8162 | else => void, |
| 8163 | }; |
| 8164 | |
| 8165 | pub const padded_pthread_spin_t = switch (native_os) { |
| 8166 | .netbsd => switch (builtin.cpu.arch) { |
| 8167 | .x86, .x86_64 => u32, |
| 8168 | .sparc, .sparc64 => u32, |
| 8169 | else => pthread_spin_t, |
| 8170 | }, |
| 8171 | else => void, |
| 8172 | }; |
| 8173 | |
| 8174 | pub const pthread_spin_t = switch (native_os) { |
| 8175 | .netbsd => switch (builtin.cpu.arch) { |
| 8176 | .aarch64, .aarch64_be => u8, |
| 8177 | .mips, .mipsel, .mips64, .mips64el => u32, |
| 8178 | .powerpc, .powerpc64, .powerpc64le => i32, |
| 8179 | .x86, .x86_64 => u8, |
| 8180 | .arm, .armeb, .thumb, .thumbeb => i32, |
| 8181 | .sparc, .sparc64 => u8, |
| 8182 | .riscv32, .riscv64 => u32, |
| 8183 | else => @compileError("undefined pthread_spin_t for this arch"), |
| 8184 | }, |
| 8185 | else => void, |
| 8186 | }; |
| 8187 | |
| 8188 | pub const sem_t = switch (native_os) { |
| 8189 | .linux, .emscripten => extern struct { |
| 8190 | __size: [4 * @sizeOf(usize)]u8 align(@alignOf(usize)), |
| 8191 | }, |
| 8192 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_int, |
| 8193 | .freebsd => extern struct { |
| 8194 | _magic: u32, |
| 8195 | _kern: extern struct { |
| 8196 | _count: u32, |
| 8197 | _flags: u32, |
| 8198 | }, |
| 8199 | _padding: u32, |
| 8200 | }, |
| 8201 | .illumos => extern struct { |
| 8202 | count: u32 = 0, |
| 8203 | type: u16 = 0, |
| 8204 | magic: u16 = 0x534d, |
| 8205 | __pad1: [3]u64 = @splat(0), |
| 8206 | __pad2: [2]u64 = @splat(0), |
| 8207 | }, |
| 8208 | .openbsd, .netbsd, .dragonfly => ?*opaque {}, |
| 8209 | .haiku => extern struct { |
| 8210 | type: i32, |
| 8211 | u: extern union { |
| 8212 | named_sem_id: i32, |
| 8213 | unnamed_sem: i32, |
| 8214 | }, |
| 8215 | padding: [2]i32, |
| 8216 | }, |
| 8217 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/semaphore.h#L23-L27 |
| 8218 | .serenity => extern struct { |
| 8219 | magic: u32, |
| 8220 | value: u32, |
| 8221 | flags: u8, |
| 8222 | }, |
| 8223 | else => void, |
| 8224 | }; |
| 8225 | |
| 8226 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. |
| 8227 | pub const Kevent = switch (native_os) { |
| 8228 | .netbsd => extern struct { |
| 8229 | ident: usize, |
| 8230 | filter: i32, |
| 8231 | flags: u32, |
| 8232 | fflags: u32, |
| 8233 | data: i64, |
| 8234 | udata: usize, |
| 8235 | }, |
| 8236 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 8237 | ident: usize, |
| 8238 | filter: i16, |
| 8239 | flags: u16, |
| 8240 | fflags: u32, |
| 8241 | data: isize, |
| 8242 | udata: usize, |
| 8243 | |
| 8244 | // sys/types.h on macos uses #pragma pack(4) so these checks are |
| 8245 | // to make sure the struct is laid out the same. These values were |
| 8246 | // produced from C code using the offsetof macro. |
| 8247 | comptime { |
| 8248 | assert(@offsetOf(@This(), "ident") == 0); |
| 8249 | assert(@offsetOf(@This(), "filter") == 8); |
| 8250 | assert(@offsetOf(@This(), "flags") == 10); |
| 8251 | assert(@offsetOf(@This(), "fflags") == 12); |
| 8252 | assert(@offsetOf(@This(), "data") == 16); |
| 8253 | assert(@offsetOf(@This(), "udata") == 24); |
| 8254 | } |
| 8255 | }, |
| 8256 | .freebsd => extern struct { |
| 8257 | /// Identifier for this event. |
| 8258 | ident: usize, |
| 8259 | /// Filter for event. |
| 8260 | filter: i16, |
| 8261 | /// Action flags for kqueue. |
| 8262 | flags: u16, |
| 8263 | /// Filter flag value. |
| 8264 | fflags: u32, |
| 8265 | /// Filter data value. |
| 8266 | data: i64, |
| 8267 | /// Opaque user data identifier. |
| 8268 | udata: usize, |
| 8269 | /// Future extensions. |
| 8270 | _ext: [4]u64 = @splat(0), |
| 8271 | }, |
| 8272 | .dragonfly => extern struct { |
| 8273 | ident: usize, |
| 8274 | filter: c_short, |
| 8275 | flags: c_ushort, |
| 8276 | fflags: c_uint, |
| 8277 | data: isize, |
| 8278 | udata: usize, |
| 8279 | }, |
| 8280 | .openbsd => extern struct { |
| 8281 | ident: usize, |
| 8282 | filter: c_short, |
| 8283 | flags: u16, |
| 8284 | fflags: c_uint, |
| 8285 | data: i64, |
| 8286 | udata: usize, |
| 8287 | }, |
| 8288 | else => void, |
| 8289 | }; |
| 8290 | |
| 8291 | pub const port_t = switch (native_os) { |
| 8292 | .illumos => c_int, |
| 8293 | else => void, |
| 8294 | }; |
| 8295 | |
| 8296 | pub const port_event = switch (native_os) { |
| 8297 | .illumos => extern struct { |
| 8298 | events: u32, |
| 8299 | /// Event source. |
| 8300 | source: u16, |
| 8301 | __pad: u16, |
| 8302 | /// Source-specific object. |
| 8303 | object: ?*anyopaque, |
| 8304 | /// User cookie. |
| 8305 | cookie: ?*anyopaque, |
| 8306 | }, |
| 8307 | else => void, |
| 8308 | }; |
| 8309 | |
| 8310 | pub const AT = switch (native_os) { |
| 8311 | .linux => linux.AT, |
| 8312 | .windows => struct { |
| 8313 | /// Remove directory instead of unlinking file |
| 8314 | pub const REMOVEDIR = 0x200; |
| 8315 | }, |
| 8316 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 8317 | pub const FDCWD = -2; |
| 8318 | /// Use effective ids in access check |
| 8319 | pub const EACCESS = 0x0010; |
| 8320 | /// Act on the symlink itself not the target |
| 8321 | pub const SYMLINK_NOFOLLOW = 0x0020; |
| 8322 | /// Act on target of symlink |
| 8323 | pub const SYMLINK_FOLLOW = 0x0040; |
| 8324 | /// Path refers to directory |
| 8325 | pub const REMOVEDIR = 0x0080; |
| 8326 | }, |
| 8327 | .freebsd => struct { |
| 8328 | /// Magic value that specify the use of the current working directory |
| 8329 | /// to determine the target of relative file paths in the openat() and |
| 8330 | /// similar syscalls. |
| 8331 | pub const FDCWD = -100; |
| 8332 | /// Check access using effective user and group ID |
| 8333 | pub const EACCESS = 0x0100; |
| 8334 | /// Do not follow symbolic links |
| 8335 | pub const SYMLINK_NOFOLLOW = 0x0200; |
| 8336 | /// Follow symbolic link |
| 8337 | pub const SYMLINK_FOLLOW = 0x0400; |
| 8338 | /// Remove directory instead of file |
| 8339 | pub const REMOVEDIR = 0x0800; |
| 8340 | /// Fail if not under dirfd |
| 8341 | pub const BENEATH = 0x1000; |
| 8342 | }, |
| 8343 | .netbsd => struct { |
| 8344 | /// Magic value that specify the use of the current working directory |
| 8345 | /// to determine the target of relative file paths in the openat() and |
| 8346 | /// similar syscalls. |
| 8347 | pub const FDCWD = -100; |
| 8348 | /// Check access using effective user and group ID |
| 8349 | pub const EACCESS = 0x0100; |
| 8350 | /// Do not follow symbolic links |
| 8351 | pub const SYMLINK_NOFOLLOW = 0x0200; |
| 8352 | /// Follow symbolic link |
| 8353 | pub const SYMLINK_FOLLOW = 0x0400; |
| 8354 | /// Remove directory instead of file |
| 8355 | pub const REMOVEDIR = 0x0800; |
| 8356 | }, |
| 8357 | .dragonfly => struct { |
| 8358 | pub const FDCWD = -328243; |
| 8359 | pub const SYMLINK_NOFOLLOW = 1; |
| 8360 | pub const REMOVEDIR = 2; |
| 8361 | pub const EACCESS = 4; |
| 8362 | pub const SYMLINK_FOLLOW = 8; |
| 8363 | }, |
| 8364 | .openbsd => struct { |
| 8365 | /// Magic value that specify the use of the current working directory |
| 8366 | /// to determine the target of relative file paths in the openat() and |
| 8367 | /// similar syscalls. |
| 8368 | pub const FDCWD = -100; |
| 8369 | /// Check access using effective user and group ID |
| 8370 | pub const EACCESS = 0x01; |
| 8371 | /// Do not follow symbolic links |
| 8372 | pub const SYMLINK_NOFOLLOW = 0x02; |
| 8373 | /// Follow symbolic link |
| 8374 | pub const SYMLINK_FOLLOW = 0x04; |
| 8375 | /// Remove directory instead of file |
| 8376 | pub const REMOVEDIR = 0x08; |
| 8377 | }, |
| 8378 | .haiku => struct { |
| 8379 | pub const FDCWD = -1; |
| 8380 | pub const SYMLINK_NOFOLLOW = 0x01; |
| 8381 | pub const SYMLINK_FOLLOW = 0x02; |
| 8382 | pub const REMOVEDIR = 0x04; |
| 8383 | pub const EACCESS = 0x08; |
| 8384 | }, |
| 8385 | .illumos => struct { |
| 8386 | /// Magic value that specify the use of the current working directory |
| 8387 | /// to determine the target of relative file paths in the openat() and |
| 8388 | /// similar syscalls. |
| 8389 | pub const FDCWD: fd_t = @bitCast(@as(u32, 0xffd19553)); |
| 8390 | /// Do not follow symbolic links |
| 8391 | pub const SYMLINK_NOFOLLOW = 0x1000; |
| 8392 | /// Follow symbolic link |
| 8393 | pub const SYMLINK_FOLLOW = 0x2000; |
| 8394 | /// Remove directory instead of file |
| 8395 | pub const REMOVEDIR = 0x1; |
| 8396 | pub const TRIGGER = 0x2; |
| 8397 | /// Check access using effective user and group ID |
| 8398 | pub const EACCESS = 0x4; |
| 8399 | }, |
| 8400 | .emscripten => struct { |
| 8401 | pub const FDCWD = -100; |
| 8402 | pub const SYMLINK_NOFOLLOW = 0x100; |
| 8403 | pub const REMOVEDIR = 0x200; |
| 8404 | pub const SYMLINK_FOLLOW = 0x400; |
| 8405 | pub const NO_AUTOMOUNT = 0x800; |
| 8406 | pub const EMPTY_PATH = 0x1000; |
| 8407 | pub const STATX_SYNC_TYPE = 0x6000; |
| 8408 | pub const STATX_SYNC_AS_STAT = 0x0000; |
| 8409 | pub const STATX_FORCE_SYNC = 0x2000; |
| 8410 | pub const STATX_DONT_SYNC = 0x4000; |
| 8411 | pub const RECURSIVE = 0x8000; |
| 8412 | }, |
| 8413 | .wasi => struct { |
| 8414 | // Match `AT_*` constants in lib/libc/include/wasm-wasi-musl/__header_fcntl.h |
| 8415 | pub const EACCESS = 0x0; |
| 8416 | pub const SYMLINK_NOFOLLOW = 0x1; |
| 8417 | pub const SYMLINK_FOLLOW = 0x2; |
| 8418 | pub const REMOVEDIR = 0x4; |
| 8419 | /// When linking libc, we follow their convention and use -2 for current working directory. |
| 8420 | /// However, without libc, Zig does a different convention: it assumes the |
| 8421 | /// current working directory is the first preopen. This behavior can be |
| 8422 | /// overridden with a public function called `wasi_cwd` in the root source |
| 8423 | /// file. |
| 8424 | pub const FDCWD: fd_t = if (builtin.link_libc) -2 else 3; |
| 8425 | }, |
| 8426 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L49-L52 |
| 8427 | .serenity => struct { |
| 8428 | pub const FDCWD = -100; |
| 8429 | pub const SYMLINK_NOFOLLOW = 0x100; |
| 8430 | pub const REMOVEDIR = 0x200; |
| 8431 | pub const EACCESS = 0x400; |
| 8432 | }, |
| 8433 | else => void, |
| 8434 | }; |
| 8435 | |
| 8436 | pub const O = switch (native_os) { |
| 8437 | .linux => linux.O, |
| 8438 | .emscripten => packed struct(u32) { |
| 8439 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8440 | _2: u4 = 0, |
| 8441 | CREAT: bool = false, |
| 8442 | EXCL: bool = false, |
| 8443 | NOCTTY: bool = false, |
| 8444 | TRUNC: bool = false, |
| 8445 | APPEND: bool = false, |
| 8446 | NONBLOCK: bool = false, |
| 8447 | DSYNC: bool = false, |
| 8448 | ASYNC: bool = false, |
| 8449 | DIRECT: bool = false, |
| 8450 | LARGEFILE: bool = false, |
| 8451 | DIRECTORY: bool = false, |
| 8452 | NOFOLLOW: bool = false, |
| 8453 | NOATIME: bool = false, |
| 8454 | CLOEXEC: bool = false, |
| 8455 | SYNC: bool = false, |
| 8456 | PATH: bool = false, |
| 8457 | /// This is typically invalid without also setting `DIRECTORY`. |
| 8458 | TMPFILE: bool = false, |
| 8459 | _: u9 = 0, |
| 8460 | }, |
| 8461 | .wasi => packed struct(u32) { |
| 8462 | // Match `O_*` bits from lib/libc/include/wasm-wasi-musl/__header_fcntl.h |
| 8463 | APPEND: bool = false, |
| 8464 | DSYNC: bool = false, |
| 8465 | NONBLOCK: bool = false, |
| 8466 | RSYNC: bool = false, |
| 8467 | SYNC: bool = false, |
| 8468 | _5: u7 = 0, |
| 8469 | CREAT: bool = false, |
| 8470 | DIRECTORY: bool = false, |
| 8471 | EXCL: bool = false, |
| 8472 | TRUNC: bool = false, |
| 8473 | _16: u8 = 0, |
| 8474 | NOFOLLOW: bool = false, |
| 8475 | EXEC: bool = false, |
| 8476 | read: bool = false, |
| 8477 | SEARCH: bool = false, |
| 8478 | write: bool = false, |
| 8479 | // O_CLOEXEC, O_TTY_ININT, O_NOCTTY are 0 in wasi-musl, so they're silently |
| 8480 | // ignored in C code. Thus no mapping in Zig. |
| 8481 | _: u3 = 0, |
| 8482 | }, |
| 8483 | .illumos => packed struct(u32) { |
| 8484 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8485 | NDELAY: bool = false, |
| 8486 | APPEND: bool = false, |
| 8487 | SYNC: bool = false, |
| 8488 | _5: u1 = 0, |
| 8489 | DSYNC: bool = false, |
| 8490 | NONBLOCK: bool = false, |
| 8491 | CREAT: bool = false, |
| 8492 | TRUNC: bool = false, |
| 8493 | EXCL: bool = false, |
| 8494 | NOCTTY: bool = false, |
| 8495 | _12: u1 = 0, |
| 8496 | LARGEFILE: bool = false, |
| 8497 | XATTR: bool = false, |
| 8498 | RSYNC: bool = false, |
| 8499 | _16: u1 = 0, |
| 8500 | NOFOLLOW: bool = false, |
| 8501 | NOLINKS: bool = false, |
| 8502 | _19: u2 = 0, |
| 8503 | SEARCH: bool = false, |
| 8504 | EXEC: bool = false, |
| 8505 | CLOEXEC: bool = false, |
| 8506 | DIRECTORY: bool = false, |
| 8507 | DIRECT: bool = false, |
| 8508 | _: u6 = 0, |
| 8509 | }, |
| 8510 | .netbsd => packed struct(u32) { |
| 8511 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8512 | NONBLOCK: bool = false, |
| 8513 | APPEND: bool = false, |
| 8514 | SHLOCK: bool = false, |
| 8515 | EXLOCK: bool = false, |
| 8516 | ASYNC: bool = false, |
| 8517 | SYNC: bool = false, |
| 8518 | NOFOLLOW: bool = false, |
| 8519 | CREAT: bool = false, |
| 8520 | TRUNC: bool = false, |
| 8521 | EXCL: bool = false, |
| 8522 | _12: u3 = 0, |
| 8523 | NOCTTY: bool = false, |
| 8524 | DSYNC: bool = false, |
| 8525 | RSYNC: bool = false, |
| 8526 | ALT_IO: bool = false, |
| 8527 | DIRECT: bool = false, |
| 8528 | _20: u1 = 0, |
| 8529 | DIRECTORY: bool = false, |
| 8530 | CLOEXEC: bool = false, |
| 8531 | SEARCH: bool = false, |
| 8532 | _: u8 = 0, |
| 8533 | }, |
| 8534 | .openbsd => packed struct(u32) { |
| 8535 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8536 | NONBLOCK: bool = false, |
| 8537 | APPEND: bool = false, |
| 8538 | SHLOCK: bool = false, |
| 8539 | EXLOCK: bool = false, |
| 8540 | ASYNC: bool = false, |
| 8541 | SYNC: bool = false, |
| 8542 | NOFOLLOW: bool = false, |
| 8543 | CREAT: bool = false, |
| 8544 | TRUNC: bool = false, |
| 8545 | EXCL: bool = false, |
| 8546 | _12: u3 = 0, |
| 8547 | NOCTTY: bool = false, |
| 8548 | CLOEXEC: bool = false, |
| 8549 | DIRECTORY: bool = false, |
| 8550 | _: u14 = 0, |
| 8551 | }, |
| 8552 | .haiku => packed struct(u32) { |
| 8553 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8554 | _2: u4 = 0, |
| 8555 | CLOEXEC: bool = false, |
| 8556 | NONBLOCK: bool = false, |
| 8557 | EXCL: bool = false, |
| 8558 | CREAT: bool = false, |
| 8559 | TRUNC: bool = false, |
| 8560 | APPEND: bool = false, |
| 8561 | NOCTTY: bool = false, |
| 8562 | NOTRAVERSE: bool = false, |
| 8563 | _14: u2 = 0, |
| 8564 | SYNC: bool = false, |
| 8565 | RSYNC: bool = false, |
| 8566 | DSYNC: bool = false, |
| 8567 | NOFOLLOW: bool = false, |
| 8568 | DIRECT: bool = false, |
| 8569 | DIRECTORY: bool = false, |
| 8570 | _: u10 = 0, |
| 8571 | }, |
| 8572 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) { |
| 8573 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8574 | NONBLOCK: bool = false, |
| 8575 | APPEND: bool = false, |
| 8576 | SHLOCK: bool = false, |
| 8577 | EXLOCK: bool = false, |
| 8578 | ASYNC: bool = false, |
| 8579 | SYNC: bool = false, |
| 8580 | NOFOLLOW: bool = false, |
| 8581 | CREAT: bool = false, |
| 8582 | TRUNC: bool = false, |
| 8583 | EXCL: bool = false, |
| 8584 | RESOLVE_BENEATH: bool = false, |
| 8585 | _13: u2 = 0, |
| 8586 | EVTONLY: bool = false, |
| 8587 | _16: u1 = 0, |
| 8588 | NOCTTY: bool = false, |
| 8589 | _18: u2 = 0, |
| 8590 | DIRECTORY: bool = false, |
| 8591 | SYMLINK: bool = false, |
| 8592 | DSYNC: bool = false, |
| 8593 | _23: u1 = 0, |
| 8594 | CLOEXEC: bool = false, |
| 8595 | _25: u4 = 0, |
| 8596 | ALERT: bool = false, |
| 8597 | _30: u1 = 0, |
| 8598 | POPUP: bool = false, |
| 8599 | }, |
| 8600 | .dragonfly => packed struct(u32) { |
| 8601 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8602 | NONBLOCK: bool = false, |
| 8603 | APPEND: bool = false, |
| 8604 | SHLOCK: bool = false, |
| 8605 | EXLOCK: bool = false, |
| 8606 | ASYNC: bool = false, |
| 8607 | SYNC: bool = false, |
| 8608 | NOFOLLOW: bool = false, |
| 8609 | CREAT: bool = false, |
| 8610 | TRUNC: bool = false, |
| 8611 | EXCL: bool = false, |
| 8612 | _12: u3 = 0, |
| 8613 | NOCTTY: bool = false, |
| 8614 | DIRECT: bool = false, |
| 8615 | CLOEXEC: bool = false, |
| 8616 | FBLOCKING: bool = false, |
| 8617 | FNONBLOCKING: bool = false, |
| 8618 | FAPPEND: bool = false, |
| 8619 | FOFFSET: bool = false, |
| 8620 | FSYNCWRITE: bool = false, |
| 8621 | FASYNCWRITE: bool = false, |
| 8622 | _24: u3 = 0, |
| 8623 | DIRECTORY: bool = false, |
| 8624 | _: u4 = 0, |
| 8625 | }, |
| 8626 | .freebsd => packed struct(u32) { |
| 8627 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8628 | NONBLOCK: bool = false, |
| 8629 | APPEND: bool = false, |
| 8630 | SHLOCK: bool = false, |
| 8631 | EXLOCK: bool = false, |
| 8632 | ASYNC: bool = false, |
| 8633 | SYNC: bool = false, |
| 8634 | NOFOLLOW: bool = false, |
| 8635 | CREAT: bool = false, |
| 8636 | TRUNC: bool = false, |
| 8637 | EXCL: bool = false, |
| 8638 | _12: u3 = 0, |
| 8639 | NOCTTY: bool = false, |
| 8640 | DIRECT: bool = false, |
| 8641 | DIRECTORY: bool = false, |
| 8642 | EXEC: bool = false, |
| 8643 | TTY_INIT: bool = false, |
| 8644 | CLOEXEC: bool = false, |
| 8645 | VERIFY: bool = false, |
| 8646 | PATH: bool = false, |
| 8647 | RESOLVE_BENEATH: bool = false, |
| 8648 | DSYNC: bool = false, |
| 8649 | EMPTY_PATH: bool = false, |
| 8650 | XATTR: bool = false, |
| 8651 | CLOFORK: bool = false, |
| 8652 | _28: u4 = 0, |
| 8653 | }, |
| 8654 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L28-L43 |
| 8655 | .serenity => packed struct(c_int) { |
| 8656 | ACCMODE: std.posix.ACCMODE = .NONE, |
| 8657 | EXEC: bool = false, |
| 8658 | CREAT: bool = false, |
| 8659 | EXCL: bool = false, |
| 8660 | NOCTTY: bool = false, |
| 8661 | TRUNC: bool = false, |
| 8662 | APPEND: bool = false, |
| 8663 | NONBLOCK: bool = false, |
| 8664 | DIRECTORY: bool = false, |
| 8665 | NOFOLLOW: bool = false, |
| 8666 | CLOEXEC: bool = false, |
| 8667 | DIRECT: bool = false, |
| 8668 | SYNC: bool = false, |
| 8669 | _: @Int(.unsigned, @bitSizeOf(c_int) - 14) = 0, |
| 8670 | }, |
| 8671 | else => void, |
| 8672 | }; |
| 8673 | |
| 8674 | pub const MAP = switch (native_os) { |
| 8675 | .linux => linux.MAP, |
| 8676 | .emscripten => packed struct(u32) { |
| 8677 | TYPE: enum(u4) { |
| 8678 | SHARED = 0x01, |
| 8679 | PRIVATE = 0x02, |
| 8680 | SHARED_VALIDATE = 0x03, |
| 8681 | }, |
| 8682 | FIXED: bool = false, |
| 8683 | ANONYMOUS: bool = false, |
| 8684 | _6: u2 = 0, |
| 8685 | GROWSDOWN: bool = false, |
| 8686 | _9: u2 = 0, |
| 8687 | DENYWRITE: bool = false, |
| 8688 | EXECUTABLE: bool = false, |
| 8689 | LOCKED: bool = false, |
| 8690 | NORESERVE: bool = false, |
| 8691 | POPULATE: bool = false, |
| 8692 | NONBLOCK: bool = false, |
| 8693 | STACK: bool = false, |
| 8694 | HUGETLB: bool = false, |
| 8695 | SYNC: bool = false, |
| 8696 | FIXED_NOREPLACE: bool = false, |
| 8697 | _: u11 = 0, |
| 8698 | }, |
| 8699 | .illumos => packed struct(u32) { |
| 8700 | TYPE: enum(u4) { |
| 8701 | SHARED = 0x01, |
| 8702 | PRIVATE = 0x02, |
| 8703 | }, |
| 8704 | FIXED: bool = false, |
| 8705 | RENAME: bool = false, |
| 8706 | NORESERVE: bool = false, |
| 8707 | @"32BIT": bool = false, |
| 8708 | ANONYMOUS: bool = false, |
| 8709 | ALIGN: bool = false, |
| 8710 | TEXT: bool = false, |
| 8711 | INITDATA: bool = false, |
| 8712 | _: u20 = 0, |
| 8713 | }, |
| 8714 | .netbsd => packed struct(u32) { |
| 8715 | TYPE: enum(u2) { |
| 8716 | SHARED = 0x01, |
| 8717 | PRIVATE = 0x02, |
| 8718 | }, |
| 8719 | REMAPDUP: bool = false, |
| 8720 | _3: u1 = 0, |
| 8721 | FIXED: bool = false, |
| 8722 | RENAME: bool = false, |
| 8723 | NORESERVE: bool = false, |
| 8724 | INHERIT: bool = false, |
| 8725 | _8: u1 = 0, |
| 8726 | HASSEMAPHORE: bool = false, |
| 8727 | TRYFIXED: bool = false, |
| 8728 | WIRED: bool = false, |
| 8729 | ANONYMOUS: bool = false, |
| 8730 | STACK: bool = false, |
| 8731 | _: u18 = 0, |
| 8732 | }, |
| 8733 | .openbsd => packed struct(u32) { |
| 8734 | TYPE: enum(u4) { |
| 8735 | SHARED = 0x01, |
| 8736 | PRIVATE = 0x02, |
| 8737 | }, |
| 8738 | FIXED: bool = false, |
| 8739 | _5: u7 = 0, |
| 8740 | ANONYMOUS: bool = false, |
| 8741 | _13: u1 = 0, |
| 8742 | STACK: bool = false, |
| 8743 | CONCEAL: bool = false, |
| 8744 | _: u16 = 0, |
| 8745 | }, |
| 8746 | .haiku => packed struct(u32) { |
| 8747 | TYPE: enum(u2) { |
| 8748 | SHARED = 0x01, |
| 8749 | PRIVATE = 0x02, |
| 8750 | }, |
| 8751 | FIXED: bool = false, |
| 8752 | ANONYMOUS: bool = false, |
| 8753 | NORESERVE: bool = false, |
| 8754 | _: u27 = 0, |
| 8755 | }, |
| 8756 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) { |
| 8757 | TYPE: enum(u4) { |
| 8758 | SHARED = 0x01, |
| 8759 | PRIVATE = 0x02, |
| 8760 | }, |
| 8761 | FIXED: bool = false, |
| 8762 | _5: u1 = 0, |
| 8763 | NORESERVE: bool = false, |
| 8764 | _7: u2 = 0, |
| 8765 | HASSEMAPHORE: bool = false, |
| 8766 | NOCACHE: bool = false, |
| 8767 | JIT: bool = false, |
| 8768 | ANONYMOUS: bool = false, |
| 8769 | _: u19 = 0, |
| 8770 | }, |
| 8771 | .dragonfly => packed struct(u32) { |
| 8772 | TYPE: enum(u4) { |
| 8773 | SHARED = 0x01, |
| 8774 | PRIVATE = 0x02, |
| 8775 | }, |
| 8776 | FIXED: bool = false, |
| 8777 | RENAME: bool = false, |
| 8778 | NORESERVE: bool = false, |
| 8779 | INHERIT: bool = false, |
| 8780 | NOEXTEND: bool = false, |
| 8781 | HASSEMAPHORE: bool = false, |
| 8782 | STACK: bool = false, |
| 8783 | NOSYNC: bool = false, |
| 8784 | ANONYMOUS: bool = false, |
| 8785 | VPAGETABLE: bool = false, |
| 8786 | _14: u2 = 0, |
| 8787 | TRYFIXED: bool = false, |
| 8788 | NOCORE: bool = false, |
| 8789 | SIZEALIGN: bool = false, |
| 8790 | _: u13 = 0, |
| 8791 | }, |
| 8792 | .freebsd => packed struct(u32) { |
| 8793 | TYPE: enum(u4) { |
| 8794 | SHARED = 0x01, |
| 8795 | PRIVATE = 0x02, |
| 8796 | }, |
| 8797 | FIXED: bool = false, |
| 8798 | _5: u5 = 0, |
| 8799 | STACK: bool = false, |
| 8800 | NOSYNC: bool = false, |
| 8801 | ANONYMOUS: bool = false, |
| 8802 | GUARD: bool = false, |
| 8803 | EXCL: bool = false, |
| 8804 | _15: u2 = 0, |
| 8805 | NOCORE: bool = false, |
| 8806 | PREFAULT_READ: bool = false, |
| 8807 | @"32BIT": bool = false, |
| 8808 | _: u12 = 0, |
| 8809 | }, |
| 8810 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L16-L26 |
| 8811 | .serenity => packed struct(c_int) { |
| 8812 | TYPE: enum(u4) { |
| 8813 | SHARED = 0x01, |
| 8814 | PRIVATE = 0x02, |
| 8815 | }, |
| 8816 | FIXED: bool = false, |
| 8817 | ANONYMOUS: bool = false, |
| 8818 | STACK: bool = false, |
| 8819 | NORESERVE: bool = false, |
| 8820 | RANDOMIZED: bool = false, |
| 8821 | PURGEABLE: bool = false, |
| 8822 | FIXED_NOREPLACE: bool = false, |
| 8823 | _: @Int(.unsigned, @bitSizeOf(c_int) - 11) = 0, |
| 8824 | }, |
| 8825 | else => void, |
| 8826 | }; |
| 8827 | |
| 8828 | pub const MREMAP = switch (native_os) { |
| 8829 | .linux => linux.MREMAP, |
| 8830 | else => void, |
| 8831 | }; |
| 8832 | |
| 8833 | /// Used by libc to communicate failure. Not actually part of the underlying syscall. |
| 8834 | pub const MAP_FAILED: *anyopaque = @ptrFromInt(maxInt(usize)); |
| 8835 | |
| 8836 | pub const cc_t = u8; |
| 8837 | |
| 8838 | /// Indices into the `cc` array in the `termios` struct. |
| 8839 | pub const V = switch (native_os) { |
| 8840 | .linux => linux.V, |
| 8841 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .netbsd, .openbsd => enum { |
| 8842 | EOF, |
| 8843 | EOL, |
| 8844 | EOL2, |
| 8845 | ERASE, |
| 8846 | WERASE, |
| 8847 | KILL, |
| 8848 | REPRINT, |
| 8849 | reserved, |
| 8850 | INTR, |
| 8851 | QUIT, |
| 8852 | SUSP, |
| 8853 | DSUSP, |
| 8854 | START, |
| 8855 | STOP, |
| 8856 | LNEXT, |
| 8857 | DISCARD, |
| 8858 | MIN, |
| 8859 | TIME, |
| 8860 | STATUS, |
| 8861 | }, |
| 8862 | .freebsd => enum { |
| 8863 | EOF, |
| 8864 | EOL, |
| 8865 | EOL2, |
| 8866 | ERASE, |
| 8867 | WERASE, |
| 8868 | KILL, |
| 8869 | REPRINT, |
| 8870 | ERASE2, |
| 8871 | INTR, |
| 8872 | QUIT, |
| 8873 | SUSP, |
| 8874 | DSUSP, |
| 8875 | START, |
| 8876 | STOP, |
| 8877 | LNEXT, |
| 8878 | DISCARD, |
| 8879 | MIN, |
| 8880 | TIME, |
| 8881 | STATUS, |
| 8882 | }, |
| 8883 | .haiku => enum { |
| 8884 | INTR, |
| 8885 | QUIT, |
| 8886 | ERASE, |
| 8887 | KILL, |
| 8888 | EOF, |
| 8889 | EOL, |
| 8890 | EOL2, |
| 8891 | SWTCH, |
| 8892 | START, |
| 8893 | STOP, |
| 8894 | SUSP, |
| 8895 | }, |
| 8896 | .illumos => enum { |
| 8897 | INTR, |
| 8898 | QUIT, |
| 8899 | ERASE, |
| 8900 | KILL, |
| 8901 | EOF, |
| 8902 | EOL, |
| 8903 | EOL2, |
| 8904 | SWTCH, |
| 8905 | START, |
| 8906 | STOP, |
| 8907 | SUSP, |
| 8908 | DSUSP, |
| 8909 | REPRINT, |
| 8910 | DISCARD, |
| 8911 | WERASE, |
| 8912 | LNEXT, |
| 8913 | STATUS, |
| 8914 | ERASE2, |
| 8915 | }, |
| 8916 | .emscripten, .wasi => enum { |
| 8917 | INTR, |
| 8918 | QUIT, |
| 8919 | ERASE, |
| 8920 | KILL, |
| 8921 | EOF, |
| 8922 | TIME, |
| 8923 | MIN, |
| 8924 | SWTC, |
| 8925 | START, |
| 8926 | STOP, |
| 8927 | SUSP, |
| 8928 | EOL, |
| 8929 | REPRINT, |
| 8930 | DISCARD, |
| 8931 | WERASE, |
| 8932 | LNEXT, |
| 8933 | EOL2, |
| 8934 | }, |
| 8935 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L32-L49 |
| 8936 | .serenity => enum { |
| 8937 | INTR, |
| 8938 | QUIT, |
| 8939 | ERASE, |
| 8940 | KILL, |
| 8941 | EOF, |
| 8942 | TIME, |
| 8943 | MIN, |
| 8944 | SWTC, |
| 8945 | START, |
| 8946 | STOP, |
| 8947 | SUSP, |
| 8948 | EOL, |
| 8949 | REPRINT, |
| 8950 | DISCARD, |
| 8951 | WERASE, |
| 8952 | LNEXT, |
| 8953 | EOL2, |
| 8954 | INFO, |
| 8955 | }, |
| 8956 | else => void, |
| 8957 | }; |
| 8958 | |
| 8959 | pub const NCCS = switch (native_os) { |
| 8960 | .linux => linux.NCCS, |
| 8961 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .freebsd, .netbsd, .openbsd, .dragonfly => 20, |
| 8962 | .haiku => 11, |
| 8963 | .illumos => 19, |
| 8964 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L15 |
| 8965 | .emscripten, .wasi, .serenity => 32, |
| 8966 | else => void, |
| 8967 | }; |
| 8968 | |
| 8969 | pub const termios = switch (native_os) { |
| 8970 | .linux => linux.termios, |
| 8971 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 8972 | iflag: tc_iflag_t, |
| 8973 | oflag: tc_oflag_t, |
| 8974 | cflag: tc_cflag_t, |
| 8975 | lflag: tc_lflag_t, |
| 8976 | cc: [NCCS]cc_t, |
| 8977 | ispeed: speed_t align(8), |
| 8978 | ospeed: speed_t, |
| 8979 | }, |
| 8980 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L21-L29 |
| 8981 | .freebsd, .netbsd, .dragonfly, .openbsd, .serenity => extern struct { |
| 8982 | iflag: tc_iflag_t, |
| 8983 | oflag: tc_oflag_t, |
| 8984 | cflag: tc_cflag_t, |
| 8985 | lflag: tc_lflag_t, |
| 8986 | cc: [NCCS]cc_t, |
| 8987 | ispeed: speed_t, |
| 8988 | ospeed: speed_t, |
| 8989 | }, |
| 8990 | .haiku => extern struct { |
| 8991 | iflag: tc_iflag_t, |
| 8992 | oflag: tc_oflag_t, |
| 8993 | cflag: tc_cflag_t, |
| 8994 | lflag: tc_lflag_t, |
| 8995 | line: cc_t, |
| 8996 | ispeed: speed_t, |
| 8997 | ospeed: speed_t, |
| 8998 | cc: [NCCS]cc_t, |
| 8999 | }, |
| 9000 | .illumos => extern struct { |
| 9001 | iflag: tc_iflag_t, |
| 9002 | oflag: tc_oflag_t, |
| 9003 | cflag: tc_cflag_t, |
| 9004 | lflag: tc_lflag_t, |
| 9005 | cc: [NCCS]cc_t, |
| 9006 | }, |
| 9007 | .emscripten, .wasi => extern struct { |
| 9008 | iflag: tc_iflag_t, |
| 9009 | oflag: tc_oflag_t, |
| 9010 | cflag: tc_cflag_t, |
| 9011 | lflag: tc_lflag_t, |
| 9012 | line: cc_t, |
| 9013 | cc: [NCCS]cc_t, |
| 9014 | ispeed: speed_t, |
| 9015 | ospeed: speed_t, |
| 9016 | }, |
| 9017 | else => void, |
| 9018 | }; |
| 9019 | |
| 9020 | pub const tc_iflag_t = switch (native_os) { |
| 9021 | .linux => linux.tc_iflag_t, |
| 9022 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) { |
| 9023 | IGNBRK: bool = false, |
| 9024 | BRKINT: bool = false, |
| 9025 | IGNPAR: bool = false, |
| 9026 | PARMRK: bool = false, |
| 9027 | INPCK: bool = false, |
| 9028 | ISTRIP: bool = false, |
| 9029 | INLCR: bool = false, |
| 9030 | IGNCR: bool = false, |
| 9031 | ICRNL: bool = false, |
| 9032 | IXON: bool = false, |
| 9033 | IXOFF: bool = false, |
| 9034 | IXANY: bool = false, |
| 9035 | _12: u1 = 0, |
| 9036 | IMAXBEL: bool = false, |
| 9037 | IUTF8: bool = false, |
| 9038 | _: u49 = 0, |
| 9039 | }, |
| 9040 | .netbsd, .freebsd, .dragonfly => packed struct(u32) { |
| 9041 | IGNBRK: bool = false, |
| 9042 | BRKINT: bool = false, |
| 9043 | IGNPAR: bool = false, |
| 9044 | PARMRK: bool = false, |
| 9045 | INPCK: bool = false, |
| 9046 | ISTRIP: bool = false, |
| 9047 | INLCR: bool = false, |
| 9048 | IGNCR: bool = false, |
| 9049 | ICRNL: bool = false, |
| 9050 | IXON: bool = false, |
| 9051 | IXOFF: bool = false, |
| 9052 | IXANY: bool = false, |
| 9053 | _12: u1 = 0, |
| 9054 | IMAXBEL: bool = false, |
| 9055 | _: u18 = 0, |
| 9056 | }, |
| 9057 | .openbsd => packed struct(u32) { |
| 9058 | IGNBRK: bool = false, |
| 9059 | BRKINT: bool = false, |
| 9060 | IGNPAR: bool = false, |
| 9061 | PARMRK: bool = false, |
| 9062 | INPCK: bool = false, |
| 9063 | ISTRIP: bool = false, |
| 9064 | INLCR: bool = false, |
| 9065 | IGNCR: bool = false, |
| 9066 | ICRNL: bool = false, |
| 9067 | IXON: bool = false, |
| 9068 | IXOFF: bool = false, |
| 9069 | IXANY: bool = false, |
| 9070 | IUCLC: bool = false, |
| 9071 | IMAXBEL: bool = false, |
| 9072 | _: u18 = 0, |
| 9073 | }, |
| 9074 | .haiku => packed struct(u32) { |
| 9075 | IGNBRK: bool = false, |
| 9076 | BRKINT: bool = false, |
| 9077 | IGNPAR: bool = false, |
| 9078 | PARMRK: bool = false, |
| 9079 | INPCK: bool = false, |
| 9080 | ISTRIP: bool = false, |
| 9081 | INLCR: bool = false, |
| 9082 | IGNCR: bool = false, |
| 9083 | ICRNL: bool = false, |
| 9084 | IUCLC: bool = false, |
| 9085 | IXON: bool = false, |
| 9086 | IXANY: bool = false, |
| 9087 | IXOFF: bool = false, |
| 9088 | _: u19 = 0, |
| 9089 | }, |
| 9090 | .illumos => packed struct(u32) { |
| 9091 | IGNBRK: bool = false, |
| 9092 | BRKINT: bool = false, |
| 9093 | IGNPAR: bool = false, |
| 9094 | PARMRK: bool = false, |
| 9095 | INPCK: bool = false, |
| 9096 | ISTRIP: bool = false, |
| 9097 | INLCR: bool = false, |
| 9098 | IGNCR: bool = false, |
| 9099 | ICRNL: bool = false, |
| 9100 | IUCLC: bool = false, |
| 9101 | IXON: bool = false, |
| 9102 | IXANY: bool = false, |
| 9103 | _12: u1 = 0, |
| 9104 | IMAXBEL: bool = false, |
| 9105 | _14: u1 = 0, |
| 9106 | DOSMODE: bool = false, |
| 9107 | _: u16 = 0, |
| 9108 | }, |
| 9109 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L52-L66 |
| 9110 | .emscripten, .wasi, .serenity => packed struct(u32) { |
| 9111 | IGNBRK: bool = false, |
| 9112 | BRKINT: bool = false, |
| 9113 | IGNPAR: bool = false, |
| 9114 | PARMRK: bool = false, |
| 9115 | INPCK: bool = false, |
| 9116 | ISTRIP: bool = false, |
| 9117 | INLCR: bool = false, |
| 9118 | IGNCR: bool = false, |
| 9119 | ICRNL: bool = false, |
| 9120 | IUCLC: bool = false, |
| 9121 | IXON: bool = false, |
| 9122 | IXANY: bool = false, |
| 9123 | IXOFF: bool = false, |
| 9124 | IMAXBEL: bool = false, |
| 9125 | IUTF8: bool = false, |
| 9126 | _: u17 = 0, |
| 9127 | }, |
| 9128 | else => void, |
| 9129 | }; |
| 9130 | |
| 9131 | pub const tc_oflag_t = switch (native_os) { |
| 9132 | .linux => linux.tc_oflag_t, |
| 9133 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) { |
| 9134 | OPOST: bool = false, |
| 9135 | ONLCR: bool = false, |
| 9136 | OXTABS: bool = false, |
| 9137 | ONOEOT: bool = false, |
| 9138 | OCRNL: bool = false, |
| 9139 | ONOCR: bool = false, |
| 9140 | ONLRET: bool = false, |
| 9141 | OFILL: bool = false, |
| 9142 | NLDLY: u2 = 0, |
| 9143 | TABDLY: u2 = 0, |
| 9144 | CRDLY: u2 = 0, |
| 9145 | FFDLY: u1 = 0, |
| 9146 | BSDLY: u1 = 0, |
| 9147 | VTDLY: u1 = 0, |
| 9148 | OFDEL: bool = false, |
| 9149 | _: u46 = 0, |
| 9150 | }, |
| 9151 | .netbsd => packed struct(u32) { |
| 9152 | OPOST: bool = false, |
| 9153 | ONLCR: bool = false, |
| 9154 | OXTABS: bool = false, |
| 9155 | ONOEOT: bool = false, |
| 9156 | OCRNL: bool = false, |
| 9157 | _5: u1 = 0, |
| 9158 | ONOCR: bool = false, |
| 9159 | ONLRET: bool = false, |
| 9160 | _: u24 = 0, |
| 9161 | }, |
| 9162 | .openbsd => packed struct(u32) { |
| 9163 | OPOST: bool = false, |
| 9164 | ONLCR: bool = false, |
| 9165 | OXTABS: bool = false, |
| 9166 | ONOEOT: bool = false, |
| 9167 | OCRNL: bool = false, |
| 9168 | OLCUC: bool = false, |
| 9169 | ONOCR: bool = false, |
| 9170 | ONLRET: bool = false, |
| 9171 | _: u24 = 0, |
| 9172 | }, |
| 9173 | .freebsd, .dragonfly => packed struct(u32) { |
| 9174 | OPOST: bool = false, |
| 9175 | ONLCR: bool = false, |
| 9176 | _2: u1 = 0, |
| 9177 | ONOEOT: bool = false, |
| 9178 | OCRNL: bool = false, |
| 9179 | ONOCR: bool = false, |
| 9180 | ONLRET: bool = false, |
| 9181 | _: u25 = 0, |
| 9182 | }, |
| 9183 | .illumos => packed struct(u32) { |
| 9184 | OPOST: bool = false, |
| 9185 | OLCUC: bool = false, |
| 9186 | ONLCR: bool = false, |
| 9187 | OCRNL: bool = false, |
| 9188 | ONOCR: bool = false, |
| 9189 | ONLRET: bool = false, |
| 9190 | OFILL: bool = false, |
| 9191 | OFDEL: bool = false, |
| 9192 | NLDLY: u1 = 0, |
| 9193 | CRDLY: u2 = 0, |
| 9194 | TABDLY: u2 = 0, |
| 9195 | BSDLY: u1 = 0, |
| 9196 | VTDLY: u1 = 0, |
| 9197 | FFDLY: u1 = 0, |
| 9198 | PAGEOUT: bool = false, |
| 9199 | WRAP: bool = false, |
| 9200 | _: u14 = 0, |
| 9201 | }, |
| 9202 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L69-L97 |
| 9203 | .haiku, .wasi, .emscripten, .serenity => packed struct(u32) { |
| 9204 | OPOST: bool = false, |
| 9205 | OLCUC: bool = false, |
| 9206 | ONLCR: bool = false, |
| 9207 | OCRNL: bool = false, |
| 9208 | ONOCR: bool = false, |
| 9209 | ONLRET: bool = false, |
| 9210 | OFILL: bool = false, |
| 9211 | OFDEL: bool = false, |
| 9212 | NLDLY: u1 = 0, |
| 9213 | CRDLY: u2 = 0, |
| 9214 | TABDLY: u2 = 0, |
| 9215 | BSDLY: u1 = 0, |
| 9216 | VTDLY: u1 = 0, |
| 9217 | FFDLY: u1 = 0, |
| 9218 | _: u16 = 0, |
| 9219 | }, |
| 9220 | else => void, |
| 9221 | }; |
| 9222 | |
| 9223 | pub const CSIZE = switch (native_os) { |
| 9224 | .linux => linux.CSIZE, |
| 9225 | .haiku => enum(u1) { CS7, CS8 }, |
| 9226 | else => enum(u2) { CS5, CS6, CS7, CS8 }, |
| 9227 | }; |
| 9228 | |
| 9229 | pub const tc_cflag_t = switch (native_os) { |
| 9230 | .linux => linux.tc_cflag_t, |
| 9231 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) { |
| 9232 | CIGNORE: bool = false, |
| 9233 | _1: u5 = 0, |
| 9234 | CSTOPB: bool = false, |
| 9235 | _7: u1 = 0, |
| 9236 | CSIZE: CSIZE = .CS5, |
| 9237 | _10: u1 = 0, |
| 9238 | CREAD: bool = false, |
| 9239 | PARENB: bool = false, |
| 9240 | PARODD: bool = false, |
| 9241 | HUPCL: bool = false, |
| 9242 | CLOCAL: bool = false, |
| 9243 | CCTS_OFLOW: bool = false, |
| 9244 | CRTS_IFLOW: bool = false, |
| 9245 | CDTR_IFLOW: bool = false, |
| 9246 | CDSR_OFLOW: bool = false, |
| 9247 | CCAR_OFLOW: bool = false, |
| 9248 | _: u43 = 0, |
| 9249 | }, |
| 9250 | .freebsd => packed struct(u32) { |
| 9251 | CIGNORE: bool = false, |
| 9252 | _1: u7 = 0, |
| 9253 | CSIZE: CSIZE = .CS5, |
| 9254 | CSTOPB: bool = false, |
| 9255 | CREAD: bool = false, |
| 9256 | PARENB: bool = false, |
| 9257 | PARODD: bool = false, |
| 9258 | HUPCL: bool = false, |
| 9259 | CLOCAL: bool = false, |
| 9260 | CCTS_OFLOW: bool = false, |
| 9261 | CRTS_IFLOW: bool = false, |
| 9262 | CDTR_IFLOW: bool = false, |
| 9263 | CDSR_OFLOW: bool = false, |
| 9264 | CCAR_OFLOW: bool = false, |
| 9265 | CNO_RTSDTR: bool = false, |
| 9266 | _: u10 = 0, |
| 9267 | }, |
| 9268 | .netbsd => packed struct(u32) { |
| 9269 | CIGNORE: bool = false, |
| 9270 | _1: u7 = 0, |
| 9271 | CSIZE: CSIZE = .CS5, |
| 9272 | CSTOPB: bool = false, |
| 9273 | CREAD: bool = false, |
| 9274 | PARENB: bool = false, |
| 9275 | PARODD: bool = false, |
| 9276 | HUPCL: bool = false, |
| 9277 | CLOCAL: bool = false, |
| 9278 | CRTSCTS: bool = false, |
| 9279 | CDTRCTS: bool = false, |
| 9280 | _18: u2 = 0, |
| 9281 | MDMBUF: bool = false, |
| 9282 | _: u11 = 0, |
| 9283 | }, |
| 9284 | .dragonfly => packed struct(u32) { |
| 9285 | CIGNORE: bool = false, |
| 9286 | _1: u7 = 0, |
| 9287 | CSIZE: CSIZE = .CS5, |
| 9288 | CSTOPB: bool = false, |
| 9289 | CREAD: bool = false, |
| 9290 | PARENB: bool = false, |
| 9291 | PARODD: bool = false, |
| 9292 | HUPCL: bool = false, |
| 9293 | CLOCAL: bool = false, |
| 9294 | CCTS_OFLOW: bool = false, |
| 9295 | CRTS_IFLOW: bool = false, |
| 9296 | CDTR_IFLOW: bool = false, |
| 9297 | CDSR_OFLOW: bool = false, |
| 9298 | CCAR_OFLOW: bool = false, |
| 9299 | _: u11 = 0, |
| 9300 | }, |
| 9301 | .openbsd => packed struct(u32) { |
| 9302 | CIGNORE: bool = false, |
| 9303 | _1: u7 = 0, |
| 9304 | CSIZE: CSIZE = .CS5, |
| 9305 | CSTOPB: bool = false, |
| 9306 | CREAD: bool = false, |
| 9307 | PARENB: bool = false, |
| 9308 | PARODD: bool = false, |
| 9309 | HUPCL: bool = false, |
| 9310 | CLOCAL: bool = false, |
| 9311 | CRTSCTS: bool = false, |
| 9312 | _17: u3 = 0, |
| 9313 | MDMBUF: bool = false, |
| 9314 | _: u11 = 0, |
| 9315 | }, |
| 9316 | .haiku => packed struct(u32) { |
| 9317 | _0: u5 = 0, |
| 9318 | CSIZE: CSIZE = .CS7, |
| 9319 | CSTOPB: bool = false, |
| 9320 | CREAD: bool = false, |
| 9321 | PARENB: bool = false, |
| 9322 | PARODD: bool = false, |
| 9323 | HUPCL: bool = false, |
| 9324 | CLOCAL: bool = false, |
| 9325 | XLOBLK: bool = false, |
| 9326 | CTSFLOW: bool = false, |
| 9327 | RTSFLOW: bool = false, |
| 9328 | _: u17 = 0, |
| 9329 | }, |
| 9330 | .illumos => packed struct(u32) { |
| 9331 | _0: u4 = 0, |
| 9332 | CSIZE: CSIZE = .CS5, |
| 9333 | CSTOPB: bool = false, |
| 9334 | CREAD: bool = false, |
| 9335 | PARENB: bool = false, |
| 9336 | PARODD: bool = false, |
| 9337 | HUPCL: bool = false, |
| 9338 | CLOCAL: bool = false, |
| 9339 | RCV1EN: bool = false, |
| 9340 | XMT1EN: bool = false, |
| 9341 | LOBLK: bool = false, |
| 9342 | XCLUDE: bool = false, |
| 9343 | _16: u4 = 0, |
| 9344 | PAREXT: bool = false, |
| 9345 | CBAUDEXT: bool = false, |
| 9346 | CIBAUDEXT: bool = false, |
| 9347 | _23: u7 = 0, |
| 9348 | CRTSXOFF: bool = false, |
| 9349 | CRTSCTS: bool = false, |
| 9350 | }, |
| 9351 | .wasi, .emscripten => packed struct(u32) { |
| 9352 | _0: u4 = 0, |
| 9353 | CSIZE: CSIZE = .CS5, |
| 9354 | CSTOPB: bool = false, |
| 9355 | CREAD: bool = false, |
| 9356 | PARENB: bool = false, |
| 9357 | PARODD: bool = false, |
| 9358 | HUPCL: bool = false, |
| 9359 | CLOCAL: bool = false, |
| 9360 | _: u20 = 0, |
| 9361 | }, |
| 9362 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L131-L141 |
| 9363 | .serenity => packed struct(u32) { |
| 9364 | _0: u4 = 0, |
| 9365 | CSIZE: CSIZE = .CS5, |
| 9366 | CSTOPB: bool = false, |
| 9367 | CREAD: bool = false, |
| 9368 | PARENB: bool = false, |
| 9369 | PARODD: bool = false, |
| 9370 | HUPCL: bool = false, |
| 9371 | CLOCAL: bool = false, |
| 9372 | CBAUDEX: bool = false, |
| 9373 | _: u19 = 0, |
| 9374 | }, |
| 9375 | else => void, |
| 9376 | }; |
| 9377 | |
| 9378 | pub const tc_lflag_t = switch (native_os) { |
| 9379 | .linux => linux.tc_lflag_t, |
| 9380 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) { |
| 9381 | ECHOKE: bool = false, |
| 9382 | ECHOE: bool = false, |
| 9383 | ECHOK: bool = false, |
| 9384 | ECHO: bool = false, |
| 9385 | ECHONL: bool = false, |
| 9386 | ECHOPRT: bool = false, |
| 9387 | ECHOCTL: bool = false, |
| 9388 | ISIG: bool = false, |
| 9389 | ICANON: bool = false, |
| 9390 | ALTWERASE: bool = false, |
| 9391 | IEXTEN: bool = false, |
| 9392 | EXTPROC: bool = false, |
| 9393 | _12: u10 = 0, |
| 9394 | TOSTOP: bool = false, |
| 9395 | FLUSHO: bool = false, |
| 9396 | _24: u1 = 0, |
| 9397 | NOKERNINFO: bool = false, |
| 9398 | _26: u3 = 0, |
| 9399 | PENDIN: bool = false, |
| 9400 | _30: u1 = 0, |
| 9401 | NOFLSH: bool = false, |
| 9402 | _: u32 = 0, |
| 9403 | }, |
| 9404 | .netbsd, .freebsd, .dragonfly => packed struct(u32) { |
| 9405 | ECHOKE: bool = false, |
| 9406 | ECHOE: bool = false, |
| 9407 | ECHOK: bool = false, |
| 9408 | ECHO: bool = false, |
| 9409 | ECHONL: bool = false, |
| 9410 | ECHOPRT: bool = false, |
| 9411 | ECHOCTL: bool = false, |
| 9412 | ISIG: bool = false, |
| 9413 | ICANON: bool = false, |
| 9414 | ALTWERASE: bool = false, |
| 9415 | IEXTEN: bool = false, |
| 9416 | EXTPROC: bool = false, |
| 9417 | _12: u10 = 0, |
| 9418 | TOSTOP: bool = false, |
| 9419 | FLUSHO: bool = false, |
| 9420 | _24: u1 = 0, |
| 9421 | NOKERNINFO: bool = false, |
| 9422 | _26: u3 = 0, |
| 9423 | PENDIN: bool = false, |
| 9424 | _30: u1 = 0, |
| 9425 | NOFLSH: bool = false, |
| 9426 | }, |
| 9427 | .openbsd => packed struct(u32) { |
| 9428 | ECHOKE: bool = false, |
| 9429 | ECHOE: bool = false, |
| 9430 | ECHOK: bool = false, |
| 9431 | ECHO: bool = false, |
| 9432 | ECHONL: bool = false, |
| 9433 | ECHOPRT: bool = false, |
| 9434 | ECHOCTL: bool = false, |
| 9435 | ISIG: bool = false, |
| 9436 | ICANON: bool = false, |
| 9437 | ALTWERASE: bool = false, |
| 9438 | IEXTEN: bool = false, |
| 9439 | EXTPROC: bool = false, |
| 9440 | _12: u10 = 0, |
| 9441 | TOSTOP: bool = false, |
| 9442 | FLUSHO: bool = false, |
| 9443 | XCASE: bool = false, |
| 9444 | NOKERNINFO: bool = false, |
| 9445 | _26: u3 = 0, |
| 9446 | PENDIN: bool = false, |
| 9447 | _30: u1 = 0, |
| 9448 | NOFLSH: bool = false, |
| 9449 | }, |
| 9450 | .haiku => packed struct(u32) { |
| 9451 | ISIG: bool = false, |
| 9452 | ICANON: bool = false, |
| 9453 | XCASE: bool = false, |
| 9454 | ECHO: bool = false, |
| 9455 | ECHOE: bool = false, |
| 9456 | ECHOK: bool = false, |
| 9457 | ECHONL: bool = false, |
| 9458 | NOFLSH: bool = false, |
| 9459 | TOSTOP: bool = false, |
| 9460 | IEXTEN: bool = false, |
| 9461 | ECHOCTL: bool = false, |
| 9462 | ECHOPRT: bool = false, |
| 9463 | ECHOKE: bool = false, |
| 9464 | FLUSHO: bool = false, |
| 9465 | PENDIN: bool = false, |
| 9466 | _: u17 = 0, |
| 9467 | }, |
| 9468 | .illumos => packed struct(u32) { |
| 9469 | ISIG: bool = false, |
| 9470 | ICANON: bool = false, |
| 9471 | XCASE: bool = false, |
| 9472 | ECHO: bool = false, |
| 9473 | ECHOE: bool = false, |
| 9474 | ECHOK: bool = false, |
| 9475 | ECHONL: bool = false, |
| 9476 | NOFLSH: bool = false, |
| 9477 | TOSTOP: bool = false, |
| 9478 | ECHOCTL: bool = false, |
| 9479 | ECHOPRT: bool = false, |
| 9480 | ECHOKE: bool = false, |
| 9481 | DEFECHO: bool = false, |
| 9482 | FLUSHO: bool = false, |
| 9483 | PENDIN: bool = false, |
| 9484 | IEXTEN: bool = false, |
| 9485 | _: u16 = 0, |
| 9486 | }, |
| 9487 | .wasi, .emscripten => packed struct(u32) { |
| 9488 | ISIG: bool = false, |
| 9489 | ICANON: bool = false, |
| 9490 | _2: u1 = 0, |
| 9491 | ECHO: bool = false, |
| 9492 | ECHOE: bool = false, |
| 9493 | ECHOK: bool = false, |
| 9494 | ECHONL: bool = false, |
| 9495 | NOFLSH: bool = false, |
| 9496 | TOSTOP: bool = false, |
| 9497 | _9: u6 = 0, |
| 9498 | IEXTEN: bool = false, |
| 9499 | _: u16 = 0, |
| 9500 | }, |
| 9501 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L168-L189 |
| 9502 | .serenity => packed struct(u32) { |
| 9503 | ISIG: bool = false, |
| 9504 | ICANON: bool = false, |
| 9505 | XCASE: bool = false, |
| 9506 | ECHO: bool = false, |
| 9507 | ECHOE: bool = false, |
| 9508 | ECHOK: bool = false, |
| 9509 | ECHONL: bool = false, |
| 9510 | NOFLSH: bool = false, |
| 9511 | TOSTOP: bool = false, |
| 9512 | ECHOCTL: bool = false, |
| 9513 | ECHOPRT: bool = false, |
| 9514 | ECHOKE: bool = false, |
| 9515 | FLUSHO: bool = false, |
| 9516 | _13: u1 = 0, |
| 9517 | PENDIN: bool = false, |
| 9518 | IEXTEN: bool = false, |
| 9519 | EXTPROC: bool = false, |
| 9520 | _: u15 = 0, |
| 9521 | }, |
| 9522 | else => void, |
| 9523 | }; |
| 9524 | |
| 9525 | pub const speed_t = switch (native_os) { |
| 9526 | .linux => linux.speed_t, |
| 9527 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .openbsd => enum(u64) { |
| 9528 | B0 = 0, |
| 9529 | B50 = 50, |
| 9530 | B75 = 75, |
| 9531 | B110 = 110, |
| 9532 | B134 = 134, |
| 9533 | B150 = 150, |
| 9534 | B200 = 200, |
| 9535 | B300 = 300, |
| 9536 | B600 = 600, |
| 9537 | B1200 = 1200, |
| 9538 | B1800 = 1800, |
| 9539 | B2400 = 2400, |
| 9540 | B4800 = 4800, |
| 9541 | B9600 = 9600, |
| 9542 | B19200 = 19200, |
| 9543 | B38400 = 38400, |
| 9544 | B7200 = 7200, |
| 9545 | B14400 = 14400, |
| 9546 | B28800 = 28800, |
| 9547 | B57600 = 57600, |
| 9548 | B76800 = 76800, |
| 9549 | B115200 = 115200, |
| 9550 | B230400 = 230400, |
| 9551 | }, |
| 9552 | .freebsd, .netbsd => enum(c_uint) { |
| 9553 | B0 = 0, |
| 9554 | B50 = 50, |
| 9555 | B75 = 75, |
| 9556 | B110 = 110, |
| 9557 | B134 = 134, |
| 9558 | B150 = 150, |
| 9559 | B200 = 200, |
| 9560 | B300 = 300, |
| 9561 | B600 = 600, |
| 9562 | B1200 = 1200, |
| 9563 | B1800 = 1800, |
| 9564 | B2400 = 2400, |
| 9565 | B4800 = 4800, |
| 9566 | B9600 = 9600, |
| 9567 | B19200 = 19200, |
| 9568 | B38400 = 38400, |
| 9569 | B7200 = 7200, |
| 9570 | B14400 = 14400, |
| 9571 | B28800 = 28800, |
| 9572 | B57600 = 57600, |
| 9573 | B76800 = 76800, |
| 9574 | B115200 = 115200, |
| 9575 | B230400 = 230400, |
| 9576 | B460800 = 460800, |
| 9577 | B500000 = 500000, |
| 9578 | B921600 = 921600, |
| 9579 | B1000000 = 1000000, |
| 9580 | B1500000 = 1500000, |
| 9581 | B2000000 = 2000000, |
| 9582 | B2500000 = 2500000, |
| 9583 | B3000000 = 3000000, |
| 9584 | B3500000 = 3500000, |
| 9585 | B4000000 = 4000000, |
| 9586 | }, |
| 9587 | .dragonfly => enum(c_uint) { |
| 9588 | B0 = 0, |
| 9589 | B50 = 50, |
| 9590 | B75 = 75, |
| 9591 | B110 = 110, |
| 9592 | B134 = 134, |
| 9593 | B150 = 150, |
| 9594 | B200 = 200, |
| 9595 | B300 = 300, |
| 9596 | B600 = 600, |
| 9597 | B1200 = 1200, |
| 9598 | B1800 = 1800, |
| 9599 | B2400 = 2400, |
| 9600 | B4800 = 4800, |
| 9601 | B9600 = 9600, |
| 9602 | B19200 = 19200, |
| 9603 | B38400 = 38400, |
| 9604 | B7200 = 7200, |
| 9605 | B14400 = 14400, |
| 9606 | B28800 = 28800, |
| 9607 | B57600 = 57600, |
| 9608 | B76800 = 76800, |
| 9609 | B115200 = 115200, |
| 9610 | B230400 = 230400, |
| 9611 | B460800 = 460800, |
| 9612 | B921600 = 921600, |
| 9613 | }, |
| 9614 | .haiku => enum(u8) { |
| 9615 | B0 = 0x00, |
| 9616 | B50 = 0x01, |
| 9617 | B75 = 0x02, |
| 9618 | B110 = 0x03, |
| 9619 | B134 = 0x04, |
| 9620 | B150 = 0x05, |
| 9621 | B200 = 0x06, |
| 9622 | B300 = 0x07, |
| 9623 | B600 = 0x08, |
| 9624 | B1200 = 0x09, |
| 9625 | B1800 = 0x0A, |
| 9626 | B2400 = 0x0B, |
| 9627 | B4800 = 0x0C, |
| 9628 | B9600 = 0x0D, |
| 9629 | B19200 = 0x0E, |
| 9630 | B38400 = 0x0F, |
| 9631 | B57600 = 0x10, |
| 9632 | B115200 = 0x11, |
| 9633 | B230400 = 0x12, |
| 9634 | B31250 = 0x13, |
| 9635 | }, |
| 9636 | .illumos => enum(c_uint) { |
| 9637 | B0 = 0, |
| 9638 | B50 = 1, |
| 9639 | B75 = 2, |
| 9640 | B110 = 3, |
| 9641 | B134 = 4, |
| 9642 | B150 = 5, |
| 9643 | B200 = 6, |
| 9644 | B300 = 7, |
| 9645 | B600 = 8, |
| 9646 | B1200 = 9, |
| 9647 | B1800 = 10, |
| 9648 | B2400 = 11, |
| 9649 | B4800 = 12, |
| 9650 | B9600 = 13, |
| 9651 | B19200 = 14, |
| 9652 | B38400 = 15, |
| 9653 | B57600 = 16, |
| 9654 | B76800 = 17, |
| 9655 | B115200 = 18, |
| 9656 | B153600 = 19, |
| 9657 | B230400 = 20, |
| 9658 | B307200 = 21, |
| 9659 | B460800 = 22, |
| 9660 | B921600 = 23, |
| 9661 | B1000000 = 24, |
| 9662 | B1152000 = 25, |
| 9663 | B1500000 = 26, |
| 9664 | B2000000 = 27, |
| 9665 | B2500000 = 28, |
| 9666 | B3000000 = 29, |
| 9667 | B3500000 = 30, |
| 9668 | B4000000 = 31, |
| 9669 | }, |
| 9670 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L111-L159 |
| 9671 | .emscripten, .wasi, .serenity => enum(u32) { |
| 9672 | B0 = 0o0000000, |
| 9673 | B50 = 0o0000001, |
| 9674 | B75 = 0o0000002, |
| 9675 | B110 = 0o0000003, |
| 9676 | B134 = 0o0000004, |
| 9677 | B150 = 0o0000005, |
| 9678 | B200 = 0o0000006, |
| 9679 | B300 = 0o0000007, |
| 9680 | B600 = 0o0000010, |
| 9681 | B1200 = 0o0000011, |
| 9682 | B1800 = 0o0000012, |
| 9683 | B2400 = 0o0000013, |
| 9684 | B4800 = 0o0000014, |
| 9685 | B9600 = 0o0000015, |
| 9686 | B19200 = 0o0000016, |
| 9687 | B38400 = 0o0000017, |
| 9688 | |
| 9689 | B57600 = 0o0010001, |
| 9690 | B115200 = 0o0010002, |
| 9691 | B230400 = 0o0010003, |
| 9692 | B460800 = 0o0010004, |
| 9693 | B500000 = 0o0010005, |
| 9694 | B576000 = 0o0010006, |
| 9695 | B921600 = 0o0010007, |
| 9696 | B1000000 = 0o0010010, |
| 9697 | B1152000 = 0o0010011, |
| 9698 | B1500000 = 0o0010012, |
| 9699 | B2000000 = 0o0010013, |
| 9700 | B2500000 = 0o0010014, |
| 9701 | B3000000 = 0o0010015, |
| 9702 | B3500000 = 0o0010016, |
| 9703 | B4000000 = 0o0010017, |
| 9704 | }, |
| 9705 | else => void, |
| 9706 | }; |
| 9707 | |
| 9708 | pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int; |
| 9709 | |
| 9710 | pub const sig_atomic_t = switch (native_os) { |
| 9711 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L20 |
| 9712 | .serenity => u32, |
| 9713 | else => c_int, |
| 9714 | }; |
| 9715 | |
| 9716 | /// maximum signal number + 1 |
| 9717 | pub const NSIG = switch (native_os) { |
| 9718 | .linux => linux.NSIG, |
| 9719 | .windows => 23, |
| 9720 | .haiku => 65, |
| 9721 | .netbsd, .freebsd => 32, |
| 9722 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.NSIG, |
| 9723 | .illumos => 75, |
| 9724 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h#L42 |
| 9725 | .openbsd, .serenity => 33, |
| 9726 | .dragonfly => 64, |
| 9727 | else => {}, |
| 9728 | }; |
| 9729 | |
| 9730 | pub const MINSIGSTKSZ = switch (native_os) { |
| 9731 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 32768, |
| 9732 | .freebsd => switch (builtin.cpu.arch) { |
| 9733 | .powerpc64, .powerpc64le, .x86, .x86_64 => 2048, |
| 9734 | .arm, .aarch64, .riscv64 => 4096, |
| 9735 | else => @compileError("unsupported arch"), |
| 9736 | }, |
| 9737 | .illumos => 2048, |
| 9738 | .haiku, .netbsd => 8192, |
| 9739 | .openbsd => 1 << openbsd.MAX_PAGE_SHIFT, |
| 9740 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L58 |
| 9741 | .serenity => 4096, |
| 9742 | else => {}, |
| 9743 | }; |
| 9744 | pub const SIGSTKSZ = switch (native_os) { |
| 9745 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 131072, |
| 9746 | .netbsd, .freebsd => MINSIGSTKSZ + 32768, |
| 9747 | .illumos => 8192, |
| 9748 | .haiku => 16384, |
| 9749 | .openbsd => MINSIGSTKSZ + (1 << openbsd.MAX_PAGE_SHIFT) * 4, |
| 9750 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L59 |
| 9751 | .serenity => 32768, |
| 9752 | else => {}, |
| 9753 | }; |
| 9754 | pub const SS = switch (native_os) { |
| 9755 | .linux => linux.SS, |
| 9756 | .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .netbsd, .freebsd => struct { |
| 9757 | pub const ONSTACK = 1; |
| 9758 | pub const DISABLE = 4; |
| 9759 | }, |
| 9760 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L54-L55 |
| 9761 | .haiku, .illumos, .serenity => struct { |
| 9762 | pub const ONSTACK = 0x1; |
| 9763 | pub const DISABLE = 0x2; |
| 9764 | }, |
| 9765 | else => void, |
| 9766 | }; |
| 9767 | |
| 9768 | pub const EV = switch (native_os) { |
| 9769 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 9770 | // https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/event.h |
| 9771 | /// add event to kq (implies enable) |
| 9772 | pub const ADD = 0x0001; |
| 9773 | /// delete event from kq |
| 9774 | pub const DELETE = 0x0002; |
| 9775 | /// enable event |
| 9776 | pub const ENABLE = 0x0004; |
| 9777 | /// disable event (not reported) |
| 9778 | pub const DISABLE = 0x0008; |
| 9779 | /// only report one occurrence |
| 9780 | pub const ONESHOT = 0x0010; |
| 9781 | /// clear event state after reporting |
| 9782 | pub const CLEAR = 0x0020; |
| 9783 | /// force immediate event output |
| 9784 | /// ... with or without ERROR |
| 9785 | /// ... use KEVENT_FLAG_ERROR_EVENTS |
| 9786 | /// on syscalls supporting flags |
| 9787 | pub const RECEIPT = 0x0040; |
| 9788 | /// disable event after reporting |
| 9789 | pub const DISPATCH = 0x0080; |
| 9790 | /// unique kevent per udata value |
| 9791 | pub const UDATA_SPECIFIC = 0x0100; |
| 9792 | /// ... in combination with DELETE |
| 9793 | /// will defer delete until udata-specific |
| 9794 | /// event enabled. EINPROGRESS will be |
| 9795 | /// returned to indicate the deferral |
| 9796 | pub const DISPATCH2 = DISPATCH | UDATA_SPECIFIC; |
| 9797 | /// report that source has vanished |
| 9798 | /// ... only valid with DISPATCH2 |
| 9799 | pub const VANISHED = 0x0200; |
| 9800 | /// reserved by system |
| 9801 | pub const SYSFLAGS = 0xF000; |
| 9802 | /// filter-specific flag |
| 9803 | pub const FLAG0 = 0x1000; |
| 9804 | /// filter-specific flag |
| 9805 | pub const FLAG1 = 0x2000; |
| 9806 | /// EOF detected (return value) |
| 9807 | pub const EOF = 0x8000; |
| 9808 | /// error, data contains errno (return value) |
| 9809 | pub const ERROR = 0x4000; |
| 9810 | /// use poll(2) semantics for EVFILT.READ |
| 9811 | pub const POLL = FLAG0; |
| 9812 | /// on input, filter should actively return in the presence of OOB on the descriptor |
| 9813 | /// on output, indicates the presence of OOB data on the descriptor |
| 9814 | pub const OOBAND = FLAG1; |
| 9815 | }, |
| 9816 | .dragonfly => struct { |
| 9817 | pub const ADD = 1; |
| 9818 | pub const DELETE = 2; |
| 9819 | pub const ENABLE = 4; |
| 9820 | pub const DISABLE = 8; |
| 9821 | pub const ONESHOT = 16; |
| 9822 | pub const CLEAR = 32; |
| 9823 | pub const RECEIPT = 64; |
| 9824 | pub const DISPATCH = 128; |
| 9825 | pub const NODATA = 4096; |
| 9826 | pub const FLAG1 = 8192; |
| 9827 | pub const ERROR = 16384; |
| 9828 | pub const EOF = 32768; |
| 9829 | pub const SYSFLAGS = 61440; |
| 9830 | }, |
| 9831 | .netbsd => struct { |
| 9832 | /// add event to kq (implies enable) |
| 9833 | pub const ADD = 0x0001; |
| 9834 | /// delete event from kq |
| 9835 | pub const DELETE = 0x0002; |
| 9836 | /// enable event |
| 9837 | pub const ENABLE = 0x0004; |
| 9838 | /// disable event (not reported) |
| 9839 | pub const DISABLE = 0x0008; |
| 9840 | /// only report one occurrence |
| 9841 | pub const ONESHOT = 0x0010; |
| 9842 | /// clear event state after reporting |
| 9843 | pub const CLEAR = 0x0020; |
| 9844 | /// force EV_ERROR on success, data=0 |
| 9845 | pub const RECEIPT = 0x0040; |
| 9846 | /// disable event after reporting |
| 9847 | pub const DISPATCH = 0x0080; |
| 9848 | /// filter-specific flag |
| 9849 | pub const FLAG1 = 0x2000; |
| 9850 | /// error, data contains errno |
| 9851 | pub const ERROR = 0x4000; |
| 9852 | /// EOF detected |
| 9853 | pub const EOF = 0x8000; |
| 9854 | }, |
| 9855 | .freebsd => struct { |
| 9856 | // https://cgit.freebsd.org/src/tree/sys/sys/event.h |
| 9857 | /// add event to kq (implies enable) |
| 9858 | pub const ADD = 0x0001; |
| 9859 | /// delete event from kq |
| 9860 | pub const DELETE = 0x0002; |
| 9861 | /// enable event |
| 9862 | pub const ENABLE = 0x0004; |
| 9863 | /// disable event (not reported) |
| 9864 | pub const DISABLE = 0x0008; |
| 9865 | /// enable _ONESHOT and force trigger |
| 9866 | pub const FORCEONESHOT = 0x0100; |
| 9867 | /// do not update the udata field |
| 9868 | pub const KEEPUDATA = 0x0200; |
| 9869 | /// only report one occurrence |
| 9870 | pub const ONESHOT = 0x0010; |
| 9871 | /// clear event state after reporting |
| 9872 | pub const CLEAR = 0x0020; |
| 9873 | /// force immediate event output |
| 9874 | /// ... with or without ERROR |
| 9875 | /// ... use KEVENT_FLAG_ERROR_EVENTS |
| 9876 | /// on syscalls supporting flags |
| 9877 | pub const RECEIPT = 0x0040; |
| 9878 | /// disable event after reporting |
| 9879 | pub const DISPATCH = 0x0080; |
| 9880 | /// reserved by system |
| 9881 | pub const SYSFLAGS = 0xF000; |
| 9882 | /// note should be dropped |
| 9883 | pub const DROP = 0x1000; |
| 9884 | /// filter-specific flag 1 |
| 9885 | pub const FLAG1 = 0x2000; |
| 9886 | /// filter-specific flag 2 |
| 9887 | pub const FLAG2 = 0x4000; |
| 9888 | /// EOF detected (return value) |
| 9889 | pub const EOF = 0x8000; |
| 9890 | /// error, event data contains errno (return value) |
| 9891 | pub const ERROR = 0x4000; |
| 9892 | }, |
| 9893 | .openbsd => struct { |
| 9894 | pub const ADD = 0x0001; |
| 9895 | pub const DELETE = 0x0002; |
| 9896 | pub const ENABLE = 0x0004; |
| 9897 | pub const DISABLE = 0x0008; |
| 9898 | pub const ONESHOT = 0x0010; |
| 9899 | pub const CLEAR = 0x0020; |
| 9900 | pub const RECEIPT = 0x0040; |
| 9901 | pub const DISPATCH = 0x0080; |
| 9902 | pub const FLAG1 = 0x2000; |
| 9903 | pub const ERROR = 0x4000; |
| 9904 | pub const EOF = 0x8000; |
| 9905 | }, |
| 9906 | .haiku => struct { |
| 9907 | /// add event to kq (implies enable) |
| 9908 | pub const ADD = 0x0001; |
| 9909 | /// delete event from kq |
| 9910 | pub const DELETE = 0x0002; |
| 9911 | /// enable event |
| 9912 | pub const ENABLE = 0x0004; |
| 9913 | /// disable event (not reported) |
| 9914 | pub const DISABLE = 0x0008; |
| 9915 | /// only report one occurrence |
| 9916 | pub const ONESHOT = 0x0010; |
| 9917 | /// clear event state after reporting |
| 9918 | pub const CLEAR = 0x0020; |
| 9919 | /// force immediate event output |
| 9920 | /// ... with or without ERROR |
| 9921 | /// ... use KEVENT_FLAG_ERROR_EVENTS |
| 9922 | /// on syscalls supporting flags |
| 9923 | pub const RECEIPT = 0x0040; |
| 9924 | /// disable event after reporting |
| 9925 | pub const DISPATCH = 0x0080; |
| 9926 | }, |
| 9927 | else => void, |
| 9928 | }; |
| 9929 | |
| 9930 | pub const EVFILT = switch (native_os) { |
| 9931 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 9932 | pub const READ = -1; |
| 9933 | pub const WRITE = -2; |
| 9934 | /// attached to aio requests |
| 9935 | pub const AIO = -3; |
| 9936 | /// attached to vnodes |
| 9937 | pub const VNODE = -4; |
| 9938 | /// attached to struct proc |
| 9939 | pub const PROC = -5; |
| 9940 | /// attached to struct proc |
| 9941 | pub const SIGNAL = -6; |
| 9942 | /// timers |
| 9943 | pub const TIMER = -7; |
| 9944 | /// Mach portsets |
| 9945 | pub const MACHPORT = -8; |
| 9946 | /// Filesystem events |
| 9947 | pub const FS = -9; |
| 9948 | /// User events |
| 9949 | pub const USER = -10; |
| 9950 | /// Virtual memory events |
| 9951 | pub const VM = -12; |
| 9952 | /// Exception events |
| 9953 | pub const EXCEPT = -15; |
| 9954 | pub const SYSCOUNT = 17; |
| 9955 | }, |
| 9956 | .haiku => struct { |
| 9957 | pub const READ = -1; |
| 9958 | pub const WRITE = -2; |
| 9959 | /// attached to aio requests |
| 9960 | pub const AIO = -3; |
| 9961 | /// attached to vnodes |
| 9962 | pub const VNODE = -4; |
| 9963 | /// attached to struct proc |
| 9964 | pub const PROC = -5; |
| 9965 | /// attached to struct proc |
| 9966 | pub const SIGNAL = -6; |
| 9967 | /// timers |
| 9968 | pub const TIMER = -7; |
| 9969 | /// Process descriptors |
| 9970 | pub const PROCDESC = -8; |
| 9971 | /// Filesystem events |
| 9972 | pub const FS = -9; |
| 9973 | pub const LIO = -10; |
| 9974 | /// User events |
| 9975 | pub const USER = -11; |
| 9976 | /// Sendfile events |
| 9977 | pub const SENDFILE = -12; |
| 9978 | pub const EMPTY = -13; |
| 9979 | }, |
| 9980 | .dragonfly => struct { |
| 9981 | pub const FS = -10; |
| 9982 | pub const USER = -9; |
| 9983 | pub const EXCEPT = -8; |
| 9984 | pub const TIMER = -7; |
| 9985 | pub const SIGNAL = -6; |
| 9986 | pub const PROC = -5; |
| 9987 | pub const VNODE = -4; |
| 9988 | pub const AIO = -3; |
| 9989 | pub const WRITE = -2; |
| 9990 | pub const READ = -1; |
| 9991 | pub const SYSCOUNT = 10; |
| 9992 | pub const MARKER = 15; |
| 9993 | }, |
| 9994 | .netbsd => struct { |
| 9995 | pub const READ = 0; |
| 9996 | pub const WRITE = 1; |
| 9997 | /// attached to aio requests |
| 9998 | pub const AIO = 2; |
| 9999 | /// attached to vnodes |
| 10000 | pub const VNODE = 3; |
| 10001 | /// attached to struct proc |
| 10002 | pub const PROC = 4; |
| 10003 | /// attached to struct proc |
| 10004 | pub const SIGNAL = 5; |
| 10005 | /// timers |
| 10006 | pub const TIMER = 6; |
| 10007 | /// Filesystem events |
| 10008 | pub const FS = 7; |
| 10009 | /// User events |
| 10010 | pub const USER = 8; |
| 10011 | /// Empty filter |
| 10012 | pub const EMPTY = 9; |
| 10013 | }, |
| 10014 | .freebsd => struct { |
| 10015 | // https://cgit.freebsd.org/src/tree/sys/sys/event.h |
| 10016 | pub const READ = -1; |
| 10017 | pub const WRITE = -2; |
| 10018 | /// attached to aio requests |
| 10019 | pub const AIO = -3; |
| 10020 | /// attached to vnodes |
| 10021 | pub const VNODE = -4; |
| 10022 | /// attached to struct proc |
| 10023 | pub const PROC = -5; |
| 10024 | /// attached to struct proc |
| 10025 | pub const SIGNAL = -6; |
| 10026 | /// timers |
| 10027 | pub const TIMER = -7; |
| 10028 | /// Process descriptors |
| 10029 | pub const PROCDESC = -8; |
| 10030 | /// Filesystem events |
| 10031 | pub const FS = -9; |
| 10032 | /// attached to lio requests |
| 10033 | pub const LIO = -10; |
| 10034 | /// User events |
| 10035 | pub const USER = -11; |
| 10036 | /// Sendfile events |
| 10037 | pub const SENDFILE = -12; |
| 10038 | /// empty send socket buf |
| 10039 | pub const EMPTY = -13; |
| 10040 | /// attached to struct prison |
| 10041 | pub const JAIL = -14; |
| 10042 | /// attached to jail descriptors |
| 10043 | pub const JAILDESC = -15; |
| 10044 | }, |
| 10045 | .openbsd => struct { |
| 10046 | pub const READ = -1; |
| 10047 | pub const WRITE = -2; |
| 10048 | pub const AIO = -3; |
| 10049 | pub const VNODE = -4; |
| 10050 | pub const PROC = -5; |
| 10051 | pub const SIGNAL = -6; |
| 10052 | pub const TIMER = -7; |
| 10053 | pub const DEVICE = -8; |
| 10054 | pub const EXCEPT = -9; |
| 10055 | pub const USER = -10; |
| 10056 | }, |
| 10057 | else => void, |
| 10058 | }; |
| 10059 | |
| 10060 | pub const NOTE = switch (native_os) { |
| 10061 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 10062 | // https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/event.h |
| 10063 | /// On input, TRIGGER causes the event to be triggered for output. |
| 10064 | pub const TRIGGER = 0x01000000; |
| 10065 | /// ignore input fflags |
| 10066 | pub const FFNOP = 0x00000000; |
| 10067 | /// and fflags |
| 10068 | pub const FFAND = 0x40000000; |
| 10069 | /// or fflags |
| 10070 | pub const FFOR = 0x80000000; |
| 10071 | /// copy fflags |
| 10072 | pub const FFCOPY = 0xc0000000; |
| 10073 | /// mask for operations |
| 10074 | pub const FFCTRLMASK = 0xc0000000; |
| 10075 | pub const FFLAGSMASK = 0x00ffffff; |
| 10076 | /// low water mark |
| 10077 | pub const LOWAT = 0x00000001; |
| 10078 | /// OOB data |
| 10079 | pub const OOB = 0x00000002; |
| 10080 | /// vnode was removed |
| 10081 | pub const DELETE = 0x00000001; |
| 10082 | /// data contents changed |
| 10083 | pub const WRITE = 0x00000002; |
| 10084 | /// size increased |
| 10085 | pub const EXTEND = 0x00000004; |
| 10086 | /// attributes changed |
| 10087 | pub const ATTRIB = 0x00000008; |
| 10088 | /// link count changed |
| 10089 | pub const LINK = 0x00000010; |
| 10090 | /// vnode was renamed |
| 10091 | pub const RENAME = 0x00000020; |
| 10092 | /// vnode access was revoked |
| 10093 | pub const REVOKE = 0x00000040; |
| 10094 | /// No specific vnode event: to test for EVFILT_READ activation |
| 10095 | pub const NONE = 0x00000080; |
| 10096 | /// vnode was unlocked by flock(2) |
| 10097 | pub const FUNLOCK = 0x00000100; |
| 10098 | /// process exited |
| 10099 | pub const EXIT = 0x80000000; |
| 10100 | /// process forked |
| 10101 | pub const FORK = 0x40000000; |
| 10102 | /// process exec'd |
| 10103 | pub const EXEC = 0x20000000; |
| 10104 | /// shared with EVFILT_SIGNAL |
| 10105 | pub const SIGNAL = 0x08000000; |
| 10106 | /// exit status to be returned, valid for child process only |
| 10107 | pub const EXITSTATUS = 0x04000000; |
| 10108 | /// provide details on reasons for exit |
| 10109 | pub const EXIT_DETAIL = 0x02000000; |
| 10110 | /// mask for signal & exit status |
| 10111 | pub const PDATAMASK = 0x000fffff; |
| 10112 | pub const PCTRLMASK = 0xf0000000; |
| 10113 | pub const EXIT_DETAIL_MASK = 0x00070000; |
| 10114 | pub const EXIT_DECRYPTFAIL = 0x00010000; |
| 10115 | pub const EXIT_MEMORY = 0x00020000; |
| 10116 | pub const EXIT_CSERROR = 0x00040000; |
| 10117 | /// will react on memory pressure |
| 10118 | pub const VM_PRESSURE = 0x80000000; |
| 10119 | /// will quit on memory pressure, possibly after cleaning up dirty state |
| 10120 | pub const VM_PRESSURE_TERMINATE = 0x40000000; |
| 10121 | /// will quit immediately on memory pressure |
| 10122 | pub const VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; |
| 10123 | /// there was an error |
| 10124 | pub const VM_ERROR = 0x10000000; |
| 10125 | /// data is seconds |
| 10126 | pub const SECONDS = 0x00000001; |
| 10127 | /// data is microseconds |
| 10128 | pub const USECONDS = 0x00000002; |
| 10129 | /// data is nanoseconds |
| 10130 | pub const NSECONDS = 0x00000004; |
| 10131 | /// absolute timeout |
| 10132 | pub const ABSOLUTE = 0x00000008; |
| 10133 | /// ext[1] holds leeway for power aware timers |
| 10134 | pub const LEEWAY = 0x00000010; |
| 10135 | /// system does minimal timer coalescing |
| 10136 | pub const CRITICAL = 0x00000020; |
| 10137 | /// system does maximum timer coalescing |
| 10138 | pub const BACKGROUND = 0x00000040; |
| 10139 | /// with ABSOLUTE: causes the timer to continue to tick across sleep, still uses gettimeofday epoch |
| 10140 | /// with MACHTIME and ABSOLUTE: uses mach continuous time epoch |
| 10141 | /// without ABSOLUTE: continues to tick across sleep |
| 10142 | pub const MACH_CONTINUOUS_TIME = 0x00000080; |
| 10143 | /// data is mach absolute time units |
| 10144 | pub const MACHTIME = 0x00000100; |
| 10145 | }, |
| 10146 | .dragonfly => struct { |
| 10147 | pub const FFNOP = 0; |
| 10148 | pub const TRACK = 1; |
| 10149 | pub const DELETE = 1; |
| 10150 | pub const LOWAT = 1; |
| 10151 | pub const TRACKERR = 2; |
| 10152 | pub const OOB = 2; |
| 10153 | pub const WRITE = 2; |
| 10154 | pub const EXTEND = 4; |
| 10155 | pub const CHILD = 4; |
| 10156 | pub const ATTRIB = 8; |
| 10157 | pub const LINK = 16; |
| 10158 | pub const RENAME = 32; |
| 10159 | pub const REVOKE = 64; |
| 10160 | pub const PDATAMASK = 1048575; |
| 10161 | pub const FFLAGSMASK = 16777215; |
| 10162 | pub const TRIGGER = 16777216; |
| 10163 | pub const EXEC = 536870912; |
| 10164 | pub const FFAND = 1073741824; |
| 10165 | pub const FORK = 1073741824; |
| 10166 | pub const EXIT = 2147483648; |
| 10167 | pub const FFOR = 2147483648; |
| 10168 | pub const FFCTRLMASK = 3221225472; |
| 10169 | pub const FFCOPY = 3221225472; |
| 10170 | pub const PCTRLMASK = 4026531840; |
| 10171 | }, |
| 10172 | .netbsd => struct { |
| 10173 | /// ignore input fflags |
| 10174 | pub const FFNOP = 0x00000000; |
| 10175 | /// AND fflags |
| 10176 | pub const FFAND = 0x40000000; |
| 10177 | /// OR fflags |
| 10178 | pub const FFOR = 0x80000000; |
| 10179 | /// copy fflags |
| 10180 | pub const FFCOPY = 0xc0000000; |
| 10181 | /// masks for operations |
| 10182 | pub const FFCTRLMASK = 0xc0000000; |
| 10183 | pub const FFLAGSMASK = 0x00ffffff; |
| 10184 | /// On input, TRIGGER causes the event to be triggered for output. |
| 10185 | pub const TRIGGER = 0x01000000; |
| 10186 | /// low water mark |
| 10187 | pub const LOWAT = 0x00000001; |
| 10188 | /// vnode was removed |
| 10189 | pub const DELETE = 0x00000001; |
| 10190 | /// data contents changed |
| 10191 | pub const WRITE = 0x00000002; |
| 10192 | /// size increased |
| 10193 | pub const EXTEND = 0x00000004; |
| 10194 | /// attributes changed |
| 10195 | pub const ATTRIB = 0x00000008; |
| 10196 | /// link count changed |
| 10197 | pub const LINK = 0x00000010; |
| 10198 | /// vnode was renamed |
| 10199 | pub const RENAME = 0x00000020; |
| 10200 | /// vnode access was revoked |
| 10201 | pub const REVOKE = 0x00000040; |
| 10202 | /// vnode was opened |
| 10203 | pub const OPEN = 0x00000080; |
| 10204 | /// file closed (no FWRITE) |
| 10205 | pub const CLOSE = 0x00000100; |
| 10206 | /// file closed (FWRITE) |
| 10207 | pub const CLOSE_WRITE = 0x00000200; |
| 10208 | /// file was read |
| 10209 | pub const READ = 0x00000400; |
| 10210 | /// process exited |
| 10211 | pub const EXIT = 0x80000000; |
| 10212 | /// process forked |
| 10213 | pub const FORK = 0x40000000; |
| 10214 | /// process exec'd |
| 10215 | pub const EXEC = 0x20000000; |
| 10216 | /// mask for signal & exit status |
| 10217 | pub const PDATAMASK = 0x000fffff; |
| 10218 | pub const PCTRLMASK = 0xf0000000; |
| 10219 | /// follow across forks |
| 10220 | pub const TRACK = 0x00000001; |
| 10221 | /// could not track child |
| 10222 | pub const TRACKERR = 0x00000002; |
| 10223 | /// am a child process |
| 10224 | pub const CHILD = 0x00000004; |
| 10225 | /// shared with EVFILT_SIGNAL |
| 10226 | pub const SIGNAL = 0x08000000; |
| 10227 | /// data is milliseconds |
| 10228 | pub const MSECONDS = 0x00000000; |
| 10229 | /// data is seconds |
| 10230 | pub const SECONDS = 0x00000001; |
| 10231 | /// data is microseconds |
| 10232 | pub const USECONDS = 0x00000002; |
| 10233 | /// data is nanoseconds |
| 10234 | pub const NSECONDS = 0x00000003; |
| 10235 | /// timeout is absolute |
| 10236 | pub const ABSTIME = 0x00000010; |
| 10237 | }, |
| 10238 | .freebsd => struct { |
| 10239 | /// On input, TRIGGER causes the event to be triggered for output. |
| 10240 | pub const TRIGGER = 0x01000000; |
| 10241 | /// ignore input fflags |
| 10242 | pub const FFNOP = 0x00000000; |
| 10243 | /// and fflags |
| 10244 | pub const FFAND = 0x40000000; |
| 10245 | /// or fflags |
| 10246 | pub const FFOR = 0x80000000; |
| 10247 | /// copy fflags |
| 10248 | pub const FFCOPY = 0xc0000000; |
| 10249 | /// mask for operations |
| 10250 | pub const FFCTRLMASK = 0xc0000000; |
| 10251 | pub const FFLAGSMASK = 0x00ffffff; |
| 10252 | /// low water mark |
| 10253 | pub const LOWAT = 0x00000001; |
| 10254 | /// behave like poll() |
| 10255 | pub const FILE_POLL = 0x00000002; |
| 10256 | /// vnode was removed |
| 10257 | pub const DELETE = 0x00000001; |
| 10258 | /// data contents changed |
| 10259 | pub const WRITE = 0x00000002; |
| 10260 | /// size increased |
| 10261 | pub const EXTEND = 0x00000004; |
| 10262 | /// attributes changed |
| 10263 | pub const ATTRIB = 0x00000008; |
| 10264 | /// link count changed |
| 10265 | pub const LINK = 0x00000010; |
| 10266 | /// vnode was renamed |
| 10267 | pub const RENAME = 0x00000020; |
| 10268 | /// vnode access was revoked |
| 10269 | pub const REVOKE = 0x00000040; |
| 10270 | /// vnode was opened |
| 10271 | pub const OPEN = 0x00000080; |
| 10272 | /// file closed, fd did not allow write |
| 10273 | pub const CLOSE = 0x00000100; |
| 10274 | /// file closed, fd did allow write |
| 10275 | pub const CLOSE_WRITE = 0x00000200; |
| 10276 | /// file was read |
| 10277 | pub const READ = 0x00000400; |
| 10278 | /// process exited |
| 10279 | pub const EXIT = 0x80000000; |
| 10280 | /// process forked |
| 10281 | pub const FORK = 0x40000000; |
| 10282 | /// process exec'd |
| 10283 | pub const EXEC = 0x20000000; |
| 10284 | /// mask for signal & exit status |
| 10285 | pub const PDATAMASK = 0x000fffff; |
| 10286 | pub const PCTRLMASK = 0xf0000000; |
| 10287 | /// data is seconds |
| 10288 | pub const SECONDS = 0x00000001; |
| 10289 | /// data is milliseconds |
| 10290 | pub const MSECONDS = 0x00000002; |
| 10291 | /// data is microseconds |
| 10292 | pub const USECONDS = 0x00000004; |
| 10293 | /// data is nanoseconds |
| 10294 | pub const NSECONDS = 0x00000008; |
| 10295 | /// timeout is absolute |
| 10296 | pub const ABSTIME = 0x00000010; |
| 10297 | }, |
| 10298 | .openbsd => struct { |
| 10299 | // data/hint flags for EVFILT.{READ|WRITE} |
| 10300 | pub const LOWAT = 0x0001; |
| 10301 | pub const EOF = 0x0002; |
| 10302 | // data/hint flags for EVFILT.EXCEPT and EVFILT.{READ|WRITE} |
| 10303 | pub const OOB = 0x0004; |
| 10304 | // data/hint flags for EVFILT.VNODE |
| 10305 | pub const DELETE = 0x0001; |
| 10306 | pub const WRITE = 0x0002; |
| 10307 | pub const EXTEND = 0x0004; |
| 10308 | pub const ATTRIB = 0x0008; |
| 10309 | pub const LINK = 0x0010; |
| 10310 | pub const RENAME = 0x0020; |
| 10311 | pub const REVOKE = 0x0040; |
| 10312 | pub const TRUNCATE = 0x0080; |
| 10313 | // data/hint flags for EVFILT.PROC |
| 10314 | pub const EXIT = 0x80000000; |
| 10315 | pub const FORK = 0x40000000; |
| 10316 | pub const EXEC = 0x20000000; |
| 10317 | pub const PDATAMASK = 0x000fffff; |
| 10318 | pub const PCTRLMASK = 0xf0000000; |
| 10319 | pub const TRACK = 0x00000001; |
| 10320 | pub const TRACKERR = 0x00000002; |
| 10321 | pub const CHILD = 0x00000004; |
| 10322 | // data/hint flags for EVFILT.DEVICE |
| 10323 | pub const CHANGE = 0x00000001; |
| 10324 | // data/hint flags for EVFILT_USER |
| 10325 | pub const FFNOP = 0x00000000; |
| 10326 | pub const FFAND = 0x40000000; |
| 10327 | pub const FFOR = 0x80000000; |
| 10328 | pub const FFCOPY = 0xc0000000; |
| 10329 | pub const FFCTRLMASK = 0xc0000000; |
| 10330 | pub const FFLAGSMASK = 0x00ffffff; |
| 10331 | pub const TRIGGER = 0x01000000; |
| 10332 | }, |
| 10333 | else => void, |
| 10334 | }; |
| 10335 | |
| 10336 | pub const FUTEX = switch (native_os) { |
| 10337 | .openbsd => openbsd.FUTEX, |
| 10338 | .serenity => serenity.FUTEX, |
| 10339 | else => void, |
| 10340 | }; |
| 10341 | |
| 10342 | pub const MFD = switch (native_os) { |
| 10343 | .linux => linux.MFD, |
| 10344 | .freebsd => freebsd.MFD, |
| 10345 | else => void, |
| 10346 | }; |
| 10347 | |
| 10348 | // Unix-like systems |
| 10349 | pub const DIR = opaque {}; |
| 10350 | pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR; |
| 10351 | pub extern "c" fn fdopendir(fd: c_int) ?*DIR; |
| 10352 | pub extern "c" fn rewinddir(dp: *DIR) void; |
| 10353 | pub extern "c" fn closedir(dp: *DIR) c_int; |
| 10354 | pub extern "c" fn telldir(dp: *DIR) c_long; |
| 10355 | pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void; |
| 10356 | |
| 10357 | pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int; |
| 10358 | |
| 10359 | pub extern "c" fn alarm(seconds: c_uint) c_uint; |
| 10360 | |
| 10361 | pub const close = switch (native_os) { |
| 10362 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.@"close$NOCANCEL", |
| 10363 | else => private.close, |
| 10364 | }; |
| 10365 | |
| 10366 | pub const clock_getres = switch (native_os) { |
| 10367 | .netbsd => private.__clock_getres50, |
| 10368 | else => private.clock_getres, |
| 10369 | }; |
| 10370 | |
| 10371 | pub const clock_gettime = switch (native_os) { |
| 10372 | .netbsd => private.__clock_gettime50, |
| 10373 | else => private.clock_gettime, |
| 10374 | }; |
| 10375 | |
| 10376 | pub const fstat = switch (native_os) { |
| 10377 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) { |
| 10378 | .x86_64 => private.@"fstat$INODE64", |
| 10379 | else => private.fstat, |
| 10380 | }, |
| 10381 | .netbsd => private.__fstat50, |
| 10382 | .linux => {}, |
| 10383 | else => private.fstat, |
| 10384 | }; |
| 10385 | |
| 10386 | pub const fstatat = switch (native_os) { |
| 10387 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) { |
| 10388 | .x86_64 => private.@"fstatat$INODE64", |
| 10389 | else => private.fstatat, |
| 10390 | }, |
| 10391 | .linux => {}, |
| 10392 | else => private.fstatat, |
| 10393 | }; |
| 10394 | |
| 10395 | pub extern "c" fn statx(dirfd: fd_t, path: [*:0]const u8, flags: u32, mask: linux.STATX, buf: *linux.Statx) c_int; |
| 10396 | |
| 10397 | pub extern "c" fn getpwent() ?*passwd; |
| 10398 | pub extern "c" fn endpwent() void; |
| 10399 | pub extern "c" fn setpwent() void; |
| 10400 | pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd; |
| 10401 | pub extern "c" fn getpwnam_r(name: [*:0]const u8, pwd: *passwd, buf: [*]u8, buflen: usize, result: *?*passwd) c_int; |
| 10402 | pub extern "c" fn getpwuid(uid: uid_t) ?*passwd; |
| 10403 | pub extern "c" fn getpwuid_r(uid: uid_t, pwd: *passwd, buf: [*]u8, buflen: usize, result: *?*passwd) c_int; |
| 10404 | pub extern "c" fn getgrent() ?*group; |
| 10405 | pub extern "c" fn setgrent() void; |
| 10406 | pub extern "c" fn endgrent() void; |
| 10407 | pub extern "c" fn getgrnam(name: [*:0]const u8) ?*group; |
| 10408 | pub extern "c" fn getgrnam_r(name: [*:0]const u8, grp: *group, buf: [*]u8, buflen: usize, result: *?*group) c_int; |
| 10409 | pub extern "c" fn getgrgid(gid: gid_t) ?*group; |
| 10410 | pub extern "c" fn getgrgid_r(gid: gid_t, grp: *group, buf: [*]u8, buflen: usize, result: *?*group) c_int; |
| 10411 | pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int; |
| 10412 | pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64; |
| 10413 | pub extern "c" fn mmap64(addr: ?*align(page_size) anyopaque, len: usize, prot: PROT, flags: MAP, fd: fd_t, offset: i64) *anyopaque; |
| 10414 | pub extern "c" fn open64(path: [*:0]const u8, oflag: O, ...) c_int; |
| 10415 | pub extern "c" fn openat64(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; |
| 10416 | pub extern "c" fn pread64(fd: fd_t, buf: [*]u8, nbyte: usize, offset: i64) isize; |
| 10417 | pub extern "c" fn preadv64(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: i64) isize; |
| 10418 | pub extern "c" fn pwrite64(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: i64) isize; |
| 10419 | pub extern "c" fn pwritev64(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: i64) isize; |
| 10420 | pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: usize) isize; |
| 10421 | pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int; |
| 10422 | |
| 10423 | pub const arc4random_buf = switch (native_os) { |
| 10424 | .linux => if (builtin.abi.isAndroid() or |
| 10425 | (builtin.abi.isGnu() and versionCheck(.{ .major = 2, .minor = 36, .patch = 0 }))) |
| 10426 | private.arc4random_buf |
| 10427 | else {}, |
| 10428 | .dragonfly, .netbsd, .freebsd, .illumos, .openbsd, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.arc4random_buf, |
| 10429 | else => {}, |
| 10430 | }; |
| 10431 | pub const getentropy = switch (native_os) { |
| 10432 | .linux => if (builtin.abi.isAndroid() and versionCheck(.{ .major = 28, .minor = 0, .patch = 0 })) private.getentropy else {}, |
| 10433 | .emscripten => private.getentropy, |
| 10434 | else => {}, |
| 10435 | }; |
| 10436 | pub const getrandom = switch (native_os) { |
| 10437 | .freebsd => private.getrandom, |
| 10438 | .linux => if (builtin.abi.isMusl() or |
| 10439 | (builtin.abi.isGnu() and versionCheck(.{ .major = 2, .minor = 25, .patch = 0 })) or |
| 10440 | (builtin.abi.isAndroid() and versionCheck(.{ .major = 28, .minor = 0, .patch = 0 }))) |
| 10441 | private.getrandom |
| 10442 | else {}, |
| 10443 | else => {}, |
| 10444 | }; |
| 10445 | |
| 10446 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; |
| 10447 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; |
| 10448 | |
| 10449 | pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int; |
| 10450 | pub extern "c" fn epoll_create1(flags: c_uint) c_int; |
| 10451 | pub extern "c" fn epoll_wait(epfd: fd_t, events: [*]epoll_event, maxevents: c_uint, timeout: c_int) c_int; |
| 10452 | pub extern "c" fn epoll_pwait( |
| 10453 | epfd: fd_t, |
| 10454 | events: [*]epoll_event, |
| 10455 | maxevents: c_int, |
| 10456 | timeout: c_int, |
| 10457 | sigmask: *const sigset_t, |
| 10458 | ) c_int; |
| 10459 | |
| 10460 | pub extern "c" fn timerfd_create(clockid: timerfd_clockid_t, flags: c_int) c_int; |
| 10461 | pub extern "c" fn timerfd_settime( |
| 10462 | fd: c_int, |
| 10463 | flags: c_int, |
| 10464 | new_value: *const itimerspec, |
| 10465 | old_value: ?*itimerspec, |
| 10466 | ) c_int; |
| 10467 | pub extern "c" fn timerfd_gettime(fd: c_int, curr_value: *itimerspec) c_int; |
| 10468 | |
| 10469 | pub extern "c" fn inotify_init1(flags: c_uint) c_int; |
| 10470 | pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) c_int; |
| 10471 | pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int; |
| 10472 | |
| 10473 | pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; |
| 10474 | pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; |
| 10475 | pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int; |
| 10476 | pub extern "c" fn fallocate(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; |
| 10477 | pub const sendfile = switch (native_os) { |
| 10478 | .freebsd => freebsd.sendfile, |
| 10479 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.sendfile, |
| 10480 | .linux => private.sendfile, |
| 10481 | else => {}, |
| 10482 | }; |
| 10483 | /// See std.elf for constants for this |
| 10484 | pub extern "c" fn getauxval(__type: c_ulong) c_ulong; |
| 10485 | |
| 10486 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int; |
| 10487 | |
| 10488 | pub const sigaltstack = switch (native_os) { |
| 10489 | .netbsd => private.__sigaltstack14, |
| 10490 | else => private.sigaltstack, |
| 10491 | }; |
| 10492 | |
| 10493 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; |
| 10494 | pub const pipe2 = switch (native_os) { |
| 10495 | .dragonfly, .emscripten, .netbsd, .freebsd, .illumos, .openbsd, .linux, .serenity => private.pipe2, |
| 10496 | else => {}, |
| 10497 | }; |
| 10498 | pub const copy_file_range = switch (native_os) { |
| 10499 | .linux => private.copy_file_range, |
| 10500 | .freebsd => freebsd.copy_file_range, |
| 10501 | else => {}, |
| 10502 | }; |
| 10503 | |
| 10504 | pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int; |
| 10505 | |
| 10506 | pub extern "c" fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: *const rlimit, old_limit: *rlimit) c_int; |
| 10507 | pub extern "c" fn mincore( |
| 10508 | addr: *align(page_size) anyopaque, |
| 10509 | length: usize, |
| 10510 | vec: [*]u8, |
| 10511 | ) c_int; |
| 10512 | |
| 10513 | pub extern "c" fn madvise( |
| 10514 | addr: *align(page_size) anyopaque, |
| 10515 | length: usize, |
| 10516 | advice: u32, |
| 10517 | ) c_int; |
| 10518 | |
| 10519 | pub const getdirentries = switch (native_os) { |
| 10520 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.__getdirentries64, |
| 10521 | else => private.getdirentries, |
| 10522 | }; |
| 10523 | |
| 10524 | pub const getdents = switch (native_os) { |
| 10525 | .netbsd => private.__getdents30, |
| 10526 | else => private.getdents, |
| 10527 | }; |
| 10528 | |
| 10529 | pub const getrusage = switch (native_os) { |
| 10530 | .netbsd => private.__getrusage50, |
| 10531 | else => private.getrusage, |
| 10532 | }; |
| 10533 | |
| 10534 | pub const gettimeofday = switch (native_os) { |
| 10535 | .netbsd => private.__gettimeofday50, |
| 10536 | else => private.gettimeofday, |
| 10537 | }; |
| 10538 | |
| 10539 | pub const mlock = switch (native_os) { |
| 10540 | .windows, .wasi => {}, |
| 10541 | else => private.mlock, |
| 10542 | }; |
| 10543 | |
| 10544 | pub const mlock2 = switch (native_os) { |
| 10545 | .linux => private.mlock2, |
| 10546 | else => {}, |
| 10547 | }; |
| 10548 | |
| 10549 | pub const munlock = switch (native_os) { |
| 10550 | .windows, .wasi => {}, |
| 10551 | else => private.munlock, |
| 10552 | }; |
| 10553 | |
| 10554 | pub const mlockall = switch (native_os) { |
| 10555 | .linux, .freebsd, .dragonfly, .netbsd, .openbsd, .illumos => private.mlockall, |
| 10556 | else => {}, |
| 10557 | }; |
| 10558 | |
| 10559 | pub const munlockall = switch (native_os) { |
| 10560 | .linux, .freebsd, .dragonfly, .netbsd, .openbsd, .illumos => private.munlockall, |
| 10561 | else => {}, |
| 10562 | }; |
| 10563 | |
| 10564 | pub const msync = switch (native_os) { |
| 10565 | .netbsd => private.__msync13, |
| 10566 | else => private.msync, |
| 10567 | }; |
| 10568 | |
| 10569 | pub const nanosleep = switch (native_os) { |
| 10570 | .netbsd => private.__nanosleep50, |
| 10571 | else => private.nanosleep, |
| 10572 | }; |
| 10573 | |
| 10574 | pub const readdir = switch (native_os) { |
| 10575 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) { |
| 10576 | .x86_64 => private.@"readdir$INODE64", |
| 10577 | else => private.readdir, |
| 10578 | }, |
| 10579 | .windows => {}, |
| 10580 | else => private.readdir, |
| 10581 | }; |
| 10582 | |
| 10583 | pub const realpath = switch (native_os) { |
| 10584 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.@"realpath$DARWIN_EXTSN", |
| 10585 | else => private.realpath, |
| 10586 | }; |
| 10587 | |
| 10588 | pub const sched_yield = switch (native_os) { |
| 10589 | .netbsd => private.__libc_thr_yield, |
| 10590 | else => private.sched_yield, |
| 10591 | }; |
| 10592 | |
| 10593 | pub const sigaction = switch (native_os) { |
| 10594 | .netbsd => private.__sigaction14, |
| 10595 | else => private.sigaction, |
| 10596 | }; |
| 10597 | |
| 10598 | /// Zig's version of SIGRTMIN. Actually a function. |
| 10599 | pub const sigrtmin = switch (native_os) { |
| 10600 | .openbsd => {}, |
| 10601 | else => sigrt_private.sigrtmin, |
| 10602 | }; |
| 10603 | |
| 10604 | /// Zig's version of SIGRTMAX. Actually a function. |
| 10605 | pub const sigrtmax = switch (native_os) { |
| 10606 | .openbsd => {}, |
| 10607 | else => sigrt_private.sigrtmax, |
| 10608 | }; |
| 10609 | |
| 10610 | const sigrt_private = struct { |
| 10611 | pub fn sigrtmin() u8 { |
| 10612 | return switch (native_os) { |
| 10613 | .freebsd => 65, |
| 10614 | .netbsd => 33, |
| 10615 | .illumos => @truncate(sysconf(@backingInt(_SC.SIGRT_MIN))), |
| 10616 | .haiku => @truncate(@as(c_uint, @bitCast(private.__signal_get_sigrtmin()))), |
| 10617 | else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmin()))), |
| 10618 | }; |
| 10619 | } |
| 10620 | |
| 10621 | pub fn sigrtmax() u8 { |
| 10622 | return switch (native_os) { |
| 10623 | .freebsd => 126, |
| 10624 | .netbsd => 63, |
| 10625 | .illumos => @truncate(sysconf(@backingInt(_SC.SIGRT_MAX))), |
| 10626 | .haiku => @truncate(@as(c_uint, @bitCast(private.__signal_get_sigrtmax()))), |
| 10627 | else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmax()))), |
| 10628 | }; |
| 10629 | } |
| 10630 | }; |
| 10631 | |
| 10632 | pub const sigfillset = switch (native_os) { |
| 10633 | .netbsd => private.__sigfillset14, |
| 10634 | else => private.sigfillset, |
| 10635 | }; |
| 10636 | |
| 10637 | pub const sigaddset = private.sigaddset; |
| 10638 | pub const sigemptyset = switch (native_os) { |
| 10639 | .netbsd => private.__sigemptyset14, |
| 10640 | else => private.sigemptyset, |
| 10641 | }; |
| 10642 | pub const sigdelset = private.sigdelset; |
| 10643 | pub const sigismember = private.sigismember; |
| 10644 | |
| 10645 | pub const sigprocmask = switch (native_os) { |
| 10646 | .netbsd => private.__sigprocmask14, |
| 10647 | else => private.sigprocmask, |
| 10648 | }; |
| 10649 | |
| 10650 | pub const socket = switch (native_os) { |
| 10651 | .netbsd => private.__socket30, |
| 10652 | else => private.socket, |
| 10653 | }; |
| 10654 | |
| 10655 | pub const socketpair = switch (native_os) { |
| 10656 | // https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/#unsupported\unavailable: |
| 10657 | .windows => {}, |
| 10658 | else => private.socketpair, |
| 10659 | }; |
| 10660 | |
| 10661 | pub const stat = switch (native_os) { |
| 10662 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) { |
| 10663 | .x86_64 => private.@"stat$INODE64", |
| 10664 | else => private.stat, |
| 10665 | }, |
| 10666 | else => private.stat, |
| 10667 | }; |
| 10668 | |
| 10669 | pub const _msize = switch (native_os) { |
| 10670 | .windows => private._msize, |
| 10671 | else => {}, |
| 10672 | }; |
| 10673 | pub const malloc_size = switch (native_os) { |
| 10674 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => private.malloc_size, |
| 10675 | else => {}, |
| 10676 | }; |
| 10677 | pub const malloc_usable_size = switch (native_os) { |
| 10678 | .freebsd, .linux, .serenity => private.malloc_usable_size, |
| 10679 | else => {}, |
| 10680 | }; |
| 10681 | pub const posix_memalign = switch (native_os) { |
| 10682 | .dragonfly, .netbsd, .freebsd, .illumos, .openbsd, .linux, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => private.posix_memalign, |
| 10683 | else => {}, |
| 10684 | }; |
| 10685 | pub const sysconf = switch (native_os) { |
| 10686 | .illumos => illumos.sysconf, |
| 10687 | else => private.sysconf, |
| 10688 | }; |
| 10689 | |
| 10690 | pub const sf_hdtr = switch (native_os) { |
| 10691 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 10692 | headers: ?[*]const iovec_const, |
| 10693 | hdr_cnt: c_int, |
| 10694 | trailers: ?[*]const iovec_const, |
| 10695 | trl_cnt: c_int, |
| 10696 | }, |
| 10697 | else => void, |
| 10698 | }; |
| 10699 | |
| 10700 | pub const flock = switch (native_os) { |
| 10701 | .windows, .wasi => {}, |
| 10702 | else => private.flock, |
| 10703 | }; |
| 10704 | |
| 10705 | pub const futex = switch (native_os) { |
| 10706 | .openbsd => openbsd.futex, |
| 10707 | .serenity => serenity.futex, |
| 10708 | else => {}, |
| 10709 | }; |
| 10710 | |
| 10711 | pub extern "c" var environ: [*:null]?[*:0]u8; |
| 10712 | |
| 10713 | pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; |
| 10714 | pub extern "c" fn fclose(stream: *FILE) c_int; |
| 10715 | pub extern "c" fn fwrite(noalias ptr: [*]const u8, size_of_type: usize, item_count: usize, noalias stream: *FILE) usize; |
| 10716 | pub extern "c" fn fread(noalias ptr: [*]u8, size_of_type: usize, item_count: usize, noalias stream: *FILE) usize; |
| 10717 | |
| 10718 | pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; |
| 10719 | pub extern "c" fn abort() noreturn; |
| 10720 | pub extern "c" fn exit(code: c_int) noreturn; |
| 10721 | pub extern "c" fn _Exit(code: c_int) noreturn; |
| 10722 | pub extern "c" fn _exit(code: c_int) noreturn; |
| 10723 | pub extern "c" fn isatty(fd: fd_t) c_int; |
| 10724 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; |
| 10725 | pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int; |
| 10726 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; |
| 10727 | pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int; |
| 10728 | pub extern "c" fn raise(sig: SIG) c_int; |
| 10729 | pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize; |
| 10730 | pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; |
| 10731 | pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize; |
| 10732 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize; |
| 10733 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; |
| 10734 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize; |
| 10735 | pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; |
| 10736 | pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize; |
| 10737 | pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: PROT, flags: MAP, fd: fd_t, offset: off_t) *anyopaque; |
| 10738 | pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int; |
| 10739 | pub extern "c" fn mremap(addr: ?*align(page_size) const anyopaque, old_len: usize, new_len: usize, flags: MREMAP, ...) *anyopaque; |
| 10740 | pub extern "c" fn mprotect(addr: *align(page_size) anyopaque, len: usize, prot: PROT) c_int; |
| 10741 | pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) c_int; |
| 10742 | pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_uint) c_int; |
| 10743 | pub extern "c" fn unlink(path: [*:0]const u8) c_int; |
| 10744 | pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int; |
| 10745 | pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8; |
| 10746 | pub extern "c" fn waitpid(pid: pid_t, status: ?*c_int, options: c_int) pid_t; |
| 10747 | |
| 10748 | pub const wait4 = switch (native_os) { |
| 10749 | .netbsd => private.__wait450, |
| 10750 | else => private.wait4, |
| 10751 | }; |
| 10752 | |
| 10753 | pub const fork = switch (native_os) { |
| 10754 | .dragonfly, |
| 10755 | .freebsd, |
| 10756 | .linux, |
| 10757 | .driverkit, |
| 10758 | .ios, |
| 10759 | .maccatalyst, |
| 10760 | .macos, |
| 10761 | .tvos, |
| 10762 | .visionos, |
| 10763 | .watchos, |
| 10764 | .netbsd, |
| 10765 | .openbsd, |
| 10766 | .illumos, |
| 10767 | .haiku, |
| 10768 | .serenity, |
| 10769 | => private.fork, |
| 10770 | else => {}, |
| 10771 | }; |
| 10772 | pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int; |
| 10773 | pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int; |
| 10774 | pub extern "c" fn pipe(fds: *[2]fd_t) c_int; |
| 10775 | pub extern "c" fn mkdir(path: [*:0]const u8, mode: mode_t) c_int; |
| 10776 | pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) c_int; |
| 10777 | pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int; |
| 10778 | pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int; |
| 10779 | pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int; |
| 10780 | pub extern "c" fn renameat(olddirfd: fd_t, old: [*:0]const u8, newdirfd: fd_t, new: [*:0]const u8) c_int; |
| 10781 | pub extern "c" fn chdir(path: [*:0]const u8) c_int; |
| 10782 | pub extern "c" fn fchdir(fd: fd_t) c_int; |
| 10783 | pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; |
| 10784 | pub extern "c" fn dup(fd: fd_t) c_int; |
| 10785 | pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; |
| 10786 | pub extern "c" fn dup3(old: c_int, new: c_int, flags: c_uint) c_int; |
| 10787 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 10788 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 10789 | pub extern "c" fn chmod(path: [*:0]const u8, mode: mode_t) c_int; |
| 10790 | pub extern "c" fn fchmod(fd: fd_t, mode: mode_t) c_int; |
| 10791 | pub extern "c" fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: c_uint) c_int; |
| 10792 | pub extern "c" fn fchown(fd: fd_t, owner: uid_t, group: gid_t) c_int; |
| 10793 | pub extern "c" fn fchownat(fd: fd_t, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: c_uint) c_int; |
| 10794 | pub extern "c" fn umask(mode: mode_t) mode_t; |
| 10795 | |
| 10796 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; |
| 10797 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; |
| 10798 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int; |
| 10799 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int; |
| 10800 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
| 10801 | pub extern "c" fn tcgetattr(fd: fd_t, termios_p: *termios) c_int; |
| 10802 | pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int; |
| 10803 | pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int; |
| 10804 | pub extern "c" fn uname(buf: *utsname) c_int; |
| 10805 | |
| 10806 | pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int; |
| 10807 | pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int; |
| 10808 | pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int; |
| 10809 | pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int; |
| 10810 | pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; |
| 10811 | pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; |
| 10812 | pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int; |
| 10813 | pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int; |
| 10814 | pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int; |
| 10815 | pub extern "c" fn getsockopt(sockfd: fd_t, level: i32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *socklen_t) c_int; |
| 10816 | pub extern "c" fn setsockopt(sockfd: fd_t, level: i32, optname: u32, optval: ?*const anyopaque, optlen: socklen_t) c_int; |
| 10817 | pub extern "c" fn send(sockfd: fd_t, buf: *const anyopaque, len: usize, flags: u32) isize; |
| 10818 | pub extern "c" fn sendto( |
| 10819 | sockfd: fd_t, |
| 10820 | buf: *const anyopaque, |
| 10821 | len: usize, |
| 10822 | flags: u32, |
| 10823 | dest_addr: ?*const sockaddr, |
| 10824 | addrlen: socklen_t, |
| 10825 | ) isize; |
| 10826 | pub extern "c" fn sendmsg(sockfd: fd_t, msg: *const msghdr_const, flags: u32) isize; |
| 10827 | pub extern "c" fn sendmmsg(sockfd: fd_t, msgvec: [*]mmsghdr, n: c_uint, flags: u32) c_int; |
| 10828 | |
| 10829 | pub extern "c" fn recv( |
| 10830 | sockfd: fd_t, |
| 10831 | arg1: ?*anyopaque, |
| 10832 | arg2: usize, |
| 10833 | arg3: c_int, |
| 10834 | ) if (native_os == .windows) c_int else isize; |
| 10835 | pub extern "c" fn recvfrom( |
| 10836 | sockfd: fd_t, |
| 10837 | noalias buf: *anyopaque, |
| 10838 | len: usize, |
| 10839 | flags: u32, |
| 10840 | noalias src_addr: ?*sockaddr, |
| 10841 | noalias addrlen: ?*socklen_t, |
| 10842 | ) if (native_os == .windows) c_int else isize; |
| 10843 | |
| 10844 | pub const recvmsg = switch (native_os) { |
| 10845 | .windows => {}, |
| 10846 | else => private.recvmsg, |
| 10847 | }; |
| 10848 | |
| 10849 | pub extern "c" fn kill(pid: pid_t, sig: SIG) c_int; |
| 10850 | |
| 10851 | pub extern "c" fn setuid(uid: uid_t) c_int; |
| 10852 | pub extern "c" fn setgid(gid: gid_t) c_int; |
| 10853 | pub extern "c" fn seteuid(euid: uid_t) c_int; |
| 10854 | pub extern "c" fn setegid(egid: gid_t) c_int; |
| 10855 | pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int; |
| 10856 | pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int; |
| 10857 | pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int; |
| 10858 | pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int; |
| 10859 | pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int; |
| 10860 | pub extern "c" fn getuid() uid_t; |
| 10861 | pub extern "c" fn getgid() gid_t; |
| 10862 | pub extern "c" fn geteuid() uid_t; |
| 10863 | pub extern "c" fn getegid() gid_t; |
| 10864 | pub extern "c" fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) c_int; |
| 10865 | pub extern "c" fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) c_int; |
| 10866 | |
| 10867 | pub extern "c" fn malloc(usize) ?*anyopaque; |
| 10868 | pub extern "c" fn calloc(usize, usize) ?*anyopaque; |
| 10869 | pub extern "c" fn realloc(?*anyopaque, usize) ?*anyopaque; |
| 10870 | pub extern "c" fn free(?*anyopaque) void; |
| 10871 | |
| 10872 | pub extern "c" fn futimes(fd: fd_t, times: ?*[2]timeval) c_int; |
| 10873 | pub extern "c" fn utimes(path: [*:0]const u8, times: ?*[2]timeval) c_int; |
| 10874 | |
| 10875 | pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: ?*const [2]timespec, flags: u32) c_int; |
| 10876 | pub extern "c" fn futimens(fd: fd_t, times: ?*const [2]timespec) c_int; |
| 10877 | |
| 10878 | pub extern "c" fn pthread_create( |
| 10879 | noalias newthread: *pthread_t, |
| 10880 | noalias attr: ?*const pthread_attr_t, |
| 10881 | start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque, |
| 10882 | noalias arg: ?*anyopaque, |
| 10883 | ) E; |
| 10884 | pub const pthread_cancelstate = switch (native_os) { |
| 10885 | .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) { |
| 10886 | ENABLE = 1, |
| 10887 | DISABLE = 0, |
| 10888 | }, |
| 10889 | .linux => if (native_abi.isMusl()) enum(c_int) { |
| 10890 | ENABLE = 0, |
| 10891 | DISABLE = 1, |
| 10892 | MASKED = 2, |
| 10893 | } else if (native_abi.isGnu()) enum(c_int) { |
| 10894 | ENABLE = 0, |
| 10895 | DISABLE = 1, |
| 10896 | }, |
| 10897 | else => void, |
| 10898 | }; |
| 10899 | pub extern "c" fn pthread_setcancelstate(pthread_cancelstate, ?*pthread_cancelstate) E; |
| 10900 | pub extern "c" fn pthread_cancel(pthread_t) E; |
| 10901 | pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E; |
| 10902 | pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *anyopaque, stacksize: usize) E; |
| 10903 | pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E; |
| 10904 | pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E; |
| 10905 | pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E; |
| 10906 | pub extern "c" fn pthread_self() pthread_t; |
| 10907 | pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E; |
| 10908 | pub extern "c" fn pthread_detach(thread: pthread_t) E; |
| 10909 | pub extern "c" fn pthread_atfork( |
| 10910 | prepare: ?*const fn () callconv(.c) void, |
| 10911 | parent: ?*const fn () callconv(.c) void, |
| 10912 | child: ?*const fn () callconv(.c) void, |
| 10913 | ) c_int; |
| 10914 | pub extern "c" fn pthread_key_create( |
| 10915 | key: *pthread_key_t, |
| 10916 | destructor: ?*const fn (value: *anyopaque) callconv(.c) void, |
| 10917 | ) E; |
| 10918 | pub extern "c" fn pthread_key_delete(key: pthread_key_t) E; |
| 10919 | pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque; |
| 10920 | pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*anyopaque) c_int; |
| 10921 | pub extern "c" fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *sigset_t) c_int; |
| 10922 | pub const pthread_setname_np = switch (native_os) { |
| 10923 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.pthread_setname_np, |
| 10924 | .illumos => illumos.pthread_setname_np, |
| 10925 | .netbsd => netbsd.pthread_setname_np, |
| 10926 | else => private.pthread_setname_np, |
| 10927 | }; |
| 10928 | |
| 10929 | pub extern "c" fn pthread_getname_np(thread: pthread_t, name: [*:0]u8, len: usize) c_int; |
| 10930 | pub extern "c" fn pthread_kill(pthread_t, signal: SIG) c_int; |
| 10931 | pub extern "c" fn pthread_exit(ptr: ?*anyopaque) noreturn; |
| 10932 | |
| 10933 | pub const pthread_threadid_np = switch (native_os) { |
| 10934 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.pthread_threadid_np, |
| 10935 | else => {}, |
| 10936 | }; |
| 10937 | |
| 10938 | pub const caddr_t = ?[*]u8; |
| 10939 | |
| 10940 | pub const ptrace = switch (native_os) { |
| 10941 | .linux, .serenity => private.ptrace, |
| 10942 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.ptrace, |
| 10943 | .dragonfly => dragonfly.ptrace, |
| 10944 | .freebsd => freebsd.ptrace, |
| 10945 | .netbsd => netbsd.ptrace, |
| 10946 | .openbsd => openbsd.ptrace, |
| 10947 | else => {}, |
| 10948 | }; |
| 10949 | |
| 10950 | pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int; |
| 10951 | pub extern "c" fn sem_destroy(sem: *sem_t) c_int; |
| 10952 | pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: mode_t, value: c_uint) *sem_t; |
| 10953 | pub extern "c" fn sem_close(sem: *sem_t) c_int; |
| 10954 | pub extern "c" fn sem_post(sem: *sem_t) c_int; |
| 10955 | pub extern "c" fn sem_wait(sem: *sem_t) c_int; |
| 10956 | pub extern "c" fn sem_trywait(sem: *sem_t) c_int; |
| 10957 | pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int; |
| 10958 | pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int; |
| 10959 | |
| 10960 | pub const shm_open = switch (native_os) { |
| 10961 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.shm_open, |
| 10962 | else => private.shm_open, |
| 10963 | }; |
| 10964 | pub extern "c" fn shm_unlink(name: [*:0]const u8) c_int; |
| 10965 | |
| 10966 | pub extern "c" fn kqueue() c_int; |
| 10967 | pub extern "c" fn kevent( |
| 10968 | kq: c_int, |
| 10969 | changelist: [*]const Kevent, |
| 10970 | nchanges: c_int, |
| 10971 | eventlist: [*]Kevent, |
| 10972 | nevents: c_int, |
| 10973 | timeout: ?*const timespec, |
| 10974 | ) c_int; |
| 10975 | |
| 10976 | pub extern "c" fn port_create() port_t; |
| 10977 | pub extern "c" fn port_associate( |
| 10978 | port: port_t, |
| 10979 | source: u32, |
| 10980 | object: usize, |
| 10981 | events: u32, |
| 10982 | user_var: ?*anyopaque, |
| 10983 | ) c_int; |
| 10984 | pub extern "c" fn port_dissociate(port: port_t, source: u32, object: usize) c_int; |
| 10985 | pub extern "c" fn port_send(port: port_t, events: u32, user_var: ?*anyopaque) c_int; |
| 10986 | pub extern "c" fn port_sendn( |
| 10987 | ports: [*]port_t, |
| 10988 | errors: []u32, |
| 10989 | num_ports: u32, |
| 10990 | events: u32, |
| 10991 | user_var: ?*anyopaque, |
| 10992 | ) c_int; |
| 10993 | pub extern "c" fn port_get(port: port_t, event: *port_event, timeout: ?*timespec) c_int; |
| 10994 | pub extern "c" fn port_getn( |
| 10995 | port: port_t, |
| 10996 | event_list: []port_event, |
| 10997 | max_events: u32, |
| 10998 | events_retrieved: *u32, |
| 10999 | timeout: ?*timespec, |
| 11000 | ) c_int; |
| 11001 | pub extern "c" fn port_alert(port: port_t, flags: u32, events: u32, user_var: ?*anyopaque) c_int; |
| 11002 | |
| 11003 | pub extern "c" fn getaddrinfo( |
| 11004 | noalias node: ?[*:0]const u8, |
| 11005 | noalias service: ?[*:0]const u8, |
| 11006 | noalias hints: ?*const addrinfo, |
| 11007 | /// On Linux, `res` will not be modified on error and `freeaddrinfo` will |
| 11008 | /// potentially crash if you pass it an undefined pointer |
| 11009 | noalias res: *?*addrinfo, |
| 11010 | ) EAI; |
| 11011 | |
| 11012 | pub extern "c" fn freeaddrinfo(res: *addrinfo) void; |
| 11013 | |
| 11014 | pub extern "c" fn getnameinfo( |
| 11015 | noalias addr: *const sockaddr, |
| 11016 | addrlen: socklen_t, |
| 11017 | noalias host: ?[*]u8, |
| 11018 | hostlen: socklen_t, |
| 11019 | noalias serv: ?[*]u8, |
| 11020 | servlen: socklen_t, |
| 11021 | flags: NI, |
| 11022 | ) EAI; |
| 11023 | |
| 11024 | pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8; |
| 11025 | |
| 11026 | pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int; |
| 11027 | pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int; |
| 11028 | |
| 11029 | pub extern "c" fn dn_expand( |
| 11030 | msg: [*:0]const u8, |
| 11031 | eomorig: [*:0]const u8, |
| 11032 | comp_dn: [*:0]const u8, |
| 11033 | exp_dn: [*:0]u8, |
| 11034 | length: c_int, |
| 11035 | ) c_int; |
| 11036 | |
| 11037 | pub const PTHREAD_PROCESS_PRIVATE: c_int = if (native_os.isDarwin()) |
| 11038 | 2 |
| 11039 | else |
| 11040 | 0; |
| 11041 | |
| 11042 | pub const PTHREAD_PROCESS_SHARED: c_int = 1; |
| 11043 | |
| 11044 | pub extern "c" fn pthread_spin_init(spin: *pthread_spinlock_t, pshared: c_int) c_int; |
| 11045 | pub extern "c" fn pthread_spin_lock(spin: *pthread_spinlock_t) c_int; |
| 11046 | pub extern "c" fn pthread_spin_unlock(spin: *pthread_spinlock_t) c_int; |
| 11047 | pub extern "c" fn pthread_spin_trylock(spin: *pthread_spinlock_t) c_int; |
| 11048 | pub extern "c" fn pthread_spin_destroy(spin: *pthread_spinlock_t) c_int; |
| 11049 | |
| 11050 | pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = .{}; |
| 11051 | pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E; |
| 11052 | pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E; |
| 11053 | pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E; |
| 11054 | pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E; |
| 11055 | |
| 11056 | pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = .{}; |
| 11057 | pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E; |
| 11058 | pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E; |
| 11059 | pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E; |
| 11060 | pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E; |
| 11061 | pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E; |
| 11062 | |
| 11063 | pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 11064 | pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 11065 | pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 11066 | pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 11067 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 11068 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 11069 | |
| 11070 | pub const pthread_t = switch (native_os) { |
| 11071 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L64 |
| 11072 | .serenity => c_int, |
| 11073 | else => *opaque {}, |
| 11074 | }; |
| 11075 | pub const FILE = opaque {}; |
| 11076 | |
| 11077 | pub extern "c" fn dlopen(path: ?[*:0]const u8, mode: RTLD) ?*anyopaque; |
| 11078 | pub extern "c" fn dlclose(handle: *anyopaque) c_int; |
| 11079 | pub extern "c" fn dlsym(handle: ?*anyopaque, symbol: [*:0]const u8) ?*anyopaque; |
| 11080 | pub extern "c" fn dlerror() ?[*:0]u8; |
| 11081 | |
| 11082 | pub const dladdr = if (native_os.isDarwin()) darwin.dladdr else {}; |
| 11083 | pub const dl_info = if (native_os.isDarwin()) darwin.dl_info else {}; |
| 11084 | |
| 11085 | pub extern "c" fn sync() void; |
| 11086 | pub extern "c" fn syncfs(fd: c_int) c_int; |
| 11087 | pub extern "c" fn fsync(fd: c_int) c_int; |
| 11088 | pub extern "c" fn fdatasync(fd: c_int) c_int; |
| 11089 | |
| 11090 | pub extern "c" fn prctl(option: c_int, ...) c_int; |
| 11091 | |
| 11092 | pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int; |
| 11093 | pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int; |
| 11094 | |
| 11095 | pub extern "c" fn fmemopen(noalias buf: ?*anyopaque, size: usize, noalias mode: [*:0]const u8) ?*FILE; |
| 11096 | |
| 11097 | pub extern "c" fn syslog(priority: c_int, message: [*:0]const u8, ...) void; |
| 11098 | pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int) void; |
| 11099 | pub extern "c" fn closelog() void; |
| 11100 | pub extern "c" fn setlogmask(maskpri: c_int) c_int; |
| 11101 | |
| 11102 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; |
| 11103 | |
| 11104 | pub extern "c" fn getpid() pid_t; |
| 11105 | pub extern "c" fn getppid() pid_t; |
| 11106 | pub extern "c" fn setsid() pid_t; |
| 11107 | |
| 11108 | /// These are implementation defined but share identical values in at least musl and glibc: |
| 11109 | /// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18 |
| 11110 | /// - https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/bits/locale.h;h=0fcbb66114be5fef0577dc9047256eb508c45919;hb=c90cfce849d010474e8cccf3e5bff49a2c8b141f#l26 |
| 11111 | pub const LC = enum(c_int) { |
| 11112 | CTYPE = 0, |
| 11113 | NUMERIC = 1, |
| 11114 | TIME = 2, |
| 11115 | COLLATE = 3, |
| 11116 | MONETARY = 4, |
| 11117 | MESSAGES = 5, |
| 11118 | ALL = 6, |
| 11119 | PAPER = 7, |
| 11120 | NAME = 8, |
| 11121 | ADDRESS = 9, |
| 11122 | TELEPHONE = 10, |
| 11123 | MEASUREMENT = 11, |
| 11124 | IDENTIFICATION = 12, |
| 11125 | _, |
| 11126 | }; |
| 11127 | |
| 11128 | pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8; |
| 11129 | |
| 11130 | pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium) |
| 11131 | f64 |
| 11132 | else if (native_os.isDarwin()) |
| 11133 | c_longdouble |
| 11134 | else |
| 11135 | extern struct { |
| 11136 | a: c_longlong, |
| 11137 | b: c_longdouble, |
| 11138 | }; |
| 11139 | |
| 11140 | pub const div_t = extern struct { |
| 11141 | quot: c_int, |
| 11142 | rem: c_int, |
| 11143 | }; |
| 11144 | |
| 11145 | pub const ldiv_t = extern struct { |
| 11146 | quot: c_long, |
| 11147 | rem: c_long, |
| 11148 | }; |
| 11149 | |
| 11150 | pub const lldiv_t = extern struct { |
| 11151 | quot: c_longlong, |
| 11152 | rem: c_longlong, |
| 11153 | }; |
| 11154 | |
| 11155 | pub const imaxdiv_t = extern struct { |
| 11156 | quot: intmax_t, |
| 11157 | rem: intmax_t, |
| 11158 | }; |
| 11159 | |
| 11160 | pub const intmax_t = i64; |
| 11161 | pub const uintmax_t = u64; |
| 11162 | |
| 11163 | pub const wint_t = switch (builtin.target.os.tag) { |
| 11164 | .windows => u16, |
| 11165 | else => i32, |
| 11166 | }; |
| 11167 | |
| 11168 | pub const wchar_t = switch (builtin.target.os.tag) { |
| 11169 | .windows => u16, |
| 11170 | else => if (builtin.target.cpu.arch.isArm() or builtin.target.cpu.arch.isAARCH64()) u32 else i32, |
| 11171 | }; |
| 11172 | |
| 11173 | pub extern "c" fn pthread_getthreadid_np() c_int; |
| 11174 | pub extern "c" fn pthread_set_name_np(thread: pthread_t, name: [*:0]const u8) void; |
| 11175 | pub extern "c" fn pthread_get_name_np(thread: pthread_t, name: [*:0]u8, len: usize) void; |
| 11176 | |
| 11177 | pub const TIMER = switch (native_os) { |
| 11178 | .linux, .emscripten => std.os.linux.TIMER, |
| 11179 | .openbsd, .netbsd, .wasi, .windows, .freebsd, .serenity => packed struct(u32) { |
| 11180 | ABSTIME: bool, |
| 11181 | _: u31 = 0, |
| 11182 | }, |
| 11183 | else => void, |
| 11184 | }; |
| 11185 | |
| 11186 | pub const clock_nanosleep = switch (native_os) { |
| 11187 | .linux, .emscripten, .netbsd, .wasi, .windows, .freebsd, .serenity => private.clock_nanosleep, |
| 11188 | else => {}, |
| 11189 | }; |
| 11190 | |
| 11191 | pub const ioctl = switch (native_os) { |
| 11192 | .windows, .wasi => {}, |
| 11193 | else => private.ioctl, |
| 11194 | }; |
| 11195 | |
| 11196 | pub extern "c" fn bzero(s: *anyopaque, n: usize) void; |
| 11197 | |
| 11198 | pub const swab = switch (builtin.abi) { |
| 11199 | .msvc => private._swab, |
| 11200 | else => private.swab, |
| 11201 | }; |
| 11202 | |
| 11203 | pub extern "c" fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int; |
| 11204 | pub extern "c" fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) c_int; |
| 11205 | pub extern "c" fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int; |
| 11206 | pub const strdup = switch (builtin.abi) { |
| 11207 | .msvc => private._strdup, |
| 11208 | else => private.strdup, |
| 11209 | }; |
| 11210 | pub extern "c" fn strndup(s: [*:0]const c_char, n: usize) ?[*:0]c_char; |
| 11211 | pub const wcsdup = switch (builtin.abi) { |
| 11212 | .msvc => private._wcsdup, |
| 11213 | else => private.wcsdup, |
| 11214 | }; |
| 11215 | |
| 11216 | pub extern "c" fn ffs(i: c_int) c_int; |
| 11217 | pub extern "c" fn ffsl(i: c_long) c_long; |
| 11218 | pub extern "c" fn ffsll(i: c_longlong) c_longlong; |
| 11219 | |
| 11220 | pub extern "c" fn erand48(xsubi: *[3]c_ushort) f64; |
| 11221 | pub extern "c" fn jrand48(xsubi: *[3]c_ushort) c_long; |
| 11222 | pub extern "c" fn nrand48(xsubi: *[3]c_ushort) c_long; |
| 11223 | |
| 11224 | pub extern "c" fn insque(element: *anyopaque, pred: ?*anyopaque) void; |
| 11225 | pub extern "c" fn remque(element: *anyopaque) void; |
| 11226 | |
| 11227 | pub extern "c" fn imaxabs(a: intmax_t) intmax_t; |
| 11228 | pub extern "c" fn imaxdiv(a: intmax_t, b: intmax_t) imaxdiv_t; |
| 11229 | |
| 11230 | pub extern "c" fn abs(a: c_int) c_int; |
| 11231 | pub extern "c" fn labs(a: c_long) c_long; |
| 11232 | pub extern "c" fn llabs(a: c_longlong) c_longlong; |
| 11233 | |
| 11234 | pub extern "c" fn div(a: c_int, b: c_int) div_t; |
| 11235 | pub extern "c" fn ldiv(a: c_long, b: c_long) ldiv_t; |
| 11236 | pub extern "c" fn lldiv(a: c_longlong, b: c_longlong) lldiv_t; |
| 11237 | |
| 11238 | pub extern "c" fn atoi(str: [*:0]const c_char) c_int; |
| 11239 | pub extern "c" fn atol(str: [*:0]const c_char) c_long; |
| 11240 | pub extern "c" fn atoll(str: [*:0]const c_char) c_longlong; |
| 11241 | |
| 11242 | pub extern "c" fn strtol(noalias str: [*:0]const c_char, noalias str_end: ?*[*:0]c_char, base: c_int) callconv(.c) c_long; |
| 11243 | pub extern "c" fn strtoll(noalias str: [*:0]const c_char, noalias str_end: ?*[*:0]c_char, base: c_int) callconv(.c) c_longlong; |
| 11244 | pub extern "c" fn strtoul(noalias str: [*:0]const c_char, noalias str_end: ?*[*:0]c_char, base: c_int) callconv(.c) c_ulong; |
| 11245 | pub extern "c" fn strtoull(noalias str: [*:0]const c_char, noalias str_end: ?*[*:0]c_char, base: c_int) callconv(.c) c_ulonglong; |
| 11246 | pub extern "c" fn strtoimax(noalias str: [*:0]const c_char, noalias str_end: ?*[*:0]c_char, base: c_int) callconv(.c) intmax_t; |
| 11247 | pub extern "c" fn strtoumax(noalias str: [*:0]const c_char, noalias str_end: ?*[*:0]c_char, base: c_int) callconv(.c) uintmax_t; |
| 11248 | |
| 11249 | pub extern "c" fn bsearch( |
| 11250 | key: *const anyopaque, |
| 11251 | base: *const anyopaque, |
| 11252 | n: usize, |
| 11253 | size: usize, |
| 11254 | compare: *const fn (a: *const anyopaque, b: *const anyopaque) callconv(.c) c_int, |
| 11255 | ) ?*anyopaque; |
| 11256 | |
| 11257 | // Math |
| 11258 | pub extern "c" fn atan(x: f64) f64; |
| 11259 | pub extern "c" fn copysign(x: f64, y: f64) f64; |
| 11260 | pub extern "c" fn fdim(x: f64, y: f64) f64; |
| 11261 | pub extern "c" fn frexp(x: f64, e: *c_int) f64; |
| 11262 | pub extern "c" fn hypot(x: f64, y: f64) f64; |
| 11263 | pub extern "c" fn modff(x: f32, iptr: *f32) f32; |
| 11264 | pub extern "c" fn modf(x: f64, iptr: *f64) f64; |
| 11265 | pub extern "c" fn modfl(x: c_longdouble, iptr: *c_longdouble) c_longdouble; |
| 11266 | pub extern "c" fn rintf(x: f32) f32; |
| 11267 | pub extern "c" fn rint(x: f64) f64; |
| 11268 | pub extern "c" fn rintl(x: c_longdouble) c_longdouble; |
| 11269 | |
| 11270 | // OS-specific bits. These are protected from being used on the wrong OS by |
| 11271 | // comptime assertions inside each OS-specific file. |
| 11272 | |
| 11273 | pub const AF_SUN = illumos.AF_SUN; |
| 11274 | pub const AT_SUN = illumos.AT_SUN; |
| 11275 | pub const FILE_EVENT = illumos.FILE_EVENT; |
| 11276 | pub const GETCONTEXT = illumos.GETCONTEXT; |
| 11277 | pub const GETUSTACK = illumos.GETUSTACK; |
| 11278 | pub const PORT_ALERT = illumos.PORT_ALERT; |
| 11279 | pub const PORT_SOURCE = illumos.PORT_SOURCE; |
| 11280 | pub const POSIX_FADV = illumos.POSIX_FADV; |
| 11281 | pub const SETCONTEXT = illumos.SETCONTEXT; |
| 11282 | pub const SETUSTACK = illumos.GETUSTACK; |
| 11283 | pub const SFD = illumos.SFD; |
| 11284 | pub const ctid_t = illumos.ctid_t; |
| 11285 | pub const file_obj = illumos.file_obj; |
| 11286 | pub const id_t = illumos.id_t; |
| 11287 | pub const lif_ifinfo_req = illumos.lif_ifinfo_req; |
| 11288 | pub const lif_nd_req = illumos.lif_nd_req; |
| 11289 | pub const lifreq = illumos.lifreq; |
| 11290 | pub const major_t = illumos.major_t; |
| 11291 | pub const minor_t = illumos.minor_t; |
| 11292 | pub const poolid_t = illumos.poolid_t; |
| 11293 | pub const port_notify = illumos.port_notify; |
| 11294 | pub const priority = illumos.priority; |
| 11295 | pub const procfs = illumos.procfs; |
| 11296 | pub const projid_t = illumos.projid_t; |
| 11297 | pub const signalfd_siginfo = illumos.signalfd_siginfo; |
| 11298 | pub const taskid_t = illumos.taskid_t; |
| 11299 | pub const zoneid_t = illumos.zoneid_t; |
| 11300 | |
| 11301 | pub const B_ABSOLUTE_TIMEOUT = haiku.B_ABSOLUTE_TIMEOUT; |
| 11302 | pub const B_OS_NAME_LENGTH = haiku.B_OS_NAME_LENGTH; |
| 11303 | pub const B_TIMEOUT_REAL_TIME_BASE = haiku.B_TIMEOUT_REAL_TIME_BASE; |
| 11304 | pub const DirEnt = haiku.DirEnt; |
| 11305 | pub const _kern_acquire_sem_etc = haiku._kern_acquire_sem_etc; |
| 11306 | pub const _kern_create_sem = haiku._kern_create_sem; |
| 11307 | pub const _kern_delete_sem = haiku._kern_delete_sem; |
| 11308 | pub const _kern_open_dir = haiku._kern_open_dir; |
| 11309 | pub const _kern_read_dir = haiku._kern_read_dir; |
| 11310 | pub const _kern_read_stat = haiku._kern_read_stat; |
| 11311 | pub const _kern_release_sem_etc = haiku._kern_release_sem_etc; |
| 11312 | pub const _kern_rewind_dir = haiku._kern_rewind_dir; |
| 11313 | pub const area_id = haiku.area_id; |
| 11314 | pub const find_thread = haiku.find_thread; |
| 11315 | pub const get_system_info = haiku.get_system_info; |
| 11316 | pub const on_exit_thread = haiku.on_exit_thread; |
| 11317 | pub const port_id = haiku.port_id; |
| 11318 | pub const readv_pos = haiku.readv_pos; |
| 11319 | pub const sem_id = haiku.sem_id; |
| 11320 | pub const status_t = haiku.status_t; |
| 11321 | pub const system_info = haiku.system_info; |
| 11322 | pub const team_id = haiku.team_id; |
| 11323 | pub const thread_id = haiku.thread_id; |
| 11324 | pub const writev_pos = haiku.writev_pos; |
| 11325 | |
| 11326 | pub const AUTH = openbsd.AUTH; |
| 11327 | pub const BI = openbsd.BI; |
| 11328 | pub const HW = openbsd.HW; |
| 11329 | pub const PTHREAD_STACK_MIN = openbsd.PTHREAD_STACK_MIN; |
| 11330 | pub const TCFLUSH = openbsd.TCFLUSH; |
| 11331 | pub const TCIO = openbsd.TCIO; |
| 11332 | pub const auth_approval = openbsd.auth_approval; |
| 11333 | pub const auth_call = openbsd.auth_call; |
| 11334 | pub const auth_cat = openbsd.auth_cat; |
| 11335 | pub const auth_challenge = openbsd.auth_challenge; |
| 11336 | pub const auth_check_change = openbsd.auth_check_change; |
| 11337 | pub const auth_check_expire = openbsd.auth_check_expire; |
| 11338 | pub const auth_checknologin = openbsd.auth_checknologin; |
| 11339 | pub const auth_clean = openbsd.auth_clean; |
| 11340 | pub const auth_close = openbsd.auth_close; |
| 11341 | pub const auth_clrenv = openbsd.auth_clrenv; |
| 11342 | pub const auth_clroption = openbsd.auth_clroption; |
| 11343 | pub const auth_clroptions = openbsd.auth_clroptions; |
| 11344 | pub const auth_getitem = openbsd.auth_getitem; |
| 11345 | pub const auth_getpwd = openbsd.auth_getpwd; |
| 11346 | pub const auth_getstate = openbsd.auth_getstate; |
| 11347 | pub const auth_getvalue = openbsd.auth_getvalue; |
| 11348 | pub const auth_item_t = openbsd.auth_item_t; |
| 11349 | pub const auth_mkvalue = openbsd.auth_mkvalue; |
| 11350 | pub const auth_open = openbsd.auth_open; |
| 11351 | pub const auth_session_t = openbsd.auth_session_t; |
| 11352 | pub const auth_setdata = openbsd.auth_setdata; |
| 11353 | pub const auth_setenv = openbsd.auth_setenv; |
| 11354 | pub const auth_setitem = openbsd.auth_setitem; |
| 11355 | pub const auth_setoption = openbsd.auth_setoption; |
| 11356 | pub const auth_setpwd = openbsd.auth_setpwd; |
| 11357 | pub const auth_setstate = openbsd.auth_setstate; |
| 11358 | pub const auth_userchallenge = openbsd.auth_userchallenge; |
| 11359 | pub const auth_usercheck = openbsd.auth_usercheck; |
| 11360 | pub const auth_userokay = openbsd.auth_userokay; |
| 11361 | pub const auth_userresponse = openbsd.auth_userresponse; |
| 11362 | pub const auth_verify = openbsd.auth_verify; |
| 11363 | pub const bcrypt = openbsd.bcrypt; |
| 11364 | pub const bcrypt_checkpass = openbsd.bcrypt_checkpass; |
| 11365 | pub const bcrypt_gensalt = openbsd.bcrypt_gensalt; |
| 11366 | pub const bcrypt_newhash = openbsd.bcrypt_newhash; |
| 11367 | pub const getpwnam_shadow = openbsd.getpwnam_shadow; |
| 11368 | pub const getpwuid_shadow = openbsd.getpwuid_shadow; |
| 11369 | pub const getthrid = openbsd.getthrid; |
| 11370 | pub const login_cap_t = openbsd.login_cap_t; |
| 11371 | pub const login_close = openbsd.login_close; |
| 11372 | pub const login_getcapbool = openbsd.login_getcapbool; |
| 11373 | pub const login_getcapnum = openbsd.login_getcapnum; |
| 11374 | pub const login_getcapsize = openbsd.login_getcapsize; |
| 11375 | pub const login_getcapstr = openbsd.login_getcapstr; |
| 11376 | pub const login_getcaptime = openbsd.login_getcaptime; |
| 11377 | pub const login_getclass = openbsd.login_getclass; |
| 11378 | pub const login_getstyle = openbsd.login_getstyle; |
| 11379 | pub const pledge = openbsd.pledge; |
| 11380 | pub const pw_dup = openbsd.pw_dup; |
| 11381 | pub const setclasscontext = openbsd.setclasscontext; |
| 11382 | pub const setpassent = openbsd.setpassent; |
| 11383 | pub const setusercontext = openbsd.setusercontext; |
| 11384 | pub const uid_from_user = openbsd.uid_from_user; |
| 11385 | pub const unveil = openbsd.unveil; |
| 11386 | pub const user_from_uid = openbsd.user_from_uid; |
| 11387 | |
| 11388 | pub const CAP_RIGHTS_VERSION = freebsd.CAP_RIGHTS_VERSION; |
| 11389 | pub const KINFO_FILE_SIZE = freebsd.KINFO_FILE_SIZE; |
| 11390 | pub const UMTX_ABSTIME = freebsd.UMTX_ABSTIME; |
| 11391 | pub const UMTX_OP = freebsd.UMTX_OP; |
| 11392 | pub const _umtx_op = freebsd._umtx_op; |
| 11393 | pub const _umtx_time = freebsd._umtx_time; |
| 11394 | pub const cap_rights = freebsd.cap_rights; |
| 11395 | pub const fflags_t = freebsd.fflags_t; |
| 11396 | pub const fsblkcnt_t = freebsd.fsblkcnt_t; |
| 11397 | pub const fsfilcnt_t = freebsd.fsfilcnt_t; |
| 11398 | pub const kinfo_file = freebsd.kinfo_file; |
| 11399 | pub const kinfo_getfile = freebsd.kinfo_getfile; |
| 11400 | |
| 11401 | pub const CALENDAR_CLOCK = darwin.CALENDAR_CLOCK; |
| 11402 | pub const COPYFILE = darwin.COPYFILE; |
| 11403 | pub const CPUFAMILY = darwin.CPUFAMILY; |
| 11404 | pub const PT = darwin.PT; |
| 11405 | pub const DB_RECORDTYPE = darwin.DB_RECORDTYPE; |
| 11406 | pub const EXC = darwin.EXC; |
| 11407 | pub const EXCEPTION = darwin.EXCEPTION; |
| 11408 | pub const KEVENT = darwin.KEVENT; |
| 11409 | pub const MACH = darwin.MACH; |
| 11410 | pub const MACH_MSG_TYPE = darwin.MACH_MSG_TYPE; |
| 11411 | pub const MACH_PORT_RIGHT = darwin.MACH_PORT_RIGHT; |
| 11412 | pub const MACH_TASK_BASIC_INFO = darwin.MACH_TASK_BASIC_INFO; |
| 11413 | pub const MACH_TASK_BASIC_INFO_COUNT = darwin.MACH_TASK_BASIC_INFO_COUNT; |
| 11414 | pub const MATTR = darwin.MATTR; |
| 11415 | pub const NSVersionOfRunTimeLibrary = darwin.NSVersionOfRunTimeLibrary; |
| 11416 | pub const OPEN_MAX = darwin.OPEN_MAX; |
| 11417 | pub const OS = darwin.OS; |
| 11418 | pub const POSIX_SPAWN = darwin.POSIX_SPAWN; |
| 11419 | pub const SYSPROTO_EVENT = darwin.SYSPROTO_EVENT; |
| 11420 | pub const SYSPROTO_CONTROL = darwin.SYSPROTO_CONTROL; |
| 11421 | pub const TASK = darwin.TASK; |
| 11422 | pub const TASK_NULL = darwin.TASK_NULL; |
| 11423 | pub const TASK_VM_INFO = darwin.TASK_VM_INFO; |
| 11424 | pub const TASK_VM_INFO_COUNT = darwin.TASK_VM_INFO_COUNT; |
| 11425 | pub const THREAD = darwin.THREAD; |
| 11426 | pub const THREAD_BASIC_INFO = darwin.THREAD_BASIC_INFO; |
| 11427 | pub const THREAD_BASIC_INFO_COUNT = darwin.THREAD_BASIC_INFO_COUNT; |
| 11428 | pub const THREAD_IDENTIFIER_INFO_COUNT = darwin.THREAD_IDENTIFIER_INFO_COUNT; |
| 11429 | pub const THREAD_NULL = darwin.THREAD_NULL; |
| 11430 | pub const THREAD_STATE_NONE = darwin.THREAD_STATE_NONE; |
| 11431 | pub const UL = darwin.UL; |
| 11432 | pub const VM = darwin.VM; |
| 11433 | pub const _NSGetExecutablePath = darwin._NSGetExecutablePath; |
| 11434 | pub const __getdirentries64 = darwin.__getdirentries64; |
| 11435 | pub const __ulock_wait = darwin.__ulock_wait; |
| 11436 | pub const __ulock_wait2 = darwin.__ulock_wait2; |
| 11437 | pub const __ulock_wake = darwin.__ulock_wake; |
| 11438 | pub const _dyld_get_image_header = darwin._dyld_get_image_header; |
| 11439 | pub const _dyld_get_image_name = darwin._dyld_get_image_name; |
| 11440 | pub const _dyld_get_image_vmaddr_slide = darwin._dyld_get_image_vmaddr_slide; |
| 11441 | pub const _dyld_image_count = darwin._dyld_image_count; |
| 11442 | pub const _dyld_get_image_header_containing_address = darwin._dyld_get_image_header_containing_address; |
| 11443 | pub const dyld_image_path_containing_address = darwin.dyld_image_path_containing_address; |
| 11444 | pub const _host_page_size = darwin._host_page_size; |
| 11445 | pub const boolean_t = darwin.boolean_t; |
| 11446 | pub const clock_get_time = darwin.clock_get_time; |
| 11447 | pub const clock_serv_t = darwin.clock_serv_t; |
| 11448 | pub const clock_res_t = darwin.clock_res_t; |
| 11449 | pub const @"close$NOCANCEL" = darwin.@"close$NOCANCEL"; |
| 11450 | pub const dispatch = darwin.dispatch; |
| 11451 | pub const fcopyfile = darwin.fcopyfile; |
| 11452 | pub const renameatx_np = darwin.renameatx_np; |
| 11453 | pub const host_t = darwin.host_t; |
| 11454 | pub const integer_t = darwin.integer_t; |
| 11455 | pub const ipc_space_t = darwin.ipc_space_t; |
| 11456 | pub const ipc_space_port_t = darwin.ipc_space_port_t; |
| 11457 | pub const kern_return_t = darwin.kern_return_t; |
| 11458 | pub const vm_size_t = darwin.vm_size_t; |
| 11459 | pub const kevent64 = darwin.kevent64; |
| 11460 | pub const kevent64_s = darwin.kevent64_s; |
| 11461 | pub const mach_absolute_time = darwin.mach_absolute_time; |
| 11462 | pub const mach_continuous_time = darwin.mach_continuous_time; |
| 11463 | pub const mach_hdr = darwin.mach_hdr; |
| 11464 | pub const mach_host_self = darwin.mach_host_self; |
| 11465 | pub const mach_msg = darwin.mach_msg; |
| 11466 | pub const mach_msg_return_t = darwin.mach_msg_return_t; |
| 11467 | pub const mach_msg_type_number_t = darwin.mach_msg_type_number_t; |
| 11468 | pub const mach_port_allocate = darwin.mach_port_allocate; |
| 11469 | pub const mach_port_array_t = darwin.mach_port_array_t; |
| 11470 | pub const mach_port_deallocate = darwin.mach_port_deallocate; |
| 11471 | pub const mach_port_insert_right = darwin.mach_port_insert_right; |
| 11472 | pub const mach_port_name_t = darwin.mach_port_name_t; |
| 11473 | pub const mach_port_t = darwin.mach_port_t; |
| 11474 | pub const mach_task_basic_info = darwin.mach_task_basic_info; |
| 11475 | pub const mach_task_self = darwin.mach_task_self; |
| 11476 | pub const mach_timebase_info = darwin.mach_timebase_info; |
| 11477 | pub const mach_timebase_info_data = darwin.mach_timebase_info_data; |
| 11478 | pub const mach_timespec_t = darwin.mach_timespec_t; |
| 11479 | pub const mach_vm_address_t = darwin.mach_vm_address_t; |
| 11480 | pub const mach_vm_protect = darwin.mach_vm_protect; |
| 11481 | pub const mach_vm_read = darwin.mach_vm_read; |
| 11482 | pub const mach_vm_region = darwin.mach_vm_region; |
| 11483 | pub const mach_vm_region_recurse = darwin.mach_vm_region_recurse; |
| 11484 | pub const mach_vm_size_t = darwin.mach_vm_size_t; |
| 11485 | pub const mach_vm_write = darwin.mach_vm_write; |
| 11486 | pub const natural_t = darwin.natural_t; |
| 11487 | pub const os_log_create = darwin.os_log_create; |
| 11488 | pub const os_log_t = darwin.os_log_t; |
| 11489 | pub const os_log_type_enabled = darwin.os_log_type_enabled; |
| 11490 | pub const os_log_type_t = darwin.os_log_type_t; |
| 11491 | pub const os_signpost_enabled = darwin.os_signpost_enabled; |
| 11492 | pub const os_signpost_id_generate = darwin.os_signpost_id_generate; |
| 11493 | pub const os_signpost_id_make_with_pointer = darwin.os_signpost_id_make_with_pointer; |
| 11494 | pub const os_signpost_id_t = darwin.os_signpost_id_t; |
| 11495 | pub const os_signpost_interval_begin = darwin.os_signpost_interval_begin; |
| 11496 | pub const os_signpost_interval_end = darwin.os_signpost_interval_end; |
| 11497 | pub const os_unfair_lock = darwin.os_unfair_lock; |
| 11498 | pub const os_unfair_lock_assert_not_owner = darwin.os_unfair_lock_assert_not_owner; |
| 11499 | pub const os_unfair_lock_assert_owner = darwin.os_unfair_lock_assert_owner; |
| 11500 | pub const os_unfair_lock_lock = darwin.os_unfair_lock_lock; |
| 11501 | pub const os_unfair_lock_t = darwin.os_unfair_lock_t; |
| 11502 | pub const os_unfair_lock_trylock = darwin.os_unfair_lock_trylock; |
| 11503 | pub const os_unfair_lock_unlock = darwin.os_unfair_lock_unlock; |
| 11504 | pub const pid_for_task = darwin.pid_for_task; |
| 11505 | pub const posix_spawn = darwin.posix_spawn; |
| 11506 | pub const posix_spawn_file_actions_addchdir_np = darwin.posix_spawn_file_actions_addchdir_np; |
| 11507 | pub const posix_spawn_file_actions_addclose = darwin.posix_spawn_file_actions_addclose; |
| 11508 | pub const posix_spawn_file_actions_adddup2 = darwin.posix_spawn_file_actions_adddup2; |
| 11509 | pub const posix_spawn_file_actions_addfchdir_np = darwin.posix_spawn_file_actions_addfchdir_np; |
| 11510 | pub const posix_spawn_file_actions_addinherit_np = darwin.posix_spawn_file_actions_addinherit_np; |
| 11511 | pub const posix_spawn_file_actions_addopen = darwin.posix_spawn_file_actions_addopen; |
| 11512 | pub const posix_spawn_file_actions_destroy = darwin.posix_spawn_file_actions_destroy; |
| 11513 | pub const posix_spawn_file_actions_init = darwin.posix_spawn_file_actions_init; |
| 11514 | pub const posix_spawn_file_actions_t = darwin.posix_spawn_file_actions_t; |
| 11515 | pub const posix_spawnattr_destroy = darwin.posix_spawnattr_destroy; |
| 11516 | pub const posix_spawnattr_getflags = darwin.posix_spawnattr_getflags; |
| 11517 | pub const posix_spawnattr_init = darwin.posix_spawnattr_init; |
| 11518 | pub const posix_spawnattr_setflags = darwin.posix_spawnattr_setflags; |
| 11519 | pub const posix_spawnattr_t = darwin.posix_spawnattr_t; |
| 11520 | pub const posix_spawnp = darwin.posix_spawnp; |
| 11521 | pub const pthread_attr_get_qos_class_np = darwin.pthread_attr_get_qos_class_np; |
| 11522 | pub const pthread_attr_set_qos_class_np = darwin.pthread_attr_set_qos_class_np; |
| 11523 | pub const pthread_get_qos_class_np = darwin.pthread_get_qos_class_np; |
| 11524 | pub const pthread_set_qos_class_self_np = darwin.pthread_set_qos_class_self_np; |
| 11525 | pub const qos_class_t = darwin.qos_class_t; |
| 11526 | pub const task_flavor_t = darwin.task_flavor_t; |
| 11527 | pub const task_for_pid = darwin.task_for_pid; |
| 11528 | pub const task_get_exception_ports = darwin.task_get_exception_ports; |
| 11529 | pub const task_info = darwin.task_info; |
| 11530 | pub const task_info_t = darwin.task_info_t; |
| 11531 | pub const task_name_t = darwin.task_name_t; |
| 11532 | pub const task_resume = darwin.task_resume; |
| 11533 | pub const task_set_exception_ports = darwin.task_set_exception_ports; |
| 11534 | pub const task_suspend = darwin.task_suspend; |
| 11535 | pub const task_threads = darwin.task_threads; |
| 11536 | pub const task_vm_info_data_t = darwin.task_vm_info_data_t; |
| 11537 | pub const thread_basic_info = darwin.thread_basic_info; |
| 11538 | pub const thread_get_state = darwin.thread_get_state; |
| 11539 | pub const thread_identifier_info = darwin.thread_identifier_info; |
| 11540 | pub const thread_info = darwin.thread_info; |
| 11541 | pub const thread_info_t = darwin.thread_info_t; |
| 11542 | pub const thread_resume = darwin.thread_resume; |
| 11543 | pub const thread_set_state = darwin.thread_set_state; |
| 11544 | pub const vm_address_t = darwin.vm_address_t; |
| 11545 | pub const vm_deallocate = darwin.vm_deallocate; |
| 11546 | pub const vm_machine_attribute = darwin.vm_machine_attribute; |
| 11547 | pub const vm_machine_attribute_t = darwin.vm_machine_attribute_t; |
| 11548 | pub const vm_machine_attribute_val_t = darwin.vm_machine_attribute_val_t; |
| 11549 | pub const vm_map_t = darwin.vm_map_t; |
| 11550 | pub const vm_offset_t = darwin.vm_offset_t; |
| 11551 | pub const vm_prot_t = darwin.vm_prot_t; |
| 11552 | pub const vm_region_basic_info_64 = darwin.vm_region_basic_info_64; |
| 11553 | pub const vm_region_extended_info = darwin.vm_region_extended_info; |
| 11554 | pub const vm_region_info_t = darwin.vm_region_info_t; |
| 11555 | pub const vm_region_recurse_info_t = darwin.vm_region_recurse_info_t; |
| 11556 | pub const vm_region_submap_info_64 = darwin.vm_region_submap_info_64; |
| 11557 | pub const vm_region_submap_short_info_64 = darwin.vm_region_submap_short_info_64; |
| 11558 | pub const vm_region_top_info = darwin.vm_region_top_info; |
| 11559 | |
| 11560 | pub const exception_behavior_array_t = darwin.exception_behavior_array_t; |
| 11561 | pub const exception_behavior_t = darwin.exception_behavior_t; |
| 11562 | pub const exception_data_t = darwin.exception_data_t; |
| 11563 | pub const exception_data_type_t = darwin.exception_data_type_t; |
| 11564 | pub const exception_flavor_array_t = darwin.exception_flavor_array_t; |
| 11565 | pub const exception_handler_array_t = darwin.exception_handler_array_t; |
| 11566 | pub const exception_handler_t = darwin.exception_handler_t; |
| 11567 | pub const exception_mask_array_t = darwin.exception_mask_array_t; |
| 11568 | pub const exception_mask_t = darwin.exception_mask_t; |
| 11569 | pub const exception_port_array_t = darwin.exception_port_array_t; |
| 11570 | pub const exception_port_t = darwin.exception_port_t; |
| 11571 | pub const exception_type_t = darwin.exception_type_t; |
| 11572 | pub const mach_exception_data_t = darwin.mach_exception_data_t; |
| 11573 | pub const mach_exception_data_type_t = darwin.mach_exception_data_type_t; |
| 11574 | pub const mach_msg_bits_t = darwin.mach_msg_bits_t; |
| 11575 | pub const mach_msg_id_t = darwin.mach_msg_id_t; |
| 11576 | pub const mach_msg_header_t = darwin.mach_msg_header_t; |
| 11577 | pub const mach_msg_option_t = darwin.mach_msg_option_t; |
| 11578 | pub const mach_msg_size_t = darwin.mach_msg_size_t; |
| 11579 | pub const mach_msg_timeout_t = darwin.mach_msg_timeout_t; |
| 11580 | pub const mach_msg_type_name_t = darwin.mach_msg_type_name_t; |
| 11581 | pub const mach_port_right_t = darwin.mach_port_right_t; |
| 11582 | pub const memory_object_offset_t = darwin.memory_object_offset_t; |
| 11583 | pub const policy_t = darwin.policy_t; |
| 11584 | pub const task_policy_flavor_t = darwin.task_policy_flavor_t; |
| 11585 | pub const task_policy_t = darwin.task_policy_t; |
| 11586 | pub const task_read_t = darwin.task_read_t; |
| 11587 | pub const task_t = darwin.task_t; |
| 11588 | pub const thread_act_t = darwin.thread_act_t; |
| 11589 | pub const thread_flavor_t = darwin.thread_flavor_t; |
| 11590 | pub const thread_port_t = darwin.thread_port_t; |
| 11591 | pub const thread_state_flavor_t = darwin.thread_state_flavor_t; |
| 11592 | pub const thread_state_t = darwin.thread_state_t; |
| 11593 | pub const thread_t = darwin.thread_t; |
| 11594 | pub const time_value_t = darwin.time_value_t; |
| 11595 | pub const vm32_object_id_t = darwin.vm32_object_id_t; |
| 11596 | pub const vm_behavior_t = darwin.vm_behavior_t; |
| 11597 | pub const vm_inherit_t = darwin.vm_inherit_t; |
| 11598 | pub const vm_map_read_t = darwin.vm_map_read_t; |
| 11599 | pub const vm_object_id_t = darwin.vm_object_id_t; |
| 11600 | pub const vm_region_flavor_t = darwin.vm_region_flavor_t; |
| 11601 | |
| 11602 | pub const _ksiginfo = netbsd._ksiginfo; |
| 11603 | pub const _lwp_self = netbsd._lwp_self; |
| 11604 | pub const _lwp_park = netbsd.___lwp_park60; |
| 11605 | pub const _lwp_unpark = netbsd._lwp_unpark; |
| 11606 | pub const _lwp_unpark_all = netbsd._lwp_unpark_all; |
| 11607 | pub const lwpid_t = netbsd.lwpid_t; |
| 11608 | |
| 11609 | pub const lwp_gettid = dragonfly.lwp_gettid; |
| 11610 | pub const umtx_sleep = dragonfly.umtx_sleep; |
| 11611 | pub const umtx_wakeup = dragonfly.umtx_wakeup; |
| 11612 | |
| 11613 | pub const PERF_EVENT = serenity.PERF_EVENT; |
| 11614 | pub const disown = serenity.disown; |
| 11615 | pub const profiling_enable = serenity.profiling_enable; |
| 11616 | pub const profiling_disable = serenity.profiling_disable; |
| 11617 | pub const profiling_free_buffer = serenity.profiling_free_buffer; |
| 11618 | pub const purge = serenity.purge; |
| 11619 | pub const perf_event = serenity.perf_event; |
| 11620 | pub const perf_register_string = serenity.perf_register_string; |
| 11621 | pub const get_stack_bounds = serenity.get_stack_bounds; |
| 11622 | pub const anon_create = serenity.anon_create; |
| 11623 | pub const getkeymap = serenity.getkeymap; |
| 11624 | pub const setkeymap = serenity.setkeymap; |
| 11625 | |
| 11626 | /// External definitions shared by two or more operating systems. |
| 11627 | const private = struct { |
| 11628 | pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char; |
| 11629 | pub extern "c" fn _strdup(s: [*:0]const c_char) ?[*:0]c_char; |
| 11630 | pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; |
| 11631 | pub extern "c" fn _wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; |
| 11632 | |
| 11633 | pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; |
| 11634 | pub extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; |
| 11635 | |
| 11636 | extern "c" fn close(fd: fd_t) c_int; |
| 11637 | extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int; |
| 11638 | extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int; |
| 11639 | 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; |
| 11640 | extern "c" fn flock(fd: fd_t, operation: c_int) c_int; |
| 11641 | extern "c" fn fork() c_int; |
| 11642 | extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; |
| 11643 | extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int; |
| 11644 | extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize; |
| 11645 | extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) switch (native_os) { |
| 11646 | .freebsd => isize, |
| 11647 | .illumos => usize, |
| 11648 | else => c_int, |
| 11649 | }; |
| 11650 | extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; |
| 11651 | extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| 11652 | extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int; |
| 11653 | extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; |
| 11654 | extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 11655 | extern "c" fn clock_nanosleep(clockid: clockid_t, flags: TIMER, t: *const timespec, remain: ?*timespec) c_int; |
| 11656 | extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int; |
| 11657 | extern "c" fn readdir(dir: *DIR) ?*dirent; |
| 11658 | extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 11659 | extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize; |
| 11660 | extern "c" fn sched_yield() c_int; |
| 11661 | extern "c" fn sendfile(out_fd: fd_t, in_fd: fd_t, offset: ?*off_t, count: usize) isize; |
| 11662 | extern "c" fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 11663 | extern "c" fn sigdelset(set: ?*sigset_t, signo: SIG) c_int; |
| 11664 | extern "c" fn sigaddset(set: ?*sigset_t, signo: SIG) c_int; |
| 11665 | extern "c" fn sigfillset(set: ?*sigset_t) c_int; |
| 11666 | extern "c" fn sigemptyset(set: ?*sigset_t) c_int; |
| 11667 | extern "c" fn sigismember(set: ?*const sigset_t, signo: SIG) c_int; |
| 11668 | extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 11669 | extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 11670 | extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int; |
| 11671 | extern "c" fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) c_int; |
| 11672 | extern "c" fn sysconf(sc: c_int) c_long; |
| 11673 | extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int; |
| 11674 | extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; |
| 11675 | |
| 11676 | extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int; |
| 11677 | |
| 11678 | extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; |
| 11679 | extern "c" fn getentropy(buffer: [*]u8, size: usize) c_int; |
| 11680 | extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 11681 | |
| 11682 | extern "c" fn _msize(?*const anyopaque) usize; |
| 11683 | extern "c" fn malloc_size(?*const anyopaque) usize; |
| 11684 | extern "c" fn malloc_usable_size(?*const anyopaque) usize; |
| 11685 | extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; |
| 11686 | |
| 11687 | extern "c" fn mlock(addr: *align(page_size) const anyopaque, len: usize) c_int; |
| 11688 | extern "c" fn mlock2(addr: *align(page_size) const anyopaque, len: usize, flags: MLOCK) c_int; |
| 11689 | extern "c" fn munlock(addr: *align(page_size) const anyopaque, len: usize) c_int; |
| 11690 | extern "c" fn mlockall(flags: MCL) c_int; |
| 11691 | extern "c" fn munlockall() c_int; |
| 11692 | |
| 11693 | // linux and https://github.com/SerenityOS/serenity/blob/502caef9a40bccc7459f9835f2174a601106299a/Userland/Libraries/LibC/sys/ptrace.cpp |
| 11694 | extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: ?*anyopaque) c_long; |
| 11695 | |
| 11696 | /// macos modernized symbols. |
| 11697 | /// x86_64 links to $INODE64 suffix for 64-bit support. |
| 11698 | /// Note these are not necessary on aarch64. |
| 11699 | extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int; |
| 11700 | extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int; |
| 11701 | extern "c" fn @"readdir$INODE64"(dir: *DIR) ?*dirent; |
| 11702 | extern "c" fn @"stat$INODE64"(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; |
| 11703 | extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; |
| 11704 | |
| 11705 | /// macos modernized symbols. |
| 11706 | extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 11707 | extern "c" fn __getdirentries64(fd: fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; |
| 11708 | |
| 11709 | extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int; |
| 11710 | |
| 11711 | /// netbsd modernized symbols. |
| 11712 | extern "c" fn __clock_getres50(clk_id: clockid_t, tp: *timespec) c_int; |
| 11713 | extern "c" fn __clock_gettime50(clk_id: clockid_t, tp: *timespec) c_int; |
| 11714 | extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int; |
| 11715 | extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int; |
| 11716 | extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| 11717 | extern "c" fn __libc_thr_yield() c_int; |
| 11718 | extern "c" fn __msync13(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; |
| 11719 | extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 11720 | extern "c" fn __sigaction14(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 11721 | extern "c" fn __sigemptyset14(set: ?*sigset_t) c_int; |
| 11722 | extern "c" fn __sigfillset14(set: ?*sigset_t) c_int; |
| 11723 | extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 11724 | extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 11725 | extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int; |
| 11726 | extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; |
| 11727 | extern "c" fn __sigaltstack14(ss: ?*const stack_t, old_ss: ?*stack_t) c_int; |
| 11728 | extern "c" fn __wait450(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; |
| 11729 | |
| 11730 | extern "c" fn __libc_current_sigrtmin() c_int; |
| 11731 | extern "c" fn __libc_current_sigrtmax() c_int; |
| 11732 | extern "c" fn __signal_get_sigrtmin() c_int; |
| 11733 | extern "c" fn __signal_get_sigrtmax() c_int; |
| 11734 | |
| 11735 | // Don't forget to add another clown when an OS picks yet another unique |
| 11736 | // symbol name for errno location! |
| 11737 | // 🤡🤡🤡🤡🤡🤡 |
| 11738 | |
| 11739 | extern "c" fn ___errno() *c_int; |
| 11740 | extern "c" fn __errno() *c_int; |
| 11741 | extern "c" fn __errno_location() *c_int; |
| 11742 | extern "c" fn __error() *c_int; |
| 11743 | extern "c" fn _errno() *c_int; |
| 11744 | |
| 11745 | extern threadlocal var errno: c_int; |
| 11746 | |
| 11747 | fn errnoFromThreadLocal() *c_int { |
| 11748 | return &private.errno; |
| 11749 | } |
| 11750 | }; |