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