| 1 |
pub type c_char = i8; |
| 2 |
pub type c_long = i64; |
| 3 |
pub type c_ulong = u64; |
| 4 |
pub type wchar_t = i32; |
| 5 |
pub type time_t = i64; |
| 6 |
pub type suseconds_t = i64; |
| 7 |
pub type register_t = i64; |
| 8 |
|
| 9 |
s! { |
| 10 |
pub struct reg32 { |
| 11 |
pub r_fs: u32, |
| 12 |
pub r_es: u32, |
| 13 |
pub r_ds: u32, |
| 14 |
pub r_edi: u32, |
| 15 |
pub r_esi: u32, |
| 16 |
pub r_ebp: u32, |
| 17 |
pub r_isp: u32, |
| 18 |
pub r_ebx: u32, |
| 19 |
pub r_edx: u32, |
| 20 |
pub r_ecx: u32, |
| 21 |
pub r_eax: u32, |
| 22 |
pub r_trapno: u32, |
| 23 |
pub r_err: u32, |
| 24 |
pub r_eip: u32, |
| 25 |
pub r_cs: u32, |
| 26 |
pub r_eflags: u32, |
| 27 |
pub r_esp: u32, |
| 28 |
pub r_ss: u32, |
| 29 |
pub r_gs: u32, |
| 30 |
} |
| 31 |
|
| 32 |
pub struct reg { |
| 33 |
pub r_r15: i64, |
| 34 |
pub r_r14: i64, |
| 35 |
pub r_r13: i64, |
| 36 |
pub r_r12: i64, |
| 37 |
pub r_r11: i64, |
| 38 |
pub r_r10: i64, |
| 39 |
pub r_r9: i64, |
| 40 |
pub r_r8: i64, |
| 41 |
pub r_rdi: i64, |
| 42 |
pub r_rsi: i64, |
| 43 |
pub r_rbp: i64, |
| 44 |
pub r_rbx: i64, |
| 45 |
pub r_rdx: i64, |
| 46 |
pub r_rcx: i64, |
| 47 |
pub r_rax: i64, |
| 48 |
pub r_trapno: u32, |
| 49 |
pub r_fs: u16, |
| 50 |
pub r_gs: u16, |
| 51 |
pub r_err: u32, |
| 52 |
pub r_es: u16, |
| 53 |
pub r_ds: u16, |
| 54 |
pub r_rip: i64, |
| 55 |
pub r_cs: i64, |
| 56 |
pub r_rflags: i64, |
| 57 |
pub r_rsp: i64, |
| 58 |
pub r_ss: i64, |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
s_no_extra_traits! { |
| 63 |
pub struct fpreg32 { |
| 64 |
pub fpr_env: [u32; 7], |
| 65 |
pub fpr_acc: [[u8; 10]; 8], |
| 66 |
pub fpr_ex_sw: u32, |
| 67 |
pub fpr_pad: [u8; 64], |
| 68 |
} |
| 69 |
|
| 70 |
pub struct fpreg { |
| 71 |
pub fpr_env: [u64; 4], |
| 72 |
pub fpr_acc: [[u8; 16]; 8], |
| 73 |
pub fpr_xacc: [[u8; 16]; 16], |
| 74 |
pub fpr_spare: [u64; 12], |
| 75 |
} |
| 76 |
|
| 77 |
pub struct xmmreg { |
| 78 |
pub xmm_env: [u32; 8], |
| 79 |
pub xmm_acc: [[u8; 16]; 8], |
| 80 |
pub xmm_reg: [[u8; 16]; 8], |
| 81 |
pub xmm_pad: [u8; 224], |
| 82 |
} |
| 83 |
|
| 84 |
#[cfg(libc_union)] |
| 85 |
pub union __c_anonymous_elf64_auxv_union { |
| 86 |
pub a_val: ::c_long, |
| 87 |
pub a_ptr: *mut ::c_void, |
| 88 |
pub a_fcn: extern "C" fn(), |
| 89 |
} |
| 90 |
|
| 91 |
pub struct Elf64_Auxinfo { |
| 92 |
pub a_type: ::c_long, |
| 93 |
#[cfg(libc_union)] |
| 94 |
pub a_un: __c_anonymous_elf64_auxv_union, |
| 95 |
} |
| 96 |
|
| 97 |
pub struct kinfo_file { |
| 98 |
pub kf_structsize: ::c_int, |
| 99 |
pub kf_type: ::c_int, |
| 100 |
pub kf_fd: ::c_int, |
| 101 |
pub kf_ref_count: ::c_int, |
| 102 |
pub kf_flags: ::c_int, |
| 103 |
_kf_pad0: ::c_int, |
| 104 |
pub kf_offset: i64, |
| 105 |
_priv: [::uintptr_t; 38], // FIXME if needed |
| 106 |
pub kf_status: u16, |
| 107 |
_kf_pad1: u16, |
| 108 |
_kf_ispare0: ::c_int, |
| 109 |
pub kf_cap_rights: ::cap_rights_t, |
| 110 |
_kf_cap_spare: u64, |
| 111 |
pub kf_path: [::c_char; ::PATH_MAX as usize], |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
cfg_if! { |
| 116 |
if #[cfg(feature = "extra_traits")] { |
| 117 |
impl PartialEq for fpreg32 { |
| 118 |
fn eq(&self, other: &fpreg32) -> bool { |
| 119 |
self.fpr_env == other.fpr_env && |
| 120 |
self.fpr_acc == other.fpr_acc && |
| 121 |
self.fpr_ex_sw == other.fpr_ex_sw && |
| 122 |
self.fpr_pad |
| 123 |
.iter() |
| 124 |
.zip(other.fpr_pad.iter()) |
| 125 |
.all(|(a,b)| a == b) |
| 126 |
} |
| 127 |
} |
| 128 |
impl Eq for fpreg32 {} |
| 129 |
impl ::fmt::Debug for fpreg32 { |
| 130 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 131 |
f.debug_struct("fpreg32") |
| 132 |
.field("fpr_env", &&self.fpr_env[..]) |
| 133 |
.field("fpr_acc", &self.fpr_acc) |
| 134 |
.field("fpr_ex_sw", &self.fpr_ex_sw) |
| 135 |
.field("fpr_pad", &&self.fpr_pad[..]) |
| 136 |
.finish() |
| 137 |
} |
| 138 |
} |
| 139 |
impl ::hash::Hash for fpreg32 { |
| 140 |
fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 141 |
self.fpr_env.hash(state); |
| 142 |
self.fpr_acc.hash(state); |
| 143 |
self.fpr_ex_sw.hash(state); |
| 144 |
self.fpr_pad.hash(state); |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
impl PartialEq for fpreg { |
| 149 |
fn eq(&self, other: &fpreg) -> bool { |
| 150 |
self.fpr_env == other.fpr_env && |
| 151 |
self.fpr_acc == other.fpr_acc && |
| 152 |
self.fpr_xacc == other.fpr_xacc && |
| 153 |
self.fpr_spare == other.fpr_spare |
| 154 |
} |
| 155 |
} |
| 156 |
impl Eq for fpreg {} |
| 157 |
impl ::fmt::Debug for fpreg { |
| 158 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 159 |
f.debug_struct("fpreg") |
| 160 |
.field("fpr_env", &self.fpr_env) |
| 161 |
.field("fpr_acc", &self.fpr_acc) |
| 162 |
.field("fpr_xacc", &self.fpr_xacc) |
| 163 |
.field("fpr_spare", &self.fpr_spare) |
| 164 |
.finish() |
| 165 |
} |
| 166 |
} |
| 167 |
impl ::hash::Hash for fpreg { |
| 168 |
fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 169 |
self.fpr_env.hash(state); |
| 170 |
self.fpr_acc.hash(state); |
| 171 |
self.fpr_xacc.hash(state); |
| 172 |
self.fpr_spare.hash(state); |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
impl PartialEq for xmmreg { |
| 177 |
fn eq(&self, other: &xmmreg) -> bool { |
| 178 |
self.xmm_env == other.xmm_env && |
| 179 |
self.xmm_acc == other.xmm_acc && |
| 180 |
self.xmm_reg == other.xmm_reg && |
| 181 |
self.xmm_pad |
| 182 |
.iter() |
| 183 |
.zip(other.xmm_pad.iter()) |
| 184 |
.all(|(a,b)| a == b) |
| 185 |
} |
| 186 |
} |
| 187 |
impl Eq for xmmreg {} |
| 188 |
impl ::fmt::Debug for xmmreg { |
| 189 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 190 |
f.debug_struct("xmmreg") |
| 191 |
.field("xmm_env", &self.xmm_env) |
| 192 |
.field("xmm_acc", &self.xmm_acc) |
| 193 |
.field("xmm_reg", &self.xmm_reg) |
| 194 |
.field("xmm_pad", &&self.xmm_pad[..]) |
| 195 |
.finish() |
| 196 |
} |
| 197 |
} |
| 198 |
impl ::hash::Hash for xmmreg { |
| 199 |
fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 200 |
self.xmm_env.hash(state); |
| 201 |
self.xmm_acc.hash(state); |
| 202 |
self.xmm_reg.hash(state); |
| 203 |
self.xmm_pad.hash(state); |
| 204 |
} |
| 205 |
} |
| 206 |
|
| 207 |
#[cfg(libc_union)] |
| 208 |
impl PartialEq for __c_anonymous_elf64_auxv_union { |
| 209 |
fn eq(&self, other: &__c_anonymous_elf64_auxv_union) -> bool { |
| 210 |
unsafe { self.a_val == other.a_val |
| 211 |
|| self.a_ptr == other.a_ptr |
| 212 |
|| self.a_fcn == other.a_fcn } |
| 213 |
} |
| 214 |
} |
| 215 |
#[cfg(libc_union)] |
| 216 |
impl Eq for __c_anonymous_elf64_auxv_union {} |
| 217 |
#[cfg(libc_union)] |
| 218 |
impl ::fmt::Debug for __c_anonymous_elf64_auxv_union { |
| 219 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 220 |
f.debug_struct("a_val") |
| 221 |
.field("a_val", unsafe { &self.a_val }) |
| 222 |
.finish() |
| 223 |
} |
| 224 |
} |
| 225 |
#[cfg(not(libc_union))] |
| 226 |
impl PartialEq for Elf64_Auxinfo { |
| 227 |
fn eq(&self, other: &Elf64_Auxinfo) -> bool { |
| 228 |
self.a_type == other.a_type |
| 229 |
} |
| 230 |
} |
| 231 |
#[cfg(libc_union)] |
| 232 |
impl PartialEq for Elf64_Auxinfo { |
| 233 |
fn eq(&self, other: &Elf64_Auxinfo) -> bool { |
| 234 |
self.a_type == other.a_type |
| 235 |
&& self.a_un == other.a_un |
| 236 |
} |
| 237 |
} |
| 238 |
impl Eq for Elf64_Auxinfo {} |
| 239 |
#[cfg(not(libc_union))] |
| 240 |
impl ::fmt::Debug for Elf64_Auxinfo { |
| 241 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 242 |
f.debug_struct("Elf64_Auxinfo") |
| 243 |
.field("a_type", &self.a_type) |
| 244 |
.finish() |
| 245 |
} |
| 246 |
} |
| 247 |
#[cfg(libc_union)] |
| 248 |
impl ::fmt::Debug for Elf64_Auxinfo { |
| 249 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 250 |
f.debug_struct("Elf64_Auxinfo") |
| 251 |
.field("a_type", &self.a_type) |
| 252 |
.field("a_un", &self.a_un) |
| 253 |
.finish() |
| 254 |
} |
| 255 |
} |
| 256 |
|
| 257 |
impl PartialEq for kinfo_file { |
| 258 |
fn eq(&self, other: &kinfo_file) -> bool { |
| 259 |
self.kf_structsize == other.kf_structsize && |
| 260 |
self.kf_type == other.kf_type && |
| 261 |
self.kf_fd == other.kf_fd && |
| 262 |
self.kf_ref_count == other.kf_ref_count && |
| 263 |
self.kf_flags == other.kf_flags && |
| 264 |
self.kf_offset == other.kf_offset && |
| 265 |
self.kf_status == other.kf_status && |
| 266 |
self.kf_cap_rights == other.kf_cap_rights && |
| 267 |
self.kf_path |
| 268 |
.iter() |
| 269 |
.zip(other.kf_path.iter()) |
| 270 |
.all(|(a,b)| a == b) |
| 271 |
} |
| 272 |
} |
| 273 |
impl Eq for kinfo_file {} |
| 274 |
impl ::fmt::Debug for kinfo_file { |
| 275 |
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 276 |
f.debug_struct("kinfo_file") |
| 277 |
.field("kf_structsize", &self.kf_structsize) |
| 278 |
.field("kf_type", &self.kf_type) |
| 279 |
.field("kf_fd", &self.kf_fd) |
| 280 |
.field("kf_ref_count", &self.kf_ref_count) |
| 281 |
.field("kf_flags", &self.kf_flags) |
| 282 |
.field("kf_offset", &self.kf_offset) |
| 283 |
.field("kf_status", &self.kf_status) |
| 284 |
.field("kf_cap_rights", &self.kf_cap_rights) |
| 285 |
.field("kf_path", &&self.kf_path[..]) |
| 286 |
.finish() |
| 287 |
} |
| 288 |
} |
| 289 |
impl ::hash::Hash for kinfo_file { |
| 290 |
fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 291 |
self.kf_structsize.hash(state); |
| 292 |
self.kf_type.hash(state); |
| 293 |
self.kf_fd.hash(state); |
| 294 |
self.kf_ref_count.hash(state); |
| 295 |
self.kf_flags.hash(state); |
| 296 |
self.kf_offset.hash(state); |
| 297 |
self.kf_status.hash(state); |
| 298 |
self.kf_cap_rights.hash(state); |
| 299 |
self.kf_path.hash(state); |
| 300 |
} |
| 301 |
} |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
// should be pub(crate), but that requires Rust 1.18.0 |
| 306 |
cfg_if! { |
| 307 |
if #[cfg(libc_const_size_of)] { |
| 308 |
#[doc(hidden)] |
| 309 |
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; |
| 310 |
} else { |
| 311 |
#[doc(hidden)] |
| 312 |
pub const _ALIGNBYTES: usize = 8 - 1; |
| 313 |
} |
| 314 |
} |
| 315 |
pub const MAP_32BIT: ::c_int = 0x00080000; |
| 316 |
pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 |
| 317 |
|
| 318 |
pub const _MC_HASSEGS: u32 = 0x1; |
| 319 |
pub const _MC_HASBASES: u32 = 0x2; |
| 320 |
pub const _MC_HASFPXSTATE: u32 = 0x4; |
| 321 |
pub const _MC_FLAG_MASK: u32 = _MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE; |
| 322 |
|
| 323 |
pub const _MC_FPFMT_NODEV: c_long = 0x10000; |
| 324 |
pub const _MC_FPFMT_XMM: c_long = 0x10002; |
| 325 |
pub const _MC_FPOWNED_NONE: c_long = 0x20000; |
| 326 |
pub const _MC_FPOWNED_FPU: c_long = 0x20001; |
| 327 |
pub const _MC_FPOWNED_PCB: c_long = 0x20002; |
| 328 |
|
| 329 |
cfg_if! { |
| 330 |
if #[cfg(libc_align)] { |
| 331 |
mod align; |
| 332 |
pub use self::align::*; |
| 333 |
} |
| 334 |
} |