1 pub type c_char = i8;
2 pub type wchar_t = i32;
3 pub type useconds_t = u32;
4 pub type dev_t = u32;
5 pub type socklen_t = u32;
6 pub type pthread_t = c_ulong;
7 pub type mode_t = u32;
8 pub type shmatt_t = ::c_ulong;
9 pub type mqd_t = ::c_int;
10 pub type msgqnum_t = ::c_ulong;
11 pub type msglen_t = ::c_ulong;
12 pub type nfds_t = ::c_ulong;
13 pub type nl_item = ::c_int;
14 pub type idtype_t = ::c_uint;
15 pub type loff_t = i64;
16 pub type pthread_key_t = ::c_uint;
17 
18 pub type clock_t = c_long;
19 pub type time_t = i64;
20 pub type suseconds_t = c_long;
21 pub type ino_t = u64;
22 pub type off_t = i64;
23 pub type blkcnt_t = i32;
24 
25 pub type blksize_t = c_long;
26 pub type fsblkcnt_t = u32;
27 pub type fsfilcnt_t = u32;
28 pub type rlim_t = u64;
29 pub type c_long = i32;
30 pub type c_ulong = u32;
31 pub type nlink_t = u32;
32 
33 pub type ino64_t = ::ino_t;
34 pub type off64_t = ::off_t;
35 pub type blkcnt64_t = ::blkcnt_t;
36 pub type rlim64_t = ::rlim_t;
37 
38 pub type rlimit64 = ::rlimit;
39 pub type flock64 = ::flock;
40 pub type stat64 = ::stat;
41 pub type statfs64 = ::statfs;
42 pub type statvfs64 = ::statvfs;
43 pub type dirent64 = ::dirent;
44 
45 #[cfg_attr(feature = "extra_traits", derive(Debug))]
46 pub enum fpos64_t {} // FIXME: fill this out with a struct
47 impl ::Copy for fpos64_t {}
48 impl ::Clone for fpos64_t {
49     fn clone(&self) -> fpos64_t {
50         *self
51     }
52 }
53 
54 s! {
55     pub struct glob_t {
56         pub gl_pathc: ::size_t,
57         pub gl_pathv: *mut *mut c_char,
58         pub gl_offs: ::size_t,
59         pub gl_flags: ::c_int,
60 
61         __unused1: *mut ::c_void,
62         __unused2: *mut ::c_void,
63         __unused3: *mut ::c_void,
64         __unused4: *mut ::c_void,
65         __unused5: *mut ::c_void,
66     }
67 
68     pub struct passwd {
69         pub pw_name: *mut ::c_char,
70         pub pw_passwd: *mut ::c_char,
71         pub pw_uid: ::uid_t,
72         pub pw_gid: ::gid_t,
73         pub pw_gecos: *mut ::c_char,
74         pub pw_dir: *mut ::c_char,
75         pub pw_shell: *mut ::c_char,
76     }
77 
78     pub struct spwd {
79         pub sp_namp: *mut ::c_char,
80         pub sp_pwdp: *mut ::c_char,
81         pub sp_lstchg: ::c_long,
82         pub sp_min: ::c_long,
83         pub sp_max: ::c_long,
84         pub sp_warn: ::c_long,
85         pub sp_inact: ::c_long,
86         pub sp_expire: ::c_long,
87         pub sp_flag: ::c_ulong,
88     }
89 
90     pub struct statvfs {
91         pub f_bsize: ::c_ulong,
92         pub f_frsize: ::c_ulong,
93         pub f_blocks: ::fsblkcnt_t,
94         pub f_bfree: ::fsblkcnt_t,
95         pub f_bavail: ::fsblkcnt_t,
96         pub f_files: ::fsfilcnt_t,
97         pub f_ffree: ::fsfilcnt_t,
98         pub f_favail: ::fsfilcnt_t,
99         pub f_fsid: ::c_ulong,
100         __f_unused: ::c_int,
101         pub f_flag: ::c_ulong,
102         pub f_namemax: ::c_ulong,
103         __f_spare: [::c_int; 6],
104     }
105 
106     pub struct signalfd_siginfo {
107         pub ssi_signo: u32,
108         pub ssi_errno: i32,
109         pub ssi_code: i32,
110         pub ssi_pid: u32,
111         pub ssi_uid: u32,
112         pub ssi_fd: i32,
113         pub ssi_tid: u32,
114         pub ssi_band: u32,
115         pub ssi_overrun: u32,
116         pub ssi_trapno: u32,
117         pub ssi_status: i32,
118         pub ssi_int: i32,
119         pub ssi_ptr: u64,
120         pub ssi_utime: u64,
121         pub ssi_stime: u64,
122         pub ssi_addr: u64,
123         pub ssi_addr_lsb: u16,
124         _pad2: u16,
125         pub ssi_syscall: i32,
126         pub ssi_call_addr: u64,
127         pub ssi_arch: u32,
128         _pad: [u8; 28],
129     }
130 
131     pub struct fsid_t {
132         __val: [::c_int; 2],
133     }
134 
135     pub struct cpu_set_t {
136         bits: [u32; 32],
137     }
138 
139     pub struct if_nameindex {
140         pub if_index: ::c_uint,
141         pub if_name: *mut ::c_char,
142     }
143 
144     // System V IPC
145     pub struct msginfo {
146         pub msgpool: ::c_int,
147         pub msgmap: ::c_int,
148         pub msgmax: ::c_int,
149         pub msgmnb: ::c_int,
150         pub msgmni: ::c_int,
151         pub msgssz: ::c_int,
152         pub msgtql: ::c_int,
153         pub msgseg: ::c_ushort,
154     }
155 
156     pub struct sembuf {
157         pub sem_num: ::c_ushort,
158         pub sem_op: ::c_short,
159         pub sem_flg: ::c_short,
160     }
161 
162     pub struct sigaction {
163         pub sa_sigaction: ::sighandler_t,
164         pub sa_mask: ::sigset_t,
165         pub sa_flags: ::c_int,
166         pub sa_restorer: ::Option<extern fn()>,
167     }
168 
169     pub struct ipc_perm {
170         pub __ipc_perm_key: ::key_t,
171         pub uid: ::uid_t,
172         pub gid: ::gid_t,
173         pub cuid: ::uid_t,
174         pub cgid: ::gid_t,
175         pub mode: ::mode_t,
176         pub __seq: ::c_int,
177         __unused1: ::c_long,
178         __unused2: ::c_long
179     }
180 
181     pub struct termios {
182         pub c_iflag: ::tcflag_t,
183         pub c_oflag: ::tcflag_t,
184         pub c_cflag: ::tcflag_t,
185         pub c_lflag: ::tcflag_t,
186         pub c_line: ::cc_t,
187         pub c_cc: [::cc_t; ::NCCS],
188         pub __c_ispeed: ::speed_t,
189         pub __c_ospeed: ::speed_t,
190     }
191 
192     pub struct flock {
193         pub l_type: ::c_short,
194         pub l_whence: ::c_short,
195         pub l_start: ::off_t,
196         pub l_len: ::off_t,
197         pub l_pid: ::pid_t,
198     }
199 
200     pub struct pthread_attr_t {
201         __size: [u32; 11]
202     }
203 
204     pub struct sigset_t {
205         __val: [::c_ulong; 32],
206     }
207 
208     pub struct msghdr {
209         pub msg_name: *mut ::c_void,
210         pub msg_namelen: ::socklen_t,
211         pub msg_iov: *mut ::iovec,
212         pub msg_iovlen: ::c_int,
213         pub msg_control: *mut ::c_void,
214         pub msg_controllen: ::socklen_t,
215         pub msg_flags: ::c_int,
216     }
217 
218     pub struct cmsghdr {
219         pub cmsg_len: ::socklen_t,
220         pub cmsg_level: ::c_int,
221         pub cmsg_type: ::c_int,
222     }
223 
224     pub struct sem_t {
225         __val: [::c_int; 4],
226     }
227     pub struct stat {
228         pub st_dev: ::dev_t,
229         #[cfg(not(emscripten_new_stat_abi))]
230         __st_dev_padding: ::c_int,
231         #[cfg(not(emscripten_new_stat_abi))]
232         __st_ino_truncated: ::c_long,
233         pub st_mode: ::mode_t,
234         pub st_nlink: ::nlink_t,
235         pub st_uid: ::uid_t,
236         pub st_gid: ::gid_t,
237         pub st_rdev: ::dev_t,
238         #[cfg(not(emscripten_new_stat_abi))]
239         __st_rdev_padding: ::c_int,
240         pub st_size: ::off_t,
241         pub st_blksize: ::blksize_t,
242         pub st_blocks: ::blkcnt_t,
243         pub st_atime: ::time_t,
244         pub st_atime_nsec: ::c_long,
245         pub st_mtime: ::time_t,
246         pub st_mtime_nsec: ::c_long,
247         pub st_ctime: ::time_t,
248         pub st_ctime_nsec: ::c_long,
249         pub st_ino: ::ino_t,
250     }
251 
252     pub struct stack_t {
253         pub ss_sp: *mut ::c_void,
254         pub ss_flags: ::c_int,
255         pub ss_size: ::size_t
256     }
257 
258     pub struct shmid_ds {
259         pub shm_perm: ::ipc_perm,
260         pub shm_segsz: ::size_t,
261         pub shm_atime: ::time_t,
262         pub shm_dtime: ::time_t,
263         pub shm_ctime: ::time_t,
264         pub shm_cpid: ::pid_t,
265         pub shm_lpid: ::pid_t,
266         pub shm_nattch: ::c_ulong,
267         __pad1: ::c_ulong,
268         __pad2: ::c_ulong,
269     }
270 
271     pub struct msqid_ds {
272         pub msg_perm: ::ipc_perm,
273         pub msg_stime: ::time_t,
274         pub msg_rtime: ::time_t,
275         pub msg_ctime: ::time_t,
276         __msg_cbytes: ::c_ulong,
277         pub msg_qnum: ::msgqnum_t,
278         pub msg_qbytes: ::msglen_t,
279         pub msg_lspid: ::pid_t,
280         pub msg_lrpid: ::pid_t,
281         __pad1: ::c_ulong,
282         __pad2: ::c_ulong,
283     }
284 
285     pub struct statfs {
286         pub f_type: ::c_ulong,
287         pub f_bsize: ::c_ulong,
288         pub f_blocks: ::fsblkcnt_t,
289         pub f_bfree: ::fsblkcnt_t,
290         pub f_bavail: ::fsblkcnt_t,
291         pub f_files: ::fsfilcnt_t,
292         pub f_ffree: ::fsfilcnt_t,
293         pub f_fsid: ::fsid_t,
294         pub f_namelen: ::c_ulong,
295         pub f_frsize: ::c_ulong,
296         pub f_flags: ::c_ulong,
297         pub f_spare: [::c_ulong; 4],
298     }
299 
300     pub struct siginfo_t {
301         pub si_signo: ::c_int,
302         pub si_errno: ::c_int,
303         pub si_code: ::c_int,
304         pub _pad: [::c_int; 29],
305         _align: [usize; 0],
306     }
307 
308     pub struct arpd_request {
309         pub req: ::c_ushort,
310         pub ip: u32,
311         pub dev: ::c_ulong,
312         pub stamp: ::c_ulong,
313         pub updated: ::c_ulong,
314         pub ha: [::c_uchar; ::MAX_ADDR_LEN],
315     }
316 
317     #[allow(missing_debug_implementations)]
318     #[repr(align(4))]
319     pub struct pthread_mutex_t {
320         size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
321     }
322 
323     #[repr(align(4))]
324     pub struct pthread_rwlock_t {
325         size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
326     }
327 
328     #[repr(align(4))]
329     pub struct pthread_mutexattr_t {
330         size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
331     }
332 
333     #[repr(align(4))]
334     pub struct pthread_rwlockattr_t {
335         size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
336     }
337 
338     #[repr(align(4))]
339     pub struct pthread_condattr_t {
340         size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
341     }
342 }
343 
344 s_no_extra_traits! {
345     pub struct dirent {
346         pub d_ino: ::ino_t,
347         pub d_off: ::off_t,
348         pub d_reclen: ::c_ushort,
349         pub d_type: ::c_uchar,
350         pub d_name: [::c_char; 256],
351     }
352 
353     pub struct sysinfo {
354         pub uptime: ::c_ulong,
355         pub loads: [::c_ulong; 3],
356         pub totalram: ::c_ulong,
357         pub freeram: ::c_ulong,
358         pub sharedram: ::c_ulong,
359         pub bufferram: ::c_ulong,
360         pub totalswap: ::c_ulong,
361         pub freeswap: ::c_ulong,
362         pub procs: ::c_ushort,
363         pub pad: ::c_ushort,
364         pub totalhigh: ::c_ulong,
365         pub freehigh: ::c_ulong,
366         pub mem_unit: ::c_uint,
367         pub __reserved: [::c_char; 256],
368     }
369 
370     pub struct mq_attr {
371         pub mq_flags: ::c_long,
372         pub mq_maxmsg: ::c_long,
373         pub mq_msgsize: ::c_long,
374         pub mq_curmsgs: ::c_long,
375         pad: [::c_long; 4]
376     }
377 
378     #[cfg_attr(target_pointer_width = "32",
379                repr(align(4)))]
380     #[cfg_attr(target_pointer_width = "64",
381                repr(align(8)))]
382     pub struct pthread_cond_t {
383         size: [u8; ::__SIZEOF_PTHREAD_COND_T],
384     }
385 
386     #[allow(missing_debug_implementations)]
387     #[repr(align(8))]
388     pub struct max_align_t {
389         priv_: [f64; 3]
390     }
391 }
392 
393 cfg_if! {
394     if #[cfg(feature = "extra_traits")] {
395         impl PartialEq for dirent {
396             fn eq(&self, other: &dirent) -> bool {
397                 self.d_ino == other.d_ino
398                     && self.d_off == other.d_off
399                     && self.d_reclen == other.d_reclen
400                     && self.d_type == other.d_type
401                     && self
402                     .d_name
403                     .iter()
404                     .zip(other.d_name.iter())
405                     .all(|(a,b)| a == b)
406             }
407         }
408         impl Eq for dirent {}
409         impl ::fmt::Debug for dirent {
410             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
411                 f.debug_struct("dirent")
412                     .field("d_ino", &self.d_ino)
413                     .field("d_off", &self.d_off)
414                     .field("d_reclen", &self.d_reclen)
415                     .field("d_type", &self.d_type)
416                     // FIXME: .field("d_name", &self.d_name)
417                     .finish()
418             }
419         }
420         impl ::hash::Hash for dirent {
421             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
422                 self.d_ino.hash(state);
423                 self.d_off.hash(state);
424                 self.d_reclen.hash(state);
425                 self.d_type.hash(state);
426                 self.d_name.hash(state);
427             }
428         }
429 
430         impl PartialEq for sysinfo {
431             fn eq(&self, other: &sysinfo) -> bool {
432                 self.uptime == other.uptime
433                     && self.loads == other.loads
434                     && self.totalram == other.totalram
435                     && self.freeram == other.freeram
436                     && self.sharedram == other.sharedram
437                     && self.bufferram == other.bufferram
438                     && self.totalswap == other.totalswap
439                     && self.freeswap == other.freeswap
440                     && self.procs == other.procs
441                     && self.pad == other.pad
442                     && self.totalhigh == other.totalhigh
443                     && self.freehigh == other.freehigh
444                     && self.mem_unit == other.mem_unit
445                     && self
446                     .__reserved
447                     .iter()
448                     .zip(other.__reserved.iter())
449                     .all(|(a,b)| a == b)
450             }
451         }
452         impl Eq for sysinfo {}
453         impl ::fmt::Debug for sysinfo {
454             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
455                 f.debug_struct("sysinfo")
456                     .field("uptime", &self.uptime)
457                     .field("loads", &self.loads)
458                     .field("totalram", &self.totalram)
459                     .field("freeram", &self.freeram)
460                     .field("sharedram", &self.sharedram)
461                     .field("bufferram", &self.bufferram)
462                     .field("totalswap", &self.totalswap)
463                     .field("freeswap", &self.freeswap)
464                     .field("procs", &self.procs)
465                     .field("pad", &self.pad)
466                     .field("totalhigh", &self.totalhigh)
467                     .field("freehigh", &self.freehigh)
468                     .field("mem_unit", &self.mem_unit)
469                     // FIXME: .field("__reserved", &self.__reserved)
470                     .finish()
471             }
472         }
473         impl ::hash::Hash for sysinfo {
474             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
475                 self.uptime.hash(state);
476                 self.loads.hash(state);
477                 self.totalram.hash(state);
478                 self.freeram.hash(state);
479                 self.sharedram.hash(state);
480                 self.bufferram.hash(state);
481                 self.totalswap.hash(state);
482                 self.freeswap.hash(state);
483                 self.procs.hash(state);
484                 self.pad.hash(state);
485                 self.totalhigh.hash(state);
486                 self.freehigh.hash(state);
487                 self.mem_unit.hash(state);
488                 self.__reserved.hash(state);
489             }
490         }
491 
492         impl PartialEq for mq_attr {
493             fn eq(&self, other: &mq_attr) -> bool {
494                 self.mq_flags == other.mq_flags &&
495                 self.mq_maxmsg == other.mq_maxmsg &&
496                 self.mq_msgsize == other.mq_msgsize &&
497                 self.mq_curmsgs == other.mq_curmsgs
498             }
499         }
500         impl Eq for mq_attr {}
501         impl ::fmt::Debug for mq_attr {
502             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
503                 f.debug_struct("mq_attr")
504                     .field("mq_flags", &self.mq_flags)
505                     .field("mq_maxmsg", &self.mq_maxmsg)
506                     .field("mq_msgsize", &self.mq_msgsize)
507                     .field("mq_curmsgs", &self.mq_curmsgs)
508                     .finish()
509             }
510         }
511         impl ::hash::Hash for mq_attr {
512             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
513                 self.mq_flags.hash(state);
514                 self.mq_maxmsg.hash(state);
515                 self.mq_msgsize.hash(state);
516                 self.mq_curmsgs.hash(state);
517             }
518         }
519 
520         impl PartialEq for pthread_cond_t {
521             fn eq(&self, other: &pthread_cond_t) -> bool {
522                 self.size
523                     .iter()
524                     .zip(other.size.iter())
525                     .all(|(a,b)| a == b)
526             }
527         }
528         impl Eq for pthread_cond_t {}
529         impl ::fmt::Debug for pthread_cond_t {
530             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
531                 f.debug_struct("pthread_cond_t")
532                     // FIXME: .field("size", &self.size)
533                     .finish()
534             }
535         }
536         impl ::hash::Hash for pthread_cond_t {
537             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
538                 self.size.hash(state);
539             }
540         }
541     }
542 }
543 
544 pub const MADV_SOFT_OFFLINE: ::c_int = 101;
545 pub const MS_NOUSER: ::c_ulong = 0x80000000;
546 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
547 
548 pub const ABDAY_1: ::nl_item = 0x20000;
549 pub const ABDAY_2: ::nl_item = 0x20001;
550 pub const ABDAY_3: ::nl_item = 0x20002;
551 pub const ABDAY_4: ::nl_item = 0x20003;
552 pub const ABDAY_5: ::nl_item = 0x20004;
553 pub const ABDAY_6: ::nl_item = 0x20005;
554 pub const ABDAY_7: ::nl_item = 0x20006;
555 
556 pub const DAY_1: ::nl_item = 0x20007;
557 pub const DAY_2: ::nl_item = 0x20008;
558 pub const DAY_3: ::nl_item = 0x20009;
559 pub const DAY_4: ::nl_item = 0x2000A;
560 pub const DAY_5: ::nl_item = 0x2000B;
561 pub const DAY_6: ::nl_item = 0x2000C;
562 pub const DAY_7: ::nl_item = 0x2000D;
563 
564 pub const ABMON_1: ::nl_item = 0x2000E;
565 pub const ABMON_2: ::nl_item = 0x2000F;
566 pub const ABMON_3: ::nl_item = 0x20010;
567 pub const ABMON_4: ::nl_item = 0x20011;
568 pub const ABMON_5: ::nl_item = 0x20012;
569 pub const ABMON_6: ::nl_item = 0x20013;
570 pub const ABMON_7: ::nl_item = 0x20014;
571 pub const ABMON_8: ::nl_item = 0x20015;
572 pub const ABMON_9: ::nl_item = 0x20016;
573 pub const ABMON_10: ::nl_item = 0x20017;
574 pub const ABMON_11: ::nl_item = 0x20018;
575 pub const ABMON_12: ::nl_item = 0x20019;
576 
577 pub const MON_1: ::nl_item = 0x2001A;
578 pub const MON_2: ::nl_item = 0x2001B;
579 pub const MON_3: ::nl_item = 0x2001C;
580 pub const MON_4: ::nl_item = 0x2001D;
581 pub const MON_5: ::nl_item = 0x2001E;
582 pub const MON_6: ::nl_item = 0x2001F;
583 pub const MON_7: ::nl_item = 0x20020;
584 pub const MON_8: ::nl_item = 0x20021;
585 pub const MON_9: ::nl_item = 0x20022;
586 pub const MON_10: ::nl_item = 0x20023;
587 pub const MON_11: ::nl_item = 0x20024;
588 pub const MON_12: ::nl_item = 0x20025;
589 
590 pub const AM_STR: ::nl_item = 0x20026;
591 pub const PM_STR: ::nl_item = 0x20027;
592 
593 pub const D_T_FMT: ::nl_item = 0x20028;
594 pub const D_FMT: ::nl_item = 0x20029;
595 pub const T_FMT: ::nl_item = 0x2002A;
596 pub const T_FMT_AMPM: ::nl_item = 0x2002B;
597 
598 pub const ERA: ::nl_item = 0x2002C;
599 pub const ERA_D_FMT: ::nl_item = 0x2002E;
600 pub const ALT_DIGITS: ::nl_item = 0x2002F;
601 pub const ERA_D_T_FMT: ::nl_item = 0x20030;
602 pub const ERA_T_FMT: ::nl_item = 0x20031;
603 
604 pub const CODESET: ::nl_item = 14;
605 
606 pub const CRNCYSTR: ::nl_item = 0x4000F;
607 
608 pub const RUSAGE_THREAD: ::c_int = 1;
609 pub const RUSAGE_CHILDREN: ::c_int = -1;
610 
611 pub const RADIXCHAR: ::nl_item = 0x10000;
612 pub const THOUSEP: ::nl_item = 0x10001;
613 
614 pub const YESEXPR: ::nl_item = 0x50000;
615 pub const NOEXPR: ::nl_item = 0x50001;
616 pub const YESSTR: ::nl_item = 0x50002;
617 pub const NOSTR: ::nl_item = 0x50003;
618 
619 pub const FILENAME_MAX: ::c_uint = 4096;
620 pub const L_tmpnam: ::c_uint = 20;
621 pub const _PC_LINK_MAX: ::c_int = 0;
622 pub const _PC_MAX_CANON: ::c_int = 1;
623 pub const _PC_MAX_INPUT: ::c_int = 2;
624 pub const _PC_NAME_MAX: ::c_int = 3;
625 pub const _PC_PATH_MAX: ::c_int = 4;
626 pub const _PC_PIPE_BUF: ::c_int = 5;
627 pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
628 pub const _PC_NO_TRUNC: ::c_int = 7;
629 pub const _PC_VDISABLE: ::c_int = 8;
630 pub const _PC_SYNC_IO: ::c_int = 9;
631 pub const _PC_ASYNC_IO: ::c_int = 10;
632 pub const _PC_PRIO_IO: ::c_int = 11;
633 pub const _PC_SOCK_MAXBUF: ::c_int = 12;
634 pub const _PC_FILESIZEBITS: ::c_int = 13;
635 pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
636 pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
637 pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
638 pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
639 pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
640 pub const _PC_SYMLINK_MAX: ::c_int = 19;
641 pub const _PC_2_SYMLINKS: ::c_int = 20;
642 
643 pub const _SC_ARG_MAX: ::c_int = 0;
644 pub const _SC_CHILD_MAX: ::c_int = 1;
645 pub const _SC_CLK_TCK: ::c_int = 2;
646 pub const _SC_NGROUPS_MAX: ::c_int = 3;
647 pub const _SC_OPEN_MAX: ::c_int = 4;
648 pub const _SC_STREAM_MAX: ::c_int = 5;
649 pub const _SC_TZNAME_MAX: ::c_int = 6;
650 pub const _SC_JOB_CONTROL: ::c_int = 7;
651 pub const _SC_SAVED_IDS: ::c_int = 8;
652 pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
653 pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
654 pub const _SC_TIMERS: ::c_int = 11;
655 pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
656 pub const _SC_PRIORITIZED_IO: ::c_int = 13;
657 pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
658 pub const _SC_FSYNC: ::c_int = 15;
659 pub const _SC_MAPPED_FILES: ::c_int = 16;
660 pub const _SC_MEMLOCK: ::c_int = 17;
661 pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
662 pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
663 pub const _SC_MESSAGE_PASSING: ::c_int = 20;
664 pub const _SC_SEMAPHORES: ::c_int = 21;
665 pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
666 pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
667 pub const _SC_AIO_MAX: ::c_int = 24;
668 pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
669 pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
670 pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
671 pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
672 pub const _SC_VERSION: ::c_int = 29;
673 pub const _SC_PAGESIZE: ::c_int = 30;
674 pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
675 pub const _SC_RTSIG_MAX: ::c_int = 31;
676 pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
677 pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
678 pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
679 pub const _SC_TIMER_MAX: ::c_int = 35;
680 pub const _SC_BC_BASE_MAX: ::c_int = 36;
681 pub const _SC_BC_DIM_MAX: ::c_int = 37;
682 pub const _SC_BC_SCALE_MAX: ::c_int = 38;
683 pub const _SC_BC_STRING_MAX: ::c_int = 39;
684 pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
685 pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
686 pub const _SC_LINE_MAX: ::c_int = 43;
687 pub const _SC_RE_DUP_MAX: ::c_int = 44;
688 pub const _SC_2_VERSION: ::c_int = 46;
689 pub const _SC_2_C_BIND: ::c_int = 47;
690 pub const _SC_2_C_DEV: ::c_int = 48;
691 pub const _SC_2_FORT_DEV: ::c_int = 49;
692 pub const _SC_2_FORT_RUN: ::c_int = 50;
693 pub const _SC_2_SW_DEV: ::c_int = 51;
694 pub const _SC_2_LOCALEDEF: ::c_int = 52;
695 pub const _SC_UIO_MAXIOV: ::c_int = 60;
696 pub const _SC_IOV_MAX: ::c_int = 60;
697 pub const _SC_THREADS: ::c_int = 67;
698 pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
699 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
700 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
701 pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
702 pub const _SC_TTY_NAME_MAX: ::c_int = 72;
703 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
704 pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
705 pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
706 pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
707 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
708 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
709 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
710 pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
711 pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
712 pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82;
713 pub const _SC_NPROCESSORS_CONF: ::c_int = 83;
714 pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
715 pub const _SC_PHYS_PAGES: ::c_int = 85;
716 pub const _SC_AVPHYS_PAGES: ::c_int = 86;
717 pub const _SC_ATEXIT_MAX: ::c_int = 87;
718 pub const _SC_PASS_MAX: ::c_int = 88;
719 pub const _SC_XOPEN_VERSION: ::c_int = 89;
720 pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
721 pub const _SC_XOPEN_UNIX: ::c_int = 91;
722 pub const _SC_XOPEN_CRYPT: ::c_int = 92;
723 pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
724 pub const _SC_XOPEN_SHM: ::c_int = 94;
725 pub const _SC_2_CHAR_TERM: ::c_int = 95;
726 pub const _SC_2_UPE: ::c_int = 97;
727 pub const _SC_XOPEN_XPG2: ::c_int = 98;
728 pub const _SC_XOPEN_XPG3: ::c_int = 99;
729 pub const _SC_XOPEN_XPG4: ::c_int = 100;
730 pub const _SC_NZERO: ::c_int = 109;
731 pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
732 pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
733 pub const _SC_XBS5_LP64_OFF64: ::c_int = 127;
734 pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
735 pub const _SC_XOPEN_LEGACY: ::c_int = 129;
736 pub const _SC_XOPEN_REALTIME: ::c_int = 130;
737 pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
738 pub const _SC_ADVISORY_INFO: ::c_int = 132;
739 pub const _SC_BARRIERS: ::c_int = 133;
740 pub const _SC_CLOCK_SELECTION: ::c_int = 137;
741 pub const _SC_CPUTIME: ::c_int = 138;
742 pub const _SC_THREAD_CPUTIME: ::c_int = 139;
743 pub const _SC_MONOTONIC_CLOCK: ::c_int = 149;
744 pub const _SC_READER_WRITER_LOCKS: ::c_int = 153;
745 pub const _SC_SPIN_LOCKS: ::c_int = 154;
746 pub const _SC_REGEXP: ::c_int = 155;
747 pub const _SC_SHELL: ::c_int = 157;
748 pub const _SC_SPAWN: ::c_int = 159;
749 pub const _SC_SPORADIC_SERVER: ::c_int = 160;
750 pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161;
751 pub const _SC_TIMEOUTS: ::c_int = 164;
752 pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165;
753 pub const _SC_2_PBS: ::c_int = 168;
754 pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169;
755 pub const _SC_2_PBS_LOCATE: ::c_int = 170;
756 pub const _SC_2_PBS_MESSAGE: ::c_int = 171;
757 pub const _SC_2_PBS_TRACK: ::c_int = 172;
758 pub const _SC_SYMLOOP_MAX: ::c_int = 173;
759 pub const _SC_STREAMS: ::c_int = 174;
760 pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175;
761 pub const _SC_V6_ILP32_OFF32: ::c_int = 176;
762 pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177;
763 pub const _SC_V6_LP64_OFF64: ::c_int = 178;
764 pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179;
765 pub const _SC_HOST_NAME_MAX: ::c_int = 180;
766 pub const _SC_TRACE: ::c_int = 181;
767 pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182;
768 pub const _SC_TRACE_INHERIT: ::c_int = 183;
769 pub const _SC_TRACE_LOG: ::c_int = 184;
770 pub const _SC_IPV6: ::c_int = 235;
771 pub const _SC_RAW_SOCKETS: ::c_int = 236;
772 pub const _SC_V7_ILP32_OFF32: ::c_int = 237;
773 pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238;
774 pub const _SC_V7_LP64_OFF64: ::c_int = 239;
775 pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240;
776 pub const _SC_SS_REPL_MAX: ::c_int = 241;
777 pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242;
778 pub const _SC_TRACE_NAME_MAX: ::c_int = 243;
779 pub const _SC_TRACE_SYS_MAX: ::c_int = 244;
780 pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245;
781 pub const _SC_XOPEN_STREAMS: ::c_int = 246;
782 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247;
783 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248;
784 
785 pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
786 pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
787 
788 pub const GLOB_ERR: ::c_int = 1 << 0;
789 pub const GLOB_MARK: ::c_int = 1 << 1;
790 pub const GLOB_NOSORT: ::c_int = 1 << 2;
791 pub const GLOB_DOOFFS: ::c_int = 1 << 3;
792 pub const GLOB_NOCHECK: ::c_int = 1 << 4;
793 pub const GLOB_APPEND: ::c_int = 1 << 5;
794 pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
795 
796 pub const GLOB_NOSPACE: ::c_int = 1;
797 pub const GLOB_ABORTED: ::c_int = 2;
798 pub const GLOB_NOMATCH: ::c_int = 3;
799 
800 pub const POSIX_MADV_NORMAL: ::c_int = 0;
801 pub const POSIX_MADV_RANDOM: ::c_int = 1;
802 pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
803 pub const POSIX_MADV_WILLNEED: ::c_int = 3;
804 
805 pub const AT_EACCESS: ::c_int = 0x200;
806 
807 pub const S_IEXEC: mode_t = 0o0100;
808 pub const S_IWRITE: mode_t = 0o0200;
809 pub const S_IREAD: mode_t = 0o0400;
810 
811 pub const F_LOCK: ::c_int = 1;
812 pub const F_TEST: ::c_int = 3;
813 pub const F_TLOCK: ::c_int = 2;
814 pub const F_ULOCK: ::c_int = 0;
815 
816 pub const ST_RDONLY: ::c_ulong = 1;
817 pub const ST_NOSUID: ::c_ulong = 2;
818 pub const ST_NODEV: ::c_ulong = 4;
819 pub const ST_NOEXEC: ::c_ulong = 8;
820 pub const ST_SYNCHRONOUS: ::c_ulong = 16;
821 pub const ST_MANDLOCK: ::c_ulong = 64;
822 pub const ST_WRITE: ::c_ulong = 128;
823 pub const ST_APPEND: ::c_ulong = 256;
824 pub const ST_IMMUTABLE: ::c_ulong = 512;
825 pub const ST_NOATIME: ::c_ulong = 1024;
826 pub const ST_NODIRATIME: ::c_ulong = 2048;
827 
828 pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
829 pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
830 pub const RTLD_NODELETE: ::c_int = 0x1000;
831 pub const RTLD_NOW: ::c_int = 0x2;
832 
833 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
834     size: [0; __SIZEOF_PTHREAD_MUTEX_T],
835 };
836 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
837     size: [0; __SIZEOF_PTHREAD_COND_T],
838 };
839 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
840     size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
841 };
842 
843 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
844 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
845 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
846 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
847 pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
848 pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
849 pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
850 
851 pub const SCHED_OTHER: ::c_int = 0;
852 pub const SCHED_FIFO: ::c_int = 1;
853 pub const SCHED_RR: ::c_int = 2;
854 pub const SCHED_BATCH: ::c_int = 3;
855 pub const SCHED_IDLE: ::c_int = 5;
856 
857 pub const AF_IB: ::c_int = 27;
858 pub const AF_MPLS: ::c_int = 28;
859 pub const AF_NFC: ::c_int = 39;
860 pub const AF_VSOCK: ::c_int = 40;
861 pub const PF_IB: ::c_int = AF_IB;
862 pub const PF_MPLS: ::c_int = AF_MPLS;
863 pub const PF_NFC: ::c_int = AF_NFC;
864 pub const PF_VSOCK: ::c_int = AF_VSOCK;
865 
866 // System V IPC
867 pub const IPC_PRIVATE: ::key_t = 0;
868 
869 pub const IPC_CREAT: ::c_int = 0o1000;
870 pub const IPC_EXCL: ::c_int = 0o2000;
871 pub const IPC_NOWAIT: ::c_int = 0o4000;
872 
873 pub const IPC_RMID: ::c_int = 0;
874 pub const IPC_SET: ::c_int = 1;
875 pub const IPC_STAT: ::c_int = 2;
876 pub const IPC_INFO: ::c_int = 3;
877 pub const MSG_STAT: ::c_int = 11;
878 pub const MSG_INFO: ::c_int = 12;
879 
880 pub const MSG_NOERROR: ::c_int = 0o10000;
881 pub const MSG_EXCEPT: ::c_int = 0o20000;
882 
883 pub const SHM_R: ::c_int = 0o400;
884 pub const SHM_W: ::c_int = 0o200;
885 
886 pub const SHM_RDONLY: ::c_int = 0o10000;
887 pub const SHM_RND: ::c_int = 0o20000;
888 pub const SHM_REMAP: ::c_int = 0o40000;
889 pub const SHM_EXEC: ::c_int = 0o100000;
890 
891 pub const SHM_LOCK: ::c_int = 11;
892 pub const SHM_UNLOCK: ::c_int = 12;
893 
894 pub const SHM_HUGETLB: ::c_int = 0o4000;
895 pub const SHM_NORESERVE: ::c_int = 0o10000;
896 
897 pub const LOG_NFACILITIES: ::c_int = 24;
898 
899 pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
900 
901 pub const AI_PASSIVE: ::c_int = 0x0001;
902 pub const AI_CANONNAME: ::c_int = 0x0002;
903 pub const AI_NUMERICHOST: ::c_int = 0x0004;
904 pub const AI_V4MAPPED: ::c_int = 0x0008;
905 pub const AI_ALL: ::c_int = 0x0010;
906 pub const AI_ADDRCONFIG: ::c_int = 0x0020;
907 
908 pub const AI_NUMERICSERV: ::c_int = 0x0400;
909 
910 pub const EAI_BADFLAGS: ::c_int = -1;
911 pub const EAI_NONAME: ::c_int = -2;
912 pub const EAI_AGAIN: ::c_int = -3;
913 pub const EAI_FAIL: ::c_int = -4;
914 pub const EAI_FAMILY: ::c_int = -6;
915 pub const EAI_SOCKTYPE: ::c_int = -7;
916 pub const EAI_SERVICE: ::c_int = -8;
917 pub const EAI_MEMORY: ::c_int = -10;
918 pub const EAI_OVERFLOW: ::c_int = -12;
919 
920 pub const NI_NUMERICHOST: ::c_int = 1;
921 pub const NI_NUMERICSERV: ::c_int = 2;
922 pub const NI_NOFQDN: ::c_int = 4;
923 pub const NI_NAMEREQD: ::c_int = 8;
924 pub const NI_DGRAM: ::c_int = 16;
925 
926 pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
927 pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
928 pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
929 
930 pub const EAI_SYSTEM: ::c_int = -11;
931 
932 pub const MREMAP_MAYMOVE: ::c_int = 1;
933 pub const MREMAP_FIXED: ::c_int = 2;
934 
935 pub const ITIMER_REAL: ::c_int = 0;
936 pub const ITIMER_VIRTUAL: ::c_int = 1;
937 pub const ITIMER_PROF: ::c_int = 2;
938 
939 pub const _POSIX_VDISABLE: ::cc_t = 0;
940 
941 pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
942 pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
943 
944 pub const NCCS: usize = 32;
945 
946 pub const O_TRUNC: ::c_int = 512;
947 pub const O_NOATIME: ::c_int = 0o1000000;
948 pub const O_CLOEXEC: ::c_int = 0x80000;
949 
950 // Defined as wasi value.
951 pub const EPERM: ::c_int = 63;
952 pub const ENOENT: ::c_int = 44;
953 pub const ESRCH: ::c_int = 71;
954 pub const EINTR: ::c_int = 27;
955 pub const EIO: ::c_int = 29;
956 pub const ENXIO: ::c_int = 60;
957 pub const E2BIG: ::c_int = 1;
958 pub const ENOEXEC: ::c_int = 45;
959 pub const EBADF: ::c_int = 8;
960 pub const ECHILD: ::c_int = 12;
961 pub const EAGAIN: ::c_int = 6;
962 pub const ENOMEM: ::c_int = 48;
963 pub const EACCES: ::c_int = 2;
964 pub const EFAULT: ::c_int = 21;
965 pub const ENOTBLK: ::c_int = 105;
966 pub const EBUSY: ::c_int = 10;
967 pub const EEXIST: ::c_int = 20;
968 pub const EXDEV: ::c_int = 75;
969 pub const ENODEV: ::c_int = 43;
970 pub const ENOTDIR: ::c_int = 54;
971 pub const EISDIR: ::c_int = 31;
972 pub const EINVAL: ::c_int = 28;
973 pub const ENFILE: ::c_int = 41;
974 pub const EMFILE: ::c_int = 33;
975 pub const ENOTTY: ::c_int = 59;
976 pub const ETXTBSY: ::c_int = 74;
977 pub const EFBIG: ::c_int = 22;
978 pub const ENOSPC: ::c_int = 51;
979 pub const ESPIPE: ::c_int = 70;
980 pub const EROFS: ::c_int = 69;
981 pub const EMLINK: ::c_int = 34;
982 pub const EPIPE: ::c_int = 64;
983 pub const EDOM: ::c_int = 18;
984 pub const ERANGE: ::c_int = 68;
985 pub const EWOULDBLOCK: ::c_int = EAGAIN;
986 pub const ENOLINK: ::c_int = 47;
987 pub const EPROTO: ::c_int = 65;
988 pub const EDEADLK: ::c_int = 16;
989 pub const EDEADLOCK: ::c_int = EDEADLK;
990 pub const ENAMETOOLONG: ::c_int = 37;
991 pub const ENOLCK: ::c_int = 46;
992 pub const ENOSYS: ::c_int = 52;
993 pub const ENOTEMPTY: ::c_int = 55;
994 pub const ELOOP: ::c_int = 32;
995 pub const ENOMSG: ::c_int = 49;
996 pub const EIDRM: ::c_int = 24;
997 pub const EMULTIHOP: ::c_int = 36;
998 pub const EBADMSG: ::c_int = 9;
999 pub const EOVERFLOW: ::c_int = 61;
1000 pub const EILSEQ: ::c_int = 25;
1001 pub const ENOTSOCK: ::c_int = 57;
1002 pub const EDESTADDRREQ: ::c_int = 17;
1003 pub const EMSGSIZE: ::c_int = 35;
1004 pub const EPROTOTYPE: ::c_int = 67;
1005 pub const ENOPROTOOPT: ::c_int = 50;
1006 pub const EPROTONOSUPPORT: ::c_int = 66;
1007 pub const EAFNOSUPPORT: ::c_int = 5;
1008 pub const EADDRINUSE: ::c_int = 3;
1009 pub const EADDRNOTAVAIL: ::c_int = 4;
1010 pub const ENETDOWN: ::c_int = 38;
1011 pub const ENETUNREACH: ::c_int = 40;
1012 pub const ENETRESET: ::c_int = 39;
1013 pub const ECONNABORTED: ::c_int = 13;
1014 pub const ECONNRESET: ::c_int = 15;
1015 pub const ENOBUFS: ::c_int = 42;
1016 pub const EISCONN: ::c_int = 30;
1017 pub const ENOTCONN: ::c_int = 53;
1018 pub const ETIMEDOUT: ::c_int = 73;
1019 pub const ECONNREFUSED: ::c_int = 14;
1020 pub const EHOSTUNREACH: ::c_int = 23;
1021 pub const EALREADY: ::c_int = 7;
1022 pub const EINPROGRESS: ::c_int = 26;
1023 pub const ESTALE: ::c_int = 72;
1024 pub const EDQUOT: ::c_int = 19;
1025 pub const ECANCELED: ::c_int = 11;
1026 pub const EOWNERDEAD: ::c_int = 62;
1027 pub const ENOTRECOVERABLE: ::c_int = 56;
1028 
1029 pub const ENOSTR: ::c_int = 100;
1030 pub const EBFONT: ::c_int = 101;
1031 pub const EBADSLT: ::c_int = 102;
1032 pub const EBADRQC: ::c_int = 103;
1033 pub const ENOANO: ::c_int = 104;
1034 pub const ECHRNG: ::c_int = 106;
1035 pub const EL3HLT: ::c_int = 107;
1036 pub const EL3RST: ::c_int = 108;
1037 pub const ELNRNG: ::c_int = 109;
1038 pub const EUNATCH: ::c_int = 110;
1039 pub const ENOCSI: ::c_int = 111;
1040 pub const EL2HLT: ::c_int = 112;
1041 pub const EBADE: ::c_int = 113;
1042 pub const EBADR: ::c_int = 114;
1043 pub const EXFULL: ::c_int = 115;
1044 pub const ENODATA: ::c_int = 116;
1045 pub const ETIME: ::c_int = 117;
1046 pub const ENOSR: ::c_int = 118;
1047 pub const ENONET: ::c_int = 119;
1048 pub const ENOPKG: ::c_int = 120;
1049 pub const EREMOTE: ::c_int = 121;
1050 pub const EADV: ::c_int = 122;
1051 pub const ESRMNT: ::c_int = 123;
1052 pub const ECOMM: ::c_int = 124;
1053 pub const EDOTDOT: ::c_int = 125;
1054 pub const ENOTUNIQ: ::c_int = 126;
1055 pub const EBADFD: ::c_int = 127;
1056 pub const EREMCHG: ::c_int = 128;
1057 pub const ELIBACC: ::c_int = 129;
1058 pub const ELIBBAD: ::c_int = 130;
1059 pub const ELIBSCN: ::c_int = 131;
1060 pub const ELIBMAX: ::c_int = 132;
1061 pub const ELIBEXEC: ::c_int = 133;
1062 pub const ERESTART: ::c_int = 134;
1063 pub const ESTRPIPE: ::c_int = 135;
1064 pub const EUSERS: ::c_int = 136;
1065 pub const ESOCKTNOSUPPORT: ::c_int = 137;
1066 pub const EOPNOTSUPP: ::c_int = 138;
1067 pub const ENOTSUP: ::c_int = EOPNOTSUPP;
1068 pub const EPFNOSUPPORT: ::c_int = 139;
1069 pub const ESHUTDOWN: ::c_int = 140;
1070 pub const ETOOMANYREFS: ::c_int = 141;
1071 pub const EHOSTDOWN: ::c_int = 142;
1072 pub const EUCLEAN: ::c_int = 143;
1073 pub const ENOTNAM: ::c_int = 144;
1074 pub const ENAVAIL: ::c_int = 145;
1075 pub const EISNAM: ::c_int = 146;
1076 pub const EREMOTEIO: ::c_int = 147;
1077 pub const ENOMEDIUM: ::c_int = 148;
1078 pub const EMEDIUMTYPE: ::c_int = 149;
1079 pub const ENOKEY: ::c_int = 150;
1080 pub const EKEYEXPIRED: ::c_int = 151;
1081 pub const EKEYREVOKED: ::c_int = 152;
1082 pub const EKEYREJECTED: ::c_int = 153;
1083 pub const ERFKILL: ::c_int = 154;
1084 pub const EHWPOISON: ::c_int = 155;
1085 pub const EL2NSYNC: ::c_int = 156;
1086 
1087 pub const SA_NODEFER: ::c_int = 0x40000000;
1088 pub const SA_RESETHAND: ::c_int = 0x80000000;
1089 pub const SA_RESTART: ::c_int = 0x10000000;
1090 pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
1091 
1092 pub const BUFSIZ: ::c_uint = 1024;
1093 pub const TMP_MAX: ::c_uint = 10000;
1094 pub const FOPEN_MAX: ::c_uint = 1000;
1095 pub const O_PATH: ::c_int = 0o10000000;
1096 pub const O_EXEC: ::c_int = 0o10000000;
1097 pub const O_SEARCH: ::c_int = 0o10000000;
1098 pub const O_ACCMODE: ::c_int = 0o10000003;
1099 pub const O_NDELAY: ::c_int = O_NONBLOCK;
1100 pub const NI_MAXHOST: ::socklen_t = 255;
1101 pub const PTHREAD_STACK_MIN: ::size_t = 2048;
1102 pub const POSIX_FADV_DONTNEED: ::c_int = 4;
1103 pub const POSIX_FADV_NOREUSE: ::c_int = 5;
1104 
1105 pub const POSIX_MADV_DONTNEED: ::c_int = 4;
1106 
1107 pub const RLIM_INFINITY: ::rlim_t = !0;
1108 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
1109 pub const RLIMIT_NLIMITS: ::c_int = 16;
1110 #[allow(deprecated)]
1111 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
1112 pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS;
1113 
1114 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
1115 
1116 #[doc(hidden)]
1117 #[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
1118 pub const SIGUNUSED: ::c_int = ::SIGSYS;
1119 
1120 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
1121 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
1122 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
1123 
1124 pub const CPU_SETSIZE: ::c_int = 1024;
1125 
1126 pub const TCSANOW: ::c_int = 0;
1127 pub const TCSADRAIN: ::c_int = 1;
1128 pub const TCSAFLUSH: ::c_int = 2;
1129 
1130 pub const TIOCINQ: ::c_int = ::FIONREAD;
1131 
1132 pub const RTLD_GLOBAL: ::c_int = 0x100;
1133 pub const RTLD_NOLOAD: ::c_int = 0x4;
1134 
1135 pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
1136 
1137 pub const MCL_CURRENT: ::c_int = 0x0001;
1138 pub const MCL_FUTURE: ::c_int = 0x0002;
1139 
1140 pub const SIGSTKSZ: ::size_t = 8192;
1141 pub const MINSIGSTKSZ: ::size_t = 2048;
1142 pub const CBAUD: ::tcflag_t = 0o0010017;
1143 pub const TAB1: ::c_int = 0x00000800;
1144 pub const TAB2: ::c_int = 0x00001000;
1145 pub const TAB3: ::c_int = 0x00001800;
1146 pub const CR1: ::c_int = 0x00000200;
1147 pub const CR2: ::c_int = 0x00000400;
1148 pub const CR3: ::c_int = 0x00000600;
1149 pub const FF1: ::c_int = 0x00008000;
1150 pub const BS1: ::c_int = 0x00002000;
1151 pub const VT1: ::c_int = 0x00004000;
1152 pub const VWERASE: usize = 14;
1153 pub const VREPRINT: usize = 12;
1154 pub const VSUSP: usize = 10;
1155 pub const VSTART: usize = 8;
1156 pub const VSTOP: usize = 9;
1157 pub const VDISCARD: usize = 13;
1158 pub const VTIME: usize = 5;
1159 pub const IXON: ::tcflag_t = 0x00000400;
1160 pub const IXOFF: ::tcflag_t = 0x00001000;
1161 pub const ONLCR: ::tcflag_t = 0x4;
1162 pub const CSIZE: ::tcflag_t = 0x00000030;
1163 pub const CS6: ::tcflag_t = 0x00000010;
1164 pub const CS7: ::tcflag_t = 0x00000020;
1165 pub const CS8: ::tcflag_t = 0x00000030;
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 ECHOKE: ::tcflag_t = 0x00000800;
1173 pub const ECHOE: ::tcflag_t = 0x00000010;
1174 pub const ECHOK: ::tcflag_t = 0x00000020;
1175 pub const ECHONL: ::tcflag_t = 0x00000040;
1176 pub const ECHOPRT: ::tcflag_t = 0x00000400;
1177 pub const ECHOCTL: ::tcflag_t = 0x00000200;
1178 pub const ISIG: ::tcflag_t = 0x00000001;
1179 pub const ICANON: ::tcflag_t = 0x00000002;
1180 pub const PENDIN: ::tcflag_t = 0x00004000;
1181 pub const NOFLSH: ::tcflag_t = 0x00000080;
1182 pub const CBAUDEX: ::tcflag_t = 0o010000;
1183 pub const VSWTC: usize = 7;
1184 pub const OLCUC: ::tcflag_t = 0o000002;
1185 pub const NLDLY: ::tcflag_t = 0o000400;
1186 pub const CRDLY: ::tcflag_t = 0o003000;
1187 pub const TABDLY: ::tcflag_t = 0o014000;
1188 pub const BSDLY: ::tcflag_t = 0o020000;
1189 pub const FFDLY: ::tcflag_t = 0o100000;
1190 pub const VTDLY: ::tcflag_t = 0o040000;
1191 pub const XTABS: ::tcflag_t = 0o014000;
1192 
1193 pub const B0: ::speed_t = 0o000000;
1194 pub const B50: ::speed_t = 0o000001;
1195 pub const B75: ::speed_t = 0o000002;
1196 pub const B110: ::speed_t = 0o000003;
1197 pub const B134: ::speed_t = 0o000004;
1198 pub const B150: ::speed_t = 0o000005;
1199 pub const B200: ::speed_t = 0o000006;
1200 pub const B300: ::speed_t = 0o000007;
1201 pub const B600: ::speed_t = 0o000010;
1202 pub const B1200: ::speed_t = 0o000011;
1203 pub const B1800: ::speed_t = 0o000012;
1204 pub const B2400: ::speed_t = 0o000013;
1205 pub const B4800: ::speed_t = 0o000014;
1206 pub const B9600: ::speed_t = 0o000015;
1207 pub const B19200: ::speed_t = 0o000016;
1208 pub const B38400: ::speed_t = 0o000017;
1209 pub const B57600: ::speed_t = 0o010001;
1210 pub const B115200: ::speed_t = 0o010002;
1211 pub const B230400: ::speed_t = 0o010003;
1212 pub const B460800: ::speed_t = 0o010004;
1213 pub const B500000: ::speed_t = 0o010005;
1214 pub const B576000: ::speed_t = 0o010006;
1215 pub const B921600: ::speed_t = 0o010007;
1216 pub const B1000000: ::speed_t = 0o010010;
1217 pub const B1152000: ::speed_t = 0o010011;
1218 pub const B1500000: ::speed_t = 0o010012;
1219 pub const B2000000: ::speed_t = 0o010013;
1220 pub const B2500000: ::speed_t = 0o010014;
1221 pub const B3000000: ::speed_t = 0o010015;
1222 pub const B3500000: ::speed_t = 0o010016;
1223 pub const B4000000: ::speed_t = 0o010017;
1224 
1225 pub const SO_BINDTODEVICE: ::c_int = 25;
1226 pub const SO_TIMESTAMP: ::c_int = 63;
1227 pub const SO_MARK: ::c_int = 36;
1228 pub const SO_RXQ_OVFL: ::c_int = 40;
1229 pub const SO_PEEK_OFF: ::c_int = 42;
1230 pub const SO_BUSY_POLL: ::c_int = 46;
1231 
1232 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
1233 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
1234 
1235 pub const O_DIRECT: ::c_int = 0x4000;
1236 pub const O_DIRECTORY: ::c_int = 0x10000;
1237 pub const O_NOFOLLOW: ::c_int = 0x20000;
1238 pub const O_ASYNC: ::c_int = 0x2000;
1239 
1240 pub const FIOCLEX: ::c_int = 0x5451;
1241 pub const FIONBIO: ::c_int = 0x5421;
1242 
1243 pub const RLIMIT_RSS: ::c_int = 5;
1244 pub const RLIMIT_NOFILE: ::c_int = 7;
1245 pub const RLIMIT_AS: ::c_int = 9;
1246 pub const RLIMIT_NPROC: ::c_int = 6;
1247 pub const RLIMIT_MEMLOCK: ::c_int = 8;
1248 pub const RLIMIT_CPU: ::c_int = 0;
1249 pub const RLIMIT_FSIZE: ::c_int = 1;
1250 pub const RLIMIT_DATA: ::c_int = 2;
1251 pub const RLIMIT_STACK: ::c_int = 3;
1252 pub const RLIMIT_CORE: ::c_int = 4;
1253 pub const RLIMIT_LOCKS: ::c_int = 10;
1254 pub const RLIMIT_SIGPENDING: ::c_int = 11;
1255 pub const RLIMIT_MSGQUEUE: ::c_int = 12;
1256 pub const RLIMIT_NICE: ::c_int = 13;
1257 pub const RLIMIT_RTPRIO: ::c_int = 14;
1258 
1259 pub const O_APPEND: ::c_int = 1024;
1260 pub const O_CREAT: ::c_int = 64;
1261 pub const O_EXCL: ::c_int = 128;
1262 pub const O_NOCTTY: ::c_int = 256;
1263 pub const O_NONBLOCK: ::c_int = 2048;
1264 pub const O_SYNC: ::c_int = 1052672;
1265 pub const O_RSYNC: ::c_int = 1052672;
1266 pub const O_DSYNC: ::c_int = 4096;
1267 
1268 pub const SOCK_NONBLOCK: ::c_int = 2048;
1269 
1270 pub const MAP_ANON: ::c_int = 0x0020;
1271 pub const MAP_GROWSDOWN: ::c_int = 0x0100;
1272 pub const MAP_DENYWRITE: ::c_int = 0x0800;
1273 pub const MAP_EXECUTABLE: ::c_int = 0x01000;
1274 pub const MAP_LOCKED: ::c_int = 0x02000;
1275 pub const MAP_NORESERVE: ::c_int = 0x04000;
1276 pub const MAP_POPULATE: ::c_int = 0x08000;
1277 pub const MAP_NONBLOCK: ::c_int = 0x010000;
1278 pub const MAP_STACK: ::c_int = 0x020000;
1279 
1280 pub const SOCK_STREAM: ::c_int = 1;
1281 pub const SOCK_DGRAM: ::c_int = 2;
1282 pub const SOCK_SEQPACKET: ::c_int = 5;
1283 
1284 pub const IPPROTO_MAX: ::c_int = 263;
1285 
1286 pub const SOL_SOCKET: ::c_int = 1;
1287 
1288 pub const SO_REUSEADDR: ::c_int = 2;
1289 pub const SO_TYPE: ::c_int = 3;
1290 pub const SO_ERROR: ::c_int = 4;
1291 pub const SO_DONTROUTE: ::c_int = 5;
1292 pub const SO_BROADCAST: ::c_int = 6;
1293 pub const SO_SNDBUF: ::c_int = 7;
1294 pub const SO_RCVBUF: ::c_int = 8;
1295 pub const SO_KEEPALIVE: ::c_int = 9;
1296 pub const SO_OOBINLINE: ::c_int = 10;
1297 pub const SO_LINGER: ::c_int = 13;
1298 pub const SO_REUSEPORT: ::c_int = 15;
1299 pub const SO_RCVLOWAT: ::c_int = 18;
1300 pub const SO_SNDLOWAT: ::c_int = 19;
1301 pub const SO_RCVTIMEO: ::c_int = 66;
1302 pub const SO_SNDTIMEO: ::c_int = 67;
1303 pub const SO_ACCEPTCONN: ::c_int = 30;
1304 
1305 pub const IPV6_RTHDR_LOOSE: ::c_int = 0;
1306 pub const IPV6_RTHDR_STRICT: ::c_int = 1;
1307 
1308 pub const SA_ONSTACK: ::c_int = 0x08000000;
1309 pub const SA_SIGINFO: ::c_int = 0x00000004;
1310 pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
1311 
1312 pub const SIGCHLD: ::c_int = 17;
1313 pub const SIGBUS: ::c_int = 7;
1314 pub const SIGTTIN: ::c_int = 21;
1315 pub const SIGTTOU: ::c_int = 22;
1316 pub const SIGXCPU: ::c_int = 24;
1317 pub const SIGXFSZ: ::c_int = 25;
1318 pub const SIGVTALRM: ::c_int = 26;
1319 pub const SIGPROF: ::c_int = 27;
1320 pub const SIGWINCH: ::c_int = 28;
1321 pub const SIGUSR1: ::c_int = 10;
1322 pub const SIGUSR2: ::c_int = 12;
1323 pub const SIGCONT: ::c_int = 18;
1324 pub const SIGSTOP: ::c_int = 19;
1325 pub const SIGTSTP: ::c_int = 20;
1326 pub const SIGURG: ::c_int = 23;
1327 pub const SIGIO: ::c_int = 29;
1328 pub const SIGSYS: ::c_int = 31;
1329 pub const SIGSTKFLT: ::c_int = 16;
1330 pub const SIGPOLL: ::c_int = 29;
1331 pub const SIGPWR: ::c_int = 30;
1332 pub const SIG_SETMASK: ::c_int = 2;
1333 pub const SIG_BLOCK: ::c_int = 0x000000;
1334 pub const SIG_UNBLOCK: ::c_int = 0x01;
1335 
1336 pub const EXTPROC: ::tcflag_t = 0x00010000;
1337 
1338 pub const MAP_HUGETLB: ::c_int = 0x040000;
1339 
1340 pub const F_GETLK: ::c_int = 12;
1341 pub const F_GETOWN: ::c_int = 9;
1342 pub const F_SETLK: ::c_int = 13;
1343 pub const F_SETLKW: ::c_int = 14;
1344 pub const F_SETOWN: ::c_int = 8;
1345 pub const F_OFD_GETLK: ::c_int = 36;
1346 pub const F_OFD_SETLK: ::c_int = 37;
1347 pub const F_OFD_SETLKW: ::c_int = 38;
1348 
1349 pub const VEOF: usize = 4;
1350 pub const VEOL: usize = 11;
1351 pub const VEOL2: usize = 16;
1352 pub const VMIN: usize = 6;
1353 pub const IEXTEN: ::tcflag_t = 0x00008000;
1354 pub const TOSTOP: ::tcflag_t = 0x00000100;
1355 pub const FLUSHO: ::tcflag_t = 0x00001000;
1356 
1357 pub const TCGETS: ::c_int = 0x5401;
1358 pub const TCSETS: ::c_int = 0x5402;
1359 pub const TCSETSW: ::c_int = 0x5403;
1360 pub const TCSETSF: ::c_int = 0x5404;
1361 pub const TCGETA: ::c_int = 0x5405;
1362 pub const TCSETA: ::c_int = 0x5406;
1363 pub const TCSETAW: ::c_int = 0x5407;
1364 pub const TCSETAF: ::c_int = 0x5408;
1365 pub const TCSBRK: ::c_int = 0x5409;
1366 pub const TCXONC: ::c_int = 0x540A;
1367 pub const TCFLSH: ::c_int = 0x540B;
1368 pub const TIOCGSOFTCAR: ::c_int = 0x5419;
1369 pub const TIOCSSOFTCAR: ::c_int = 0x541A;
1370 pub const TIOCLINUX: ::c_int = 0x541C;
1371 pub const TIOCGSERIAL: ::c_int = 0x541E;
1372 pub const TIOCEXCL: ::c_int = 0x540C;
1373 pub const TIOCNXCL: ::c_int = 0x540D;
1374 pub const TIOCSCTTY: ::c_int = 0x540E;
1375 pub const TIOCGPGRP: ::c_int = 0x540F;
1376 pub const TIOCSPGRP: ::c_int = 0x5410;
1377 pub const TIOCOUTQ: ::c_int = 0x5411;
1378 pub const TIOCSTI: ::c_int = 0x5412;
1379 pub const TIOCGWINSZ: ::c_int = 0x5413;
1380 pub const TIOCSWINSZ: ::c_int = 0x5414;
1381 pub const TIOCMGET: ::c_int = 0x5415;
1382 pub const TIOCMBIS: ::c_int = 0x5416;
1383 pub const TIOCMBIC: ::c_int = 0x5417;
1384 pub const TIOCMSET: ::c_int = 0x5418;
1385 pub const FIONREAD: ::c_int = 0x541B;
1386 pub const TIOCCONS: ::c_int = 0x541D;
1387 
1388 pub const SYS_gettid: ::c_long = 224; // Valid for arm (32-bit) and x86 (32-bit)
1389 
1390 pub const POLLWRNORM: ::c_short = 0x100;
1391 pub const POLLWRBAND: ::c_short = 0x200;
1392 
1393 pub const TIOCM_LE: ::c_int = 0x001;
1394 pub const TIOCM_DTR: ::c_int = 0x002;
1395 pub const TIOCM_RTS: ::c_int = 0x004;
1396 pub const TIOCM_ST: ::c_int = 0x008;
1397 pub const TIOCM_SR: ::c_int = 0x010;
1398 pub const TIOCM_CTS: ::c_int = 0x020;
1399 pub const TIOCM_CAR: ::c_int = 0x040;
1400 pub const TIOCM_RNG: ::c_int = 0x080;
1401 pub const TIOCM_DSR: ::c_int = 0x100;
1402 pub const TIOCM_CD: ::c_int = TIOCM_CAR;
1403 pub const TIOCM_RI: ::c_int = TIOCM_RNG;
1404 pub const O_TMPFILE: ::c_int = 0x410000;
1405 
1406 pub const MAX_ADDR_LEN: usize = 7;
1407 pub const ARPD_UPDATE: ::c_ushort = 0x01;
1408 pub const ARPD_LOOKUP: ::c_ushort = 0x02;
1409 pub const ARPD_FLUSH: ::c_ushort = 0x03;
1410 pub const ATF_MAGIC: ::c_int = 0x80;
1411 
1412 pub const PRIO_PROCESS: ::c_int = 0;
1413 pub const PRIO_PGRP: ::c_int = 1;
1414 pub const PRIO_USER: ::c_int = 2;
1415 
1416 pub const SOMAXCONN: ::c_int = 128;
1417 
1418 f! {
1419     pub fn CMSG_NXTHDR(mhdr: *const msghdr,
1420                        cmsg: *const cmsghdr) -> *mut cmsghdr {
1421         if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
1422             return 0 as *mut cmsghdr;
1423         };
1424         let next = (cmsg as usize +
1425                     super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
1426             as *mut cmsghdr;
1427         let max = (*mhdr).msg_control as usize
1428             + (*mhdr).msg_controllen as usize;
1429         if (next.offset(1)) as usize > max {
1430             0 as *mut cmsghdr
1431         } else {
1432             next as *mut cmsghdr
1433         }
1434     }
1435 
1436     pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
1437         for slot in cpuset.bits.iter_mut() {
1438             *slot = 0;
1439         }
1440     }
1441 
1442     pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1443         let size_in_bits
1444             = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
1445         let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1446         cpuset.bits[idx] |= 1 << offset;
1447         ()
1448     }
1449 
1450     pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1451         let size_in_bits
1452             = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
1453         let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1454         cpuset.bits[idx] &= !(1 << offset);
1455         ()
1456     }
1457 
1458     pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
1459         let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
1460         let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1461         0 != (cpuset.bits[idx] & (1 << offset))
1462     }
1463 
1464     pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
1465         set1.bits == set2.bits
1466     }
1467 
1468     pub fn major(dev: ::dev_t) -> ::c_uint {
1469         // see
1470         // https://github.com/emscripten-core/emscripten/blob/
1471         // main/system/lib/libc/musl/include/sys/sysmacros.h
1472         let mut major = 0;
1473         major |= (dev & 0x00000fff) >> 8;
1474         major |= (dev & 0xfffff000) >> 31 >> 1;
1475         major as ::c_uint
1476     }
1477 
1478     pub fn minor(dev: ::dev_t) -> ::c_uint {
1479         // see
1480         // https://github.com/emscripten-core/emscripten/blob/
1481         // main/system/lib/libc/musl/include/sys/sysmacros.h
1482         let mut minor = 0;
1483         minor |= (dev & 0x000000ff) >> 0;
1484         minor |= (dev & 0xffffff00) >> 12;
1485         minor as ::c_uint
1486     }
1487 }
1488 
1489 safe_f! {
1490     pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
1491         let major = major as ::dev_t;
1492         let minor = minor as ::dev_t;
1493         let mut dev = 0;
1494         dev |= (major & 0x00000fff) << 8;
1495         dev |= (major & 0xfffff000) << 31 << 1;
1496         dev |= (minor & 0x000000ff) << 0;
1497         dev |= (minor & 0xffffff00) << 12;
1498         dev
1499     }
1500 }
1501 
1502 extern "C" {
1503     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
1504     pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
1505     pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
1506 
1507     pub fn abs(i: ::c_int) -> ::c_int;
1508     pub fn labs(i: ::c_long) -> ::c_long;
1509     pub fn rand() -> ::c_int;
1510     pub fn srand(seed: ::c_uint);
1511 
1512     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
1513 
1514     pub fn setpwent();
1515     pub fn endpwent();
1516     pub fn getpwent() -> *mut passwd;
1517 
1518     pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int;
1519 
1520     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
1521     pub fn __errno_location() -> *mut ::c_int;
1522 
1523     pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
1524     pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
1525         -> ::ssize_t;
1526     pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t;
1527     pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
1528     pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
1529     pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;
1530     pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
1531     pub fn accept4(
1532         fd: ::c_int,
1533         addr: *mut ::sockaddr,
1534         len: *mut ::socklen_t,
1535         flg: ::c_int,
1536     ) -> ::c_int;
1537     pub fn getnameinfo(
1538         sa: *const ::sockaddr,
1539         salen: ::socklen_t,
1540         host: *mut ::c_char,
1541         hostlen: ::socklen_t,
1542         serv: *mut ::c_char,
1543         servlen: ::socklen_t,
1544         flags: ::c_int,
1545     ) -> ::c_int;
1546     pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
1547 
1548     pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
1549     pub fn if_nameindex() -> *mut if_nameindex;
1550     pub fn if_freenameindex(ptr: *mut if_nameindex);
1551 
1552     pub fn mremap(
1553         addr: *mut ::c_void,
1554         len: ::size_t,
1555         new_len: ::size_t,
1556         flags: ::c_int,
1557         ...
1558     ) -> *mut ::c_void;
1559 
1560     pub fn glob(
1561         pattern: *const c_char,
1562         flags: ::c_int,
1563         errfunc: ::Option<extern "C" fn(epath: *const c_char, errno: ::c_int) -> ::c_int>,
1564         pglob: *mut ::glob_t,
1565     ) -> ::c_int;
1566     pub fn globfree(pglob: *mut ::glob_t);
1567 
1568     pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
1569 
1570     pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
1571 
1572     pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
1573 
1574     pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
1575     pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
1576 
1577     pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
1578 
1579     pub fn recvfrom(
1580         socket: ::c_int,
1581         buf: *mut ::c_void,
1582         len: ::size_t,
1583         flags: ::c_int,
1584         addr: *mut ::sockaddr,
1585         addrlen: *mut ::socklen_t,
1586     ) -> ::ssize_t;
1587     pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
1588     pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
1589 
1590     pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
1591     pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1592     pub fn sendmmsg(
1593         sockfd: ::c_int,
1594         msgvec: *mut ::mmsghdr,
1595         vlen: ::c_uint,
1596         flags: ::c_uint,
1597     ) -> ::c_int;
1598     pub fn recvmmsg(
1599         sockfd: ::c_int,
1600         msgvec: *mut ::mmsghdr,
1601         vlen: ::c_uint,
1602         flags: ::c_uint,
1603         timeout: *mut ::timespec,
1604     ) -> ::c_int;
1605     pub fn sync();
1606     pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
1607     pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
1608     pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
1609     pub fn pthread_create(
1610         native: *mut ::pthread_t,
1611         attr: *const ::pthread_attr_t,
1612         f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
1613         value: *mut ::c_void,
1614     ) -> ::c_int;
1615 
1616     pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
1617 
1618     pub fn getpwnam_r(
1619         name: *const ::c_char,
1620         pwd: *mut passwd,
1621         buf: *mut ::c_char,
1622         buflen: ::size_t,
1623         result: *mut *mut passwd,
1624     ) -> ::c_int;
1625     pub fn getpwuid_r(
1626         uid: ::uid_t,
1627         pwd: *mut passwd,
1628         buf: *mut ::c_char,
1629         buflen: ::size_t,
1630         result: *mut *mut passwd,
1631     ) -> ::c_int;
1632 
1633     // grp.h
1634     pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
1635     pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
1636     pub fn getgrnam_r(
1637         name: *const ::c_char,
1638         grp: *mut ::group,
1639         buf: *mut ::c_char,
1640         buflen: ::size_t,
1641         result: *mut *mut ::group,
1642     ) -> ::c_int;
1643     pub fn getgrgid_r(
1644         gid: ::gid_t,
1645         grp: *mut ::group,
1646         buf: *mut ::c_char,
1647         buflen: ::size_t,
1648         result: *mut *mut ::group,
1649     ) -> ::c_int;
1650 }
1651 
1652 // Alias <foo> to <foo>64 to mimic glibc's LFS64 support
1653 mod lfs64;
1654 pub use self::lfs64::*;
1655