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