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