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_lwpid: c_uint,
95         #[cfg(target_os = "solaris")]
96         pub uc_filler: [c_long; 2],
97     }
98 }
99 
100 cfg_if! {
101     if #[cfg(feature = "extra_traits")] {
102         impl PartialEq for __c_anonymous_fp_reg_set {
103             fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool {
104                 unsafe {
105                     self.fpchip_state == other.fpchip_state
106                         || self
107                             .f_fpregs
108                             .iter()
109                             .zip(other.f_fpregs.iter())
110                             .all(|(a, b)| a == b)
111                 }
112             }
113         }
114         impl Eq for __c_anonymous_fp_reg_set {}
115         impl PartialEq for fpregset_t {
116             fn eq(&self, other: &fpregset_t) -> bool {
117                 self.fp_reg_set == other.fp_reg_set
118             }
119         }
120         impl Eq for fpregset_t {}
121         impl PartialEq for mcontext_t {
122             fn eq(&self, other: &mcontext_t) -> bool {
123                 self.gregs == other.gregs && self.fpregs == other.fpregs
124             }
125         }
126         impl Eq for mcontext_t {}
127         impl PartialEq for ucontext_t {
128             fn eq(&self, other: &ucontext_t) -> bool {
129                 self.uc_flags == other.uc_flags
130                     && self.uc_link == other.uc_link
131                     && self.uc_sigmask == other.uc_sigmask
132                     && self.uc_stack == other.uc_stack
133                     && self.uc_mcontext == other.uc_mcontext
134                     && self.uc_filler == other.uc_filler
135             }
136         }
137         impl Eq for ucontext_t {}
138     }
139 }
140 
141 // sys/regset.h
142 
143 pub const REG_GSBASE: c_int = 27;
144 pub const REG_FSBASE: c_int = 26;
145 pub const REG_DS: c_int = 25;
146 pub const REG_ES: c_int = 24;
147 pub const REG_GS: c_int = 23;
148 pub const REG_FS: c_int = 22;
149 pub const REG_SS: c_int = 21;
150 pub const REG_RSP: c_int = 20;
151 pub const REG_RFL: c_int = 19;
152 pub const REG_CS: c_int = 18;
153 pub const REG_RIP: c_int = 17;
154 pub const REG_ERR: c_int = 16;
155 pub const REG_TRAPNO: c_int = 15;
156 pub const REG_RAX: c_int = 14;
157 pub const REG_RCX: c_int = 13;
158 pub const REG_RDX: c_int = 12;
159 pub const REG_RBX: c_int = 11;
160 pub const REG_RBP: c_int = 10;
161 pub const REG_RSI: c_int = 9;
162 pub const REG_RDI: c_int = 8;
163 pub const REG_R8: c_int = 7;
164 pub const REG_R9: c_int = 6;
165 pub const REG_R10: c_int = 5;
166 pub const REG_R11: c_int = 4;
167 pub const REG_R12: c_int = 3;
168 pub const REG_R13: c_int = 2;
169 pub const REG_R14: c_int = 1;
170 pub const REG_R15: c_int = 0;
171