1 pub type c_char = u8; 2 pub type c_long = i64; 3 pub type c_ulong = u64; 4 pub type wchar_t = ::c_int; 5 pub type time_t = i64; 6 pub type suseconds_t = ::c_long; 7 pub type register_t = i64; 8 9 s_no_extra_traits! { 10 pub struct gpregs { 11 pub gp_ra: ::register_t, 12 pub gp_sp: ::register_t, 13 pub gp_gp: ::register_t, 14 pub gp_tp: ::register_t, 15 pub gp_t: [::register_t; 7], 16 pub gp_s: [::register_t; 12], 17 pub gp_a: [::register_t; 8], 18 pub gp_sepc: ::register_t, 19 pub gp_sstatus: ::register_t, 20 } 21 22 pub struct fpregs { 23 pub fp_x: [[::register_t; 2]; 32], 24 pub fp_fcsr: ::register_t, 25 pub fp_flags: ::c_int, 26 pub fp_pad: ::c_int, 27 } 28 29 pub struct mcontext_t { 30 pub mc_gpregs: gpregs, 31 pub mc_fpregs: fpregs, 32 pub mc_flags: ::c_int, 33 pub mc_pad: ::c_int, 34 pub mc_spare: [u64; 8], 35 } 36 } 37 38 // should be pub(crate), but that requires Rust 1.18.0 39 cfg_if! { 40 if #[cfg(libc_const_size_of)] { 41 #[doc(hidden)] 42 pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; 43 } else { 44 #[doc(hidden)] 45 pub const _ALIGNBYTES: usize = 8 - 1; 46 } 47 } 48 49 cfg_if! { 50 if #[cfg(feature = "extra_traits")] { 51 impl PartialEq for gpregs { eqnull52 fn eq(&self, other: &gpregs) -> bool { 53 self.gp_ra == other.gp_ra && 54 self.gp_sp == other.gp_sp && 55 self.gp_gp == other.gp_gp && 56 self.gp_tp == other.gp_tp && 57 self.gp_t.iter().zip(other.gp_t.iter()).all(|(a, b)| a == b) && 58 self.gp_s.iter().zip(other.gp_s.iter()).all(|(a, b)| a == b) && 59 self.gp_a.iter().zip(other.gp_a.iter()).all(|(a, b)| a == b) && 60 self.gp_sepc == other.gp_sepc && 61 self.gp_sstatus == other.gp_sstatus 62 } 63 } 64 impl Eq for gpregs {} 65 impl ::fmt::Debug for gpregs { fmtnull66 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 67 f.debug_struct("gpregs") 68 .field("gp_ra", &self.gp_ra) 69 .field("gp_sp", &self.gp_sp) 70 .field("gp_gp", &self.gp_gp) 71 .field("gp_tp", &self.gp_tp) 72 .field("gp_t", &self.gp_t) 73 .field("gp_s", &self.gp_s) 74 .field("gp_a", &self.gp_a) 75 .field("gp_sepc", &self.gp_sepc) 76 .field("gp_sstatus", &self.gp_sstatus) 77 .finish() 78 } 79 } 80 impl ::hash::Hash for gpregs { hashnull81 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 82 self.gp_ra.hash(state); 83 self.gp_sp.hash(state); 84 self.gp_gp.hash(state); 85 self.gp_tp.hash(state); 86 self.gp_t.hash(state); 87 self.gp_s.hash(state); 88 self.gp_a.hash(state); 89 self.gp_sepc.hash(state); 90 self.gp_sstatus.hash(state); 91 } 92 } 93 impl PartialEq for fpregs { eqnull94 fn eq(&self, other: &fpregs) -> bool { 95 self.fp_x == other.fp_x && 96 self.fp_fcsr == other.fp_fcsr && 97 self.fp_flags == other.fp_flags && 98 self.fp_pad == other.fp_pad 99 } 100 } 101 impl Eq for fpregs {} 102 impl ::fmt::Debug for fpregs { fmtnull103 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 104 f.debug_struct("fpregs") 105 .field("fp_x", &self.fp_x) 106 .field("fp_fcsr", &self.fp_fcsr) 107 .field("fp_flags", &self.fp_flags) 108 .field("fp_pad", &self.fp_pad) 109 .finish() 110 } 111 } 112 impl ::hash::Hash for fpregs { hashnull113 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 114 self.fp_x.hash(state); 115 self.fp_fcsr.hash(state); 116 self.fp_flags.hash(state); 117 self.fp_pad.hash(state); 118 } 119 } 120 impl PartialEq for mcontext_t { eqnull121 fn eq(&self, other: &mcontext_t) -> bool { 122 self.mc_gpregs == other.mc_gpregs && 123 self.mc_fpregs == other.mc_fpregs && 124 self.mc_flags == other.mc_flags && 125 self.mc_pad == other.mc_pad && 126 self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b) 127 } 128 } 129 impl Eq for mcontext_t {} 130 impl ::fmt::Debug for mcontext_t { fmtnull131 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 132 f.debug_struct("mcontext_t") 133 .field("mc_gpregs", &self.mc_gpregs) 134 .field("mc_fpregs", &self.mc_fpregs) 135 .field("mc_flags", &self.mc_flags) 136 .field("mc_pad", &self.mc_pad) 137 .field("mc_spare", &self.mc_spare) 138 .finish() 139 } 140 } 141 impl ::hash::Hash for mcontext_t { hashnull142 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 143 self.mc_gpregs.hash(state); 144 self.mc_fpregs.hash(state); 145 self.mc_flags.hash(state); 146 self.mc_pad.hash(state); 147 self.mc_spare.hash(state); 148 } 149 } 150 } 151 } 152 153 pub const MAP_32BIT: ::c_int = 0x00080000; 154 pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 155