1pub type rlim_t = ::uintptr_t; 2pub type sa_family_t = u8; 3pub type pthread_key_t = ::c_int; 4pub type nfds_t = ::c_ulong; 5pub type tcflag_t = ::c_uint; 6pub type speed_t = ::c_uchar; 7pub type c_char = i8; 8pub type clock_t = i32; 9pub type clockid_t = i32; 10pub type suseconds_t = i32; 11pub type wchar_t = i32; 12pub type off_t = i64; 13pub type ino_t = i64; 14pub type blkcnt_t = i64; 15pub type blksize_t = i32; 16pub type dev_t = i32; 17pub type mode_t = u32; 18pub type nlink_t = i32; 19pub type useconds_t = u32; 20pub type socklen_t = u32; 21pub type pthread_t = ::uintptr_t; 22pub type pthread_condattr_t = ::uintptr_t; 23pub type pthread_mutexattr_t = ::uintptr_t; 24pub type pthread_rwlockattr_t = ::uintptr_t; 25pub type sigset_t = u64; 26pub type fsblkcnt_t = i64; 27pub type fsfilcnt_t = i64; 28pub type pthread_attr_t = *mut ::c_void; 29pub type nl_item = ::c_int; 30pub type id_t = i32; 31pub type idtype_t = ::c_int; 32pub type fd_mask = u32; 33pub type regoff_t = ::c_int; 34pub type key_t = i32; 35pub type msgqnum_t = u32; 36pub type msglen_t = u32; 37 38pub type Elf32_Addr = u32; 39pub type Elf32_Half = u16; 40pub type Elf32_Off = u32; 41pub type Elf32_Sword = i32; 42pub type Elf32_Word = u32; 43 44pub type Elf64_Addr = u64; 45pub type Elf64_Half = u16; 46pub type Elf64_Off = u64; 47pub type Elf64_Sword = i32; 48pub type Elf64_Sxword = i64; 49pub type Elf64_Word = u32; 50pub type Elf64_Xword = u64; 51 52pub type ENTRY = entry; 53pub type ACTION = ::c_int; 54 55pub type posix_spawnattr_t = *mut ::c_void; 56pub type posix_spawn_file_actions_t = *mut ::c_void; 57 58#[cfg_attr(feature = "extra_traits", derive(Debug))] 59pub enum timezone {} 60impl ::Copy for timezone {} 61impl ::Clone for timezone { 62 fn clone(&self) -> timezone { 63 *self 64 } 65} 66 67impl siginfo_t { 68 pub unsafe fn si_addr(&self) -> *mut ::c_void { 69 self.si_addr 70 } 71 72 pub unsafe fn si_pid(&self) -> ::pid_t { 73 self.si_pid 74 } 75 76 pub unsafe fn si_uid(&self) -> ::uid_t { 77 self.si_uid 78 } 79 80 pub unsafe fn si_status(&self) -> ::c_int { 81 self.si_status 82 } 83} 84 85s! { 86 pub struct in_addr { 87 pub s_addr: ::in_addr_t, 88 } 89 90 pub struct ip_mreq { 91 pub imr_multiaddr: in_addr, 92 pub imr_interface: in_addr, 93 } 94 95 pub struct sockaddr { 96 pub sa_len: u8, 97 pub sa_family: sa_family_t, 98 pub sa_data: [u8; 30], 99 } 100 101 pub struct sockaddr_in { 102 pub sin_len: u8, 103 pub sin_family: sa_family_t, 104 pub sin_port: ::in_port_t, 105 pub sin_addr: ::in_addr, 106 pub sin_zero: [i8; 24], 107 } 108 109 pub struct sockaddr_in6 { 110 pub sin6_len: u8, 111 pub sin6_family: u8, 112 pub sin6_port: u16, 113 pub sin6_flowinfo: u32, 114 pub sin6_addr: ::in6_addr, 115 pub sin6_scope_id: u32, 116 } 117 118 pub struct addrinfo { 119 pub ai_flags: ::c_int, 120 pub ai_family: ::c_int, 121 pub ai_socktype: ::c_int, 122 pub ai_protocol: ::c_int, 123 pub ai_addrlen: socklen_t, 124 pub ai_canonname: *mut c_char, 125 pub ai_addr: *mut ::sockaddr, 126 pub ai_next: *mut addrinfo, 127 } 128 129 pub struct ifaddrs { 130 pub ifa_next: *mut ifaddrs, 131 pub ifa_name: *const ::c_char, 132 pub ifa_flags: ::c_uint, 133 pub ifa_addr: *mut ::sockaddr, 134 pub ifa_netmask: *mut ::sockaddr, 135 pub ifa_dstaddr: *mut ::sockaddr, 136 pub ifa_data: *mut ::c_void, 137 } 138 139 pub struct fd_set { 140 // size for 1024 bits, and a fd_mask with size u32 141 fds_bits: [fd_mask; 32], 142 } 143 144 pub struct tm { 145 pub tm_sec: ::c_int, 146 pub tm_min: ::c_int, 147 pub tm_hour: ::c_int, 148 pub tm_mday: ::c_int, 149 pub tm_mon: ::c_int, 150 pub tm_year: ::c_int, 151 pub tm_wday: ::c_int, 152 pub tm_yday: ::c_int, 153 pub tm_isdst: ::c_int, 154 pub tm_gmtoff: ::c_int, 155 pub tm_zone: *mut ::c_char, 156 } 157 158 pub struct utsname { 159 pub sysname: [::c_char; 32], 160 pub nodename: [::c_char; 32], 161 pub release: [::c_char; 32], 162 pub version: [::c_char; 32], 163 pub machine: [::c_char; 32], 164 } 165 166 pub struct lconv { 167 pub decimal_point: *mut ::c_char, 168 pub thousands_sep: *mut ::c_char, 169 pub grouping: *mut ::c_char, 170 pub int_curr_symbol: *mut ::c_char, 171 pub currency_symbol: *mut ::c_char, 172 pub mon_decimal_point: *mut ::c_char, 173 pub mon_thousands_sep: *mut ::c_char, 174 pub mon_grouping: *mut ::c_char, 175 pub positive_sign: *mut ::c_char, 176 pub negative_sign: *mut ::c_char, 177 pub int_frac_digits: ::c_char, 178 pub frac_digits: ::c_char, 179 pub p_cs_precedes: ::c_char, 180 pub p_sep_by_space: ::c_char, 181 pub n_cs_precedes: ::c_char, 182 pub n_sep_by_space: ::c_char, 183 pub p_sign_posn: ::c_char, 184 pub n_sign_posn: ::c_char, 185 pub int_p_cs_precedes: ::c_char, 186 pub int_p_sep_by_space: ::c_char, 187 pub int_n_cs_precedes: ::c_char, 188 pub int_n_sep_by_space: ::c_char, 189 pub int_p_sign_posn: ::c_char, 190 pub int_n_sign_posn: ::c_char, 191 } 192 193 pub struct msghdr { 194 pub msg_name: *mut ::c_void, 195 pub msg_namelen: socklen_t, 196 pub msg_iov: *mut ::iovec, 197 pub msg_iovlen: ::c_int, 198 pub msg_control: *mut ::c_void, 199 pub msg_controllen: socklen_t, 200 pub msg_flags: ::c_int, 201 } 202 203 pub struct cmsghdr { 204 pub cmsg_len: ::socklen_t, 205 pub cmsg_level: ::c_int, 206 pub cmsg_type: ::c_int, 207 } 208 209 pub struct Dl_info { 210 pub dli_fname: *const ::c_char, 211 pub dli_fbase: *mut ::c_void, 212 pub dli_sname: *const ::c_char, 213 pub dli_saddr: *mut ::c_void, 214 } 215 216 pub struct termios { 217 pub c_iflag: ::tcflag_t, 218 pub c_oflag: ::tcflag_t, 219 pub c_cflag: ::tcflag_t, 220 pub c_lflag: ::tcflag_t, 221 pub c_line: ::c_char, 222 pub c_ispeed: ::speed_t, 223 pub c_ospeed: ::speed_t, 224 pub c_cc: [::cc_t; ::NCCS], 225 } 226 227 pub struct flock { 228 pub l_type: ::c_short, 229 pub l_whence: ::c_short, 230 pub l_start: ::off_t, 231 pub l_len: ::off_t, 232 pub l_pid: ::pid_t, 233 } 234 235 pub struct stat { 236 pub st_dev: dev_t, 237 pub st_ino: ino_t, 238 pub st_mode: mode_t, 239 pub st_nlink: nlink_t, 240 pub st_uid: ::uid_t, 241 pub st_gid: ::gid_t, 242 pub st_size: off_t, 243 pub st_rdev: dev_t, 244 pub st_blksize: blksize_t, 245 pub st_atime: time_t, 246 pub st_atime_nsec: c_long, 247 pub st_mtime: time_t, 248 pub st_mtime_nsec: c_long, 249 pub st_ctime: time_t, 250 pub st_ctime_nsec: c_long, 251 pub st_crtime: time_t, 252 pub st_crtime_nsec: c_long, 253 pub st_type: u32, 254 pub st_blocks: blkcnt_t, 255 } 256 257 pub struct glob_t { 258 pub gl_pathc: ::size_t, 259 __unused1: ::size_t, 260 pub gl_offs: ::size_t, 261 __unused2: ::size_t, 262 pub gl_pathv: *mut *mut c_char, 263 264 __unused3: *mut ::c_void, 265 __unused4: *mut ::c_void, 266 __unused5: *mut ::c_void, 267 __unused6: *mut ::c_void, 268 __unused7: *mut ::c_void, 269 __unused8: *mut ::c_void, 270 } 271 272 pub struct pthread_mutex_t { 273 flags: u32, 274 lock: i32, 275 unused: i32, 276 owner: i32, 277 owner_count: i32, 278 } 279 280 pub struct pthread_cond_t { 281 flags: u32, 282 unused: i32, 283 mutex: *mut ::c_void, 284 waiter_count: i32, 285 lock: i32, 286 } 287 288 pub struct pthread_rwlock_t { 289 flags: u32, 290 owner: i32, 291 lock_sem: i32, // this is actually a union 292 lock_count: i32, 293 reader_count: i32, 294 writer_count: i32, 295 waiters: [*mut ::c_void; 2], 296 } 297 298 pub struct pthread_spinlock_t { 299 lock: u32, 300 } 301 302 pub struct passwd { 303 pub pw_name: *mut ::c_char, 304 pub pw_passwd: *mut ::c_char, 305 pub pw_uid: ::uid_t, 306 pub pw_gid: ::gid_t, 307 pub pw_dir: *mut ::c_char, 308 pub pw_shell: *mut ::c_char, 309 pub pw_gecos: *mut ::c_char, 310 } 311 312 pub struct statvfs { 313 pub f_bsize: ::c_ulong, 314 pub f_frsize: ::c_ulong, 315 pub f_blocks: ::fsblkcnt_t, 316 pub f_bfree: ::fsblkcnt_t, 317 pub f_bavail: ::fsblkcnt_t, 318 pub f_files: ::fsfilcnt_t, 319 pub f_ffree: ::fsfilcnt_t, 320 pub f_favail: ::fsfilcnt_t, 321 pub f_fsid: ::c_ulong, 322 pub f_flag: ::c_ulong, 323 pub f_namemax: ::c_ulong, 324 } 325 326 pub struct stack_t { 327 pub ss_sp: *mut ::c_void, 328 pub ss_size: ::size_t, 329 pub ss_flags: ::c_int, 330 } 331 332 pub struct siginfo_t { 333 pub si_signo: ::c_int, 334 pub si_code: ::c_int, 335 pub si_errno: ::c_int, 336 pub si_pid: ::pid_t, 337 pub si_uid: ::uid_t, 338 pub si_addr: *mut ::c_void, 339 pub si_status: ::c_int, 340 pub si_band: c_long, 341 pub sigval: *mut ::c_void, 342 } 343 344 pub struct sigaction { 345 pub sa_sigaction: ::sighandler_t, //actually a union with sa_handler 346 pub sa_mask: ::sigset_t, 347 pub sa_flags: ::c_int, 348 sa_userdata: *mut ::c_void, 349 } 350 351 pub struct sem_t { 352 pub type_: i32, 353 pub named_sem_id: i32, // actually a union with unnamed_sem (i32) 354 pub padding: [i32; 2], 355 } 356 357 pub struct ucred { 358 pub pid: ::pid_t, 359 pub uid: ::uid_t, 360 pub gid: ::gid_t, 361 } 362 363 pub struct sockaddr_dl { 364 pub sdl_len: u8, 365 pub sdl_family: u8, 366 pub sdl_e_type: u16, 367 pub sdl_index: u32, 368 pub sdl_type: u8, 369 pub sdl_nlen: u8, 370 pub sdl_alen: u8, 371 pub sdl_slen: u8, 372 pub sdl_data: [u8; 46], 373 } 374 375 pub struct spwd { 376 pub sp_namp: *mut ::c_char, 377 pub sp_pwdp: *mut ::c_char, 378 pub sp_lstchg: ::c_int, 379 pub sp_min: ::c_int, 380 pub sp_max: ::c_int, 381 pub sp_warn: ::c_int, 382 pub sp_inact: ::c_int, 383 pub sp_expire: ::c_int, 384 pub sp_flag: ::c_int, 385 } 386 387 pub struct regex_t { 388 __buffer: *mut ::c_void, 389 __allocated: ::size_t, 390 __used: ::size_t, 391 __syntax: ::c_ulong, 392 __fastmap: *mut ::c_char, 393 __translate: *mut ::c_char, 394 __re_nsub: ::size_t, 395 __bitfield: u8, 396 } 397 398 pub struct regmatch_t { 399 pub rm_so: regoff_t, 400 pub rm_eo: regoff_t, 401 } 402 403 pub struct msqid_ds { 404 pub msg_perm: ::ipc_perm, 405 pub msg_qnum: ::msgqnum_t, 406 pub msg_qbytes: ::msglen_t, 407 pub msg_lspid: ::pid_t, 408 pub msg_lrpid: ::pid_t, 409 pub msg_stime: ::time_t, 410 pub msg_rtime: ::time_t, 411 pub msg_ctime: ::time_t, 412 } 413 414 pub struct ipc_perm { 415 pub key: ::key_t, 416 pub uid: ::uid_t, 417 pub gid: ::gid_t, 418 pub cuid: ::uid_t, 419 pub cgid: ::gid_t, 420 pub mode: ::mode_t, 421 } 422 423 pub struct sembuf { 424 pub sem_num: ::c_ushort, 425 pub sem_op: ::c_short, 426 pub sem_flg: ::c_short, 427 } 428 429 pub struct entry { 430 pub key: *mut ::c_char, 431 pub data: *mut ::c_void, 432 } 433 434 pub struct option { 435 pub name: *const ::c_char, 436 pub has_arg: ::c_int, 437 pub flag: *mut ::c_int, 438 pub val: ::c_int, 439 } 440} 441 442s_no_extra_traits! { 443 pub struct sockaddr_un { 444 pub sun_len: u8, 445 pub sun_family: sa_family_t, 446 pub sun_path: [::c_char; 126] 447 } 448 pub struct sockaddr_storage { 449 pub ss_len: u8, 450 pub ss_family: sa_family_t, 451 __ss_pad1: [u8; 6], 452 __ss_pad2: u64, 453 __ss_pad3: [u8; 112], 454 } 455 pub struct dirent { 456 pub d_dev: dev_t, 457 pub d_pdev: dev_t, 458 pub d_ino: ino_t, 459 pub d_pino: i64, 460 pub d_reclen: ::c_ushort, 461 pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX 462 } 463 464 pub struct sigevent { 465 pub sigev_notify: ::c_int, 466 pub sigev_signo: ::c_int, 467 pub sigev_value: ::sigval, 468 __unused1: *mut ::c_void, // actually a function pointer 469 pub sigev_notify_attributes: *mut ::pthread_attr_t, 470 } 471 472 pub struct utmpx { 473 pub ut_type: ::c_short, 474 pub ut_tv: ::timeval, 475 pub ut_id: [::c_char; 8], 476 pub ut_pid: ::pid_t, 477 pub ut_user: [::c_char; 32], 478 pub ut_line: [::c_char; 16], 479 pub ut_host: [::c_char; 128], 480 __ut_reserved: [::c_char; 64], 481 } 482} 483 484cfg_if! { 485 if #[cfg(feature = "extra_traits")] { 486 impl PartialEq for utmpx { 487 fn eq(&self, other: &utmpx) -> bool { 488 self.ut_type == other.ut_type 489 && self.ut_tv == other.ut_tv 490 && self.ut_id == other.ut_id 491 && self.ut_pid == other.ut_pid 492 && self.ut_user == other.ut_user 493 && self.ut_line == other.ut_line 494 && self.ut_host.iter().zip(other.ut_host.iter()).all(|(a,b)| a == b) 495 && self.__ut_reserved == other.__ut_reserved 496 } 497 } 498 499 impl Eq for utmpx {} 500 501 impl ::fmt::Debug for utmpx { 502 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 503 f.debug_struct("utmpx") 504 .field("ut_type", &self.ut_type) 505 .field("ut_tv", &self.ut_tv) 506 .field("ut_id", &self.ut_id) 507 .field("ut_pid", &self.ut_pid) 508 .field("ut_user", &self.ut_user) 509 .field("ut_line", &self.ut_line) 510 .field("ut_host", &self.ut_host) 511 .field("__ut_reserved", &self.__ut_reserved) 512 .finish() 513 } 514 } 515 516 impl ::hash::Hash for utmpx { 517 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 518 self.ut_type.hash(state); 519 self.ut_tv.hash(state); 520 self.ut_id.hash(state); 521 self.ut_pid.hash(state); 522 self.ut_user.hash(state); 523 self.ut_line.hash(state); 524 self.ut_host.hash(state); 525 self.__ut_reserved.hash(state); 526 } 527 } 528 impl PartialEq for sockaddr_un { 529 fn eq(&self, other: &sockaddr_un) -> bool { 530 self.sun_len == other.sun_len 531 && self.sun_family == other.sun_family 532 && self 533 .sun_path 534 .iter() 535 .zip(other.sun_path.iter()) 536 .all(|(a,b)| a == b) 537 } 538 } 539 impl Eq for sockaddr_un {} 540 impl ::fmt::Debug for sockaddr_un { 541 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 542 f.debug_struct("sockaddr_un") 543 .field("sun_len", &self.sun_len) 544 .field("sun_family", &self.sun_family) 545 // FIXME: .field("sun_path", &self.sun_path) 546 .finish() 547 } 548 } 549 impl ::hash::Hash for sockaddr_un { 550 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 551 self.sun_len.hash(state); 552 self.sun_family.hash(state); 553 self.sun_path.hash(state); 554 } 555 } 556 557 impl PartialEq for sockaddr_storage { 558 fn eq(&self, other: &sockaddr_storage) -> bool { 559 self.ss_len == other.ss_len 560 && self.ss_family == other.ss_family 561 && self 562 .__ss_pad1 563 .iter() 564 .zip(other.__ss_pad1.iter()) 565 .all(|(a, b)| a == b) 566 && self.__ss_pad2 == other.__ss_pad2 567 && self 568 .__ss_pad3 569 .iter() 570 .zip(other.__ss_pad3.iter()) 571 .all(|(a, b)| a == b) 572 } 573 } 574 impl Eq for sockaddr_storage {} 575 impl ::fmt::Debug for sockaddr_storage { 576 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 577 f.debug_struct("sockaddr_storage") 578 .field("ss_len", &self.ss_len) 579 .field("ss_family", &self.ss_family) 580 .field("__ss_pad1", &self.__ss_pad1) 581 .field("__ss_pad2", &self.__ss_pad2) 582 // FIXME: .field("__ss_pad3", &self.__ss_pad3) 583 .finish() 584 } 585 } 586 impl ::hash::Hash for sockaddr_storage { 587 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 588 self.ss_len.hash(state); 589 self.ss_family.hash(state); 590 self.__ss_pad1.hash(state); 591 self.__ss_pad2.hash(state); 592 self.__ss_pad3.hash(state); 593 } 594 } 595 596 impl PartialEq for dirent { 597 fn eq(&self, other: &dirent) -> bool { 598 self.d_dev == other.d_dev 599 && self.d_pdev == other.d_pdev 600 && self.d_ino == other.d_ino 601 && self.d_pino == other.d_pino 602 && self.d_reclen == other.d_reclen 603 && self 604 .d_name 605 .iter() 606 .zip(other.d_name.iter()) 607 .all(|(a,b)| a == b) 608 } 609 } 610 impl Eq for dirent {} 611 impl ::fmt::Debug for dirent { 612 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 613 f.debug_struct("dirent") 614 .field("d_dev", &self.d_dev) 615 .field("d_pdev", &self.d_pdev) 616 .field("d_ino", &self.d_ino) 617 .field("d_pino", &self.d_pino) 618 .field("d_reclen", &self.d_reclen) 619 // FIXME: .field("d_name", &self.d_name) 620 .finish() 621 } 622 } 623 impl ::hash::Hash for dirent { 624 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 625 self.d_dev.hash(state); 626 self.d_pdev.hash(state); 627 self.d_ino.hash(state); 628 self.d_pino.hash(state); 629 self.d_reclen.hash(state); 630 self.d_name.hash(state); 631 } 632 } 633 634 impl PartialEq for sigevent { 635 fn eq(&self, other: &sigevent) -> bool { 636 self.sigev_notify == other.sigev_notify 637 && self.sigev_signo == other.sigev_signo 638 && self.sigev_value == other.sigev_value 639 && self.sigev_notify_attributes 640 == other.sigev_notify_attributes 641 } 642 } 643 impl Eq for sigevent {} 644 impl ::fmt::Debug for sigevent { 645 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 646 f.debug_struct("sigevent") 647 .field("sigev_notify", &self.sigev_notify) 648 .field("sigev_signo", &self.sigev_signo) 649 .field("sigev_value", &self.sigev_value) 650 .field("sigev_notify_attributes", 651 &self.sigev_notify_attributes) 652 .finish() 653 } 654 } 655 impl ::hash::Hash for sigevent { 656 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 657 self.sigev_notify.hash(state); 658 self.sigev_signo.hash(state); 659 self.sigev_value.hash(state); 660 self.sigev_notify_attributes.hash(state); 661 } 662 } 663 } 664} 665 666pub const EXIT_FAILURE: ::c_int = 1; 667pub const EXIT_SUCCESS: ::c_int = 0; 668pub const RAND_MAX: ::c_int = 2147483647; 669pub const EOF: ::c_int = -1; 670pub const SEEK_SET: ::c_int = 0; 671pub const SEEK_CUR: ::c_int = 1; 672pub const SEEK_END: ::c_int = 2; 673pub const _IOFBF: ::c_int = 0; 674pub const _IONBF: ::c_int = 2; 675pub const _IOLBF: ::c_int = 1; 676 677pub const F_DUPFD: ::c_int = 0x0001; 678pub const F_GETFD: ::c_int = 0x0002; 679pub const F_SETFD: ::c_int = 0x0004; 680pub const F_GETFL: ::c_int = 0x0008; 681pub const F_SETFL: ::c_int = 0x0010; 682pub const F_GETLK: ::c_int = 0x0020; 683pub const F_SETLK: ::c_int = 0x0080; 684pub const F_SETLKW: ::c_int = 0x0100; 685pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200; 686 687pub const F_RDLCK: ::c_int = 0x0040; 688pub const F_UNLCK: ::c_int = 0x0200; 689pub const F_WRLCK: ::c_int = 0x0400; 690 691pub const AT_FDCWD: ::c_int = -1; 692pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01; 693pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02; 694pub const AT_REMOVEDIR: ::c_int = 0x04; 695pub const AT_EACCESS: ::c_int = 0x08; 696 697pub const POLLIN: ::c_short = 0x0001; 698pub const POLLOUT: ::c_short = 0x0002; 699pub const POLLRDNORM: ::c_short = POLLIN; 700pub const POLLWRNORM: ::c_short = POLLOUT; 701pub const POLLRDBAND: ::c_short = 0x0008; 702pub const POLLWRBAND: ::c_short = 0x0010; 703pub const POLLPRI: ::c_short = 0x0020; 704pub const POLLERR: ::c_short = 0x0004; 705pub const POLLHUP: ::c_short = 0x0080; 706pub const POLLNVAL: ::c_short = 0x1000; 707 708pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; 709pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; 710 711pub const CLOCK_REALTIME: ::c_int = -1; 712pub const CLOCK_MONOTONIC: ::c_int = 0; 713pub const CLOCK_PROCESS_CPUTIME_ID: ::c_int = -2; 714pub const CLOCK_THREAD_CPUTIME_ID: ::c_int = -3; 715 716pub const RLIMIT_CORE: ::c_int = 0; 717pub const RLIMIT_CPU: ::c_int = 1; 718pub const RLIMIT_DATA: ::c_int = 2; 719pub const RLIMIT_FSIZE: ::c_int = 3; 720pub const RLIMIT_NOFILE: ::c_int = 4; 721pub const RLIMIT_STACK: ::c_int = 5; 722pub const RLIMIT_AS: ::c_int = 6; 723pub const RLIM_INFINITY: ::rlim_t = 0xffffffff; 724// Haiku specific 725pub const RLIMIT_NOVMON: ::c_int = 7; 726pub const RLIM_NLIMITS: ::c_int = 8; 727 728pub const RUSAGE_SELF: ::c_int = 0; 729 730pub const RTLD_LAZY: ::c_int = 0; 731 732pub const NCCS: usize = 11; 733 734pub const O_RDONLY: ::c_int = 0x0000; 735pub const O_WRONLY: ::c_int = 0x0001; 736pub const O_RDWR: ::c_int = 0x0002; 737pub const O_ACCMODE: ::c_int = 0x0003; 738 739pub const O_EXCL: ::c_int = 0x0100; 740pub const O_CREAT: ::c_int = 0x0200; 741pub const O_TRUNC: ::c_int = 0x0400; 742pub const O_NOCTTY: ::c_int = 0x1000; 743pub const O_NOTRAVERSE: ::c_int = 0x2000; 744 745pub const O_CLOEXEC: ::c_int = 0x00000040; 746pub const O_NONBLOCK: ::c_int = 0x00000080; 747pub const O_APPEND: ::c_int = 0x00000800; 748pub const O_SYNC: ::c_int = 0x00010000; 749pub const O_RSYNC: ::c_int = 0x00020000; 750pub const O_DSYNC: ::c_int = 0x00040000; 751pub const O_NOFOLLOW: ::c_int = 0x00080000; 752pub const O_NOCACHE: ::c_int = 0x00100000; 753pub const O_DIRECTORY: ::c_int = 0x00200000; 754 755pub const S_IFIFO: ::mode_t = 4096; 756pub const S_IFCHR: ::mode_t = 8192; 757pub const S_IFBLK: ::mode_t = 24576; 758pub const S_IFDIR: ::mode_t = 16384; 759pub const S_IFREG: ::mode_t = 32768; 760pub const S_IFLNK: ::mode_t = 40960; 761pub const S_IFSOCK: ::mode_t = 49152; 762pub const S_IFMT: ::mode_t = 61440; 763 764pub const S_IRWXU: ::mode_t = 0o00700; 765pub const S_IRUSR: ::mode_t = 0o00400; 766pub const S_IWUSR: ::mode_t = 0o00200; 767pub const S_IXUSR: ::mode_t = 0o00100; 768pub const S_IRWXG: ::mode_t = 0o00070; 769pub const S_IRGRP: ::mode_t = 0o00040; 770pub const S_IWGRP: ::mode_t = 0o00020; 771pub const S_IXGRP: ::mode_t = 0o00010; 772pub const S_IRWXO: ::mode_t = 0o00007; 773pub const S_IROTH: ::mode_t = 0o00004; 774pub const S_IWOTH: ::mode_t = 0o00002; 775pub const S_IXOTH: ::mode_t = 0o00001; 776 777pub const F_OK: ::c_int = 0; 778pub const R_OK: ::c_int = 4; 779pub const W_OK: ::c_int = 2; 780pub const X_OK: ::c_int = 1; 781pub const STDIN_FILENO: ::c_int = 0; 782pub const STDOUT_FILENO: ::c_int = 1; 783pub const STDERR_FILENO: ::c_int = 2; 784 785pub const SIGHUP: ::c_int = 1; 786pub const SIGINT: ::c_int = 2; 787pub const SIGQUIT: ::c_int = 3; 788pub const SIGILL: ::c_int = 4; 789pub const SIGCHLD: ::c_int = 5; 790pub const SIGABRT: ::c_int = 6; 791pub const SIGPIPE: ::c_int = 7; 792pub const SIGFPE: ::c_int = 8; 793pub const SIGKILL: ::c_int = 9; 794pub const SIGSTOP: ::c_int = 10; 795pub const SIGSEGV: ::c_int = 11; 796pub const SIGCONT: ::c_int = 12; 797pub const SIGTSTP: ::c_int = 13; 798pub const SIGALRM: ::c_int = 14; 799pub const SIGTERM: ::c_int = 15; 800pub const SIGTTIN: ::c_int = 16; 801pub const SIGTTOU: ::c_int = 17; 802pub const SIGUSR1: ::c_int = 18; 803pub const SIGUSR2: ::c_int = 19; 804pub const SIGWINCH: ::c_int = 20; 805pub const SIGKILLTHR: ::c_int = 21; 806pub const SIGTRAP: ::c_int = 22; 807pub const SIGPOLL: ::c_int = 23; 808pub const SIGPROF: ::c_int = 24; 809pub const SIGSYS: ::c_int = 25; 810pub const SIGURG: ::c_int = 26; 811pub const SIGVTALRM: ::c_int = 27; 812pub const SIGXCPU: ::c_int = 28; 813pub const SIGXFSZ: ::c_int = 29; 814pub const SIGBUS: ::c_int = 30; 815 816pub const SIG_BLOCK: ::c_int = 1; 817pub const SIG_UNBLOCK: ::c_int = 2; 818pub const SIG_SETMASK: ::c_int = 3; 819 820pub const SIGEV_NONE: ::c_int = 0; 821pub const SIGEV_SIGNAL: ::c_int = 1; 822pub const SIGEV_THREAD: ::c_int = 2; 823 824pub const EAI_AGAIN: ::c_int = 2; 825pub const EAI_BADFLAGS: ::c_int = 3; 826pub const EAI_FAIL: ::c_int = 4; 827pub const EAI_FAMILY: ::c_int = 5; 828pub const EAI_MEMORY: ::c_int = 6; 829pub const EAI_NODATA: ::c_int = 7; 830pub const EAI_NONAME: ::c_int = 8; 831pub const EAI_SERVICE: ::c_int = 9; 832pub const EAI_SOCKTYPE: ::c_int = 10; 833pub const EAI_SYSTEM: ::c_int = 11; 834pub const EAI_OVERFLOW: ::c_int = 14; 835 836pub const PROT_NONE: ::c_int = 0; 837pub const PROT_READ: ::c_int = 1; 838pub const PROT_WRITE: ::c_int = 2; 839pub const PROT_EXEC: ::c_int = 4; 840 841pub const LC_ALL: ::c_int = 0; 842pub const LC_COLLATE: ::c_int = 1; 843pub const LC_CTYPE: ::c_int = 2; 844pub const LC_MONETARY: ::c_int = 3; 845pub const LC_NUMERIC: ::c_int = 4; 846pub const LC_TIME: ::c_int = 5; 847pub const LC_MESSAGES: ::c_int = 6; 848 849// FIXME: Haiku does not have MAP_FILE, but libstd/os.rs requires it 850pub const MAP_FILE: ::c_int = 0x00; 851pub const MAP_SHARED: ::c_int = 0x01; 852pub const MAP_PRIVATE: ::c_int = 0x02; 853pub const MAP_FIXED: ::c_int = 0x04; 854pub const MAP_ANONYMOUS: ::c_int = 0x08; 855pub const MAP_NORESERVE: ::c_int = 0x10; 856pub const MAP_ANON: ::c_int = MAP_ANONYMOUS; 857 858pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; 859 860pub const MS_ASYNC: ::c_int = 0x01; 861pub const MS_INVALIDATE: ::c_int = 0x04; 862pub const MS_SYNC: ::c_int = 0x02; 863 864pub const E2BIG: ::c_int = -2147454975; 865pub const ECHILD: ::c_int = -2147454974; 866pub const EDEADLK: ::c_int = -2147454973; 867pub const EFBIG: ::c_int = -2147454972; 868pub const EMLINK: ::c_int = -2147454971; 869pub const ENFILE: ::c_int = -2147454970; 870pub const ENODEV: ::c_int = -2147454969; 871pub const ENOLCK: ::c_int = -2147454968; 872pub const ENOSYS: ::c_int = -2147454967; 873pub const ENOTTY: ::c_int = -2147454966; 874pub const ENXIO: ::c_int = -2147454965; 875pub const ESPIPE: ::c_int = -2147454964; 876pub const ESRCH: ::c_int = -2147454963; 877pub const EFPOS: ::c_int = -2147454962; 878pub const ESIGPARM: ::c_int = -2147454961; 879pub const EDOM: ::c_int = -2147454960; 880pub const ERANGE: ::c_int = -2147454959; 881pub const EPROTOTYPE: ::c_int = -2147454958; 882pub const EPROTONOSUPPORT: ::c_int = -2147454957; 883pub const EPFNOSUPPORT: ::c_int = -2147454956; 884pub const EAFNOSUPPORT: ::c_int = -2147454955; 885pub const EADDRINUSE: ::c_int = -2147454954; 886pub const EADDRNOTAVAIL: ::c_int = -2147454953; 887pub const ENETDOWN: ::c_int = -2147454952; 888pub const ENETUNREACH: ::c_int = -2147454951; 889pub const ENETRESET: ::c_int = -2147454950; 890pub const ECONNABORTED: ::c_int = -2147454949; 891pub const ECONNRESET: ::c_int = -2147454948; 892pub const EISCONN: ::c_int = -2147454947; 893pub const ENOTCONN: ::c_int = -2147454946; 894pub const ESHUTDOWN: ::c_int = -2147454945; 895pub const ECONNREFUSED: ::c_int = -2147454944; 896pub const EHOSTUNREACH: ::c_int = -2147454943; 897pub const ENOPROTOOPT: ::c_int = -2147454942; 898pub const ENOBUFS: ::c_int = -2147454941; 899pub const EINPROGRESS: ::c_int = -2147454940; 900pub const EALREADY: ::c_int = -2147454939; 901pub const EILSEQ: ::c_int = -2147454938; 902pub const ENOMSG: ::c_int = -2147454937; 903pub const ESTALE: ::c_int = -2147454936; 904pub const EOVERFLOW: ::c_int = -2147454935; 905pub const EMSGSIZE: ::c_int = -2147454934; 906pub const EOPNOTSUPP: ::c_int = -2147454933; 907pub const ENOTSOCK: ::c_int = -2147454932; 908pub const EHOSTDOWN: ::c_int = -2147454931; 909pub const EBADMSG: ::c_int = -2147454930; 910pub const ECANCELED: ::c_int = -2147454929; 911pub const EDESTADDRREQ: ::c_int = -2147454928; 912pub const EDQUOT: ::c_int = -2147454927; 913pub const EIDRM: ::c_int = -2147454926; 914pub const EMULTIHOP: ::c_int = -2147454925; 915pub const ENODATA: ::c_int = -2147454924; 916pub const ENOLINK: ::c_int = -2147454923; 917pub const ENOSR: ::c_int = -2147454922; 918pub const ENOSTR: ::c_int = -2147454921; 919pub const ENOTSUP: ::c_int = -2147454920; 920pub const EPROTO: ::c_int = -2147454919; 921pub const ETIME: ::c_int = -2147454918; 922pub const ETXTBSY: ::c_int = -2147454917; 923pub const ENOATTR: ::c_int = -2147454916; 924 925// INT_MIN 926pub const ENOMEM: ::c_int = -2147483648; 927 928// POSIX errors that can be mapped to BeOS error codes 929pub const EACCES: ::c_int = -2147483646; 930pub const EINTR: ::c_int = -2147483638; 931pub const EIO: ::c_int = -2147483647; 932pub const EBUSY: ::c_int = -2147483634; 933pub const EFAULT: ::c_int = -2147478783; 934pub const ETIMEDOUT: ::c_int = -2147483639; 935pub const EAGAIN: ::c_int = -2147483637; 936pub const EWOULDBLOCK: ::c_int = -2147483637; 937pub const EBADF: ::c_int = -2147459072; 938pub const EEXIST: ::c_int = -2147459070; 939pub const EINVAL: ::c_int = -2147483643; 940pub const ENAMETOOLONG: ::c_int = -2147459068; 941pub const ENOENT: ::c_int = -2147459069; 942pub const EPERM: ::c_int = -2147483633; 943pub const ENOTDIR: ::c_int = -2147459067; 944pub const EISDIR: ::c_int = -2147459063; 945pub const ENOTEMPTY: ::c_int = -2147459066; 946pub const ENOSPC: ::c_int = -2147459065; 947pub const EROFS: ::c_int = -2147459064; 948pub const EMFILE: ::c_int = -2147459062; 949pub const EXDEV: ::c_int = -2147459061; 950pub const ELOOP: ::c_int = -2147459060; 951pub const ENOEXEC: ::c_int = -2147478782; 952pub const EPIPE: ::c_int = -2147459059; 953 954pub const IPPROTO_RAW: ::c_int = 255; 955 956// These are prefixed with POSIX_ on Haiku 957pub const MADV_NORMAL: ::c_int = 1; 958pub const MADV_SEQUENTIAL: ::c_int = 2; 959pub const MADV_RANDOM: ::c_int = 3; 960pub const MADV_WILLNEED: ::c_int = 4; 961pub const MADV_DONTNEED: ::c_int = 5; 962pub const MADV_FREE: ::c_int = 6; 963 964// https://github.com/haiku/haiku/blob/master/headers/posix/net/if.h#L80 965pub const IFF_UP: ::c_int = 0x0001; 966pub const IFF_BROADCAST: ::c_int = 0x0002; // valid broadcast address 967pub const IFF_LOOPBACK: ::c_int = 0x0008; 968pub const IFF_POINTOPOINT: ::c_int = 0x0010; // point-to-point link 969pub const IFF_NOARP: ::c_int = 0x0040; // no address resolution 970pub const IFF_AUTOUP: ::c_int = 0x0080; // auto dial 971pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets 972pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets 973pub const IFF_SIMPLEX: ::c_int = 0x0800; // doesn't receive own transmissions 974pub const IFF_LINK: ::c_int = 0x1000; // has link 975pub const IFF_AUTO_CONFIGURED: ::c_int = 0x2000; 976pub const IFF_CONFIGURING: ::c_int = 0x4000; 977pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast 978 979pub const AF_UNSPEC: ::c_int = 0; 980pub const AF_INET: ::c_int = 1; 981pub const AF_APPLETALK: ::c_int = 2; 982pub const AF_ROUTE: ::c_int = 3; 983pub const AF_LINK: ::c_int = 4; 984pub const AF_INET6: ::c_int = 5; 985pub const AF_DLI: ::c_int = 6; 986pub const AF_IPX: ::c_int = 7; 987pub const AF_NOTIFY: ::c_int = 8; 988pub const AF_LOCAL: ::c_int = 9; 989pub const AF_UNIX: ::c_int = AF_LOCAL; 990pub const AF_BLUETOOTH: ::c_int = 10; 991 992pub const PF_UNSPEC: ::c_int = AF_UNSPEC; 993pub const PF_INET: ::c_int = AF_INET; 994pub const PF_ROUTE: ::c_int = AF_ROUTE; 995pub const PF_LINK: ::c_int = AF_LINK; 996pub const PF_INET6: ::c_int = AF_INET6; 997pub const PF_LOCAL: ::c_int = AF_LOCAL; 998pub const PF_UNIX: ::c_int = AF_UNIX; 999pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; 1000 1001pub const IP_OPTIONS: ::c_int = 1; 1002pub const IP_HDRINCL: ::c_int = 2; 1003pub const IP_TOS: ::c_int = 3; 1004pub const IP_TTL: ::c_int = 4; 1005pub const IP_RECVOPTS: ::c_int = 5; 1006pub const IP_RECVRETOPTS: ::c_int = 6; 1007pub const IP_RECVDSTADDR: ::c_int = 7; 1008pub const IP_RETOPTS: ::c_int = 8; 1009pub const IP_MULTICAST_IF: ::c_int = 9; 1010pub const IP_MULTICAST_TTL: ::c_int = 10; 1011pub const IP_MULTICAST_LOOP: ::c_int = 11; 1012pub const IP_ADD_MEMBERSHIP: ::c_int = 12; 1013pub const IP_DROP_MEMBERSHIP: ::c_int = 13; 1014pub const IP_BLOCK_SOURCE: ::c_int = 14; 1015pub const IP_UNBLOCK_SOURCE: ::c_int = 15; 1016pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 16; 1017pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 17; 1018 1019pub const TCP_NODELAY: ::c_int = 0x01; 1020pub const TCP_MAXSEG: ::c_int = 0x02; 1021pub const TCP_NOPUSH: ::c_int = 0x04; 1022pub const TCP_NOOPT: ::c_int = 0x08; 1023 1024pub const IF_NAMESIZE: ::size_t = 32; 1025pub const IFNAMSIZ: ::size_t = IF_NAMESIZE; 1026 1027pub const IPV6_MULTICAST_IF: ::c_int = 24; 1028pub const IPV6_MULTICAST_HOPS: ::c_int = 25; 1029pub const IPV6_MULTICAST_LOOP: ::c_int = 26; 1030pub const IPV6_UNICAST_HOPS: ::c_int = 27; 1031pub const IPV6_JOIN_GROUP: ::c_int = 28; 1032pub const IPV6_LEAVE_GROUP: ::c_int = 29; 1033pub const IPV6_V6ONLY: ::c_int = 30; 1034pub const IPV6_PKTINFO: ::c_int = 31; 1035pub const IPV6_RECVPKTINFO: ::c_int = 32; 1036pub const IPV6_HOPLIMIT: ::c_int = 33; 1037pub const IPV6_RECVHOPLIMIT: ::c_int = 34; 1038pub const IPV6_HOPOPTS: ::c_int = 35; 1039pub const IPV6_DSTOPTS: ::c_int = 36; 1040pub const IPV6_RTHDR: ::c_int = 37; 1041 1042pub const MSG_OOB: ::c_int = 0x0001; 1043pub const MSG_PEEK: ::c_int = 0x0002; 1044pub const MSG_DONTROUTE: ::c_int = 0x0004; 1045pub const MSG_EOR: ::c_int = 0x0008; 1046pub const MSG_TRUNC: ::c_int = 0x0010; 1047pub const MSG_CTRUNC: ::c_int = 0x0020; 1048pub const MSG_WAITALL: ::c_int = 0x0040; 1049pub const MSG_DONTWAIT: ::c_int = 0x0080; 1050pub const MSG_BCAST: ::c_int = 0x0100; 1051pub const MSG_MCAST: ::c_int = 0x0200; 1052pub const MSG_EOF: ::c_int = 0x0400; 1053pub const MSG_NOSIGNAL: ::c_int = 0x0800; 1054 1055pub const SHUT_RD: ::c_int = 0; 1056pub const SHUT_WR: ::c_int = 1; 1057pub const SHUT_RDWR: ::c_int = 2; 1058 1059pub const LOCK_SH: ::c_int = 0x01; 1060pub const LOCK_EX: ::c_int = 0x02; 1061pub const LOCK_NB: ::c_int = 0x04; 1062pub const LOCK_UN: ::c_int = 0x08; 1063 1064pub const MINSIGSTKSZ: ::size_t = 8192; 1065pub const SIGSTKSZ: ::size_t = 16384; 1066 1067pub const IOV_MAX: ::c_int = 1024; 1068pub const PATH_MAX: ::c_int = 1024; 1069 1070pub const SA_NOCLDSTOP: ::c_int = 0x01; 1071pub const SA_NOCLDWAIT: ::c_int = 0x02; 1072pub const SA_RESETHAND: ::c_int = 0x04; 1073pub const SA_NODEFER: ::c_int = 0x08; 1074pub const SA_RESTART: ::c_int = 0x10; 1075pub const SA_ONSTACK: ::c_int = 0x20; 1076pub const SA_SIGINFO: ::c_int = 0x40; 1077pub const SA_NOMASK: ::c_int = SA_NODEFER; 1078pub const SA_STACK: ::c_int = SA_ONSTACK; 1079pub const SA_ONESHOT: ::c_int = SA_RESETHAND; 1080 1081pub const SS_ONSTACK: ::c_int = 0x1; 1082pub const SS_DISABLE: ::c_int = 0x2; 1083 1084pub const FD_SETSIZE: usize = 1024; 1085 1086pub const RTLD_LOCAL: ::c_int = 0x0; 1087pub const RTLD_NOW: ::c_int = 0x1; 1088pub const RTLD_GLOBAL: ::c_int = 0x2; 1089pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void; 1090 1091pub const BUFSIZ: ::c_uint = 8192; 1092pub const FILENAME_MAX: ::c_uint = 256; 1093pub const FOPEN_MAX: ::c_uint = 128; 1094pub const L_tmpnam: ::c_uint = 512; 1095pub const TMP_MAX: ::c_uint = 32768; 1096 1097pub const _PC_CHOWN_RESTRICTED: ::c_int = 1; 1098pub const _PC_MAX_CANON: ::c_int = 2; 1099pub const _PC_MAX_INPUT: ::c_int = 3; 1100pub const _PC_NAME_MAX: ::c_int = 4; 1101pub const _PC_NO_TRUNC: ::c_int = 5; 1102pub const _PC_PATH_MAX: ::c_int = 6; 1103pub const _PC_PIPE_BUF: ::c_int = 7; 1104pub const _PC_VDISABLE: ::c_int = 8; 1105pub const _PC_LINK_MAX: ::c_int = 25; 1106pub const _PC_SYNC_IO: ::c_int = 26; 1107pub const _PC_ASYNC_IO: ::c_int = 27; 1108pub const _PC_PRIO_IO: ::c_int = 28; 1109pub const _PC_SOCK_MAXBUF: ::c_int = 29; 1110pub const _PC_FILESIZEBITS: ::c_int = 30; 1111pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 31; 1112pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 32; 1113pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 33; 1114pub const _PC_REC_XFER_ALIGN: ::c_int = 34; 1115pub const _PC_ALLOC_SIZE_MIN: ::c_int = 35; 1116pub const _PC_SYMLINK_MAX: ::c_int = 36; 1117pub const _PC_2_SYMLINKS: ::c_int = 37; 1118pub const _PC_XATTR_EXISTS: ::c_int = 38; 1119pub const _PC_XATTR_ENABLED: ::c_int = 39; 1120 1121pub const FIONBIO: ::c_ulong = 0xbe000000; 1122pub const FIONREAD: ::c_ulong = 0xbe000001; 1123pub const FIOSEEKDATA: ::c_ulong = 0xbe000002; 1124pub const FIOSEEKHOLE: ::c_ulong = 0xbe000003; 1125 1126pub const _SC_ARG_MAX: ::c_int = 15; 1127pub const _SC_CHILD_MAX: ::c_int = 16; 1128pub const _SC_CLK_TCK: ::c_int = 17; 1129pub const _SC_JOB_CONTROL: ::c_int = 18; 1130pub const _SC_NGROUPS_MAX: ::c_int = 19; 1131pub const _SC_OPEN_MAX: ::c_int = 20; 1132pub const _SC_SAVED_IDS: ::c_int = 21; 1133pub const _SC_STREAM_MAX: ::c_int = 22; 1134pub const _SC_TZNAME_MAX: ::c_int = 23; 1135pub const _SC_VERSION: ::c_int = 24; 1136pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 25; 1137pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 26; 1138pub const _SC_PAGESIZE: ::c_int = 27; 1139pub const _SC_PAGE_SIZE: ::c_int = 27; 1140pub const _SC_SEM_NSEMS_MAX: ::c_int = 28; 1141pub const _SC_SEM_VALUE_MAX: ::c_int = 29; 1142pub const _SC_SEMAPHORES: ::c_int = 30; 1143pub const _SC_THREADS: ::c_int = 31; 1144pub const _SC_IOV_MAX: ::c_int = 32; 1145pub const _SC_UIO_MAXIOV: ::c_int = 32; 1146pub const _SC_NPROCESSORS_CONF: ::c_int = 34; 1147pub const _SC_NPROCESSORS_ONLN: ::c_int = 35; 1148pub const _SC_ATEXIT_MAX: ::c_int = 37; 1149pub const _SC_PASS_MAX: ::c_int = 39; 1150pub const _SC_PHYS_PAGES: ::c_int = 40; 1151pub const _SC_AVPHYS_PAGES: ::c_int = 41; 1152pub const _SC_PIPE: ::c_int = 42; 1153pub const _SC_SELECT: ::c_int = 43; 1154pub const _SC_POLL: ::c_int = 44; 1155pub const _SC_MAPPED_FILES: ::c_int = 45; 1156pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 46; 1157pub const _SC_THREAD_STACK_MIN: ::c_int = 47; 1158pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 48; 1159pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 49; 1160pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 50; 1161pub const _SC_REALTIME_SIGNALS: ::c_int = 51; 1162pub const _SC_MEMORY_PROTECTION: ::c_int = 52; 1163pub const _SC_SIGQUEUE_MAX: ::c_int = 53; 1164pub const _SC_RTSIG_MAX: ::c_int = 54; 1165pub const _SC_MONOTONIC_CLOCK: ::c_int = 55; 1166pub const _SC_DELAYTIMER_MAX: ::c_int = 56; 1167pub const _SC_TIMER_MAX: ::c_int = 57; 1168pub const _SC_TIMERS: ::c_int = 58; 1169pub const _SC_CPUTIME: ::c_int = 59; 1170pub const _SC_THREAD_CPUTIME: ::c_int = 60; 1171pub const _SC_HOST_NAME_MAX: ::c_int = 61; 1172pub const _SC_REGEXP: ::c_int = 62; 1173pub const _SC_SYMLOOP_MAX: ::c_int = 63; 1174pub const _SC_SHELL: ::c_int = 64; 1175pub const _SC_TTY_NAME_MAX: ::c_int = 65; 1176 1177pub const PTHREAD_STACK_MIN: ::size_t = 8192; 1178 1179pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { 1180 flags: 0, 1181 lock: 0, 1182 unused: -42, 1183 owner: -1, 1184 owner_count: 0, 1185}; 1186pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { 1187 flags: 0, 1188 unused: -42, 1189 mutex: 0 as *mut _, 1190 waiter_count: 0, 1191 lock: 0, 1192}; 1193pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { 1194 flags: 0, 1195 owner: -1, 1196 lock_sem: 0, 1197 lock_count: 0, 1198 reader_count: 0, 1199 writer_count: 0, 1200 waiters: [0 as *mut _; 2], 1201}; 1202 1203pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0; 1204pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1; 1205pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; 1206pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3; 1207 1208pub const FIOCLEX: c_ulong = 0; // FIXME: does not exist on Haiku! 1209 1210pub const RUSAGE_CHILDREN: ::c_int = -1; 1211 1212pub const SOCK_STREAM: ::c_int = 1; 1213pub const SOCK_DGRAM: ::c_int = 2; 1214pub const SOCK_RAW: ::c_int = 3; 1215pub const SOCK_SEQPACKET: ::c_int = 5; 1216 1217pub const SOL_SOCKET: ::c_int = -1; 1218pub const SO_ACCEPTCONN: ::c_int = 0x00000001; 1219pub const SO_BROADCAST: ::c_int = 0x00000002; 1220pub const SO_DEBUG: ::c_int = 0x00000004; 1221pub const SO_DONTROUTE: ::c_int = 0x00000008; 1222pub const SO_KEEPALIVE: ::c_int = 0x00000010; 1223pub const SO_OOBINLINE: ::c_int = 0x00000020; 1224pub const SO_REUSEADDR: ::c_int = 0x00000040; 1225pub const SO_REUSEPORT: ::c_int = 0x00000080; 1226pub const SO_USELOOPBACK: ::c_int = 0x00000100; 1227pub const SO_LINGER: ::c_int = 0x00000200; 1228pub const SO_SNDBUF: ::c_int = 0x40000001; 1229pub const SO_SNDLOWAT: ::c_int = 0x40000002; 1230pub const SO_SNDTIMEO: ::c_int = 0x40000003; 1231pub const SO_RCVBUF: ::c_int = 0x40000004; 1232pub const SO_RCVLOWAT: ::c_int = 0x40000005; 1233pub const SO_RCVTIMEO: ::c_int = 0x40000006; 1234pub const SO_ERROR: ::c_int = 0x40000007; 1235pub const SO_TYPE: ::c_int = 0x40000008; 1236pub const SO_NONBLOCK: ::c_int = 0x40000009; 1237pub const SO_BINDTODEVICE: ::c_int = 0x4000000a; 1238pub const SO_PEERCRED: ::c_int = 0x4000000b; 1239 1240pub const SCM_RIGHTS: ::c_int = 0x01; 1241 1242pub const SOMAXCONN: ::c_int = 32; 1243 1244pub const NI_MAXHOST: ::size_t = 1025; 1245 1246pub const WNOHANG: ::c_int = 0x01; 1247pub const WUNTRACED: ::c_int = 0x02; 1248pub const WCONTINUED: ::c_int = 0x04; 1249pub const WEXITED: ::c_int = 0x08; 1250pub const WSTOPPED: ::c_int = 0x10; 1251pub const WNOWAIT: ::c_int = 0x20; 1252 1253// si_code values for SIGBUS signal 1254pub const BUS_ADRALN: ::c_int = 40; 1255pub const BUS_ADRERR: ::c_int = 41; 1256pub const BUS_OBJERR: ::c_int = 42; 1257 1258// si_code values for SIGCHLD signal 1259pub const CLD_EXITED: ::c_int = 60; 1260pub const CLD_KILLED: ::c_int = 61; 1261pub const CLD_DUMPED: ::c_int = 62; 1262pub const CLD_TRAPPED: ::c_int = 63; 1263pub const CLD_STOPPED: ::c_int = 64; 1264pub const CLD_CONTINUED: ::c_int = 65; 1265 1266pub const P_ALL: idtype_t = 0; 1267pub const P_PID: idtype_t = 1; 1268pub const P_PGID: idtype_t = 2; 1269 1270pub const UTIME_OMIT: c_long = 1000000001; 1271pub const UTIME_NOW: c_long = 1000000000; 1272 1273pub const VINTR: usize = 0; 1274pub const VQUIT: usize = 1; 1275pub const VERASE: usize = 2; 1276pub const VKILL: usize = 3; 1277pub const VEOF: usize = 4; 1278pub const VEOL: usize = 5; 1279pub const VMIN: usize = 4; 1280pub const VTIME: usize = 5; 1281pub const VEOL2: usize = 6; 1282pub const VSWTCH: usize = 7; 1283pub const VSTART: usize = 8; 1284pub const VSTOP: usize = 9; 1285pub const VSUSP: usize = 10; 1286 1287pub const IGNBRK: ::tcflag_t = 0x01; 1288pub const BRKINT: ::tcflag_t = 0x02; 1289pub const IGNPAR: ::tcflag_t = 0x04; 1290pub const PARMRK: ::tcflag_t = 0x08; 1291pub const INPCK: ::tcflag_t = 0x10; 1292pub const ISTRIP: ::tcflag_t = 0x20; 1293pub const INLCR: ::tcflag_t = 0x40; 1294pub const IGNCR: ::tcflag_t = 0x80; 1295pub const ICRNL: ::tcflag_t = 0x100; 1296pub const IUCLC: ::tcflag_t = 0x200; 1297pub const IXON: ::tcflag_t = 0x400; 1298pub const IXANY: ::tcflag_t = 0x800; 1299pub const IXOFF: ::tcflag_t = 0x1000; 1300 1301pub const OPOST: ::tcflag_t = 0x00000001; 1302pub const OLCUC: ::tcflag_t = 0x00000002; 1303pub const ONLCR: ::tcflag_t = 0x00000004; 1304pub const OCRNL: ::tcflag_t = 0x00000008; 1305pub const ONOCR: ::tcflag_t = 0x00000010; 1306pub const ONLRET: ::tcflag_t = 0x00000020; 1307pub const OFILL: ::tcflag_t = 0x00000040; 1308pub const OFDEL: ::tcflag_t = 0x00000080; 1309pub const NLDLY: ::tcflag_t = 0x00000100; 1310pub const NL0: ::tcflag_t = 0x00000000; 1311pub const NL1: ::tcflag_t = 0x00000100; 1312pub const CRDLY: ::tcflag_t = 0x00000600; 1313pub const CR0: ::tcflag_t = 0x00000000; 1314pub const CR1: ::tcflag_t = 0x00000200; 1315pub const CR2: ::tcflag_t = 0x00000400; 1316pub const CR3: ::tcflag_t = 0x00000600; 1317pub const TABDLY: ::tcflag_t = 0x00001800; 1318pub const TAB0: ::tcflag_t = 0x00000000; 1319pub const TAB1: ::tcflag_t = 0x00000800; 1320pub const TAB2: ::tcflag_t = 0x00001000; 1321pub const TAB3: ::tcflag_t = 0x00001800; 1322pub const BSDLY: ::tcflag_t = 0x00002000; 1323pub const BS0: ::tcflag_t = 0x00000000; 1324pub const BS1: ::tcflag_t = 0x00002000; 1325pub const VTDLY: ::tcflag_t = 0x00004000; 1326pub const VT0: ::tcflag_t = 0x00000000; 1327pub const VT1: ::tcflag_t = 0x00004000; 1328pub const FFDLY: ::tcflag_t = 0x00008000; 1329pub const FF0: ::tcflag_t = 0x00000000; 1330pub const FF1: ::tcflag_t = 0x00008000; 1331 1332pub const CSIZE: ::tcflag_t = 0x00000020; 1333pub const CS5: ::tcflag_t = 0x00000000; 1334pub const CS6: ::tcflag_t = 0x00000000; 1335pub const CS7: ::tcflag_t = 0x00000000; 1336pub const CS8: ::tcflag_t = 0x00000020; 1337pub const CSTOPB: ::tcflag_t = 0x00000040; 1338pub const CREAD: ::tcflag_t = 0x00000080; 1339pub const PARENB: ::tcflag_t = 0x00000100; 1340pub const PARODD: ::tcflag_t = 0x00000200; 1341pub const HUPCL: ::tcflag_t = 0x00000400; 1342pub const CLOCAL: ::tcflag_t = 0x00000800; 1343pub const XLOBLK: ::tcflag_t = 0x00001000; 1344pub const CTSFLOW: ::tcflag_t = 0x00002000; 1345pub const RTSFLOW: ::tcflag_t = 0x00004000; 1346pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW; 1347 1348pub const ISIG: ::tcflag_t = 0x00000001; 1349pub const ICANON: ::tcflag_t = 0x00000002; 1350pub const XCASE: ::tcflag_t = 0x00000004; 1351pub const ECHO: ::tcflag_t = 0x00000008; 1352pub const ECHOE: ::tcflag_t = 0x00000010; 1353pub const ECHOK: ::tcflag_t = 0x00000020; 1354pub const ECHONL: ::tcflag_t = 0x00000040; 1355pub const NOFLSH: ::tcflag_t = 0x00000080; 1356pub const TOSTOP: ::tcflag_t = 0x00000100; 1357pub const IEXTEN: ::tcflag_t = 0x00000200; 1358pub const ECHOCTL: ::tcflag_t = 0x00000400; 1359pub const ECHOPRT: ::tcflag_t = 0x00000800; 1360pub const ECHOKE: ::tcflag_t = 0x00001000; 1361pub const FLUSHO: ::tcflag_t = 0x00002000; 1362pub const PENDIN: ::tcflag_t = 0x00004000; 1363 1364pub const TCGB_CTS: ::c_int = 0x01; 1365pub const TCGB_DSR: ::c_int = 0x02; 1366pub const TCGB_RI: ::c_int = 0x04; 1367pub const TCGB_DCD: ::c_int = 0x08; 1368pub const TIOCM_CTS: ::c_int = TCGB_CTS; 1369pub const TIOCM_CD: ::c_int = TCGB_DCD; 1370pub const TIOCM_CAR: ::c_int = TIOCM_CD; 1371pub const TIOCM_RI: ::c_int = TCGB_RI; 1372pub const TIOCM_DSR: ::c_int = TCGB_DSR; 1373pub const TIOCM_DTR: ::c_int = 0x10; 1374pub const TIOCM_RTS: ::c_int = 0x20; 1375 1376pub const B0: speed_t = 0x00; 1377pub const B50: speed_t = 0x01; 1378pub const B75: speed_t = 0x02; 1379pub const B110: speed_t = 0x03; 1380pub const B134: speed_t = 0x04; 1381pub const B150: speed_t = 0x05; 1382pub const B200: speed_t = 0x06; 1383pub const B300: speed_t = 0x07; 1384pub const B600: speed_t = 0x08; 1385pub const B1200: speed_t = 0x09; 1386pub const B1800: speed_t = 0x0A; 1387pub const B2400: speed_t = 0x0B; 1388pub const B4800: speed_t = 0x0C; 1389pub const B9600: speed_t = 0x0D; 1390pub const B19200: speed_t = 0x0E; 1391pub const B38400: speed_t = 0x0F; 1392pub const B57600: speed_t = 0x10; 1393pub const B115200: speed_t = 0x11; 1394pub const B230400: speed_t = 0x12; 1395pub const B31250: speed_t = 0x13; 1396 1397pub const TCSANOW: ::c_int = 0x01; 1398pub const TCSADRAIN: ::c_int = 0x02; 1399pub const TCSAFLUSH: ::c_int = 0x04; 1400 1401pub const TCOOFF: ::c_int = 0x01; 1402pub const TCOON: ::c_int = 0x02; 1403pub const TCIOFF: ::c_int = 0x04; 1404pub const TCION: ::c_int = 0x08; 1405 1406pub const TCIFLUSH: ::c_int = 0x01; 1407pub const TCOFLUSH: ::c_int = 0x02; 1408pub const TCIOFLUSH: ::c_int = 0x03; 1409 1410pub const TCGETA: ::c_ulong = 0x8000; 1411pub const TCSETA: ::c_ulong = TCGETA + 1; 1412pub const TCSETAF: ::c_ulong = TCGETA + 2; 1413pub const TCSETAW: ::c_ulong = TCGETA + 3; 1414pub const TCWAITEVENT: ::c_ulong = TCGETA + 4; 1415pub const TCSBRK: ::c_ulong = TCGETA + 5; 1416pub const TCFLSH: ::c_ulong = TCGETA + 6; 1417pub const TCXONC: ::c_ulong = TCGETA + 7; 1418pub const TCQUERYCONNECTED: ::c_ulong = TCGETA + 8; 1419pub const TCGETBITS: ::c_ulong = TCGETA + 9; 1420pub const TCSETDTR: ::c_ulong = TCGETA + 10; 1421pub const TCSETRTS: ::c_ulong = TCGETA + 11; 1422pub const TIOCGWINSZ: ::c_ulong = TCGETA + 12; 1423pub const TIOCSWINSZ: ::c_ulong = TCGETA + 13; 1424pub const TCVTIME: ::c_ulong = TCGETA + 14; 1425pub const TIOCGPGRP: ::c_ulong = TCGETA + 15; 1426pub const TIOCSPGRP: ::c_ulong = TCGETA + 16; 1427pub const TIOCSCTTY: ::c_ulong = TCGETA + 17; 1428pub const TIOCMGET: ::c_ulong = TCGETA + 18; 1429pub const TIOCMSET: ::c_ulong = TCGETA + 19; 1430pub const TIOCSBRK: ::c_ulong = TCGETA + 20; 1431pub const TIOCCBRK: ::c_ulong = TCGETA + 21; 1432pub const TIOCMBIS: ::c_ulong = TCGETA + 22; 1433pub const TIOCMBIC: ::c_ulong = TCGETA + 23; 1434 1435pub const PRIO_PROCESS: ::c_int = 0; 1436pub const PRIO_PGRP: ::c_int = 1; 1437pub const PRIO_USER: ::c_int = 2; 1438 1439// utmpx entry types 1440pub const EMPTY: ::c_short = 0; 1441pub const BOOT_TIME: ::c_short = 1; 1442pub const OLD_TIME: ::c_short = 2; 1443pub const NEW_TIME: ::c_short = 3; 1444pub const USER_PROCESS: ::c_short = 4; 1445pub const INIT_PROCESS: ::c_short = 5; 1446pub const LOGIN_PROCESS: ::c_short = 6; 1447pub const DEAD_PROCESS: ::c_short = 7; 1448 1449pub const LOG_PID: ::c_int = 1 << 12; 1450pub const LOG_CONS: ::c_int = 2 << 12; 1451pub const LOG_ODELAY: ::c_int = 4 << 12; 1452pub const LOG_NDELAY: ::c_int = 8 << 12; 1453pub const LOG_SERIAL: ::c_int = 16 << 12; 1454pub const LOG_PERROR: ::c_int = 32 << 12; 1455pub const LOG_NOWAIT: ::c_int = 64 << 12; 1456 1457// spawn.h 1458pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; 1459pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; 1460pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; 1461pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; 1462pub const POSIX_SPAWN_SETSID: ::c_int = 0x40; 1463 1464const_fn! { 1465 {const} fn CMSG_ALIGN(len: usize) -> usize { 1466 len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1) 1467 } 1468} 1469 1470f! { 1471 pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { 1472 if (*mhdr).msg_controllen as usize >= ::mem::size_of::<cmsghdr>() { 1473 (*mhdr).msg_control as *mut cmsghdr 1474 } else { 1475 0 as *mut cmsghdr 1476 } 1477 } 1478 1479 pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { 1480 (cmsg as *mut ::c_uchar) 1481 .offset(CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) 1482 } 1483 1484 pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { 1485 (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>())) 1486 as ::c_uint 1487 } 1488 1489 pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { 1490 CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length 1491 } 1492 1493 pub fn CMSG_NXTHDR(mhdr: *const msghdr, 1494 cmsg: *const cmsghdr) -> *mut cmsghdr { 1495 if cmsg.is_null() { 1496 return ::CMSG_FIRSTHDR(mhdr); 1497 }; 1498 let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize) 1499 + CMSG_ALIGN(::mem::size_of::<::cmsghdr>()); 1500 let max = (*mhdr).msg_control as usize 1501 + (*mhdr).msg_controllen as usize; 1502 if next > max { 1503 0 as *mut ::cmsghdr 1504 } else { 1505 (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) 1506 as *mut ::cmsghdr 1507 } 1508 } 1509 1510 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { 1511 let fd = fd as usize; 1512 let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; 1513 (*set).fds_bits[fd / size] &= !(1 << (fd % size)); 1514 return 1515 } 1516 1517 pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { 1518 let fd = fd as usize; 1519 let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; 1520 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 1521 } 1522 1523 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { 1524 let fd = fd as usize; 1525 let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; 1526 (*set).fds_bits[fd / size] |= 1 << (fd % size); 1527 return 1528 } 1529 1530 pub fn FD_ZERO(set: *mut fd_set) -> () { 1531 for slot in (*set).fds_bits.iter_mut() { 1532 *slot = 0; 1533 } 1534 } 1535} 1536 1537safe_f! { 1538 pub {const} fn WIFEXITED(status: ::c_int) -> bool { 1539 (status & !0xff) == 0 1540 } 1541 1542 pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { 1543 status & 0xff 1544 } 1545 1546 pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { 1547 ((status >> 8) & 0xff) != 0 1548 } 1549 1550 pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { 1551 (status >> 8) & 0xff 1552 } 1553 1554 pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { 1555 ((status >> 16) & 0xff) != 0 1556 } 1557 1558 pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { 1559 (status >> 16) & 0xff 1560 } 1561 1562 // actually WIFCORED, but this is used everywhere else 1563 pub {const} fn WCOREDUMP(status: ::c_int) -> bool { 1564 (status & 0x10000) != 0 1565 } 1566 1567 pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { 1568 (status & 0x20000) != 0 1569 } 1570} 1571 1572extern "C" { 1573 pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; 1574 pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; 1575 pub fn getpriority(which: ::c_int, who: id_t) -> ::c_int; 1576 pub fn setpriority(which: ::c_int, who: id_t, priority: ::c_int) -> ::c_int; 1577 1578 pub fn endusershell(); 1579 pub fn getpass(prompt: *const ::c_char) -> *mut ::c_char; 1580 pub fn getusershell() -> *mut ::c_char; 1581 pub fn issetugid() -> ::c_int; 1582 pub fn setusershell(); 1583 1584 pub fn utimensat( 1585 fd: ::c_int, 1586 path: *const ::c_char, 1587 times: *const ::timespec, 1588 flag: ::c_int, 1589 ) -> ::c_int; 1590 pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; 1591 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; 1592 pub fn _errnop() -> *mut ::c_int; 1593 1594 pub fn abs(i: ::c_int) -> ::c_int; 1595 pub fn labs(i: ::c_long) -> ::c_long; 1596 pub fn rand() -> ::c_int; 1597 pub fn srand(seed: ::c_uint); 1598 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; 1599 pub fn freeifaddrs(ifa: *mut ::ifaddrs); 1600 pub fn ppoll( 1601 fds: *mut ::pollfd, 1602 numfds: ::nfds_t, 1603 timeout: *const ::timespec, 1604 sigMask: *const sigset_t, 1605 ) -> ::c_int; 1606 1607 pub fn getspent() -> *mut spwd; 1608 pub fn getspent_r( 1609 pwd: *mut spwd, 1610 buf: *mut ::c_char, 1611 bufferSize: ::size_t, 1612 res: *mut *mut spwd, 1613 ) -> ::c_int; 1614 pub fn setspent(); 1615 pub fn endspent(); 1616 pub fn getspnam(name: *const ::c_char) -> *mut spwd; 1617 pub fn getspnam_r( 1618 name: *const ::c_char, 1619 spwd: *mut spwd, 1620 buffer: *mut ::c_char, 1621 bufferSize: ::size_t, 1622 res: *mut *mut spwd, 1623 ) -> ::c_int; 1624 pub fn sgetspent(line: *const ::c_char) -> *mut spwd; 1625 pub fn sgetspent_r( 1626 line: *const ::c_char, 1627 spwd: *mut spwd, 1628 buffer: *mut ::c_char, 1629 bufferSize: ::size_t, 1630 res: *mut *mut spwd, 1631 ) -> ::c_int; 1632 pub fn fgetspent(file: *mut ::FILE) -> *mut spwd; 1633 pub fn fgetspent_r( 1634 file: *mut ::FILE, 1635 spwd: *mut spwd, 1636 buffer: *mut ::c_char, 1637 bufferSize: ::size_t, 1638 res: *mut *mut spwd, 1639 ) -> ::c_int; 1640 pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; 1641 pub fn mknodat( 1642 dirfd: ::c_int, 1643 pathname: *const ::c_char, 1644 mode: ::mode_t, 1645 dev: dev_t, 1646 ) -> ::c_int; 1647 pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; 1648 pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int; 1649 1650 pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; 1651 pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; 1652 pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; 1653 pub fn clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::c_int; 1654 pub fn pthread_create( 1655 thread: *mut ::pthread_t, 1656 attr: *const ::pthread_attr_t, 1657 f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, 1658 value: *mut ::c_void, 1659 ) -> ::c_int; 1660 pub fn pthread_attr_getguardsize( 1661 attr: *const ::pthread_attr_t, 1662 guardsize: *mut ::size_t, 1663 ) -> ::c_int; 1664 pub fn pthread_attr_getstack( 1665 attr: *const ::pthread_attr_t, 1666 stackaddr: *mut *mut ::c_void, 1667 stacksize: *mut ::size_t, 1668 ) -> ::c_int; 1669 pub fn pthread_condattr_getclock( 1670 attr: *const pthread_condattr_t, 1671 clock_id: *mut clockid_t, 1672 ) -> ::c_int; 1673 pub fn pthread_condattr_setclock( 1674 attr: *mut pthread_condattr_t, 1675 clock_id: ::clockid_t, 1676 ) -> ::c_int; 1677 pub fn valloc(numBytes: ::size_t) -> *mut ::c_void; 1678 pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t; 1679 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; 1680 pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; 1681 pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; 1682 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; 1683 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; 1684 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; 1685 pub fn getnameinfo( 1686 sa: *const ::sockaddr, 1687 salen: ::socklen_t, 1688 host: *mut ::c_char, 1689 hostlen: ::socklen_t, 1690 serv: *mut ::c_char, 1691 sevlen: ::socklen_t, 1692 flags: ::c_int, 1693 ) -> ::c_int; 1694 pub fn pthread_mutex_timedlock( 1695 lock: *mut pthread_mutex_t, 1696 abstime: *const ::timespec, 1697 ) -> ::c_int; 1698 pub fn pthread_spin_init(lock: *mut ::pthread_spinlock_t, pshared: ::c_int) -> ::c_int; 1699 pub fn pthread_spin_destroy(lock: *mut ::pthread_spinlock_t) -> ::c_int; 1700 pub fn pthread_spin_lock(lock: *mut ::pthread_spinlock_t) -> ::c_int; 1701 pub fn pthread_spin_trylock(lock: *mut ::pthread_spinlock_t) -> ::c_int; 1702 pub fn pthread_spin_unlock(lock: *mut ::pthread_spinlock_t) -> ::c_int; 1703 pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) 1704 -> ::c_int; 1705 1706 pub fn glob( 1707 pattern: *const ::c_char, 1708 flags: ::c_int, 1709 errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>, 1710 pglob: *mut ::glob_t, 1711 ) -> ::c_int; 1712 pub fn globfree(pglob: *mut ::glob_t); 1713 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; 1714 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; 1715 pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advice: ::c_int) -> ::c_int; 1716 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; 1717 1718 pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int; 1719 pub fn shm_unlink(name: *const ::c_char) -> ::c_int; 1720 1721 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); 1722 1723 pub fn telldir(dirp: *mut ::DIR) -> ::c_long; 1724 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; 1725 1726 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; 1727 1728 pub fn recvfrom( 1729 socket: ::c_int, 1730 buf: *mut ::c_void, 1731 len: ::size_t, 1732 flags: ::c_int, 1733 addr: *mut ::sockaddr, 1734 addrlen: *mut ::socklen_t, 1735 ) -> ::ssize_t; 1736 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; 1737 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; 1738 1739 pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int; 1740 1741 pub fn writev(fd: ::c_int, iov: *const ::iovec, count: ::c_int) -> ::ssize_t; 1742 pub fn readv(fd: ::c_int, iov: *const ::iovec, count: ::c_int) -> ::ssize_t; 1743 1744 pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; 1745 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; 1746 pub fn execvpe( 1747 file: *const ::c_char, 1748 argv: *const *const ::c_char, 1749 environment: *const *const ::c_char, 1750 ) -> ::c_int; 1751 pub fn getgrgid_r( 1752 gid: ::gid_t, 1753 grp: *mut ::group, 1754 buf: *mut ::c_char, 1755 buflen: ::size_t, 1756 result: *mut *mut ::group, 1757 ) -> ::c_int; 1758 pub fn getgrouplist( 1759 user: *const ::c_char, 1760 basegroup: ::gid_t, 1761 grouplist: *mut ::gid_t, 1762 groupcount: *mut ::c_int, 1763 ) -> ::c_int; 1764 pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; 1765 pub fn sem_close(sem: *mut sem_t) -> ::c_int; 1766 pub fn getdtablesize() -> ::c_int; 1767 pub fn getgrnam_r( 1768 name: *const ::c_char, 1769 grp: *mut ::group, 1770 buf: *mut ::c_char, 1771 buflen: ::size_t, 1772 result: *mut *mut ::group, 1773 ) -> ::c_int; 1774 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int; 1775 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; 1776 pub fn getgrnam(name: *const ::c_char) -> *mut ::group; 1777 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; 1778 pub fn sem_unlink(name: *const ::c_char) -> ::c_int; 1779 pub fn getpwnam_r( 1780 name: *const ::c_char, 1781 pwd: *mut passwd, 1782 buf: *mut ::c_char, 1783 buflen: ::size_t, 1784 result: *mut *mut passwd, 1785 ) -> ::c_int; 1786 pub fn getpwuid_r( 1787 uid: ::uid_t, 1788 pwd: *mut passwd, 1789 buf: *mut ::c_char, 1790 buflen: ::size_t, 1791 result: *mut *mut passwd, 1792 ) -> ::c_int; 1793 pub fn getpwent() -> *mut passwd; 1794 pub fn setpwent(); 1795 pub fn endpwent(); 1796 pub fn endgrent(); 1797 pub fn getgrent() -> *mut ::group; 1798 pub fn setgrent(); 1799 pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; 1800 pub fn pthread_atfork( 1801 prepare: ::Option<unsafe extern "C" fn()>, 1802 parent: ::Option<unsafe extern "C" fn()>, 1803 child: ::Option<unsafe extern "C" fn()>, 1804 ) -> ::c_int; 1805 pub fn getgrgid(gid: ::gid_t) -> *mut ::group; 1806 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; 1807 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; 1808 pub fn uname(buf: *mut ::utsname) -> ::c_int; 1809 pub fn getutxent() -> *mut utmpx; 1810 pub fn getutxid(ut: *const utmpx) -> *mut utmpx; 1811 pub fn getutxline(ut: *const utmpx) -> *mut utmpx; 1812 pub fn pututxline(ut: *const utmpx) -> *mut utmpx; 1813 pub fn setutxent(); 1814 pub fn endutxent(); 1815 pub fn faccessat( 1816 dirfd: ::c_int, 1817 pathname: *const ::c_char, 1818 mode: ::c_int, 1819 flags: ::c_int, 1820 ) -> ::c_int; 1821 1822 pub fn sigtimedwait( 1823 set: *const sigset_t, 1824 info: *mut siginfo_t, 1825 timeout: *const ::timespec, 1826 ) -> ::c_int; 1827 pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; 1828 1829 pub fn getitimer(which: ::c_int, curr_value: *mut ::itimerval) -> ::c_int; 1830 pub fn setitimer( 1831 which: ::c_int, 1832 new_value: *const ::itimerval, 1833 old_value: *mut ::itimerval, 1834 ) -> ::c_int; 1835 1836 pub fn regcomp(preg: *mut regex_t, pattern: *const ::c_char, cflags: ::c_int) -> ::c_int; 1837 1838 pub fn regexec( 1839 preg: *const regex_t, 1840 input: *const ::c_char, 1841 nmatch: ::size_t, 1842 pmatch: *mut regmatch_t, 1843 eflags: ::c_int, 1844 ) -> ::c_int; 1845 1846 pub fn regerror( 1847 errcode: ::c_int, 1848 preg: *const regex_t, 1849 errbuf: *mut ::c_char, 1850 errbuf_size: ::size_t, 1851 ) -> ::size_t; 1852 1853 pub fn regfree(preg: *mut regex_t); 1854 1855 pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int; 1856 pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; 1857 pub fn msgrcv( 1858 msqid: ::c_int, 1859 msgp: *mut ::c_void, 1860 msgsz: ::size_t, 1861 msgtype: ::c_long, 1862 msgflg: ::c_int, 1863 ) -> ::ssize_t; 1864 pub fn msgsnd( 1865 msqid: ::c_int, 1866 msgp: *const ::c_void, 1867 msgsz: ::size_t, 1868 msgflg: ::c_int, 1869 ) -> ::c_int; 1870 pub fn semget(key: ::key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int; 1871 pub fn semctl(semid: ::c_int, semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int; 1872 pub fn semop(semid: ::c_int, sops: *mut sembuf, nsops: ::size_t) -> ::c_int; 1873 pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; 1874 1875 pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; 1876 1877 pub fn lsearch( 1878 key: *const ::c_void, 1879 base: *mut ::c_void, 1880 nelp: *mut ::size_t, 1881 width: ::size_t, 1882 compar: ::Option<unsafe extern "C" fn(*const ::c_void, *const ::c_void) -> ::c_int>, 1883 ) -> *mut ::c_void; 1884 pub fn lfind( 1885 key: *const ::c_void, 1886 base: *const ::c_void, 1887 nelp: *mut ::size_t, 1888 width: ::size_t, 1889 compar: ::Option<unsafe extern "C" fn(*const ::c_void, *const ::c_void) -> ::c_int>, 1890 ) -> *mut ::c_void; 1891 pub fn hcreate(nelt: ::size_t) -> ::c_int; 1892 pub fn hdestroy(); 1893 pub fn hsearch(entry: ::ENTRY, action: ::ACTION) -> *mut ::ENTRY; 1894 1895 pub fn drand48() -> ::c_double; 1896 pub fn erand48(xseed: *mut ::c_ushort) -> ::c_double; 1897 pub fn lrand48() -> ::c_long; 1898 pub fn nrand48(xseed: *mut ::c_ushort) -> ::c_long; 1899 pub fn mrand48() -> ::c_long; 1900 pub fn jrand48(xseed: *mut ::c_ushort) -> ::c_long; 1901 pub fn srand48(seed: ::c_long); 1902 pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort; 1903 pub fn lcong48(p: *mut ::c_ushort); 1904 1905 pub fn clearenv() -> ::c_int; 1906 pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; 1907 1908 pub fn sync(); 1909 pub fn getpagesize() -> ::c_int; 1910 1911 pub fn brk(addr: *mut ::c_void) -> ::c_int; 1912 pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; 1913 1914 pub fn posix_spawn( 1915 pid: *mut ::pid_t, 1916 path: *const ::c_char, 1917 file_actions: *const ::posix_spawn_file_actions_t, 1918 attrp: *const ::posix_spawnattr_t, 1919 argv: *const *mut ::c_char, 1920 envp: *const *mut ::c_char, 1921 ) -> ::c_int; 1922 pub fn posix_spawnp( 1923 pid: *mut ::pid_t, 1924 file: *const ::c_char, 1925 file_actions: *const ::posix_spawn_file_actions_t, 1926 attrp: *const ::posix_spawnattr_t, 1927 argv: *const *mut ::c_char, 1928 envp: *const *mut ::c_char, 1929 ) -> ::c_int; 1930 1931 pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> ::c_int; 1932 pub fn posix_spawn_file_actions_destroy( 1933 file_actions: *mut posix_spawn_file_actions_t, 1934 ) -> ::c_int; 1935 pub fn posix_spawn_file_actions_addopen( 1936 file_actions: *mut posix_spawn_file_actions_t, 1937 fildes: ::c_int, 1938 path: *const ::c_char, 1939 oflag: ::c_int, 1940 mode: ::mode_t, 1941 ) -> ::c_int; 1942 pub fn posix_spawn_file_actions_addclose( 1943 file_actions: *mut posix_spawn_file_actions_t, 1944 fildes: ::c_int, 1945 ) -> ::c_int; 1946 pub fn posix_spawn_file_actions_adddup2( 1947 file_actions: *mut posix_spawn_file_actions_t, 1948 fildes: ::c_int, 1949 newfildes: ::c_int, 1950 ) -> ::c_int; 1951 1952 pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; 1953 pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; 1954 pub fn posix_spawnattr_getflags( 1955 attr: *const posix_spawnattr_t, 1956 _flags: *mut ::c_short, 1957 ) -> ::c_int; 1958 pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int; 1959 pub fn posix_spawnattr_getpgroup( 1960 attr: *const posix_spawnattr_t, 1961 _pgroup: *mut ::pid_t, 1962 ) -> ::c_int; 1963 pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: ::pid_t) -> ::c_int; 1964 pub fn posix_spawnattr_getsigdefault( 1965 attr: *const posix_spawnattr_t, 1966 sigdefault: *mut ::sigset_t, 1967 ) -> ::c_int; 1968 pub fn posix_spawnattr_setsigdefault( 1969 attr: *mut posix_spawnattr_t, 1970 sigdefault: *const ::sigset_t, 1971 ) -> ::c_int; 1972 pub fn posix_spawnattr_getsigmask( 1973 attr: *const posix_spawnattr_t, 1974 _sigmask: *mut ::sigset_t, 1975 ) -> ::c_int; 1976 pub fn posix_spawnattr_setsigmask( 1977 attr: *mut posix_spawnattr_t, 1978 sigmask: *const ::sigset_t, 1979 ) -> ::c_int; 1980 pub fn getopt_long( 1981 argc: ::c_int, 1982 argv: *const *mut c_char, 1983 optstring: *const c_char, 1984 longopts: *const option, 1985 longindex: *mut ::c_int, 1986 ) -> ::c_int; 1987} 1988 1989#[link(name = "bsd")] 1990extern "C" { 1991 pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; 1992 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; 1993 pub fn forkpty( 1994 amaster: *mut ::c_int, 1995 name: *mut ::c_char, 1996 termp: *mut termios, 1997 winp: *mut ::winsize, 1998 ) -> ::pid_t; 1999 pub fn openpty( 2000 amaster: *mut ::c_int, 2001 aslave: *mut ::c_int, 2002 name: *mut ::c_char, 2003 termp: *mut termios, 2004 winp: *mut ::winsize, 2005 ) -> ::c_int; 2006 pub fn strsep(string: *mut *mut ::c_char, delimiters: *const ::c_char) -> *mut ::c_char; 2007 pub fn explicit_bzero(buf: *mut ::c_void, len: ::size_t); 2008 pub fn login_tty(_fd: ::c_int) -> ::c_int; 2009} 2010 2011cfg_if! { 2012 if #[cfg(target_pointer_width = "64")] { 2013 mod b64; 2014 pub use self::b64::*; 2015 } else { 2016 mod b32; 2017 pub use self::b32::*; 2018 } 2019} 2020 2021cfg_if! { 2022 if #[cfg(target_arch = "x86")] { 2023 // TODO 2024 // mod x86; 2025 // pub use self::x86::*; 2026 } else if #[cfg(target_arch = "x86_64")] { 2027 mod x86_64; 2028 pub use self::x86_64::*; 2029 } else if #[cfg(target_arch = "aarch64")] { 2030 // TODO 2031 // mod aarch64; 2032 // pub use self::aarch64::*; 2033 } 2034} 2035 2036mod native; 2037pub use self::native::*; 2038