Auto merge of #2373 - devnexen:solarish_ucontext, r=Amanieu

solarish adding ucontext struct
This commit is contained in:
bors 2021-08-28 15:50:29 +00:00
commit f01492db1b
3 changed files with 214 additions and 4 deletions

View file

@ -831,6 +831,9 @@ fn test_solarish(target: &str) {
});
cfg.skip_struct(move |ty| {
if ty.starts_with("__c_anonymous_") {
return true;
}
// the union handling is a mess
if ty.contains("door_desc_t_") {
return true;
@ -1378,9 +1381,7 @@ fn test_wasi(target: &str) {
cfg.type_name(move |ty, is_struct, is_union| match ty {
"FILE" | "fd_set" | "DIR" => ty.to_string(),
t if is_union => format!("union {}", t),
t if t.starts_with("__wasi") && t.ends_with("_u") => {
format!("union {}", t)
}
t if t.starts_with("__wasi") && t.ends_with("_u") => format!("union {}", t),
t if t.starts_with("__wasi") && is_struct => format!("struct {}", t),
t if t.ends_with("_t") => t.to_string(),
t if is_struct => format!("struct {}", t),

View file

@ -417,7 +417,6 @@ s! {
pub maxerror: i32,
pub esterror: i32,
}
}
s_no_extra_traits! {
@ -502,6 +501,18 @@ s_no_extra_traits! {
pub sigev_notify_attributes: *const ::pthread_attr_t,
__sigev_pad2: ::c_int,
}
#[cfg(libc_union)]
pub union pad128_t {
pub _q: ::c_double,
pub _l: [i32; 4],
}
#[cfg(libc_union)]
pub union upad128_t {
pub _q: ::c_double,
pub _l: [u32; 4],
}
}
cfg_if! {
@ -827,6 +838,68 @@ cfg_if! {
}
}
#[cfg(libc_union)]
impl PartialEq for pad128_t {
fn eq(&self, other: &pad128_t) -> bool {
unsafe {
self._q == other._q ||
self._l == other._l
}
}
}
#[cfg(libc_union)]
impl Eq for pad128_t {}
#[cfg(libc_union)]
impl ::fmt::Debug for pad128_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
f.debug_struct("pad128_t")
.field("_q", &{self._q})
.field("_l", &{self._l})
.finish()
}
}
}
#[cfg(libc_union)]
impl ::hash::Hash for pad128_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
state.write_i64(self._q as i64);
self._l.hash(state);
}
}
}
#[cfg(libc_union)]
impl PartialEq for upad128_t {
fn eq(&self, other: &upad128_t) -> bool {
unsafe {
self._q == other._q ||
self._l == other._l
}
}
}
#[cfg(libc_union)]
impl Eq for upad128_t {}
#[cfg(libc_union)]
impl ::fmt::Debug for upad128_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
f.debug_struct("upad128_t")
.field("_q", &{self._q})
.field("_l", &{self._l})
.finish()
}
}
}
#[cfg(libc_union)]
impl ::hash::Hash for upad128_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
state.write_i64(self._q as i64);
self._l.hash(state);
}
}
}
}
}
@ -2694,3 +2767,10 @@ cfg_if! {
// Unknown target_os
}
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
}
}

129
src/unix/solarish/x86_64.rs Normal file
View file

@ -0,0 +1,129 @@
pub type greg_t = ::c_long;
s! {
pub struct __c_anonymous_fpchip_state {
pub cw: u16,
pub sw: u16,
pub fctw: u8,
pub __fx_rsvd: u8,
pub fop: u16,
pub rip: u64,
pub rdp: u64,
pub mxcsr: u32,
pub mxcsr_mask: u32,
pub st: [::upad128_t; 8],
pub xmm: [::upad128_t; 16],
pub __fx_ign: [::upad128_t; 6],
pub status: u32,
pub xstatus: u32,
}
}
s_no_extra_traits! {
#[cfg(libc_union)]
pub union __c_anonymous_fp_reg_set {
pub fpchip_state: __c_anonymous_fpchip_state,
pub f_fpregs: [[u32; 13]; 10],
}
pub struct fpregset_t {
pub fp_reg_set: __c_anonymous_fp_reg_set,
}
pub struct mcontext_t {
pub gregs: [::greg_t; 28],
pub fpgregs: fpregset_t,
}
pub struct ucontext_t {
pub uc_flags: ::c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_sigmask: ::sigset_t,
pub uc_stack: ::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_filler: [::c_long; 5],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
#[cfg(libc_union)]
impl PartialEq for __c_anonymous_fp_reg_set {
fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool {
unsafe {
self.fpchip_state == other.fpchip_state ||
self.
f_fpregs.
iter().
zip(other.f_fpregs.iter()).
all(|(a, b)| a == b)
}
}
}
#[cfg(libc_union)]
impl Eq for __c_anonymous_fp_reg_set {}
#[cfg(libc_union)]
impl ::fmt::Debug for __c_anonymous_fp_reg_set {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
f.debug_struct("__c_anonymous_fp_reg_set")
.field("fpchip_state", &{self.fpchip_state})
.field("f_fpregs", &{self.f_fpregs})
.finish()
}
}
}
impl PartialEq for fpregset_t {
fn eq(&self, other: &fpregset_t) -> bool {
self.fp_reg_set == other.fp_reg_set
}
}
impl Eq for fpregset_t {}
impl ::fmt::Debug for fpregset_t {
fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("fpregset_t")
.field("fp_reg_set", &self.fp_reg_set)
.finish()
}
}
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.gregs == other.gregs &&
self.fpgregs == other.fpgregs
}
}
impl Eq for mcontext_t {}
impl ::fmt::Debug for mcontext_t {
fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("mcontext_t")
.field("gregs", &self.gregs)
.field("fpgregs", &self.fpgregs)
.finish()
}
}
impl PartialEq for ucontext_t {
fn eq(&self, other: &ucontext_t) -> bool {
self.uc_flags == other.uc_flags
&& self.uc_link == other.uc_link
&& self.uc_sigmask == other.uc_sigmask
&& self.uc_stack == other.uc_stack
&& self.uc_mcontext == other.uc_mcontext
&& self.uc_filler == other.uc_filler
}
}
impl Eq for ucontext_t {}
impl ::fmt::Debug for ucontext_t {
fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ucontext_t")
.field("uc_flags", &self.uc_flags)
.field("uc_link", &self.uc_link)
.field("uc_sigmask", &self.uc_sigmask)
.field("uc_stack", &self.uc_stack)
.field("uc_mcontext", &self.uc_mcontext)
.field("uc_filler", &self.uc_filler)
.finish()
}
}
}
}