| ... | ... | @@ -19,6 +19,7 @@ const netbsd = @import("c/netbsd.zig"); |
| 19 | 19 | const dragonfly = @import("c/dragonfly.zig"); |
| 20 | 20 | const haiku = @import("c/haiku.zig"); |
| 21 | 21 | const openbsd = @import("c/openbsd.zig"); |
| 22 | const serenity = @import("c/serenity.zig"); |
| 22 | 23 | |
| 23 | 24 | // These constants are shared among all operating systems even when not linking |
| 24 | 25 | // libc. |
| ... | ... | @@ -75,12 +76,14 @@ pub const ino_t = switch (native_os) { |
| 75 | 76 | .wasi => wasi.inode_t, |
| 76 | 77 | .windows => windows.LARGE_INTEGER, |
| 77 | 78 | .haiku => i64, |
| 79 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L38 |
| 78 | 80 | else => u64, |
| 79 | 81 | }; |
| 80 | 82 | |
| 81 | 83 | pub const off_t = switch (native_os) { |
| 82 | 84 | .linux => linux.off_t, |
| 83 | 85 | .emscripten => emscripten.off_t, |
| 86 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L39 |
| 84 | 87 | else => i64, |
| 85 | 88 | }; |
| 86 | 89 | |
| ... | ... | @@ -105,7 +108,8 @@ pub const timespec = switch (native_os) { |
| 105 | 108 | @as(wasi.timestamp_t, @intCast(ts.nsec)); |
| 106 | 109 | } |
| 107 | 110 | }, |
| 108 | | .windows => extern struct { |
| 111 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20 |
| 112 | .windows, .serenity => extern struct { |
| 109 | 113 | sec: time_t, |
| 110 | 114 | nsec: c_long, |
| 111 | 115 | }, |
| ... | ... | @@ -129,7 +133,8 @@ pub const dev_t = switch (native_os) { |
| 129 | 133 | .emscripten => emscripten.dev_t, |
| 130 | 134 | .wasi => wasi.device_t, |
| 131 | 135 | .openbsd, .haiku, .solaris, .illumos, .macos, .ios, .tvos, .watchos, .visionos => i32, |
| 132 | | .netbsd, .freebsd => u64, |
| 136 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L43 |
| 137 | .netbsd, .freebsd, .serenity => u64, |
| 133 | 138 | else => void, |
| 134 | 139 | }; |
| 135 | 140 | |
| ... | ... | @@ -137,7 +142,8 @@ pub const mode_t = switch (native_os) { |
| 137 | 142 | .linux => linux.mode_t, |
| 138 | 143 | .emscripten => emscripten.mode_t, |
| 139 | 144 | .openbsd, .haiku, .netbsd, .solaris, .illumos, .wasi, .windows => u32, |
| 140 | | .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .dragonfly => u16, |
| 145 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L44 |
| 146 | .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .dragonfly, .serenity => u16, |
| 141 | 147 | else => u0, |
| 142 | 148 | }; |
| 143 | 149 | |
| ... | ... | @@ -145,7 +151,8 @@ pub const nlink_t = switch (native_os) { |
| 145 | 151 | .linux => linux.nlink_t, |
| 146 | 152 | .emscripten => emscripten.nlink_t, |
| 147 | 153 | .wasi => c_ulonglong, |
| 148 | | .freebsd => u64, |
| 154 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L45 |
| 155 | .freebsd, .serenity => u64, |
| 149 | 156 | .openbsd, .netbsd, .solaris, .illumos => u32, |
| 150 | 157 | .haiku => i32, |
| 151 | 158 | else => void, |
| ... | ... | @@ -154,12 +161,14 @@ pub const nlink_t = switch (native_os) { |
| 154 | 161 | pub const uid_t = switch (native_os) { |
| 155 | 162 | .linux => linux.uid_t, |
| 156 | 163 | .emscripten => emscripten.uid_t, |
| 164 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L28 |
| 157 | 165 | else => u32, |
| 158 | 166 | }; |
| 159 | 167 | |
| 160 | 168 | pub const gid_t = switch (native_os) { |
| 161 | 169 | .linux => linux.gid_t, |
| 162 | 170 | .emscripten => emscripten.gid_t, |
| 171 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L29 |
| 163 | 172 | else => u32, |
| 164 | 173 | }; |
| 165 | 174 | |
| ... | ... | @@ -167,11 +176,14 @@ pub const blksize_t = switch (native_os) { |
| 167 | 176 | .linux => linux.blksize_t, |
| 168 | 177 | .emscripten => emscripten.blksize_t, |
| 169 | 178 | .wasi => c_long, |
| 179 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L42 |
| 180 | .serenity => u64, |
| 170 | 181 | else => i32, |
| 171 | 182 | }; |
| 172 | 183 | |
| 173 | 184 | pub const passwd = switch (native_os) { |
| 174 | | .linux => extern struct { |
| 185 | // https://github.com/SerenityOS/serenity/blob/7442cfb5072b74a62c0e061e6e9ff44fda08780d/Userland/Libraries/LibC/pwd.h#L15-L23 |
| 186 | .linux, .serenity => extern struct { |
| 175 | 187 | name: ?[*:0]const u8, // username |
| 176 | 188 | passwd: ?[*:0]const u8, // user password |
| 177 | 189 | uid: uid_t, // user ID |
| ... | ... | @@ -199,6 +211,8 @@ pub const blkcnt_t = switch (native_os) { |
| 199 | 211 | .linux => linux.blkcnt_t, |
| 200 | 212 | .emscripten => emscripten.blkcnt_t, |
| 201 | 213 | .wasi => c_longlong, |
| 214 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L41 |
| 215 | .serenity => u64, |
| 202 | 216 | else => i64, |
| 203 | 217 | }; |
| 204 | 218 | |
| ... | ... | @@ -206,6 +220,7 @@ pub const fd_t = switch (native_os) { |
| 206 | 220 | .linux => linux.fd_t, |
| 207 | 221 | .wasi => wasi.fd_t, |
| 208 | 222 | .windows => windows.HANDLE, |
| 223 | .serenity => c_int, |
| 209 | 224 | else => i32, |
| 210 | 225 | }; |
| 211 | 226 | |
| ... | ... | @@ -309,6 +324,14 @@ pub const clockid_t = switch (native_os) { |
| 309 | 324 | MONOTONIC = 3, |
| 310 | 325 | THREAD_CPUTIME_ID = 4, |
| 311 | 326 | }, |
| 327 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L24-L36 |
| 328 | .serenity => enum(c_int) { |
| 329 | REALTIME = 0, |
| 330 | MONOTONIC = 1, |
| 331 | MONOTONIC_RAW = 2, |
| 332 | REALTIME_COARSE = 3, |
| 333 | MONOTONIC_COARSE = 4, |
| 334 | }, |
| 312 | 335 | else => void, |
| 313 | 336 | }; |
| 314 | 337 | pub const CPU_COUNT = switch (native_os) { |
| ... | ... | @@ -681,6 +704,93 @@ pub const E = switch (native_os) { |
| 681 | 704 | .dragonfly => dragonfly.E, |
| 682 | 705 | .haiku => haiku.E, |
| 683 | 706 | .openbsd => openbsd.E, |
| 707 | // https://github.com/SerenityOS/serenity/blob/dd59fe35c7e5bbaf6b6b3acb3f9edc56619d4b66/Kernel/API/POSIX/errno.h |
| 708 | .serenity => enum(c_int) { |
| 709 | SUCCESS = 0, |
| 710 | PERM = 1, |
| 711 | NOENT = 2, |
| 712 | SRCH = 3, |
| 713 | INTR = 4, |
| 714 | IO = 5, |
| 715 | NXIO = 6, |
| 716 | @"2BIG" = 7, |
| 717 | NOEXEC = 8, |
| 718 | BADF = 9, |
| 719 | CHILD = 10, |
| 720 | AGAIN = 11, |
| 721 | NOMEM = 12, |
| 722 | ACCES = 13, |
| 723 | FAULT = 14, |
| 724 | NOTBLK = 15, |
| 725 | BUSY = 16, |
| 726 | EXIST = 17, |
| 727 | XDEV = 18, |
| 728 | NODEV = 19, |
| 729 | NOTDIR = 20, |
| 730 | ISDIR = 21, |
| 731 | INVAL = 22, |
| 732 | NFILE = 23, |
| 733 | MFILE = 24, |
| 734 | NOTTY = 25, |
| 735 | TXTBSY = 26, |
| 736 | FBIG = 27, |
| 737 | NOSPC = 28, |
| 738 | SPIPE = 29, |
| 739 | ROFS = 30, |
| 740 | MLINK = 31, |
| 741 | PIPE = 32, |
| 742 | RANGE = 33, |
| 743 | NAMETOOLONG = 34, |
| 744 | LOOP = 35, |
| 745 | OVERFLOW = 36, |
| 746 | OPNOTSUPP = 37, |
| 747 | NOSYS = 38, |
| 748 | NOTIMPL = 39, |
| 749 | AFNOSUPPORT = 40, |
| 750 | NOTSOCK = 41, |
| 751 | ADDRINUSE = 42, |
| 752 | NOTEMPTY = 43, |
| 753 | DOM = 44, |
| 754 | CONNREFUSED = 45, |
| 755 | HOSTDOWN = 46, |
| 756 | ADDRNOTAVAIL = 47, |
| 757 | ISCONN = 48, |
| 758 | CONNABORTED = 49, |
| 759 | ALREADY = 50, |
| 760 | CONNRESET = 51, |
| 761 | DESTADDRREQ = 52, |
| 762 | HOSTUNREACH = 53, |
| 763 | ILSEQ = 54, |
| 764 | MSGSIZE = 55, |
| 765 | NETDOWN = 56, |
| 766 | NETUNREACH = 57, |
| 767 | NETRESET = 58, |
| 768 | NOBUFS = 59, |
| 769 | NOLCK = 60, |
| 770 | NOMSG = 61, |
| 771 | NOPROTOOPT = 62, |
| 772 | NOTCONN = 63, |
| 773 | SHUTDOWN = 64, |
| 774 | TOOMANYREFS = 65, |
| 775 | SOCKTNOSUPPORT = 66, |
| 776 | PROTONOSUPPORT = 67, |
| 777 | DEADLK = 68, |
| 778 | TIMEDOUT = 69, |
| 779 | PROTOTYPE = 70, |
| 780 | INPROGRESS = 71, |
| 781 | NOTHREAD = 72, |
| 782 | PROTO = 73, |
| 783 | NOTSUP = 74, |
| 784 | PFNOSUPPORT = 75, |
| 785 | DIRINTOSELF = 76, |
| 786 | DQUOT = 77, |
| 787 | NOTRECOVERABLE = 78, |
| 788 | CANCELED = 79, |
| 789 | PROMISEVIOLATION = 80, |
| 790 | STALE = 81, |
| 791 | SRCNOTFOUND = 82, |
| 792 | _, |
| 793 | }, |
| 684 | 794 | else => void, |
| 685 | 795 | }; |
| 686 | 796 | pub const Elf_Symndx = switch (native_os) { |
| ... | ... | @@ -1054,6 +1164,24 @@ pub const F = switch (native_os) { |
| 1054 | 1164 | pub const UNLCK = 2; |
| 1055 | 1165 | pub const WRLCK = 3; |
| 1056 | 1166 | }, |
| 1167 | .serenity => struct { |
| 1168 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L15-L24 |
| 1169 | pub const DUPFD = 0; |
| 1170 | pub const GETFD = 1; |
| 1171 | pub const SETFD = 2; |
| 1172 | pub const GETFL = 3; |
| 1173 | pub const SETFL = 4; |
| 1174 | pub const ISTTY = 5; |
| 1175 | pub const GETLK = 6; |
| 1176 | pub const SETLK = 7; |
| 1177 | pub const SETLKW = 8; |
| 1178 | pub const DUPFD_CLOEXEC = 9; |
| 1179 | |
| 1180 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L45-L47 |
| 1181 | pub const RDLCK = 0; |
| 1182 | pub const WRLCK = 1; |
| 1183 | pub const UNLCK = 2; |
| 1184 | }, |
| 1057 | 1185 | else => void, |
| 1058 | 1186 | }; |
| 1059 | 1187 | pub const FD_CLOEXEC = switch (native_os) { |
| ... | ... | @@ -1129,18 +1257,29 @@ pub const Flock = switch (native_os) { |
| 1129 | 1257 | len: off_t, |
| 1130 | 1258 | pid: pid_t, |
| 1131 | 1259 | }, |
| 1260 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L54-L60 |
| 1261 | .serenity => extern struct { |
| 1262 | type: c_short, |
| 1263 | whence: c_short, |
| 1264 | start: off_t, |
| 1265 | len: off_t, |
| 1266 | pid: pid_t, |
| 1267 | }, |
| 1132 | 1268 | else => void, |
| 1133 | 1269 | }; |
| 1134 | 1270 | pub const HOST_NAME_MAX = switch (native_os) { |
| 1135 | 1271 | .linux => linux.HOST_NAME_MAX, |
| 1136 | 1272 | .macos, .ios, .tvos, .watchos, .visionos => 72, |
| 1137 | 1273 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd => 255, |
| 1274 | // https://github.com/SerenityOS/serenity/blob/c87557e9c1865fa1a6440de34ff6ce6fc858a2b7/Kernel/API/POSIX/sys/limits.h#L22 |
| 1275 | .serenity => 64, |
| 1138 | 1276 | else => {}, |
| 1139 | 1277 | }; |
| 1140 | 1278 | pub const IOV_MAX = switch (native_os) { |
| 1141 | 1279 | .linux => linux.IOV_MAX, |
| 1142 | 1280 | .emscripten => emscripten.IOV_MAX, |
| 1143 | | .openbsd, .haiku, .solaris, .illumos, .wasi => 1024, |
| 1281 | // https://github.com/SerenityOS/serenity/blob/098af0f846a87b651731780ff48420205fd33754/Kernel/API/POSIX/sys/uio.h#L16 |
| 1282 | .openbsd, .haiku, .solaris, .illumos, .wasi, .serenity => 1024, |
| 1144 | 1283 | .macos, .ios, .tvos, .watchos, .visionos => 16, |
| 1145 | 1284 | .dragonfly, .netbsd, .freebsd => KERN.IOV_MAX, |
| 1146 | 1285 | else => {}, |
| ... | ... | @@ -1425,6 +1564,16 @@ pub const MADV = switch (native_os) { |
| 1425 | 1564 | pub const INVAL = 10; |
| 1426 | 1565 | pub const SETMAP = 11; |
| 1427 | 1566 | }, |
| 1567 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L35-L41 |
| 1568 | .serenity => struct { |
| 1569 | pub const NORMAL = 0x0; |
| 1570 | pub const SET_VOLATILE = 0x1; |
| 1571 | pub const SET_NONVOLATILE = 0x2; |
| 1572 | pub const DONTNEED = 0x3; |
| 1573 | pub const WILLNEED = 0x4; |
| 1574 | pub const SEQUENTIAL = 0x5; |
| 1575 | pub const RANDOM = 0x6; |
| 1576 | }, |
| 1428 | 1577 | else => void, |
| 1429 | 1578 | }; |
| 1430 | 1579 | pub const MSF = switch (native_os) { |
| ... | ... | @@ -1444,6 +1593,12 @@ pub const MSF = switch (native_os) { |
| 1444 | 1593 | pub const INVALIDATE = 2; |
| 1445 | 1594 | pub const SYNC = 4; |
| 1446 | 1595 | }, |
| 1596 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L50-L52 |
| 1597 | .serenity => struct { |
| 1598 | pub const SYNC = 1; |
| 1599 | pub const ASYNC = 2; |
| 1600 | pub const INVALIDATE = 4; |
| 1601 | }, |
| 1447 | 1602 | else => void, |
| 1448 | 1603 | }; |
| 1449 | 1604 | pub const MMAP2_UNIT = switch (native_os) { |
| ... | ... | @@ -1456,7 +1611,8 @@ pub const NAME_MAX = switch (native_os) { |
| 1456 | 1611 | // Haiku's headers make this 256, to contain room for the terminating null |
| 1457 | 1612 | // character, but POSIX definition says that NAME_MAX does not include the |
| 1458 | 1613 | // terminating null. |
| 1459 | | .haiku, .openbsd, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => 255, |
| 1614 | // https://github.com/SerenityOS/serenity/blob/c87557e9c1865fa1a6440de34ff6ce6fc858a2b7/Kernel/API/POSIX/sys/limits.h#L20 |
| 1615 | .haiku, .openbsd, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => 255, |
| 1460 | 1616 | else => {}, |
| 1461 | 1617 | }; |
| 1462 | 1618 | pub const PATH_MAX = switch (native_os) { |
| ... | ... | @@ -1464,7 +1620,7 @@ pub const PATH_MAX = switch (native_os) { |
| 1464 | 1620 | .emscripten => emscripten.PATH_MAX, |
| 1465 | 1621 | .wasi => 4096, |
| 1466 | 1622 | .windows => 260, |
| 1467 | | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => 1024, |
| 1623 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => 1024, |
| 1468 | 1624 | else => {}, |
| 1469 | 1625 | }; |
| 1470 | 1626 | |
| ... | ... | @@ -1597,6 +1753,19 @@ pub const POLL = switch (native_os) { |
| 1597 | 1753 | pub const RDBAND = 0x0080; |
| 1598 | 1754 | pub const WRBAND = 0x0100; |
| 1599 | 1755 | }, |
| 1756 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L15-L24 |
| 1757 | .serenity => struct { |
| 1758 | pub const IN = 0x0001; |
| 1759 | pub const PRI = 0x0002; |
| 1760 | pub const OUT = 0x0004; |
| 1761 | pub const ERR = 0x0008; |
| 1762 | pub const HUP = 0x0010; |
| 1763 | pub const NVAL = 0x0020; |
| 1764 | pub const RDNORM = IN; |
| 1765 | pub const WRNORM = OUT; |
| 1766 | pub const WRBAND = 0x1000; |
| 1767 | pub const RDHUP = 0x2000; |
| 1768 | }, |
| 1600 | 1769 | else => void, |
| 1601 | 1770 | }; |
| 1602 | 1771 | |
| ... | ... | @@ -1604,7 +1773,8 @@ pub const POLL = switch (native_os) { |
| 1604 | 1773 | pub const PROT = switch (native_os) { |
| 1605 | 1774 | .linux => linux.PROT, |
| 1606 | 1775 | .emscripten => emscripten.PROT, |
| 1607 | | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .windows => struct { |
| 1776 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L28-L31 |
| 1777 | .openbsd, .haiku, .dragonfly, .netbsd, .solaris, .illumos, .freebsd, .windows, .serenity => struct { |
| 1608 | 1778 | /// page can not be accessed |
| 1609 | 1779 | pub const NONE = 0x0; |
| 1610 | 1780 | /// page can be read |
| ... | ... | @@ -1719,7 +1889,8 @@ pub const REG = switch (native_os) { |
| 1719 | 1889 | pub const RLIM = switch (native_os) { |
| 1720 | 1890 | .linux => linux.RLIM, |
| 1721 | 1891 | .emscripten => emscripten.RLIM, |
| 1722 | | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => struct { |
| 1892 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L52 |
| 1893 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => struct { |
| 1723 | 1894 | /// No limit |
| 1724 | 1895 | pub const INFINITY: rlim_t = (1 << 63) - 1; |
| 1725 | 1896 | |
| ... | ... | @@ -2174,6 +2345,66 @@ pub const S = switch (native_os) { |
| 2174 | 2345 | return m & IFMT == IFSOCK; |
| 2175 | 2346 | } |
| 2176 | 2347 | }, |
| 2348 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L16-L51 |
| 2349 | .serenity => struct { |
| 2350 | pub const IFMT = 0o170000; |
| 2351 | pub const IFDIR = 0o040000; |
| 2352 | pub const IFCHR = 0o020000; |
| 2353 | pub const IFBLK = 0o060000; |
| 2354 | pub const IFREG = 0o100000; |
| 2355 | pub const IFIFO = 0o010000; |
| 2356 | pub const IFLNK = 0o120000; |
| 2357 | pub const IFSOCK = 0o140000; |
| 2358 | |
| 2359 | pub const ISUID = 0o4000; |
| 2360 | pub const ISGID = 0o2000; |
| 2361 | pub const ISVTX = 0o1000; |
| 2362 | pub const IRUSR = 0o400; |
| 2363 | pub const IWUSR = 0o200; |
| 2364 | pub const IXUSR = 0o100; |
| 2365 | pub const IREAD = IRUSR; |
| 2366 | pub const IWRITE = IWUSR; |
| 2367 | pub const IEXEC = IXUSR; |
| 2368 | pub const IRGRP = 0o040; |
| 2369 | pub const IWGRP = 0o020; |
| 2370 | pub const IXGRP = 0o010; |
| 2371 | pub const IROTH = 0o004; |
| 2372 | pub const IWOTH = 0o002; |
| 2373 | pub const IXOTH = 0o001; |
| 2374 | |
| 2375 | pub const IRWXU = IRUSR | IWUSR | IXUSR; |
| 2376 | |
| 2377 | pub const IRWXG = IRWXU >> 3; |
| 2378 | pub const IRWXO = IRWXG >> 3; |
| 2379 | |
| 2380 | pub fn ISDIR(m: u32) bool { |
| 2381 | return m & IFMT == IFDIR; |
| 2382 | } |
| 2383 | |
| 2384 | pub fn ISCHR(m: u32) bool { |
| 2385 | return m & IFMT == IFCHR; |
| 2386 | } |
| 2387 | |
| 2388 | pub fn ISBLK(m: u32) bool { |
| 2389 | return m & IFMT == IFBLK; |
| 2390 | } |
| 2391 | |
| 2392 | pub fn ISREG(m: u32) bool { |
| 2393 | return m & IFMT == IFREG; |
| 2394 | } |
| 2395 | |
| 2396 | pub fn ISFIFO(m: u32) bool { |
| 2397 | return m & IFMT == IFIFO; |
| 2398 | } |
| 2399 | |
| 2400 | pub fn ISLNK(m: u32) bool { |
| 2401 | return m & IFMT == IFLNK; |
| 2402 | } |
| 2403 | |
| 2404 | pub fn ISSOCK(m: u32) bool { |
| 2405 | return m & IFMT == IFSOCK; |
| 2406 | } |
| 2407 | }, |
| 2177 | 2408 | else => void, |
| 2178 | 2409 | }; |
| 2179 | 2410 | pub const SA = switch (native_os) { |
| ... | ... | @@ -2254,6 +2485,18 @@ pub const SA = switch (native_os) { |
| 2254 | 2485 | pub const NOCLDWAIT = 0x0020; |
| 2255 | 2486 | pub const SIGINFO = 0x0040; |
| 2256 | 2487 | }, |
| 2488 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L65-L71 |
| 2489 | .serenity => struct { |
| 2490 | pub const NOCLDSTOP = 1; |
| 2491 | pub const NOCLDWAIT = 2; |
| 2492 | pub const SIGINFO = 4; |
| 2493 | pub const ONSTACK = 0x08000000; |
| 2494 | pub const RESTART = 0x10000000; |
| 2495 | pub const NODEFER = 0x40000000; |
| 2496 | pub const RESETHAND = 0x80000000; |
| 2497 | pub const NOMASK = NODEFER; |
| 2498 | pub const ONESHOT = RESETHAND; |
| 2499 | }, |
| 2257 | 2500 | else => void, |
| 2258 | 2501 | }; |
| 2259 | 2502 | pub const sigval_t = switch (native_os) { |
| ... | ... | @@ -2298,6 +2541,24 @@ pub const _SC = switch (native_os) { |
| 2298 | 2541 | PAGESIZE = 11, |
| 2299 | 2542 | NPROCESSORS_ONLN = 15, |
| 2300 | 2543 | }, |
| 2544 | // https://github.com/SerenityOS/serenity/blob/1dfc9e2df39dd23f1de92530677c845aae4345f2/Kernel/API/POSIX/unistd.h#L36-L52 |
| 2545 | .serenity => enum(c_int) { |
| 2546 | MONOTONIC_CLOCK = 0, |
| 2547 | NPROCESSORS_CONF = 1, |
| 2548 | NPROCESSORS_ONLN = 2, |
| 2549 | OPEN_MAX = 3, |
| 2550 | HOST_NAME_MAX = 4, |
| 2551 | TTY_NAME_MAX = 5, |
| 2552 | PAGESIZE = 6, |
| 2553 | GETPW_R_SIZE_MAX = 7, |
| 2554 | GETGR_R_SIZE_MAX = 8, |
| 2555 | CLK_TCK = 9, |
| 2556 | SYMLOOP_MAX = 10, |
| 2557 | MAPPED_FILES = 11, |
| 2558 | ARG_MAX = 12, |
| 2559 | IOV_MAX = 13, |
| 2560 | PHYS_PAGES = 14, |
| 2561 | }, |
| 2301 | 2562 | else => void, |
| 2302 | 2563 | }; |
| 2303 | 2564 | |
| ... | ... | @@ -2309,7 +2570,8 @@ pub const SEEK = switch (native_os) { |
| 2309 | 2570 | pub const CUR: wasi.whence_t = .CUR; |
| 2310 | 2571 | pub const END: wasi.whence_t = .END; |
| 2311 | 2572 | }, |
| 2312 | | .openbsd, .haiku, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .windows => struct { |
| 2573 | // https://github.com/SerenityOS/serenity/blob/808ce594db1f2190e5212a250e900bde2ffe710b/Kernel/API/POSIX/stdio.h#L15-L17 |
| 2574 | .openbsd, .haiku, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .windows, .serenity => struct { |
| 2313 | 2575 | pub const SET = 0; |
| 2314 | 2576 | pub const CUR = 1; |
| 2315 | 2577 | pub const END = 2; |
| ... | ... | @@ -2326,6 +2588,7 @@ pub const SEEK = switch (native_os) { |
| 2326 | 2588 | pub const SHUT = switch (native_os) { |
| 2327 | 2589 | .linux => linux.SHUT, |
| 2328 | 2590 | .emscripten => emscripten.SHUT, |
| 2591 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L40-L42 |
| 2329 | 2592 | else => struct { |
| 2330 | 2593 | pub const RD = 0; |
| 2331 | 2594 | pub const WR = 1; |
| ... | ... | @@ -2785,6 +3048,42 @@ pub const SIG = switch (native_os) { |
| 2785 | 3048 | pub const UNBLOCK = 2; |
| 2786 | 3049 | pub const SETMASK = 3; |
| 2787 | 3050 | }, |
| 3051 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h |
| 3052 | .serenity => struct { |
| 3053 | pub const INVAL = 0; |
| 3054 | pub const HUP = 1; |
| 3055 | pub const INT = 2; |
| 3056 | pub const QUIT = 3; |
| 3057 | pub const ILL = 4; |
| 3058 | pub const TRAP = 5; |
| 3059 | pub const ABRT = 6; |
| 3060 | pub const BUS = 7; |
| 3061 | pub const FPE = 8; |
| 3062 | pub const KILL = 9; |
| 3063 | pub const USR1 = 10; |
| 3064 | pub const SEGV = 11; |
| 3065 | pub const USR2 = 12; |
| 3066 | pub const PIPE = 13; |
| 3067 | pub const ALRM = 14; |
| 3068 | pub const TERM = 15; |
| 3069 | pub const STKFLT = 16; |
| 3070 | pub const CHLD = 17; |
| 3071 | pub const CONT = 18; |
| 3072 | pub const STOP = 19; |
| 3073 | pub const TSTP = 20; |
| 3074 | pub const TTIN = 21; |
| 3075 | pub const TTOU = 22; |
| 3076 | pub const URG = 23; |
| 3077 | pub const XCPU = 24; |
| 3078 | pub const XFSZ = 25; |
| 3079 | pub const VTALRM = 26; |
| 3080 | pub const PROF = 27; |
| 3081 | pub const WINCH = 28; |
| 3082 | pub const IO = 29; |
| 3083 | pub const INFO = 30; |
| 3084 | pub const SYS = 31; |
| 3085 | pub const CANCEL = 32; |
| 3086 | }, |
| 2788 | 3087 | else => void, |
| 2789 | 3088 | }; |
| 2790 | 3089 | |
| ... | ... | @@ -2792,6 +3091,8 @@ pub const SIOCGIFINDEX = switch (native_os) { |
| 2792 | 3091 | .linux => linux.SIOCGIFINDEX, |
| 2793 | 3092 | .emscripten => emscripten.SIOCGIFINDEX, |
| 2794 | 3093 | .solaris, .illumos => solaris.SIOCGLIFINDEX, |
| 3094 | // https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L118 |
| 3095 | .serenity => 34, |
| 2795 | 3096 | else => void, |
| 2796 | 3097 | }; |
| 2797 | 3098 | |
| ... | ... | @@ -2936,6 +3237,18 @@ pub const Sigaction = switch (native_os) { |
| 2936 | 3237 | /// signal options |
| 2937 | 3238 | flags: c_uint, |
| 2938 | 3239 | }, |
| 3240 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L39-L46 |
| 3241 | .serenity => extern struct { |
| 3242 | pub const handler_fn = *align(1) const fn (c_int) callconv(.c) void; |
| 3243 | pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
| 3244 | |
| 3245 | handler: extern union { |
| 3246 | handler: ?handler_fn, |
| 3247 | sigaction: ?sigaction_fn, |
| 3248 | }, |
| 3249 | mask: sigset_t, |
| 3250 | flags: c_int, |
| 3251 | }, |
| 2939 | 3252 | else => void, |
| 2940 | 3253 | }; |
| 2941 | 3254 | pub const T = switch (native_os) { |
| ... | ... | @@ -3311,6 +3624,22 @@ pub const T = switch (native_os) { |
| 3311 | 3624 | pub const IOCGDRAINWAIT = 0x40047456; |
| 3312 | 3625 | pub const IOCISPTMASTER = 0x20007455; |
| 3313 | 3626 | }, |
| 3627 | // https://github.com/SerenityOS/serenity/blob/cb10f70394fb7e9cfc77f827adb2e46d199bc3a5/Kernel/API/Ioctl.h#L84-L96 |
| 3628 | .serenity => struct { |
| 3629 | pub const IOCGPGRP = 0; |
| 3630 | pub const IOCSPGRP = 1; |
| 3631 | pub const CGETS = 2; |
| 3632 | pub const CSETS = 3; |
| 3633 | pub const CSETSW = 4; |
| 3634 | pub const CSETSF = 5; |
| 3635 | pub const CFLSH = 6; |
| 3636 | pub const IOCGWINSZ = 7; |
| 3637 | pub const IOCSCTTY = 8; |
| 3638 | pub const IOCSTI = 9; |
| 3639 | pub const IOCNOTTY = 10; |
| 3640 | pub const IOCSWINSZ = 11; |
| 3641 | pub const IOCGPTN = 12; |
| 3642 | }, |
| 3314 | 3643 | else => void, |
| 3315 | 3644 | }; |
| 3316 | 3645 | pub const IOCPARM_MASK = switch (native_os) { |
| ... | ... | @@ -3546,6 +3875,43 @@ pub const W = switch (native_os) { |
| 3546 | 3875 | return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0); |
| 3547 | 3876 | } |
| 3548 | 3877 | }, |
| 3878 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/wait.h |
| 3879 | .serenity => struct { |
| 3880 | pub const NOHANG = 1; |
| 3881 | pub const UNTRACED = 2; |
| 3882 | pub const STOPPED = UNTRACED; |
| 3883 | pub const EXITED = 4; |
| 3884 | pub const CONTINUED = 8; |
| 3885 | pub const NOWAIT = 0x1000000; |
| 3886 | |
| 3887 | pub fn EXITSTATUS(s: u32) u8 { |
| 3888 | return @intCast((s & 0xff00) >> 8); |
| 3889 | } |
| 3890 | |
| 3891 | pub fn STOPSIG(s: u32) u32 { |
| 3892 | return EXITSTATUS(s); |
| 3893 | } |
| 3894 | |
| 3895 | pub fn TERMSIG(s: u32) u32 { |
| 3896 | return s & 0x7f; |
| 3897 | } |
| 3898 | |
| 3899 | pub fn IFEXITED(s: u32) bool { |
| 3900 | return TERMSIG(s) == 0; |
| 3901 | } |
| 3902 | |
| 3903 | pub fn IFSTOPPED(s: u32) bool { |
| 3904 | return (s & 0xff) == 0x7f; |
| 3905 | } |
| 3906 | |
| 3907 | pub fn IFSIGNALED(s: u32) bool { |
| 3908 | return (((s & 0x7f) + 1) >> 1) > 0; |
| 3909 | } |
| 3910 | |
| 3911 | pub fn IFCONTINUED(s: u32) bool { |
| 3912 | return s == 0xffff; |
| 3913 | } |
| 3914 | }, |
| 3549 | 3915 | else => void, |
| 3550 | 3916 | }; |
| 3551 | 3917 | pub const clock_t = switch (native_os) { |
| ... | ... | @@ -3556,6 +3922,8 @@ pub const clock_t = switch (native_os) { |
| 3556 | 3922 | .openbsd, .solaris, .illumos => i64, |
| 3557 | 3923 | .netbsd => u32, |
| 3558 | 3924 | .haiku => i32, |
| 3925 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L50 |
| 3926 | .serenity => u64, |
| 3559 | 3927 | else => void, |
| 3560 | 3928 | }; |
| 3561 | 3929 | pub const cpu_set_t = switch (native_os) { |
| ... | ... | @@ -3568,7 +3936,7 @@ pub const dl_phdr_info = switch (native_os) { |
| 3568 | 3936 | .emscripten => emscripten.dl_phdr_info, |
| 3569 | 3937 | .freebsd => extern struct { |
| 3570 | 3938 | /// Module relocation base. |
| 3571 | | addr: if (builtin.target.ptrBitWidth() == 32) std.elf.Elf32_Addr else std.elf.Elf64_Addr, |
| 3939 | addr: std.elf.Addr, |
| 3572 | 3940 | /// Module name. |
| 3573 | 3941 | name: ?[*:0]const u8, |
| 3574 | 3942 | /// Pointer to module's phdr. |
| ... | ... | @@ -3592,11 +3960,12 @@ pub const dl_phdr_info = switch (native_os) { |
| 3592 | 3960 | /// Incremented when an object is unmapped from the process. |
| 3593 | 3961 | subs: u64, |
| 3594 | 3962 | }, |
| 3595 | | .openbsd, .haiku, .dragonfly, .netbsd => extern struct { |
| 3963 | // https://github.com/SerenityOS/serenity/blob/45d81dceed81df0c8ef75b440b20cc0938195faa/Userland/Libraries/LibC/link.h#L15-L20 |
| 3964 | .openbsd, .haiku, .dragonfly, .netbsd, .serenity => extern struct { |
| 3596 | 3965 | addr: usize, |
| 3597 | 3966 | name: ?[*:0]const u8, |
| 3598 | 3967 | phdr: [*]std.elf.Phdr, |
| 3599 | | phnum: u16, |
| 3968 | phnum: std.elf.Half, |
| 3600 | 3969 | }, |
| 3601 | 3970 | else => void, |
| 3602 | 3971 | }; |
| ... | ... | @@ -3608,6 +3977,26 @@ pub const ifreq = switch (native_os) { |
| 3608 | 3977 | .linux => linux.ifreq, |
| 3609 | 3978 | .emscripten => emscripten.ifreq, |
| 3610 | 3979 | .solaris, .illumos => lifreq, |
| 3980 | // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L49-L82 |
| 3981 | .serenity => extern struct { |
| 3982 | // Not actually in a union, but the stdlib expects one for ifreq |
| 3983 | ifrn: extern union { |
| 3984 | name: [IFNAMESIZE]u8, |
| 3985 | }, |
| 3986 | ifru: extern union { |
| 3987 | addr: sockaddr, |
| 3988 | dstaddr: sockaddr, |
| 3989 | broadaddr: sockaddr, |
| 3990 | netmask: sockaddr, |
| 3991 | hwaddr: sockaddr, |
| 3992 | flags: c_short, |
| 3993 | metric: c_int, |
| 3994 | vnetid: i64, |
| 3995 | media: u64, |
| 3996 | data: ?*anyopaque, |
| 3997 | index: c_uint, |
| 3998 | }, |
| 3999 | }, |
| 3611 | 4000 | else => void, |
| 3612 | 4001 | }; |
| 3613 | 4002 | pub const itimerspec = switch (native_os) { |
| ... | ... | @@ -3650,6 +4039,16 @@ pub const msghdr = switch (native_os) { |
| 3650 | 4039 | /// flags on received message |
| 3651 | 4040 | flags: i32, |
| 3652 | 4041 | }, |
| 4042 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L74-L82 |
| 4043 | .serenity => extern struct { |
| 4044 | name: ?*anyopaque, |
| 4045 | namelen: socklen_t, |
| 4046 | iov: [*]iovec, |
| 4047 | iovlen: c_int, |
| 4048 | control: ?*anyopaque, |
| 4049 | controllen: socklen_t, |
| 4050 | flags: c_int, |
| 4051 | }, |
| 3653 | 4052 | else => void, |
| 3654 | 4053 | }; |
| 3655 | 4054 | pub const msghdr_const = switch (native_os) { |
| ... | ... | @@ -3684,6 +4083,15 @@ pub const msghdr_const = switch (native_os) { |
| 3684 | 4083 | /// flags on received message |
| 3685 | 4084 | flags: i32, |
| 3686 | 4085 | }, |
| 4086 | .serenity => extern struct { |
| 4087 | name: ?*const anyopaque, |
| 4088 | namelen: socklen_t, |
| 4089 | iov: [*]const iovec, |
| 4090 | iovlen: c_int, |
| 4091 | control: ?*const anyopaque, |
| 4092 | controllen: socklen_t, |
| 4093 | flags: c_int, |
| 4094 | }, |
| 3687 | 4095 | else => void, |
| 3688 | 4096 | }; |
| 3689 | 4097 | pub const nfds_t = switch (native_os) { |
| ... | ... | @@ -3692,6 +4100,8 @@ pub const nfds_t = switch (native_os) { |
| 3692 | 4100 | .haiku, .solaris, .illumos, .wasi => usize, |
| 3693 | 4101 | .windows => c_ulong, |
| 3694 | 4102 | .openbsd, .dragonfly, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => u32, |
| 4103 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L32 |
| 4104 | .serenity => c_uint, |
| 3695 | 4105 | else => void, |
| 3696 | 4106 | }; |
| 3697 | 4107 | pub const perf_event_attr = switch (native_os) { |
| ... | ... | @@ -3702,12 +4112,20 @@ pub const pid_t = switch (native_os) { |
| 3702 | 4112 | .linux => linux.pid_t, |
| 3703 | 4113 | .emscripten => emscripten.pid_t, |
| 3704 | 4114 | .windows => windows.HANDLE, |
| 4115 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L31-L32 |
| 4116 | .serenity => c_int, |
| 3705 | 4117 | else => i32, |
| 3706 | 4118 | }; |
| 3707 | 4119 | pub const pollfd = switch (native_os) { |
| 3708 | 4120 | .linux => linux.pollfd, |
| 3709 | 4121 | .emscripten => emscripten.pollfd, |
| 3710 | 4122 | .windows => ws2_32.pollfd, |
| 4123 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L26-L30 |
| 4124 | .serenity => extern struct { |
| 4125 | fd: fd_t, |
| 4126 | events: c_short, |
| 4127 | revents: c_short, |
| 4128 | }, |
| 3711 | 4129 | else => extern struct { |
| 3712 | 4130 | fd: fd_t, |
| 3713 | 4131 | events: i16, |
| ... | ... | @@ -3719,11 +4137,14 @@ pub const rlim_t = switch (native_os) { |
| 3719 | 4137 | .emscripten => emscripten.rlim_t, |
| 3720 | 4138 | .openbsd, .netbsd, .solaris, .illumos, .macos, .ios, .tvos, .watchos, .visionos => u64, |
| 3721 | 4139 | .haiku, .dragonfly, .freebsd => i64, |
| 4140 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L54 |
| 4141 | .serenity => usize, |
| 3722 | 4142 | else => void, |
| 3723 | 4143 | }; |
| 3724 | 4144 | pub const rlimit = switch (native_os) { |
| 3725 | 4145 | .linux, .emscripten => linux.rlimit, |
| 3726 | 4146 | .windows => void, |
| 4147 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L56-L59 |
| 3727 | 4148 | else => extern struct { |
| 3728 | 4149 | /// Soft limit |
| 3729 | 4150 | cur: rlim_t, |
| ... | ... | @@ -3825,6 +4246,17 @@ pub const rlimit_resource = switch (native_os) { |
| 3825 | 4246 | NOVMON = 7, |
| 3826 | 4247 | _, |
| 3827 | 4248 | }, |
| 4249 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L42-L48 |
| 4250 | .serenity => enum(c_int) { |
| 4251 | CORE = 1, |
| 4252 | CPU = 2, |
| 4253 | DATA = 3, |
| 4254 | FSIZE = 4, |
| 4255 | NOFILE = 5, |
| 4256 | STACK = 6, |
| 4257 | AS = 7, |
| 4258 | _, |
| 4259 | }, |
| 3828 | 4260 | else => void, |
| 3829 | 4261 | }; |
| 3830 | 4262 | pub const rusage = switch (native_os) { |
| ... | ... | @@ -3873,6 +4305,28 @@ pub const rusage = switch (native_os) { |
| 3873 | 4305 | pub const CHILDREN = -1; |
| 3874 | 4306 | pub const THREAD = 1; |
| 3875 | 4307 | }, |
| 4308 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/sys/resource.h#L18-L38 |
| 4309 | .serenity => extern struct { |
| 4310 | utime: timeval, |
| 4311 | stime: timeval, |
| 4312 | maxrss: c_long, |
| 4313 | ixrss: c_long, |
| 4314 | idrss: c_long, |
| 4315 | isrss: c_long, |
| 4316 | minflt: c_long, |
| 4317 | majflt: c_long, |
| 4318 | nswap: c_long, |
| 4319 | inblock: c_long, |
| 4320 | oublock: c_long, |
| 4321 | msgsnd: c_long, |
| 4322 | msgrcv: c_long, |
| 4323 | nsignals: c_long, |
| 4324 | nvcsw: c_long, |
| 4325 | nivcsw: c_long, |
| 4326 | |
| 4327 | pub const SELF = 1; |
| 4328 | pub const CHILDREN = 2; |
| 4329 | }, |
| 3876 | 4330 | else => void, |
| 3877 | 4331 | }; |
| 3878 | 4332 | |
| ... | ... | @@ -4050,12 +4504,25 @@ pub const siginfo_t = switch (native_os) { |
| 4050 | 4504 | assert(@sizeOf(@This()) == 136); |
| 4051 | 4505 | } |
| 4052 | 4506 | }, |
| 4507 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L27-L37 |
| 4508 | .serenity => extern struct { |
| 4509 | signo: c_int, |
| 4510 | code: c_int, |
| 4511 | errno: c_int, |
| 4512 | pid: pid_t, |
| 4513 | uid: uid_t, |
| 4514 | addr: ?*anyopaque, |
| 4515 | status: c_int, |
| 4516 | band: c_int, |
| 4517 | value: sigval, |
| 4518 | }, |
| 4053 | 4519 | else => void, |
| 4054 | 4520 | }; |
| 4055 | 4521 | pub const sigset_t = switch (native_os) { |
| 4056 | 4522 | .linux => linux.sigset_t, |
| 4057 | 4523 | .emscripten => emscripten.sigset_t, |
| 4058 | | .openbsd, .macos, .ios, .tvos, .watchos, .visionos => u32, |
| 4524 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L19 |
| 4525 | .openbsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => u32, |
| 4059 | 4526 | .dragonfly, .netbsd, .solaris, .illumos, .freebsd => extern struct { |
| 4060 | 4527 | __bits: [SIG.WORDS]u32, |
| 4061 | 4528 | }, |
| ... | ... | @@ -4075,7 +4542,8 @@ pub const filled_sigset = switch (native_os) { |
| 4075 | 4542 | }; |
| 4076 | 4543 | pub const sigval = switch (native_os) { |
| 4077 | 4544 | .linux => linux.sigval, |
| 4078 | | .openbsd, .dragonfly, .freebsd => extern union { |
| 4545 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L22-L25 |
| 4546 | .openbsd, .dragonfly, .freebsd, .serenity => extern union { |
| 4079 | 4547 | int: c_int, |
| 4080 | 4548 | ptr: ?*anyopaque, |
| 4081 | 4549 | }, |
| ... | ... | @@ -4144,7 +4612,8 @@ pub const addrinfo = if (builtin.abi.isAndroid()) extern struct { |
| 4144 | 4612 | addr: ?*sockaddr, |
| 4145 | 4613 | next: ?*addrinfo, |
| 4146 | 4614 | }, |
| 4147 | | .openbsd => extern struct { |
| 4615 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L66-L75 |
| 4616 | .openbsd, .serenity => extern struct { |
| 4148 | 4617 | flags: AI, |
| 4149 | 4618 | family: c_int, |
| 4150 | 4619 | socktype: c_int, |
| ... | ... | @@ -4460,11 +4929,41 @@ pub const sockaddr = switch (native_os) { |
| 4460 | 4929 | path: [104]u8, |
| 4461 | 4930 | }; |
| 4462 | 4931 | }, |
| 4932 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L110-L114 |
| 4933 | .serenity => extern struct { |
| 4934 | family: sa_family_t, |
| 4935 | data: [26]u8, |
| 4936 | |
| 4937 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/netinet/in.h |
| 4938 | const in_addr = u32; |
| 4939 | const in6_addr = [16]u8; |
| 4940 | pub const in = extern struct { |
| 4941 | family: sa_family_t = AF.INET, |
| 4942 | port: in_port_t, |
| 4943 | addr: in_addr, |
| 4944 | zero: [8]u8 = @splat(0), |
| 4945 | }; |
| 4946 | pub const in6 = extern struct { |
| 4947 | family: sa_family_t = AF.INET6, |
| 4948 | port: in_port_t, |
| 4949 | flowinfo: u32, |
| 4950 | addr: in6_addr, |
| 4951 | scope_id: u32, |
| 4952 | }; |
| 4953 | |
| 4954 | // https://github.com/SerenityOS/serenity/blob/b92e6b02e53b2927732f31b1442cad420b62d1ef/Kernel/API/POSIX/sys/un.h |
| 4955 | const UNIX_PATH_MAX = 108; |
| 4956 | pub const un = extern struct { |
| 4957 | family: sa_family_t = AF.LOCAL, |
| 4958 | path: [UNIX_PATH_MAX]u8, |
| 4959 | }; |
| 4960 | }, |
| 4463 | 4961 | else => void, |
| 4464 | 4962 | }; |
| 4465 | 4963 | pub const socklen_t = switch (native_os) { |
| 4466 | 4964 | .linux, .emscripten => linux.socklen_t, |
| 4467 | 4965 | .windows => ws2_32.socklen_t, |
| 4966 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L57 |
| 4468 | 4967 | else => u32, |
| 4469 | 4968 | }; |
| 4470 | 4969 | pub const in_port_t = u16; |
| ... | ... | @@ -4472,7 +4971,8 @@ pub const sa_family_t = switch (native_os) { |
| 4472 | 4971 | .linux, .emscripten => linux.sa_family_t, |
| 4473 | 4972 | .windows => ws2_32.ADDRESS_FAMILY, |
| 4474 | 4973 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => u8, |
| 4475 | | .solaris, .illumos => u16, |
| 4974 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L66 |
| 4975 | .solaris, .illumos, .serenity => u16, |
| 4476 | 4976 | else => void, |
| 4477 | 4977 | }; |
| 4478 | 4978 | pub const AF = if (builtin.abi.isAndroid()) struct { |
| ... | ... | @@ -4751,6 +5251,15 @@ pub const AF = if (builtin.abi.isAndroid()) struct { |
| 4751 | 5251 | pub const ISDN = 26; |
| 4752 | 5252 | pub const MAX = 36; |
| 4753 | 5253 | }, |
| 5254 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L17-L22 |
| 5255 | .serenity => struct { |
| 5256 | pub const UNSPEC = 0; |
| 5257 | pub const LOCAL = 1; |
| 5258 | pub const UNIX = LOCAL; |
| 5259 | pub const INET = 2; |
| 5260 | pub const INET6 = 3; |
| 5261 | pub const MAX = 4; |
| 5262 | }, |
| 4754 | 5263 | else => void, |
| 4755 | 5264 | }; |
| 4756 | 5265 | pub const PF = if (builtin.abi.isAndroid()) struct { |
| ... | ... | @@ -5020,11 +5529,21 @@ pub const PF = if (builtin.abi.isAndroid()) struct { |
| 5020 | 5529 | pub const ISDN = AF.ISDN; |
| 5021 | 5530 | pub const MAX = AF.MAX; |
| 5022 | 5531 | }, |
| 5532 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L24-L29 |
| 5533 | .serenity => struct { |
| 5534 | pub const LOCAL = AF.LOCAL; |
| 5535 | pub const UNIX = AF.LOCAL; |
| 5536 | pub const INET = AF.INET; |
| 5537 | pub const INET6 = AF.INET6; |
| 5538 | pub const UNSPEC = AF.UNSPEC; |
| 5539 | pub const MAX = AF.MAX; |
| 5540 | }, |
| 5023 | 5541 | else => void, |
| 5024 | 5542 | }; |
| 5025 | 5543 | pub const DT = switch (native_os) { |
| 5026 | 5544 | .linux => linux.DT, |
| 5027 | | .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => struct { |
| 5545 | // https://github.com/SerenityOS/serenity/blob/1262a7d1424d0d2e89d80644409721cbf056ab17/Kernel/API/POSIX/dirent.h#L16-L35 |
| 5546 | .netbsd, .freebsd, .openbsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => struct { |
| 5028 | 5547 | pub const UNKNOWN = 0; |
| 5029 | 5548 | pub const FIFO = 1; |
| 5030 | 5549 | pub const CHR = 2; |
| ... | ... | @@ -5047,17 +5566,6 @@ pub const DT = switch (native_os) { |
| 5047 | 5566 | pub const WHT = 14; |
| 5048 | 5567 | pub const DBF = 15; |
| 5049 | 5568 | }, |
| 5050 | | .openbsd => struct { |
| 5051 | | pub const UNKNOWN = 0; |
| 5052 | | pub const FIFO = 1; |
| 5053 | | pub const CHR = 2; |
| 5054 | | pub const DIR = 4; |
| 5055 | | pub const BLK = 6; |
| 5056 | | pub const REG = 8; |
| 5057 | | pub const LNK = 10; |
| 5058 | | pub const SOCK = 12; |
| 5059 | | pub const WHT = 14; // XXX |
| 5060 | | }, |
| 5061 | 5569 | else => void, |
| 5062 | 5570 | }; |
| 5063 | 5571 | pub const MSG = switch (native_os) { |
| ... | ... | @@ -5078,6 +5586,18 @@ pub const MSG = switch (native_os) { |
| 5078 | 5586 | pub const EOF = 0x0400; |
| 5079 | 5587 | pub const NOSIGNAL = 0x0800; |
| 5080 | 5588 | }, |
| 5589 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L56-L64 |
| 5590 | .serenity => struct { |
| 5591 | pub const TRUNC = 0x1; |
| 5592 | pub const CTRUNC = 0x2; |
| 5593 | pub const PEEK = 0x4; |
| 5594 | pub const OOB = 0x8; |
| 5595 | pub const DONTROUTE = 0x10; |
| 5596 | pub const WAITALL = 0x20; |
| 5597 | pub const DONTWAIT = 0x40; |
| 5598 | pub const NOSIGNAL = 0x80; |
| 5599 | pub const EOR = 0x100; |
| 5600 | }, |
| 5081 | 5601 | else => void, |
| 5082 | 5602 | }; |
| 5083 | 5603 | pub const SOCK = switch (native_os) { |
| ... | ... | @@ -5168,6 +5688,17 @@ pub const SOCK = switch (native_os) { |
| 5168 | 5688 | pub const CLOEXEC = 0x8000; |
| 5169 | 5689 | pub const NONBLOCK = 0x4000; |
| 5170 | 5690 | }, |
| 5691 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L31-L38 |
| 5692 | .serenity => struct { |
| 5693 | pub const STREAM = 1; |
| 5694 | pub const DGRAM = 2; |
| 5695 | pub const RAW = 3; |
| 5696 | pub const RDM = 4; |
| 5697 | pub const SEQPACKET = 5; |
| 5698 | |
| 5699 | pub const NONBLOCK = 0o4000; |
| 5700 | pub const CLOEXEC = 0o2000000; |
| 5701 | }, |
| 5171 | 5702 | else => void, |
| 5172 | 5703 | }; |
| 5173 | 5704 | pub const TCP = switch (native_os) { |
| ... | ... | @@ -5175,6 +5706,11 @@ pub const TCP = switch (native_os) { |
| 5175 | 5706 | .linux => linux.TCP, |
| 5176 | 5707 | .emscripten => emscripten.TCP, |
| 5177 | 5708 | .windows => ws2_32.TCP, |
| 5709 | // https://github.com/SerenityOS/serenity/blob/61ac554a3403838f79ca746bd1c65ded6f97d124/Kernel/API/POSIX/netinet/tcp.h#L13-L14 |
| 5710 | .serenity => struct { |
| 5711 | pub const NODELAY = 10; |
| 5712 | pub const MAXSEG = 11; |
| 5713 | }, |
| 5178 | 5714 | else => void, |
| 5179 | 5715 | }; |
| 5180 | 5716 | pub const IPPROTO = switch (native_os) { |
| ... | ... | @@ -5759,6 +6295,20 @@ pub const IPPROTO = switch (native_os) { |
| 5759 | 6295 | /// raw IP packet |
| 5760 | 6296 | pub const RAW = 255; |
| 5761 | 6297 | }, |
| 6298 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L44-L54 |
| 6299 | .serenity => struct { |
| 6300 | pub const IP = 0; |
| 6301 | pub const ICMP = 1; |
| 6302 | pub const IGMP = 2; |
| 6303 | pub const IPIP = 4; |
| 6304 | pub const TCP = 6; |
| 6305 | pub const UDP = 17; |
| 6306 | pub const IPV6 = 41; |
| 6307 | pub const ESP = 50; |
| 6308 | pub const AH = 51; |
| 6309 | pub const ICMPV6 = 58; |
| 6310 | pub const RAW = 255; |
| 6311 | }, |
| 5762 | 6312 | else => void, |
| 5763 | 6313 | }; |
| 5764 | 6314 | pub const SOL = switch (native_os) { |
| ... | ... | @@ -5774,6 +6324,10 @@ pub const SOL = switch (native_os) { |
| 5774 | 6324 | pub const PACKET = 0xfffd; |
| 5775 | 6325 | pub const FILTER = 0xfffc; |
| 5776 | 6326 | }, |
| 6327 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L127 |
| 6328 | .serenity => struct { |
| 6329 | pub const SOCKET = 1; |
| 6330 | }, |
| 5777 | 6331 | else => void, |
| 5778 | 6332 | }; |
| 5779 | 6333 | pub const SO = switch (native_os) { |
| ... | ... | @@ -5991,12 +6545,35 @@ pub const SO = switch (native_os) { |
| 5991 | 6545 | pub const DOMAIN = 0x1024; |
| 5992 | 6546 | pub const PROTOCOL = 0x1025; |
| 5993 | 6547 | }, |
| 6548 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L130-L150 |
| 6549 | .serenity => struct { |
| 6550 | pub const RCVTIMEO = 0; |
| 6551 | pub const SNDTIMEO = 1; |
| 6552 | pub const TYPE = 2; |
| 6553 | pub const ERROR = 3; |
| 6554 | pub const PEERCRED = 4; |
| 6555 | pub const RCVBUF = 5; |
| 6556 | pub const SNDBUF = 6; |
| 6557 | pub const DEBUG = 7; |
| 6558 | pub const REUSEADDR = 8; |
| 6559 | pub const BINDTODEVICE = 9; |
| 6560 | pub const KEEPALIVE = 10; |
| 6561 | pub const TIMESTAMP = 11; |
| 6562 | pub const BROADCAST = 12; |
| 6563 | pub const LINGER = 13; |
| 6564 | pub const ACCEPTCONN = 14; |
| 6565 | pub const DONTROUTE = 15; |
| 6566 | pub const OOBINLINE = 16; |
| 6567 | pub const SNDLOWAT = 17; |
| 6568 | pub const RCVLOWAT = 18; |
| 6569 | }, |
| 5994 | 6570 | else => void, |
| 5995 | 6571 | }; |
| 5996 | 6572 | pub const SOMAXCONN = switch (native_os) { |
| 5997 | 6573 | .linux => linux.SOMAXCONN, |
| 5998 | 6574 | .windows => ws2_32.SOMAXCONN, |
| 5999 | | .solaris, .illumos => 128, |
| 6575 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L128 |
| 6576 | .solaris, .illumos, .serenity => 128, |
| 6000 | 6577 | .openbsd => 28, |
| 6001 | 6578 | else => void, |
| 6002 | 6579 | }; |
| ... | ... | @@ -6004,7 +6581,8 @@ pub const IFNAMESIZE = switch (native_os) { |
| 6004 | 6581 | .linux => linux.IFNAMESIZE, |
| 6005 | 6582 | .emscripten => emscripten.IFNAMESIZE, |
| 6006 | 6583 | .windows => 30, |
| 6007 | | .openbsd, .dragonfly, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos => 16, |
| 6584 | // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L50 |
| 6585 | .openbsd, .dragonfly, .netbsd, .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => 16, |
| 6008 | 6586 | .solaris, .illumos => 32, |
| 6009 | 6587 | else => void, |
| 6010 | 6588 | }; |
| ... | ... | @@ -6020,6 +6598,12 @@ pub const stack_t = switch (native_os) { |
| 6020 | 6598 | /// SS_DISABLE and/or SS_ONSTACK. |
| 6021 | 6599 | flags: i32, |
| 6022 | 6600 | }, |
| 6601 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L48-L52 |
| 6602 | .serenity => extern struct { |
| 6603 | sp: *anyopaque, |
| 6604 | flags: c_int, |
| 6605 | size: usize, |
| 6606 | }, |
| 6023 | 6607 | else => extern struct { |
| 6024 | 6608 | sp: [*]u8, |
| 6025 | 6609 | size: isize, |
| ... | ... | @@ -6030,10 +6614,12 @@ pub const time_t = switch (native_os) { |
| 6030 | 6614 | .linux => linux.time_t, |
| 6031 | 6615 | .emscripten => emscripten.time_t, |
| 6032 | 6616 | .haiku, .dragonfly => isize, |
| 6617 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47 |
| 6033 | 6618 | else => i64, |
| 6034 | 6619 | }; |
| 6035 | 6620 | pub const suseconds_t = switch (native_os) { |
| 6036 | | .solaris, .illumos => i64, |
| 6621 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L49 |
| 6622 | .solaris, .illumos, .serenity => i64, |
| 6037 | 6623 | .freebsd, .dragonfly => c_long, |
| 6038 | 6624 | .netbsd => c_int, |
| 6039 | 6625 | .haiku => i32, |
| ... | ... | @@ -6051,7 +6637,8 @@ pub const timeval = switch (native_os) { |
| 6051 | 6637 | sec: c_long, |
| 6052 | 6638 | usec: i32, |
| 6053 | 6639 | }, |
| 6054 | | .dragonfly, .netbsd, .freebsd, .solaris, .illumos => extern struct { |
| 6640 | // https://github.com/SerenityOS/serenity/blob/6b6eca0631c893c5f8cfb8274cdfe18e2d0637c0/Kernel/API/POSIX/sys/time.h#L15-L18 |
| 6641 | .dragonfly, .netbsd, .freebsd, .solaris, .illumos, .serenity => extern struct { |
| 6055 | 6642 | /// seconds |
| 6056 | 6643 | sec: time_t, |
| 6057 | 6644 | /// microseconds |
| ... | ... | @@ -6070,6 +6657,11 @@ pub const timezone = switch (native_os) { |
| 6070 | 6657 | minuteswest: i32, |
| 6071 | 6658 | dsttime: i32, |
| 6072 | 6659 | }, |
| 6660 | // https://github.com/SerenityOS/serenity/blob/ba776390b5878ec0be1a9e595a3471a6cfe0a0cf/Userland/Libraries/LibC/sys/time.h#L19-L22 |
| 6661 | .serenity => extern struct { |
| 6662 | minuteswest: c_int, |
| 6663 | dsttime: c_int, |
| 6664 | }, |
| 6073 | 6665 | else => void, |
| 6074 | 6666 | }; |
| 6075 | 6667 | |
| ... | ... | @@ -6127,7 +6719,8 @@ pub const ucontext_t = switch (native_os) { |
| 6127 | 6719 | arg: ?*void, |
| 6128 | 6720 | _spare: [4]c_int, |
| 6129 | 6721 | }, |
| 6130 | | .haiku => extern struct { |
| 6722 | // https://github.com/SerenityOS/serenity/blob/87eac0e424cff4a1f941fb704b9362a08654c24d/Kernel/API/POSIX/ucontext.h#L19-L24 |
| 6723 | .haiku, .serenity => extern struct { |
| 6131 | 6724 | link: ?*ucontext_t, |
| 6132 | 6725 | sigmask: sigset_t, |
| 6133 | 6726 | stack: stack_t, |
| ... | ... | @@ -6222,6 +6815,47 @@ pub const mcontext_t = switch (native_os) { |
| 6222 | 6815 | }, |
| 6223 | 6816 | .dragonfly => dragonfly.mcontext_t, |
| 6224 | 6817 | .haiku => haiku.mcontext_t, |
| 6818 | .serenity => switch (native_arch) { |
| 6819 | // https://github.com/SerenityOS/serenity/blob/200e91cd7f1ec5453799a2720d4dc114a59cc289/Kernel/Arch/aarch64/mcontext.h#L15-L19 |
| 6820 | .aarch64 => extern struct { |
| 6821 | x: [31]u64, |
| 6822 | sp: u64, |
| 6823 | pc: u64, |
| 6824 | }, |
| 6825 | // https://github.com/SerenityOS/serenity/blob/66f8d0f031ef25c409dbb4fecaa454800fecae0f/Kernel/Arch/riscv64/mcontext.h#L15-L18 |
| 6826 | .riscv64 => extern struct { |
| 6827 | x: [31]u64, |
| 6828 | pc: u64, |
| 6829 | }, |
| 6830 | // https://github.com/SerenityOS/serenity/blob/7b9ea3efdec9f86a1042893e8107d0b23aad8727/Kernel/Arch/x86_64/mcontext.h#L15-L40 |
| 6831 | .x86_64 => extern struct { |
| 6832 | rax: u64, |
| 6833 | rcx: u64, |
| 6834 | rdx: u64, |
| 6835 | rbx: u64, |
| 6836 | rsp: u64, |
| 6837 | rbp: u64, |
| 6838 | rsi: u64, |
| 6839 | rdi: u64, |
| 6840 | rip: u64, |
| 6841 | r8: u64, |
| 6842 | r9: u64, |
| 6843 | r10: u64, |
| 6844 | r11: u64, |
| 6845 | r12: u64, |
| 6846 | r13: u64, |
| 6847 | r14: u64, |
| 6848 | r15: u64, |
| 6849 | rflags: u64, |
| 6850 | cs: u32, |
| 6851 | ss: u32, |
| 6852 | ds: u32, |
| 6853 | es: u32, |
| 6854 | fs: u32, |
| 6855 | gs: u32, |
| 6856 | }, |
| 6857 | else => struct {}, |
| 6858 | }, |
| 6225 | 6859 | else => void, |
| 6226 | 6860 | }; |
| 6227 | 6861 | |
| ... | ... | @@ -6247,6 +6881,16 @@ pub const utsname = switch (native_os) { |
| 6247 | 6881 | version: [256:0]u8, |
| 6248 | 6882 | machine: [256:0]u8, |
| 6249 | 6883 | }, |
| 6884 | // https://github.com/SerenityOS/serenity/blob/d794ed1de7a46482272683f8dc4c858806390f29/Kernel/API/POSIX/sys/utsname.h#L17-L23 |
| 6885 | .serenity => extern struct { |
| 6886 | sysname: [UTSNAME_ENTRY_LEN:0]u8, |
| 6887 | nodename: [UTSNAME_ENTRY_LEN:0]u8, |
| 6888 | release: [UTSNAME_ENTRY_LEN:0]u8, |
| 6889 | version: [UTSNAME_ENTRY_LEN:0]u8, |
| 6890 | machine: [UTSNAME_ENTRY_LEN:0]u8, |
| 6891 | |
| 6892 | const UTSNAME_ENTRY_LEN = 65; |
| 6893 | }, |
| 6250 | 6894 | else => void, |
| 6251 | 6895 | }; |
| 6252 | 6896 | pub const PR = switch (native_os) { |
| ... | ... | @@ -6265,6 +6909,8 @@ pub const _errno = switch (native_os) { |
| 6265 | 6909 | .solaris, .illumos => private.___errno, |
| 6266 | 6910 | .openbsd, .netbsd => private.__errno, |
| 6267 | 6911 | .haiku => haiku._errnop, |
| 6912 | // https://github.com/SerenityOS/serenity/blob/a353ceecf13b6f156a078e32f1ddf1d21366934c/Userland/Libraries/LibC/errno.h#L33 |
| 6913 | .serenity => private.__errno_location, |
| 6268 | 6914 | else => {}, |
| 6269 | 6915 | }; |
| 6270 | 6916 | |
| ... | ... | @@ -6340,6 +6986,16 @@ pub const RTLD = switch (native_os) { |
| 6340 | 6986 | FIRST: bool = false, |
| 6341 | 6987 | _: u23 = 0, |
| 6342 | 6988 | }, |
| 6989 | // https://github.com/SerenityOS/serenity/blob/36a26d7fa80bc9c72b19442912d8967f448368ff/Userland/Libraries/LibC/dlfcn.h#L13-L17 |
| 6990 | .serenity => packed struct(c_int) { |
| 6991 | DEFAULT: bool = false, |
| 6992 | _1: u1, |
| 6993 | LAZY: bool = false, |
| 6994 | NOW: bool = false, |
| 6995 | GLOBAL: bool = false, |
| 6996 | LOCAL: bool = false, |
| 6997 | _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 6) = 0, |
| 6998 | }, |
| 6343 | 6999 | else => void, |
| 6344 | 7000 | }; |
| 6345 | 7001 | |
| ... | ... | @@ -6413,11 +7069,20 @@ pub const dirent = switch (native_os) { |
| 6413 | 7069 | _: u32 align(1) = 0, |
| 6414 | 7070 | name: [MAXNAMLEN:0]u8, |
| 6415 | 7071 | }, |
| 7072 | // https://github.com/SerenityOS/serenity/blob/abc150085f532f123b598949218893cb272ccc4c/Userland/Libraries/LibC/dirent.h#L14-L20 |
| 7073 | .serenity => extern struct { |
| 7074 | ino: ino_t, |
| 7075 | off: off_t, |
| 7076 | reclen: c_ushort, |
| 7077 | type: u8, |
| 7078 | name: [256:0]u8, |
| 7079 | }, |
| 6416 | 7080 | else => void, |
| 6417 | 7081 | }; |
| 6418 | 7082 | pub const MAXNAMLEN = switch (native_os) { |
| 6419 | 7083 | .netbsd, .solaris, .illumos => 511, |
| 6420 | | .haiku => NAME_MAX, |
| 7084 | // https://github.com/SerenityOS/serenity/blob/1262a7d1424d0d2e89d80644409721cbf056ab17/Kernel/API/POSIX/dirent.h#L37 |
| 7085 | .haiku, .serenity => NAME_MAX, |
| 6421 | 7086 | .openbsd => 255, |
| 6422 | 7087 | else => {}, |
| 6423 | 7088 | }; |
| ... | ... | @@ -6499,6 +7164,17 @@ pub const AI = if (builtin.abi.isAndroid()) packed struct(u32) { |
| 6499 | 7164 | _: u19 = 0, |
| 6500 | 7165 | }, |
| 6501 | 7166 | .windows => ws2_32.AI, |
| 7167 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L90-L96 |
| 7168 | .serenity => packed struct(c_int) { |
| 7169 | PASSIVE: bool = false, |
| 7170 | CANONNAME: bool = false, |
| 7171 | NUMERICHOST: bool = false, |
| 7172 | NUMERICSERV: bool = false, |
| 7173 | V4MAPPED: bool = false, |
| 7174 | ALL: bool = false, |
| 7175 | ADDRCONFIG: bool = false, |
| 7176 | _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 7) = 0, |
| 7177 | }, |
| 6502 | 7178 | else => void, |
| 6503 | 7179 | }; |
| 6504 | 7180 | |
| ... | ... | @@ -6523,6 +7199,15 @@ pub const NI = switch (native_os) { |
| 6523 | 7199 | NUMERICSCOPE: bool = false, |
| 6524 | 7200 | _: u25 = 0, |
| 6525 | 7201 | }, |
| 7202 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L101-L105 |
| 7203 | .serenity => packed struct(c_int) { |
| 7204 | NUMERICHOST: bool = false, |
| 7205 | NUMERICSERV: bool = false, |
| 7206 | NAMEREQD: bool = false, |
| 7207 | NOFQDN: bool = false, |
| 7208 | DGRAM: bool = false, |
| 7209 | _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 5) = 0, |
| 7210 | }, |
| 6526 | 7211 | else => void, |
| 6527 | 7212 | }; |
| 6528 | 7213 | |
| ... | ... | @@ -6675,6 +7360,22 @@ pub const EAI = if (builtin.abi.isAndroid()) enum(c_int) { |
| 6675 | 7360 | OVERFLOW = -14, |
| 6676 | 7361 | _, |
| 6677 | 7362 | }, |
| 7363 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L77-L88 |
| 7364 | .serenity => enum(c_int) { |
| 7365 | ADDRFAMILY = 1, |
| 7366 | AGAIN = 2, |
| 7367 | BADFLAGS = 3, |
| 7368 | FAIL = 4, |
| 7369 | FAMILY = 5, |
| 7370 | MEMORY = 6, |
| 7371 | NODATA = 7, |
| 7372 | NONAME = 8, |
| 7373 | SERVICE = 9, |
| 7374 | SOCKTYPE = 10, |
| 7375 | SYSTEM = 11, |
| 7376 | OVERFLOW = 12, |
| 7377 | _, |
| 7378 | }, |
| 6678 | 7379 | else => void, |
| 6679 | 7380 | }; |
| 6680 | 7381 | |
| ... | ... | @@ -7097,6 +7798,34 @@ pub const Stat = switch (native_os) { |
| 7097 | 7798 | return self.birthtim; |
| 7098 | 7799 | } |
| 7099 | 7800 | }, |
| 7801 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L53-L67 |
| 7802 | .serenity => extern struct { |
| 7803 | dev: dev_t, |
| 7804 | ino: ino_t, |
| 7805 | mode: mode_t, |
| 7806 | nlink: nlink_t, |
| 7807 | uid: uid_t, |
| 7808 | gid: gid_t, |
| 7809 | rdev: dev_t, |
| 7810 | size: off_t, |
| 7811 | blksize: blksize_t, |
| 7812 | blocks: blkcnt_t, |
| 7813 | atim: timespec, |
| 7814 | mtim: timespec, |
| 7815 | ctim: timespec, |
| 7816 | |
| 7817 | pub fn atime(self: @This()) timespec { |
| 7818 | return self.atim; |
| 7819 | } |
| 7820 | |
| 7821 | pub fn mtime(self: @This()) timespec { |
| 7822 | return self.mtim; |
| 7823 | } |
| 7824 | |
| 7825 | pub fn ctime(self: @This()) timespec { |
| 7826 | return self.ctim; |
| 7827 | } |
| 7828 | }, |
| 7100 | 7829 | else => void, |
| 7101 | 7830 | }; |
| 7102 | 7831 | |
| ... | ... | @@ -7159,6 +7888,13 @@ pub const pthread_mutex_t = switch (native_os) { |
| 7159 | 7888 | .emscripten => extern struct { |
| 7160 | 7889 | data: [24]u8 align(4) = [_]u8{0} ** 24, |
| 7161 | 7890 | }, |
| 7891 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L68-L73 |
| 7892 | .serenity => extern struct { |
| 7893 | lock: u32 = 0, |
| 7894 | owner: pthread_t = 0, |
| 7895 | level: c_int = 0, |
| 7896 | type: c_int = 0, |
| 7897 | }, |
| 7162 | 7898 | else => void, |
| 7163 | 7899 | }; |
| 7164 | 7900 | |
| ... | ... | @@ -7201,6 +7937,12 @@ pub const pthread_cond_t = switch (native_os) { |
| 7201 | 7937 | .fuchsia, .emscripten => extern struct { |
| 7202 | 7938 | data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48, |
| 7203 | 7939 | }, |
| 7940 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L80-L84 |
| 7941 | .serenity => extern struct { |
| 7942 | mutex: ?*pthread_mutex_t = null, |
| 7943 | value: u32 = 0, |
| 7944 | clockid: clockid_t = .REALTIME_COARSE, |
| 7945 | }, |
| 7204 | 7946 | else => void, |
| 7205 | 7947 | }; |
| 7206 | 7948 | |
| ... | ... | @@ -7258,6 +8000,10 @@ pub const pthread_rwlock_t = switch (native_os) { |
| 7258 | 8000 | .emscripten => extern struct { |
| 7259 | 8001 | size: [32]u8 align(4) = [_]u8{0} ** 32, |
| 7260 | 8002 | }, |
| 8003 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L86 |
| 8004 | .serenity => extern struct { |
| 8005 | inner: u64 = 0, |
| 8006 | }, |
| 7261 | 8007 | else => void, |
| 7262 | 8008 | }; |
| 7263 | 8009 | |
| ... | ... | @@ -7270,7 +8016,8 @@ pub const pthread_attr_t = switch (native_os) { |
| 7270 | 8016 | __sig: c_long, |
| 7271 | 8017 | __opaque: [56]u8, |
| 7272 | 8018 | }, |
| 7273 | | .freebsd => extern struct { |
| 8019 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L75 |
| 8020 | .freebsd, .openbsd, .serenity => extern struct { |
| 7274 | 8021 | inner: ?*anyopaque = null, |
| 7275 | 8022 | }, |
| 7276 | 8023 | .solaris, .illumos => extern struct { |
| ... | ... | @@ -7288,16 +8035,14 @@ pub const pthread_attr_t = switch (native_os) { |
| 7288 | 8035 | guard_size: i32, |
| 7289 | 8036 | stack_address: ?*anyopaque, |
| 7290 | 8037 | }, |
| 7291 | | .openbsd => extern struct { |
| 7292 | | inner: ?*anyopaque = null, |
| 7293 | | }, |
| 7294 | 8038 | else => void, |
| 7295 | 8039 | }; |
| 7296 | 8040 | |
| 7297 | 8041 | pub const pthread_key_t = switch (native_os) { |
| 7298 | 8042 | .linux, .emscripten => c_uint, |
| 7299 | 8043 | .macos, .ios, .tvos, .watchos, .visionos => c_ulong, |
| 7300 | | .openbsd, .solaris, .illumos => c_int, |
| 8044 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L65 |
| 8045 | .openbsd, .solaris, .illumos, .serenity => c_int, |
| 7301 | 8046 | else => void, |
| 7302 | 8047 | }; |
| 7303 | 8048 | |
| ... | ... | @@ -7353,6 +8098,12 @@ pub const sem_t = switch (native_os) { |
| 7353 | 8098 | }, |
| 7354 | 8099 | padding: [2]i32, |
| 7355 | 8100 | }, |
| 8101 | // https://github.com/SerenityOS/serenity/blob/aae106e37b48f2158e68902293df1e4bf7b80c0f/Userland/Libraries/LibC/semaphore.h#L23-L27 |
| 8102 | .serenity => extern struct { |
| 8103 | magic: u32, |
| 8104 | value: u32, |
| 8105 | flags: u8, |
| 8106 | }, |
| 7356 | 8107 | else => void, |
| 7357 | 8108 | }; |
| 7358 | 8109 | |
| ... | ... | @@ -7556,6 +8307,13 @@ pub const AT = switch (native_os) { |
| 7556 | 8307 | /// file. |
| 7557 | 8308 | pub const FDCWD: fd_t = if (builtin.link_libc) -2 else 3; |
| 7558 | 8309 | }, |
| 8310 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L49-L52 |
| 8311 | .serenity => struct { |
| 8312 | pub const FDCWD = -100; |
| 8313 | pub const SYMLINK_NOFOLLOW = 0x100; |
| 8314 | pub const REMOVEDIR = 0x200; |
| 8315 | pub const EACCESS = 0x400; |
| 8316 | }, |
| 7559 | 8317 | else => void, |
| 7560 | 8318 | }; |
| 7561 | 8319 | |
| ... | ... | @@ -7771,6 +8529,23 @@ pub const O = switch (native_os) { |
| 7771 | 8529 | TMPFILE: bool = false, |
| 7772 | 8530 | _: u9 = 0, |
| 7773 | 8531 | }, |
| 8532 | // https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L28-L43 |
| 8533 | .serenity => packed struct(c_int) { |
| 8534 | ACCMODE: std.posix.ACCMODE = .RDONLY, |
| 8535 | EXEC: bool = false, |
| 8536 | CREAT: bool = false, |
| 8537 | EXCL: bool = false, |
| 8538 | NOCTTY: bool = false, |
| 8539 | TRUNC: bool = false, |
| 8540 | APPEND: bool = false, |
| 8541 | NONBLOCK: bool = false, |
| 8542 | DIRECTORY: bool = false, |
| 8543 | NOFOLLOW: bool = false, |
| 8544 | CLOEXEC: bool = false, |
| 8545 | DIRECT: bool = false, |
| 8546 | SYNC: bool = false, |
| 8547 | _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 14) = 0, |
| 8548 | }, |
| 7774 | 8549 | else => void, |
| 7775 | 8550 | }; |
| 7776 | 8551 | |
| ... | ... | @@ -7910,6 +8685,21 @@ pub const MAP = switch (native_os) { |
| 7910 | 8685 | @"32BIT": bool = false, |
| 7911 | 8686 | _: u12 = 0, |
| 7912 | 8687 | }, |
| 8688 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L16-L26 |
| 8689 | .serenity => packed struct(c_int) { |
| 8690 | FILE: bool = false, |
| 8691 | SHARED: bool = false, |
| 8692 | PRIVATE: bool = false, |
| 8693 | _3: u2 = 0, |
| 8694 | FIXED: bool = false, |
| 8695 | ANONYMOUS: bool = false, |
| 8696 | STACK: bool = false, |
| 8697 | NORESERVE: bool = false, |
| 8698 | RANDOMIZED: bool = false, |
| 8699 | PURGEABLE: bool = false, |
| 8700 | FIXED_NOREPLACE: bool = false, |
| 8701 | _: std.meta.Int(.unsigned, @bitSizeOf(c_int) - 12) = 0, |
| 8702 | }, |
| 7913 | 8703 | else => void, |
| 7914 | 8704 | }; |
| 7915 | 8705 | |
| ... | ... | @@ -8020,6 +8810,27 @@ pub const V = switch (native_os) { |
| 8020 | 8810 | LNEXT, |
| 8021 | 8811 | EOL2, |
| 8022 | 8812 | }, |
| 8813 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L32-L49 |
| 8814 | .serenity => enum { |
| 8815 | INTR, |
| 8816 | QUIT, |
| 8817 | ERASE, |
| 8818 | KILL, |
| 8819 | EOF, |
| 8820 | TIME, |
| 8821 | MIN, |
| 8822 | SWTC, |
| 8823 | START, |
| 8824 | STOP, |
| 8825 | SUSP, |
| 8826 | EOL, |
| 8827 | REPRINT, |
| 8828 | DISCARD, |
| 8829 | WERASE, |
| 8830 | LNEXT, |
| 8831 | EOL2, |
| 8832 | INFO, |
| 8833 | }, |
| 8023 | 8834 | else => void, |
| 8024 | 8835 | }; |
| 8025 | 8836 | |
| ... | ... | @@ -8028,7 +8839,8 @@ pub const NCCS = switch (native_os) { |
| 8028 | 8839 | .macos, .ios, .tvos, .watchos, .visionos, .freebsd, .netbsd, .openbsd, .dragonfly => 20, |
| 8029 | 8840 | .haiku => 11, |
| 8030 | 8841 | .solaris, .illumos => 19, |
| 8031 | | .emscripten, .wasi => 32, |
| 8842 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L15 |
| 8843 | .emscripten, .wasi, .serenity => 32, |
| 8032 | 8844 | else => void, |
| 8033 | 8845 | }; |
| 8034 | 8846 | |
| ... | ... | @@ -8043,7 +8855,8 @@ pub const termios = switch (native_os) { |
| 8043 | 8855 | ispeed: speed_t align(8), |
| 8044 | 8856 | ospeed: speed_t, |
| 8045 | 8857 | }, |
| 8046 | | .freebsd, .netbsd, .dragonfly, .openbsd => extern struct { |
| 8858 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L21-L29 |
| 8859 | .freebsd, .netbsd, .dragonfly, .openbsd, .serenity => extern struct { |
| 8047 | 8860 | iflag: tc_iflag_t, |
| 8048 | 8861 | oflag: tc_oflag_t, |
| 8049 | 8862 | cflag: tc_cflag_t, |
| ... | ... | @@ -8171,7 +8984,8 @@ pub const tc_iflag_t = switch (native_os) { |
| 8171 | 8984 | DOSMODE: bool = false, |
| 8172 | 8985 | _: u16 = 0, |
| 8173 | 8986 | }, |
| 8174 | | .emscripten, .wasi => packed struct(u32) { |
| 8987 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L52-L66 |
| 8988 | .emscripten, .wasi, .serenity => packed struct(u32) { |
| 8175 | 8989 | IGNBRK: bool = false, |
| 8176 | 8990 | BRKINT: bool = false, |
| 8177 | 8991 | IGNPAR: bool = false, |
| ... | ... | @@ -8263,7 +9077,8 @@ pub const tc_oflag_t = switch (native_os) { |
| 8263 | 9077 | WRAP: bool = false, |
| 8264 | 9078 | _: u14 = 0, |
| 8265 | 9079 | }, |
| 8266 | | .haiku, .wasi, .emscripten => packed struct(u32) { |
| 9080 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L69-L97 |
| 9081 | .haiku, .wasi, .emscripten, .serenity => packed struct(u32) { |
| 8267 | 9082 | OPOST: bool = false, |
| 8268 | 9083 | OLCUC: bool = false, |
| 8269 | 9084 | ONLCR: bool = false, |
| ... | ... | @@ -8422,6 +9237,19 @@ pub const tc_cflag_t = switch (native_os) { |
| 8422 | 9237 | CLOCAL: bool = false, |
| 8423 | 9238 | _: u20 = 0, |
| 8424 | 9239 | }, |
| 9240 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L131-L141 |
| 9241 | .serenity => packed struct(u32) { |
| 9242 | _0: u4 = 0, |
| 9243 | CSIZE: CSIZE = .CS5, |
| 9244 | CSTOPB: bool = false, |
| 9245 | CREAD: bool = false, |
| 9246 | PARENB: bool = false, |
| 9247 | PARODD: bool = false, |
| 9248 | HUPCL: bool = false, |
| 9249 | CLOCAL: bool = false, |
| 9250 | CBAUDEX: bool = false, |
| 9251 | _: u19 = 0, |
| 9252 | }, |
| 8425 | 9253 | else => void, |
| 8426 | 9254 | }; |
| 8427 | 9255 | |
| ... | ... | @@ -8548,6 +9376,27 @@ pub const tc_lflag_t = switch (native_os) { |
| 8548 | 9376 | IEXTEN: bool = false, |
| 8549 | 9377 | _: u16 = 0, |
| 8550 | 9378 | }, |
| 9379 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L168-L189 |
| 9380 | .serenity => packed struct(u32) { |
| 9381 | ISIG: bool = false, |
| 9382 | ICANON: bool = false, |
| 9383 | XCASE: bool = false, |
| 9384 | ECHO: bool = false, |
| 9385 | ECHOE: bool = false, |
| 9386 | ECHOK: bool = false, |
| 9387 | ECHONL: bool = false, |
| 9388 | NOFLSH: bool = false, |
| 9389 | TOSTOP: bool = false, |
| 9390 | ECHOCTL: bool = false, |
| 9391 | ECHOPRT: bool = false, |
| 9392 | ECHOKE: bool = false, |
| 9393 | FLUSHO: bool = false, |
| 9394 | PENDIN: bool = false, |
| 9395 | _14: u6 = 0, |
| 9396 | IEXTEN: bool = false, |
| 9397 | EXTPROC: bool = false, |
| 9398 | _: u15 = 0, |
| 9399 | }, |
| 8551 | 9400 | else => void, |
| 8552 | 9401 | }; |
| 8553 | 9402 | |
| ... | ... | @@ -8696,7 +9545,8 @@ pub const speed_t = switch (native_os) { |
| 8696 | 9545 | B3500000 = 30, |
| 8697 | 9546 | B4000000 = 31, |
| 8698 | 9547 | }, |
| 8699 | | .emscripten, .wasi => enum(u32) { |
| 9548 | // https://github.com/SerenityOS/serenity/blob/d277cdfd4c7ed21d5248a83217ae03b9f890c3c8/Kernel/API/POSIX/termios.h#L111-L159 |
| 9549 | .emscripten, .wasi, .serenity => enum(u32) { |
| 8700 | 9550 | B0 = 0o0000000, |
| 8701 | 9551 | B50 = 0o0000001, |
| 8702 | 9552 | B75 = 0o0000002, |
| ... | ... | @@ -8735,7 +9585,11 @@ pub const speed_t = switch (native_os) { |
| 8735 | 9585 | |
| 8736 | 9586 | pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int; |
| 8737 | 9587 | |
| 8738 | | pub const sig_atomic_t = c_int; |
| 9588 | pub const sig_atomic_t = switch (native_os) { |
| 9589 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L20 |
| 9590 | .serenity => u32, |
| 9591 | else => c_int, |
| 9592 | }; |
| 8739 | 9593 | |
| 8740 | 9594 | /// maximum signal number + 1 |
| 8741 | 9595 | pub const NSIG = switch (native_os) { |
| ... | ... | @@ -8744,7 +9598,8 @@ pub const NSIG = switch (native_os) { |
| 8744 | 9598 | .haiku => 65, |
| 8745 | 9599 | .netbsd, .freebsd => 32, |
| 8746 | 9600 | .solaris, .illumos => 75, |
| 8747 | | .openbsd => 33, |
| 9601 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h#L42 |
| 9602 | .openbsd, .serenity => 33, |
| 8748 | 9603 | else => {}, |
| 8749 | 9604 | }; |
| 8750 | 9605 | |
| ... | ... | @@ -8758,6 +9613,8 @@ pub const MINSIGSTKSZ = switch (native_os) { |
| 8758 | 9613 | .solaris, .illumos => 2048, |
| 8759 | 9614 | .haiku, .netbsd => 8192, |
| 8760 | 9615 | .openbsd => 1 << openbsd.MAX_PAGE_SHIFT, |
| 9616 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L58 |
| 9617 | .serenity => 4096, |
| 8761 | 9618 | else => {}, |
| 8762 | 9619 | }; |
| 8763 | 9620 | pub const SIGSTKSZ = switch (native_os) { |
| ... | ... | @@ -8766,6 +9623,8 @@ pub const SIGSTKSZ = switch (native_os) { |
| 8766 | 9623 | .solaris, .illumos => 8192, |
| 8767 | 9624 | .haiku => 16384, |
| 8768 | 9625 | .openbsd => MINSIGSTKSZ + (1 << openbsd.MAX_PAGE_SHIFT) * 4, |
| 9626 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L59 |
| 9627 | .serenity => 32768, |
| 8769 | 9628 | else => {}, |
| 8770 | 9629 | }; |
| 8771 | 9630 | pub const SS = switch (native_os) { |
| ... | ... | @@ -8774,7 +9633,8 @@ pub const SS = switch (native_os) { |
| 8774 | 9633 | pub const ONSTACK = 1; |
| 8775 | 9634 | pub const DISABLE = 4; |
| 8776 | 9635 | }, |
| 8777 | | .haiku, .solaris, .illumos => struct { |
| 9636 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L54-L55 |
| 9637 | .haiku, .solaris, .illumos, .serenity => struct { |
| 8778 | 9638 | pub const ONSTACK = 0x1; |
| 8779 | 9639 | pub const DISABLE = 0x2; |
| 8780 | 9640 | }, |
| ... | ... | @@ -9267,6 +10127,12 @@ pub const NOTE = switch (native_os) { |
| 9267 | 10127 | else => void, |
| 9268 | 10128 | }; |
| 9269 | 10129 | |
| 10130 | pub const FUTEX = switch (native_os) { |
| 10131 | .openbsd => openbsd.FUTEX, |
| 10132 | .serenity => serenity.FUTEX, |
| 10133 | else => void, |
| 10134 | }; |
| 10135 | |
| 9270 | 10136 | // Unix-like systems |
| 9271 | 10137 | pub const DIR = opaque {}; |
| 9272 | 10138 | pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR; |
| ... | ... | @@ -9327,7 +10193,7 @@ pub extern "c" fn sendfile64(out_fd: fd_t, in_fd: fd_t, offset: ?*i64, count: us |
| 9327 | 10193 | pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_int; |
| 9328 | 10194 | |
| 9329 | 10195 | pub const arc4random_buf = switch (native_os) { |
| 9330 | | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf, |
| 10196 | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .macos, .ios, .tvos, .watchos, .visionos, .serenity => private.arc4random_buf, |
| 9331 | 10197 | else => {}, |
| 9332 | 10198 | }; |
| 9333 | 10199 | pub const getentropy = switch (native_os) { |
| ... | ... | @@ -9395,7 +10261,7 @@ pub const sigaltstack = switch (native_os) { |
| 9395 | 10261 | |
| 9396 | 10262 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; |
| 9397 | 10263 | pub const pipe2 = switch (native_os) { |
| 9398 | | .dragonfly, .emscripten, .netbsd, .freebsd, .solaris, .illumos, .openbsd, .linux => private.pipe2, |
| 10264 | .dragonfly, .emscripten, .netbsd, .freebsd, .solaris, .illumos, .openbsd, .linux, .serenity => private.pipe2, |
| 9399 | 10265 | else => {}, |
| 9400 | 10266 | }; |
| 9401 | 10267 | pub const copy_file_range = switch (native_os) { |
| ... | ... | @@ -9501,15 +10367,15 @@ pub const _msize = switch (native_os) { |
| 9501 | 10367 | else => {}, |
| 9502 | 10368 | }; |
| 9503 | 10369 | pub const malloc_size = switch (native_os) { |
| 9504 | | .macos, .ios, .tvos, .watchos, .visionos => private.malloc_size, |
| 10370 | .macos, .ios, .tvos, .watchos, .visionos, .serenity => private.malloc_size, |
| 9505 | 10371 | else => {}, |
| 9506 | 10372 | }; |
| 9507 | 10373 | pub const malloc_usable_size = switch (native_os) { |
| 9508 | | .freebsd, .linux => private.malloc_usable_size, |
| 10374 | .freebsd, .linux, .serenity => private.malloc_usable_size, |
| 9509 | 10375 | else => {}, |
| 9510 | 10376 | }; |
| 9511 | 10377 | pub const posix_memalign = switch (native_os) { |
| 9512 | | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .linux, .macos, .ios, .tvos, .watchos, .visionos => private.posix_memalign, |
| 10378 | .dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .linux, .macos, .ios, .tvos, .watchos, .visionos, .serenity => private.posix_memalign, |
| 9513 | 10379 | else => {}, |
| 9514 | 10380 | }; |
| 9515 | 10381 | pub const sysconf = switch (native_os) { |
| ... | ... | @@ -9532,6 +10398,12 @@ pub const flock = switch (native_os) { |
| 9532 | 10398 | else => private.flock, |
| 9533 | 10399 | }; |
| 9534 | 10400 | |
| 10401 | pub const futex = switch (native_os) { |
| 10402 | .openbsd => openbsd.futex, |
| 10403 | .serenity => serenity.futex, |
| 10404 | else => {}, |
| 10405 | }; |
| 10406 | |
| 9535 | 10407 | pub extern "c" var environ: [*:null]?[*:0]u8; |
| 9536 | 10408 | |
| 9537 | 10409 | pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; |
| ... | ... | @@ -9582,6 +10454,7 @@ pub const fork = switch (native_os) { |
| 9582 | 10454 | .watchos, |
| 9583 | 10455 | .visionos, |
| 9584 | 10456 | .haiku, |
| 10457 | .serenity, |
| 9585 | 10458 | => private.fork, |
| 9586 | 10459 | else => {}, |
| 9587 | 10460 | }; |
| ... | ... | @@ -9825,7 +10698,11 @@ pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) |
| 9825 | 10698 | pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9826 | 10699 | pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E; |
| 9827 | 10700 | |
| 9828 | | pub const pthread_t = *opaque {}; |
| 10701 | pub const pthread_t = switch (native_os) { |
| 10702 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L64 |
| 10703 | .serenity => c_int, |
| 10704 | else => *opaque {}, |
| 10705 | }; |
| 9829 | 10706 | pub const FILE = opaque {}; |
| 9830 | 10707 | |
| 9831 | 10708 | pub extern "c" fn dlopen(path: ?[*:0]const u8, mode: RTLD) ?*anyopaque; |
| ... | ... | @@ -9958,7 +10835,6 @@ pub const thread_id = haiku.thread_id; |
| 9958 | 10835 | |
| 9959 | 10836 | pub const AUTH = openbsd.AUTH; |
| 9960 | 10837 | pub const BI = openbsd.BI; |
| 9961 | | pub const FUTEX = openbsd.FUTEX; |
| 9962 | 10838 | pub const HW = openbsd.HW; |
| 9963 | 10839 | pub const PTHREAD_STACK_MIN = openbsd.PTHREAD_STACK_MIN; |
| 9964 | 10840 | pub const TCFLUSH = openbsd.TCFLUSH; |
| ... | ... | @@ -9999,7 +10875,6 @@ pub const bcrypt_checkpass = openbsd.bcrypt_checkpass; |
| 9999 | 10875 | pub const bcrypt_gensalt = openbsd.bcrypt_gensalt; |
| 10000 | 10876 | pub const bcrypt_newhash = openbsd.bcrypt_newhash; |
| 10001 | 10877 | pub const endpwent = openbsd.endpwent; |
| 10002 | | pub const futex = openbsd.futex; |
| 10003 | 10878 | pub const getpwent = openbsd.getpwent; |
| 10004 | 10879 | pub const getpwnam_r = openbsd.getpwnam_r; |
| 10005 | 10880 | pub const getpwnam_shadow = openbsd.getpwnam_shadow; |
| ... | ... | @@ -10226,6 +11101,24 @@ pub const lwp_gettid = dragonfly.lwp_gettid; |
| 10226 | 11101 | pub const umtx_sleep = dragonfly.umtx_sleep; |
| 10227 | 11102 | pub const umtx_wakeup = dragonfly.umtx_wakeup; |
| 10228 | 11103 | |
| 11104 | pub const PERF_EVENT = serenity.PERF_EVENT; |
| 11105 | pub const disown = serenity.disown; |
| 11106 | pub const profiling_enable = serenity.profiling_enable; |
| 11107 | pub const profiling_disable = serenity.profiling_disable; |
| 11108 | pub const profiling_free_buffer = serenity.profiling_free_buffer; |
| 11109 | pub const futex_wait = serenity.futex_wait; |
| 11110 | pub const futex_wake = serenity.futex_wake; |
| 11111 | pub const purge = serenity.purge; |
| 11112 | pub const perf_event = serenity.perf_event; |
| 11113 | pub const perf_register_string = serenity.perf_register_string; |
| 11114 | pub const get_stack_bounds = serenity.get_stack_bounds; |
| 11115 | pub const anon_create = serenity.anon_create; |
| 11116 | pub const serenity_readlink = serenity.serenity_readlink; |
| 11117 | pub const serenity_open = serenity.serenity_open; |
| 11118 | pub const getkeymap = serenity.getkeymap; |
| 11119 | pub const setkeymap = serenity.setkeymap; |
| 11120 | pub const internet_checksum = serenity.internet_checksum; |
| 11121 | |
| 10229 | 11122 | /// External definitions shared by two or more operating systems. |
| 10230 | 11123 | const private = struct { |
| 10231 | 11124 | extern "c" fn close(fd: fd_t) c_int; |