Skip to content

Commit 44fcc99

Browse files
committed
netbsd adding mcontext related data for riscv64
1 parent 7412a8b commit 44fcc99

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

src/unix/bsd/netbsdlike/netbsd/aarch64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ pub type __cpu_simple_lock_nv_t = ::c_uchar;
99
s! {
1010
pub struct __fregset {
1111
pub __qregs: [__c_anonymous__freg; 32],
12+
#[cfg(not(libc_union))]
13+
pub __qregs: [u128; 1],
1214
pub __fpcr: u32,
1315
pub __fpsr: u32,
1416
}

src/unix/bsd/netbsdlike/netbsd/riscv64.rs

+97
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,108 @@ use PT_FIRSTMACH;
33
pub type c_long = i64;
44
pub type c_ulong = u64;
55
pub type c_char = u8;
6+
pub type __greg_t = u64;
67
pub type __cpu_simple_lock_nv_t = ::c_int;
78

89
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
10+
s! {
11+
pub struct mcontext_t {
12+
pub __gregs: [::greg_t; 32],
13+
pub __fregs: [__c_anonymous__fpreg; 33],
14+
__spare: [::__greg_t; 7],
15+
}
16+
17+
pub struct ucontext_t {
18+
pub uc_flags: ::c_uint,
19+
pub uc_link: *mut ucontext_t,
20+
pub uc_sigmask: ::sigset_t,
21+
pub uc_stack: ::stack_t,
22+
pub uc_mcontext: mcontext_t,
23+
}
24+
}
25+
26+
s_no_extra_traits! {
27+
pub union __c_anonymous__fpreg {
28+
pub u_u64: u64,
29+
pub u_d: ::c_double,
30+
}
31+
}
32+
33+
cfg_if! {
34+
if #[cfg(feature = "extra_traits")] {
35+
impl PartialEq for __c_anonymous__fpreg {
36+
fn eq(&self, other: &__c_anonymous__fpreg) -> bool {
37+
unsafe {
38+
self.u_u64 == other.u_u64
39+
|| self.u_ud == other.u_ud
40+
}
41+
}
42+
}
43+
impl Eq for __c_anonymous__fpreg {}
44+
impl ::fmt::Debug for __c_anonymous__fpreg {
45+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
46+
unsafe {
47+
f.debug_struct("__c_anonymous__fpreg")
48+
.field("u_u64", &self.u_u64)
49+
.field("u_ud", &self.u_ud)
50+
}
51+
}
52+
}
53+
}
54+
if #[cfg(libc_const_size_of)] {
55+
#[doc(hidden)]
56+
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
57+
} else {
58+
#[doc(hidden)]
59+
pub const _ALIGNBYTES: usize = 8 - 1;
60+
}
61+
}
962

1063
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
1164
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;
1265
pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2;
1366
pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 3;
67+
68+
pub const _REG_X1: ::c_int = 0;
69+
pub const _REG_X2: ::c_int = 1;
70+
pub const _REG_X3: ::c_int = 2;
71+
pub const _REG_X4: ::c_int = 3;
72+
pub const _REG_X5: ::c_int = 4;
73+
pub const _REG_X6: ::c_int = 5;
74+
pub const _REG_X7: ::c_int = 6;
75+
pub const _REG_X8: ::c_int = 7;
76+
pub const _REG_X9: ::c_int = 8;
77+
pub const _REG_X10: ::c_int = 9;
78+
pub const _REG_X11: ::c_int = 10;
79+
pub const _REG_X12: ::c_int = 11;
80+
pub const _REG_X13: ::c_int = 12;
81+
pub const _REG_X14: ::c_int = 13;
82+
pub const _REG_X15: ::c_int = 14;
83+
pub const _REG_X16: ::c_int = 15;
84+
pub const _REG_X17: ::c_int = 16;
85+
pub const _REG_X18: ::c_int = 17;
86+
pub const _REG_X19: ::c_int = 18;
87+
pub const _REG_X20: ::c_int = 19;
88+
pub const _REG_X21: ::c_int = 20;
89+
pub const _REG_X22: ::c_int = 21;
90+
pub const _REG_X23: ::c_int = 22;
91+
pub const _REG_X24: ::c_int = 23;
92+
pub const _REG_X25: ::c_int = 24;
93+
pub const _REG_X26: ::c_int = 25;
94+
pub const _REG_X27: ::c_int = 26;
95+
pub const _REG_X28: ::c_int = 27;
96+
pub const _REG_X29: ::c_int = 28;
97+
pub const _REG_X30: ::c_int = 29;
98+
pub const _REG_X31: ::c_int = 30;
99+
pub const _REG_PC: ::c_int = 31;
100+
101+
pub const _REG_RA: ::c_int = _REG_X1;
102+
pub const _REG_SP: ::c_int = _REG_X2;
103+
pub const _REG_GP: ::c_int = _REG_X3;
104+
pub const _REG_TP: ::c_int = _REG_X4;
105+
pub const _REG_S0: ::c_int = _REG_X8;
106+
pub const _REG_RV: ::c_int = _REG_X10;
107+
pub const _REG_A0: ::c_int = _REG_X10;
108+
109+
pub const _REG_F0: ::c_int = 0;
110+
pub const _REG_FPCSR: ::c_int = 32;

0 commit comments

Comments
 (0)