| 1 | //! x86_64-specific definitions for 64-bit linux-like values |
| 2 | |
| 3 | use crate::prelude::*; |
| 4 | use crate::{off64_t, off_t}; |
| 5 | |
| 6 | pub type wchar_t = i32; |
| 7 | pub type nlink_t = u64; |
| 8 | pub type blksize_t = i64; |
| 9 | pub type greg_t = i64; |
| 10 | pub type suseconds_t = i64; |
| 11 | pub type __u64 = c_ulonglong; |
| 12 | pub type __s64 = c_longlong; |
| 13 | |
| 14 | s! { |
| 15 | pub struct sigaction { |
| 16 | pub sa_sigaction: crate::sighandler_t, |
| 17 | pub sa_mask: crate::sigset_t, |
| 18 | #[cfg (target_arch = "sparc64" )] |
| 19 | __reserved0: c_int, |
| 20 | pub sa_flags: c_int, |
| 21 | pub sa_restorer: Option<extern "C" fn()>, |
| 22 | } |
| 23 | |
| 24 | pub struct statfs { |
| 25 | pub f_type: crate::__fsword_t, |
| 26 | pub f_bsize: crate::__fsword_t, |
| 27 | pub f_blocks: crate::fsblkcnt_t, |
| 28 | pub f_bfree: crate::fsblkcnt_t, |
| 29 | pub f_bavail: crate::fsblkcnt_t, |
| 30 | |
| 31 | pub f_files: crate::fsfilcnt_t, |
| 32 | pub f_ffree: crate::fsfilcnt_t, |
| 33 | pub f_fsid: crate::fsid_t, |
| 34 | |
| 35 | pub f_namelen: crate::__fsword_t, |
| 36 | pub f_frsize: crate::__fsword_t, |
| 37 | f_spare: [crate::__fsword_t; 5], |
| 38 | } |
| 39 | |
| 40 | pub struct flock { |
| 41 | pub l_type: c_short, |
| 42 | pub l_whence: c_short, |
| 43 | pub l_start: off_t, |
| 44 | pub l_len: off_t, |
| 45 | pub l_pid: crate::pid_t, |
| 46 | } |
| 47 | |
| 48 | pub struct flock64 { |
| 49 | pub l_type: c_short, |
| 50 | pub l_whence: c_short, |
| 51 | pub l_start: off64_t, |
| 52 | pub l_len: off64_t, |
| 53 | pub l_pid: crate::pid_t, |
| 54 | } |
| 55 | |
| 56 | pub struct siginfo_t { |
| 57 | pub si_signo: c_int, |
| 58 | pub si_errno: c_int, |
| 59 | pub si_code: c_int, |
| 60 | #[doc (hidden)] |
| 61 | #[deprecated ( |
| 62 | since = "0.2.54" , |
| 63 | note = "Please leave a comment on \ |
| 64 | https://github.com/rust-lang/libc/pull/1316 if you're using \ |
| 65 | this field" |
| 66 | )] |
| 67 | pub _pad: [c_int; 29], |
| 68 | _align: [u64; 0], |
| 69 | } |
| 70 | |
| 71 | pub struct stack_t { |
| 72 | pub ss_sp: *mut c_void, |
| 73 | pub ss_flags: c_int, |
| 74 | pub ss_size: size_t, |
| 75 | } |
| 76 | |
| 77 | pub struct stat { |
| 78 | pub st_dev: crate::dev_t, |
| 79 | pub st_ino: crate::ino_t, |
| 80 | pub st_nlink: crate::nlink_t, |
| 81 | pub st_mode: crate::mode_t, |
| 82 | pub st_uid: crate::uid_t, |
| 83 | pub st_gid: crate::gid_t, |
| 84 | __pad0: c_int, |
| 85 | pub st_rdev: crate::dev_t, |
| 86 | pub st_size: off_t, |
| 87 | pub st_blksize: crate::blksize_t, |
| 88 | pub st_blocks: crate::blkcnt_t, |
| 89 | pub st_atime: crate::time_t, |
| 90 | pub st_atime_nsec: i64, |
| 91 | pub st_mtime: crate::time_t, |
| 92 | pub st_mtime_nsec: i64, |
| 93 | pub st_ctime: crate::time_t, |
| 94 | pub st_ctime_nsec: i64, |
| 95 | __unused: [i64; 3], |
| 96 | } |
| 97 | |
| 98 | pub struct stat64 { |
| 99 | pub st_dev: crate::dev_t, |
| 100 | pub st_ino: crate::ino64_t, |
| 101 | pub st_nlink: crate::nlink_t, |
| 102 | pub st_mode: crate::mode_t, |
| 103 | pub st_uid: crate::uid_t, |
| 104 | pub st_gid: crate::gid_t, |
| 105 | __pad0: c_int, |
| 106 | pub st_rdev: crate::dev_t, |
| 107 | pub st_size: off_t, |
| 108 | pub st_blksize: crate::blksize_t, |
| 109 | pub st_blocks: crate::blkcnt64_t, |
| 110 | pub st_atime: crate::time_t, |
| 111 | pub st_atime_nsec: i64, |
| 112 | pub st_mtime: crate::time_t, |
| 113 | pub st_mtime_nsec: i64, |
| 114 | pub st_ctime: crate::time_t, |
| 115 | pub st_ctime_nsec: i64, |
| 116 | __reserved: [i64; 3], |
| 117 | } |
| 118 | |
| 119 | pub struct statfs64 { |
| 120 | pub f_type: crate::__fsword_t, |
| 121 | pub f_bsize: crate::__fsword_t, |
| 122 | pub f_blocks: u64, |
| 123 | pub f_bfree: u64, |
| 124 | pub f_bavail: u64, |
| 125 | pub f_files: u64, |
| 126 | pub f_ffree: u64, |
| 127 | pub f_fsid: crate::fsid_t, |
| 128 | pub f_namelen: crate::__fsword_t, |
| 129 | pub f_frsize: crate::__fsword_t, |
| 130 | pub f_flags: crate::__fsword_t, |
| 131 | pub f_spare: [crate::__fsword_t; 4], |
| 132 | } |
| 133 | |
| 134 | pub struct statvfs64 { |
| 135 | pub f_bsize: c_ulong, |
| 136 | pub f_frsize: c_ulong, |
| 137 | pub f_blocks: u64, |
| 138 | pub f_bfree: u64, |
| 139 | pub f_bavail: u64, |
| 140 | pub f_files: u64, |
| 141 | pub f_ffree: u64, |
| 142 | pub f_favail: u64, |
| 143 | pub f_fsid: c_ulong, |
| 144 | pub f_flag: c_ulong, |
| 145 | pub f_namemax: c_ulong, |
| 146 | __f_spare: [c_int; 6], |
| 147 | } |
| 148 | |
| 149 | pub struct pthread_attr_t { |
| 150 | #[cfg (target_pointer_width = "32" )] |
| 151 | __size: [u32; 8], |
| 152 | #[cfg (target_pointer_width = "64" )] |
| 153 | __size: [u64; 7], |
| 154 | } |
| 155 | |
| 156 | pub struct _libc_fpxreg { |
| 157 | pub significand: [u16; 4], |
| 158 | pub exponent: u16, |
| 159 | __private: [u16; 3], |
| 160 | } |
| 161 | |
| 162 | pub struct _libc_xmmreg { |
| 163 | pub element: [u32; 4], |
| 164 | } |
| 165 | |
| 166 | pub struct _libc_fpstate { |
| 167 | pub cwd: u16, |
| 168 | pub swd: u16, |
| 169 | pub ftw: u16, |
| 170 | pub fop: u16, |
| 171 | pub rip: u64, |
| 172 | pub rdp: u64, |
| 173 | pub mxcsr: u32, |
| 174 | pub mxcr_mask: u32, |
| 175 | pub _st: [_libc_fpxreg; 8], |
| 176 | pub _xmm: [_libc_xmmreg; 16], |
| 177 | __private: [u64; 12], |
| 178 | } |
| 179 | |
| 180 | pub struct user_regs_struct { |
| 181 | pub r15: c_ulonglong, |
| 182 | pub r14: c_ulonglong, |
| 183 | pub r13: c_ulonglong, |
| 184 | pub r12: c_ulonglong, |
| 185 | pub rbp: c_ulonglong, |
| 186 | pub rbx: c_ulonglong, |
| 187 | pub r11: c_ulonglong, |
| 188 | pub r10: c_ulonglong, |
| 189 | pub r9: c_ulonglong, |
| 190 | pub r8: c_ulonglong, |
| 191 | pub rax: c_ulonglong, |
| 192 | pub rcx: c_ulonglong, |
| 193 | pub rdx: c_ulonglong, |
| 194 | pub rsi: c_ulonglong, |
| 195 | pub rdi: c_ulonglong, |
| 196 | pub orig_rax: c_ulonglong, |
| 197 | pub rip: c_ulonglong, |
| 198 | pub cs: c_ulonglong, |
| 199 | pub eflags: c_ulonglong, |
| 200 | pub rsp: c_ulonglong, |
| 201 | pub ss: c_ulonglong, |
| 202 | pub fs_base: c_ulonglong, |
| 203 | pub gs_base: c_ulonglong, |
| 204 | pub ds: c_ulonglong, |
| 205 | pub es: c_ulonglong, |
| 206 | pub fs: c_ulonglong, |
| 207 | pub gs: c_ulonglong, |
| 208 | } |
| 209 | |
| 210 | pub struct user { |
| 211 | pub regs: user_regs_struct, |
| 212 | pub u_fpvalid: c_int, |
| 213 | pub i387: user_fpregs_struct, |
| 214 | pub u_tsize: c_ulonglong, |
| 215 | pub u_dsize: c_ulonglong, |
| 216 | pub u_ssize: c_ulonglong, |
| 217 | pub start_code: c_ulonglong, |
| 218 | pub start_stack: c_ulonglong, |
| 219 | pub signal: c_longlong, |
| 220 | __reserved: c_int, |
| 221 | #[cfg (target_pointer_width = "32" )] |
| 222 | __pad1: u32, |
| 223 | pub u_ar0: *mut user_regs_struct, |
| 224 | #[cfg (target_pointer_width = "32" )] |
| 225 | __pad2: u32, |
| 226 | pub u_fpstate: *mut user_fpregs_struct, |
| 227 | pub magic: c_ulonglong, |
| 228 | pub u_comm: [c_char; 32], |
| 229 | pub u_debugreg: [c_ulonglong; 8], |
| 230 | } |
| 231 | |
| 232 | pub struct mcontext_t { |
| 233 | pub gregs: [greg_t; 23], |
| 234 | pub fpregs: *mut _libc_fpstate, |
| 235 | __private: [u64; 8], |
| 236 | } |
| 237 | |
| 238 | pub struct ipc_perm { |
| 239 | pub __key: crate::key_t, |
| 240 | pub uid: crate::uid_t, |
| 241 | pub gid: crate::gid_t, |
| 242 | pub cuid: crate::uid_t, |
| 243 | pub cgid: crate::gid_t, |
| 244 | pub mode: c_ushort, |
| 245 | __pad1: c_ushort, |
| 246 | pub __seq: c_ushort, |
| 247 | __pad2: c_ushort, |
| 248 | __unused1: u64, |
| 249 | __unused2: u64, |
| 250 | } |
| 251 | |
| 252 | pub struct shmid_ds { |
| 253 | pub shm_perm: crate::ipc_perm, |
| 254 | pub shm_segsz: size_t, |
| 255 | pub shm_atime: crate::time_t, |
| 256 | pub shm_dtime: crate::time_t, |
| 257 | pub shm_ctime: crate::time_t, |
| 258 | pub shm_cpid: crate::pid_t, |
| 259 | pub shm_lpid: crate::pid_t, |
| 260 | pub shm_nattch: crate::shmatt_t, |
| 261 | __unused4: u64, |
| 262 | __unused5: u64, |
| 263 | } |
| 264 | |
| 265 | pub struct ptrace_rseq_configuration { |
| 266 | pub rseq_abi_pointer: crate::__u64, |
| 267 | pub rseq_abi_size: crate::__u32, |
| 268 | pub signature: crate::__u32, |
| 269 | pub flags: crate::__u32, |
| 270 | pub pad: crate::__u32, |
| 271 | } |
| 272 | |
| 273 | #[repr (align(8))] |
| 274 | pub struct clone_args { |
| 275 | pub flags: c_ulonglong, |
| 276 | pub pidfd: c_ulonglong, |
| 277 | pub child_tid: c_ulonglong, |
| 278 | pub parent_tid: c_ulonglong, |
| 279 | pub exit_signal: c_ulonglong, |
| 280 | pub stack: c_ulonglong, |
| 281 | pub stack_size: c_ulonglong, |
| 282 | pub tls: c_ulonglong, |
| 283 | pub set_tid: c_ulonglong, |
| 284 | pub set_tid_size: c_ulonglong, |
| 285 | pub cgroup: c_ulonglong, |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | s_no_extra_traits! { |
| 290 | pub struct user_fpregs_struct { |
| 291 | pub cwd: c_ushort, |
| 292 | pub swd: c_ushort, |
| 293 | pub ftw: c_ushort, |
| 294 | pub fop: c_ushort, |
| 295 | pub rip: c_ulonglong, |
| 296 | pub rdp: c_ulonglong, |
| 297 | pub mxcsr: c_uint, |
| 298 | pub mxcr_mask: c_uint, |
| 299 | pub st_space: [c_uint; 32], |
| 300 | pub xmm_space: [c_uint; 64], |
| 301 | padding: [c_uint; 24], |
| 302 | } |
| 303 | |
| 304 | pub struct ucontext_t { |
| 305 | pub uc_flags: c_ulong, |
| 306 | pub uc_link: *mut ucontext_t, |
| 307 | pub uc_stack: crate::stack_t, |
| 308 | pub uc_mcontext: mcontext_t, |
| 309 | pub uc_sigmask: crate::sigset_t, |
| 310 | __private: [u8; 512], |
| 311 | // FIXME(glibc): the shadow stack field requires glibc >= 2.28. |
| 312 | // Re-add once we drop compatibility with glibc versions older than |
| 313 | // 2.28. |
| 314 | // |
| 315 | // __ssp: [c_ulonglong; 4], |
| 316 | } |
| 317 | |
| 318 | #[allow (missing_debug_implementations)] |
| 319 | #[repr (align(16))] |
| 320 | pub struct max_align_t { |
| 321 | priv_: [f64; 4], |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | cfg_if! { |
| 326 | if #[cfg(feature = "extra_traits" )] { |
| 327 | impl PartialEq for user_fpregs_struct { |
| 328 | fn eq(&self, other: &user_fpregs_struct) -> bool { |
| 329 | self.cwd == other.cwd |
| 330 | && self.swd == other.swd |
| 331 | && self.ftw == other.ftw |
| 332 | && self.fop == other.fop |
| 333 | && self.rip == other.rip |
| 334 | && self.rdp == other.rdp |
| 335 | && self.mxcsr == other.mxcsr |
| 336 | && self.mxcr_mask == other.mxcr_mask |
| 337 | && self.st_space == other.st_space |
| 338 | && self |
| 339 | .xmm_space |
| 340 | .iter() |
| 341 | .zip(other.xmm_space.iter()) |
| 342 | .all(|(a, b)| a == b) |
| 343 | // Ignore padding field |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | impl Eq for user_fpregs_struct {} |
| 348 | |
| 349 | impl fmt::Debug for user_fpregs_struct { |
| 350 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 351 | f.debug_struct("user_fpregs_struct" ) |
| 352 | .field("cwd" , &self.cwd) |
| 353 | .field("ftw" , &self.ftw) |
| 354 | .field("fop" , &self.fop) |
| 355 | .field("rip" , &self.rip) |
| 356 | .field("rdp" , &self.rdp) |
| 357 | .field("mxcsr" , &self.mxcsr) |
| 358 | .field("mxcr_mask" , &self.mxcr_mask) |
| 359 | .field("st_space" , &self.st_space) |
| 360 | // FIXME(debug): .field("xmm_space", &self.xmm_space) |
| 361 | // Ignore padding field |
| 362 | .finish() |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | impl hash::Hash for user_fpregs_struct { |
| 367 | fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 368 | self.cwd.hash(state); |
| 369 | self.ftw.hash(state); |
| 370 | self.fop.hash(state); |
| 371 | self.rip.hash(state); |
| 372 | self.rdp.hash(state); |
| 373 | self.mxcsr.hash(state); |
| 374 | self.mxcr_mask.hash(state); |
| 375 | self.st_space.hash(state); |
| 376 | self.xmm_space.hash(state); |
| 377 | // Ignore padding field |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | impl PartialEq for ucontext_t { |
| 382 | fn eq(&self, other: &ucontext_t) -> bool { |
| 383 | self.uc_flags == other.uc_flags |
| 384 | && self.uc_link == other.uc_link |
| 385 | && self.uc_stack == other.uc_stack |
| 386 | && self.uc_mcontext == other.uc_mcontext |
| 387 | && self.uc_sigmask == other.uc_sigmask |
| 388 | // Ignore __private field |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | impl Eq for ucontext_t {} |
| 393 | |
| 394 | impl fmt::Debug for ucontext_t { |
| 395 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 396 | f.debug_struct("ucontext_t" ) |
| 397 | .field("uc_flags" , &self.uc_flags) |
| 398 | .field("uc_link" , &self.uc_link) |
| 399 | .field("uc_stack" , &self.uc_stack) |
| 400 | .field("uc_mcontext" , &self.uc_mcontext) |
| 401 | .field("uc_sigmask" , &self.uc_sigmask) |
| 402 | // Ignore __private field |
| 403 | .finish() |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | impl hash::Hash for ucontext_t { |
| 408 | fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 409 | self.uc_flags.hash(state); |
| 410 | self.uc_link.hash(state); |
| 411 | self.uc_stack.hash(state); |
| 412 | self.uc_mcontext.hash(state); |
| 413 | self.uc_sigmask.hash(state); |
| 414 | // Ignore __private field |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | pub const POSIX_FADV_DONTNEED: c_int = 4; |
| 421 | pub const POSIX_FADV_NOREUSE: c_int = 5; |
| 422 | |
| 423 | pub const VEOF: usize = 4; |
| 424 | pub const RTLD_DEEPBIND: c_int = 0x8; |
| 425 | pub const RTLD_GLOBAL: c_int = 0x100; |
| 426 | pub const RTLD_NOLOAD: c_int = 0x4; |
| 427 | |
| 428 | pub const O_APPEND: c_int = 1024; |
| 429 | pub const O_CREAT: c_int = 64; |
| 430 | pub const O_EXCL: c_int = 128; |
| 431 | pub const O_NOCTTY: c_int = 256; |
| 432 | pub const O_NONBLOCK: c_int = 2048; |
| 433 | pub const O_SYNC: c_int = 1052672; |
| 434 | pub const O_RSYNC: c_int = 1052672; |
| 435 | pub const O_DSYNC: c_int = 4096; |
| 436 | pub const O_FSYNC: c_int = 0x101000; |
| 437 | pub const O_NOATIME: c_int = 0o1000000; |
| 438 | pub const O_PATH: c_int = 0o10000000; |
| 439 | pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; |
| 440 | |
| 441 | pub const MADV_SOFT_OFFLINE: c_int = 101; |
| 442 | pub const MAP_GROWSDOWN: c_int = 0x0100; |
| 443 | |
| 444 | pub const EDEADLK: c_int = 35; |
| 445 | pub const ENAMETOOLONG: c_int = 36; |
| 446 | pub const ENOLCK: c_int = 37; |
| 447 | pub const ENOSYS: c_int = 38; |
| 448 | pub const ENOTEMPTY: c_int = 39; |
| 449 | pub const ELOOP: c_int = 40; |
| 450 | pub const ENOMSG: c_int = 42; |
| 451 | pub const EIDRM: c_int = 43; |
| 452 | pub const ECHRNG: c_int = 44; |
| 453 | pub const EL2NSYNC: c_int = 45; |
| 454 | pub const EL3HLT: c_int = 46; |
| 455 | pub const EL3RST: c_int = 47; |
| 456 | pub const ELNRNG: c_int = 48; |
| 457 | pub const EUNATCH: c_int = 49; |
| 458 | pub const ENOCSI: c_int = 50; |
| 459 | pub const EL2HLT: c_int = 51; |
| 460 | pub const EBADE: c_int = 52; |
| 461 | pub const EBADR: c_int = 53; |
| 462 | pub const EXFULL: c_int = 54; |
| 463 | pub const ENOANO: c_int = 55; |
| 464 | pub const EBADRQC: c_int = 56; |
| 465 | pub const EBADSLT: c_int = 57; |
| 466 | pub const EMULTIHOP: c_int = 72; |
| 467 | pub const EOVERFLOW: c_int = 75; |
| 468 | pub const ENOTUNIQ: c_int = 76; |
| 469 | pub const EBADFD: c_int = 77; |
| 470 | pub const EBADMSG: c_int = 74; |
| 471 | pub const EREMCHG: c_int = 78; |
| 472 | pub const ELIBACC: c_int = 79; |
| 473 | pub const ELIBBAD: c_int = 80; |
| 474 | pub const ELIBSCN: c_int = 81; |
| 475 | pub const ELIBMAX: c_int = 82; |
| 476 | pub const ELIBEXEC: c_int = 83; |
| 477 | pub const EILSEQ: c_int = 84; |
| 478 | pub const ERESTART: c_int = 85; |
| 479 | pub const ESTRPIPE: c_int = 86; |
| 480 | pub const EUSERS: c_int = 87; |
| 481 | pub const ENOTSOCK: c_int = 88; |
| 482 | pub const EDESTADDRREQ: c_int = 89; |
| 483 | pub const EMSGSIZE: c_int = 90; |
| 484 | pub const EPROTOTYPE: c_int = 91; |
| 485 | pub const ENOPROTOOPT: c_int = 92; |
| 486 | pub const EPROTONOSUPPORT: c_int = 93; |
| 487 | pub const ESOCKTNOSUPPORT: c_int = 94; |
| 488 | pub const EOPNOTSUPP: c_int = 95; |
| 489 | pub const EPFNOSUPPORT: c_int = 96; |
| 490 | pub const EAFNOSUPPORT: c_int = 97; |
| 491 | pub const EADDRINUSE: c_int = 98; |
| 492 | pub const EADDRNOTAVAIL: c_int = 99; |
| 493 | pub const ENETDOWN: c_int = 100; |
| 494 | pub const ENETUNREACH: c_int = 101; |
| 495 | pub const ENETRESET: c_int = 102; |
| 496 | pub const ECONNABORTED: c_int = 103; |
| 497 | pub const ECONNRESET: c_int = 104; |
| 498 | pub const ENOBUFS: c_int = 105; |
| 499 | pub const EISCONN: c_int = 106; |
| 500 | pub const ENOTCONN: c_int = 107; |
| 501 | pub const ESHUTDOWN: c_int = 108; |
| 502 | pub const ETOOMANYREFS: c_int = 109; |
| 503 | pub const ETIMEDOUT: c_int = 110; |
| 504 | pub const ECONNREFUSED: c_int = 111; |
| 505 | pub const EHOSTDOWN: c_int = 112; |
| 506 | pub const EHOSTUNREACH: c_int = 113; |
| 507 | pub const EALREADY: c_int = 114; |
| 508 | pub const EINPROGRESS: c_int = 115; |
| 509 | pub const ESTALE: c_int = 116; |
| 510 | pub const EDQUOT: c_int = 122; |
| 511 | pub const ENOMEDIUM: c_int = 123; |
| 512 | pub const EMEDIUMTYPE: c_int = 124; |
| 513 | pub const ECANCELED: c_int = 125; |
| 514 | pub const ENOKEY: c_int = 126; |
| 515 | pub const EKEYEXPIRED: c_int = 127; |
| 516 | pub const EKEYREVOKED: c_int = 128; |
| 517 | pub const EKEYREJECTED: c_int = 129; |
| 518 | pub const EOWNERDEAD: c_int = 130; |
| 519 | pub const ENOTRECOVERABLE: c_int = 131; |
| 520 | pub const EHWPOISON: c_int = 133; |
| 521 | pub const ERFKILL: c_int = 132; |
| 522 | |
| 523 | pub const SOCK_STREAM: c_int = 1; |
| 524 | pub const SOCK_DGRAM: c_int = 2; |
| 525 | |
| 526 | pub const SA_ONSTACK: c_int = 0x08000000; |
| 527 | pub const SA_SIGINFO: c_int = 0x00000004; |
| 528 | pub const SA_NOCLDWAIT: c_int = 0x00000002; |
| 529 | |
| 530 | pub const SIGTTIN: c_int = 21; |
| 531 | pub const SIGTTOU: c_int = 22; |
| 532 | pub const SIGXCPU: c_int = 24; |
| 533 | pub const SIGXFSZ: c_int = 25; |
| 534 | pub const SIGVTALRM: c_int = 26; |
| 535 | pub const SIGPROF: c_int = 27; |
| 536 | pub const SIGWINCH: c_int = 28; |
| 537 | pub const SIGCHLD: c_int = 17; |
| 538 | pub const SIGBUS: c_int = 7; |
| 539 | pub const SIGUSR1: c_int = 10; |
| 540 | pub const SIGUSR2: c_int = 12; |
| 541 | pub const SIGCONT: c_int = 18; |
| 542 | pub const SIGSTOP: c_int = 19; |
| 543 | pub const SIGTSTP: c_int = 20; |
| 544 | pub const SIGURG: c_int = 23; |
| 545 | pub const SIGIO: c_int = 29; |
| 546 | pub const SIGSYS: c_int = 31; |
| 547 | pub const SIGSTKFLT: c_int = 16; |
| 548 | #[deprecated (since = "0.2.55" , note = "Use SIGSYS instead" )] |
| 549 | pub const SIGUNUSED: c_int = 31; |
| 550 | pub const SIGPOLL: c_int = 29; |
| 551 | pub const SIGPWR: c_int = 30; |
| 552 | pub const SIG_SETMASK: c_int = 2; |
| 553 | pub const SIG_BLOCK: c_int = 0x000000; |
| 554 | pub const SIG_UNBLOCK: c_int = 0x01; |
| 555 | |
| 556 | pub const POLLWRNORM: c_short = 0x100; |
| 557 | pub const POLLWRBAND: c_short = 0x200; |
| 558 | |
| 559 | pub const O_ASYNC: c_int = 0x2000; |
| 560 | pub const O_NDELAY: c_int = 0x800; |
| 561 | |
| 562 | pub const PTRACE_DETACH: c_uint = 17; |
| 563 | pub const PTRACE_GET_RSEQ_CONFIGURATION: c_uint = 0x420f; |
| 564 | |
| 565 | pub const EFD_NONBLOCK: c_int = 0x800; |
| 566 | |
| 567 | pub const F_GETLK: c_int = 5; |
| 568 | pub const F_GETOWN: c_int = 9; |
| 569 | pub const F_SETOWN: c_int = 8; |
| 570 | pub const F_SETLK: c_int = 6; |
| 571 | pub const F_SETLKW: c_int = 7; |
| 572 | pub const F_OFD_GETLK: c_int = 36; |
| 573 | pub const F_OFD_SETLK: c_int = 37; |
| 574 | pub const F_OFD_SETLKW: c_int = 38; |
| 575 | |
| 576 | pub const F_RDLCK: c_int = 0; |
| 577 | pub const F_WRLCK: c_int = 1; |
| 578 | pub const F_UNLCK: c_int = 2; |
| 579 | |
| 580 | pub const SFD_NONBLOCK: c_int = 0x0800; |
| 581 | |
| 582 | pub const TCSANOW: c_int = 0; |
| 583 | pub const TCSADRAIN: c_int = 1; |
| 584 | pub const TCSAFLUSH: c_int = 2; |
| 585 | |
| 586 | pub const SFD_CLOEXEC: c_int = 0x080000; |
| 587 | |
| 588 | pub const NCCS: usize = 32; |
| 589 | |
| 590 | pub const O_TRUNC: c_int = 512; |
| 591 | |
| 592 | pub const O_CLOEXEC: c_int = 0x80000; |
| 593 | |
| 594 | pub const EBFONT: c_int = 59; |
| 595 | pub const ENOSTR: c_int = 60; |
| 596 | pub const ENODATA: c_int = 61; |
| 597 | pub const ETIME: c_int = 62; |
| 598 | pub const ENOSR: c_int = 63; |
| 599 | pub const ENONET: c_int = 64; |
| 600 | pub const ENOPKG: c_int = 65; |
| 601 | pub const EREMOTE: c_int = 66; |
| 602 | pub const ENOLINK: c_int = 67; |
| 603 | pub const EADV: c_int = 68; |
| 604 | pub const ESRMNT: c_int = 69; |
| 605 | pub const ECOMM: c_int = 70; |
| 606 | pub const EPROTO: c_int = 71; |
| 607 | pub const EDOTDOT: c_int = 73; |
| 608 | |
| 609 | pub const SA_NODEFER: c_int = 0x40000000; |
| 610 | pub const SA_RESETHAND: c_int = 0x80000000; |
| 611 | pub const SA_RESTART: c_int = 0x10000000; |
| 612 | pub const SA_NOCLDSTOP: c_int = 0x00000001; |
| 613 | |
| 614 | pub const EPOLL_CLOEXEC: c_int = 0x80000; |
| 615 | |
| 616 | pub const EFD_CLOEXEC: c_int = 0x80000; |
| 617 | |
| 618 | pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; |
| 619 | pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; |
| 620 | pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; |
| 621 | |
| 622 | pub const O_DIRECT: c_int = 0x4000; |
| 623 | pub const O_DIRECTORY: c_int = 0x10000; |
| 624 | pub const O_NOFOLLOW: c_int = 0x20000; |
| 625 | |
| 626 | pub const MAP_HUGETLB: c_int = 0x040000; |
| 627 | pub const MAP_LOCKED: c_int = 0x02000; |
| 628 | pub const MAP_NORESERVE: c_int = 0x04000; |
| 629 | pub const MAP_32BIT: c_int = 0x0040; |
| 630 | pub const MAP_ANON: c_int = 0x0020; |
| 631 | pub const MAP_ANONYMOUS: c_int = 0x0020; |
| 632 | pub const MAP_DENYWRITE: c_int = 0x0800; |
| 633 | pub const MAP_EXECUTABLE: c_int = 0x01000; |
| 634 | pub const MAP_POPULATE: c_int = 0x08000; |
| 635 | pub const MAP_NONBLOCK: c_int = 0x010000; |
| 636 | pub const MAP_STACK: c_int = 0x020000; |
| 637 | pub const MAP_SYNC: c_int = 0x080000; |
| 638 | |
| 639 | pub const EDEADLOCK: c_int = 35; |
| 640 | pub const EUCLEAN: c_int = 117; |
| 641 | pub const ENOTNAM: c_int = 118; |
| 642 | pub const ENAVAIL: c_int = 119; |
| 643 | pub const EISNAM: c_int = 120; |
| 644 | pub const EREMOTEIO: c_int = 121; |
| 645 | |
| 646 | pub const PTRACE_GETFPREGS: c_uint = 14; |
| 647 | pub const PTRACE_SETFPREGS: c_uint = 15; |
| 648 | pub const PTRACE_GETFPXREGS: c_uint = 18; |
| 649 | pub const PTRACE_SETFPXREGS: c_uint = 19; |
| 650 | pub const PTRACE_GETREGS: c_uint = 12; |
| 651 | pub const PTRACE_SETREGS: c_uint = 13; |
| 652 | pub const PTRACE_PEEKSIGINFO_SHARED: c_uint = 1; |
| 653 | pub const PTRACE_SYSEMU: c_uint = 31; |
| 654 | pub const PTRACE_SYSEMU_SINGLESTEP: c_uint = 32; |
| 655 | |
| 656 | pub const PR_GET_SPECULATION_CTRL: c_int = 52; |
| 657 | pub const PR_SET_SPECULATION_CTRL: c_int = 53; |
| 658 | pub const PR_SPEC_NOT_AFFECTED: c_uint = 0; |
| 659 | pub const PR_SPEC_PRCTL: c_uint = 1 << 0; |
| 660 | pub const PR_SPEC_ENABLE: c_uint = 1 << 1; |
| 661 | pub const PR_SPEC_DISABLE: c_uint = 1 << 2; |
| 662 | pub const PR_SPEC_FORCE_DISABLE: c_uint = 1 << 3; |
| 663 | pub const PR_SPEC_DISABLE_NOEXEC: c_uint = 1 << 4; |
| 664 | pub const PR_SPEC_STORE_BYPASS: c_int = 0; |
| 665 | pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; |
| 666 | // FIXME(linux): perharps for later |
| 667 | //pub const PR_SPEC_L1D_FLUSH: c_int = 2; |
| 668 | |
| 669 | pub const MCL_CURRENT: c_int = 0x0001; |
| 670 | pub const MCL_FUTURE: c_int = 0x0002; |
| 671 | pub const MCL_ONFAULT: c_int = 0x0004; |
| 672 | |
| 673 | pub const SIGSTKSZ: size_t = 8192; |
| 674 | pub const MINSIGSTKSZ: size_t = 2048; |
| 675 | pub const CBAUD: crate::tcflag_t = 0o0010017; |
| 676 | pub const TAB1: crate::tcflag_t = 0x00000800; |
| 677 | pub const TAB2: crate::tcflag_t = 0x00001000; |
| 678 | pub const TAB3: crate::tcflag_t = 0x00001800; |
| 679 | pub const CR1: crate::tcflag_t = 0x00000200; |
| 680 | pub const CR2: crate::tcflag_t = 0x00000400; |
| 681 | pub const CR3: crate::tcflag_t = 0x00000600; |
| 682 | pub const FF1: crate::tcflag_t = 0x00008000; |
| 683 | pub const BS1: crate::tcflag_t = 0x00002000; |
| 684 | pub const VT1: crate::tcflag_t = 0x00004000; |
| 685 | pub const VWERASE: usize = 14; |
| 686 | pub const VREPRINT: usize = 12; |
| 687 | pub const VSUSP: usize = 10; |
| 688 | pub const VSTART: usize = 8; |
| 689 | pub const VSTOP: usize = 9; |
| 690 | pub const VDISCARD: usize = 13; |
| 691 | pub const VTIME: usize = 5; |
| 692 | pub const IXON: crate::tcflag_t = 0x00000400; |
| 693 | pub const IXOFF: crate::tcflag_t = 0x00001000; |
| 694 | pub const ONLCR: crate::tcflag_t = 0x4; |
| 695 | pub const CSIZE: crate::tcflag_t = 0x00000030; |
| 696 | pub const CS6: crate::tcflag_t = 0x00000010; |
| 697 | pub const CS7: crate::tcflag_t = 0x00000020; |
| 698 | pub const CS8: crate::tcflag_t = 0x00000030; |
| 699 | pub const CSTOPB: crate::tcflag_t = 0x00000040; |
| 700 | pub const CREAD: crate::tcflag_t = 0x00000080; |
| 701 | pub const PARENB: crate::tcflag_t = 0x00000100; |
| 702 | pub const PARODD: crate::tcflag_t = 0x00000200; |
| 703 | pub const HUPCL: crate::tcflag_t = 0x00000400; |
| 704 | pub const CLOCAL: crate::tcflag_t = 0x00000800; |
| 705 | pub const ECHOKE: crate::tcflag_t = 0x00000800; |
| 706 | pub const ECHOE: crate::tcflag_t = 0x00000010; |
| 707 | pub const ECHOK: crate::tcflag_t = 0x00000020; |
| 708 | pub const ECHONL: crate::tcflag_t = 0x00000040; |
| 709 | pub const ECHOPRT: crate::tcflag_t = 0x00000400; |
| 710 | pub const ECHOCTL: crate::tcflag_t = 0x00000200; |
| 711 | pub const ISIG: crate::tcflag_t = 0x00000001; |
| 712 | pub const ICANON: crate::tcflag_t = 0x00000002; |
| 713 | pub const PENDIN: crate::tcflag_t = 0x00004000; |
| 714 | pub const NOFLSH: crate::tcflag_t = 0x00000080; |
| 715 | pub const CIBAUD: crate::tcflag_t = 0o02003600000; |
| 716 | pub const CBAUDEX: crate::tcflag_t = 0o010000; |
| 717 | pub const VSWTC: usize = 7; |
| 718 | pub const OLCUC: crate::tcflag_t = 0o000002; |
| 719 | pub const NLDLY: crate::tcflag_t = 0o000400; |
| 720 | pub const CRDLY: crate::tcflag_t = 0o003000; |
| 721 | pub const TABDLY: crate::tcflag_t = 0o014000; |
| 722 | pub const BSDLY: crate::tcflag_t = 0o020000; |
| 723 | pub const FFDLY: crate::tcflag_t = 0o100000; |
| 724 | pub const VTDLY: crate::tcflag_t = 0o040000; |
| 725 | pub const XTABS: crate::tcflag_t = 0o014000; |
| 726 | |
| 727 | pub const B0: crate::speed_t = 0o000000; |
| 728 | pub const B50: crate::speed_t = 0o000001; |
| 729 | pub const B75: crate::speed_t = 0o000002; |
| 730 | pub const B110: crate::speed_t = 0o000003; |
| 731 | pub const B134: crate::speed_t = 0o000004; |
| 732 | pub const B150: crate::speed_t = 0o000005; |
| 733 | pub const B200: crate::speed_t = 0o000006; |
| 734 | pub const B300: crate::speed_t = 0o000007; |
| 735 | pub const B600: crate::speed_t = 0o000010; |
| 736 | pub const B1200: crate::speed_t = 0o000011; |
| 737 | pub const B1800: crate::speed_t = 0o000012; |
| 738 | pub const B2400: crate::speed_t = 0o000013; |
| 739 | pub const B4800: crate::speed_t = 0o000014; |
| 740 | pub const B9600: crate::speed_t = 0o000015; |
| 741 | pub const B19200: crate::speed_t = 0o000016; |
| 742 | pub const B38400: crate::speed_t = 0o000017; |
| 743 | pub const EXTA: crate::speed_t = B19200; |
| 744 | pub const EXTB: crate::speed_t = B38400; |
| 745 | pub const B57600: crate::speed_t = 0o010001; |
| 746 | pub const B115200: crate::speed_t = 0o010002; |
| 747 | pub const B230400: crate::speed_t = 0o010003; |
| 748 | pub const B460800: crate::speed_t = 0o010004; |
| 749 | pub const B500000: crate::speed_t = 0o010005; |
| 750 | pub const B576000: crate::speed_t = 0o010006; |
| 751 | pub const B921600: crate::speed_t = 0o010007; |
| 752 | pub const B1000000: crate::speed_t = 0o010010; |
| 753 | pub const B1152000: crate::speed_t = 0o010011; |
| 754 | pub const B1500000: crate::speed_t = 0o010012; |
| 755 | pub const B2000000: crate::speed_t = 0o010013; |
| 756 | pub const B2500000: crate::speed_t = 0o010014; |
| 757 | pub const B3000000: crate::speed_t = 0o010015; |
| 758 | pub const B3500000: crate::speed_t = 0o010016; |
| 759 | pub const B4000000: crate::speed_t = 0o010017; |
| 760 | |
| 761 | pub const VEOL: usize = 11; |
| 762 | pub const VEOL2: usize = 16; |
| 763 | pub const VMIN: usize = 6; |
| 764 | pub const IEXTEN: crate::tcflag_t = 0x00008000; |
| 765 | pub const TOSTOP: crate::tcflag_t = 0x00000100; |
| 766 | pub const FLUSHO: crate::tcflag_t = 0x00001000; |
| 767 | pub const EXTPROC: crate::tcflag_t = 0x00010000; |
| 768 | |
| 769 | // offsets in user_regs_structs, from sys/reg.h |
| 770 | pub const R15: c_int = 0; |
| 771 | pub const R14: c_int = 1; |
| 772 | pub const R13: c_int = 2; |
| 773 | pub const R12: c_int = 3; |
| 774 | pub const RBP: c_int = 4; |
| 775 | pub const RBX: c_int = 5; |
| 776 | pub const R11: c_int = 6; |
| 777 | pub const R10: c_int = 7; |
| 778 | pub const R9: c_int = 8; |
| 779 | pub const R8: c_int = 9; |
| 780 | pub const RAX: c_int = 10; |
| 781 | pub const RCX: c_int = 11; |
| 782 | pub const RDX: c_int = 12; |
| 783 | pub const RSI: c_int = 13; |
| 784 | pub const RDI: c_int = 14; |
| 785 | pub const ORIG_RAX: c_int = 15; |
| 786 | pub const RIP: c_int = 16; |
| 787 | pub const CS: c_int = 17; |
| 788 | pub const EFLAGS: c_int = 18; |
| 789 | pub const RSP: c_int = 19; |
| 790 | pub const SS: c_int = 20; |
| 791 | pub const FS_BASE: c_int = 21; |
| 792 | pub const GS_BASE: c_int = 22; |
| 793 | pub const DS: c_int = 23; |
| 794 | pub const ES: c_int = 24; |
| 795 | pub const FS: c_int = 25; |
| 796 | pub const GS: c_int = 26; |
| 797 | |
| 798 | // offsets in mcontext_t.gregs from sys/ucontext.h |
| 799 | pub const REG_R8: c_int = 0; |
| 800 | pub const REG_R9: c_int = 1; |
| 801 | pub const REG_R10: c_int = 2; |
| 802 | pub const REG_R11: c_int = 3; |
| 803 | pub const REG_R12: c_int = 4; |
| 804 | pub const REG_R13: c_int = 5; |
| 805 | pub const REG_R14: c_int = 6; |
| 806 | pub const REG_R15: c_int = 7; |
| 807 | pub const REG_RDI: c_int = 8; |
| 808 | pub const REG_RSI: c_int = 9; |
| 809 | pub const REG_RBP: c_int = 10; |
| 810 | pub const REG_RBX: c_int = 11; |
| 811 | pub const REG_RDX: c_int = 12; |
| 812 | pub const REG_RAX: c_int = 13; |
| 813 | pub const REG_RCX: c_int = 14; |
| 814 | pub const REG_RSP: c_int = 15; |
| 815 | pub const REG_RIP: c_int = 16; |
| 816 | pub const REG_EFL: c_int = 17; |
| 817 | pub const REG_CSGSFS: c_int = 18; |
| 818 | pub const REG_ERR: c_int = 19; |
| 819 | pub const REG_TRAPNO: c_int = 20; |
| 820 | pub const REG_OLDMASK: c_int = 21; |
| 821 | pub const REG_CR2: c_int = 22; |
| 822 | |
| 823 | unsafeextern "C" { |
| 824 | pub unsafefn getcontext(ucp: *mut ucontext_t) -> c_int; |
| 825 | pub unsafefn setcontext(ucp: *const ucontext_t) -> c_int; |
| 826 | pub unsafefn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); |
| 827 | pub unsafefn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; |
| 828 | } |
| 829 | |
| 830 | cfg_if! { |
| 831 | if #[cfg(target_pointer_width = "32" )] { |
| 832 | mod x32; |
| 833 | pub use self::x32::*; |
| 834 | } else { |
| 835 | mod not_x32; |
| 836 | pub use self::not_x32::*; |
| 837 | } |
| 838 | } |
| 839 | |