Skip to content

Commit

Permalink
Auto merge of #2685 - Amanieu:riscv-ucontext, r=Amanieu
Browse files Browse the repository at this point in the history
Add ucontext_t and mcontext_t for RISC-V Linux
  • Loading branch information
bors committed Feb 14, 2022
2 parents e2e056b + 3fa2b56 commit b3c9c69
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/riscv32/align.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
s_no_extra_traits! {
#[allow(missing_debug_implementations)]
pub struct ucontext_t {
pub __uc_flags: ::c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: ::stack_t,
pub uc_sigmask: ::sigset_t,
pub uc_mcontext: mcontext_t,
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct mcontext_t {
pub __gregs: [::c_ulong; 32],
pub __fpregs: __riscv_mc_fp_state,
}

#[allow(missing_debug_implementations)]
pub union __riscv_mc_fp_state {
pub __f: __riscv_mc_f_ext_state,
pub __d: __riscv_mc_d_ext_state,
pub __q: __riscv_mc_q_ext_state,
}

#[allow(missing_debug_implementations)]
pub struct __riscv_mc_f_ext_state {
pub __f: [::c_uint; 32],
pub __fcsr: ::c_uint,
}

#[allow(missing_debug_implementations)]
pub struct __riscv_mc_d_ext_state {
pub __f: [::c_ulonglong; 32],
pub __fcsr: ::c_uint,
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct __riscv_mc_q_ext_state {
pub __f: [::c_ulonglong; 64],
pub __fcsr: ::c_uint,
pub __glibc_reserved: [::c_uint; 3],
}
}
17 changes: 17 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ pub const FLUSHO: ::tcflag_t = 4096;
pub const EXTPROC: ::tcflag_t = 65536;
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
pub const NGREG: usize = 32;
pub const REG_PC: usize = 0;
pub const REG_RA: usize = 1;
pub const REG_SP: usize = 2;
pub const REG_TP: usize = 4;
pub const REG_S0: usize = 8;
pub const REG_S1: usize = 9;
pub const REG_A0: usize = 10;
pub const REG_S2: usize = 18;
pub const REG_NARGS: usize = 8;

pub const SYS_read: ::c_long = 63;
pub const SYS_write: ::c_long = 64;
Expand Down Expand Up @@ -752,3 +762,10 @@ pub const SYS_faccessat2: ::c_long = 439;
pub const SYS_process_madvise: ::c_long = 440;
pub const SYS_epoll_pwait2: ::c_long = 441;
pub const SYS_mount_setattr: ::c_long = 442;

cfg_if! {
if #[cfg(libc_align)] {
mod align;
pub use self::align::*;
}
}
44 changes: 44 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/riscv64/align.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
s_no_extra_traits! {
#[allow(missing_debug_implementations)]
pub struct ucontext_t {
pub __uc_flags: ::c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: ::stack_t,
pub uc_sigmask: ::sigset_t,
pub uc_mcontext: mcontext_t,
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct mcontext_t {
pub __gregs: [::c_ulong; 32],
pub __fpregs: __riscv_mc_fp_state,
}

#[allow(missing_debug_implementations)]
pub union __riscv_mc_fp_state {
pub __f: __riscv_mc_f_ext_state,
pub __d: __riscv_mc_d_ext_state,
pub __q: __riscv_mc_q_ext_state,
}

#[allow(missing_debug_implementations)]
pub struct __riscv_mc_f_ext_state {
pub __f: [::c_uint; 32],
pub __fcsr: ::c_uint,
}

#[allow(missing_debug_implementations)]
pub struct __riscv_mc_d_ext_state {
pub __f: [::c_ulonglong; 32],
pub __fcsr: ::c_uint,
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct __riscv_mc_q_ext_state {
pub __f: [::c_ulonglong; 64],
pub __fcsr: ::c_uint,
pub __glibc_reserved: [::c_uint; 3],
}
}
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ pub const FLUSHO: ::tcflag_t = 4096;
pub const EXTPROC: ::tcflag_t = 65536;
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
pub const NGREG: usize = 32;
pub const REG_PC: usize = 0;
pub const REG_RA: usize = 1;
pub const REG_SP: usize = 2;
pub const REG_TP: usize = 4;
pub const REG_S0: usize = 8;
pub const REG_S1: usize = 9;
pub const REG_A0: usize = 10;
pub const REG_S2: usize = 18;
pub const REG_NARGS: usize = 8;

pub const SYS_read: ::c_long = 63;
pub const SYS_write: ::c_long = 64;
pub const SYS_close: ::c_long = 57;
Expand Down Expand Up @@ -790,3 +801,10 @@ pub const SYS_faccessat2: ::c_long = 439;
pub const SYS_process_madvise: ::c_long = 440;
pub const SYS_epoll_pwait2: ::c_long = 441;
pub const SYS_mount_setattr: ::c_long = 442;

cfg_if! {
if #[cfg(libc_align)] {
mod align;
pub use self::align::*;
}
}
44 changes: 44 additions & 0 deletions src/unix/linux_like/linux/musl/b64/riscv64/align.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
s_no_extra_traits! {
#[allow(missing_debug_implementations)]
pub struct ucontext_t {
pub __uc_flags: ::c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: ::stack_t,
pub uc_sigmask: ::sigset_t,
pub uc_mcontext: mcontext_t,
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct mcontext_t {
pub __gregs: [::c_ulong; 32],
pub __fpregs: __riscv_mc_fp_state,
}

#[allow(missing_debug_implementations)]
pub union __riscv_mc_fp_state {
pub __f: __riscv_mc_f_ext_state,
pub __d: __riscv_mc_d_ext_state,
pub __q: __riscv_mc_q_ext_state,
}

#[allow(missing_debug_implementations)]
pub struct __riscv_mc_f_ext_state {
pub __f: [::c_uint; 32],
pub __fcsr: ::c_uint,
}

#[allow(missing_debug_implementations)]
pub struct __riscv_mc_d_ext_state {
pub __f: [::c_ulonglong; 32],
pub __fcsr: ::c_uint,
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct __riscv_mc_q_ext_state {
pub __f: [::c_ulonglong; 64],
pub __fcsr: ::c_uint,
pub __glibc_reserved: [::c_uint; 3],
}
}
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/musl/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,21 @@ pub const VMIN: usize = 6;
pub const IEXTEN: ::tcflag_t = 0x00008000;
pub const TOSTOP: ::tcflag_t = 0x00000100;
pub const FLUSHO: ::tcflag_t = 0x00001000;

pub const NGREG: usize = 32;
pub const REG_PC: usize = 0;
pub const REG_RA: usize = 1;
pub const REG_SP: usize = 2;
pub const REG_TP: usize = 4;
pub const REG_S0: usize = 8;
pub const REG_S1: usize = 9;
pub const REG_A0: usize = 10;
pub const REG_S2: usize = 18;
pub const REG_NARGS: usize = 8;

cfg_if! {
if #[cfg(libc_align)] {
mod align;
pub use self::align::*;
}
}

0 comments on commit b3c9c69

Please sign in to comment.