Commit 36dbe66cf4

Alex Rønne Petersen <alex@alexrp.com>
2025-10-09 09:55:40
std: stop exposing anything having to do with ucontext_t
This type is useful for two things: * Doing non-local control flow with ucontext.h functions. * Inspecting machine state in a signal handler. The first use case is not one we support; we no longer expose bindings to those functions in the standard library. They're also deprecated in POSIX and, as a result, not available in musl. The second use case is valid, but is very poorly served by the standard library. As evidenced by my changes to std.debug.cpu_context.signal_context_t, users will be better served rolling their own ucontext_t and especially mcontext_t types which fit their specific situation. Further, these types tend to evolve frequently as architectures evolve, and the standard library has not done a good job keeping up, or even providing them for all supported targets.
1 parent f33d3a5
lib/std/c/solaris.zig
@@ -31,29 +31,6 @@ pub const poolid_t = id_t;
 pub const zoneid_t = id_t;
 pub const ctid_t = id_t;
 
-pub const fpregset_t = extern union {
-    regs: [130]u32,
-    chip_state: extern struct {
-        cw: u16,
-        sw: u16,
-        fctw: u8,
-        __fx_rsvd: u8,
-        fop: u16,
-        rip: u64,
-        rdp: u64,
-        mxcsr: u32,
-        mxcsr_mask: u32,
-        st: [8]extern union {
-            fpr_16: [5]u16,
-            __fpr_pad: u128,
-        },
-        xmm: [16]u128,
-        __fx_ign2: [6]u128,
-        status: u32,
-        xstatus: u32,
-    },
-};
-
 pub const GETCONTEXT = 0;
 pub const SETCONTEXT = 1;
 pub const GETUSTACK = 2;
lib/std/os/linux/aarch64.zig
@@ -241,23 +241,4 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-pub const mcontext_t = extern struct {
-    fault_address: usize,
-    regs: [31]usize,
-    sp: usize,
-    pc: usize,
-    pstate: usize,
-    // Make sure the field is correctly aligned since this area
-    // holds various FP/vector registers
-    reserved1: [256 * 16]u8 align(16),
-};
-
-pub const ucontext_t = extern struct {
-    flags: usize,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    mcontext: mcontext_t,
-};
-
 pub const Elf_Symndx = u32;
lib/std/os/linux/arm.zig
@@ -277,37 +277,4 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-pub const mcontext_t = extern struct {
-    trap_no: usize,
-    error_code: usize,
-    oldmask: usize,
-    arm_r0: usize,
-    arm_r1: usize,
-    arm_r2: usize,
-    arm_r3: usize,
-    arm_r4: usize,
-    arm_r5: usize,
-    arm_r6: usize,
-    arm_r7: usize,
-    arm_r8: usize,
-    arm_r9: usize,
-    arm_r10: usize,
-    arm_fp: usize,
-    arm_ip: usize,
-    arm_sp: usize,
-    arm_lr: usize,
-    arm_pc: usize,
-    arm_cpsr: usize,
-    fault_address: usize,
-};
-
-pub const ucontext_t = extern struct {
-    flags: usize,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    regspace: [64]u64,
-};
-
 pub const Elf_Symndx = u32;
