xref: /rust-libc-0.2.174/src/unix/mod.rs (revision 2d11246b)
1 //! Definitions found commonly among almost all Unix derivatives
2 //!
3 //! More functions and definitions can be found in the more specific modules
4 //! according to the platform in question.
5 
6 pub type c_schar = i8;
7 pub type c_uchar = u8;
8 pub type c_short = i16;
9 pub type c_ushort = u16;
10 pub type c_int = i32;
11 pub type c_uint = u32;
12 pub type c_float = f32;
13 pub type c_double = f64;
14 pub type c_longlong = i64;
15 pub type c_ulonglong = u64;
16 pub type intmax_t = i64;
17 pub type uintmax_t = u64;
18 
19 pub type size_t = usize;
20 pub type ptrdiff_t = isize;
21 pub type intptr_t = isize;
22 pub type uintptr_t = usize;
23 pub type ssize_t = isize;
24 
25 pub type pid_t = i32;
26 pub type in_addr_t = u32;
27 pub type in_port_t = u16;
28 pub type sighandler_t = ::size_t;
29 pub type cc_t = ::c_uchar;
30 
31 cfg_if! {
32     if #[cfg(any(target_os = "espidf", target_os = "horizon"))] {
33         pub type uid_t = ::c_ushort;
34         pub type gid_t = ::c_ushort;
35     } else {
36         pub type uid_t = u32;
37         pub type gid_t = u32;
38     }
39 }
40 
41 #[cfg_attr(feature = "extra_traits", derive(Debug))]
42 pub enum DIR {}
43 impl ::Copy for DIR {}
44 impl ::Clone for DIR {
45     fn clone(&self) -> DIR {
46         *self
47     }
48 }
49 pub type locale_t = *mut ::c_void;
50 
51 s! {
52     pub struct group {
53         pub gr_name: *mut ::c_char,
54         pub gr_passwd: *mut ::c_char,
55         pub gr_gid: ::gid_t,
56         pub gr_mem: *mut *mut ::c_char,
57     }
58 
59     pub struct utimbuf {
60         pub actime: time_t,
61         pub modtime: time_t,
62     }
63 
64     pub struct timeval {
65         pub tv_sec: time_t,
66         pub tv_usec: suseconds_t,
67     }
68 
69     // linux x32 compatibility
70     // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
71     pub struct timespec {
72         pub tv_sec: time_t,
73         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
74         pub tv_nsec: i64,
75         #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
76         pub tv_nsec: ::c_long,
77     }
78 
79     pub struct rlimit {
80         pub rlim_cur: rlim_t,
81         pub rlim_max: rlim_t,
82     }
83 
84     pub struct rusage {
85         pub ru_utime: timeval,
86         pub ru_stime: timeval,
87         pub ru_maxrss: c_long,
88         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
89         __pad1: u32,
90         pub ru_ixrss: c_long,
91         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
92         __pad2: u32,
93         pub ru_idrss: c_long,
94         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
95         __pad3: u32,
96         pub ru_isrss: c_long,
97         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
98         __pad4: u32,
99         pub ru_minflt: c_long,
100         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
101         __pad5: u32,
102         pub ru_majflt: c_long,
103         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
104         __pad6: u32,
105         pub ru_nswap: c_long,
106         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
107         __pad7: u32,
108         pub ru_inblock: c_long,
109         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
110         __pad8: u32,
111         pub ru_oublock: c_long,
112         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
113         __pad9: u32,
114         pub ru_msgsnd: c_long,
115         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
116         __pad10: u32,
117         pub ru_msgrcv: c_long,
118         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
119         __pad11: u32,
120         pub ru_nsignals: c_long,
121         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
122         __pad12: u32,
123         pub ru_nvcsw: c_long,
124         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
125         __pad13: u32,
126         pub ru_nivcsw: c_long,
127         #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
128         __pad14: u32,
129 
130         #[cfg(any(target_env = "musl", target_os = "emscripten"))]
131         __reserved: [c_long; 16],
132     }
133 
134     pub struct ipv6_mreq {
135         pub ipv6mr_multiaddr: in6_addr,
136         #[cfg(target_os = "android")]
137         pub ipv6mr_interface: ::c_int,
138         #[cfg(not(target_os = "android"))]
139         pub ipv6mr_interface: ::c_uint,
140     }
141 
142     pub struct hostent {
143         pub h_name: *mut ::c_char,
144         pub h_aliases: *mut *mut ::c_char,
145         pub h_addrtype: ::c_int,
146         pub h_length: ::c_int,
147         pub h_addr_list: *mut *mut ::c_char,
148     }
149 
150     pub struct iovec {
151         pub iov_base: *mut ::c_void,
152         pub iov_len: ::size_t,
153     }
154 
155     pub struct pollfd {
156         pub fd: ::c_int,
157         pub events: ::c_short,
158         pub revents: ::c_short,
159     }
160 
161     pub struct winsize {
162         pub ws_row: ::c_ushort,
163         pub ws_col: ::c_ushort,
164         pub ws_xpixel: ::c_ushort,
165         pub ws_ypixel: ::c_ushort,
166     }
167 
168     pub struct linger {
169         pub l_onoff: ::c_int,
170         pub l_linger: ::c_int,
171     }
172 
173     pub struct sigval {
174         // Actually a union of an int and a void*
175         pub sival_ptr: *mut ::c_void
176     }
177 
178     // <sys/time.h>
179     pub struct itimerval {
180         pub it_interval: ::timeval,
181         pub it_value: ::timeval,
182     }
183 
184     // <sys/times.h>
185     pub struct tms {
186         pub tms_utime: ::clock_t,
187         pub tms_stime: ::clock_t,
188         pub tms_cutime: ::clock_t,
189         pub tms_cstime: ::clock_t,
190     }
191 
192     pub struct servent {
193         pub s_name: *mut ::c_char,
194         pub s_aliases: *mut *mut ::c_char,
195         pub s_port: ::c_int,
196         pub s_proto: *mut ::c_char,
197     }
198 
199     pub struct protoent {
200         pub p_name: *mut ::c_char,
201         pub p_aliases: *mut *mut ::c_char,
202         pub p_proto: ::c_int,
203     }
204 }
205 
206 pub const INT_MIN: c_int = -2147483648;
207 pub const INT_MAX: c_int = 2147483647;
208 
209 pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
210 pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
211 pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
212 
213 pub const DT_UNKNOWN: u8 = 0;
214 pub const DT_FIFO: u8 = 1;
215 pub const DT_CHR: u8 = 2;
216 pub const DT_DIR: u8 = 4;
217 pub const DT_BLK: u8 = 6;
218 pub const DT_REG: u8 = 8;
219 pub const DT_LNK: u8 = 10;
220 pub const DT_SOCK: u8 = 12;
221 
222 cfg_if! {
223     if #[cfg(not(target_os = "redox"))] {
224         pub const FD_CLOEXEC: ::c_int = 0x1;
225     }
226 }
227 
228 pub const USRQUOTA: ::c_int = 0;
229 pub const GRPQUOTA: ::c_int = 1;
230 
231 pub const SIGIOT: ::c_int = 6;
232 
233 pub const S_ISUID: ::mode_t = 0x800;
234 pub const S_ISGID: ::mode_t = 0x400;
235 pub const S_ISVTX: ::mode_t = 0x200;
236 
237 cfg_if! {
238     if #[cfg(not(any(target_os = "haiku", target_os = "illumos",
239                      target_os = "solaris")))] {
240         pub const IF_NAMESIZE: ::size_t = 16;
241         pub const IFNAMSIZ: ::size_t = IF_NAMESIZE;
242     }
243 }
244 
245 pub const LOG_EMERG: ::c_int = 0;
246 pub const LOG_ALERT: ::c_int = 1;
247 pub const LOG_CRIT: ::c_int = 2;
248 pub const LOG_ERR: ::c_int = 3;
249 pub const LOG_WARNING: ::c_int = 4;
250 pub const LOG_NOTICE: ::c_int = 5;
251 pub const LOG_INFO: ::c_int = 6;
252 pub const LOG_DEBUG: ::c_int = 7;
253 
254 pub const LOG_KERN: ::c_int = 0;
255 pub const LOG_USER: ::c_int = 1 << 3;
256 pub const LOG_MAIL: ::c_int = 2 << 3;
257 pub const LOG_DAEMON: ::c_int = 3 << 3;
258 pub const LOG_AUTH: ::c_int = 4 << 3;
259 pub const LOG_SYSLOG: ::c_int = 5 << 3;
260 pub const LOG_LPR: ::c_int = 6 << 3;
261 pub const LOG_NEWS: ::c_int = 7 << 3;
262 pub const LOG_UUCP: ::c_int = 8 << 3;
263 pub const LOG_LOCAL0: ::c_int = 16 << 3;
264 pub const LOG_LOCAL1: ::c_int = 17 << 3;
265 pub const LOG_LOCAL2: ::c_int = 18 << 3;
266 pub const LOG_LOCAL3: ::c_int = 19 << 3;
267 pub const LOG_LOCAL4: ::c_int = 20 << 3;
268 pub const LOG_LOCAL5: ::c_int = 21 << 3;
269 pub const LOG_LOCAL6: ::c_int = 22 << 3;
270 pub const LOG_LOCAL7: ::c_int = 23 << 3;
271 
272 cfg_if! {
273     if #[cfg(not(target_os = "haiku"))] {
274         pub const LOG_PID: ::c_int = 0x01;
275         pub const LOG_CONS: ::c_int = 0x02;
276         pub const LOG_ODELAY: ::c_int = 0x04;
277         pub const LOG_NDELAY: ::c_int = 0x08;
278         pub const LOG_NOWAIT: ::c_int = 0x10;
279     }
280 }
281 pub const LOG_PRIMASK: ::c_int = 7;
282 pub const LOG_FACMASK: ::c_int = 0x3f8;
283 
284 pub const PRIO_MIN: ::c_int = -20;
285 pub const PRIO_MAX: ::c_int = 20;
286 
287 pub const IPPROTO_ICMP: ::c_int = 1;
288 pub const IPPROTO_ICMPV6: ::c_int = 58;
289 pub const IPPROTO_TCP: ::c_int = 6;
290 pub const IPPROTO_UDP: ::c_int = 17;
291 pub const IPPROTO_IP: ::c_int = 0;
292 pub const IPPROTO_IPV6: ::c_int = 41;
293 
294 pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
295 pub const INADDR_ANY: in_addr_t = 0;
296 pub const INADDR_BROADCAST: in_addr_t = 4294967295;
297 pub const INADDR_NONE: in_addr_t = 4294967295;
298 
299 pub const ARPOP_REQUEST: u16 = 1;
300 pub const ARPOP_REPLY: u16 = 2;
301 
302 pub const ATF_COM: ::c_int = 0x02;
303 pub const ATF_PERM: ::c_int = 0x04;
304 pub const ATF_PUBL: ::c_int = 0x08;
305 pub const ATF_USETRAILERS: ::c_int = 0x10;
306 
307 cfg_if! {
308     if #[cfg(any(target_os = "l4re", target_os = "espidf"))] {
309         // required libraries for L4Re and the ESP-IDF framework are linked externally, ATM
310     } else if #[cfg(feature = "std")] {
311         // cargo build, don't pull in anything extra as the libstd dep
312         // already pulls in all libs.
313     } else if #[cfg(all(target_os = "linux",
314                         any(target_env = "gnu", target_env = "uclibc"),
315                         feature = "rustc-dep-of-std"))] {
316         #[link(name = "util", kind = "static", modifiers = "-bundle",
317             cfg(target_feature = "crt-static"))]
318         #[link(name = "rt", kind = "static", modifiers = "-bundle",
319             cfg(target_feature = "crt-static"))]
320         #[link(name = "pthread", kind = "static", modifiers = "-bundle",
321             cfg(target_feature = "crt-static"))]
322         #[link(name = "m", kind = "static", modifiers = "-bundle",
323             cfg(target_feature = "crt-static"))]
324         #[link(name = "dl", kind = "static", modifiers = "-bundle",
325             cfg(target_feature = "crt-static"))]
326         #[link(name = "c", kind = "static", modifiers = "-bundle",
327             cfg(target_feature = "crt-static"))]
328         #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle",
329             cfg(target_feature = "crt-static"))]
330         #[link(name = "gcc", kind = "static", modifiers = "-bundle",
331             cfg(target_feature = "crt-static"))]
332         #[link(name = "util", cfg(not(target_feature = "crt-static")))]
333         #[link(name = "rt", cfg(not(target_feature = "crt-static")))]
334         #[link(name = "pthread", cfg(not(target_feature = "crt-static")))]
335         #[link(name = "m", cfg(not(target_feature = "crt-static")))]
336         #[link(name = "dl", cfg(not(target_feature = "crt-static")))]
337         #[link(name = "c", cfg(not(target_feature = "crt-static")))]
338         extern {}
339     } else if #[cfg(target_env = "musl")] {
340         #[cfg_attr(feature = "rustc-dep-of-std",
341                    link(name = "c", kind = "static", modifiers = "-bundle",
342                         cfg(target_feature = "crt-static")))]
343         #[cfg_attr(feature = "rustc-dep-of-std",
344                    link(name = "c", cfg(not(target_feature = "crt-static"))))]
345         extern {}
346     } else if #[cfg(target_os = "emscripten")] {
347         #[link(name = "c")]
348         extern {}
349     } else if #[cfg(all(target_os = "netbsd",
350                         feature = "rustc-dep-of-std",
351                         target_vendor = "rumprun"))] {
352         // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled
353         // in automatically by the linker. We avoid passing it explicitly, as it
354         // causes some versions of binutils to crash with an assertion failure.
355         #[link(name = "m")]
356         extern {}
357     } else if #[cfg(any(target_os = "macos",
358                         target_os = "ios",
359                         target_os = "watchos",
360                         target_os = "android",
361                         target_os = "openbsd"))] {
362         #[link(name = "c")]
363         #[link(name = "m")]
364         extern {}
365     } else if #[cfg(target_os = "haiku")] {
366         #[link(name = "root")]
367         #[link(name = "network")]
368         extern {}
369     } else if #[cfg(target_env = "newlib")] {
370         #[link(name = "c")]
371         #[link(name = "m")]
372         extern {}
373     } else if #[cfg(target_os = "hermit")] {
374         // no_default_libraries is set to false for HermitCore, so only a link
375         // to "pthread" needs to be added.
376         #[link(name = "pthread")]
377         extern {}
378     } else if #[cfg(target_env = "illumos")] {
379         #[link(name = "c")]
380         #[link(name = "m")]
381         extern {}
382     } else if #[cfg(target_os = "redox")] {
383         #[cfg_attr(feature = "rustc-dep-of-std",
384                    link(name = "c", kind = "static", modifiers = "-bundle",
385                         cfg(target_feature = "crt-static")))]
386         #[cfg_attr(feature = "rustc-dep-of-std",
387                    link(name = "c", cfg(not(target_feature = "crt-static"))))]
388         extern {}
389     } else {
390         #[link(name = "c")]
391         #[link(name = "m")]
392         #[link(name = "rt")]
393         #[link(name = "pthread")]
394         extern {}
395     }
396 }
397 
398 #[cfg_attr(feature = "extra_traits", derive(Debug))]
399 pub enum FILE {}
400 impl ::Copy for FILE {}
401 impl ::Clone for FILE {
402     fn clone(&self) -> FILE {
403         *self
404     }
405 }
406 #[cfg_attr(feature = "extra_traits", derive(Debug))]
407 pub enum fpos_t {} // FIXME: fill this out with a struct
408 impl ::Copy for fpos_t {}
409 impl ::Clone for fpos_t {
410     fn clone(&self) -> fpos_t {
411         *self
412     }
413 }
414 
415 extern "C" {
416     pub fn isalnum(c: c_int) -> c_int;
417     pub fn isalpha(c: c_int) -> c_int;
418     pub fn iscntrl(c: c_int) -> c_int;
419     pub fn isdigit(c: c_int) -> c_int;
420     pub fn isgraph(c: c_int) -> c_int;
421     pub fn islower(c: c_int) -> c_int;
422     pub fn isprint(c: c_int) -> c_int;
423     pub fn ispunct(c: c_int) -> c_int;
424     pub fn isspace(c: c_int) -> c_int;
425     pub fn isupper(c: c_int) -> c_int;
426     pub fn isxdigit(c: c_int) -> c_int;
427     pub fn isblank(c: c_int) -> c_int;
428     pub fn tolower(c: c_int) -> c_int;
429     pub fn toupper(c: c_int) -> c_int;
430     pub fn qsort(
431         base: *mut c_void,
432         num: size_t,
433         size: size_t,
434         compar: ::Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
435     );
436     pub fn bsearch(
437         key: *const c_void,
438         base: *const c_void,
439         num: size_t,
440         size: size_t,
441         compar: ::Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
442     ) -> *mut c_void;
443     #[cfg_attr(
444         all(target_os = "macos", target_arch = "x86"),
445         link_name = "fopen$UNIX2003"
446     )]
447     pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
448     #[cfg_attr(
449         all(target_os = "macos", target_arch = "x86"),
450         link_name = "freopen$UNIX2003"
451     )]
452     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
453     pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE;
454     pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE;
455 
456     pub fn fflush(file: *mut FILE) -> c_int;
457     pub fn fclose(file: *mut FILE) -> c_int;
458     pub fn remove(filename: *const c_char) -> c_int;
459     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
460     pub fn tmpfile() -> *mut FILE;
461     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
462     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
463     pub fn getchar() -> c_int;
464     pub fn putchar(c: c_int) -> c_int;
465     pub fn fgetc(stream: *mut FILE) -> c_int;
466     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
467     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
468     #[cfg_attr(
469         all(target_os = "macos", target_arch = "x86"),
470         link_name = "fputs$UNIX2003"
471     )]
472     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
473     pub fn puts(s: *const c_char) -> c_int;
474     pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
475     pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
476     #[cfg_attr(
477         all(target_os = "macos", target_arch = "x86"),
478         link_name = "fwrite$UNIX2003"
479     )]
480     pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
481     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
482     pub fn ftell(stream: *mut FILE) -> c_long;
483     pub fn rewind(stream: *mut FILE);
484     #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
485     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
486     #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
487     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
488     pub fn feof(stream: *mut FILE) -> c_int;
489     pub fn ferror(stream: *mut FILE) -> c_int;
490     pub fn clearerr(stream: *mut FILE);
491     pub fn perror(s: *const c_char);
492     pub fn atoi(s: *const c_char) -> c_int;
493     #[cfg_attr(
494         all(target_os = "macos", target_arch = "x86"),
495         link_name = "strtod$UNIX2003"
496     )]
497     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
498     pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
499     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
500     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
501     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
502     pub fn malloc(size: size_t) -> *mut c_void;
503     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
504     pub fn free(p: *mut c_void);
505     pub fn abort() -> !;
506     pub fn exit(status: c_int) -> !;
507     pub fn _exit(status: c_int) -> !;
508     pub fn atexit(cb: extern "C" fn()) -> c_int;
509     #[cfg_attr(
510         all(target_os = "macos", target_arch = "x86"),
511         link_name = "system$UNIX2003"
512     )]
513     pub fn system(s: *const c_char) -> c_int;
514     pub fn getenv(s: *const c_char) -> *mut c_char;
515 
516     pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
517     pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
518     pub fn stpcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
519     pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
520     pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
521     pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
522     pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
523     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
524     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
525     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
526     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
527     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
528     pub fn strdup(cs: *const c_char) -> *mut c_char;
529     pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char;
530     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
531     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
532     pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
533     pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
534     pub fn strlen(cs: *const c_char) -> size_t;
535     pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
536     #[cfg_attr(
537         all(target_os = "macos", target_arch = "x86"),
538         link_name = "strerror$UNIX2003"
539     )]
540     pub fn strerror(n: c_int) -> *mut c_char;
541     pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
542     pub fn strtok_r(s: *mut c_char, t: *const c_char, p: *mut *mut c_char) -> *mut c_char;
543     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
544     pub fn strsignal(sig: c_int) -> *mut c_char;
545     pub fn wcslen(buf: *const wchar_t) -> size_t;
546     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t;
547 
548     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
549     pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
550     pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
551     pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
552     pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
553     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
554 }
555 
556 extern "C" {
557     #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
558     pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
559     #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
560     pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
561 
562     pub fn fprintf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
563     pub fn printf(format: *const ::c_char, ...) -> ::c_int;
564     pub fn snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int;
565     pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
566     #[cfg_attr(
567         all(target_os = "linux", not(target_env = "uclibc")),
568         link_name = "__isoc99_fscanf"
569     )]
570     pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
571     #[cfg_attr(
572         all(target_os = "linux", not(target_env = "uclibc")),
573         link_name = "__isoc99_scanf"
574     )]
575     pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
576     #[cfg_attr(
577         all(target_os = "linux", not(target_env = "uclibc")),
578         link_name = "__isoc99_sscanf"
579     )]
580     pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
581     pub fn getchar_unlocked() -> ::c_int;
582     pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
583 
584     #[cfg(not(all(
585         libc_cfg_target_vendor,
586         target_arch = "powerpc",
587         target_vendor = "nintendo"
588     )))]
589     #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
590     #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
591     #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
592     pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
593     #[cfg(not(all(
594         libc_cfg_target_vendor,
595         target_arch = "powerpc",
596         target_vendor = "nintendo"
597     )))]
598     #[cfg_attr(
599         all(target_os = "macos", target_arch = "x86"),
600         link_name = "connect$UNIX2003"
601     )]
602     #[cfg_attr(target_os = "illumos", link_name = "__xnet_connect")]
603     #[cfg_attr(target_os = "espidf", link_name = "lwip_connect")]
604     pub fn connect(socket: ::c_int, address: *const sockaddr, len: socklen_t) -> ::c_int;
605     #[cfg_attr(
606         all(target_os = "macos", target_arch = "x86"),
607         link_name = "listen$UNIX2003"
608     )]
609     #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")]
610     pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
611     #[cfg(not(all(
612         libc_cfg_target_vendor,
613         target_arch = "powerpc",
614         target_vendor = "nintendo"
615     )))]
616     #[cfg_attr(
617         all(target_os = "macos", target_arch = "x86"),
618         link_name = "accept$UNIX2003"
619     )]
620     #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")]
621     pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int;
622     #[cfg(not(all(
623         libc_cfg_target_vendor,
624         target_arch = "powerpc",
625         target_vendor = "nintendo"
626     )))]
627     #[cfg_attr(
628         all(target_os = "macos", target_arch = "x86"),
629         link_name = "getpeername$UNIX2003"
630     )]
631     #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")]
632     pub fn getpeername(
633         socket: ::c_int,
634         address: *mut sockaddr,
635         address_len: *mut socklen_t,
636     ) -> ::c_int;
637     #[cfg(not(all(
638         libc_cfg_target_vendor,
639         target_arch = "powerpc",
640         target_vendor = "nintendo"
641     )))]
642     #[cfg_attr(
643         all(target_os = "macos", target_arch = "x86"),
644         link_name = "getsockname$UNIX2003"
645     )]
646     #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")]
647     pub fn getsockname(
648         socket: ::c_int,
649         address: *mut sockaddr,
650         address_len: *mut socklen_t,
651     ) -> ::c_int;
652     #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")]
653     pub fn setsockopt(
654         socket: ::c_int,
655         level: ::c_int,
656         name: ::c_int,
657         value: *const ::c_void,
658         option_len: socklen_t,
659     ) -> ::c_int;
660     #[cfg_attr(
661         all(target_os = "macos", target_arch = "x86"),
662         link_name = "socketpair$UNIX2003"
663     )]
664     #[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")]
665     pub fn socketpair(
666         domain: ::c_int,
667         type_: ::c_int,
668         protocol: ::c_int,
669         socket_vector: *mut ::c_int,
670     ) -> ::c_int;
671     #[cfg(not(all(
672         libc_cfg_target_vendor,
673         target_arch = "powerpc",
674         target_vendor = "nintendo"
675     )))]
676     #[cfg_attr(
677         all(target_os = "macos", target_arch = "x86"),
678         link_name = "sendto$UNIX2003"
679     )]
680     #[cfg_attr(target_os = "illumos", link_name = "__xnet_sendto")]
681     #[cfg_attr(target_os = "espidf", link_name = "lwip_sendto")]
682     pub fn sendto(
683         socket: ::c_int,
684         buf: *const ::c_void,
685         len: ::size_t,
686         flags: ::c_int,
687         addr: *const sockaddr,
688         addrlen: socklen_t,
689     ) -> ::ssize_t;
690     #[cfg_attr(target_os = "espidf", link_name = "lwip_shutdown")]
691     pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
692 
693     #[cfg_attr(
694         all(target_os = "macos", target_arch = "x86"),
695         link_name = "chmod$UNIX2003"
696     )]
697     pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
698     #[cfg_attr(
699         all(target_os = "macos", target_arch = "x86"),
700         link_name = "fchmod$UNIX2003"
701     )]
702     pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
703 
704     #[cfg_attr(
705         all(target_os = "macos", not(target_arch = "aarch64")),
706         link_name = "fstat$INODE64"
707     )]
708     #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
709     #[cfg_attr(
710         all(target_os = "freebsd", any(freebsd11, freebsd10)),
711         link_name = "fstat@FBSD_1.0"
712     )]
713     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
714 
715     pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
716 
717     #[cfg_attr(
718         all(target_os = "macos", not(target_arch = "aarch64")),
719         link_name = "stat$INODE64"
720     )]
721     #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
722     #[cfg_attr(
723         all(target_os = "freebsd", any(freebsd11, freebsd10)),
724         link_name = "stat@FBSD_1.0"
725     )]
726     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
727 
728     pub fn pclose(stream: *mut ::FILE) -> ::c_int;
729     #[cfg_attr(
730         all(target_os = "macos", target_arch = "x86"),
731         link_name = "fdopen$UNIX2003"
732     )]
733     pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
734     pub fn fileno(stream: *mut ::FILE) -> ::c_int;
735 
736     #[cfg_attr(
737         all(target_os = "macos", target_arch = "x86"),
738         link_name = "open$UNIX2003"
739     )]
740     pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
741     #[cfg_attr(
742         all(target_os = "macos", target_arch = "x86"),
743         link_name = "creat$UNIX2003"
744     )]
745     pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
746     #[cfg_attr(
747         all(target_os = "macos", target_arch = "x86"),
748         link_name = "fcntl$UNIX2003"
749     )]
750     pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
751 
752     #[cfg_attr(
753         all(target_os = "macos", target_arch = "x86_64"),
754         link_name = "opendir$INODE64"
755     )]
756     #[cfg_attr(
757         all(target_os = "macos", target_arch = "x86"),
758         link_name = "opendir$INODE64$UNIX2003"
759     )]
760     #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
761     pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
762 
763     #[cfg_attr(
764         all(target_os = "macos", not(target_arch = "aarch64")),
765         link_name = "readdir$INODE64"
766     )]
767     #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
768     #[cfg_attr(
769         all(target_os = "freebsd", any(freebsd11, freebsd10)),
770         link_name = "readdir@FBSD_1.0"
771     )]
772     pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
773     #[cfg_attr(
774         all(target_os = "macos", target_arch = "x86"),
775         link_name = "closedir$UNIX2003"
776     )]
777     pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
778     #[cfg_attr(
779         all(target_os = "macos", target_arch = "x86_64"),
780         link_name = "rewinddir$INODE64"
781     )]
782     #[cfg_attr(
783         all(target_os = "macos", target_arch = "x86"),
784         link_name = "rewinddir$INODE64$UNIX2003"
785     )]
786     pub fn rewinddir(dirp: *mut ::DIR);
787 
788     pub fn fchmodat(
789         dirfd: ::c_int,
790         pathname: *const ::c_char,
791         mode: ::mode_t,
792         flags: ::c_int,
793     ) -> ::c_int;
794     pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int;
795     pub fn fchownat(
796         dirfd: ::c_int,
797         pathname: *const ::c_char,
798         owner: ::uid_t,
799         group: ::gid_t,
800         flags: ::c_int,
801     ) -> ::c_int;
802     #[cfg_attr(
803         all(target_os = "macos", not(target_arch = "aarch64")),
804         link_name = "fstatat$INODE64"
805     )]
806     #[cfg_attr(
807         all(target_os = "freebsd", any(freebsd11, freebsd10)),
808         link_name = "fstatat@FBSD_1.1"
809     )]
810     pub fn fstatat(
811         dirfd: ::c_int,
812         pathname: *const ::c_char,
813         buf: *mut stat,
814         flags: ::c_int,
815     ) -> ::c_int;
816     pub fn linkat(
817         olddirfd: ::c_int,
818         oldpath: *const ::c_char,
819         newdirfd: ::c_int,
820         newpath: *const ::c_char,
821         flags: ::c_int,
822     ) -> ::c_int;
823     pub fn renameat(
824         olddirfd: ::c_int,
825         oldpath: *const ::c_char,
826         newdirfd: ::c_int,
827         newpath: *const ::c_char,
828     ) -> ::c_int;
829     pub fn symlinkat(
830         target: *const ::c_char,
831         newdirfd: ::c_int,
832         linkpath: *const ::c_char,
833     ) -> ::c_int;
834     pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int) -> ::c_int;
835 
836     pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
837     pub fn alarm(seconds: ::c_uint) -> ::c_uint;
838     pub fn chdir(dir: *const c_char) -> ::c_int;
839     pub fn fchdir(dirfd: ::c_int) -> ::c_int;
840     pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
841     #[cfg_attr(
842         all(target_os = "macos", target_arch = "x86"),
843         link_name = "lchown$UNIX2003"
844     )]
845     pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
846     #[cfg_attr(
847         all(target_os = "macos", target_arch = "x86"),
848         link_name = "close$NOCANCEL$UNIX2003"
849     )]
850     #[cfg_attr(
851         all(target_os = "macos", target_arch = "x86_64"),
852         link_name = "close$NOCANCEL"
853     )]
854     pub fn close(fd: ::c_int) -> ::c_int;
855     pub fn dup(fd: ::c_int) -> ::c_int;
856     pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
857     pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int;
858     pub fn execle(path: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int;
859     pub fn execlp(file: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int;
860     pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int;
861     pub fn execve(
862         prog: *const c_char,
863         argv: *const *const c_char,
864         envp: *const *const c_char,
865     ) -> ::c_int;
866     pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int;
867     pub fn fork() -> pid_t;
868     pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
869     pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
870     pub fn getegid() -> gid_t;
871     pub fn geteuid() -> uid_t;
872     pub fn getgid() -> gid_t;
873     pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int;
874     #[cfg_attr(target_os = "illumos", link_name = "getloginx")]
875     pub fn getlogin() -> *mut c_char;
876     #[cfg_attr(
877         all(target_os = "macos", target_arch = "x86"),
878         link_name = "getopt$UNIX2003"
879     )]
880     pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int;
881     pub fn getpgid(pid: pid_t) -> pid_t;
882     pub fn getpgrp() -> pid_t;
883     pub fn getpid() -> pid_t;
884     pub fn getppid() -> pid_t;
885     pub fn getuid() -> uid_t;
886     pub fn isatty(fd: ::c_int) -> ::c_int;
887     pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
888     pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
889     pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
890     pub fn pipe(fds: *mut ::c_int) -> ::c_int;
891     pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int;
892     #[cfg_attr(
893         all(target_os = "macos", target_arch = "x86"),
894         link_name = "read$UNIX2003"
895     )]
896     pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t;
897     pub fn rmdir(path: *const c_char) -> ::c_int;
898     pub fn seteuid(uid: uid_t) -> ::c_int;
899     pub fn setegid(gid: gid_t) -> ::c_int;
900     pub fn setgid(gid: gid_t) -> ::c_int;
901     pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
902     pub fn setsid() -> pid_t;
903     pub fn setuid(uid: uid_t) -> ::c_int;
904     pub fn setreuid(ruid: uid_t, euid: uid_t) -> ::c_int;
905     pub fn setregid(rgid: gid_t, egid: gid_t) -> ::c_int;
906     #[cfg_attr(
907         all(target_os = "macos", target_arch = "x86"),
908         link_name = "sleep$UNIX2003"
909     )]
910     pub fn sleep(secs: ::c_uint) -> ::c_uint;
911     #[cfg_attr(
912         all(target_os = "macos", target_arch = "x86"),
913         link_name = "nanosleep$UNIX2003"
914     )]
915     #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
916     pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int;
917     pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
918     pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
919     pub fn ttyname(fd: ::c_int) -> *mut c_char;
920     #[cfg_attr(
921         all(target_os = "macos", target_arch = "x86"),
922         link_name = "ttyname_r$UNIX2003"
923     )]
924     #[cfg_attr(target_os = "illumos", link_name = "__posix_ttyname_r")]
925     pub fn ttyname_r(fd: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
926     pub fn unlink(c: *const c_char) -> ::c_int;
927     #[cfg_attr(
928         all(target_os = "macos", target_arch = "x86"),
929         link_name = "wait$UNIX2003"
930     )]
931     pub fn wait(status: *mut ::c_int) -> pid_t;
932     #[cfg_attr(
933         all(target_os = "macos", target_arch = "x86"),
934         link_name = "waitpid$UNIX2003"
935     )]
936     pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t;
937     #[cfg_attr(
938         all(target_os = "macos", target_arch = "x86"),
939         link_name = "write$UNIX2003"
940     )]
941     pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t;
942     #[cfg_attr(
943         all(target_os = "macos", target_arch = "x86"),
944         link_name = "pread$UNIX2003"
945     )]
946     pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
947     #[cfg_attr(
948         all(target_os = "macos", target_arch = "x86"),
949         link_name = "pwrite$UNIX2003"
950     )]
951     pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
952     pub fn umask(mask: mode_t) -> mode_t;
953 
954     #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
955     pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
956 
957     #[cfg_attr(
958         all(target_os = "macos", target_arch = "x86"),
959         link_name = "kill$UNIX2003"
960     )]
961     pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
962     #[cfg_attr(
963         all(target_os = "macos", target_arch = "x86"),
964         link_name = "killpg$UNIX2003"
965     )]
966     pub fn killpg(pgrp: pid_t, sig: ::c_int) -> ::c_int;
967 
968     pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
969     pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
970     pub fn mlockall(flags: ::c_int) -> ::c_int;
971     pub fn munlockall() -> ::c_int;
972 
973     #[cfg_attr(
974         all(target_os = "macos", target_arch = "x86"),
975         link_name = "mmap$UNIX2003"
976     )]
977     pub fn mmap(
978         addr: *mut ::c_void,
979         len: ::size_t,
980         prot: ::c_int,
981         flags: ::c_int,
982         fd: ::c_int,
983         offset: off_t,
984     ) -> *mut ::c_void;
985     #[cfg_attr(
986         all(target_os = "macos", target_arch = "x86"),
987         link_name = "munmap$UNIX2003"
988     )]
989     pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
990 
991     pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
992     pub fn if_indextoname(ifindex: ::c_uint, ifname: *mut ::c_char) -> *mut ::c_char;
993 
994     #[cfg_attr(
995         all(target_os = "macos", not(target_arch = "aarch64")),
996         link_name = "lstat$INODE64"
997     )]
998     #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
999     #[cfg_attr(
1000         all(target_os = "freebsd", any(freebsd11, freebsd10)),
1001         link_name = "lstat@FBSD_1.0"
1002     )]
1003     pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
1004 
1005     #[cfg_attr(
1006         all(target_os = "macos", target_arch = "x86"),
1007         link_name = "fsync$UNIX2003"
1008     )]
1009     pub fn fsync(fd: ::c_int) -> ::c_int;
1010 
1011     #[cfg_attr(
1012         all(target_os = "macos", target_arch = "x86"),
1013         link_name = "setenv$UNIX2003"
1014     )]
1015     pub fn setenv(name: *const c_char, val: *const c_char, overwrite: ::c_int) -> ::c_int;
1016     #[cfg_attr(
1017         all(target_os = "macos", target_arch = "x86"),
1018         link_name = "unsetenv$UNIX2003"
1019     )]
1020     #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
1021     pub fn unsetenv(name: *const c_char) -> ::c_int;
1022 
1023     pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
1024 
1025     pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
1026 
1027     pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
1028 
1029     #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
1030     pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
1031 
1032     #[cfg_attr(
1033         any(target_os = "macos", target_os = "ios", target_os = "watchos"),
1034         link_name = "realpath$DARWIN_EXTSN"
1035     )]
1036     pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char;
1037 
1038     pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1039 
1040     #[cfg_attr(target_os = "netbsd", link_name = "__times13")]
1041     pub fn times(buf: *mut ::tms) -> ::clock_t;
1042 
1043     pub fn pthread_self() -> ::pthread_t;
1044     #[cfg_attr(
1045         all(target_os = "macos", target_arch = "x86"),
1046         link_name = "pthread_join$UNIX2003"
1047     )]
1048     pub fn pthread_join(native: ::pthread_t, value: *mut *mut ::c_void) -> ::c_int;
1049     pub fn pthread_exit(value: *mut ::c_void) -> !;
1050     pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
1051     pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
1052     pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stack_size: ::size_t) -> ::c_int;
1053     pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int;
1054     pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
1055     #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
1056     pub fn sched_yield() -> ::c_int;
1057     pub fn pthread_key_create(
1058         key: *mut pthread_key_t,
1059         dtor: ::Option<unsafe extern "C" fn(*mut ::c_void)>,
1060     ) -> ::c_int;
1061     pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
1062     pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
1063     pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) -> ::c_int;
1064     pub fn pthread_mutex_init(
1065         lock: *mut pthread_mutex_t,
1066         attr: *const pthread_mutexattr_t,
1067     ) -> ::c_int;
1068     pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
1069     pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
1070     pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
1071     pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
1072 
1073     pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
1074     #[cfg_attr(
1075         all(target_os = "macos", target_arch = "x86"),
1076         link_name = "pthread_mutexattr_destroy$UNIX2003"
1077     )]
1078     pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
1079     pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: ::c_int) -> ::c_int;
1080 
1081     #[cfg_attr(
1082         all(target_os = "macos", target_arch = "x86"),
1083         link_name = "pthread_cond_init$UNIX2003"
1084     )]
1085     pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t)
1086         -> ::c_int;
1087     #[cfg_attr(
1088         all(target_os = "macos", target_arch = "x86"),
1089         link_name = "pthread_cond_wait$UNIX2003"
1090     )]
1091     pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> ::c_int;
1092     #[cfg_attr(
1093         all(target_os = "macos", target_arch = "x86"),
1094         link_name = "pthread_cond_timedwait$UNIX2003"
1095     )]
1096     pub fn pthread_cond_timedwait(
1097         cond: *mut pthread_cond_t,
1098         lock: *mut pthread_mutex_t,
1099         abstime: *const ::timespec,
1100     ) -> ::c_int;
1101     pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
1102     pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
1103     pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
1104     pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
1105     pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
1106     #[cfg_attr(
1107         all(target_os = "macos", target_arch = "x86"),
1108         link_name = "pthread_rwlock_init$UNIX2003"
1109     )]
1110     pub fn pthread_rwlock_init(
1111         lock: *mut pthread_rwlock_t,
1112         attr: *const pthread_rwlockattr_t,
1113     ) -> ::c_int;
1114     #[cfg_attr(
1115         all(target_os = "macos", target_arch = "x86"),
1116         link_name = "pthread_rwlock_destroy$UNIX2003"
1117     )]
1118     pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
1119     #[cfg_attr(
1120         all(target_os = "macos", target_arch = "x86"),
1121         link_name = "pthread_rwlock_rdlock$UNIX2003"
1122     )]
1123     pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1124     #[cfg_attr(
1125         all(target_os = "macos", target_arch = "x86"),
1126         link_name = "pthread_rwlock_tryrdlock$UNIX2003"
1127     )]
1128     pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1129     #[cfg_attr(
1130         all(target_os = "macos", target_arch = "x86"),
1131         link_name = "pthread_rwlock_wrlock$UNIX2003"
1132     )]
1133     pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1134     #[cfg_attr(
1135         all(target_os = "macos", target_arch = "x86"),
1136         link_name = "pthread_rwlock_trywrlock$UNIX2003"
1137     )]
1138     pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1139     #[cfg_attr(
1140         all(target_os = "macos", target_arch = "x86"),
1141         link_name = "pthread_rwlock_unlock$UNIX2003"
1142     )]
1143     pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1144     pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
1145     pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> ::c_int;
1146 
1147     #[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")]
1148     #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")]
1149     pub fn getsockopt(
1150         sockfd: ::c_int,
1151         level: ::c_int,
1152         optname: ::c_int,
1153         optval: *mut ::c_void,
1154         optlen: *mut ::socklen_t,
1155     ) -> ::c_int;
1156     pub fn raise(signum: ::c_int) -> ::c_int;
1157     #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
1158     pub fn sigaction(signum: ::c_int, act: *const sigaction, oldact: *mut sigaction) -> ::c_int;
1159 
1160     #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
1161     pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int;
1162     pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void;
1163     pub fn dlerror() -> *mut ::c_char;
1164     pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void;
1165     pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
1166     pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
1167 
1168     #[cfg(not(all(
1169         libc_cfg_target_vendor,
1170         target_arch = "powerpc",
1171         target_vendor = "nintendo"
1172     )))]
1173     #[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")]
1174     #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")]
1175     pub fn getaddrinfo(
1176         node: *const c_char,
1177         service: *const c_char,
1178         hints: *const addrinfo,
1179         res: *mut *mut addrinfo,
1180     ) -> ::c_int;
1181     #[cfg(not(all(
1182         libc_cfg_target_vendor,
1183         target_arch = "powerpc",
1184         target_vendor = "nintendo"
1185     )))]
1186     #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")]
1187     pub fn freeaddrinfo(res: *mut addrinfo);
1188     pub fn hstrerror(errcode: ::c_int) -> *const ::c_char;
1189     pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
1190     #[cfg_attr(
1191         any(
1192             all(target_os = "linux", not(target_env = "musl")),
1193             target_os = "freebsd",
1194             target_os = "dragonfly",
1195             target_os = "haiku"
1196         ),
1197         link_name = "__res_init"
1198     )]
1199     #[cfg_attr(
1200         any(target_os = "macos", target_os = "ios", target_os = "watchos"),
1201         link_name = "res_9_init"
1202     )]
1203     pub fn res_init() -> ::c_int;
1204 
1205     #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
1206     #[cfg_attr(target_env = "musl", allow(deprecated))]
1207     // FIXME: for `time_t`
1208     pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1209     #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
1210     #[cfg_attr(target_env = "musl", allow(deprecated))]
1211     // FIXME: for `time_t`
1212     pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1213     #[cfg_attr(
1214         all(target_os = "macos", target_arch = "x86"),
1215         link_name = "mktime$UNIX2003"
1216     )]
1217     #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
1218     #[cfg_attr(target_env = "musl", allow(deprecated))]
1219     // FIXME: for `time_t`
1220     pub fn mktime(tm: *mut tm) -> time_t;
1221     #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
1222     #[cfg_attr(target_env = "musl", allow(deprecated))]
1223     // FIXME: for `time_t`
1224     pub fn time(time: *mut time_t) -> time_t;
1225     #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
1226     #[cfg_attr(target_env = "musl", allow(deprecated))]
1227     // FIXME: for `time_t`
1228     pub fn gmtime(time_p: *const time_t) -> *mut tm;
1229     #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
1230     #[cfg_attr(target_env = "musl", allow(deprecated))]
1231     // FIXME: for `time_t`
1232     pub fn localtime(time_p: *const time_t) -> *mut tm;
1233     #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
1234     #[cfg_attr(target_env = "musl", allow(deprecated))]
1235     // FIXME: for `time_t`
1236     pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
1237     #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
1238     #[cfg_attr(target_env = "musl", allow(deprecated))]
1239     // FIXME: for `time_t`
1240     pub fn timegm(tm: *mut ::tm) -> time_t;
1241 
1242     #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
1243     #[cfg_attr(
1244         all(target_os = "freebsd", any(freebsd11, freebsd10)),
1245         link_name = "mknod@FBSD_1.0"
1246     )]
1247     pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, dev: ::dev_t) -> ::c_int;
1248     pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
1249     pub fn endservent();
1250     pub fn getservbyname(name: *const ::c_char, proto: *const ::c_char) -> *mut servent;
1251     pub fn getservbyport(port: ::c_int, proto: *const ::c_char) -> *mut servent;
1252     pub fn getservent() -> *mut servent;
1253     pub fn setservent(stayopen: ::c_int);
1254     pub fn getprotobyname(name: *const ::c_char) -> *mut protoent;
1255     pub fn getprotobynumber(proto: ::c_int) -> *mut protoent;
1256     pub fn chroot(name: *const ::c_char) -> ::c_int;
1257     #[cfg_attr(
1258         all(target_os = "macos", target_arch = "x86"),
1259         link_name = "usleep$UNIX2003"
1260     )]
1261     pub fn usleep(secs: ::c_uint) -> ::c_int;
1262     #[cfg_attr(
1263         all(target_os = "macos", target_arch = "x86"),
1264         link_name = "send$UNIX2003"
1265     )]
1266     #[cfg_attr(target_os = "espidf", link_name = "lwip_send")]
1267     pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
1268     #[cfg_attr(
1269         all(target_os = "macos", target_arch = "x86"),
1270         link_name = "recv$UNIX2003"
1271     )]
1272     #[cfg_attr(target_os = "espidf", link_name = "lwip_recv")]
1273     pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
1274     #[cfg_attr(
1275         all(target_os = "macos", target_arch = "x86"),
1276         link_name = "putenv$UNIX2003"
1277     )]
1278     #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
1279     pub fn putenv(string: *mut c_char) -> ::c_int;
1280     #[cfg_attr(
1281         all(target_os = "macos", target_arch = "x86"),
1282         link_name = "poll$UNIX2003"
1283     )]
1284     pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
1285     #[cfg_attr(
1286         all(target_os = "macos", target_arch = "x86_64"),
1287         link_name = "select$1050"
1288     )]
1289     #[cfg_attr(
1290         all(target_os = "macos", target_arch = "x86"),
1291         link_name = "select$UNIX2003"
1292     )]
1293     #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
1294     pub fn select(
1295         nfds: ::c_int,
1296         readfs: *mut fd_set,
1297         writefds: *mut fd_set,
1298         errorfds: *mut fd_set,
1299         timeout: *mut timeval,
1300     ) -> ::c_int;
1301     #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
1302     pub fn setlocale(category: ::c_int, locale: *const ::c_char) -> *mut ::c_char;
1303     pub fn localeconv() -> *mut lconv;
1304 
1305     #[cfg_attr(
1306         all(target_os = "macos", target_arch = "x86"),
1307         link_name = "sem_wait$UNIX2003"
1308     )]
1309     pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
1310     pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
1311     pub fn sem_post(sem: *mut sem_t) -> ::c_int;
1312     pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
1313     pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
1314 
1315     pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: ::size_t) -> ::ssize_t;
1316 
1317     #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
1318     pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
1319     #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
1320     pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
1321     #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
1322     pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
1323     #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
1324     pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
1325     #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
1326     pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
1327 
1328     #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
1329     pub fn sigprocmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int;
1330     #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
1331     pub fn sigpending(set: *mut sigset_t) -> ::c_int;
1332 
1333     pub fn sysconf(name: ::c_int) -> ::c_long;
1334 
1335     pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
1336 
1337     #[cfg_attr(
1338         all(target_os = "macos", target_arch = "x86_64"),
1339         link_name = "pselect$1050"
1340     )]
1341     #[cfg_attr(
1342         all(target_os = "macos", target_arch = "x86"),
1343         link_name = "pselect$UNIX2003"
1344     )]
1345     #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
1346     pub fn pselect(
1347         nfds: ::c_int,
1348         readfs: *mut fd_set,
1349         writefds: *mut fd_set,
1350         errorfds: *mut fd_set,
1351         timeout: *const timespec,
1352         sigmask: *const sigset_t,
1353     ) -> ::c_int;
1354     pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int;
1355     pub fn ftello(stream: *mut ::FILE) -> ::off_t;
1356     #[cfg_attr(
1357         all(target_os = "macos", target_arch = "x86"),
1358         link_name = "tcdrain$UNIX2003"
1359     )]
1360     pub fn tcdrain(fd: ::c_int) -> ::c_int;
1361     pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
1362     pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
1363     pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
1364     pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
1365     pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
1366     pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const ::termios) -> ::c_int;
1367     pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
1368     pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
1369     pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
1370     pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
1371     pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
1372     pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
1373 
1374     pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
1375 
1376     pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
1377     pub fn closelog();
1378     pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
1379     #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")]
1380     pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
1381     #[cfg_attr(
1382         all(target_os = "macos", target_arch = "x86"),
1383         link_name = "nice$UNIX2003"
1384     )]
1385     pub fn nice(incr: ::c_int) -> ::c_int;
1386 
1387     pub fn grantpt(fd: ::c_int) -> ::c_int;
1388     pub fn posix_openpt(flags: ::c_int) -> ::c_int;
1389     pub fn ptsname(fd: ::c_int) -> *mut ::c_char;
1390     pub fn unlockpt(fd: ::c_int) -> ::c_int;
1391 
1392     pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
1393     pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
1394 
1395     pub fn lockf(fd: ::c_int, cmd: ::c_int, len: ::off_t) -> ::c_int;
1396 
1397 }
1398 cfg_if! {
1399     if #[cfg(not(any(target_os = "emscripten",
1400                      target_os = "android",
1401                      target_os = "haiku")))] {
1402         extern "C" {
1403             pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int;
1404             pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
1405         }
1406     }
1407 }
1408 
1409 cfg_if! {
1410     if #[cfg(not(target_env = "uclibc"))] {
1411         extern "C" {
1412             pub fn open_wmemstream(
1413                 ptr: *mut *mut wchar_t,
1414                 sizeloc: *mut size_t,
1415             ) -> *mut FILE;
1416         }
1417     }
1418 }
1419 
1420 cfg_if! {
1421     if #[cfg(not(target_os = "redox"))] {
1422         extern {
1423             pub fn getsid(pid: pid_t) -> pid_t;
1424             pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
1425             #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1426                        link_name = "pause$UNIX2003")]
1427             pub fn pause() -> ::c_int;
1428 
1429             pub fn readlinkat(dirfd: ::c_int,
1430                               pathname: *const ::c_char,
1431                               buf: *mut ::c_char,
1432                               bufsiz: ::size_t) -> ::ssize_t;
1433             pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
1434                            mode: ::mode_t) -> ::c_int;
1435             pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
1436                           flags: ::c_int, ...) -> ::c_int;
1437 
1438             #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
1439                        link_name = "fdopendir$INODE64")]
1440             #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1441                        link_name = "fdopendir$INODE64$UNIX2003")]
1442             pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
1443 
1444             #[cfg_attr(all(target_os = "macos", not(target_arch = "aarch64")),
1445                        link_name = "readdir_r$INODE64")]
1446             #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
1447             #[cfg_attr(
1448                 all(target_os = "freebsd", any(freebsd11, freebsd10)),
1449                 link_name = "readdir_r@FBSD_1.0"
1450             )]
1451             #[allow(non_autolinks)] // FIXME: `<>` breaks line length limit.
1452             /// The 64-bit libc on Solaris and illumos only has readdir_r. If a
1453             /// 32-bit Solaris or illumos target is ever created, it should use
1454             /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos:
1455             /// https://illumos.org/man/3lib/libc
1456             /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
1457             /// https://www.unix.com/man-page/opensolaris/3LIB/libc/
1458             pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
1459                              result: *mut *mut ::dirent) -> ::c_int;
1460         }
1461     }
1462 }
1463 
1464 cfg_if! {
1465    if #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] {
1466         extern {
1467             pub fn cfmakeraw(termios: *mut ::termios);
1468             pub fn cfsetspeed(termios: *mut ::termios,
1469                               speed: ::speed_t) -> ::c_int;
1470         }
1471    }
1472 }
1473 
1474 cfg_if! {
1475     if #[cfg(target_env = "newlib")] {
1476         mod newlib;
1477         pub use self::newlib::*;
1478     } else if #[cfg(any(target_os = "linux",
1479                         target_os = "l4re",
1480                         target_os = "android",
1481                         target_os = "emscripten"))] {
1482         mod linux_like;
1483         pub use self::linux_like::*;
1484     } else if #[cfg(any(target_os = "macos",
1485                         target_os = "ios",
1486                         target_os = "watchos",
1487                         target_os = "freebsd",
1488                         target_os = "dragonfly",
1489                         target_os = "openbsd",
1490                         target_os = "netbsd"))] {
1491         mod bsd;
1492         pub use self::bsd::*;
1493     } else if #[cfg(any(target_os = "solaris",
1494                         target_os = "illumos"))] {
1495         mod solarish;
1496         pub use self::solarish::*;
1497     } else if #[cfg(target_os = "haiku")] {
1498         mod haiku;
1499         pub use self::haiku::*;
1500     } else if #[cfg(target_os = "hermit")] {
1501         mod hermit;
1502         pub use self::hermit::*;
1503     } else if #[cfg(target_os = "redox")] {
1504         mod redox;
1505         pub use self::redox::*;
1506     } else {
1507         // Unknown target_os
1508     }
1509 }
1510 
1511 cfg_if! {
1512     if #[cfg(libc_core_cvoid)] {
1513         pub use ::ffi::c_void;
1514     } else {
1515         // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
1516         // enable more optimization opportunities around it recognizing things
1517         // like malloc/free.
1518         #[repr(u8)]
1519         #[allow(missing_copy_implementations)]
1520         #[allow(missing_debug_implementations)]
1521         pub enum c_void {
1522             // Two dummy variants so the #[repr] attribute can be used.
1523             #[doc(hidden)]
1524             __variant1,
1525             #[doc(hidden)]
1526             __variant2,
1527         }
1528     }
1529 }
1530 
1531 cfg_if! {
1532     if #[cfg(libc_align)] {
1533         mod align;
1534         pub use self::align::*;
1535     } else {
1536         mod no_align;
1537         pub use self::no_align::*;
1538     }
1539 }
1540