Skip to content

Commit bbe2b2f

Browse files
committed
netbsd adding mcontext related data for riscv64
1 parent 1bca87e commit bbe2b2f

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ s! {
1010
pub struct __fregset {
1111
#[cfg(libc_union)]
1212
pub __qregs: [__c_anonymous__freg; 32],
13+
#[cfg(not(libc_union))]
14+
pub __qregs: [u128; 1],
1315
pub __fpcr: u32,
1416
pub __fpsr: u32,
1517
}

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

+95
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,60 @@ 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

9+
s! {
10+
pub struct mcontext_t {
11+
pub __gregs: [::greg_t; 32],
12+
#[cfg(libc_union)]
13+
pub __fregs: [__c_anonymous__fpreg; 33],
14+
#[cfg(not(libc_union))]
15+
pub __fregs: [u64; 33],
16+
__spare: [::__greg_t; 7],
17+
}
18+
19+
pub struct ucontext_t {
20+
pub uc_flags: ::c_uint,
21+
pub uc_link: *mut ucontext_t,
22+
pub uc_sigmask: ::sigset_t,
23+
pub uc_stack: ::stack_t,
24+
pub uc_mcontext: mcontext_t,
25+
}
26+
}
27+
28+
s_no_extra_traits! {
29+
#[cfg(libc_union)]
30+
pub union __c_anonymous__fpreg {
31+
pub u_u64: u64,
32+
pub u_d: ::c_double,
33+
}
34+
}
35+
836
cfg_if! {
37+
if #[cfg(feature = "extra_traits")] {
38+
#[cfg(libc_union)]
39+
impl PartialEq for __c_anonymous__fpreg {
40+
fn eq(&self, other: &__c_anonymous__fpreg) -> bool {
41+
unsafe {
42+
self.u_u64 == other.u_u64
43+
|| self.u_ud == other.u_ud
44+
}
45+
}
46+
}
47+
#[cfg(libc_union)]
48+
impl Eq for __c_anonymous__fpreg {}
49+
#[cfg(libc_union)]
50+
impl ::fmt::Debug for __c_anonymous__fpreg {
51+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
52+
unsafe {
53+
f.debug_struct("__c_anonymous__fpreg")
54+
.field("u_u64", &self.u_u64)
55+
.field("u_ud", &self.u_ud)
56+
}
57+
}
58+
}
59+
}
960
if #[cfg(libc_const_size_of)] {
1061
#[doc(hidden)]
1162
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
@@ -19,3 +70,47 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
1970
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;
2071
pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2;
2172
pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 3;
73+
74+
pub const _REG_X1: ::c_int = 0;
75+
pub const _REG_X2: ::c_int = 1;
76+
pub const _REG_X3: ::c_int = 2;
77+
pub const _REG_X4: ::c_int = 3;
78+
pub const _REG_X5: ::c_int = 4;
79+
pub const _REG_X6: ::c_int = 5;
80+
pub const _REG_X7: ::c_int = 6;
81+
pub const _REG_X8: ::c_int = 7;
82+
pub const _REG_X9: ::c_int = 8;
83+
pub const _REG_X10: ::c_int = 9;
84+
pub const _REG_X11: ::c_int = 10;
85+
pub const _REG_X12: ::c_int = 11;
86+
pub const _REG_X13: ::c_int = 12;
87+
pub const _REG_X14: ::c_int = 13;
88+
pub const _REG_X15: ::c_int = 14;
89+
pub const _REG_X16: ::c_int = 15;
90+
pub const _REG_X17: ::c_int = 16;
91+
pub const _REG_X18: ::c_int = 17;
92+
pub const _REG_X19: ::c_int = 18;
93+
pub const _REG_X20: ::c_int = 19;
94+
pub const _REG_X21: ::c_int = 20;
95+
pub const _REG_X22: ::c_int = 21;
96+
pub const _REG_X23: ::c_int = 22;
97+
pub const _REG_X24: ::c_int = 23;
98+
pub const _REG_X25: ::c_int = 24;
99+
pub const _REG_X26: ::c_int = 25;
100+
pub const _REG_X27: ::c_int = 26;
101+
pub const _REG_X28: ::c_int = 27;
102+
pub const _REG_X29: ::c_int = 28;
103+
pub const _REG_X30: ::c_int = 29;
104+
pub const _REG_X31: ::c_int = 30;
105+
pub const _REG_PC: ::c_int = 31;
106+
107+
pub const _REG_RA: ::c_int = _REG_X1;
108+
pub const _REG_SP: ::c_int = _REG_X2;
109+
pub const _REG_GP: ::c_int = _REG_X3;
110+
pub const _REG_TP: ::c_int = _REG_X4;
111+
pub const _REG_S0: ::c_int = _REG_X8;
112+
pub const _REG_RV: ::c_int = _REG_X10;
113+
pub const _REG_A0: ::c_int = _REG_X10;
114+
115+
pub const _REG_F0: ::c_int = 0;
116+
pub const _REG_FPCSR: ::c_int = 32;

0 commit comments

Comments
 (0)