lib/std/os/linux/hexagon.zig
@@ -212,31 +212,3 @@ pub const Stat = extern struct {
 pub const Elf_Symndx = u32;
 
 pub const VDSO = void;
-
-pub const mcontext_t = extern struct {
-    gregs: [32]u32 align(8),
-    sa0: u32,
-    lc0: u32,
-    sa1: u32,
-    lc1: u32,
-    m0: u32,
-    m1: u32,
-    usr: u32,
-    p3_0: u32,
-    gp: u32,
-    ugp: u32,
-    pc: u32,
-    cause: u32,
-    badva: u32,
-    cs0: u32,
-    cs1: u32,
-    _pad1: u32,
-};
-
-pub const ucontext_t = extern struct {
-    flags: u32,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: sigset_t,
-};
lib/std/os/linux/loongarch64.zig
@@ -210,19 +210,4 @@ pub const VDSO = struct {
     pub const CGT_VER = "LINUX_5.10";
 };
 
-pub const mcontext_t = extern struct {
-    pc: u64,
-    regs: [32]u64,
-    flags: u32,
-    extcontext: [0]u64 align(16),
-};
-
-pub const ucontext_t = extern struct {
-    flags: c_ulong,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    mcontext: mcontext_t,
-};
-
 pub const Elf_Symndx = u32;
lib/std/os/linux/m68k.zig
@@ -234,6 +234,3 @@ pub const Elf_Symndx = u32;
 
 // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6.
 pub const VDSO = void;
-
-/// TODO
-pub const ucontext_t = void;
lib/std/os/linux/mips.zig
@@ -348,32 +348,3 @@ pub const timezone = extern struct {
 };
 
 pub const Elf_Symndx = u32;
-
-pub const mcontext_t = extern struct {
-    _regmask: u32,
-    _status: u32,
-    pc: u64,
-    regs: [32]u64,
-    fpregs: [32]f64,
-    acx: u32,
-    fpc_csr: u32,
-    _fpc_eir: u32,
-    used_math: u32,
-    dsp: u32,
-    mdhi: u64,
-    mdlo: u64,
-    hi1: u32,
-    lo1: u32,
-    hi2: u32,
-    lo2: u32,
-    hi3: u32,
-    lo3: u32,
-};
-
-pub const ucontext_t = extern struct {
-    flags: u32,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: sigset_t,
-};
lib/std/os/linux/mips64.zig
@@ -327,29 +327,3 @@ pub const timezone = extern struct {
 };
 
 pub const Elf_Symndx = u32;
-
-pub const mcontext_t = extern struct {
-    regs: [32]u64,
-    fpregs: [32]f64,
-    mdhi: u64,
-    hi1: u64,
-    hi2: u64,
-    hi3: u64,
-    mdlo: u64,
-    lo1: u64,
-    lo2: u64,
-    lo3: u64,
-    pc: u64,
-    fpc_csr: u32,
-    used_math: u32,
-    dsp: u32,
-    _reserved: u32,
-};
-
-pub const ucontext_t = extern struct {
-    flags: u32,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: sigset_t,
-};
lib/std/os/linux/powerpc.zig
@@ -351,33 +351,4 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-pub const greg_t = u32;
-pub const gregset_t = [48]greg_t;
-pub const fpregset_t = [33]f64;
-
-pub const vrregset = extern struct {
-    vrregs: [32][4]u32,
-    vrsave: u32,
-    _pad: [2]u32,
-    vscr: u32,
-};
-pub const vrregset_t = vrregset;
-
-pub const mcontext_t = extern struct {
-    gp_regs: gregset_t,
-    fp_regs: fpregset_t,
-    v_regs: vrregset_t align(16),
-};
-
-pub const ucontext_t = extern struct {
-    flags: u32,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    pad: [7]i32,
-    regs: *mcontext_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    pad2: [3]i32,
-    mcontext: mcontext_t,
-};
-
 pub const Elf_Symndx = u32;
lib/std/os/linux/powerpc64.zig
@@ -336,43 +336,4 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-pub const greg_t = u64;
-pub const gregset_t = [48]greg_t;
-pub const fpregset_t = [33]f64;
-
-/// The position of the vscr register depends on endianness.
-/// On C, macros are used to change vscr_word's offset to
-/// account for this. Here we'll just define vscr_word_le
-/// and vscr_word_be. Code must take care to use the correct one.
-pub const vrregset = extern struct {
-    vrregs: [32][4]u32 align(16),
-    vscr_word_le: u32,
-    _pad1: [2]u32,
-    vscr_word_be: u32,
-    vrsave: u32,
-    _pad2: [3]u32,
-};
-pub const vrregset_t = vrregset;
-
-pub const mcontext_t = extern struct {
-    __unused: [4]u64,
-    signal: i32,
-    _pad0: i32,
-    handler: u64,
-    oldmask: u64,
-    regs: ?*anyopaque,
-    gp_regs: gregset_t,
-    fp_regs: fpregset_t,
-    v_regs: *vrregset_t,
-    vmx_reserve: [34 + 34 + 32 + 1]i64,
-};
-
-pub const ucontext_t = extern struct {
-    flags: u32,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    mcontext: mcontext_t,
-};
-
 pub const Elf_Symndx = u32;
lib/std/os/linux/riscv32.zig
@@ -220,38 +220,3 @@ pub const VDSO = struct {
     pub const CGT_SYM = "__vdso_clock_gettime";
     pub const CGT_VER = "LINUX_4.15";
 };
-
-pub const f_ext_state = extern struct {
-    f: [32]f32,
-    fcsr: u32,
-};
-
-pub const d_ext_state = extern struct {
-    f: [32]f64,
-    fcsr: u32,
-};
-
-pub const q_ext_state = extern struct {
-    f: [32]f128,
-    fcsr: u32,
-    _reserved: [3]u32,
-};
-
-pub const fpstate = extern union {
-    f: f_ext_state,
-    d: d_ext_state,
-    q: q_ext_state,
-};
-
-pub const mcontext_t = extern struct {
-    gregs: [32]u32,
-    fpregs: fpstate,
-};
-
-pub const ucontext_t = extern struct {
-    flags: c_ulong,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    mcontext: mcontext_t,
-};
lib/std/os/linux/riscv64.zig
@@ -220,38 +220,3 @@ pub const VDSO = struct {
     pub const CGT_SYM = "__vdso_clock_gettime";
     pub const CGT_VER = "LINUX_4.15";
 };
-
-pub const f_ext_state = extern struct {
-    f: [32]f32,
-    fcsr: u32,
-};
-
-pub const d_ext_state = extern struct {
-    f: [32]f64,
-    fcsr: u32,
-};
-
-pub const q_ext_state = extern struct {
-    f: [32]f128,
-    fcsr: u32,
-    _reserved: [3]u32,
-};
-
-pub const fpstate = extern union {
-    f: f_ext_state,
-    d: d_ext_state,
-    q: q_ext_state,
-};
-
-pub const mcontext_t = extern struct {
-    gregs: [32]u64,
-    fpregs: fpstate,
-};
-
-pub const ucontext_t = extern struct {
-    flags: c_ulong,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    mcontext: mcontext_t,
-};
lib/std/os/linux/s390x.zig
@@ -235,22 +235,3 @@ pub const VDSO = struct {
     pub const CGT_SYM = "__kernel_clock_gettime";
     pub const CGT_VER = "LINUX_2.6.29";
 };
-
-pub const ucontext_t = extern struct {
-    flags: u64,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-};
-
-pub const mcontext_t = extern struct {
-    psw: extern struct {
-        mask: u64,
-        addr: u64,
-    },
-    gregs: [16]u64,
-    aregs: [16]u32,
-    fpc: u32,
-    fregs: [16]f64,
-};
lib/std/os/linux/sparc64.zig
@@ -325,104 +325,4 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-// TODO I'm not sure if the code below is correct, need someone with more
-// knowledge about sparc64 linux internals to look into.
-
 pub const Elf_Symndx = u32;
-
-pub const fpstate = extern struct {
-    regs: [32]u64,
-    fsr: u64,
-    gsr: u64,
-    fprs: u64,
-};
-
-pub const __fpq = extern struct {
-    fpq_addr: *u32,
-    fpq_instr: u32,
-};
-
-pub const __fq = extern struct {
-    FQu: extern union {
-        whole: f64,
-        fpq: __fpq,
-    },
-};
-
-pub const fpregset_t = extern struct {
-    fpu_fr: extern union {
-        fpu_regs: [32]u32,
-        fpu_dregs: [32]f64,
-        fpu_qregs: [16]c_longdouble,
-    },
-    fpu_q: *__fq,
-    fpu_fsr: u64,
-    fpu_qcnt: u8,
-    fpu_q_entrysize: u8,
-    fpu_en: u8,
-};
-
-pub const siginfo_fpu_t = extern struct {
-    float_regs: [64]u32,
-    fsr: u64,
-    gsr: u64,
-    fprs: u64,
-};
-
-pub const sigcontext = extern struct {
-    info: [128]i8,
-    regs: extern struct {
-        u_regs: [16]u64,
-        tstate: u64,
-        tpc: u64,
-        tnpc: u64,
-        y: u64,
-        fprs: u64,
-    },
-    fpu_save: *siginfo_fpu_t,
-    stack: extern struct {
-        sp: usize,
-        flags: i32,
-        size: u64,
-    },
-    mask: u64,
-};
-
-pub const greg_t = u64;
-pub const gregset_t = [19]greg_t;
-
-pub const fq = extern struct {
-    addr: *u64,
-    insn: u32,
-};
-
-pub const fpu_t = extern struct {
-    fregs: extern union {
-        sregs: [32]u32,
-        dregs: [32]u64,
-        qregs: [16]c_longdouble,
-    },
-    fsr: u64,
-    fprs: u64,
-    gsr: u64,
-    fq: *fq,
-    qcnt: u8,
-    qentsz: u8,
-    enab: u8,
-};
-
-pub const mcontext_t = extern struct {
-    gregs: gregset_t,
-    fp: greg_t,
-    i7: greg_t,
-    fpregs: fpu_t,
-};
-
-pub const ucontext_t = extern struct {
-    link: ?*ucontext_t,
-    flags: u64,
-    sigmask: u64,
-    mcontext: mcontext_t,
-    stack: stack_t,
-    sigset: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-};
lib/std/os/linux/x86.zig
@@ -288,44 +288,6 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-pub const mcontext_t = extern struct {
-    gregs: [19]usize,
-    fpregs: [*]u8,
-    oldmask: usize,
-    cr2: usize,
-};
-
-pub const REG = struct {
-    pub const GS = 0;
-    pub const FS = 1;
-    pub const ES = 2;
-    pub const DS = 3;
-    pub const EDI = 4;
-    pub const ESI = 5;
-    pub const EBP = 6;
-    pub const ESP = 7;
-    pub const EBX = 8;
-    pub const EDX = 9;
-    pub const ECX = 10;
-    pub const EAX = 11;
-    pub const TRAPNO = 12;
-    pub const ERR = 13;
-    pub const EIP = 14;
-    pub const CS = 15;
-    pub const EFL = 16;
-    pub const UESP = 17;
-    pub const SS = 18;
-};
-
-pub const ucontext_t = extern struct {
-    flags: usize,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
-    regspace: [64]u64,
-};
-
 pub const Elf_Symndx = u32;
 
 pub const user_desc = extern struct {
@@ -366,73 +328,3 @@ pub const SC = struct {
     pub const recvmmsg = 19;
     pub const sendmmsg = 20;
 };
-
-fn gpRegisterOffset(comptime reg_index: comptime_int) usize {
-    return @offsetOf(ucontext_t, "mcontext") + @offsetOf(mcontext_t, "gregs") + @sizeOf(usize) * reg_index;
-}
-
-noinline fn getContextReturnAddress() usize {
-    return @returnAddress();
-}
-
-pub fn getContextInternal() callconv(.naked) usize {
-    asm volatile (
-        \\ movl $0, %[flags_offset:c](%%edx)
-        \\ movl $0, %[link_offset:c](%%edx)
-        \\ movl %%edi, %[edi_offset:c](%%edx)
-        \\ movl %%esi, %[esi_offset:c](%%edx)
-        \\ movl %%ebp, %[ebp_offset:c](%%edx)
-        \\ movl %%ebx, %[ebx_offset:c](%%edx)
-        \\ movl %%edx, %[edx_offset:c](%%edx)
-        \\ movl %%ecx, %[ecx_offset:c](%%edx)
-        \\ movl %%eax, %[eax_offset:c](%%edx)
-        \\ movl (%%esp), %%ecx
-        \\ movl %%ecx, %[eip_offset:c](%%edx)
-        \\ leal 4(%%esp), %%ecx
-        \\ movl %%ecx, %[esp_offset:c](%%edx)
-        \\ xorl %%ecx, %%ecx
-        \\ movw %%fs, %%cx
-        \\ movl %%ecx, %[fs_offset:c](%%edx)
-        \\ leal %[regspace_offset:c](%%edx), %%ecx
-        \\ movl %%ecx, %[fpregs_offset:c](%%edx)
-        \\ fnstenv (%%ecx)
-        \\ fldenv (%%ecx)
-        \\ pushl %%ebx
-        \\ pushl %%esi
-        \\ xorl %%ebx, %%ebx
-        \\ movl %[sigaltstack], %%eax
-        \\ leal %[stack_offset:c](%%edx), %%ecx
-        \\ int $0x80
-        \\ testl %%eax, %%eax
-        \\ jnz 0f
-        \\ movl %[sigprocmask], %%eax
-        \\ xorl %%ecx, %%ecx
-        \\ leal %[sigmask_offset:c](%%edx), %%edx
-        \\ movl %[sigset_size], %%esi
-        \\ int $0x80
-        \\0:
-        \\ popl %%esi
-        \\ popl %%ebx
-        \\ retl
-        :
-        : [flags_offset] "i" (@offsetOf(ucontext_t, "flags")),
-          [link_offset] "i" (@offsetOf(ucontext_t, "link")),
-          [edi_offset] "i" (comptime gpRegisterOffset(REG.EDI)),
-          [esi_offset] "i" (comptime gpRegisterOffset(REG.ESI)),
-          [ebp_offset] "i" (comptime gpRegisterOffset(REG.EBP)),
-          [esp_offset] "i" (comptime gpRegisterOffset(REG.ESP)),
-          [ebx_offset] "i" (comptime gpRegisterOffset(REG.EBX)),
-          [edx_offset] "i" (comptime gpRegisterOffset(REG.EDX)),
-          [ecx_offset] "i" (comptime gpRegisterOffset(REG.ECX)),
-          [eax_offset] "i" (comptime gpRegisterOffset(REG.EAX)),
-          [eip_offset] "i" (comptime gpRegisterOffset(REG.EIP)),
-          [fs_offset] "i" (comptime gpRegisterOffset(REG.FS)),
-          [fpregs_offset] "i" (@offsetOf(ucontext_t, "mcontext") + @offsetOf(mcontext_t, "fpregs")),
-          [regspace_offset] "i" (@offsetOf(ucontext_t, "regspace")),
-          [sigaltstack] "i" (@intFromEnum(linux.SYS.sigaltstack)),
-          [stack_offset] "i" (@offsetOf(ucontext_t, "stack")),
-          [sigprocmask] "i" (@intFromEnum(linux.SYS.rt_sigprocmask)),
-          [sigmask_offset] "i" (@offsetOf(ucontext_t, "sigmask")),
-          [sigset_size] "i" (linux.NSIG / 8),
-        : .{ .cc = true, .memory = true, .eax = true, .ecx = true, .edx = true });
-}
lib/std/os/linux/x86_64.zig
@@ -190,32 +190,6 @@ pub const ARCH = struct {
     pub const GET_GS = 0x1004;
 };
 
-pub const REG = struct {
-    pub const R8 = 0;
-    pub const R9 = 1;
-    pub const R10 = 2;
-    pub const R11 = 3;
-    pub const R12 = 4;
-    pub const R13 = 5;
-    pub const R14 = 6;
-    pub const R15 = 7;
-    pub const RDI = 8;
-    pub const RSI = 9;
-    pub const RBP = 10;
-    pub const RBX = 11;
-    pub const RDX = 12;
-    pub const RAX = 13;
-    pub const RCX = 14;
-    pub const RSP = 15;
-    pub const RIP = 16;
-    pub const EFL = 17;
-    pub const CSGSFS = 18;
-    pub const ERR = 19;
-    pub const TRAPNO = 20;
-    pub const OLDMASK = 21;
-    pub const CR2 = 22;
-};
-
 pub const Flock = extern struct {
     type: i16,
     whence: i16,
@@ -272,83 +246,3 @@ pub const timezone = extern struct {
 };
 
 pub const Elf_Symndx = u32;
-
-pub const greg_t = usize;
-pub const gregset_t = [23]greg_t;
-pub const fpstate = extern struct {
-    cwd: u16,
-    swd: u16,
-    ftw: u16,
-    fop: u16,
-    rip: usize,
-    rdp: usize,
-    mxcsr: u32,
-    mxcr_mask: u32,
-    st: [8]extern struct {
-        significand: [4]u16,
-        exponent: u16,
-        padding: [3]u16 = undefined,
-    },
-    xmm: [16]extern struct {
-        element: [4]u32,
-    },
-    padding: [24]u32 = undefined,
-};
-pub const fpregset_t = *fpstate;
-pub const sigcontext = extern struct {
-    r8: usize,
-    r9: usize,
-    r10: usize,
-    r11: usize,
-    r12: usize,
-    r13: usize,
-    r14: usize,
-    r15: usize,
-
-    rdi: usize,
-    rsi: usize,
-    rbp: usize,
-    rbx: usize,
-    rdx: usize,
-    rax: usize,
-    rcx: usize,
-    rsp: usize,
-    rip: usize,
-    eflags: usize,
-
-    cs: u16,
-    gs: u16,
-    fs: u16,
-    pad0: u16 = undefined,
-
-    err: usize,
-    trapno: usize,
-    oldmask: usize,
-    cr2: usize,
-
-    fpstate: *fpstate,
-    reserved1: [8]usize = undefined,
-};
-
-pub const mcontext_t = extern struct {
-    gregs: gregset_t,
-    fpregs: fpregset_t,
-    reserved1: [8]usize = undefined,
-};
-
-/// ucontext_t is part of the state pushed on the stack by the kernel for
-/// a signal handler.  And also a subset of the state returned from the
-/// makecontext/getcontext/swapcontext POSIX APIs.
-///
-/// Currently this structure matches the glibc/musl layout.  It contains a
-/// 1024-bit signal mask, and `fpregs_mem`.  This structure should be
-/// split into one for the kernel ABI and c.zig should define a glibc/musl
-/// compatible structure.
-pub const ucontext_t = extern struct {
-    flags: usize,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a glibc-compatible (1024-bit) sigmask.
-    fpregs_mem: [64]usize, // Not part of kernel ABI, only part of glibc ucontext_t
-};
lib/std/os/emscripten.zig
@@ -400,28 +400,6 @@ pub const timeval = extern struct {
     usec: i32,
 };
 
-pub const REG = struct {
-    pub const GS = 0;
-    pub const FS = 1;
-    pub const ES = 2;
-    pub const DS = 3;
-    pub const EDI = 4;
-    pub const ESI = 5;
-    pub const EBP = 6;
-    pub const ESP = 7;
-    pub const EBX = 8;
-    pub const EDX = 9;
-    pub const ECX = 10;
-    pub const EAX = 11;
-    pub const TRAPNO = 12;
-    pub const ERR = 13;
-    pub const EIP = 14;
-    pub const CS = 15;
-    pub const EFL = 16;
-    pub const UESP = 17;
-    pub const SS = 18;
-};
-
 pub const S = struct {
     pub const IFMT = 0o170000;
 
@@ -813,13 +791,6 @@ pub const dl_phdr_info = extern struct {
     phnum: u16,
 };
 
-pub const mcontext_t = extern struct {
-    gregs: [19]usize,
-    fpregs: [*]u8,
-    oldmask: usize,
-    cr2: usize,
-};
-
 pub const msghdr = std.c.msghdr;
 pub const msghdr_const = std.c.msghdr;
 
@@ -846,15 +817,6 @@ pub const timezone = extern struct {
     dsttime: i32,
 };
 
-pub const ucontext_t = extern struct {
-    flags: usize,
-    link: ?*ucontext_t,
-    stack: stack_t,
-    mcontext: mcontext_t,
-    sigmask: sigset_t,
-    regspace: [28]usize,
-};
-
 pub const utsname = extern struct {
     sysname: [64:0]u8,
     nodename: [64:0]u8,
lib/std/os/freebsd.zig
@@ -48,75 +48,3 @@ pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64,
         else => |err| return unexpectedErrno(err),
     }
 }
-
-pub const ucontext_t = extern struct {
-    sigmask: std.c.sigset_t,
-    mcontext: mcontext_t,
-    link: ?*ucontext_t,
-    stack: std.c.stack_t,
-    flags: c_int,
-    __spare__: [4]c_int,
-    const mcontext_t = 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 => void,
-    };
-};
lib/std/os/linux.zig
@@ -47,9 +47,7 @@ const arch_bits = switch (native_arch) {
     .powerpc, .powerpcle => @import("linux/powerpc.zig"),
     .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"),
     .s390x => @import("linux/s390x.zig"),
-    else => struct {
-        pub const ucontext_t = void;
-    },
+    else => struct {},
 };
 
 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;
 pub const F = arch_bits.F;
 pub const Flock = arch_bits.Flock;
 pub const HWCAP = arch_bits.HWCAP;
-pub const REG = arch_bits.REG;
 pub const SC = arch_bits.SC;
 pub const Stat = arch_bits.Stat;
 pub const VDSO = arch_bits.VDSO;
@@ -102,14 +99,12 @@ pub const blkcnt_t = arch_bits.blkcnt_t;
 pub const blksize_t = arch_bits.blksize_t;
 pub const dev_t = arch_bits.dev_t;
 pub const ino_t = arch_bits.ino_t;
-pub const mcontext_t = arch_bits.mcontext_t;
 pub const mode_t = arch_bits.mode_t;
 pub const nlink_t = arch_bits.nlink_t;
 pub const off_t = arch_bits.off_t;
 pub const time_t = arch_bits.time_t;
 pub const timeval = arch_bits.timeval;
 pub const timezone = arch_bits.timezone;
-pub const ucontext_t = arch_bits.ucontext_t;
 pub const user_desc = arch_bits.user_desc;
 
 pub const tls = @import("linux/tls.zig");
lib/std/c.zig
@@ -1841,110 +1841,6 @@ pub const PROT = switch (native_os) {
     else => void,
 };
 
-pub const REG = switch (native_os) {
-    .linux => linux.REG,
-    .emscripten => emscripten.REG,
-    .freebsd => switch (builtin.cpu.arch) {
-        .aarch64 => struct {
-            pub const FP = 29;
-            pub const SP = 31;
-            pub const PC = 32;
-        },
-        .arm => struct {
-            pub const FP = 11;
-            pub const SP = 13;
-            pub const PC = 15;
-        },
-        .x86_64 => struct {
-            pub const RBP = 12;
-            pub const RIP = 21;
-            pub const RSP = 24;
-        },
-        else => struct {},
-    },
-    .solaris, .illumos => struct {
-        pub const R15 = 0;
-        pub const R14 = 1;
-        pub const R13 = 2;
-        pub const R12 = 3;
-        pub const R11 = 4;
-        pub const R10 = 5;
-        pub const R9 = 6;
-        pub const R8 = 7;
-        pub const RDI = 8;
-        pub const RSI = 9;
-        pub const RBP = 10;
-        pub const RBX = 11;
-        pub const RDX = 12;
-        pub const RCX = 13;
-        pub const RAX = 14;
-        pub const RIP = 17;
-        pub const RSP = 20;
-    },
-    .netbsd => switch (builtin.cpu.arch) {
-        .aarch64, .aarch64_be => struct {
-            pub const FP = 29;
-            pub const SP = 31;
-            pub const PC = 32;
-        },
-        .arm, .armeb => struct {
-            pub const FP = 11;
-            pub const SP = 13;
-            pub const PC = 15;
-        },
-        .x86 => struct {
-            pub const GS = 0;
-            pub const FS = 1;
-            pub const ES = 2;
-            pub const DS = 3;
-            pub const EDI = 4;
-            pub const ESI = 5;
-            pub const EBP = 6;
-            pub const ESP = 7;
-            pub const EBX = 8;
-            pub const EDX = 9;
-            pub const ECX = 10;
-            pub const EAX = 11;
-            pub const TRAPNO = 12;
-            pub const ERR = 13;
-            pub const EIP = 14;
-            pub const CS = 15;
-            pub const EFL = 16;
-            pub const UESP = 17;
-            pub const SS = 18;
-        },
-        .x86_64 => struct {
-            pub const RDI = 0;
-            pub const RSI = 1;
-            pub const RDX = 2;
-            pub const RCX = 3;
-            pub const R8 = 4;
-            pub const R9 = 5;
-            pub const R10 = 6;
-            pub const R11 = 7;
-            pub const R12 = 8;
-            pub const R13 = 9;
-            pub const R14 = 10;
-            pub const R15 = 11;
-            pub const RBP = 12;
-            pub const RBX = 13;
-            pub const RAX = 14;
-            pub const GS = 15;
-            pub const FS = 16;
-            pub const ES = 17;
-            pub const DS = 18;
-            pub const TRAPNO = 19;
-            pub const ERR = 20;
-            pub const RIP = 21;
-            pub const CS = 22;
-            pub const RFLAGS = 23;
-            pub const RSP = 24;
-            pub const SS = 25;
-        },
-        else => struct {},
-    },
-    else => struct {},
-};
 pub const RLIM = switch (native_os) {
     .linux => linux.RLIM,
     .emscripten => emscripten.RLIM,
@@ -4553,7 +4449,7 @@ pub const rusage = switch (native_os) {
 pub const siginfo_t = switch (native_os) {
     .linux => linux.siginfo_t,
     .emscripten => emscripten.siginfo_t,
-    .macos, .ios, .tvos, .watchos, .visionos => extern struct {
+    .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
         signo: c_int,
         errno: c_int,
         code: c_int,
@@ -11084,7 +10980,6 @@ pub const SETUSTACK = solaris.GETUSTACK;
 pub const SFD = solaris.SFD;
 pub const ctid_t = solaris.ctid_t;
 pub const file_obj = solaris.file_obj;
-pub const fpregset_t = solaris.fpregset_t;
 pub const id_t = solaris.id_t;
 pub const lif_ifinfo_req = solaris.lif_ifinfo_req;
 pub const lif_nd_req = solaris.lif_nd_req;
lib/std/posix.zig
@@ -97,7 +97,6 @@ pub const POLL = system.POLL;
 pub const POSIX_FADV = system.POSIX_FADV;
 pub const PR = system.PR;
 pub const PROT = system.PROT;
-pub const REG = system.REG;
 pub const RLIM = system.RLIM;
 pub const RR = system.RR;
 pub const S = system.S;