master
    1const builtin = @import("builtin");
    2const native_abi = builtin.abi;
    3const native_arch = builtin.cpu.arch;
    4const native_os = builtin.os.tag;
    5const native_endian = builtin.cpu.arch.endian();
    6
    7const std = @import("std");
    8const c = @This();
    9const maxInt = std.math.maxInt;
   10const assert = std.debug.assert;
   11const page_size = std.heap.page_size_min;
   12const linux = std.os.linux;
   13const emscripten = std.os.emscripten;
   14const wasi = std.os.wasi;
   15const windows = std.os.windows;
   16const ws2_32 = std.os.windows.ws2_32;
   17const darwin = @import("c/darwin.zig");
   18const freebsd = @import("c/freebsd.zig");
   19const illumos = @import("c/illumos.zig");
   20const netbsd = @import("c/netbsd.zig");
   21const dragonfly = @import("c/dragonfly.zig");
   22const haiku = @import("c/haiku.zig");
   23const openbsd = @import("c/openbsd.zig");
   24const serenity = @import("c/serenity.zig");
   25
   26// These constants are shared among all operating systems even when not linking
   27// libc.
   28
   29pub const iovec = std.posix.iovec;
   30pub const iovec_const = std.posix.iovec_const;
   31pub const LOCK = std.posix.LOCK;
   32pub 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.
   42pub extern var _mh_execute_header: mach_hdr;
   43var dummy_execute_header: mach_hdr = undefined;
   44comptime {
   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`.
   57pub 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.
   76pub fn errno(rc: anytype) E {
   77    return if (rc == -1) @enumFromInt(_errno().*) else .SUCCESS;
   78}
   79
   80pub 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
   90pub 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
   97pub const timespec = switch (native_os) {
   98    .linux => linux.timespec,
   99    .emscripten => emscripten.timespec,
  100    .wasi => extern struct {
  101        sec: time_t,
  102        nsec: isize,
  103
  104        pub fn fromTimestamp(tm: wasi.timestamp_t) timespec {
  105            const sec: wasi.timestamp_t = tm / 1_000_000_000;
  106            const nsec = tm - sec * 1_000_000_000;
  107            return .{
  108                .sec = @as(time_t, @intCast(sec)),
  109                .nsec = @as(isize, @intCast(nsec)),
  110            };
  111        }
  112
  113        pub fn toTimestamp(ts: timespec) wasi.timestamp_t {
  114            return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) +
  115                @as(wasi.timestamp_t, @intCast(ts.nsec));
  116        }
  117    },
  118    // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20
  119    .windows, .serenity => extern struct {
  120        sec: time_t,
  121        nsec: c_long,
  122    },
  123    .dragonfly, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
  124        sec: isize,
  125        nsec: isize,
  126    },
  127    .netbsd, .illumos => extern struct {
  128        sec: i64,
  129        nsec: isize,
  130    },
  131    .openbsd, .haiku => extern struct {
  132        sec: time_t,
  133        nsec: isize,
  134    },
  135    else => void,
  136};
  137
  138pub const dev_t = switch (native_os) {
  139    .linux => linux.dev_t,
  140    .emscripten => emscripten.dev_t,
  141    .wasi => wasi.device_t,
  142    .openbsd, .haiku, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => i32,
  143    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L43
  144    .netbsd, .freebsd, .serenity => u64,
  145    else => void,
  146};
  147
  148pub const mode_t = switch (native_os) {
  149    .linux => linux.mode_t,
  150    .emscripten => emscripten.mode_t,
  151    .openbsd, .haiku, .netbsd, .illumos, .wasi, .windows => u32,
  152    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L44
  153    .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .dragonfly, .serenity => u16,
  154    else => u0,
  155};
  156
  157pub const nlink_t = switch (native_os) {
  158    .linux => linux.nlink_t,
  159    .emscripten => emscripten.nlink_t,
  160    .wasi => c_ulonglong,
  161    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L45
  162    .freebsd, .serenity => u64,
  163    .openbsd, .netbsd, .illumos => u32,
  164    .haiku => i32,
  165    else => void,
  166};
  167
  168pub const uid_t = switch (native_os) {
  169    .linux => linux.uid_t,
  170    .emscripten => emscripten.uid_t,
  171    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L28
  172    else => u32,
  173};
  174
  175pub const gid_t = switch (native_os) {
  176    .linux => linux.gid_t,
  177    .emscripten => emscripten.gid_t,
  178    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L29
  179    else => u32,
  180};
  181
  182pub const blksize_t = switch (native_os) {
  183    .linux => linux.blksize_t,
  184    .emscripten => emscripten.blksize_t,
  185    .wasi => c_long,
  186    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L42
  187    .serenity => u64,
  188    else => i32,
  189};
  190
  191pub const passwd = switch (native_os) {
  192    // https://github.com/SerenityOS/serenity/blob/7442cfb5072b74a62c0e061e6e9ff44fda08780d/Userland/Libraries/LibC/pwd.h#L15-L23
  193    .linux, .serenity => extern struct {
  194        name: ?[*:0]const u8, // username
  195        passwd: ?[*:0]const u8, // user password
  196        uid: uid_t, // user ID
  197        gid: gid_t, // group ID
  198        gecos: ?[*:0]const u8, // user information
  199        dir: ?[*:0]const u8, // home directory
  200        shell: ?[*:0]const u8, // shell program
  201    },
  202    .netbsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
  203        name: ?[*:0]const u8, // user name
  204        passwd: ?[*:0]const u8, // encrypted password
  205        uid: uid_t, // user uid
  206        gid: gid_t, // user gid
  207        change: time_t, // password change time
  208        class: ?[*:0]const u8, // user access class
  209        gecos: ?[*:0]const u8, // Honeywell login info
  210        dir: ?[*:0]const u8, // home directory
  211        shell: ?[*:0]const u8, // default shell
  212        expire: time_t, // account expiration
  213    },
  214    .dragonfly, .freebsd => extern struct {
  215        name: ?[*:0]const u8, // user name
  216        passwd: ?[*:0]const u8, // encrypted password
  217        uid: uid_t, // user uid
  218        gid: gid_t, // user gid
  219        change: time_t, // password change time
  220        class: ?[*:0]const u8, // user access class
  221        gecos: ?[*:0]const u8, // Honeywell login info
  222        dir: ?[*:0]const u8, // home directory
  223        shell: ?[*:0]const u8, // default shell
  224        expire: time_t, // account expiration
  225        fields: c_int, // internal
  226    },
  227    else => void,
  228};
  229
  230pub const group = switch (native_os) {
  231    .linux, .freebsd, .openbsd, .dragonfly, .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
  232        name: ?[*:0]const u8,
  233        passwd: ?[*:0]const u8,
  234        gid: gid_t,
  235        mem: [*:null]?[*:0]const u8,
  236    },
  237    else => void,
  238};
  239
  240pub const blkcnt_t = switch (native_os) {
  241    .linux => linux.blkcnt_t,
  242    .emscripten => emscripten.blkcnt_t,
  243    .wasi => c_longlong,
  244    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L41
  245    .serenity => u64,
  246    else => i64,
  247};
  248
  249pub const fd_t = switch (native_os) {
  250    .linux => linux.fd_t,
  251    .wasi => wasi.fd_t,
  252    .windows => windows.HANDLE,
  253    .serenity => c_int,
  254    else => i32,
  255};
  256
  257pub const ARCH = switch (native_os) {
  258    .linux => linux.ARCH,
  259    else => void,
  260};
  261
  262// For use with posix.timerfd_create()
  263// Actually, the parameter for the timerfd_create() function is an integer,
  264// which means that the developer has to figure out which value is appropriate.
  265// To make this easier and, above all, safer, because an incorrect value leads
  266// to a panic, an enum is introduced which only allows the values
  267// that actually work.
  268pub const TIMERFD_CLOCK = timerfd_clockid_t;
  269pub const timerfd_clockid_t = switch (native_os) {
  270    .freebsd => enum(u32) {
  271        REALTIME = 0,
  272        MONOTONIC = 4,
  273        _,
  274    },
  275    .linux => linux.timerfd_clockid_t,
  276    else => clockid_t,
  277};
  278
  279pub const CLOCK = clockid_t;
  280pub const clockid_t = switch (native_os) {
  281    .linux, .emscripten => linux.clockid_t,
  282    .wasi => wasi.clockid_t,
  283    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(u32) {
  284        REALTIME = 0,
  285        MONOTONIC = 6,
  286        MONOTONIC_RAW = 4,
  287        MONOTONIC_RAW_APPROX = 5,
  288        UPTIME_RAW = 8,
  289        UPTIME_RAW_APPROX = 9,
  290        PROCESS_CPUTIME_ID = 12,
  291        THREAD_CPUTIME_ID = 16,
  292        _,
  293    },
  294    .haiku => enum(i32) {
  295        /// system-wide monotonic clock (aka system time)
  296        MONOTONIC = 0,
  297        /// system-wide real time clock
  298        REALTIME = -1,
  299        /// clock measuring the used CPU time of the current process
  300        PROCESS_CPUTIME_ID = -2,
  301        /// clock measuring the used CPU time of the current thread
  302        THREAD_CPUTIME_ID = -3,
  303    },
  304    .freebsd => enum(u32) {
  305        REALTIME = 0,
  306        VIRTUAL = 1,
  307        PROF = 2,
  308        MONOTONIC = 4,
  309        UPTIME = 5,
  310        UPTIME_PRECISE = 7,
  311        UPTIME_FAST = 8,
  312        REALTIME_PRECISE = 9,
  313        REALTIME_FAST = 10,
  314        MONOTONIC_PRECISE = 11,
  315        MONOTONIC_FAST = 12,
  316        SECOND = 13,
  317        THREAD_CPUTIME_ID = 14,
  318        PROCESS_CPUTIME_ID = 15,
  319    },
  320    .illumos => enum(u32) {
  321        VIRTUAL = 1,
  322        THREAD_CPUTIME_ID = 2,
  323        REALTIME = 3,
  324        MONOTONIC = 4,
  325        PROCESS_CPUTIME_ID = 5,
  326    },
  327    .netbsd => enum(u32) {
  328        REALTIME = 0,
  329        VIRTUAL = 1,
  330        PROF = 2,
  331        MONOTONIC = 3,
  332        THREAD_CPUTIME_ID = 0x20000000,
  333        PROCESS_CPUTIME_ID = 0x40000000,
  334    },
  335    .dragonfly => enum(u32) {
  336        REALTIME = 0,
  337        VIRTUAL = 1,
  338        PROF = 2,
  339        MONOTONIC = 4,
  340        UPTIME = 5,
  341        UPTIME_PRECISE = 7,
  342        UPTIME_FAST = 8,
  343        REALTIME_PRECISE = 9,
  344        REALTIME_FAST = 10,
  345        MONOTONIC_PRECISE = 11,
  346        MONOTONIC_FAST = 12,
  347        SECOND = 13,
  348        THREAD_CPUTIME_ID = 14,
  349        PROCESS_CPUTIME_ID = 15,
  350    },
  351    .openbsd => enum(u32) {
  352        REALTIME = 0,
  353        PROCESS_CPUTIME_ID = 2,
  354        MONOTONIC = 3,
  355        THREAD_CPUTIME_ID = 4,
  356    },
  357    // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L24-L36
  358    .serenity => enum(c_int) {
  359        REALTIME = 0,
  360        MONOTONIC = 1,
  361        MONOTONIC_RAW = 2,
  362        REALTIME_COARSE = 3,
  363        MONOTONIC_COARSE = 4,
  364    },
  365    else => void,
  366};
  367pub const CPU_COUNT = switch (native_os) {
  368    .linux => linux.CPU_COUNT,
  369    .emscripten => emscripten.CPU_COUNT,
  370    else => void,
  371};
  372pub const E = switch (native_os) {
  373    .linux => linux.E,
  374    .emscripten => emscripten.E,
  375    .wasi => wasi.errno_t,
  376    .windows => enum(u16) {
  377        /// No error occurred.
  378        SUCCESS = 0,
  379        PERM = 1,
  380        NOENT = 2,
  381        SRCH = 3,
  382        INTR = 4,
  383        IO = 5,
  384        NXIO = 6,
  385        @"2BIG" = 7,
  386        NOEXEC = 8,
  387        BADF = 9,
  388        CHILD = 10,
  389        AGAIN = 11,
  390        NOMEM = 12,
  391        ACCES = 13,
  392        FAULT = 14,
  393        BUSY = 16,
  394        EXIST = 17,
  395        XDEV = 18,
  396        NODEV = 19,
  397        NOTDIR = 20,
  398        ISDIR = 21,
  399        NFILE = 23,
  400        MFILE = 24,
  401        NOTTY = 25,
  402        FBIG = 27,
  403        NOSPC = 28,
  404        SPIPE = 29,
  405        ROFS = 30,
  406        MLINK = 31,
  407        PIPE = 32,
  408        DOM = 33,
  409        /// Also means `DEADLOCK`.
  410        DEADLK = 36,
  411        NAMETOOLONG = 38,
  412        NOLCK = 39,
  413        NOSYS = 40,
  414        NOTEMPTY = 41,
  415
  416        INVAL = 22,
  417        RANGE = 34,
  418        ILSEQ = 42,
  419
  420        // POSIX Supplement
  421        ADDRINUSE = 100,
  422        ADDRNOTAVAIL = 101,
  423        AFNOSUPPORT = 102,
  424        ALREADY = 103,
  425        BADMSG = 104,
  426        CANCELED = 105,
  427        CONNABORTED = 106,
  428        CONNREFUSED = 107,
  429        CONNRESET = 108,
  430        DESTADDRREQ = 109,
  431        HOSTUNREACH = 110,
  432        IDRM = 111,
  433        INPROGRESS = 112,
  434        ISCONN = 113,
  435        LOOP = 114,
  436        MSGSIZE = 115,
  437        NETDOWN = 116,
  438        NETRESET = 117,
  439        NETUNREACH = 118,
  440        NOBUFS = 119,
  441        NODATA = 120,
  442        NOLINK = 121,
  443        NOMSG = 122,
  444        NOPROTOOPT = 123,
  445        NOSR = 124,
  446        NOSTR = 125,
  447        NOTCONN = 126,
  448        NOTRECOVERABLE = 127,
  449        NOTSOCK = 128,
  450        NOTSUP = 129,
  451        OPNOTSUPP = 130,
  452        OTHER = 131,
  453        OVERFLOW = 132,
  454        OWNERDEAD = 133,
  455        PROTO = 134,
  456        PROTONOSUPPORT = 135,
  457        PROTOTYPE = 136,
  458        TIME = 137,
  459        TIMEDOUT = 138,
  460        TXTBSY = 139,
  461        WOULDBLOCK = 140,
  462        DQUOT = 10069,
  463        _,
  464    },
  465    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.E,
  466    .freebsd => freebsd.E,
  467    .illumos => enum(u16) {
  468        /// No error occurred.
  469        SUCCESS = 0,
  470        /// Not super-user
  471        PERM = 1,
  472        /// No such file or directory
  473        NOENT = 2,
  474        /// No such process
  475        SRCH = 3,
  476        /// interrupted system call
  477        INTR = 4,
  478        /// I/O error
  479        IO = 5,
  480        /// No such device or address
  481        NXIO = 6,
  482        /// Arg list too long
  483        @"2BIG" = 7,
  484        /// Exec format error
  485        NOEXEC = 8,
  486        /// Bad file number
  487        BADF = 9,
  488        /// No children
  489        CHILD = 10,
  490        /// Resource temporarily unavailable.
  491        /// also: WOULDBLOCK: Operation would block.
  492        AGAIN = 11,
  493        /// Not enough core
  494        NOMEM = 12,
  495        /// Permission denied
  496        ACCES = 13,
  497        /// Bad address
  498        FAULT = 14,
  499        /// Block device required
  500        NOTBLK = 15,
  501        /// Mount device busy
  502        BUSY = 16,
  503        /// File exists
  504        EXIST = 17,
  505        /// Cross-device link
  506        XDEV = 18,
  507        /// No such device
  508        NODEV = 19,
  509        /// Not a directory
  510        NOTDIR = 20,
  511        /// Is a directory
  512        ISDIR = 21,
  513        /// Invalid argument
  514        INVAL = 22,
  515        /// File table overflow
  516        NFILE = 23,
  517        /// Too many open files
  518        MFILE = 24,
  519        /// Inappropriate ioctl for device
  520        NOTTY = 25,
  521        /// Text file busy
  522        TXTBSY = 26,
  523        /// File too large
  524        FBIG = 27,
  525        /// No space left on device
  526        NOSPC = 28,
  527        /// Illegal seek
  528        SPIPE = 29,
  529        /// Read only file system
  530        ROFS = 30,
  531        /// Too many links
  532        MLINK = 31,
  533        /// Broken pipe
  534        PIPE = 32,
  535        /// Math arg out of domain of func
  536        DOM = 33,
  537        /// Math result not representable
  538        RANGE = 34,
  539        /// No message of desired type
  540        NOMSG = 35,
  541        /// Identifier removed
  542        IDRM = 36,
  543        /// Channel number out of range
  544        CHRNG = 37,
  545        /// Level 2 not synchronized
  546        L2NSYNC = 38,
  547        /// Level 3 halted
  548        L3HLT = 39,
  549        /// Level 3 reset
  550        L3RST = 40,
  551        /// Link number out of range
  552        LNRNG = 41,
  553        /// Protocol driver not attached
  554        UNATCH = 42,
  555        /// No CSI structure available
  556        NOCSI = 43,
  557        /// Level 2 halted
  558        L2HLT = 44,
  559        /// Deadlock condition.
  560        DEADLK = 45,
  561        /// No record locks available.
  562        NOLCK = 46,
  563        /// Operation canceled
  564        CANCELED = 47,
  565        /// Operation not supported
  566        NOTSUP = 48,
  567
  568        // Filesystem Quotas
  569        /// Disc quota exceeded
  570        DQUOT = 49,
  571
  572        // Convergent Error Returns
  573        /// invalid exchange
  574        BADE = 50,
  575        /// invalid request descriptor
  576        BADR = 51,
  577        /// exchange full
  578        XFULL = 52,
  579        /// no anode
  580        NOANO = 53,
  581        /// invalid request code
  582        BADRQC = 54,
  583        /// invalid slot
  584        BADSLT = 55,
  585        /// file locking deadlock error
  586        DEADLOCK = 56,
  587        /// bad font file fmt
  588        BFONT = 57,
  589
  590        // Interprocess Robust Locks
  591        /// process died with the lock
  592        OWNERDEAD = 58,
  593        /// lock is not recoverable
  594        NOTRECOVERABLE = 59,
  595        /// locked lock was unmapped
  596        LOCKUNMAPPED = 72,
  597        /// Facility is not active
  598        NOTACTIVE = 73,
  599        /// multihop attempted
  600        MULTIHOP = 74,
  601        /// trying to read unreadable message
  602        BADMSG = 77,
  603        /// path name is too long
  604        NAMETOOLONG = 78,
  605        /// value too large to be stored in data type
  606        OVERFLOW = 79,
  607        /// given log. name not unique
  608        NOTUNIQ = 80,
  609        /// f.d. invalid for this operation
  610        BADFD = 81,
  611        /// Remote address changed
  612        REMCHG = 82,
  613
  614        // Stream Problems
  615        /// Device not a stream
  616        NOSTR = 60,
  617        /// no data (for no delay io)
  618        NODATA = 61,
  619        /// timer expired
  620        TIME = 62,
  621        /// out of streams resources
  622        NOSR = 63,
  623        /// Machine is not on the network
  624        NONET = 64,
  625        /// Package not installed
  626        NOPKG = 65,
  627        /// The object is remote
  628        REMOTE = 66,
  629        /// the link has been severed
  630        NOLINK = 67,
  631        /// advertise error
  632        ADV = 68,
  633        /// srmount error
  634        SRMNT = 69,
  635        /// Communication error on send
  636        COMM = 70,
  637        /// Protocol error
  638        PROTO = 71,
  639
  640        // Shared Library Problems
  641        /// Can't access a needed shared lib.
  642        LIBACC = 83,
  643        /// Accessing a corrupted shared lib.
  644        LIBBAD = 84,
  645        /// .lib section in a.out corrupted.
  646        LIBSCN = 85,
  647        /// Attempting to link in too many libs.
  648        LIBMAX = 86,
  649        /// Attempting to exec a shared library.
  650        LIBEXEC = 87,
  651        /// Illegal byte sequence.
  652        ILSEQ = 88,
  653        /// Unsupported file system operation
  654        NOSYS = 89,
  655        /// Symbolic link loop
  656        LOOP = 90,
  657        /// Restartable system call
  658        RESTART = 91,
  659        /// if pipe/FIFO, don't sleep in stream head
  660        STRPIPE = 92,
  661        /// directory not empty
  662        NOTEMPTY = 93,
  663        /// Too many users (for UFS)
  664        USERS = 94,
  665
  666        // BSD Networking Software
  667        // Argument Errors
  668        /// Socket operation on non-socket
  669        NOTSOCK = 95,
  670        /// Destination address required
  671        DESTADDRREQ = 96,
  672        /// Message too long
  673        MSGSIZE = 97,
  674        /// Protocol wrong type for socket
  675        PROTOTYPE = 98,
  676        /// Protocol not available
  677        NOPROTOOPT = 99,
  678        /// Protocol not supported
  679        PROTONOSUPPORT = 120,
  680        /// Socket type not supported
  681        SOCKTNOSUPPORT = 121,
  682        /// Operation not supported on socket
  683        OPNOTSUPP = 122,
  684        /// Protocol family not supported
  685        PFNOSUPPORT = 123,
  686        /// Address family not supported by
  687        AFNOSUPPORT = 124,
  688        /// Address already in use
  689        ADDRINUSE = 125,
  690        /// Can't assign requested address
  691        ADDRNOTAVAIL = 126,
  692
  693        // Operational Errors
  694        /// Network is down
  695        NETDOWN = 127,
  696        /// Network is unreachable
  697        NETUNREACH = 128,
  698        /// Network dropped connection because
  699        NETRESET = 129,
  700        /// Software caused connection abort
  701        CONNABORTED = 130,
  702        /// Connection reset by peer
  703        CONNRESET = 131,
  704        /// No buffer space available
  705        NOBUFS = 132,
  706        /// Socket is already connected
  707        ISCONN = 133,
  708        /// Socket is not connected
  709        NOTCONN = 134,
  710        /// Can't send after socket shutdown
  711        SHUTDOWN = 143,
  712        /// Too many references: can't splice
  713        TOOMANYREFS = 144,
  714        /// Connection timed out
  715        TIMEDOUT = 145,
  716        /// Connection refused
  717        CONNREFUSED = 146,
  718        /// Host is down
  719        HOSTDOWN = 147,
  720        /// No route to host
  721        HOSTUNREACH = 148,
  722        /// operation already in progress
  723        ALREADY = 149,
  724        /// operation now in progress
  725        INPROGRESS = 150,
  726
  727        // SUN Network File System
  728        /// Stale NFS file handle
  729        STALE = 151,
  730
  731        _,
  732    },
  733    .netbsd => netbsd.E,
  734    .dragonfly => dragonfly.E,
  735    .haiku => haiku.E,
  736    .openbsd => openbsd.E,
  737    // https://github.com/SerenityOS/serenity/blob/dd59fe35c7e5bbaf6b6b3acb3f9edc56619d4b66/Kernel/API/POSIX/errno.h
  738    .serenity => enum(c_int) {
  739        SUCCESS = 0,
  740        PERM = 1,
  741        NOENT = 2,
  742        SRCH = 3,
  743        INTR = 4,
  744        IO = 5,
  745        NXIO = 6,
  746        @"2BIG" = 7,
  747        NOEXEC = 8,
  748        BADF = 9,
  749        CHILD = 10,
  750        AGAIN = 11,
  751        NOMEM = 12,
  752        ACCES = 13,
  753        FAULT = 14,
  754        NOTBLK = 15,
  755        BUSY = 16,
  756        EXIST = 17,
  757        XDEV = 18,
  758        NODEV = 19,
  759        NOTDIR = 20,
  760        ISDIR = 21,
  761        INVAL = 22,
  762        NFILE = 23,
  763        MFILE = 24,
  764        NOTTY = 25,
  765        TXTBSY = 26,
  766        FBIG = 27,
  767        NOSPC = 28,
  768        SPIPE = 29,
  769        ROFS = 30,
  770        MLINK = 31,
  771        PIPE = 32,
  772        RANGE = 33,
  773        NAMETOOLONG = 34,
  774        LOOP = 35,
  775        OVERFLOW = 36,
  776        OPNOTSUPP = 37,
  777        NOSYS = 38,
  778        NOTIMPL = 39,
  779        AFNOSUPPORT = 40,
  780        NOTSOCK = 41,
  781        ADDRINUSE = 42,
  782        NOTEMPTY = 43,
  783        DOM = 44,
  784        CONNREFUSED = 45,
  785        HOSTDOWN = 46,
  786        ADDRNOTAVAIL = 47,
  787        ISCONN = 48,
  788        CONNABORTED = 49,
  789        ALREADY = 50,
  790        CONNRESET = 51,
  791        DESTADDRREQ = 52,
  792        HOSTUNREACH = 53,
  793        ILSEQ = 54,
  794        MSGSIZE = 55,
  795        NETDOWN = 56,
  796        NETUNREACH = 57,
  797        NETRESET = 58,
  798        NOBUFS = 59,
  799        NOLCK = 60,
  800        NOMSG = 61,
  801        NOPROTOOPT = 62,
  802        NOTCONN = 63,
  803        SHUTDOWN = 64,
  804        TOOMANYREFS = 65,
  805        SOCKTNOSUPPORT = 66,
  806        PROTONOSUPPORT = 67,
  807        DEADLK = 68,
  808        TIMEDOUT = 69,
  809        PROTOTYPE = 70,
  810        INPROGRESS = 71,
  811        NOTHREAD = 72,
  812        PROTO = 73,
  813        NOTSUP = 74,
  814        PFNOSUPPORT = 75,
  815        DIRINTOSELF = 76,
  816        DQUOT = 77,
  817        NOTRECOVERABLE = 78,
  818        CANCELED = 79,
  819        PROMISEVIOLATION = 80,
  820        STALE = 81,
  821        SRCNOTFOUND = 82,
  822        _,
  823    },
  824    else => void,
  825};
  826pub const Elf_Symndx = switch (native_os) {
  827    .linux => linux.Elf_Symndx,
  828    else => void,
  829};
  830/// Command flags for fcntl(2).
  831pub const F = switch (native_os) {
  832    .linux => linux.F,
  833    .emscripten => emscripten.F,
  834    .wasi => struct {
  835        // Match `F_*` constants from lib/libc/include/wasm-wasi-musl/__header_fcntl.h
  836        pub const GETFD = 1;
  837        pub const SETFD = 2;
  838        pub const GETFL = 3;
  839        pub const SETFL = 4;
  840    },
  841    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
  842        /// duplicate file descriptor
  843        pub const DUPFD = 0;
  844        /// get file descriptor flags
  845        pub const GETFD = 1;
  846        /// set file descriptor flags
  847        pub const SETFD = 2;
  848        /// get file status flags
  849        pub const GETFL = 3;
  850        /// set file status flags
  851        pub const SETFL = 4;
  852        /// get SIGIO/SIGURG proc/pgrp
  853        pub const GETOWN = 5;
  854        /// set SIGIO/SIGURG proc/pgrp
  855        pub const SETOWN = 6;
  856        /// get record locking information
  857        pub const GETLK = 7;
  858        /// set record locking information
  859        pub const SETLK = 8;
  860        /// F.SETLK; wait if blocked
  861        pub const SETLKW = 9;
  862        /// F.SETLK; wait if blocked, return on timeout
  863        pub const SETLKWTIMEOUT = 10;
  864        pub const FLUSH_DATA = 40;
  865        /// Used for regression test
  866        pub const CHKCLEAN = 41;
  867        /// Preallocate storage
  868        pub const PREALLOCATE = 42;
  869        /// Truncate a file without zeroing space
  870        pub const SETSIZE = 43;
  871        /// Issue an advisory read async with no copy to user
  872        pub const RDADVISE = 44;
  873        /// turn read ahead off/on for this fd
  874        pub const RDAHEAD = 45;
  875        /// turn data caching off/on for this fd
  876        pub const NOCACHE = 48;
  877        /// file offset to device offset
  878        pub const LOG2PHYS = 49;
  879        /// return the full path of the fd
  880        pub const GETPATH = 50;
  881        /// fsync + ask the drive to flush to the media
  882        pub const FULLFSYNC = 51;
  883        /// find which component (if any) is a package
  884        pub const PATHPKG_CHECK = 52;
  885        /// "freeze" all fs operations
  886        pub const FREEZE_FS = 53;
  887        /// "thaw" all fs operations
  888        pub const THAW_FS = 54;
  889        /// turn data caching off/on (globally) for this file
  890        pub const GLOBAL_NOCACHE = 55;
  891        /// add detached signatures
  892        pub const ADDSIGS = 59;
  893        /// add signature from same file (used by dyld for shared libs)
  894        pub const ADDFILESIGS = 61;
  895        /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchronous writes
  896        /// should not be used (i.e. its ok to temporarily create cached pages)
  897        pub const NODIRECT = 62;
  898        /// Get the protection class of a file from the EA, returns int
  899        pub const GETPROTECTIONCLASS = 63;
  900        /// Set the protection class of a file for the EA, requires int
  901        pub const SETPROTECTIONCLASS = 64;
  902        /// file offset to device offset, extended
  903        pub const LOG2PHYS_EXT = 65;
  904        /// get record locking information, per-process
  905        pub const GETLKPID = 66;
  906        /// Mark the file as being the backing store for another filesystem
  907        pub const SETBACKINGSTORE = 70;
  908        /// return the full path of the FD, but error in specific mtmd circumstances
  909        pub const GETPATH_MTMINFO = 71;
  910        /// Returns the code directory, with associated hashes, to the caller
  911        pub const GETCODEDIR = 72;
  912        /// No SIGPIPE generated on EPIPE
  913        pub const SETNOSIGPIPE = 73;
  914        /// Status of SIGPIPE for this fd
  915        pub const GETNOSIGPIPE = 74;
  916        /// For some cases, we need to rewrap the key for AKS/MKB
  917        pub const TRANSCODEKEY = 75;
  918        /// file being written to a by single writer... if throttling enabled, writes
  919        /// may be broken into smaller chunks with throttling in between
  920        pub const SINGLE_WRITER = 76;
  921        /// Get the protection version number for this filesystem
  922        pub const GETPROTECTIONLEVEL = 77;
  923        /// Add detached code signatures (used by dyld for shared libs)
  924        pub const FINDSIGS = 78;
  925        /// Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
  926        pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
  927        /// fsync + issue barrier to drive
  928        pub const BARRIERFSYNC = 85;
  929        /// Add signature from same file, return end offset in structure on success
  930        pub const ADDFILESIGS_RETURN = 97;
  931        /// Check if Library Validation allows this Mach-O file to be mapped into the calling process
  932        pub const CHECK_LV = 98;
  933        /// Deallocate a range of the file
  934        pub const PUNCHHOLE = 99;
  935        /// Trim an active file
  936        pub const TRIM_ACTIVE_FILE = 100;
  937        /// mark the dup with FD_CLOEXEC
  938        pub const DUPFD_CLOEXEC = 67;
  939        /// shared or read lock
  940        pub const RDLCK = 1;
  941        /// unlock
  942        pub const UNLCK = 2;
  943        /// exclusive or write lock
  944        pub const WRLCK = 3;
  945    },
  946    .freebsd => struct {
  947        /// Duplicate file descriptor.
  948        pub const DUPFD = 0;
  949        /// Get file descriptor flags.
  950        pub const GETFD = 1;
  951        /// Set file descriptor flags.
  952        pub const SETFD = 2;
  953        /// Get file status flags.
  954        pub const GETFL = 3;
  955        /// Set file status flags.
  956        pub const SETFL = 4;
  957
  958        /// Get SIGIO/SIGURG proc/pgrrp.
  959        pub const GETOWN = 5;
  960        /// Set SIGIO/SIGURG proc/pgrrp.
  961        pub const SETOWN = 6;
  962
  963        /// Get record locking information.
  964        pub const GETLK = 11;
  965        /// Set record locking information.
  966        pub const SETLK = 12;
  967        /// Set record locking information and wait if blocked.
  968        pub const SETLKW = 13;
  969
  970        /// Debugging support for remote locks.
  971        pub const SETLK_REMOTE = 14;
  972        /// Read ahead.
  973        pub const READAHEAD = 15;
  974
  975        /// DUPFD with FD_CLOEXEC set.
  976        pub const DUPFD_CLOEXEC = 17;
  977        /// DUP2FD with FD_CLOEXEC set.
  978        pub const DUP2FD_CLOEXEC = 18;
  979
  980        pub const ADD_SEALS = 19;
  981        pub const GET_SEALS = 20;
  982        /// Return `kinfo_file` for a file descriptor.
  983        pub const KINFO = 22;
  984
  985        // Seals (ADD_SEALS, GET_SEALS)
  986        /// Prevent adding sealings.
  987        pub const SEAL_SEAL = 0x0001;
  988        /// May not shrink
  989        pub const SEAL_SHRINK = 0x0002;
  990        /// May not grow.
  991        pub const SEAL_GROW = 0x0004;
  992        /// May not write.
  993        pub const SEAL_WRITE = 0x0008;
  994
  995        // Record locking flags (GETLK, SETLK, SETLKW).
  996        /// Shared or read lock.
  997        pub const RDLCK = 1;
  998        /// Unlock.
  999        pub const UNLCK = 2;
 1000        /// Exclusive or write lock.
 1001        pub const WRLCK = 3;
 1002        /// Purge locks for a given system ID.
 1003        pub const UNLCKSYS = 4;
 1004        /// Cancel an async lock request.
 1005        pub const CANCEL = 5;
 1006
 1007        pub const SETOWN_EX = 15;
 1008        pub const GETOWN_EX = 16;
 1009
 1010        pub const GETOWNER_UIDS = 17;
 1011    },
 1012    .illumos => struct {
 1013        /// Unlock a previously locked region
 1014        pub const ULOCK = 0;
 1015        /// Lock a region for exclusive use
 1016        pub const LOCK = 1;
 1017        /// Test and lock a region for exclusive use
 1018        pub const TLOCK = 2;
 1019        /// Test a region for other processes locks
 1020        pub const TEST = 3;
 1021
 1022        /// Duplicate fildes
 1023        pub const DUPFD = 0;
 1024        /// Get fildes flags
 1025        pub const GETFD = 1;
 1026        /// Set fildes flags
 1027        pub const SETFD = 2;
 1028        /// Get file flags
 1029        pub const GETFL = 3;
 1030        /// Get file flags including open-only flags
 1031        pub const GETXFL = 45;
 1032        /// Set file flags
 1033        pub const SETFL = 4;
 1034
 1035        /// Unused
 1036        pub const CHKFL = 8;
 1037        /// Duplicate fildes at third arg
 1038        pub const DUP2FD = 9;
 1039        /// Like DUP2FD with O_CLOEXEC set EINVAL is fildes matches arg1
 1040        pub const DUP2FD_CLOEXEC = 36;
 1041        /// Like DUPFD with O_CLOEXEC set
 1042        pub const DUPFD_CLOEXEC = 37;
 1043
 1044        /// Is the file desc. a stream ?
 1045        pub const ISSTREAM = 13;
 1046        /// Turn on private access to file
 1047        pub const PRIV = 15;
 1048        /// Turn off private access to file
 1049        pub const NPRIV = 16;
 1050        /// UFS quota call
 1051        pub const QUOTACTL = 17;
 1052        /// Get number of BLKSIZE blocks allocated
 1053        pub const BLOCKS = 18;
 1054        /// Get optimal I/O block size
 1055        pub const BLKSIZE = 19;
 1056        /// Get owner (socket emulation)
 1057        pub const GETOWN = 23;
 1058        /// Set owner (socket emulation)
 1059        pub const SETOWN = 24;
 1060        /// Object reuse revoke access to file desc.
 1061        pub const REVOKE = 25;
 1062        /// Does vp have NFS locks private to lock manager
 1063        pub const HASREMOTELOCKS = 26;
 1064
 1065        /// Set file lock
 1066        pub const SETLK = 6;
 1067        /// Set file lock and wait
 1068        pub const SETLKW = 7;
 1069        /// Allocate file space
 1070        pub const ALLOCSP = 10;
 1071        /// Free file space
 1072        pub const FREESP = 11;
 1073        /// Get file lock
 1074        pub const GETLK = 14;
 1075        /// Get file lock owned by file
 1076        pub const OFD_GETLK = 47;
 1077        /// Set file lock owned by file
 1078        pub const OFD_SETLK = 48;
 1079        /// Set file lock owned by file and wait
 1080        pub const OFD_SETLKW = 49;
 1081        /// Set a file share reservation
 1082        pub const SHARE = 40;
 1083        /// Remove a file share reservation
 1084        pub const UNSHARE = 41;
 1085        /// Create Poison FD
 1086        pub const BADFD = 46;
 1087
 1088        /// Read lock
 1089        pub const RDLCK = 1;
 1090        /// Write lock
 1091        pub const WRLCK = 2;
 1092        /// Remove lock(s)
 1093        pub const UNLCK = 3;
 1094        /// remove remote locks for a given system
 1095        pub const UNLKSYS = 4;
 1096
 1097        // f_access values
 1098        /// Read-only share access
 1099        pub const RDACC = 0x1;
 1100        /// Write-only share access
 1101        pub const WRACC = 0x2;
 1102        /// Read-Write share access
 1103        pub const RWACC = 0x3;
 1104
 1105        // f_deny values
 1106        /// Don't deny others access
 1107        pub const NODNY = 0x0;
 1108        /// Deny others read share access
 1109        pub const RDDNY = 0x1;
 1110        /// Deny others write share access
 1111        pub const WRDNY = 0x2;
 1112        /// Deny others read or write share access
 1113        pub const RWDNY = 0x3;
 1114        /// private flag: Deny delete share access
 1115        pub const RMDNY = 0x4;
 1116    },
 1117    .netbsd => struct {
 1118        pub const DUPFD = 0;
 1119        pub const GETFD = 1;
 1120        pub const SETFD = 2;
 1121        pub const GETFL = 3;
 1122        pub const SETFL = 4;
 1123        pub const GETOWN = 5;
 1124        pub const SETOWN = 6;
 1125        pub const GETLK = 7;
 1126        pub const SETLK = 8;
 1127        pub const SETLKW = 9;
 1128        pub const CLOSEM = 10;
 1129        pub const MAXFD = 11;
 1130        pub const DUPFD_CLOEXEC = 12;
 1131        pub const GETNOSIGPIPE = 13;
 1132        pub const SETNOSIGPIPE = 14;
 1133        pub const GETPATH = 15;
 1134
 1135        pub const RDLCK = 1;
 1136        pub const WRLCK = 3;
 1137        pub const UNLCK = 2;
 1138    },
 1139    .dragonfly => struct {
 1140        pub const ULOCK = 0;
 1141        pub const LOCK = 1;
 1142        pub const TLOCK = 2;
 1143        pub const TEST = 3;
 1144
 1145        pub const DUPFD = 0;
 1146        pub const GETFD = 1;
 1147        pub const RDLCK = 1;
 1148        pub const SETFD = 2;
 1149        pub const UNLCK = 2;
 1150        pub const WRLCK = 3;
 1151        pub const GETFL = 3;
 1152        pub const SETFL = 4;
 1153        pub const GETOWN = 5;
 1154        pub const SETOWN = 6;
 1155        pub const GETLK = 7;
 1156        pub const SETLK = 8;
 1157        pub const SETLKW = 9;
 1158        pub const DUP2FD = 10;
 1159        pub const DUPFD_CLOEXEC = 17;
 1160        pub const DUP2FD_CLOEXEC = 18;
 1161        pub const GETPATH = 19;
 1162    },
 1163    .haiku => struct {
 1164        pub const DUPFD = 0x0001;
 1165        pub const GETFD = 0x0002;
 1166        pub const SETFD = 0x0004;
 1167        pub const GETFL = 0x0008;
 1168        pub const SETFL = 0x0010;
 1169
 1170        pub const GETLK = 0x0020;
 1171        pub const SETLK = 0x0080;
 1172        pub const SETLKW = 0x0100;
 1173        pub const DUPFD_CLOEXEC = 0x0200;
 1174
 1175        pub const RDLCK = 0x0040;
 1176        pub const UNLCK = 0x0200;
 1177        pub const WRLCK = 0x0400;
 1178    },
 1179    .openbsd => struct {
 1180        pub const DUPFD = 0;
 1181        pub const GETFD = 1;
 1182        pub const SETFD = 2;
 1183        pub const GETFL = 3;
 1184        pub const SETFL = 4;
 1185
 1186        pub const GETOWN = 5;
 1187        pub const SETOWN = 6;
 1188
 1189        pub const GETLK = 7;
 1190        pub const SETLK = 8;
 1191        pub const SETLKW = 9;
 1192
 1193        pub const RDLCK = 1;
 1194        pub const UNLCK = 2;
 1195        pub const WRLCK = 3;
 1196    },
 1197    .serenity => struct {
 1198        // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L15-L24
 1199        pub const DUPFD = 0;
 1200        pub const GETFD = 1;
 1201        pub const SETFD = 2;
 1202        pub const GETFL = 3;
 1203        pub const SETFL = 4;
 1204        pub const ISTTY = 5;
 1205        pub const GETLK = 6;
 1206        pub const SETLK = 7;
 1207        pub const SETLKW = 8;
 1208        pub const DUPFD_CLOEXEC = 9;
 1209
 1210        // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L45-L47
 1211        pub const RDLCK = 0;
 1212        pub const WRLCK = 1;
 1213        pub const UNLCK = 2;
 1214    },
 1215    else => void,
 1216};
 1217pub const FD_CLOEXEC = switch (native_os) {
 1218    .linux => linux.FD_CLOEXEC,
 1219    .emscripten => emscripten.FD_CLOEXEC,
 1220    else => 1,
 1221};
 1222
 1223/// Test for existence of file.
 1224pub const F_OK = switch (native_os) {
 1225    .linux => linux.F_OK,
 1226    .emscripten => emscripten.F_OK,
 1227    else => 0,
 1228};
 1229/// Test for execute or search permission.
 1230pub const X_OK = switch (native_os) {
 1231    .linux => linux.X_OK,
 1232    .emscripten => emscripten.X_OK,
 1233    else => 1,
 1234};
 1235/// Test for write permission.
 1236pub const W_OK = switch (native_os) {
 1237    .linux => linux.W_OK,
 1238    .emscripten => emscripten.W_OK,
 1239    else => 2,
 1240};
 1241/// Test for read permission.
 1242pub const R_OK = switch (native_os) {
 1243    .linux => linux.R_OK,
 1244    .emscripten => emscripten.R_OK,
 1245    else => 4,
 1246};
 1247
 1248pub const Flock = switch (native_os) {
 1249    .linux => linux.Flock,
 1250    .emscripten => emscripten.Flock,
 1251    .openbsd, .dragonfly, .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 1252        start: off_t,
 1253        len: off_t,
 1254        pid: pid_t,
 1255        type: i16,
 1256        whence: i16,
 1257    },
 1258    .freebsd => extern struct {
 1259        /// Starting offset.
 1260        start: off_t,
 1261        /// Number of consecutive bytes to be locked.
 1262        /// A value of 0 means to the end of the file.
 1263        len: off_t,
 1264        /// Lock owner.
 1265        pid: pid_t,
 1266        /// Lock type.
 1267        type: i16,
 1268        /// Type of the start member.
 1269        whence: i16,
 1270        /// Remote system id or zero for local.
 1271        sysid: i32,
 1272    },
 1273    .illumos => extern struct {
 1274        type: c_short,
 1275        whence: c_short,
 1276        start: off_t,
 1277        // len == 0 means until end of file.
 1278        len: off_t,
 1279        sysid: c_int,
 1280        pid: pid_t,
 1281        __pad: [4]c_long,
 1282    },
 1283    .haiku => extern struct {
 1284        type: i16,
 1285        whence: i16,
 1286        start: off_t,
 1287        len: off_t,
 1288        pid: pid_t,
 1289    },
 1290    // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L54-L60
 1291    .serenity => extern struct {
 1292        type: c_short,
 1293        whence: c_short,
 1294        start: off_t,
 1295        len: off_t,
 1296        pid: pid_t,
 1297    },
 1298    else => void,
 1299};
 1300pub const HOST_NAME_MAX = switch (native_os) {
 1301    .linux => linux.HOST_NAME_MAX,
 1302    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 72,
 1303    .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd => 255,
 1304    // https://github.com/SerenityOS/serenity/blob/c87557e9c1865fa1a6440de34ff6ce6fc858a2b7/Kernel/API/POSIX/sys/limits.h#L22
 1305    .serenity => 64,
 1306    else => {},
 1307};
 1308pub const IOV_MAX = switch (native_os) {
 1309    .linux => linux.IOV_MAX,
 1310    .emscripten => emscripten.IOV_MAX,
 1311    // https://github.com/SerenityOS/serenity/blob/098af0f846a87b651731780ff48420205fd33754/Kernel/API/POSIX/sys/uio.h#L16
 1312    .openbsd, .haiku, .illumos, .wasi, .serenity => 1024,
 1313    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 16,
 1314    .dragonfly, .netbsd, .freebsd => KERN.IOV_MAX,
 1315    else => {},
 1316};
 1317pub const CTL = switch (native_os) {
 1318    .freebsd => struct {
 1319        pub const KERN = 1;
 1320        pub const DEBUG = 5;
 1321    },
 1322    .netbsd => struct {
 1323        pub const KERN = 1;
 1324        pub const DEBUG = 5;
 1325    },
 1326    .dragonfly => struct {
 1327        pub const UNSPEC = 0;
 1328        pub const KERN = 1;
 1329        pub const VM = 2;
 1330        pub const VFS = 3;
 1331        pub const NET = 4;
 1332        pub const DEBUG = 5;
 1333        pub const HW = 6;
 1334        pub const MACHDEP = 7;
 1335        pub const USER = 8;
 1336        pub const LWKT = 10;
 1337        pub const MAXID = 11;
 1338        pub const MAXNAME = 12;
 1339    },
 1340    .openbsd => struct {
 1341        pub const UNSPEC = 0;
 1342        pub const KERN = 1;
 1343        pub const VM = 2;
 1344        pub const FS = 3;
 1345        pub const NET = 4;
 1346        pub const DEBUG = 5;
 1347        pub const HW = 6;
 1348        pub const MACHDEP = 7;
 1349
 1350        pub const DDB = 9;
 1351        pub const VFS = 10;
 1352    },
 1353    else => void,
 1354};
 1355pub const KERN = switch (native_os) {
 1356    .freebsd => struct {
 1357        /// struct: process entries
 1358        pub const PROC = 14;
 1359        /// path to executable
 1360        pub const PROC_PATHNAME = 12;
 1361        /// file descriptors for process
 1362        pub const PROC_FILEDESC = 33;
 1363        pub const IOV_MAX = 35;
 1364    },
 1365    .netbsd => struct {
 1366        /// struct: process argv/env
 1367        pub const PROC_ARGS = 48;
 1368        /// path to executable
 1369        pub const PROC_PATHNAME = 5;
 1370        pub const IOV_MAX = 38;
 1371    },
 1372    .dragonfly => struct {
 1373        pub const PROC_ALL = 0;
 1374        pub const OSTYPE = 1;
 1375        pub const PROC_PID = 1;
 1376        pub const OSRELEASE = 2;
 1377        pub const PROC_PGRP = 2;
 1378        pub const OSREV = 3;
 1379        pub const PROC_SESSION = 3;
 1380        pub const VERSION = 4;
 1381        pub const PROC_TTY = 4;
 1382        pub const MAXVNODES = 5;
 1383        pub const PROC_UID = 5;
 1384        pub const MAXPROC = 6;
 1385        pub const PROC_RUID = 6;
 1386        pub const MAXFILES = 7;
 1387        pub const PROC_ARGS = 7;
 1388        pub const ARGMAX = 8;
 1389        pub const PROC_CWD = 8;
 1390        pub const PROC_PATHNAME = 9;
 1391        pub const SECURELVL = 9;
 1392        pub const PROC_SIGTRAMP = 10;
 1393        pub const HOSTNAME = 10;
 1394        pub const HOSTID = 11;
 1395        pub const CLOCKRATE = 12;
 1396        pub const VNODE = 13;
 1397        pub const PROC = 14;
 1398        pub const FILE = 15;
 1399        pub const PROC_FLAGMASK = 16;
 1400        pub const PROF = 16;
 1401        pub const PROC_FLAG_LWP = 16;
 1402        pub const POSIX1 = 17;
 1403        pub const NGROUPS = 18;
 1404        pub const JOB_CONTROL = 19;
 1405        pub const SAVED_IDS = 20;
 1406        pub const BOOTTIME = 21;
 1407        pub const NISDOMAINNAME = 22;
 1408        pub const UPDATEINTERVAL = 23;
 1409        pub const OSRELDATE = 24;
 1410        pub const NTP_PLL = 25;
 1411        pub const BOOTFILE = 26;
 1412        pub const MAXFILESPERPROC = 27;
 1413        pub const MAXPROCPERUID = 28;
 1414        pub const DUMPDEV = 29;
 1415        pub const IPC = 30;
 1416        pub const DUMMY = 31;
 1417        pub const PS_STRINGS = 32;
 1418        pub const USRSTACK = 33;
 1419        pub const LOGSIGEXIT = 34;
 1420        pub const IOV_MAX = 35;
 1421        pub const MAXPOSIXLOCKSPERUID = 36;
 1422        pub const MAXID = 37;
 1423    },
 1424    .openbsd => struct {
 1425        pub const OSTYPE = 1;
 1426        pub const OSRELEASE = 2;
 1427        pub const OSREV = 3;
 1428        pub const VERSION = 4;
 1429        pub const MAXVNODES = 5;
 1430        pub const MAXPROC = 6;
 1431        pub const MAXFILES = 7;
 1432        pub const ARGMAX = 8;
 1433        pub const SECURELVL = 9;
 1434        pub const HOSTNAME = 10;
 1435        pub const HOSTID = 11;
 1436        pub const CLOCKRATE = 12;
 1437
 1438        pub const PROF = 16;
 1439        pub const POSIX1 = 17;
 1440        pub const NGROUPS = 18;
 1441        pub const JOB_CONTROL = 19;
 1442        pub const SAVED_IDS = 20;
 1443        pub const BOOTTIME = 21;
 1444        pub const DOMAINNAME = 22;
 1445        pub const MAXPARTITIONS = 23;
 1446        pub const RAWPARTITION = 24;
 1447        pub const MAXTHREAD = 25;
 1448        pub const NTHREADS = 26;
 1449        pub const OSVERSION = 27;
 1450        pub const SOMAXCONN = 28;
 1451        pub const SOMINCONN = 29;
 1452
 1453        pub const NOSUIDCOREDUMP = 32;
 1454        pub const FSYNC = 33;
 1455        pub const SYSVMSG = 34;
 1456        pub const SYSVSEM = 35;
 1457        pub const SYSVSHM = 36;
 1458
 1459        pub const MSGBUFSIZE = 38;
 1460        pub const MALLOCSTATS = 39;
 1461        pub const CPTIME = 40;
 1462        pub const NCHSTATS = 41;
 1463        pub const FORKSTAT = 42;
 1464        pub const NSELCOLL = 43;
 1465        pub const TTY = 44;
 1466        pub const CCPU = 45;
 1467        pub const FSCALE = 46;
 1468        pub const NPROCS = 47;
 1469        pub const MSGBUF = 48;
 1470        pub const POOL = 49;
 1471        pub const STACKGAPRANDOM = 50;
 1472        pub const SYSVIPC_INFO = 51;
 1473        pub const ALLOWKMEM = 52;
 1474        pub const WITNESSWATCH = 53;
 1475        pub const SPLASSERT = 54;
 1476        pub const PROC_ARGS = 55;
 1477        pub const NFILES = 56;
 1478        pub const TTYCOUNT = 57;
 1479        pub const NUMVNODES = 58;
 1480        pub const MBSTAT = 59;
 1481        pub const WITNESS = 60;
 1482        pub const SEMINFO = 61;
 1483        pub const SHMINFO = 62;
 1484        pub const INTRCNT = 63;
 1485        pub const WATCHDOG = 64;
 1486        pub const ALLOWDT = 65;
 1487        pub const PROC = 66;
 1488        pub const MAXCLUSTERS = 67;
 1489        pub const EVCOUNT = 68;
 1490        pub const TIMECOUNTER = 69;
 1491        pub const MAXLOCKSPERUID = 70;
 1492        pub const CPTIME2 = 71;
 1493        pub const CACHEPCT = 72;
 1494        pub const FILE = 73;
 1495        pub const WXABORT = 74;
 1496        pub const CONSDEV = 75;
 1497        pub const NETLIVELOCKS = 76;
 1498        pub const POOL_DEBUG = 77;
 1499        pub const PROC_CWD = 78;
 1500        pub const PROC_NOBROADCASTKILL = 79;
 1501        pub const PROC_VMMAP = 80;
 1502        pub const GLOBAL_PTRACE = 81;
 1503        pub const CONSBUFSIZE = 82;
 1504        pub const CONSBUF = 83;
 1505        pub const AUDIO = 84;
 1506        pub const CPUSTATS = 85;
 1507        pub const PFSTATUS = 86;
 1508        pub const TIMEOUT_STATS = 87;
 1509        pub const UTC_OFFSET = 88;
 1510        pub const VIDEO = 89;
 1511
 1512        pub const PROC_ALL = 0;
 1513        pub const PROC_PID = 1;
 1514        pub const PROC_PGRP = 2;
 1515        pub const PROC_SESSION = 3;
 1516        pub const PROC_TTY = 4;
 1517        pub const PROC_UID = 5;
 1518        pub const PROC_RUID = 6;
 1519        pub const PROC_KTHREAD = 7;
 1520        pub const PROC_SHOW_THREADS = 0x40000000;
 1521
 1522        pub const PROC_ARGV = 1;
 1523        pub const PROC_NARGV = 2;
 1524        pub const PROC_ENV = 3;
 1525        pub const PROC_NENV = 4;
 1526    },
 1527    else => void,
 1528};
 1529pub const MADV = switch (native_os) {
 1530    .linux => linux.MADV,
 1531    .emscripten => emscripten.MADV,
 1532    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 1533        pub const NORMAL = 0;
 1534        pub const RANDOM = 1;
 1535        pub const SEQUENTIAL = 2;
 1536        pub const WILLNEED = 3;
 1537        pub const DONTNEED = 4;
 1538        pub const FREE = 5;
 1539        pub const ZERO_WIRED_PAGES = 6;
 1540        pub const FREE_REUSABLE = 7;
 1541        pub const FREE_REUSE = 8;
 1542        pub const CAN_REUSE = 9;
 1543        pub const PAGEOUT = 10;
 1544        pub const ZERO = 11;
 1545    },
 1546    .freebsd => struct {
 1547        pub const NORMAL = 0;
 1548        pub const RANDOM = 1;
 1549        pub const SEQUENTIAL = 2;
 1550        pub const WILLNEED = 3;
 1551        pub const DONTNEED = 4;
 1552        pub const FREE = 5;
 1553        pub const NOSYNC = 6;
 1554        pub const AUTOSYNC = 7;
 1555        pub const NOCORE = 8;
 1556        pub const CORE = 9;
 1557        pub const PROTECT = 10;
 1558    },
 1559    .illumos => struct {
 1560        /// no further special treatment
 1561        pub const NORMAL = 0;
 1562        /// expect random page references
 1563        pub const RANDOM = 1;
 1564        /// expect sequential page references
 1565        pub const SEQUENTIAL = 2;
 1566        /// will need these pages
 1567        pub const WILLNEED = 3;
 1568        /// don't need these pages
 1569        pub const DONTNEED = 4;
 1570        /// contents can be freed
 1571        pub const FREE = 5;
 1572        /// default access
 1573        pub const ACCESS_DEFAULT = 6;
 1574        /// next LWP to access heavily
 1575        pub const ACCESS_LWP = 7;
 1576        /// many processes to access heavily
 1577        pub const ACCESS_MANY = 8;
 1578        /// contents will be purged
 1579        pub const PURGE = 9;
 1580    },
 1581    .dragonfly => struct {
 1582        pub const SEQUENTIAL = 2;
 1583        pub const CONTROL_END = SETMAP;
 1584        pub const DONTNEED = 4;
 1585        pub const RANDOM = 1;
 1586        pub const WILLNEED = 3;
 1587        pub const NORMAL = 0;
 1588        pub const CONTROL_START = INVAL;
 1589        pub const FREE = 5;
 1590        pub const NOSYNC = 6;
 1591        pub const AUTOSYNC = 7;
 1592        pub const NOCORE = 8;
 1593        pub const CORE = 9;
 1594        pub const INVAL = 10;
 1595        pub const SETMAP = 11;
 1596    },
 1597    // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L35-L41
 1598    .serenity => struct {
 1599        pub const NORMAL = 0x0;
 1600        pub const SET_VOLATILE = 0x1;
 1601        pub const SET_NONVOLATILE = 0x2;
 1602        pub const DONTNEED = 0x3;
 1603        pub const WILLNEED = 0x4;
 1604        pub const SEQUENTIAL = 0x5;
 1605        pub const RANDOM = 0x6;
 1606    },
 1607    .netbsd, .openbsd => struct {
 1608        pub const NORMAL = 0;
 1609        pub const RANDOM = 1;
 1610        pub const SEQUENTIAL = 2;
 1611        pub const WILLNEED = 3;
 1612        pub const DONTNEED = 4;
 1613        pub const SPACEAVAIL = 5;
 1614        pub const FREE = 6;
 1615    },
 1616    else => void,
 1617};
 1618pub const MCL = switch (native_os) {
 1619    .linux => linux.MCL,
 1620    // https://github.com/freebsd/freebsd-src/blob/39fea5c8dc598021e900c4feaf0e18111fda57b2/sys/sys/mman.h#L133
 1621    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/088552723935447397400336f5ddb7aa5f5de660/sys/sys/mman.h#L118
 1622    // https://github.com/NetBSD/src/blob/fd2741deca927c18e3ba15acdf78b8b14b2abe36/sys/sys/mman.h#L179
 1623    // https://github.com/openbsd/src/blob/39404228f6d36c0ca4be5f04ab5385568ebd6aa3/sys/sys/mman.h#L129
 1624    // https://github.com/illumos/illumos-gate/blob/5280477614f83fea20fc938729df6adb3e44340d/usr/src/uts/common/sys/mman.h#L343
 1625    .freebsd, .dragonfly, .netbsd, .openbsd, .illumos => packed struct(c_int) {
 1626        CURRENT: bool = 0,
 1627        FUTURE: bool = 0,
 1628        _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 2) = 0,
 1629    },
 1630    else => void,
 1631};
 1632pub const MLOCK = switch (native_os) {
 1633    .linux => linux.MLOCK,
 1634    else => void,
 1635};
 1636pub const MSF = switch (native_os) {
 1637    .linux => linux.MSF,
 1638    .emscripten => emscripten.MSF,
 1639    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 1640        pub const ASYNC = 0x1;
 1641        pub const INVALIDATE = 0x2;
 1642        /// invalidate, leave mapped
 1643        pub const KILLPAGES = 0x4;
 1644        /// deactivate, leave mapped
 1645        pub const DEACTIVATE = 0x8;
 1646        pub const SYNC = 0x10;
 1647    },
 1648    .freebsd, .dragonfly => struct {
 1649        pub const SYNC = 0;
 1650        pub const ASYNC = 1;
 1651        pub const INVALIDATE = 2;
 1652    },
 1653    .openbsd => struct {
 1654        pub const ASYNC = 1;
 1655        pub const SYNC = 2;
 1656        pub const INVALIDATE = 4;
 1657    },
 1658    .haiku, .netbsd, .illumos => struct {
 1659        pub const ASYNC = 1;
 1660        pub const INVALIDATE = 2;
 1661        pub const SYNC = 4;
 1662    },
 1663    // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L50-L52
 1664    .serenity => struct {
 1665        pub const SYNC = 1;
 1666        pub const ASYNC = 2;
 1667        pub const INVALIDATE = 4;
 1668    },
 1669    else => void,
 1670};
 1671pub const NAME_MAX = switch (native_os) {
 1672    .linux => linux.NAME_MAX,
 1673    .emscripten => emscripten.NAME_MAX,
 1674    // Haiku's headers make this 256, to contain room for the terminating null
 1675    // character, but POSIX definition says that NAME_MAX does not include the
 1676    // terminating null.
 1677    // https://github.com/SerenityOS/serenity/blob/c87557e9c1865fa1a6440de34ff6ce6fc858a2b7/Kernel/API/POSIX/sys/limits.h#L20
 1678    .haiku, .openbsd, .dragonfly, .netbsd, .illumos, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 255,
 1679    else => {},
 1680};
 1681pub const PATH_MAX = switch (native_os) {
 1682    .linux => linux.PATH_MAX,
 1683    .emscripten => emscripten.PATH_MAX,
 1684    .wasi => 4096,
 1685    .windows => 260,
 1686    .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 1024,
 1687    else => {},
 1688};
 1689
 1690pub const POLL = switch (native_os) {
 1691    .linux => linux.POLL,
 1692    .emscripten => emscripten.POLL,
 1693    .wasi => struct {
 1694        pub const RDNORM = 0x1;
 1695        pub const WRNORM = 0x2;
 1696        pub const IN = RDNORM;
 1697        pub const OUT = WRNORM;
 1698        pub const ERR = 0x1000;
 1699        pub const HUP = 0x2000;
 1700        pub const NVAL = 0x4000;
 1701    },
 1702    .windows => ws2_32.POLL,
 1703    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 1704        pub const IN = 0x001;
 1705        pub const PRI = 0x002;
 1706        pub const OUT = 0x004;
 1707        pub const RDNORM = 0x040;
 1708        pub const WRNORM = OUT;
 1709        pub const RDBAND = 0x080;
 1710        pub const WRBAND = 0x100;
 1711
 1712        pub const EXTEND = 0x0200;
 1713        pub const ATTRIB = 0x0400;
 1714        pub const NLINK = 0x0800;
 1715        pub const WRITE = 0x1000;
 1716
 1717        pub const ERR = 0x008;
 1718        pub const HUP = 0x010;
 1719        pub const NVAL = 0x020;
 1720
 1721        pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
 1722    },
 1723    .freebsd => struct {
 1724        /// any readable data available.
 1725        pub const IN = 0x0001;
 1726        /// OOB/Urgent readable data.
 1727        pub const PRI = 0x0002;
 1728        /// file descriptor is writeable.
 1729        pub const OUT = 0x0004;
 1730        /// non-OOB/URG data available.
 1731        pub const RDNORM = 0x0040;
 1732        /// no write type differentiation.
 1733        pub const WRNORM = OUT;
 1734        /// OOB/Urgent readable data.
 1735        pub const RDBAND = 0x0080;
 1736        /// OOB/Urgent data can be written.
 1737        pub const WRBAND = 0x0100;
 1738        /// like IN, except ignore EOF.
 1739        pub const INIGNEOF = 0x2000;
 1740        /// some poll error occurred.
 1741        pub const ERR = 0x0008;
 1742        /// file descriptor was "hung up".
 1743        pub const HUP = 0x0010;
 1744        /// requested events "invalid".
 1745        pub const NVAL = 0x0020;
 1746
 1747        pub const STANDARD = IN | PRI | OUT | RDNORM | RDBAND | WRBAND | ERR | HUP | NVAL;
 1748    },
 1749    .illumos => struct {
 1750        pub const IN = 0x0001;
 1751        pub const PRI = 0x0002;
 1752        pub const OUT = 0x0004;
 1753        pub const RDNORM = 0x0040;
 1754        pub const WRNORM = .OUT;
 1755        pub const RDBAND = 0x0080;
 1756        pub const WRBAND = 0x0100;
 1757        /// Read-side hangup.
 1758        pub const RDHUP = 0x4000;
 1759
 1760        /// Non-testable events (may not be specified in events).
 1761        pub const ERR = 0x0008;
 1762        pub const HUP = 0x0010;
 1763        pub const NVAL = 0x0020;
 1764
 1765        /// Events to control `/dev/poll` (not specified in revents)
 1766        pub const REMOVE = 0x0800;
 1767        pub const ONESHOT = 0x1000;
 1768        pub const ET = 0x2000;
 1769    },
 1770    .dragonfly, .netbsd => struct {
 1771        /// Testable events (may be specified in events field).
 1772        pub const IN = 0x0001;
 1773        pub const PRI = 0x0002;
 1774        pub const OUT = 0x0004;
 1775        pub const RDNORM = 0x0040;
 1776        pub const WRNORM = OUT;
 1777        pub const RDBAND = 0x0080;
 1778        pub const WRBAND = 0x0100;
 1779
 1780        /// Non-testable events (may not be specified in events field).
 1781        pub const ERR = 0x0008;
 1782        pub const HUP = 0x0010;
 1783        pub const NVAL = 0x0020;
 1784    },
 1785    .haiku => struct {
 1786        /// any readable data available
 1787        pub const IN = 0x0001;
 1788        /// file descriptor is writeable
 1789        pub const OUT = 0x0002;
 1790        pub const RDNORM = IN;
 1791        pub const WRNORM = OUT;
 1792        /// priority readable data
 1793        pub const RDBAND = 0x0008;
 1794        /// priority data can be written
 1795        pub const WRBAND = 0x0010;
 1796        /// high priority readable data
 1797        pub const PRI = 0x0020;
 1798
 1799        /// errors pending
 1800        pub const ERR = 0x0004;
 1801        /// disconnected
 1802        pub const HUP = 0x0080;
 1803        /// invalid file descriptor
 1804        pub const NVAL = 0x1000;
 1805    },
 1806    .openbsd => struct {
 1807        pub const IN = 0x0001;
 1808        pub const PRI = 0x0002;
 1809        pub const OUT = 0x0004;
 1810        pub const ERR = 0x0008;
 1811        pub const HUP = 0x0010;
 1812        pub const NVAL = 0x0020;
 1813        pub const RDNORM = 0x0040;
 1814        pub const NORM = RDNORM;
 1815        pub const WRNORM = OUT;
 1816        pub const RDBAND = 0x0080;
 1817        pub const WRBAND = 0x0100;
 1818    },
 1819    // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L15-L24
 1820    .serenity => struct {
 1821        pub const IN = 0x0001;
 1822        pub const PRI = 0x0002;
 1823        pub const OUT = 0x0004;
 1824        pub const ERR = 0x0008;
 1825        pub const HUP = 0x0010;
 1826        pub const NVAL = 0x0020;
 1827        pub const RDNORM = IN;
 1828        pub const WRNORM = OUT;
 1829        pub const WRBAND = 0x1000;
 1830        pub const RDHUP = 0x2000;
 1831    },
 1832    else => void,
 1833};
 1834
 1835/// Basic memory protection flags
 1836pub const PROT = switch (native_os) {
 1837    .linux => linux.PROT,
 1838    .emscripten => emscripten.PROT,
 1839    // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L28-L31
 1840    .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd, .windows, .serenity => struct {
 1841        /// page can not be accessed
 1842        pub const NONE = 0x0;
 1843        /// page can be read
 1844        pub const READ = 0x1;
 1845        /// page can be written
 1846        pub const WRITE = 0x2;
 1847        /// page can be executed
 1848        pub const EXEC = 0x4;
 1849    },
 1850    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 1851        /// [MC2] no permissions
 1852        pub const NONE: vm_prot_t = 0x00;
 1853        /// [MC2] pages can be read
 1854        pub const READ: vm_prot_t = 0x01;
 1855        /// [MC2] pages can be written
 1856        pub const WRITE: vm_prot_t = 0x02;
 1857        /// [MC2] pages can be executed
 1858        pub const EXEC: vm_prot_t = 0x04;
 1859        /// When a caller finds that they cannot obtain write permission on a
 1860        /// mapped entry, the following flag can be used. The entry will be
 1861        /// made "needs copy" effectively copying the object (using COW),
 1862        /// and write permission will be added to the maximum protections for
 1863        /// the associated entry.
 1864        pub const COPY: vm_prot_t = 0x10;
 1865    },
 1866    else => void,
 1867};
 1868
 1869pub const RLIM = switch (native_os) {
 1870    .linux => linux.RLIM,
 1871    .emscripten => emscripten.RLIM,
 1872    // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L52
 1873    .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => struct {
 1874        /// No limit
 1875        pub const INFINITY: rlim_t = (1 << 63) - 1;
 1876
 1877        pub const SAVED_MAX = INFINITY;
 1878        pub const SAVED_CUR = INFINITY;
 1879    },
 1880    .illumos => struct {
 1881        /// No limit
 1882        pub const INFINITY: rlim_t = (1 << 63) - 3;
 1883        pub const SAVED_MAX: rlim_t = (1 << 63) - 2;
 1884        pub const SAVED_CUR: rlim_t = (1 << 63) - 1;
 1885    },
 1886    else => void,
 1887};
 1888pub const S = switch (native_os) {
 1889    .linux => linux.S,
 1890    .emscripten => emscripten.S,
 1891    .wasi => struct {
 1892        // Match `S_*` constants from lib/libc/include/wasm-wasi-musl/__mode_t.h
 1893        pub const IFBLK = 0x6000;
 1894        pub const IFCHR = 0x2000;
 1895        pub const IFDIR = 0x4000;
 1896        pub const IFIFO = 0x1000;
 1897        pub const IFLNK = 0xa000;
 1898        pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK;
 1899        pub const IFREG = 0x8000;
 1900        pub const IFSOCK = 0xc000;
 1901
 1902        pub fn ISBLK(m: u32) bool {
 1903            return m & IFMT == IFBLK;
 1904        }
 1905
 1906        pub fn ISCHR(m: u32) bool {
 1907            return m & IFMT == IFCHR;
 1908        }
 1909
 1910        pub fn ISDIR(m: u32) bool {
 1911            return m & IFMT == IFDIR;
 1912        }
 1913
 1914        pub fn ISFIFO(m: u32) bool {
 1915            return m & IFMT == IFIFO;
 1916        }
 1917
 1918        pub fn ISLNK(m: u32) bool {
 1919            return m & IFMT == IFLNK;
 1920        }
 1921
 1922        pub fn ISREG(m: u32) bool {
 1923            return m & IFMT == IFREG;
 1924        }
 1925
 1926        pub fn ISSOCK(m: u32) bool {
 1927            return m & IFMT == IFSOCK;
 1928        }
 1929    },
 1930    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 1931        pub const IFMT = 0o170000;
 1932
 1933        pub const IFIFO = 0o010000;
 1934        pub const IFCHR = 0o020000;
 1935        pub const IFDIR = 0o040000;
 1936        pub const IFBLK = 0o060000;
 1937        pub const IFREG = 0o100000;
 1938        pub const IFLNK = 0o120000;
 1939        pub const IFSOCK = 0o140000;
 1940        pub const IFWHT = 0o160000;
 1941
 1942        pub const ISUID = 0o4000;
 1943        pub const ISGID = 0o2000;
 1944        pub const ISVTX = 0o1000;
 1945        pub const IRWXU = 0o700;
 1946        pub const IRUSR = 0o400;
 1947        pub const IWUSR = 0o200;
 1948        pub const IXUSR = 0o100;
 1949        pub const IRWXG = 0o070;
 1950        pub const IRGRP = 0o040;
 1951        pub const IWGRP = 0o020;
 1952        pub const IXGRP = 0o010;
 1953        pub const IRWXO = 0o007;
 1954        pub const IROTH = 0o004;
 1955        pub const IWOTH = 0o002;
 1956        pub const IXOTH = 0o001;
 1957
 1958        pub fn ISFIFO(m: u32) bool {
 1959            return m & IFMT == IFIFO;
 1960        }
 1961
 1962        pub fn ISCHR(m: u32) bool {
 1963            return m & IFMT == IFCHR;
 1964        }
 1965
 1966        pub fn ISDIR(m: u32) bool {
 1967            return m & IFMT == IFDIR;
 1968        }
 1969
 1970        pub fn ISBLK(m: u32) bool {
 1971            return m & IFMT == IFBLK;
 1972        }
 1973
 1974        pub fn ISREG(m: u32) bool {
 1975            return m & IFMT == IFREG;
 1976        }
 1977
 1978        pub fn ISLNK(m: u32) bool {
 1979            return m & IFMT == IFLNK;
 1980        }
 1981
 1982        pub fn ISSOCK(m: u32) bool {
 1983            return m & IFMT == IFSOCK;
 1984        }
 1985
 1986        pub fn IWHT(m: u32) bool {
 1987            return m & IFMT == IFWHT;
 1988        }
 1989    },
 1990    .freebsd => struct {
 1991        pub const IFMT = 0o170000;
 1992
 1993        pub const IFIFO = 0o010000;
 1994        pub const IFCHR = 0o020000;
 1995        pub const IFDIR = 0o040000;
 1996        pub const IFBLK = 0o060000;
 1997        pub const IFREG = 0o100000;
 1998        pub const IFLNK = 0o120000;
 1999        pub const IFSOCK = 0o140000;
 2000        pub const IFWHT = 0o160000;
 2001
 2002        pub const ISUID = 0o4000;
 2003        pub const ISGID = 0o2000;
 2004        pub const ISVTX = 0o1000;
 2005        pub const IRWXU = 0o700;
 2006        pub const IRUSR = 0o400;
 2007        pub const IWUSR = 0o200;
 2008        pub const IXUSR = 0o100;
 2009        pub const IRWXG = 0o070;
 2010        pub const IRGRP = 0o040;
 2011        pub const IWGRP = 0o020;
 2012        pub const IXGRP = 0o010;
 2013        pub const IRWXO = 0o007;
 2014        pub const IROTH = 0o004;
 2015        pub const IWOTH = 0o002;
 2016        pub const IXOTH = 0o001;
 2017
 2018        pub fn ISFIFO(m: u32) bool {
 2019            return m & IFMT == IFIFO;
 2020        }
 2021
 2022        pub fn ISCHR(m: u32) bool {
 2023            return m & IFMT == IFCHR;
 2024        }
 2025
 2026        pub fn ISDIR(m: u32) bool {
 2027            return m & IFMT == IFDIR;
 2028        }
 2029
 2030        pub fn ISBLK(m: u32) bool {
 2031            return m & IFMT == IFBLK;
 2032        }
 2033
 2034        pub fn ISREG(m: u32) bool {
 2035            return m & IFMT == IFREG;
 2036        }
 2037
 2038        pub fn ISLNK(m: u32) bool {
 2039            return m & IFMT == IFLNK;
 2040        }
 2041
 2042        pub fn ISSOCK(m: u32) bool {
 2043            return m & IFMT == IFSOCK;
 2044        }
 2045
 2046        pub fn IWHT(m: u32) bool {
 2047            return m & IFMT == IFWHT;
 2048        }
 2049    },
 2050    .illumos => struct {
 2051        pub const IFMT = 0o170000;
 2052
 2053        pub const IFIFO = 0o010000;
 2054        pub const IFCHR = 0o020000;
 2055        pub const IFDIR = 0o040000;
 2056        pub const IFBLK = 0o060000;
 2057        pub const IFREG = 0o100000;
 2058        pub const IFLNK = 0o120000;
 2059        pub const IFSOCK = 0o140000;
 2060        /// SunOS 2.6 Door
 2061        pub const IFDOOR = 0o150000;
 2062        /// Solaris 10 Event Port
 2063        pub const IFPORT = 0o160000;
 2064
 2065        pub const ISUID = 0o4000;
 2066        pub const ISGID = 0o2000;
 2067        pub const ISVTX = 0o1000;
 2068        pub const IRWXU = 0o700;
 2069        pub const IRUSR = 0o400;
 2070        pub const IWUSR = 0o200;
 2071        pub const IXUSR = 0o100;
 2072        pub const IRWXG = 0o070;
 2073        pub const IRGRP = 0o040;
 2074        pub const IWGRP = 0o020;
 2075        pub const IXGRP = 0o010;
 2076        pub const IRWXO = 0o007;
 2077        pub const IROTH = 0o004;
 2078        pub const IWOTH = 0o002;
 2079        pub const IXOTH = 0o001;
 2080
 2081        pub fn ISFIFO(m: u32) bool {
 2082            return m & IFMT == IFIFO;
 2083        }
 2084
 2085        pub fn ISCHR(m: u32) bool {
 2086            return m & IFMT == IFCHR;
 2087        }
 2088
 2089        pub fn ISDIR(m: u32) bool {
 2090            return m & IFMT == IFDIR;
 2091        }
 2092
 2093        pub fn ISBLK(m: u32) bool {
 2094            return m & IFMT == IFBLK;
 2095        }
 2096
 2097        pub fn ISREG(m: u32) bool {
 2098            return m & IFMT == IFREG;
 2099        }
 2100
 2101        pub fn ISLNK(m: u32) bool {
 2102            return m & IFMT == IFLNK;
 2103        }
 2104
 2105        pub fn ISSOCK(m: u32) bool {
 2106            return m & IFMT == IFSOCK;
 2107        }
 2108
 2109        pub fn ISDOOR(m: u32) bool {
 2110            return m & IFMT == IFDOOR;
 2111        }
 2112
 2113        pub fn ISPORT(m: u32) bool {
 2114            return m & IFMT == IFPORT;
 2115        }
 2116    },
 2117    .netbsd => struct {
 2118        pub const IFMT = 0o170000;
 2119
 2120        pub const IFIFO = 0o010000;
 2121        pub const IFCHR = 0o020000;
 2122        pub const IFDIR = 0o040000;
 2123        pub const IFBLK = 0o060000;
 2124        pub const IFREG = 0o100000;
 2125        pub const IFLNK = 0o120000;
 2126        pub const IFSOCK = 0o140000;
 2127        pub const IFWHT = 0o160000;
 2128
 2129        pub const ISUID = 0o4000;
 2130        pub const ISGID = 0o2000;
 2131        pub const ISVTX = 0o1000;
 2132        pub const IRWXU = 0o700;
 2133        pub const IRUSR = 0o400;
 2134        pub const IWUSR = 0o200;
 2135        pub const IXUSR = 0o100;
 2136        pub const IRWXG = 0o070;
 2137        pub const IRGRP = 0o040;
 2138        pub const IWGRP = 0o020;
 2139        pub const IXGRP = 0o010;
 2140        pub const IRWXO = 0o007;
 2141        pub const IROTH = 0o004;
 2142        pub const IWOTH = 0o002;
 2143        pub const IXOTH = 0o001;
 2144
 2145        pub fn ISFIFO(m: u32) bool {
 2146            return m & IFMT == IFIFO;
 2147        }
 2148
 2149        pub fn ISCHR(m: u32) bool {
 2150            return m & IFMT == IFCHR;
 2151        }
 2152
 2153        pub fn ISDIR(m: u32) bool {
 2154            return m & IFMT == IFDIR;
 2155        }
 2156
 2157        pub fn ISBLK(m: u32) bool {
 2158            return m & IFMT == IFBLK;
 2159        }
 2160
 2161        pub fn ISREG(m: u32) bool {
 2162            return m & IFMT == IFREG;
 2163        }
 2164
 2165        pub fn ISLNK(m: u32) bool {
 2166            return m & IFMT == IFLNK;
 2167        }
 2168
 2169        pub fn ISSOCK(m: u32) bool {
 2170            return m & IFMT == IFSOCK;
 2171        }
 2172
 2173        pub fn IWHT(m: u32) bool {
 2174            return m & IFMT == IFWHT;
 2175        }
 2176    },
 2177    .dragonfly => struct {
 2178        pub const IFMT = 0o170000;
 2179
 2180        pub const IFIFO = 0o010000;
 2181        pub const IFCHR = 0o020000;
 2182        pub const IFDIR = 0o040000;
 2183        pub const IFBLK = 0o060000;
 2184        pub const IFREG = 0o100000;
 2185        pub const IFLNK = 0o120000;
 2186        pub const IFSOCK = 0o140000;
 2187        pub const IFWHT = 0o160000;
 2188
 2189        pub const ISUID = 0o4000;
 2190        pub const ISGID = 0o2000;
 2191        pub const ISVTX = 0o1000;
 2192        pub const IRWXU = 0o700;
 2193        pub const IRUSR = 0o400;
 2194        pub const IWUSR = 0o200;
 2195        pub const IXUSR = 0o100;
 2196        pub const IRWXG = 0o070;
 2197        pub const IRGRP = 0o040;
 2198        pub const IWGRP = 0o020;
 2199        pub const IXGRP = 0o010;
 2200        pub const IRWXO = 0o007;
 2201        pub const IROTH = 0o004;
 2202        pub const IWOTH = 0o002;
 2203        pub const IXOTH = 0o001;
 2204
 2205        pub const IREAD = IRUSR;
 2206        pub const IEXEC = IXUSR;
 2207        pub const IWRITE = IWUSR;
 2208        pub const ISTXT = 512;
 2209        pub const BLKSIZE = 512;
 2210
 2211        pub fn ISFIFO(m: u32) bool {
 2212            return m & IFMT == IFIFO;
 2213        }
 2214
 2215        pub fn ISCHR(m: u32) bool {
 2216            return m & IFMT == IFCHR;
 2217        }
 2218
 2219        pub fn ISDIR(m: u32) bool {
 2220            return m & IFMT == IFDIR;
 2221        }
 2222
 2223        pub fn ISBLK(m: u32) bool {
 2224            return m & IFMT == IFBLK;
 2225        }
 2226
 2227        pub fn ISREG(m: u32) bool {
 2228            return m & IFMT == IFREG;
 2229        }
 2230
 2231        pub fn ISLNK(m: u32) bool {
 2232            return m & IFMT == IFLNK;
 2233        }
 2234
 2235        pub fn ISSOCK(m: u32) bool {
 2236            return m & IFMT == IFSOCK;
 2237        }
 2238
 2239        pub fn IWHT(m: u32) bool {
 2240            return m & IFMT == IFWHT;
 2241        }
 2242    },
 2243    .haiku => struct {
 2244        pub const IFMT = 0o170000;
 2245        pub const IFSOCK = 0o140000;
 2246        pub const IFLNK = 0o120000;
 2247        pub const IFREG = 0o100000;
 2248        pub const IFBLK = 0o060000;
 2249        pub const IFDIR = 0o040000;
 2250        pub const IFCHR = 0o020000;
 2251        pub const IFIFO = 0o010000;
 2252        pub const INDEX_DIR = 0o4000000000;
 2253
 2254        pub const IUMSK = 0o7777;
 2255        pub const ISUID = 0o4000;
 2256        pub const ISGID = 0o2000;
 2257        pub const ISVTX = 0o1000;
 2258        pub const IRWXU = 0o700;
 2259        pub const IRUSR = 0o400;
 2260        pub const IWUSR = 0o200;
 2261        pub const IXUSR = 0o100;
 2262        pub const IRWXG = 0o070;
 2263        pub const IRGRP = 0o040;
 2264        pub const IWGRP = 0o020;
 2265        pub const IXGRP = 0o010;
 2266        pub const IRWXO = 0o007;
 2267        pub const IROTH = 0o004;
 2268        pub const IWOTH = 0o002;
 2269        pub const IXOTH = 0o001;
 2270
 2271        pub fn ISREG(m: u32) bool {
 2272            return m & IFMT == IFREG;
 2273        }
 2274
 2275        pub fn ISLNK(m: u32) bool {
 2276            return m & IFMT == IFLNK;
 2277        }
 2278
 2279        pub fn ISBLK(m: u32) bool {
 2280            return m & IFMT == IFBLK;
 2281        }
 2282
 2283        pub fn ISDIR(m: u32) bool {
 2284            return m & IFMT == IFDIR;
 2285        }
 2286
 2287        pub fn ISCHR(m: u32) bool {
 2288            return m & IFMT == IFCHR;
 2289        }
 2290
 2291        pub fn ISFIFO(m: u32) bool {
 2292            return m & IFMT == IFIFO;
 2293        }
 2294
 2295        pub fn ISSOCK(m: u32) bool {
 2296            return m & IFMT == IFSOCK;
 2297        }
 2298
 2299        pub fn ISINDEX(m: u32) bool {
 2300            return m & INDEX_DIR == INDEX_DIR;
 2301        }
 2302    },
 2303    .openbsd => struct {
 2304        pub const IFMT = 0o170000;
 2305
 2306        pub const IFIFO = 0o010000;
 2307        pub const IFCHR = 0o020000;
 2308        pub const IFDIR = 0o040000;
 2309        pub const IFBLK = 0o060000;
 2310        pub const IFREG = 0o100000;
 2311        pub const IFLNK = 0o120000;
 2312        pub const IFSOCK = 0o140000;
 2313
 2314        pub const ISUID = 0o4000;
 2315        pub const ISGID = 0o2000;
 2316        pub const ISVTX = 0o1000;
 2317        pub const IRWXU = 0o700;
 2318        pub const IRUSR = 0o400;
 2319        pub const IWUSR = 0o200;
 2320        pub const IXUSR = 0o100;
 2321        pub const IRWXG = 0o070;
 2322        pub const IRGRP = 0o040;
 2323        pub const IWGRP = 0o020;
 2324        pub const IXGRP = 0o010;
 2325        pub const IRWXO = 0o007;
 2326        pub const IROTH = 0o004;
 2327        pub const IWOTH = 0o002;
 2328        pub const IXOTH = 0o001;
 2329
 2330        pub fn ISFIFO(m: u32) bool {
 2331            return m & IFMT == IFIFO;
 2332        }
 2333
 2334        pub fn ISCHR(m: u32) bool {
 2335            return m & IFMT == IFCHR;
 2336        }
 2337
 2338        pub fn ISDIR(m: u32) bool {
 2339            return m & IFMT == IFDIR;
 2340        }
 2341
 2342        pub fn ISBLK(m: u32) bool {
 2343            return m & IFMT == IFBLK;
 2344        }
 2345
 2346        pub fn ISREG(m: u32) bool {
 2347            return m & IFMT == IFREG;
 2348        }
 2349
 2350        pub fn ISLNK(m: u32) bool {
 2351            return m & IFMT == IFLNK;
 2352        }
 2353
 2354        pub fn ISSOCK(m: u32) bool {
 2355            return m & IFMT == IFSOCK;
 2356        }
 2357    },
 2358    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L16-L51
 2359    .serenity => struct {
 2360        pub const IFMT = 0o170000;
 2361        pub const IFDIR = 0o040000;
 2362        pub const IFCHR = 0o020000;
 2363        pub const IFBLK = 0o060000;
 2364        pub const IFREG = 0o100000;
 2365        pub const IFIFO = 0o010000;
 2366        pub const IFLNK = 0o120000;
 2367        pub const IFSOCK = 0o140000;
 2368
 2369        pub const ISUID = 0o4000;
 2370        pub const ISGID = 0o2000;
 2371        pub const ISVTX = 0o1000;
 2372        pub const IRUSR = 0o400;
 2373        pub const IWUSR = 0o200;
 2374        pub const IXUSR = 0o100;
 2375        pub const IREAD = IRUSR;
 2376        pub const IWRITE = IWUSR;
 2377        pub const IEXEC = IXUSR;
 2378        pub const IRGRP = 0o040;
 2379        pub const IWGRP = 0o020;
 2380        pub const IXGRP = 0o010;
 2381        pub const IROTH = 0o004;
 2382        pub const IWOTH = 0o002;
 2383        pub const IXOTH = 0o001;
 2384
 2385        pub const IRWXU = IRUSR | IWUSR | IXUSR;
 2386
 2387        pub const IRWXG = IRWXU >> 3;
 2388        pub const IRWXO = IRWXG >> 3;
 2389
 2390        pub fn ISDIR(m: u32) bool {
 2391            return m & IFMT == IFDIR;
 2392        }
 2393
 2394        pub fn ISCHR(m: u32) bool {
 2395            return m & IFMT == IFCHR;
 2396        }
 2397
 2398        pub fn ISBLK(m: u32) bool {
 2399            return m & IFMT == IFBLK;
 2400        }
 2401
 2402        pub fn ISREG(m: u32) bool {
 2403            return m & IFMT == IFREG;
 2404        }
 2405
 2406        pub fn ISFIFO(m: u32) bool {
 2407            return m & IFMT == IFIFO;
 2408        }
 2409
 2410        pub fn ISLNK(m: u32) bool {
 2411            return m & IFMT == IFLNK;
 2412        }
 2413
 2414        pub fn ISSOCK(m: u32) bool {
 2415            return m & IFMT == IFSOCK;
 2416        }
 2417    },
 2418    else => void,
 2419};
 2420pub const SA = switch (native_os) {
 2421    .linux => linux.SA,
 2422    .emscripten => emscripten.SA,
 2423    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 2424        /// take signal on signal stack
 2425        pub const ONSTACK = 0x0001;
 2426        /// restart system on signal return
 2427        pub const RESTART = 0x0002;
 2428        /// reset to SIG.DFL when taking signal
 2429        pub const RESETHAND = 0x0004;
 2430        /// do not generate SIG.CHLD on child stop
 2431        pub const NOCLDSTOP = 0x0008;
 2432        /// don't mask the signal we're delivering
 2433        pub const NODEFER = 0x0010;
 2434        /// don't keep zombies around
 2435        pub const NOCLDWAIT = 0x0020;
 2436        /// signal handler with SIGINFO args
 2437        pub const SIGINFO = 0x0040;
 2438        /// do not bounce off kernel's sigtramp
 2439        pub const USERTRAMP = 0x0100;
 2440        /// signal handler with SIGINFO args with 64bit regs information
 2441        pub const @"64REGSET" = 0x0200;
 2442    },
 2443    .freebsd => struct {
 2444        pub const ONSTACK = 0x0001;
 2445        pub const RESTART = 0x0002;
 2446        pub const RESETHAND = 0x0004;
 2447        pub const NOCLDSTOP = 0x0008;
 2448        pub const NODEFER = 0x0010;
 2449        pub const NOCLDWAIT = 0x0020;
 2450        pub const SIGINFO = 0x0040;
 2451    },
 2452    .illumos => struct {
 2453        pub const ONSTACK = 0x00000001;
 2454        pub const RESETHAND = 0x00000002;
 2455        pub const RESTART = 0x00000004;
 2456        pub const SIGINFO = 0x00000008;
 2457        pub const NODEFER = 0x00000010;
 2458        pub const NOCLDWAIT = 0x00010000;
 2459    },
 2460    .netbsd => struct {
 2461        pub const ONSTACK = 0x0001;
 2462        pub const RESTART = 0x0002;
 2463        pub const RESETHAND = 0x0004;
 2464        pub const NOCLDSTOP = 0x0008;
 2465        pub const NODEFER = 0x0010;
 2466        pub const NOCLDWAIT = 0x0020;
 2467        pub const SIGINFO = 0x0040;
 2468    },
 2469    .dragonfly => struct {
 2470        pub const ONSTACK = 0x0001;
 2471        pub const RESTART = 0x0002;
 2472        pub const RESETHAND = 0x0004;
 2473        pub const NODEFER = 0x0010;
 2474        pub const NOCLDWAIT = 0x0020;
 2475        pub const SIGINFO = 0x0040;
 2476    },
 2477    .haiku => struct {
 2478        pub const NOCLDSTOP = 0x01;
 2479        pub const NOCLDWAIT = 0x02;
 2480        pub const RESETHAND = 0x04;
 2481        pub const NODEFER = 0x08;
 2482        pub const RESTART = 0x10;
 2483        pub const ONSTACK = 0x20;
 2484        pub const SIGINFO = 0x40;
 2485        pub const NOMASK = NODEFER;
 2486        pub const STACK = ONSTACK;
 2487        pub const ONESHOT = RESETHAND;
 2488    },
 2489    .openbsd => struct {
 2490        pub const ONSTACK = 0x0001;
 2491        pub const RESTART = 0x0002;
 2492        pub const RESETHAND = 0x0004;
 2493        pub const NOCLDSTOP = 0x0008;
 2494        pub const NODEFER = 0x0010;
 2495        pub const NOCLDWAIT = 0x0020;
 2496        pub const SIGINFO = 0x0040;
 2497    },
 2498    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L65-L71
 2499    .serenity => struct {
 2500        pub const NOCLDSTOP = 1;
 2501        pub const NOCLDWAIT = 2;
 2502        pub const SIGINFO = 4;
 2503        pub const ONSTACK = 0x08000000;
 2504        pub const RESTART = 0x10000000;
 2505        pub const NODEFER = 0x40000000;
 2506        pub const RESETHAND = 0x80000000;
 2507        pub const NOMASK = NODEFER;
 2508        pub const ONESHOT = RESETHAND;
 2509    },
 2510    else => void,
 2511};
 2512pub const sigval_t = switch (native_os) {
 2513    .netbsd, .illumos => extern union {
 2514        int: i32,
 2515        ptr: ?*anyopaque,
 2516    },
 2517    else => void,
 2518};
 2519
 2520pub const SC = switch (native_os) {
 2521    .linux => linux.SC,
 2522    else => void,
 2523};
 2524
 2525pub const _SC = if (builtin.abi.isAndroid()) enum(c_int) {
 2526    PAGESIZE = 39,
 2527    NPROCESSORS_ONLN = 97,
 2528} else switch (native_os) {
 2529    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) {
 2530        PAGESIZE = 29,
 2531    },
 2532    .dragonfly => enum(c_int) {
 2533        PAGESIZE = 47,
 2534    },
 2535    .freebsd => enum(c_int) {
 2536        PAGESIZE = 47,
 2537    },
 2538    .fuchsia => enum(c_int) {
 2539        PAGESIZE = 30,
 2540    },
 2541    .haiku => enum(c_int) {
 2542        PAGESIZE = 27,
 2543    },
 2544    .linux => enum(c_int) {
 2545        PAGESIZE = 30,
 2546    },
 2547    .netbsd => enum(c_int) {
 2548        PAGESIZE = 28,
 2549    },
 2550    .openbsd => enum(c_int) {
 2551        PAGESIZE = 28,
 2552    },
 2553    .illumos => enum(c_int) {
 2554        PAGESIZE = 11,
 2555        NPROCESSORS_ONLN = 15,
 2556        SIGRT_MIN = 40,
 2557        SIGRT_MAX = 41,
 2558    },
 2559    // https://github.com/SerenityOS/serenity/blob/1dfc9e2df39dd23f1de92530677c845aae4345f2/Kernel/API/POSIX/unistd.h#L36-L52
 2560    .serenity => enum(c_int) {
 2561        MONOTONIC_CLOCK = 0,
 2562        NPROCESSORS_CONF = 1,
 2563        NPROCESSORS_ONLN = 2,
 2564        OPEN_MAX = 3,
 2565        HOST_NAME_MAX = 4,
 2566        TTY_NAME_MAX = 5,
 2567        PAGESIZE = 6,
 2568        GETPW_R_SIZE_MAX = 7,
 2569        GETGR_R_SIZE_MAX = 8,
 2570        CLK_TCK = 9,
 2571        SYMLOOP_MAX = 10,
 2572        MAPPED_FILES = 11,
 2573        ARG_MAX = 12,
 2574        IOV_MAX = 13,
 2575        PHYS_PAGES = 14,
 2576    },
 2577    else => void,
 2578};
 2579
 2580pub const SEEK = switch (native_os) {
 2581    .linux => linux.SEEK,
 2582    .emscripten => emscripten.SEEK,
 2583    .wasi => struct {
 2584        pub const SET: wasi.whence_t = .SET;
 2585        pub const CUR: wasi.whence_t = .CUR;
 2586        pub const END: wasi.whence_t = .END;
 2587    },
 2588    // https://github.com/SerenityOS/serenity/blob/808ce594db1f2190e5212a250e900bde2ffe710b/Kernel/API/POSIX/stdio.h#L15-L17
 2589    .openbsd, .haiku, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows, .serenity => struct {
 2590        pub const SET = 0;
 2591        pub const CUR = 1;
 2592        pub const END = 2;
 2593    },
 2594    .dragonfly, .illumos => struct {
 2595        pub const SET = 0;
 2596        pub const CUR = 1;
 2597        pub const END = 2;
 2598        pub const DATA = 3;
 2599        pub const HOLE = 4;
 2600    },
 2601    else => void,
 2602};
 2603pub const SHUT = switch (native_os) {
 2604    .linux => linux.SHUT,
 2605    .emscripten => emscripten.SHUT,
 2606    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L40-L42
 2607    else => struct {
 2608        pub const RD = 0;
 2609        pub const WR = 1;
 2610        pub const RDWR = 2;
 2611    },
 2612};
 2613
 2614/// Signal types
 2615pub const SIG = switch (native_os) {
 2616    .linux, .emscripten => linux.SIG,
 2617    .windows => enum(u32) {
 2618        /// interrupt
 2619        INT = 2,
 2620        /// illegal instruction - invalid function image
 2621        ILL = 4,
 2622        /// floating point exception
 2623        FPE = 8,
 2624        /// segment violation
 2625        SEGV = 11,
 2626        /// Software termination signal from kill
 2627        TERM = 15,
 2628        /// Ctrl-Break sequence
 2629        BREAK = 21,
 2630        /// abnormal termination triggered by abort call
 2631        ABRT = 22,
 2632        /// SIGABRT compatible with other platforms, same as SIGABRT
 2633        ABRT_COMPAT = 6,
 2634
 2635        // Signal action codes
 2636        /// default signal action
 2637        pub const DFL = 0;
 2638        /// ignore signal
 2639        pub const IGN = 1;
 2640        /// return current value
 2641        pub const GET = 2;
 2642        /// signal gets error
 2643        pub const SGE = 3;
 2644        /// acknowledge
 2645        pub const ACK = 4;
 2646        /// Signal error value (returned by signal call on error)
 2647        pub const ERR = -1;
 2648    },
 2649    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(u32) {
 2650        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 2651        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 2652        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 2653        pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(5);
 2654
 2655        /// block specified signal set
 2656        pub const BLOCK = 1;
 2657        /// unblock specified signal set
 2658        pub const UNBLOCK = 2;
 2659        /// set specified signal set
 2660        pub const SETMASK = 3;
 2661
 2662        pub const IOT: SIG = .ABRT;
 2663        pub const POLL: SIG = .EMT;
 2664
 2665        /// hangup
 2666        HUP = 1,
 2667        /// interrupt
 2668        INT = 2,
 2669        /// quit
 2670        QUIT = 3,
 2671        /// illegal instruction (not reset when caught)
 2672        ILL = 4,
 2673        /// trace trap (not reset when caught)
 2674        TRAP = 5,
 2675        /// abort()
 2676        ABRT = 6,
 2677        /// EMT instruction
 2678        EMT = 7,
 2679        /// floating point exception
 2680        FPE = 8,
 2681        /// kill (cannot be caught or ignored)
 2682        KILL = 9,
 2683        /// bus error
 2684        BUS = 10,
 2685        /// segmentation violation
 2686        SEGV = 11,
 2687        /// bad argument to system call
 2688        SYS = 12,
 2689        /// write on a pipe with no one to read it
 2690        PIPE = 13,
 2691        /// alarm clock
 2692        ALRM = 14,
 2693        /// software termination signal from kill
 2694        TERM = 15,
 2695        /// urgent condition on IO channel
 2696        URG = 16,
 2697        /// sendable stop signal not from tty
 2698        STOP = 17,
 2699        /// stop signal from tty
 2700        TSTP = 18,
 2701        /// continue a stopped process
 2702        CONT = 19,
 2703        /// to parent on child stop or exit
 2704        CHLD = 20,
 2705        /// to readers pgrp upon background tty read
 2706        TTIN = 21,
 2707        /// like TTIN for output if (tp->t_local&LTOSTOP)
 2708        TTOU = 22,
 2709        /// input/output possible signal
 2710        IO = 23,
 2711        /// exceeded CPU time limit
 2712        XCPU = 24,
 2713        /// exceeded file size limit
 2714        XFSZ = 25,
 2715        /// virtual time alarm
 2716        VTALRM = 26,
 2717        /// profiling time alarm
 2718        PROF = 27,
 2719        /// window size changes
 2720        WINCH = 28,
 2721        /// information request
 2722        INFO = 29,
 2723        /// user defined signal 1
 2724        USR1 = 30,
 2725        /// user defined signal 2
 2726        USR2 = 31,
 2727    },
 2728    .freebsd => enum(u32) {
 2729        pub const BLOCK = 1;
 2730        pub const UNBLOCK = 2;
 2731        pub const SETMASK = 3;
 2732
 2733        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 2734        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 2735        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 2736
 2737        pub const WORDS = 4;
 2738        pub const MAXSIG = 128;
 2739
 2740        pub inline fn IDX(sig: usize) usize {
 2741            return sig - 1;
 2742        }
 2743        pub inline fn WORD(sig: usize) usize {
 2744            return IDX(sig) >> 5;
 2745        }
 2746        pub inline fn BIT(sig: usize) usize {
 2747            return 1 << (IDX(sig) & 31);
 2748        }
 2749        pub inline fn VALID(sig: usize) usize {
 2750            return sig <= MAXSIG and sig > 0;
 2751        }
 2752
 2753        pub const IOT: SIG = .ABRT;
 2754        pub const LWP: SIG = .THR;
 2755
 2756        pub const RTMIN = 65;
 2757        pub const RTMAX = 126;
 2758
 2759        HUP = 1,
 2760        INT = 2,
 2761        QUIT = 3,
 2762        ILL = 4,
 2763        TRAP = 5,
 2764        ABRT = 6,
 2765        EMT = 7,
 2766        FPE = 8,
 2767        KILL = 9,
 2768        BUS = 10,
 2769        SEGV = 11,
 2770        SYS = 12,
 2771        PIPE = 13,
 2772        ALRM = 14,
 2773        TERM = 15,
 2774        URG = 16,
 2775        STOP = 17,
 2776        TSTP = 18,
 2777        CONT = 19,
 2778        CHLD = 20,
 2779        TTIN = 21,
 2780        TTOU = 22,
 2781        IO = 23,
 2782        XCPU = 24,
 2783        XFSZ = 25,
 2784        VTALRM = 26,
 2785        PROF = 27,
 2786        WINCH = 28,
 2787        INFO = 29,
 2788        USR1 = 30,
 2789        USR2 = 31,
 2790        THR = 32,
 2791        LIBRT = 33,
 2792    },
 2793    .illumos => enum(u32) {
 2794        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 2795        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 2796        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 2797        pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(2);
 2798
 2799        pub const WORDS = 4;
 2800        pub const MAXSIG = 75;
 2801
 2802        pub const BLOCK = 1;
 2803        pub const UNBLOCK = 2;
 2804        pub const SETMASK = 3;
 2805
 2806        pub const RTMIN = 42;
 2807        pub const RTMAX = 74;
 2808
 2809        pub inline fn IDX(sig: usize) usize {
 2810            return sig - 1;
 2811        }
 2812        pub inline fn WORD(sig: usize) usize {
 2813            return IDX(sig) >> 5;
 2814        }
 2815        pub inline fn BIT(sig: usize) usize {
 2816            return 1 << (IDX(sig) & 31);
 2817        }
 2818        pub inline fn VALID(sig: usize) usize {
 2819            return sig <= MAXSIG and sig > 0;
 2820        }
 2821
 2822        pub const POLL: SIG = .IO;
 2823
 2824        HUP = 1,
 2825        INT = 2,
 2826        QUIT = 3,
 2827        ILL = 4,
 2828        TRAP = 5,
 2829        IOT = 6,
 2830        ABRT = 6,
 2831        EMT = 7,
 2832        FPE = 8,
 2833        KILL = 9,
 2834        BUS = 10,
 2835        SEGV = 11,
 2836        SYS = 12,
 2837        PIPE = 13,
 2838        ALRM = 14,
 2839        TERM = 15,
 2840        USR1 = 16,
 2841        USR2 = 17,
 2842        CLD = 18,
 2843        CHLD = 18,
 2844        PWR = 19,
 2845        WINCH = 20,
 2846        URG = 21,
 2847        IO = 22,
 2848        STOP = 23,
 2849        TSTP = 24,
 2850        CONT = 25,
 2851        TTIN = 26,
 2852        TTOU = 27,
 2853        VTALRM = 28,
 2854        PROF = 29,
 2855        XCPU = 30,
 2856        XFSZ = 31,
 2857        WAITING = 32,
 2858        LWP = 33,
 2859        FREEZE = 34,
 2860        THAW = 35,
 2861        CANCEL = 36,
 2862        LOST = 37,
 2863        XRES = 38,
 2864        JVM1 = 39,
 2865        JVM2 = 40,
 2866        INFO = 41,
 2867    },
 2868    .netbsd => enum(u32) {
 2869        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 2870        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 2871        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 2872
 2873        pub const WORDS = 4;
 2874        pub const MAXSIG = 128;
 2875
 2876        pub const BLOCK = 1;
 2877        pub const UNBLOCK = 2;
 2878        pub const SETMASK = 3;
 2879
 2880        pub const RTMIN = 33;
 2881        pub const RTMAX = 63;
 2882
 2883        pub inline fn IDX(sig: usize) usize {
 2884            return sig - 1;
 2885        }
 2886        pub inline fn WORD(sig: usize) usize {
 2887            return IDX(sig) >> 5;
 2888        }
 2889        pub inline fn BIT(sig: usize) usize {
 2890            return 1 << (IDX(sig) & 31);
 2891        }
 2892        pub inline fn VALID(sig: usize) usize {
 2893            return sig <= MAXSIG and sig > 0;
 2894        }
 2895
 2896        pub const IOT: SIG = .ABRT;
 2897
 2898        HUP = 1,
 2899        INT = 2,
 2900        QUIT = 3,
 2901        ILL = 4,
 2902        TRAP = 5,
 2903        ABRT = 6,
 2904        EMT = 7,
 2905        FPE = 8,
 2906        KILL = 9,
 2907        BUS = 10,
 2908        SEGV = 11,
 2909        SYS = 12,
 2910        PIPE = 13,
 2911        ALRM = 14,
 2912        TERM = 15,
 2913        URG = 16,
 2914        STOP = 17,
 2915        TSTP = 18,
 2916        CONT = 19,
 2917        CHLD = 20,
 2918        TTIN = 21,
 2919        TTOU = 22,
 2920        IO = 23,
 2921        XCPU = 24,
 2922        XFSZ = 25,
 2923        VTALRM = 26,
 2924        PROF = 27,
 2925        WINCH = 28,
 2926        INFO = 29,
 2927        USR1 = 30,
 2928        USR2 = 31,
 2929        PWR = 32,
 2930    },
 2931    .dragonfly => enum(u32) {
 2932        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 2933        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 2934        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 2935
 2936        pub const BLOCK = 1;
 2937        pub const UNBLOCK = 2;
 2938        pub const SETMASK = 3;
 2939
 2940        pub const WORDS = 4;
 2941
 2942        pub const IOT: SIG = .ABRT;
 2943
 2944        HUP = 1,
 2945        INT = 2,
 2946        QUIT = 3,
 2947        ILL = 4,
 2948        TRAP = 5,
 2949        ABRT = 6,
 2950        EMT = 7,
 2951        FPE = 8,
 2952        KILL = 9,
 2953        BUS = 10,
 2954        SEGV = 11,
 2955        SYS = 12,
 2956        PIPE = 13,
 2957        ALRM = 14,
 2958        TERM = 15,
 2959        URG = 16,
 2960        STOP = 17,
 2961        TSTP = 18,
 2962        CONT = 19,
 2963        CHLD = 20,
 2964        TTIN = 21,
 2965        TTOU = 22,
 2966        IO = 23,
 2967        XCPU = 24,
 2968        XFSZ = 25,
 2969        VTALRM = 26,
 2970        PROF = 27,
 2971        WINCH = 28,
 2972        INFO = 29,
 2973        USR1 = 30,
 2974        USR2 = 31,
 2975        THR = 32,
 2976        CKPT = 33,
 2977        CKPTEXIT = 34,
 2978    },
 2979    .haiku => enum(u32) {
 2980        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 2981        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 2982        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 2983
 2984        pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3);
 2985
 2986        pub const BLOCK = 1;
 2987        pub const UNBLOCK = 2;
 2988        pub const SETMASK = 3;
 2989
 2990        pub const IOT: SIG = .ABRT;
 2991
 2992        HUP = 1,
 2993        INT = 2,
 2994        QUIT = 3,
 2995        ILL = 4,
 2996        CHLD = 5,
 2997        ABRT = 6,
 2998        PIPE = 7,
 2999        FPE = 8,
 3000        KILL = 9,
 3001        STOP = 10,
 3002        SEGV = 11,
 3003        CONT = 12,
 3004        TSTP = 13,
 3005        ALRM = 14,
 3006        TERM = 15,
 3007        TTIN = 16,
 3008        TTOU = 17,
 3009        USR1 = 18,
 3010        USR2 = 19,
 3011        WINCH = 20,
 3012        KILLTHR = 21,
 3013        TRAP = 22,
 3014        POLL = 23,
 3015        PROF = 24,
 3016        SYS = 25,
 3017        URG = 26,
 3018        VTALRM = 27,
 3019        XCPU = 28,
 3020        XFSZ = 29,
 3021        BUS = 30,
 3022        RESERVED1 = 31,
 3023        RESERVED2 = 32,
 3024    },
 3025    .openbsd => enum(u32) {
 3026        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 3027        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 3028        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 3029        pub const CATCH: ?Sigaction.handler_fn = @ptrFromInt(2);
 3030        pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3);
 3031
 3032        pub const BLOCK = 1;
 3033        pub const UNBLOCK = 2;
 3034        pub const SETMASK = 3;
 3035
 3036        pub const IOT: SIG = .ABRT;
 3037
 3038        HUP = 1,
 3039        INT = 2,
 3040        QUIT = 3,
 3041        ILL = 4,
 3042        TRAP = 5,
 3043        ABRT = 6,
 3044        EMT = 7,
 3045        FPE = 8,
 3046        KILL = 9,
 3047        BUS = 10,
 3048        SEGV = 11,
 3049        SYS = 12,
 3050        PIPE = 13,
 3051        ALRM = 14,
 3052        TERM = 15,
 3053        URG = 16,
 3054        STOP = 17,
 3055        TSTP = 18,
 3056        CONT = 19,
 3057        CHLD = 20,
 3058        TTIN = 21,
 3059        TTOU = 22,
 3060        IO = 23,
 3061        XCPU = 24,
 3062        XFSZ = 25,
 3063        VTALRM = 26,
 3064        PROF = 27,
 3065        WINCH = 28,
 3066        INFO = 29,
 3067        USR1 = 30,
 3068        USR2 = 31,
 3069        PWR = 32,
 3070    },
 3071    // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal.h
 3072    // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h
 3073    .serenity => enum(u32) {
 3074        pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
 3075        pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
 3076        pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
 3077
 3078        pub const BLOCK = 1;
 3079        pub const UNBLOCK = 2;
 3080        pub const SETMASK = 3;
 3081
 3082        INVAL = 0,
 3083        HUP = 1,
 3084        INT = 2,
 3085        QUIT = 3,
 3086        ILL = 4,
 3087        TRAP = 5,
 3088        ABRT = 6,
 3089        BUS = 7,
 3090        FPE = 8,
 3091        KILL = 9,
 3092        USR1 = 10,
 3093        SEGV = 11,
 3094        USR2 = 12,
 3095        PIPE = 13,
 3096        ALRM = 14,
 3097        TERM = 15,
 3098        STKFLT = 16,
 3099        CHLD = 17,
 3100        CONT = 18,
 3101        STOP = 19,
 3102        TSTP = 20,
 3103        TTIN = 21,
 3104        TTOU = 22,
 3105        URG = 23,
 3106        XCPU = 24,
 3107        XFSZ = 25,
 3108        VTALRM = 26,
 3109        PROF = 27,
 3110        WINCH = 28,
 3111        IO = 29,
 3112        INFO = 30,
 3113        SYS = 31,
 3114        CANCEL = 32,
 3115    },
 3116    else => void,
 3117};
 3118
 3119pub const SIOCGIFINDEX = switch (native_os) {
 3120    .linux => linux.SIOCGIFINDEX,
 3121    .emscripten => emscripten.SIOCGIFINDEX,
 3122    .illumos => illumos.SIOCGLIFINDEX,
 3123    // https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L118
 3124    .serenity => 34,
 3125    else => void,
 3126};
 3127
 3128pub const STDIN_FILENO = switch (native_os) {
 3129    .linux => linux.STDIN_FILENO,
 3130    .emscripten => emscripten.STDIN_FILENO,
 3131    else => 0,
 3132};
 3133pub const STDOUT_FILENO = switch (native_os) {
 3134    .linux => linux.STDOUT_FILENO,
 3135    .emscripten => emscripten.STDOUT_FILENO,
 3136    else => 1,
 3137};
 3138pub const STDERR_FILENO = switch (native_os) {
 3139    .linux => linux.STDERR_FILENO,
 3140    .emscripten => emscripten.STDERR_FILENO,
 3141    else => 2,
 3142};
 3143
 3144pub const SYS = switch (native_os) {
 3145    .linux => linux.SYS,
 3146    else => void,
 3147};
 3148
 3149/// A common format for the Sigaction struct across a variety of Linux flavors.
 3150const common_linux_Sigaction = extern struct {
 3151    pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3152    pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3153
 3154    handler: extern union {
 3155        handler: ?handler_fn,
 3156        sigaction: ?sigaction_fn,
 3157    },
 3158    mask: sigset_t,
 3159    flags: c_uint,
 3160    restorer: ?*const fn () callconv(.c) void = null, // C library will fill this in
 3161};
 3162
 3163/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
 3164pub const Sigaction = switch (native_os) {
 3165    .linux => switch (native_arch) {
 3166        .mips,
 3167        .mipsel,
 3168        .mips64,
 3169        .mips64el,
 3170        => if (builtin.target.abi.isMusl())
 3171            common_linux_Sigaction
 3172        else if (builtin.target.ptrBitWidth() == 64) extern struct {
 3173            pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3174            pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3175
 3176            flags: c_uint,
 3177            handler: extern union {
 3178                handler: ?handler_fn,
 3179                sigaction: ?sigaction_fn,
 3180            },
 3181            mask: sigset_t,
 3182            restorer: ?*const fn () callconv(.c) void = null,
 3183        } else extern struct {
 3184            pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3185            pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3186
 3187            flags: c_uint,
 3188            handler: extern union {
 3189                handler: ?handler_fn,
 3190                sigaction: ?sigaction_fn,
 3191            },
 3192            mask: sigset_t,
 3193            restorer: ?*const fn () callconv(.c) void = null,
 3194            __resv: [1]c_int = .{0},
 3195        },
 3196        .s390x => if (builtin.abi == .gnu) extern struct {
 3197            pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3198            pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3199
 3200            handler: extern union {
 3201                handler: ?handler_fn,
 3202                sigaction: ?sigaction_fn,
 3203            },
 3204            __glibc_reserved0: c_int = 0,
 3205            flags: c_uint,
 3206            restorer: ?*const fn () callconv(.c) void = null,
 3207            mask: sigset_t,
 3208        } else common_linux_Sigaction,
 3209        else => common_linux_Sigaction,
 3210    },
 3211    .emscripten => emscripten.Sigaction,
 3212    .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 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        handler: extern union {
 3217            handler: ?handler_fn,
 3218            sigaction: ?sigaction_fn,
 3219        },
 3220        mask: sigset_t,
 3221        flags: c_uint,
 3222    },
 3223    .dragonfly, .freebsd => extern struct {
 3224        pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3225        pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3226
 3227        /// signal handler
 3228        handler: extern union {
 3229            handler: ?handler_fn,
 3230            sigaction: ?sigaction_fn,
 3231        },
 3232        /// see signal options
 3233        flags: c_uint,
 3234        /// signal mask to apply
 3235        mask: sigset_t,
 3236    },
 3237    .illumos => extern struct {
 3238        pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3239        pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3240
 3241        /// signal options
 3242        flags: c_uint,
 3243        /// signal handler
 3244        handler: extern union {
 3245            handler: ?handler_fn,
 3246            sigaction: ?sigaction_fn,
 3247        },
 3248        /// signal mask to apply
 3249        mask: sigset_t,
 3250    },
 3251    .haiku => extern struct {
 3252        pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3253        pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3254
 3255        /// signal handler
 3256        handler: extern union {
 3257            handler: handler_fn,
 3258            sigaction: sigaction_fn,
 3259        },
 3260
 3261        /// signal mask to apply
 3262        mask: sigset_t,
 3263
 3264        /// see signal options
 3265        flags: i32,
 3266
 3267        /// will be passed to the signal handler, BeOS extension
 3268        userdata: *allowzero anyopaque = undefined,
 3269    },
 3270    .openbsd => extern struct {
 3271        pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3272        pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3273
 3274        /// signal handler
 3275        handler: extern union {
 3276            handler: ?handler_fn,
 3277            sigaction: ?sigaction_fn,
 3278        },
 3279        /// signal mask to apply
 3280        mask: sigset_t,
 3281        /// signal options
 3282        flags: c_uint,
 3283    },
 3284    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L39-L46
 3285    .serenity => extern struct {
 3286        pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
 3287        pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
 3288
 3289        handler: extern union {
 3290            handler: ?handler_fn,
 3291            sigaction: ?sigaction_fn,
 3292        },
 3293        mask: sigset_t,
 3294        flags: c_uint,
 3295    },
 3296    else => void,
 3297};
 3298pub const T = switch (native_os) {
 3299    .linux => linux.T,
 3300    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 3301        pub const IOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize));
 3302
 3303        fn ior(inout: u32, group_arg: usize, num: usize, len: usize) usize {
 3304            return (inout | ((len & IOCPARM_MASK) << 16) | ((group_arg) << 8) | (num));
 3305        }
 3306    },
 3307    .freebsd => struct {
 3308        pub const IOCEXCL = 0x2000740d;
 3309        pub const IOCNXCL = 0x2000740e;
 3310        pub const IOCSCTTY = 0x20007461;
 3311        pub const IOCGPGRP = 0x40047477;
 3312        pub const IOCSPGRP = 0x80047476;
 3313        pub const IOCOUTQ = 0x40047473;
 3314        pub const IOCSTI = 0x80017472;
 3315        pub const IOCGWINSZ = 0x40087468;
 3316        pub const IOCSWINSZ = 0x80087467;
 3317        pub const IOCMGET = 0x4004746a;
 3318        pub const IOCMBIS = 0x8004746c;
 3319        pub const IOCMBIC = 0x8004746b;
 3320        pub const IOCMSET = 0x8004746d;
 3321        pub const FIONREAD = 0x4004667f;
 3322        pub const IOCCONS = 0x80047462;
 3323        pub const IOCPKT = 0x80047470;
 3324        pub const FIONBIO = 0x8004667e;
 3325        pub const IOCNOTTY = 0x20007471;
 3326        pub const IOCSETD = 0x8004741b;
 3327        pub const IOCGETD = 0x4004741a;
 3328        pub const IOCSBRK = 0x2000747b;
 3329        pub const IOCCBRK = 0x2000747a;
 3330        pub const IOCGSID = 0x40047463;
 3331        pub const IOCGPTN = 0x4004740f;
 3332        pub const IOCSIG = 0x2004745f;
 3333    },
 3334    .illumos => struct {
 3335        pub const CGETA = tioc('T', 1);
 3336        pub const CSETA = tioc('T', 2);
 3337        pub const CSETAW = tioc('T', 3);
 3338        pub const CSETAF = tioc('T', 4);
 3339        pub const CSBRK = tioc('T', 5);
 3340        pub const CXONC = tioc('T', 6);
 3341        pub const CFLSH = tioc('T', 7);
 3342        pub const IOCGWINSZ = tioc('T', 104);
 3343        pub const IOCSWINSZ = tioc('T', 103);
 3344        // Softcarrier ioctls
 3345        pub const IOCGSOFTCAR = tioc('T', 105);
 3346        pub const IOCSSOFTCAR = tioc('T', 106);
 3347        // termios ioctls
 3348        pub const CGETS = tioc('T', 13);
 3349        pub const CSETS = tioc('T', 14);
 3350        pub const CSANOW = tioc('T', 14);
 3351        pub const CSETSW = tioc('T', 15);
 3352        pub const CSADRAIN = tioc('T', 15);
 3353        pub const CSETSF = tioc('T', 16);
 3354        pub const IOCSETLD = tioc('T', 123);
 3355        pub const IOCGETLD = tioc('T', 124);
 3356        // NTP PPS ioctls
 3357        pub const IOCGPPS = tioc('T', 125);
 3358        pub const IOCSPPS = tioc('T', 126);
 3359        pub const IOCGPPSEV = tioc('T', 127);
 3360
 3361        pub const IOCGETD = tioc('t', 0);
 3362        pub const IOCSETD = tioc('t', 1);
 3363        pub const IOCHPCL = tioc('t', 2);
 3364        pub const IOCGETP = tioc('t', 8);
 3365        pub const IOCSETP = tioc('t', 9);
 3366        pub const IOCSETN = tioc('t', 10);
 3367        pub const IOCEXCL = tioc('t', 13);
 3368        pub const IOCNXCL = tioc('t', 14);
 3369        pub const IOCFLUSH = tioc('t', 16);
 3370        pub const IOCSETC = tioc('t', 17);
 3371        pub const IOCGETC = tioc('t', 18);
 3372        /// bis local mode bits
 3373        pub const IOCLBIS = tioc('t', 127);
 3374        /// bic local mode bits
 3375        pub const IOCLBIC = tioc('t', 126);
 3376        /// set entire local mode word
 3377        pub const IOCLSET = tioc('t', 125);
 3378        /// get local modes
 3379        pub const IOCLGET = tioc('t', 124);
 3380        /// set break bit
 3381        pub const IOCSBRK = tioc('t', 123);
 3382        /// clear break bit
 3383        pub const IOCCBRK = tioc('t', 122);
 3384        /// set data terminal ready
 3385        pub const IOCSDTR = tioc('t', 121);
 3386        /// clear data terminal ready
 3387        pub const IOCCDTR = tioc('t', 120);
 3388        /// set local special chars
 3389        pub const IOCSLTC = tioc('t', 117);
 3390        /// get local special chars
 3391        pub const IOCGLTC = tioc('t', 116);
 3392        /// driver output queue size
 3393        pub const IOCOUTQ = tioc('t', 115);
 3394        /// void tty association
 3395        pub const IOCNOTTY = tioc('t', 113);
 3396        /// get a ctty
 3397        pub const IOCSCTTY = tioc('t', 132);
 3398        /// stop output, like ^S
 3399        pub const IOCSTOP = tioc('t', 111);
 3400        /// start output, like ^Q
 3401        pub const IOCSTART = tioc('t', 110);
 3402        /// get pgrp of tty
 3403        pub const IOCGPGRP = tioc('t', 20);
 3404        /// set pgrp of tty
 3405        pub const IOCSPGRP = tioc('t', 21);
 3406        /// get session id on ctty
 3407        pub const IOCGSID = tioc('t', 22);
 3408        /// simulate terminal input
 3409        pub const IOCSTI = tioc('t', 23);
 3410        /// set all modem bits
 3411        pub const IOCMSET = tioc('t', 26);
 3412        /// bis modem bits
 3413        pub const IOCMBIS = tioc('t', 27);
 3414        /// bic modem bits
 3415        pub const IOCMBIC = tioc('t', 28);
 3416        /// get all modem bits
 3417        pub const IOCMGET = tioc('t', 29);
 3418
 3419        fn tioc(t: u16, num: u8) u16 {
 3420            return (t << 8) | num;
 3421        }
 3422    },
 3423    .netbsd => struct {
 3424        pub const IOCCBRK = 0x2000747a;
 3425        pub const IOCCDTR = 0x20007478;
 3426        pub const IOCCONS = 0x80047462;
 3427        pub const IOCDCDTIMESTAMP = 0x40107458;
 3428        pub const IOCDRAIN = 0x2000745e;
 3429        pub const IOCEXCL = 0x2000740d;
 3430        pub const IOCEXT = 0x80047460;
 3431        pub const IOCFLAG_CDTRCTS = 0x10;
 3432        pub const IOCFLAG_CLOCAL = 0x2;
 3433        pub const IOCFLAG_CRTSCTS = 0x4;
 3434        pub const IOCFLAG_MDMBUF = 0x8;
 3435        pub const IOCFLAG_SOFTCAR = 0x1;
 3436        pub const IOCFLUSH = 0x80047410;
 3437        pub const IOCGETA = 0x402c7413;
 3438        pub const IOCGETD = 0x4004741a;
 3439        pub const IOCGFLAGS = 0x4004745d;
 3440        pub const IOCGLINED = 0x40207442;
 3441        pub const IOCGPGRP = 0x40047477;
 3442        pub const IOCGQSIZE = 0x40047481;
 3443        pub const IOCGRANTPT = 0x20007447;
 3444        pub const IOCGSID = 0x40047463;
 3445        pub const IOCGSIZE = 0x40087468;
 3446        pub const IOCGWINSZ = 0x40087468;
 3447        pub const IOCMBIC = 0x8004746b;
 3448        pub const IOCMBIS = 0x8004746c;
 3449        pub const IOCMGET = 0x4004746a;
 3450        pub const IOCMSET = 0x8004746d;
 3451        pub const IOCM_CAR = 0x40;
 3452        pub const IOCM_CD = 0x40;
 3453        pub const IOCM_CTS = 0x20;
 3454        pub const IOCM_DSR = 0x100;
 3455        pub const IOCM_DTR = 0x2;
 3456        pub const IOCM_LE = 0x1;
 3457        pub const IOCM_RI = 0x80;
 3458        pub const IOCM_RNG = 0x80;
 3459        pub const IOCM_RTS = 0x4;
 3460        pub const IOCM_SR = 0x10;
 3461        pub const IOCM_ST = 0x8;
 3462        pub const IOCNOTTY = 0x20007471;
 3463        pub const IOCNXCL = 0x2000740e;
 3464        pub const IOCOUTQ = 0x40047473;
 3465        pub const IOCPKT = 0x80047470;
 3466        pub const IOCPKT_DATA = 0x0;
 3467        pub const IOCPKT_DOSTOP = 0x20;
 3468        pub const IOCPKT_FLUSHREAD = 0x1;
 3469        pub const IOCPKT_FLUSHWRITE = 0x2;
 3470        pub const IOCPKT_IOCTL = 0x40;
 3471        pub const IOCPKT_NOSTOP = 0x10;
 3472        pub const IOCPKT_START = 0x8;
 3473        pub const IOCPKT_STOP = 0x4;
 3474        pub const IOCPTMGET = 0x40287446;
 3475        pub const IOCPTSNAME = 0x40287448;
 3476        pub const IOCRCVFRAME = 0x80087445;
 3477        pub const IOCREMOTE = 0x80047469;
 3478        pub const IOCSBRK = 0x2000747b;
 3479        pub const IOCSCTTY = 0x20007461;
 3480        pub const IOCSDTR = 0x20007479;
 3481        pub const IOCSETA = 0x802c7414;
 3482        pub const IOCSETAF = 0x802c7416;
 3483        pub const IOCSETAW = 0x802c7415;
 3484        pub const IOCSETD = 0x8004741b;
 3485        pub const IOCSFLAGS = 0x8004745c;
 3486        pub const IOCSIG = 0x2000745f;
 3487        pub const IOCSLINED = 0x80207443;
 3488        pub const IOCSPGRP = 0x80047476;
 3489        pub const IOCSQSIZE = 0x80047480;
 3490        pub const IOCSSIZE = 0x80087467;
 3491        pub const IOCSTART = 0x2000746e;
 3492        pub const IOCSTAT = 0x80047465;
 3493        pub const IOCSTI = 0x80017472;
 3494        pub const IOCSTOP = 0x2000746f;
 3495        pub const IOCSWINSZ = 0x80087467;
 3496        pub const IOCUCNTL = 0x80047466;
 3497        pub const IOCXMTFRAME = 0x80087444;
 3498    },
 3499    .haiku => struct {
 3500        pub const CGETA = 0x8000;
 3501        pub const CSETA = 0x8001;
 3502        pub const CSETAF = 0x8002;
 3503        pub const CSETAW = 0x8003;
 3504        pub const CWAITEVENT = 0x8004;
 3505        pub const CSBRK = 0x8005;
 3506        pub const CFLSH = 0x8006;
 3507        pub const CXONC = 0x8007;
 3508        pub const CQUERYCONNECTED = 0x8008;
 3509        pub const CGETBITS = 0x8009;
 3510        pub const CSETDTR = 0x8010;
 3511        pub const CSETRTS = 0x8011;
 3512        pub const IOCGWINSZ = 0x8012;
 3513        pub const IOCSWINSZ = 0x8013;
 3514        pub const CVTIME = 0x8014;
 3515        pub const IOCGPGRP = 0x8015;
 3516        pub const IOCSPGRP = 0x8016;
 3517        pub const IOCSCTTY = 0x8017;
 3518        pub const IOCMGET = 0x8018;
 3519        pub const IOCMSET = 0x8019;
 3520        pub const IOCSBRK = 0x8020;
 3521        pub const IOCCBRK = 0x8021;
 3522        pub const IOCMBIS = 0x8022;
 3523        pub const IOCMBIC = 0x8023;
 3524        pub const IOCGSID = 0x8024;
 3525
 3526        pub const FIONREAD = 0xbe000001;
 3527        pub const FIONBIO = 0xbe000000;
 3528    },
 3529    .openbsd => struct {
 3530        pub const IOCCBRK = 0x2000747a;
 3531        pub const IOCCDTR = 0x20007478;
 3532        pub const IOCCONS = 0x80047462;
 3533        pub const IOCDCDTIMESTAMP = 0x40107458;
 3534        pub const IOCDRAIN = 0x2000745e;
 3535        pub const IOCEXCL = 0x2000740d;
 3536        pub const IOCEXT = 0x80047460;
 3537        pub const IOCFLAG_CDTRCTS = 0x10;
 3538        pub const IOCFLAG_CLOCAL = 0x2;
 3539        pub const IOCFLAG_CRTSCTS = 0x4;
 3540        pub const IOCFLAG_MDMBUF = 0x8;
 3541        pub const IOCFLAG_SOFTCAR = 0x1;
 3542        pub const IOCFLUSH = 0x80047410;
 3543        pub const IOCGETA = 0x402c7413;
 3544        pub const IOCGETD = 0x4004741a;
 3545        pub const IOCGFLAGS = 0x4004745d;
 3546        pub const IOCGLINED = 0x40207442;
 3547        pub const IOCGPGRP = 0x40047477;
 3548        pub const IOCGQSIZE = 0x40047481;
 3549        pub const IOCGRANTPT = 0x20007447;
 3550        pub const IOCGSID = 0x40047463;
 3551        pub const IOCGSIZE = 0x40087468;
 3552        pub const IOCGWINSZ = 0x40087468;
 3553        pub const IOCMBIC = 0x8004746b;
 3554        pub const IOCMBIS = 0x8004746c;
 3555        pub const IOCMGET = 0x4004746a;
 3556        pub const IOCMSET = 0x8004746d;
 3557        pub const IOCM_CAR = 0x40;
 3558        pub const IOCM_CD = 0x40;
 3559        pub const IOCM_CTS = 0x20;
 3560        pub const IOCM_DSR = 0x100;
 3561        pub const IOCM_DTR = 0x2;
 3562        pub const IOCM_LE = 0x1;
 3563        pub const IOCM_RI = 0x80;
 3564        pub const IOCM_RNG = 0x80;
 3565        pub const IOCM_RTS = 0x4;
 3566        pub const IOCM_SR = 0x10;
 3567        pub const IOCM_ST = 0x8;
 3568        pub const IOCNOTTY = 0x20007471;
 3569        pub const IOCNXCL = 0x2000740e;
 3570        pub const IOCOUTQ = 0x40047473;
 3571        pub const IOCPKT = 0x80047470;
 3572        pub const IOCPKT_DATA = 0x0;
 3573        pub const IOCPKT_DOSTOP = 0x20;
 3574        pub const IOCPKT_FLUSHREAD = 0x1;
 3575        pub const IOCPKT_FLUSHWRITE = 0x2;
 3576        pub const IOCPKT_IOCTL = 0x40;
 3577        pub const IOCPKT_NOSTOP = 0x10;
 3578        pub const IOCPKT_START = 0x8;
 3579        pub const IOCPKT_STOP = 0x4;
 3580        pub const IOCPTMGET = 0x40287446;
 3581        pub const IOCPTSNAME = 0x40287448;
 3582        pub const IOCRCVFRAME = 0x80087445;
 3583        pub const IOCREMOTE = 0x80047469;
 3584        pub const IOCSBRK = 0x2000747b;
 3585        pub const IOCSCTTY = 0x20007461;
 3586        pub const IOCSDTR = 0x20007479;
 3587        pub const IOCSETA = 0x802c7414;
 3588        pub const IOCSETAF = 0x802c7416;
 3589        pub const IOCSETAW = 0x802c7415;
 3590        pub const IOCSETD = 0x8004741b;
 3591        pub const IOCSFLAGS = 0x8004745c;
 3592        pub const IOCSIG = 0x2000745f;
 3593        pub const IOCSLINED = 0x80207443;
 3594        pub const IOCSPGRP = 0x80047476;
 3595        pub const IOCSQSIZE = 0x80047480;
 3596        pub const IOCSSIZE = 0x80087467;
 3597        pub const IOCSTART = 0x2000746e;
 3598        pub const IOCSTAT = 0x80047465;
 3599        pub const IOCSTI = 0x80017472;
 3600        pub const IOCSTOP = 0x2000746f;
 3601        pub const IOCSWINSZ = 0x80087467;
 3602        pub const IOCUCNTL = 0x80047466;
 3603        pub const IOCXMTFRAME = 0x80087444;
 3604    },
 3605    .dragonfly => struct {
 3606        pub const IOCMODG = 0x40047403;
 3607        pub const IOCMODS = 0x80047404;
 3608        pub const IOCM_LE = 0x00000001;
 3609        pub const IOCM_DTR = 0x00000002;
 3610        pub const IOCM_RTS = 0x00000004;
 3611        pub const IOCM_ST = 0x00000008;
 3612        pub const IOCM_SR = 0x00000010;
 3613        pub const IOCM_CTS = 0x00000020;
 3614        pub const IOCM_CAR = 0x00000040;
 3615        pub const IOCM_CD = 0x00000040;
 3616        pub const IOCM_RNG = 0x00000080;
 3617        pub const IOCM_RI = 0x00000080;
 3618        pub const IOCM_DSR = 0x00000100;
 3619        pub const IOCEXCL = 0x2000740d;
 3620        pub const IOCNXCL = 0x2000740e;
 3621        pub const IOCFLUSH = 0x80047410;
 3622        pub const IOCGETA = 0x402c7413;
 3623        pub const IOCSETA = 0x802c7414;
 3624        pub const IOCSETAW = 0x802c7415;
 3625        pub const IOCSETAF = 0x802c7416;
 3626        pub const IOCGETD = 0x4004741a;
 3627        pub const IOCSETD = 0x8004741b;
 3628        pub const IOCSBRK = 0x2000747b;
 3629        pub const IOCCBRK = 0x2000747a;
 3630        pub const IOCSDTR = 0x20007479;
 3631        pub const IOCCDTR = 0x20007478;
 3632        pub const IOCGPGRP = 0x40047477;
 3633        pub const IOCSPGRP = 0x80047476;
 3634        pub const IOCOUTQ = 0x40047473;
 3635        pub const IOCSTI = 0x80017472;
 3636        pub const IOCNOTTY = 0x20007471;
 3637        pub const IOCPKT = 0x80047470;
 3638        pub const IOCPKT_DATA = 0x00000000;
 3639        pub const IOCPKT_FLUSHREAD = 0x00000001;
 3640        pub const IOCPKT_FLUSHWRITE = 0x00000002;
 3641        pub const IOCPKT_STOP = 0x00000004;
 3642        pub const IOCPKT_START = 0x00000008;
 3643        pub const IOCPKT_NOSTOP = 0x00000010;
 3644        pub const IOCPKT_DOSTOP = 0x00000020;
 3645        pub const IOCPKT_IOCTL = 0x00000040;
 3646        pub const IOCSTOP = 0x2000746f;
 3647        pub const IOCSTART = 0x2000746e;
 3648        pub const IOCMSET = 0x8004746d;
 3649        pub const IOCMBIS = 0x8004746c;
 3650        pub const IOCMBIC = 0x8004746b;
 3651        pub const IOCMGET = 0x4004746a;
 3652        pub const IOCREMOTE = 0x80047469;
 3653        pub const IOCGWINSZ = 0x40087468;
 3654        pub const IOCSWINSZ = 0x80087467;
 3655        pub const IOCUCNTL = 0x80047466;
 3656        pub const IOCSTAT = 0x20007465;
 3657        pub const IOCGSID = 0x40047463;
 3658        pub const IOCCONS = 0x80047462;
 3659        pub const IOCSCTTY = 0x20007461;
 3660        pub const IOCEXT = 0x80047460;
 3661        pub const IOCSIG = 0x2000745f;
 3662        pub const IOCDRAIN = 0x2000745e;
 3663        pub const IOCMSDTRWAIT = 0x8004745b;
 3664        pub const IOCMGDTRWAIT = 0x4004745a;
 3665        pub const IOCTIMESTAMP = 0x40107459;
 3666        pub const IOCDCDTIMESTAMP = 0x40107458;
 3667        pub const IOCSDRAINWAIT = 0x80047457;
 3668        pub const IOCGDRAINWAIT = 0x40047456;
 3669        pub const IOCISPTMASTER = 0x20007455;
 3670    },
 3671    // https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L84-L96
 3672    .serenity => struct {
 3673        pub const IOCGPGRP = 0;
 3674        pub const IOCSPGRP = 1;
 3675        pub const CGETS = 2;
 3676        pub const CSETS = 3;
 3677        pub const CSETSW = 4;
 3678        pub const CSETSF = 5;
 3679        pub const CFLSH = 6;
 3680        pub const IOCGWINSZ = 7;
 3681        pub const IOCSCTTY = 8;
 3682        pub const IOCSTI = 9;
 3683        pub const IOCNOTTY = 10;
 3684        pub const IOCSWINSZ = 11;
 3685        pub const IOCGPTN = 12;
 3686    },
 3687    else => void,
 3688};
 3689pub const IOCPARM_MASK = switch (native_os) {
 3690    .windows => ws2_32.IOCPARM_MASK,
 3691    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 0x1fff,
 3692    else => void,
 3693};
 3694pub const TCSA = std.posix.TCSA;
 3695pub const TFD = switch (native_os) {
 3696    .linux => linux.TFD,
 3697    else => void,
 3698};
 3699pub const VDSO = switch (native_os) {
 3700    .linux => linux.VDSO,
 3701    else => void,
 3702};
 3703pub const W = switch (native_os) {
 3704    .linux => linux.W,
 3705    .emscripten => emscripten.W,
 3706    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 3707        /// [XSI] no hang in wait/no child to reap
 3708        pub const NOHANG = 0x00000001;
 3709        /// [XSI] notify on stop, untraced child
 3710        pub const UNTRACED = 0x00000002;
 3711
 3712        pub fn EXITSTATUS(x: u32) u8 {
 3713            return @as(u8, @intCast(x >> 8));
 3714        }
 3715        pub fn TERMSIG(x: u32) u32 {
 3716            return status(x);
 3717        }
 3718        pub fn STOPSIG(x: u32) u32 {
 3719            return x >> 8;
 3720        }
 3721        pub fn IFEXITED(x: u32) bool {
 3722            return status(x) == 0;
 3723        }
 3724        pub fn IFSTOPPED(x: u32) bool {
 3725            return status(x) == stopped and STOPSIG(x) != 0x13;
 3726        }
 3727        pub fn IFSIGNALED(x: u32) bool {
 3728            return status(x) != stopped and status(x) != 0;
 3729        }
 3730
 3731        fn status(x: u32) u32 {
 3732            return x & 0o177;
 3733        }
 3734        const stopped = 0o177;
 3735    },
 3736    .freebsd => struct {
 3737        pub const NOHANG = 1;
 3738        pub const UNTRACED = 2;
 3739        pub const STOPPED = UNTRACED;
 3740        pub const CONTINUED = 4;
 3741        pub const NOWAIT = 8;
 3742        pub const EXITED = 16;
 3743        pub const TRAPPED = 32;
 3744
 3745        pub fn EXITSTATUS(s: u32) u8 {
 3746            return @as(u8, @intCast((s & 0xff00) >> 8));
 3747        }
 3748        pub fn TERMSIG(s: u32) u32 {
 3749            return s & 0x7f;
 3750        }
 3751        pub fn STOPSIG(s: u32) u32 {
 3752            return EXITSTATUS(s);
 3753        }
 3754        pub fn IFEXITED(s: u32) bool {
 3755            return TERMSIG(s) == 0;
 3756        }
 3757        pub fn IFSTOPPED(s: u32) bool {
 3758            return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00;
 3759        }
 3760        pub fn IFSIGNALED(s: u32) bool {
 3761            return (s & 0xffff) -% 1 < 0xff;
 3762        }
 3763    },
 3764    .illumos => struct {
 3765        pub const EXITED = 0o001;
 3766        pub const TRAPPED = 0o002;
 3767        pub const UNTRACED = 0o004;
 3768        pub const STOPPED = UNTRACED;
 3769        pub const CONTINUED = 0o010;
 3770        pub const NOHANG = 0o100;
 3771        pub const NOWAIT = 0o200;
 3772
 3773        pub fn EXITSTATUS(s: u32) u8 {
 3774            return @as(u8, @intCast((s >> 8) & 0xff));
 3775        }
 3776        pub fn TERMSIG(s: u32) u32 {
 3777            return s & 0x7f;
 3778        }
 3779        pub fn STOPSIG(s: u32) u32 {
 3780            return EXITSTATUS(s);
 3781        }
 3782        pub fn IFEXITED(s: u32) bool {
 3783            return TERMSIG(s) == 0;
 3784        }
 3785
 3786        pub fn IFCONTINUED(s: u32) bool {
 3787            return ((s & 0o177777) == 0o177777);
 3788        }
 3789
 3790        pub fn IFSTOPPED(s: u32) bool {
 3791            return (s & 0x00ff != 0o177) and !(s & 0xff00 != 0);
 3792        }
 3793
 3794        pub fn IFSIGNALED(s: u32) bool {
 3795            return s & 0x00ff > 0 and s & 0xff00 == 0;
 3796        }
 3797    },
 3798    .netbsd => struct {
 3799        pub const NOHANG = 0x00000001;
 3800        pub const UNTRACED = 0x00000002;
 3801        pub const STOPPED = UNTRACED;
 3802        pub const CONTINUED = 0x00000010;
 3803        pub const NOWAIT = 0x00010000;
 3804        pub const EXITED = 0x00000020;
 3805        pub const TRAPPED = 0x00000040;
 3806
 3807        pub fn EXITSTATUS(s: u32) u8 {
 3808            return @as(u8, @intCast((s >> 8) & 0xff));
 3809        }
 3810        pub fn TERMSIG(s: u32) u32 {
 3811            return s & 0x7f;
 3812        }
 3813        pub fn STOPSIG(s: u32) u32 {
 3814            return EXITSTATUS(s);
 3815        }
 3816        pub fn IFEXITED(s: u32) bool {
 3817            return TERMSIG(s) == 0;
 3818        }
 3819
 3820        pub fn IFCONTINUED(s: u32) bool {
 3821            return ((s & 0x7f) == 0xffff);
 3822        }
 3823
 3824        pub fn IFSTOPPED(s: u32) bool {
 3825            return ((s & 0x7f != 0x7f) and !IFCONTINUED(s));
 3826        }
 3827
 3828        pub fn IFSIGNALED(s: u32) bool {
 3829            return !IFSTOPPED(s) and !IFCONTINUED(s) and !IFEXITED(s);
 3830        }
 3831    },
 3832    .dragonfly => struct {
 3833        pub const NOHANG = 0x0001;
 3834        pub const UNTRACED = 0x0002;
 3835        pub const CONTINUED = 0x0004;
 3836        pub const STOPPED = UNTRACED;
 3837        pub const NOWAIT = 0x0008;
 3838        pub const EXITED = 0x0010;
 3839        pub const TRAPPED = 0x0020;
 3840
 3841        pub fn EXITSTATUS(s: u32) u8 {
 3842            return @as(u8, @intCast((s & 0xff00) >> 8));
 3843        }
 3844        pub fn TERMSIG(s: u32) u32 {
 3845            return s & 0x7f;
 3846        }
 3847        pub fn STOPSIG(s: u32) u32 {
 3848            return EXITSTATUS(s);
 3849        }
 3850        pub fn IFEXITED(s: u32) bool {
 3851            return TERMSIG(s) == 0;
 3852        }
 3853        pub fn IFSTOPPED(s: u32) bool {
 3854            return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00;
 3855        }
 3856        pub fn IFSIGNALED(s: u32) bool {
 3857            return (s & 0xffff) -% 1 < 0xff;
 3858        }
 3859    },
 3860    .haiku => struct {
 3861        pub const NOHANG = 0x1;
 3862        pub const UNTRACED = 0x2;
 3863        pub const CONTINUED = 0x4;
 3864        pub const EXITED = 0x08;
 3865        pub const STOPPED = 0x10;
 3866        pub const NOWAIT = 0x20;
 3867
 3868        pub fn EXITSTATUS(s: u32) u8 {
 3869            return @as(u8, @intCast(s & 0xff));
 3870        }
 3871
 3872        pub fn TERMSIG(s: u32) u32 {
 3873            return (s >> 8) & 0xff;
 3874        }
 3875
 3876        pub fn STOPSIG(s: u32) u32 {
 3877            return (s >> 16) & 0xff;
 3878        }
 3879
 3880        pub fn IFEXITED(s: u32) bool {
 3881            return (s & ~@as(u32, 0xff)) == 0;
 3882        }
 3883
 3884        pub fn IFSTOPPED(s: u32) bool {
 3885            return ((s >> 16) & 0xff) != 0;
 3886        }
 3887
 3888        pub fn IFSIGNALED(s: u32) bool {
 3889            return ((s >> 8) & 0xff) != 0;
 3890        }
 3891    },
 3892    .openbsd => struct {
 3893        pub const NOHANG = 1;
 3894        pub const UNTRACED = 2;
 3895        pub const CONTINUED = 8;
 3896
 3897        pub fn EXITSTATUS(s: u32) u8 {
 3898            return @as(u8, @intCast((s >> 8) & 0xff));
 3899        }
 3900        pub fn TERMSIG(s: u32) u32 {
 3901            return (s & 0x7f);
 3902        }
 3903        pub fn STOPSIG(s: u32) u32 {
 3904            return EXITSTATUS(s);
 3905        }
 3906        pub fn IFEXITED(s: u32) bool {
 3907            return TERMSIG(s) == 0;
 3908        }
 3909
 3910        pub fn IFCONTINUED(s: u32) bool {
 3911            return ((s & 0o177777) == 0o177777);
 3912        }
 3913
 3914        pub fn IFSTOPPED(s: u32) bool {
 3915            return (s & 0xff == 0o177);
 3916        }
 3917
 3918        pub fn IFSIGNALED(s: u32) bool {
 3919            return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0);
 3920        }
 3921    },
 3922    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/wait.h
 3923    .serenity => struct {
 3924        pub const NOHANG = 1;
 3925        pub const UNTRACED = 2;
 3926        pub const STOPPED = UNTRACED;
 3927        pub const EXITED = 4;
 3928        pub const CONTINUED = 8;
 3929        pub const NOWAIT = 0x1000000;
 3930
 3931        pub fn EXITSTATUS(s: u32) u8 {
 3932            return @intCast((s & 0xff00) >> 8);
 3933        }
 3934
 3935        pub fn STOPSIG(s: u32) u32 {
 3936            return EXITSTATUS(s);
 3937        }
 3938
 3939        pub fn TERMSIG(s: u32) u32 {
 3940            return s & 0x7f;
 3941        }
 3942
 3943        pub fn IFEXITED(s: u32) bool {
 3944            return TERMSIG(s) == 0;
 3945        }
 3946
 3947        pub fn IFSTOPPED(s: u32) bool {
 3948            return (s & 0xff) == 0x7f;
 3949        }
 3950
 3951        pub fn IFSIGNALED(s: u32) bool {
 3952            return (((s & 0x7f) + 1) >> 1) > 0;
 3953        }
 3954
 3955        pub fn IFCONTINUED(s: u32) bool {
 3956            return s == 0xffff;
 3957        }
 3958    },
 3959    else => void,
 3960};
 3961pub const accept_filter_arg = switch (native_os) {
 3962    // https://github.com/freebsd/freebsd-src/blob/2024887abc7d1b931e00fbb0697658e98adf048d/sys/sys/socket.h#L205
 3963    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L164
 3964    // https://github.com/NetBSD/src/blob/cad5c68a8524927f65e22ad651de3905382be6e0/sys/sys/socket.h#L188
 3965    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L504
 3966    .freebsd, .dragonfly, .netbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 3967        name: [16]u8,
 3968        arg: [240]u8,
 3969    },
 3970    else => void,
 3971};
 3972pub const clock_t = switch (native_os) {
 3973    .linux => linux.clock_t,
 3974    .emscripten => emscripten.clock_t,
 3975    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_ulong,
 3976    .freebsd => isize,
 3977    .openbsd, .illumos => i64,
 3978    .netbsd => u32,
 3979    .haiku => i32,
 3980    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L50
 3981    .serenity => u64,
 3982    else => void,
 3983};
 3984pub const cpu_set_t = switch (native_os) {
 3985    .linux => linux.cpu_set_t,
 3986    .emscripten => emscripten.cpu_set_t,
 3987    else => void,
 3988};
 3989pub const dl_phdr_info = switch (native_os) {
 3990    .linux => linux.dl_phdr_info,
 3991    .emscripten => emscripten.dl_phdr_info,
 3992    .freebsd => extern struct {
 3993        /// Module relocation base.
 3994        addr: std.elf.Addr,
 3995        /// Module name.
 3996        name: ?[*:0]const u8,
 3997        /// Pointer to module's phdr.
 3998        phdr: [*]std.elf.ElfN.Phdr,
 3999        /// Number of entries in phdr.
 4000        phnum: u16,
 4001        /// Total number of loads.
 4002        adds: u64,
 4003        /// Total number of unloads.
 4004        subs: u64,
 4005        tls_modid: usize,
 4006        tls_data: ?*anyopaque,
 4007    },
 4008    .illumos => extern struct {
 4009        addr: std.elf.Addr,
 4010        name: ?[*:0]const u8,
 4011        phdr: [*]std.elf.ElfN.Phdr,
 4012        phnum: std.elf.Half,
 4013        /// Incremented when a new object is mapped into the process.
 4014        adds: u64,
 4015        /// Incremented when an object is unmapped from the process.
 4016        subs: u64,
 4017    },
 4018    // https://github.com/SerenityOS/serenity/blob/45d81dceed81df0c8ef75b440b20cc0938195faa/Userland/Libraries/LibC/link.h#L15-L20
 4019    .openbsd, .haiku, .dragonfly, .netbsd, .serenity => extern struct {
 4020        addr: usize,
 4021        name: ?[*:0]const u8,
 4022        phdr: [*]std.elf.ElfN.Phdr,
 4023        phnum: std.elf.Half,
 4024    },
 4025    else => void,
 4026};
 4027pub const epoll_event = switch (native_os) {
 4028    .linux => linux.epoll_event,
 4029    else => void,
 4030};
 4031pub const ifreq = switch (native_os) {
 4032    .linux => linux.ifreq,
 4033    .emscripten => emscripten.ifreq,
 4034    .illumos => lifreq,
 4035    // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L49-L82
 4036    .serenity => extern struct {
 4037        // Not actually in a union, but the stdlib expects one for ifreq
 4038        ifrn: extern union {
 4039            name: [IFNAMESIZE]u8,
 4040        },
 4041        ifru: extern union {
 4042            addr: sockaddr,
 4043            dstaddr: sockaddr,
 4044            broadaddr: sockaddr,
 4045            netmask: sockaddr,
 4046            hwaddr: sockaddr,
 4047            flags: c_short,
 4048            metric: c_int,
 4049            vnetid: i64,
 4050            media: u64,
 4051            data: ?*anyopaque,
 4052            index: c_uint,
 4053        },
 4054    },
 4055    else => void,
 4056};
 4057pub const in_pktinfo = switch (native_os) {
 4058    .linux => linux.in_pktinfo,
 4059    // https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L1132
 4060    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet/in.h#L696
 4061    .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 4062        ifindex: u32,
 4063        spec_dst: u32,
 4064        addr: u32,
 4065    },
 4066    else => void,
 4067};
 4068pub const in6_pktinfo = switch (native_os) {
 4069    .linux => linux.in6_pktinfo,
 4070    // https://github.com/freebsd/freebsd-src/blob/9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd/sys/netinet6/in6.h#L547
 4071    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/netinet6/in6.h#L575
 4072    // https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/netinet6/in6.h#L468
 4073    // https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/netinet6/in6.h#L365
 4074    // https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/netinet/in.h#L114IP1
 4075    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/netinet6/in6.h#L737
 4076    // https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/netinet6/in6.h#L63
 4077    // https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122
 4078    .freebsd, .dragonfly, .netbsd, .openbsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .haiku, .serenity => extern struct {
 4079        addr: [16]u8,
 4080        ifindex: u32,
 4081    },
 4082    else => void,
 4083};
 4084pub const itimerspec = switch (native_os) {
 4085    .linux => linux.itimerspec,
 4086    .haiku => extern struct {
 4087        interval: timespec,
 4088        value: timespec,
 4089    },
 4090    else => void,
 4091};
 4092pub const linger = switch (native_os) {
 4093    .linux => linux.linger,
 4094    // https://github.com/freebsd/freebsd-src/blob/46347b3619757e3d683a87ca03efaf2ae242335f/sys/sys/socket.h#L200
 4095    .freebsd,
 4096    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L158
 4097    .dragonfly,
 4098    // https://github.com/NetBSD/src/blob/80bf25a5691072d4755e84567ccbdf0729370dea/sys/sys/socket.h#L183
 4099    .netbsd,
 4100    // https://github.com/openbsd/src/blob/718a31b40d39fc6064de6355eb144e74633133fc/sys/sys/socket.h#L126
 4101    .openbsd,
 4102    // https://github.com/illumos/illumos-gate/blob/608eb926e14f4ba4736b2d59e891335f1cba9e1e/usr/src/uts/common/sys/socket.h#L250
 4103    .illumos,
 4104    // https://github.com/haiku/haiku/blob/2aab5f5f14aeb3f34c3a3d9a9064cc3c0d914bea/headers/posix/sys/socket.h#L87
 4105    .haiku,
 4106    // https://github.com/SerenityOS/serenity/blob/5bd8af99be0bc4b2e14f361fd7d7590e6bcfa4d6/Kernel/API/POSIX/sys/socket.h#L122
 4107    .serenity,
 4108    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L498
 4109    .driverkit,
 4110    .ios,
 4111    .maccatalyst,
 4112    .macos,
 4113    .tvos,
 4114    .visionos,
 4115    .watchos,
 4116    => extern struct {
 4117        onoff: i32, // non-zero to linger on close
 4118        linger: i32, // time to linger in seconds
 4119    },
 4120    else => void,
 4121};
 4122
 4123pub const msghdr = switch (native_os) {
 4124    .linux => if (@bitSizeOf(usize) > @bitSizeOf(i32) and builtin.abi.isMusl()) posix_msghdr else linux.msghdr,
 4125    .openbsd,
 4126    .emscripten,
 4127    .dragonfly,
 4128    .freebsd,
 4129    .netbsd,
 4130    .haiku,
 4131    .illumos,
 4132    .driverkit,
 4133    .ios,
 4134    .maccatalyst,
 4135    .macos,
 4136    .tvos,
 4137    .visionos,
 4138    .watchos,
 4139    .serenity, // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L74-L82
 4140    => posix_msghdr,
 4141    else => void,
 4142};
 4143
 4144/// https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html
 4145const posix_msghdr = extern struct {
 4146    name: ?*sockaddr,
 4147    namelen: socklen_t,
 4148    iov: [*]iovec,
 4149    pad0: if (@sizeOf(usize) == 8 and native_endian == .big) u32 else u0 = 0,
 4150    iovlen: u32,
 4151    pad1: if (@sizeOf(usize) == 8 and native_endian == .little) u32 else u0 = 0,
 4152    control: ?*anyopaque,
 4153    pad2: if (@sizeOf(usize) == 8 and native_endian == .big) u32 else u0 = 0,
 4154    controllen: socklen_t,
 4155    pad3: if (@sizeOf(usize) == 8 and native_endian == .little) u32 else u0 = 0,
 4156    flags: u32,
 4157};
 4158
 4159pub const msghdr_const = switch (native_os) {
 4160    .linux => if (@bitSizeOf(usize) > @bitSizeOf(i32) and builtin.abi.isMusl()) posix_msghdr_const else linux.msghdr_const,
 4161    .openbsd,
 4162    .emscripten,
 4163    .dragonfly,
 4164    .freebsd,
 4165    .netbsd,
 4166    .haiku,
 4167    .illumos,
 4168    .driverkit,
 4169    .ios,
 4170    .maccatalyst,
 4171    .macos,
 4172    .tvos,
 4173    .visionos,
 4174    .watchos,
 4175    .serenity,
 4176    => posix_msghdr_const,
 4177    else => void,
 4178};
 4179
 4180const posix_msghdr_const = extern struct {
 4181    name: ?*const sockaddr,
 4182    namelen: socklen_t,
 4183    iov: [*]const iovec_const,
 4184    pad0: if (@sizeOf(usize) == 8 and native_endian == .big) u32 else u0 = 0,
 4185    iovlen: u32,
 4186    pad1: if (@sizeOf(usize) == 8 and native_endian == .little) u32 else u0 = 0,
 4187    control: ?*const anyopaque,
 4188    pad2: if (@sizeOf(usize) == 8 and native_endian == .big) u32 else u0 = 0,
 4189    controllen: socklen_t,
 4190    pad3: if (@sizeOf(usize) == 8 and native_endian == .little) u32 else u0 = 0,
 4191    flags: u32,
 4192};
 4193
 4194pub const mmsghdr = switch (native_os) {
 4195    .linux => linux.mmsghdr,
 4196    else => extern struct {
 4197        hdr: msghdr,
 4198        len: u32,
 4199    },
 4200};
 4201
 4202pub const cmsghdr = switch (native_os) {
 4203    .linux => if (@bitSizeOf(usize) > @bitSizeOf(i32) and builtin.abi.isMusl()) posix_cmsghdr else linux.cmsghdr,
 4204    // https://github.com/emscripten-core/emscripten/blob/96371ed7888fc78c040179f4d4faa82a6a07a116/system/lib/libc/musl/include/sys/socket.h#L44
 4205    .emscripten => linux.cmsghdr,
 4206    // https://github.com/freebsd/freebsd-src/blob/b197d2abcb6895d78bc9df8404e374397aa44748/sys/sys/socket.h#L492
 4207    .freebsd,
 4208    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/107c0518337ba90e7fa49e74845d8d44320c9a6d/sys/sys/socket.h#L452
 4209    .dragonfly,
 4210    // https://github.com/NetBSD/src/blob/ba8e1774fd9c0c26ecca461c07bc95d9ebb69579/sys/sys/socket.h#L528
 4211    .netbsd,
 4212    // https://github.com/openbsd/src/blob/master/sys/sys/socket.h#L527
 4213    .openbsd,
 4214    // https://github.com/illumos/illumos-gate/blob/afdf2e523873cb523df379676067bf9785a0f456/usr/src/uts/common/sys/socket.h#L460
 4215    .illumos,
 4216    // https://github.com/SerenityOS/serenity/blob/4ee360a348a5e2490eeaeeabb3eb19e70dd450eb/Kernel/API/POSIX/sys/socket.h#L68
 4217    .serenity,
 4218    // https://github.com/haiku/haiku/blob/b54f586058fd6623645512e4631468cede9933b9/headers/posix/sys/socket.h#L132
 4219    .haiku,
 4220    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1041
 4221    .driverkit,
 4222    .ios,
 4223    .maccatalyst,
 4224    .macos,
 4225    .tvos,
 4226    .visionos,
 4227    .watchos,
 4228    => posix_cmsghdr,
 4229
 4230    else => void,
 4231};
 4232
 4233const posix_cmsghdr = extern struct {
 4234    pad0: if (@sizeOf(usize) == 8 and native_endian == .big) u32 else u0 = 0,
 4235    len: socklen_t,
 4236    pad1: if (@sizeOf(usize) == 8 and native_endian == .little) u32 else u0 = 0,
 4237    level: c_int,
 4238    type: c_int,
 4239};
 4240
 4241pub const nfds_t = switch (native_os) {
 4242    .linux => linux.nfds_t,
 4243    .emscripten => emscripten.nfds_t,
 4244    .haiku, .illumos, .wasi => usize,
 4245    .windows => c_ulong,
 4246    .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u32,
 4247    // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L32
 4248    .serenity => c_uint,
 4249    else => void,
 4250};
 4251pub const perf_event_attr = switch (native_os) {
 4252    .linux => linux.perf_event_attr,
 4253    else => void,
 4254};
 4255pub const pid_t = switch (native_os) {
 4256    .linux => linux.pid_t,
 4257    .emscripten => emscripten.pid_t,
 4258    .windows => windows.HANDLE,
 4259    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L31-L32
 4260    .serenity => c_int,
 4261    else => i32,
 4262};
 4263pub const pollfd = switch (native_os) {
 4264    .linux => linux.pollfd,
 4265    .emscripten => emscripten.pollfd,
 4266    .windows => ws2_32.pollfd,
 4267    // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L26-L30
 4268    .serenity => extern struct {
 4269        fd: fd_t,
 4270        events: c_short,
 4271        revents: c_short,
 4272    },
 4273    else => extern struct {
 4274        fd: fd_t,
 4275        events: i16,
 4276        revents: i16,
 4277    },
 4278};
 4279pub const rlim_t = switch (native_os) {
 4280    .linux => linux.rlim_t,
 4281    .emscripten => emscripten.rlim_t,
 4282    .openbsd, .netbsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u64,
 4283    .haiku, .dragonfly, .freebsd => i64,
 4284    // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L54
 4285    .serenity => usize,
 4286    else => void,
 4287};
 4288pub const rlimit = switch (native_os) {
 4289    .linux, .emscripten => linux.rlimit,
 4290    .windows => void,
 4291    // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L56-L59
 4292    else => extern struct {
 4293        /// Soft limit
 4294        cur: rlim_t,
 4295        /// Hard limit
 4296        max: rlim_t,
 4297    },
 4298};
 4299pub const rlimit_resource = switch (native_os) {
 4300    .linux => linux.rlimit_resource,
 4301    .emscripten => emscripten.rlimit_resource,
 4302    .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) {
 4303        CPU = 0,
 4304        FSIZE = 1,
 4305        DATA = 2,
 4306        STACK = 3,
 4307        CORE = 4,
 4308        RSS = 5,
 4309        MEMLOCK = 6,
 4310        NPROC = 7,
 4311        NOFILE = 8,
 4312        _,
 4313
 4314        pub const AS: rlimit_resource = .RSS;
 4315    },
 4316    .freebsd => enum(c_int) {
 4317        CPU = 0,
 4318        FSIZE = 1,
 4319        DATA = 2,
 4320        STACK = 3,
 4321        CORE = 4,
 4322        RSS = 5,
 4323        MEMLOCK = 6,
 4324        NPROC = 7,
 4325        NOFILE = 8,
 4326        SBSIZE = 9,
 4327        VMEM = 10,
 4328        NPTS = 11,
 4329        SWAP = 12,
 4330        KQUEUES = 13,
 4331        UMTXP = 14,
 4332        _,
 4333
 4334        pub const AS: rlimit_resource = .VMEM;
 4335    },
 4336    .illumos => enum(c_int) {
 4337        CPU = 0,
 4338        FSIZE = 1,
 4339        DATA = 2,
 4340        STACK = 3,
 4341        CORE = 4,
 4342        NOFILE = 5,
 4343        VMEM = 6,
 4344        _,
 4345
 4346        pub const AS: rlimit_resource = .VMEM;
 4347    },
 4348    .netbsd => enum(c_int) {
 4349        CPU = 0,
 4350        FSIZE = 1,
 4351        DATA = 2,
 4352        STACK = 3,
 4353        CORE = 4,
 4354        RSS = 5,
 4355        MEMLOCK = 6,
 4356        NPROC = 7,
 4357        NOFILE = 8,
 4358        SBSIZE = 9,
 4359        VMEM = 10,
 4360        NTHR = 11,
 4361        _,
 4362
 4363        pub const AS: rlimit_resource = .VMEM;
 4364    },
 4365    .dragonfly => enum(c_int) {
 4366        CPU = 0,
 4367        FSIZE = 1,
 4368        DATA = 2,
 4369        STACK = 3,
 4370        CORE = 4,
 4371        RSS = 5,
 4372        MEMLOCK = 6,
 4373        NPROC = 7,
 4374        NOFILE = 8,
 4375        SBSIZE = 9,
 4376        VMEM = 10,
 4377        POSIXLOCKS = 11,
 4378        _,
 4379
 4380        pub const AS: rlimit_resource = .VMEM;
 4381    },
 4382    .haiku => enum(i32) {
 4383        CORE = 0,
 4384        CPU = 1,
 4385        DATA = 2,
 4386        FSIZE = 3,
 4387        NOFILE = 4,
 4388        STACK = 5,
 4389        AS = 6,
 4390        NOVMON = 7,
 4391        _,
 4392    },
 4393    // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L42-L48
 4394    .serenity => enum(c_int) {
 4395        CORE = 1,
 4396        CPU = 2,
 4397        DATA = 3,
 4398        FSIZE = 4,
 4399        NOFILE = 5,
 4400        STACK = 6,
 4401        AS = 7,
 4402        _,
 4403    },
 4404    else => void,
 4405};
 4406pub const rusage = switch (native_os) {
 4407    .linux => linux.rusage,
 4408    .emscripten => emscripten.rusage,
 4409    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 4410        utime: timeval,
 4411        stime: timeval,
 4412        maxrss: isize,
 4413        ixrss: isize,
 4414        idrss: isize,
 4415        isrss: isize,
 4416        minflt: isize,
 4417        majflt: isize,
 4418        nswap: isize,
 4419        inblock: isize,
 4420        oublock: isize,
 4421        msgsnd: isize,
 4422        msgrcv: isize,
 4423        nsignals: isize,
 4424        nvcsw: isize,
 4425        nivcsw: isize,
 4426
 4427        pub const SELF = 0;
 4428        pub const CHILDREN = -1;
 4429    },
 4430    .illumos => extern struct {
 4431        utime: timeval,
 4432        stime: timeval,
 4433        maxrss: isize,
 4434        ixrss: isize,
 4435        idrss: isize,
 4436        isrss: isize,
 4437        minflt: isize,
 4438        majflt: isize,
 4439        nswap: isize,
 4440        inblock: isize,
 4441        oublock: isize,
 4442        msgsnd: isize,
 4443        msgrcv: isize,
 4444        nsignals: isize,
 4445        nvcsw: isize,
 4446        nivcsw: isize,
 4447
 4448        pub const SELF = 0;
 4449        pub const CHILDREN = -1;
 4450        pub const THREAD = 1;
 4451    },
 4452    // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L18-L38
 4453    .serenity => extern struct {
 4454        utime: timeval,
 4455        stime: timeval,
 4456        maxrss: c_long,
 4457        ixrss: c_long,
 4458        idrss: c_long,
 4459        isrss: c_long,
 4460        minflt: c_long,
 4461        majflt: c_long,
 4462        nswap: c_long,
 4463        inblock: c_long,
 4464        oublock: c_long,
 4465        msgsnd: c_long,
 4466        msgrcv: c_long,
 4467        nsignals: c_long,
 4468        nvcsw: c_long,
 4469        nivcsw: c_long,
 4470
 4471        pub const SELF = 1;
 4472        pub const CHILDREN = 2;
 4473    },
 4474    .freebsd => extern struct {
 4475        utime: timeval,
 4476        stime: timeval,
 4477        maxrss: c_long,
 4478        ixrss: c_long,
 4479        idrss: c_long,
 4480        isrss: c_long,
 4481        minflt: c_long,
 4482        majflt: c_long,
 4483        nswap: c_long,
 4484        inblock: c_long,
 4485        oublock: c_long,
 4486        msgsnd: c_long,
 4487        msgrcv: c_long,
 4488        nsignals: c_long,
 4489        nvcsw: c_long,
 4490        nivcsw: c_long,
 4491
 4492        pub const SELF = 0;
 4493        pub const CHILDREN = -1;
 4494        pub const THREAD = 1;
 4495    },
 4496    else => void,
 4497};
 4498
 4499pub const siginfo_t = switch (native_os) {
 4500    .linux => linux.siginfo_t,
 4501    .emscripten => emscripten.siginfo_t,
 4502    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 4503        signo: SIG,
 4504        errno: c_int,
 4505        code: c_int,
 4506        pid: pid_t,
 4507        uid: uid_t,
 4508        status: c_int,
 4509        addr: *allowzero anyopaque,
 4510        value: extern union {
 4511            int: c_int,
 4512            ptr: *anyopaque,
 4513        },
 4514        si_band: c_long,
 4515        _pad: [7]c_ulong,
 4516    },
 4517    .freebsd => extern struct {
 4518        // Signal number.
 4519        signo: SIG,
 4520        // Errno association.
 4521        errno: c_int,
 4522        /// Signal code.
 4523        ///
 4524        /// Cause of signal, one of the SI_ macros or signal-specific values, i.e.
 4525        /// one of the FPE_... values for SIGFPE.
 4526        /// This value is equivalent to the second argument to an old-style FreeBSD
 4527        /// signal handler.
 4528        code: c_int,
 4529        /// Sending process.
 4530        pid: pid_t,
 4531        /// Sender's ruid.
 4532        uid: uid_t,
 4533        /// Exit value.
 4534        status: c_int,
 4535        /// Faulting instruction.
 4536        addr: *allowzero anyopaque,
 4537        /// Signal value.
 4538        value: sigval,
 4539        reason: extern union {
 4540            fault: extern struct {
 4541                /// Machine specific trap code.
 4542                trapno: c_int,
 4543            },
 4544            timer: extern struct {
 4545                timerid: c_int,
 4546                overrun: c_int,
 4547            },
 4548            mesgq: extern struct {
 4549                mqd: c_int,
 4550            },
 4551            poll: extern struct {
 4552                /// Band event for SIGPOLL. UNUSED.
 4553                band: c_long,
 4554            },
 4555            spare: extern struct {
 4556                spare1: c_long,
 4557                spare2: [7]c_int,
 4558            },
 4559        },
 4560    },
 4561    .illumos => extern struct {
 4562        signo: SIG,
 4563        code: c_int,
 4564        errno: c_int,
 4565        // 64bit architectures insert 4bytes of padding here, this is done by
 4566        // correctly aligning the reason field
 4567        reason: extern union {
 4568            proc: extern struct {
 4569                pid: pid_t,
 4570                pdata: extern union {
 4571                    kill: extern struct {
 4572                        uid: uid_t,
 4573                        value: sigval_t,
 4574                    },
 4575                    cld: extern struct {
 4576                        utime: clock_t,
 4577                        status: c_int,
 4578                        stime: clock_t,
 4579                    },
 4580                },
 4581                contract: illumos.ctid_t,
 4582                zone: illumos.zoneid_t,
 4583            },
 4584            fault: extern struct {
 4585                addr: *allowzero anyopaque,
 4586                trapno: c_int,
 4587                pc: ?*anyopaque,
 4588            },
 4589            file: extern struct {
 4590                // fd not currently available for SIGPOLL.
 4591                fd: c_int,
 4592                band: c_long,
 4593            },
 4594            prof: extern struct {
 4595                addr: ?*anyopaque,
 4596                timestamp: timespec,
 4597                syscall: c_short,
 4598                sysarg: u8,
 4599                fault: u8,
 4600                args: [8]c_long,
 4601                state: [10]c_int,
 4602            },
 4603            rctl: extern struct {
 4604                entity: i32,
 4605            },
 4606            __pad: [256 - 4 * @sizeOf(c_int)]u8,
 4607        } align(@sizeOf(usize)),
 4608
 4609        comptime {
 4610            assert(@sizeOf(@This()) == 256);
 4611            assert(@alignOf(@This()) == @sizeOf(usize));
 4612        }
 4613    },
 4614    .netbsd => extern union {
 4615        pad: [128]u8,
 4616        info: netbsd._ksiginfo,
 4617    },
 4618    .dragonfly => extern struct {
 4619        signo: SIG,
 4620        errno: c_int,
 4621        code: c_int,
 4622        pid: c_int,
 4623        uid: uid_t,
 4624        status: c_int,
 4625        addr: *allowzero anyopaque,
 4626        value: sigval,
 4627        band: c_long,
 4628        __spare__: [7]c_int,
 4629    },
 4630    .haiku => extern struct {
 4631        signo: SIG,
 4632        code: i32,
 4633        errno: i32,
 4634
 4635        pid: pid_t,
 4636        uid: uid_t,
 4637        addr: *allowzero anyopaque,
 4638    },
 4639    .openbsd => extern struct {
 4640        signo: SIG,
 4641        code: c_int,
 4642        errno: c_int,
 4643        data: extern union {
 4644            proc: extern struct {
 4645                pid: pid_t,
 4646                pdata: extern union {
 4647                    kill: extern struct {
 4648                        uid: uid_t,
 4649                        value: sigval,
 4650                    },
 4651                    cld: extern struct {
 4652                        utime: clock_t,
 4653                        stime: clock_t,
 4654                        status: c_int,
 4655                    },
 4656                },
 4657            },
 4658            fault: extern struct {
 4659                addr: *allowzero anyopaque,
 4660                trapno: c_int,
 4661            },
 4662            __pad: [128 - 3 * @sizeOf(c_int)]u8,
 4663        },
 4664
 4665        comptime {
 4666            if (@sizeOf(usize) == 4)
 4667                assert(@sizeOf(@This()) == 128)
 4668            else
 4669                // Take into account the padding between errno and data fields.
 4670                assert(@sizeOf(@This()) == 136);
 4671        }
 4672    },
 4673    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L27-L37
 4674    .serenity => extern struct {
 4675        signo: SIG,
 4676        code: c_int,
 4677        errno: c_int,
 4678        pid: pid_t,
 4679        uid: uid_t,
 4680        addr: ?*anyopaque,
 4681        status: c_int,
 4682        band: c_int,
 4683        value: sigval,
 4684    },
 4685    else => void,
 4686};
 4687pub const sigset_t = switch (native_os) {
 4688    .linux => [1024 / @bitSizeOf(c_ulong)]c_ulong, // glibc and musl present a 1024-bit sigset_t, while kernel's is 128-bit or less.
 4689    .emscripten => emscripten.sigset_t,
 4690    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L19
 4691    .openbsd, .serenity => u32,
 4692    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.sigset_t,
 4693    .dragonfly, .netbsd, .illumos, .freebsd => extern struct {
 4694        __bits: [SIG.WORDS]u32,
 4695    },
 4696    .haiku => u64,
 4697    else => u0,
 4698};
 4699
 4700pub const sigval = switch (native_os) {
 4701    .linux => linux.sigval,
 4702    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L22-L25
 4703    .openbsd, .dragonfly, .freebsd, .serenity => extern union {
 4704        int: c_int,
 4705        ptr: ?*anyopaque,
 4706    },
 4707    else => void,
 4708};
 4709
 4710pub const addrinfo = if (builtin.abi.isAndroid()) extern struct {
 4711    flags: AI,
 4712    family: i32,
 4713    socktype: i32,
 4714    protocol: i32,
 4715    addrlen: socklen_t,
 4716    canonname: ?[*:0]u8,
 4717    addr: ?*sockaddr,
 4718    next: ?*addrinfo,
 4719} else switch (native_os) {
 4720    .linux, .emscripten => linux.addrinfo,
 4721    .windows => ws2_32.addrinfo,
 4722    .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 4723        flags: AI,
 4724        family: i32,
 4725        socktype: i32,
 4726        protocol: i32,
 4727        addrlen: socklen_t,
 4728        canonname: ?[*:0]u8,
 4729        addr: ?*sockaddr,
 4730        next: ?*addrinfo,
 4731    },
 4732    .illumos => extern struct {
 4733        flags: AI,
 4734        family: i32,
 4735        socktype: i32,
 4736        protocol: i32,
 4737        addrlen: socklen_t,
 4738        canonname: ?[*:0]u8,
 4739        addr: ?*sockaddr,
 4740        next: ?*addrinfo,
 4741    },
 4742    .netbsd => extern struct {
 4743        flags: AI,
 4744        family: i32,
 4745        socktype: i32,
 4746        protocol: i32,
 4747        addrlen: socklen_t,
 4748        canonname: ?[*:0]u8,
 4749        addr: ?*sockaddr,
 4750        next: ?*addrinfo,
 4751    },
 4752    .dragonfly => extern struct {
 4753        flags: AI,
 4754        family: i32,
 4755        socktype: i32,
 4756        protocol: i32,
 4757        addrlen: socklen_t,
 4758        canonname: ?[*:0]u8,
 4759        addr: ?*sockaddr,
 4760        next: ?*addrinfo,
 4761    },
 4762    .haiku => extern struct {
 4763        flags: AI,
 4764        family: i32,
 4765        socktype: i32,
 4766        protocol: i32,
 4767        addrlen: socklen_t,
 4768        canonname: ?[*:0]u8,
 4769        addr: ?*sockaddr,
 4770        next: ?*addrinfo,
 4771    },
 4772    // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L66-L75
 4773    .openbsd, .serenity => extern struct {
 4774        flags: AI,
 4775        family: c_int,
 4776        socktype: c_int,
 4777        protocol: c_int,
 4778        addrlen: socklen_t,
 4779        addr: ?*sockaddr,
 4780        canonname: ?[*:0]u8,
 4781        next: ?*addrinfo,
 4782    },
 4783    else => void,
 4784};
 4785pub const sockaddr = switch (native_os) {
 4786    .linux, .emscripten => linux.sockaddr,
 4787    .windows => ws2_32.sockaddr,
 4788    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 4789        len: u8,
 4790        family: sa_family_t,
 4791        data: [14]u8,
 4792
 4793        pub const SS_MAXSIZE = 128;
 4794        pub const storage = extern struct {
 4795            len: u8 align(8),
 4796            family: sa_family_t,
 4797            padding: [126]u8 = undefined,
 4798
 4799            comptime {
 4800                assert(@sizeOf(storage) == SS_MAXSIZE);
 4801                assert(@alignOf(storage) == 8);
 4802            }
 4803        };
 4804        pub const in = extern struct {
 4805            len: u8 = @sizeOf(in),
 4806            family: sa_family_t = AF.INET,
 4807            port: in_port_t,
 4808            addr: u32,
 4809            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 4810        };
 4811        pub const in6 = extern struct {
 4812            len: u8 = @sizeOf(in6),
 4813            family: sa_family_t = AF.INET6,
 4814            port: in_port_t,
 4815            flowinfo: u32,
 4816            addr: [16]u8,
 4817            scope_id: u32,
 4818        };
 4819
 4820        /// UNIX domain socket
 4821        pub const un = extern struct {
 4822            len: u8 = @sizeOf(un),
 4823            family: sa_family_t = AF.UNIX,
 4824            path: [104]u8,
 4825        };
 4826    },
 4827    .freebsd => extern struct {
 4828        /// total length
 4829        len: u8,
 4830        /// address family
 4831        family: sa_family_t,
 4832        /// actually longer; address value
 4833        data: [14]u8,
 4834
 4835        pub const SS_MAXSIZE = 128;
 4836        pub const storage = extern struct {
 4837            len: u8 align(8),
 4838            family: sa_family_t,
 4839            padding: [126]u8 = undefined,
 4840
 4841            comptime {
 4842                assert(@sizeOf(storage) == SS_MAXSIZE);
 4843                assert(@alignOf(storage) == 8);
 4844            }
 4845        };
 4846
 4847        pub const in = extern struct {
 4848            len: u8 = @sizeOf(in),
 4849            family: sa_family_t = AF.INET,
 4850            port: in_port_t,
 4851            addr: u32,
 4852            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 4853        };
 4854
 4855        pub const in6 = extern struct {
 4856            len: u8 = @sizeOf(in6),
 4857            family: sa_family_t = AF.INET6,
 4858            port: in_port_t,
 4859            flowinfo: u32,
 4860            addr: [16]u8,
 4861            scope_id: u32,
 4862        };
 4863
 4864        pub const un = extern struct {
 4865            len: u8 = @sizeOf(un),
 4866            family: sa_family_t = AF.UNIX,
 4867            path: [104]u8,
 4868        };
 4869    },
 4870    .illumos => extern struct {
 4871        /// address family
 4872        family: sa_family_t,
 4873
 4874        /// actually longer; address value
 4875        data: [14]u8,
 4876
 4877        pub const SS_MAXSIZE = 256;
 4878        pub const storage = extern struct {
 4879            family: sa_family_t align(8),
 4880            padding: [254]u8 = undefined,
 4881
 4882            comptime {
 4883                assert(@sizeOf(storage) == SS_MAXSIZE);
 4884                assert(@alignOf(storage) == 8);
 4885            }
 4886        };
 4887
 4888        pub const in = extern struct {
 4889            family: sa_family_t = AF.INET,
 4890            port: in_port_t,
 4891            addr: u32,
 4892            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 4893        };
 4894
 4895        pub const in6 = extern struct {
 4896            family: sa_family_t = AF.INET6,
 4897            port: in_port_t,
 4898            flowinfo: u32,
 4899            addr: [16]u8,
 4900            scope_id: u32,
 4901            __src_id: u32 = 0,
 4902        };
 4903
 4904        /// Definitions for UNIX IPC domain.
 4905        pub const un = extern struct {
 4906            family: sa_family_t = AF.UNIX,
 4907            path: [108]u8,
 4908        };
 4909    },
 4910    .netbsd => extern struct {
 4911        /// total length
 4912        len: u8,
 4913        /// address family
 4914        family: sa_family_t,
 4915        /// actually longer; address value
 4916        data: [14]u8,
 4917
 4918        pub const SS_MAXSIZE = 128;
 4919        pub const storage = extern struct {
 4920            len: u8 align(8),
 4921            family: sa_family_t,
 4922            padding: [126]u8 = undefined,
 4923
 4924            comptime {
 4925                assert(@sizeOf(storage) == SS_MAXSIZE);
 4926                assert(@alignOf(storage) == 8);
 4927            }
 4928        };
 4929
 4930        pub const in = extern struct {
 4931            len: u8 = @sizeOf(in),
 4932            family: sa_family_t = AF.INET,
 4933            port: in_port_t,
 4934            addr: u32,
 4935            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 4936        };
 4937
 4938        pub const in6 = extern struct {
 4939            len: u8 = @sizeOf(in6),
 4940            family: sa_family_t = AF.INET6,
 4941            port: in_port_t,
 4942            flowinfo: u32,
 4943            addr: [16]u8,
 4944            scope_id: u32,
 4945        };
 4946
 4947        /// Definitions for UNIX IPC domain.
 4948        pub const un = extern struct {
 4949            /// total sockaddr length
 4950            len: u8 = @sizeOf(un),
 4951
 4952            family: sa_family_t = AF.LOCAL,
 4953
 4954            /// path name
 4955            path: [104]u8,
 4956        };
 4957    },
 4958    .dragonfly => extern struct {
 4959        len: u8,
 4960        family: sa_family_t,
 4961        data: [14]u8,
 4962
 4963        pub const SS_MAXSIZE = 128;
 4964        pub const storage = extern struct {
 4965            len: u8 align(8),
 4966            family: sa_family_t,
 4967            padding: [126]u8 = undefined,
 4968
 4969            comptime {
 4970                assert(@sizeOf(storage) == SS_MAXSIZE);
 4971                assert(@alignOf(storage) == 8);
 4972            }
 4973        };
 4974
 4975        pub const in = extern struct {
 4976            len: u8 = @sizeOf(in),
 4977            family: sa_family_t = AF.INET,
 4978            port: in_port_t,
 4979            addr: u32,
 4980            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 4981        };
 4982
 4983        pub const in6 = extern struct {
 4984            len: u8 = @sizeOf(in6),
 4985            family: sa_family_t = AF.INET6,
 4986            port: in_port_t,
 4987            flowinfo: u32,
 4988            addr: [16]u8,
 4989            scope_id: u32,
 4990        };
 4991
 4992        pub const un = extern struct {
 4993            len: u8 = @sizeOf(un),
 4994            family: sa_family_t = AF.UNIX,
 4995            path: [104]u8,
 4996        };
 4997    },
 4998    .haiku => extern struct {
 4999        /// total length
 5000        len: u8,
 5001        /// address family
 5002        family: sa_family_t,
 5003        /// actually longer; address value
 5004        data: [14]u8,
 5005
 5006        pub const SS_MAXSIZE = 128;
 5007        pub const storage = extern struct {
 5008            len: u8 align(8),
 5009            family: sa_family_t,
 5010            padding: [126]u8 = undefined,
 5011
 5012            comptime {
 5013                assert(@sizeOf(storage) == SS_MAXSIZE);
 5014                assert(@alignOf(storage) == 8);
 5015            }
 5016        };
 5017
 5018        pub const in = extern struct {
 5019            len: u8 = @sizeOf(in),
 5020            family: sa_family_t = AF.INET,
 5021            port: in_port_t,
 5022            addr: u32,
 5023            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 5024        };
 5025
 5026        pub const in6 = extern struct {
 5027            len: u8 = @sizeOf(in6),
 5028            family: sa_family_t = AF.INET6,
 5029            port: in_port_t,
 5030            flowinfo: u32,
 5031            addr: [16]u8,
 5032            scope_id: u32,
 5033        };
 5034
 5035        pub const un = extern struct {
 5036            len: u8 = @sizeOf(un),
 5037            family: sa_family_t = AF.UNIX,
 5038            path: [104]u8,
 5039        };
 5040    },
 5041    .openbsd => extern struct {
 5042        /// total length
 5043        len: u8,
 5044        /// address family
 5045        family: sa_family_t,
 5046        /// actually longer; address value
 5047        data: [14]u8,
 5048
 5049        pub const SS_MAXSIZE = 256;
 5050        pub const storage = extern struct {
 5051            len: u8 align(8),
 5052            family: sa_family_t,
 5053            padding: [254]u8 = undefined,
 5054
 5055            comptime {
 5056                assert(@sizeOf(storage) == SS_MAXSIZE);
 5057                assert(@alignOf(storage) == 8);
 5058            }
 5059        };
 5060
 5061        pub const in = extern struct {
 5062            len: u8 = @sizeOf(in),
 5063            family: sa_family_t = AF.INET,
 5064            port: in_port_t,
 5065            addr: u32,
 5066            zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
 5067        };
 5068
 5069        pub const in6 = extern struct {
 5070            len: u8 = @sizeOf(in6),
 5071            family: sa_family_t = AF.INET6,
 5072            port: in_port_t,
 5073            flowinfo: u32,
 5074            addr: [16]u8,
 5075            scope_id: u32,
 5076        };
 5077
 5078        /// Definitions for UNIX IPC domain.
 5079        pub const un = extern struct {
 5080            /// total sockaddr length
 5081            len: u8 = @sizeOf(un),
 5082
 5083            family: sa_family_t = AF.LOCAL,
 5084
 5085            /// path name
 5086            path: [104]u8,
 5087        };
 5088    },
 5089    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L110-L114
 5090    .serenity => extern struct {
 5091        family: sa_family_t,
 5092        data: [26]u8,
 5093
 5094        // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/netinet/in.h
 5095        const in_addr = u32;
 5096        const in6_addr = [16]u8;
 5097        pub const in = extern struct {
 5098            family: sa_family_t = AF.INET,
 5099            port: in_port_t,
 5100            addr: in_addr,
 5101            zero: [8]u8 = @splat(0),
 5102        };
 5103        pub const in6 = extern struct {
 5104            family: sa_family_t = AF.INET6,
 5105            port: in_port_t,
 5106            flowinfo: u32,
 5107            addr: in6_addr,
 5108            scope_id: u32,
 5109        };
 5110
 5111        // https://github.com/SerenityOS/serenity/blob/b92e6b02e53b2927732f31b1442cad420b62d1ef/Kernel/API/POSIX/sys/un.h
 5112        const UNIX_PATH_MAX = 108;
 5113        pub const un = extern struct {
 5114            family: sa_family_t = AF.LOCAL,
 5115            path: [UNIX_PATH_MAX]u8,
 5116        };
 5117    },
 5118    else => void,
 5119};
 5120pub const socklen_t = switch (native_os) {
 5121    .linux, .emscripten => linux.socklen_t,
 5122    .windows => ws2_32.socklen_t,
 5123    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L57
 5124    else => u32,
 5125};
 5126pub const in_port_t = u16;
 5127pub const sa_family_t = switch (native_os) {
 5128    .linux, .emscripten => linux.sa_family_t,
 5129    .windows => ws2_32.ADDRESS_FAMILY,
 5130    .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u8,
 5131    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L66
 5132    .illumos, .serenity => u16,
 5133    else => void,
 5134};
 5135pub const AF = if (builtin.abi.isAndroid()) struct {
 5136    pub const UNSPEC = 0;
 5137    pub const UNIX = 1;
 5138    pub const LOCAL = 1;
 5139    pub const INET = 2;
 5140    pub const AX25 = 3;
 5141    pub const IPX = 4;
 5142    pub const APPLETALK = 5;
 5143    pub const NETROM = 6;
 5144    pub const BRIDGE = 7;
 5145    pub const ATMPVC = 8;
 5146    pub const X25 = 9;
 5147    pub const INET6 = 10;
 5148    pub const ROSE = 11;
 5149    pub const DECnet = 12;
 5150    pub const NETBEUI = 13;
 5151    pub const SECURITY = 14;
 5152    pub const KEY = 15;
 5153    pub const NETLINK = 16;
 5154    pub const ROUTE = NETLINK;
 5155    pub const PACKET = 17;
 5156    pub const ASH = 18;
 5157    pub const ECONET = 19;
 5158    pub const ATMSVC = 20;
 5159    pub const RDS = 21;
 5160    pub const SNA = 22;
 5161    pub const IRDA = 23;
 5162    pub const PPPOX = 24;
 5163    pub const WANPIPE = 25;
 5164    pub const LLC = 26;
 5165    pub const CAN = 29;
 5166    pub const TIPC = 30;
 5167    pub const BLUETOOTH = 31;
 5168    pub const IUCV = 32;
 5169    pub const RXRPC = 33;
 5170    pub const ISDN = 34;
 5171    pub const PHONET = 35;
 5172    pub const IEEE802154 = 36;
 5173    pub const CAIF = 37;
 5174    pub const ALG = 38;
 5175    pub const NFC = 39;
 5176    pub const VSOCK = 40;
 5177    pub const KCM = 41;
 5178    pub const QIPCRTR = 42;
 5179    pub const MAX = 43;
 5180} else switch (native_os) {
 5181    .linux, .emscripten => linux.AF,
 5182    .windows => ws2_32.AF,
 5183    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 5184        pub const UNSPEC = 0;
 5185        pub const LOCAL = 1;
 5186        pub const UNIX = LOCAL;
 5187        pub const INET = 2;
 5188        pub const SYS_CONTROL = 2;
 5189        pub const IMPLINK = 3;
 5190        pub const PUP = 4;
 5191        pub const CHAOS = 5;
 5192        pub const NS = 6;
 5193        pub const ISO = 7;
 5194        pub const OSI = ISO;
 5195        pub const ECMA = 8;
 5196        pub const DATAKIT = 9;
 5197        pub const CCITT = 10;
 5198        pub const SNA = 11;
 5199        pub const DECnet = 12;
 5200        pub const DLI = 13;
 5201        pub const LAT = 14;
 5202        pub const HYLINK = 15;
 5203        pub const APPLETALK = 16;
 5204        pub const ROUTE = 17;
 5205        pub const LINK = 18;
 5206        pub const XTP = 19;
 5207        pub const COIP = 20;
 5208        pub const CNT = 21;
 5209        pub const RTIP = 22;
 5210        pub const IPX = 23;
 5211        pub const SIP = 24;
 5212        pub const PIP = 25;
 5213        pub const ISDN = 28;
 5214        pub const E164 = ISDN;
 5215        pub const KEY = 29;
 5216        pub const INET6 = 30;
 5217        pub const NATM = 31;
 5218        pub const SYSTEM = 32;
 5219        pub const NETBIOS = 33;
 5220        pub const PPP = 34;
 5221        pub const MAX = 40;
 5222    },
 5223    .freebsd => struct {
 5224        pub const UNSPEC = 0;
 5225        pub const UNIX = 1;
 5226        pub const LOCAL = UNIX;
 5227        pub const FILE = LOCAL;
 5228        pub const INET = 2;
 5229        pub const IMPLINK = 3;
 5230        pub const PUP = 4;
 5231        pub const CHAOS = 5;
 5232        pub const NETBIOS = 6;
 5233        pub const ISO = 7;
 5234        pub const OSI = ISO;
 5235        pub const ECMA = 8;
 5236        pub const DATAKIT = 9;
 5237        pub const CCITT = 10;
 5238        pub const SNA = 11;
 5239        pub const DECnet = 12;
 5240        pub const DLI = 13;
 5241        pub const LAT = 14;
 5242        pub const HYLINK = 15;
 5243        pub const APPLETALK = 16;
 5244        pub const ROUTE = 17;
 5245        pub const LINK = 18;
 5246        pub const pseudo_XTP = 19;
 5247        pub const COIP = 20;
 5248        pub const CNT = 21;
 5249        pub const pseudo_RTIP = 22;
 5250        pub const IPX = 23;
 5251        pub const SIP = 24;
 5252        pub const pseudo_PIP = 25;
 5253        pub const ISDN = 26;
 5254        pub const E164 = ISDN;
 5255        pub const pseudo_KEY = 27;
 5256        pub const INET6 = 28;
 5257        pub const NATM = 29;
 5258        pub const ATM = 30;
 5259        pub const pseudo_HDRCMPLT = 31;
 5260        pub const NETGRAPH = 32;
 5261        pub const SLOW = 33;
 5262        pub const SCLUSTER = 34;
 5263        pub const ARP = 35;
 5264        pub const BLUETOOTH = 36;
 5265        pub const IEEE80211 = 37;
 5266        pub const INET_SDP = 40;
 5267        pub const INET6_SDP = 42;
 5268        pub const MAX = 42;
 5269    },
 5270    .illumos => struct {
 5271        pub const UNSPEC = 0;
 5272        pub const UNIX = 1;
 5273        pub const LOCAL = UNIX;
 5274        pub const FILE = UNIX;
 5275        pub const INET = 2;
 5276        pub const IMPLINK = 3;
 5277        pub const PUP = 4;
 5278        pub const CHAOS = 5;
 5279        pub const NS = 6;
 5280        pub const NBS = 7;
 5281        pub const ECMA = 8;
 5282        pub const DATAKIT = 9;
 5283        pub const CCITT = 10;
 5284        pub const SNA = 11;
 5285        pub const DECnet = 12;
 5286        pub const DLI = 13;
 5287        pub const LAT = 14;
 5288        pub const HYLINK = 15;
 5289        pub const APPLETALK = 16;
 5290        pub const NIT = 17;
 5291        pub const @"802" = 18;
 5292        pub const OSI = 19;
 5293        pub const X25 = 20;
 5294        pub const OSINET = 21;
 5295        pub const GOSIP = 22;
 5296        pub const IPX = 23;
 5297        pub const ROUTE = 24;
 5298        pub const LINK = 25;
 5299        pub const INET6 = 26;
 5300        pub const KEY = 27;
 5301        pub const NCA = 28;
 5302        pub const POLICY = 29;
 5303        pub const INET_OFFLOAD = 30;
 5304        pub const TRILL = 31;
 5305        pub const PACKET = 32;
 5306        pub const LX_NETLINK = 33;
 5307        pub const MAX = 33;
 5308    },
 5309    .netbsd => struct {
 5310        pub const UNSPEC = 0;
 5311        pub const LOCAL = 1;
 5312        pub const UNIX = LOCAL;
 5313        pub const INET = 2;
 5314        pub const IMPLINK = 3;
 5315        pub const PUP = 4;
 5316        pub const CHAOS = 5;
 5317        pub const NS = 6;
 5318        pub const ISO = 7;
 5319        pub const OSI = ISO;
 5320        pub const ECMA = 8;
 5321        pub const DATAKIT = 9;
 5322        pub const CCITT = 10;
 5323        pub const SNA = 11;
 5324        pub const DECnet = 12;
 5325        pub const DLI = 13;
 5326        pub const LAT = 14;
 5327        pub const HYLINK = 15;
 5328        pub const APPLETALK = 16;
 5329        pub const OROUTE = 17;
 5330        pub const LINK = 18;
 5331        pub const COIP = 20;
 5332        pub const CNT = 21;
 5333        pub const IPX = 23;
 5334        pub const INET6 = 24;
 5335        pub const ISDN = 26;
 5336        pub const E164 = ISDN;
 5337        pub const NATM = 27;
 5338        pub const ARP = 28;
 5339        pub const BLUETOOTH = 31;
 5340        pub const IEEE80211 = 32;
 5341        pub const MPLS = 33;
 5342        pub const ROUTE = 34;
 5343        pub const CAN = 35;
 5344        pub const ETHER = 36;
 5345        pub const MAX = 37;
 5346    },
 5347    .dragonfly => struct {
 5348        pub const UNSPEC = 0;
 5349        pub const OSI = ISO;
 5350        pub const UNIX = LOCAL;
 5351        pub const LOCAL = 1;
 5352        pub const INET = 2;
 5353        pub const IMPLINK = 3;
 5354        pub const PUP = 4;
 5355        pub const CHAOS = 5;
 5356        pub const NETBIOS = 6;
 5357        pub const ISO = 7;
 5358        pub const ECMA = 8;
 5359        pub const DATAKIT = 9;
 5360        pub const CCITT = 10;
 5361        pub const SNA = 11;
 5362        pub const DLI = 13;
 5363        pub const LAT = 14;
 5364        pub const HYLINK = 15;
 5365        pub const APPLETALK = 16;
 5366        pub const ROUTE = 17;
 5367        pub const LINK = 18;
 5368        pub const COIP = 20;
 5369        pub const CNT = 21;
 5370        pub const IPX = 23;
 5371        pub const SIP = 24;
 5372        pub const ISDN = 26;
 5373        pub const INET6 = 28;
 5374        pub const NATM = 29;
 5375        pub const ATM = 30;
 5376        pub const NETGRAPH = 32;
 5377        pub const BLUETOOTH = 33;
 5378        pub const MPLS = 34;
 5379        pub const MAX = 36;
 5380    },
 5381    .haiku => struct {
 5382        pub const UNSPEC = 0;
 5383        pub const INET = 1;
 5384        pub const APPLETALK = 2;
 5385        pub const ROUTE = 3;
 5386        pub const LINK = 4;
 5387        pub const INET6 = 5;
 5388        pub const DLI = 6;
 5389        pub const IPX = 7;
 5390        pub const NOTIFY = 8;
 5391        pub const LOCAL = 9;
 5392        pub const UNIX = LOCAL;
 5393        pub const BLUETOOTH = 10;
 5394        pub const MAX = 11;
 5395    },
 5396    .openbsd => struct {
 5397        pub const UNSPEC = 0;
 5398        pub const UNIX = 1;
 5399        pub const LOCAL = UNIX;
 5400        pub const INET = 2;
 5401        pub const APPLETALK = 16;
 5402        pub const INET6 = 24;
 5403        pub const KEY = 30;
 5404        pub const ROUTE = 17;
 5405        pub const SNA = 11;
 5406        pub const MPLS = 33;
 5407        pub const BLUETOOTH = 32;
 5408        pub const ISDN = 26;
 5409        pub const MAX = 36;
 5410    },
 5411    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L17-L22
 5412    .serenity => struct {
 5413        pub const UNSPEC = 0;
 5414        pub const LOCAL = 1;
 5415        pub const UNIX = LOCAL;
 5416        pub const INET = 2;
 5417        pub const INET6 = 3;
 5418        pub const MAX = 4;
 5419    },
 5420    else => void,
 5421};
 5422pub const PF = if (builtin.abi.isAndroid()) struct {
 5423    pub const UNSPEC = AF.UNSPEC;
 5424    pub const UNIX = AF.UNIX;
 5425    pub const LOCAL = AF.LOCAL;
 5426    pub const INET = AF.INET;
 5427    pub const AX25 = AF.AX25;
 5428    pub const IPX = AF.IPX;
 5429    pub const APPLETALK = AF.APPLETALK;
 5430    pub const NETROM = AF.NETROM;
 5431    pub const BRIDGE = AF.BRIDGE;
 5432    pub const ATMPVC = AF.ATMPVC;
 5433    pub const X25 = AF.X25;
 5434    pub const PF_INET6 = AF.INET6;
 5435    pub const PF_ROSE = AF.ROSE;
 5436    pub const PF_DECnet = AF.DECnet;
 5437    pub const PF_NETBEUI = AF.NETBEUI;
 5438    pub const PF_SECURITY = AF.SECURITY;
 5439    pub const PF_KEY = AF.KEY;
 5440    pub const PF_NETLINK = AF.NETLINK;
 5441    pub const PF_ROUTE = AF.ROUTE;
 5442    pub const PF_PACKET = AF.PACKET;
 5443    pub const PF_ASH = AF.ASH;
 5444    pub const PF_ECONET = AF.ECONET;
 5445    pub const PF_ATMSVC = AF.ATMSVC;
 5446    pub const PF_RDS = AF.RDS;
 5447    pub const PF_SNA = AF.SNA;
 5448    pub const PF_IRDA = AF.IRDA;
 5449    pub const PF_PPPOX = AF.PPPOX;
 5450    pub const PF_WANPIPE = AF.WANPIPE;
 5451    pub const PF_LLC = AF.LLC;
 5452    pub const PF_CAN = AF.CAN;
 5453    pub const PF_TIPC = AF.TIPC;
 5454    pub const PF_BLUETOOTH = AF.BLUETOOTH;
 5455    pub const PF_IUCV = AF.IUCV;
 5456    pub const PF_RXRPC = AF.RXRPC;
 5457    pub const PF_ISDN = AF.ISDN;
 5458    pub const PF_PHONET = AF.PHONET;
 5459    pub const PF_IEEE802154 = AF.IEEE802154;
 5460    pub const PF_CAIF = AF.CAIF;
 5461    pub const PF_ALG = AF.ALG;
 5462    pub const PF_NFC = AF.NFC;
 5463    pub const PF_VSOCK = AF.VSOCK;
 5464    pub const PF_KCM = AF.KCM;
 5465    pub const PF_QIPCRTR = AF.QIPCRTR;
 5466    pub const PF_MAX = AF.MAX;
 5467} else switch (native_os) {
 5468    .linux, .emscripten => linux.PF,
 5469    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 5470        pub const UNSPEC = AF.UNSPEC;
 5471        pub const LOCAL = AF.LOCAL;
 5472        pub const UNIX = PF.LOCAL;
 5473        pub const INET = AF.INET;
 5474        pub const IMPLINK = AF.IMPLINK;
 5475        pub const PUP = AF.PUP;
 5476        pub const CHAOS = AF.CHAOS;
 5477        pub const NS = AF.NS;
 5478        pub const ISO = AF.ISO;
 5479        pub const OSI = AF.ISO;
 5480        pub const ECMA = AF.ECMA;
 5481        pub const DATAKIT = AF.DATAKIT;
 5482        pub const CCITT = AF.CCITT;
 5483        pub const SNA = AF.SNA;
 5484        pub const DECnet = AF.DECnet;
 5485        pub const DLI = AF.DLI;
 5486        pub const LAT = AF.LAT;
 5487        pub const HYLINK = AF.HYLINK;
 5488        pub const APPLETALK = AF.APPLETALK;
 5489        pub const ROUTE = AF.ROUTE;
 5490        pub const LINK = AF.LINK;
 5491        pub const XTP = AF.XTP;
 5492        pub const COIP = AF.COIP;
 5493        pub const CNT = AF.CNT;
 5494        pub const SIP = AF.SIP;
 5495        pub const IPX = AF.IPX;
 5496        pub const RTIP = AF.RTIP;
 5497        pub const PIP = AF.PIP;
 5498        pub const ISDN = AF.ISDN;
 5499        pub const KEY = AF.KEY;
 5500        pub const INET6 = AF.INET6;
 5501        pub const NATM = AF.NATM;
 5502        pub const SYSTEM = AF.SYSTEM;
 5503        pub const NETBIOS = AF.NETBIOS;
 5504        pub const PPP = AF.PPP;
 5505        pub const MAX = AF.MAX;
 5506    },
 5507    .freebsd => struct {
 5508        pub const UNSPEC = AF.UNSPEC;
 5509        pub const LOCAL = AF.LOCAL;
 5510        pub const UNIX = PF.LOCAL;
 5511        pub const INET = AF.INET;
 5512        pub const IMPLINK = AF.IMPLINK;
 5513        pub const PUP = AF.PUP;
 5514        pub const CHAOS = AF.CHAOS;
 5515        pub const NETBIOS = AF.NETBIOS;
 5516        pub const ISO = AF.ISO;
 5517        pub const OSI = AF.ISO;
 5518        pub const ECMA = AF.ECMA;
 5519        pub const DATAKIT = AF.DATAKIT;
 5520        pub const CCITT = AF.CCITT;
 5521        pub const DECnet = AF.DECnet;
 5522        pub const DLI = AF.DLI;
 5523        pub const LAT = AF.LAT;
 5524        pub const HYLINK = AF.HYLINK;
 5525        pub const APPLETALK = AF.APPLETALK;
 5526        pub const ROUTE = AF.ROUTE;
 5527        pub const LINK = AF.LINK;
 5528        pub const XTP = AF.pseudo_XTP;
 5529        pub const COIP = AF.COIP;
 5530        pub const CNT = AF.CNT;
 5531        pub const SIP = AF.SIP;
 5532        pub const IPX = AF.IPX;
 5533        pub const RTIP = AF.pseudo_RTIP;
 5534        pub const PIP = AF.pseudo_PIP;
 5535        pub const ISDN = AF.ISDN;
 5536        pub const KEY = AF.pseudo_KEY;
 5537        pub const INET6 = AF.pseudo_INET6;
 5538        pub const NATM = AF.NATM;
 5539        pub const ATM = AF.ATM;
 5540        pub const NETGRAPH = AF.NETGRAPH;
 5541        pub const SLOW = AF.SLOW;
 5542        pub const SCLUSTER = AF.SCLUSTER;
 5543        pub const ARP = AF.ARP;
 5544        pub const BLUETOOTH = AF.BLUETOOTH;
 5545        pub const IEEE80211 = AF.IEEE80211;
 5546        pub const INET_SDP = AF.INET_SDP;
 5547        pub const INET6_SDP = AF.INET6_SDP;
 5548        pub const MAX = AF.MAX;
 5549    },
 5550    .illumos => struct {
 5551        pub const UNSPEC = AF.UNSPEC;
 5552        pub const UNIX = AF.UNIX;
 5553        pub const LOCAL = UNIX;
 5554        pub const FILE = UNIX;
 5555        pub const INET = AF.INET;
 5556        pub const IMPLINK = AF.IMPLINK;
 5557        pub const PUP = AF.PUP;
 5558        pub const CHAOS = AF.CHAOS;
 5559        pub const NS = AF.NS;
 5560        pub const NBS = AF.NBS;
 5561        pub const ECMA = AF.ECMA;
 5562        pub const DATAKIT = AF.DATAKIT;
 5563        pub const CCITT = AF.CCITT;
 5564        pub const SNA = AF.SNA;
 5565        pub const DECnet = AF.DECnet;
 5566        pub const DLI = AF.DLI;
 5567        pub const LAT = AF.LAT;
 5568        pub const HYLINK = AF.HYLINK;
 5569        pub const APPLETALK = AF.APPLETALK;
 5570        pub const NIT = AF.NIT;
 5571        pub const @"802" = AF.@"802";
 5572        pub const OSI = AF.OSI;
 5573        pub const X25 = AF.X25;
 5574        pub const OSINET = AF.OSINET;
 5575        pub const GOSIP = AF.GOSIP;
 5576        pub const IPX = AF.IPX;
 5577        pub const ROUTE = AF.ROUTE;
 5578        pub const LINK = AF.LINK;
 5579        pub const INET6 = AF.INET6;
 5580        pub const KEY = AF.KEY;
 5581        pub const NCA = AF.NCA;
 5582        pub const POLICY = AF.POLICY;
 5583        pub const TRILL = AF.TRILL;
 5584        pub const PACKET = AF.PACKET;
 5585        pub const LX_NETLINK = AF.LX_NETLINK;
 5586        pub const MAX = AF.MAX;
 5587    },
 5588    .netbsd => struct {
 5589        pub const UNSPEC = AF.UNSPEC;
 5590        pub const LOCAL = AF.LOCAL;
 5591        pub const UNIX = PF.LOCAL;
 5592        pub const INET = AF.INET;
 5593        pub const IMPLINK = AF.IMPLINK;
 5594        pub const PUP = AF.PUP;
 5595        pub const CHAOS = AF.CHAOS;
 5596        pub const NS = AF.NS;
 5597        pub const ISO = AF.ISO;
 5598        pub const OSI = AF.ISO;
 5599        pub const ECMA = AF.ECMA;
 5600        pub const DATAKIT = AF.DATAKIT;
 5601        pub const CCITT = AF.CCITT;
 5602        pub const SNA = AF.SNA;
 5603        pub const DECnet = AF.DECnet;
 5604        pub const DLI = AF.DLI;
 5605        pub const LAT = AF.LAT;
 5606        pub const HYLINK = AF.HYLINK;
 5607        pub const APPLETALK = AF.APPLETALK;
 5608        pub const OROUTE = AF.OROUTE;
 5609        pub const LINK = AF.LINK;
 5610        pub const COIP = AF.COIP;
 5611        pub const CNT = AF.CNT;
 5612        pub const INET6 = AF.INET6;
 5613        pub const IPX = AF.IPX;
 5614        pub const ISDN = AF.ISDN;
 5615        pub const E164 = AF.E164;
 5616        pub const NATM = AF.NATM;
 5617        pub const ARP = AF.ARP;
 5618        pub const BLUETOOTH = AF.BLUETOOTH;
 5619        pub const MPLS = AF.MPLS;
 5620        pub const ROUTE = AF.ROUTE;
 5621        pub const CAN = AF.CAN;
 5622        pub const ETHER = AF.ETHER;
 5623        pub const MAX = AF.MAX;
 5624    },
 5625    .dragonfly => struct {
 5626        pub const INET6 = AF.INET6;
 5627        pub const IMPLINK = AF.IMPLINK;
 5628        pub const ROUTE = AF.ROUTE;
 5629        pub const ISO = AF.ISO;
 5630        pub const PIP = AF.pseudo_PIP;
 5631        pub const CHAOS = AF.CHAOS;
 5632        pub const DATAKIT = AF.DATAKIT;
 5633        pub const INET = AF.INET;
 5634        pub const APPLETALK = AF.APPLETALK;
 5635        pub const SIP = AF.SIP;
 5636        pub const OSI = AF.ISO;
 5637        pub const CNT = AF.CNT;
 5638        pub const LINK = AF.LINK;
 5639        pub const HYLINK = AF.HYLINK;
 5640        pub const MAX = AF.MAX;
 5641        pub const KEY = AF.pseudo_KEY;
 5642        pub const PUP = AF.PUP;
 5643        pub const COIP = AF.COIP;
 5644        pub const SNA = AF.SNA;
 5645        pub const LOCAL = AF.LOCAL;
 5646        pub const NETBIOS = AF.NETBIOS;
 5647        pub const NATM = AF.NATM;
 5648        pub const BLUETOOTH = AF.BLUETOOTH;
 5649        pub const UNSPEC = AF.UNSPEC;
 5650        pub const NETGRAPH = AF.NETGRAPH;
 5651        pub const ECMA = AF.ECMA;
 5652        pub const IPX = AF.IPX;
 5653        pub const DLI = AF.DLI;
 5654        pub const ATM = AF.ATM;
 5655        pub const CCITT = AF.CCITT;
 5656        pub const ISDN = AF.ISDN;
 5657        pub const RTIP = AF.pseudo_RTIP;
 5658        pub const LAT = AF.LAT;
 5659        pub const UNIX = PF.LOCAL;
 5660        pub const XTP = AF.pseudo_XTP;
 5661        pub const DECnet = AF.DECnet;
 5662    },
 5663    .haiku => struct {
 5664        pub const UNSPEC = AF.UNSPEC;
 5665        pub const INET = AF.INET;
 5666        pub const ROUTE = AF.ROUTE;
 5667        pub const LINK = AF.LINK;
 5668        pub const INET6 = AF.INET6;
 5669        pub const LOCAL = AF.LOCAL;
 5670        pub const UNIX = AF.UNIX;
 5671        pub const BLUETOOTH = AF.BLUETOOTH;
 5672    },
 5673    .openbsd => struct {
 5674        pub const UNSPEC = AF.UNSPEC;
 5675        pub const LOCAL = AF.LOCAL;
 5676        pub const UNIX = AF.UNIX;
 5677        pub const INET = AF.INET;
 5678        pub const APPLETALK = AF.APPLETALK;
 5679        pub const INET6 = AF.INET6;
 5680        pub const DECnet = AF.DECnet;
 5681        pub const KEY = AF.KEY;
 5682        pub const ROUTE = AF.ROUTE;
 5683        pub const SNA = AF.SNA;
 5684        pub const MPLS = AF.MPLS;
 5685        pub const BLUETOOTH = AF.BLUETOOTH;
 5686        pub const ISDN = AF.ISDN;
 5687        pub const MAX = AF.MAX;
 5688    },
 5689    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L24-L29
 5690    .serenity => struct {
 5691        pub const LOCAL = AF.LOCAL;
 5692        pub const UNIX = AF.LOCAL;
 5693        pub const INET = AF.INET;
 5694        pub const INET6 = AF.INET6;
 5695        pub const UNSPEC = AF.UNSPEC;
 5696        pub const MAX = AF.MAX;
 5697    },
 5698    else => void,
 5699};
 5700pub const DT = switch (native_os) {
 5701    .linux => linux.DT,
 5702    // https://github.com/SerenityOS/serenity/blob/1262a7d1424d0d2e89d80644409721cbf056ab17/Kernel/API/POSIX/dirent.h#L16-L35
 5703    .netbsd, .freebsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => struct {
 5704        pub const UNKNOWN = 0;
 5705        pub const FIFO = 1;
 5706        pub const CHR = 2;
 5707        pub const DIR = 4;
 5708        pub const BLK = 6;
 5709        pub const REG = 8;
 5710        pub const LNK = 10;
 5711        pub const SOCK = 12;
 5712        pub const WHT = 14;
 5713    },
 5714    .dragonfly => struct {
 5715        pub const UNKNOWN = 0;
 5716        pub const FIFO = 1;
 5717        pub const CHR = 2;
 5718        pub const DIR = 4;
 5719        pub const BLK = 6;
 5720        pub const REG = 8;
 5721        pub const LNK = 10;
 5722        pub const SOCK = 12;
 5723        pub const WHT = 14;
 5724        pub const DBF = 15;
 5725    },
 5726    else => void,
 5727};
 5728pub const MSG = switch (native_os) {
 5729    .linux => linux.MSG,
 5730    .emscripten => emscripten.MSG,
 5731    .windows => ws2_32.MSG,
 5732    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.MSG,
 5733    .haiku => struct {
 5734        pub const OOB = 0x0001;
 5735        pub const PEEK = 0x0002;
 5736        pub const DONTROUTE = 0x0004;
 5737        pub const EOR = 0x0008;
 5738        pub const TRUNC = 0x0010;
 5739        pub const CTRUNC = 0x0020;
 5740        pub const WAITALL = 0x0040;
 5741        pub const DONTWAIT = 0x0080;
 5742        pub const BCAST = 0x0100;
 5743        pub const MCAST = 0x0200;
 5744        pub const EOF = 0x0400;
 5745        pub const NOSIGNAL = 0x0800;
 5746    },
 5747    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L56-L64
 5748    .serenity => struct {
 5749        pub const TRUNC = 0x1;
 5750        pub const CTRUNC = 0x2;
 5751        pub const PEEK = 0x4;
 5752        pub const OOB = 0x8;
 5753        pub const DONTROUTE = 0x10;
 5754        pub const WAITALL = 0x20;
 5755        pub const DONTWAIT = 0x40;
 5756        pub const NOSIGNAL = 0x80;
 5757        pub const EOR = 0x100;
 5758    },
 5759    .freebsd => struct {
 5760        pub const OOB = 0x00000001;
 5761        pub const PEEK = 0x00000002;
 5762        pub const DONTROUTE = 0x00000004;
 5763        pub const EOR = 0x00000008;
 5764        pub const TRUNC = 0x00000010;
 5765        pub const CTRUNC = 0x00000020;
 5766        pub const WAITALL = 0x00000040;
 5767        pub const DONTWAIT = 0x00000080;
 5768        pub const EOF = 0x00000100;
 5769        pub const NOTIFICATION = 0x00002000;
 5770        pub const NBIO = 0x00004000;
 5771        pub const COMPAT = 0x00008000;
 5772        pub const SOCALLBCK = 0x00010000;
 5773        pub const NOSIGNAL = 0x00020000;
 5774        pub const CMSG_CLOEXEC = 0x00040000;
 5775        pub const WAITFORONE = 0x00080000;
 5776        pub const MORETOCOME = 0x00100000;
 5777        pub const TLSAPPDATA = 0x00200000;
 5778    },
 5779    .netbsd => struct {
 5780        pub const OOB = 0x0001;
 5781        pub const PEEK = 0x0002;
 5782        pub const DONTROUTE = 0x0004;
 5783        pub const EOR = 0x0008;
 5784        pub const TRUNC = 0x0010;
 5785        pub const CTRUNC = 0x0020;
 5786        pub const WAITALL = 0x0040;
 5787        pub const DONTWAIT = 0x0080;
 5788        pub const BCAST = 0x0100;
 5789        pub const MCAST = 0x0200;
 5790        pub const NOSIGNAL = 0x0400;
 5791        pub const CMSG_CLOEXEC = 0x0800;
 5792        pub const NBIO = 0x1000;
 5793        pub const WAITFORONE = 0x2000;
 5794        pub const NOTIFICATION = 0x4000;
 5795    },
 5796    // https://github.com/openbsd/src/blob/42a7be81bef70c04732f45ec573622effe56b563/sys/sys/socket.h#L506
 5797    .openbsd => struct {
 5798        pub const OOB = 0x1;
 5799        pub const PEEK = 0x2;
 5800        pub const DONTROUTE = 0x4;
 5801        pub const EOR = 0x8;
 5802        pub const TRUNC = 0x10;
 5803        pub const CTRUNC = 0x20;
 5804        pub const WAITALL = 0x40;
 5805        pub const DONTWAIT = 0x80;
 5806        pub const BCAST = 0x100;
 5807        pub const MCAST = 0x200;
 5808        pub const NOSIGNAL = 0x400;
 5809        pub const CMSG_CLOEXEC = 0x800;
 5810        pub const WAITFORONE = 0x1000;
 5811        pub const CMSG_CLOFORK = 0x2000;
 5812    },
 5813    .dragonfly => struct {
 5814        pub const OOB = 0x0001;
 5815        pub const PEEK = 0x0002;
 5816        pub const DONTROUTE = 0x0004;
 5817        pub const EOR = 0x0008;
 5818        pub const TRUNC = 0x0010;
 5819        pub const CTRUNC = 0x0020;
 5820        pub const WAITALL = 0x0040;
 5821        pub const DONTWAIT = 0x0080;
 5822        pub const NOSIGNAL = 0x0400;
 5823        pub const SYNC = 0x0800;
 5824        pub const CMSG_CLOEXEC = 0x1000;
 5825        pub const CMSG_CLOFORK = 0x2000;
 5826        pub const FBLOCKING = 0x10000;
 5827        pub const FNONBLOCKING = 0x20000;
 5828    },
 5829    .illumos => struct {
 5830        pub const OOB = 0x0001;
 5831        pub const PEEK = 0x0002;
 5832        pub const DONTROUTE = 0x0004;
 5833        pub const EOR = 0x0008;
 5834        pub const CTRUNC = 0x0010;
 5835        pub const TRUNC = 0x0020;
 5836        pub const WAITALL = 0x0040;
 5837        pub const DONTWAIT = 0x0080;
 5838        pub const NOTIFICATION = 0x0100;
 5839        pub const NOSIGNAL = 0x0200;
 5840        pub const CMSG_CLOEXEC = 0x1000;
 5841        pub const CMSG_CLOFORK = 0x2000;
 5842    },
 5843    else => void,
 5844};
 5845pub const SOCK = switch (native_os) {
 5846    .linux => linux.SOCK,
 5847    .emscripten => emscripten.SOCK,
 5848    .windows => ws2_32.SOCK,
 5849    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 5850        pub const STREAM = 1;
 5851        pub const DGRAM = 2;
 5852        pub const RAW = 3;
 5853        pub const RDM = 4;
 5854        pub const SEQPACKET = 5;
 5855        pub const MAXADDRLEN = 255;
 5856
 5857        /// Not actually supported by Darwin, but Zig supplies a shim.
 5858        /// This numerical value is not ABI-stable. It need only not conflict
 5859        /// with any other `SOCK` bits.
 5860        pub const CLOEXEC = 1 << 15;
 5861        /// Not actually supported by Darwin, but Zig supplies a shim.
 5862        /// This numerical value is not ABI-stable. It need only not conflict
 5863        /// with any other `SOCK` bits.
 5864        pub const NONBLOCK = 1 << 16;
 5865    },
 5866    .freebsd => struct {
 5867        pub const STREAM = 1;
 5868        pub const DGRAM = 2;
 5869        pub const RAW = 3;
 5870        pub const RDM = 4;
 5871        pub const SEQPACKET = 5;
 5872
 5873        pub const CLOEXEC = 0x10000000;
 5874        pub const NONBLOCK = 0x20000000;
 5875    },
 5876    .illumos => struct {
 5877        /// Datagram.
 5878        pub const DGRAM = 1;
 5879        /// STREAM.
 5880        pub const STREAM = 2;
 5881        /// Raw-protocol interface.
 5882        pub const RAW = 4;
 5883        /// Reliably-delivered message.
 5884        pub const RDM = 5;
 5885        /// Sequenced packed stream.
 5886        pub const SEQPACKET = 6;
 5887
 5888        pub const NONBLOCK = 0x100000;
 5889        pub const NDELAY = 0x200000;
 5890        pub const CLOEXEC = 0x080000;
 5891    },
 5892    .netbsd => struct {
 5893        pub const STREAM = 1;
 5894        pub const DGRAM = 2;
 5895        pub const RAW = 3;
 5896        pub const RDM = 4;
 5897        pub const SEQPACKET = 5;
 5898        pub const CONN_DGRAM = 6;
 5899        pub const DCCP = CONN_DGRAM;
 5900
 5901        pub const CLOEXEC = 0x10000000;
 5902        pub const NONBLOCK = 0x20000000;
 5903        pub const NOSIGPIPE = 0x40000000;
 5904        pub const FLAGS_MASK = 0xf0000000;
 5905    },
 5906    .dragonfly => struct {
 5907        pub const STREAM = 1;
 5908        pub const DGRAM = 2;
 5909        pub const RAW = 3;
 5910        pub const RDM = 4;
 5911        pub const SEQPACKET = 5;
 5912        pub const MAXADDRLEN = 255;
 5913        pub const CLOEXEC = 0x10000000;
 5914        pub const NONBLOCK = 0x20000000;
 5915    },
 5916    .haiku => struct {
 5917        pub const STREAM = 1;
 5918        pub const DGRAM = 2;
 5919        pub const RAW = 3;
 5920        pub const SEQPACKET = 5;
 5921        pub const MISC = 255;
 5922
 5923        pub const NONBLOCK = 0x40000;
 5924        pub const CLOEXEC = 0x80000;
 5925    },
 5926    .openbsd => struct {
 5927        pub const STREAM = 1;
 5928        pub const DGRAM = 2;
 5929        pub const RAW = 3;
 5930        pub const RDM = 4;
 5931        pub const SEQPACKET = 5;
 5932
 5933        pub const CLOEXEC = 0x8000;
 5934        pub const NONBLOCK = 0x4000;
 5935    },
 5936    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L31-L38
 5937    .serenity => struct {
 5938        pub const STREAM = 1;
 5939        pub const DGRAM = 2;
 5940        pub const RAW = 3;
 5941        pub const RDM = 4;
 5942        pub const SEQPACKET = 5;
 5943
 5944        pub const NONBLOCK = 0o4000;
 5945        pub const CLOEXEC = 0o2000000;
 5946    },
 5947    else => void,
 5948};
 5949pub const TCP = switch (native_os) {
 5950    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.TCP,
 5951    .linux => linux.TCP,
 5952    .emscripten => emscripten.TCP,
 5953    .windows => ws2_32.TCP,
 5954    // https://github.com/SerenityOS/serenity/blob/61ac554a3403838f79ca746bd1c65ded6f97d124/Kernel/API/POSIX/netinet/tcp.h#L13-L14
 5955    .serenity => struct {
 5956        pub const NODELAY = 10;
 5957        pub const MAXSEG = 11;
 5958    },
 5959    else => void,
 5960};
 5961pub const IPPROTO = switch (native_os) {
 5962    .linux, .emscripten => linux.IPPROTO,
 5963    .windows => ws2_32.IPPROTO,
 5964    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 5965        pub const ICMP = 1;
 5966        pub const ICMPV6 = 58;
 5967        pub const TCP = 6;
 5968        pub const UDP = 17;
 5969        pub const IP = 0;
 5970        pub const IPV6 = 41;
 5971    },
 5972    .freebsd => struct {
 5973        /// dummy for IP
 5974        pub const IP = 0;
 5975        /// control message protocol
 5976        pub const ICMP = 1;
 5977        /// tcp
 5978        pub const TCP = 6;
 5979        /// user datagram protocol
 5980        pub const UDP = 17;
 5981        /// IP6 header
 5982        pub const IPV6 = 41;
 5983        /// raw IP packet
 5984        pub const RAW = 255;
 5985        /// IP6 hop-by-hop options
 5986        pub const HOPOPTS = 0;
 5987        /// group mgmt protocol
 5988        pub const IGMP = 2;
 5989        /// gateway^2 (deprecated)
 5990        pub const GGP = 3;
 5991        /// IPv4 encapsulation
 5992        pub const IPV4 = 4;
 5993        /// for compatibility
 5994        pub const IPIP = IPV4;
 5995        /// Stream protocol II
 5996        pub const ST = 7;
 5997        /// exterior gateway protocol
 5998        pub const EGP = 8;
 5999        /// private interior gateway
 6000        pub const PIGP = 9;
 6001        /// BBN RCC Monitoring
 6002        pub const RCCMON = 10;
 6003        /// network voice protocol
 6004        pub const NVPII = 11;
 6005        /// pup
 6006        pub const PUP = 12;
 6007        /// Argus
 6008        pub const ARGUS = 13;
 6009        /// EMCON
 6010        pub const EMCON = 14;
 6011        /// Cross Net Debugger
 6012        pub const XNET = 15;
 6013        /// Chaos
 6014        pub const CHAOS = 16;
 6015        /// Multiplexing
 6016        pub const MUX = 18;
 6017        /// DCN Measurement Subsystems
 6018        pub const MEAS = 19;
 6019        /// Host Monitoring
 6020        pub const HMP = 20;
 6021        /// Packet Radio Measurement
 6022        pub const PRM = 21;
 6023        /// xns idp
 6024        pub const IDP = 22;
 6025        /// Trunk-1
 6026        pub const TRUNK1 = 23;
 6027        /// Trunk-2
 6028        pub const TRUNK2 = 24;
 6029        /// Leaf-1
 6030        pub const LEAF1 = 25;
 6031        /// Leaf-2
 6032        pub const LEAF2 = 26;
 6033        /// Reliable Data
 6034        pub const RDP = 27;
 6035        /// Reliable Transaction
 6036        pub const IRTP = 28;
 6037        /// tp-4 w/ class negotiation
 6038        pub const TP = 29;
 6039        /// Bulk Data Transfer
 6040        pub const BLT = 30;
 6041        /// Network Services
 6042        pub const NSP = 31;
 6043        /// Merit Internodal
 6044        pub const INP = 32;
 6045        /// Datagram Congestion Control Protocol
 6046        pub const DCCP = 33;
 6047        /// Third Party Connect
 6048        pub const @"3PC" = 34;
 6049        /// InterDomain Policy Routing
 6050        pub const IDPR = 35;
 6051        /// XTP
 6052        pub const XTP = 36;
 6053        /// Datagram Delivery
 6054        pub const DDP = 37;
 6055        /// Control Message Transport
 6056        pub const CMTP = 38;
 6057        /// TP++ Transport
 6058        pub const TPXX = 39;
 6059        /// IL transport protocol
 6060        pub const IL = 40;
 6061        /// Source Demand Routing
 6062        pub const SDRP = 42;
 6063        /// IP6 routing header
 6064        pub const ROUTING = 43;
 6065        /// IP6 fragmentation header
 6066        pub const FRAGMENT = 44;
 6067        /// InterDomain Routing
 6068        pub const IDRP = 45;
 6069        /// resource reservation
 6070        pub const RSVP = 46;
 6071        /// General Routing Encap.
 6072        pub const GRE = 47;
 6073        /// Mobile Host Routing
 6074        pub const MHRP = 48;
 6075        /// BHA
 6076        pub const BHA = 49;
 6077        /// IP6 Encap Sec. Payload
 6078        pub const ESP = 50;
 6079        /// IP6 Auth Header
 6080        pub const AH = 51;
 6081        /// Integ. Net Layer Security
 6082        pub const INLSP = 52;
 6083        /// IP with encryption
 6084        pub const SWIPE = 53;
 6085        /// Next Hop Resolution
 6086        pub const NHRP = 54;
 6087        /// IP Mobility
 6088        pub const MOBILE = 55;
 6089        /// Transport Layer Security
 6090        pub const TLSP = 56;
 6091        /// SKIP
 6092        pub const SKIP = 57;
 6093        /// ICMP6
 6094        pub const ICMPV6 = 58;
 6095        /// IP6 no next header
 6096        pub const NONE = 59;
 6097        /// IP6 destination option
 6098        pub const DSTOPTS = 60;
 6099        /// any host internal protocol
 6100        pub const AHIP = 61;
 6101        /// CFTP
 6102        pub const CFTP = 62;
 6103        /// "hello" routing protocol
 6104        pub const HELLO = 63;
 6105        /// SATNET/Backroom EXPAK
 6106        pub const SATEXPAK = 64;
 6107        /// Kryptolan
 6108        pub const KRYPTOLAN = 65;
 6109        /// Remote Virtual Disk
 6110        pub const RVD = 66;
 6111        /// Pluribus Packet Core
 6112        pub const IPPC = 67;
 6113        /// Any distributed FS
 6114        pub const ADFS = 68;
 6115        /// Satnet Monitoring
 6116        pub const SATMON = 69;
 6117        /// VISA Protocol
 6118        pub const VISA = 70;
 6119        /// Packet Core Utility
 6120        pub const IPCV = 71;
 6121        /// Comp. Prot. Net. Executive
 6122        pub const CPNX = 72;
 6123        /// Comp. Prot. HeartBeat
 6124        pub const CPHB = 73;
 6125        /// Wang Span Network
 6126        pub const WSN = 74;
 6127        /// Packet Video Protocol
 6128        pub const PVP = 75;
 6129        /// BackRoom SATNET Monitoring
 6130        pub const BRSATMON = 76;
 6131        /// Sun net disk proto (temp.)
 6132        pub const ND = 77;
 6133        /// WIDEBAND Monitoring
 6134        pub const WBMON = 78;
 6135        /// WIDEBAND EXPAK
 6136        pub const WBEXPAK = 79;
 6137        /// ISO cnlp
 6138        pub const EON = 80;
 6139        /// VMTP
 6140        pub const VMTP = 81;
 6141        /// Secure VMTP
 6142        pub const SVMTP = 82;
 6143        /// Banyon VINES
 6144        pub const VINES = 83;
 6145        /// TTP
 6146        pub const TTP = 84;
 6147        /// NSFNET-IGP
 6148        pub const IGP = 85;
 6149        /// dissimilar gateway prot.
 6150        pub const DGP = 86;
 6151        /// TCF
 6152        pub const TCF = 87;
 6153        /// Cisco/GXS IGRP
 6154        pub const IGRP = 88;
 6155        /// OSPFIGP
 6156        pub const OSPFIGP = 89;
 6157        /// Strite RPC protocol
 6158        pub const SRPC = 90;
 6159        /// Locus Address Resoloution
 6160        pub const LARP = 91;
 6161        /// Multicast Transport
 6162        pub const MTP = 92;
 6163        /// AX.25 Frames
 6164        pub const AX25 = 93;
 6165        /// IP encapsulated in IP
 6166        pub const IPEIP = 94;
 6167        /// Mobile Int.ing control
 6168        pub const MICP = 95;
 6169        /// Semaphore Comm. security
 6170        pub const SCCSP = 96;
 6171        /// Ethernet IP encapsulation
 6172        pub const ETHERIP = 97;
 6173        /// encapsulation header
 6174        pub const ENCAP = 98;
 6175        /// any private encr. scheme
 6176        pub const APES = 99;
 6177        /// GMTP
 6178        pub const GMTP = 100;
 6179        /// payload compression (IPComp)
 6180        pub const IPCOMP = 108;
 6181        /// SCTP
 6182        pub const SCTP = 132;
 6183        /// IPv6 Mobility Header
 6184        pub const MH = 135;
 6185        /// UDP-Lite
 6186        pub const UDPLITE = 136;
 6187        /// IP6 Host Identity Protocol
 6188        pub const HIP = 139;
 6189        /// IP6 Shim6 Protocol
 6190        pub const SHIM6 = 140;
 6191        /// Protocol Independent Mcast
 6192        pub const PIM = 103;
 6193        /// CARP
 6194        pub const CARP = 112;
 6195        /// PGM
 6196        pub const PGM = 113;
 6197        /// MPLS-in-IP
 6198        pub const MPLS = 137;
 6199        /// PFSYNC
 6200        pub const PFSYNC = 240;
 6201        /// Reserved
 6202        pub const RESERVED_253 = 253;
 6203        /// Reserved
 6204        pub const RESERVED_254 = 254;
 6205    },
 6206    .illumos => struct {
 6207        /// dummy for IP
 6208        pub const IP = 0;
 6209        /// Hop by hop header for IPv6
 6210        pub const HOPOPTS = 0;
 6211        /// control message protocol
 6212        pub const ICMP = 1;
 6213        /// group control protocol
 6214        pub const IGMP = 2;
 6215        /// gateway^2 (deprecated)
 6216        pub const GGP = 3;
 6217        /// IP in IP encapsulation
 6218        pub const ENCAP = 4;
 6219        /// tcp
 6220        pub const TCP = 6;
 6221        /// exterior gateway protocol
 6222        pub const EGP = 8;
 6223        /// pup
 6224        pub const PUP = 12;
 6225        /// user datagram protocol
 6226        pub const UDP = 17;
 6227        /// xns idp
 6228        pub const IDP = 22;
 6229        /// IPv6 encapsulated in IP
 6230        pub const IPV6 = 41;
 6231        /// Routing header for IPv6
 6232        pub const ROUTING = 43;
 6233        /// Fragment header for IPv6
 6234        pub const FRAGMENT = 44;
 6235        /// rsvp
 6236        pub const RSVP = 46;
 6237        /// IPsec Encap. Sec. Payload
 6238        pub const ESP = 50;
 6239        /// IPsec Authentication Hdr.
 6240        pub const AH = 51;
 6241        /// ICMP for IPv6
 6242        pub const ICMPV6 = 58;
 6243        /// No next header for IPv6
 6244        pub const NONE = 59;
 6245        /// Destination options
 6246        pub const DSTOPTS = 60;
 6247        /// "hello" routing protocol
 6248        pub const HELLO = 63;
 6249        /// UNOFFICIAL net disk proto
 6250        pub const ND = 77;
 6251        /// ISO clnp
 6252        pub const EON = 80;
 6253        /// OSPF
 6254        pub const OSPF = 89;
 6255        /// PIM routing protocol
 6256        pub const PIM = 103;
 6257        /// Stream Control
 6258        pub const SCTP = 132;
 6259        /// raw IP packet
 6260        pub const RAW = 255;
 6261        /// Sockets Direct Protocol
 6262        pub const PROTO_SDP = 257;
 6263    },
 6264    .netbsd => struct {
 6265        /// dummy for IP
 6266        pub const IP = 0;
 6267        /// IP6 hop-by-hop options
 6268        pub const HOPOPTS = 0;
 6269        /// control message protocol
 6270        pub const ICMP = 1;
 6271        /// group mgmt protocol
 6272        pub const IGMP = 2;
 6273        /// gateway^2 (deprecated)
 6274        pub const GGP = 3;
 6275        /// IP header
 6276        pub const IPV4 = 4;
 6277        /// IP inside IP
 6278        pub const IPIP = 4;
 6279        /// tcp
 6280        pub const TCP = 6;
 6281        /// exterior gateway protocol
 6282        pub const EGP = 8;
 6283        /// pup
 6284        pub const PUP = 12;
 6285        /// user datagram protocol
 6286        pub const UDP = 17;
 6287        /// xns idp
 6288        pub const IDP = 22;
 6289        /// tp-4 w/ class negotiation
 6290        pub const TP = 29;
 6291        /// DCCP
 6292        pub const DCCP = 33;
 6293        /// IP6 header
 6294        pub const IPV6 = 41;
 6295        /// IP6 routing header
 6296        pub const ROUTING = 43;
 6297        /// IP6 fragmentation header
 6298        pub const FRAGMENT = 44;
 6299        /// resource reservation
 6300        pub const RSVP = 46;
 6301        /// GRE encaps RFC 1701
 6302        pub const GRE = 47;
 6303        /// encap. security payload
 6304        pub const ESP = 50;
 6305        /// authentication header
 6306        pub const AH = 51;
 6307        /// IP Mobility RFC 2004
 6308        pub const MOBILE = 55;
 6309        /// IPv6 ICMP
 6310        pub const IPV6_ICMP = 58;
 6311        /// ICMP6
 6312        pub const ICMPV6 = 58;
 6313        /// IP6 no next header
 6314        pub const NONE = 59;
 6315        /// IP6 destination option
 6316        pub const DSTOPTS = 60;
 6317        /// ISO cnlp
 6318        pub const EON = 80;
 6319        /// Ethernet-in-IP
 6320        pub const ETHERIP = 97;
 6321        /// encapsulation header
 6322        pub const ENCAP = 98;
 6323        /// Protocol indep. multicast
 6324        pub const PIM = 103;
 6325        /// IP Payload Comp. Protocol
 6326        pub const IPCOMP = 108;
 6327        /// VRRP RFC 2338
 6328        pub const VRRP = 112;
 6329        /// Common Address Resolution Protocol
 6330        pub const CARP = 112;
 6331        /// L2TPv3
 6332        pub const L2TP = 115;
 6333        /// SCTP
 6334        pub const SCTP = 132;
 6335        /// PFSYNC
 6336        pub const PFSYNC = 240;
 6337        /// raw IP packet
 6338        pub const RAW = 255;
 6339    },
 6340    .dragonfly => struct {
 6341        pub const IP = 0;
 6342        pub const ICMP = 1;
 6343        pub const TCP = 6;
 6344        pub const UDP = 17;
 6345        pub const IPV6 = 41;
 6346        pub const RAW = 255;
 6347        pub const HOPOPTS = 0;
 6348        pub const IGMP = 2;
 6349        pub const GGP = 3;
 6350        pub const IPV4 = 4;
 6351        pub const IPIP = IPV4;
 6352        pub const ST = 7;
 6353        pub const EGP = 8;
 6354        pub const PIGP = 9;
 6355        pub const RCCMON = 10;
 6356        pub const NVPII = 11;
 6357        pub const PUP = 12;
 6358        pub const ARGUS = 13;
 6359        pub const EMCON = 14;
 6360        pub const XNET = 15;
 6361        pub const CHAOS = 16;
 6362        pub const MUX = 18;
 6363        pub const MEAS = 19;
 6364        pub const HMP = 20;
 6365        pub const PRM = 21;
 6366        pub const IDP = 22;
 6367        pub const TRUNK1 = 23;
 6368        pub const TRUNK2 = 24;
 6369        pub const LEAF1 = 25;
 6370        pub const LEAF2 = 26;
 6371        pub const RDP = 27;
 6372        pub const IRTP = 28;
 6373        pub const TP = 29;
 6374        pub const BLT = 30;
 6375        pub const NSP = 31;
 6376        pub const INP = 32;
 6377        pub const SEP = 33;
 6378        pub const @"3PC" = 34;
 6379        pub const IDPR = 35;
 6380        pub const XTP = 36;
 6381        pub const DDP = 37;
 6382        pub const CMTP = 38;
 6383        pub const TPXX = 39;
 6384        pub const IL = 40;
 6385        pub const SDRP = 42;
 6386        pub const ROUTING = 43;
 6387        pub const FRAGMENT = 44;
 6388        pub const IDRP = 45;
 6389        pub const RSVP = 46;
 6390        pub const GRE = 47;
 6391        pub const MHRP = 48;
 6392        pub const BHA = 49;
 6393        pub const ESP = 50;
 6394        pub const AH = 51;
 6395        pub const INLSP = 52;
 6396        pub const SWIPE = 53;
 6397        pub const NHRP = 54;
 6398        pub const MOBILE = 55;
 6399        pub const TLSP = 56;
 6400        pub const SKIP = 57;
 6401        pub const ICMPV6 = 58;
 6402        pub const NONE = 59;
 6403        pub const DSTOPTS = 60;
 6404        pub const AHIP = 61;
 6405        pub const CFTP = 62;
 6406        pub const HELLO = 63;
 6407        pub const SATEXPAK = 64;
 6408        pub const KRYPTOLAN = 65;
 6409        pub const RVD = 66;
 6410        pub const IPPC = 67;
 6411        pub const ADFS = 68;
 6412        pub const SATMON = 69;
 6413        pub const VISA = 70;
 6414        pub const IPCV = 71;
 6415        pub const CPNX = 72;
 6416        pub const CPHB = 73;
 6417        pub const WSN = 74;
 6418        pub const PVP = 75;
 6419        pub const BRSATMON = 76;
 6420        pub const ND = 77;
 6421        pub const WBMON = 78;
 6422        pub const WBEXPAK = 79;
 6423        pub const EON = 80;
 6424        pub const VMTP = 81;
 6425        pub const SVMTP = 82;
 6426        pub const VINES = 83;
 6427        pub const TTP = 84;
 6428        pub const IGP = 85;
 6429        pub const DGP = 86;
 6430        pub const TCF = 87;
 6431        pub const IGRP = 88;
 6432        pub const OSPFIGP = 89;
 6433        pub const SRPC = 90;
 6434        pub const LARP = 91;
 6435        pub const MTP = 92;
 6436        pub const AX25 = 93;
 6437        pub const IPEIP = 94;
 6438        pub const MICP = 95;
 6439        pub const SCCSP = 96;
 6440        pub const ETHERIP = 97;
 6441        pub const ENCAP = 98;
 6442        pub const APES = 99;
 6443        pub const GMTP = 100;
 6444        pub const IPCOMP = 108;
 6445        pub const PIM = 103;
 6446        pub const CARP = 112;
 6447        pub const PGM = 113;
 6448        pub const PFSYNC = 240;
 6449        pub const DIVERT = 254;
 6450        pub const MAX = 256;
 6451        pub const DONE = 257;
 6452        pub const UNKNOWN = 258;
 6453    },
 6454    .haiku => struct {
 6455        pub const IP = 0;
 6456        pub const HOPOPTS = 0;
 6457        pub const ICMP = 1;
 6458        pub const IGMP = 2;
 6459        pub const TCP = 6;
 6460        pub const UDP = 17;
 6461        pub const IPV6 = 41;
 6462        pub const ROUTING = 43;
 6463        pub const FRAGMENT = 44;
 6464        pub const ESP = 50;
 6465        pub const AH = 51;
 6466        pub const ICMPV6 = 58;
 6467        pub const NONE = 59;
 6468        pub const DSTOPTS = 60;
 6469        pub const ETHERIP = 97;
 6470        pub const RAW = 255;
 6471        pub const MAX = 256;
 6472    },
 6473    .openbsd => struct {
 6474        /// dummy for IP
 6475        pub const IP = 0;
 6476        /// IP6 hop-by-hop options
 6477        pub const HOPOPTS = IPPROTO.IP;
 6478        /// control message protocol
 6479        pub const ICMP = 1;
 6480        /// group mgmt protocol
 6481        pub const IGMP = 2;
 6482        /// gateway^2 (deprecated)
 6483        pub const GGP = 3;
 6484        /// IP header
 6485        pub const IPV4 = IPIP;
 6486        /// IP inside IP
 6487        pub const IPIP = 4;
 6488        /// tcp
 6489        pub const TCP = 6;
 6490        /// exterior gateway protocol
 6491        pub const EGP = 8;
 6492        /// pup
 6493        pub const PUP = 12;
 6494        /// user datagram protocol
 6495        pub const UDP = 17;
 6496        /// xns idp
 6497        pub const IDP = 22;
 6498        /// tp-4 w/ class negotiation
 6499        pub const TP = 29;
 6500        /// IP6 header
 6501        pub const IPV6 = 41;
 6502        /// IP6 routing header
 6503        pub const ROUTING = 43;
 6504        /// IP6 fragmentation header
 6505        pub const FRAGMENT = 44;
 6506        /// resource reservation
 6507        pub const RSVP = 46;
 6508        /// GRE encaps RFC 1701
 6509        pub const GRE = 47;
 6510        /// encap. security payload
 6511        pub const ESP = 50;
 6512        /// authentication header
 6513        pub const AH = 51;
 6514        /// IP Mobility RFC 2004
 6515        pub const MOBILE = 55;
 6516        /// IPv6 ICMP
 6517        pub const IPV6_ICMP = 58;
 6518        /// ICMP6
 6519        pub const ICMPV6 = 58;
 6520        /// IP6 no next header
 6521        pub const NONE = 59;
 6522        /// IP6 destination option
 6523        pub const DSTOPTS = 60;
 6524        /// ISO cnlp
 6525        pub const EON = 80;
 6526        /// Ethernet-in-IP
 6527        pub const ETHERIP = 97;
 6528        /// encapsulation header
 6529        pub const ENCAP = 98;
 6530        /// Protocol indep. multicast
 6531        pub const PIM = 103;
 6532        /// IP Payload Comp. Protocol
 6533        pub const IPCOMP = 108;
 6534        /// VRRP RFC 2338
 6535        pub const VRRP = 112;
 6536        /// Common Address Resolution Protocol
 6537        pub const CARP = 112;
 6538        /// PFSYNC
 6539        pub const PFSYNC = 240;
 6540        /// raw IP packet
 6541        pub const RAW = 255;
 6542    },
 6543    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L44-L54
 6544    .serenity => struct {
 6545        pub const IP = 0;
 6546        pub const ICMP = 1;
 6547        pub const IGMP = 2;
 6548        pub const IPIP = 4;
 6549        pub const TCP = 6;
 6550        pub const UDP = 17;
 6551        pub const IPV6 = 41;
 6552        pub const ESP = 50;
 6553        pub const AH = 51;
 6554        pub const ICMPV6 = 58;
 6555        pub const RAW = 255;
 6556    },
 6557    else => void,
 6558};
 6559pub const IP = switch (native_os) {
 6560    .linux => linux.IP,
 6561    .freebsd => freebsd.IP,
 6562    .dragonfly => dragonfly.IP,
 6563    .netbsd => netbsd.IP,
 6564    .openbsd => openbsd.IP,
 6565    .illumos => illumos.IP,
 6566    .haiku => haiku.IP,
 6567    .serenity => serenity.IP,
 6568    else => void,
 6569};
 6570pub const IPV6 = switch (native_os) {
 6571    .linux => linux.IPV6,
 6572    .freebsd => freebsd.IPV6,
 6573    .dragonfly => dragonfly.IPV6,
 6574    .netbsd => netbsd.IPV6,
 6575    .openbsd => openbsd.IPV6,
 6576    .illumos => illumos.IPV6,
 6577    .haiku => haiku.IPV6,
 6578    .serenity => serenity.IPV6,
 6579    else => void,
 6580};
 6581pub const IPTOS = switch (native_os) {
 6582    .linux => linux.IPTOS,
 6583    .freebsd => freebsd.IPTOS,
 6584    .dragonfly => dragonfly.IPTOS,
 6585    .netbsd => netbsd.IPTOS,
 6586    .openbsd => openbsd.IPTOS,
 6587    .illumos => illumos.IPTOS,
 6588    .haiku => haiku.IPTOS,
 6589    .serenity => serenity.IPTOS,
 6590    else => void,
 6591};
 6592pub const SOL = switch (native_os) {
 6593    .linux => linux.SOL,
 6594    .emscripten => emscripten.SOL,
 6595    .windows => ws2_32.SOL,
 6596    .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 6597        pub const SOCKET = 0xffff;
 6598    },
 6599    .illumos => struct {
 6600        pub const SOCKET = 0xffff;
 6601        pub const ROUTE = 0xfffe;
 6602        pub const PACKET = 0xfffd;
 6603        pub const FILTER = 0xfffc;
 6604    },
 6605    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L127
 6606    .serenity => struct {
 6607        pub const SOCKET = 1;
 6608    },
 6609    else => void,
 6610};
 6611pub const SO = switch (native_os) {
 6612    .linux => linux.SO,
 6613    .emscripten => emscripten.SO,
 6614    .windows => ws2_32.SO,
 6615    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 6616        pub const DEBUG = 0x0001;
 6617        pub const ACCEPTCONN = 0x0002;
 6618        pub const REUSEADDR = 0x0004;
 6619        pub const KEEPALIVE = 0x0008;
 6620        pub const DONTROUTE = 0x0010;
 6621        pub const BROADCAST = 0x0020;
 6622        pub const USELOOPBACK = 0x0040;
 6623        pub const LINGER = 0x1080;
 6624        pub const OOBINLINE = 0x0100;
 6625        pub const REUSEPORT = 0x0200;
 6626        pub const ACCEPTFILTER = 0x1000;
 6627        pub const SNDBUF = 0x1001;
 6628        pub const RCVBUF = 0x1002;
 6629        pub const SNDLOWAT = 0x1003;
 6630        pub const RCVLOWAT = 0x1004;
 6631        pub const SNDTIMEO = 0x1005;
 6632        pub const RCVTIMEO = 0x1006;
 6633        pub const ERROR = 0x1007;
 6634        pub const TYPE = 0x1008;
 6635
 6636        pub const NREAD = 0x1020;
 6637        pub const NKE = 0x1021;
 6638        pub const NOSIGPIPE = 0x1022;
 6639        pub const NOADDRERR = 0x1023;
 6640        pub const NWRITE = 0x1024;
 6641        pub const REUSESHAREUID = 0x1025;
 6642    },
 6643    .freebsd => struct {
 6644        pub const DEBUG = 0x00000001;
 6645        pub const ACCEPTCONN = 0x00000002;
 6646        pub const REUSEADDR = 0x00000004;
 6647        pub const KEEPALIVE = 0x00000008;
 6648        pub const DONTROUTE = 0x00000010;
 6649        pub const BROADCAST = 0x00000020;
 6650        pub const USELOOPBACK = 0x00000040;
 6651        pub const LINGER = 0x00000080;
 6652        pub const OOBINLINE = 0x00000100;
 6653        pub const REUSEPORT = 0x00000200;
 6654        pub const TIMESTAMP = 0x00000400;
 6655        pub const NOSIGPIPE = 0x00000800;
 6656        pub const ACCEPTFILTER = 0x00001000;
 6657        pub const BINTIME = 0x00002000;
 6658        pub const NO_OFFLOAD = 0x00004000;
 6659        pub const NO_DDP = 0x00008000;
 6660        pub const REUSEPORT_LB = 0x00010000;
 6661
 6662        pub const SNDBUF = 0x1001;
 6663        pub const RCVBUF = 0x1002;
 6664        pub const SNDLOWAT = 0x1003;
 6665        pub const RCVLOWAT = 0x1004;
 6666        pub const SNDTIMEO = 0x1005;
 6667        pub const RCVTIMEO = 0x1006;
 6668        pub const ERROR = 0x1007;
 6669        pub const TYPE = 0x1008;
 6670        pub const LABEL = 0x1009;
 6671        pub const PEERLABEL = 0x1010;
 6672        pub const LISTENQLIMIT = 0x1011;
 6673        pub const LISTENQLEN = 0x1012;
 6674        pub const LISTENINCQLEN = 0x1013;
 6675        pub const SETFIB = 0x1014;
 6676        pub const USER_COOKIE = 0x1015;
 6677        pub const PROTOCOL = 0x1016;
 6678        pub const PROTOTYPE = PROTOCOL;
 6679        pub const TS_CLOCK = 0x1017;
 6680        pub const MAX_PACING_RATE = 0x1018;
 6681        pub const DOMAIN = 0x1019;
 6682    },
 6683    .illumos => struct {
 6684        pub const DEBUG = 0x0001;
 6685        pub const ACCEPTCONN = 0x0002;
 6686        pub const REUSEADDR = 0x0004;
 6687        pub const KEEPALIVE = 0x0008;
 6688        pub const DONTROUTE = 0x0010;
 6689        pub const BROADCAST = 0x0020;
 6690        pub const USELOOPBACK = 0x0040;
 6691        pub const LINGER = 0x0080;
 6692        pub const OOBINLINE = 0x0100;
 6693        pub const DGRAM_ERRIND = 0x0200;
 6694        pub const RECVUCRED = 0x0400;
 6695
 6696        pub const SNDBUF = 0x1001;
 6697        pub const RCVBUF = 0x1002;
 6698        pub const SNDLOWAT = 0x1003;
 6699        pub const RCVLOWAT = 0x1004;
 6700        pub const SNDTIMEO = 0x1005;
 6701        pub const RCVTIMEO = 0x1006;
 6702        pub const ERROR = 0x1007;
 6703        pub const TYPE = 0x1008;
 6704        pub const PROTOTYPE = 0x1009;
 6705        pub const ANON_MLP = 0x100a;
 6706        pub const MAC_EXEMPT = 0x100b;
 6707        pub const DOMAIN = 0x100c;
 6708        pub const RCVPSH = 0x100d;
 6709
 6710        pub const SECATTR = 0x1011;
 6711        pub const TIMESTAMP = 0x1013;
 6712        pub const ALLZONES = 0x1014;
 6713        pub const EXCLBIND = 0x1015;
 6714        pub const MAC_IMPLICIT = 0x1016;
 6715        pub const VRRP = 0x1017;
 6716    },
 6717    .netbsd => struct {
 6718        pub const DEBUG = 0x0001;
 6719        pub const ACCEPTCONN = 0x0002;
 6720        pub const REUSEADDR = 0x0004;
 6721        pub const KEEPALIVE = 0x0008;
 6722        pub const DONTROUTE = 0x0010;
 6723        pub const BROADCAST = 0x0020;
 6724        pub const USELOOPBACK = 0x0040;
 6725        pub const LINGER = 0x0080;
 6726        pub const OOBINLINE = 0x0100;
 6727        pub const REUSEPORT = 0x0200;
 6728        pub const NOSIGPIPE = 0x0800;
 6729        pub const ACCEPTFILTER = 0x1000;
 6730        pub const TIMESTAMP = 0x2000;
 6731        pub const RERROR = 0x4000;
 6732
 6733        pub const SNDBUF = 0x1001;
 6734        pub const RCVBUF = 0x1002;
 6735        pub const SNDLOWAT = 0x1003;
 6736        pub const RCVLOWAT = 0x1004;
 6737        pub const ERROR = 0x1007;
 6738        pub const TYPE = 0x1008;
 6739        pub const OVERFLOWED = 0x1009;
 6740
 6741        pub const NOHEADER = 0x100a;
 6742        pub const SNDTIMEO = 0x100b;
 6743        pub const RCVTIMEO = 0x100c;
 6744    },
 6745    .dragonfly => struct {
 6746        pub const DEBUG = 0x0001;
 6747        pub const ACCEPTCONN = 0x0002;
 6748        pub const REUSEADDR = 0x0004;
 6749        pub const KEEPALIVE = 0x0008;
 6750        pub const DONTROUTE = 0x0010;
 6751        pub const BROADCAST = 0x0020;
 6752        pub const USELOOPBACK = 0x0040;
 6753        pub const LINGER = 0x0080;
 6754        pub const OOBINLINE = 0x0100;
 6755        pub const REUSEPORT = 0x0200;
 6756        pub const TIMESTAMP = 0x0400;
 6757        pub const NOSIGPIPE = 0x0800;
 6758        pub const ACCEPTFILTER = 0x1000;
 6759        pub const RERROR = 0x2000;
 6760        pub const PASSCRED = 0x4000;
 6761
 6762        pub const SNDBUF = 0x1001;
 6763        pub const RCVBUF = 0x1002;
 6764        pub const SNDLOWAT = 0x1003;
 6765        pub const RCVLOWAT = 0x1004;
 6766        pub const SNDTIMEO = 0x1005;
 6767        pub const RCVTIMEO = 0x1006;
 6768        pub const ERROR = 0x1007;
 6769        pub const TYPE = 0x1008;
 6770        pub const SNDSPACE = 0x100a;
 6771        pub const CPUHINT = 0x1030;
 6772    },
 6773    .haiku => struct {
 6774        pub const ACCEPTCONN = 0x00000001;
 6775        pub const BROADCAST = 0x00000002;
 6776        pub const DEBUG = 0x00000004;
 6777        pub const DONTROUTE = 0x00000008;
 6778        pub const KEEPALIVE = 0x00000010;
 6779        pub const OOBINLINE = 0x00000020;
 6780        pub const REUSEADDR = 0x00000040;
 6781        pub const REUSEPORT = 0x00000080;
 6782        pub const USELOOPBACK = 0x00000100;
 6783        pub const LINGER = 0x00000200;
 6784
 6785        pub const SNDBUF = 0x40000001;
 6786        pub const SNDLOWAT = 0x40000002;
 6787        pub const SNDTIMEO = 0x40000003;
 6788        pub const RCVBUF = 0x40000004;
 6789        pub const RCVLOWAT = 0x40000005;
 6790        pub const RCVTIMEO = 0x40000006;
 6791        pub const ERROR = 0x40000007;
 6792        pub const TYPE = 0x40000008;
 6793        pub const NONBLOCK = 0x40000009;
 6794        pub const BINDTODEVICE = 0x4000000a;
 6795        pub const PEERCRED = 0x4000000b;
 6796    },
 6797    .openbsd => 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 TIMESTAMP = 0x0800;
 6809        pub const BINDANY = 0x1000;
 6810        pub const ZEROIZE = 0x2000;
 6811        pub const SNDBUF = 0x1001;
 6812        pub const RCVBUF = 0x1002;
 6813        pub const SNDLOWAT = 0x1003;
 6814        pub const RCVLOWAT = 0x1004;
 6815        pub const SNDTIMEO = 0x1005;
 6816        pub const RCVTIMEO = 0x1006;
 6817        pub const ERROR = 0x1007;
 6818        pub const TYPE = 0x1008;
 6819        pub const NETPROC = 0x1020;
 6820        pub const RTABLE = 0x1021;
 6821        pub const PEERCRED = 0x1022;
 6822        pub const SPLICE = 0x1023;
 6823        pub const DOMAIN = 0x1024;
 6824        pub const PROTOCOL = 0x1025;
 6825    },
 6826    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L130-L150
 6827    .serenity => struct {
 6828        pub const RCVTIMEO = 0;
 6829        pub const SNDTIMEO = 1;
 6830        pub const TYPE = 2;
 6831        pub const ERROR = 3;
 6832        pub const PEERCRED = 4;
 6833        pub const RCVBUF = 5;
 6834        pub const SNDBUF = 6;
 6835        pub const DEBUG = 7;
 6836        pub const REUSEADDR = 8;
 6837        pub const BINDTODEVICE = 9;
 6838        pub const KEEPALIVE = 10;
 6839        pub const TIMESTAMP = 11;
 6840        pub const BROADCAST = 12;
 6841        pub const LINGER = 13;
 6842        pub const ACCEPTCONN = 14;
 6843        pub const DONTROUTE = 15;
 6844        pub const OOBINLINE = 16;
 6845        pub const SNDLOWAT = 17;
 6846        pub const RCVLOWAT = 18;
 6847    },
 6848    else => void,
 6849};
 6850pub const SOMAXCONN = switch (native_os) {
 6851    .linux => linux.SOMAXCONN,
 6852    .windows => ws2_32.SOMAXCONN,
 6853    // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L128
 6854    .illumos, .serenity => 128,
 6855    // https://github.com/freebsd/freebsd-src/blob/9ab31f821ad1c6bad474510447387c50bef2c24c/sys/sys/socket.h#L434
 6856    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/fd3d1949d526ffa646e57037770acd6f2f3bb617/sys/sys/socket.h#L393
 6857    // https://github.com/NetBSD/src/blob/a673fb3f8487e974c669216064f7588207229fea/sys/sys/socket.h#L472
 6858    // https://github.com/openbsd/src/blob/8ba9cd88f10123fef7af805b8e5ccc2463ad8fa4/sys/sys/socket.h#L483
 6859    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L815
 6860    .freebsd, .dragonfly, .netbsd, .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 128,
 6861    else => void,
 6862};
 6863pub const SCM = switch (native_os) {
 6864    .linux, .emscripten => linux.SCM,
 6865    // https://github.com/illumos/illumos-gate/blob/489f6310fe8952e87fc1dce8af87990fcfd90f18/usr/src/uts/common/sys/socket.h#L196
 6866    .illumos => struct {
 6867        pub const RIGHTS = 0x1010;
 6868        pub const UCRED = 0x1012;
 6869        pub const TIMESTAMP = SO.TIMESTAMP;
 6870    },
 6871    // https://github.com/haiku/haiku/blob/e3d01e53a25446d5ba4999d0ff6dff29a2418657/headers/posix/sys/socket.h#L156
 6872    .haiku => struct {
 6873        pub const RIGHTS = 1;
 6874    },
 6875    // https://github.com/SerenityOS/serenity/blob/c6618f36bf0949bd76177f202659b1f3079e0792/Kernel/API/POSIX/sys/socket.h#L171
 6876    .serenity => struct {
 6877        pub const TIMESTAMP = 0;
 6878        pub const RIGHTS = 1;
 6879    },
 6880    // https://github.com/freebsd/freebsd-src/blob/614e9b33bf5594d9d09b5d296afa4f3aa6971823/sys/sys/socket.h#L593
 6881    .freebsd => struct {
 6882        pub const RIGHTS = 1;
 6883        pub const TIMESTAMP = 2;
 6884        pub const CREDS = 3;
 6885        pub const BINTIME = 4;
 6886        pub const REALTIME = 5;
 6887        pub const MONOTONIC = 6;
 6888        pub const TIME_INFO = 7;
 6889        pub const CREDS2 = 8;
 6890    },
 6891    // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/6098912863ed4c7b3f70d7483910ce2956cf4ed3/sys/sys/socket.h#L520
 6892    .dragonfly => struct {
 6893        pub const RIGHTS = 1;
 6894        pub const TIMESTAMP = 2;
 6895        pub const CREDS = 3;
 6896    },
 6897    // https://github.com/NetBSD/src/blob/3311177ea898ab8322292ba0e48faa9b2e834cb6/sys/sys/socket.h#L578
 6898    .netbsd => struct {
 6899        pub const RIGHTS = 0x01;
 6900        pub const TIMESTAMP = 0x08;
 6901        pub const CREDS = 0x10;
 6902    },
 6903    // https://github.com/openbsd/src/blob/1b1dd04c9634112eb763374379af99a68ace4328/sys/sys/socket.h#L566
 6904    .openbsd => struct {
 6905        pub const RIGHTS = 0x01;
 6906        pub const TIMESTAMP = 0x04;
 6907    },
 6908    // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/socket.h#L1114
 6909    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 6910        pub const RIGHTS = 1;
 6911        pub const TIMESTAMP = 2;
 6912        pub const CREDS = 3;
 6913        pub const TIMESTAMP_MONOTONIC = 4;
 6914    },
 6915    else => void,
 6916};
 6917
 6918pub const IFNAMESIZE = switch (native_os) {
 6919    .linux => linux.IFNAMESIZE,
 6920    .emscripten => emscripten.IFNAMESIZE,
 6921    .windows => 30,
 6922    // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L50
 6923    .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 16,
 6924    .illumos => 32,
 6925    else => {},
 6926};
 6927
 6928pub const stack_t = switch (native_os) {
 6929    .linux => linux.stack_t,
 6930    .emscripten => emscripten.stack_t,
 6931    .freebsd, .openbsd => extern struct {
 6932        /// Signal stack base.
 6933        sp: *anyopaque,
 6934        /// Signal stack length.
 6935        size: usize,
 6936        /// SS_DISABLE and/or SS_ONSTACK.
 6937        flags: i32,
 6938    },
 6939    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L48-L52
 6940    .serenity => extern struct {
 6941        sp: *anyopaque,
 6942        flags: c_int,
 6943        size: usize,
 6944    },
 6945    else => extern struct {
 6946        sp: [*]u8,
 6947        size: isize,
 6948        flags: i32,
 6949    },
 6950};
 6951pub const time_t = switch (native_os) {
 6952    .linux => linux.time_t,
 6953    .emscripten => emscripten.time_t,
 6954    .haiku, .dragonfly => isize,
 6955    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47
 6956    else => i64,
 6957};
 6958pub const suseconds_t = switch (native_os) {
 6959    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L49
 6960    .illumos, .serenity => i64,
 6961    .freebsd, .dragonfly => c_long,
 6962    .netbsd => c_int,
 6963    .haiku => i32,
 6964    else => void,
 6965};
 6966
 6967pub const timeval = switch (native_os) {
 6968    .linux => linux.timeval,
 6969    .emscripten => emscripten.timeval,
 6970    .windows => extern struct {
 6971        sec: c_long,
 6972        usec: c_long,
 6973    },
 6974    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 6975        sec: c_long,
 6976        usec: i32,
 6977    },
 6978    // https://github.com/SerenityOS/serenity/blob/6b6eca0631c893c5f8cfb8274cdfe18e2d0637c0/Kernel/API/POSIX/sys/time.h#L15-L18
 6979    .dragonfly, .netbsd, .freebsd, .illumos, .serenity => extern struct {
 6980        /// seconds
 6981        sec: time_t,
 6982        /// microseconds
 6983        usec: suseconds_t,
 6984    },
 6985    .openbsd => extern struct {
 6986        sec: time_t,
 6987        usec: c_long,
 6988    },
 6989    else => void,
 6990};
 6991pub const timezone = switch (native_os) {
 6992    .linux => linux.timezone,
 6993    .emscripten => emscripten.timezone,
 6994    .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 6995        minuteswest: i32,
 6996        dsttime: i32,
 6997    },
 6998    // https://github.com/SerenityOS/serenity/blob/ba776390b5878ec0be1a9e595a3471a6cfe0a0cf/Userland/Libraries/LibC/sys/time.h#L19-L22
 6999    .serenity => extern struct {
 7000        minuteswest: c_int,
 7001        dsttime: c_int,
 7002    },
 7003    else => void,
 7004};
 7005
 7006pub const user_desc = switch (native_os) {
 7007    .linux => linux.user_desc,
 7008    else => void,
 7009};
 7010pub const utsname = switch (native_os) {
 7011    .linux => linux.utsname,
 7012    .emscripten => emscripten.utsname,
 7013    .illumos => extern struct {
 7014        sysname: [256:0]u8,
 7015        nodename: [256:0]u8,
 7016        release: [256:0]u8,
 7017        version: [256:0]u8,
 7018        machine: [256:0]u8,
 7019        domainname: [256:0]u8,
 7020    },
 7021    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 7022        sysname: [255:0]u8,
 7023        nodename: [255:0]u8,
 7024        release: [255:0]u8,
 7025        version: [255:0]u8,
 7026        machine: [255:0]u8,
 7027    },
 7028    // https://github.com/SerenityOS/serenity/blob/d794ed1de7a46482272683f8dc4c858806390f29/Kernel/API/POSIX/sys/utsname.h#L17-L23
 7029    .serenity => extern struct {
 7030        sysname: [UTSNAME_ENTRY_LEN:0]u8,
 7031        nodename: [UTSNAME_ENTRY_LEN:0]u8,
 7032        release: [UTSNAME_ENTRY_LEN:0]u8,
 7033        version: [UTSNAME_ENTRY_LEN:0]u8,
 7034        machine: [UTSNAME_ENTRY_LEN:0]u8,
 7035
 7036        const UTSNAME_ENTRY_LEN = 64;
 7037    },
 7038    else => void,
 7039};
 7040pub const PR = switch (native_os) {
 7041    .linux => linux.PR,
 7042    else => void,
 7043};
 7044pub const _errno = switch (native_os) {
 7045    .linux => switch (native_abi) {
 7046        .android, .androideabi => private.__errno,
 7047        else => private.__errno_location,
 7048    },
 7049    .emscripten => private.__errno_location,
 7050    .wasi, .dragonfly => private.errnoFromThreadLocal,
 7051    .windows => private._errno,
 7052    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .freebsd => private.__error,
 7053    .illumos => private.___errno,
 7054    .openbsd, .netbsd => private.__errno,
 7055    .haiku => haiku._errnop,
 7056    // https://github.com/SerenityOS/serenity/blob/a353ceecf13b6f156a078e32f1ddf1d21366934c/Userland/Libraries/LibC/errno.h#L33
 7057    .serenity => private.__errno_location,
 7058    else => {},
 7059};
 7060
 7061pub const RTLD = switch (native_os) {
 7062    .linux, .emscripten => packed struct(u32) {
 7063        LAZY: bool = false,
 7064        NOW: bool = false,
 7065        NOLOAD: bool = false,
 7066        DEEPBIND: bool = false,
 7067        _4: u4 = 0,
 7068        GLOBAL: bool = false,
 7069        _9: u3 = 0,
 7070        NODELETE: bool = false,
 7071        _: u19 = 0,
 7072    },
 7073    .dragonfly, .freebsd => packed struct(u32) {
 7074        LAZY: bool = false,
 7075        NOW: bool = false,
 7076        _2: u6 = 0,
 7077        GLOBAL: bool = false,
 7078        TRACE: bool = false,
 7079        _10: u2 = 0,
 7080        NODELETE: bool = false,
 7081        NOLOAD: bool = false,
 7082        _: u18 = 0,
 7083    },
 7084    .haiku => packed struct(u32) {
 7085        NOW: bool = false,
 7086        GLOBAL: bool = false,
 7087        _: u30 = 0,
 7088    },
 7089    .netbsd => packed struct(u32) {
 7090        LAZY: bool = false,
 7091        NOW: bool = false,
 7092        _2: u6 = 0,
 7093        GLOBAL: bool = false,
 7094        LOCAL: bool = false,
 7095        _10: u2 = 0,
 7096        NODELETE: bool = false,
 7097        NOLOAD: bool = false,
 7098        _: u18 = 0,
 7099    },
 7100    .illumos => packed struct(u32) {
 7101        LAZY: bool = false,
 7102        NOW: bool = false,
 7103        NOLOAD: bool = false,
 7104        _3: u5 = 0,
 7105        GLOBAL: bool = false,
 7106        PARENT: bool = false,
 7107        GROUP: bool = false,
 7108        WORLD: bool = false,
 7109        NODELETE: bool = false,
 7110        FIRST: bool = false,
 7111        _14: u2 = 0,
 7112        CONFGEN: bool = false,
 7113        _: u15 = 0,
 7114    },
 7115    .openbsd => packed struct(u32) {
 7116        LAZY: bool = false,
 7117        NOW: bool = false,
 7118        _2: u6 = 0,
 7119        GLOBAL: bool = false,
 7120        TRACE: bool = false,
 7121        _: u22 = 0,
 7122    },
 7123    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) {
 7124        LAZY: bool = false,
 7125        NOW: bool = false,
 7126        LOCAL: bool = false,
 7127        GLOBAL: bool = false,
 7128        NOLOAD: bool = false,
 7129        _5: u2 = 0,
 7130        NODELETE: bool = false,
 7131        FIRST: bool = false,
 7132        _: u23 = 0,
 7133    },
 7134    // https://github.com/SerenityOS/serenity/blob/36a26d7fa80bc9c72b19442912d8967f448368ff/Userland/Libraries/LibC/dlfcn.h#L13-L17
 7135    .serenity => packed struct(c_int) {
 7136        DEFAULT: bool = false,
 7137        _1: u1,
 7138        LAZY: bool = false,
 7139        NOW: bool = false,
 7140        GLOBAL: bool = false,
 7141        LOCAL: bool = false,
 7142        _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 6) = 0,
 7143    },
 7144    else => void,
 7145};
 7146
 7147pub const dirent = switch (native_os) {
 7148    .linux, .emscripten => extern struct {
 7149        ino: ino_t,
 7150        off: off_t,
 7151        reclen: c_ushort,
 7152        type: u8,
 7153        name: [256]u8,
 7154    },
 7155    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 7156        ino: u64,
 7157        seekoff: u64,
 7158        reclen: u16,
 7159        namlen: u16,
 7160        type: u8,
 7161        name: [1024]u8,
 7162    },
 7163    .freebsd => extern struct {
 7164        /// File number of entry.
 7165        fileno: ino_t,
 7166        /// Directory offset of entry.
 7167        off: off_t,
 7168        /// Length of this record.
 7169        reclen: u16,
 7170        /// File type, one of DT_.
 7171        type: u8,
 7172        pad0: u8 = 0,
 7173        /// Length of the name member.
 7174        namlen: u16,
 7175        pad1: u16 = 0,
 7176        /// Name of entry.
 7177        name: [255:0]u8,
 7178    },
 7179    .illumos => extern struct {
 7180        /// Inode number of entry.
 7181        ino: ino_t,
 7182        /// Offset of this entry on disk.
 7183        off: off_t,
 7184        /// Length of this record.
 7185        reclen: u16,
 7186        /// File name.
 7187        name: [MAXNAMLEN:0]u8,
 7188    },
 7189    .netbsd => extern struct {
 7190        fileno: ino_t,
 7191        reclen: u16,
 7192        namlen: u16,
 7193        type: u8,
 7194        name: [MAXNAMLEN:0]u8,
 7195    },
 7196    .dragonfly => extern struct {
 7197        fileno: c_ulong,
 7198        namlen: u16,
 7199        type: u8,
 7200        unused1: u8,
 7201        unused2: u32,
 7202        name: [256]u8,
 7203
 7204        pub fn reclen(self: dirent) u16 {
 7205            return (@offsetOf(dirent, "name") + self.namlen + 1 + 7) & ~@as(u16, 7);
 7206        }
 7207    },
 7208    .openbsd => extern struct {
 7209        fileno: ino_t,
 7210        off: off_t,
 7211        reclen: u16,
 7212        type: u8,
 7213        namlen: u8,
 7214        _: u32 align(1) = 0,
 7215        name: [MAXNAMLEN:0]u8,
 7216    },
 7217    // https://github.com/SerenityOS/serenity/blob/abc150085f532f123b598949218893cb272ccc4c/Userland/Libraries/LibC/dirent.h#L14-L20
 7218    .serenity => extern struct {
 7219        ino: ino_t,
 7220        off: off_t,
 7221        reclen: c_ushort,
 7222        type: u8,
 7223        name: [255:0]u8,
 7224    },
 7225    else => void,
 7226};
 7227pub const MAXNAMLEN = switch (native_os) {
 7228    .netbsd, .illumos => 511,
 7229    // https://github.com/SerenityOS/serenity/blob/1262a7d1424d0d2e89d80644409721cbf056ab17/Kernel/API/POSIX/dirent.h#L37
 7230    .haiku, .serenity => NAME_MAX,
 7231    .openbsd => 255,
 7232    else => {},
 7233};
 7234pub const dirent64 = switch (native_os) {
 7235    .linux => extern struct {
 7236        ino: c_ulong,
 7237        off: c_ulong,
 7238        reclen: c_ushort,
 7239        type: u8,
 7240        name: [256]u8,
 7241    },
 7242    else => void,
 7243};
 7244
 7245pub const AI = if (builtin.abi.isAndroid()) packed struct(u32) {
 7246    PASSIVE: bool = false,
 7247    CANONNAME: bool = false,
 7248    NUMERICHOST: bool = false,
 7249    NUMERICSERV: bool = false,
 7250    _4: u4 = 0,
 7251    ALL: bool = false,
 7252    V4MAPPED_CFG: bool = false,
 7253    ADDRCONFIG: bool = false,
 7254    V4MAPPED: bool = false,
 7255    _: u20 = 0,
 7256} else switch (native_os) {
 7257    .linux, .emscripten => linux.AI,
 7258    .dragonfly, .haiku, .freebsd => packed struct(u32) {
 7259        PASSIVE: bool = false,
 7260        CANONNAME: bool = false,
 7261        NUMERICHOST: bool = false,
 7262        NUMERICSERV: bool = false,
 7263        _4: u4 = 0,
 7264        ALL: bool = false,
 7265        V4MAPPED_CFG: bool = false,
 7266        ADDRCONFIG: bool = false,
 7267        V4MAPPED: bool = false,
 7268        _: u20 = 0,
 7269    },
 7270    .netbsd => packed struct(u32) {
 7271        PASSIVE: bool = false,
 7272        CANONNAME: bool = false,
 7273        NUMERICHOST: bool = false,
 7274        NUMERICSERV: bool = false,
 7275        _4: u6 = 0,
 7276        ADDRCONFIG: bool = false,
 7277        SRV: bool = false,
 7278        _: u20 = 0,
 7279    },
 7280    .illumos => packed struct(u32) {
 7281        V4MAPPED: bool = false,
 7282        ALL: bool = false,
 7283        ADDRCONFIG: bool = false,
 7284        PASSIVE: bool = false,
 7285        CANONNAME: bool = false,
 7286        NUMERICHOST: bool = false,
 7287        NUMERICSERV: bool = false,
 7288        _: u25 = 0,
 7289    },
 7290    .openbsd => packed struct(u32) {
 7291        PASSIVE: bool = false,
 7292        CANONNAME: bool = false,
 7293        NUMERICHOST: bool = false,
 7294        EXT: bool = false,
 7295        NUMERICSERV: bool = false,
 7296        FQDN: bool = false,
 7297        ADDRCONFIG: bool = false,
 7298        _: u25 = 0,
 7299    },
 7300    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) {
 7301        PASSIVE: bool = false,
 7302        CANONNAME: bool = false,
 7303        NUMERICHOST: bool = false,
 7304        _3: u5 = 0,
 7305        ALL: bool = false,
 7306        V4MAPPED_CFG: bool = false,
 7307        ADDRCONFIG: bool = false,
 7308        V4MAPPED: bool = false,
 7309        NUMERICSERV: bool = false,
 7310        _: u19 = 0,
 7311    },
 7312    .windows => ws2_32.AI,
 7313    // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L90-L96
 7314    .serenity => packed struct(c_int) {
 7315        PASSIVE: bool = false,
 7316        CANONNAME: bool = false,
 7317        NUMERICHOST: bool = false,
 7318        NUMERICSERV: bool = false,
 7319        V4MAPPED: bool = false,
 7320        ALL: bool = false,
 7321        ADDRCONFIG: bool = false,
 7322        _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 7) = 0,
 7323    },
 7324    else => void,
 7325};
 7326
 7327pub const NI = switch (native_os) {
 7328    .linux, .emscripten => packed struct(u32) {
 7329        NUMERICHOST: bool = false,
 7330        NUMERICSERV: bool = false,
 7331        NOFQDN: bool = false,
 7332        NAMEREQD: bool = false,
 7333        DGRAM: bool = false,
 7334        _5: u3 = 0,
 7335        NUMERICSCOPE: bool = false,
 7336        _: u23 = 0,
 7337    },
 7338    .illumos => packed struct(u32) {
 7339        NOFQDN: bool = false,
 7340        NUMERICHOST: bool = false,
 7341        NAMEREQD: bool = false,
 7342        NUMERICSERV: bool = false,
 7343        DGRAM: bool = false,
 7344        WITHSCOPEID: bool = false,
 7345        NUMERICSCOPE: bool = false,
 7346        _: u25 = 0,
 7347    },
 7348    // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L101-L105
 7349    .serenity => packed struct(c_int) {
 7350        NUMERICHOST: bool = false,
 7351        NUMERICSERV: bool = false,
 7352        NAMEREQD: bool = false,
 7353        NOFQDN: bool = false,
 7354        DGRAM: bool = false,
 7355        _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 5) = 0,
 7356    },
 7357    .freebsd, .haiku => packed struct(u32) {
 7358        NOFQDN: bool = false,
 7359        NUMERICHOST: bool = false,
 7360        NAMEREQD: bool = false,
 7361        NUMERICSERV: bool = false,
 7362        DGRAM: bool = false,
 7363        NUMERICSCOPE: bool = false,
 7364        _: u26 = 0,
 7365    },
 7366    .dragonfly, .netbsd => packed struct(u32) {
 7367        NOFQDN: bool = false,
 7368        NUMERICHOST: bool = false,
 7369        NAMEREQD: bool = false,
 7370        NUMERICSERV: bool = false,
 7371        DGRAM: bool = false,
 7372        _5: u1 = 0,
 7373        NUMERICSCOPE: bool = false,
 7374        _: u25 = 0,
 7375    },
 7376    .openbsd => packed struct(u32) {
 7377        NUMERICHOST: bool = false,
 7378        NUMERICSERV: bool = false,
 7379        NOFQDN: bool = false,
 7380        NAMEREQD: bool = false,
 7381        DGRAM: bool = false,
 7382        _: u27 = 0,
 7383    },
 7384    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) {
 7385        NOFQDN: bool = false,
 7386        NUMERICHOST: bool = false,
 7387        NAMEREQD: bool = false,
 7388        NUMERICSERV: bool = false,
 7389        DGRAM: bool = false,
 7390        _5: u3 = 0,
 7391        NUMERICSCOPE: bool = false,
 7392        _: u23 = 0,
 7393    },
 7394    else => void,
 7395};
 7396
 7397pub const EAI = if (builtin.abi.isAndroid()) enum(c_int) {
 7398    /// address family for hostname not supported
 7399    ADDRFAMILY = 1,
 7400    /// temporary failure in name resolution
 7401    AGAIN = 2,
 7402    /// invalid value for ai_flags
 7403    BADFLAGS = 3,
 7404    /// non-recoverable failure in name resolution
 7405    FAIL = 4,
 7406    /// ai_family not supported
 7407    FAMILY = 5,
 7408    /// memory allocation failure
 7409    MEMORY = 6,
 7410    /// no address associated with hostname
 7411    NODATA = 7,
 7412    /// hostname nor servname provided, or not known
 7413    NONAME = 8,
 7414    /// servname not supported for ai_socktype
 7415    SERVICE = 9,
 7416    /// ai_socktype not supported
 7417    SOCKTYPE = 10,
 7418    /// system error returned in errno
 7419    SYSTEM = 11,
 7420    /// invalid value for hints
 7421    BADHINTS = 12,
 7422    /// resolved protocol is unknown
 7423    PROTOCOL = 13,
 7424    /// argument buffer overflow
 7425    OVERFLOW = 14,
 7426
 7427    MAX = 15,
 7428
 7429    _,
 7430} else switch (native_os) {
 7431    .linux, .emscripten => enum(c_int) {
 7432        BADFLAGS = -1,
 7433        NONAME = -2,
 7434        AGAIN = -3,
 7435        FAIL = -4,
 7436        FAMILY = -6,
 7437        SOCKTYPE = -7,
 7438        SERVICE = -8,
 7439        MEMORY = -10,
 7440        SYSTEM = -11,
 7441        OVERFLOW = -12,
 7442
 7443        NODATA = -5,
 7444        ADDRFAMILY = -9,
 7445        INPROGRESS = -100,
 7446        CANCELED = -101,
 7447        NOTCANCELED = -102,
 7448        ALLDONE = -103,
 7449        INTR = -104,
 7450        IDN_ENCODE = -105,
 7451
 7452        _,
 7453    },
 7454    .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(c_int) {
 7455        /// address family for hostname not supported
 7456        ADDRFAMILY = 1,
 7457        /// temporary failure in name resolution
 7458        AGAIN = 2,
 7459        /// invalid value for ai_flags
 7460        BADFLAGS = 3,
 7461        /// non-recoverable failure in name resolution
 7462        FAIL = 4,
 7463        /// ai_family not supported
 7464        FAMILY = 5,
 7465        /// memory allocation failure
 7466        MEMORY = 6,
 7467        /// no address associated with hostname
 7468        NODATA = 7,
 7469        /// hostname nor servname provided, or not known
 7470        NONAME = 8,
 7471        /// servname not supported for ai_socktype
 7472        SERVICE = 9,
 7473        /// ai_socktype not supported
 7474        SOCKTYPE = 10,
 7475        /// system error returned in errno
 7476        SYSTEM = 11,
 7477        /// invalid value for hints
 7478        BADHINTS = 12,
 7479        /// resolved protocol is unknown
 7480        PROTOCOL = 13,
 7481        /// argument buffer overflow
 7482        OVERFLOW = 14,
 7483        _,
 7484    },
 7485    .illumos => enum(c_int) {
 7486        /// address family for hostname not supported
 7487        ADDRFAMILY = 1,
 7488        /// name could not be resolved at this time
 7489        AGAIN = 2,
 7490        /// flags parameter had an invalid value
 7491        BADFLAGS = 3,
 7492        /// non-recoverable failure in name resolution
 7493        FAIL = 4,
 7494        /// address family not recognized
 7495        FAMILY = 5,
 7496        /// memory allocation failure
 7497        MEMORY = 6,
 7498        /// no address associated with hostname
 7499        NODATA = 7,
 7500        /// name does not resolve
 7501        NONAME = 8,
 7502        /// service not recognized for socket type
 7503        SERVICE = 9,
 7504        /// intended socket type was not recognized
 7505        SOCKTYPE = 10,
 7506        /// system error returned in errno
 7507        SYSTEM = 11,
 7508        /// argument buffer overflow
 7509        OVERFLOW = 12,
 7510        /// resolved protocol is unknown
 7511        PROTOCOL = 13,
 7512
 7513        _,
 7514    },
 7515    .openbsd => enum(c_int) {
 7516        /// address family for hostname not supported
 7517        ADDRFAMILY = -9,
 7518        /// name could not be resolved at this time
 7519        AGAIN = -3,
 7520        /// flags parameter had an invalid value
 7521        BADFLAGS = -1,
 7522        /// non-recoverable failure in name resolution
 7523        FAIL = -4,
 7524        /// address family not recognized
 7525        FAMILY = -6,
 7526        /// memory allocation failure
 7527        MEMORY = -10,
 7528        /// no address associated with hostname
 7529        NODATA = -5,
 7530        /// name does not resolve
 7531        NONAME = -2,
 7532        /// service not recognized for socket type
 7533        SERVICE = -8,
 7534        /// intended socket type was not recognized
 7535        SOCKTYPE = -7,
 7536        /// system error returned in errno
 7537        SYSTEM = -11,
 7538        /// invalid value for hints
 7539        BADHINTS = -12,
 7540        /// resolved protocol is unknown
 7541        PROTOCOL = -13,
 7542        /// argument buffer overflow
 7543        OVERFLOW = -14,
 7544        _,
 7545    },
 7546    // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L77-L88
 7547    .serenity => enum(c_int) {
 7548        ADDRFAMILY = 1,
 7549        AGAIN = 2,
 7550        BADFLAGS = 3,
 7551        FAIL = 4,
 7552        FAMILY = 5,
 7553        MEMORY = 6,
 7554        NODATA = 7,
 7555        NONAME = 8,
 7556        SERVICE = 9,
 7557        SOCKTYPE = 10,
 7558        SYSTEM = 11,
 7559        OVERFLOW = 12,
 7560        _,
 7561    },
 7562    else => void,
 7563};
 7564
 7565pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int;
 7566
 7567pub const Stat = switch (native_os) {
 7568    .linux => switch (native_arch) {
 7569        .sparc64 => extern struct {
 7570            dev: u64,
 7571            __pad1: u16,
 7572            ino: ino_t,
 7573            mode: u32,
 7574            nlink: u32,
 7575
 7576            uid: u32,
 7577            gid: u32,
 7578            rdev: u64,
 7579            __pad2: u16,
 7580
 7581            size: off_t,
 7582            blksize: isize,
 7583            blocks: i64,
 7584
 7585            atim: timespec,
 7586            mtim: timespec,
 7587            ctim: timespec,
 7588            __reserved: [2]usize,
 7589
 7590            pub fn atime(self: @This()) timespec {
 7591                return self.atim;
 7592            }
 7593
 7594            pub fn mtime(self: @This()) timespec {
 7595                return self.mtim;
 7596            }
 7597
 7598            pub fn ctime(self: @This()) timespec {
 7599                return self.ctim;
 7600            }
 7601        },
 7602        .mips, .mipsel => if (builtin.target.abi.isMusl()) extern struct {
 7603            dev: dev_t,
 7604            __pad0: [2]i32,
 7605            ino: ino_t,
 7606            mode: mode_t,
 7607            nlink: nlink_t,
 7608            uid: uid_t,
 7609            gid: gid_t,
 7610            rdev: dev_t,
 7611            __pad1: [2]i32,
 7612            size: off_t,
 7613            atim: timespec,
 7614            mtim: timespec,
 7615            ctim: timespec,
 7616            blksize: blksize_t,
 7617            __pad3: i32,
 7618            blocks: blkcnt_t,
 7619            __pad4: [14]i32,
 7620
 7621            pub fn atime(self: @This()) timespec {
 7622                return self.atim;
 7623            }
 7624
 7625            pub fn mtime(self: @This()) timespec {
 7626                return self.mtim;
 7627            }
 7628
 7629            pub fn ctime(self: @This()) timespec {
 7630                return self.ctim;
 7631            }
 7632        } else extern struct {
 7633            dev: u32,
 7634            __pad0: [3]u32,
 7635            ino: ino_t,
 7636            mode: mode_t,
 7637            nlink: nlink_t,
 7638            uid: uid_t,
 7639            gid: gid_t,
 7640            rdev: u32,
 7641            __pad1: [3]u32,
 7642            size: off_t,
 7643            atim: timespec,
 7644            mtim: timespec,
 7645            ctim: timespec,
 7646            blksize: blksize_t,
 7647            __pad3: u32,
 7648            blocks: blkcnt_t,
 7649            __pad4: [14]u32,
 7650
 7651            pub fn atime(self: @This()) timespec {
 7652                return self.atim;
 7653            }
 7654
 7655            pub fn mtime(self: @This()) timespec {
 7656                return self.mtim;
 7657            }
 7658
 7659            pub fn ctime(self: @This()) timespec {
 7660                return self.ctim;
 7661            }
 7662        },
 7663        .mips64, .mips64el => if (builtin.target.abi.isMusl()) extern struct {
 7664            dev: dev_t,
 7665            __pad0: [3]i32,
 7666            ino: ino_t,
 7667            mode: mode_t,
 7668            nlink: nlink_t,
 7669            uid: uid_t,
 7670            gid: gid_t,
 7671            rdev: dev_t,
 7672            __pad1: [2]u32,
 7673            size: off_t,
 7674            __pad2: i32,
 7675            atim: timespec,
 7676            mtim: timespec,
 7677            ctim: timespec,
 7678            blksize: blksize_t,
 7679            __pad3: u32,
 7680            blocks: blkcnt_t,
 7681            __pad4: [14]i32,
 7682
 7683            pub fn atime(self: @This()) timespec {
 7684                return self.atim;
 7685            }
 7686
 7687            pub fn mtime(self: @This()) timespec {
 7688                return self.mtim;
 7689            }
 7690
 7691            pub fn ctime(self: @This()) timespec {
 7692                return self.ctim;
 7693            }
 7694        } else extern struct {
 7695            dev: dev_t,
 7696            __pad0: [3]u32,
 7697            ino: ino_t,
 7698            mode: mode_t,
 7699            nlink: nlink_t,
 7700            uid: uid_t,
 7701            gid: gid_t,
 7702            rdev: dev_t,
 7703            __pad1: [3]u32,
 7704            size: off_t,
 7705            atim: timespec,
 7706            mtim: timespec,
 7707            ctim: timespec,
 7708            blksize: blksize_t,
 7709            __pad3: u32,
 7710            blocks: blkcnt_t,
 7711            __pad4: [14]i32,
 7712
 7713            pub fn atime(self: @This()) timespec {
 7714                return self.atim;
 7715            }
 7716
 7717            pub fn mtime(self: @This()) timespec {
 7718                return self.mtim;
 7719            }
 7720
 7721            pub fn ctime(self: @This()) timespec {
 7722                return self.ctim;
 7723            }
 7724        },
 7725
 7726        else => std.os.linux.Stat, // libc stat is the same as kernel stat.
 7727    },
 7728    .emscripten => emscripten.Stat,
 7729    .wasi => extern struct {
 7730        // Match wasi-libc's `struct stat` in lib/libc/include/wasm-wasi-musl/__struct_stat.h
 7731        dev: dev_t,
 7732        ino: ino_t,
 7733        nlink: nlink_t,
 7734        mode: mode_t,
 7735        uid: uid_t,
 7736        gid: gid_t,
 7737        __pad0: c_uint = 0,
 7738        rdev: dev_t,
 7739        size: off_t,
 7740        blksize: blksize_t,
 7741        blocks: blkcnt_t,
 7742        atim: timespec,
 7743        mtim: timespec,
 7744        ctim: timespec,
 7745        __reserved: [3]c_longlong = [3]c_longlong{ 0, 0, 0 },
 7746
 7747        pub fn atime(self: @This()) timespec {
 7748            return self.atim;
 7749        }
 7750
 7751        pub fn mtime(self: @This()) timespec {
 7752            return self.mtim;
 7753        }
 7754
 7755        pub fn ctime(self: @This()) timespec {
 7756            return self.ctim;
 7757        }
 7758
 7759        pub fn fromFilestat(st: wasi.filestat_t) Stat {
 7760            return .{
 7761                .dev = st.dev,
 7762                .ino = st.ino,
 7763                .mode = switch (st.filetype) {
 7764                    .UNKNOWN => 0,
 7765                    .BLOCK_DEVICE => S.IFBLK,
 7766                    .CHARACTER_DEVICE => S.IFCHR,
 7767                    .DIRECTORY => S.IFDIR,
 7768                    .REGULAR_FILE => S.IFREG,
 7769                    .SOCKET_DGRAM => S.IFSOCK,
 7770                    .SOCKET_STREAM => S.IFIFO,
 7771                    .SYMBOLIC_LINK => S.IFLNK,
 7772                    _ => 0,
 7773                },
 7774                .nlink = st.nlink,
 7775                .size = @intCast(st.size),
 7776                .atim = timespec.fromTimestamp(st.atim),
 7777                .mtim = timespec.fromTimestamp(st.mtim),
 7778                .ctim = timespec.fromTimestamp(st.ctim),
 7779
 7780                .uid = 0,
 7781                .gid = 0,
 7782                .rdev = 0,
 7783                .blksize = 0,
 7784                .blocks = 0,
 7785            };
 7786        }
 7787    },
 7788    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 7789        dev: i32,
 7790        mode: u16,
 7791        nlink: u16,
 7792        ino: ino_t,
 7793        uid: uid_t,
 7794        gid: gid_t,
 7795        rdev: i32,
 7796        atimespec: timespec,
 7797        mtimespec: timespec,
 7798        ctimespec: timespec,
 7799        birthtimespec: timespec,
 7800        size: off_t,
 7801        blocks: i64,
 7802        blksize: i32,
 7803        flags: u32,
 7804        gen: u32,
 7805        lspare: i32,
 7806        qspare: [2]i64,
 7807
 7808        pub fn atime(self: @This()) timespec {
 7809            return self.atimespec;
 7810        }
 7811
 7812        pub fn mtime(self: @This()) timespec {
 7813            return self.mtimespec;
 7814        }
 7815
 7816        pub fn ctime(self: @This()) timespec {
 7817            return self.ctimespec;
 7818        }
 7819
 7820        pub fn birthtime(self: @This()) timespec {
 7821            return self.birthtimespec;
 7822        }
 7823    },
 7824    .freebsd => freebsd.Stat,
 7825    .illumos => extern struct {
 7826        dev: dev_t,
 7827        ino: ino_t,
 7828        mode: mode_t,
 7829        nlink: nlink_t,
 7830        uid: uid_t,
 7831        gid: gid_t,
 7832        rdev: dev_t,
 7833        size: off_t,
 7834        atim: timespec,
 7835        mtim: timespec,
 7836        ctim: timespec,
 7837        blksize: blksize_t,
 7838        blocks: blkcnt_t,
 7839        fstype: [16]u8,
 7840
 7841        pub fn atime(self: @This()) timespec {
 7842            return self.atim;
 7843        }
 7844
 7845        pub fn mtime(self: @This()) timespec {
 7846            return self.mtim;
 7847        }
 7848
 7849        pub fn ctime(self: @This()) timespec {
 7850            return self.ctim;
 7851        }
 7852    },
 7853    .netbsd => extern struct {
 7854        dev: dev_t,
 7855        mode: mode_t,
 7856        ino: ino_t,
 7857        nlink: nlink_t,
 7858        uid: uid_t,
 7859        gid: gid_t,
 7860        rdev: dev_t,
 7861        atim: timespec,
 7862        mtim: timespec,
 7863        ctim: timespec,
 7864        birthtim: timespec,
 7865        size: off_t,
 7866        blocks: blkcnt_t,
 7867        blksize: blksize_t,
 7868        flags: u32,
 7869        gen: u32,
 7870        __spare: [2]u32,
 7871
 7872        pub fn atime(self: @This()) timespec {
 7873            return self.atim;
 7874        }
 7875
 7876        pub fn mtime(self: @This()) timespec {
 7877            return self.mtim;
 7878        }
 7879
 7880        pub fn ctime(self: @This()) timespec {
 7881            return self.ctim;
 7882        }
 7883
 7884        pub fn birthtime(self: @This()) timespec {
 7885            return self.birthtim;
 7886        }
 7887    },
 7888    .dragonfly => extern struct {
 7889        ino: ino_t,
 7890        nlink: c_uint,
 7891        dev: c_uint,
 7892        mode: c_ushort,
 7893        padding1: u16,
 7894        uid: uid_t,
 7895        gid: gid_t,
 7896        rdev: c_uint,
 7897        atim: timespec,
 7898        mtim: timespec,
 7899        ctim: timespec,
 7900        size: c_ulong,
 7901        blocks: i64,
 7902        blksize: u32,
 7903        flags: u32,
 7904        gen: u32,
 7905        lspare: i32,
 7906        qspare1: i64,
 7907        qspare2: i64,
 7908        pub fn atime(self: @This()) timespec {
 7909            return self.atim;
 7910        }
 7911
 7912        pub fn mtime(self: @This()) timespec {
 7913            return self.mtim;
 7914        }
 7915
 7916        pub fn ctime(self: @This()) timespec {
 7917            return self.ctim;
 7918        }
 7919    },
 7920    .haiku => extern struct {
 7921        dev: dev_t,
 7922        ino: ino_t,
 7923        mode: mode_t,
 7924        nlink: nlink_t,
 7925        uid: uid_t,
 7926        gid: gid_t,
 7927        size: off_t,
 7928        rdev: dev_t,
 7929        blksize: blksize_t,
 7930        atim: timespec,
 7931        mtim: timespec,
 7932        ctim: timespec,
 7933        crtim: timespec,
 7934        type: u32,
 7935        blocks: blkcnt_t,
 7936
 7937        pub fn atime(self: @This()) timespec {
 7938            return self.atim;
 7939        }
 7940        pub fn mtime(self: @This()) timespec {
 7941            return self.mtim;
 7942        }
 7943        pub fn ctime(self: @This()) timespec {
 7944            return self.ctim;
 7945        }
 7946        pub fn birthtime(self: @This()) timespec {
 7947            return self.crtim;
 7948        }
 7949    },
 7950    .openbsd => extern struct {
 7951        mode: mode_t,
 7952        dev: dev_t,
 7953        ino: ino_t,
 7954        nlink: nlink_t,
 7955        uid: uid_t,
 7956        gid: gid_t,
 7957        rdev: dev_t,
 7958        atim: timespec,
 7959        mtim: timespec,
 7960        ctim: timespec,
 7961        size: off_t,
 7962        blocks: blkcnt_t,
 7963        blksize: blksize_t,
 7964        flags: u32,
 7965        gen: u32,
 7966        birthtim: timespec,
 7967
 7968        pub fn atime(self: @This()) timespec {
 7969            return self.atim;
 7970        }
 7971
 7972        pub fn mtime(self: @This()) timespec {
 7973            return self.mtim;
 7974        }
 7975
 7976        pub fn ctime(self: @This()) timespec {
 7977            return self.ctim;
 7978        }
 7979
 7980        pub fn birthtime(self: @This()) timespec {
 7981            return self.birthtim;
 7982        }
 7983    },
 7984    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L53-L67
 7985    .serenity => extern struct {
 7986        dev: dev_t,
 7987        ino: ino_t,
 7988        mode: mode_t,
 7989        nlink: nlink_t,
 7990        uid: uid_t,
 7991        gid: gid_t,
 7992        rdev: dev_t,
 7993        size: off_t,
 7994        blksize: blksize_t,
 7995        blocks: blkcnt_t,
 7996        atim: timespec,
 7997        mtim: timespec,
 7998        ctim: timespec,
 7999
 8000        pub fn atime(self: @This()) timespec {
 8001            return self.atim;
 8002        }
 8003
 8004        pub fn mtime(self: @This()) timespec {
 8005            return self.mtim;
 8006        }
 8007
 8008        pub fn ctime(self: @This()) timespec {
 8009            return self.ctim;
 8010        }
 8011    },
 8012    else => void,
 8013};
 8014
 8015pub const pthread_mutex_t = switch (native_os) {
 8016    .linux => extern struct {
 8017        data: [data_len]u8 align(@alignOf(usize)) = [_]u8{0} ** data_len,
 8018
 8019        const data_len = switch (native_abi) {
 8020            .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24,
 8021            .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) {
 8022                .aarch64 => 48,
 8023                .x86_64 => if (native_abi == .gnux32) 32 else 40,
 8024                .mips64, .powerpc64, .powerpc64le, .sparc64 => 40,
 8025                else => if (@sizeOf(usize) == 8) 40 else 24,
 8026            },
 8027            .android, .androideabi => if (@sizeOf(usize) == 8) 40 else 4,
 8028            else => @compileError("unsupported ABI"),
 8029        };
 8030    },
 8031    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 8032        sig: c_long = 0x32AAABA7,
 8033        data: [data_len]u8 = [_]u8{0} ** data_len,
 8034
 8035        const data_len = if (@sizeOf(usize) == 8) 56 else 40;
 8036    },
 8037    .freebsd, .dragonfly, .openbsd => extern struct {
 8038        inner: ?*anyopaque = null,
 8039    },
 8040    .hermit => extern struct {
 8041        ptr: usize = maxInt(usize),
 8042    },
 8043    .netbsd => extern struct {
 8044        magic: u32 = 0x33330003,
 8045        errorcheck: padded_pthread_spin_t = 0,
 8046        ceiling: padded_pthread_spin_t = 0,
 8047        owner: usize = 0,
 8048        waiters: ?*u8 = null,
 8049        recursed: u32 = 0,
 8050        spare2: ?*anyopaque = null,
 8051    },
 8052    .haiku => extern struct {
 8053        flags: u32 = 0,
 8054        lock: i32 = 0,
 8055        unused: i32 = -42,
 8056        owner: i32 = -1,
 8057        owner_count: i32 = 0,
 8058    },
 8059    .illumos => extern struct {
 8060        flag1: u16 = 0,
 8061        flag2: u8 = 0,
 8062        ceiling: u8 = 0,
 8063        type: u16 = 0,
 8064        magic: u16 = 0x4d58,
 8065        lock: u64 = 0,
 8066        data: u64 = 0,
 8067    },
 8068    .fuchsia => extern struct {
 8069        data: [40]u8 align(@alignOf(usize)) = [_]u8{0} ** 40,
 8070    },
 8071    .emscripten => extern struct {
 8072        data: [24]u8 align(4) = [_]u8{0} ** 24,
 8073    },
 8074    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L68-L73
 8075    .serenity => extern struct {
 8076        lock: u32 = 0,
 8077        owner: pthread_t = 0,
 8078        level: c_int = 0,
 8079        type: c_int = 0,
 8080    },
 8081    else => void,
 8082};
 8083
 8084pub const pthread_cond_t = switch (native_os) {
 8085    .linux => extern struct {
 8086        data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
 8087    },
 8088    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 8089        sig: c_long = 0x3CB0B1BB,
 8090        data: [data_len]u8 = [_]u8{0} ** data_len,
 8091        const data_len = if (@sizeOf(usize) == 8) 40 else 24;
 8092    },
 8093    .freebsd, .dragonfly, .openbsd => extern struct {
 8094        inner: ?*anyopaque = null,
 8095    },
 8096    .hermit => extern struct {
 8097        ptr: usize = maxInt(usize),
 8098    },
 8099    .netbsd => extern struct {
 8100        magic: u32 = 0x55550005,
 8101        lock: pthread_spin_t = 0,
 8102        waiters_first: ?*u8 = null,
 8103        waiters_last: ?*u8 = null,
 8104        mutex: ?*pthread_mutex_t = null,
 8105        private: ?*anyopaque = null,
 8106    },
 8107    .haiku => extern struct {
 8108        flags: u32 = 0,
 8109        unused: i32 = -42,
 8110        mutex: ?*anyopaque = null,
 8111        waiter_count: i32 = 0,
 8112        lock: i32 = 0,
 8113    },
 8114    .illumos => extern struct {
 8115        flag: [4]u8 = [_]u8{0} ** 4,
 8116        type: u16 = 0,
 8117        magic: u16 = 0x4356,
 8118        data: u64 = 0,
 8119    },
 8120    .fuchsia, .emscripten => extern struct {
 8121        data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
 8122    },
 8123    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L80-L84
 8124    .serenity => extern struct {
 8125        mutex: ?*pthread_mutex_t = null,
 8126        value: u32 = 0,
 8127        clockid: clockid_t = .REALTIME_COARSE,
 8128    },
 8129    else => void,
 8130};
 8131
 8132pub const pthread_rwlock_t = switch (native_os) {
 8133    .linux => switch (native_abi) {
 8134        .android, .androideabi => switch (@sizeOf(usize)) {
 8135            4 => extern struct {
 8136                data: [40]u8 align(@alignOf(usize)) = [_]u8{0} ** 40,
 8137            },
 8138            8 => extern struct {
 8139                data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
 8140            },
 8141            else => @compileError("impossible pointer size"),
 8142        },
 8143        else => extern struct {
 8144            data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
 8145        },
 8146    },
 8147    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 8148        sig: c_long = 0x2DA8B3B4,
 8149        data: [192]u8 = [_]u8{0} ** 192,
 8150    },
 8151    .freebsd, .dragonfly, .openbsd => extern struct {
 8152        ptr: ?*anyopaque = null,
 8153    },
 8154    .hermit => extern struct {
 8155        ptr: usize = maxInt(usize),
 8156    },
 8157    .netbsd => extern struct {
 8158        magic: c_uint = 0x99990009,
 8159        interlock: switch (builtin.cpu.arch) {
 8160            .aarch64, .aarch64_be, .m68k, .sparc, .sparc64, .x86, .x86_64 => u8,
 8161            .arm, .armeb, .powerpc => c_int,
 8162            .mips, .mipsel, .mips64, .mips64el => c_uint,
 8163            else => unreachable,
 8164        } = 0,
 8165        rblocked_first: ?*u8 = null,
 8166        rblocked_last: ?*u8 = null,
 8167        wblocked_first: ?*u8 = null,
 8168        wblocked_last: ?*u8 = null,
 8169        nreaders: c_uint = 0,
 8170        owner: ?pthread_t = null,
 8171        private: ?*anyopaque = null,
 8172    },
 8173    .illumos => extern struct {
 8174        readers: i32 = 0,
 8175        type: u16 = 0,
 8176        magic: u16 = 0x5257,
 8177        mutex: pthread_mutex_t = .{},
 8178        readercv: pthread_cond_t = .{},
 8179        writercv: pthread_cond_t = .{},
 8180    },
 8181    .fuchsia => extern struct {
 8182        size: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
 8183    },
 8184    .emscripten => extern struct {
 8185        size: [32]u8 align(4) = [_]u8{0} ** 32,
 8186    },
 8187    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L86
 8188    .serenity => extern struct {
 8189        inner: u64 = 0,
 8190    },
 8191    else => void,
 8192};
 8193
 8194pub const pthread_attr_t = switch (native_os) {
 8195    .linux, .emscripten, .dragonfly => extern struct {
 8196        __size: [56]u8,
 8197        __align: c_long,
 8198    },
 8199    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 8200        __sig: c_long,
 8201        __opaque: [56]u8,
 8202    },
 8203    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L75
 8204    .freebsd, .openbsd, .serenity => extern struct {
 8205        inner: ?*anyopaque = null,
 8206    },
 8207    .illumos => extern struct {
 8208        mutexattr: ?*anyopaque = null,
 8209    },
 8210    .netbsd => extern struct {
 8211        magic: u32,
 8212        flags: i32,
 8213        private: ?*anyopaque,
 8214    },
 8215    .haiku => extern struct {
 8216        detach_state: i32,
 8217        sched_priority: i32,
 8218        stack_size: i32,
 8219        guard_size: i32,
 8220        stack_address: ?*anyopaque,
 8221    },
 8222    else => void,
 8223};
 8224
 8225pub const pthread_key_t = switch (native_os) {
 8226    .linux, .emscripten => c_uint,
 8227    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_ulong,
 8228    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L65
 8229    .openbsd, .illumos, .serenity => c_int,
 8230    else => void,
 8231};
 8232
 8233pub const padded_pthread_spin_t = switch (native_os) {
 8234    .netbsd => switch (builtin.cpu.arch) {
 8235        .x86, .x86_64 => u32,
 8236        .sparc, .sparc64 => u32,
 8237        else => pthread_spin_t,
 8238    },
 8239    else => void,
 8240};
 8241
 8242pub const pthread_spin_t = switch (native_os) {
 8243    .netbsd => switch (builtin.cpu.arch) {
 8244        .aarch64, .aarch64_be => u8,
 8245        .mips, .mipsel, .mips64, .mips64el => u32,
 8246        .powerpc, .powerpc64, .powerpc64le => i32,
 8247        .x86, .x86_64 => u8,
 8248        .arm, .armeb, .thumb, .thumbeb => i32,
 8249        .sparc, .sparc64 => u8,
 8250        .riscv32, .riscv64 => u32,
 8251        else => @compileError("undefined pthread_spin_t for this arch"),
 8252    },
 8253    else => void,
 8254};
 8255
 8256pub const sem_t = switch (native_os) {
 8257    .linux, .emscripten => extern struct {
 8258        __size: [4 * @sizeOf(usize)]u8 align(@alignOf(usize)),
 8259    },
 8260    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_int,
 8261    .freebsd => extern struct {
 8262        _magic: u32,
 8263        _kern: extern struct {
 8264            _count: u32,
 8265            _flags: u32,
 8266        },
 8267        _padding: u32,
 8268    },
 8269    .illumos => extern struct {
 8270        count: u32 = 0,
 8271        type: u16 = 0,
 8272        magic: u16 = 0x534d,
 8273        __pad1: [3]u64 = [_]u64{0} ** 3,
 8274        __pad2: [2]u64 = [_]u64{0} ** 2,
 8275    },
 8276    .openbsd, .netbsd, .dragonfly => ?*opaque {},
 8277    .haiku => extern struct {
 8278        type: i32,
 8279        u: extern union {
 8280            named_sem_id: i32,
 8281            unnamed_sem: i32,
 8282        },
 8283        padding: [2]i32,
 8284    },
 8285    // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/semaphore.h#L23-L27
 8286    .serenity => extern struct {
 8287        magic: u32,
 8288        value: u32,
 8289        flags: u8,
 8290    },
 8291    else => void,
 8292};
 8293
 8294/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
 8295pub const Kevent = switch (native_os) {
 8296    .netbsd => extern struct {
 8297        ident: usize,
 8298        filter: i32,
 8299        flags: u32,
 8300        fflags: u32,
 8301        data: i64,
 8302        udata: usize,
 8303    },
 8304    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 8305        ident: usize,
 8306        filter: i16,
 8307        flags: u16,
 8308        fflags: u32,
 8309        data: isize,
 8310        udata: usize,
 8311
 8312        // sys/types.h on macos uses #pragma pack(4) so these checks are
 8313        // to make sure the struct is laid out the same. These values were
 8314        // produced from C code using the offsetof macro.
 8315        comptime {
 8316            assert(@offsetOf(@This(), "ident") == 0);
 8317            assert(@offsetOf(@This(), "filter") == 8);
 8318            assert(@offsetOf(@This(), "flags") == 10);
 8319            assert(@offsetOf(@This(), "fflags") == 12);
 8320            assert(@offsetOf(@This(), "data") == 16);
 8321            assert(@offsetOf(@This(), "udata") == 24);
 8322        }
 8323    },
 8324    .freebsd => extern struct {
 8325        /// Identifier for this event.
 8326        ident: usize,
 8327        /// Filter for event.
 8328        filter: i16,
 8329        /// Action flags for kqueue.
 8330        flags: u16,
 8331        /// Filter flag value.
 8332        fflags: u32,
 8333        /// Filter data value.
 8334        data: i64,
 8335        /// Opaque user data identifier.
 8336        udata: usize,
 8337        /// Future extensions.
 8338        _ext: [4]u64 = [_]u64{0} ** 4,
 8339    },
 8340    .dragonfly => extern struct {
 8341        ident: usize,
 8342        filter: c_short,
 8343        flags: c_ushort,
 8344        fflags: c_uint,
 8345        data: isize,
 8346        udata: usize,
 8347    },
 8348    .openbsd => extern struct {
 8349        ident: usize,
 8350        filter: c_short,
 8351        flags: u16,
 8352        fflags: c_uint,
 8353        data: i64,
 8354        udata: usize,
 8355    },
 8356    else => void,
 8357};
 8358
 8359pub const port_t = switch (native_os) {
 8360    .illumos => c_int,
 8361    else => void,
 8362};
 8363
 8364pub const port_event = switch (native_os) {
 8365    .illumos => extern struct {
 8366        events: u32,
 8367        /// Event source.
 8368        source: u16,
 8369        __pad: u16,
 8370        /// Source-specific object.
 8371        object: ?*anyopaque,
 8372        /// User cookie.
 8373        cookie: ?*anyopaque,
 8374    },
 8375    else => void,
 8376};
 8377
 8378pub const AT = switch (native_os) {
 8379    .linux => linux.AT,
 8380    .windows => struct {
 8381        /// Remove directory instead of unlinking file
 8382        pub const REMOVEDIR = 0x200;
 8383    },
 8384    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 8385        pub const FDCWD = -2;
 8386        /// Use effective ids in access check
 8387        pub const EACCESS = 0x0010;
 8388        /// Act on the symlink itself not the target
 8389        pub const SYMLINK_NOFOLLOW = 0x0020;
 8390        /// Act on target of symlink
 8391        pub const SYMLINK_FOLLOW = 0x0040;
 8392        /// Path refers to directory
 8393        pub const REMOVEDIR = 0x0080;
 8394    },
 8395    .freebsd => struct {
 8396        /// Magic value that specify the use of the current working directory
 8397        /// to determine the target of relative file paths in the openat() and
 8398        /// similar syscalls.
 8399        pub const FDCWD = -100;
 8400        /// Check access using effective user and group ID
 8401        pub const EACCESS = 0x0100;
 8402        /// Do not follow symbolic links
 8403        pub const SYMLINK_NOFOLLOW = 0x0200;
 8404        /// Follow symbolic link
 8405        pub const SYMLINK_FOLLOW = 0x0400;
 8406        /// Remove directory instead of file
 8407        pub const REMOVEDIR = 0x0800;
 8408        /// Fail if not under dirfd
 8409        pub const BENEATH = 0x1000;
 8410    },
 8411    .netbsd => struct {
 8412        /// Magic value that specify the use of the current working directory
 8413        /// to determine the target of relative file paths in the openat() and
 8414        /// similar syscalls.
 8415        pub const FDCWD = -100;
 8416        /// Check access using effective user and group ID
 8417        pub const EACCESS = 0x0100;
 8418        /// Do not follow symbolic links
 8419        pub const SYMLINK_NOFOLLOW = 0x0200;
 8420        /// Follow symbolic link
 8421        pub const SYMLINK_FOLLOW = 0x0400;
 8422        /// Remove directory instead of file
 8423        pub const REMOVEDIR = 0x0800;
 8424    },
 8425    .dragonfly => struct {
 8426        pub const FDCWD = -328243;
 8427        pub const SYMLINK_NOFOLLOW = 1;
 8428        pub const REMOVEDIR = 2;
 8429        pub const EACCESS = 4;
 8430        pub const SYMLINK_FOLLOW = 8;
 8431    },
 8432    .openbsd => struct {
 8433        /// Magic value that specify the use of the current working directory
 8434        /// to determine the target of relative file paths in the openat() and
 8435        /// similar syscalls.
 8436        pub const FDCWD = -100;
 8437        /// Check access using effective user and group ID
 8438        pub const EACCESS = 0x01;
 8439        /// Do not follow symbolic links
 8440        pub const SYMLINK_NOFOLLOW = 0x02;
 8441        /// Follow symbolic link
 8442        pub const SYMLINK_FOLLOW = 0x04;
 8443        /// Remove directory instead of file
 8444        pub const REMOVEDIR = 0x08;
 8445    },
 8446    .haiku => struct {
 8447        pub const FDCWD = -1;
 8448        pub const SYMLINK_NOFOLLOW = 0x01;
 8449        pub const SYMLINK_FOLLOW = 0x02;
 8450        pub const REMOVEDIR = 0x04;
 8451        pub const EACCESS = 0x08;
 8452    },
 8453    .illumos => struct {
 8454        /// Magic value that specify the use of the current working directory
 8455        /// to determine the target of relative file paths in the openat() and
 8456        /// similar syscalls.
 8457        pub const FDCWD: fd_t = @bitCast(@as(u32, 0xffd19553));
 8458        /// Do not follow symbolic links
 8459        pub const SYMLINK_NOFOLLOW = 0x1000;
 8460        /// Follow symbolic link
 8461        pub const SYMLINK_FOLLOW = 0x2000;
 8462        /// Remove directory instead of file
 8463        pub const REMOVEDIR = 0x1;
 8464        pub const TRIGGER = 0x2;
 8465        /// Check access using effective user and group ID
 8466        pub const EACCESS = 0x4;
 8467    },
 8468    .emscripten => struct {
 8469        pub const FDCWD = -100;
 8470        pub const SYMLINK_NOFOLLOW = 0x100;
 8471        pub const REMOVEDIR = 0x200;
 8472        pub const SYMLINK_FOLLOW = 0x400;
 8473        pub const NO_AUTOMOUNT = 0x800;
 8474        pub const EMPTY_PATH = 0x1000;
 8475        pub const STATX_SYNC_TYPE = 0x6000;
 8476        pub const STATX_SYNC_AS_STAT = 0x0000;
 8477        pub const STATX_FORCE_SYNC = 0x2000;
 8478        pub const STATX_DONT_SYNC = 0x4000;
 8479        pub const RECURSIVE = 0x8000;
 8480    },
 8481    .wasi => struct {
 8482        // Match `AT_*` constants in lib/libc/include/wasm-wasi-musl/__header_fcntl.h
 8483        pub const EACCESS = 0x0;
 8484        pub const SYMLINK_NOFOLLOW = 0x1;
 8485        pub const SYMLINK_FOLLOW = 0x2;
 8486        pub const REMOVEDIR = 0x4;
 8487        /// When linking libc, we follow their convention and use -2 for current working directory.
 8488        /// However, without libc, Zig does a different convention: it assumes the
 8489        /// current working directory is the first preopen. This behavior can be
 8490        /// overridden with a public function called `wasi_cwd` in the root source
 8491        /// file.
 8492        pub const FDCWD: fd_t = if (builtin.link_libc) -2 else 3;
 8493    },
 8494    // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L49-L52
 8495    .serenity => struct {
 8496        pub const FDCWD = -100;
 8497        pub const SYMLINK_NOFOLLOW = 0x100;
 8498        pub const REMOVEDIR = 0x200;
 8499        pub const EACCESS = 0x400;
 8500    },
 8501    else => void,
 8502};
 8503
 8504pub const O = switch (native_os) {
 8505    .linux => linux.O,
 8506    .emscripten => packed struct(u32) {
 8507        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8508        _2: u4 = 0,
 8509        CREAT: bool = false,
 8510        EXCL: bool = false,
 8511        NOCTTY: bool = false,
 8512        TRUNC: bool = false,
 8513        APPEND: bool = false,
 8514        NONBLOCK: bool = false,
 8515        DSYNC: bool = false,
 8516        ASYNC: bool = false,
 8517        DIRECT: bool = false,
 8518        LARGEFILE: bool = false,
 8519        DIRECTORY: bool = false,
 8520        NOFOLLOW: bool = false,
 8521        NOATIME: bool = false,
 8522        CLOEXEC: bool = false,
 8523        SYNC: bool = false,
 8524        PATH: bool = false,
 8525        TMPFILE: bool = false,
 8526        _: u9 = 0,
 8527    },
 8528    .wasi => packed struct(u32) {
 8529        // Match `O_*` bits from lib/libc/include/wasm-wasi-musl/__header_fcntl.h
 8530        APPEND: bool = false,
 8531        DSYNC: bool = false,
 8532        NONBLOCK: bool = false,
 8533        RSYNC: bool = false,
 8534        SYNC: bool = false,
 8535        _5: u7 = 0,
 8536        CREAT: bool = false,
 8537        DIRECTORY: bool = false,
 8538        EXCL: bool = false,
 8539        TRUNC: bool = false,
 8540        _16: u8 = 0,
 8541        NOFOLLOW: bool = false,
 8542        EXEC: bool = false,
 8543        read: bool = false,
 8544        SEARCH: bool = false,
 8545        write: bool = false,
 8546        // O_CLOEXEC, O_TTY_ININT, O_NOCTTY are 0 in wasi-musl, so they're silently
 8547        // ignored in C code.  Thus no mapping in Zig.
 8548        _: u3 = 0,
 8549    },
 8550    .illumos => packed struct(u32) {
 8551        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8552        NDELAY: bool = false,
 8553        APPEND: bool = false,
 8554        SYNC: bool = false,
 8555        _5: u1 = 0,
 8556        DSYNC: bool = false,
 8557        NONBLOCK: bool = false,
 8558        CREAT: bool = false,
 8559        TRUNC: bool = false,
 8560        EXCL: bool = false,
 8561        NOCTTY: bool = false,
 8562        _12: u1 = 0,
 8563        LARGEFILE: bool = false,
 8564        XATTR: bool = false,
 8565        RSYNC: bool = false,
 8566        _16: u1 = 0,
 8567        NOFOLLOW: bool = false,
 8568        NOLINKS: bool = false,
 8569        _19: u2 = 0,
 8570        SEARCH: bool = false,
 8571        EXEC: bool = false,
 8572        CLOEXEC: bool = false,
 8573        DIRECTORY: bool = false,
 8574        DIRECT: bool = false,
 8575        _: u6 = 0,
 8576    },
 8577    .netbsd => packed struct(u32) {
 8578        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8579        NONBLOCK: bool = false,
 8580        APPEND: bool = false,
 8581        SHLOCK: bool = false,
 8582        EXLOCK: bool = false,
 8583        ASYNC: bool = false,
 8584        SYNC: bool = false,
 8585        NOFOLLOW: bool = false,
 8586        CREAT: bool = false,
 8587        TRUNC: bool = false,
 8588        EXCL: bool = false,
 8589        _12: u3 = 0,
 8590        NOCTTY: bool = false,
 8591        DSYNC: bool = false,
 8592        RSYNC: bool = false,
 8593        ALT_IO: bool = false,
 8594        DIRECT: bool = false,
 8595        _20: u1 = 0,
 8596        DIRECTORY: bool = false,
 8597        CLOEXEC: bool = false,
 8598        SEARCH: bool = false,
 8599        _: u8 = 0,
 8600    },
 8601    .openbsd => packed struct(u32) {
 8602        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8603        NONBLOCK: bool = false,
 8604        APPEND: bool = false,
 8605        SHLOCK: bool = false,
 8606        EXLOCK: bool = false,
 8607        ASYNC: bool = false,
 8608        SYNC: bool = false,
 8609        NOFOLLOW: bool = false,
 8610        CREAT: bool = false,
 8611        TRUNC: bool = false,
 8612        EXCL: bool = false,
 8613        _12: u3 = 0,
 8614        NOCTTY: bool = false,
 8615        CLOEXEC: bool = false,
 8616        DIRECTORY: bool = false,
 8617        _: u14 = 0,
 8618    },
 8619    .haiku => packed struct(u32) {
 8620        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8621        _2: u4 = 0,
 8622        CLOEXEC: bool = false,
 8623        NONBLOCK: bool = false,
 8624        EXCL: bool = false,
 8625        CREAT: bool = false,
 8626        TRUNC: bool = false,
 8627        APPEND: bool = false,
 8628        NOCTTY: bool = false,
 8629        NOTRAVERSE: bool = false,
 8630        _14: u2 = 0,
 8631        SYNC: bool = false,
 8632        RSYNC: bool = false,
 8633        DSYNC: bool = false,
 8634        NOFOLLOW: bool = false,
 8635        DIRECT: bool = false,
 8636        DIRECTORY: bool = false,
 8637        _: u10 = 0,
 8638    },
 8639    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) {
 8640        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8641        NONBLOCK: bool = false,
 8642        APPEND: bool = false,
 8643        SHLOCK: bool = false,
 8644        EXLOCK: bool = false,
 8645        ASYNC: bool = false,
 8646        SYNC: bool = false,
 8647        NOFOLLOW: bool = false,
 8648        CREAT: bool = false,
 8649        TRUNC: bool = false,
 8650        EXCL: bool = false,
 8651        _12: u3 = 0,
 8652        EVTONLY: bool = false,
 8653        _16: u1 = 0,
 8654        NOCTTY: bool = false,
 8655        _18: u2 = 0,
 8656        DIRECTORY: bool = false,
 8657        SYMLINK: bool = false,
 8658        DSYNC: bool = false,
 8659        _23: u1 = 0,
 8660        CLOEXEC: bool = false,
 8661        _25: u4 = 0,
 8662        ALERT: bool = false,
 8663        _30: u1 = 0,
 8664        POPUP: bool = false,
 8665    },
 8666    .dragonfly => packed struct(u32) {
 8667        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8668        NONBLOCK: bool = false,
 8669        APPEND: bool = false,
 8670        SHLOCK: bool = false,
 8671        EXLOCK: bool = false,
 8672        ASYNC: bool = false,
 8673        SYNC: bool = false,
 8674        NOFOLLOW: bool = false,
 8675        CREAT: bool = false,
 8676        TRUNC: bool = false,
 8677        EXCL: bool = false,
 8678        _12: u3 = 0,
 8679        NOCTTY: bool = false,
 8680        DIRECT: bool = false,
 8681        CLOEXEC: bool = false,
 8682        FBLOCKING: bool = false,
 8683        FNONBLOCKING: bool = false,
 8684        FAPPEND: bool = false,
 8685        FOFFSET: bool = false,
 8686        FSYNCWRITE: bool = false,
 8687        FASYNCWRITE: bool = false,
 8688        _24: u3 = 0,
 8689        DIRECTORY: bool = false,
 8690        _: u4 = 0,
 8691    },
 8692    .freebsd => packed struct(u32) {
 8693        ACCMODE: std.posix.ACCMODE = .RDONLY,
 8694        NONBLOCK: bool = false,
 8695        APPEND: bool = false,
 8696        SHLOCK: bool = false,
 8697        EXLOCK: bool = false,
 8698        ASYNC: bool = false,
 8699        SYNC: bool = false,
 8700        NOFOLLOW: bool = false,
 8701        CREAT: bool = false,
 8702        TRUNC: bool = false,
 8703        EXCL: bool = false,
 8704        DSYNC: bool = false,
 8705        _13: u2 = 0,
 8706        NOCTTY: bool = false,
 8707        DIRECT: bool = false,
 8708        DIRECTORY: bool = false,
 8709        NOATIME: bool = false,
 8710        _19: u1 = 0,
 8711        CLOEXEC: bool = false,
 8712        PATH: bool = false,
 8713        TMPFILE: bool = false,
 8714        _: u9 = 0,
 8715    },
 8716    // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L28-L43
 8717    .serenity => packed struct(c_int) {
 8718        ACCMODE: std.posix.ACCMODE = .NONE,
 8719        EXEC: bool = false,
 8720        CREAT: bool = false,
 8721        EXCL: bool = false,
 8722        NOCTTY: bool = false,
 8723        TRUNC: bool = false,
 8724        APPEND: bool = false,
 8725        NONBLOCK: bool = false,
 8726        DIRECTORY: bool = false,
 8727        NOFOLLOW: bool = false,
 8728        CLOEXEC: bool = false,
 8729        DIRECT: bool = false,
 8730        SYNC: bool = false,
 8731        _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 14) = 0,
 8732    },
 8733    else => void,
 8734};
 8735
 8736pub const MAP = switch (native_os) {
 8737    .linux => linux.MAP,
 8738    .emscripten => packed struct(u32) {
 8739        TYPE: enum(u4) {
 8740            SHARED = 0x01,
 8741            PRIVATE = 0x02,
 8742            SHARED_VALIDATE = 0x03,
 8743        },
 8744        FIXED: bool = false,
 8745        ANONYMOUS: bool = false,
 8746        _6: u2 = 0,
 8747        GROWSDOWN: bool = false,
 8748        _9: u2 = 0,
 8749        DENYWRITE: bool = false,
 8750        EXECUTABLE: bool = false,
 8751        LOCKED: bool = false,
 8752        NORESERVE: bool = false,
 8753        POPULATE: bool = false,
 8754        NONBLOCK: bool = false,
 8755        STACK: bool = false,
 8756        HUGETLB: bool = false,
 8757        SYNC: bool = false,
 8758        FIXED_NOREPLACE: bool = false,
 8759        _: u11 = 0,
 8760    },
 8761    .illumos => packed struct(u32) {
 8762        TYPE: enum(u4) {
 8763            SHARED = 0x01,
 8764            PRIVATE = 0x02,
 8765        },
 8766        FIXED: bool = false,
 8767        RENAME: bool = false,
 8768        NORESERVE: bool = false,
 8769        @"32BIT": bool = false,
 8770        ANONYMOUS: bool = false,
 8771        ALIGN: bool = false,
 8772        TEXT: bool = false,
 8773        INITDATA: bool = false,
 8774        _: u20 = 0,
 8775    },
 8776    .netbsd => packed struct(u32) {
 8777        TYPE: enum(u2) {
 8778            SHARED = 0x01,
 8779            PRIVATE = 0x02,
 8780        },
 8781        REMAPDUP: bool = false,
 8782        _3: u1 = 0,
 8783        FIXED: bool = false,
 8784        RENAME: bool = false,
 8785        NORESERVE: bool = false,
 8786        INHERIT: bool = false,
 8787        _8: u1 = 0,
 8788        HASSEMAPHORE: bool = false,
 8789        TRYFIXED: bool = false,
 8790        WIRED: bool = false,
 8791        ANONYMOUS: bool = false,
 8792        STACK: bool = false,
 8793        _: u18 = 0,
 8794    },
 8795    .openbsd => packed struct(u32) {
 8796        TYPE: enum(u4) {
 8797            SHARED = 0x01,
 8798            PRIVATE = 0x02,
 8799        },
 8800        FIXED: bool = false,
 8801        _5: u7 = 0,
 8802        ANONYMOUS: bool = false,
 8803        _13: u1 = 0,
 8804        STACK: bool = false,
 8805        CONCEAL: bool = false,
 8806        _: u16 = 0,
 8807    },
 8808    .haiku => packed struct(u32) {
 8809        TYPE: enum(u2) {
 8810            SHARED = 0x01,
 8811            PRIVATE = 0x02,
 8812        },
 8813        FIXED: bool = false,
 8814        ANONYMOUS: bool = false,
 8815        NORESERVE: bool = false,
 8816        _: u27 = 0,
 8817    },
 8818    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u32) {
 8819        TYPE: enum(u4) {
 8820            SHARED = 0x01,
 8821            PRIVATE = 0x02,
 8822        },
 8823        FIXED: bool = false,
 8824        _5: u1 = 0,
 8825        NORESERVE: bool = false,
 8826        _7: u2 = 0,
 8827        HASSEMAPHORE: bool = false,
 8828        NOCACHE: bool = false,
 8829        JIT: bool = false,
 8830        ANONYMOUS: bool = false,
 8831        _: u19 = 0,
 8832    },
 8833    .dragonfly => packed struct(u32) {
 8834        TYPE: enum(u4) {
 8835            SHARED = 0x01,
 8836            PRIVATE = 0x02,
 8837        },
 8838        FIXED: bool = false,
 8839        RENAME: bool = false,
 8840        NORESERVE: bool = false,
 8841        INHERIT: bool = false,
 8842        NOEXTEND: bool = false,
 8843        HASSEMAPHORE: bool = false,
 8844        STACK: bool = false,
 8845        NOSYNC: bool = false,
 8846        ANONYMOUS: bool = false,
 8847        VPAGETABLE: bool = false,
 8848        _14: u2 = 0,
 8849        TRYFIXED: bool = false,
 8850        NOCORE: bool = false,
 8851        SIZEALIGN: bool = false,
 8852        _: u13 = 0,
 8853    },
 8854    .freebsd => packed struct(u32) {
 8855        TYPE: enum(u4) {
 8856            SHARED = 0x01,
 8857            PRIVATE = 0x02,
 8858        },
 8859        FIXED: bool = false,
 8860        _5: u5 = 0,
 8861        STACK: bool = false,
 8862        NOSYNC: bool = false,
 8863        ANONYMOUS: bool = false,
 8864        GUARD: bool = false,
 8865        EXCL: bool = false,
 8866        _15: u2 = 0,
 8867        NOCORE: bool = false,
 8868        PREFAULT_READ: bool = false,
 8869        @"32BIT": bool = false,
 8870        _: u12 = 0,
 8871    },
 8872    // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L16-L26
 8873    .serenity => packed struct(c_int) {
 8874        TYPE: enum(u4) {
 8875            SHARED = 0x01,
 8876            PRIVATE = 0x02,
 8877        },
 8878        FIXED: bool = false,
 8879        ANONYMOUS: bool = false,
 8880        STACK: bool = false,
 8881        NORESERVE: bool = false,
 8882        RANDOMIZED: bool = false,
 8883        PURGEABLE: bool = false,
 8884        FIXED_NOREPLACE: bool = false,
 8885        _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 11) = 0,
 8886    },
 8887    else => void,
 8888};
 8889
 8890pub const MREMAP = switch (native_os) {
 8891    .linux => linux.MREMAP,
 8892    else => void,
 8893};
 8894
 8895/// Used by libc to communicate failure. Not actually part of the underlying syscall.
 8896pub const MAP_FAILED: *anyopaque = @ptrFromInt(maxInt(usize));
 8897
 8898pub const cc_t = u8;
 8899
 8900/// Indices into the `cc` array in the `termios` struct.
 8901pub const V = switch (native_os) {
 8902    .linux => linux.V,
 8903    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .netbsd, .openbsd => enum {
 8904        EOF,
 8905        EOL,
 8906        EOL2,
 8907        ERASE,
 8908        WERASE,
 8909        KILL,
 8910        REPRINT,
 8911        reserved,
 8912        INTR,
 8913        QUIT,
 8914        SUSP,
 8915        DSUSP,
 8916        START,
 8917        STOP,
 8918        LNEXT,
 8919        DISCARD,
 8920        MIN,
 8921        TIME,
 8922        STATUS,
 8923    },
 8924    .freebsd => enum {
 8925        EOF,
 8926        EOL,
 8927        EOL2,
 8928        ERASE,
 8929        WERASE,
 8930        KILL,
 8931        REPRINT,
 8932        ERASE2,
 8933        INTR,
 8934        QUIT,
 8935        SUSP,
 8936        DSUSP,
 8937        START,
 8938        STOP,
 8939        LNEXT,
 8940        DISCARD,
 8941        MIN,
 8942        TIME,
 8943        STATUS,
 8944    },
 8945    .haiku => enum {
 8946        INTR,
 8947        QUIT,
 8948        ERASE,
 8949        KILL,
 8950        EOF,
 8951        EOL,
 8952        EOL2,
 8953        SWTCH,
 8954        START,
 8955        STOP,
 8956        SUSP,
 8957    },
 8958    .illumos => enum {
 8959        INTR,
 8960        QUIT,
 8961        ERASE,
 8962        KILL,
 8963        EOF,
 8964        EOL,
 8965        EOL2,
 8966        SWTCH,
 8967        START,
 8968        STOP,
 8969        SUSP,
 8970        DSUSP,
 8971        REPRINT,
 8972        DISCARD,
 8973        WERASE,
 8974        LNEXT,
 8975        STATUS,
 8976        ERASE2,
 8977    },
 8978    .emscripten, .wasi => enum {
 8979        INTR,
 8980        QUIT,
 8981        ERASE,
 8982        KILL,
 8983        EOF,
 8984        TIME,
 8985        MIN,
 8986        SWTC,
 8987        START,
 8988        STOP,
 8989        SUSP,
 8990        EOL,
 8991        REPRINT,
 8992        DISCARD,
 8993        WERASE,
 8994        LNEXT,
 8995        EOL2,
 8996    },
 8997    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L32-L49
 8998    .serenity => enum {
 8999        INTR,
 9000        QUIT,
 9001        ERASE,
 9002        KILL,
 9003        EOF,
 9004        TIME,
 9005        MIN,
 9006        SWTC,
 9007        START,
 9008        STOP,
 9009        SUSP,
 9010        EOL,
 9011        REPRINT,
 9012        DISCARD,
 9013        WERASE,
 9014        LNEXT,
 9015        EOL2,
 9016        INFO,
 9017    },
 9018    else => void,
 9019};
 9020
 9021pub const NCCS = switch (native_os) {
 9022    .linux => linux.NCCS,
 9023    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .freebsd, .netbsd, .openbsd, .dragonfly => 20,
 9024    .haiku => 11,
 9025    .illumos => 19,
 9026    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L15
 9027    .emscripten, .wasi, .serenity => 32,
 9028    else => void,
 9029};
 9030
 9031pub const termios = switch (native_os) {
 9032    .linux => linux.termios,
 9033    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
 9034        iflag: tc_iflag_t,
 9035        oflag: tc_oflag_t,
 9036        cflag: tc_cflag_t,
 9037        lflag: tc_lflag_t,
 9038        cc: [NCCS]cc_t,
 9039        ispeed: speed_t align(8),
 9040        ospeed: speed_t,
 9041    },
 9042    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L21-L29
 9043    .freebsd, .netbsd, .dragonfly, .openbsd, .serenity => extern struct {
 9044        iflag: tc_iflag_t,
 9045        oflag: tc_oflag_t,
 9046        cflag: tc_cflag_t,
 9047        lflag: tc_lflag_t,
 9048        cc: [NCCS]cc_t,
 9049        ispeed: speed_t,
 9050        ospeed: speed_t,
 9051    },
 9052    .haiku => extern struct {
 9053        iflag: tc_iflag_t,
 9054        oflag: tc_oflag_t,
 9055        cflag: tc_cflag_t,
 9056        lflag: tc_lflag_t,
 9057        line: cc_t,
 9058        ispeed: speed_t,
 9059        ospeed: speed_t,
 9060        cc: [NCCS]cc_t,
 9061    },
 9062    .illumos => extern struct {
 9063        iflag: tc_iflag_t,
 9064        oflag: tc_oflag_t,
 9065        cflag: tc_cflag_t,
 9066        lflag: tc_lflag_t,
 9067        cc: [NCCS]cc_t,
 9068    },
 9069    .emscripten, .wasi => extern struct {
 9070        iflag: tc_iflag_t,
 9071        oflag: tc_oflag_t,
 9072        cflag: tc_cflag_t,
 9073        lflag: tc_lflag_t,
 9074        line: cc_t,
 9075        cc: [NCCS]cc_t,
 9076        ispeed: speed_t,
 9077        ospeed: speed_t,
 9078    },
 9079    else => void,
 9080};
 9081
 9082pub const tc_iflag_t = switch (native_os) {
 9083    .linux => linux.tc_iflag_t,
 9084    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) {
 9085        IGNBRK: bool = false,
 9086        BRKINT: bool = false,
 9087        IGNPAR: bool = false,
 9088        PARMRK: bool = false,
 9089        INPCK: bool = false,
 9090        ISTRIP: bool = false,
 9091        INLCR: bool = false,
 9092        IGNCR: bool = false,
 9093        ICRNL: bool = false,
 9094        IXON: bool = false,
 9095        IXOFF: bool = false,
 9096        IXANY: bool = false,
 9097        _12: u1 = 0,
 9098        IMAXBEL: bool = false,
 9099        IUTF8: bool = false,
 9100        _: u49 = 0,
 9101    },
 9102    .netbsd, .freebsd, .dragonfly => packed struct(u32) {
 9103        IGNBRK: bool = false,
 9104        BRKINT: bool = false,
 9105        IGNPAR: bool = false,
 9106        PARMRK: bool = false,
 9107        INPCK: bool = false,
 9108        ISTRIP: bool = false,
 9109        INLCR: bool = false,
 9110        IGNCR: bool = false,
 9111        ICRNL: bool = false,
 9112        IXON: bool = false,
 9113        IXOFF: bool = false,
 9114        IXANY: bool = false,
 9115        _12: u1 = 0,
 9116        IMAXBEL: bool = false,
 9117        _: u18 = 0,
 9118    },
 9119    .openbsd => packed struct(u32) {
 9120        IGNBRK: bool = false,
 9121        BRKINT: bool = false,
 9122        IGNPAR: bool = false,
 9123        PARMRK: bool = false,
 9124        INPCK: bool = false,
 9125        ISTRIP: bool = false,
 9126        INLCR: bool = false,
 9127        IGNCR: bool = false,
 9128        ICRNL: bool = false,
 9129        IXON: bool = false,
 9130        IXOFF: bool = false,
 9131        IXANY: bool = false,
 9132        IUCLC: bool = false,
 9133        IMAXBEL: bool = false,
 9134        _: u18 = 0,
 9135    },
 9136    .haiku => packed struct(u32) {
 9137        IGNBRK: bool = false,
 9138        BRKINT: bool = false,
 9139        IGNPAR: bool = false,
 9140        PARMRK: bool = false,
 9141        INPCK: bool = false,
 9142        ISTRIP: bool = false,
 9143        INLCR: bool = false,
 9144        IGNCR: bool = false,
 9145        ICRNL: bool = false,
 9146        IUCLC: bool = false,
 9147        IXON: bool = false,
 9148        IXANY: bool = false,
 9149        IXOFF: bool = false,
 9150        _: u19 = 0,
 9151    },
 9152    .illumos => packed struct(u32) {
 9153        IGNBRK: bool = false,
 9154        BRKINT: bool = false,
 9155        IGNPAR: bool = false,
 9156        PARMRK: bool = false,
 9157        INPCK: bool = false,
 9158        ISTRIP: bool = false,
 9159        INLCR: bool = false,
 9160        IGNCR: bool = false,
 9161        ICRNL: bool = false,
 9162        IUCLC: bool = false,
 9163        IXON: bool = false,
 9164        IXANY: bool = false,
 9165        _12: u1 = 0,
 9166        IMAXBEL: bool = false,
 9167        _14: u1 = 0,
 9168        DOSMODE: bool = false,
 9169        _: u16 = 0,
 9170    },
 9171    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L52-L66
 9172    .emscripten, .wasi, .serenity => packed struct(u32) {
 9173        IGNBRK: bool = false,
 9174        BRKINT: bool = false,
 9175        IGNPAR: bool = false,
 9176        PARMRK: bool = false,
 9177        INPCK: bool = false,
 9178        ISTRIP: bool = false,
 9179        INLCR: bool = false,
 9180        IGNCR: bool = false,
 9181        ICRNL: bool = false,
 9182        IUCLC: bool = false,
 9183        IXON: bool = false,
 9184        IXANY: bool = false,
 9185        IXOFF: bool = false,
 9186        IMAXBEL: bool = false,
 9187        IUTF8: bool = false,
 9188        _: u17 = 0,
 9189    },
 9190    else => void,
 9191};
 9192
 9193pub const tc_oflag_t = switch (native_os) {
 9194    .linux => linux.tc_oflag_t,
 9195    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) {
 9196        OPOST: bool = false,
 9197        ONLCR: bool = false,
 9198        OXTABS: bool = false,
 9199        ONOEOT: bool = false,
 9200        OCRNL: bool = false,
 9201        ONOCR: bool = false,
 9202        ONLRET: bool = false,
 9203        OFILL: bool = false,
 9204        NLDLY: u2 = 0,
 9205        TABDLY: u2 = 0,
 9206        CRDLY: u2 = 0,
 9207        FFDLY: u1 = 0,
 9208        BSDLY: u1 = 0,
 9209        VTDLY: u1 = 0,
 9210        OFDEL: bool = false,
 9211        _: u46 = 0,
 9212    },
 9213    .netbsd => packed struct(u32) {
 9214        OPOST: bool = false,
 9215        ONLCR: bool = false,
 9216        OXTABS: bool = false,
 9217        ONOEOT: bool = false,
 9218        OCRNL: bool = false,
 9219        _5: u1 = 0,
 9220        ONOCR: bool = false,
 9221        ONLRET: bool = false,
 9222        _: u24 = 0,
 9223    },
 9224    .openbsd => packed struct(u32) {
 9225        OPOST: bool = false,
 9226        ONLCR: bool = false,
 9227        OXTABS: bool = false,
 9228        ONOEOT: bool = false,
 9229        OCRNL: bool = false,
 9230        OLCUC: bool = false,
 9231        ONOCR: bool = false,
 9232        ONLRET: bool = false,
 9233        _: u24 = 0,
 9234    },
 9235    .freebsd, .dragonfly => packed struct(u32) {
 9236        OPOST: bool = false,
 9237        ONLCR: bool = false,
 9238        _2: u1 = 0,
 9239        ONOEOT: bool = false,
 9240        OCRNL: bool = false,
 9241        ONOCR: bool = false,
 9242        ONLRET: bool = false,
 9243        _: u25 = 0,
 9244    },
 9245    .illumos => packed struct(u32) {
 9246        OPOST: bool = false,
 9247        OLCUC: bool = false,
 9248        ONLCR: bool = false,
 9249        OCRNL: bool = false,
 9250        ONOCR: bool = false,
 9251        ONLRET: bool = false,
 9252        OFILL: bool = false,
 9253        OFDEL: bool = false,
 9254        NLDLY: u1 = 0,
 9255        CRDLY: u2 = 0,
 9256        TABDLY: u2 = 0,
 9257        BSDLY: u1 = 0,
 9258        VTDLY: u1 = 0,
 9259        FFDLY: u1 = 0,
 9260        PAGEOUT: bool = false,
 9261        WRAP: bool = false,
 9262        _: u14 = 0,
 9263    },
 9264    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L69-L97
 9265    .haiku, .wasi, .emscripten, .serenity => packed struct(u32) {
 9266        OPOST: bool = false,
 9267        OLCUC: bool = false,
 9268        ONLCR: bool = false,
 9269        OCRNL: bool = false,
 9270        ONOCR: bool = false,
 9271        ONLRET: bool = false,
 9272        OFILL: bool = false,
 9273        OFDEL: bool = false,
 9274        NLDLY: u1 = 0,
 9275        CRDLY: u2 = 0,
 9276        TABDLY: u2 = 0,
 9277        BSDLY: u1 = 0,
 9278        VTDLY: u1 = 0,
 9279        FFDLY: u1 = 0,
 9280        _: u16 = 0,
 9281    },
 9282    else => void,
 9283};
 9284
 9285pub const CSIZE = switch (native_os) {
 9286    .linux => linux.CSIZE,
 9287    .haiku => enum(u1) { CS7, CS8 },
 9288    else => enum(u2) { CS5, CS6, CS7, CS8 },
 9289};
 9290
 9291pub const tc_cflag_t = switch (native_os) {
 9292    .linux => linux.tc_cflag_t,
 9293    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) {
 9294        CIGNORE: bool = false,
 9295        _1: u5 = 0,
 9296        CSTOPB: bool = false,
 9297        _7: u1 = 0,
 9298        CSIZE: CSIZE = .CS5,
 9299        _10: u1 = 0,
 9300        CREAD: bool = false,
 9301        PARENB: bool = false,
 9302        PARODD: bool = false,
 9303        HUPCL: bool = false,
 9304        CLOCAL: bool = false,
 9305        CCTS_OFLOW: bool = false,
 9306        CRTS_IFLOW: bool = false,
 9307        CDTR_IFLOW: bool = false,
 9308        CDSR_OFLOW: bool = false,
 9309        CCAR_OFLOW: bool = false,
 9310        _: u43 = 0,
 9311    },
 9312    .freebsd => packed struct(u32) {
 9313        CIGNORE: bool = false,
 9314        _1: u7 = 0,
 9315        CSIZE: CSIZE = .CS5,
 9316        CSTOPB: bool = false,
 9317        CREAD: bool = false,
 9318        PARENB: bool = false,
 9319        PARODD: bool = false,
 9320        HUPCL: bool = false,
 9321        CLOCAL: bool = false,
 9322        CCTS_OFLOW: bool = false,
 9323        CRTS_IFLOW: bool = false,
 9324        CDTR_IFLOW: bool = false,
 9325        CDSR_OFLOW: bool = false,
 9326        CCAR_OFLOW: bool = false,
 9327        CNO_RTSDTR: bool = false,
 9328        _: u10 = 0,
 9329    },
 9330    .netbsd => packed struct(u32) {
 9331        CIGNORE: bool = false,
 9332        _1: u7 = 0,
 9333        CSIZE: CSIZE = .CS5,
 9334        CSTOPB: bool = false,
 9335        CREAD: bool = false,
 9336        PARENB: bool = false,
 9337        PARODD: bool = false,
 9338        HUPCL: bool = false,
 9339        CLOCAL: bool = false,
 9340        CRTSCTS: bool = false,
 9341        CDTRCTS: bool = false,
 9342        _18: u2 = 0,
 9343        MDMBUF: bool = false,
 9344        _: u11 = 0,
 9345    },
 9346    .dragonfly => packed struct(u32) {
 9347        CIGNORE: bool = false,
 9348        _1: u7 = 0,
 9349        CSIZE: CSIZE = .CS5,
 9350        CSTOPB: bool = false,
 9351        CREAD: bool = false,
 9352        PARENB: bool = false,
 9353        PARODD: bool = false,
 9354        HUPCL: bool = false,
 9355        CLOCAL: bool = false,
 9356        CCTS_OFLOW: bool = false,
 9357        CRTS_IFLOW: bool = false,
 9358        CDTR_IFLOW: bool = false,
 9359        CDSR_OFLOW: bool = false,
 9360        CCAR_OFLOW: bool = false,
 9361        _: u11 = 0,
 9362    },
 9363    .openbsd => packed struct(u32) {
 9364        CIGNORE: bool = false,
 9365        _1: u7 = 0,
 9366        CSIZE: CSIZE = .CS5,
 9367        CSTOPB: bool = false,
 9368        CREAD: bool = false,
 9369        PARENB: bool = false,
 9370        PARODD: bool = false,
 9371        HUPCL: bool = false,
 9372        CLOCAL: bool = false,
 9373        CRTSCTS: bool = false,
 9374        _17: u3 = 0,
 9375        MDMBUF: bool = false,
 9376        _: u11 = 0,
 9377    },
 9378    .haiku => packed struct(u32) {
 9379        _0: u5 = 0,
 9380        CSIZE: CSIZE = .CS7,
 9381        CSTOPB: bool = false,
 9382        CREAD: bool = false,
 9383        PARENB: bool = false,
 9384        PARODD: bool = false,
 9385        HUPCL: bool = false,
 9386        CLOCAL: bool = false,
 9387        XLOBLK: bool = false,
 9388        CTSFLOW: bool = false,
 9389        RTSFLOW: bool = false,
 9390        _: u17 = 0,
 9391    },
 9392    .illumos => packed struct(u32) {
 9393        _0: u4 = 0,
 9394        CSIZE: CSIZE = .CS5,
 9395        CSTOPB: bool = false,
 9396        CREAD: bool = false,
 9397        PARENB: bool = false,
 9398        PARODD: bool = false,
 9399        HUPCL: bool = false,
 9400        CLOCAL: bool = false,
 9401        RCV1EN: bool = false,
 9402        XMT1EN: bool = false,
 9403        LOBLK: bool = false,
 9404        XCLUDE: bool = false,
 9405        _16: u4 = 0,
 9406        PAREXT: bool = false,
 9407        CBAUDEXT: bool = false,
 9408        CIBAUDEXT: bool = false,
 9409        _23: u7 = 0,
 9410        CRTSXOFF: bool = false,
 9411        CRTSCTS: bool = false,
 9412    },
 9413    .wasi, .emscripten => packed struct(u32) {
 9414        _0: u4 = 0,
 9415        CSIZE: CSIZE = .CS5,
 9416        CSTOPB: bool = false,
 9417        CREAD: bool = false,
 9418        PARENB: bool = false,
 9419        PARODD: bool = false,
 9420        HUPCL: bool = false,
 9421        CLOCAL: bool = false,
 9422        _: u20 = 0,
 9423    },
 9424    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L131-L141
 9425    .serenity => packed struct(u32) {
 9426        _0: u4 = 0,
 9427        CSIZE: CSIZE = .CS5,
 9428        CSTOPB: bool = false,
 9429        CREAD: bool = false,
 9430        PARENB: bool = false,
 9431        PARODD: bool = false,
 9432        HUPCL: bool = false,
 9433        CLOCAL: bool = false,
 9434        CBAUDEX: bool = false,
 9435        _: u19 = 0,
 9436    },
 9437    else => void,
 9438};
 9439
 9440pub const tc_lflag_t = switch (native_os) {
 9441    .linux => linux.tc_lflag_t,
 9442    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => packed struct(u64) {
 9443        ECHOKE: bool = false,
 9444        ECHOE: bool = false,
 9445        ECHOK: bool = false,
 9446        ECHO: bool = false,
 9447        ECHONL: bool = false,
 9448        ECHOPRT: bool = false,
 9449        ECHOCTL: bool = false,
 9450        ISIG: bool = false,
 9451        ICANON: bool = false,
 9452        ALTWERASE: bool = false,
 9453        IEXTEN: bool = false,
 9454        EXTPROC: bool = false,
 9455        _12: u10 = 0,
 9456        TOSTOP: bool = false,
 9457        FLUSHO: bool = false,
 9458        _24: u1 = 0,
 9459        NOKERNINFO: bool = false,
 9460        _26: u3 = 0,
 9461        PENDIN: bool = false,
 9462        _30: u1 = 0,
 9463        NOFLSH: bool = false,
 9464        _: u32 = 0,
 9465    },
 9466    .netbsd, .freebsd, .dragonfly => packed struct(u32) {
 9467        ECHOKE: bool = false,
 9468        ECHOE: bool = false,
 9469        ECHOK: bool = false,
 9470        ECHO: bool = false,
 9471        ECHONL: bool = false,
 9472        ECHOPRT: bool = false,
 9473        ECHOCTL: bool = false,
 9474        ISIG: bool = false,
 9475        ICANON: bool = false,
 9476        ALTWERASE: bool = false,
 9477        IEXTEN: bool = false,
 9478        EXTPROC: bool = false,
 9479        _12: u10 = 0,
 9480        TOSTOP: bool = false,
 9481        FLUSHO: bool = false,
 9482        _24: u1 = 0,
 9483        NOKERNINFO: bool = false,
 9484        _26: u3 = 0,
 9485        PENDIN: bool = false,
 9486        _30: u1 = 0,
 9487        NOFLSH: bool = false,
 9488    },
 9489    .openbsd => packed struct(u32) {
 9490        ECHOKE: bool = false,
 9491        ECHOE: bool = false,
 9492        ECHOK: bool = false,
 9493        ECHO: bool = false,
 9494        ECHONL: bool = false,
 9495        ECHOPRT: bool = false,
 9496        ECHOCTL: bool = false,
 9497        ISIG: bool = false,
 9498        ICANON: bool = false,
 9499        ALTWERASE: bool = false,
 9500        IEXTEN: bool = false,
 9501        EXTPROC: bool = false,
 9502        _12: u10 = 0,
 9503        TOSTOP: bool = false,
 9504        FLUSHO: bool = false,
 9505        XCASE: bool = false,
 9506        NOKERNINFO: bool = false,
 9507        _26: u3 = 0,
 9508        PENDIN: bool = false,
 9509        _30: u1 = 0,
 9510        NOFLSH: bool = false,
 9511    },
 9512    .haiku => packed struct(u32) {
 9513        ISIG: bool = false,
 9514        ICANON: bool = false,
 9515        XCASE: bool = false,
 9516        ECHO: bool = false,
 9517        ECHOE: bool = false,
 9518        ECHOK: bool = false,
 9519        ECHONL: bool = false,
 9520        NOFLSH: bool = false,
 9521        TOSTOP: bool = false,
 9522        IEXTEN: bool = false,
 9523        ECHOCTL: bool = false,
 9524        ECHOPRT: bool = false,
 9525        ECHOKE: bool = false,
 9526        FLUSHO: bool = false,
 9527        PENDIN: bool = false,
 9528        _: u17 = 0,
 9529    },
 9530    .illumos => packed struct(u32) {
 9531        ISIG: bool = false,
 9532        ICANON: bool = false,
 9533        XCASE: bool = false,
 9534        ECHO: bool = false,
 9535        ECHOE: bool = false,
 9536        ECHOK: bool = false,
 9537        ECHONL: bool = false,
 9538        NOFLSH: bool = false,
 9539        TOSTOP: bool = false,
 9540        ECHOCTL: bool = false,
 9541        ECHOPRT: bool = false,
 9542        ECHOKE: bool = false,
 9543        DEFECHO: bool = false,
 9544        FLUSHO: bool = false,
 9545        PENDIN: bool = false,
 9546        IEXTEN: bool = false,
 9547        _: u16 = 0,
 9548    },
 9549    .wasi, .emscripten => packed struct(u32) {
 9550        ISIG: bool = false,
 9551        ICANON: bool = false,
 9552        _2: u1 = 0,
 9553        ECHO: bool = false,
 9554        ECHOE: bool = false,
 9555        ECHOK: bool = false,
 9556        ECHONL: bool = false,
 9557        NOFLSH: bool = false,
 9558        TOSTOP: bool = false,
 9559        _9: u6 = 0,
 9560        IEXTEN: bool = false,
 9561        _: u16 = 0,
 9562    },
 9563    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L168-L189
 9564    .serenity => packed struct(u32) {
 9565        ISIG: bool = false,
 9566        ICANON: bool = false,
 9567        XCASE: bool = false,
 9568        ECHO: bool = false,
 9569        ECHOE: bool = false,
 9570        ECHOK: bool = false,
 9571        ECHONL: bool = false,
 9572        NOFLSH: bool = false,
 9573        TOSTOP: bool = false,
 9574        ECHOCTL: bool = false,
 9575        ECHOPRT: bool = false,
 9576        ECHOKE: bool = false,
 9577        FLUSHO: bool = false,
 9578        PENDIN: bool = false,
 9579        _14: u6 = 0,
 9580        IEXTEN: bool = false,
 9581        EXTPROC: bool = false,
 9582        _: u15 = 0,
 9583    },
 9584    else => void,
 9585};
 9586
 9587pub const speed_t = switch (native_os) {
 9588    .linux => linux.speed_t,
 9589    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .openbsd => enum(u64) {
 9590        B0 = 0,
 9591        B50 = 50,
 9592        B75 = 75,
 9593        B110 = 110,
 9594        B134 = 134,
 9595        B150 = 150,
 9596        B200 = 200,
 9597        B300 = 300,
 9598        B600 = 600,
 9599        B1200 = 1200,
 9600        B1800 = 1800,
 9601        B2400 = 2400,
 9602        B4800 = 4800,
 9603        B9600 = 9600,
 9604        B19200 = 19200,
 9605        B38400 = 38400,
 9606        B7200 = 7200,
 9607        B14400 = 14400,
 9608        B28800 = 28800,
 9609        B57600 = 57600,
 9610        B76800 = 76800,
 9611        B115200 = 115200,
 9612        B230400 = 230400,
 9613    },
 9614    .freebsd, .netbsd => enum(c_uint) {
 9615        B0 = 0,
 9616        B50 = 50,
 9617        B75 = 75,
 9618        B110 = 110,
 9619        B134 = 134,
 9620        B150 = 150,
 9621        B200 = 200,
 9622        B300 = 300,
 9623        B600 = 600,
 9624        B1200 = 1200,
 9625        B1800 = 1800,
 9626        B2400 = 2400,
 9627        B4800 = 4800,
 9628        B9600 = 9600,
 9629        B19200 = 19200,
 9630        B38400 = 38400,
 9631        B7200 = 7200,
 9632        B14400 = 14400,
 9633        B28800 = 28800,
 9634        B57600 = 57600,
 9635        B76800 = 76800,
 9636        B115200 = 115200,
 9637        B230400 = 230400,
 9638        B460800 = 460800,
 9639        B500000 = 500000,
 9640        B921600 = 921600,
 9641        B1000000 = 1000000,
 9642        B1500000 = 1500000,
 9643        B2000000 = 2000000,
 9644        B2500000 = 2500000,
 9645        B3000000 = 3000000,
 9646        B3500000 = 3500000,
 9647        B4000000 = 4000000,
 9648    },
 9649    .dragonfly => enum(c_uint) {
 9650        B0 = 0,
 9651        B50 = 50,
 9652        B75 = 75,
 9653        B110 = 110,
 9654        B134 = 134,
 9655        B150 = 150,
 9656        B200 = 200,
 9657        B300 = 300,
 9658        B600 = 600,
 9659        B1200 = 1200,
 9660        B1800 = 1800,
 9661        B2400 = 2400,
 9662        B4800 = 4800,
 9663        B9600 = 9600,
 9664        B19200 = 19200,
 9665        B38400 = 38400,
 9666        B7200 = 7200,
 9667        B14400 = 14400,
 9668        B28800 = 28800,
 9669        B57600 = 57600,
 9670        B76800 = 76800,
 9671        B115200 = 115200,
 9672        B230400 = 230400,
 9673        B460800 = 460800,
 9674        B921600 = 921600,
 9675    },
 9676    .haiku => enum(u8) {
 9677        B0 = 0x00,
 9678        B50 = 0x01,
 9679        B75 = 0x02,
 9680        B110 = 0x03,
 9681        B134 = 0x04,
 9682        B150 = 0x05,
 9683        B200 = 0x06,
 9684        B300 = 0x07,
 9685        B600 = 0x08,
 9686        B1200 = 0x09,
 9687        B1800 = 0x0A,
 9688        B2400 = 0x0B,
 9689        B4800 = 0x0C,
 9690        B9600 = 0x0D,
 9691        B19200 = 0x0E,
 9692        B38400 = 0x0F,
 9693        B57600 = 0x10,
 9694        B115200 = 0x11,
 9695        B230400 = 0x12,
 9696        B31250 = 0x13,
 9697    },
 9698    .illumos => enum(c_uint) {
 9699        B0 = 0,
 9700        B50 = 1,
 9701        B75 = 2,
 9702        B110 = 3,
 9703        B134 = 4,
 9704        B150 = 5,
 9705        B200 = 6,
 9706        B300 = 7,
 9707        B600 = 8,
 9708        B1200 = 9,
 9709        B1800 = 10,
 9710        B2400 = 11,
 9711        B4800 = 12,
 9712        B9600 = 13,
 9713        B19200 = 14,
 9714        B38400 = 15,
 9715        B57600 = 16,
 9716        B76800 = 17,
 9717        B115200 = 18,
 9718        B153600 = 19,
 9719        B230400 = 20,
 9720        B307200 = 21,
 9721        B460800 = 22,
 9722        B921600 = 23,
 9723        B1000000 = 24,
 9724        B1152000 = 25,
 9725        B1500000 = 26,
 9726        B2000000 = 27,
 9727        B2500000 = 28,
 9728        B3000000 = 29,
 9729        B3500000 = 30,
 9730        B4000000 = 31,
 9731    },
 9732    // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L111-L159
 9733    .emscripten, .wasi, .serenity => enum(u32) {
 9734        B0 = 0o0000000,
 9735        B50 = 0o0000001,
 9736        B75 = 0o0000002,
 9737        B110 = 0o0000003,
 9738        B134 = 0o0000004,
 9739        B150 = 0o0000005,
 9740        B200 = 0o0000006,
 9741        B300 = 0o0000007,
 9742        B600 = 0o0000010,
 9743        B1200 = 0o0000011,
 9744        B1800 = 0o0000012,
 9745        B2400 = 0o0000013,
 9746        B4800 = 0o0000014,
 9747        B9600 = 0o0000015,
 9748        B19200 = 0o0000016,
 9749        B38400 = 0o0000017,
 9750
 9751        B57600 = 0o0010001,
 9752        B115200 = 0o0010002,
 9753        B230400 = 0o0010003,
 9754        B460800 = 0o0010004,
 9755        B500000 = 0o0010005,
 9756        B576000 = 0o0010006,
 9757        B921600 = 0o0010007,
 9758        B1000000 = 0o0010010,
 9759        B1152000 = 0o0010011,
 9760        B1500000 = 0o0010012,
 9761        B2000000 = 0o0010013,
 9762        B2500000 = 0o0010014,
 9763        B3000000 = 0o0010015,
 9764        B3500000 = 0o0010016,
 9765        B4000000 = 0o0010017,
 9766    },
 9767    else => void,
 9768};
 9769
 9770pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;
 9771
 9772pub const sig_atomic_t = switch (native_os) {
 9773    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L20
 9774    .serenity => u32,
 9775    else => c_int,
 9776};
 9777
 9778/// maximum signal number + 1
 9779pub const NSIG = switch (native_os) {
 9780    .linux => linux.NSIG,
 9781    .windows => 23,
 9782    .haiku => 65,
 9783    .netbsd, .freebsd => 32,
 9784    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.NSIG,
 9785    .illumos => 75,
 9786    // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h#L42
 9787    .openbsd, .serenity => 33,
 9788    else => {},
 9789};
 9790
 9791pub const MINSIGSTKSZ = switch (native_os) {
 9792    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 32768,
 9793    .freebsd => switch (builtin.cpu.arch) {
 9794        .powerpc64, .powerpc64le, .x86, .x86_64 => 2048,
 9795        .arm, .aarch64, .riscv64 => 4096,
 9796        else => @compileError("unsupported arch"),
 9797    },
 9798    .illumos => 2048,
 9799    .haiku, .netbsd => 8192,
 9800    .openbsd => 1 << openbsd.MAX_PAGE_SHIFT,
 9801    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L58
 9802    .serenity => 4096,
 9803    else => {},
 9804};
 9805pub const SIGSTKSZ = switch (native_os) {
 9806    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 131072,
 9807    .netbsd, .freebsd => MINSIGSTKSZ + 32768,
 9808    .illumos => 8192,
 9809    .haiku => 16384,
 9810    .openbsd => MINSIGSTKSZ + (1 << openbsd.MAX_PAGE_SHIFT) * 4,
 9811    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L59
 9812    .serenity => 32768,
 9813    else => {},
 9814};
 9815pub const SS = switch (native_os) {
 9816    .linux => linux.SS,
 9817    .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .netbsd, .freebsd => struct {
 9818        pub const ONSTACK = 1;
 9819        pub const DISABLE = 4;
 9820    },
 9821    // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L54-L55
 9822    .haiku, .illumos, .serenity => struct {
 9823        pub const ONSTACK = 0x1;
 9824        pub const DISABLE = 0x2;
 9825    },
 9826    else => void,
 9827};
 9828
 9829pub const EV = switch (native_os) {
 9830    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 9831        /// add event to kq (implies enable)
 9832        pub const ADD = 0x0001;
 9833        /// delete event from kq
 9834        pub const DELETE = 0x0002;
 9835        /// enable event
 9836        pub const ENABLE = 0x0004;
 9837        /// disable event (not reported)
 9838        pub const DISABLE = 0x0008;
 9839        /// only report one occurrence
 9840        pub const ONESHOT = 0x0010;
 9841        /// clear event state after reporting
 9842        pub const CLEAR = 0x0020;
 9843        /// force immediate event output
 9844        /// ... with or without ERROR
 9845        /// ... use KEVENT_FLAG_ERROR_EVENTS
 9846        ///     on syscalls supporting flags
 9847        pub const RECEIPT = 0x0040;
 9848        /// disable event after reporting
 9849        pub const DISPATCH = 0x0080;
 9850        /// unique kevent per udata value
 9851        pub const UDATA_SPECIFIC = 0x0100;
 9852        /// ... in combination with DELETE
 9853        /// will defer delete until udata-specific
 9854        /// event enabled. EINPROGRESS will be
 9855        /// returned to indicate the deferral
 9856        pub const DISPATCH2 = DISPATCH | UDATA_SPECIFIC;
 9857        /// report that source has vanished
 9858        /// ... only valid with DISPATCH2
 9859        pub const VANISHED = 0x0200;
 9860        /// reserved by system
 9861        pub const SYSFLAGS = 0xF000;
 9862        /// filter-specific flag
 9863        pub const FLAG0 = 0x1000;
 9864        /// filter-specific flag
 9865        pub const FLAG1 = 0x2000;
 9866        /// EOF detected
 9867        pub const EOF = 0x8000;
 9868        /// error, data contains errno
 9869        pub const ERROR = 0x4000;
 9870        pub const POLL = FLAG0;
 9871        pub const OOBAND = FLAG1;
 9872    },
 9873    .dragonfly => struct {
 9874        pub const ADD = 1;
 9875        pub const DELETE = 2;
 9876        pub const ENABLE = 4;
 9877        pub const DISABLE = 8;
 9878        pub const ONESHOT = 16;
 9879        pub const CLEAR = 32;
 9880        pub const RECEIPT = 64;
 9881        pub const DISPATCH = 128;
 9882        pub const NODATA = 4096;
 9883        pub const FLAG1 = 8192;
 9884        pub const ERROR = 16384;
 9885        pub const EOF = 32768;
 9886        pub const SYSFLAGS = 61440;
 9887    },
 9888    .netbsd => struct {
 9889        /// add event to kq (implies enable)
 9890        pub const ADD = 0x0001;
 9891        /// delete event from kq
 9892        pub const DELETE = 0x0002;
 9893        /// enable event
 9894        pub const ENABLE = 0x0004;
 9895        /// disable event (not reported)
 9896        pub const DISABLE = 0x0008;
 9897        /// only report one occurrence
 9898        pub const ONESHOT = 0x0010;
 9899        /// clear event state after reporting
 9900        pub const CLEAR = 0x0020;
 9901        /// force immediate event output
 9902        /// ... with or without ERROR
 9903        /// ... use KEVENT_FLAG_ERROR_EVENTS
 9904        ///     on syscalls supporting flags
 9905        pub const RECEIPT = 0x0040;
 9906        /// disable event after reporting
 9907        pub const DISPATCH = 0x0080;
 9908    },
 9909    .freebsd => struct {
 9910        /// add event to kq (implies enable)
 9911        pub const ADD = 0x0001;
 9912        /// delete event from kq
 9913        pub const DELETE = 0x0002;
 9914        /// enable event
 9915        pub const ENABLE = 0x0004;
 9916        /// disable event (not reported)
 9917        pub const DISABLE = 0x0008;
 9918        /// only report one occurrence
 9919        pub const ONESHOT = 0x0010;
 9920        /// clear event state after reporting
 9921        pub const CLEAR = 0x0020;
 9922        /// error, event data contains errno
 9923        pub const ERROR = 0x4000;
 9924        /// force immediate event output
 9925        /// ... with or without ERROR
 9926        /// ... use KEVENT_FLAG_ERROR_EVENTS
 9927        ///     on syscalls supporting flags
 9928        pub const RECEIPT = 0x0040;
 9929        /// disable event after reporting
 9930        pub const DISPATCH = 0x0080;
 9931    },
 9932    .openbsd => struct {
 9933        pub const ADD = 0x0001;
 9934        pub const DELETE = 0x0002;
 9935        pub const ENABLE = 0x0004;
 9936        pub const DISABLE = 0x0008;
 9937        pub const ONESHOT = 0x0010;
 9938        pub const CLEAR = 0x0020;
 9939        pub const RECEIPT = 0x0040;
 9940        pub const DISPATCH = 0x0080;
 9941        pub const FLAG1 = 0x2000;
 9942        pub const ERROR = 0x4000;
 9943        pub const EOF = 0x8000;
 9944    },
 9945    .haiku => struct {
 9946        /// add event to kq (implies enable)
 9947        pub const ADD = 0x0001;
 9948        /// delete event from kq
 9949        pub const DELETE = 0x0002;
 9950        /// enable event
 9951        pub const ENABLE = 0x0004;
 9952        /// disable event (not reported)
 9953        pub const DISABLE = 0x0008;
 9954        /// only report one occurrence
 9955        pub const ONESHOT = 0x0010;
 9956        /// clear event state after reporting
 9957        pub const CLEAR = 0x0020;
 9958        /// force immediate event output
 9959        /// ... with or without ERROR
 9960        /// ... use KEVENT_FLAG_ERROR_EVENTS
 9961        ///     on syscalls supporting flags
 9962        pub const RECEIPT = 0x0040;
 9963        /// disable event after reporting
 9964        pub const DISPATCH = 0x0080;
 9965    },
 9966    else => void,
 9967};
 9968
 9969pub const EVFILT = switch (native_os) {
 9970    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
 9971        pub const READ = -1;
 9972        pub const WRITE = -2;
 9973        /// attached to aio requests
 9974        pub const AIO = -3;
 9975        /// attached to vnodes
 9976        pub const VNODE = -4;
 9977        /// attached to struct proc
 9978        pub const PROC = -5;
 9979        /// attached to struct proc
 9980        pub const SIGNAL = -6;
 9981        /// timers
 9982        pub const TIMER = -7;
 9983        /// Mach portsets
 9984        pub const MACHPORT = -8;
 9985        /// Filesystem events
 9986        pub const FS = -9;
 9987        /// User events
 9988        pub const USER = -10;
 9989        /// Virtual memory events
 9990        pub const VM = -12;
 9991        /// Exception events
 9992        pub const EXCEPT = -15;
 9993        pub const SYSCOUNT = 17;
 9994    },
 9995    .haiku => struct {
 9996        pub const READ = -1;
 9997        pub const WRITE = -2;
 9998        /// attached to aio requests
 9999        pub const AIO = -3;
10000        /// attached to vnodes
10001        pub const VNODE = -4;
10002        /// attached to struct proc
10003        pub const PROC = -5;
10004        /// attached to struct proc
10005        pub const SIGNAL = -6;
10006        /// timers
10007        pub const TIMER = -7;
10008        /// Process descriptors
10009        pub const PROCDESC = -8;
10010        /// Filesystem events
10011        pub const FS = -9;
10012        pub const LIO = -10;
10013        /// User events
10014        pub const USER = -11;
10015        /// Sendfile events
10016        pub const SENDFILE = -12;
10017        pub const EMPTY = -13;
10018    },
10019    .dragonfly => struct {
10020        pub const FS = -10;
10021        pub const USER = -9;
10022        pub const EXCEPT = -8;
10023        pub const TIMER = -7;
10024        pub const SIGNAL = -6;
10025        pub const PROC = -5;
10026        pub const VNODE = -4;
10027        pub const AIO = -3;
10028        pub const WRITE = -2;
10029        pub const READ = -1;
10030        pub const SYSCOUNT = 10;
10031        pub const MARKER = 15;
10032    },
10033    .netbsd => struct {
10034        pub const READ = 0;
10035        pub const WRITE = 1;
10036        /// attached to aio requests
10037        pub const AIO = 2;
10038        /// attached to vnodes
10039        pub const VNODE = 3;
10040        /// attached to struct proc
10041        pub const PROC = 4;
10042        /// attached to struct proc
10043        pub const SIGNAL = 5;
10044        /// timers
10045        pub const TIMER = 6;
10046        /// Filesystem events
10047        pub const FS = 7;
10048        /// User events
10049        pub const USER = 8;
10050        /// Empty filter
10051        pub const EMPTY = 9;
10052    },
10053    .freebsd => struct {
10054        pub const READ = -1;
10055        pub const WRITE = -2;
10056        /// attached to aio requests
10057        pub const AIO = -3;
10058        /// attached to vnodes
10059        pub const VNODE = -4;
10060        /// attached to struct proc
10061        pub const PROC = -5;
10062        /// attached to struct proc
10063        pub const SIGNAL = -6;
10064        /// timers
10065        pub const TIMER = -7;
10066        /// Process descriptors
10067        pub const PROCDESC = -8;
10068        /// Filesystem events
10069        pub const FS = -9;
10070        pub const LIO = -10;
10071        /// User events
10072        pub const USER = -11;
10073        /// Sendfile events
10074        pub const SENDFILE = -12;
10075        pub const EMPTY = -13;
10076    },
10077    .openbsd => struct {
10078        pub const READ = -1;
10079        pub const WRITE = -2;
10080        pub const AIO = -3;
10081        pub const VNODE = -4;
10082        pub const PROC = -5;
10083        pub const SIGNAL = -6;
10084        pub const TIMER = -7;
10085        pub const DEVICE = -8;
10086        pub const EXCEPT = -9;
10087        pub const USER = -10;
10088    },
10089    else => void,
10090};
10091
10092pub const NOTE = switch (native_os) {
10093    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
10094        /// On input, TRIGGER causes the event to be triggered for output.
10095        pub const TRIGGER = 0x01000000;
10096        /// ignore input fflags
10097        pub const FFNOP = 0x00000000;
10098        /// and fflags
10099        pub const FFAND = 0x40000000;
10100        /// or fflags
10101        pub const FFOR = 0x80000000;
10102        /// copy fflags
10103        pub const FFCOPY = 0xc0000000;
10104        /// mask for operations
10105        pub const FFCTRLMASK = 0xc0000000;
10106        pub const FFLAGSMASK = 0x00ffffff;
10107        /// low water mark
10108        pub const LOWAT = 0x00000001;
10109        /// OOB data
10110        pub const OOB = 0x00000002;
10111        /// vnode was removed
10112        pub const DELETE = 0x00000001;
10113        /// data contents changed
10114        pub const WRITE = 0x00000002;
10115        /// size increased
10116        pub const EXTEND = 0x00000004;
10117        /// attributes changed
10118        pub const ATTRIB = 0x00000008;
10119        /// link count changed
10120        pub const LINK = 0x00000010;
10121        /// vnode was renamed
10122        pub const RENAME = 0x00000020;
10123        /// vnode access was revoked
10124        pub const REVOKE = 0x00000040;
10125        /// No specific vnode event: to test for EVFILT_READ      activation
10126        pub const NONE = 0x00000080;
10127        /// vnode was unlocked by flock(2)
10128        pub const FUNLOCK = 0x00000100;
10129        /// process exited
10130        pub const EXIT = 0x80000000;
10131        /// process forked
10132        pub const FORK = 0x40000000;
10133        /// process exec'd
10134        pub const EXEC = 0x20000000;
10135        /// shared with EVFILT_SIGNAL
10136        pub const SIGNAL = 0x08000000;
10137        /// exit status to be returned, valid for child       process only
10138        pub const EXITSTATUS = 0x04000000;
10139        /// provide details on reasons for exit
10140        pub const EXIT_DETAIL = 0x02000000;
10141        /// mask for signal & exit status
10142        pub const PDATAMASK = 0x000fffff;
10143        pub const PCTRLMASK = 0xf0000000;
10144        pub const EXIT_DETAIL_MASK = 0x00070000;
10145        pub const EXIT_DECRYPTFAIL = 0x00010000;
10146        pub const EXIT_MEMORY = 0x00020000;
10147        pub const EXIT_CSERROR = 0x00040000;
10148        /// will react on memory          pressure
10149        pub const VM_PRESSURE = 0x80000000;
10150        /// will quit on memory       pressure, possibly after cleaning up dirty state
10151        pub const VM_PRESSURE_TERMINATE = 0x40000000;
10152        /// will quit immediately on      memory pressure
10153        pub const VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
10154        /// there was an error
10155        pub const VM_ERROR = 0x10000000;
10156        /// data is seconds
10157        pub const SECONDS = 0x00000001;
10158        /// data is microseconds
10159        pub const USECONDS = 0x00000002;
10160        /// data is nanoseconds
10161        pub const NSECONDS = 0x00000004;
10162        /// absolute timeout
10163        pub const ABSOLUTE = 0x00000008;
10164        /// ext[1] holds leeway for power aware timers
10165        pub const LEEWAY = 0x00000010;
10166        /// system does minimal timer coalescing
10167        pub const CRITICAL = 0x00000020;
10168        /// system does maximum timer coalescing
10169        pub const BACKGROUND = 0x00000040;
10170        pub const MACH_CONTINUOUS_TIME = 0x00000080;
10171        /// data is mach absolute time units
10172        pub const MACHTIME = 0x00000100;
10173    },
10174    .dragonfly => struct {
10175        pub const FFNOP = 0;
10176        pub const TRACK = 1;
10177        pub const DELETE = 1;
10178        pub const LOWAT = 1;
10179        pub const TRACKERR = 2;
10180        pub const OOB = 2;
10181        pub const WRITE = 2;
10182        pub const EXTEND = 4;
10183        pub const CHILD = 4;
10184        pub const ATTRIB = 8;
10185        pub const LINK = 16;
10186        pub const RENAME = 32;
10187        pub const REVOKE = 64;
10188        pub const PDATAMASK = 1048575;
10189        pub const FFLAGSMASK = 16777215;
10190        pub const TRIGGER = 16777216;
10191        pub const EXEC = 536870912;
10192        pub const FFAND = 1073741824;
10193        pub const FORK = 1073741824;
10194        pub const EXIT = 2147483648;
10195        pub const FFOR = 2147483648;
10196        pub const FFCTRLMASK = 3221225472;
10197        pub const FFCOPY = 3221225472;
10198        pub const PCTRLMASK = 4026531840;
10199    },
10200    .netbsd => struct {
10201        /// ignore input fflags
10202        pub const FFNOP = 0x00000000;
10203        /// AND fflags
10204        pub const FFAND = 0x40000000;
10205        /// OR fflags
10206        pub const FFOR = 0x80000000;
10207        /// copy fflags
10208        pub const FFCOPY = 0xc0000000;
10209        /// masks for operations
10210        pub const FFCTRLMASK = 0xc0000000;
10211        pub const FFLAGSMASK = 0x00ffffff;
10212        /// On input, TRIGGER causes the event to be triggered for output.
10213        pub const TRIGGER = 0x01000000;
10214        /// low water mark
10215        pub const LOWAT = 0x00000001;
10216        /// vnode was removed
10217        pub const DELETE = 0x00000001;
10218        /// data contents changed
10219        pub const WRITE = 0x00000002;
10220        /// size increased
10221        pub const EXTEND = 0x00000004;
10222        /// attributes changed
10223        pub const ATTRIB = 0x00000008;
10224        /// link count changed
10225        pub const LINK = 0x00000010;
10226        /// vnode was renamed
10227        pub const RENAME = 0x00000020;
10228        /// vnode access was revoked
10229        pub const REVOKE = 0x00000040;
10230        /// vnode was opened
10231        pub const OPEN = 0x00000080;
10232        /// file closed (no FWRITE)
10233        pub const CLOSE = 0x00000100;
10234        /// file closed (FWRITE)
10235        pub const CLOSE_WRITE = 0x00000200;
10236        /// file was read
10237        pub const READ = 0x00000400;
10238        /// process exited
10239        pub const EXIT = 0x80000000;
10240        /// process forked
10241        pub const FORK = 0x40000000;
10242        /// process exec'd
10243        pub const EXEC = 0x20000000;
10244        /// mask for signal & exit status
10245        pub const PDATAMASK = 0x000fffff;
10246        pub const PCTRLMASK = 0xf0000000;
10247        /// follow across forks
10248        pub const TRACK = 0x00000001;
10249        /// could not track child
10250        pub const TRACKERR = 0x00000002;
10251        /// am a child process
10252        pub const CHILD = 0x00000004;
10253        /// shared with EVFILT_SIGNAL
10254        pub const SIGNAL = 0x08000000;
10255        /// data is milliseconds
10256        pub const MSECONDS = 0x00000000;
10257        /// data is seconds
10258        pub const SECONDS = 0x00000001;
10259        /// data is microseconds
10260        pub const USECONDS = 0x00000002;
10261        /// data is nanoseconds
10262        pub const NSECONDS = 0x00000003;
10263        /// timeout is absolute
10264        pub const ABSTIME = 0x00000010;
10265    },
10266    .freebsd => struct {
10267        /// On input, TRIGGER causes the event to be triggered for output.
10268        pub const TRIGGER = 0x01000000;
10269        /// ignore input fflags
10270        pub const FFNOP = 0x00000000;
10271        /// and fflags
10272        pub const FFAND = 0x40000000;
10273        /// or fflags
10274        pub const FFOR = 0x80000000;
10275        /// copy fflags
10276        pub const FFCOPY = 0xc0000000;
10277        /// mask for operations
10278        pub const FFCTRLMASK = 0xc0000000;
10279        pub const FFLAGSMASK = 0x00ffffff;
10280        /// low water mark
10281        pub const LOWAT = 0x00000001;
10282        /// behave like poll()
10283        pub const FILE_POLL = 0x00000002;
10284        /// vnode was removed
10285        pub const DELETE = 0x00000001;
10286        /// data contents changed
10287        pub const WRITE = 0x00000002;
10288        /// size increased
10289        pub const EXTEND = 0x00000004;
10290        /// attributes changed
10291        pub const ATTRIB = 0x00000008;
10292        /// link count changed
10293        pub const LINK = 0x00000010;
10294        /// vnode was renamed
10295        pub const RENAME = 0x00000020;
10296        /// vnode access was revoked
10297        pub const REVOKE = 0x00000040;
10298        /// vnode was opened
10299        pub const OPEN = 0x00000080;
10300        /// file closed, fd did not allow write
10301        pub const CLOSE = 0x00000100;
10302        /// file closed, fd did allow write
10303        pub const CLOSE_WRITE = 0x00000200;
10304        /// file was read
10305        pub const READ = 0x00000400;
10306        /// process exited
10307        pub const EXIT = 0x80000000;
10308        /// process forked
10309        pub const FORK = 0x40000000;
10310        /// process exec'd
10311        pub const EXEC = 0x20000000;
10312        /// mask for signal & exit status
10313        pub const PDATAMASK = 0x000fffff;
10314        pub const PCTRLMASK = 0xf0000000;
10315        /// data is seconds
10316        pub const SECONDS = 0x00000001;
10317        /// data is milliseconds
10318        pub const MSECONDS = 0x00000002;
10319        /// data is microseconds
10320        pub const USECONDS = 0x00000004;
10321        /// data is nanoseconds
10322        pub const NSECONDS = 0x00000008;
10323        /// timeout is absolute
10324        pub const ABSTIME = 0x00000010;
10325    },
10326    .openbsd => struct {
10327        // data/hint flags for EVFILT.{READ|WRITE}
10328        pub const LOWAT = 0x0001;
10329        pub const EOF = 0x0002;
10330        // data/hint flags for EVFILT.EXCEPT and EVFILT.{READ|WRITE}
10331        pub const OOB = 0x0004;
10332        // data/hint flags for EVFILT.VNODE
10333        pub const DELETE = 0x0001;
10334        pub const WRITE = 0x0002;
10335        pub const EXTEND = 0x0004;
10336        pub const ATTRIB = 0x0008;
10337        pub const LINK = 0x0010;
10338        pub const RENAME = 0x0020;
10339        pub const REVOKE = 0x0040;
10340        pub const TRUNCATE = 0x0080;
10341        // data/hint flags for EVFILT.PROC
10342        pub const EXIT = 0x80000000;
10343        pub const FORK = 0x40000000;
10344        pub const EXEC = 0x20000000;
10345        pub const PDATAMASK = 0x000fffff;
10346        pub const PCTRLMASK = 0xf0000000;
10347        pub const TRACK = 0x00000001;
10348        pub const TRACKERR = 0x00000002;
10349        pub const CHILD = 0x00000004;
10350        // data/hint flags for EVFILT.DEVICE
10351        pub const CHANGE = 0x00000001;
10352        // data/hint flags for EVFILT_USER
10353        pub const FFNOP = 0x00000000;
10354        pub const FFAND = 0x40000000;
10355        pub const FFOR = 0x80000000;
10356        pub const FFCOPY = 0xc0000000;
10357        pub const FFCTRLMASK = 0xc0000000;
10358        pub const FFLAGSMASK = 0x00ffffff;
10359        pub const TRIGGER = 0x01000000;
10360    },
10361    else => void,
10362};
10363
10364pub const FUTEX = switch (native_os) {
10365    .openbsd => openbsd.FUTEX,
10366    .serenity => serenity.FUTEX,
10367    else => void,
10368};
10369
10370// Unix-like systems
10371pub const DIR = opaque {};
10372pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR;
10373pub extern "c" fn fdopendir(fd: c_int) ?*DIR;
10374pub extern "c" fn rewinddir(dp: *DIR) void;
10375pub extern "c" fn closedir(dp: *DIR) c_int;
10376pub extern "c" fn telldir(dp: *DIR) c_long;
10377pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;
10378
10379pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
10380
10381pub extern "c" fn alarm(seconds: c_uint) c_uint;
10382
10383pub const close = switch (native_os) {
10384    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.@"close$NOCANCEL",
10385    else => private.close,
10386};
10387
10388pub const clock_getres = switch (native_os) {
10389    .netbsd => private.__clock_getres50,
10390    else => private.clock_getres,
10391};
10392
10393pub const clock_gettime = switch (native_os) {
10394    .netbsd => private.__clock_gettime50,
10395    else => private.clock_gettime,
10396};
10397
10398pub const fstat = switch (native_os) {
10399    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) {
10400        .x86_64 => private.@"fstat$INODE64",
10401        else => private.fstat,
10402    },
10403    .netbsd => private.__fstat50,
10404    else => private.fstat,
10405};
10406
10407pub const fstatat = switch (native_os) {
10408    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) {
10409        .x86_64 => private.@"fstatat$INODE64",
10410        else => private.fstatat,
10411    },
10412    else => private.fstatat,
10413};
10414pub extern "c" fn getpwent() ?*passwd;
10415pub extern "c" fn endpwent() void;
10416pub extern "c" fn setpwent() void;
10417pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd;
10418pub extern "c" fn getpwnam_r(name: [*:0]const u8, pwd: *passwd, buf: [*]u8, buflen: usize, result: *?*passwd) c_int;
10419pub extern "c" fn getpwuid(uid: uid_t) ?*passwd;
10420pub extern "c" fn getpwuid_r(uid: uid_t, pwd: *passwd, buf: [*]u8, buflen: usize, result: *?*passwd) c_int;
10421pub extern "c" fn getgrent() ?*group;
10422pub extern "c" fn setgrent() void;
10423pub extern "c" fn endgrent() void;
10424pub extern "c" fn getgrnam(name: [*:0]const u8) ?*passwd;
10425pub extern "c" fn getgrnam_r(name: [*:0]const u8, grp: *group, buf: [*]u8, buflen: usize, result: *?*group) c_int;
10426pub extern "c" fn getgrgid(gid: gid_t) ?*group;
10427pub extern "c" fn getgrgid_r(gid: gid_t, grp: *group, buf: [*]u8, buflen: usize, result: *?*group) c_int;
10428pub extern "c" fn getrlimit64(resource: rlimit_resource, rlim: *rlimit) c_int;
10429pub extern "c" fn lseek64(fd: fd_t, offset: i64, whence: c_int) i64;
10430pub extern "c" fn mmap64(addr: ?*align(page_size) anyopaque, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: i64) *anyopaque;
10431pub extern "c" fn open64(path: [*:0]const u8, oflag: O, ...) c_int;
10432pub extern "c" fn openat64(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int;
10433pub extern "c" fn pread64(fd: fd_t, buf: [*]u8, nbyte: usize, offset: i64) isize;
10434pub extern "c" fn preadv64(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: i64) isize;
10435pub extern "c" fn pwrite64(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: i64) isize;
10436pub extern "c" fn pwritev64(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: i64) isize;
10437pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: usize) isize;
10438pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int;
10439
10440pub const arc4random_buf = switch (native_os) {
10441    .linux => if (builtin.abi.isAndroid()) private.arc4random_buf else {},
10442    .dragonfly, .netbsd, .freebsd, .illumos, .openbsd, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.arc4random_buf,
10443    else => {},
10444};
10445pub const getentropy = switch (native_os) {
10446    .linux => if (builtin.abi.isAndroid() and versionCheck(.{ .major = 28, .minor = 0, .patch = 0 })) private.getentropy else {},
10447    .emscripten => private.getentropy,
10448    else => {},
10449};
10450pub const getrandom = switch (native_os) {
10451    .freebsd => private.getrandom,
10452    .linux => if (builtin.abi.isMusl() or
10453        (builtin.abi.isGnu() and versionCheck(.{ .major = 2, .minor = 25, .patch = 0 })) or
10454        (builtin.abi.isAndroid() and versionCheck(.{ .major = 28, .minor = 0, .patch = 0 })))
10455        private.getrandom
10456    else {},
10457    else => {},
10458};
10459
10460pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int;
10461pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int;
10462
10463pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int;
10464pub extern "c" fn epoll_create1(flags: c_uint) c_int;
10465pub extern "c" fn epoll_wait(epfd: fd_t, events: [*]epoll_event, maxevents: c_uint, timeout: c_int) c_int;
10466pub extern "c" fn epoll_pwait(
10467    epfd: fd_t,
10468    events: [*]epoll_event,
10469    maxevents: c_int,
10470    timeout: c_int,
10471    sigmask: *const sigset_t,
10472) c_int;
10473
10474pub extern "c" fn timerfd_create(clockid: timerfd_clockid_t, flags: c_int) c_int;
10475pub extern "c" fn timerfd_settime(
10476    fd: c_int,
10477    flags: c_int,
10478    new_value: *const itimerspec,
10479    old_value: ?*itimerspec,
10480) c_int;
10481pub extern "c" fn timerfd_gettime(fd: c_int, curr_value: *itimerspec) c_int;
10482
10483pub extern "c" fn inotify_init1(flags: c_uint) c_int;
10484pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) c_int;
10485pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int;
10486
10487pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int;
10488pub extern "c" fn fstatat64(dirfd: fd_t, noalias path: [*:0]const u8, noalias stat_buf: *Stat, flags: u32) c_int;
10489pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int;
10490pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
10491pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int;
10492pub extern "c" fn fallocate(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int;
10493pub const sendfile = switch (native_os) {
10494    .freebsd => freebsd.sendfile,
10495    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.sendfile,
10496    .linux => private.sendfile,
10497    else => {},
10498};
10499/// See std.elf for constants for this
10500pub extern "c" fn getauxval(__type: c_ulong) c_ulong;
10501
10502pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int;
10503
10504pub const sigaltstack = switch (native_os) {
10505    .netbsd => private.__sigaltstack14,
10506    else => private.sigaltstack,
10507};
10508
10509pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int;
10510pub const pipe2 = switch (native_os) {
10511    .dragonfly, .emscripten, .netbsd, .freebsd, .illumos, .openbsd, .linux, .serenity => private.pipe2,
10512    else => {},
10513};
10514pub const copy_file_range = switch (native_os) {
10515    .linux => private.copy_file_range,
10516    .freebsd => freebsd.copy_file_range,
10517    else => {},
10518};
10519
10520pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int;
10521
10522pub extern "c" fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: *const rlimit, old_limit: *rlimit) c_int;
10523pub extern "c" fn mincore(
10524    addr: *align(page_size) anyopaque,
10525    length: usize,
10526    vec: [*]u8,
10527) c_int;
10528
10529pub extern "c" fn madvise(
10530    addr: *align(page_size) anyopaque,
10531    length: usize,
10532    advice: u32,
10533) c_int;
10534
10535pub const getdirentries = switch (native_os) {
10536    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.__getdirentries64,
10537    else => private.getdirentries,
10538};
10539
10540pub const getdents = switch (native_os) {
10541    .netbsd => private.__getdents30,
10542    else => private.getdents,
10543};
10544
10545pub const getrusage = switch (native_os) {
10546    .netbsd => private.__getrusage50,
10547    else => private.getrusage,
10548};
10549
10550pub const gettimeofday = switch (native_os) {
10551    .netbsd => private.__gettimeofday50,
10552    else => private.gettimeofday,
10553};
10554
10555pub const mlock = switch (native_os) {
10556    .windows, .wasi => {},
10557    else => private.mlock,
10558};
10559
10560pub const mlock2 = switch (native_os) {
10561    linux => private.mlock2,
10562    else => {},
10563};
10564
10565pub const munlock = switch (native_os) {
10566    .windows, .wasi => {},
10567    else => private.munlock,
10568};
10569
10570pub const mlockall = switch (native_os) {
10571    .linux, .freebsd, .dragonfly, .netbsd, .openbsd, .illumos => private.mlockall,
10572    else => {},
10573};
10574
10575pub const munlockall = switch (native_os) {
10576    .linux, .freebsd, .dragonfly, .netbsd, .openbsd, .illumos => private.munlockall,
10577    else => {},
10578};
10579
10580pub const msync = switch (native_os) {
10581    .netbsd => private.__msync13,
10582    else => private.msync,
10583};
10584
10585pub const nanosleep = switch (native_os) {
10586    .netbsd => private.__nanosleep50,
10587    else => private.nanosleep,
10588};
10589
10590pub const readdir = switch (native_os) {
10591    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) {
10592        .x86_64 => private.@"readdir$INODE64",
10593        else => private.readdir,
10594    },
10595    .windows => {},
10596    else => private.readdir,
10597};
10598
10599pub const realpath = switch (native_os) {
10600    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.@"realpath$DARWIN_EXTSN",
10601    else => private.realpath,
10602};
10603
10604pub const sched_yield = switch (native_os) {
10605    .netbsd => private.__libc_thr_yield,
10606    else => private.sched_yield,
10607};
10608
10609pub const sigaction = switch (native_os) {
10610    .netbsd => private.__sigaction14,
10611    else => private.sigaction,
10612};
10613
10614/// Zig's version of SIGRTMIN.  Actually a function.
10615pub fn sigrtmin() u8 {
10616    return switch (native_os) {
10617        .freebsd => 65,
10618        .netbsd => 33,
10619        .illumos => @truncate(sysconf(@intFromEnum(_SC.SIGRT_MIN))),
10620        else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmin()))),
10621    };
10622}
10623
10624/// Zig's version of SIGRTMAX.  Actually a function.
10625pub fn sigrtmax() u8 {
10626    return switch (native_os) {
10627        .freebsd => 126,
10628        .netbsd => 63,
10629        .illumos => @truncate(sysconf(@intFromEnum(_SC.SIGRT_MAX))),
10630        else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmax()))),
10631    };
10632}
10633
10634pub const sigfillset = switch (native_os) {
10635    .netbsd => private.__sigfillset14,
10636    else => private.sigfillset,
10637};
10638
10639pub const sigaddset = private.sigaddset;
10640pub const sigemptyset = switch (native_os) {
10641    .netbsd => private.__sigemptyset14,
10642    else => private.sigemptyset,
10643};
10644pub const sigdelset = private.sigdelset;
10645pub const sigismember = private.sigismember;
10646
10647pub const sigprocmask = switch (native_os) {
10648    .netbsd => private.__sigprocmask14,
10649    else => private.sigprocmask,
10650};
10651
10652pub const socket = switch (native_os) {
10653    .netbsd => private.__socket30,
10654    else => private.socket,
10655};
10656
10657pub const socketpair = switch (native_os) {
10658    // https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/#unsupported\unavailable:
10659    .windows => void,
10660    else => private.socketpair,
10661};
10662
10663pub const stat = switch (native_os) {
10664    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (native_arch) {
10665        .x86_64 => private.@"stat$INODE64",
10666        else => private.stat,
10667    },
10668    else => private.stat,
10669};
10670
10671pub const _msize = switch (native_os) {
10672    .windows => private._msize,
10673    else => {},
10674};
10675pub const malloc_size = switch (native_os) {
10676    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => private.malloc_size,
10677    else => {},
10678};
10679pub const malloc_usable_size = switch (native_os) {
10680    .freebsd, .linux, .serenity => private.malloc_usable_size,
10681    else => {},
10682};
10683pub const posix_memalign = switch (native_os) {
10684    .dragonfly, .netbsd, .freebsd, .illumos, .openbsd, .linux, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => private.posix_memalign,
10685    else => {},
10686};
10687pub const sysconf = switch (native_os) {
10688    .illumos => illumos.sysconf,
10689    else => private.sysconf,
10690};
10691
10692pub const sf_hdtr = switch (native_os) {
10693    .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
10694        headers: ?[*]const iovec_const,
10695        hdr_cnt: c_int,
10696        trailers: ?[*]const iovec_const,
10697        trl_cnt: c_int,
10698    },
10699    else => void,
10700};
10701
10702pub const flock = switch (native_os) {
10703    .windows, .wasi => {},
10704    else => private.flock,
10705};
10706
10707pub const futex = switch (native_os) {
10708    .openbsd => openbsd.futex,
10709    .serenity => serenity.futex,
10710    else => {},
10711};
10712
10713pub extern "c" var environ: [*:null]?[*:0]u8;
10714
10715pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
10716pub extern "c" fn fclose(stream: *FILE) c_int;
10717pub extern "c" fn fwrite(noalias ptr: [*]const u8, size_of_type: usize, item_count: usize, noalias stream: *FILE) usize;
10718pub extern "c" fn fread(noalias ptr: [*]u8, size_of_type: usize, item_count: usize, noalias stream: *FILE) usize;
10719
10720pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
10721pub extern "c" fn abort() noreturn;
10722pub extern "c" fn exit(code: c_int) noreturn;
10723pub extern "c" fn _exit(code: c_int) noreturn;
10724pub extern "c" fn isatty(fd: fd_t) c_int;
10725pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t;
10726pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int;
10727pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int;
10728pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int;
10729pub extern "c" fn raise(sig: SIG) c_int;
10730pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
10731pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
10732pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize;
10733pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize;
10734pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
10735pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize;
10736pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
10737pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize;
10738pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: c_uint, flags: MAP, fd: fd_t, offset: off_t) *anyopaque;
10739pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int;
10740pub extern "c" fn mremap(addr: ?*align(page_size) const anyopaque, old_len: usize, new_len: usize, flags: MREMAP, ...) *anyopaque;
10741pub extern "c" fn mprotect(addr: *align(page_size) anyopaque, len: usize, prot: c_uint) c_int;
10742pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) c_int;
10743pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_int) c_int;
10744pub extern "c" fn unlink(path: [*:0]const u8) c_int;
10745pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int;
10746pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;
10747pub extern "c" fn waitpid(pid: pid_t, status: ?*c_int, options: c_int) pid_t;
10748pub extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t;
10749pub const fork = switch (native_os) {
10750    .dragonfly,
10751    .freebsd,
10752    .linux,
10753    .driverkit,
10754    .ios,
10755    .maccatalyst,
10756    .macos,
10757    .tvos,
10758    .visionos,
10759    .watchos,
10760    .netbsd,
10761    .openbsd,
10762    .illumos,
10763    .haiku,
10764    .serenity,
10765    => private.fork,
10766    else => {},
10767};
10768pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
10769pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
10770pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
10771pub extern "c" fn mkdir(path: [*:0]const u8, mode: mode_t) c_int;
10772pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) c_int;
10773pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
10774pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;
10775pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
10776pub extern "c" fn renameat(olddirfd: fd_t, old: [*:0]const u8, newdirfd: fd_t, new: [*:0]const u8) c_int;
10777pub extern "c" fn chdir(path: [*:0]const u8) c_int;
10778pub extern "c" fn fchdir(fd: fd_t) c_int;
10779pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;
10780pub extern "c" fn dup(fd: fd_t) c_int;
10781pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int;
10782pub extern "c" fn dup3(old: c_int, new: c_int, flags: c_uint) c_int;
10783pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
10784pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
10785pub extern "c" fn chmod(path: [*:0]const u8, mode: mode_t) c_int;
10786pub extern "c" fn fchmod(fd: fd_t, mode: mode_t) c_int;
10787pub extern "c" fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: c_uint) c_int;
10788pub extern "c" fn fchown(fd: fd_t, owner: uid_t, group: gid_t) c_int;
10789pub extern "c" fn umask(mode: mode_t) mode_t;
10790
10791pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
10792pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
10793pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int;
10794pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*anyopaque, oldlenp: ?*usize, newp: ?*anyopaque, newlen: usize) c_int;
10795pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
10796pub extern "c" fn tcgetattr(fd: fd_t, termios_p: *termios) c_int;
10797pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int;
10798pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int;
10799pub extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;
10800pub extern "c" fn uname(buf: *utsname) c_int;
10801
10802pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;
10803pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int;
10804pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int;
10805pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int;
10806pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
10807pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
10808pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int;
10809pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int;
10810pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int;
10811pub extern "c" fn getsockopt(sockfd: fd_t, level: i32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *socklen_t) c_int;
10812pub extern "c" fn setsockopt(sockfd: fd_t, level: i32, optname: u32, optval: ?*const anyopaque, optlen: socklen_t) c_int;
10813pub extern "c" fn send(sockfd: fd_t, buf: *const anyopaque, len: usize, flags: u32) isize;
10814pub extern "c" fn sendto(
10815    sockfd: fd_t,
10816    buf: *const anyopaque,
10817    len: usize,
10818    flags: u32,
10819    dest_addr: ?*const sockaddr,
10820    addrlen: socklen_t,
10821) isize;
10822pub extern "c" fn sendmsg(sockfd: fd_t, msg: *const msghdr_const, flags: u32) isize;
10823pub extern "c" fn sendmmsg(sockfd: fd_t, msgvec: [*]mmsghdr, n: c_uint, flags: u32) c_int;
10824
10825pub extern "c" fn recv(
10826    sockfd: fd_t,
10827    arg1: ?*anyopaque,
10828    arg2: usize,
10829    arg3: c_int,
10830) if (native_os == .windows) c_int else isize;
10831pub extern "c" fn recvfrom(
10832    sockfd: fd_t,
10833    noalias buf: *anyopaque,
10834    len: usize,
10835    flags: u32,
10836    noalias src_addr: ?*sockaddr,
10837    noalias addrlen: ?*socklen_t,
10838) if (native_os == .windows) c_int else isize;
10839
10840pub const recvmsg = switch (native_os) {
10841    // Windows: Technically, a form of recvmsg() exists for Windows, but the
10842    // user has to install some kind of callback for it.  I'm not sure if/how
10843    // we can map this to normal recvmsg() interface use.
10844    // https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nc-mswsock-lpfn_wsarecvmsg
10845    .windows => void,
10846    else => private.recvmsg,
10847};
10848
10849pub extern "c" fn kill(pid: pid_t, sig: SIG) c_int;
10850
10851pub extern "c" fn setuid(uid: uid_t) c_int;
10852pub extern "c" fn setgid(gid: gid_t) c_int;
10853pub extern "c" fn seteuid(euid: uid_t) c_int;
10854pub extern "c" fn setegid(egid: gid_t) c_int;
10855pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int;
10856pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int;
10857pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
10858pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
10859pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int;
10860pub extern "c" fn getuid() uid_t;
10861pub extern "c" fn getgid() gid_t;
10862pub extern "c" fn geteuid() uid_t;
10863pub extern "c" fn getegid() gid_t;
10864pub extern "c" fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) c_int;
10865pub extern "c" fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) c_int;
10866
10867pub extern "c" fn malloc(usize) ?*anyopaque;
10868pub extern "c" fn calloc(usize, usize) ?*anyopaque;
10869pub extern "c" fn realloc(?*anyopaque, usize) ?*anyopaque;
10870pub extern "c" fn free(?*anyopaque) void;
10871
10872pub extern "c" fn futimes(fd: fd_t, times: ?*[2]timeval) c_int;
10873pub extern "c" fn utimes(path: [*:0]const u8, times: ?*[2]timeval) c_int;
10874
10875pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: ?*[2]timespec, flags: u32) c_int;
10876pub extern "c" fn futimens(fd: fd_t, times: ?*const [2]timespec) c_int;
10877
10878pub 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;
10884pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
10885pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *anyopaque, stacksize: usize) E;
10886pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E;
10887pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E;
10888pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E;
10889pub extern "c" fn pthread_self() pthread_t;
10890pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
10891pub extern "c" fn pthread_detach(thread: pthread_t) E;
10892pub extern "c" fn pthread_atfork(
10893    prepare: ?*const fn () callconv(.c) void,
10894    parent: ?*const fn () callconv(.c) void,
10895    child: ?*const fn () callconv(.c) void,
10896) c_int;
10897pub extern "c" fn pthread_key_create(
10898    key: *pthread_key_t,
10899    destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
10900) E;
10901pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
10902pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque;
10903pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*anyopaque) c_int;
10904pub extern "c" fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *sigset_t) c_int;
10905pub const pthread_setname_np = switch (native_os) {
10906    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.pthread_setname_np,
10907    .illumos => illumos.pthread_setname_np,
10908    .netbsd => netbsd.pthread_setname_np,
10909    else => private.pthread_setname_np,
10910};
10911
10912pub extern "c" fn pthread_getname_np(thread: pthread_t, name: [*:0]u8, len: usize) c_int;
10913pub extern "c" fn pthread_kill(pthread_t, signal: SIG) c_int;
10914
10915pub const pthread_threadid_np = switch (native_os) {
10916    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => private.pthread_threadid_np,
10917    else => {},
10918};
10919
10920pub const caddr_t = ?[*]u8;
10921
10922pub const ptrace = switch (native_os) {
10923    .linux, .serenity => private.ptrace,
10924    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.ptrace,
10925    .dragonfly => dragonfly.ptrace,
10926    .freebsd => freebsd.ptrace,
10927    .netbsd => netbsd.ptrace,
10928    .openbsd => openbsd.ptrace,
10929    else => {},
10930};
10931
10932pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int;
10933pub extern "c" fn sem_destroy(sem: *sem_t) c_int;
10934pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: mode_t, value: c_uint) *sem_t;
10935pub extern "c" fn sem_close(sem: *sem_t) c_int;
10936pub extern "c" fn sem_post(sem: *sem_t) c_int;
10937pub extern "c" fn sem_wait(sem: *sem_t) c_int;
10938pub extern "c" fn sem_trywait(sem: *sem_t) c_int;
10939pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int;
10940pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int;
10941
10942pub const shm_open = switch (native_os) {
10943    .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.shm_open,
10944    else => private.shm_open,
10945};
10946pub extern "c" fn shm_unlink(name: [*:0]const u8) c_int;
10947
10948pub extern "c" fn kqueue() c_int;
10949pub extern "c" fn kevent(
10950    kq: c_int,
10951    changelist: [*]const Kevent,
10952    nchanges: c_int,
10953    eventlist: [*]Kevent,
10954    nevents: c_int,
10955    timeout: ?*const timespec,
10956) c_int;
10957
10958pub extern "c" fn port_create() port_t;
10959pub extern "c" fn port_associate(
10960    port: port_t,
10961    source: u32,
10962    object: usize,
10963    events: u32,
10964    user_var: ?*anyopaque,
10965) c_int;
10966pub extern "c" fn port_dissociate(port: port_t, source: u32, object: usize) c_int;
10967pub extern "c" fn port_send(port: port_t, events: u32, user_var: ?*anyopaque) c_int;
10968pub extern "c" fn port_sendn(
10969    ports: [*]port_t,
10970    errors: []u32,
10971    num_ports: u32,
10972    events: u32,
10973    user_var: ?*anyopaque,
10974) c_int;
10975pub extern "c" fn port_get(port: port_t, event: *port_event, timeout: ?*timespec) c_int;
10976pub extern "c" fn port_getn(
10977    port: port_t,
10978    event_list: []port_event,
10979    max_events: u32,
10980    events_retrieved: *u32,
10981    timeout: ?*timespec,
10982) c_int;
10983pub extern "c" fn port_alert(port: port_t, flags: u32, events: u32, user_var: ?*anyopaque) c_int;
10984
10985pub extern "c" fn getaddrinfo(
10986    noalias node: ?[*:0]const u8,
10987    noalias service: ?[*:0]const u8,
10988    noalias hints: ?*const addrinfo,
10989    /// On Linux, `res` will not be modified on error and `freeaddrinfo` will
10990    /// potentially crash if you pass it an undefined pointer
10991    noalias res: *?*addrinfo,
10992) EAI;
10993
10994pub extern "c" fn freeaddrinfo(res: *addrinfo) void;
10995
10996pub extern "c" fn getnameinfo(
10997    noalias addr: *const sockaddr,
10998    addrlen: socklen_t,
10999    noalias host: ?[*]u8,
11000    hostlen: socklen_t,
11001    noalias serv: ?[*]u8,
11002    servlen: socklen_t,
11003    flags: NI,
11004) EAI;
11005
11006pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8;
11007
11008pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int;
11009pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int;
11010
11011pub extern "c" fn dn_expand(
11012    msg: [*:0]const u8,
11013    eomorig: [*:0]const u8,
11014    comp_dn: [*:0]const u8,
11015    exp_dn: [*:0]u8,
11016    length: c_int,
11017) c_int;
11018
11019pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = .{};
11020pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;
11021pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;
11022pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E;
11023pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E;
11024
11025pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = .{};
11026pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E;
11027pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E;
11028pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
11029pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
11030pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
11031
11032pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E;
11033pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
11034pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
11035pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
11036pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
11037pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E;
11038
11039pub const pthread_t = switch (native_os) {
11040    // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L64
11041    .serenity => c_int,
11042    else => *opaque {},
11043};
11044pub const FILE = opaque {};
11045
11046pub extern "c" fn dlopen(path: ?[*:0]const u8, mode: RTLD) ?*anyopaque;
11047pub extern "c" fn dlclose(handle: *anyopaque) c_int;
11048pub extern "c" fn dlsym(handle: ?*anyopaque, symbol: [*:0]const u8) ?*anyopaque;
11049pub extern "c" fn dlerror() ?[*:0]u8;
11050
11051pub const dladdr = if (native_os.isDarwin()) darwin.dladdr else {};
11052pub const dl_info = if (native_os.isDarwin()) darwin.dl_info else {};
11053
11054pub extern "c" fn sync() void;
11055pub extern "c" fn syncfs(fd: c_int) c_int;
11056pub extern "c" fn fsync(fd: c_int) c_int;
11057pub extern "c" fn fdatasync(fd: c_int) c_int;
11058
11059pub extern "c" fn prctl(option: c_int, ...) c_int;
11060
11061pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int;
11062pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int;
11063
11064pub extern "c" fn fmemopen(noalias buf: ?*anyopaque, size: usize, noalias mode: [*:0]const u8) ?*FILE;
11065
11066pub extern "c" fn syslog(priority: c_int, message: [*:0]const u8, ...) void;
11067pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int) void;
11068pub extern "c" fn closelog() void;
11069pub extern "c" fn setlogmask(maskpri: c_int) c_int;
11070
11071pub extern "c" fn if_nametoindex([*:0]const u8) c_int;
11072
11073pub extern "c" fn getpid() pid_t;
11074pub extern "c" fn getppid() pid_t;
11075pub extern "c" fn setsid() pid_t;
11076
11077/// These are implementation defined but share identical values in at least musl and glibc:
11078/// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18
11079/// - https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/bits/locale.h;h=0fcbb66114be5fef0577dc9047256eb508c45919;hb=c90cfce849d010474e8cccf3e5bff49a2c8b141f#l26
11080pub const LC = enum(c_int) {
11081    CTYPE = 0,
11082    NUMERIC = 1,
11083    TIME = 2,
11084    COLLATE = 3,
11085    MONETARY = 4,
11086    MESSAGES = 5,
11087    ALL = 6,
11088    PAPER = 7,
11089    NAME = 8,
11090    ADDRESS = 9,
11091    TELEPHONE = 10,
11092    MEASUREMENT = 11,
11093    IDENTIFICATION = 12,
11094    _,
11095};
11096
11097pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8;
11098
11099pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
11100    f64
11101else if (native_os.isDarwin())
11102    c_longdouble
11103else
11104    extern struct {
11105        a: c_longlong,
11106        b: c_longdouble,
11107    };
11108
11109pub const intmax_t = i64;
11110pub const uintmax_t = u64;
11111
11112pub extern "c" fn pthread_getthreadid_np() c_int;
11113pub extern "c" fn pthread_set_name_np(thread: pthread_t, name: [*:0]const u8) void;
11114pub extern "c" fn pthread_get_name_np(thread: pthread_t, name: [*:0]u8, len: usize) void;
11115
11116// OS-specific bits. These are protected from being used on the wrong OS by
11117// comptime assertions inside each OS-specific file.
11118
11119pub const AF_SUN = illumos.AF_SUN;
11120pub const AT_SUN = illumos.AT_SUN;
11121pub const FILE_EVENT = illumos.FILE_EVENT;
11122pub const GETCONTEXT = illumos.GETCONTEXT;
11123pub const GETUSTACK = illumos.GETUSTACK;
11124pub const PORT_ALERT = illumos.PORT_ALERT;
11125pub const PORT_SOURCE = illumos.PORT_SOURCE;
11126pub const POSIX_FADV = illumos.POSIX_FADV;
11127pub const SETCONTEXT = illumos.SETCONTEXT;
11128pub const SETUSTACK = illumos.GETUSTACK;
11129pub const SFD = illumos.SFD;
11130pub const ctid_t = illumos.ctid_t;
11131pub const file_obj = illumos.file_obj;
11132pub const id_t = illumos.id_t;
11133pub const lif_ifinfo_req = illumos.lif_ifinfo_req;
11134pub const lif_nd_req = illumos.lif_nd_req;
11135pub const lifreq = illumos.lifreq;
11136pub const major_t = illumos.major_t;
11137pub const minor_t = illumos.minor_t;
11138pub const poolid_t = illumos.poolid_t;
11139pub const port_notify = illumos.port_notify;
11140pub const priority = illumos.priority;
11141pub const procfs = illumos.procfs;
11142pub const projid_t = illumos.projid_t;
11143pub const signalfd_siginfo = illumos.signalfd_siginfo;
11144pub const taskid_t = illumos.taskid_t;
11145pub const zoneid_t = illumos.zoneid_t;
11146
11147pub const DirEnt = haiku.DirEnt;
11148pub const _get_next_area_info = haiku._get_next_area_info;
11149pub const _get_next_image_info = haiku._get_next_image_info;
11150pub const _get_team_info = haiku._get_team_info;
11151pub const _kern_get_current_team = haiku._kern_get_current_team;
11152pub const _kern_open_dir = haiku._kern_open_dir;
11153pub const _kern_read_dir = haiku._kern_read_dir;
11154pub const _kern_read_stat = haiku._kern_read_stat;
11155pub const _kern_rewind_dir = haiku._kern_rewind_dir;
11156pub const area_id = haiku.area_id;
11157pub const area_info = haiku.area_info;
11158pub const directory_which = haiku.directory_which;
11159pub const find_directory = haiku.find_directory;
11160pub const find_thread = haiku.find_thread;
11161pub const get_system_info = haiku.get_system_info;
11162pub const image_info = haiku.image_info;
11163pub const port_id = haiku.port_id;
11164pub const sem_id = haiku.sem_id;
11165pub const status_t = haiku.status_t;
11166pub const system_info = haiku.system_info;
11167pub const team_id = haiku.team_id;
11168pub const team_info = haiku.team_info;
11169pub const thread_id = haiku.thread_id;
11170
11171pub const AUTH = openbsd.AUTH;
11172pub const BI = openbsd.BI;
11173pub const HW = openbsd.HW;
11174pub const PTHREAD_STACK_MIN = openbsd.PTHREAD_STACK_MIN;
11175pub const TCFLUSH = openbsd.TCFLUSH;
11176pub const TCIO = openbsd.TCIO;
11177pub const auth_approval = openbsd.auth_approval;
11178pub const auth_call = openbsd.auth_call;
11179pub const auth_cat = openbsd.auth_cat;
11180pub const auth_challenge = openbsd.auth_challenge;
11181pub const auth_check_change = openbsd.auth_check_change;
11182pub const auth_check_expire = openbsd.auth_check_expire;
11183pub const auth_checknologin = openbsd.auth_checknologin;
11184pub const auth_clean = openbsd.auth_clean;
11185pub const auth_close = openbsd.auth_close;
11186pub const auth_clrenv = openbsd.auth_clrenv;
11187pub const auth_clroption = openbsd.auth_clroption;
11188pub const auth_clroptions = openbsd.auth_clroptions;
11189pub const auth_getitem = openbsd.auth_getitem;
11190pub const auth_getpwd = openbsd.auth_getpwd;
11191pub const auth_getstate = openbsd.auth_getstate;
11192pub const auth_getvalue = openbsd.auth_getvalue;
11193pub const auth_item_t = openbsd.auth_item_t;
11194pub const auth_mkvalue = openbsd.auth_mkvalue;
11195pub const auth_open = openbsd.auth_open;
11196pub const auth_session_t = openbsd.auth_session_t;
11197pub const auth_setdata = openbsd.auth_setdata;
11198pub const auth_setenv = openbsd.auth_setenv;
11199pub const auth_setitem = openbsd.auth_setitem;
11200pub const auth_setoption = openbsd.auth_setoption;
11201pub const auth_setpwd = openbsd.auth_setpwd;
11202pub const auth_setstate = openbsd.auth_setstate;
11203pub const auth_userchallenge = openbsd.auth_userchallenge;
11204pub const auth_usercheck = openbsd.auth_usercheck;
11205pub const auth_userokay = openbsd.auth_userokay;
11206pub const auth_userresponse = openbsd.auth_userresponse;
11207pub const auth_verify = openbsd.auth_verify;
11208pub const bcrypt = openbsd.bcrypt;
11209pub const bcrypt_checkpass = openbsd.bcrypt_checkpass;
11210pub const bcrypt_gensalt = openbsd.bcrypt_gensalt;
11211pub const bcrypt_newhash = openbsd.bcrypt_newhash;
11212pub const getpwnam_shadow = openbsd.getpwnam_shadow;
11213pub const getpwuid_shadow = openbsd.getpwuid_shadow;
11214pub const getthrid = openbsd.getthrid;
11215pub const login_cap_t = openbsd.login_cap_t;
11216pub const login_close = openbsd.login_close;
11217pub const login_getcapbool = openbsd.login_getcapbool;
11218pub const login_getcapnum = openbsd.login_getcapnum;
11219pub const login_getcapsize = openbsd.login_getcapsize;
11220pub const login_getcapstr = openbsd.login_getcapstr;
11221pub const login_getcaptime = openbsd.login_getcaptime;
11222pub const login_getclass = openbsd.login_getclass;
11223pub const login_getstyle = openbsd.login_getstyle;
11224pub const pledge = openbsd.pledge;
11225pub const pthread_spinlock_t = openbsd.pthread_spinlock_t;
11226pub const pw_dup = openbsd.pw_dup;
11227pub const setclasscontext = openbsd.setclasscontext;
11228pub const setpassent = openbsd.setpassent;
11229pub const setusercontext = openbsd.setusercontext;
11230pub const uid_from_user = openbsd.uid_from_user;
11231pub const unveil = openbsd.unveil;
11232pub const user_from_uid = openbsd.user_from_uid;
11233
11234pub const CAP_RIGHTS_VERSION = freebsd.CAP_RIGHTS_VERSION;
11235pub const KINFO_FILE_SIZE = freebsd.KINFO_FILE_SIZE;
11236pub const MFD = freebsd.MFD;
11237pub const UMTX_ABSTIME = freebsd.UMTX_ABSTIME;
11238pub const UMTX_OP = freebsd.UMTX_OP;
11239pub const _umtx_op = freebsd._umtx_op;
11240pub const _umtx_time = freebsd._umtx_time;
11241pub const cap_rights = freebsd.cap_rights;
11242pub const fflags_t = freebsd.fflags_t;
11243pub const fsblkcnt_t = freebsd.fsblkcnt_t;
11244pub const fsfilcnt_t = freebsd.fsfilcnt_t;
11245pub const kinfo_file = freebsd.kinfo_file;
11246pub const kinfo_getfile = freebsd.kinfo_getfile;
11247
11248pub const CALENDAR_CLOCK = darwin.CALENDAR_CLOCK;
11249pub const COPYFILE = darwin.COPYFILE;
11250pub const CPUFAMILY = darwin.CPUFAMILY;
11251pub const PT = darwin.PT;
11252pub const DB_RECORDTYPE = darwin.DB_RECORDTYPE;
11253pub const EXC = darwin.EXC;
11254pub const EXCEPTION = darwin.EXCEPTION;
11255pub const KEVENT = darwin.KEVENT;
11256pub const MACH = darwin.MACH;
11257pub const MACH_MSG_TYPE = darwin.MACH_MSG_TYPE;
11258pub const MACH_PORT_RIGHT = darwin.MACH_PORT_RIGHT;
11259pub const MACH_TASK_BASIC_INFO = darwin.MACH_TASK_BASIC_INFO;
11260pub const MACH_TASK_BASIC_INFO_COUNT = darwin.MACH_TASK_BASIC_INFO_COUNT;
11261pub const MATTR = darwin.MATTR;
11262pub const NSVersionOfRunTimeLibrary = darwin.NSVersionOfRunTimeLibrary;
11263pub const OPEN_MAX = darwin.OPEN_MAX;
11264pub const OS = darwin.OS;
11265pub const POSIX_SPAWN = darwin.POSIX_SPAWN;
11266pub const SYSPROTO_EVENT = darwin.SYSPROTO_EVENT;
11267pub const SYSPROTO_CONTROL = darwin.SYSPROTO_CONTROL;
11268pub const TASK = darwin.TASK;
11269pub const TASK_NULL = darwin.TASK_NULL;
11270pub const TASK_VM_INFO = darwin.TASK_VM_INFO;
11271pub const TASK_VM_INFO_COUNT = darwin.TASK_VM_INFO_COUNT;
11272pub const THREAD = darwin.THREAD;
11273pub const THREAD_BASIC_INFO = darwin.THREAD_BASIC_INFO;
11274pub const THREAD_BASIC_INFO_COUNT = darwin.THREAD_BASIC_INFO_COUNT;
11275pub const THREAD_IDENTIFIER_INFO_COUNT = darwin.THREAD_IDENTIFIER_INFO_COUNT;
11276pub const THREAD_NULL = darwin.THREAD_NULL;
11277pub const THREAD_STATE_NONE = darwin.THREAD_STATE_NONE;
11278pub const UL = darwin.UL;
11279pub const VM = darwin.VM;
11280pub const _NSGetExecutablePath = darwin._NSGetExecutablePath;
11281pub const __getdirentries64 = darwin.__getdirentries64;
11282pub const __ulock_wait = darwin.__ulock_wait;
11283pub const __ulock_wait2 = darwin.__ulock_wait2;
11284pub const __ulock_wake = darwin.__ulock_wake;
11285pub const _dyld_get_image_header = darwin._dyld_get_image_header;
11286pub const _dyld_get_image_name = darwin._dyld_get_image_name;
11287pub const _dyld_get_image_vmaddr_slide = darwin._dyld_get_image_vmaddr_slide;
11288pub const _dyld_image_count = darwin._dyld_image_count;
11289pub const _host_page_size = darwin._host_page_size;
11290pub const boolean_t = darwin.boolean_t;
11291pub const clock_get_time = darwin.clock_get_time;
11292pub const clock_serv_t = darwin.clock_serv_t;
11293pub const clock_res_t = darwin.clock_res_t;
11294pub const @"close$NOCANCEL" = darwin.@"close$NOCANCEL";
11295pub const dispatch_function_t = darwin.dispatch_function_t;
11296pub const dispatch_once_f = darwin.dispatch_once_f;
11297pub const dispatch_once_t = darwin.dispatch_once_t;
11298pub const dispatch_release = darwin.dispatch_release;
11299pub const dispatch_semaphore_create = darwin.dispatch_semaphore_create;
11300pub const dispatch_semaphore_signal = darwin.dispatch_semaphore_signal;
11301pub const dispatch_semaphore_t = darwin.dispatch_semaphore_t;
11302pub const dispatch_semaphore_wait = darwin.dispatch_semaphore_wait;
11303pub const dispatch_time = darwin.dispatch_time;
11304pub const dispatch_time_t = darwin.dispatch_time_t;
11305pub const fcopyfile = darwin.fcopyfile;
11306pub const host_t = darwin.host_t;
11307pub const integer_t = darwin.integer_t;
11308pub const ipc_space_t = darwin.ipc_space_t;
11309pub const ipc_space_port_t = darwin.ipc_space_port_t;
11310pub const kern_return_t = darwin.kern_return_t;
11311pub const vm_size_t = darwin.vm_size_t;
11312pub const kevent64 = darwin.kevent64;
11313pub const kevent64_s = darwin.kevent64_s;
11314pub const mach_absolute_time = darwin.mach_absolute_time;
11315pub const mach_continuous_time = darwin.mach_continuous_time;
11316pub const mach_hdr = darwin.mach_hdr;
11317pub const mach_host_self = darwin.mach_host_self;
11318pub const mach_msg = darwin.mach_msg;
11319pub const mach_msg_return_t = darwin.mach_msg_return_t;
11320pub const mach_msg_type_number_t = darwin.mach_msg_type_number_t;
11321pub const mach_port_allocate = darwin.mach_port_allocate;
11322pub const mach_port_array_t = darwin.mach_port_array_t;
11323pub const mach_port_deallocate = darwin.mach_port_deallocate;
11324pub const mach_port_insert_right = darwin.mach_port_insert_right;
11325pub const mach_port_name_t = darwin.mach_port_name_t;
11326pub const mach_port_t = darwin.mach_port_t;
11327pub const mach_task_basic_info = darwin.mach_task_basic_info;
11328pub const mach_task_self = darwin.mach_task_self;
11329pub const mach_timebase_info = darwin.mach_timebase_info;
11330pub const mach_timebase_info_data = darwin.mach_timebase_info_data;
11331pub const mach_timespec_t = darwin.mach_timespec_t;
11332pub const mach_vm_address_t = darwin.mach_vm_address_t;
11333pub const mach_vm_protect = darwin.mach_vm_protect;
11334pub const mach_vm_read = darwin.mach_vm_read;
11335pub const mach_vm_region = darwin.mach_vm_region;
11336pub const mach_vm_region_recurse = darwin.mach_vm_region_recurse;
11337pub const mach_vm_size_t = darwin.mach_vm_size_t;
11338pub const mach_vm_write = darwin.mach_vm_write;
11339pub const natural_t = darwin.natural_t;
11340pub const os_log_create = darwin.os_log_create;
11341pub const os_log_t = darwin.os_log_t;
11342pub const os_log_type_enabled = darwin.os_log_type_enabled;
11343pub const os_log_type_t = darwin.os_log_type_t;
11344pub const os_signpost_enabled = darwin.os_signpost_enabled;
11345pub const os_signpost_id_generate = darwin.os_signpost_id_generate;
11346pub const os_signpost_id_make_with_pointer = darwin.os_signpost_id_make_with_pointer;
11347pub const os_signpost_id_t = darwin.os_signpost_id_t;
11348pub const os_signpost_interval_begin = darwin.os_signpost_interval_begin;
11349pub const os_signpost_interval_end = darwin.os_signpost_interval_end;
11350pub const os_unfair_lock = darwin.os_unfair_lock;
11351pub const os_unfair_lock_assert_not_owner = darwin.os_unfair_lock_assert_not_owner;
11352pub const os_unfair_lock_assert_owner = darwin.os_unfair_lock_assert_owner;
11353pub const os_unfair_lock_lock = darwin.os_unfair_lock_lock;
11354pub const os_unfair_lock_t = darwin.os_unfair_lock_t;
11355pub const os_unfair_lock_trylock = darwin.os_unfair_lock_trylock;
11356pub const os_unfair_lock_unlock = darwin.os_unfair_lock_unlock;
11357pub const pid_for_task = darwin.pid_for_task;
11358pub const posix_spawn = darwin.posix_spawn;
11359pub const posix_spawn_file_actions_addchdir_np = darwin.posix_spawn_file_actions_addchdir_np;
11360pub const posix_spawn_file_actions_addclose = darwin.posix_spawn_file_actions_addclose;
11361pub const posix_spawn_file_actions_adddup2 = darwin.posix_spawn_file_actions_adddup2;
11362pub const posix_spawn_file_actions_addfchdir_np = darwin.posix_spawn_file_actions_addfchdir_np;
11363pub const posix_spawn_file_actions_addinherit_np = darwin.posix_spawn_file_actions_addinherit_np;
11364pub const posix_spawn_file_actions_addopen = darwin.posix_spawn_file_actions_addopen;
11365pub const posix_spawn_file_actions_destroy = darwin.posix_spawn_file_actions_destroy;
11366pub const posix_spawn_file_actions_init = darwin.posix_spawn_file_actions_init;
11367pub const posix_spawn_file_actions_t = darwin.posix_spawn_file_actions_t;
11368pub const posix_spawnattr_destroy = darwin.posix_spawnattr_destroy;
11369pub const posix_spawnattr_getflags = darwin.posix_spawnattr_getflags;
11370pub const posix_spawnattr_init = darwin.posix_spawnattr_init;
11371pub const posix_spawnattr_setflags = darwin.posix_spawnattr_setflags;
11372pub const posix_spawnattr_t = darwin.posix_spawnattr_t;
11373pub const posix_spawnp = darwin.posix_spawnp;
11374pub const pthread_attr_get_qos_class_np = darwin.pthread_attr_get_qos_class_np;
11375pub const pthread_attr_set_qos_class_np = darwin.pthread_attr_set_qos_class_np;
11376pub const pthread_get_qos_class_np = darwin.pthread_get_qos_class_np;
11377pub const pthread_set_qos_class_self_np = darwin.pthread_set_qos_class_self_np;
11378pub const qos_class_t = darwin.qos_class_t;
11379pub const task_flavor_t = darwin.task_flavor_t;
11380pub const task_for_pid = darwin.task_for_pid;
11381pub const task_get_exception_ports = darwin.task_get_exception_ports;
11382pub const task_info = darwin.task_info;
11383pub const task_info_t = darwin.task_info_t;
11384pub const task_name_t = darwin.task_name_t;
11385pub const task_resume = darwin.task_resume;
11386pub const task_set_exception_ports = darwin.task_set_exception_ports;
11387pub const task_suspend = darwin.task_suspend;
11388pub const task_threads = darwin.task_threads;
11389pub const task_vm_info_data_t = darwin.task_vm_info_data_t;
11390pub const thread_basic_info = darwin.thread_basic_info;
11391pub const thread_get_state = darwin.thread_get_state;
11392pub const thread_identifier_info = darwin.thread_identifier_info;
11393pub const thread_info = darwin.thread_info;
11394pub const thread_info_t = darwin.thread_info_t;
11395pub const thread_resume = darwin.thread_resume;
11396pub const thread_set_state = darwin.thread_set_state;
11397pub const vm_address_t = darwin.vm_address_t;
11398pub const vm_deallocate = darwin.vm_deallocate;
11399pub const vm_machine_attribute = darwin.vm_machine_attribute;
11400pub const vm_machine_attribute_t = darwin.vm_machine_attribute_t;
11401pub const vm_machine_attribute_val_t = darwin.vm_machine_attribute_val_t;
11402pub const vm_map_t = darwin.vm_map_t;
11403pub const vm_offset_t = darwin.vm_offset_t;
11404pub const vm_prot_t = darwin.vm_prot_t;
11405pub const vm_region_basic_info_64 = darwin.vm_region_basic_info_64;
11406pub const vm_region_extended_info = darwin.vm_region_extended_info;
11407pub const vm_region_info_t = darwin.vm_region_info_t;
11408pub const vm_region_recurse_info_t = darwin.vm_region_recurse_info_t;
11409pub const vm_region_submap_info_64 = darwin.vm_region_submap_info_64;
11410pub const vm_region_submap_short_info_64 = darwin.vm_region_submap_short_info_64;
11411pub const vm_region_top_info = darwin.vm_region_top_info;
11412
11413pub const exception_behavior_array_t = darwin.exception_behavior_array_t;
11414pub const exception_behavior_t = darwin.exception_behavior_t;
11415pub const exception_data_t = darwin.exception_data_t;
11416pub const exception_data_type_t = darwin.exception_data_type_t;
11417pub const exception_flavor_array_t = darwin.exception_flavor_array_t;
11418pub const exception_handler_array_t = darwin.exception_handler_array_t;
11419pub const exception_handler_t = darwin.exception_handler_t;
11420pub const exception_mask_array_t = darwin.exception_mask_array_t;
11421pub const exception_mask_t = darwin.exception_mask_t;
11422pub const exception_port_array_t = darwin.exception_port_array_t;
11423pub const exception_port_t = darwin.exception_port_t;
11424pub const exception_type_t = darwin.exception_type_t;
11425pub const mach_exception_data_t = darwin.mach_exception_data_t;
11426pub const mach_exception_data_type_t = darwin.mach_exception_data_type_t;
11427pub const mach_msg_bits_t = darwin.mach_msg_bits_t;
11428pub const mach_msg_id_t = darwin.mach_msg_id_t;
11429pub const mach_msg_header_t = darwin.mach_msg_header_t;
11430pub const mach_msg_option_t = darwin.mach_msg_option_t;
11431pub const mach_msg_size_t = darwin.mach_msg_size_t;
11432pub const mach_msg_timeout_t = darwin.mach_msg_timeout_t;
11433pub const mach_msg_type_name_t = darwin.mach_msg_type_name_t;
11434pub const mach_port_right_t = darwin.mach_port_right_t;
11435pub const memory_object_offset_t = darwin.memory_object_offset_t;
11436pub const policy_t = darwin.policy_t;
11437pub const task_policy_flavor_t = darwin.task_policy_flavor_t;
11438pub const task_policy_t = darwin.task_policy_t;
11439pub const task_read_t = darwin.task_read_t;
11440pub const task_t = darwin.task_t;
11441pub const thread_act_t = darwin.thread_act_t;
11442pub const thread_flavor_t = darwin.thread_flavor_t;
11443pub const thread_port_t = darwin.thread_port_t;
11444pub const thread_state_flavor_t = darwin.thread_state_flavor_t;
11445pub const thread_state_t = darwin.thread_state_t;
11446pub const thread_t = darwin.thread_t;
11447pub const time_value_t = darwin.time_value_t;
11448pub const vm32_object_id_t = darwin.vm32_object_id_t;
11449pub const vm_behavior_t = darwin.vm_behavior_t;
11450pub const vm_inherit_t = darwin.vm_inherit_t;
11451pub const vm_map_read_t = darwin.vm_map_read_t;
11452pub const vm_object_id_t = darwin.vm_object_id_t;
11453pub const vm_region_flavor_t = darwin.vm_region_flavor_t;
11454
11455pub const _ksiginfo = netbsd._ksiginfo;
11456pub const _lwp_self = netbsd._lwp_self;
11457pub const lwpid_t = netbsd.lwpid_t;
11458
11459pub const lwp_gettid = dragonfly.lwp_gettid;
11460pub const umtx_sleep = dragonfly.umtx_sleep;
11461pub const umtx_wakeup = dragonfly.umtx_wakeup;
11462
11463pub const PERF_EVENT = serenity.PERF_EVENT;
11464pub const disown = serenity.disown;
11465pub const profiling_enable = serenity.profiling_enable;
11466pub const profiling_disable = serenity.profiling_disable;
11467pub const profiling_free_buffer = serenity.profiling_free_buffer;
11468pub const futex_wait = serenity.futex_wait;
11469pub const futex_wake = serenity.futex_wake;
11470pub const purge = serenity.purge;
11471pub const perf_event = serenity.perf_event;
11472pub const perf_register_string = serenity.perf_register_string;
11473pub const get_stack_bounds = serenity.get_stack_bounds;
11474pub const anon_create = serenity.anon_create;
11475pub const serenity_readlink = serenity.serenity_readlink;
11476pub const serenity_open = serenity.serenity_open;
11477pub const getkeymap = serenity.getkeymap;
11478pub const setkeymap = serenity.setkeymap;
11479
11480/// External definitions shared by two or more operating systems.
11481const private = struct {
11482    extern "c" fn close(fd: fd_t) c_int;
11483    extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int;
11484    extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int;
11485    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;
11486    extern "c" fn flock(fd: fd_t, operation: c_int) c_int;
11487    extern "c" fn fork() c_int;
11488    extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
11489    extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int;
11490    extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
11491    extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) switch (native_os) {
11492        .freebsd => isize,
11493        .illumos => usize,
11494        else => c_int,
11495    };
11496    extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
11497    extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
11498    extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
11499    extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
11500    extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int;
11501    extern "c" fn readdir(dir: *DIR) ?*dirent;
11502    extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
11503    extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize;
11504    extern "c" fn sched_yield() c_int;
11505    extern "c" fn sendfile(out_fd: fd_t, in_fd: fd_t, offset: ?*off_t, count: usize) isize;
11506    extern "c" fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
11507    extern "c" fn sigdelset(set: ?*sigset_t, signo: SIG) c_int;
11508    extern "c" fn sigaddset(set: ?*sigset_t, signo: SIG) c_int;
11509    extern "c" fn sigfillset(set: ?*sigset_t) c_int;
11510    extern "c" fn sigemptyset(set: ?*sigset_t) c_int;
11511    extern "c" fn sigismember(set: ?*const sigset_t, signo: SIG) c_int;
11512    extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
11513    extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
11514    extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int;
11515    extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
11516    extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
11517    extern "c" fn sysconf(sc: c_int) c_long;
11518    extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int;
11519
11520    extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int;
11521
11522    extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;
11523    extern "c" fn getentropy(buffer: [*]u8, size: usize) c_int;
11524    extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
11525
11526    extern "c" fn _msize(?*const anyopaque) usize;
11527    extern "c" fn malloc_size(?*const anyopaque) usize;
11528    extern "c" fn malloc_usable_size(?*const anyopaque) usize;
11529    extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
11530
11531    extern "c" fn mlock(addr: *align(page_size) const anyopaque, len: usize) c_int;
11532    extern "c" fn mlock2(addr: *align(page_size) const anyopaque, len: usize, flags: MLOCK) c_int;
11533    extern "c" fn munlock(addr: *align(page_size) const anyopaque, len: usize) c_int;
11534    extern "c" fn mlockall(flags: MCL) c_int;
11535    extern "c" fn munlockall() c_int;
11536
11537    // linux and https://github.com/SerenityOS/serenity/blob/502caef9a40bccc7459f9835f2174a601106299a/Userland/Libraries/LibC/sys/ptrace.cpp
11538    extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: ?*anyopaque) c_long;
11539
11540    /// macos modernized symbols.
11541    /// x86_64 links to $INODE64 suffix for 64-bit support.
11542    /// Note these are not necessary on aarch64.
11543    extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;
11544    extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int;
11545    extern "c" fn @"readdir$INODE64"(dir: *DIR) ?*dirent;
11546    extern "c" fn @"stat$INODE64"(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
11547
11548    /// macos modernized symbols.
11549    extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
11550    extern "c" fn __getdirentries64(fd: fd_t, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize;
11551
11552    extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int;
11553
11554    /// netbsd modernized symbols.
11555    extern "c" fn __clock_getres50(clk_id: clockid_t, tp: *timespec) c_int;
11556    extern "c" fn __clock_gettime50(clk_id: clockid_t, tp: *timespec) c_int;
11557    extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
11558    extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
11559    extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
11560    extern "c" fn __libc_thr_yield() c_int;
11561    extern "c" fn __msync13(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
11562    extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
11563    extern "c" fn __sigaction14(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
11564    extern "c" fn __sigemptyset14(set: ?*sigset_t) c_int;
11565    extern "c" fn __sigfillset14(set: ?*sigset_t) c_int;
11566    extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
11567    extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
11568    extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
11569    extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
11570    extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
11571
11572    extern "c" fn __libc_current_sigrtmin() c_int;
11573    extern "c" fn __libc_current_sigrtmax() c_int;
11574
11575    // Don't forget to add another clown when an OS picks yet another unique
11576    // symbol name for errno location!
11577    // 🤡🤡🤡🤡🤡🤡
11578
11579    extern "c" fn ___errno() *c_int;
11580    extern "c" fn __errno() *c_int;
11581    extern "c" fn __errno_location() *c_int;
11582    extern "c" fn __error() *c_int;
11583    extern "c" fn _errno() *c_int;
11584
11585    extern threadlocal var errno: c_int;
11586
11587    fn errnoFromThreadLocal() *c_int {
11588        return &private.errno;
11589    }
11590};