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