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 
369 cfg_if! {
370     if #[cfg(feature = "extra_traits")] {
371         impl PartialEq for sockaddr_un {
372             fn eq(&self, other: &sockaddr_un) -> bool {
373                 self.sun_len == other.sun_len
374                     && self.sun_family == other.sun_family
375                     && self
376                     .sun_path
377                     .iter()
378                     .zip(other.sun_path.iter())
379                     .all(|(a,b)| a == b)
380             }
381         }
382         impl Eq for sockaddr_un {}
383         impl ::fmt::Debug for sockaddr_un {
384             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
385                 f.debug_struct("sockaddr_un")
386                     .field("sun_len", &self.sun_len)
387                     .field("sun_family", &self.sun_family)
388                     // FIXME: .field("sun_path", &self.sun_path)
389                     .finish()
390             }
391         }
392         impl ::hash::Hash for sockaddr_un {
393             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
394                 self.sun_len.hash(state);
395                 self.sun_family.hash(state);
396                 self.sun_path.hash(state);
397             }
398         }
399 
400         impl PartialEq for sockaddr_storage {
401             fn eq(&self, other: &sockaddr_storage) -> bool {
402                 self.ss_len == other.ss_len
403                     && self.ss_family == other.ss_family
404                     && self
405                     .__ss_pad1
406                     .iter()
407                     .zip(other.__ss_pad1.iter())
408                     .all(|(a, b)| a == b)
409                     && self.__ss_pad2 == other.__ss_pad2
410                     && self
411                     .__ss_pad3
412                     .iter()
413                     .zip(other.__ss_pad3.iter())
414                     .all(|(a, b)| a == b)
415             }
416         }
417         impl Eq for sockaddr_storage {}
418         impl ::fmt::Debug for sockaddr_storage {
419             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
420                 f.debug_struct("sockaddr_storage")
421                     .field("ss_len", &self.ss_len)
422                     .field("ss_family", &self.ss_family)
423                     .field("__ss_pad1", &self.__ss_pad1)
424                     .field("__ss_pad2", &self.__ss_pad2)
425                     // FIXME: .field("__ss_pad3", &self.__ss_pad3)
426                     .finish()
427             }
428         }
429         impl ::hash::Hash for sockaddr_storage {
430             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
431                 self.ss_len.hash(state);
432                 self.ss_family.hash(state);
433                 self.__ss_pad1.hash(state);
434                 self.__ss_pad2.hash(state);
435                 self.__ss_pad3.hash(state);
436             }
437         }
438 
439         impl PartialEq for dirent {
440             fn eq(&self, other: &dirent) -> bool {
441                 self.d_dev == other.d_dev
442                     && self.d_pdev == other.d_pdev
443                     && self.d_ino == other.d_ino
444                     && self.d_pino == other.d_pino
445                     && self.d_reclen == other.d_reclen
446                     && self
447                     .d_name
448                     .iter()
449                     .zip(other.d_name.iter())
450                     .all(|(a,b)| a == b)
451             }
452         }
453         impl Eq for dirent {}
454         impl ::fmt::Debug for dirent {
455             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
456                 f.debug_struct("dirent")
457                     .field("d_dev", &self.d_dev)
458                     .field("d_pdev", &self.d_pdev)
459                     .field("d_ino", &self.d_ino)
460                     .field("d_pino", &self.d_pino)
461                     .field("d_reclen", &self.d_reclen)
462                     // FIXME: .field("d_name", &self.d_name)
463                     .finish()
464             }
465         }
466         impl ::hash::Hash for dirent {
467             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
468                 self.d_dev.hash(state);
469                 self.d_pdev.hash(state);
470                 self.d_ino.hash(state);
471                 self.d_pino.hash(state);
472                 self.d_reclen.hash(state);
473                 self.d_name.hash(state);
474             }
475         }
476 
477         impl PartialEq for sigevent {
478             fn eq(&self, other: &sigevent) -> bool {
479                 self.sigev_notify == other.sigev_notify
480                     && self.sigev_signo == other.sigev_signo
481                     && self.sigev_value == other.sigev_value
482                     && self.sigev_notify_attributes
483                         == other.sigev_notify_attributes
484             }
485         }
486         impl Eq for sigevent {}
487         impl ::fmt::Debug for sigevent {
488             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
489                 f.debug_struct("sigevent")
490                     .field("sigev_notify", &self.sigev_notify)
491                     .field("sigev_signo", &self.sigev_signo)
492                     .field("sigev_value", &self.sigev_value)
493                     .field("sigev_notify_attributes",
494                            &self.sigev_notify_attributes)
495                     .finish()
496             }
497         }
498         impl ::hash::Hash for sigevent {
499             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
500                 self.sigev_notify.hash(state);
501                 self.sigev_signo.hash(state);
502                 self.sigev_value.hash(state);
503                 self.sigev_notify_attributes.hash(state);
504             }
505         }
506     }
507 }
508 
509 pub const EXIT_FAILURE: ::c_int = 1;
510 pub const EXIT_SUCCESS: ::c_int = 0;
511 pub const RAND_MAX: ::c_int = 2147483647;
512 pub const EOF: ::c_int = -1;
513 pub const SEEK_SET: ::c_int = 0;
514 pub const SEEK_CUR: ::c_int = 1;
515 pub const SEEK_END: ::c_int = 2;
516 pub const _IOFBF: ::c_int = 0;
517 pub const _IONBF: ::c_int = 2;
518 pub const _IOLBF: ::c_int = 1;
519 
520 pub const F_DUPFD: ::c_int = 0x0001;
521 pub const F_GETFD: ::c_int = 0x0002;
522 pub const F_SETFD: ::c_int = 0x0004;
523 pub const F_GETFL: ::c_int = 0x0008;
524 pub const F_SETFL: ::c_int = 0x0010;
525 pub const F_GETLK: ::c_int = 0x0020;
526 pub const F_SETLK: ::c_int = 0x0080;
527 pub const F_SETLKW: ::c_int = 0x0100;
528 pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200;
529 
530 pub const F_RDLCK: ::c_int = 0x0040;
531 pub const F_UNLCK: ::c_int = 0x0200;
532 pub const F_WRLCK: ::c_int = 0x0400;
533 
534 pub const AT_FDCWD: ::c_int = -1;
535 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01;
536 pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02;
537 pub const AT_REMOVEDIR: ::c_int = 0x04;
538 pub const AT_EACCESS: ::c_int = 0x08;
539 
540 pub const POLLIN: ::c_short = 0x0001;
541 pub const POLLOUT: ::c_short = 0x0002;
542 pub const POLLRDNORM: ::c_short = POLLIN;
543 pub const POLLWRNORM: ::c_short = POLLOUT;
544 pub const POLLRDBAND: ::c_short = 0x0008;
545 pub const POLLWRBAND: ::c_short = 0x0010;
546 pub const POLLPRI: ::c_short = 0x0020;
547 pub const POLLERR: ::c_short = 0x0004;
548 pub const POLLHUP: ::c_short = 0x0080;
549 pub const POLLNVAL: ::c_short = 0x1000;
550 
551 pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
552 pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
553 
554 pub const CLOCK_REALTIME: ::c_int = -1;
555 pub const CLOCK_MONOTONIC: ::c_int = 0;
556 
557 pub const RLIMIT_CORE: ::c_int = 0;
558 pub const RLIMIT_CPU: ::c_int = 1;
559 pub const RLIMIT_DATA: ::c_int = 2;
560 pub const RLIMIT_FSIZE: ::c_int = 3;
561 pub const RLIMIT_NOFILE: ::c_int = 4;
562 pub const RLIMIT_STACK: ::c_int = 5;
563 pub const RLIMIT_AS: ::c_int = 6;
564 pub const RLIM_INFINITY: ::c_ulong = 0xffffffff;
565 // Haiku specific
566 pub const RLIMIT_NOVMON: ::c_int = 7;
567 pub const RLIM_NLIMITS: ::c_int = 8;
568 
569 pub const RUSAGE_SELF: ::c_int = 0;
570 
571 pub const RTLD_LAZY: ::c_int = 0;
572 
573 pub const NCCS: usize = 11;
574 
575 pub const O_RDONLY: ::c_int = 0x0000;
576 pub const O_WRONLY: ::c_int = 0x0001;
577 pub const O_RDWR: ::c_int = 0x0002;
578 pub const O_ACCMODE: ::c_int = 0x0003;
579 
580 pub const O_EXCL: ::c_int = 0x0100;
581 pub const O_CREAT: ::c_int = 0x0200;
582 pub const O_TRUNC: ::c_int = 0x0400;
583 pub const O_NOCTTY: ::c_int = 0x1000;
584 pub const O_NOTRAVERSE: ::c_int = 0x2000;
585 
586 pub const O_CLOEXEC: ::c_int = 0x00000040;
587 pub const O_NONBLOCK: ::c_int = 0x00000080;
588 pub const O_APPEND: ::c_int = 0x00000800;
589 pub const O_SYNC: ::c_int = 0x00010000;
590 pub const O_RSYNC: ::c_int = 0x00020000;
591 pub const O_DSYNC: ::c_int = 0x00040000;
592 pub const O_NOFOLLOW: ::c_int = 0x00080000;
593 pub const O_NOCACHE: ::c_int = 0x00100000;
594 pub const O_DIRECTORY: ::c_int = 0x00200000;
595 
596 pub const S_IFIFO: ::mode_t = 4096;
597 pub const S_IFCHR: ::mode_t = 8192;
598 pub const S_IFBLK: ::mode_t = 24576;
599 pub const S_IFDIR: ::mode_t = 16384;
600 pub const S_IFREG: ::mode_t = 32768;
601 pub const S_IFLNK: ::mode_t = 40960;
602 pub const S_IFSOCK: ::mode_t = 49152;
603 pub const S_IFMT: ::mode_t = 61440;
604 
605 pub const S_IRWXU: ::mode_t = 0o00700;
606 pub const S_IRUSR: ::mode_t = 0o00400;
607 pub const S_IWUSR: ::mode_t = 0o00200;
608 pub const S_IXUSR: ::mode_t = 0o00100;
609 pub const S_IRWXG: ::mode_t = 0o00070;
610 pub const S_IRGRP: ::mode_t = 0o00040;
611 pub const S_IWGRP: ::mode_t = 0o00020;
612 pub const S_IXGRP: ::mode_t = 0o00010;
613 pub const S_IRWXO: ::mode_t = 0o00007;
614 pub const S_IROTH: ::mode_t = 0o00004;
615 pub const S_IWOTH: ::mode_t = 0o00002;
616 pub const S_IXOTH: ::mode_t = 0o00001;
617 
618 pub const F_OK: ::c_int = 0;
619 pub const R_OK: ::c_int = 4;
620 pub const W_OK: ::c_int = 2;
621 pub const X_OK: ::c_int = 1;
622 pub const STDIN_FILENO: ::c_int = 0;
623 pub const STDOUT_FILENO: ::c_int = 1;
624 pub const STDERR_FILENO: ::c_int = 2;
625 
626 pub const SIGHUP: ::c_int = 1;
627 pub const SIGINT: ::c_int = 2;
628 pub const SIGQUIT: ::c_int = 3;
629 pub const SIGILL: ::c_int = 4;
630 pub const SIGCHLD: ::c_int = 5;
631 pub const SIGABRT: ::c_int = 6;
632 pub const SIGPIPE: ::c_int = 7;
633 pub const SIGFPE: ::c_int = 8;
634 pub const SIGKILL: ::c_int = 9;
635 pub const SIGSTOP: ::c_int = 10;
636 pub const SIGSEGV: ::c_int = 11;
637 pub const SIGCONT: ::c_int = 12;
638 pub const SIGTSTP: ::c_int = 13;
639 pub const SIGALRM: ::c_int = 14;
640 pub const SIGTERM: ::c_int = 15;
641 pub const SIGTTIN: ::c_int = 16;
642 pub const SIGTTOU: ::c_int = 17;
643 pub const SIGUSR1: ::c_int = 18;
644 pub const SIGUSR2: ::c_int = 19;
645 pub const SIGWINCH: ::c_int = 20;
646 pub const SIGKILLTHR: ::c_int = 21;
647 pub const SIGTRAP: ::c_int = 22;
648 pub const SIGPOLL: ::c_int = 23;
649 pub const SIGPROF: ::c_int = 24;
650 pub const SIGSYS: ::c_int = 25;
651 pub const SIGURG: ::c_int = 26;
652 pub const SIGVTALRM: ::c_int = 27;
653 pub const SIGXCPU: ::c_int = 28;
654 pub const SIGXFSZ: ::c_int = 29;
655 pub const SIGBUS: ::c_int = 30;
656 
657 pub const SIG_BLOCK: ::c_int = 1;
658 pub const SIG_UNBLOCK: ::c_int = 2;
659 pub const SIG_SETMASK: ::c_int = 3;
660 
661 pub const SIGEV_NONE: ::c_int = 0;
662 pub const SIGEV_SIGNAL: ::c_int = 1;
663 pub const SIGEV_THREAD: ::c_int = 2;
664 
665 pub const EAI_AGAIN: ::c_int = 2;
666 pub const EAI_BADFLAGS: ::c_int = 3;
667 pub const EAI_FAIL: ::c_int = 4;
668 pub const EAI_FAMILY: ::c_int = 5;
669 pub const EAI_MEMORY: ::c_int = 6;
670 pub const EAI_NODATA: ::c_int = 7;
671 pub const EAI_NONAME: ::c_int = 8;
672 pub const EAI_SERVICE: ::c_int = 9;
673 pub const EAI_SOCKTYPE: ::c_int = 10;
674 pub const EAI_SYSTEM: ::c_int = 11;
675 pub const EAI_OVERFLOW: ::c_int = 14;
676 
677 pub const PROT_NONE: ::c_int = 0;
678 pub const PROT_READ: ::c_int = 1;
679 pub const PROT_WRITE: ::c_int = 2;
680 pub const PROT_EXEC: ::c_int = 4;
681 
682 pub const LC_ALL: ::c_int = 0;
683 pub const LC_COLLATE: ::c_int = 1;
684 pub const LC_CTYPE: ::c_int = 2;
685 pub const LC_MONETARY: ::c_int = 3;
686 pub const LC_NUMERIC: ::c_int = 4;
687 pub const LC_TIME: ::c_int = 5;
688 pub const LC_MESSAGES: ::c_int = 6;
689 
690 // FIXME: Haiku does not have MAP_FILE, but libstd/os.rs requires it
691 pub const MAP_FILE: ::c_int = 0x00;
692 pub const MAP_SHARED: ::c_int = 0x01;
693 pub const MAP_PRIVATE: ::c_int = 0x02;
694 pub const MAP_FIXED: ::c_int = 0x04;
695 pub const MAP_ANONYMOUS: ::c_int = 0x08;
696 pub const MAP_NORESERVE: ::c_int = 0x10;
697 pub const MAP_ANON: ::c_int = MAP_ANONYMOUS;
698 
699 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
700 
701 pub const MS_ASYNC: ::c_int = 0x01;
702 pub const MS_INVALIDATE: ::c_int = 0x04;
703 pub const MS_SYNC: ::c_int = 0x02;
704 
705 pub const E2BIG: ::c_int = -2147454975;
706 pub const ECHILD: ::c_int = -2147454974;
707 pub const EDEADLK: ::c_int = -2147454973;
708 pub const EFBIG: ::c_int = -2147454972;
709 pub const EMLINK: ::c_int = -2147454971;
710 pub const ENFILE: ::c_int = -2147454970;
711 pub const ENODEV: ::c_int = -2147454969;
712 pub const ENOLCK: ::c_int = -2147454968;
713 pub const ENOSYS: ::c_int = -2147454967;
714 pub const ENOTTY: ::c_int = -2147454966;
715 pub const ENXIO: ::c_int = -2147454965;
716 pub const ESPIPE: ::c_int = -2147454964;
717 pub const ESRCH: ::c_int = -2147454963;
718 pub const EFPOS: ::c_int = -2147454962;
719 pub const ESIGPARM: ::c_int = -2147454961;
720 pub const EDOM: ::c_int = -2147454960;
721 pub const ERANGE: ::c_int = -2147454959;
722 pub const EPROTOTYPE: ::c_int = -2147454958;
723 pub const EPROTONOSUPPORT: ::c_int = -2147454957;
724 pub const EPFNOSUPPORT: ::c_int = -2147454956;
725 pub const EAFNOSUPPORT: ::c_int = -2147454955;
726 pub const EADDRINUSE: ::c_int = -2147454954;
727 pub const EADDRNOTAVAIL: ::c_int = -2147454953;
728 pub const ENETDOWN: ::c_int = -2147454952;
729 pub const ENETUNREACH: ::c_int = -2147454951;
730 pub const ENETRESET: ::c_int = -2147454950;
731 pub const ECONNABORTED: ::c_int = -2147454949;
732 pub const ECONNRESET: ::c_int = -2147454948;
733 pub const EISCONN: ::c_int = -2147454947;
734 pub const ENOTCONN: ::c_int = -2147454946;
735 pub const ESHUTDOWN: ::c_int = -2147454945;
736 pub const ECONNREFUSED: ::c_int = -2147454944;
737 pub const EHOSTUNREACH: ::c_int = -2147454943;
738 pub const ENOPROTOOPT: ::c_int = -2147454942;
739 pub const ENOBUFS: ::c_int = -2147454941;
740 pub const EINPROGRESS: ::c_int = -2147454940;
741 pub const EALREADY: ::c_int = -2147454939;
742 pub const EILSEQ: ::c_int = -2147454938;
743 pub const ENOMSG: ::c_int = -2147454937;
744 pub const ESTALE: ::c_int = -2147454936;
745 pub const EOVERFLOW: ::c_int = -2147454935;
746 pub const EMSGSIZE: ::c_int = -2147454934;
747 pub const EOPNOTSUPP: ::c_int = -2147454933;
748 pub const ENOTSOCK: ::c_int = -2147454932;
749 pub const EHOSTDOWN: ::c_int = -2147454931;
750 pub const EBADMSG: ::c_int = -2147454930;
751 pub const ECANCELED: ::c_int = -2147454929;
752 pub const EDESTADDRREQ: ::c_int = -2147454928;
753 pub const EDQUOT: ::c_int = -2147454927;
754 pub const EIDRM: ::c_int = -2147454926;
755 pub const EMULTIHOP: ::c_int = -2147454925;
756 pub const ENODATA: ::c_int = -2147454924;
757 pub const ENOLINK: ::c_int = -2147454923;
758 pub const ENOSR: ::c_int = -2147454922;
759 pub const ENOSTR: ::c_int = -2147454921;
760 pub const ENOTSUP: ::c_int = -2147454920;
761 pub const EPROTO: ::c_int = -2147454919;
762 pub const ETIME: ::c_int = -2147454918;
763 pub const ETXTBSY: ::c_int = -2147454917;
764 pub const ENOATTR: ::c_int = -2147454916;
765 
766 // INT_MIN
767 pub const ENOMEM: ::c_int = -2147483648;
768 
769 // POSIX errors that can be mapped to BeOS error codes
770 pub const EACCES: ::c_int = -2147483646;
771 pub const EINTR: ::c_int = -2147483638;
772 pub const EIO: ::c_int = -2147483647;
773 pub const EBUSY: ::c_int = -2147483634;
774 pub const EFAULT: ::c_int = -2147478783;
775 pub const ETIMEDOUT: ::c_int = -2147483639;
776 pub const EAGAIN: ::c_int = -2147483637;
777 pub const EWOULDBLOCK: ::c_int = -2147483637;
778 pub const EBADF: ::c_int = -2147459072;
779 pub const EEXIST: ::c_int = -2147459070;
780 pub const EINVAL: ::c_int = -2147483643;
781 pub const ENAMETOOLONG: ::c_int = -2147459068;
782 pub const ENOENT: ::c_int = -2147459069;
783 pub const EPERM: ::c_int = -2147483633;
784 pub const ENOTDIR: ::c_int = -2147459067;
785 pub const EISDIR: ::c_int = -2147459063;
786 pub const ENOTEMPTY: ::c_int = -2147459066;
787 pub const ENOSPC: ::c_int = -2147459065;
788 pub const EROFS: ::c_int = -2147459064;
789 pub const EMFILE: ::c_int = -2147459062;
790 pub const EXDEV: ::c_int = -2147459061;
791 pub const ELOOP: ::c_int = -2147459060;
792 pub const ENOEXEC: ::c_int = -2147478782;
793 pub const EPIPE: ::c_int = -2147459059;
794 
795 pub const IPPROTO_RAW: ::c_int = 255;
796 
797 // These are prefixed with POSIX_ on Haiku
798 pub const MADV_NORMAL: ::c_int = 1;
799 pub const MADV_SEQUENTIAL: ::c_int = 2;
800 pub const MADV_RANDOM: ::c_int = 3;
801 pub const MADV_WILLNEED: ::c_int = 4;
802 pub const MADV_DONTNEED: ::c_int = 5;
803 pub const MADV_FREE: ::c_int = 6;
804 
805 // https://github.com/haiku/haiku/blob/master/headers/posix/net/if.h#L80
806 pub const IFF_UP: ::c_int = 0x0001;
807 pub const IFF_BROADCAST: ::c_int = 0x0002; // valid broadcast address
808 pub const IFF_LOOPBACK: ::c_int = 0x0008;
809 pub const IFF_POINTOPOINT: ::c_int = 0x0010; // point-to-point link
810 pub const IFF_NOARP: ::c_int = 0x0040; // no address resolution
811 pub const IFF_AUTOUP: ::c_int = 0x0080; // auto dial
812 pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
813 pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
814 pub const IFF_SIMPLEX: ::c_int = 0x0800; // doesn't receive own transmissions
815 pub const IFF_LINK: ::c_int = 0x1000; // has link
816 pub const IFF_AUTO_CONFIGURED: ::c_int = 0x2000;
817 pub const IFF_CONFIGURING: ::c_int = 0x4000;
818 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
819 
820 pub const AF_UNSPEC: ::c_int = 0;
821 pub const AF_INET: ::c_int = 1;
822 pub const AF_APPLETALK: ::c_int = 2;
823 pub const AF_ROUTE: ::c_int = 3;
824 pub const AF_LINK: ::c_int = 4;
825 pub const AF_INET6: ::c_int = 5;
826 pub const AF_DLI: ::c_int = 6;
827 pub const AF_IPX: ::c_int = 7;
828 pub const AF_NOTIFY: ::c_int = 8;
829 pub const AF_LOCAL: ::c_int = 9;
830 pub const AF_UNIX: ::c_int = AF_LOCAL;
831 pub const AF_BLUETOOTH: ::c_int = 10;
832 
833 pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
834 pub const PF_INET: ::c_int = AF_INET;
835 pub const PF_ROUTE: ::c_int = AF_ROUTE;
836 pub const PF_LINK: ::c_int = AF_LINK;
837 pub const PF_INET6: ::c_int = AF_INET6;
838 pub const PF_LOCAL: ::c_int = AF_LOCAL;
839 pub const PF_UNIX: ::c_int = AF_UNIX;
840 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
841 
842 pub const IP_OPTIONS: ::c_int = 1;
843 pub const IP_HDRINCL: ::c_int = 2;
844 pub const IP_TOS: ::c_int = 3;
845 pub const IP_TTL: ::c_int = 4;
846 pub const IP_RECVOPTS: ::c_int = 5;
847 pub const IP_RECVRETOPTS: ::c_int = 6;
848 pub const IP_RECVDSTADDR: ::c_int = 7;
849 pub const IP_RETOPTS: ::c_int = 8;
850 pub const IP_MULTICAST_IF: ::c_int = 9;
851 pub const IP_MULTICAST_TTL: ::c_int = 10;
852 pub const IP_MULTICAST_LOOP: ::c_int = 11;
853 pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
854 pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
855 pub const IP_BLOCK_SOURCE: ::c_int = 14;
856 pub const IP_UNBLOCK_SOURCE: ::c_int = 15;
857 pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 16;
858 pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 17;
859 
860 pub const TCP_NODELAY: ::c_int = 0x01;
861 pub const TCP_MAXSEG: ::c_int = 0x02;
862 pub const TCP_NOPUSH: ::c_int = 0x04;
863 pub const TCP_NOOPT: ::c_int = 0x08;
864 
865 pub const IF_NAMESIZE: ::size_t = 32;
866 pub const IFNAMSIZ: ::size_t = IF_NAMESIZE;
867 
868 pub const IPV6_MULTICAST_IF: ::c_int = 24;
869 pub const IPV6_MULTICAST_HOPS: ::c_int = 25;
870 pub const IPV6_MULTICAST_LOOP: ::c_int = 26;
871 pub const IPV6_UNICAST_HOPS: ::c_int = 27;
872 pub const IPV6_JOIN_GROUP: ::c_int = 28;
873 pub const IPV6_LEAVE_GROUP: ::c_int = 29;
874 pub const IPV6_V6ONLY: ::c_int = 30;
875 pub const IPV6_PKTINFO: ::c_int = 31;
876 pub const IPV6_RECVPKTINFO: ::c_int = 32;
877 pub const IPV6_HOPLIMIT: ::c_int = 33;
878 pub const IPV6_RECVHOPLIMIT: ::c_int = 34;
879 pub const IPV6_HOPOPTS: ::c_int = 35;
880 pub const IPV6_DSTOPTS: ::c_int = 36;
881 pub const IPV6_RTHDR: ::c_int = 37;
882 
883 pub const MSG_OOB: ::c_int = 0x0001;
884 pub const MSG_PEEK: ::c_int = 0x0002;
885 pub const MSG_DONTROUTE: ::c_int = 0x0004;
886 pub const MSG_EOR: ::c_int = 0x0008;
887 pub const MSG_TRUNC: ::c_int = 0x0010;
888 pub const MSG_CTRUNC: ::c_int = 0x0020;
889 pub const MSG_WAITALL: ::c_int = 0x0040;
890 pub const MSG_DONTWAIT: ::c_int = 0x0080;
891 pub const MSG_BCAST: ::c_int = 0x0100;
892 pub const MSG_MCAST: ::c_int = 0x0200;
893 pub const MSG_EOF: ::c_int = 0x0400;
894 pub const MSG_NOSIGNAL: ::c_int = 0x0800;
895 
896 pub const SHUT_RD: ::c_int = 0;
897 pub const SHUT_WR: ::c_int = 1;
898 pub const SHUT_RDWR: ::c_int = 2;
899 
900 pub const LOCK_SH: ::c_int = 0x01;
901 pub const LOCK_EX: ::c_int = 0x02;
902 pub const LOCK_NB: ::c_int = 0x04;
903 pub const LOCK_UN: ::c_int = 0x08;
904 
905 pub const SIGSTKSZ: ::size_t = 16384;
906 
907 pub const IOV_MAX: ::c_int = 1024;
908 pub const PATH_MAX: ::c_int = 1024;
909 
910 pub const SA_NOCLDSTOP: ::c_int = 0x01;
911 pub const SA_NOCLDWAIT: ::c_int = 0x02;
912 pub const SA_RESETHAND: ::c_int = 0x04;
913 pub const SA_NODEFER: ::c_int = 0x08;
914 pub const SA_RESTART: ::c_int = 0x10;
915 pub const SA_ONSTACK: ::c_int = 0x20;
916 pub const SA_SIGINFO: ::c_int = 0x40;
917 pub const SA_NOMASK: ::c_int = SA_NODEFER;
918 pub const SA_STACK: ::c_int = SA_ONSTACK;
919 pub const SA_ONESHOT: ::c_int = SA_RESETHAND;
920 
921 pub const FD_SETSIZE: usize = 1024;
922 
923 pub const RTLD_LOCAL: ::c_int = 0x0;
924 pub const RTLD_NOW: ::c_int = 0x1;
925 pub const RTLD_GLOBAL: ::c_int = 0x2;
926 pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void;
927 
928 pub const BUFSIZ: ::c_uint = 8192;
929 pub const FILENAME_MAX: ::c_uint = 256;
930 pub const FOPEN_MAX: ::c_uint = 128;
931 pub const L_tmpnam: ::c_uint = 512;
932 pub const TMP_MAX: ::c_uint = 32768;
933 
934 pub const _PC_CHOWN_RESTRICTED: ::c_int = 1;
935 pub const _PC_MAX_CANON: ::c_int = 2;
936 pub const _PC_MAX_INPUT: ::c_int = 3;
937 pub const _PC_NAME_MAX: ::c_int = 4;
938 pub const _PC_NO_TRUNC: ::c_int = 5;
939 pub const _PC_PATH_MAX: ::c_int = 6;
940 pub const _PC_PIPE_BUF: ::c_int = 7;
941 pub const _PC_VDISABLE: ::c_int = 8;
942 pub const _PC_LINK_MAX: ::c_int = 25;
943 pub const _PC_SYNC_IO: ::c_int = 26;
944 pub const _PC_ASYNC_IO: ::c_int = 27;
945 pub const _PC_PRIO_IO: ::c_int = 28;
946 pub const _PC_SOCK_MAXBUF: ::c_int = 29;
947 pub const _PC_FILESIZEBITS: ::c_int = 30;
948 pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 31;
949 pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 32;
950 pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 33;
951 pub const _PC_REC_XFER_ALIGN: ::c_int = 34;
952 pub const _PC_ALLOC_SIZE_MIN: ::c_int = 35;
953 pub const _PC_SYMLINK_MAX: ::c_int = 36;
954 pub const _PC_2_SYMLINKS: ::c_int = 37;
955 pub const _PC_XATTR_EXISTS: ::c_int = 38;
956 pub const _PC_XATTR_ENABLED: ::c_int = 39;
957 
958 pub const FIONBIO: ::c_ulong = 0xbe000000;
959 pub const FIONREAD: ::c_ulong = 0xbe000001;
960 pub const FIOSEEKDATA: ::c_ulong = 0xbe000002;
961 pub const FIOSEEKHOLE: ::c_ulong = 0xbe000003;
962 
963 pub const _SC_ARG_MAX: ::c_int = 15;
964 pub const _SC_CHILD_MAX: ::c_int = 16;
965 pub const _SC_CLK_TCK: ::c_int = 17;
966 pub const _SC_JOB_CONTROL: ::c_int = 18;
967 pub const _SC_NGROUPS_MAX: ::c_int = 19;
968 pub const _SC_OPEN_MAX: ::c_int = 20;
969 pub const _SC_SAVED_IDS: ::c_int = 21;
970 pub const _SC_STREAM_MAX: ::c_int = 22;
971 pub const _SC_TZNAME_MAX: ::c_int = 23;
972 pub const _SC_VERSION: ::c_int = 24;
973 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 25;
974 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 26;
975 pub const _SC_PAGESIZE: ::c_int = 27;
976 pub const _SC_PAGE_SIZE: ::c_int = 27;
977 pub const _SC_SEM_NSEMS_MAX: ::c_int = 28;
978 pub const _SC_SEM_VALUE_MAX: ::c_int = 29;
979 pub const _SC_SEMAPHORES: ::c_int = 30;
980 pub const _SC_THREADS: ::c_int = 31;
981 pub const _SC_IOV_MAX: ::c_int = 32;
982 pub const _SC_UIO_MAXIOV: ::c_int = 32;
983 pub const _SC_NPROCESSORS_CONF: ::c_int = 34;
984 pub const _SC_NPROCESSORS_ONLN: ::c_int = 35;
985 pub const _SC_ATEXIT_MAX: ::c_int = 37;
986 pub const _SC_PASS_MAX: ::c_int = 39;
987 pub const _SC_PHYS_PAGES: ::c_int = 40;
988 pub const _SC_AVPHYS_PAGES: ::c_int = 41;
989 pub const _SC_PIPE: ::c_int = 42;
990 pub const _SC_SELECT: ::c_int = 43;
991 pub const _SC_POLL: ::c_int = 44;
992 pub const _SC_MAPPED_FILES: ::c_int = 45;
993 pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 46;
994 pub const _SC_THREAD_STACK_MIN: ::c_int = 47;
995 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 48;
996 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 49;
997 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 50;
998 pub const _SC_REALTIME_SIGNALS: ::c_int = 51;
999 pub const _SC_MEMORY_PROTECTION: ::c_int = 52;
1000 pub const _SC_SIGQUEUE_MAX: ::c_int = 53;
1001 pub const _SC_RTSIG_MAX: ::c_int = 54;
1002 pub const _SC_MONOTONIC_CLOCK: ::c_int = 55;
1003 pub const _SC_DELAYTIMER_MAX: ::c_int = 56;
1004 pub const _SC_TIMER_MAX: ::c_int = 57;
1005 pub const _SC_TIMERS: ::c_int = 58;
1006 pub const _SC_CPUTIME: ::c_int = 59;
1007 pub const _SC_THREAD_CPUTIME: ::c_int = 60;
1008 pub const _SC_HOST_NAME_MAX: ::c_int = 61;
1009 pub const _SC_REGEXP: ::c_int = 62;
1010 pub const _SC_SYMLOOP_MAX: ::c_int = 63;
1011 pub const _SC_SHELL: ::c_int = 64;
1012 pub const _SC_TTY_NAME_MAX: ::c_int = 65;
1013 
1014 pub const PTHREAD_STACK_MIN: ::size_t = 8192;
1015 
1016 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1017     flags: 0,
1018     lock: 0,
1019     unused: -42,
1020     owner: -1,
1021     owner_count: 0,
1022 };
1023 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1024     flags: 0,
1025     unused: -42,
1026     mutex: 0 as *mut _,
1027     waiter_count: 0,
1028     lock: 0,
1029 };
1030 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1031     flags: 0,
1032     owner: -1,
1033     lock_sem: 0,
1034     lock_count: 0,
1035     reader_count: 0,
1036     writer_count: 0,
1037     waiters: [0 as *mut _; 2],
1038 };
1039 
1040 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0;
1041 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1;
1042 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
1043 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3;
1044 
1045 pub const FIOCLEX: c_ulong = 0; // FIXME: does not exist on Haiku!
1046 
1047 pub const RUSAGE_CHILDREN: ::c_int = -1;
1048 
1049 pub const SOCK_STREAM: ::c_int = 1;
1050 pub const SOCK_DGRAM: ::c_int = 2;
1051 pub const SOCK_RAW: ::c_int = 3;
1052 pub const SOCK_SEQPACKET: ::c_int = 5;
1053 
1054 pub const SOL_SOCKET: ::c_int = -1;
1055 pub const SO_ACCEPTCONN: ::c_int = 0x00000001;
1056 pub const SO_BROADCAST: ::c_int = 0x00000002;
1057 pub const SO_DEBUG: ::c_int = 0x00000004;
1058 pub const SO_DONTROUTE: ::c_int = 0x00000008;
1059 pub const SO_KEEPALIVE: ::c_int = 0x00000010;
1060 pub const SO_OOBINLINE: ::c_int = 0x00000020;
1061 pub const SO_REUSEADDR: ::c_int = 0x00000040;
1062 pub const SO_REUSEPORT: ::c_int = 0x00000080;
1063 pub const SO_USELOOPBACK: ::c_int = 0x00000100;
1064 pub const SO_LINGER: ::c_int = 0x00000200;
1065 pub const SO_SNDBUF: ::c_int = 0x40000001;
1066 pub const SO_SNDLOWAT: ::c_int = 0x40000002;
1067 pub const SO_SNDTIMEO: ::c_int = 0x40000003;
1068 pub const SO_RCVBUF: ::c_int = 0x40000004;
1069 pub const SO_RCVLOWAT: ::c_int = 0x40000005;
1070 pub const SO_RCVTIMEO: ::c_int = 0x40000006;
1071 pub const SO_ERROR: ::c_int = 0x40000007;
1072 pub const SO_TYPE: ::c_int = 0x40000008;
1073 pub const SO_NONBLOCK: ::c_int = 0x40000009;
1074 pub const SO_BINDTODEVICE: ::c_int = 0x4000000a;
1075 pub const SO_PEERCRED: ::c_int = 0x4000000b;
1076 
1077 pub const SCM_RIGHTS: ::c_int = 0x01;
1078 
1079 pub const NI_MAXHOST: ::size_t = 1025;
1080 
1081 pub const WNOHANG: ::c_int = 0x01;
1082 pub const WUNTRACED: ::c_int = 0x02;
1083 pub const WCONTINUED: ::c_int = 0x04;
1084 pub const WEXITED: ::c_int = 0x08;
1085 pub const WSTOPPED: ::c_int = 0x10;
1086 pub const WNOWAIT: ::c_int = 0x20;
1087 
1088 pub const CLD_EXITED: ::c_int = 60;
1089 pub const CLD_KILLED: ::c_int = 61;
1090 pub const CLD_DUMPED: ::c_int = 62;
1091 pub const CLD_TRAPPED: ::c_int = 63;
1092 pub const CLD_STOPPED: ::c_int = 64;
1093 pub const CLD_CONTINUED: ::c_int = 65;
1094 
1095 pub const P_ALL: idtype_t = 0;
1096 pub const P_PID: idtype_t = 1;
1097 pub const P_PGID: idtype_t = 2;
1098 
1099 pub const UTIME_OMIT: c_long = 1000000001;
1100 pub const UTIME_NOW: c_long = 1000000000;
1101 
1102 pub const VINTR: usize = 0;
1103 pub const VQUIT: usize = 1;
1104 pub const VERASE: usize = 2;
1105 pub const VKILL: usize = 3;
1106 pub const VEOF: usize = 4;
1107 pub const VEOL: usize = 5;
1108 pub const VMIN: usize = 4;
1109 pub const VTIME: usize = 5;
1110 pub const VEOL2: usize = 6;
1111 pub const VSWTCH: usize = 7;
1112 pub const VSTART: usize = 8;
1113 pub const VSTOP: usize = 9;
1114 pub const VSUSP: usize = 10;
1115 
1116 pub const IGNBRK: ::tcflag_t = 0x01;
1117 pub const BRKINT: ::tcflag_t = 0x02;
1118 pub const IGNPAR: ::tcflag_t = 0x04;
1119 pub const PARMRK: ::tcflag_t = 0x08;
1120 pub const INPCK: ::tcflag_t = 0x10;
1121 pub const ISTRIP: ::tcflag_t = 0x20;
1122 pub const INLCR: ::tcflag_t = 0x40;
1123 pub const IGNCR: ::tcflag_t = 0x80;
1124 pub const ICRNL: ::tcflag_t = 0x100;
1125 pub const IUCLC: ::tcflag_t = 0x200;
1126 pub const IXON: ::tcflag_t = 0x400;
1127 pub const IXANY: ::tcflag_t = 0x800;
1128 pub const IXOFF: ::tcflag_t = 0x1000;
1129 
1130 pub const OPOST: ::tcflag_t = 0x00000001;
1131 pub const OLCUC: ::tcflag_t = 0x00000002;
1132 pub const ONLCR: ::tcflag_t = 0x00000004;
1133 pub const OCRNL: ::tcflag_t = 0x00000008;
1134 pub const ONOCR: ::tcflag_t = 0x00000010;
1135 pub const ONLRET: ::tcflag_t = 0x00000020;
1136 pub const OFILL: ::tcflag_t = 0x00000040;
1137 pub const OFDEL: ::tcflag_t = 0x00000080;
1138 pub const NLDLY: ::tcflag_t = 0x00000100;
1139 pub const NL0: ::tcflag_t = 0x00000000;
1140 pub const NL1: ::tcflag_t = 0x00000100;
1141 pub const CRDLY: ::tcflag_t = 0x00000600;
1142 pub const CR0: ::tcflag_t = 0x00000000;
1143 pub const CR1: ::tcflag_t = 0x00000200;
1144 pub const CR2: ::tcflag_t = 0x00000400;
1145 pub const CR3: ::tcflag_t = 0x00000600;
1146 pub const TABDLY: ::tcflag_t = 0x00001800;
1147 pub const TAB0: ::tcflag_t = 0x00000000;
1148 pub const TAB1: ::tcflag_t = 0x00000800;
1149 pub const TAB2: ::tcflag_t = 0x00001000;
1150 pub const TAB3: ::tcflag_t = 0x00001800;
1151 pub const BSDLY: ::tcflag_t = 0x00002000;
1152 pub const BS0: ::tcflag_t = 0x00000000;
1153 pub const BS1: ::tcflag_t = 0x00002000;
1154 pub const VTDLY: ::tcflag_t = 0x00004000;
1155 pub const VT0: ::tcflag_t = 0x00000000;
1156 pub const VT1: ::tcflag_t = 0x00004000;
1157 pub const FFDLY: ::tcflag_t = 0x00008000;
1158 pub const FF0: ::tcflag_t = 0x00000000;
1159 pub const FF1: ::tcflag_t = 0x00008000;
1160 
1161 pub const CSIZE: ::tcflag_t = 0x00000020;
1162 pub const CS5: ::tcflag_t = 0x00000000;
1163 pub const CS6: ::tcflag_t = 0x00000000;
1164 pub const CS7: ::tcflag_t = 0x00000000;
1165 pub const CS8: ::tcflag_t = 0x00000020;
1166 pub const CSTOPB: ::tcflag_t = 0x00000040;
1167 pub const CREAD: ::tcflag_t = 0x00000080;
1168 pub const PARENB: ::tcflag_t = 0x00000100;
1169 pub const PARODD: ::tcflag_t = 0x00000200;
1170 pub const HUPCL: ::tcflag_t = 0x00000400;
1171 pub const CLOCAL: ::tcflag_t = 0x00000800;
1172 pub const XLOBLK: ::tcflag_t = 0x00001000;
1173 pub const CTSFLOW: ::tcflag_t = 0x00002000;
1174 pub const RTSFLOW: ::tcflag_t = 0x00004000;
1175 pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW;
1176 
1177 pub const ISIG: ::tcflag_t = 0x00000001;
1178 pub const ICANON: ::tcflag_t = 0x00000002;
1179 pub const XCASE: ::tcflag_t = 0x00000004;
1180 pub const ECHO: ::tcflag_t = 0x00000008;
1181 pub const ECHOE: ::tcflag_t = 0x00000010;
1182 pub const ECHOK: ::tcflag_t = 0x00000020;
1183 pub const ECHONL: ::tcflag_t = 0x00000040;
1184 pub const NOFLSH: ::tcflag_t = 0x00000080;
1185 pub const TOSTOP: ::tcflag_t = 0x00000100;
1186 pub const IEXTEN: ::tcflag_t = 0x00000200;
1187 pub const ECHOCTL: ::tcflag_t = 0x00000400;
1188 pub const ECHOPRT: ::tcflag_t = 0x00000800;
1189 pub const ECHOKE: ::tcflag_t = 0x00001000;
1190 pub const FLUSHO: ::tcflag_t = 0x00002000;
1191 pub const PENDIN: ::tcflag_t = 0x00004000;
1192 
1193 pub const TCGB_CTS: ::c_int = 0x01;
1194 pub const TCGB_DSR: ::c_int = 0x02;
1195 pub const TCGB_RI: ::c_int = 0x04;
1196 pub const TCGB_DCD: ::c_int = 0x08;
1197 pub const TIOCM_CTS: ::c_int = TCGB_CTS;
1198 pub const TIOCM_CD: ::c_int = TCGB_DCD;
1199 pub const TIOCM_CAR: ::c_int = TIOCM_CD;
1200 pub const TIOCM_RI: ::c_int = TCGB_RI;
1201 pub const TIOCM_DSR: ::c_int = TCGB_DSR;
1202 pub const TIOCM_DTR: ::c_int = 0x10;
1203 pub const TIOCM_RTS: ::c_int = 0x20;
1204 
1205 pub const B0: speed_t = 0x00;
1206 pub const B50: speed_t = 0x01;
1207 pub const B75: speed_t = 0x02;
1208 pub const B110: speed_t = 0x03;
1209 pub const B134: speed_t = 0x04;
1210 pub const B150: speed_t = 0x05;
1211 pub const B200: speed_t = 0x06;
1212 pub const B300: speed_t = 0x07;
1213 pub const B600: speed_t = 0x08;
1214 pub const B1200: speed_t = 0x09;
1215 pub const B1800: speed_t = 0x0A;
1216 pub const B2400: speed_t = 0x0B;
1217 pub const B4800: speed_t = 0x0C;
1218 pub const B9600: speed_t = 0x0D;
1219 pub const B19200: speed_t = 0x0E;
1220 pub const B38400: speed_t = 0x0F;
1221 pub const B57600: speed_t = 0x10;
1222 pub const B115200: speed_t = 0x11;
1223 pub const B230400: speed_t = 0x12;
1224 pub const B31250: speed_t = 0x13;
1225 
1226 pub const TCSANOW: ::c_int = 0x01;
1227 pub const TCSADRAIN: ::c_int = 0x02;
1228 pub const TCSAFLUSH: ::c_int = 0x04;
1229 
1230 pub const TCOOFF: ::c_int = 0x01;
1231 pub const TCOON: ::c_int = 0x02;
1232 pub const TCIOFF: ::c_int = 0x04;
1233 pub const TCION: ::c_int = 0x08;
1234 
1235 pub const TCIFLUSH: ::c_int = 0x01;
1236 pub const TCOFLUSH: ::c_int = 0x02;
1237 pub const TCIOFLUSH: ::c_int = 0x03;
1238 
1239 pub const TCGETA: ::c_ulong = 0x8000;
1240 pub const TCSETA: ::c_ulong = TCGETA + 1;
1241 pub const TCSETAF: ::c_ulong = TCGETA + 2;
1242 pub const TCSETAW: ::c_ulong = TCGETA + 3;
1243 pub const TCWAITEVENT: ::c_ulong = TCGETA + 4;
1244 pub const TCSBRK: ::c_ulong = TCGETA + 5;
1245 pub const TCFLSH: ::c_ulong = TCGETA + 6;
1246 pub const TCXONC: ::c_ulong = TCGETA + 7;
1247 pub const TCQUERYCONNECTED: ::c_ulong = TCGETA + 8;
1248 pub const TCGETBITS: ::c_ulong = TCGETA + 9;
1249 pub const TCSETDTR: ::c_ulong = TCGETA + 10;
1250 pub const TCSETRTS: ::c_ulong = TCGETA + 11;
1251 pub const TIOCGWINSZ: ::c_ulong = TCGETA + 12;
1252 pub const TIOCSWINSZ: ::c_ulong = TCGETA + 13;
1253 pub const TCVTIME: ::c_ulong = TCGETA + 14;
1254 pub const TIOCGPGRP: ::c_ulong = TCGETA + 15;
1255 pub const TIOCSPGRP: ::c_ulong = TCGETA + 16;
1256 pub const TIOCSCTTY: ::c_ulong = TCGETA + 17;
1257 pub const TIOCMGET: ::c_ulong = TCGETA + 18;
1258 pub const TIOCMSET: ::c_ulong = TCGETA + 19;
1259 pub const TIOCSBRK: ::c_ulong = TCGETA + 20;
1260 pub const TIOCCBRK: ::c_ulong = TCGETA + 21;
1261 pub const TIOCMBIS: ::c_ulong = TCGETA + 22;
1262 pub const TIOCMBIC: ::c_ulong = TCGETA + 23;
1263 
1264 pub const PRIO_PROCESS: ::c_int = 0;
1265 pub const PRIO_PGRP: ::c_int = 1;
1266 pub const PRIO_USER: ::c_int = 2;
1267 
1268 pub const LOG_PID: ::c_int = 1 << 12;
1269 pub const LOG_CONS: ::c_int = 2 << 12;
1270 pub const LOG_ODELAY: ::c_int = 4 << 12;
1271 pub const LOG_NDELAY: ::c_int = 8 << 12;
1272 pub const LOG_SERIAL: ::c_int = 16 << 12;
1273 pub const LOG_PERROR: ::c_int = 32 << 12;
1274 pub const LOG_NOWAIT: ::c_int = 64 << 12;
1275 
1276 const_fn! {
1277     {const} fn CMSG_ALIGN(len: usize) -> usize {
1278         len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
1279     }
1280 }
1281 
1282 f! {
1283     pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1284         if (*mhdr).msg_controllen as usize >= ::mem::size_of::<cmsghdr>() {
1285             (*mhdr).msg_control as *mut cmsghdr
1286         } else {
1287             0 as *mut cmsghdr
1288         }
1289     }
1290 
1291     pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
1292         (cmsg as *mut ::c_uchar)
1293             .offset(CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1294     }
1295 
1296     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1297         (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
1298             as ::c_uint
1299     }
1300 
1301     pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1302         CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length
1303     }
1304 
1305     pub fn CMSG_NXTHDR(mhdr: *const msghdr,
1306                        cmsg: *const cmsghdr) -> *mut cmsghdr {
1307         if cmsg.is_null() {
1308             return ::CMSG_FIRSTHDR(mhdr);
1309         };
1310         let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)
1311             + CMSG_ALIGN(::mem::size_of::<::cmsghdr>());
1312         let max = (*mhdr).msg_control as usize
1313             + (*mhdr).msg_controllen as usize;
1314         if next > max {
1315             0 as *mut ::cmsghdr
1316         } else {
1317             (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize))
1318                 as *mut ::cmsghdr
1319         }
1320     }
1321 
1322     pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
1323         let fd = fd as usize;
1324         let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
1325         (*set).fds_bits[fd / size] &= !(1 << (fd % size));
1326         return
1327     }
1328 
1329     pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
1330         let fd = fd as usize;
1331         let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
1332         return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
1333     }
1334 
1335     pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
1336         let fd = fd as usize;
1337         let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
1338         (*set).fds_bits[fd / size] |= 1 << (fd % size);
1339         return
1340     }
1341 
1342     pub fn FD_ZERO(set: *mut fd_set) -> () {
1343         for slot in (*set).fds_bits.iter_mut() {
1344             *slot = 0;
1345         }
1346     }
1347 }
1348 
1349 safe_f! {
1350     pub {const} fn WIFEXITED(status: ::c_int) -> bool {
1351         (status & !0xff) == 0
1352     }
1353 
1354     pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
1355         status & 0xff
1356     }
1357 
1358     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1359         ((status >> 8) & 0xff) != 0
1360     }
1361 
1362     pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
1363         (status >> 8) & 0xff
1364     }
1365 
1366     pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1367         ((status >> 16) & 0xff) != 0
1368     }
1369 
1370     pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1371         (status >> 16) & 0xff
1372     }
1373 
1374     // actually WIFCORED, but this is used everywhere else
1375     pub {const} fn WCOREDUMP(status: ::c_int) -> bool {
1376         (status & 0x10000) != 0
1377     }
1378 
1379     pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1380         (status & 0x20000) != 0
1381     }
1382 }
1383 
1384 extern "C" {
getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int1385     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int1386     pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
getpriority(which: ::c_int, who: id_t) -> ::c_int1387     pub fn getpriority(which: ::c_int, who: id_t) -> ::c_int;
setpriority(which: ::c_int, who: id_t, priority: ::c_int) -> ::c_int1388     pub fn setpriority(which: ::c_int, who: id_t, priority: ::c_int) -> ::c_int;
1389 
utimensat( fd: ::c_int, path: *const ::c_char, times: *const ::timespec, flag: ::c_int, ) -> ::c_int1390     pub fn utimensat(
1391         fd: ::c_int,
1392         path: *const ::c_char,
1393         times: *const ::timespec,
1394         flag: ::c_int,
1395     ) -> ::c_int;
futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int1396     pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int1397     pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
_errnop() -> *mut ::c_int1398     pub fn _errnop() -> *mut ::c_int;
1399 
abs(i: ::c_int) -> ::c_int1400     pub fn abs(i: ::c_int) -> ::c_int;
atof(s: *const ::c_char) -> ::c_double1401     pub fn atof(s: *const ::c_char) -> ::c_double;
labs(i: ::c_long) -> ::c_long1402     pub fn labs(i: ::c_long) -> ::c_long;
rand() -> ::c_int1403     pub fn rand() -> ::c_int;
srand(seed: ::c_uint)1404     pub fn srand(seed: ::c_uint);
1405 }
1406 
1407 #[link(name = "bsd")]
1408 extern "C" {
sem_destroy(sem: *mut sem_t) -> ::c_int1409     pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int1410     pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
1411 
clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int1412     pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int1413     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_int1414     pub fn pthread_create(
1415         thread: *mut ::pthread_t,
1416         attr: *const ::pthread_attr_t,
1417         f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
1418         value: *mut ::c_void,
1419     ) -> ::c_int;
pthread_attr_getguardsize( attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int1420     pub fn pthread_attr_getguardsize(
1421         attr: *const ::pthread_attr_t,
1422         guardsize: *mut ::size_t,
1423     ) -> ::c_int;
pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t, ) -> ::c_int1424     pub fn pthread_attr_getstack(
1425         attr: *const ::pthread_attr_t,
1426         stackaddr: *mut *mut ::c_void,
1427         stacksize: *mut ::size_t,
1428     ) -> ::c_int;
pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, ) -> ::c_int1429     pub fn pthread_condattr_getclock(
1430         attr: *const pthread_condattr_t,
1431         clock_id: *mut clockid_t,
1432     ) -> ::c_int;
pthread_condattr_setclock( attr: *mut pthread_condattr_t, clock_id: ::clockid_t, ) -> ::c_int1433     pub fn pthread_condattr_setclock(
1434         attr: *mut pthread_condattr_t,
1435         clock_id: ::clockid_t,
1436     ) -> ::c_int;
valloc(numBytes: ::size_t) -> *mut ::c_void1437     pub fn valloc(numBytes: ::size_t) -> *mut ::c_void;
malloc_usable_size(ptr: *mut ::c_void) -> ::size_t1438     pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void1439     pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int1440     pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int;
ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int1441     pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int1442     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
dirfd(dirp: *mut ::DIR) -> ::c_int1443     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_int1444     pub fn getnameinfo(
1445         sa: *const ::sockaddr,
1446         salen: ::socklen_t,
1447         host: *mut ::c_char,
1448         hostlen: ::socklen_t,
1449         serv: *mut ::c_char,
1450         sevlen: ::socklen_t,
1451         flags: ::c_int,
1452     ) -> ::c_int;
pthread_mutex_timedlock( lock: *mut pthread_mutex_t, abstime: *const ::timespec, ) -> ::c_int1453     pub fn pthread_mutex_timedlock(
1454         lock: *mut pthread_mutex_t,
1455         abstime: *const ::timespec,
1456     ) -> ::c_int;
waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int1457     pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int)
1458         -> ::c_int;
1459 
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_int1460     pub fn glob(
1461         pattern: *const ::c_char,
1462         flags: ::c_int,
1463         errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
1464         pglob: *mut ::glob_t,
1465     ) -> ::c_int;
globfree(pglob: *mut ::glob_t)1466     pub fn globfree(pglob: *mut ::glob_t);
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int1467     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_int1468     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_int1469     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_int1470     pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
1471 
shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int1472     pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int;
shm_unlink(name: *const ::c_char) -> ::c_int1473     pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
1474 
seekdir(dirp: *mut ::DIR, loc: ::c_long)1475     pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
1476 
telldir(dirp: *mut ::DIR) -> ::c_long1477     pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int1478     pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
1479 
msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int1480     pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
1481 
recvfrom( socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t, ) -> ::ssize_t1482     pub fn recvfrom(
1483         socket: ::c_int,
1484         buf: *mut ::c_void,
1485         len: ::size_t,
1486         flags: ::c_int,
1487         addr: *mut ::sockaddr,
1488         addrlen: *mut ::socklen_t,
1489     ) -> ::ssize_t;
mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int1490     pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int1491     pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
nl_langinfo(item: ::nl_item) -> *mut ::c_char1492     pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
1493 
bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int1494     pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;
1495 
writev(fd: ::c_int, iov: *const ::iovec, count: ::c_int) -> ::ssize_t1496     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_t1497     pub fn readv(fd: ::c_int, iov: *const ::iovec, count: ::c_int) -> ::ssize_t;
1498 
sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t1499     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_t1500     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_int1501     pub fn execvpe(
1502         file: *const ::c_char,
1503         argv: *const *const ::c_char,
1504         environment: *const *const ::c_char,
1505     ) -> ::c_int;
getgrgid_r( gid: ::gid_t, grp: *mut ::group, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int1506     pub fn getgrgid_r(
1507         gid: ::gid_t,
1508         grp: *mut ::group,
1509         buf: *mut ::c_char,
1510         buflen: ::size_t,
1511         result: *mut *mut ::group,
1512     ) -> ::c_int;
sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int1513     pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int;
sem_close(sem: *mut sem_t) -> ::c_int1514     pub fn sem_close(sem: *mut sem_t) -> ::c_int;
getdtablesize() -> ::c_int1515     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_int1516     pub fn getgrnam_r(
1517         name: *const ::c_char,
1518         grp: *mut ::group,
1519         buf: *mut ::c_char,
1520         buflen: ::size_t,
1521         result: *mut *mut ::group,
1522     ) -> ::c_int;
pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int1523     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_t1524     pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
getgrnam(name: *const ::c_char) -> *mut ::group1525     pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int1526     pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
sem_unlink(name: *const ::c_char) -> ::c_int1527     pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int1528     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_int1529     pub fn getpwnam_r(
1530         name: *const ::c_char,
1531         pwd: *mut passwd,
1532         buf: *mut ::c_char,
1533         buflen: ::size_t,
1534         result: *mut *mut passwd,
1535     ) -> ::c_int;
getpwuid_r( uid: ::uid_t, pwd: *mut passwd, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd, ) -> ::c_int1536     pub fn getpwuid_r(
1537         uid: ::uid_t,
1538         pwd: *mut passwd,
1539         buf: *mut ::c_char,
1540         buflen: ::size_t,
1541         result: *mut *mut passwd,
1542     ) -> ::c_int;
sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int1543     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_int1544     pub fn pthread_atfork(
1545         prepare: ::Option<unsafe extern "C" fn()>,
1546         parent: ::Option<unsafe extern "C" fn()>,
1547         child: ::Option<unsafe extern "C" fn()>,
1548     ) -> ::c_int;
getgrgid(gid: ::gid_t) -> *mut ::group1549     pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE1550     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_int1551     pub fn openpty(
1552         amaster: *mut ::c_int,
1553         aslave: *mut ::c_int,
1554         name: *mut ::c_char,
1555         termp: *mut termios,
1556         winp: *mut ::winsize,
1557     ) -> ::c_int;
forkpty( amaster: *mut ::c_int, name: *mut ::c_char, termp: *mut termios, winp: *mut ::winsize, ) -> ::pid_t1558     pub fn forkpty(
1559         amaster: *mut ::c_int,
1560         name: *mut ::c_char,
1561         termp: *mut termios,
1562         winp: *mut ::winsize,
1563     ) -> ::pid_t;
sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int1564     pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
uname(buf: *mut ::utsname) -> ::c_int1565     pub fn uname(buf: *mut ::utsname) -> ::c_int;
1566 }
1567 
1568 cfg_if! {
1569     if #[cfg(target_pointer_width = "64")] {
1570         mod b64;
1571         pub use self::b64::*;
1572     } else {
1573         mod b32;
1574         pub use self::b32::*;
1575     }
1576 }
1577 
1578 cfg_if! {
1579     if #[cfg(target_arch = "x86")] {
1580         // TODO
1581         // mod x86;
1582         // pub use self::x86::*;
1583     } else if #[cfg(target_arch = "x86_64")] {
1584         mod x86_64;
1585         pub use self::x86_64::*;
1586     } else if #[cfg(target_arch = "aarch64")] {
1587         // TODO
1588         // mod aarch64;
1589         // pub use self::aarch64::*;
1590     }
1591 }
1592 
1593 mod native;
1594 pub use self::native::*;
1595