Add sigaltstack test.

This commit is contained in:
4lDO2
2024-09-28 16:51:17 +02:00
parent 487b8f0e56
commit 07af4e49f7
6 changed files with 234 additions and 42 deletions
+49
View File
@@ -1,3 +1,5 @@
use super::{siginfo_t, sigset_t, stack_t};
use crate::platform::types::*;
use core::arch::global_asm;
// Needs to be defined in assembly because it can't have a function prologue
@@ -79,3 +81,50 @@ pub const SIGSTKSZ: usize = 8096;
pub const SI_QUEUE: i32 = -1;
pub const SI_USER: i32 = 0;
// Mirrors the ucontext_t struct from the libc crate on Linux.
pub(crate) type ucontext_t = ucontext;
pub(crate) type mcontext_t = mcontext;
#[repr(C)]
pub struct ucontext {
pub uc_flags: c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask: sigset_t,
__private: [u8; 512],
}
#[repr(C)]
pub struct _libc_fpstate {
pub cwd: u16,
pub swd: u16,
pub ftw: u16,
pub fop: u16,
pub rip: u64,
pub rdp: u64,
pub mxcsr: u32,
pub mxcr_mask: u32,
pub _st: [_libc_fpxreg; 8],
pub _xmm: [_libc_xmmreg; 16],
__private: [u64; 12],
}
#[repr(C)]
pub struct _libc_fpxreg {
pub significand: [u16; 4],
pub exponent: u16,
__private: [u16; 3],
}
#[repr(C)]
pub struct _libc_xmmreg {
pub element: [u32; 4],
}
#[repr(C)]
pub struct mcontext {
pub gregs: [i64; 23], // TODO: greg_t?
pub fpregs: *mut _libc_fpstate,
__private: [u64; 8],
}