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