| author | |
| committer | |
| log | f010a3131976b2e85aadccaaeda5c03d2288849f |
| tree | 81a24e3f4113356f994dc8a214b2f6fe379d2662 |
| parent | 07b6dbf8cae53d1e7a0c43cf514bb9286c3fd09e |
| parent | 36dbe66cf4499e4a8f656bdf4629ec1623b345c1 |
| signature |
`std.debug`: greatly expand target support for segfault handling/unwinding, and remove public `ucontext_t` completely24 files changed, 931 insertions(+), 1649 deletions(-)
lib/std/c.zig+1-106| ... | @@ -1841,110 +1841,6 @@ pub const PROT = switch (native_os) { | ... | @@ -1841,110 +1841,6 @@ pub const PROT = switch (native_os) { |
| 1841 | else => void, | 1841 | else => void, |
| 1842 | }; | 1842 | }; |
| 1843 | 1843 | ||
| 1844 | pub const REG = switch (native_os) { | ||
| 1845 | .linux => linux.REG, | ||
| 1846 | .emscripten => emscripten.REG, | ||
| 1847 | .freebsd => switch (builtin.cpu.arch) { | ||
| 1848 | .aarch64 => struct { | ||
| 1849 | pub const FP = 29; | ||
| 1850 | pub const SP = 31; | ||
| 1851 | pub const PC = 32; | ||
| 1852 | }, | ||
| 1853 | .arm => struct { | ||
| 1854 | pub const FP = 11; | ||
| 1855 | pub const SP = 13; | ||
| 1856 | pub const PC = 15; | ||
| 1857 | }, | ||
| 1858 | .x86_64 => struct { | ||
| 1859 | pub const RBP = 12; | ||
| 1860 | pub const RIP = 21; | ||
| 1861 | pub const RSP = 24; | ||
| 1862 | }, | ||
| 1863 | else => struct {}, | ||
| 1864 | }, | ||
| 1865 | .solaris, .illumos => struct { | ||
| 1866 | pub const R15 = 0; | ||
| 1867 | pub const R14 = 1; | ||
| 1868 | pub const R13 = 2; | ||
| 1869 | pub const R12 = 3; | ||
| 1870 | pub const R11 = 4; | ||
| 1871 | pub const R10 = 5; | ||
| 1872 | pub const R9 = 6; | ||
| 1873 | pub const R8 = 7; | ||
| 1874 | pub const RDI = 8; | ||
| 1875 | pub const RSI = 9; | ||
| 1876 | pub const RBP = 10; | ||
| 1877 | pub const RBX = 11; | ||
| 1878 | pub const RDX = 12; | ||
| 1879 | pub const RCX = 13; | ||
| 1880 | pub const RAX = 14; | ||
| 1881 | pub const RIP = 17; | ||
| 1882 | pub const RSP = 20; | ||
| 1883 | }, | ||
| 1884 | .netbsd => switch (builtin.cpu.arch) { | ||
| 1885 | .aarch64, .aarch64_be => struct { | ||
| 1886 | pub const FP = 29; | ||
| 1887 | pub const SP = 31; | ||
| 1888 | pub const PC = 32; | ||
| 1889 | }, | ||
| 1890 | .arm, .armeb => struct { | ||
| 1891 | pub const FP = 11; | ||
| 1892 | pub const SP = 13; | ||
| 1893 | pub const PC = 15; | ||
| 1894 | }, | ||
| 1895 | .x86 => struct { | ||
| 1896 | pub const GS = 0; | ||
| 1897 | pub const FS = 1; | ||
| 1898 | pub const ES = 2; | ||
| 1899 | pub const DS = 3; | ||
| 1900 | pub const EDI = 4; | ||
| 1901 | pub const ESI = 5; | ||
| 1902 | pub const EBP = 6; | ||
| 1903 | pub const ESP = 7; | ||
| 1904 | pub const EBX = 8; | ||
| 1905 | pub const EDX = 9; | ||
| 1906 | pub const ECX = 10; | ||
| 1907 | pub const EAX = 11; | ||
| 1908 | pub const TRAPNO = 12; | ||
| 1909 | pub const ERR = 13; | ||
| 1910 | pub const EIP = 14; | ||
| 1911 | pub const CS = 15; | ||
| 1912 | pub const EFL = 16; | ||
| 1913 | pub const UESP = 17; | ||
| 1914 | pub const SS = 18; | ||
| 1915 | }, | ||
| 1916 | .x86_64 => struct { | ||
| 1917 | pub const RDI = 0; | ||
| 1918 | pub const RSI = 1; | ||
| 1919 | pub const RDX = 2; | ||
| 1920 | pub const RCX = 3; | ||
| 1921 | pub const R8 = 4; | ||
| 1922 | pub const R9 = 5; | ||
| 1923 | pub const R10 = 6; | ||
| 1924 | pub const R11 = 7; | ||
| 1925 | pub const R12 = 8; | ||
| 1926 | pub const R13 = 9; | ||
| 1927 | pub const R14 = 10; | ||
| 1928 | pub const R15 = 11; | ||
| 1929 | pub const RBP = 12; | ||
| 1930 | pub const RBX = 13; | ||
| 1931 | pub const RAX = 14; | ||
| 1932 | pub const GS = 15; | ||
| 1933 | pub const FS = 16; | ||
| 1934 | pub const ES = 17; | ||
| 1935 | pub const DS = 18; | ||
| 1936 | pub const TRAPNO = 19; | ||
| 1937 | pub const ERR = 20; | ||
| 1938 | pub const RIP = 21; | ||
| 1939 | pub const CS = 22; | ||
| 1940 | pub const RFLAGS = 23; | ||
| 1941 | pub const RSP = 24; | ||
| 1942 | pub const SS = 25; | ||
| 1943 | }, | ||
| 1944 | else => struct {}, | ||
| 1945 | }, | ||
| 1946 | else => struct {}, | ||
| 1947 | }; | ||
| 1948 | pub const RLIM = switch (native_os) { | 1844 | pub const RLIM = switch (native_os) { |
| 1949 | .linux => linux.RLIM, | 1845 | .linux => linux.RLIM, |
| 1950 | .emscripten => emscripten.RLIM, | 1846 | .emscripten => emscripten.RLIM, |
| ... | @@ -4553,7 +4449,7 @@ pub const rusage = switch (native_os) { | ... | @@ -4553,7 +4449,7 @@ pub const rusage = switch (native_os) { |
| 4553 | pub const siginfo_t = switch (native_os) { | 4449 | pub const siginfo_t = switch (native_os) { |
| 4554 | .linux => linux.siginfo_t, | 4450 | .linux => linux.siginfo_t, |
| 4555 | .emscripten => emscripten.siginfo_t, | 4451 | .emscripten => emscripten.siginfo_t, |
| 4556 | .macos, .ios, .tvos, .watchos, .visionos => extern struct { | 4452 | .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct { |
| 4557 | signo: c_int, | 4453 | signo: c_int, |
| 4558 | errno: c_int, | 4454 | errno: c_int, |
| 4559 | code: c_int, | 4455 | code: c_int, |
| ... | @@ -11084,7 +10980,6 @@ pub const SETUSTACK = solaris.GETUSTACK; | ... | @@ -11084,7 +10980,6 @@ pub const SETUSTACK = solaris.GETUSTACK; |
| 11084 | pub const SFD = solaris.SFD; | 10980 | pub const SFD = solaris.SFD; |
| 11085 | pub const ctid_t = solaris.ctid_t; | 10981 | pub const ctid_t = solaris.ctid_t; |
| 11086 | pub const file_obj = solaris.file_obj; | 10982 | pub const file_obj = solaris.file_obj; |
| 11087 | pub const fpregset_t = solaris.fpregset_t; | ||
| 11088 | pub const id_t = solaris.id_t; | 10983 | pub const id_t = solaris.id_t; |
| 11089 | pub const lif_ifinfo_req = solaris.lif_ifinfo_req; | 10984 | pub const lif_ifinfo_req = solaris.lif_ifinfo_req; |
| 11090 | pub const lif_nd_req = solaris.lif_nd_req; | 10985 | pub const lif_nd_req = solaris.lif_nd_req; |
lib/std/c/solaris.zig-23| ... | @@ -31,29 +31,6 @@ pub const poolid_t = id_t; | ... | @@ -31,29 +31,6 @@ pub const poolid_t = id_t; |
| 31 | pub const zoneid_t = id_t; | 31 | pub const zoneid_t = id_t; |
| 32 | pub const ctid_t = id_t; | 32 | pub const ctid_t = id_t; |
| 33 | 33 | ||
| 34 | pub const fpregset_t = extern union { | ||
| 35 | regs: [130]u32, | ||
| 36 | chip_state: extern struct { | ||
| 37 | cw: u16, | ||
| 38 | sw: u16, | ||
| 39 | fctw: u8, | ||
| 40 | __fx_rsvd: u8, | ||
| 41 | fop: u16, | ||
| 42 | rip: u64, | ||
| 43 | rdp: u64, | ||
| 44 | mxcsr: u32, | ||
| 45 | mxcsr_mask: u32, | ||
| 46 | st: [8]extern union { | ||
| 47 | fpr_16: [5]u16, | ||
| 48 | __fpr_pad: u128, | ||
| 49 | }, | ||
| 50 | xmm: [16]u128, | ||
| 51 | __fx_ign2: [6]u128, | ||
| 52 | status: u32, | ||
| 53 | xstatus: u32, | ||
| 54 | }, | ||
| 55 | }; | ||
| 56 | |||
| 57 | pub const GETCONTEXT = 0; | 34 | pub const GETCONTEXT = 0; |
| 58 | pub const SETCONTEXT = 1; | 35 | pub const SETCONTEXT = 1; |
| 59 | pub const GETUSTACK = 2; | 36 | pub const GETUSTACK = 2; |
lib/std/debug.zig+42-13| ... | @@ -63,7 +63,10 @@ pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfI | ... | @@ -63,7 +63,10 @@ pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfI |
| 63 | root.debug.SelfInfo | 63 | root.debug.SelfInfo |
| 64 | else switch (std.Target.ObjectFormat.default(native_os, native_arch)) { | 64 | else switch (std.Target.ObjectFormat.default(native_os, native_arch)) { |
| 65 | .coff => if (native_os == .windows) @import("debug/SelfInfo/Windows.zig") else void, | 65 | .coff => if (native_os == .windows) @import("debug/SelfInfo/Windows.zig") else void, |
| 66 | .elf => @import("debug/SelfInfo/Elf.zig"), | 66 | .elf => switch (native_os) { |
| 67 | .freestanding, .other => void, | ||
| 68 | else => @import("debug/SelfInfo/Elf.zig"), | ||
| 69 | }, | ||
| 67 | .macho => @import("debug/SelfInfo/MachO.zig"), | 70 | .macho => @import("debug/SelfInfo/MachO.zig"), |
| 68 | .goff, .plan9, .spirv, .wasm, .xcoff => void, | 71 | .goff, .plan9, .spirv, .wasm, .xcoff => void, |
| 69 | .c, .hex, .raw => unreachable, | 72 | .c, .hex, .raw => unreachable, |
| ... | @@ -985,7 +988,7 @@ const StackIterator = union(enum) { | ... | @@ -985,7 +988,7 @@ const StackIterator = union(enum) { |
| 985 | // On RISC-V the frame pointer points to the top of the saved register | 988 | // On RISC-V the frame pointer points to the top of the saved register |
| 986 | // area, on pretty much every other architecture it points to the stack | 989 | // area, on pretty much every other architecture it points to the stack |
| 987 | // slot where the previous frame pointer is saved. | 990 | // slot where the previous frame pointer is saved. |
| 988 | if (native_arch.isRISCV()) break :off -2 * @sizeOf(usize); | 991 | if (native_arch.isLoongArch() or native_arch.isRISCV()) break :off -2 * @sizeOf(usize); |
| 989 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. | 992 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. |
| 990 | if (native_arch.isSPARC()) break :off 14 * @sizeOf(usize); | 993 | if (native_arch.isSPARC()) break :off 14 * @sizeOf(usize); |
| 991 | break :off 0; | 994 | break :off 0; |
| ... | @@ -993,7 +996,7 @@ const StackIterator = union(enum) { | ... | @@ -993,7 +996,7 @@ const StackIterator = union(enum) { |
| 993 | 996 | ||
| 994 | /// Offset of the saved return address wrt the frame pointer. | 997 | /// Offset of the saved return address wrt the frame pointer. |
| 995 | const ra_offset = off: { | 998 | const ra_offset = off: { |
| 996 | if (native_arch.isRISCV()) break :off -1 * @sizeOf(usize); | 999 | if (native_arch.isLoongArch() or native_arch.isRISCV()) break :off -1 * @sizeOf(usize); |
| 997 | if (native_arch.isSPARC()) break :off 15 * @sizeOf(usize); | 1000 | if (native_arch.isSPARC()) break :off 15 * @sizeOf(usize); |
| 998 | if (native_arch.isPowerPC64()) break :off 2 * @sizeOf(usize); | 1001 | if (native_arch.isPowerPC64()) break :off 2 * @sizeOf(usize); |
| 999 | // On s390x, r14 is the link register and we need to grab it from its customary slot in the | 1002 | // On s390x, r14 is the link register and we need to grab it from its customary slot in the |
| ... | @@ -1312,15 +1315,26 @@ fn getDebugInfoAllocator() Allocator { | ... | @@ -1312,15 +1315,26 @@ fn getDebugInfoAllocator() Allocator { |
| 1312 | 1315 | ||
| 1313 | /// Whether or not the current target can print useful debug information when a segfault occurs. | 1316 | /// Whether or not the current target can print useful debug information when a segfault occurs. |
| 1314 | pub const have_segfault_handling_support = switch (native_os) { | 1317 | pub const have_segfault_handling_support = switch (native_os) { |
| 1318 | .haiku, | ||
| 1315 | .linux, | 1319 | .linux, |
| 1316 | .macos, | 1320 | .serenity, |
| 1321 | |||
| 1322 | .dragonfly, | ||
| 1323 | .freebsd, | ||
| 1317 | .netbsd, | 1324 | .netbsd, |
| 1318 | .solaris, | 1325 | .openbsd, |
| 1326 | |||
| 1327 | .driverkit, | ||
| 1328 | .ios, | ||
| 1329 | .macos, | ||
| 1330 | .tvos, | ||
| 1331 | .visionos, | ||
| 1332 | .watchos, | ||
| 1333 | |||
| 1319 | .illumos, | 1334 | .illumos, |
| 1335 | .solaris, | ||
| 1336 | |||
| 1320 | .windows, | 1337 | .windows, |
| 1321 | .freebsd, | ||
| 1322 | .openbsd, | ||
| 1323 | .serenity, | ||
| 1324 | => true, | 1338 | => true, |
| 1325 | 1339 | ||
| 1326 | else => false, | 1340 | else => false, |
| ... | @@ -1403,11 +1417,26 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa | ... | @@ -1403,11 +1417,26 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa |
| 1403 | } | 1417 | } |
| 1404 | } | 1418 | } |
| 1405 | const addr: usize = switch (native_os) { | 1419 | const addr: usize = switch (native_os) { |
| 1406 | .linux => @intFromPtr(info.fields.sigfault.addr), | 1420 | .serenity, |
| 1407 | .freebsd, .macos, .serenity => @intFromPtr(info.addr), | 1421 | .dragonfly, |
| 1408 | .netbsd => @intFromPtr(info.info.reason.fault.addr), | 1422 | .freebsd, |
| 1409 | .openbsd => @intFromPtr(info.data.fault.addr), | 1423 | .driverkit, |
| 1410 | .solaris, .illumos => @intFromPtr(info.reason.fault.addr), | 1424 | .ios, |
| 1425 | .macos, | ||
| 1426 | .tvos, | ||
| 1427 | .visionos, | ||
| 1428 | .watchos, | ||
| 1429 | => @intFromPtr(info.addr), | ||
| 1430 | .linux, | ||
| 1431 | => @intFromPtr(info.fields.sigfault.addr), | ||
| 1432 | .netbsd, | ||
| 1433 | => @intFromPtr(info.info.reason.fault.addr), | ||
| 1434 | .haiku, | ||
| 1435 | .openbsd, | ||
| 1436 | => @intFromPtr(info.data.fault.addr), | ||
| 1437 | .illumos, | ||
| 1438 | .solaris, | ||
| 1439 | => @intFromPtr(info.reason.fault.addr), | ||
| 1411 | else => comptime unreachable, | 1440 | else => comptime unreachable, |
| 1412 | }; | 1441 | }; |
| 1413 | const name = switch (sig) { | 1442 | const name = switch (sig) { |
lib/std/debug/SelfInfo/Elf.zig+41-9| ... | @@ -94,6 +94,15 @@ pub const can_unwind: bool = s: { | ... | @@ -94,6 +94,15 @@ pub const can_unwind: bool = s: { |
| 94 | // Notably, we are yet to support unwinding on ARM. There, unwinding is not done through | 94 | // Notably, we are yet to support unwinding on ARM. There, unwinding is not done through |
| 95 | // `.eh_frame`, but instead with the `.ARM.exidx` section, which has a different format. | 95 | // `.eh_frame`, but instead with the `.ARM.exidx` section, which has a different format. |
| 96 | const archs: []const std.Target.Cpu.Arch = switch (builtin.target.os.tag) { | 96 | const archs: []const std.Target.Cpu.Arch = switch (builtin.target.os.tag) { |
| 97 | // Not supported yet: arm, m68k, sparc64 | ||
| 98 | .haiku => &.{ | ||
| 99 | .aarch64, | ||
| 100 | .powerpc, | ||
| 101 | .riscv64, | ||
| 102 | .x86, | ||
| 103 | .x86_64, | ||
| 104 | }, | ||
| 105 | // Not supported yet: arc, arm/armeb/thumb/thumbeb, csky, m68k, or1k, sparc/sparc64, xtensa | ||
| 97 | .linux => &.{ | 106 | .linux => &.{ |
| 98 | .aarch64, | 107 | .aarch64, |
| 99 | .aarch64_be, | 108 | .aarch64_be, |
| ... | @@ -113,31 +122,54 @@ pub const can_unwind: bool = s: { | ... | @@ -113,31 +122,54 @@ pub const can_unwind: bool = s: { |
| 113 | .x86, | 122 | .x86, |
| 114 | .x86_64, | 123 | .x86_64, |
| 115 | }, | 124 | }, |
| 116 | .netbsd => &.{ | 125 | .serenity => &.{ |
| 117 | .aarch64, | 126 | .aarch64, |
| 118 | .aarch64_be, | ||
| 119 | .x86, | ||
| 120 | .x86_64, | 127 | .x86_64, |
| 128 | .riscv64, | ||
| 121 | }, | 129 | }, |
| 122 | .freebsd => &.{ | 130 | |
| 131 | .dragonfly => &.{ | ||
| 123 | .x86_64, | 132 | .x86_64, |
| 133 | }, | ||
| 134 | // Not supported yet: arm | ||
| 135 | .freebsd => &.{ | ||
| 124 | .aarch64, | 136 | .aarch64, |
| 137 | .powerpc64, | ||
| 138 | .powerpc64le, | ||
| 139 | .riscv64, | ||
| 140 | .x86_64, | ||
| 125 | }, | 141 | }, |
| 126 | .openbsd => &.{ | 142 | // Not supported yet: arm/armeb, m68k, mips64/mips64el, sparc/sparc64 |
| 143 | .netbsd => &.{ | ||
| 144 | .aarch64, | ||
| 145 | .aarch64_be, | ||
| 146 | .mips, | ||
| 147 | .mipsel, | ||
| 148 | .powerpc, | ||
| 149 | .x86, | ||
| 127 | .x86_64, | 150 | .x86_64, |
| 128 | }, | 151 | }, |
| 129 | .solaris => &.{ | 152 | // Not supported yet: arm, sparc64 |
| 153 | .openbsd => &.{ | ||
| 154 | .aarch64, | ||
| 155 | .mips64, | ||
| 156 | .mips64el, | ||
| 157 | .powerpc, | ||
| 158 | .powerpc64, | ||
| 159 | .riscv64, | ||
| 160 | .x86, | ||
| 130 | .x86_64, | 161 | .x86_64, |
| 131 | }, | 162 | }, |
| 163 | |||
| 132 | .illumos => &.{ | 164 | .illumos => &.{ |
| 133 | .x86, | 165 | .x86, |
| 134 | .x86_64, | 166 | .x86_64, |
| 135 | }, | 167 | }, |
| 136 | .serenity => &.{ | 168 | // Not supported yet: sparc64 |
| 169 | .solaris => &.{ | ||
| 137 | .x86_64, | 170 | .x86_64, |
| 138 | .aarch64, | ||
| 139 | .riscv64, | ||
| 140 | }, | 171 | }, |
| 172 | |||
| 141 | else => unreachable, | 173 | else => unreachable, |
| 142 | }; | 174 | }; |
| 143 | for (archs) |a| { | 175 | for (archs) |a| { |
lib/std/debug/cpu_context.zig+845-662| ... | @@ -24,229 +24,92 @@ pub const DwarfRegisterError = error{ | ... | @@ -24,229 +24,92 @@ pub const DwarfRegisterError = error{ |
| 24 | 24 | ||
| 25 | pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { | 25 | pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { |
| 26 | if (signal_ucontext_t == void) return null; | 26 | if (signal_ucontext_t == void) return null; |
| 27 | |||
| 28 | // In general, we include the hardwired zero register in the context if applicable. | ||
| 27 | const uc: *const signal_ucontext_t = @ptrCast(@alignCast(ctx_ptr)); | 29 | const uc: *const signal_ucontext_t = @ptrCast(@alignCast(ctx_ptr)); |
| 30 | |||
| 31 | // Deal with some special cases first. | ||
| 32 | if (native_arch.isMIPS32() and native_os == .linux) { | ||
| 33 | // The O32 kABI uses 64-bit fields for some reason. | ||
| 34 | return .{ | ||
| 35 | .r = s: { | ||
| 36 | var regs: [32]Mips.Gpr = undefined; | ||
| 37 | for (uc.mcontext.r, 0..) |r, i| regs[i] = @truncate(r); | ||
| 38 | break :s regs; | ||
| 39 | }, | ||
| 40 | .pc = @truncate(uc.mcontext.pc), | ||
| 41 | }; | ||
| 42 | } | ||
| 43 | |||
| 44 | // Only unified conversions from here. | ||
| 28 | return switch (native_arch) { | 45 | return switch (native_arch) { |
| 29 | .x86 => switch (native_os) { | 46 | .arm, .armeb, .thumb, .thumbeb => .{ |
| 30 | .linux, .netbsd, .illumos => .{ .gprs = .init(.{ | 47 | .r = uc.mcontext.r ++ [_]u32{uc.mcontext.pc}, |
| 31 | .eax = uc.mcontext.gregs[std.posix.REG.EAX], | ||
| 32 | .ecx = uc.mcontext.gregs[std.posix.REG.ECX], | ||
| 33 | .edx = uc.mcontext.gregs[std.posix.REG.EDX], | ||
| 34 | .ebx = uc.mcontext.gregs[std.posix.REG.EBX], | ||
| 35 | .esp = uc.mcontext.gregs[std.posix.REG.ESP], | ||
| 36 | .ebp = uc.mcontext.gregs[std.posix.REG.EBP], | ||
| 37 | .esi = uc.mcontext.gregs[std.posix.REG.ESI], | ||
| 38 | .edi = uc.mcontext.gregs[std.posix.REG.EDI], | ||
| 39 | .eip = uc.mcontext.gregs[std.posix.REG.EIP], | ||
| 40 | }) }, | ||
| 41 | else => null, | ||
| 42 | }, | 48 | }, |
| 43 | .x86_64 => switch (native_os) { | 49 | .aarch64, .aarch64_be => .{ |
| 44 | .linux, .solaris, .illumos => .{ .gprs = .init(.{ | 50 | .x = uc.mcontext.x ++ [_]u64{uc.mcontext.lr}, |
| 45 | .rax = uc.mcontext.gregs[std.posix.REG.RAX], | 51 | .sp = uc.mcontext.sp, |
| 46 | .rdx = uc.mcontext.gregs[std.posix.REG.RDX], | 52 | .pc = uc.mcontext.pc, |
| 47 | .rcx = uc.mcontext.gregs[std.posix.REG.RCX], | ||
| 48 | .rbx = uc.mcontext.gregs[std.posix.REG.RBX], | ||
| 49 | .rsi = uc.mcontext.gregs[std.posix.REG.RSI], | ||
| 50 | .rdi = uc.mcontext.gregs[std.posix.REG.RDI], | ||
| 51 | .rbp = uc.mcontext.gregs[std.posix.REG.RBP], | ||
| 52 | .rsp = uc.mcontext.gregs[std.posix.REG.RSP], | ||
| 53 | .r8 = uc.mcontext.gregs[std.posix.REG.R8], | ||
| 54 | .r9 = uc.mcontext.gregs[std.posix.REG.R9], | ||
| 55 | .r10 = uc.mcontext.gregs[std.posix.REG.R10], | ||
| 56 | .r11 = uc.mcontext.gregs[std.posix.REG.R11], | ||
| 57 | .r12 = uc.mcontext.gregs[std.posix.REG.R12], | ||
| 58 | .r13 = uc.mcontext.gregs[std.posix.REG.R13], | ||
| 59 | .r14 = uc.mcontext.gregs[std.posix.REG.R14], | ||
| 60 | .r15 = uc.mcontext.gregs[std.posix.REG.R15], | ||
| 61 | .rip = uc.mcontext.gregs[std.posix.REG.RIP], | ||
| 62 | }) }, | ||
| 63 | .freebsd, .serenity => .{ .gprs = .init(.{ | ||
| 64 | .rax = uc.mcontext.rax, | ||
| 65 | .rdx = uc.mcontext.rdx, | ||
| 66 | .rcx = uc.mcontext.rcx, | ||
| 67 | .rbx = uc.mcontext.rbx, | ||
| 68 | .rsi = uc.mcontext.rsi, | ||
| 69 | .rdi = uc.mcontext.rdi, | ||
| 70 | .rbp = uc.mcontext.rbp, | ||
| 71 | .rsp = uc.mcontext.rsp, | ||
| 72 | .r8 = uc.mcontext.r8, | ||
| 73 | .r9 = uc.mcontext.r9, | ||
| 74 | .r10 = uc.mcontext.r10, | ||
| 75 | .r11 = uc.mcontext.r11, | ||
| 76 | .r12 = uc.mcontext.r12, | ||
| 77 | .r13 = uc.mcontext.r13, | ||
| 78 | .r14 = uc.mcontext.r14, | ||
| 79 | .r15 = uc.mcontext.r15, | ||
| 80 | .rip = uc.mcontext.rip, | ||
| 81 | }) }, | ||
| 82 | .openbsd => .{ .gprs = .init(.{ | ||
| 83 | .rax = @bitCast(uc.sc_rax), | ||
| 84 | .rdx = @bitCast(uc.sc_rdx), | ||
| 85 | .rcx = @bitCast(uc.sc_rcx), | ||
| 86 | .rbx = @bitCast(uc.sc_rbx), | ||
| 87 | .rsi = @bitCast(uc.sc_rsi), | ||
| 88 | .rdi = @bitCast(uc.sc_rdi), | ||
| 89 | .rbp = @bitCast(uc.sc_rbp), | ||
| 90 | .rsp = @bitCast(uc.sc_rsp), | ||
| 91 | .r8 = @bitCast(uc.sc_r8), | ||
| 92 | .r9 = @bitCast(uc.sc_r9), | ||
| 93 | .r10 = @bitCast(uc.sc_r10), | ||
| 94 | .r11 = @bitCast(uc.sc_r11), | ||
| 95 | .r12 = @bitCast(uc.sc_r12), | ||
| 96 | .r13 = @bitCast(uc.sc_r13), | ||
| 97 | .r14 = @bitCast(uc.sc_r14), | ||
| 98 | .r15 = @bitCast(uc.sc_r15), | ||
| 99 | .rip = @bitCast(uc.sc_rip), | ||
| 100 | }) }, | ||
| 101 | .driverkit, .macos, .ios => .{ .gprs = .init(.{ | ||
| 102 | .rax = uc.mcontext.ss.rax, | ||
| 103 | .rdx = uc.mcontext.ss.rdx, | ||
| 104 | .rcx = uc.mcontext.ss.rcx, | ||
| 105 | .rbx = uc.mcontext.ss.rbx, | ||
| 106 | .rsi = uc.mcontext.ss.rsi, | ||
| 107 | .rdi = uc.mcontext.ss.rdi, | ||
| 108 | .rbp = uc.mcontext.ss.rbp, | ||
| 109 | .rsp = uc.mcontext.ss.rsp, | ||
| 110 | .r8 = uc.mcontext.ss.r8, | ||
| 111 | .r9 = uc.mcontext.ss.r9, | ||
| 112 | .r10 = uc.mcontext.ss.r10, | ||
| 113 | .r11 = uc.mcontext.ss.r11, | ||
| 114 | .r12 = uc.mcontext.ss.r12, | ||
| 115 | .r13 = uc.mcontext.ss.r13, | ||
| 116 | .r14 = uc.mcontext.ss.r14, | ||
| 117 | .r15 = uc.mcontext.ss.r15, | ||
| 118 | .rip = uc.mcontext.ss.rip, | ||
| 119 | }) }, | ||
| 120 | else => null, | ||
| 121 | }, | 53 | }, |
| 122 | .arm, .armeb, .thumb, .thumbeb => switch (builtin.os.tag) { | 54 | .hexagon, .loongarch32, .loongarch64, .mips, .mipsel, .mips64, .mips64el, .or1k => .{ |
| 123 | .linux => .{ | 55 | .r = uc.mcontext.r, |
| 124 | .r = .{ | 56 | .pc = uc.mcontext.pc, |
| 125 | uc.mcontext.arm_r0, | ||
| 126 | uc.mcontext.arm_r1, | ||
| 127 | uc.mcontext.arm_r2, | ||
| 128 | uc.mcontext.arm_r3, | ||
| 129 | uc.mcontext.arm_r4, | ||
| 130 | uc.mcontext.arm_r5, | ||
| 131 | uc.mcontext.arm_r6, | ||
| 132 | uc.mcontext.arm_r7, | ||
| 133 | uc.mcontext.arm_r8, | ||
| 134 | uc.mcontext.arm_r9, | ||
| 135 | uc.mcontext.arm_r10, | ||
| 136 | uc.mcontext.arm_fp, // r11 = fp | ||
| 137 | uc.mcontext.arm_ip, // r12 = ip | ||
| 138 | uc.mcontext.arm_sp, // r13 = sp | ||
| 139 | uc.mcontext.arm_lr, // r14 = lr | ||
| 140 | uc.mcontext.arm_pc, // r15 = pc | ||
| 141 | }, | ||
| 142 | }, | ||
| 143 | else => null, | ||
| 144 | }, | 57 | }, |
| 145 | .aarch64, .aarch64_be => switch (builtin.os.tag) { | 58 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => .{ |
| 146 | .driverkit, .macos, .ios, .tvos, .watchos, .visionos => .{ | 59 | .r = uc.mcontext.r, |
| 147 | .x = uc.mcontext.ss.regs ++ @as([2]u64, .{ | 60 | .pc = uc.mcontext.pc, |
| 148 | uc.mcontext.ss.fp, // x29 = fp | 61 | .lr = uc.mcontext.lr, |
| 149 | uc.mcontext.ss.lr, // x30 = lr | ||
| 150 | }), | ||
| 151 | .sp = uc.mcontext.ss.sp, | ||
| 152 | .pc = uc.mcontext.ss.pc, | ||
| 153 | }, | ||
| 154 | .netbsd => .{ | ||
| 155 | .x = uc.mcontext.gregs[0..31].*, | ||
| 156 | .sp = uc.mcontext.gregs[31], | ||
| 157 | .pc = uc.mcontext.gregs[32], | ||
| 158 | }, | ||
| 159 | .freebsd => .{ | ||
| 160 | .x = uc.mcontext.gpregs.x ++ @as([1]u64, .{ | ||
| 161 | uc.mcontext.gpregs.lr, // x30 = lr | ||
| 162 | }), | ||
| 163 | .sp = uc.mcontext.gpregs.sp, | ||
| 164 | // On aarch64, the register ELR_LR1 defines the address to return to after handling | ||
| 165 | // a CPU exception (ELR is "Exception Link Register"). FreeBSD's ucontext_t uses | ||
| 166 | // this as the field name, but it's the same thing as the context's PC. | ||
| 167 | .pc = uc.mcontext.gpregs.elr, | ||
| 168 | }, | ||
| 169 | .openbsd => .{ | ||
| 170 | .x = uc.sc_x ++ .{uc.sc_lr}, | ||
| 171 | .sp = uc.sc_sp, | ||
| 172 | // Not a bug; see freebsd above for explanation. | ||
| 173 | .pc = uc.sc_elr, | ||
| 174 | }, | ||
| 175 | .linux => .{ | ||
| 176 | .x = uc.mcontext.regs, | ||
| 177 | .sp = uc.mcontext.sp, | ||
| 178 | .pc = uc.mcontext.pc, | ||
| 179 | }, | ||
| 180 | .serenity => .{ | ||
| 181 | .x = uc.mcontext.x, | ||
| 182 | .sp = uc.mcontext.sp, | ||
| 183 | .pc = uc.mcontext.pc, | ||
| 184 | }, | ||
| 185 | else => null, | ||
| 186 | }, | ||
| 187 | .hexagon => switch (builtin.os.tag) { | ||
| 188 | .linux => .{ | ||
| 189 | .r = uc.mcontext.gregs, | ||
| 190 | .pc = uc.mcontext.pc, | ||
| 191 | }, | ||
| 192 | else => null, | ||
| 193 | }, | 62 | }, |
| 194 | .loongarch64 => switch (builtin.os.tag) { | 63 | .riscv32, .riscv32be, .riscv64, .riscv64be => .{ |
| 195 | .linux => .{ | 64 | // You can thank FreeBSD and OpenBSD for this silliness; they decided to be cute and |
| 196 | .r = uc.mcontext.regs, // includes r0 (hardwired zero) | 65 | // group the registers by ABI mnemonic rather than register number. |
| 197 | .pc = uc.mcontext.pc, | 66 | .x = [_]Riscv.Gpr{0} ++ |
| 198 | }, | 67 | uc.mcontext.ra_sp_gp_tp ++ |
| 199 | else => null, | 68 | uc.mcontext.t0_2 ++ |
| 69 | uc.mcontext.s0_1 ++ | ||
| 70 | uc.mcontext.a ++ | ||
| 71 | uc.mcontext.s2_11 ++ | ||
| 72 | uc.mcontext.t3_6, | ||
| 73 | .pc = uc.mcontext.pc, | ||
| 200 | }, | 74 | }, |
| 201 | .mips, .mipsel => switch (builtin.os.tag) { | 75 | .s390x => .{ |
| 202 | // The O32 kABI uses 64-bit fields for some reason... | 76 | .r = uc.mcontext.r, |
| 203 | .linux => .{ | 77 | .psw = .{ |
| 204 | .r = s: { | 78 | .mask = uc.mcontext.psw.mask, |
| 205 | var regs: [32]Mips.Gpr = undefined; | 79 | .addr = uc.mcontext.psw.addr, |
| 206 | for (uc.mcontext.regs, 0..) |r, i| regs[i] = @truncate(r); // includes r0 (hardwired zero) | ||
| 207 | break :s regs; | ||
| 208 | }, | ||
| 209 | .pc = @truncate(uc.mcontext.pc), | ||
| 210 | }, | 80 | }, |
| 211 | else => null, | ||
| 212 | }, | 81 | }, |
| 213 | .mips64, .mips64el => switch (builtin.os.tag) { | 82 | .x86 => .{ .gprs = .init(.{ |
| 214 | .linux => .{ | 83 | .eax = uc.mcontext.eax, |
| 215 | .r = uc.mcontext.regs, // includes r0 (hardwired zero) | 84 | .ecx = uc.mcontext.ecx, |
| 216 | .pc = uc.mcontext.pc, | 85 | .edx = uc.mcontext.edx, |
| 217 | }, | 86 | .ebx = uc.mcontext.ebx, |
| 218 | else => null, | 87 | .esp = uc.mcontext.esp, |
| 219 | }, | 88 | .ebp = uc.mcontext.ebp, |
| 220 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => switch (builtin.os.tag) { | 89 | .esi = uc.mcontext.esi, |
| 221 | .linux => .{ | 90 | .edi = uc.mcontext.edi, |
| 222 | .r = uc.mcontext.gp_regs[0..32].*, | 91 | .eip = uc.mcontext.eip, |
| 223 | .pc = uc.mcontext.gp_regs[32], | 92 | }) }, |
| 224 | .lr = uc.mcontext.gp_regs[36], | 93 | .x86_64 => .{ .gprs = .init(.{ |
| 225 | }, | 94 | .rax = uc.mcontext.rax, |
| 226 | else => null, | 95 | .rdx = uc.mcontext.rdx, |
| 227 | }, | 96 | .rcx = uc.mcontext.rcx, |
| 228 | .riscv32, .riscv64 => switch (builtin.os.tag) { | 97 | .rbx = uc.mcontext.rbx, |
| 229 | .linux => .{ | 98 | .rsi = uc.mcontext.rsi, |
| 230 | .r = [1]usize{0} ++ uc.mcontext.gregs[1..].*, // r0 position is used for pc; replace with zero | 99 | .rdi = uc.mcontext.rdi, |
| 231 | .pc = uc.mcontext.gregs[0], | 100 | .rbp = uc.mcontext.rbp, |
| 232 | }, | 101 | .rsp = uc.mcontext.rsp, |
| 233 | .serenity => if (native_arch == .riscv32) null else .{ | 102 | .r8 = uc.mcontext.r8, |
| 234 | .r = [1]u64{0} ++ uc.mcontext.x, | 103 | .r9 = uc.mcontext.r9, |
| 235 | .pc = uc.mcontext.pc, | 104 | .r10 = uc.mcontext.r10, |
| 236 | }, | 105 | .r11 = uc.mcontext.r11, |
| 237 | else => null, | 106 | .r12 = uc.mcontext.r12, |
| 238 | }, | 107 | .r13 = uc.mcontext.r13, |
| 239 | .s390x => switch (builtin.os.tag) { | 108 | .r14 = uc.mcontext.r14, |
| 240 | .linux => .{ | 109 | .r15 = uc.mcontext.r15, |
| 241 | .r = uc.mcontext.gregs, | 110 | .rip = uc.mcontext.rip, |
| 242 | .psw = .{ | 111 | }) }, |
| 243 | .mask = uc.mcontext.psw.mask, | 112 | else => comptime unreachable, |
| 244 | .addr = uc.mcontext.psw.addr, | ||
| 245 | }, | ||
| 246 | }, | ||
| 247 | else => null, | ||
| 248 | }, | ||
| 249 | else => null, | ||
| 250 | }; | 113 | }; |
| 251 | } | 114 | } |
| 252 | 115 | ||
| ... | @@ -615,7 +478,7 @@ const LoongArch = extern struct { | ... | @@ -615,7 +478,7 @@ const LoongArch = extern struct { |
| 615 | r: [32]Gpr, | 478 | r: [32]Gpr, |
| 616 | pc: Gpr, | 479 | pc: Gpr, |
| 617 | 480 | ||
| 618 | pub const Gpr = if (builtin.target.cpu.arch == .loongarch64) u64 else u32; | 481 | pub const Gpr = if (native_arch == .loongarch64) u64 else u32; |
| 619 | 482 | ||
| 620 | pub inline fn current() LoongArch { | 483 | pub inline fn current() LoongArch { |
| 621 | var ctx: LoongArch = undefined; | 484 | var ctx: LoongArch = undefined; |
| ... | @@ -717,7 +580,7 @@ const Mips = extern struct { | ... | @@ -717,7 +580,7 @@ const Mips = extern struct { |
| 717 | r: [32]Gpr, | 580 | r: [32]Gpr, |
| 718 | pc: Gpr, | 581 | pc: Gpr, |
| 719 | 582 | ||
| 720 | pub const Gpr = if (builtin.target.cpu.arch.isMIPS64()) u64 else u32; | 583 | pub const Gpr = if (native_arch.isMIPS64()) u64 else u32; |
| 721 | 584 | ||
| 722 | pub inline fn current() Mips { | 585 | pub inline fn current() Mips { |
| 723 | var ctx: Mips = undefined; | 586 | var ctx: Mips = undefined; |
| ... | @@ -840,7 +703,7 @@ const Powerpc = extern struct { | ... | @@ -840,7 +703,7 @@ const Powerpc = extern struct { |
| 840 | pc: Gpr, | 703 | pc: Gpr, |
| 841 | lr: Gpr, | 704 | lr: Gpr, |
| 842 | 705 | ||
| 843 | pub const Gpr = if (builtin.target.cpu.arch.isPowerPC64()) u64 else u32; | 706 | pub const Gpr = if (native_arch.isPowerPC64()) u64 else u32; |
| 844 | 707 | ||
| 845 | pub inline fn current() Powerpc { | 708 | pub inline fn current() Powerpc { |
| 846 | var ctx: Powerpc = undefined; | 709 | var ctx: Powerpc = undefined; |
| ... | @@ -992,10 +855,10 @@ const Powerpc = extern struct { | ... | @@ -992,10 +855,10 @@ const Powerpc = extern struct { |
| 992 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. | 855 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 993 | const Riscv = extern struct { | 856 | const Riscv = extern struct { |
| 994 | /// The numbered general-purpose registers r0 - r31. r0 must be zero. | 857 | /// The numbered general-purpose registers r0 - r31. r0 must be zero. |
| 995 | r: [32]Gpr, | 858 | x: [32]Gpr, |
| 996 | pc: Gpr, | 859 | pc: Gpr, |
| 997 | 860 | ||
| 998 | pub const Gpr = if (builtin.target.cpu.arch.isRiscv64()) u64 else u32; | 861 | pub const Gpr = if (native_arch.isRiscv64()) u64 else u32; |
| 999 | 862 | ||
| 1000 | pub inline fn current() Riscv { | 863 | pub inline fn current() Riscv { |
| 1001 | var ctx: Riscv = undefined; | 864 | var ctx: Riscv = undefined; |
| ... | @@ -1081,7 +944,7 @@ const Riscv = extern struct { | ... | @@ -1081,7 +944,7 @@ const Riscv = extern struct { |
| 1081 | 944 | ||
| 1082 | pub fn dwarfRegisterBytes(ctx: *Riscv, register_num: u16) DwarfRegisterError![]u8 { | 945 | pub fn dwarfRegisterBytes(ctx: *Riscv, register_num: u16) DwarfRegisterError![]u8 { |
| 1083 | switch (register_num) { | 946 | switch (register_num) { |
| 1084 | 0...31 => return @ptrCast(&ctx.r[register_num]), | 947 | 0...31 => return @ptrCast(&ctx.x[register_num]), |
| 1085 | 65 => return @ptrCast(&ctx.pc), | 948 | 65 => return @ptrCast(&ctx.pc), |
| 1086 | 949 | ||
| 1087 | 32...63 => return error.UnsupportedRegister, // f0 - f31 | 950 | 32...63 => return error.UnsupportedRegister, // f0 - f31 |
| ... | @@ -1138,61 +1001,199 @@ const S390x = extern struct { | ... | @@ -1138,61 +1001,199 @@ const S390x = extern struct { |
| 1138 | } | 1001 | } |
| 1139 | }; | 1002 | }; |
| 1140 | 1003 | ||
| 1004 | /// The native operating system's `ucontext_t` as seen in the third argument to signal handlers. | ||
| 1005 | /// | ||
| 1006 | /// These are dramatically simplified since we only need general-purpose registers and don't care | ||
| 1007 | /// about all the complicated extension state (floating point, vector, etc). This means that these | ||
| 1008 | /// structures are almost all shorter than the real ones, which is safe because we only access them | ||
| 1009 | /// through a pointer. | ||
| 1010 | /// | ||
| 1011 | /// Some effort is made to have structures for the same architecture use the same access pattern, | ||
| 1012 | /// e.g. `uc.mcontext.x` for `aarch64-linux` and `aarch64-freebsd` even though that's not quite how | ||
| 1013 | /// they're declared and spelled in the C headers for both targets. Similarly, registers are typed | ||
| 1014 | /// as unsigned everywhere even if that's not how they're declared in the C headers. | ||
| 1141 | const signal_ucontext_t = switch (native_os) { | 1015 | const signal_ucontext_t = switch (native_os) { |
| 1142 | .linux => std.os.linux.ucontext_t, | 1016 | .linux => switch (native_arch) { |
| 1143 | .emscripten => std.os.emscripten.ucontext_t, | 1017 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arm64/include/uapi/asm/ucontext.h |
| 1144 | .freebsd => std.os.freebsd.ucontext_t, | 1018 | .aarch64, |
| 1145 | .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct { | 1019 | .aarch64_be, |
| 1146 | onstack: c_int, | 1020 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/loongarch/include/uapi/asm/ucontext.h |
| 1147 | sigmask: std.c.sigset_t, | 1021 | .loongarch64, |
| 1148 | stack: std.c.stack_t, | 1022 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/powerpc/include/uapi/asm/ucontext.h |
| 1149 | link: ?*signal_ucontext_t, | 1023 | .powerpc64, |
| 1150 | mcsize: u64, | 1024 | .powerpc64le, |
| 1151 | mcontext: *mcontext_t, | 1025 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/riscv/include/uapi/asm/ucontext.h |
| 1152 | const mcontext_t = switch (native_arch) { | 1026 | .riscv32, |
| 1153 | .aarch64 => extern struct { | 1027 | .riscv64, |
| 1154 | es: extern struct { | 1028 | => extern struct { |
| 1155 | far: u64, // Virtual Fault Address | 1029 | _flags: usize, |
| 1156 | esr: u32, // Exception syndrome | 1030 | _link: ?*signal_ucontext_t, |
| 1157 | exception: u32, // Number of arm exception taken | 1031 | _stack: std.os.linux.stack_t, |
| 1158 | }, | 1032 | _sigmask: std.os.linux.sigset_t, |
| 1159 | ss: extern struct { | 1033 | _unused: [120]u8, |
| 1160 | /// General purpose registers | 1034 | mcontext: switch (native_arch) { |
| 1161 | regs: [29]u64, | 1035 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arm64/include/uapi/asm/sigcontext.h |
| 1162 | /// Frame pointer x29 | 1036 | .aarch64, .aarch64_be => extern struct { |
| 1163 | fp: u64, | 1037 | _fault_address: u64 align(16), |
| 1164 | /// Link register x30 | 1038 | x: [30]u64, |
| 1165 | lr: u64, | 1039 | lr: u64, |
| 1166 | /// Stack pointer x31 | ||
| 1167 | sp: u64, | 1040 | sp: u64, |
| 1168 | /// Program counter | ||
| 1169 | pc: u64, | 1041 | pc: u64, |
| 1170 | /// Current program status register | ||
| 1171 | cpsr: u32, | ||
| 1172 | __pad: u32, | ||
| 1173 | }, | 1042 | }, |
| 1174 | ns: extern struct { | 1043 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/loongarch/include/uapi/asm/sigcontext.h |
| 1175 | q: [32]u128, | 1044 | .loongarch64 => extern struct { |
| 1176 | fpsr: u32, | 1045 | pc: u64 align(16), |
| 1177 | fpcr: u32, | 1046 | r: [32]u64, |
| 1047 | }, | ||
| 1048 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/powerpc/include/uapi/asm/sigcontext.h | ||
| 1049 | .powerpc64, .powerpc64le => extern struct { | ||
| 1050 | _unused: [4]u64, | ||
| 1051 | _signal: i32, | ||
| 1052 | _pad: i32, | ||
| 1053 | _handler: u64, | ||
| 1054 | _oldmask: u64, | ||
| 1055 | _regs: ?*anyopaque, | ||
| 1056 | r: [32]u64, | ||
| 1057 | pc: u64, | ||
| 1058 | _msr: u64, | ||
| 1059 | _orig_r3: u64, | ||
| 1060 | _ctr: u64, | ||
| 1061 | lr: u64, | ||
| 1062 | }, | ||
| 1063 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/riscv/include/uapi/asm/sigcontext.h | ||
| 1064 | .riscv32, .riscv64 => extern struct { | ||
| 1065 | pc: usize align(16), | ||
| 1066 | ra_sp_gp_tp: [4]usize, | ||
| 1067 | t0_2: [3]usize, | ||
| 1068 | s0_1: [2]usize, | ||
| 1069 | a: [8]usize, | ||
| 1070 | s2_11: [10]usize, | ||
| 1071 | t3_6: [4]usize, | ||
| 1178 | }, | 1072 | }, |
| 1073 | else => unreachable, | ||
| 1179 | }, | 1074 | }, |
| 1180 | .x86_64 => extern struct { | 1075 | }, |
| 1181 | es: extern struct { | 1076 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/include/uapi/asm-generic/ucontext.h |
| 1182 | trapno: u16, | 1077 | .arc, |
| 1183 | cpu: u16, | 1078 | .csky, |
| 1184 | err: u32, | 1079 | .hexagon, |
| 1185 | faultvaddr: u64, | 1080 | .m68k, |
| 1081 | .mips, | ||
| 1082 | .mipsel, | ||
| 1083 | .mips64, | ||
| 1084 | .mips64el, | ||
| 1085 | .or1k, | ||
| 1086 | .s390x, | ||
| 1087 | .x86, | ||
| 1088 | .x86_64, | ||
| 1089 | .xtensa, | ||
| 1090 | => extern struct { | ||
| 1091 | _flags: usize, | ||
| 1092 | _link: ?*signal_ucontext_t, | ||
| 1093 | _stack: std.os.linux.stack_t, | ||
| 1094 | mcontext: switch (native_arch) { | ||
| 1095 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arc/include/uapi/asm/sigcontext.h | ||
| 1096 | .arc => extern struct { | ||
| 1097 | _pad1: u32, | ||
| 1098 | _bta: u32, | ||
| 1099 | _lp: extern struct { | ||
| 1100 | _start: u32, | ||
| 1101 | _end: u32, | ||
| 1102 | _count: u32, | ||
| 1103 | }, | ||
| 1104 | _status32: u32, | ||
| 1105 | pc: u32, | ||
| 1106 | r31: u32, | ||
| 1107 | r27_26: [2]u32, | ||
| 1108 | r12_0: [13]u32, | ||
| 1109 | r28: u32, | ||
| 1110 | _pad2: u32, | ||
| 1111 | r25_13: [13]u32, | ||
| 1112 | _efa: u32, | ||
| 1113 | _stop_pc: u32, | ||
| 1114 | r30: u32, | ||
| 1186 | }, | 1115 | }, |
| 1187 | ss: extern struct { | 1116 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/csky/include/uapi/asm/sigcontext.h |
| 1188 | rax: u64, | 1117 | .csky => extern struct { |
| 1189 | rbx: u64, | 1118 | r31: u32, |
| 1190 | rcx: u64, | 1119 | r15: u32, |
| 1191 | rdx: u64, | 1120 | pc: u32, |
| 1192 | rdi: u64, | 1121 | _sr: u32, |
| 1193 | rsi: u64, | 1122 | r14: u32, |
| 1194 | rbp: u64, | 1123 | _orig_a0: u32, |
| 1195 | rsp: u64, | 1124 | r0_13: [14]u32, |
| 1125 | r16_30: [15]u32, | ||
| 1126 | }, | ||
| 1127 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/hexagon/include/uapi/asm/sigcontext.h | ||
| 1128 | .hexagon => extern struct { | ||
| 1129 | r: [32]u32 align(8), | ||
| 1130 | _salc: [2]extern struct { | ||
| 1131 | _sa: u32, | ||
| 1132 | _lc: u32, | ||
| 1133 | }, | ||
| 1134 | _m: [2]u32, | ||
| 1135 | _usr: u32, | ||
| 1136 | _p: u32, | ||
| 1137 | _gp: u32, | ||
| 1138 | _ugp: u32, | ||
| 1139 | pc: u32, | ||
| 1140 | }, | ||
| 1141 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/m68k/include/asm/ucontext.h | ||
| 1142 | .m68k => extern struct { | ||
| 1143 | _version: i32, | ||
| 1144 | d: [8]u32, | ||
| 1145 | a: [8]u32, | ||
| 1146 | pc: u32, | ||
| 1147 | }, | ||
| 1148 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/mips/include/uapi/asm/sigcontext.h | ||
| 1149 | .mips, .mipsel => extern struct { | ||
| 1150 | _regmask: u32, | ||
| 1151 | _status: u32, | ||
| 1152 | // ??? A spectacularly failed attempt to be future-proof? | ||
| 1153 | pc: u64, | ||
| 1154 | r: [32]u64, | ||
| 1155 | }, | ||
| 1156 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/mips/include/uapi/asm/sigcontext.h | ||
| 1157 | .mips64, .mips64el => extern struct { | ||
| 1158 | r: [32]u64, | ||
| 1159 | _fpregs: [32]u64, | ||
| 1160 | _hi: [4]u64, | ||
| 1161 | _lo: [4]u64, | ||
| 1162 | pc: u64, | ||
| 1163 | }, | ||
| 1164 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/openrisc/include/uapi/asm/sigcontext.h | ||
| 1165 | .or1k => extern struct { | ||
| 1166 | r: [32]u32, | ||
| 1167 | pc: u32, | ||
| 1168 | }, | ||
| 1169 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/s390/include/uapi/asm/sigcontext.h | ||
| 1170 | .s390x => extern struct { | ||
| 1171 | psw: extern struct { | ||
| 1172 | mask: u64, | ||
| 1173 | addr: u64, | ||
| 1174 | }, | ||
| 1175 | r: [16]u64, | ||
| 1176 | }, | ||
| 1177 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/x86/include/uapi/asm/sigcontext.h | ||
| 1178 | .x86 => extern struct { | ||
| 1179 | _gs: u32, | ||
| 1180 | _fs: u32, | ||
| 1181 | _es: u32, | ||
| 1182 | _ds: u32, | ||
| 1183 | edi: u32, | ||
| 1184 | esi: u32, | ||
| 1185 | ebp: u32, | ||
| 1186 | esp: u32, | ||
| 1187 | ebx: u32, | ||
| 1188 | edx: u32, | ||
| 1189 | ecx: u32, | ||
| 1190 | eax: u32, | ||
| 1191 | _trapno: u32, | ||
| 1192 | _err: u32, | ||
| 1193 | eip: u32, | ||
| 1194 | }, | ||
| 1195 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/x86/include/uapi/asm/sigcontext.h | ||
| 1196 | .x86_64 => extern struct { | ||
| 1196 | r8: u64, | 1197 | r8: u64, |
| 1197 | r9: u64, | 1198 | r9: u64, |
| 1198 | r10: u64, | 1199 | r10: u64, |
| ... | @@ -1201,197 +1202,540 @@ const signal_ucontext_t = switch (native_os) { | ... | @@ -1201,197 +1202,540 @@ const signal_ucontext_t = switch (native_os) { |
| 1201 | r13: u64, | 1202 | r13: u64, |
| 1202 | r14: u64, | 1203 | r14: u64, |
| 1203 | r15: u64, | 1204 | r15: u64, |
| 1205 | rdi: u64, | ||
| 1206 | rsi: u64, | ||
| 1207 | rbp: u64, | ||
| 1208 | rbx: u64, | ||
| 1209 | rdx: u64, | ||
| 1210 | rax: u64, | ||
| 1211 | rcx: u64, | ||
| 1212 | rsp: u64, | ||
| 1204 | rip: u64, | 1213 | rip: u64, |
| 1205 | rflags: u64, | ||
| 1206 | cs: u64, | ||
| 1207 | fs: u64, | ||
| 1208 | gs: u64, | ||
| 1209 | }, | 1214 | }, |
| 1210 | fs: extern struct { | 1215 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/xtensa/include/uapi/asm/sigcontext.h |
| 1211 | reserved: [2]c_int, | 1216 | .xtensa => extern struct { |
| 1212 | fcw: u16, | 1217 | pc: u32, |
| 1213 | fsw: u16, | 1218 | _ps: u32, |
| 1214 | ftw: u8, | 1219 | _l: extern struct { |
| 1215 | rsrv1: u8, | 1220 | _beg: u32, |
| 1216 | fop: u16, | 1221 | _end: u32, |
| 1217 | ip: u32, | 1222 | _count: u32, |
| 1218 | cs: u16, | 1223 | }, |
| 1219 | rsrv2: u16, | 1224 | _sar: u32, |
| 1220 | dp: u32, | 1225 | _acc: extern struct { |
| 1221 | ds: u16, | 1226 | _lo: u32, |
| 1222 | rsrv3: u16, | 1227 | _hi: u32, |
| 1223 | mxcsr: u32, | 1228 | }, |
| 1224 | mxcsrmask: u32, | 1229 | a: [16]u32, |
| 1225 | stmm: [8]stmm_reg, | ||
| 1226 | xmm: [16]xmm_reg, | ||
| 1227 | rsrv4: [96]u8, | ||
| 1228 | reserved1: c_int, | ||
| 1229 | |||
| 1230 | const stmm_reg = [16]u8; | ||
| 1231 | const xmm_reg = [16]u8; | ||
| 1232 | }, | 1230 | }, |
| 1231 | else => unreachable, | ||
| 1233 | }, | 1232 | }, |
| 1234 | else => void, | 1233 | }, |
| 1235 | }; | 1234 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arm/include/asm/ucontext.h |
| 1235 | .arm, .armeb, .thumb, .thumbeb => extern struct { | ||
| 1236 | _flags: u32, | ||
| 1237 | _link: ?*signal_ucontext_t, | ||
| 1238 | _stack: std.os.linux.stack_t, | ||
| 1239 | _unused: [31]i32, | ||
| 1240 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arm/include/uapi/asm/sigcontext.h | ||
| 1241 | mcontext: extern struct { | ||
| 1242 | _trap_no: u32, | ||
| 1243 | _error_code: u32, | ||
| 1244 | _oldmask: u32, | ||
| 1245 | r: [15]u32, | ||
| 1246 | pc: u32, | ||
| 1247 | }, | ||
| 1248 | }, | ||
| 1249 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/powerpc/include/uapi/asm/ucontext.h | ||
| 1250 | .powerpc, .powerpcle => extern struct { | ||
| 1251 | _flags: u32, | ||
| 1252 | _link: ?*signal_ucontext_t, | ||
| 1253 | _stack: std.os.linux.stack_t, | ||
| 1254 | _pad1: [7]i32, | ||
| 1255 | _regs: ?*anyopaque, | ||
| 1256 | _sigmask: std.os.linux.sigset_t, | ||
| 1257 | _unused: [120]u8, | ||
| 1258 | _pad2: [3]i32, | ||
| 1259 | mcontext: extern struct { | ||
| 1260 | r: [32]u32 align(16), | ||
| 1261 | pc: u32, | ||
| 1262 | _msr: u32, | ||
| 1263 | _orig_r3: u32, | ||
| 1264 | _ctr: u32, | ||
| 1265 | lr: u32, | ||
| 1266 | }, | ||
| 1267 | }, | ||
| 1268 | // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/sparc/include/uapi/asm/uctx.h | ||
| 1269 | .sparc => @compileError("sparc-linux ucontext_t missing"), | ||
| 1270 | .sparc64 => @compileError("sparc64-linux ucontext_t missing"), | ||
| 1271 | else => unreachable, | ||
| 1236 | }, | 1272 | }, |
| 1237 | .solaris, .illumos => extern struct { | 1273 | // https://github.com/freebsd/freebsd-src/blob/55c28005f544282b984ae0e15dacd0c108d8ab12/sys/sys/_ucontext.h |
| 1238 | flags: u64, | 1274 | .freebsd => extern struct { |
| 1239 | link: ?*signal_ucontext_t, | 1275 | _sigmask: std.c.sigset_t, |
| 1240 | sigmask: std.c.sigset_t, | 1276 | mcontext: switch (native_arch) { |
| 1241 | stack: std.c.stack_t, | 1277 | // https://github.com/freebsd/freebsd-src/blob/55c28005f544282b984ae0e15dacd0c108d8ab12/sys/arm64/include/ucontext.h |
| 1242 | mcontext: mcontext_t, | 1278 | .aarch64 => extern struct { |
| 1243 | brand_data: [3]?*anyopaque, | 1279 | x: [30]u64 align(16), |
| 1244 | filler: [2]i64, | 1280 | lr: u64, |
| 1245 | const mcontext_t = extern struct { | 1281 | sp: u64, |
| 1246 | gregs: [28]u64, | 1282 | pc: u64, |
| 1247 | fpregs: std.c.fpregset_t, | 1283 | }, |
| 1248 | }; | 1284 | // https://github.com/freebsd/freebsd-src/blob/55c28005f544282b984ae0e15dacd0c108d8ab12/sys/arm/include/ucontext.h |
| 1285 | .arm => extern struct { | ||
| 1286 | r: [15]u32, | ||
| 1287 | pc: u32, | ||
| 1288 | }, | ||
| 1289 | // https://github.com/freebsd/freebsd-src/blob/55c28005f544282b984ae0e15dacd0c108d8ab12/sys/powerpc/include/ucontext.h | ||
| 1290 | .powerpc64, .powerpc64le => extern struct { | ||
| 1291 | _vers: i32 align(16), | ||
| 1292 | _flags: i32, | ||
| 1293 | _onstack: i32, | ||
| 1294 | _len: i32, | ||
| 1295 | _avec: [32 * 2]u64, | ||
| 1296 | _av: [2]u32, | ||
| 1297 | r: [32]u64, | ||
| 1298 | lr: u64, | ||
| 1299 | _cr: u64, | ||
| 1300 | _xer: u64, | ||
| 1301 | _ctr: u64, | ||
| 1302 | pc: u64, | ||
| 1303 | }, | ||
| 1304 | // https://github.com/freebsd/freebsd-src/blob/55c28005f544282b984ae0e15dacd0c108d8ab12/sys/riscv/include/ucontext.h | ||
| 1305 | .riscv64 => extern struct { | ||
| 1306 | ra_sp_gp_tp: [4]u64, | ||
| 1307 | t0_2: [3]u64, | ||
| 1308 | t3_6: [4]u64, | ||
| 1309 | s0_1: [2]u64, | ||
| 1310 | s2_11: [10]u64, | ||
| 1311 | a: [8]u64, | ||
| 1312 | pc: u64, | ||
| 1313 | }, | ||
| 1314 | // https://github.com/freebsd/freebsd-src/blob/55c28005f544282b984ae0e15dacd0c108d8ab12/sys/x86/include/ucontext.h | ||
| 1315 | .x86_64 => extern struct { | ||
| 1316 | _onstack: i64, | ||
| 1317 | rdi: u64, | ||
| 1318 | rsi: u64, | ||
| 1319 | rdx: u64, | ||
| 1320 | rcx: u64, | ||
| 1321 | r8: u64, | ||
| 1322 | r9: u64, | ||
| 1323 | rax: u64, | ||
| 1324 | rbx: u64, | ||
| 1325 | rbp: u64, | ||
| 1326 | r10: u64, | ||
| 1327 | r11: u64, | ||
| 1328 | r12: u64, | ||
| 1329 | r13: u64, | ||
| 1330 | r14: u64, | ||
| 1331 | r15: u64, | ||
| 1332 | _trapno: i32, | ||
| 1333 | _fs: i16, | ||
| 1334 | _gs: i16, | ||
| 1335 | _addr: i64, | ||
| 1336 | _flags: i32, | ||
| 1337 | _es: i16, | ||
| 1338 | _ds: i16, | ||
| 1339 | _err: i64, | ||
| 1340 | rip: u64, | ||
| 1341 | _cs: i64, | ||
| 1342 | _rflags: i64, | ||
| 1343 | rsp: u64, | ||
| 1344 | }, | ||
| 1345 | else => unreachable, | ||
| 1346 | }, | ||
| 1249 | }, | 1347 | }, |
| 1250 | .openbsd => switch (builtin.cpu.arch) { | 1348 | // https://github.com/ziglang/zig/blob/60be67d3c0ba6ae15fa7115596734ab1e74fbcd3/lib/libc/include/any-macos-any/sys/_types/_ucontext.h |
| 1251 | .x86_64 => extern struct { | 1349 | .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct { |
| 1252 | sc_rdi: c_long, | 1350 | _onstack: i32, |
| 1253 | sc_rsi: c_long, | 1351 | _sigmask: std.c.sigset_t, |
| 1254 | sc_rdx: c_long, | 1352 | _stack: std.c.stack_t, |
| 1255 | sc_rcx: c_long, | 1353 | _link: ?*signal_ucontext_t, |
| 1256 | sc_r8: c_long, | 1354 | _mcsize: u64, |
| 1257 | sc_r9: c_long, | 1355 | mcontext: *switch (native_arch) { |
| 1258 | sc_r10: c_long, | 1356 | // https://github.com/ziglang/zig/blob/60be67d3c0ba6ae15fa7115596734ab1e74fbcd3/lib/libc/include/any-macos-any/arm/_mcontext.h |
| 1259 | sc_r11: c_long, | 1357 | // https://github.com/ziglang/zig/blob/60be67d3c0ba6ae15fa7115596734ab1e74fbcd3/lib/libc/include/any-macos-any/mach/arm/_structs.h |
| 1260 | sc_r12: c_long, | 1358 | .aarch64 => extern struct { |
| 1261 | sc_r13: c_long, | 1359 | _far: u64 align(16), |
| 1262 | sc_r14: c_long, | 1360 | _esr: u64, |
| 1263 | sc_r15: c_long, | 1361 | x: [30]u64, |
| 1264 | sc_rbp: c_long, | 1362 | lr: u64, |
| 1265 | sc_rbx: c_long, | 1363 | sp: u64, |
| 1266 | sc_rax: c_long, | 1364 | pc: u64, |
| 1267 | sc_gs: c_long, | 1365 | }, |
| 1268 | sc_fs: c_long, | 1366 | // https://github.com/ziglang/zig/blob/60be67d3c0ba6ae15fa7115596734ab1e74fbcd3/lib/libc/include/any-macos-any/i386/_mcontext.h |
| 1269 | sc_es: c_long, | 1367 | // https://github.com/ziglang/zig/blob/60be67d3c0ba6ae15fa7115596734ab1e74fbcd3/lib/libc/include/any-macos-any/mach/i386/_structs.h |
| 1270 | sc_ds: c_long, | 1368 | .x86_64 => extern struct { |
| 1271 | sc_trapno: c_long, | 1369 | _trapno: u16, |
| 1272 | sc_err: c_long, | 1370 | _cpu: u16, |
| 1273 | sc_rip: c_long, | 1371 | _err: u32, |
| 1274 | sc_cs: c_long, | 1372 | _faultvaddr: u64, |
| 1275 | sc_rflags: c_long, | 1373 | rax: u64, |
| 1276 | sc_rsp: c_long, | 1374 | rbx: u64, |
| 1277 | sc_ss: c_long, | 1375 | rcx: u64, |
| 1278 | 1376 | rdx: u64, | |
| 1279 | sc_fpstate: *anyopaque, // struct fxsave64 * | 1377 | rdi: u64, |
| 1280 | __sc_unused: c_int, | 1378 | rsi: u64, |
| 1281 | sc_mask: c_int, | 1379 | rbp: u64, |
| 1282 | sc_cookie: c_long, | 1380 | rsp: u64, |
| 1381 | r8: u64, | ||
| 1382 | r9: u64, | ||
| 1383 | r10: u64, | ||
| 1384 | r11: u64, | ||
| 1385 | r12: u64, | ||
| 1386 | r13: u64, | ||
| 1387 | r14: u64, | ||
| 1388 | r15: u64, | ||
| 1389 | rip: u64, | ||
| 1390 | }, | ||
| 1391 | else => unreachable, | ||
| 1283 | }, | 1392 | }, |
| 1393 | }, | ||
| 1394 | // This needs to be audited by someone with access to the Solaris headers. | ||
| 1395 | .solaris => extern struct { | ||
| 1396 | _flags: u64, | ||
| 1397 | _link: ?*signal_ucontext_t, | ||
| 1398 | _sigmask: std.c.sigset_t, | ||
| 1399 | _stack: std.c.stack_t, | ||
| 1400 | mcontext: switch (native_arch) { | ||
| 1401 | .sparc64 => @compileError("sparc64-solaris mcontext_t missing"), | ||
| 1402 | .x86_64 => extern struct { | ||
| 1403 | r15: u64, | ||
| 1404 | r14: u64, | ||
| 1405 | r13: u64, | ||
| 1406 | r12: u64, | ||
| 1407 | r11: u64, | ||
| 1408 | r10: u64, | ||
| 1409 | r9: u64, | ||
| 1410 | r8: u64, | ||
| 1411 | rdi: u64, | ||
| 1412 | rsi: u64, | ||
| 1413 | rbp: u64, | ||
| 1414 | rbx: u64, | ||
| 1415 | rdx: u64, | ||
| 1416 | rcx: u64, | ||
| 1417 | rax: u64, | ||
| 1418 | _trapno: i64, | ||
| 1419 | _err: i64, | ||
| 1420 | rip: u64, | ||
| 1421 | }, | ||
| 1422 | else => unreachable, | ||
| 1423 | }, | ||
| 1424 | }, | ||
| 1425 | // https://github.com/illumos/illumos-gate/blob/d4ce137bba3bd16823db6374d9e9a643264ce245/usr/src/uts/intel/sys/ucontext.h | ||
| 1426 | .illumos => extern struct { | ||
| 1427 | _flags: usize, | ||
| 1428 | _link: ?*signal_ucontext_t, | ||
| 1429 | _sigmask: std.c.sigset_t, | ||
| 1430 | _stack: std.c.stack_t, | ||
| 1431 | mcontext: switch (native_arch) { | ||
| 1432 | // https://github.com/illumos/illumos-gate/blob/d4ce137bba3bd16823db6374d9e9a643264ce245/usr/src/uts/intel/sys/mcontext.h | ||
| 1433 | .x86 => extern struct { | ||
| 1434 | _gs: u32, | ||
| 1435 | _fs: u32, | ||
| 1436 | _es: u32, | ||
| 1437 | _ds: u32, | ||
| 1438 | edi: u32, | ||
| 1439 | esi: u32, | ||
| 1440 | ebp: u32, | ||
| 1441 | esp: u32, | ||
| 1442 | ebx: u32, | ||
| 1443 | edx: u32, | ||
| 1444 | ecx: u32, | ||
| 1445 | eax: u32, | ||
| 1446 | _trapno: i32, | ||
| 1447 | _err: i32, | ||
| 1448 | eip: u32, | ||
| 1449 | }, | ||
| 1450 | .x86_64 => extern struct { | ||
| 1451 | r15: u64, | ||
| 1452 | r14: u64, | ||
| 1453 | r13: u64, | ||
| 1454 | r12: u64, | ||
| 1455 | r11: u64, | ||
| 1456 | r10: u64, | ||
| 1457 | r9: u64, | ||
| 1458 | r8: u64, | ||
| 1459 | rdi: u64, | ||
| 1460 | rsi: u64, | ||
| 1461 | rbp: u64, | ||
| 1462 | rbx: u64, | ||
| 1463 | rdx: u64, | ||
| 1464 | rcx: u64, | ||
| 1465 | rax: u64, | ||
| 1466 | _trapno: i64, | ||
| 1467 | _err: i64, | ||
| 1468 | rip: u64, | ||
| 1469 | }, | ||
| 1470 | else => unreachable, | ||
| 1471 | }, | ||
| 1472 | }, | ||
| 1473 | .openbsd => switch (native_arch) { | ||
| 1474 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/arm64/include/signal.h | ||
| 1284 | .aarch64 => extern struct { | 1475 | .aarch64 => extern struct { |
| 1285 | __sc_unused: c_int, | 1476 | _unused: i32, |
| 1286 | sc_mask: c_int, | 1477 | _mask: i32, |
| 1287 | sc_sp: c_ulong, | 1478 | mcontext: extern struct { |
| 1288 | sc_lr: c_ulong, | 1479 | sp: u64, |
| 1289 | sc_elr: c_ulong, | 1480 | lr: u64, |
| 1290 | sc_spsr: c_ulong, | 1481 | pc: u64, |
| 1291 | sc_x: [30]c_ulong, | 1482 | _spsr: u64, |
| 1292 | sc_cookie: c_long, | 1483 | x: [30]u64, |
| 1484 | }, | ||
| 1485 | }, | ||
| 1486 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/arm/include/signal.h | ||
| 1487 | .arm => extern struct { | ||
| 1488 | _cookie: i32, | ||
| 1489 | _mask: i32, | ||
| 1490 | mcontext: extern struct { | ||
| 1491 | _spsr: u32 align(8), | ||
| 1492 | r: [15]u32, | ||
| 1493 | _svc_lr: u32, | ||
| 1494 | pc: u32, | ||
| 1495 | }, | ||
| 1293 | }, | 1496 | }, |
| 1294 | else => void, | 1497 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/mips64/include/signal.h |
| 1498 | .mips64, .mips64el => extern struct { | ||
| 1499 | _cookie: i64, | ||
| 1500 | _mask: i64, | ||
| 1501 | mcontext: extern struct { | ||
| 1502 | pc: u64, | ||
| 1503 | r: [32]u64, | ||
| 1504 | }, | ||
| 1505 | }, | ||
| 1506 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/powerpc/include/signal.h | ||
| 1507 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/powerpc64/include/signal.h | ||
| 1508 | .powerpc, .powerpc64 => extern struct { | ||
| 1509 | _cookie: isize, | ||
| 1510 | _mask: i32, | ||
| 1511 | mcontext: extern struct { | ||
| 1512 | r: [32]usize, | ||
| 1513 | lr: usize, | ||
| 1514 | _cr: usize, | ||
| 1515 | _xer: usize, | ||
| 1516 | _ctr: usize, | ||
| 1517 | pc: usize, | ||
| 1518 | }, | ||
| 1519 | }, | ||
| 1520 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/riscv64/include/signal.h | ||
| 1521 | .riscv64 => extern struct { | ||
| 1522 | _unused: i32, | ||
| 1523 | _mask: i32, | ||
| 1524 | mcontext: extern struct { | ||
| 1525 | ra_sp_gp_tp: [4]u64, | ||
| 1526 | t0_2: [3]u64, | ||
| 1527 | t3_6: [4]u64, | ||
| 1528 | s0_1: [2]u64, | ||
| 1529 | s2_11: [10]u64, | ||
| 1530 | a: [8]u64, | ||
| 1531 | pc: u64, | ||
| 1532 | }, | ||
| 1533 | }, | ||
| 1534 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/sparc64/include/signal.h | ||
| 1535 | .sparc64 => @compileError("sparc64-openbsd mcontext_t missing"), | ||
| 1536 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/i386/include/signal.h | ||
| 1537 | .x86 => extern struct { | ||
| 1538 | mcontext: extern struct { | ||
| 1539 | _gs: i32, | ||
| 1540 | _fs: i32, | ||
| 1541 | _es: i32, | ||
| 1542 | _ds: i32, | ||
| 1543 | edi: u32, | ||
| 1544 | esi: u32, | ||
| 1545 | ebp: u32, | ||
| 1546 | ebx: u32, | ||
| 1547 | edx: u32, | ||
| 1548 | ecx: u32, | ||
| 1549 | eax: u32, | ||
| 1550 | eip: u32, | ||
| 1551 | _cs: i32, | ||
| 1552 | _eflags: i32, | ||
| 1553 | esp: u32, | ||
| 1554 | }, | ||
| 1555 | }, | ||
| 1556 | // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/amd64/include/signal.h | ||
| 1557 | .x86_64 => extern struct { | ||
| 1558 | mcontext: extern struct { | ||
| 1559 | rdi: u64, | ||
| 1560 | rsi: u64, | ||
| 1561 | rdx: u64, | ||
| 1562 | rcx: u64, | ||
| 1563 | r8: u64, | ||
| 1564 | r9: u64, | ||
| 1565 | r10: u64, | ||
| 1566 | r11: u64, | ||
| 1567 | r12: u64, | ||
| 1568 | r13: u64, | ||
| 1569 | r14: u64, | ||
| 1570 | r15: u64, | ||
| 1571 | rbp: u64, | ||
| 1572 | rbx: u64, | ||
| 1573 | rax: u64, | ||
| 1574 | _gs: i64, | ||
| 1575 | _fs: i64, | ||
| 1576 | _es: i64, | ||
| 1577 | _ds: i64, | ||
| 1578 | _trapno: i64, | ||
| 1579 | _err: i64, | ||
| 1580 | rip: u64, | ||
| 1581 | _cs: i64, | ||
| 1582 | _rflags: i64, | ||
| 1583 | rsp: u64, | ||
| 1584 | }, | ||
| 1585 | }, | ||
| 1586 | else => unreachable, | ||
| 1295 | }, | 1587 | }, |
| 1588 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/sys/ucontext.h | ||
| 1296 | .netbsd => extern struct { | 1589 | .netbsd => extern struct { |
| 1297 | flags: u32, | 1590 | _flags: u32, |
| 1298 | link: ?*signal_ucontext_t, | 1591 | _link: ?*signal_ucontext_t, |
| 1299 | sigmask: std.c.sigset_t, | 1592 | _sigmask: std.c.sigset_t, |
| 1300 | stack: std.c.stack_t, | 1593 | _stack: std.c.stack_t, |
| 1301 | mcontext: mcontext_t, | 1594 | mcontext: switch (native_arch) { |
| 1302 | __pad: [ | 1595 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/arm/include/mcontext.h |
| 1303 | switch (builtin.cpu.arch) { | ||
| 1304 | .x86 => 4, | ||
| 1305 | .mips, .mipsel, .mips64, .mips64el => 14, | ||
| 1306 | .arm, .armeb, .thumb, .thumbeb => 1, | ||
| 1307 | .sparc, .sparc64 => if (@sizeOf(usize) == 4) 43 else 8, | ||
| 1308 | else => 0, | ||
| 1309 | } | ||
| 1310 | ]u32, | ||
| 1311 | const mcontext_t = switch (builtin.cpu.arch) { | ||
| 1312 | .aarch64, .aarch64_be => extern struct { | 1596 | .aarch64, .aarch64_be => extern struct { |
| 1313 | gregs: [35]u64, | 1597 | x: [30]u64 align(16), |
| 1314 | fregs: [528]u8 align(16), | 1598 | lr: u64, |
| 1315 | spare: [8]u64, | 1599 | sp: u64, |
| 1600 | pc: u64, | ||
| 1601 | }, | ||
| 1602 | .arm, .armeb => extern struct { | ||
| 1603 | r: [15]u32 align(8), | ||
| 1604 | pc: u32, | ||
| 1316 | }, | 1605 | }, |
| 1606 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/m68k/include/mcontext.h | ||
| 1607 | .m68k => extern struct { | ||
| 1608 | d: [8]u32, | ||
| 1609 | a: [8]u32, | ||
| 1610 | pc: u32, | ||
| 1611 | }, | ||
| 1612 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/mips/include/mcontext.h | ||
| 1613 | .mips, .mipsel => extern struct { | ||
| 1614 | r: [32]u32 align(8), | ||
| 1615 | _lo: i32, | ||
| 1616 | _hi: i32, | ||
| 1617 | _cause: i32, | ||
| 1618 | pc: u32, | ||
| 1619 | }, | ||
| 1620 | .mips64, .mips64el => @compileError("https://github.com/ziglang/zig/issues/23765#issuecomment-2880386178"), | ||
| 1621 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/powerpc/include/mcontext.h | ||
| 1622 | .powerpc => extern struct { | ||
| 1623 | r: [32]u32 align(16), | ||
| 1624 | _cr: i32, | ||
| 1625 | lr: u32, | ||
| 1626 | pc: u32, | ||
| 1627 | }, | ||
| 1628 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/sparc/include/mcontext.h | ||
| 1629 | .sparc => @compileError("sparc-netbsd mcontext_t missing"), | ||
| 1630 | .sparc64 => @compileError("sparc64-netbsd mcontext_t missing"), | ||
| 1631 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/i386/include/mcontext.h | ||
| 1317 | .x86 => extern struct { | 1632 | .x86 => extern struct { |
| 1318 | gregs: [19]u32, | 1633 | _gs: i32, |
| 1319 | fpregs: [161]u32, | 1634 | _fs: i32, |
| 1320 | mc_tlsbase: u32, | 1635 | _es: i32, |
| 1636 | _ds: i32, | ||
| 1637 | edi: u32, | ||
| 1638 | esi: u32, | ||
| 1639 | ebp: u32, | ||
| 1640 | esp: u32, | ||
| 1641 | ebx: u32, | ||
| 1642 | edx: u32, | ||
| 1643 | ecx: u32, | ||
| 1644 | eax: u32, | ||
| 1645 | _trapno: i32, | ||
| 1646 | _err: i32, | ||
| 1647 | eip: u32, | ||
| 1321 | }, | 1648 | }, |
| 1649 | // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/amd64/include/mcontext.h | ||
| 1322 | .x86_64 => extern struct { | 1650 | .x86_64 => extern struct { |
| 1323 | gregs: [26]u64, | 1651 | rdi: u64, |
| 1324 | mc_tlsbase: u64, | 1652 | rsi: u64, |
| 1325 | fpregs: [512]u8 align(8), | 1653 | rdx: u64, |
| 1654 | rcx: u64, | ||
| 1655 | r8: u64, | ||
| 1656 | r9: u64, | ||
| 1657 | r10: u64, | ||
| 1658 | r11: u64, | ||
| 1659 | r12: u64, | ||
| 1660 | r13: u64, | ||
| 1661 | r14: u64, | ||
| 1662 | r15: u64, | ||
| 1663 | rbp: u64, | ||
| 1664 | rbx: u64, | ||
| 1665 | rax: u64, | ||
| 1666 | _gs: i64, | ||
| 1667 | _fs: i64, | ||
| 1668 | _es: i64, | ||
| 1669 | _ds: i64, | ||
| 1670 | _trapno: i64, | ||
| 1671 | _err: i64, | ||
| 1672 | rip: u64, | ||
| 1673 | _cs: i64, | ||
| 1674 | _rflags: i64, | ||
| 1675 | rsp: u64, | ||
| 1326 | }, | 1676 | }, |
| 1327 | else => void, | 1677 | else => unreachable, |
| 1328 | }; | 1678 | }, |
| 1329 | }, | 1679 | }, |
| 1680 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/3de1e9d36269616d22237f19d60a737a41271ab5/sys/sys/_ucontext.h | ||
| 1330 | .dragonfly => extern struct { | 1681 | .dragonfly => extern struct { |
| 1331 | sigmask: std.c.sigset_t, | 1682 | _sigmask: std.c.sigset_t, |
| 1332 | mcontext: mcontext_t, | 1683 | mcontext: switch (native_arch) { |
| 1333 | link: ?*signal_ucontext_t, | 1684 | // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/3de1e9d36269616d22237f19d60a737a41271ab5/sys/cpu/x86_64/include/ucontext.h |
| 1334 | stack: std.c.stack_t, | 1685 | .x86_64 => extern struct { |
| 1335 | cofunc: ?*fn (?*signal_ucontext_t, ?*anyopaque) void, | 1686 | _onstack: i64 align(64), |
| 1336 | arg: ?*void, | 1687 | rdi: u64, |
| 1337 | _spare: [4]c_int, | 1688 | rsi: u64, |
| 1338 | const mcontext_t = extern struct { | 1689 | rdx: u64, |
| 1339 | const register_t = isize; | 1690 | rcx: u64, |
| 1340 | onstack: register_t, // XXX - sigcontext compat. | 1691 | r8: u64, |
| 1341 | rdi: register_t, | 1692 | r9: u64, |
| 1342 | rsi: register_t, | 1693 | rax: u64, |
| 1343 | rdx: register_t, | 1694 | rbx: u64, |
| 1344 | rcx: register_t, | 1695 | rbp: u64, |
| 1345 | r8: register_t, | 1696 | r10: u64, |
| 1346 | r9: register_t, | 1697 | r11: u64, |
| 1347 | rax: register_t, | 1698 | r12: u64, |
| 1348 | rbx: register_t, | 1699 | r13: u64, |
| 1349 | rbp: register_t, | 1700 | r14: u64, |
| 1350 | r10: register_t, | 1701 | r15: u64, |
| 1351 | r11: register_t, | 1702 | _xflags: i64, |
| 1352 | r12: register_t, | 1703 | _trapno: i64, |
| 1353 | r13: register_t, | 1704 | _addr: i64, |
| 1354 | r14: register_t, | 1705 | _flags: i64, |
| 1355 | r15: register_t, | 1706 | _err: i64, |
| 1356 | xflags: register_t, | 1707 | rip: u64, |
| 1357 | trapno: register_t, | 1708 | _cs: i64, |
| 1358 | addr: register_t, | 1709 | _rflags: i64, |
| 1359 | flags: register_t, | 1710 | rsp: u64, |
| 1360 | err: register_t, | 1711 | }, |
| 1361 | rip: register_t, | 1712 | else => unreachable, |
| 1362 | cs: register_t, | 1713 | }, |
| 1363 | rflags: register_t, | ||
| 1364 | rsp: register_t, // machine state | ||
| 1365 | ss: register_t, | ||
| 1366 | |||
| 1367 | len: c_uint, // sizeof(mcontext_t) | ||
| 1368 | fpformat: c_uint, | ||
| 1369 | ownedfp: c_uint, | ||
| 1370 | reserved: c_uint, | ||
| 1371 | unused: [8]c_uint, | ||
| 1372 | |||
| 1373 | // NOTE! 64-byte aligned as of here. Also must match savefpu structure. | ||
| 1374 | fpregs: [256]c_int align(64), | ||
| 1375 | }; | ||
| 1376 | }, | 1714 | }, |
| 1715 | // https://github.com/SerenityOS/serenity/blob/103d6a07de9e28f3c94dfa2351b9af76a49ba6e6/Kernel/API/POSIX/ucontext.h | ||
| 1377 | .serenity => extern struct { | 1716 | .serenity => extern struct { |
| 1378 | link: ?*signal_ucontext_t, | 1717 | _link: ?*signal_ucontext_t, |
| 1379 | sigmask: std.c.sigset_t, | 1718 | _sigmask: std.c.sigset_t, |
| 1380 | stack: std.c.stack_t, | 1719 | _stack: std.c.stack_t, |
| 1381 | mcontext: mcontext_t, | 1720 | mcontext: switch (native_arch) { |
| 1382 | const mcontext_t = switch (builtin.cpu.arch) { | 1721 | // https://github.com/SerenityOS/serenity/blob/103d6a07de9e28f3c94dfa2351b9af76a49ba6e6/Kernel/Arch/aarch64/mcontext.h |
| 1383 | // https://github.com/SerenityOS/serenity/blob/200e91cd7f1ec5453799a2720d4dc114a59cc289/Kernel/Arch/aarch64/mcontext.h#L15-L19 | ||
| 1384 | .aarch64 => extern struct { | 1722 | .aarch64 => extern struct { |
| 1385 | x: [31]u64, | 1723 | x: [30]u64, |
| 1724 | lr: u64, | ||
| 1386 | sp: u64, | 1725 | sp: u64, |
| 1387 | pc: u64, | 1726 | pc: u64, |
| 1388 | }, | 1727 | }, |
| 1389 | // https://github.com/SerenityOS/serenity/blob/66f8d0f031ef25c409dbb4fecaa454800fecae0f/Kernel/Arch/riscv64/mcontext.h#L15-L18 | 1728 | // https://github.com/SerenityOS/serenity/blob/103d6a07de9e28f3c94dfa2351b9af76a49ba6e6/Kernel/Arch/riscv64/mcontext.h |
| 1390 | .riscv64 => extern struct { | 1729 | .riscv64 => extern struct { |
| 1391 | x: [31]u64, | 1730 | ra_sp_gp_tp: [4]u64, |
| 1731 | t0_2: [3]u64, | ||
| 1732 | s0_1: [2]u64, | ||
| 1733 | a: [8]u64, | ||
| 1734 | s2_11: [10]u64, | ||
| 1735 | t3_6: [4]u64, | ||
| 1392 | pc: u64, | 1736 | pc: u64, |
| 1393 | }, | 1737 | }, |
| 1394 | // https://github.com/SerenityOS/serenity/blob/7b9ea3efdec9f86a1042893e8107d0b23aad8727/Kernel/Arch/x86_64/mcontext.h#L15-L40 | 1738 | // https://github.com/SerenityOS/serenity/blob/103d6a07de9e28f3c94dfa2351b9af76a49ba6e6/Kernel/Arch/x86_64/mcontext.h |
| 1395 | .x86_64 => extern struct { | 1739 | .x86_64 => extern struct { |
| 1396 | rax: u64, | 1740 | rax: u64, |
| 1397 | rcx: u64, | 1741 | rcx: u64, |
| ... | @@ -1410,262 +1754,103 @@ const signal_ucontext_t = switch (native_os) { | ... | @@ -1410,262 +1754,103 @@ const signal_ucontext_t = switch (native_os) { |
| 1410 | r13: u64, | 1754 | r13: u64, |
| 1411 | r14: u64, | 1755 | r14: u64, |
| 1412 | r15: u64, | 1756 | r15: u64, |
| 1413 | rflags: u64, | ||
| 1414 | cs: u32, | ||
| 1415 | ss: u32, | ||
| 1416 | ds: u32, | ||
| 1417 | es: u32, | ||
| 1418 | fs: u32, | ||
| 1419 | gs: u32, | ||
| 1420 | }, | 1757 | }, |
| 1421 | else => void, | 1758 | else => unreachable, |
| 1422 | }; | 1759 | }, |
| 1423 | }, | 1760 | }, |
| 1761 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/signal.h#L356 | ||
| 1424 | .haiku => extern struct { | 1762 | .haiku => extern struct { |
| 1425 | link: ?*signal_ucontext_t, | 1763 | _link: ?*signal_ucontext_t, |
| 1426 | sigmask: std.c.sigset_t, | 1764 | _sigmask: std.c.sigset_t, |
| 1427 | stack: std.c.stack_t, | 1765 | _stack: std.c.stack_t, |
| 1428 | mcontext: mcontext_t, | 1766 | mcontext: switch (native_arch) { |
| 1429 | const mcontext_t = switch (builtin.cpu.arch) { | 1767 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/arm/signal.h |
| 1430 | .arm, .thumb => extern struct { | 1768 | .arm => extern struct { |
| 1431 | r0: u32, | 1769 | r: [15]u32 align(8), |
| 1432 | r1: u32, | 1770 | pc: u32, |
| 1433 | r2: u32, | ||
| 1434 | r3: u32, | ||
| 1435 | r4: u32, | ||
| 1436 | r5: u32, | ||
| 1437 | r6: u32, | ||
| 1438 | r7: u32, | ||
| 1439 | r8: u32, | ||
| 1440 | r9: u32, | ||
| 1441 | r10: u32, | ||
| 1442 | r11: u32, | ||
| 1443 | r12: u32, | ||
| 1444 | r13: u32, | ||
| 1445 | r14: u32, | ||
| 1446 | r15: u32, | ||
| 1447 | cpsr: u32, | ||
| 1448 | }, | 1771 | }, |
| 1772 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/arm64/signal.h | ||
| 1449 | .aarch64 => extern struct { | 1773 | .aarch64 => extern struct { |
| 1450 | x: [10]u64, | 1774 | x: [30]u64 align(16), |
| 1451 | lr: u64, | 1775 | lr: u64, |
| 1452 | sp: u64, | 1776 | sp: u64, |
| 1453 | elr: u64, | 1777 | pc: u64, |
| 1454 | spsr: u64, | ||
| 1455 | fp_q: [32]u128, | ||
| 1456 | fpsr: u32, | ||
| 1457 | fpcr: u32, | ||
| 1458 | }, | 1778 | }, |
| 1779 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/m68k/signal.h | ||
| 1459 | .m68k => extern struct { | 1780 | .m68k => extern struct { |
| 1460 | pc: u32, | 1781 | pc: u32 align(8), |
| 1461 | d0: u32, | 1782 | d: [8]u32, |
| 1462 | d1: u32, | 1783 | a: [8]u32, |
| 1463 | d2: u32, | ||
| 1464 | d3: u32, | ||
| 1465 | d4: u32, | ||
| 1466 | d5: u32, | ||
| 1467 | d6: u32, | ||
| 1468 | d7: u32, | ||
| 1469 | a0: u32, | ||
| 1470 | a1: u32, | ||
| 1471 | a2: u32, | ||
| 1472 | a3: u32, | ||
| 1473 | a4: u32, | ||
| 1474 | a5: u32, | ||
| 1475 | a6: u32, | ||
| 1476 | a7: u32, | ||
| 1477 | ccr: u8, | ||
| 1478 | f0: f64, | ||
| 1479 | f1: f64, | ||
| 1480 | f2: f64, | ||
| 1481 | f3: f64, | ||
| 1482 | f4: f64, | ||
| 1483 | f5: f64, | ||
| 1484 | f6: f64, | ||
| 1485 | f7: f64, | ||
| 1486 | f8: f64, | ||
| 1487 | f9: f64, | ||
| 1488 | f10: f64, | ||
| 1489 | f11: f64, | ||
| 1490 | f12: f64, | ||
| 1491 | f13: f64, | ||
| 1492 | }, | ||
| 1493 | .mipsel => extern struct { | ||
| 1494 | r0: u32, | ||
| 1495 | }, | 1784 | }, |
| 1785 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/ppc/signal.h | ||
| 1496 | .powerpc => extern struct { | 1786 | .powerpc => extern struct { |
| 1497 | pc: u32, | 1787 | pc: u32 align(8), |
| 1498 | r0: u32, | 1788 | r: [13]u32, // Um, are you okay, Haiku? |
| 1499 | r1: u32, | 1789 | _f: [14]f64, |
| 1500 | r2: u32, | 1790 | _reserved: u32, |
| 1501 | r3: u32, | 1791 | _fpscr: u32, |
| 1502 | r4: u32, | 1792 | _ctr: u32, |
| 1503 | r5: u32, | 1793 | _xer: u32, |
| 1504 | r6: u32, | 1794 | _cr: u32, |
| 1505 | r7: u32, | 1795 | _msr: u32, |
| 1506 | r8: u32, | ||
| 1507 | r9: u32, | ||
| 1508 | r10: u32, | ||
| 1509 | r11: u32, | ||
| 1510 | r12: u32, | ||
| 1511 | f0: f64, | ||
| 1512 | f1: f64, | ||
| 1513 | f2: f64, | ||
| 1514 | f3: f64, | ||
| 1515 | f4: f64, | ||
| 1516 | f5: f64, | ||
| 1517 | f6: f64, | ||
| 1518 | f7: f64, | ||
| 1519 | f8: f64, | ||
| 1520 | f9: f64, | ||
| 1521 | f10: f64, | ||
| 1522 | f11: f64, | ||
| 1523 | f12: f64, | ||
| 1524 | f13: f64, | ||
| 1525 | reserved: u32, | ||
| 1526 | fpscr: u32, | ||
| 1527 | ctr: u32, | ||
| 1528 | xer: u32, | ||
| 1529 | cr: u32, | ||
| 1530 | msr: u32, | ||
| 1531 | lr: u32, | 1796 | lr: u32, |
| 1532 | }, | 1797 | }, |
| 1798 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/riscv64/signal.h | ||
| 1533 | .riscv64 => extern struct { | 1799 | .riscv64 => extern struct { |
| 1534 | x: [31]u64, | 1800 | ra_sp_gp_tp: [4]u64, |
| 1801 | t0_2: [3]u64, | ||
| 1802 | s0_1: [2]u64, | ||
| 1803 | a: [8]u64, | ||
| 1804 | s2_11: [10]u64, | ||
| 1805 | t3_6: [4]u64, | ||
| 1535 | pc: u64, | 1806 | pc: u64, |
| 1536 | f: [32]f64, | ||
| 1537 | fcsr: u64, | ||
| 1538 | }, | ||
| 1539 | .sparc64 => extern struct { | ||
| 1540 | g1: u64, | ||
| 1541 | g2: u64, | ||
| 1542 | g3: u64, | ||
| 1543 | g4: u64, | ||
| 1544 | g5: u64, | ||
| 1545 | g6: u64, | ||
| 1546 | g7: u64, | ||
| 1547 | o0: u64, | ||
| 1548 | o1: u64, | ||
| 1549 | o2: u64, | ||
| 1550 | o3: u64, | ||
| 1551 | o4: u64, | ||
| 1552 | o5: u64, | ||
| 1553 | sp: u64, | ||
| 1554 | o7: u64, | ||
| 1555 | l0: u64, | ||
| 1556 | l1: u64, | ||
| 1557 | l2: u64, | ||
| 1558 | l3: u64, | ||
| 1559 | l4: u64, | ||
| 1560 | l5: u64, | ||
| 1561 | l6: u64, | ||
| 1562 | l7: u64, | ||
| 1563 | i0: u64, | ||
| 1564 | i1: u64, | ||
| 1565 | i2: u64, | ||
| 1566 | i3: u64, | ||
| 1567 | i4: u64, | ||
| 1568 | i5: u64, | ||
| 1569 | fp: u64, | ||
| 1570 | i7: u64, | ||
| 1571 | }, | 1807 | }, |
| 1808 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/sparc64/signal.h | ||
| 1809 | .sparc64 => @compileError("sparc64-haiku mcontext_t missing"), | ||
| 1810 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/x86/signal.h | ||
| 1572 | .x86 => extern struct { | 1811 | .x86 => extern struct { |
| 1573 | pub const old_extended_regs = extern struct { | ||
| 1574 | control: u16, | ||
| 1575 | reserved1: u16, | ||
| 1576 | status: u16, | ||
| 1577 | reserved2: u16, | ||
| 1578 | tag: u16, | ||
| 1579 | reserved3: u16, | ||
| 1580 | eip: u32, | ||
| 1581 | cs: u16, | ||
| 1582 | opcode: u16, | ||
| 1583 | datap: u32, | ||
| 1584 | ds: u16, | ||
| 1585 | reserved4: u16, | ||
| 1586 | fp_mmx: [8][10]u8, | ||
| 1587 | }; | ||
| 1588 | |||
| 1589 | pub const fp_register = extern struct { value: [10]u8, reserved: [6]u8 }; | ||
| 1590 | |||
| 1591 | pub const xmm_register = extern struct { value: [16]u8 }; | ||
| 1592 | |||
| 1593 | pub const new_extended_regs = extern struct { | ||
| 1594 | control: u16, | ||
| 1595 | status: u16, | ||
| 1596 | tag: u16, | ||
| 1597 | opcode: u16, | ||
| 1598 | eip: u32, | ||
| 1599 | cs: u16, | ||
| 1600 | reserved1: u16, | ||
| 1601 | datap: u32, | ||
| 1602 | ds: u16, | ||
| 1603 | reserved2: u16, | ||
| 1604 | mxcsr: u32, | ||
| 1605 | reserved3: u32, | ||
| 1606 | fp_mmx: [8]fp_register, | ||
| 1607 | xmmx: [8]xmm_register, | ||
| 1608 | reserved4: [224]u8, | ||
| 1609 | }; | ||
| 1610 | |||
| 1611 | pub const extended_regs = extern struct { | ||
| 1612 | state: extern union { | ||
| 1613 | old_format: old_extended_regs, | ||
| 1614 | new_format: new_extended_regs, | ||
| 1615 | }, | ||
| 1616 | format: u32, | ||
| 1617 | }; | ||
| 1618 | |||
| 1619 | eip: u32, | 1812 | eip: u32, |
| 1620 | eflags: u32, | 1813 | _eflags: u32, |
| 1621 | eax: u32, | 1814 | eax: u32, |
| 1622 | ecx: u32, | 1815 | ecx: u32, |
| 1623 | edx: u32, | 1816 | edx: u32, |
| 1624 | esp: u32, | 1817 | esp: u32, |
| 1625 | ebp: u32, | 1818 | ebp: u32, |
| 1626 | reserved: u32, | 1819 | _reserved: u32, |
| 1627 | xregs: extended_regs, | 1820 | _xregs: extern struct { |
| 1821 | _fp_control: u16, | ||
| 1822 | _fp_status: u16, | ||
| 1823 | _fp_tag: u16, | ||
| 1824 | _fp_opcode: u16, | ||
| 1825 | _fp_eip: u32, | ||
| 1826 | _fp_cs: u16, | ||
| 1827 | _reserved1: u16, | ||
| 1828 | _fp_datap: u32, | ||
| 1829 | _fp_ds: u16, | ||
| 1830 | _reserved2: u16, | ||
| 1831 | _mxcsr: u32, | ||
| 1832 | _mxcsr_mask: u32, | ||
| 1833 | _mmx: [8][16]u8, | ||
| 1834 | _xmmx: [8][16]u8, | ||
| 1835 | _reserved3: [176]u8, | ||
| 1836 | _fault_address: u32, | ||
| 1837 | _error_code: u32, | ||
| 1838 | _cs: u16, | ||
| 1839 | _ds: u16, | ||
| 1840 | _es: u16, | ||
| 1841 | _fs: u16, | ||
| 1842 | _gs: u16, | ||
| 1843 | _ss: u16, | ||
| 1844 | _trap_number: u8, | ||
| 1845 | _reserved4: [27]u8, | ||
| 1846 | _format: u32, | ||
| 1847 | }, | ||
| 1628 | edi: u32, | 1848 | edi: u32, |
| 1629 | esi: u32, | 1849 | esi: u32, |
| 1630 | ebx: u32, | 1850 | ebx: u32, |
| 1631 | }, | 1851 | }, |
| 1852 | // https://github.com/haiku/haiku/blob/47538c534fe0aadc626c09d121773fee8ea10d71/headers/posix/arch/x86_64/signal.h | ||
| 1632 | .x86_64 => extern struct { | 1853 | .x86_64 => extern struct { |
| 1633 | pub const fp_register = extern struct { | ||
| 1634 | value: [10]u8, | ||
| 1635 | reserved: [6]u8, | ||
| 1636 | }; | ||
| 1637 | |||
| 1638 | pub const xmm_register = extern struct { | ||
| 1639 | value: [16]u8, | ||
| 1640 | }; | ||
| 1641 | |||
| 1642 | pub const fpu_state = extern struct { | ||
| 1643 | control: u16, | ||
| 1644 | status: u16, | ||
| 1645 | tag: u16, | ||
| 1646 | opcode: u16, | ||
| 1647 | rip: u64, | ||
| 1648 | rdp: u64, | ||
| 1649 | mxcsr: u32, | ||
| 1650 | mscsr_mask: u32, | ||
| 1651 | |||
| 1652 | fp_mmx: [8]fp_register, | ||
| 1653 | xmm: [16]xmm_register, | ||
| 1654 | reserved: [96]u8, | ||
| 1655 | }; | ||
| 1656 | |||
| 1657 | pub const xstate_hdr = extern struct { | ||
| 1658 | bv: u64, | ||
| 1659 | xcomp_bv: u64, | ||
| 1660 | reserved: [48]u8, | ||
| 1661 | }; | ||
| 1662 | |||
| 1663 | pub const savefpu = extern struct { | ||
| 1664 | fxsave: fpu_state, | ||
| 1665 | xstate: xstate_hdr, | ||
| 1666 | ymm: [16]xmm_register, | ||
| 1667 | }; | ||
| 1668 | |||
| 1669 | rax: u64, | 1854 | rax: u64, |
| 1670 | rbx: u64, | 1855 | rbx: u64, |
| 1671 | rcx: u64, | 1856 | rcx: u64, |
| ... | @@ -1683,11 +1868,9 @@ const signal_ucontext_t = switch (native_os) { | ... | @@ -1683,11 +1868,9 @@ const signal_ucontext_t = switch (native_os) { |
| 1683 | r15: u64, | 1868 | r15: u64, |
| 1684 | rsp: u64, | 1869 | rsp: u64, |
| 1685 | rip: u64, | 1870 | rip: u64, |
| 1686 | rflags: u64, | ||
| 1687 | fpu: savefpu, | ||
| 1688 | }, | 1871 | }, |
| 1689 | else => void, | 1872 | else => unreachable, |
| 1690 | }; | 1873 | }, |
| 1691 | }, | 1874 | }, |
| 1692 | else => void, | 1875 | else => void, |
| 1693 | }; | 1876 | }; |
lib/std/os/emscripten.zig-38| ... | @@ -400,28 +400,6 @@ pub const timeval = extern struct { | ... | @@ -400,28 +400,6 @@ pub const timeval = extern struct { |
| 400 | usec: i32, | 400 | usec: i32, |
| 401 | }; | 401 | }; |
| 402 | 402 | ||
| 403 | pub const REG = struct { | ||
| 404 | pub const GS = 0; | ||
| 405 | pub const FS = 1; | ||
| 406 | pub const ES = 2; | ||
| 407 | pub const DS = 3; | ||
| 408 | pub const EDI = 4; | ||
| 409 | pub const ESI = 5; | ||
| 410 | pub const EBP = 6; | ||
| 411 | pub const ESP = 7; | ||
| 412 | pub const EBX = 8; | ||
| 413 | pub const EDX = 9; | ||
| 414 | pub const ECX = 10; | ||
| 415 | pub const EAX = 11; | ||
| 416 | pub const TRAPNO = 12; | ||
| 417 | pub const ERR = 13; | ||
| 418 | pub const EIP = 14; | ||
| 419 | pub const CS = 15; | ||
| 420 | pub const EFL = 16; | ||
| 421 | pub const UESP = 17; | ||
| 422 | pub const SS = 18; | ||
| 423 | }; | ||
| 424 | |||
| 425 | pub const S = struct { | 403 | pub const S = struct { |
| 426 | pub const IFMT = 0o170000; | 404 | pub const IFMT = 0o170000; |
| 427 | 405 | ||
| ... | @@ -813,13 +791,6 @@ pub const dl_phdr_info = extern struct { | ... | @@ -813,13 +791,6 @@ pub const dl_phdr_info = extern struct { |
| 813 | phnum: u16, | 791 | phnum: u16, |
| 814 | }; | 792 | }; |
| 815 | 793 | ||
| 816 | pub const mcontext_t = extern struct { | ||
| 817 | gregs: [19]usize, | ||
| 818 | fpregs: [*]u8, | ||
| 819 | oldmask: usize, | ||
| 820 | cr2: usize, | ||
| 821 | }; | ||
| 822 | |||
| 823 | pub const msghdr = std.c.msghdr; | 794 | pub const msghdr = std.c.msghdr; |
| 824 | pub const msghdr_const = std.c.msghdr; | 795 | pub const msghdr_const = std.c.msghdr; |
| 825 | 796 | ||
| ... | @@ -846,15 +817,6 @@ pub const timezone = extern struct { | ... | @@ -846,15 +817,6 @@ pub const timezone = extern struct { |
| 846 | dsttime: i32, | 817 | dsttime: i32, |
| 847 | }; | 818 | }; |
| 848 | 819 | ||
| 849 | pub const ucontext_t = extern struct { | ||
| 850 | flags: usize, | ||
| 851 | link: ?*ucontext_t, | ||
| 852 | stack: stack_t, | ||
| 853 | mcontext: mcontext_t, | ||
| 854 | sigmask: sigset_t, | ||
| 855 | regspace: [28]usize, | ||
| 856 | }; | ||
| 857 | |||
| 858 | pub const utsname = extern struct { | 820 | pub const utsname = extern struct { |
| 859 | sysname: [64:0]u8, | 821 | sysname: [64:0]u8, |
| 860 | nodename: [64:0]u8, | 822 | nodename: [64:0]u8, |
lib/std/os/freebsd.zig-72| ... | @@ -48,75 +48,3 @@ pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, | ... | @@ -48,75 +48,3 @@ pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, |
| 48 | else => |err| return unexpectedErrno(err), | 48 | else => |err| return unexpectedErrno(err), |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | |||
| 52 | pub const ucontext_t = extern struct { | ||
| 53 | sigmask: std.c.sigset_t, | ||
| 54 | mcontext: mcontext_t, | ||
| 55 | link: ?*ucontext_t, | ||
| 56 | stack: std.c.stack_t, | ||
| 57 | flags: c_int, | ||
| 58 | __spare__: [4]c_int, | ||
| 59 | const mcontext_t = switch (builtin.cpu.arch) { | ||
| 60 | .x86_64 => extern struct { | ||
| 61 | onstack: u64, | ||
| 62 | rdi: u64, | ||
| 63 | rsi: u64, | ||
| 64 | rdx: u64, | ||
| 65 | rcx: u64, | ||
| 66 | r8: u64, | ||
| 67 | r9: u64, | ||
| 68 | rax: u64, | ||
| 69 | rbx: u64, | ||
| 70 | rbp: u64, | ||
| 71 | r10: u64, | ||
| 72 | r11: u64, | ||
| 73 | r12: u64, | ||
| 74 | r13: u64, | ||
| 75 | r14: u64, | ||
| 76 | r15: u64, | ||
| 77 | trapno: u32, | ||
| 78 | fs: u16, | ||
| 79 | gs: u16, | ||
| 80 | addr: u64, | ||
| 81 | flags: u32, | ||
| 82 | es: u16, | ||
| 83 | ds: u16, | ||
| 84 | err: u64, | ||
| 85 | rip: u64, | ||
| 86 | cs: u64, | ||
| 87 | rflags: u64, | ||
| 88 | rsp: u64, | ||
| 89 | ss: u64, | ||
| 90 | len: u64, | ||
| 91 | fpformat: u64, | ||
| 92 | ownedfp: u64, | ||
| 93 | fpstate: [64]u64 align(16), | ||
| 94 | fsbase: u64, | ||
| 95 | gsbase: u64, | ||
| 96 | xfpustate: u64, | ||
| 97 | xfpustate_len: u64, | ||
| 98 | spare: [4]u64, | ||
| 99 | }, | ||
| 100 | .aarch64 => extern struct { | ||
| 101 | gpregs: extern struct { | ||
| 102 | x: [30]u64, | ||
| 103 | lr: u64, | ||
| 104 | sp: u64, | ||
| 105 | elr: u64, | ||
| 106 | spsr: u32, | ||
| 107 | _pad: u32, | ||
| 108 | }, | ||
| 109 | fpregs: extern struct { | ||
| 110 | q: [32]u128, | ||
| 111 | sr: u32, | ||
| 112 | cr: u32, | ||
| 113 | flags: u32, | ||
| 114 | _pad: u32, | ||
| 115 | }, | ||
| 116 | flags: u32, | ||
| 117 | _pad: u32, | ||
| 118 | _spare: [8]u64, | ||
| 119 | }, | ||
| 120 | else => void, | ||
| 121 | }; | ||
| 122 | }; |
lib/std/os/linux.zig+2-8| ... | @@ -47,9 +47,7 @@ const arch_bits = switch (native_arch) { | ... | @@ -47,9 +47,7 @@ const arch_bits = switch (native_arch) { |
| 47 | .powerpc, .powerpcle => @import("linux/powerpc.zig"), | 47 | .powerpc, .powerpcle => @import("linux/powerpc.zig"), |
| 48 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), | 48 | .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), |
| 49 | .s390x => @import("linux/s390x.zig"), | 49 | .s390x => @import("linux/s390x.zig"), |
| 50 | else => struct { | 50 | else => struct {}, |
| 51 | pub const ucontext_t = void; | ||
| 52 | }, | ||
| 53 | }; | 51 | }; |
| 54 | 52 | ||
| 55 | const syscall_bits = if (native_arch.isThumb()) @import("linux/thumb.zig") else arch_bits; | 53 | const syscall_bits = if (native_arch.isThumb()) @import("linux/thumb.zig") else arch_bits; |
| ... | @@ -94,7 +92,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx; | ... | @@ -94,7 +92,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx; |
| 94 | pub const F = arch_bits.F; | 92 | pub const F = arch_bits.F; |
| 95 | pub const Flock = arch_bits.Flock; | 93 | pub const Flock = arch_bits.Flock; |
| 96 | pub const HWCAP = arch_bits.HWCAP; | 94 | pub const HWCAP = arch_bits.HWCAP; |
| 97 | pub const REG = arch_bits.REG; | ||
| 98 | pub const SC = arch_bits.SC; | 95 | pub const SC = arch_bits.SC; |
| 99 | pub const Stat = arch_bits.Stat; | 96 | pub const Stat = arch_bits.Stat; |
| 100 | pub const VDSO = arch_bits.VDSO; | 97 | pub const VDSO = arch_bits.VDSO; |
| ... | @@ -102,14 +99,12 @@ pub const blkcnt_t = arch_bits.blkcnt_t; | ... | @@ -102,14 +99,12 @@ pub const blkcnt_t = arch_bits.blkcnt_t; |
| 102 | pub const blksize_t = arch_bits.blksize_t; | 99 | pub const blksize_t = arch_bits.blksize_t; |
| 103 | pub const dev_t = arch_bits.dev_t; | 100 | pub const dev_t = arch_bits.dev_t; |
| 104 | pub const ino_t = arch_bits.ino_t; | 101 | pub const ino_t = arch_bits.ino_t; |
| 105 | pub const mcontext_t = arch_bits.mcontext_t; | ||
| 106 | pub const mode_t = arch_bits.mode_t; | 102 | pub const mode_t = arch_bits.mode_t; |
| 107 | pub const nlink_t = arch_bits.nlink_t; | 103 | pub const nlink_t = arch_bits.nlink_t; |
| 108 | pub const off_t = arch_bits.off_t; | 104 | pub const off_t = arch_bits.off_t; |
| 109 | pub const time_t = arch_bits.time_t; | 105 | pub const time_t = arch_bits.time_t; |
| 110 | pub const timeval = arch_bits.timeval; | 106 | pub const timeval = arch_bits.timeval; |
| 111 | pub const timezone = arch_bits.timezone; | 107 | pub const timezone = arch_bits.timezone; |
| 112 | pub const ucontext_t = arch_bits.ucontext_t; | ||
| 113 | pub const user_desc = arch_bits.user_desc; | 108 | pub const user_desc = arch_bits.user_desc; |
| 114 | 109 | ||
| 115 | pub const tls = @import("linux/tls.zig"); | 110 | pub const tls = @import("linux/tls.zig"); |
| ... | @@ -3614,8 +3609,7 @@ pub const PROT = struct { | ... | @@ -3614,8 +3609,7 @@ pub const PROT = struct { |
| 3614 | pub const EXEC = 0x4; | 3609 | pub const EXEC = 0x4; |
| 3615 | /// page may be used for atomic ops | 3610 | /// page may be used for atomic ops |
| 3616 | pub const SEM = switch (native_arch) { | 3611 | pub const SEM = switch (native_arch) { |
| 3617 | // TODO: also xtensa | 3612 | .mips, .mipsel, .mips64, .mips64el, .xtensa => 0x10, |
| 3618 | .mips, .mipsel, .mips64, .mips64el => 0x10, | ||
| 3619 | else => 0x8, | 3613 | else => 0x8, |
| 3620 | }; | 3614 | }; |
| 3621 | /// mprotect flag: extend change to start of growsdown vma | 3615 | /// mprotect flag: extend change to start of growsdown vma |
lib/std/os/linux/aarch64.zig-19| ... | @@ -241,23 +241,4 @@ pub const timezone = extern struct { | ... | @@ -241,23 +241,4 @@ pub const timezone = extern struct { |
| 241 | dsttime: i32, | 241 | dsttime: i32, |
| 242 | }; | 242 | }; |
| 243 | 243 | ||
| 244 | pub const mcontext_t = extern struct { | ||
| 245 | fault_address: usize, | ||
| 246 | regs: [31]usize, | ||
| 247 | sp: usize, | ||
| 248 | pc: usize, | ||
| 249 | pstate: usize, | ||
| 250 | // Make sure the field is correctly aligned since this area | ||
| 251 | // holds various FP/vector registers | ||
| 252 | reserved1: [256 * 16]u8 align(16), | ||
| 253 | }; | ||
| 254 | |||
| 255 | pub const ucontext_t = extern struct { | ||
| 256 | flags: usize, | ||
| 257 | link: ?*ucontext_t, | ||
| 258 | stack: stack_t, | ||
| 259 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 260 | mcontext: mcontext_t, | ||
| 261 | }; | ||
| 262 | |||
| 263 | pub const Elf_Symndx = u32; | 244 | pub const Elf_Symndx = u32; |
lib/std/os/linux/arm.zig-33| ... | @@ -277,37 +277,4 @@ pub const timezone = extern struct { | ... | @@ -277,37 +277,4 @@ pub const timezone = extern struct { |
| 277 | dsttime: i32, | 277 | dsttime: i32, |
| 278 | }; | 278 | }; |
| 279 | 279 | ||
| 280 | pub const mcontext_t = extern struct { | ||
| 281 | trap_no: usize, | ||
| 282 | error_code: usize, | ||
| 283 | oldmask: usize, | ||
| 284 | arm_r0: usize, | ||
| 285 | arm_r1: usize, | ||
| 286 | arm_r2: usize, | ||
| 287 | arm_r3: usize, | ||
| 288 | arm_r4: usize, | ||
| 289 | arm_r5: usize, | ||
| 290 | arm_r6: usize, | ||
| 291 | arm_r7: usize, | ||
| 292 | arm_r8: usize, | ||
| 293 | arm_r9: usize, | ||
| 294 | arm_r10: usize, | ||
| 295 | arm_fp: usize, | ||
| 296 | arm_ip: usize, | ||
| 297 | arm_sp: usize, | ||
| 298 | arm_lr: usize, | ||
| 299 | arm_pc: usize, | ||
| 300 | arm_cpsr: usize, | ||
| 301 | fault_address: usize, | ||
| 302 | }; | ||
| 303 | |||
| 304 | pub const ucontext_t = extern struct { | ||
| 305 | flags: usize, | ||
| 306 | link: ?*ucontext_t, | ||
| 307 | stack: stack_t, | ||
| 308 | mcontext: mcontext_t, | ||
| 309 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 310 | regspace: [64]u64, | ||
| 311 | }; | ||
| 312 | |||
| 313 | pub const Elf_Symndx = u32; | 280 | pub const Elf_Symndx = u32; |
lib/std/os/linux/hexagon.zig-52| ... | @@ -168,30 +168,6 @@ pub const Flock = extern struct { | ... | @@ -168,30 +168,6 @@ pub const Flock = extern struct { |
| 168 | __unused: [4]u8, | 168 | __unused: [4]u8, |
| 169 | }; | 169 | }; |
| 170 | 170 | ||
| 171 | pub const msghdr = extern struct { | ||
| 172 | name: ?*sockaddr, | ||
| 173 | namelen: socklen_t, | ||
| 174 | iov: [*]iovec, | ||
| 175 | iovlen: i32, | ||
| 176 | __pad1: i32 = 0, | ||
| 177 | control: ?*anyopaque, | ||
| 178 | controllen: socklen_t, | ||
| 179 | __pad2: socklen_t = 0, | ||
| 180 | flags: i32, | ||
| 181 | }; | ||
| 182 | |||
| 183 | pub const msghdr_const = extern struct { | ||
| 184 | name: ?*const sockaddr, | ||
| 185 | namelen: socklen_t, | ||
| 186 | iov: [*]const iovec_const, | ||
| 187 | iovlen: i32, | ||
| 188 | __pad1: i32 = 0, | ||
| 189 | control: ?*const anyopaque, | ||
| 190 | controllen: socklen_t, | ||
| 191 | __pad2: socklen_t = 0, | ||
| 192 | flags: i32, | ||
| 193 | }; | ||
| 194 | |||
| 195 | pub const blksize_t = i32; | 171 | pub const blksize_t = i32; |
| 196 | pub const nlink_t = u32; | 172 | pub const nlink_t = u32; |
| 197 | pub const time_t = i32; | 173 | pub const time_t = i32; |
| ... | @@ -236,31 +212,3 @@ pub const Stat = extern struct { | ... | @@ -236,31 +212,3 @@ pub const Stat = extern struct { |
| 236 | pub const Elf_Symndx = u32; | 212 | pub const Elf_Symndx = u32; |
| 237 | 213 | ||
| 238 | pub const VDSO = void; | 214 | pub const VDSO = void; |
| 239 | |||
| 240 | pub const mcontext_t = extern struct { | ||
| 241 | gregs: [32]u32 align(8), | ||
| 242 | sa0: u32, | ||
| 243 | lc0: u32, | ||
| 244 | sa1: u32, | ||
| 245 | lc1: u32, | ||
| 246 | m0: u32, | ||
| 247 | m1: u32, | ||
| 248 | usr: u32, | ||
| 249 | p3_0: u32, | ||
| 250 | gp: u32, | ||
| 251 | ugp: u32, | ||
| 252 | pc: u32, | ||
| 253 | cause: u32, | ||
| 254 | badva: u32, | ||
| 255 | cs0: u32, | ||
| 256 | cs1: u32, | ||
| 257 | _pad1: u32, | ||
| 258 | }; | ||
| 259 | |||
| 260 | pub const ucontext_t = extern struct { | ||
| 261 | flags: u32, | ||
| 262 | link: ?*ucontext_t, | ||
| 263 | stack: stack_t, | ||
| 264 | mcontext: mcontext_t, | ||
| 265 | sigmask: sigset_t, | ||
| 266 | }; |
lib/std/os/linux/loongarch64.zig-39| ... | @@ -135,30 +135,6 @@ pub fn clone() callconv(.naked) usize { | ... | @@ -135,30 +135,6 @@ pub fn clone() callconv(.naked) usize { |
| 135 | ); | 135 | ); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | pub const msghdr = extern struct { | ||
| 139 | name: ?*sockaddr, | ||
| 140 | namelen: socklen_t, | ||
| 141 | iov: [*]iovec, | ||
| 142 | iovlen: i32, | ||
| 143 | __pad1: i32 = 0, | ||
| 144 | control: ?*anyopaque, | ||
| 145 | controllen: socklen_t, | ||
| 146 | __pad2: socklen_t = 0, | ||
| 147 | flags: i32, | ||
| 148 | }; | ||
| 149 | |||
| 150 | pub const msghdr_const = extern struct { | ||
| 151 | name: ?*const sockaddr, | ||
| 152 | namelen: socklen_t, | ||
| 153 | iov: [*]const iovec_const, | ||
| 154 | iovlen: i32, | ||
| 155 | __pad1: i32 = 0, | ||
| 156 | control: ?*const anyopaque, | ||
| 157 | controllen: socklen_t, | ||
| 158 | __pad2: socklen_t = 0, | ||
| 159 | flags: i32, | ||
| 160 | }; | ||
| 161 | |||
| 162 | pub const blksize_t = i32; | 138 | pub const blksize_t = i32; |
| 163 | pub const nlink_t = u32; | 139 | pub const nlink_t = u32; |
| 164 | pub const time_t = i64; | 140 | pub const time_t = i64; |
| ... | @@ -234,19 +210,4 @@ pub const VDSO = struct { | ... | @@ -234,19 +210,4 @@ pub const VDSO = struct { |
| 234 | pub const CGT_VER = "LINUX_5.10"; | 210 | pub const CGT_VER = "LINUX_5.10"; |
| 235 | }; | 211 | }; |
| 236 | 212 | ||
| 237 | pub const mcontext_t = extern struct { | ||
| 238 | pc: u64, | ||
| 239 | regs: [32]u64, | ||
| 240 | flags: u32, | ||
| 241 | extcontext: [0]u64 align(16), | ||
| 242 | }; | ||
| 243 | |||
| 244 | pub const ucontext_t = extern struct { | ||
| 245 | flags: c_ulong, | ||
| 246 | link: ?*ucontext_t, | ||
| 247 | stack: stack_t, | ||
| 248 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 249 | mcontext: mcontext_t, | ||
| 250 | }; | ||
| 251 | |||
| 252 | pub const Elf_Symndx = u32; | 213 | pub const Elf_Symndx = u32; |
lib/std/os/linux/m68k.zig-24| ... | @@ -199,27 +199,6 @@ pub const Flock = extern struct { | ... | @@ -199,27 +199,6 @@ pub const Flock = extern struct { |
| 199 | pid: pid_t, | 199 | pid: pid_t, |
| 200 | }; | 200 | }; |
| 201 | 201 | ||
| 202 | // TODO: not 100% sure of padding for msghdr | ||
| 203 | pub const msghdr = extern struct { | ||
| 204 | name: ?*sockaddr, | ||
| 205 | namelen: socklen_t, | ||
| 206 | iov: [*]iovec, | ||
| 207 | iovlen: i32, | ||
| 208 | control: ?*anyopaque, | ||
| 209 | controllen: socklen_t, | ||
| 210 | flags: i32, | ||
| 211 | }; | ||
| 212 | |||
| 213 | pub const msghdr_const = extern struct { | ||
| 214 | name: ?*const sockaddr, | ||
| 215 | namelen: socklen_t, | ||
| 216 | iov: [*]const iovec_const, | ||
| 217 | iovlen: i32, | ||
| 218 | control: ?*const anyopaque, | ||
| 219 | controllen: socklen_t, | ||
| 220 | flags: i32, | ||
| 221 | }; | ||
| 222 | |||
| 223 | pub const Stat = extern struct { | 202 | pub const Stat = extern struct { |
| 224 | dev: dev_t, | 203 | dev: dev_t, |
| 225 | __pad: i16, | 204 | __pad: i16, |
| ... | @@ -255,6 +234,3 @@ pub const Elf_Symndx = u32; | ... | @@ -255,6 +234,3 @@ pub const Elf_Symndx = u32; |
| 255 | 234 | ||
| 256 | // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6. | 235 | // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6. |
| 257 | pub const VDSO = void; | 236 | pub const VDSO = void; |
| 258 | |||
| 259 | /// TODO | ||
| 260 | pub const ucontext_t = void; |
lib/std/os/linux/mips.zig-29| ... | @@ -348,32 +348,3 @@ pub const timezone = extern struct { | ... | @@ -348,32 +348,3 @@ pub const timezone = extern struct { |
| 348 | }; | 348 | }; |
| 349 | 349 | ||
| 350 | pub const Elf_Symndx = u32; | 350 | pub const Elf_Symndx = u32; |
| 351 | |||
| 352 | pub const mcontext_t = extern struct { | ||
| 353 | _regmask: u32, | ||
| 354 | _status: u32, | ||
| 355 | pc: u64, | ||
| 356 | regs: [32]u64, | ||
| 357 | fpregs: [32]f64, | ||
| 358 | acx: u32, | ||
| 359 | fpc_csr: u32, | ||
| 360 | _fpc_eir: u32, | ||
| 361 | used_math: u32, | ||
| 362 | dsp: u32, | ||
| 363 | mdhi: u64, | ||
| 364 | mdlo: u64, | ||
| 365 | hi1: u32, | ||
| 366 | lo1: u32, | ||
| 367 | hi2: u32, | ||
| 368 | lo2: u32, | ||
| 369 | hi3: u32, | ||
| 370 | lo3: u32, | ||
| 371 | }; | ||
| 372 | |||
| 373 | pub const ucontext_t = extern struct { | ||
| 374 | flags: u32, | ||
| 375 | link: ?*ucontext_t, | ||
| 376 | stack: stack_t, | ||
| 377 | mcontext: mcontext_t, | ||
| 378 | sigmask: sigset_t, | ||
| 379 | }; |
lib/std/os/linux/mips64.zig-26| ... | @@ -327,29 +327,3 @@ pub const timezone = extern struct { | ... | @@ -327,29 +327,3 @@ pub const timezone = extern struct { |
| 327 | }; | 327 | }; |
| 328 | 328 | ||
| 329 | pub const Elf_Symndx = u32; | 329 | pub const Elf_Symndx = u32; |
| 330 | |||
| 331 | pub const mcontext_t = extern struct { | ||
| 332 | regs: [32]u64, | ||
| 333 | fpregs: [32]f64, | ||
| 334 | mdhi: u64, | ||
| 335 | hi1: u64, | ||
| 336 | hi2: u64, | ||
| 337 | hi3: u64, | ||
| 338 | mdlo: u64, | ||
| 339 | lo1: u64, | ||
| 340 | lo2: u64, | ||
| 341 | lo3: u64, | ||
| 342 | pc: u64, | ||
| 343 | fpc_csr: u32, | ||
| 344 | used_math: u32, | ||
| 345 | dsp: u32, | ||
| 346 | _reserved: u32, | ||
| 347 | }; | ||
| 348 | |||
| 349 | pub const ucontext_t = extern struct { | ||
| 350 | flags: u32, | ||
| 351 | link: ?*ucontext_t, | ||
| 352 | stack: stack_t, | ||
| 353 | mcontext: mcontext_t, | ||
| 354 | sigmask: sigset_t, | ||
| 355 | }; |
lib/std/os/linux/powerpc.zig-29| ... | @@ -351,33 +351,4 @@ pub const timezone = extern struct { | ... | @@ -351,33 +351,4 @@ pub const timezone = extern struct { |
| 351 | dsttime: i32, | 351 | dsttime: i32, |
| 352 | }; | 352 | }; |
| 353 | 353 | ||
| 354 | pub const greg_t = u32; | ||
| 355 | pub const gregset_t = [48]greg_t; | ||
| 356 | pub const fpregset_t = [33]f64; | ||
| 357 | |||
| 358 | pub const vrregset = extern struct { | ||
| 359 | vrregs: [32][4]u32, | ||
| 360 | vrsave: u32, | ||
| 361 | _pad: [2]u32, | ||
| 362 | vscr: u32, | ||
| 363 | }; | ||
| 364 | pub const vrregset_t = vrregset; | ||
| 365 | |||
| 366 | pub const mcontext_t = extern struct { | ||
| 367 | gp_regs: gregset_t, | ||
| 368 | fp_regs: fpregset_t, | ||
| 369 | v_regs: vrregset_t align(16), | ||
| 370 | }; | ||
| 371 | |||
| 372 | pub const ucontext_t = extern struct { | ||
| 373 | flags: u32, | ||
| 374 | link: ?*ucontext_t, | ||
| 375 | stack: stack_t, | ||
| 376 | pad: [7]i32, | ||
| 377 | regs: *mcontext_t, | ||
| 378 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 379 | pad2: [3]i32, | ||
| 380 | mcontext: mcontext_t, | ||
| 381 | }; | ||
| 382 | |||
| 383 | pub const Elf_Symndx = u32; | 354 | pub const Elf_Symndx = u32; |
lib/std/os/linux/powerpc64.zig-39| ... | @@ -336,43 +336,4 @@ pub const timezone = extern struct { | ... | @@ -336,43 +336,4 @@ pub const timezone = extern struct { |
| 336 | dsttime: i32, | 336 | dsttime: i32, |
| 337 | }; | 337 | }; |
| 338 | 338 | ||
| 339 | pub const greg_t = u64; | ||
| 340 | pub const gregset_t = [48]greg_t; | ||
| 341 | pub const fpregset_t = [33]f64; | ||
| 342 | |||
| 343 | /// The position of the vscr register depends on endianness. | ||
| 344 | /// On C, macros are used to change vscr_word's offset to | ||
| 345 | /// account for this. Here we'll just define vscr_word_le | ||
| 346 | /// and vscr_word_be. Code must take care to use the correct one. | ||
| 347 | pub const vrregset = extern struct { | ||
| 348 | vrregs: [32][4]u32 align(16), | ||
| 349 | vscr_word_le: u32, | ||
| 350 | _pad1: [2]u32, | ||
| 351 | vscr_word_be: u32, | ||
| 352 | vrsave: u32, | ||
| 353 | _pad2: [3]u32, | ||
| 354 | }; | ||
| 355 | pub const vrregset_t = vrregset; | ||
| 356 | |||
| 357 | pub const mcontext_t = extern struct { | ||
| 358 | __unused: [4]u64, | ||
| 359 | signal: i32, | ||
| 360 | _pad0: i32, | ||
| 361 | handler: u64, | ||
| 362 | oldmask: u64, | ||
| 363 | regs: ?*anyopaque, | ||
| 364 | gp_regs: gregset_t, | ||
| 365 | fp_regs: fpregset_t, | ||
| 366 | v_regs: *vrregset_t, | ||
| 367 | vmx_reserve: [34 + 34 + 32 + 1]i64, | ||
| 368 | }; | ||
| 369 | |||
| 370 | pub const ucontext_t = extern struct { | ||
| 371 | flags: u32, | ||
| 372 | link: ?*ucontext_t, | ||
| 373 | stack: stack_t, | ||
| 374 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 375 | mcontext: mcontext_t, | ||
| 376 | }; | ||
| 377 | |||
| 378 | pub const Elf_Symndx = u32; | 339 | pub const Elf_Symndx = u32; |
lib/std/os/linux/riscv32.zig-35| ... | @@ -220,38 +220,3 @@ pub const VDSO = struct { | ... | @@ -220,38 +220,3 @@ pub const VDSO = struct { |
| 220 | pub const CGT_SYM = "__vdso_clock_gettime"; | 220 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 221 | pub const CGT_VER = "LINUX_4.15"; | 221 | pub const CGT_VER = "LINUX_4.15"; |
| 222 | }; | 222 | }; |
| 223 | |||
| 224 | pub const f_ext_state = extern struct { | ||
| 225 | f: [32]f32, | ||
| 226 | fcsr: u32, | ||
| 227 | }; | ||
| 228 | |||
| 229 | pub const d_ext_state = extern struct { | ||
| 230 | f: [32]f64, | ||
| 231 | fcsr: u32, | ||
| 232 | }; | ||
| 233 | |||
| 234 | pub const q_ext_state = extern struct { | ||
| 235 | f: [32]f128, | ||
| 236 | fcsr: u32, | ||
| 237 | _reserved: [3]u32, | ||
| 238 | }; | ||
| 239 | |||
| 240 | pub const fpstate = extern union { | ||
| 241 | f: f_ext_state, | ||
| 242 | d: d_ext_state, | ||
| 243 | q: q_ext_state, | ||
| 244 | }; | ||
| 245 | |||
| 246 | pub const mcontext_t = extern struct { | ||
| 247 | gregs: [32]u32, | ||
| 248 | fpregs: fpstate, | ||
| 249 | }; | ||
| 250 | |||
| 251 | pub const ucontext_t = extern struct { | ||
| 252 | flags: c_ulong, | ||
| 253 | link: ?*ucontext_t, | ||
| 254 | stack: stack_t, | ||
| 255 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 256 | mcontext: mcontext_t, | ||
| 257 | }; |
lib/std/os/linux/riscv64.zig-35| ... | @@ -220,38 +220,3 @@ pub const VDSO = struct { | ... | @@ -220,38 +220,3 @@ pub const VDSO = struct { |
| 220 | pub const CGT_SYM = "__vdso_clock_gettime"; | 220 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 221 | pub const CGT_VER = "LINUX_4.15"; | 221 | pub const CGT_VER = "LINUX_4.15"; |
| 222 | }; | 222 | }; |
| 223 | |||
| 224 | pub const f_ext_state = extern struct { | ||
| 225 | f: [32]f32, | ||
| 226 | fcsr: u32, | ||
| 227 | }; | ||
| 228 | |||
| 229 | pub const d_ext_state = extern struct { | ||
| 230 | f: [32]f64, | ||
| 231 | fcsr: u32, | ||
| 232 | }; | ||
| 233 | |||
| 234 | pub const q_ext_state = extern struct { | ||
| 235 | f: [32]f128, | ||
| 236 | fcsr: u32, | ||
| 237 | _reserved: [3]u32, | ||
| 238 | }; | ||
| 239 | |||
| 240 | pub const fpstate = extern union { | ||
| 241 | f: f_ext_state, | ||
| 242 | d: d_ext_state, | ||
| 243 | q: q_ext_state, | ||
| 244 | }; | ||
| 245 | |||
| 246 | pub const mcontext_t = extern struct { | ||
| 247 | gregs: [32]u64, | ||
| 248 | fpregs: fpstate, | ||
| 249 | }; | ||
| 250 | |||
| 251 | pub const ucontext_t = extern struct { | ||
| 252 | flags: c_ulong, | ||
| 253 | link: ?*ucontext_t, | ||
| 254 | stack: stack_t, | ||
| 255 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 256 | mcontext: mcontext_t, | ||
| 257 | }; |
lib/std/os/linux/s390x.zig-43| ... | @@ -199,30 +199,6 @@ pub const Flock = extern struct { | ... | @@ -199,30 +199,6 @@ pub const Flock = extern struct { |
| 199 | pid: pid_t, | 199 | pid: pid_t, |
| 200 | }; | 200 | }; |
| 201 | 201 | ||
| 202 | pub const msghdr = extern struct { | ||
| 203 | name: ?*sockaddr, | ||
| 204 | namelen: socklen_t, | ||
| 205 | iov: [*]iovec, | ||
| 206 | __pad1: i32 = 0, | ||
| 207 | iovlen: i32, | ||
| 208 | control: ?*anyopaque, | ||
| 209 | __pad2: i32 = 0, | ||
| 210 | controllen: socklen_t, | ||
| 211 | flags: i32, | ||
| 212 | }; | ||
| 213 | |||
| 214 | pub const msghdr_const = extern struct { | ||
| 215 | name: ?*const sockaddr, | ||
| 216 | namelen: socklen_t, | ||
| 217 | iov: [*]const iovec_const, | ||
| 218 | __pad1: i32 = 0, | ||
| 219 | iovlen: i32, | ||
| 220 | control: ?*const anyopaque, | ||
| 221 | __pad2: i32 = 0, | ||
| 222 | controllen: socklen_t, | ||
| 223 | flags: i32, | ||
| 224 | }; | ||
| 225 | |||
| 226 | // The `stat` definition used by the Linux kernel. | 202 | // The `stat` definition used by the Linux kernel. |
| 227 | pub const Stat = extern struct { | 203 | pub const Stat = extern struct { |
| 228 | dev: dev_t, | 204 | dev: dev_t, |
| ... | @@ -259,22 +235,3 @@ pub const VDSO = struct { | ... | @@ -259,22 +235,3 @@ pub const VDSO = struct { |
| 259 | pub const CGT_SYM = "__kernel_clock_gettime"; | 235 | pub const CGT_SYM = "__kernel_clock_gettime"; |
| 260 | pub const CGT_VER = "LINUX_2.6.29"; | 236 | pub const CGT_VER = "LINUX_2.6.29"; |
| 261 | }; | 237 | }; |
| 262 | |||
| 263 | pub const ucontext_t = extern struct { | ||
| 264 | flags: u64, | ||
| 265 | link: ?*ucontext_t, | ||
| 266 | stack: stack_t, | ||
| 267 | mcontext: mcontext_t, | ||
| 268 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 269 | }; | ||
| 270 | |||
| 271 | pub const mcontext_t = extern struct { | ||
| 272 | psw: extern struct { | ||
| 273 | mask: u64, | ||
| 274 | addr: u64, | ||
| 275 | }, | ||
| 276 | gregs: [16]u64, | ||
| 277 | aregs: [16]u32, | ||
| 278 | fpc: u32, | ||
| 279 | fregs: [16]f64, | ||
| 280 | }; |
lib/std/os/linux/sparc64.zig-100| ... | @@ -325,104 +325,4 @@ pub const timezone = extern struct { | ... | @@ -325,104 +325,4 @@ pub const timezone = extern struct { |
| 325 | dsttime: i32, | 325 | dsttime: i32, |
| 326 | }; | 326 | }; |
| 327 | 327 | ||
| 328 | // TODO I'm not sure if the code below is correct, need someone with more | ||
| 329 | // knowledge about sparc64 linux internals to look into. | ||
| 330 | |||
| 331 | pub const Elf_Symndx = u32; | 328 | pub const Elf_Symndx = u32; |
| 332 | |||
| 333 | pub const fpstate = extern struct { | ||
| 334 | regs: [32]u64, | ||
| 335 | fsr: u64, | ||
| 336 | gsr: u64, | ||
| 337 | fprs: u64, | ||
| 338 | }; | ||
| 339 | |||
| 340 | pub const __fpq = extern struct { | ||
| 341 | fpq_addr: *u32, | ||
| 342 | fpq_instr: u32, | ||
| 343 | }; | ||
| 344 | |||
| 345 | pub const __fq = extern struct { | ||
| 346 | FQu: extern union { | ||
| 347 | whole: f64, | ||
| 348 | fpq: __fpq, | ||
| 349 | }, | ||
| 350 | }; | ||
| 351 | |||
| 352 | pub const fpregset_t = extern struct { | ||
| 353 | fpu_fr: extern union { | ||
| 354 | fpu_regs: [32]u32, | ||
| 355 | fpu_dregs: [32]f64, | ||
| 356 | fpu_qregs: [16]c_longdouble, | ||
| 357 | }, | ||
| 358 | fpu_q: *__fq, | ||
| 359 | fpu_fsr: u64, | ||
| 360 | fpu_qcnt: u8, | ||
| 361 | fpu_q_entrysize: u8, | ||
| 362 | fpu_en: u8, | ||
| 363 | }; | ||
| 364 | |||
| 365 | pub const siginfo_fpu_t = extern struct { | ||
| 366 | float_regs: [64]u32, | ||
| 367 | fsr: u64, | ||
| 368 | gsr: u64, | ||
| 369 | fprs: u64, | ||
| 370 | }; | ||
| 371 | |||
| 372 | pub const sigcontext = extern struct { | ||
| 373 | info: [128]i8, | ||
| 374 | regs: extern struct { | ||
| 375 | u_regs: [16]u64, | ||
| 376 | tstate: u64, | ||
| 377 | tpc: u64, | ||
| 378 | tnpc: u64, | ||
| 379 | y: u64, | ||
| 380 | fprs: u64, | ||
| 381 | }, | ||
| 382 | fpu_save: *siginfo_fpu_t, | ||
| 383 | stack: extern struct { | ||
| 384 | sp: usize, | ||
| 385 | flags: i32, | ||
| 386 | size: u64, | ||
| 387 | }, | ||
| 388 | mask: u64, | ||
| 389 | }; | ||
| 390 | |||
| 391 | pub const greg_t = u64; | ||
| 392 | pub const gregset_t = [19]greg_t; | ||
| 393 | |||
| 394 | pub const fq = extern struct { | ||
| 395 | addr: *u64, | ||
| 396 | insn: u32, | ||
| 397 | }; | ||
| 398 | |||
| 399 | pub const fpu_t = extern struct { | ||
| 400 | fregs: extern union { | ||
| 401 | sregs: [32]u32, | ||
| 402 | dregs: [32]u64, | ||
| 403 | qregs: [16]c_longdouble, | ||
| 404 | }, | ||
| 405 | fsr: u64, | ||
| 406 | fprs: u64, | ||
| 407 | gsr: u64, | ||
| 408 | fq: *fq, | ||
| 409 | qcnt: u8, | ||
| 410 | qentsz: u8, | ||
| 411 | enab: u8, | ||
| 412 | }; | ||
| 413 | |||
| 414 | pub const mcontext_t = extern struct { | ||
| 415 | gregs: gregset_t, | ||
| 416 | fp: greg_t, | ||
| 417 | i7: greg_t, | ||
| 418 | fpregs: fpu_t, | ||
| 419 | }; | ||
| 420 | |||
| 421 | pub const ucontext_t = extern struct { | ||
| 422 | link: ?*ucontext_t, | ||
| 423 | flags: u64, | ||
| 424 | sigmask: u64, | ||
| 425 | mcontext: mcontext_t, | ||
| 426 | stack: stack_t, | ||
| 427 | sigset: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 428 | }; |
lib/std/os/linux/x86.zig-108| ... | @@ -288,44 +288,6 @@ pub const timezone = extern struct { | ... | @@ -288,44 +288,6 @@ pub const timezone = extern struct { |
| 288 | dsttime: i32, | 288 | dsttime: i32, |
| 289 | }; | 289 | }; |
| 290 | 290 | ||
| 291 | pub const mcontext_t = extern struct { | ||
| 292 | gregs: [19]usize, | ||
| 293 | fpregs: [*]u8, | ||
| 294 | oldmask: usize, | ||
| 295 | cr2: usize, | ||
| 296 | }; | ||
| 297 | |||
| 298 | pub const REG = struct { | ||
| 299 | pub const GS = 0; | ||
| 300 | pub const FS = 1; | ||
| 301 | pub const ES = 2; | ||
| 302 | pub const DS = 3; | ||
| 303 | pub const EDI = 4; | ||
| 304 | pub const ESI = 5; | ||
| 305 | pub const EBP = 6; | ||
| 306 | pub const ESP = 7; | ||
| 307 | pub const EBX = 8; | ||
| 308 | pub const EDX = 9; | ||
| 309 | pub const ECX = 10; | ||
| 310 | pub const EAX = 11; | ||
| 311 | pub const TRAPNO = 12; | ||
| 312 | pub const ERR = 13; | ||
| 313 | pub const EIP = 14; | ||
| 314 | pub const CS = 15; | ||
| 315 | pub const EFL = 16; | ||
| 316 | pub const UESP = 17; | ||
| 317 | pub const SS = 18; | ||
| 318 | }; | ||
| 319 | |||
| 320 | pub const ucontext_t = extern struct { | ||
| 321 | flags: usize, | ||
| 322 | link: ?*ucontext_t, | ||
| 323 | stack: stack_t, | ||
| 324 | mcontext: mcontext_t, | ||
| 325 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask | ||
| 326 | regspace: [64]u64, | ||
| 327 | }; | ||
| 328 | |||
| 329 | pub const Elf_Symndx = u32; | 291 | pub const Elf_Symndx = u32; |
| 330 | 292 | ||
| 331 | pub const user_desc = extern struct { | 293 | pub const user_desc = extern struct { |
| ... | @@ -366,73 +328,3 @@ pub const SC = struct { | ... | @@ -366,73 +328,3 @@ pub const SC = struct { |
| 366 | pub const recvmmsg = 19; | 328 | pub const recvmmsg = 19; |
| 367 | pub const sendmmsg = 20; | 329 | pub const sendmmsg = 20; |
| 368 | }; | 330 | }; |
| 369 | |||
| 370 | fn gpRegisterOffset(comptime reg_index: comptime_int) usize { | ||
| 371 | return @offsetOf(ucontext_t, "mcontext") + @offsetOf(mcontext_t, "gregs") + @sizeOf(usize) * reg_index; | ||
| 372 | } | ||
| 373 | |||
| 374 | noinline fn getContextReturnAddress() usize { | ||
| 375 | return @returnAddress(); | ||
| 376 | } | ||
| 377 | |||
| 378 | pub fn getContextInternal() callconv(.naked) usize { | ||
| 379 | asm volatile ( | ||
| 380 | \\ movl $0, %[flags_offset:c](%%edx) | ||
| 381 | \\ movl $0, %[link_offset:c](%%edx) | ||
| 382 | \\ movl %%edi, %[edi_offset:c](%%edx) | ||
| 383 | \\ movl %%esi, %[esi_offset:c](%%edx) | ||
| 384 | \\ movl %%ebp, %[ebp_offset:c](%%edx) | ||
| 385 | \\ movl %%ebx, %[ebx_offset:c](%%edx) | ||
| 386 | \\ movl %%edx, %[edx_offset:c](%%edx) | ||
| 387 | \\ movl %%ecx, %[ecx_offset:c](%%edx) | ||
| 388 | \\ movl %%eax, %[eax_offset:c](%%edx) | ||
| 389 | \\ movl (%%esp), %%ecx | ||
| 390 | \\ movl %%ecx, %[eip_offset:c](%%edx) | ||
| 391 | \\ leal 4(%%esp), %%ecx | ||
| 392 | \\ movl %%ecx, %[esp_offset:c](%%edx) | ||
| 393 | \\ xorl %%ecx, %%ecx | ||
| 394 | \\ movw %%fs, %%cx | ||
| 395 | \\ movl %%ecx, %[fs_offset:c](%%edx) | ||
| 396 | \\ leal %[regspace_offset:c](%%edx), %%ecx | ||
| 397 | \\ movl %%ecx, %[fpregs_offset:c](%%edx) | ||
| 398 | \\ fnstenv (%%ecx) | ||
| 399 | \\ fldenv (%%ecx) | ||
| 400 | \\ pushl %%ebx | ||
| 401 | \\ pushl %%esi | ||
| 402 | \\ xorl %%ebx, %%ebx | ||
| 403 | \\ movl %[sigaltstack], %%eax | ||
| 404 | \\ leal %[stack_offset:c](%%edx), %%ecx | ||
| 405 | \\ int $0x80 | ||
| 406 | \\ testl %%eax, %%eax | ||
| 407 | \\ jnz 0f | ||
| 408 | \\ movl %[sigprocmask], %%eax | ||
| 409 | \\ xorl %%ecx, %%ecx | ||
| 410 | \\ leal %[sigmask_offset:c](%%edx), %%edx | ||
| 411 | \\ movl %[sigset_size], %%esi | ||
| 412 | \\ int $0x80 | ||
| 413 | \\0: | ||
| 414 | \\ popl %%esi | ||
| 415 | \\ popl %%ebx | ||
| 416 | \\ retl | ||
| 417 | : | ||
| 418 | : [flags_offset] "i" (@offsetOf(ucontext_t, "flags")), | ||
| 419 | [link_offset] "i" (@offsetOf(ucontext_t, "link")), | ||
| 420 | [edi_offset] "i" (comptime gpRegisterOffset(REG.EDI)), | ||
| 421 | [esi_offset] "i" (comptime gpRegisterOffset(REG.ESI)), | ||
| 422 | [ebp_offset] "i" (comptime gpRegisterOffset(REG.EBP)), | ||
| 423 | [esp_offset] "i" (comptime gpRegisterOffset(REG.ESP)), | ||
| 424 | [ebx_offset] "i" (comptime gpRegisterOffset(REG.EBX)), | ||
| 425 | [edx_offset] "i" (comptime gpRegisterOffset(REG.EDX)), | ||
| 426 | [ecx_offset] "i" (comptime gpRegisterOffset(REG.ECX)), | ||
| 427 | [eax_offset] "i" (comptime gpRegisterOffset(REG.EAX)), | ||
| 428 | [eip_offset] "i" (comptime gpRegisterOffset(REG.EIP)), | ||
| 429 | [fs_offset] "i" (comptime gpRegisterOffset(REG.FS)), | ||
| 430 | [fpregs_offset] "i" (@offsetOf(ucontext_t, "mcontext") + @offsetOf(mcontext_t, "fpregs")), | ||
| 431 | [regspace_offset] "i" (@offsetOf(ucontext_t, "regspace")), | ||
| 432 | [sigaltstack] "i" (@intFromEnum(linux.SYS.sigaltstack)), | ||
| 433 | [stack_offset] "i" (@offsetOf(ucontext_t, "stack")), | ||
| 434 | [sigprocmask] "i" (@intFromEnum(linux.SYS.rt_sigprocmask)), | ||
| 435 | [sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")), | ||
| 436 | [sigset_size] "i" (linux.NSIG / 8), | ||
| 437 | : .{ .cc = true, .memory = true, .eax = true, .ecx = true, .edx = true }); | ||
| 438 | } |
lib/std/os/linux/x86_64.zig-106| ... | @@ -190,32 +190,6 @@ pub const ARCH = struct { | ... | @@ -190,32 +190,6 @@ pub const ARCH = struct { |
| 190 | pub const GET_GS = 0x1004; | 190 | pub const GET_GS = 0x1004; |
| 191 | }; | 191 | }; |
| 192 | 192 | ||
| 193 | pub const REG = struct { | ||
| 194 | pub const R8 = 0; | ||
| 195 | pub const R9 = 1; | ||
| 196 | pub const R10 = 2; | ||
| 197 | pub const R11 = 3; | ||
| 198 | pub const R12 = 4; | ||
| 199 | pub const R13 = 5; | ||
| 200 | pub const R14 = 6; | ||
| 201 | pub const R15 = 7; | ||
| 202 | pub const RDI = 8; | ||
| 203 | pub const RSI = 9; | ||
| 204 | pub const RBP = 10; | ||
| 205 | pub const RBX = 11; | ||
| 206 | pub const RDX = 12; | ||
| 207 | pub const RAX = 13; | ||
| 208 | pub const RCX = 14; | ||
| 209 | pub const RSP = 15; | ||
| 210 | pub const RIP = 16; | ||
| 211 | pub const EFL = 17; | ||
| 212 | pub const CSGSFS = 18; | ||
| 213 | pub const ERR = 19; | ||
| 214 | pub const TRAPNO = 20; | ||
| 215 | pub const OLDMASK = 21; | ||
| 216 | pub const CR2 = 22; | ||
| 217 | }; | ||
| 218 | |||
| 219 | pub const Flock = extern struct { | 193 | pub const Flock = extern struct { |
| 220 | type: i16, | 194 | type: i16, |
| 221 | whence: i16, | 195 | whence: i16, |
| ... | @@ -272,83 +246,3 @@ pub const timezone = extern struct { | ... | @@ -272,83 +246,3 @@ pub const timezone = extern struct { |
| 272 | }; | 246 | }; |
| 273 | 247 | ||
| 274 | pub const Elf_Symndx = u32; | 248 | pub const Elf_Symndx = u32; |
| 275 | |||
| 276 | pub const greg_t = usize; | ||
| 277 | pub const gregset_t = [23]greg_t; | ||
| 278 | pub const fpstate = extern struct { | ||
| 279 | cwd: u16, | ||
| 280 | swd: u16, | ||
| 281 | ftw: u16, | ||
| 282 | fop: u16, | ||
| 283 | rip: usize, | ||
| 284 | rdp: usize, | ||
| 285 | mxcsr: u32, | ||
| 286 | mxcr_mask: u32, | ||
| 287 | st: [8]extern struct { | ||
| 288 | significand: [4]u16, | ||
| 289 | exponent: u16, | ||
| 290 | padding: [3]u16 = undefined, | ||
| 291 | }, | ||
| 292 | xmm: [16]extern struct { | ||
| 293 | element: [4]u32, | ||
| 294 | }, | ||
| 295 | padding: [24]u32 = undefined, | ||
| 296 | }; | ||
| 297 | pub const fpregset_t = *fpstate; | ||
| 298 | pub const sigcontext = extern struct { | ||
| 299 | r8: usize, | ||
| 300 | r9: usize, | ||
| 301 | r10: usize, | ||
| 302 | r11: usize, | ||
| 303 | r12: usize, | ||
| 304 | r13: usize, | ||
| 305 | r14: usize, | ||
| 306 | r15: usize, | ||
| 307 | |||
| 308 | rdi: usize, | ||
| 309 | rsi: usize, | ||
| 310 | rbp: usize, | ||
| 311 | rbx: usize, | ||
| 312 | rdx: usize, | ||
| 313 | rax: usize, | ||
| 314 | rcx: usize, | ||
| 315 | rsp: usize, | ||
| 316 | rip: usize, | ||
| 317 | eflags: usize, | ||
| 318 | |||
| 319 | cs: u16, | ||
| 320 | gs: u16, | ||
| 321 | fs: u16, | ||
| 322 | pad0: u16 = undefined, | ||
| 323 | |||
| 324 | err: usize, | ||
| 325 | trapno: usize, | ||
| 326 | oldmask: usize, | ||
| 327 | cr2: usize, | ||
| 328 | |||
| 329 | fpstate: *fpstate, | ||
| 330 | reserved1: [8]usize = undefined, | ||
| 331 | }; | ||
| 332 | |||
| 333 | pub const mcontext_t = extern struct { | ||
| 334 | gregs: gregset_t, | ||
| 335 | fpregs: fpregset_t, | ||
| 336 | reserved1: [8]usize = undefined, | ||
| 337 | }; | ||
| 338 | |||
| 339 | /// ucontext_t is part of the state pushed on the stack by the kernel for | ||
| 340 | /// a signal handler. And also a subset of the state returned from the | ||
| 341 | /// makecontext/getcontext/swapcontext POSIX APIs. | ||
| 342 | /// | ||
| 343 | /// Currently this structure matches the glibc/musl layout. It contains a | ||
| 344 | /// 1024-bit signal mask, and `fpregs_mem`. This structure should be | ||
| 345 | /// split into one for the kernel ABI and c.zig should define a glibc/musl | ||
| 346 | /// compatible structure. | ||
| 347 | pub const ucontext_t = extern struct { | ||
| 348 | flags: usize, | ||
| 349 | link: ?*ucontext_t, | ||
| 350 | stack: stack_t, | ||
| 351 | mcontext: mcontext_t, | ||
| 352 | sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a glibc-compatible (1024-bit) sigmask. | ||
| 353 | fpregs_mem: [64]usize, // Not part of kernel ABI, only part of glibc ucontext_t | ||
| 354 | }; |
lib/std/posix.zig-1| ... | @@ -97,7 +97,6 @@ pub const POLL = system.POLL; | ... | @@ -97,7 +97,6 @@ pub const POLL = system.POLL; |
| 97 | pub const POSIX_FADV = system.POSIX_FADV; | 97 | pub const POSIX_FADV = system.POSIX_FADV; |
| 98 | pub const PR = system.PR; | 98 | pub const PR = system.PR; |
| 99 | pub const PROT = system.PROT; | 99 | pub const PROT = system.PROT; |
| 100 | pub const REG = system.REG; | ||
| 101 | pub const RLIM = system.RLIM; | 100 | pub const RLIM = system.RLIM; |
| 102 | pub const RR = system.RR; | 101 | pub const RR = system.RR; |
| 103 | pub const S = system.S; | 102 | pub const S = system.S; |