Skip to content

Commit ec88c37

Browse files
committed
Auto merge of #2676 - Amanieu:arm_mcontext, r=Amanieu
Add mcontext_t and ucontext_t for ARM Linux
2 parents b30ec40 + 26665e7 commit ec88c37

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed

src/unix/linux_like/linux/gnu/b32/arm/align.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,50 @@ s_no_extra_traits! {
44
pub struct max_align_t {
55
priv_: [i64; 2]
66
}
7+
8+
#[allow(missing_debug_implementations)]
9+
#[repr(align(8))]
10+
pub struct ucontext_t {
11+
pub uc_flags: ::c_ulong,
12+
pub uc_link: *mut ucontext_t,
13+
pub uc_stack: ::stack_t,
14+
pub uc_mcontext: ::mcontext_t,
15+
pub uc_sigmask: ::sigset_t,
16+
pub uc_regspace: [::c_ulong; 128],
17+
}
18+
}
19+
20+
cfg_if! {
21+
if #[cfg(feature = "extra_traits")] {
22+
impl PartialEq for ucontext_t {
23+
fn eq(&self, other: &ucontext_t) -> bool {
24+
self.uc_flags == other.uc_flags
25+
&& self.uc_link == other.uc_link
26+
&& self.uc_stack == other.uc_stack
27+
&& self.uc_mcontext == other.uc_mcontext
28+
&& self.uc_sigmask == other.uc_sigmask
29+
}
30+
}
31+
impl Eq for ucontext_t {}
32+
impl ::fmt::Debug for ucontext_t {
33+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
34+
f.debug_struct("ucontext_t")
35+
.field("uc_flags", &self.uc_link)
36+
.field("uc_link", &self.uc_link)
37+
.field("uc_stack", &self.uc_stack)
38+
.field("uc_mcontext", &self.uc_mcontext)
39+
.field("uc_sigmask", &self.uc_sigmask)
40+
.finish()
41+
}
42+
}
43+
impl ::hash::Hash for ucontext_t {
44+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
45+
self.uc_flags.hash(state);
46+
self.uc_link.hash(state);
47+
self.uc_stack.hash(state);
48+
self.uc_mcontext.hash(state);
49+
self.uc_sigmask.hash(state);
50+
}
51+
}
52+
}
753
}

src/unix/linux_like/linux/gnu/b32/arm/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ s! {
167167
pub seccomp_notif_resp: ::__u16,
168168
pub seccomp_data: ::__u16,
169169
}
170+
171+
pub struct mcontext_t {
172+
pub trap_no: ::c_ulong,
173+
pub error_code: ::c_ulong,
174+
pub oldmask: ::c_ulong,
175+
pub arm_r0: ::c_ulong,
176+
pub arm_r1: ::c_ulong,
177+
pub arm_r2: ::c_ulong,
178+
pub arm_r3: ::c_ulong,
179+
pub arm_r4: ::c_ulong,
180+
pub arm_r5: ::c_ulong,
181+
pub arm_r6: ::c_ulong,
182+
pub arm_r7: ::c_ulong,
183+
pub arm_r8: ::c_ulong,
184+
pub arm_r9: ::c_ulong,
185+
pub arm_r10: ::c_ulong,
186+
pub arm_fp: ::c_ulong,
187+
pub arm_ip: ::c_ulong,
188+
pub arm_sp: ::c_ulong,
189+
pub arm_lr: ::c_ulong,
190+
pub arm_pc: ::c_ulong,
191+
pub arm_cpsr: ::c_ulong,
192+
pub fault_address: ::c_ulong,
193+
}
170194
}
171195

172196
pub const RLIM_INFINITY: ::rlim_t = !0;

src/unix/linux_like/linux/musl/b32/arm/mod.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,77 @@ s! {
150150
pub f_namemax: ::c_ulong,
151151
__f_spare: [::c_int; 6],
152152
}
153+
154+
pub struct mcontext_t {
155+
pub trap_no: ::c_ulong,
156+
pub error_code: ::c_ulong,
157+
pub oldmask: ::c_ulong,
158+
pub arm_r0: ::c_ulong,
159+
pub arm_r1: ::c_ulong,
160+
pub arm_r2: ::c_ulong,
161+
pub arm_r3: ::c_ulong,
162+
pub arm_r4: ::c_ulong,
163+
pub arm_r5: ::c_ulong,
164+
pub arm_r6: ::c_ulong,
165+
pub arm_r7: ::c_ulong,
166+
pub arm_r8: ::c_ulong,
167+
pub arm_r9: ::c_ulong,
168+
pub arm_r10: ::c_ulong,
169+
pub arm_fp: ::c_ulong,
170+
pub arm_ip: ::c_ulong,
171+
pub arm_sp: ::c_ulong,
172+
pub arm_lr: ::c_ulong,
173+
pub arm_pc: ::c_ulong,
174+
pub arm_cpsr: ::c_ulong,
175+
pub fault_address: ::c_ulong,
176+
}
177+
}
178+
179+
s_no_extra_traits! {
180+
#[allow(missing_debug_implementations)]
181+
pub struct ucontext_t {
182+
pub uc_flags: ::c_ulong,
183+
pub uc_link: *mut ucontext_t,
184+
pub uc_stack: ::stack_t,
185+
pub uc_mcontext: mcontext_t,
186+
pub uc_sigmask: ::sigset_t,
187+
pub uc_regspace: [::c_ulonglong; 64],
188+
}
189+
}
190+
191+
cfg_if! {
192+
if #[cfg(feature = "extra_traits")] {
193+
impl PartialEq for ucontext_t {
194+
fn eq(&self, other: &ucontext_t) -> bool {
195+
self.uc_flags == other.uc_flags
196+
&& self.uc_link == other.uc_link
197+
&& self.uc_stack == other.uc_stack
198+
&& self.uc_mcontext == other.uc_mcontext
199+
&& self.uc_sigmask == other.uc_sigmask
200+
}
201+
}
202+
impl Eq for ucontext_t {}
203+
impl ::fmt::Debug for ucontext_t {
204+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
205+
f.debug_struct("ucontext_t")
206+
.field("uc_flags", &self.uc_link)
207+
.field("uc_link", &self.uc_link)
208+
.field("uc_stack", &self.uc_stack)
209+
.field("uc_mcontext", &self.uc_mcontext)
210+
.field("uc_sigmask", &self.uc_sigmask)
211+
.finish()
212+
}
213+
}
214+
impl ::hash::Hash for ucontext_t {
215+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
216+
self.uc_flags.hash(state);
217+
self.uc_link.hash(state);
218+
self.uc_stack.hash(state);
219+
self.uc_mcontext.hash(state);
220+
self.uc_sigmask.hash(state);
221+
}
222+
}
223+
}
153224
}
154225

155226
pub const SIGSTKSZ: ::size_t = 8192;

0 commit comments

Comments
 (0)