Skip to content

Commit f01492d

Browse files
committed
Auto merge of #2373 - devnexen:solarish_ucontext, r=Amanieu
solarish adding ucontext struct
2 parents 9d6d76a + abcffb8 commit f01492d

File tree

3 files changed

+214
-4
lines changed

3 files changed

+214
-4
lines changed

libc-test/build.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,9 @@ fn test_solarish(target: &str) {
831831
});
832832

833833
cfg.skip_struct(move |ty| {
834+
if ty.starts_with("__c_anonymous_") {
835+
return true;
836+
}
834837
// the union handling is a mess
835838
if ty.contains("door_desc_t_") {
836839
return true;
@@ -1378,9 +1381,7 @@ fn test_wasi(target: &str) {
13781381
cfg.type_name(move |ty, is_struct, is_union| match ty {
13791382
"FILE" | "fd_set" | "DIR" => ty.to_string(),
13801383
t if is_union => format!("union {}", t),
1381-
t if t.starts_with("__wasi") && t.ends_with("_u") => {
1382-
format!("union {}", t)
1383-
}
1384+
t if t.starts_with("__wasi") && t.ends_with("_u") => format!("union {}", t),
13841385
t if t.starts_with("__wasi") && is_struct => format!("struct {}", t),
13851386
t if t.ends_with("_t") => t.to_string(),
13861387
t if is_struct => format!("struct {}", t),

src/unix/solarish/mod.rs

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ s! {
417417
pub maxerror: i32,
418418
pub esterror: i32,
419419
}
420-
421420
}
422421

423422
s_no_extra_traits! {
@@ -502,6 +501,18 @@ s_no_extra_traits! {
502501
pub sigev_notify_attributes: *const ::pthread_attr_t,
503502
__sigev_pad2: ::c_int,
504503
}
504+
505+
#[cfg(libc_union)]
506+
pub union pad128_t {
507+
pub _q: ::c_double,
508+
pub _l: [i32; 4],
509+
}
510+
511+
#[cfg(libc_union)]
512+
pub union upad128_t {
513+
pub _q: ::c_double,
514+
pub _l: [u32; 4],
515+
}
505516
}
506517

507518
cfg_if! {
@@ -827,6 +838,68 @@ cfg_if! {
827838
}
828839
}
829840

841+
#[cfg(libc_union)]
842+
impl PartialEq for pad128_t {
843+
fn eq(&self, other: &pad128_t) -> bool {
844+
unsafe {
845+
self._q == other._q ||
846+
self._l == other._l
847+
}
848+
}
849+
}
850+
#[cfg(libc_union)]
851+
impl Eq for pad128_t {}
852+
#[cfg(libc_union)]
853+
impl ::fmt::Debug for pad128_t {
854+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
855+
unsafe {
856+
f.debug_struct("pad128_t")
857+
.field("_q", &{self._q})
858+
.field("_l", &{self._l})
859+
.finish()
860+
}
861+
}
862+
}
863+
#[cfg(libc_union)]
864+
impl ::hash::Hash for pad128_t {
865+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
866+
unsafe {
867+
state.write_i64(self._q as i64);
868+
self._l.hash(state);
869+
}
870+
}
871+
}
872+
#[cfg(libc_union)]
873+
impl PartialEq for upad128_t {
874+
fn eq(&self, other: &upad128_t) -> bool {
875+
unsafe {
876+
self._q == other._q ||
877+
self._l == other._l
878+
}
879+
}
880+
}
881+
#[cfg(libc_union)]
882+
impl Eq for upad128_t {}
883+
#[cfg(libc_union)]
884+
impl ::fmt::Debug for upad128_t {
885+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
886+
unsafe {
887+
f.debug_struct("upad128_t")
888+
.field("_q", &{self._q})
889+
.field("_l", &{self._l})
890+
.finish()
891+
}
892+
}
893+
}
894+
#[cfg(libc_union)]
895+
impl ::hash::Hash for upad128_t {
896+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
897+
unsafe {
898+
state.write_i64(self._q as i64);
899+
self._l.hash(state);
900+
}
901+
}
902+
}
830903
}
831904
}
832905

@@ -2694,3 +2767,10 @@ cfg_if! {
26942767
// Unknown target_os
26952768
}
26962769
}
2770+
2771+
cfg_if! {
2772+
if #[cfg(target_arch = "x86_64")] {
2773+
mod x86_64;
2774+
pub use self::x86_64::*;
2775+
}
2776+
}

