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