authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-30 06:54:45+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-01 23:03:13+02:00
logfd2d4507c86057bf43ae2198edeb3ebddfa6caca
tree5fb4a65f7ccd18c278ac9d636eb5268502134d22
parent07114e6bc69106fb77beb879a8a2f78a4ba4b256
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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

Closes #24239.

2 files changed, 72 insertions(+), 4 deletions(-)

lib/std/os/linux/riscv32.zig+36-2
......@@ -7,6 +7,8 @@ const SYS = linux.SYS;
77const uid_t = std.os.linux.uid_t;
88const gid_t = std.os.linux.gid_t;
99const pid_t = std.os.linux.pid_t;
10const stack_t = linux.stack_t;
11const sigset_t = linux.sigset_t;
1012const sockaddr = linux.sockaddr;
1113const socklen_t = linux.socklen_t;
1214const timespec = std.os.linux.timespec;
......@@ -261,8 +263,40 @@ pub const VDSO = struct {
261263 pub const CGT_VER = "LINUX_4.15";
262264};
263265
264/// TODO
265pub const ucontext_t = void;
266pub const f_ext_state = extern struct {
267 f: [32]f32,
268 fcsr: u32,
269};
270
271pub const d_ext_state = extern struct {
272 f: [32]f64,
273 fcsr: u32,
274};
275
276pub const q_ext_state = extern struct {
277 f: [32]f128,
278 fcsr: u32,
279 _reserved: [3]u32,
280};
281
282pub const fpstate = extern union {
283 f: f_ext_state,
284 d: d_ext_state,
285 q: q_ext_state,
286};
287
288pub const mcontext_t = extern struct {
289 gregs: [32]u32,
290 fpregs: fpstate,
291};
292
293pub const ucontext_t = extern struct {
294 flags: c_ulong,
295 link: ?*ucontext_t,
296 stack: stack_t,
297 sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
298 mcontext: mcontext_t,
299};
266300
267301/// TODO
268302pub const getcontext = {};
lib/std/os/linux/riscv64.zig+36-2
......@@ -7,6 +7,8 @@ const SYS = linux.SYS;
77const uid_t = std.os.linux.uid_t;
88const gid_t = std.os.linux.gid_t;
99const pid_t = std.os.linux.pid_t;
10const stack_t = linux.stack_t;
11const sigset_t = linux.sigset_t;
1012const sockaddr = linux.sockaddr;
1113const socklen_t = linux.socklen_t;
1214const timespec = std.os.linux.timespec;
......@@ -261,8 +263,40 @@ pub const VDSO = struct {
261263 pub const CGT_VER = "LINUX_4.15";
262264};
263265
264/// TODO
265pub const ucontext_t = void;
266pub const f_ext_state = extern struct {
267 f: [32]f32,
268 fcsr: u32,
269};
270
271pub const d_ext_state = extern struct {
272 f: [32]f64,
273 fcsr: u32,
274};
275
276pub const q_ext_state = extern struct {
277 f: [32]f128,
278 fcsr: u32,
279 _reserved: [3]u32,
280};
281
282pub const fpstate = extern union {
283 f: f_ext_state,
284 d: d_ext_state,
285 q: q_ext_state,
286};
287
288pub const mcontext_t = extern struct {
289 gregs: [32]u64,
290 fpregs: fpstate,
291};
292
293pub const ucontext_t = extern struct {
294 flags: c_ulong,
295 link: ?*ucontext_t,
296 stack: stack_t,
297 sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
298 mcontext: mcontext_t,
299};
266300
267301/// TODO
268302pub const getcontext = {};