xref: /rust-libc-0.2.174/src/unix/mod.rs (revision 5ffdbc68)
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 = "android", feature = "rustc-dep-of-std"))] {
350         #[link(name = "c", kind = "static", modifiers = "-bundle",
351             cfg(target_feature = "crt-static"))]
352         #[link(name = "m", kind = "static", modifiers = "-bundle",
353             cfg(target_feature = "crt-static"))]
354         #[link(name = "m", cfg(not(target_feature = "crt-static")))]
355         #[link(name = "c", cfg(not(target_feature = "crt-static")))]
356         extern {}
357     } else if #[cfg(any(target_os = "macos",
358                         target_os = "ios",
359                         target_os = "tvos",
360                         target_os = "watchos",
361                         target_os = "android",
362                         target_os = "openbsd"))] {
363         #[link(name = "c")]
364         #[link(name = "m")]
365         extern {}
366     } else if #[cfg(target_os = "haiku")] {
367         #[link(name = "root")]
368         #[link(name = "network")]
369         extern {}
370     } else if #[cfg(target_env = "newlib")] {
371         #[link(name = "c")]
372         #[link(name = "m")]
373         extern {}
374     } else if #[cfg(target_os = "hermit")] {
375         // no_default_libraries is set to false for HermitCore, so only a link
376         // to "pthread" needs to be added.
377         #[link(name = "pthread")]
378         extern {}
379     } else if #[cfg(target_env = "illumos")] {
380         #[link(name = "c")]
381         #[link(name = "m")]
382         extern {}
383     } else if #[cfg(target_os = "redox")] {
384         #[cfg_attr(feature = "rustc-dep-of-std",
385                    link(name = "c", kind = "static", modifiers = "-bundle",
386                         cfg(target_feature = "crt-static")))]
387         #[cfg_attr(feature = "rustc-dep-of-std",
388                    link(name = "c", cfg(not(target_feature = "crt-static"))))]
389         extern {}
390     } else {
391         #[link(name = "c")]
392         #[link(name = "m")]
393         #[link(name = "rt")]
394         #[link(name = "pthread")]
395         extern {}
396     }
397 }
398 
399 #[cfg_attr(feature = "extra_traits", derive(Debug))]
400 pub enum FILE {}
401 impl ::Copy for FILE {}
402 impl ::Clone for FILE {
403     fn clone(&self) -> FILE {
404         *self
405     }
406 }
407 #[cfg_attr(feature = "extra_traits", derive(Debug))]
408 pub enum fpos_t {} // FIXME: fill this out with a struct
409 impl ::Copy for fpos_t {}
410 impl ::Clone for fpos_t {
411     fn clone(&self) -> fpos_t {
412         *self
413     }
414 }
415 
416 extern "C" {
417     pub fn isalnum(c: c_int) -> c_int;
418     pub fn isalpha(c: c_int) -> c_int;
419     pub fn iscntrl(c: c_int) -> c_int;
420     pub fn isdigit(c: c_int) -> c_int;
421     pub fn isgraph(c: c_int) -> c_int;
422     pub fn islower(c: c_int) -> c_int;
423     pub fn isprint(c: c_int) -> c_int;
424     pub fn ispunct(c: c_int) -> c_int;
425     pub fn isspace(c: c_int) -> c_int;
426     pub fn isupper(c: c_int) -> c_int;
427     pub fn isxdigit(c: c_int) -> c_int;
428     pub fn isblank(c: c_int) -> c_int;
429     pub fn tolower(c: c_int) -> c_int;
430     pub fn toupper(c: c_int) -> c_int;
431     pub fn qsort(
432         base: *mut c_void,
433         num: size_t,
434         size: size_t,
435         compar: ::Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
436     );
437     pub fn bsearch(
438         key: *const c_void,
439         base: *const c_void,
440         num: size_t,
441         size: size_t,
442         compar: ::Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
443     ) -> *mut c_void;
444     #[cfg_attr(
445         all(target_os = "macos", target_arch = "x86"),
446         link_name = "fopen$UNIX2003"
447     )]
448     pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
449     #[cfg_attr(
450         all(target_os = "macos", target_arch = "x86"),
451         link_name = "freopen$UNIX2003"
452     )]
453     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
454     pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE;
455     pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE;
456 
457     pub fn fflush(file: *mut FILE) -> c_int;
458     pub fn fclose(file: *mut FILE) -> c_int;
459     pub fn remove(filename: *const c_char) -> c_int;
460     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
461     pub fn tmpfile() -> *mut FILE;
462     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
463     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
464     pub fn getchar() -> c_int;
465     pub fn putchar(c: c_int) -> c_int;
466     pub fn fgetc(stream: *mut FILE) -> c_int;
467     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
468     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
469     #[cfg_attr(
470         all(target_os = "macos", target_arch = "x86"),
471         link_name = "fputs$UNIX2003"
472     )]
473     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
474     pub fn puts(s: *const c_char) -> c_int;
475     pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
476     pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
477     #[cfg_attr(
478         all(target_os = "macos", target_arch = "x86"),
479         link_name = "fwrite$UNIX2003"
480     )]
481     pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
482     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
483     pub fn ftell(stream: *mut FILE) -> c_long;
484     pub fn rewind(stream: *mut FILE);
485     #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
486     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
487     #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
488     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
489     pub fn feof(stream: *mut FILE) -> c_int;
490     pub fn ferror(stream: *mut FILE) -> c_int;
491     pub fn clearerr(stream: *mut FILE);
492     pub fn perror(s: *const c_char);
493     pub fn atoi(s: *const c_char) -> c_int;
494     #[cfg_attr(
495         all(target_os = "macos", target_arch = "x86"),
496         link_name = "strtod$UNIX2003"
497     )]
498     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
499     pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
500     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
501     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
502     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
503     pub fn malloc(size: size_t) -> *mut c_void;
504     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
505     pub fn free(p: *mut c_void);
506     pub fn abort() -> !;
507     pub fn exit(status: c_int) -> !;
508     pub fn _exit(status: c_int) -> !;
509     pub fn atexit(cb: extern "C" fn()) -> c_int;
510     #[cfg_attr(
511         all(target_os = "macos", target_arch = "x86"),
512         link_name = "system$UNIX2003"
513     )]
514     pub fn system(s: *const c_char) -> c_int;
515     pub fn getenv(s: *const c_char) -> *mut c_char;
516 
517     pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
518     pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
519     pub fn stpcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
520     pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
521     pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
522     pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
523     pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
524     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
525     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
526     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
527     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
528     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
529     pub fn strdup(cs: *const c_char) -> *mut c_char;
530     pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char;
531     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
532     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
533     pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
534     pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
535     pub fn strlen(cs: *const c_char) -> size_t;
536     pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
537     #[cfg_attr(
538         all(target_os = "macos", target_arch = "x86"),
539         link_name = "strerror$UNIX2003"
540     )]
541     pub fn strerror(n: c_int) -> *mut c_char;
542     pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
543     pub fn strtok_r(s: *mut c_char, t: *const c_char, p: *mut *mut c_char) -> *mut c_char;
544     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
545     pub fn strsignal(sig: c_int) -> *mut c_char;
546     pub fn wcslen(buf: *const wchar_t) -> size_t;
547     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t;
548 
549     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
550     pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
551     pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
552     pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
553     pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
554     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
555 }
556 
557 extern "C" {
558     #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
559     pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
560     #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
561     pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
562 
563     pub fn fprintf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
564     pub fn printf(format: *const ::c_char, ...) -> ::c_int;
565     pub fn snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int;
566     pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
567     #[cfg_attr(
568         all(target_os = "linux", not(target_env = "uclibc")),
569         link_name = "__isoc99_fscanf"
570     )]
571     pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
572     #[cfg_attr(
573         all(target_os = "linux", not(target_env = "uclibc")),
574         link_name = "__isoc99_scanf"
575     )]
576     pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
577     #[cfg_attr(
578         all(target_os = "linux", not(target_env = "uclibc")),
579         link_name = "__isoc99_sscanf"
580     )]
581     pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
582     pub fn getchar_unlocked() -> ::c_int;
583     pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
584 
585     #[cfg(not(all(
586         libc_cfg_target_vendor,
587         target_arch = "powerpc",
588         target_vendor = "nintendo"
589     )))]
590     #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
591     #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
592     #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
593     pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
594     #[cfg(not(all(
595         libc_cfg_target_vendor,
596         target_arch = "powerpc",
597         target_vendor = "nintendo"
598     )))]
599     #[cfg_attr(
600         all(target_os = "macos", target_arch = "x86"),
601         link_name = "connect$UNIX2003"
602     )]
603     #[cfg_attr(target_os = "illumos", link_name = "__xnet_connect")]
604     #[cfg_attr(target_os = "espidf", link_name = "lwip_connect")]
605     pub fn connect(socket: ::c_int, address: *const sockaddr, len: socklen_t) -> ::c_int;
606     #[cfg_attr(
607         all(target_os = "macos", target_arch = "x86"),
608         link_name = "listen$UNIX2003"
609     )]
610     #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")]
611     pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
612     #[cfg(not(all(
613         libc_cfg_target_vendor,
614         target_arch = "powerpc",
615         target_vendor = "nintendo"
616     )))]
617     #[cfg_attr(
618         all(target_os = "macos", target_arch = "x86"),
619         link_name = "accept$UNIX2003"
620     )]
621     #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")]
622     pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int;
623     #[cfg(not(all(
624         libc_cfg_target_vendor,
625         target_arch = "powerpc",
626         target_vendor = "nintendo"
627     )))]
628     #[cfg_attr(
629         all(target_os = "macos", target_arch = "x86"),
630         link_name = "getpeername$UNIX2003"
631     )]
632     #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")]
633     pub fn getpeername(
634         socket: ::c_int,
635         address: *mut sockaddr,
636         address_len: *mut socklen_t,
637     ) -> ::c_int;
638     #[cfg(not(all(
639         libc_cfg_target_vendor,
640         target_arch = "powerpc",
641         target_vendor = "nintendo"
642     )))]
643     #[cfg_attr(
644         all(target_os = "macos", target_arch = "x86"),
645         link_name = "getsockname$UNIX2003"
646     )]
647     #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")]
648     pub fn getsockname(
649         socket: ::c_int,
650         address: *mut sockaddr,
651         address_len: *mut socklen_t,
652     ) -> ::c_int;
653     #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")]
654     pub fn setsockopt(
655         socket: ::c_int,
656         level: ::c_int,
657         name: ::c_int,
658         value: *const ::c_void,
659         option_len: socklen_t,
660     ) -> ::c_int;
661     #[cfg_attr(
662         all(target_os = "macos", target_arch = "x86"),
663         link_name = "socketpair$UNIX2003"
664     )]
665     #[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")]
666     pub fn socketpair(
667         domain: ::c_int,
668         type_: ::c_int,
669         protocol: ::c_int,
670         socket_vector: *mut ::c_int,
671     ) -> ::c_int;
672     #[cfg(not(all(
673         libc_cfg_target_vendor,
674         target_arch = "powerpc",
675         target_vendor = "nintendo"
676     )))]
677     #[cfg_attr(
678         all(target_os = "macos", target_arch = "x86"),
679         link_name = "sendto$UNIX2003"
680     )]
681     #[cfg_attr(target_os = "illumos", link_name = "__xnet_sendto")]
682     #[cfg_attr(target_os = "espidf", link_name = "lwip_sendto")]
683     pub fn sendto(
684         socket: ::c_int,
685         buf: *const ::c_void,
686         len: ::size_t,
687         flags: ::c_int,
688         addr: *const sockaddr,
689         addrlen: socklen_t,
690     ) -> ::ssize_t;
691     #[cfg_attr(target_os = "espidf", link_name = "lwip_shutdown")]
692     pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
693 
694     #[cfg_attr(
695         all(target_os = "macos", target_arch = "x86"),
696         link_name = "chmod$UNIX2003"
697     )]
698     pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
699     #[cfg_attr(
700         all(target_os = "macos", target_arch = "x86"),
701         link_name = "fchmod$UNIX2003"
702     )]
703     pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
704 
705     #[cfg_attr(
706         all(target_os = "macos", not(target_arch = "aarch64")),
707         link_name = "fstat$INODE64"
708     )]
709     #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
710     #[cfg_attr(
711         all(target_os = "freebsd", any(freebsd11, freebsd10)),
712         link_name = "fstat@FBSD_1.0"
713     )]
714     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
715 
716     pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
717 
718     #[cfg_attr(
719         all(target_os = "macos", not(target_arch = "aarch64")),
720         link_name = "stat$INODE64"
721     )]
722     #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
723     #[cfg_attr(
724         all(target_os = "freebsd", any(freebsd11, freebsd10)),
725         link_name = "stat@FBSD_1.0"
726     )]
727     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
728 
729     pub fn pclose(stream: *mut ::FILE) -> ::c_int;
730     #[cfg_attr(
731         all(target_os = "macos", target_arch = "x86"),
732         link_name = "fdopen$UNIX2003"
733     )]
734     pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
735     pub fn fileno(stream: *mut ::FILE) -> ::c_int;
736 
737     #[cfg_attr(
738         all(target_os = "macos", target_arch = "x86"),
739         link_name = "open$UNIX2003"
740     )]
741     pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
742     #[cfg_attr(
743         all(target_os = "macos", target_arch = "x86"),
744         link_name = "creat$UNIX2003"
745     )]
746     pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
747     #[cfg_attr(
748         all(target_os = "macos", target_arch = "x86"),
749         link_name = "fcntl$UNIX2003"
750     )]
751     pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
752 
753     #[cfg_attr(
754         all(target_os = "macos", target_arch = "x86_64"),
755         link_name = "opendir$INODE64"
756     )]
757     #[cfg_attr(
758         all(target_os = "macos", target_arch = "x86"),
759         link_name = "opendir$INODE64$UNIX2003"
760     )]
761     #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
762     pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
763 
764     #[cfg_attr(
765         all(target_os = "macos", not(target_arch = "aarch64")),
766         link_name = "readdir$INODE64"
767     )]
768     #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
769     #[cfg_attr(
770         all(target_os = "freebsd", any(freebsd11, freebsd10)),
771         link_name = "readdir@FBSD_1.0"
772     )]
773     pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
774     #[cfg_attr(
775         all(target_os = "macos", target_arch = "x86"),
776         link_name = "closedir$UNIX2003"
777     )]
778     pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
779     #[cfg_attr(
780         all(target_os = "macos", target_arch = "x86_64"),
781         link_name = "rewinddir$INODE64"
782     )]
783     #[cfg_attr(
784         all(target_os = "macos", target_arch = "x86"),
785         link_name = "rewinddir$INODE64$UNIX2003"
786     )]
787     pub fn rewinddir(dirp: *mut ::DIR);
788 
789     pub fn fchmodat(
790         dirfd: ::c_int,
791         pathname: *const ::c_char,
792         mode: ::mode_t,
793         flags: ::c_int,
794     ) -> ::c_int;
795     pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int;
796     pub fn fchownat(
797         dirfd: ::c_int,
798         pathname: *const ::c_char,
799         owner: ::uid_t,
800         group: ::gid_t,
801         flags: ::c_int,
802     ) -> ::c_int;
803     #[cfg_attr(
804         all(target_os = "macos", not(target_arch = "aarch64")),
805         link_name = "fstatat$INODE64"
806     )]
807     #[cfg_attr(
808         all(target_os = "freebsd", any(freebsd11, freebsd10)),
809         link_name = "fstatat@FBSD_1.1"
810     )]
811     pub fn fstatat(
812         dirfd: ::c_int,
813         pathname: *const ::c_char,
814         buf: *mut stat,
815         flags: ::c_int,
816     ) -> ::c_int;
817     pub fn linkat(
818         olddirfd: ::c_int,
819         oldpath: *const ::c_char,
820         newdirfd: ::c_int,
821         newpath: *const ::c_char,
822         flags: ::c_int,
823     ) -> ::c_int;
824     pub fn renameat(
825         olddirfd: ::c_int,
826         oldpath: *const ::c_char,
827         newdirfd: ::c_int,
828         newpath: *const ::c_char,
829     ) -> ::c_int;
830     pub fn symlinkat(
831         target: *const ::c_char,
832         newdirfd: ::c_int,
833         linkpath: *const ::c_char,
834     ) -> ::c_int;
835     pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int) -> ::c_int;
836 
837     pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
838     pub fn alarm(seconds: ::c_uint) -> ::c_uint;
839     pub fn chdir(dir: *const c_char) -> ::c_int;
840     pub fn fchdir(dirfd: ::c_int) -> ::c_int;
841     pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
842     #[cfg_attr(
843         all(target_os = "macos", target_arch = "x86"),
844         link_name = "lchown$UNIX2003"
845     )]
846     pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
847     #[cfg_attr(
848         all(target_os = "macos", target_arch = "x86"),
849         link_name = "close$NOCANCEL$UNIX2003"
850     )]
851     #[cfg_attr(
852         all(target_os = "macos", target_arch = "x86_64"),
853         link_name = "close$NOCANCEL"
854     )]
855     pub fn close(fd: ::c_int) -> ::c_int;
856     pub fn dup(fd: ::c_int) -> ::c_int;
857     pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
858     pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int;
859     pub fn execle(path: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int;
860     pub fn execlp(file: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int;
861     pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int;
862     pub fn execve(
863         prog: *const c_char,
864         argv: *const *const c_char,
865         envp: *const *const c_char,
866     ) -> ::c_int;
867     pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int;
868     pub fn fork() -> pid_t;
869     pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
870     pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
871     pub fn getegid() -> gid_t;
872     pub fn geteuid() -> uid_t;
873     pub fn getgid() -> gid_t;
874     pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int;
875     #[cfg_attr(target_os = "illumos", link_name = "getloginx")]
876     pub fn getlogin() -> *mut c_char;
877     #[cfg_attr(
878         all(target_os = "macos", target_arch = "x86"),
879         link_name = "getopt$UNIX2003"
880     )]
881     pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int;
882     pub fn getpgid(pid: pid_t) -> pid_t;
883     pub fn getpgrp() -> pid_t;
884     pub fn getpid() -> pid_t;
885     pub fn getppid() -> pid_t;
886     pub fn getuid() -> uid_t;
887     pub fn isatty(fd: ::c_int) -> ::c_int;
888     pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
889     pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
890     pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
891     pub fn pipe(fds: *mut ::c_int) -> ::c_int;
892     pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int;
893     #[cfg_attr(
894         all(target_os = "macos", target_arch = "x86"),
895         link_name = "read$UNIX2003"
896     )]
897     pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t;
898     pub fn rmdir(path: *const c_char) -> ::c_int;
899     pub fn seteuid(uid: uid_t) -> ::c_int;
900     pub fn setegid(gid: gid_t) -> ::c_int;
901     pub fn setgid(gid: gid_t) -> ::c_int;
902     pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
903     pub fn setsid() -> pid_t;
904     pub fn setuid(uid: uid_t) -> ::c_int;
905     pub fn setreuid(ruid: uid_t, euid: uid_t) -> ::c_int;
906     pub fn setregid(rgid: gid_t, egid: gid_t) -> ::c_int;
907     #[cfg_attr(
908         all(target_os = "macos", target_arch = "x86"),
909         link_name = "sleep$UNIX2003"
910     )]
911     pub fn sleep(secs: ::c_uint) -> ::c_uint;
912     #[cfg_attr(
913         all(target_os = "macos", target_arch = "x86"),
914         link_name = "nanosleep$UNIX2003"
915     )]
916     #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
917     pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int;
918     pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
919     pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
920     pub fn ttyname(fd: ::c_int) -> *mut c_char;
921     #[cfg_attr(
922         all(target_os = "macos", target_arch = "x86"),
923         link_name = "ttyname_r$UNIX2003"
924     )]
925     #[cfg_attr(target_os = "illumos", link_name = "__posix_ttyname_r")]
926     pub fn ttyname_r(fd: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
927     pub fn unlink(c: *const c_char) -> ::c_int;
928     #[cfg_attr(
929         all(target_os = "macos", target_arch = "x86"),
930         link_name = "wait$UNIX2003"
931     )]
932     pub fn wait(status: *mut ::c_int) -> pid_t;
933     #[cfg_attr(
934         all(target_os = "macos", target_arch = "x86"),
935         link_name = "waitpid$UNIX2003"
936     )]
937     pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t;
938     #[cfg_attr(
939         all(target_os = "macos", target_arch = "x86"),
940         link_name = "write$UNIX2003"
941     )]
942     pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t;
943     #[cfg_attr(
944         all(target_os = "macos", target_arch = "x86"),
945         link_name = "pread$UNIX2003"
946     )]
947     pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
948     #[cfg_attr(
949         all(target_os = "macos", target_arch = "x86"),
950         link_name = "pwrite$UNIX2003"
951     )]
952     pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
953     pub fn umask(mask: mode_t) -> mode_t;
954 
955     #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
956     pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
957 
958     #[cfg_attr(
959         all(target_os = "macos", target_arch = "x86"),
960         link_name = "kill$UNIX2003"
961     )]
962     pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
963     #[cfg_attr(
964         all(target_os = "macos", target_arch = "x86"),
965         link_name = "killpg$UNIX2003"
966     )]
967     pub fn killpg(pgrp: pid_t, sig: ::c_int) -> ::c_int;
968 
969     pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
970     pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
971     pub fn mlockall(flags: ::c_int) -> ::c_int;
972     pub fn munlockall() -> ::c_int;
973 
974     #[cfg_attr(
975         all(target_os = "macos", target_arch = "x86"),
976         link_name = "mmap$UNIX2003"
977     )]
978     pub fn mmap(
979         addr: *mut ::c_void,
980         len: ::size_t,
981         prot: ::c_int,
982         flags: ::c_int,
983         fd: ::c_int,
984         offset: off_t,
985     ) -> *mut ::c_void;
986     #[cfg_attr(
987         all(target_os = "macos", target_arch = "x86"),
988         link_name = "munmap$UNIX2003"
989     )]
990     pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
991 
992     pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
993     pub fn if_indextoname(ifindex: ::c_uint, ifname: *mut ::c_char) -> *mut ::c_char;
994 
995     #[cfg_attr(
996         all(target_os = "macos", not(target_arch = "aarch64")),
997         link_name = "lstat$INODE64"
998     )]
999     #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
1000     #[cfg_attr(
1001         all(target_os = "freebsd", any(freebsd11, freebsd10)),
1002         link_name = "lstat@FBSD_1.0"
1003     )]
1004     pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
1005 
1006     #[cfg_attr(
1007         all(target_os = "macos", target_arch = "x86"),
1008         link_name = "fsync$UNIX2003"
1009     )]
1010     pub fn fsync(fd: ::c_int) -> ::c_int;
1011 
1012     #[cfg_attr(
1013         all(target_os = "macos", target_arch = "x86"),
1014         link_name = "setenv$UNIX2003"
1015     )]
1016     pub fn setenv(name: *const c_char, val: *const c_char, overwrite: ::c_int) -> ::c_int;
1017     #[cfg_attr(
1018         all(target_os = "macos", target_arch = "x86"),
1019         link_name = "unsetenv$UNIX2003"
1020     )]
1021     #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
1022     pub fn unsetenv(name: *const c_char) -> ::c_int;
1023 
1024     pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
1025 
1026     pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
1027 
1028     pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
1029 
1030     #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
1031     pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
1032 
1033     #[cfg_attr(
1034         any(
1035             target_os = "macos",
1036             target_os = "ios",
1037             target_os = "tvos",
1038             target_os = "watchos"
1039         ),
1040         link_name = "realpath$DARWIN_EXTSN"
1041     )]
1042     pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char;
1043 
1044     pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1045 
1046     #[cfg_attr(target_os = "netbsd", link_name = "__times13")]
1047     pub fn times(buf: *mut ::tms) -> ::clock_t;
1048 
1049     pub fn pthread_self() -> ::pthread_t;
1050     #[cfg_attr(
1051         all(target_os = "macos", target_arch = "x86"),
1052         link_name = "pthread_join$UNIX2003"
1053     )]
1054     pub fn pthread_join(native: ::pthread_t, value: *mut *mut ::c_void) -> ::c_int;
1055     pub fn pthread_exit(value: *mut ::c_void) -> !;
1056     pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
1057     pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
1058     pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stack_size: ::size_t) -> ::c_int;
1059     pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int;
1060     pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
1061     #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
1062     pub fn sched_yield() -> ::c_int;
1063     pub fn pthread_key_create(
1064         key: *mut pthread_key_t,
1065         dtor: ::Option<unsafe extern "C" fn(*mut ::c_void)>,
1066     ) -> ::c_int;
1067     pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
1068     pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
1069     pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) -> ::c_int;
1070     pub fn pthread_mutex_init(
1071         lock: *mut pthread_mutex_t,
1072         attr: *const pthread_mutexattr_t,
1073     ) -> ::c_int;
1074     pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
1075     pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
1076     pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
1077     pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
1078 
1079     pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
1080     #[cfg_attr(
1081         all(target_os = "macos", target_arch = "x86"),
1082         link_name = "pthread_mutexattr_destroy$UNIX2003"
1083     )]
1084     pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
1085     pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: ::c_int) -> ::c_int;
1086 
1087     #[cfg_attr(
1088         all(target_os = "macos", target_arch = "x86"),
1089         link_name = "pthread_cond_init$UNIX2003"
1090     )]
1091     pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t)
1092         -> ::c_int;
1093     #[cfg_attr(
1094         all(target_os = "macos", target_arch = "x86"),
1095         link_name = "pthread_cond_wait$UNIX2003"
1096     )]
1097     pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> ::c_int;
1098     #[cfg_attr(
1099         all(target_os = "macos", target_arch = "x86"),
1100         link_name = "pthread_cond_timedwait$UNIX2003"
1101     )]
1102     pub fn pthread_cond_timedwait(
1103         cond: *mut pthread_cond_t,
1104         lock: *mut pthread_mutex_t,
1105         abstime: *const ::timespec,
1106     ) -> ::c_int;
1107     pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
1108     pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
1109     pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
1110     pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
1111     pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
1112     #[cfg_attr(
1113         all(target_os = "macos", target_arch = "x86"),
1114         link_name = "pthread_rwlock_init$UNIX2003"
1115     )]
1116     pub fn pthread_rwlock_init(
1117         lock: *mut pthread_rwlock_t,
1118         attr: *const pthread_rwlockattr_t,
1119     ) -> ::c_int;
1120     #[cfg_attr(
1121         all(target_os = "macos", target_arch = "x86"),
1122         link_name = "pthread_rwlock_destroy$UNIX2003"
1123     )]
1124     pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
1125     #[cfg_attr(
1126         all(target_os = "macos", target_arch = "x86"),
1127         link_name = "pthread_rwlock_rdlock$UNIX2003"
1128     )]
1129     pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1130     #[cfg_attr(
1131         all(target_os = "macos", target_arch = "x86"),
1132         link_name = "pthread_rwlock_tryrdlock$UNIX2003"
1133     )]
1134     pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1135     #[cfg_attr(
1136         all(target_os = "macos", target_arch = "x86"),
1137         link_name = "pthread_rwlock_wrlock$UNIX2003"
1138     )]
1139     pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1140     #[cfg_attr(
1141         all(target_os = "macos", target_arch = "x86"),
1142         link_name = "pthread_rwlock_trywrlock$UNIX2003"
1143     )]
1144     pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1145     #[cfg_attr(
1146         all(target_os = "macos", target_arch = "x86"),
1147         link_name = "pthread_rwlock_unlock$UNIX2003"
1148     )]
1149     pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
1150     pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
1151     pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> ::c_int;
1152 
1153     #[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")]
1154     #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")]
1155     pub fn getsockopt(
1156         sockfd: ::c_int,
1157         level: ::c_int,
1158         optname: ::c_int,
1159         optval: *mut ::c_void,
1160         optlen: *mut ::socklen_t,
1161     ) -> ::c_int;
1162     pub fn raise(signum: ::c_int) -> ::c_int;
1163     #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
1164     pub fn sigaction(signum: ::c_int, act: *const sigaction, oldact: *mut sigaction) -> ::c_int;
1165 
1166     #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
1167     pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int;
1168     pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void;
1169     pub fn dlerror() -> *mut ::c_char;
1170     pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void;
1171     pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
1172     pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
1173 
1174     #[cfg(not(all(
1175         libc_cfg_target_vendor,
1176         target_arch = "powerpc",
1177         target_vendor = "nintendo"
1178     )))]
1179     #[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")]
1180     #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")]
1181     pub fn getaddrinfo(
1182         node: *const c_char,
1183         service: *const c_char,
1184         hints: *const addrinfo,
1185         res: *mut *mut addrinfo,
1186     ) -> ::c_int;
1187     #[cfg(not(all(
1188         libc_cfg_target_vendor,
1189         target_arch = "powerpc",
1190         target_vendor = "nintendo"
1191     )))]
1192     #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")]
1193     pub fn freeaddrinfo(res: *mut addrinfo);
1194     pub fn hstrerror(errcode: ::c_int) -> *const ::c_char;
1195     pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
1196     #[cfg_attr(
1197         any(
1198             all(target_os = "linux", not(target_env = "musl")),
1199             target_os = "freebsd",
1200             target_os = "dragonfly",
1201             target_os = "haiku"
1202         ),
1203         link_name = "__res_init"
1204     )]
1205     #[cfg_attr(
1206         any(
1207             target_os = "macos",
1208             target_os = "ios",
1209             target_os = "tvos",
1210             target_os = "watchos"
1211         ),
1212         link_name = "res_9_init"
1213     )]
1214     pub fn res_init() -> ::c_int;
1215 
1216     #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
1217     #[cfg_attr(target_env = "musl", allow(deprecated))]
1218     // FIXME: for `time_t`
1219     pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1220     #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
1221     #[cfg_attr(target_env = "musl", allow(deprecated))]
1222     // FIXME: for `time_t`
1223     pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1224     #[cfg_attr(
1225         all(target_os = "macos", target_arch = "x86"),
1226         link_name = "mktime$UNIX2003"
1227     )]
1228     #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
1229     #[cfg_attr(target_env = "musl", allow(deprecated))]
1230     // FIXME: for `time_t`
1231     pub fn mktime(tm: *mut tm) -> time_t;
1232     #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
1233     #[cfg_attr(target_env = "musl", allow(deprecated))]
1234     // FIXME: for `time_t`
1235     pub fn time(time: *mut time_t) -> time_t;
1236     #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
1237     #[cfg_attr(target_env = "musl", allow(deprecated))]
1238     // FIXME: for `time_t`
1239     pub fn gmtime(time_p: *const time_t) -> *mut tm;
1240     #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
1241     #[cfg_attr(target_env = "musl", allow(deprecated))]
1242     // FIXME: for `time_t`
1243     pub fn localtime(time_p: *const time_t) -> *mut tm;
1244     #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
1245     #[cfg_attr(target_env = "musl", allow(deprecated))]
1246     // FIXME: for `time_t`
1247     pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
1248     #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
1249     #[cfg_attr(target_env = "musl", allow(deprecated))]
1250     // FIXME: for `time_t`
1251     pub fn timegm(tm: *mut ::tm) -> time_t;
1252 
1253     #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
1254     #[cfg_attr(
1255         all(target_os = "freebsd", any(freebsd11, freebsd10)),
1256         link_name = "mknod@FBSD_1.0"
1257     )]
1258     pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, dev: ::dev_t) -> ::c_int;
1259     pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
1260     pub fn endservent();
1261     pub fn getservbyname(name: *const ::c_char, proto: *const ::c_char) -> *mut servent;
1262     pub fn getservbyport(port: ::c_int, proto: *const ::c_char) -> *mut servent;
1263     pub fn getservent() -> *mut servent;
1264     pub fn setservent(stayopen: ::c_int);
1265     pub fn getprotobyname(name: *const ::c_char) -> *mut protoent;
1266     pub fn getprotobynumber(proto: ::c_int) -> *mut protoent;
1267     pub fn chroot(name: *const ::c_char) -> ::c_int;
1268     #[cfg_attr(
1269         all(target_os = "macos", target_arch = "x86"),
1270         link_name = "usleep$UNIX2003"
1271     )]
1272     pub fn usleep(secs: ::c_uint) -> ::c_int;
1273     #[cfg_attr(
1274         all(target_os = "macos", target_arch = "x86"),
1275         link_name = "send$UNIX2003"
1276     )]
1277     #[cfg_attr(target_os = "espidf", link_name = "lwip_send")]
1278     pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
1279     #[cfg_attr(
1280         all(target_os = "macos", target_arch = "x86"),
1281         link_name = "recv$UNIX2003"
1282     )]
1283     #[cfg_attr(target_os = "espidf", link_name = "lwip_recv")]
1284     pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
1285     #[cfg_attr(
1286         all(target_os = "macos", target_arch = "x86"),
1287         link_name = "putenv$UNIX2003"
1288     )]
1289     #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
1290     pub fn putenv(string: *mut c_char) -> ::c_int;
1291     #[cfg_attr(
1292         all(target_os = "macos", target_arch = "x86"),
1293         link_name = "poll$UNIX2003"
1294     )]
1295     pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
1296     #[cfg_attr(
1297         all(target_os = "macos", target_arch = "x86_64"),
1298         link_name = "select$1050"
1299     )]
1300     #[cfg_attr(
1301         all(target_os = "macos", target_arch = "x86"),
1302         link_name = "select$UNIX2003"
1303     )]
1304     #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
1305     pub fn select(
1306         nfds: ::c_int,
1307         readfs: *mut fd_set,
1308         writefds: *mut fd_set,
1309         errorfds: *mut fd_set,
1310         timeout: *mut timeval,
1311     ) -> ::c_int;
1312     #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
1313     pub fn setlocale(category: ::c_int, locale: *const ::c_char) -> *mut ::c_char;
1314     pub fn localeconv() -> *mut lconv;
1315 
1316     #[cfg_attr(
1317         all(target_os = "macos", target_arch = "x86"),
1318         link_name = "sem_wait$UNIX2003"
1319     )]
1320     pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
1321     pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
1322     pub fn sem_post(sem: *mut sem_t) -> ::c_int;
1323     pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
1324     pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
1325 
1326     pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: ::size_t) -> ::ssize_t;
1327 
1328     #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
1329     pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
1330     #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
1331     pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
1332     #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
1333     pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
1334     #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
1335     pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
1336     #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
1337     pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
1338 
1339     #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
1340     pub fn sigprocmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int;
1341     #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
1342     pub fn sigpending(set: *mut sigset_t) -> ::c_int;
1343 
1344     pub fn sysconf(name: ::c_int) -> ::c_long;
1345 
1346     pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
1347 
1348     #[cfg_attr(
1349         all(target_os = "macos", target_arch = "x86_64"),
1350         link_name = "pselect$1050"
1351     )]
1352     #[cfg_attr(
1353         all(target_os = "macos", target_arch = "x86"),
1354         link_name = "pselect$UNIX2003"
1355     )]
1356     #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
1357     pub fn pselect(
1358         nfds: ::c_int,
1359         readfs: *mut fd_set,
1360         writefds: *mut fd_set,
1361         errorfds: *mut fd_set,
1362         timeout: *const timespec,
1363         sigmask: *const sigset_t,
1364     ) -> ::c_int;
1365     pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int;
1366     pub fn ftello(stream: *mut ::FILE) -> ::off_t;
1367     #[cfg_attr(
1368         all(target_os = "macos", target_arch = "x86"),
1369         link_name = "tcdrain$UNIX2003"
1370     )]
1371     pub fn tcdrain(fd: ::c_int) -> ::c_int;
1372     pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
1373     pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
1374     pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
1375     pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
1376     pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
1377     pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const ::termios) -> ::c_int;
1378     pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
1379     pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
1380     pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
1381     pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
1382     pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
1383     pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
1384 
1385     pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
1386 
1387     pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
1388     pub fn closelog();
1389     pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
1390     #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")]
1391     pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
1392     #[cfg_attr(
1393         all(target_os = "macos", target_arch = "x86"),
1394         link_name = "nice$UNIX2003"
1395     )]
1396     pub fn nice(incr: ::c_int) -> ::c_int;
1397 
1398     pub fn grantpt(fd: ::c_int) -> ::c_int;
1399     pub fn posix_openpt(flags: ::c_int) -> ::c_int;
1400     pub fn ptsname(fd: ::c_int) -> *mut ::c_char;
1401     pub fn unlockpt(fd: ::c_int) -> ::c_int;
1402 
1403     pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
1404     pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
1405 
1406     pub fn lockf(fd: ::c_int, cmd: ::c_int, len: ::off_t) -> ::c_int;
1407 
1408 }
1409 cfg_if! {
1410     if #[cfg(not(any(target_os = "emscripten",
1411                      target_os = "android",
1412                      target_os = "haiku")))] {
1413         extern "C" {
1414             pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int;
1415             pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
1416         }
1417     }
1418 }
1419 
1420 cfg_if! {
1421     if #[cfg(not(target_env = "uclibc"))] {
1422         extern "C" {
1423             pub fn open_wmemstream(
1424                 ptr: *mut *mut wchar_t,
1425                 sizeloc: *mut size_t,
1426             ) -> *mut FILE;
1427         }
1428     }
1429 }
1430 
1431 cfg_if! {
1432     if #[cfg(not(target_os = "redox"))] {
1433         extern {
1434             pub fn getsid(pid: pid_t) -> pid_t;
1435             pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
1436             #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1437                        link_name = "pause$UNIX2003")]
1438             pub fn pause() -> ::c_int;
1439 
1440             pub fn readlinkat(dirfd: ::c_int,
1441                               pathname: *const ::c_char,
1442                               buf: *mut ::c_char,
1443                               bufsiz: ::size_t) -> ::ssize_t;
1444             pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
1445                            mode: ::mode_t) -> ::c_int;
1446             pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
1447                           flags: ::c_int, ...) -> ::c_int;
1448 
1449             #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
1450                        link_name = "fdopendir$INODE64")]
1451             #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1452                        link_name = "fdopendir$INODE64$UNIX2003")]
1453             pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
1454 
1455             #[cfg_attr(all(target_os = "macos", not(target_arch = "aarch64")),
1456                        link_name = "readdir_r$INODE64")]
1457             #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
1458             #[cfg_attr(
1459                 all(target_os = "freebsd", any(freebsd11, freebsd10)),
1460                 link_name = "readdir_r@FBSD_1.0"
1461             )]
1462             #[allow(non_autolinks)] // FIXME: `<>` breaks line length limit.
1463             /// The 64-bit libc on Solaris and illumos only has readdir_r. If a
1464             /// 32-bit Solaris or illumos target is ever created, it should use
1465             /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos:
1466             /// https://illumos.org/man/3lib/libc
1467             /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
1468             /// https://www.unix.com/man-page/opensolaris/3LIB/libc/
1469             pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
1470                              result: *mut *mut ::dirent) -> ::c_int;
1471         }
1472     }
1473 }
1474 
1475 cfg_if! {
1476    if #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] {
1477         extern {
1478             pub fn cfmakeraw(termios: *mut ::termios);
1479             pub fn cfsetspeed(termios: *mut ::termios,
1480                               speed: ::speed_t) -> ::c_int;
1481         }
1482    }
1483 }
1484 
1485 cfg_if! {
1486     if #[cfg(target_env = "newlib")] {
1487         mod newlib;
1488         pub use self::newlib::*;
1489     } else if #[cfg(any(target_os = "linux",
1490                         target_os = "l4re",
1491                         target_os = "android",
1492                         target_os = "emscripten"))] {
1493         mod linux_like;
1494         pub use self::linux_like::*;
1495     } else if #[cfg(any(target_os = "macos",
1496                         target_os = "ios",
1497                         target_os = "tvos",
1498                         target_os = "watchos",
1499                         target_os = "freebsd",
1500                         target_os = "dragonfly",
1501                         target_os = "openbsd",
1502                         target_os = "netbsd"))] {
1503         mod bsd;
1504         pub use self::bsd::*;
1505     } else if #[cfg(any(target_os = "solaris",
1506                         target_os = "illumos"))] {
1507         mod solarish;
1508         pub use self::solarish::*;
1509     } else if #[cfg(target_os = "haiku")] {
1510         mod haiku;
1511         pub use self::haiku::*;
1512     } else if #[cfg(target_os = "hermit")] {
1513         mod hermit;
1514         pub use self::hermit::*;
1515     } else if #[cfg(target_os = "redox")] {
1516         mod redox;
1517         pub use self::redox::*;
1518     } else {
1519         // Unknown target_os
1520     }
1521 }
1522 
1523 cfg_if! {
1524     if #[cfg(libc_core_cvoid)] {
1525         pub use ::ffi::c_void;
1526     } else {
1527         // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
1528         // enable more optimization opportunities around it recognizing things
1529         // like malloc/free.
1530         #[repr(u8)]
1531         #[allow(missing_copy_implementations)]
1532         #[allow(missing_debug_implementations)]
1533         pub enum c_void {
1534             // Two dummy variants so the #[repr] attribute can be used.
1535             #[doc(hidden)]
1536             __variant1,
1537             #[doc(hidden)]
1538             __variant2,
1539         }
1540     }
1541 }
1542 
1543 cfg_if! {
1544     if #[cfg(libc_align)] {
1545         mod align;
1546         pub use self::align::*;
1547     } else {
1548         mod no_align;
1549         pub use self::no_align::*;
1550     }
1551 }
1552