Source
pub const mcontext_t = switch (native_os) {
.linux => linux.mcontext_t,
.emscripten => emscripten.mcontext_t,
.macos, .ios, .tvos, .watchos, .visionos => darwin.mcontext_t,
.freebsd => switch (builtin.cpu.arch) {
.x86_64 => extern struct {
onstack: u64,
rdi: u64,
rsi: u64,
rdx: u64,
rcx: u64,
r8: u64,
r9: u64,
rax: u64,
rbx: u64,
rbp: u64,
r10: u64,
r11: u64,
r12: u64,
r13: u64,
r14: u64,
r15: u64,
trapno: u32,
fs: u16,
gs: u16,
addr: u64,
flags: u32,
es: u16,
ds: u16,
err: u64,
rip: u64,
cs: u64,
rflags: u64,
rsp: u64,
ss: u64,
len: u64,
fpformat: u64,
ownedfp: u64,
fpstate: [64]u64 align(16),
fsbase: u64,
gsbase: u64,
xfpustate: u64,
xfpustate_len: u64,
spare: [4]u64,
},
.aarch64 => extern struct {
gpregs: extern struct {
x: [30]u64,
lr: u64,
sp: u64,
elr: u64,
spsr: u32,
_pad: u32,
},
fpregs: extern struct {
q: [32]u128,
sr: u32,
cr: u32,
flags: u32,
_pad: u32,
},
flags: u32,
_pad: u32,
_spare: [8]u64,
},
else => struct {},
},
.solaris, .illumos => extern struct {
gregs: [28]u64,
fpregs: solaris.fpregset_t,
},
.netbsd => switch (builtin.cpu.arch) {
.aarch64 => extern struct {
gregs: [35]u64,
fregs: [528]u8 align(16),
spare: [8]u64,
},
.x86_64 => extern struct {
gregs: [26]u64,
mc_tlsbase: u64,
fpregs: [512]u8 align(8),
},
else => struct {},
},
.dragonfly => dragonfly.mcontext_t,
.haiku => haiku.mcontext_t,
.serenity => switch (native_arch) {
// https://github.com/SerenityOS/serenity/blob/200e91cd7f1ec5453799a2720d4dc114a59cc289/Kernel/Arch/aarch64/mcontext.h#L15-L19
.aarch64 => extern struct {
x: [31]u64,
sp: u64,
pc: u64,
},
// https://github.com/SerenityOS/serenity/blob/66f8d0f031ef25c409dbb4fecaa454800fecae0f/Kernel/Arch/riscv64/mcontext.h#L15-L18
.riscv64 => extern struct {
x: [31]u64,
pc: u64,
},
// https://github.com/SerenityOS/serenity/blob/7b9ea3efdec9f86a1042893e8107d0b23aad8727/Kernel/Arch/x86_64/mcontext.h#L15-L40
.x86_64 => extern struct {
rax: u64,
rcx: u64,
rdx: u64,
rbx: u64,
rsp: u64,
rbp: u64,
rsi: u64,
rdi: u64,
rip: u64,
r8: u64,
r9: u64,
r10: u64,
r11: u64,
r12: u64,
r13: u64,
r14: u64,
r15: u64,
rflags: u64,
cs: u32,
ss: u32,
ds: u32,
es: u32,
fs: u32,
gs: u32,
},
else => struct {},
},
else => void,
}