src/unix/solarish/x86_64.rs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
pub type greg_t = ::c_long;
2+
3+
s! {
4+
pub struct __c_anonymous_fpchip_state {
5+
pub cw: u16,
6+
pub sw: u16,
7+
pub fctw: u8,
8+
pub __fx_rsvd: u8,
9+
pub fop: u16,
10+
pub rip: u64,
11+
pub rdp: u64,
12+
pub mxcsr: u32,
13+
pub mxcsr_mask: u32,
14+
pub st: [::upad128_t; 8],
15+
pub xmm: [::upad128_t; 16],
16+
pub __fx_ign: [::upad128_t; 6],
17+
pub status: u32,
18+
pub xstatus: u32,
19+
}
20+
}
21+
22+
s_no_extra_traits! {
23+
#[cfg(libc_union)]
24+
pub union __c_anonymous_fp_reg_set {
25+
pub fpchip_state: __c_anonymous_fpchip_state,
26+
pub f_fpregs: [[u32; 13]; 10],
27+
}
28+
29+
pub struct fpregset_t {
30+
pub fp_reg_set: __c_anonymous_fp_reg_set,
31+
}
32+
33+
pub struct mcontext_t {
34+
pub gregs: [::greg_t; 28],
35+
pub fpgregs: fpregset_t,
36+
}
37+
38+
pub struct ucontext_t {
39+
pub uc_flags: ::c_ulong,
40+
pub uc_link: *mut ucontext_t,
41+
pub uc_sigmask: ::sigset_t,
42+
pub uc_stack: ::stack_t,
43+
pub uc_mcontext: mcontext_t,
44+
pub uc_filler: [::c_long; 5],
45+
}
46+
}
47+
48+
cfg_if! {
49+
if #[cfg(feature = "extra_traits")] {
50+
#[cfg(libc_union)]
51+
impl PartialEq for __c_anonymous_fp_reg_set {
52+
fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool {
53+
unsafe {
54+
self.fpchip_state == other.fpchip_state ||
55+
self.
56+
f_fpregs.
57+
iter().
58+
zip(other.f_fpregs.iter()).
59+
all(|(a, b)| a == b)
60+
}
61+
}
62+
}
63+
#[cfg(libc_union)]
64+
impl Eq for __c_anonymous_fp_reg_set {}
65+
#[cfg(libc_union)]
66+
impl ::fmt::Debug for __c_anonymous_fp_reg_set {
67+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
68+
unsafe {
69+
f.debug_struct("__c_anonymous_fp_reg_set")
70+
.field("fpchip_state", &{self.fpchip_state})
71+
.field("f_fpregs", &{self.f_fpregs})
72+
.finish()
73+
}
74+
}
75+
}
76+
impl PartialEq for fpregset_t {
77+
fn eq(&self, other: &fpregset_t) -> bool {
78+
self.fp_reg_set == other.fp_reg_set
79+
}
80+
}
81+
impl Eq for fpregset_t {}
82+
impl ::fmt::Debug for fpregset_t {
83+
fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result {
84+
f.debug_struct("fpregset_t")
85+
.field("fp_reg_set", &self.fp_reg_set)
86+
.finish()
87+
}
88+
}
89+
impl PartialEq for mcontext_t {
90+
fn eq(&self, other: &mcontext_t) -> bool {
91+
self.gregs == other.gregs &&
92+
self.fpgregs == other.fpgregs
93+
}
94+
}
95+
impl Eq for mcontext_t {}
96+
impl ::fmt::Debug for mcontext_t {
97+
fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result {
98+
f.debug_struct("mcontext_t")
99+
.field("gregs", &self.gregs)
100+
.field("fpgregs", &self.fpgregs)
101+
.finish()
102+
}
103+
}
104+
impl PartialEq for ucontext_t {
105+
fn eq(&self, other: &ucontext_t) -> bool {
106+
self.uc_flags == other.uc_flags
107+
&& self.uc_link == other.uc_link
108+
&& self.uc_sigmask == other.uc_sigmask
109+
&& self.uc_stack == other.uc_stack
110+
&& self.uc_mcontext == other.uc_mcontext
111+
&& self.uc_filler == other.uc_filler
112+
}
113+
}
114+
impl Eq for ucontext_t {}
115+
impl ::fmt::Debug for ucontext_t {
116+
fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result {
117+
f.debug_struct("ucontext_t")
118+
.field("uc_flags", &self.uc_flags)
119+
.field("uc_link", &self.uc_link)
120+
.field("uc_sigmask", &self.uc_sigmask)
121+
.field("uc_stack", &self.uc_stack)
122+
.field("uc_mcontext", &self.uc_mcontext)
123+
.field("uc_filler", &self.uc_filler)
124+
.finish()
125+
}
126+
}
127+
128+
}
129+
}

0 commit comments

Comments
 (0)