zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit fd2d4507c86057bf43ae2198edeb3ebddfa6caca (tree)
parent 07114e6bc69106fb77beb879a8a2f78a4ba4b256
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Mon, 30 Jun 2025 06:54:45 +0200

std.os.linux: Define ucontext_t and mcontext_t for RISC-V

Closes #24239.

Diffstat:
Mlib/std/os/linux/riscv32.zig | 38++++++++++++++++++++++++++++++++++++--
Mlib/std/os/linux/riscv64.zig | 38++++++++++++++++++++++++++++++++++++--
2 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/lib/std/os/linux/riscv32.zig b/lib/std/os/linux/riscv32.zig @@ -7,6 +7,8 @@ const SYS = linux.SYS; const uid_t = std.os.linux.uid_t; const gid_t = std.os.linux.gid_t; const pid_t = std.os.linux.pid_t; +const stack_t = linux.stack_t; +const sigset_t = linux.sigset_t; const sockaddr = linux.sockaddr; const socklen_t = linux.socklen_t; const timespec = std.os.linux.timespec; @@ -261,8 +263,40 @@ pub const VDSO = struct { pub const CGT_VER = "LINUX_4.15"; }; -/// TODO -pub const ucontext_t = void; +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, +}; /// TODO pub const getcontext = {}; diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig @@ -7,6 +7,8 @@ const SYS = linux.SYS; const uid_t = std.os.linux.uid_t; const gid_t = std.os.linux.gid_t; const pid_t = std.os.linux.pid_t; +const stack_t = linux.stack_t; +const sigset_t = linux.sigset_t; const sockaddr = linux.sockaddr; const socklen_t = linux.socklen_t; const timespec = std.os.linux.timespec; @@ -261,8 +263,40 @@ pub const VDSO = struct { pub const CGT_VER = "LINUX_4.15"; }; -/// TODO -pub const ucontext_t = void; +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, +}; /// TODO pub const getcontext = {};