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