1 pub type sa_family_t = u16;
2 pub type speed_t = ::c_uint;
3 pub type tcflag_t = ::c_uint;
4 pub type clockid_t = ::c_int;
5 pub type timer_t = *mut ::c_void;
6 pub type key_t = ::c_int;
7 pub type id_t = ::c_uint;
8 
9 #[cfg_attr(feature = "extra_traits", derive(Debug))]
10 pub enum timezone {}
11 impl ::Copy for timezone {}
12 impl ::Clone for timezone {
clone(&self) -> timezone13     fn clone(&self) -> timezone {
14         *self
15     }
16 }
17 
18 s! {
19     pub struct in_addr {
20         pub s_addr: ::in_addr_t,
21     }
22 
23     pub struct ip_mreq {
24         pub imr_multiaddr: in_addr,
25         pub imr_interface: in_addr,
26     }
27 
28     pub struct ip_mreq_source {
29         pub imr_multiaddr: in_addr,
30         pub imr_interface: in_addr,
31         pub imr_sourceaddr: in_addr,
32     }
33 
34     pub struct sockaddr {
35         pub sa_family: sa_family_t,
36         pub sa_data: [::c_char; 14],
37     }
38 
39     pub struct sockaddr_in {
40         pub sin_family: sa_family_t,
41         pub sin_port: ::in_port_t,
42         pub sin_addr: ::in_addr,
43         pub sin_zero: [u8; 8],
44     }
45 
46     pub struct sockaddr_in6 {
47         pub sin6_family: sa_family_t,
48         pub sin6_port: ::in_port_t,
49         pub sin6_flowinfo: u32,
50         pub sin6_addr: ::in6_addr,
51         pub sin6_scope_id: u32,
52     }
53 
54     // The order of the `ai_addr` field in this struct is crucial
55     // for converting between the Rust and C types.
56     pub struct addrinfo {
57         pub ai_flags: ::c_int,
58         pub ai_family: ::c_int,
59         pub ai_socktype: ::c_int,
60         pub ai_protocol: ::c_int,
61         pub ai_addrlen: socklen_t,
62 
63         #[cfg(any(target_os = "linux",
64                   target_os = "emscripten"))]
65         pub ai_addr: *mut ::sockaddr,
66 
67         pub ai_canonname: *mut c_char,
68 
69         #[cfg(target_os = "android")]
70         pub ai_addr: *mut ::sockaddr,
71 
72         pub ai_next: *mut addrinfo,
73     }
74 
75     pub struct sockaddr_ll {
76         pub sll_family: ::c_ushort,
77         pub sll_protocol: ::c_ushort,
78         pub sll_ifindex: ::c_int,
79         pub sll_hatype: ::c_ushort,
80         pub sll_pkttype: ::c_uchar,
81         pub sll_halen: ::c_uchar,
82         pub sll_addr: [::c_uchar; 8]
83     }
84 
85     pub struct fd_set {
86         fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
87     }
88 
89     pub struct tm {
90         pub tm_sec: ::c_int,
91         pub tm_min: ::c_int,
92         pub tm_hour: ::c_int,
93         pub tm_mday: ::c_int,
94         pub tm_mon: ::c_int,
95         pub tm_year: ::c_int,
96         pub tm_wday: ::c_int,
97         pub tm_yday: ::c_int,
98         pub tm_isdst: ::c_int,
99         pub tm_gmtoff: ::c_long,
100         pub tm_zone: *const ::c_char,
101     }
102 
103     pub struct sched_param {
104         pub sched_priority: ::c_int,
105         #[cfg(any(target_env = "musl", target_os = "emscripten"))]
106         pub sched_ss_low_priority: ::c_int,
107         #[cfg(any(target_env = "musl", target_os = "emscripten"))]
108         pub sched_ss_repl_period: ::timespec,
109         #[cfg(any(target_env = "musl", target_os = "emscripten"))]
110         pub sched_ss_init_budget: ::timespec,
111         #[cfg(any(target_env = "musl", target_os = "emscripten"))]
112         pub sched_ss_max_repl: ::c_int,
113     }
114 
115     pub struct Dl_info {
116         pub dli_fname: *const ::c_char,
117         pub dli_fbase: *mut ::c_void,
118         pub dli_sname: *const ::c_char,
119         pub dli_saddr: *mut ::c_void,
120     }
121 
122     pub struct lconv {
123         pub decimal_point: *mut ::c_char,
124         pub thousands_sep: *mut ::c_char,
125         pub grouping: *mut ::c_char,
126         pub int_curr_symbol: *mut ::c_char,
127         pub currency_symbol: *mut ::c_char,
128         pub mon_decimal_point: *mut ::c_char,
129         pub mon_thousands_sep: *mut ::c_char,
130         pub mon_grouping: *mut ::c_char,
131         pub positive_sign: *mut ::c_char,
132         pub negative_sign: *mut ::c_char,
133         pub int_frac_digits: ::c_char,
134         pub frac_digits: ::c_char,
135         pub p_cs_precedes: ::c_char,
136         pub p_sep_by_space: ::c_char,
137         pub n_cs_precedes: ::c_char,
138         pub n_sep_by_space: ::c_char,
139         pub p_sign_posn: ::c_char,
140         pub n_sign_posn: ::c_char,
141         pub int_p_cs_precedes: ::c_char,
142         pub int_p_sep_by_space: ::c_char,
143         pub int_n_cs_precedes: ::c_char,
144         pub int_n_sep_by_space: ::c_char,
145         pub int_p_sign_posn: ::c_char,
146         pub int_n_sign_posn: ::c_char,
147     }
148 
149     pub struct in_pktinfo {
150         pub ipi_ifindex: ::c_int,
151         pub ipi_spec_dst: ::in_addr,
152         pub ipi_addr: ::in_addr,
153     }
154 
155     pub struct ifaddrs {
156         pub ifa_next: *mut ifaddrs,
157         pub ifa_name: *mut c_char,
158         pub ifa_flags: ::c_uint,
159         pub ifa_addr: *mut ::sockaddr,
160         pub ifa_netmask: *mut ::sockaddr,
161         pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
162         pub ifa_data: *mut ::c_void
163     }
164 
165     pub struct in6_rtmsg {
166         rtmsg_dst: ::in6_addr,
167         rtmsg_src: ::in6_addr,
168         rtmsg_gateway: ::in6_addr,
169         rtmsg_type: u32,
170         rtmsg_dst_len: u16,
171         rtmsg_src_len: u16,
172         rtmsg_metric: u32,
173         rtmsg_info: ::c_ulong,
174         rtmsg_flags: u32,
175         rtmsg_ifindex: ::c_int,
176     }
177 
178     pub struct arpreq {
179         pub arp_pa: ::sockaddr,
180         pub arp_ha: ::sockaddr,
181         pub arp_flags: ::c_int,
182         pub arp_netmask: ::sockaddr,
183         pub arp_dev: [::c_char; 16],
184     }
185 
186     pub struct arpreq_old {
187         pub arp_pa: ::sockaddr,
188         pub arp_ha: ::sockaddr,
189         pub arp_flags: ::c_int,
190         pub arp_netmask: ::sockaddr,
191     }
192 
193     pub struct arphdr {
194         pub ar_hrd: u16,
195         pub ar_pro: u16,
196         pub ar_hln: u8,
197         pub ar_pln: u8,
198         pub ar_op: u16,
199     }
200 
201     pub struct mmsghdr {
202         pub msg_hdr: ::msghdr,
203         pub msg_len: ::c_uint,
204     }
205 }
206 
207 s_no_extra_traits! {
208     #[cfg_attr(
209         any(
210             all(
211                 target_arch = "x86",
212                 not(target_env = "musl"),
213                 not(target_os = "android")),
214             target_arch = "x86_64"),
215         repr(packed))]
216     pub struct epoll_event {
217         pub events: u32,
218         pub u64: u64,
219     }
220 
221     pub struct sockaddr_un {
222         pub sun_family: sa_family_t,
223         pub sun_path: [::c_char; 108]
224     }
225 
226     pub struct sockaddr_storage {
227         pub ss_family: sa_family_t,
228         __ss_align: ::size_t,
229         #[cfg(target_pointer_width = "32")]
230         __ss_pad2: [u8; 128 - 2 * 4],
231         #[cfg(target_pointer_width = "64")]
232         __ss_pad2: [u8; 128 - 2 * 8],
233     }
234 
235     pub struct utsname {
236         pub sysname: [::c_char; 65],
237         pub nodename: [::c_char; 65],
238         pub release: [::c_char; 65],
239         pub version: [::c_char; 65],
240         pub machine: [::c_char; 65],
241         pub domainname: [::c_char; 65]
242     }
243 
244     pub struct sigevent {
245         pub sigev_value: ::sigval,
246         pub sigev_signo: ::c_int,
247         pub sigev_notify: ::c_int,
248         // Actually a union.  We only expose sigev_notify_thread_id because it's
249         // the most useful member
250         pub sigev_notify_thread_id: ::c_int,
251         #[cfg(target_pointer_width = "64")]
252         __unused1: [::c_int; 11],
253         #[cfg(target_pointer_width = "32")]
254         __unused1: [::c_int; 12]
255     }
256 }
257 
258 cfg_if! {
259     if #[cfg(feature = "extra_traits")] {
260         impl PartialEq for epoll_event {
261             fn eq(&self, other: &epoll_event) -> bool {
262                 self.events == other.events
263                     && self.u64 == other.u64
264             }
265         }
266         impl Eq for epoll_event {}
267         impl ::fmt::Debug for epoll_event {
268             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
269                 let events = self.events;
270                 let u64 = self.u64;
271                 f.debug_struct("epoll_event")
272                     .field("events", &events)
273                     .field("u64", &u64)
274                     .finish()
275             }
276         }
277         impl ::hash::Hash for epoll_event {
278             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
279                 let events = self.events;
280                 let u64 = self.u64;
281                 events.hash(state);
282                 u64.hash(state);
283             }
284         }
285 
286         impl PartialEq for sockaddr_un {
287             fn eq(&self, other: &sockaddr_un) -> bool {
288                 self.sun_family == other.sun_family
289                     && self
290                     .sun_path
291                     .iter()
292                     .zip(other.sun_path.iter())
293                     .all(|(a, b)| a == b)
294             }
295         }
296         impl Eq for sockaddr_un {}
297         impl ::fmt::Debug for sockaddr_un {
298             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
299                 f.debug_struct("sockaddr_un")
300                     .field("sun_family", &self.sun_family)
301                 // FIXME: .field("sun_path", &self.sun_path)
302                     .finish()
303             }
304         }
305         impl ::hash::Hash for sockaddr_un {
306             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
307                 self.sun_family.hash(state);
308                 self.sun_path.hash(state);
309             }
310         }
311 
312         impl PartialEq for sockaddr_storage {
313             fn eq(&self, other: &sockaddr_storage) -> bool {
314                 self.ss_family == other.ss_family
315                     && self
316                     .__ss_pad2
317                     .iter()
318                     .zip(other.__ss_pad2.iter())
319                     .all(|(a, b)| a == b)
320             }
321         }
322 
323         impl Eq for sockaddr_storage {}
324 
325         impl ::fmt::Debug for sockaddr_storage {
326             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
327                 f.debug_struct("sockaddr_storage")
328                     .field("ss_family", &self.ss_family)
329                     .field("__ss_align", &self.__ss_align)
330                 // FIXME: .field("__ss_pad2", &self.__ss_pad2)
331                     .finish()
332             }
333         }
334 
335         impl ::hash::Hash for sockaddr_storage {
336             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
337                 self.ss_family.hash(state);
338                 self.__ss_pad2.hash(state);
339             }
340         }
341 
342         impl PartialEq for utsname {
343             fn eq(&self, other: &utsname) -> bool {
344                 self.sysname
345                     .iter()
346                     .zip(other.sysname.iter())
347                     .all(|(a, b)| a == b)
348                     && self
349                     .nodename
350                     .iter()
351                     .zip(other.nodename.iter())
352                     .all(|(a, b)| a == b)
353                     && self
354                     .release
355                     .iter()
356                     .zip(other.release.iter())
357                     .all(|(a, b)| a == b)
358                     && self
359                     .version
360                     .iter()
361                     .zip(other.version.iter())
362                     .all(|(a, b)| a == b)
363                     && self
364                     .machine
365                     .iter()
366                     .zip(other.machine.iter())
367                     .all(|(a, b)| a == b)
368                     && self
369                     .domainname
370                     .iter()
371                     .zip(other.domainname.iter())
372                     .all(|(a, b)| a == b)
373             }
374         }
375 
376         impl Eq for utsname {}
377 
378         impl ::fmt::Debug for utsname {
379             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
380                 f.debug_struct("utsname")
381                 // FIXME: .field("sysname", &self.sysname)
382                 // FIXME: .field("nodename", &self.nodename)
383                 // FIXME: .field("release", &self.release)
384                 // FIXME: .field("version", &self.version)
385                 // FIXME: .field("machine", &self.machine)
386                 // FIXME: .field("domainname", &self.domainname)
387                     .finish()
388             }
389         }
390 
391         impl ::hash::Hash for utsname {
392             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
393                 self.sysname.hash(state);
394                 self.nodename.hash(state);
395                 self.release.hash(state);
396                 self.version.hash(state);
397                 self.machine.hash(state);
398                 self.domainname.hash(state);
399             }
400         }
401 
402         impl PartialEq for sigevent {
403             fn eq(&self, other: &sigevent) -> bool {
404                 self.sigev_value == other.sigev_value
405                     && self.sigev_signo == other.sigev_signo
406                     && self.sigev_notify == other.sigev_notify
407                     && self.sigev_notify_thread_id
408                         == other.sigev_notify_thread_id
409             }
410         }
411         impl Eq for sigevent {}
412         impl ::fmt::Debug for sigevent {
413             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
414                 f.debug_struct("sigevent")
415                     .field("sigev_value", &self.sigev_value)
416                     .field("sigev_signo", &self.sigev_signo)
417                     .field("sigev_notify", &self.sigev_notify)
418                     .field("sigev_notify_thread_id",
419                            &self.sigev_notify_thread_id)
420                     .finish()
421             }
422         }
423         impl ::hash::Hash for sigevent {
424             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
425                 self.sigev_value.hash(state);
426                 self.sigev_signo.hash(state);
427                 self.sigev_notify.hash(state);
428                 self.sigev_notify_thread_id.hash(state);
429             }
430         }
431     }
432 }
433 
434 // intentionally not public, only used for fd_set
435 cfg_if! {
436     if #[cfg(target_pointer_width = "32")] {
437         const ULONG_SIZE: usize = 32;
438     } else if #[cfg(target_pointer_width = "64")] {
439         const ULONG_SIZE: usize = 64;
440     } else {
441         // Unknown target_pointer_width
442     }
443 }
444 
445 pub const EXIT_FAILURE: ::c_int = 1;
446 pub const EXIT_SUCCESS: ::c_int = 0;
447 pub const RAND_MAX: ::c_int = 2147483647;
448 pub const EOF: ::c_int = -1;
449 pub const SEEK_SET: ::c_int = 0;
450 pub const SEEK_CUR: ::c_int = 1;
451 pub const SEEK_END: ::c_int = 2;
452 pub const _IOFBF: ::c_int = 0;
453 pub const _IONBF: ::c_int = 2;
454 pub const _IOLBF: ::c_int = 1;
455 
456 pub const F_DUPFD: ::c_int = 0;
457 pub const F_GETFD: ::c_int = 1;
458 pub const F_SETFD: ::c_int = 2;
459 pub const F_GETFL: ::c_int = 3;
460 pub const F_SETFL: ::c_int = 4;
461 
462 // Linux-specific fcntls
463 pub const F_SETLEASE: ::c_int = 1024;
464 pub const F_GETLEASE: ::c_int = 1025;
465 pub const F_NOTIFY: ::c_int = 1026;
466 pub const F_CANCELLK: ::c_int = 1029;
467 pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
468 pub const F_SETPIPE_SZ: ::c_int = 1031;
469 pub const F_GETPIPE_SZ: ::c_int = 1032;
470 pub const F_ADD_SEALS: ::c_int = 1033;
471 pub const F_GET_SEALS: ::c_int = 1034;
472 
473 pub const F_SEAL_SEAL: ::c_int = 0x0001;
474 pub const F_SEAL_SHRINK: ::c_int = 0x0002;
475 pub const F_SEAL_GROW: ::c_int = 0x0004;
476 pub const F_SEAL_WRITE: ::c_int = 0x0008;
477 
478 // FIXME(#235): Include file sealing fcntls once we have a way to verify them.
479 
480 pub const SIGTRAP: ::c_int = 5;
481 
482 pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
483 pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
484 
485 pub const CLOCK_REALTIME: ::clockid_t = 0;
486 pub const CLOCK_MONOTONIC: ::clockid_t = 1;
487 pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
488 pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3;
489 pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4;
490 pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5;
491 pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6;
492 pub const CLOCK_BOOTTIME: ::clockid_t = 7;
493 pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8;
494 pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9;
495 pub const CLOCK_TAI: ::clockid_t = 11;
496 pub const TIMER_ABSTIME: ::c_int = 1;
497 
498 pub const RUSAGE_SELF: ::c_int = 0;
499 
500 pub const O_RDONLY: ::c_int = 0;
501 pub const O_WRONLY: ::c_int = 1;
502 pub const O_RDWR: ::c_int = 2;
503 
504 pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
505 
506 pub const S_IFIFO: ::mode_t = 4096;
507 pub const S_IFCHR: ::mode_t = 8192;
508 pub const S_IFBLK: ::mode_t = 24576;
509 pub const S_IFDIR: ::mode_t = 16384;
510 pub const S_IFREG: ::mode_t = 32768;
511 pub const S_IFLNK: ::mode_t = 40960;
512 pub const S_IFSOCK: ::mode_t = 49152;
513 pub const S_IFMT: ::mode_t = 61440;
514 pub const S_IRWXU: ::mode_t = 448;
515 pub const S_IXUSR: ::mode_t = 64;
516 pub const S_IWUSR: ::mode_t = 128;
517 pub const S_IRUSR: ::mode_t = 256;
518 pub const S_IRWXG: ::mode_t = 56;
519 pub const S_IXGRP: ::mode_t = 8;
520 pub const S_IWGRP: ::mode_t = 16;
521 pub const S_IRGRP: ::mode_t = 32;
522 pub const S_IRWXO: ::mode_t = 7;
523 pub const S_IXOTH: ::mode_t = 1;
524 pub const S_IWOTH: ::mode_t = 2;
525 pub const S_IROTH: ::mode_t = 4;
526 pub const F_OK: ::c_int = 0;
527 pub const R_OK: ::c_int = 4;
528 pub const W_OK: ::c_int = 2;
529 pub const X_OK: ::c_int = 1;
530 pub const STDIN_FILENO: ::c_int = 0;
531 pub const STDOUT_FILENO: ::c_int = 1;
532 pub const STDERR_FILENO: ::c_int = 2;
533 pub const SIGHUP: ::c_int = 1;
534 pub const SIGINT: ::c_int = 2;
535 pub const SIGQUIT: ::c_int = 3;
536 pub const SIGILL: ::c_int = 4;
537 pub const SIGABRT: ::c_int = 6;
538 pub const SIGFPE: ::c_int = 8;
539 pub const SIGKILL: ::c_int = 9;
540 pub const SIGSEGV: ::c_int = 11;
541 pub const SIGPIPE: ::c_int = 13;
542 pub const SIGALRM: ::c_int = 14;
543 pub const SIGTERM: ::c_int = 15;
544 
545 pub const PROT_NONE: ::c_int = 0;
546 pub const PROT_READ: ::c_int = 1;
547 pub const PROT_WRITE: ::c_int = 2;
548 pub const PROT_EXEC: ::c_int = 4;
549 
550 pub const XATTR_CREATE: ::c_int = 0x1;
551 pub const XATTR_REPLACE: ::c_int = 0x2;
552 
553 cfg_if! {
554     if #[cfg(not(target_env = "uclibc"))] {
555         pub const LC_CTYPE: ::c_int = 0;
556         pub const LC_NUMERIC: ::c_int = 1;
557         pub const LC_TIME: ::c_int = 2;
558         pub const LC_COLLATE: ::c_int = 3;
559         pub const LC_MONETARY: ::c_int = 4;
560         pub const LC_MESSAGES: ::c_int = 5;
561         pub const LC_ALL: ::c_int = 6;
562     }
563 }
564 
565 pub const LC_CTYPE_MASK: ::c_int = 1 << LC_CTYPE;
566 pub const LC_NUMERIC_MASK: ::c_int = 1 << LC_NUMERIC;
567 pub const LC_TIME_MASK: ::c_int = 1 << LC_TIME;
568 pub const LC_COLLATE_MASK: ::c_int = 1 << LC_COLLATE;
569 pub const LC_MONETARY_MASK: ::c_int = 1 << LC_MONETARY;
570 pub const LC_MESSAGES_MASK: ::c_int = 1 << LC_MESSAGES;
571 // LC_ALL_MASK defined per platform
572 
573 pub const MAP_FILE: ::c_int = 0x0000;
574 pub const MAP_SHARED: ::c_int = 0x0001;
575 pub const MAP_PRIVATE: ::c_int = 0x0002;
576 pub const MAP_FIXED: ::c_int = 0x0010;
577 
578 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
579 
580 // MS_ flags for msync(2)
581 pub const MS_ASYNC: ::c_int = 0x0001;
582 pub const MS_INVALIDATE: ::c_int = 0x0002;
583 pub const MS_SYNC: ::c_int = 0x0004;
584 
585 // MS_ flags for mount(2)
586 pub const MS_RDONLY: ::c_ulong = 0x01;
587 pub const MS_NOSUID: ::c_ulong = 0x02;
588 pub const MS_NODEV: ::c_ulong = 0x04;
589 pub const MS_NOEXEC: ::c_ulong = 0x08;
590 pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
591 pub const MS_REMOUNT: ::c_ulong = 0x20;
592 pub const MS_MANDLOCK: ::c_ulong = 0x40;
593 pub const MS_DIRSYNC: ::c_ulong = 0x80;
594 pub const MS_NOATIME: ::c_ulong = 0x0400;
595 pub const MS_NODIRATIME: ::c_ulong = 0x0800;
596 pub const MS_BIND: ::c_ulong = 0x1000;
597 pub const MS_MOVE: ::c_ulong = 0x2000;
598 pub const MS_REC: ::c_ulong = 0x4000;
599 pub const MS_SILENT: ::c_ulong = 0x8000;
600 pub const MS_POSIXACL: ::c_ulong = 0x010000;
601 pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
602 pub const MS_PRIVATE: ::c_ulong = 0x040000;
603 pub const MS_SLAVE: ::c_ulong = 0x080000;
604 pub const MS_SHARED: ::c_ulong = 0x100000;
605 pub const MS_RELATIME: ::c_ulong = 0x200000;
606 pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
607 pub const MS_I_VERSION: ::c_ulong = 0x800000;
608 pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
609 pub const MS_LAZYTIME: ::c_ulong = 0x2000000;
610 pub const MS_ACTIVE: ::c_ulong = 0x40000000;
611 pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
612 pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
613 
614 pub const SCM_RIGHTS: ::c_int = 0x01;
615 pub const SCM_CREDENTIALS: ::c_int = 0x02;
616 
617 pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
618 pub const PROT_GROWSUP: ::c_int = 0x2000000;
619 
620 pub const MAP_TYPE: ::c_int = 0x000f;
621 
622 pub const MADV_NORMAL: ::c_int = 0;
623 pub const MADV_RANDOM: ::c_int = 1;
624 pub const MADV_SEQUENTIAL: ::c_int = 2;
625 pub const MADV_WILLNEED: ::c_int = 3;
626 pub const MADV_DONTNEED: ::c_int = 4;
627 pub const MADV_FREE: ::c_int = 8;
628 pub const MADV_REMOVE: ::c_int = 9;
629 pub const MADV_DONTFORK: ::c_int = 10;
630 pub const MADV_DOFORK: ::c_int = 11;
631 pub const MADV_MERGEABLE: ::c_int = 12;
632 pub const MADV_UNMERGEABLE: ::c_int = 13;
633 pub const MADV_HUGEPAGE: ::c_int = 14;
634 pub const MADV_NOHUGEPAGE: ::c_int = 15;
635 pub const MADV_DONTDUMP: ::c_int = 16;
636 pub const MADV_DODUMP: ::c_int = 17;
637 pub const MADV_HWPOISON: ::c_int = 100;
638 
639 pub const IFF_UP: ::c_int = 0x1;
640 pub const IFF_BROADCAST: ::c_int = 0x2;
641 pub const IFF_DEBUG: ::c_int = 0x4;
642 pub const IFF_LOOPBACK: ::c_int = 0x8;
643 pub const IFF_POINTOPOINT: ::c_int = 0x10;
644 pub const IFF_NOTRAILERS: ::c_int = 0x20;
645 pub const IFF_RUNNING: ::c_int = 0x40;
646 pub const IFF_NOARP: ::c_int = 0x80;
647 pub const IFF_PROMISC: ::c_int = 0x100;
648 pub const IFF_ALLMULTI: ::c_int = 0x200;
649 pub const IFF_MASTER: ::c_int = 0x400;
650 pub const IFF_SLAVE: ::c_int = 0x800;
651 pub const IFF_MULTICAST: ::c_int = 0x1000;
652 pub const IFF_PORTSEL: ::c_int = 0x2000;
653 pub const IFF_AUTOMEDIA: ::c_int = 0x4000;
654 pub const IFF_DYNAMIC: ::c_int = 0x8000;
655 
656 pub const SOL_IP: ::c_int = 0;
657 pub const SOL_TCP: ::c_int = 6;
658 pub const SOL_UDP: ::c_int = 17;
659 pub const SOL_IPV6: ::c_int = 41;
660 pub const SOL_ICMPV6: ::c_int = 58;
661 pub const SOL_RAW: ::c_int = 255;
662 pub const SOL_DECNET: ::c_int = 261;
663 pub const SOL_X25: ::c_int = 262;
664 pub const SOL_PACKET: ::c_int = 263;
665 pub const SOL_ATM: ::c_int = 264;
666 pub const SOL_AAL: ::c_int = 265;
667 pub const SOL_IRDA: ::c_int = 266;
668 pub const SOL_NETBEUI: ::c_int = 267;
669 pub const SOL_LLC: ::c_int = 268;
670 pub const SOL_DCCP: ::c_int = 269;
671 pub const SOL_NETLINK: ::c_int = 270;
672 pub const SOL_TIPC: ::c_int = 271;
673 pub const SOL_BLUETOOTH: ::c_int = 274;
674 pub const SOL_ALG: ::c_int = 279;
675 
676 pub const AF_UNSPEC: ::c_int = 0;
677 pub const AF_UNIX: ::c_int = 1;
678 pub const AF_LOCAL: ::c_int = 1;
679 pub const AF_INET: ::c_int = 2;
680 pub const AF_AX25: ::c_int = 3;
681 pub const AF_IPX: ::c_int = 4;
682 pub const AF_APPLETALK: ::c_int = 5;
683 pub const AF_NETROM: ::c_int = 6;
684 pub const AF_BRIDGE: ::c_int = 7;
685 pub const AF_ATMPVC: ::c_int = 8;
686 pub const AF_X25: ::c_int = 9;
687 pub const AF_INET6: ::c_int = 10;
688 pub const AF_ROSE: ::c_int = 11;
689 pub const AF_DECnet: ::c_int = 12;
690 pub const AF_NETBEUI: ::c_int = 13;
691 pub const AF_SECURITY: ::c_int = 14;
692 pub const AF_KEY: ::c_int = 15;
693 pub const AF_NETLINK: ::c_int = 16;
694 pub const AF_ROUTE: ::c_int = AF_NETLINK;
695 pub const AF_PACKET: ::c_int = 17;
696 pub const AF_ASH: ::c_int = 18;
697 pub const AF_ECONET: ::c_int = 19;
698 pub const AF_ATMSVC: ::c_int = 20;
699 pub const AF_RDS: ::c_int = 21;
700 pub const AF_SNA: ::c_int = 22;
701 pub const AF_IRDA: ::c_int = 23;
702 pub const AF_PPPOX: ::c_int = 24;
703 pub const AF_WANPIPE: ::c_int = 25;
704 pub const AF_LLC: ::c_int = 26;
705 pub const AF_CAN: ::c_int = 29;
706 pub const AF_TIPC: ::c_int = 30;
707 pub const AF_BLUETOOTH: ::c_int = 31;
708 pub const AF_IUCV: ::c_int = 32;
709 pub const AF_RXRPC: ::c_int = 33;
710 pub const AF_ISDN: ::c_int = 34;
711 pub const AF_PHONET: ::c_int = 35;
712 pub const AF_IEEE802154: ::c_int = 36;
713 pub const AF_CAIF: ::c_int = 37;
714 pub const AF_ALG: ::c_int = 38;
715 
716 pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
717 pub const PF_UNIX: ::c_int = AF_UNIX;
718 pub const PF_LOCAL: ::c_int = AF_LOCAL;
719 pub const PF_INET: ::c_int = AF_INET;
720 pub const PF_AX25: ::c_int = AF_AX25;
721 pub const PF_IPX: ::c_int = AF_IPX;
722 pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
723 pub const PF_NETROM: ::c_int = AF_NETROM;
724 pub const PF_BRIDGE: ::c_int = AF_BRIDGE;
725 pub const PF_ATMPVC: ::c_int = AF_ATMPVC;
726 pub const PF_X25: ::c_int = AF_X25;
727 pub const PF_INET6: ::c_int = AF_INET6;
728 pub const PF_ROSE: ::c_int = AF_ROSE;
729 pub const PF_DECnet: ::c_int = AF_DECnet;
730 pub const PF_NETBEUI: ::c_int = AF_NETBEUI;
731 pub const PF_SECURITY: ::c_int = AF_SECURITY;
732 pub const PF_KEY: ::c_int = AF_KEY;
733 pub const PF_NETLINK: ::c_int = AF_NETLINK;
734 pub const PF_ROUTE: ::c_int = AF_ROUTE;
735 pub const PF_PACKET: ::c_int = AF_PACKET;
736 pub const PF_ASH: ::c_int = AF_ASH;
737 pub const PF_ECONET: ::c_int = AF_ECONET;
738 pub const PF_ATMSVC: ::c_int = AF_ATMSVC;
739 pub const PF_RDS: ::c_int = AF_RDS;
740 pub const PF_SNA: ::c_int = AF_SNA;
741 pub const PF_IRDA: ::c_int = AF_IRDA;
742 pub const PF_PPPOX: ::c_int = AF_PPPOX;
743 pub const PF_WANPIPE: ::c_int = AF_WANPIPE;
744 pub const PF_LLC: ::c_int = AF_LLC;
745 pub const PF_CAN: ::c_int = AF_CAN;
746 pub const PF_TIPC: ::c_int = AF_TIPC;
747 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
748 pub const PF_IUCV: ::c_int = AF_IUCV;
749 pub const PF_RXRPC: ::c_int = AF_RXRPC;
750 pub const PF_ISDN: ::c_int = AF_ISDN;
751 pub const PF_PHONET: ::c_int = AF_PHONET;
752 pub const PF_IEEE802154: ::c_int = AF_IEEE802154;
753 pub const PF_CAIF: ::c_int = AF_CAIF;
754 pub const PF_ALG: ::c_int = AF_ALG;
755 
756 pub const SOMAXCONN: ::c_int = 128;
757 
758 pub const MSG_OOB: ::c_int = 1;
759 pub const MSG_PEEK: ::c_int = 2;
760 pub const MSG_DONTROUTE: ::c_int = 4;
761 pub const MSG_CTRUNC: ::c_int = 8;
762 pub const MSG_TRUNC: ::c_int = 0x20;
763 pub const MSG_DONTWAIT: ::c_int = 0x40;
764 pub const MSG_EOR: ::c_int = 0x80;
765 pub const MSG_WAITALL: ::c_int = 0x100;
766 pub const MSG_FIN: ::c_int = 0x200;
767 pub const MSG_SYN: ::c_int = 0x400;
768 pub const MSG_CONFIRM: ::c_int = 0x800;
769 pub const MSG_RST: ::c_int = 0x1000;
770 pub const MSG_ERRQUEUE: ::c_int = 0x2000;
771 pub const MSG_NOSIGNAL: ::c_int = 0x4000;
772 pub const MSG_MORE: ::c_int = 0x8000;
773 pub const MSG_WAITFORONE: ::c_int = 0x10000;
774 pub const MSG_FASTOPEN: ::c_int = 0x20000000;
775 pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000;
776 
777 pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
778 
779 pub const SOCK_RAW: ::c_int = 3;
780 pub const SOCK_RDM: ::c_int = 4;
781 pub const IP_TOS: ::c_int = 1;
782 pub const IP_TTL: ::c_int = 2;
783 pub const IP_HDRINCL: ::c_int = 3;
784 pub const IP_OPTIONS: ::c_int = 4;
785 pub const IP_ROUTER_ALERT: ::c_int = 5;
786 pub const IP_RECVOPTS: ::c_int = 6;
787 pub const IP_RETOPTS: ::c_int = 7;
788 pub const IP_PKTINFO: ::c_int = 8;
789 pub const IP_PKTOPTIONS: ::c_int = 9;
790 pub const IP_MTU_DISCOVER: ::c_int = 10;
791 pub const IP_RECVERR: ::c_int = 11;
792 pub const IP_RECVTTL: ::c_int = 12;
793 pub const IP_RECVTOS: ::c_int = 13;
794 pub const IP_MTU: ::c_int = 14;
795 pub const IP_FREEBIND: ::c_int = 15;
796 pub const IP_IPSEC_POLICY: ::c_int = 16;
797 pub const IP_XFRM_POLICY: ::c_int = 17;
798 pub const IP_PASSSEC: ::c_int = 18;
799 pub const IP_TRANSPARENT: ::c_int = 19;
800 pub const IP_ORIGDSTADDR: ::c_int = 20;
801 pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR;
802 pub const IP_MINTTL: ::c_int = 21;
803 pub const IP_NODEFRAG: ::c_int = 22;
804 pub const IP_CHECKSUM: ::c_int = 23;
805 pub const IP_BIND_ADDRESS_NO_PORT: ::c_int = 24;
806 pub const IP_MULTICAST_IF: ::c_int = 32;
807 pub const IP_MULTICAST_TTL: ::c_int = 33;
808 pub const IP_MULTICAST_LOOP: ::c_int = 34;
809 pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
810 pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
811 pub const IP_UNBLOCK_SOURCE: ::c_int = 37;
812 pub const IP_BLOCK_SOURCE: ::c_int = 38;
813 pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39;
814 pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40;
815 pub const IP_MSFILTER: ::c_int = 41;
816 pub const IP_MULTICAST_ALL: ::c_int = 49;
817 pub const IP_UNICAST_IF: ::c_int = 50;
818 
819 pub const IP_DEFAULT_MULTICAST_TTL: ::c_int = 1;
820 pub const IP_DEFAULT_MULTICAST_LOOP: ::c_int = 1;
821 
822 pub const IP_PMTUDISC_DONT: ::c_int = 0;
823 pub const IP_PMTUDISC_WANT: ::c_int = 1;
824 pub const IP_PMTUDISC_DO: ::c_int = 2;
825 pub const IP_PMTUDISC_PROBE: ::c_int = 3;
826 pub const IP_PMTUDISC_INTERFACE: ::c_int = 4;
827 pub const IP_PMTUDISC_OMIT: ::c_int = 5;
828 
829 // IPPROTO_IP defined in src/unix/mod.rs
830 /// Hop-by-hop option header
831 pub const IPPROTO_HOPOPTS: ::c_int = 0;
832 // IPPROTO_ICMP defined in src/unix/mod.rs
833 /// group mgmt protocol
834 pub const IPPROTO_IGMP: ::c_int = 2;
835 /// for compatibility
836 pub const IPPROTO_IPIP: ::c_int = 4;
837 // IPPROTO_TCP defined in src/unix/mod.rs
838 /// exterior gateway protocol
839 pub const IPPROTO_EGP: ::c_int = 8;
840 /// pup
841 pub const IPPROTO_PUP: ::c_int = 12;
842 // IPPROTO_UDP defined in src/unix/mod.rs
843 /// xns idp
844 pub const IPPROTO_IDP: ::c_int = 22;
845 /// tp-4 w/ class negotiation
846 pub const IPPROTO_TP: ::c_int = 29;
847 /// DCCP
848 pub const IPPROTO_DCCP: ::c_int = 33;
849 // IPPROTO_IPV6 defined in src/unix/mod.rs
850 /// IP6 routing header
851 pub const IPPROTO_ROUTING: ::c_int = 43;
852 /// IP6 fragmentation header
853 pub const IPPROTO_FRAGMENT: ::c_int = 44;
854 /// resource reservation
855 pub const IPPROTO_RSVP: ::c_int = 46;
856 /// General Routing Encap.
857 pub const IPPROTO_GRE: ::c_int = 47;
858 /// IP6 Encap Sec. Payload
859 pub const IPPROTO_ESP: ::c_int = 50;
860 /// IP6 Auth Header
861 pub const IPPROTO_AH: ::c_int = 51;
862 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
863 /// IP6 no next header
864 pub const IPPROTO_NONE: ::c_int = 59;
865 /// IP6 destination option
866 pub const IPPROTO_DSTOPTS: ::c_int = 60;
867 pub const IPPROTO_MTP: ::c_int = 92;
868 /// encapsulation header
869 pub const IPPROTO_ENCAP: ::c_int = 98;
870 /// Protocol indep. multicast
871 pub const IPPROTO_PIM: ::c_int = 103;
872 /// IP Payload Comp. Protocol
873 pub const IPPROTO_COMP: ::c_int = 108;
874 /// SCTP
875 pub const IPPROTO_SCTP: ::c_int = 132;
876 pub const IPPROTO_MH: ::c_int = 135;
877 pub const IPPROTO_UDPLITE: ::c_int = 136;
878 /// raw IP packet
879 pub const IPPROTO_RAW: ::c_int = 255;
880 pub const IPPROTO_BEETPH: ::c_int = 94;
881 pub const IPPROTO_MPLS: ::c_int = 137;
882 
883 pub const MCAST_EXCLUDE: ::c_int = 0;
884 pub const MCAST_INCLUDE: ::c_int = 1;
885 pub const MCAST_JOIN_GROUP: ::c_int = 42;
886 pub const MCAST_BLOCK_SOURCE: ::c_int = 43;
887 pub const MCAST_UNBLOCK_SOURCE: ::c_int = 44;
888 pub const MCAST_LEAVE_GROUP: ::c_int = 45;
889 pub const MCAST_JOIN_SOURCE_GROUP: ::c_int = 46;
890 pub const MCAST_LEAVE_SOURCE_GROUP: ::c_int = 47;
891 pub const MCAST_MSFILTER: ::c_int = 48;
892 
893 pub const IPV6_ADDRFORM: ::c_int = 1;
894 pub const IPV6_2292PKTINFO: ::c_int = 2;
895 pub const IPV6_2292HOPOPTS: ::c_int = 3;
896 pub const IPV6_2292DSTOPTS: ::c_int = 4;
897 pub const IPV6_2292RTHDR: ::c_int = 5;
898 pub const IPV6_2292PKTOPTIONS: ::c_int = 6;
899 pub const IPV6_CHECKSUM: ::c_int = 7;
900 pub const IPV6_2292HOPLIMIT: ::c_int = 8;
901 pub const IPV6_NEXTHOP: ::c_int = 9;
902 pub const IPV6_AUTHHDR: ::c_int = 10;
903 pub const IPV6_UNICAST_HOPS: ::c_int = 16;
904 pub const IPV6_MULTICAST_IF: ::c_int = 17;
905 pub const IPV6_MULTICAST_HOPS: ::c_int = 18;
906 pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
907 pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
908 pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
909 pub const IPV6_ROUTER_ALERT: ::c_int = 22;
910 pub const IPV6_MTU_DISCOVER: ::c_int = 23;
911 pub const IPV6_MTU: ::c_int = 24;
912 pub const IPV6_RECVERR: ::c_int = 25;
913 pub const IPV6_V6ONLY: ::c_int = 26;
914 pub const IPV6_JOIN_ANYCAST: ::c_int = 27;
915 pub const IPV6_LEAVE_ANYCAST: ::c_int = 28;
916 pub const IPV6_IPSEC_POLICY: ::c_int = 34;
917 pub const IPV6_XFRM_POLICY: ::c_int = 35;
918 pub const IPV6_HDRINCL: ::c_int = 36;
919 pub const IPV6_RECVPKTINFO: ::c_int = 49;
920 pub const IPV6_PKTINFO: ::c_int = 50;
921 pub const IPV6_RECVHOPLIMIT: ::c_int = 51;
922 pub const IPV6_HOPLIMIT: ::c_int = 52;
923 pub const IPV6_RECVHOPOPTS: ::c_int = 53;
924 pub const IPV6_HOPOPTS: ::c_int = 54;
925 pub const IPV6_RTHDRDSTOPTS: ::c_int = 55;
926 pub const IPV6_RECVRTHDR: ::c_int = 56;
927 pub const IPV6_RTHDR: ::c_int = 57;
928 pub const IPV6_RECVDSTOPTS: ::c_int = 58;
929 pub const IPV6_DSTOPTS: ::c_int = 59;
930 pub const IPV6_RECVPATHMTU: ::c_int = 60;
931 pub const IPV6_PATHMTU: ::c_int = 61;
932 pub const IPV6_DONTFRAG: ::c_int = 62;
933 pub const IPV6_RECVTCLASS: ::c_int = 66;
934 pub const IPV6_TCLASS: ::c_int = 67;
935 pub const IPV6_AUTOFLOWLABEL: ::c_int = 70;
936 pub const IPV6_ADDR_PREFERENCES: ::c_int = 72;
937 pub const IPV6_MINHOPCOUNT: ::c_int = 73;
938 pub const IPV6_ORIGDSTADDR: ::c_int = 74;
939 pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
940 pub const IPV6_TRANSPARENT: ::c_int = 75;
941 pub const IPV6_UNICAST_IF: ::c_int = 76;
942 pub const IPV6_PREFER_SRC_TMP: ::c_int = 0x0001;
943 pub const IPV6_PREFER_SRC_PUBLIC: ::c_int = 0x0002;
944 pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT: ::c_int = 0x0100;
945 pub const IPV6_PREFER_SRC_COA: ::c_int = 0x0004;
946 pub const IPV6_PREFER_SRC_HOME: ::c_int = 0x0400;
947 pub const IPV6_PREFER_SRC_CGA: ::c_int = 0x0008;
948 pub const IPV6_PREFER_SRC_NONCGA: ::c_int = 0x0800;
949 
950 pub const IPV6_PMTUDISC_DONT: ::c_int = 0;
951 pub const IPV6_PMTUDISC_WANT: ::c_int = 1;
952 pub const IPV6_PMTUDISC_DO: ::c_int = 2;
953 pub const IPV6_PMTUDISC_PROBE: ::c_int = 3;
954 pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4;
955 pub const IPV6_PMTUDISC_OMIT: ::c_int = 5;
956 
957 pub const TCP_NODELAY: ::c_int = 1;
958 pub const TCP_MAXSEG: ::c_int = 2;
959 pub const TCP_CORK: ::c_int = 3;
960 pub const TCP_KEEPIDLE: ::c_int = 4;
961 pub const TCP_KEEPINTVL: ::c_int = 5;
962 pub const TCP_KEEPCNT: ::c_int = 6;
963 pub const TCP_SYNCNT: ::c_int = 7;
964 pub const TCP_LINGER2: ::c_int = 8;
965 pub const TCP_DEFER_ACCEPT: ::c_int = 9;
966 pub const TCP_WINDOW_CLAMP: ::c_int = 10;
967 pub const TCP_INFO: ::c_int = 11;
968 pub const TCP_QUICKACK: ::c_int = 12;
969 pub const TCP_CONGESTION: ::c_int = 13;
970 pub const TCP_MD5SIG: ::c_int = 14;
971 cfg_if! {
972     if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "musl")))] {
973         // WARN: deprecated
974         pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
975     }
976 }
977 pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
978 pub const TCP_THIN_DUPACK: ::c_int = 17;
979 pub const TCP_USER_TIMEOUT: ::c_int = 18;
980 pub const TCP_REPAIR: ::c_int = 19;
981 pub const TCP_REPAIR_QUEUE: ::c_int = 20;
982 pub const TCP_QUEUE_SEQ: ::c_int = 21;
983 pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
984 pub const TCP_FASTOPEN: ::c_int = 23;
985 pub const TCP_TIMESTAMP: ::c_int = 24;
986 pub const TCP_NOTSENT_LOWAT: ::c_int = 25;
987 pub const TCP_CC_INFO: ::c_int = 26;
988 pub const TCP_SAVE_SYN: ::c_int = 27;
989 pub const TCP_SAVED_SYN: ::c_int = 28;
990 cfg_if! {
991     if #[cfg(not(target_os = "emscripten"))] {
992         // NOTE: emscripten doesn't support these options yet.
993 
994         pub const TCP_REPAIR_WINDOW: ::c_int = 29;
995         pub const TCP_FASTOPEN_CONNECT: ::c_int = 30;
996         pub const TCP_ULP: ::c_int = 31;
997         pub const TCP_MD5SIG_EXT: ::c_int = 32;
998         pub const TCP_FASTOPEN_KEY: ::c_int = 33;
999         pub const TCP_FASTOPEN_NO_COOKIE: ::c_int = 34;
1000         pub const TCP_ZEROCOPY_RECEIVE: ::c_int = 35;
1001         pub const TCP_INQ: ::c_int = 36;
1002         pub const TCP_CM_INQ: ::c_int = TCP_INQ;
1003         // NOTE: Some CI images doesn't have this option yet.
1004         // pub const TCP_TX_DELAY: ::c_int = 37;
1005     }
1006 }
1007 
1008 pub const SO_DEBUG: ::c_int = 1;
1009 
1010 pub const SHUT_RD: ::c_int = 0;
1011 pub const SHUT_WR: ::c_int = 1;
1012 pub const SHUT_RDWR: ::c_int = 2;
1013 
1014 pub const LOCK_SH: ::c_int = 1;
1015 pub const LOCK_EX: ::c_int = 2;
1016 pub const LOCK_NB: ::c_int = 4;
1017 pub const LOCK_UN: ::c_int = 8;
1018 
1019 pub const SS_ONSTACK: ::c_int = 1;
1020 pub const SS_DISABLE: ::c_int = 2;
1021 
1022 pub const PATH_MAX: ::c_int = 4096;
1023 
1024 pub const UIO_MAXIOV: ::c_int = 1024;
1025 
1026 pub const FD_SETSIZE: usize = 1024;
1027 
1028 pub const EPOLLIN: ::c_int = 0x1;
1029 pub const EPOLLPRI: ::c_int = 0x2;
1030 pub const EPOLLOUT: ::c_int = 0x4;
1031 pub const EPOLLERR: ::c_int = 0x8;
1032 pub const EPOLLHUP: ::c_int = 0x10;
1033 pub const EPOLLRDNORM: ::c_int = 0x40;
1034 pub const EPOLLRDBAND: ::c_int = 0x80;
1035 pub const EPOLLWRNORM: ::c_int = 0x100;
1036 pub const EPOLLWRBAND: ::c_int = 0x200;
1037 pub const EPOLLMSG: ::c_int = 0x400;
1038 pub const EPOLLRDHUP: ::c_int = 0x2000;
1039 pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
1040 pub const EPOLLWAKEUP: ::c_int = 0x20000000;
1041 pub const EPOLLONESHOT: ::c_int = 0x40000000;
1042 pub const EPOLLET: ::c_int = 0x80000000;
1043 
1044 pub const EPOLL_CTL_ADD: ::c_int = 1;
1045 pub const EPOLL_CTL_MOD: ::c_int = 3;
1046 pub const EPOLL_CTL_DEL: ::c_int = 2;
1047 
1048 pub const MNT_DETACH: ::c_int = 0x2;
1049 pub const MNT_EXPIRE: ::c_int = 0x4;
1050 
1051 pub const Q_GETFMT: ::c_int = 0x800004;
1052 pub const Q_GETINFO: ::c_int = 0x800005;
1053 pub const Q_SETINFO: ::c_int = 0x800006;
1054 pub const QIF_BLIMITS: u32 = 1;
1055 pub const QIF_SPACE: u32 = 2;
1056 pub const QIF_ILIMITS: u32 = 4;
1057 pub const QIF_INODES: u32 = 8;
1058 pub const QIF_BTIME: u32 = 16;
1059 pub const QIF_ITIME: u32 = 32;
1060 pub const QIF_LIMITS: u32 = 5;
1061 pub const QIF_USAGE: u32 = 10;
1062 pub const QIF_TIMES: u32 = 48;
1063 pub const QIF_ALL: u32 = 63;
1064 
1065 pub const MNT_FORCE: ::c_int = 0x1;
1066 
1067 pub const Q_SYNC: ::c_int = 0x800001;
1068 pub const Q_QUOTAON: ::c_int = 0x800002;
1069 pub const Q_QUOTAOFF: ::c_int = 0x800003;
1070 pub const Q_GETQUOTA: ::c_int = 0x800007;
1071 pub const Q_SETQUOTA: ::c_int = 0x800008;
1072 
1073 pub const TCIOFF: ::c_int = 2;
1074 pub const TCION: ::c_int = 3;
1075 pub const TCOOFF: ::c_int = 0;
1076 pub const TCOON: ::c_int = 1;
1077 pub const TCIFLUSH: ::c_int = 0;
1078 pub const TCOFLUSH: ::c_int = 1;
1079 pub const TCIOFLUSH: ::c_int = 2;
1080 pub const NL0: ::tcflag_t = 0x00000000;
1081 pub const NL1: ::tcflag_t = 0x00000100;
1082 pub const TAB0: ::tcflag_t = 0x00000000;
1083 pub const CR0: ::tcflag_t = 0x00000000;
1084 pub const FF0: ::tcflag_t = 0x00000000;
1085 pub const BS0: ::tcflag_t = 0x00000000;
1086 pub const VT0: ::tcflag_t = 0x00000000;
1087 pub const VERASE: usize = 2;
1088 pub const VKILL: usize = 3;
1089 pub const VINTR: usize = 0;
1090 pub const VQUIT: usize = 1;
1091 pub const VLNEXT: usize = 15;
1092 pub const IGNBRK: ::tcflag_t = 0x00000001;
1093 pub const BRKINT: ::tcflag_t = 0x00000002;
1094 pub const IGNPAR: ::tcflag_t = 0x00000004;
1095 pub const PARMRK: ::tcflag_t = 0x00000008;
1096 pub const INPCK: ::tcflag_t = 0x00000010;
1097 pub const ISTRIP: ::tcflag_t = 0x00000020;
1098 pub const INLCR: ::tcflag_t = 0x00000040;
1099 pub const IGNCR: ::tcflag_t = 0x00000080;
1100 pub const ICRNL: ::tcflag_t = 0x00000100;
1101 pub const IXANY: ::tcflag_t = 0x00000800;
1102 pub const IMAXBEL: ::tcflag_t = 0x00002000;
1103 pub const OPOST: ::tcflag_t = 0x1;
1104 pub const CS5: ::tcflag_t = 0x00000000;
1105 pub const CRTSCTS: ::tcflag_t = 0x80000000;
1106 pub const ECHO: ::tcflag_t = 0x00000008;
1107 pub const OCRNL: ::tcflag_t = 0o000010;
1108 pub const ONOCR: ::tcflag_t = 0o000020;
1109 pub const ONLRET: ::tcflag_t = 0o000040;
1110 pub const OFILL: ::tcflag_t = 0o000100;
1111 pub const OFDEL: ::tcflag_t = 0o000200;
1112 
1113 pub const CLONE_VM: ::c_int = 0x100;
1114 pub const CLONE_FS: ::c_int = 0x200;
1115 pub const CLONE_FILES: ::c_int = 0x400;
1116 pub const CLONE_SIGHAND: ::c_int = 0x800;
1117 pub const CLONE_PTRACE: ::c_int = 0x2000;
1118 pub const CLONE_VFORK: ::c_int = 0x4000;
1119 pub const CLONE_PARENT: ::c_int = 0x8000;
1120 pub const CLONE_THREAD: ::c_int = 0x10000;
1121 pub const CLONE_NEWNS: ::c_int = 0x20000;
1122 pub const CLONE_SYSVSEM: ::c_int = 0x40000;
1123 pub const CLONE_SETTLS: ::c_int = 0x80000;
1124 pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
1125 pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
1126 pub const CLONE_DETACHED: ::c_int = 0x400000;
1127 pub const CLONE_UNTRACED: ::c_int = 0x800000;
1128 pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
1129 pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
1130 pub const CLONE_NEWUTS: ::c_int = 0x04000000;
1131 pub const CLONE_NEWIPC: ::c_int = 0x08000000;
1132 pub const CLONE_NEWUSER: ::c_int = 0x10000000;
1133 pub const CLONE_NEWPID: ::c_int = 0x20000000;
1134 pub const CLONE_NEWNET: ::c_int = 0x40000000;
1135 pub const CLONE_IO: ::c_int = 0x80000000;
1136 
1137 pub const WNOHANG: ::c_int = 0x00000001;
1138 pub const WUNTRACED: ::c_int = 0x00000002;
1139 pub const WSTOPPED: ::c_int = WUNTRACED;
1140 pub const WEXITED: ::c_int = 0x00000004;
1141 pub const WCONTINUED: ::c_int = 0x00000008;
1142 pub const WNOWAIT: ::c_int = 0x01000000;
1143 
1144 // Options for personality(2).
1145 pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000;
1146 pub const MMAP_PAGE_ZERO: ::c_int = 0x0100000;
1147 pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000;
1148 pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000;
1149 pub const ADDR_LIMIT_32BIT: ::c_int = 0x0800000;
1150 pub const SHORT_INODE: ::c_int = 0x1000000;
1151 pub const WHOLE_SECONDS: ::c_int = 0x2000000;
1152 pub const STICKY_TIMEOUTS: ::c_int = 0x4000000;
1153 pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000;
1154 
1155 // Options set using PTRACE_SETOPTIONS.
1156 pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
1157 pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002;
1158 pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004;
1159 pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008;
1160 pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010;
1161 pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020;
1162 pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040;
1163 pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080;
1164 pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000;
1165 pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000;
1166 
1167 // Wait extended result codes for the above trace options.
1168 pub const PTRACE_EVENT_FORK: ::c_int = 1;
1169 pub const PTRACE_EVENT_VFORK: ::c_int = 2;
1170 pub const PTRACE_EVENT_CLONE: ::c_int = 3;
1171 pub const PTRACE_EVENT_EXEC: ::c_int = 4;
1172 pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5;
1173 pub const PTRACE_EVENT_EXIT: ::c_int = 6;
1174 pub const PTRACE_EVENT_SECCOMP: ::c_int = 7;
1175 
1176 pub const __WNOTHREAD: ::c_int = 0x20000000;
1177 pub const __WALL: ::c_int = 0x40000000;
1178 pub const __WCLONE: ::c_int = 0x80000000;
1179 
1180 pub const SPLICE_F_MOVE: ::c_uint = 0x01;
1181 pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
1182 pub const SPLICE_F_MORE: ::c_uint = 0x04;
1183 pub const SPLICE_F_GIFT: ::c_uint = 0x08;
1184 
1185 pub const RTLD_LOCAL: ::c_int = 0;
1186 pub const RTLD_LAZY: ::c_int = 1;
1187 
1188 pub const POSIX_FADV_NORMAL: ::c_int = 0;
1189 pub const POSIX_FADV_RANDOM: ::c_int = 1;
1190 pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
1191 pub const POSIX_FADV_WILLNEED: ::c_int = 3;
1192 
1193 pub const AT_FDCWD: ::c_int = -100;
1194 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
1195 pub const AT_REMOVEDIR: ::c_int = 0x200;
1196 pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
1197 pub const AT_NO_AUTOMOUNT: ::c_int = 0x800;
1198 pub const AT_EMPTY_PATH: ::c_int = 0x1000;
1199 
1200 pub const LOG_CRON: ::c_int = 9 << 3;
1201 pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
1202 pub const LOG_FTP: ::c_int = 11 << 3;
1203 pub const LOG_PERROR: ::c_int = 0x20;
1204 
1205 pub const PIPE_BUF: usize = 4096;
1206 
1207 pub const SI_LOAD_SHIFT: ::c_uint = 16;
1208 
1209 pub const CLD_EXITED: ::c_int = 1;
1210 pub const CLD_KILLED: ::c_int = 2;
1211 pub const CLD_DUMPED: ::c_int = 3;
1212 pub const CLD_TRAPPED: ::c_int = 4;
1213 pub const CLD_STOPPED: ::c_int = 5;
1214 pub const CLD_CONTINUED: ::c_int = 6;
1215 
1216 pub const SIGEV_SIGNAL: ::c_int = 0;
1217 pub const SIGEV_NONE: ::c_int = 1;
1218 pub const SIGEV_THREAD: ::c_int = 2;
1219 
1220 pub const P_ALL: idtype_t = 0;
1221 pub const P_PID: idtype_t = 1;
1222 pub const P_PGID: idtype_t = 2;
1223 cfg_if! {
1224     if #[cfg(not(target_os = "emscripten"))] {
1225         pub const P_PIDFD: idtype_t = 3;
1226     }
1227 }
1228 
1229 pub const UTIME_OMIT: c_long = 1073741822;
1230 pub const UTIME_NOW: c_long = 1073741823;
1231 
1232 pub const POLLIN: ::c_short = 0x1;
1233 pub const POLLPRI: ::c_short = 0x2;
1234 pub const POLLOUT: ::c_short = 0x4;
1235 pub const POLLERR: ::c_short = 0x8;
1236 pub const POLLHUP: ::c_short = 0x10;
1237 pub const POLLNVAL: ::c_short = 0x20;
1238 pub const POLLRDNORM: ::c_short = 0x040;
1239 pub const POLLRDBAND: ::c_short = 0x080;
1240 #[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))]
1241 pub const POLLRDHUP: ::c_short = 0x2000;
1242 #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))]
1243 pub const POLLRDHUP: ::c_short = 0x800;
1244 
1245 pub const IPTOS_LOWDELAY: u8 = 0x10;
1246 pub const IPTOS_THROUGHPUT: u8 = 0x08;
1247 pub const IPTOS_RELIABILITY: u8 = 0x04;
1248 pub const IPTOS_MINCOST: u8 = 0x02;
1249 
1250 pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0;
1251 pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0;
1252 pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0;
1253 pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80;
1254 pub const IPTOS_PREC_FLASH: u8 = 0x60;
1255 pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40;
1256 pub const IPTOS_PREC_PRIORITY: u8 = 0x20;
1257 pub const IPTOS_PREC_ROUTINE: u8 = 0x00;
1258 
1259 pub const IPTOS_ECN_MASK: u8 = 0x03;
1260 pub const IPTOS_ECN_ECT1: u8 = 0x01;
1261 pub const IPTOS_ECN_ECT0: u8 = 0x02;
1262 pub const IPTOS_ECN_CE: u8 = 0x03;
1263 
1264 pub const IPOPT_COPY: u8 = 0x80;
1265 pub const IPOPT_CLASS_MASK: u8 = 0x60;
1266 pub const IPOPT_NUMBER_MASK: u8 = 0x1f;
1267 
1268 pub const IPOPT_CONTROL: u8 = 0x00;
1269 pub const IPOPT_RESERVED1: u8 = 0x20;
1270 pub const IPOPT_MEASUREMENT: u8 = 0x40;
1271 pub const IPOPT_RESERVED2: u8 = 0x60;
1272 pub const IPOPT_END: u8 = 0 | IPOPT_CONTROL;
1273 pub const IPOPT_NOOP: u8 = 1 | IPOPT_CONTROL;
1274 pub const IPOPT_SEC: u8 = 2 | IPOPT_CONTROL | IPOPT_COPY;
1275 pub const IPOPT_LSRR: u8 = 3 | IPOPT_CONTROL | IPOPT_COPY;
1276 pub const IPOPT_TIMESTAMP: u8 = 4 | IPOPT_MEASUREMENT;
1277 pub const IPOPT_RR: u8 = 7 | IPOPT_CONTROL;
1278 pub const IPOPT_SID: u8 = 8 | IPOPT_CONTROL | IPOPT_COPY;
1279 pub const IPOPT_SSRR: u8 = 9 | IPOPT_CONTROL | IPOPT_COPY;
1280 pub const IPOPT_RA: u8 = 20 | IPOPT_CONTROL | IPOPT_COPY;
1281 pub const IPVERSION: u8 = 4;
1282 pub const MAXTTL: u8 = 255;
1283 pub const IPDEFTTL: u8 = 64;
1284 pub const IPOPT_OPTVAL: u8 = 0;
1285 pub const IPOPT_OLEN: u8 = 1;
1286 pub const IPOPT_OFFSET: u8 = 2;
1287 pub const IPOPT_MINOFF: u8 = 4;
1288 pub const MAX_IPOPTLEN: u8 = 40;
1289 pub const IPOPT_NOP: u8 = IPOPT_NOOP;
1290 pub const IPOPT_EOL: u8 = IPOPT_END;
1291 pub const IPOPT_TS: u8 = IPOPT_TIMESTAMP;
1292 pub const IPOPT_TS_TSONLY: u8 = 0;
1293 pub const IPOPT_TS_TSANDADDR: u8 = 1;
1294 pub const IPOPT_TS_PRESPEC: u8 = 3;
1295 
1296 pub const ARPOP_RREQUEST: u16 = 3;
1297 pub const ARPOP_RREPLY: u16 = 4;
1298 pub const ARPOP_InREQUEST: u16 = 8;
1299 pub const ARPOP_InREPLY: u16 = 9;
1300 pub const ARPOP_NAK: u16 = 10;
1301 
1302 pub const ATF_NETMASK: ::c_int = 0x20;
1303 pub const ATF_DONTPUB: ::c_int = 0x40;
1304 
1305 pub const ARPHRD_NETROM: u16 = 0;
1306 pub const ARPHRD_ETHER: u16 = 1;
1307 pub const ARPHRD_EETHER: u16 = 2;
1308 pub const ARPHRD_AX25: u16 = 3;
1309 pub const ARPHRD_PRONET: u16 = 4;
1310 pub const ARPHRD_CHAOS: u16 = 5;
1311 pub const ARPHRD_IEEE802: u16 = 6;
1312 pub const ARPHRD_ARCNET: u16 = 7;
1313 pub const ARPHRD_APPLETLK: u16 = 8;
1314 pub const ARPHRD_DLCI: u16 = 15;
1315 pub const ARPHRD_ATM: u16 = 19;
1316 pub const ARPHRD_METRICOM: u16 = 23;
1317 pub const ARPHRD_IEEE1394: u16 = 24;
1318 pub const ARPHRD_EUI64: u16 = 27;
1319 pub const ARPHRD_INFINIBAND: u16 = 32;
1320 
1321 pub const ARPHRD_SLIP: u16 = 256;
1322 pub const ARPHRD_CSLIP: u16 = 257;
1323 pub const ARPHRD_SLIP6: u16 = 258;
1324 pub const ARPHRD_CSLIP6: u16 = 259;
1325 pub const ARPHRD_RSRVD: u16 = 260;
1326 pub const ARPHRD_ADAPT: u16 = 264;
1327 pub const ARPHRD_ROSE: u16 = 270;
1328 pub const ARPHRD_X25: u16 = 271;
1329 pub const ARPHRD_HWX25: u16 = 272;
1330 pub const ARPHRD_CAN: u16 = 280;
1331 pub const ARPHRD_PPP: u16 = 512;
1332 pub const ARPHRD_CISCO: u16 = 513;
1333 pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO;
1334 pub const ARPHRD_LAPB: u16 = 516;
1335 pub const ARPHRD_DDCMP: u16 = 517;
1336 pub const ARPHRD_RAWHDLC: u16 = 518;
1337 
1338 pub const ARPHRD_TUNNEL: u16 = 768;
1339 pub const ARPHRD_TUNNEL6: u16 = 769;
1340 pub const ARPHRD_FRAD: u16 = 770;
1341 pub const ARPHRD_SKIP: u16 = 771;
1342 pub const ARPHRD_LOOPBACK: u16 = 772;
1343 pub const ARPHRD_LOCALTLK: u16 = 773;
1344 pub const ARPHRD_FDDI: u16 = 774;
1345 pub const ARPHRD_BIF: u16 = 775;
1346 pub const ARPHRD_SIT: u16 = 776;
1347 pub const ARPHRD_IPDDP: u16 = 777;
1348 pub const ARPHRD_IPGRE: u16 = 778;
1349 pub const ARPHRD_PIMREG: u16 = 779;
1350 pub const ARPHRD_HIPPI: u16 = 780;
1351 pub const ARPHRD_ASH: u16 = 781;
1352 pub const ARPHRD_ECONET: u16 = 782;
1353 pub const ARPHRD_IRDA: u16 = 783;
1354 pub const ARPHRD_FCPP: u16 = 784;
1355 pub const ARPHRD_FCAL: u16 = 785;
1356 pub const ARPHRD_FCPL: u16 = 786;
1357 pub const ARPHRD_FCFABRIC: u16 = 787;
1358 pub const ARPHRD_IEEE802_TR: u16 = 800;
1359 pub const ARPHRD_IEEE80211: u16 = 801;
1360 pub const ARPHRD_IEEE80211_PRISM: u16 = 802;
1361 pub const ARPHRD_IEEE80211_RADIOTAP: u16 = 803;
1362 pub const ARPHRD_IEEE802154: u16 = 804;
1363 
1364 pub const ARPHRD_VOID: u16 = 0xFFFF;
1365 pub const ARPHRD_NONE: u16 = 0xFFFE;
1366 
1367 cfg_if! {
1368     if #[cfg(not(target_env = "uclibc"))] {
1369         pub const PTRACE_O_MASK: ::c_int = 0x003000ff;
1370     }
1371 }
1372 
1373 const_fn! {
1374     {const} fn CMSG_ALIGN(len: usize) -> usize {
1375         len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
1376     }
1377 }
1378 
1379 f! {
1380     pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1381         if (*mhdr).msg_controllen as usize >= ::mem::size_of::<cmsghdr>() {
1382             (*mhdr).msg_control as *mut cmsghdr
1383         } else {
1384             0 as *mut cmsghdr
1385         }
1386     }
1387 
1388     pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar {
1389         cmsg.offset(1) as *mut ::c_uchar
1390     }
1391 
1392     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1393         (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
1394             as ::c_uint
1395     }
1396 
1397     pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1398         CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length
1399     }
1400 
1401     pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
1402         let fd = fd as usize;
1403         let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
1404         (*set).fds_bits[fd / size] &= !(1 << (fd % size));
1405         return
1406     }
1407 
1408     pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
1409         let fd = fd as usize;
1410         let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
1411         return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
1412     }
1413 
1414     pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
1415         let fd = fd as usize;
1416         let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
1417         (*set).fds_bits[fd / size] |= 1 << (fd % size);
1418         return
1419     }
1420 
1421     pub fn FD_ZERO(set: *mut fd_set) -> () {
1422         for slot in (*set).fds_bits.iter_mut() {
1423             *slot = 0;
1424         }
1425     }
1426 }
1427 
1428 safe_f! {
1429     pub fn SIGRTMAX() -> ::c_int {
1430         unsafe { __libc_current_sigrtmax() }
1431     }
1432 
1433     pub fn SIGRTMIN() -> ::c_int {
1434         unsafe { __libc_current_sigrtmin() }
1435     }
1436 
1437     pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1438         (status & 0xff) == 0x7f
1439     }
1440 
1441     pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1442         (status >> 8) & 0xff
1443     }
1444 
1445     pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1446         status == 0xffff
1447     }
1448 
1449     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1450         ((status & 0x7f) + 1) as i8 >= 2
1451     }
1452 
1453     pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
1454         status & 0x7f
1455     }
1456 
1457     pub {const} fn WIFEXITED(status: ::c_int) -> bool {
1458         (status & 0x7f) == 0
1459     }
1460 
1461     pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
1462         (status >> 8) & 0xff
1463     }
1464 
1465     pub {const} fn WCOREDUMP(status: ::c_int) -> bool {
1466         (status & 0x80) != 0
1467     }
1468 
1469     pub {const} fn W_EXITCODE(ret: ::c_int, sig: ::c_int) -> ::c_int {
1470         (ret << 8) | sig
1471     }
1472 
1473     pub {const} fn W_STOPCODE(sig: ::c_int) -> ::c_int {
1474         (sig << 8) | 0x7f
1475     }
1476 
1477     pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
1478         (cmd << 8) | (type_ & 0x00ff)
1479     }
1480 
1481     pub {const} fn IPOPT_COPIED(o: u8) -> u8 {
1482         o & IPOPT_COPY
1483     }
1484 
1485     pub {const} fn IPOPT_CLASS(o: u8) -> u8 {
1486         o & IPOPT_CLASS_MASK
1487     }
1488 
1489     pub {const} fn IPOPT_NUMBER(o: u8) -> u8 {
1490         o & IPOPT_NUMBER_MASK
1491     }
1492 
1493     pub {const} fn IPTOS_ECN(x: u8) -> u8 {
1494         x & ::IPTOS_ECN_MASK
1495     }
1496 }
1497 
1498 extern "C" {
1499     #[doc(hidden)]
__libc_current_sigrtmax() -> ::c_int1500     pub fn __libc_current_sigrtmax() -> ::c_int;
1501     #[doc(hidden)]
__libc_current_sigrtmin() -> ::c_int1502     pub fn __libc_current_sigrtmin() -> ::c_int;
1503 
sem_destroy(sem: *mut sem_t) -> ::c_int1504     pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int1505     pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
fdatasync(fd: ::c_int) -> ::c_int1506     pub fn fdatasync(fd: ::c_int) -> ::c_int;
mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int1507     pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int;
1508 
clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int1509     pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int1510     pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int1511     pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::c_int1512     pub fn clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::c_int;
1513 
dirfd(dirp: *mut ::DIR) -> ::c_int1514     pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
1515 
pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int1516     pub fn pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t, ) -> ::c_int1517     pub fn pthread_attr_getstack(
1518         attr: *const ::pthread_attr_t,
1519         stackaddr: *mut *mut ::c_void,
1520         stacksize: *mut ::size_t,
1521     ) -> ::c_int;
memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void1522     pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int1523     pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int;
pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int1524     pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int1525     pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int1526     pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int;
fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int1527     pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int1528     pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int;
statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int1529     pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int;
fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int1530     pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int;
memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void1531     pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
1532 
posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int1533     pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int;
posix_fadvise64( fd: ::c_int, offset: ::off64_t, len: ::off64_t, advise: ::c_int, ) -> ::c_int1534     pub fn posix_fadvise64(
1535         fd: ::c_int,
1536         offset: ::off64_t,
1537         len: ::off64_t,
1538         advise: ::c_int,
1539     ) -> ::c_int;
futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int1540     pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
utimensat( dirfd: ::c_int, path: *const ::c_char, times: *const ::timespec, flag: ::c_int, ) -> ::c_int1541     pub fn utimensat(
1542         dirfd: ::c_int,
1543         path: *const ::c_char,
1544         times: *const ::timespec,
1545         flag: ::c_int,
1546     ) -> ::c_int;
duplocale(base: ::locale_t) -> ::locale_t1547     pub fn duplocale(base: ::locale_t) -> ::locale_t;
freelocale(loc: ::locale_t)1548     pub fn freelocale(loc: ::locale_t);
newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t1549     pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
uselocale(loc: ::locale_t) -> ::locale_t1550     pub fn uselocale(loc: ::locale_t) -> ::locale_t;
creat64(path: *const c_char, mode: mode_t) -> ::c_int1551     pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int;
fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int1552     pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
fstatat64( dirfd: ::c_int, pathname: *const c_char, buf: *mut stat64, flags: ::c_int, ) -> ::c_int1553     pub fn fstatat64(
1554         dirfd: ::c_int,
1555         pathname: *const c_char,
1556         buf: *mut stat64,
1557         flags: ::c_int,
1558     ) -> ::c_int;
ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int1559     pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t1560     pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int1561     pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
mmap64( addr: *mut ::c_void, len: ::size_t, prot: ::c_int, flags: ::c_int, fd: ::c_int, offset: off64_t, ) -> *mut ::c_void1562     pub fn mmap64(
1563         addr: *mut ::c_void,
1564         len: ::size_t,
1565         prot: ::c_int,
1566         flags: ::c_int,
1567         fd: ::c_int,
1568         offset: off64_t,
1569     ) -> *mut ::c_void;
open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int1570     pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
openat64(fd: ::c_int, path: *const c_char, oflag: ::c_int, ...) -> ::c_int1571     pub fn openat64(fd: ::c_int, path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t1572     pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t;
pwrite64( fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off64_t, ) -> ::ssize_t1573     pub fn pwrite64(
1574         fd: ::c_int,
1575         buf: *const ::c_void,
1576         count: ::size_t,
1577         offset: off64_t,
1578     ) -> ::ssize_t;
readdir64(dirp: *mut ::DIR) -> *mut ::dirent641579     pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
readdir64_r( dirp: *mut ::DIR, entry: *mut ::dirent64, result: *mut *mut ::dirent64, ) -> ::c_int1580     pub fn readdir64_r(
1581         dirp: *mut ::DIR,
1582         entry: *mut ::dirent64,
1583         result: *mut *mut ::dirent64,
1584     ) -> ::c_int;
stat64(path: *const c_char, buf: *mut stat64) -> ::c_int1585     pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
truncate64(path: *const c_char, length: off64_t) -> ::c_int1586     pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int;
1587 
mknodat( dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t, ) -> ::c_int1588     pub fn mknodat(
1589         dirfd: ::c_int,
1590         pathname: *const ::c_char,
1591         mode: ::mode_t,
1592         dev: dev_t,
1593     ) -> ::c_int;
pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, ) -> ::c_int1594     pub fn pthread_condattr_getclock(
1595         attr: *const pthread_condattr_t,
1596         clock_id: *mut clockid_t,
1597     ) -> ::c_int;
pthread_condattr_setclock( attr: *mut pthread_condattr_t, clock_id: ::clockid_t, ) -> ::c_int1598     pub fn pthread_condattr_setclock(
1599         attr: *mut pthread_condattr_t,
1600         clock_id: ::clockid_t,
1601     ) -> ::c_int;
pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int1602     pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int;
pthread_mutexattr_setpshared( attr: *mut pthread_mutexattr_t, pshared: ::c_int, ) -> ::c_int1603     pub fn pthread_mutexattr_setpshared(
1604         attr: *mut pthread_mutexattr_t,
1605         pshared: ::c_int,
1606     ) -> ::c_int;
pthread_rwlockattr_getpshared( attr: *const pthread_rwlockattr_t, val: *mut ::c_int, ) -> ::c_int1607     pub fn pthread_rwlockattr_getpshared(
1608         attr: *const pthread_rwlockattr_t,
1609         val: *mut ::c_int,
1610     ) -> ::c_int;
pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: ::c_int) -> ::c_int1611     pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: ::c_int) -> ::c_int;
ptsname_r(fd: ::c_int, buf: *mut ::c_char, buflen: ::size_t) -> ::c_int1612     pub fn ptsname_r(fd: ::c_int, buf: *mut ::c_char, buflen: ::size_t) -> ::c_int;
clearenv() -> ::c_int1613     pub fn clearenv() -> ::c_int;
waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int1614     pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int)
1615         -> ::c_int;
setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int1616     pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int;
setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int1617     pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int;
getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int1618     pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int;
getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int1619     pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int;
acct(filename: *const ::c_char) -> ::c_int1620     pub fn acct(filename: *const ::c_char) -> ::c_int;
brk(addr: *mut ::c_void) -> ::c_int1621     pub fn brk(addr: *mut ::c_void) -> ::c_int;
sbrk(increment: ::intptr_t) -> *mut ::c_void1622     pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
1623     #[deprecated(
1624         since = "0.2.66",
1625         note = "causes memory corruption, see rust-lang/libc#1596"
1626     )]
vfork() -> ::pid_t1627     pub fn vfork() -> ::pid_t;
setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int1628     pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int1629     pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
wait4( pid: ::pid_t, status: *mut ::c_int, options: ::c_int, rusage: *mut ::rusage, ) -> ::pid_t1630     pub fn wait4(
1631         pid: ::pid_t,
1632         status: *mut ::c_int,
1633         options: ::c_int,
1634         rusage: *mut ::rusage,
1635     ) -> ::pid_t;
login_tty(fd: ::c_int) -> ::c_int1636     pub fn login_tty(fd: ::c_int) -> ::c_int;
execvpe( file: *const ::c_char, argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int1637     pub fn execvpe(
1638         file: *const ::c_char,
1639         argv: *const *const ::c_char,
1640         envp: *const *const ::c_char,
1641     ) -> ::c_int;
fexecve( fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int1642     pub fn fexecve(
1643         fd: ::c_int,
1644         argv: *const *const ::c_char,
1645         envp: *const *const ::c_char,
1646     ) -> ::c_int;
getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int1647     pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
freeifaddrs(ifa: *mut ::ifaddrs)1648     pub fn freeifaddrs(ifa: *mut ::ifaddrs);
bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int1649     pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;
1650 
writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t1651     pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t1652     pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
1653 
sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t1654     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_t1655     pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
uname(buf: *mut ::utsname) -> ::c_int1656     pub fn uname(buf: *mut ::utsname) -> ::c_int;
1657 }
1658 
1659 cfg_if! {
1660     if #[cfg(not(target_env = "uclibc"))] {
1661         extern "C" {
1662             pub fn preadv64(
1663                 fd: ::c_int,
1664                 iov: *const ::iovec,
1665                 iovcnt: ::c_int,
1666                 offset: ::off64_t,
1667             ) -> ::ssize_t;
1668             pub fn pwritev64(
1669                 fd: ::c_int,
1670                 iov: *const ::iovec,
1671                 iovcnt: ::c_int,
1672                 offset: ::off64_t,
1673             ) -> ::ssize_t;
1674             // uclibc has separate non-const version of this function
1675             pub fn forkpty(
1676                 amaster: *mut ::c_int,
1677                 name: *mut ::c_char,
1678                 termp: *const termios,
1679                 winp: *const ::winsize,
1680             ) -> ::pid_t;
1681             // uclibc has separate non-const version of this function
1682             pub fn openpty(
1683                 amaster: *mut ::c_int,
1684                 aslave: *mut ::c_int,
1685                 name: *mut ::c_char,
1686                 termp: *const termios,
1687                 winp: *const ::winsize,
1688             ) -> ::c_int;
1689         }
1690     }
1691 }
1692 
1693 cfg_if! {
1694     if #[cfg(target_os = "emscripten")] {
1695         mod emscripten;
1696         pub use self::emscripten::*;
1697     } else if #[cfg(target_os = "linux")] {
1698         mod linux;
1699         pub use self::linux::*;
1700     } else if #[cfg(target_os = "l4re")] {
1701         mod linux;
1702         pub use self::linux::*;
1703     } else if #[cfg(target_os = "android")] {
1704         mod android;
1705         pub use self::android::*;
1706     } else {
1707         // Unknown target_os
1708     }
1709 }
1710