| 1 |
use crate::prelude::*; |
| 2 |
|
| 3 |
cfg_if! { |
| 4 |
if #[cfg(target_os = "solaris")] { |
| 5 |
use crate::unix::solarish::solaris; |
| 6 |
} |
| 7 |
} |
| 8 |
|
| 9 |
pub type greg_t = c_long; |
| 10 |
|
| 11 |
pub type Elf64_Addr = c_ulong; |
| 12 |
pub type Elf64_Half = c_ushort; |
| 13 |
pub type Elf64_Off = c_ulong; |
| 14 |
pub type Elf64_Sword = c_int; |
| 15 |
pub type Elf64_Sxword = c_long; |
| 16 |
pub type Elf64_Word = c_uint; |
| 17 |
pub type Elf64_Xword = c_ulong; |
| 18 |
pub type Elf64_Lword = c_ulong; |
| 19 |
pub type Elf64_Phdr = __c_anonymous_Elf64_Phdr; |
| 20 |
|
| 21 |
s! { |
| 22 |
pub struct __c_anonymous_fpchip_state { |
| 23 |
pub cw: u16, |
| 24 |
pub sw: u16, |
| 25 |
pub fctw: u8, |
| 26 |
pub __fx_rsvd: u8, |
| 27 |
pub fop: u16, |
| 28 |
pub rip: u64, |
| 29 |
pub rdp: u64, |
| 30 |
pub mxcsr: u32, |
| 31 |
pub mxcsr_mask: u32, |
| 32 |
pub st: [crate::upad128_t; 8], |
| 33 |
pub xmm: [crate::upad128_t; 16], |
| 34 |
pub __fx_ign: [crate::upad128_t; 6], |
| 35 |
pub status: u32, |
| 36 |
pub xstatus: u32, |
| 37 |
} |
| 38 |
|
| 39 |
pub struct __c_anonymous_Elf64_Phdr { |
| 40 |
pub p_type: crate::Elf64_Word, |
| 41 |
pub p_flags: crate::Elf64_Word, |
| 42 |
pub p_offset: crate::Elf64_Off, |
| 43 |
pub p_vaddr: crate::Elf64_Addr, |
| 44 |
pub p_paddr: crate::Elf64_Addr, |
| 45 |
pub p_filesz: crate::Elf64_Xword, |
| 46 |
pub p_memsz: crate::Elf64_Xword, |
| 47 |
pub p_align: crate::Elf64_Xword, |
| 48 |
} |
| 49 |
|
| 50 |
pub struct dl_phdr_info { |
| 51 |
pub dlpi_addr: crate::Elf64_Addr, |
| 52 |
pub dlpi_name: *const c_char, |
| 53 |
pub dlpi_phdr: *const crate::Elf64_Phdr, |
| 54 |
pub dlpi_phnum: crate::Elf64_Half, |
| 55 |
pub dlpi_adds: c_ulonglong, |
| 56 |
pub dlpi_subs: c_ulonglong, |
| 57 |
#[cfg(target_os = "solaris")] |
| 58 |
pub dlpi_tls_modid: c_ulong, |
| 59 |
#[cfg(target_os = "solaris")] |
| 60 |
pub dlpi_tls_data: *mut c_void, |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
s_no_extra_traits! { |
| 65 |
pub union __c_anonymous_fp_reg_set { |
| 66 |
pub fpchip_state: __c_anonymous_fpchip_state, |
| 67 |
pub f_fpregs: [[u32; 13]; 10], |
| 68 |
} |
| 69 |
|
| 70 |
pub struct fpregset_t { |
| 71 |
pub fp_reg_set: __c_anonymous_fp_reg_set, |
| 72 |
} |
| 73 |
|
| 74 |
pub struct mcontext_t { |
| 75 |
pub gregs: [crate::greg_t; 28], |
| 76 |
pub fpregs: fpregset_t, |
| 77 |
} |
| 78 |
|
| 79 |
pub struct ucontext_t { |
| 80 |
pub uc_flags: c_ulong, |
| 81 |
pub uc_link: *mut ucontext_t, |
| 82 |
pub uc_sigmask: crate::sigset_t, |
| 83 |
pub uc_stack: crate::stack_t, |
| 84 |
pub uc_mcontext: mcontext_t, |
| 85 |
#[cfg(target_os = "illumos")] |
| 86 |
pub uc_brand_data: [*mut c_void; 3], |
| 87 |
#[cfg(target_os = "illumos")] |
| 88 |
pub uc_xsave: c_long, |
| 89 |
#[cfg(target_os = "illumos")] |
| 90 |
pub uc_filler: c_long, |
| 91 |
#[cfg(target_os = "solaris")] |
| 92 |
pub uc_xrs: solaris::xrs_t, |
| 93 |
#[cfg(target_os = "solaris")] |
| 94 |
pub uc_filler: [c_long; 3], |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
cfg_if! { |
| 99 |
if #[cfg(feature = "extra_traits")] { |
| 100 |
impl PartialEq for __c_anonymous_fp_reg_set { |
| 101 |
fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool { |
| 102 |
unsafe { |
| 103 |
self.fpchip_state == other.fpchip_state |
| 104 |
|| self |
| 105 |
.f_fpregs |
| 106 |
.iter() |
| 107 |
.zip(other.f_fpregs.iter()) |
| 108 |
.all(|(a, b)| a == b) |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
impl Eq for __c_anonymous_fp_reg_set {} |
| 113 |
impl PartialEq for fpregset_t { |
| 114 |
fn eq(&self, other: &fpregset_t) -> bool { |
| 115 |
self.fp_reg_set == other.fp_reg_set |
| 116 |
} |
| 117 |
} |
| 118 |
impl Eq for fpregset_t {} |
| 119 |
impl fmt::Debug for fpregset_t { |
| 120 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 121 |
f.debug_struct("fpregset_t") |
| 122 |
.field("fp_reg_set", &self.fp_reg_set) |
| 123 |
.finish() |
| 124 |
} |
| 125 |
} |
| 126 |
impl PartialEq for mcontext_t { |
| 127 |
fn eq(&self, other: &mcontext_t) -> bool { |
| 128 |
self.gregs == other.gregs && self.fpregs == other.fpregs |
| 129 |
} |
| 130 |
} |
| 131 |
impl Eq for mcontext_t {} |
| 132 |
impl fmt::Debug for mcontext_t { |
| 133 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 134 |
f.debug_struct("mcontext_t") |
| 135 |
.field("gregs", &self.gregs) |
| 136 |
.field("fpregs", &self.fpregs) |
| 137 |
.finish() |
| 138 |
} |
| 139 |
} |
| 140 |
impl PartialEq for ucontext_t { |
| 141 |
fn eq(&self, other: &ucontext_t) -> bool { |
| 142 |
self.uc_flags == other.uc_flags |
| 143 |
&& self.uc_link == other.uc_link |
| 144 |
&& self.uc_sigmask == other.uc_sigmask |
| 145 |
&& self.uc_stack == other.uc_stack |
| 146 |
&& self.uc_mcontext == other.uc_mcontext |
| 147 |
&& self.uc_filler == other.uc_filler |
| 148 |
} |
| 149 |
} |
| 150 |
impl Eq for ucontext_t {} |
| 151 |
impl fmt::Debug for ucontext_t { |
| 152 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 153 |
f.debug_struct("ucontext_t") |
| 154 |
.field("uc_flags", &self.uc_flags) |
| 155 |
.field("uc_link", &self.uc_link) |
| 156 |
.field("uc_sigmask", &self.uc_sigmask) |
| 157 |
.field("uc_stack", &self.uc_stack) |
| 158 |
.field("uc_mcontext", &self.uc_mcontext) |
| 159 |
.field("uc_filler", &self.uc_filler) |
| 160 |
.finish() |
| 161 |
} |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
// sys/regset.h |
| 167 |
|
| 168 |
pub const REG_GSBASE: c_int = 27; |
| 169 |
pub const REG_FSBASE: c_int = 26; |
| 170 |
pub const REG_DS: c_int = 25; |
| 171 |
pub const REG_ES: c_int = 24; |
| 172 |
pub const REG_GS: c_int = 23; |
| 173 |
pub const REG_FS: c_int = 22; |
| 174 |
pub const REG_SS: c_int = 21; |
| 175 |
pub const REG_RSP: c_int = 20; |
| 176 |
pub const REG_RFL: c_int = 19; |
| 177 |
pub const REG_CS: c_int = 18; |
| 178 |
pub const REG_RIP: c_int = 17; |
| 179 |
pub const REG_ERR: c_int = 16; |
| 180 |
pub const REG_TRAPNO: c_int = 15; |
| 181 |
pub const REG_RAX: c_int = 14; |
| 182 |
pub const REG_RCX: c_int = 13; |
| 183 |
pub const REG_RDX: c_int = 12; |
| 184 |
pub const REG_RBX: c_int = 11; |
| 185 |
pub const REG_RBP: c_int = 10; |
| 186 |
pub const REG_RSI: c_int = 9; |
| 187 |
pub const REG_RDI: c_int = 8; |
| 188 |
pub const REG_R8: c_int = 7; |
| 189 |
pub const REG_R9: c_int = 6; |
| 190 |
pub const REG_R10: c_int = 5; |
| 191 |
pub const REG_R11: c_int = 4; |
| 192 |
pub const REG_R12: c_int = 3; |
| 193 |
pub const REG_R13: c_int = 2; |
| 194 |
pub const REG_R14: c_int = 1; |
| 195 |
pub const REG_R15: c_int = 0; |