Skip to content

Commit fa543d1

Browse files
author
Yuji Yamamoto
committed
1 parent 10fcecf commit fa543d1

File tree

1 file changed

+160
-0
lines changed
  • src/unix/linux_like/android/b32/x86

1 file changed

+160
-0
lines changed

src/unix/linux_like/android/b32/x86/mod.rs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,144 @@
11
pub type c_char = i8;
22
pub type wchar_t = i32;
3+
pub type greg_t = i32;
4+
5+
s! {
6+
pub struct _libc_fpreg {
7+
pub significand: [u16; 4],
8+
pub exponent: u16,
9+
}
10+
11+
pub struct _libc_fpstate {
12+
pub cw: ::c_ulong,
13+
pub sw: ::c_ulong,
14+
pub tag: ::c_ulong,
15+
pub ipoff: ::c_ulong,
16+
pub cssel: ::c_ulong,
17+
pub dataoff: ::c_ulong,
18+
pub datasel: ::c_ulong,
19+
pub _st: [_libc_fpreg; 8],
20+
pub status: ::c_ulong,
21+
}
22+
23+
pub struct mcontext_t {
24+
pub gregs: [greg_t; 19],
25+
pub fpregs: *mut _libc_fpstate,
26+
pub oldmask: ::c_ulong,
27+
pub cr2: ::c_ulong,
28+
}
29+
}
30+
31+
cfg_if! {
32+
if #[cfg(libc_union)] {
33+
s_no_extra_traits! {
34+
pub struct __c_anonymous_uc_sigmask_with_padding {
35+
pub uc_sigmask: ::sigset_t,
36+
/* Android has a wrong (smaller) sigset_t on x86. */
37+
__padding_rt_sigset: u32,
38+
}
39+
40+
pub union __c_anonymous_uc_sigmask {
41+
uc_sigmask: __c_anonymous_uc_sigmask_with_padding,
42+
uc_sigmask64: ::sigset64_t,
43+
}
44+
45+
pub struct ucontext_t {
46+
pub uc_flags: ::c_ulong,
47+
pub uc_link: *mut ucontext_t,
48+
pub uc_stack: ::stack_t,
49+
pub uc_mcontext: mcontext_t,
50+
pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask,
51+
__padding_rt_sigset: u32,
52+
__fpregs_mem: _libc_fpstate,
53+
}
54+
}
55+
56+
cfg_if! {
57+
if #[cfg(feature = "extra_traits")] {
58+
impl PartialEq for __c_anonymous_uc_sigmask_with_padding {
59+
fn eq(
60+
&self, other: &__c_anonymous_uc_sigmask_with_padding
61+
) -> bool {
62+
self.uc_sigmask == other.uc_sigmask
63+
// Ignore padding
64+
}
65+
}
66+
impl Eq for __c_anonymous_uc_sigmask_with_padding {}
67+
impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding {
68+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
69+
f.debug_struct("uc_sigmask_with_padding")
70+
.field("uc_sigmask_with_padding", &self.uc_sigmask)
71+
// Ignore padding
72+
.finish()
73+
}
74+
}
75+
impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding {
76+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
77+
self.uc_sigmask.hash(state)
78+
// Ignore padding
79+
}
80+
}
81+
82+
impl PartialEq for __c_anonymous_uc_sigmask {
83+
fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool {
84+
unsafe { self.uc_sigmask == other.uc_sigmask }
85+
}
86+
}
87+
impl Eq for __c_anonymous_uc_sigmask {}
88+
impl ::fmt::Debug for __c_anonymous_uc_sigmask {
89+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
90+
f.debug_struct("uc_sigmask")
91+
.field("uc_sigmask", unsafe { &self.uc_sigmask })
92+
.finish()
93+
}
94+
}
95+
impl ::hash::Hash for __c_anonymous_uc_sigmask {
96+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
97+
unsafe { self.uc_sigmask.hash(state) }
98+
}
99+
}
100+
101+
impl PartialEq for ucontext_t {
102+
fn eq(&self, other: &Self) -> bool {
103+
self.uc_flags == other.uc_flags
104+
&& self.uc_link == other.uc_link
105+
&& self.uc_stack == other.uc_stack
106+
&& self.uc_mcontext == other.uc_mcontext
107+
&& self.uc_sigmask__c_anonymous_union
108+
== other.uc_sigmask__c_anonymous_union
109+
// Ignore padding field
110+
}
111+
}
112+
impl Eq for ucontext_t {}
113+
impl ::fmt::Debug for ucontext_t {
114+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
115+
f.debug_struct("ucontext_t")
116+
.field("uc_flags", &self.uc_flags)
117+
.field("uc_link", &self.uc_link)
118+
.field("uc_stack", &self.uc_stack)
119+
.field("uc_mcontext", &self.uc_mcontext)
120+
.field(
121+
"uc_sigmask__c_anonymous_union",
122+
&self.uc_sigmask__c_anonymous_union
123+
)
124+
// Ignore padding field
125+
.finish()
126+
}
127+
}
128+
impl ::hash::Hash for ucontext_t {
129+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
130+
self.uc_flags.hash(state);
131+
self.uc_link.hash(state);
132+
self.uc_stack.hash(state);
133+
self.uc_mcontext.hash(state);
134+
self.uc_sigmask__c_anonymous_union.hash(state);
135+
// Ignore padding field
136+
}
137+
}
138+
}
139+
}
140+
}
141+
}
3142

4143
pub const O_DIRECT: ::c_int = 0x4000;
5144
pub const O_DIRECTORY: ::c_int = 0x10000;
@@ -414,6 +553,27 @@ pub const EFL: ::c_int = 14;
414553
pub const UESP: ::c_int = 15;
415554
pub const SS: ::c_int = 16;
416555

556+
// offsets in mcontext_t.gregs from sys/ucontext.h
557+
pub const REG_GS: ::c_int = 0;
558+
pub const REG_FS: ::c_int = 1;
559+
pub const REG_ES: ::c_int = 2;
560+
pub const REG_DS: ::c_int = 3;
561+
pub const REG_EDI: ::c_int = 4;
562+
pub const REG_ESI: ::c_int = 5;
563+
pub const REG_EBP: ::c_int = 6;
564+
pub const REG_ESP: ::c_int = 7;
565+
pub const REG_EBX: ::c_int = 8;
566+
pub const REG_EDX: ::c_int = 9;
567+
pub const REG_ECX: ::c_int = 10;
568+
pub const REG_EAX: ::c_int = 11;
569+
pub const REG_TRAPNO: ::c_int = 12;
570+
pub const REG_ERR: ::c_int = 13;
571+
pub const REG_EIP: ::c_int = 14;
572+
pub const REG_CS: ::c_int = 15;
573+
pub const REG_EFL: ::c_int = 16;
574+
pub const REG_UESP: ::c_int = 17;
575+
pub const REG_SS: ::c_int = 18;
576+
417577
cfg_if! {
418578
if #[cfg(libc_align)] {
419579
mod align;

0 commit comments

Comments
 (0)