hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 3370d5374b4bf7f9f0e76d3d406f0e61f0d5df5f
parent a129bf33fda5f38248a33c7181752fb018b6bb4a
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Jan 2024 12:35:03 +0100

rt: add ucontext structures for +linux

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mrt/+linux/+aarch64.ha | 18++++++++++++++++++
Mrt/+linux/+riscv64.ha | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mrt/+linux/+x86_64.ha | 39+++++++++++++++++++++++++++++++++++++++
3 files changed, 129 insertions(+), 0 deletions(-)

diff --git a/rt/+linux/+aarch64.ha b/rt/+linux/+aarch64.ha @@ -51,3 +51,21 @@ export type epoll_event = struct { export type cpu_set = struct { __bits: [16]u64, }; + +export type ucontext = struct { + uc_flags: u64, + uc_link: *ucontext, + uc_stack: stack_t, + uc_sigmask: sigset, + _u8: [1024 / 8 - size(sigset)]u8, + uc_mcontext: sigcontext, +}; + +export type sigcontext = struct { + fault_address: u64, + sp: u64, + regs: [31]u64, + pc: u64, + pstate: u64, + reserved: [4096]u8, +}; diff --git a/rt/+linux/+riscv64.ha b/rt/+linux/+riscv64.ha @@ -49,3 +49,75 @@ export type epoll_event = struct { export type cpu_set = struct { __bits: [16]u64, }; + +export type ucontext = struct { + uc_flags: u64, + uc_link: *ucontext, + uc_stack: stack_t, + uc_sigmask: sigset, + _u8: [1024 / 8 - size(sigset)]u8, + uc_mcontext: sigcontext, +}; + +export type sigcontext = struct { + sc_regs: user_regs, + sc_fpregs: fp_state, +}; + +export type user_regs = struct { + x0: u64, // XXX: Why is this here? + pc: u64, + ra: u64, + sp: u64, + gp: u64, + tp: u64, + t0: u64, + t1: u64, + t2: u64, + s0: u64, + s1: u64, + a0: u64, + a1: u64, + a2: u64, + a3: u64, + a4: u64, + a5: u64, + a6: u64, + a7: u64, + s2: u64, + s3: u64, + s4: u64, + s5: u64, + s6: u64, + s7: u64, + s8: u64, + s9: u64, + s10: u64, + s11: u64, + t3: u64, + t4: u64, + t5: u64, + t6: u64, +}; + +export type fp_state = union { + f: f_ext_state, + d: d_ext_state, + q: q_ext_state, +}; + +export type f_ext_state = struct { + f: [32]u32, + fcsr: u32, +}; + +export type d_ext_state = struct { + f: [32]u64, + fcsr: u32, +}; + +export type q_ext_state = struct { + f: [64]u64, + fcsr: u32, + reserved: [3]u32, +}; diff --git a/rt/+linux/+x86_64.ha b/rt/+linux/+x86_64.ha @@ -54,3 +54,42 @@ export type cpu_set = struct { export fn alarm(seconds: uint) uint = { return syscall1(SYS_alarm, seconds: u64): uint; }; + +export type ucontext = struct { + uc_flags: u64, + uc_link: *ucontext, + uc_stack: stack_t, + uc_mcontext: sigcontext, + uc_sigmask: sigset, +}; + +export type sigcontext = struct { + r8: u64, + r9: u64, + r10: u64, + r11: u64, + r12: u64, + r13: u64, + r14: u64, + r15: u64, + di: u64, + si: u64, + bp: u64, + bx: u64, + dx: u64, + ax: u64, + cx: u64, + sp: u64, + ip: u64, + flags: u64, + cs: u16, + gs: u16, + fs: u16, + ss: u16, + err: u64, + trapno: u64, + oldmask: u64, + cr2: u64, + fpstate: u64, + reserved1: [8]u64, +};