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
40extern_ty! {
41 pub enum DIR {}
42}
43
44#[cfg(not(target_os = "nuttx"))]
45pub type locale_t = *mut c_void;
46
47s! {
48 pub struct group {
49 pub gr_name: *mut c_char,
50 pub gr_passwd: *mut c_char,
51 pub gr_gid: crate::gid_t,
52 pub gr_mem: *mut *mut c_char,
53 }
54
55 pub struct utimbuf {
56 pub actime: time_t,
57 pub modtime: time_t,
58 }
59
60 pub struct timeval {
61 pub tv_sec: time_t,
62 #[cfg(not(gnu_time_bits64))]
63 pub tv_usec: crate::suseconds_t,
64 #[cfg(gnu_time_bits64)]
67 pub tv_usec: __suseconds64_t,
68 }
69
70 #[cfg(not(target_env = "gnu"))]
73 pub struct timespec {
74 pub tv_sec: time_t,
75 #[cfg(all(musl32_time64, target_endian = "big"))]
76 __pad0: Padding<u32>,
77 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
78 pub tv_nsec: i64,
79 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
80 pub tv_nsec: c_long,
81 #[cfg(all(musl32_time64, target_endian = "little"))]
82 __pad0: Padding<u32>,
83 }
84
85 pub struct rlimit {
86 pub rlim_cur: rlim_t,
87 pub rlim_max: rlim_t,
88 }
89
90 pub struct rusage {
91 pub ru_utime: timeval,
92 pub ru_stime: timeval,
93 pub ru_maxrss: c_long,
94 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
95 __pad1: Padding<u32>,
96 pub ru_ixrss: c_long,
97 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
98 __pad2: Padding<u32>,
99 pub ru_idrss: c_long,
100 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
101 __pad3: Padding<u32>,
102 pub ru_isrss: c_long,
103 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
104 __pad4: Padding<u32>,
105 pub ru_minflt: c_long,
106 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
107 __pad5: Padding<u32>,
108 pub ru_majflt: c_long,
109 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
110 __pad6: Padding<u32>,
111 pub ru_nswap: c_long,
112 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
113 __pad7: Padding<u32>,
114 pub ru_inblock: c_long,
115 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
116 __pad8: Padding<u32>,
117 pub ru_oublock: c_long,
118 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
119 __pad9: Padding<u32>,
120 pub ru_msgsnd: c_long,
121 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
122 __pad10: Padding<u32>,
123 pub ru_msgrcv: c_long,
124 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
125 __pad11: Padding<u32>,
126 pub ru_nsignals: c_long,
127 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
128 __pad12: Padding<u32>,
129 pub ru_nvcsw: c_long,
130 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
131 __pad13: Padding<u32>,
132 pub ru_nivcsw: c_long,
133 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
134 __pad14: Padding<u32>,
135
136 #[cfg(any(target_env = "musl", target_env = "ohos", target_os = "emscripten"))]
137 __reserved: Padding<[c_long; 16]>,
138 }
139
140 #[cfg(not(target_os = "nuttx"))]
141 pub struct ipv6_mreq {
142 pub ipv6mr_multiaddr: in6_addr,
143 #[cfg(target_os = "android")]
144 pub ipv6mr_interface: c_int,
145 #[cfg(not(target_os = "android"))]
146 pub ipv6mr_interface: c_uint,
147 }
148
149 #[cfg(all(not(target_os = "cygwin"), not(target_os = "horizon")))]
150 pub struct hostent {
151 pub h_name: *mut c_char,
152 pub h_aliases: *mut *mut c_char,
153 pub h_addrtype: c_int,
154 pub h_length: c_int,
155 pub h_addr_list: *mut *mut c_char,
156 }
157
158 pub struct iovec {
159 pub iov_base: *mut c_void,
160 pub iov_len: size_t,
161 }
162
163 #[cfg(not(target_os = "horizon"))]
164 pub struct pollfd {
165 pub fd: c_int,
166 pub events: c_short,
167 pub revents: c_short,
168 }
169
170 pub struct winsize {
171 pub ws_row: c_ushort,
172 pub ws_col: c_ushort,
173 pub ws_xpixel: c_ushort,
174 pub ws_ypixel: c_ushort,
175 }
176
177 #[cfg(not(target_os = "cygwin"))]
178 pub struct linger {
179 pub l_onoff: c_int,
180 pub l_linger: c_int,
181 }
182
183 pub struct sigval {
184 pub sival_ptr: *mut c_void,
186 }
187
188 pub struct itimerval {
190 pub it_interval: crate::timeval,
191 pub it_value: crate::timeval,
192 }
193
194 pub struct tms {
196 pub tms_utime: crate::clock_t,
197 pub tms_stime: crate::clock_t,
198 pub tms_cutime: crate::clock_t,
199 pub tms_cstime: crate::clock_t,
200 }
201
202 pub struct servent {
203 pub s_name: *mut c_char,
204 pub s_aliases: *mut *mut c_char,
205 #[cfg(target_os = "cygwin")]
206 pub s_port: c_short,
207 #[cfg(not(target_os = "cygwin"))]
208 pub s_port: c_int,
209 pub s_proto: *mut c_char,
210 }
211
212 pub struct protoent {
213 pub p_name: *mut c_char,
214 pub p_aliases: *mut *mut c_char,
215 #[cfg(not(target_os = "cygwin"))]
216 pub p_proto: c_int,
217 #[cfg(target_os = "cygwin")]
218 pub p_proto: c_short,
219 }
220
221 #[repr(align(4))]
222 pub struct in6_addr {
223 pub s6_addr: [u8; 16],
224 }
225}
226
227pub const INT_MIN: c_int = -2147483648;
228pub const INT_MAX: c_int = 2147483647;
229
230pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
231pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
232pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
233
234cfg_if! {
235 if #[cfg(all(not(target_os = "nto"), not(target_os = "aix")))] {
236 pub const DT_UNKNOWN: u8 = 0;
237 pub const DT_FIFO: u8 = 1;
238 pub const DT_CHR: u8 = 2;
239 pub const DT_DIR: u8 = 4;
240 pub const DT_BLK: u8 = 6;
241 pub const DT_REG: u8 = 8;
242 pub const DT_LNK: u8 = 10;
243 pub const DT_SOCK: u8 = 12;
244 }
245}
246cfg_if! {
247 if #[cfg(not(target_os = "redox"))] {
248 pub const FD_CLOEXEC: c_int = 0x1;
249 }
250}
251
252cfg_if! {
253 if #[cfg(not(any(target_os = "nto", target_os = "l4re")))] {
254 pub const USRQUOTA: c_int = 0;
255 pub const GRPQUOTA: c_int = 1;
256 }
257}
258pub const SIGIOT: c_int = 6;
259
260pub const S_ISUID: mode_t = 0o4000;
261pub const S_ISGID: mode_t = 0o2000;
262pub const S_ISVTX: mode_t = 0o1000;
263
264cfg_if! {
265 if #[cfg(not(any(
266 target_os = "haiku",
267 target_os = "illumos",
268 target_os = "solaris",
269 target_os = "cygwin"
270 )))] {
271 pub const IF_NAMESIZE: size_t = 16;
272 pub const IFNAMSIZ: size_t = IF_NAMESIZE;
273 }
274}
275
276pub const LOG_EMERG: c_int = 0;
277pub const LOG_ALERT: c_int = 1;
278pub const LOG_CRIT: c_int = 2;
279pub const LOG_ERR: c_int = 3;
280pub const LOG_WARNING: c_int = 4;
281pub const LOG_NOTICE: c_int = 5;
282pub const LOG_INFO: c_int = 6;
283pub const LOG_DEBUG: c_int = 7;
284
285pub const LOG_KERN: c_int = 0;
286pub const LOG_USER: c_int = 1 << 3;
287pub const LOG_MAIL: c_int = 2 << 3;
288pub const LOG_DAEMON: c_int = 3 << 3;
289pub const LOG_AUTH: c_int = 4 << 3;
290pub const LOG_SYSLOG: c_int = 5 << 3;
291pub const LOG_LPR: c_int = 6 << 3;
292pub const LOG_NEWS: c_int = 7 << 3;
293pub const LOG_UUCP: c_int = 8 << 3;
294pub const LOG_LOCAL0: c_int = 16 << 3;
295pub const LOG_LOCAL1: c_int = 17 << 3;
296pub const LOG_LOCAL2: c_int = 18 << 3;
297pub const LOG_LOCAL3: c_int = 19 << 3;
298pub const LOG_LOCAL4: c_int = 20 << 3;
299pub const LOG_LOCAL5: c_int = 21 << 3;
300pub const LOG_LOCAL6: c_int = 22 << 3;
301pub const LOG_LOCAL7: c_int = 23 << 3;
302
303cfg_if! {
304 if #[cfg(not(target_os = "haiku"))] {
305 pub const LOG_PID: c_int = 0x01;
306 pub const LOG_CONS: c_int = 0x02;
307 pub const LOG_ODELAY: c_int = 0x04;
308 pub const LOG_NDELAY: c_int = 0x08;
309 pub const LOG_NOWAIT: c_int = 0x10;
310 }
311}
312pub const LOG_PRIMASK: c_int = 7;
313pub const LOG_FACMASK: c_int = 0x3f8;
314
315cfg_if! {
316 if #[cfg(not(target_os = "nto"))] {
317 pub const PRIO_MIN: c_int = -20;
318 pub const PRIO_MAX: c_int = 20;
319 }
320}
321pub const IPPROTO_ICMP: c_int = 1;
322pub const IPPROTO_ICMPV6: c_int = 58;
323pub const IPPROTO_TCP: c_int = 6;
324pub const IPPROTO_UDP: c_int = 17;
325pub const IPPROTO_IP: c_int = 0;
326pub const IPPROTO_IPV6: c_int = 41;
327
328pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
329pub const INADDR_ANY: in_addr_t = 0;
330pub const INADDR_BROADCAST: in_addr_t = 4294967295;
331pub const INADDR_NONE: in_addr_t = 4294967295;
332
333pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr {
334 s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
335};
336
337pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr {
338 s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
339};
340
341pub const ARPOP_REQUEST: u16 = 1;
342pub const ARPOP_REPLY: u16 = 2;
343
344pub const ATF_COM: c_int = 0x02;
345pub const ATF_PERM: c_int = 0x04;
346pub const ATF_PUBL: c_int = 0x08;
347pub const ATF_USETRAILERS: c_int = 0x10;
348
349cfg_if! {
350 if #[cfg(any(target_os = "nto", target_os = "aix"))] {
351 pub const FNM_PERIOD: c_int = 1 << 1;
352 } else {
353 pub const FNM_PERIOD: c_int = 1 << 2;
354 }
355}
356pub const FNM_NOMATCH: c_int = 1;
357
358cfg_if! {
359 if #[cfg(any(
360 target_os = "illumos",
361 target_os = "solaris",
362 target_os = "netbsd"
363 ))] {
364 pub const FNM_CASEFOLD: c_int = 1 << 3;
365 } else if #[cfg(not(target_os = "aix"))] {
366 pub const FNM_CASEFOLD: c_int = 1 << 4;
367 }
368}
369
370cfg_if! {
371 if #[cfg(any(
372 target_os = "macos",
373 target_os = "freebsd",
374 target_os = "android",
375 target_os = "openbsd",
376 target_os = "cygwin",
377 target_os = "netbsd",
378 ))] {
379 pub const FNM_PATHNAME: c_int = 1 << 1;
380 } else {
381 pub const FNM_PATHNAME: c_int = 1 << 0;
382 }
383}
384
385cfg_if! {
386 if #[cfg(any(
387 target_os = "macos",
388 target_os = "freebsd",
389 target_os = "android",
390 target_os = "openbsd",
391 target_os = "netbsd",
392 target_os = "cygwin",
393 ))] {
394 pub const FNM_NOESCAPE: c_int = 1 << 0;
395 } else if #[cfg(target_os = "nto")] {
396 pub const FNM_NOESCAPE: c_int = 1 << 2;
397 } else if #[cfg(target_os = "aix")] {
398 pub const FNM_NOESCAPE: c_int = 1 << 3;
399 } else {
400 pub const FNM_NOESCAPE: c_int = 1 << 1;
401 }
402}
403
404extern "C" {
405 pub static in6addr_loopback: in6_addr;
406 pub static in6addr_any: in6_addr;
407}
408
409cfg_if! {
410 if #[cfg(any(
411 target_os = "l4re",
412 target_os = "espidf",
413 target_os = "nuttx"
414 ))] {
415 } else if #[cfg(feature = "std")] {
420 } else if #[cfg(all(
423 any(
424 all(
425 target_os = "linux",
426 any(target_env = "gnu", target_env = "uclibc")
427 ),
428 target_os = "cygwin"
429 ),
430 feature = "rustc-dep-of-std"
431 ))] {
432 #[link(
433 name = "util",
434 kind = "static",
435 modifiers = "-bundle",
436 cfg(target_feature = "crt-static")
437 )]
438 #[link(
439 name = "rt",
440 kind = "static",
441 modifiers = "-bundle",
442 cfg(target_feature = "crt-static")
443 )]
444 #[link(
445 name = "pthread",
446 kind = "static",
447 modifiers = "-bundle",
448 cfg(target_feature = "crt-static")
449 )]
450 #[link(
451 name = "m",
452 kind = "static",
453 modifiers = "-bundle",
454 cfg(target_feature = "crt-static")
455 )]
456 #[link(
457 name = "dl",
458 kind = "static",
459 modifiers = "-bundle",
460 cfg(target_feature = "crt-static")
461 )]
462 #[link(
463 name = "c",
464 kind = "static",
465 modifiers = "-bundle",
466 cfg(target_feature = "crt-static")
467 )]
468 #[link(
469 name = "gcc_eh",
470 kind = "static",
471 modifiers = "-bundle",
472 cfg(target_feature = "crt-static")
473 )]
474 #[link(
475 name = "gcc",
476 kind = "static",
477 modifiers = "-bundle",
478 cfg(target_feature = "crt-static")
479 )]
480 #[link(
481 name = "c",
482 kind = "static",
483 modifiers = "-bundle",
484 cfg(target_feature = "crt-static")
485 )]
486 #[link(name = "util", cfg(not(target_feature = "crt-static")))]
487 #[link(name = "rt", cfg(not(target_feature = "crt-static")))]
488 #[link(name = "pthread", cfg(not(target_feature = "crt-static")))]
489 #[link(name = "m", cfg(not(target_feature = "crt-static")))]
490 #[link(name = "dl", cfg(not(target_feature = "crt-static")))]
491 #[link(name = "c", cfg(not(target_feature = "crt-static")))]
492 extern "C" {}
493 } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
494 #[cfg_attr(
495 feature = "rustc-dep-of-std",
496 link(
497 name = "c",
498 kind = "static",
499 modifiers = "-bundle",
500 cfg(target_feature = "crt-static")
501 )
502 )]
503 #[cfg_attr(
504 feature = "rustc-dep-of-std",
505 link(name = "c", cfg(not(target_feature = "crt-static")))
506 )]
507 extern "C" {}
508 } else if #[cfg(target_os = "emscripten")] {
509 } else if #[cfg(all(target_os = "android", feature = "rustc-dep-of-std"))] {
512 #[link(
513 name = "c",
514 kind = "static",
515 modifiers = "-bundle",
516 cfg(target_feature = "crt-static")
517 )]
518 #[link(
519 name = "m",
520 kind = "static",
521 modifiers = "-bundle",
522 cfg(target_feature = "crt-static")
523 )]
524 #[link(name = "m", cfg(not(target_feature = "crt-static")))]
525 #[link(name = "c", cfg(not(target_feature = "crt-static")))]
526 extern "C" {}
527 } else if #[cfg(any(
528 target_os = "macos",
529 target_os = "ios",
530 target_os = "tvos",
531 target_os = "watchos",
532 target_os = "visionos",
533 target_os = "android",
534 target_os = "openbsd",
535 target_os = "nto",
536 ))] {
537 #[link(name = "c")]
538 #[link(name = "m")]
539 extern "C" {}
540 } else if #[cfg(target_os = "haiku")] {
541 #[link(name = "root")]
542 #[link(name = "network")]
543 extern "C" {}
544 } else if #[cfg(target_env = "newlib")] {
545 #[link(name = "c")]
546 #[link(name = "m")]
547 extern "C" {}
548 } else if #[cfg(target_env = "illumos")] {
549 #[link(name = "c")]
550 #[link(name = "m")]
551 extern "C" {}
552 } else if #[cfg(target_os = "redox")] {
553 #[cfg_attr(
554 feature = "rustc-dep-of-std",
555 link(
556 name = "c",
557 kind = "static",
558 modifiers = "-bundle",
559 cfg(target_feature = "crt-static")
560 )
561 )]
562 #[cfg_attr(
563 feature = "rustc-dep-of-std",
564 link(name = "c", cfg(not(target_feature = "crt-static")))
565 )]
566 extern "C" {}
567 } else if #[cfg(target_os = "aix")] {
568 #[link(name = "c")]
569 #[link(name = "m")]
570 #[link(name = "bsd")]
571 #[link(name = "pthread")]
572 extern "C" {}
573 } else {
574 #[link(name = "c")]
575 #[link(name = "m")]
576 #[link(name = "rt")]
577 #[link(name = "pthread")]
578 extern "C" {}
579 }
580}
581
582cfg_if! {
583 if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] {
584 extern_ty! {
585 pub enum fpos_t {} }
587 }
588}
589
590extern_ty! {
591 pub enum FILE {}
592}
593
594extern "C" {
595 pub fn isalnum(c: c_int) -> c_int;
596 pub fn isalpha(c: c_int) -> c_int;
597 pub fn iscntrl(c: c_int) -> c_int;
598 pub fn isdigit(c: c_int) -> c_int;
599 pub fn isgraph(c: c_int) -> c_int;
600 pub fn islower(c: c_int) -> c_int;
601 pub fn isprint(c: c_int) -> c_int;
602 pub fn ispunct(c: c_int) -> c_int;
603 pub fn isspace(c: c_int) -> c_int;
604 pub fn isupper(c: c_int) -> c_int;
605 pub fn isxdigit(c: c_int) -> c_int;
606 pub fn isblank(c: c_int) -> c_int;
607 pub fn tolower(c: c_int) -> c_int;
608 pub fn toupper(c: c_int) -> c_int;
609 pub fn qsort(
610 base: *mut c_void,
611 num: size_t,
612 size: size_t,
613 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
614 );
615 pub fn bsearch(
616 key: *const c_void,
617 base: *const c_void,
618 num: size_t,
619 size: size_t,
620 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
621 ) -> *mut c_void;
622 #[cfg_attr(
623 all(target_os = "macos", target_arch = "x86"),
624 link_name = "fopen$UNIX2003"
625 )]
626 #[cfg_attr(gnu_file_offset_bits64, link_name = "fopen64")]
627 pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
628 #[cfg_attr(
629 all(target_os = "macos", target_arch = "x86"),
630 link_name = "freopen$UNIX2003"
631 )]
632 #[cfg_attr(gnu_file_offset_bits64, link_name = "freopen64")]
633 pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
634
635 pub fn fflush(file: *mut FILE) -> c_int;
636 pub fn fclose(file: *mut FILE) -> c_int;
637 pub fn remove(filename: *const c_char) -> c_int;
638 pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
639 #[cfg_attr(gnu_file_offset_bits64, link_name = "tmpfile64")]
640 pub fn tmpfile() -> *mut FILE;
641 pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
642 pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
643 pub fn getchar() -> c_int;
644 pub fn putchar(c: c_int) -> c_int;
645 pub fn fgetc(stream: *mut FILE) -> c_int;
646 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
647 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
648 #[cfg_attr(
649 all(target_os = "macos", target_arch = "x86"),
650 link_name = "fputs$UNIX2003"
651 )]
652 pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
653 pub fn puts(s: *const c_char) -> c_int;
654 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
655 pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
656 #[cfg_attr(
657 all(target_os = "macos", target_arch = "x86"),
658 link_name = "fwrite$UNIX2003"
659 )]
660 pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
661 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
662 pub fn ftell(stream: *mut FILE) -> c_long;
663 pub fn rewind(stream: *mut FILE);
664 #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
665 #[cfg_attr(gnu_file_offset_bits64, link_name = "fgetpos64")]
666 pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
667 #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
668 #[cfg_attr(gnu_file_offset_bits64, link_name = "fsetpos64")]
669 pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
670 pub fn feof(stream: *mut FILE) -> c_int;
671 pub fn ferror(stream: *mut FILE) -> c_int;
672 pub fn clearerr(stream: *mut FILE);
673 pub fn perror(s: *const c_char);
674 pub fn atof(s: *const c_char) -> c_double;
675 pub fn atoi(s: *const c_char) -> c_int;
676 pub fn atol(s: *const c_char) -> c_long;
677 pub fn atoll(s: *const c_char) -> c_longlong;
678 #[cfg_attr(
679 all(target_os = "macos", target_arch = "x86"),
680 link_name = "strtod$UNIX2003"
681 )]
682 pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
683 pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
684 pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
685 pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
686 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
687 pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
688 #[cfg_attr(target_os = "aix", link_name = "vec_calloc")]
689 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
690 #[cfg_attr(target_os = "aix", link_name = "vec_malloc")]
691 pub fn malloc(size: size_t) -> *mut c_void;
692 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
693 pub fn free(p: *mut c_void);
694 pub fn abort() -> !;
695 pub fn exit(status: c_int) -> !;
696 pub fn _exit(status: c_int) -> !;
697 #[cfg_attr(
698 all(target_os = "macos", target_arch = "x86"),
699 link_name = "system$UNIX2003"
700 )]
701 pub fn system(s: *const c_char) -> c_int;
702 pub fn getenv(s: *const c_char) -> *mut c_char;
703
704 pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
705 pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
706 pub fn stpcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
707 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
708 pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
709 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
710 pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
711 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
712 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
713 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
714 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
715 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
716 pub fn strdup(cs: *const c_char) -> *mut c_char;
717 pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char;
718 pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
719 pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
720 pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
721 pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
722 pub fn strlen(cs: *const c_char) -> size_t;
723 pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
724 #[cfg_attr(
725 all(target_os = "macos", target_arch = "x86"),
726 link_name = "strerror$UNIX2003"
727 )]
728 pub fn strerror(n: c_int) -> *mut c_char;
729 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
730 pub fn strtok_r(s: *mut c_char, t: *const c_char, p: *mut *mut c_char) -> *mut c_char;
731 pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
732 pub fn strsignal(sig: c_int) -> *mut c_char;
733 pub fn wcslen(buf: *const wchar_t) -> size_t;
734 pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t;
735
736 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
737 pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
738 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
739 pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
740 pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
741 pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
742 pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void;
743}
744
745extern "C" {
746 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
747 pub fn getpwnam(name: *const c_char) -> *mut passwd;
748 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
749 pub fn getpwuid(uid: crate::uid_t) -> *mut passwd;
750
751 pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int;
752 pub fn printf(format: *const c_char, ...) -> c_int;
753 pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int;
754 pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int;
755 #[cfg_attr(
756 all(target_os = "linux", not(target_env = "uclibc")),
757 link_name = "__isoc99_fscanf"
758 )]
759 pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int;
760 #[cfg_attr(
761 all(target_os = "linux", not(target_env = "uclibc")),
762 link_name = "__isoc99_scanf"
763 )]
764 pub fn scanf(format: *const c_char, ...) -> c_int;
765 #[cfg_attr(
766 all(target_os = "linux", not(target_env = "uclibc")),
767 link_name = "__isoc99_sscanf"
768 )]
769 pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int;
770 pub fn getchar_unlocked() -> c_int;
771 pub fn putchar_unlocked(c: c_int) -> c_int;
772
773 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
774 #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
775 #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
776 #[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")]
777 #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
778 pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
779 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
780 #[cfg_attr(
781 all(target_os = "macos", target_arch = "x86"),
782 link_name = "connect$UNIX2003"
783 )]
784 #[cfg_attr(
785 any(target_os = "illumos", target_os = "solaris"),
786 link_name = "__xnet_connect"
787 )]
788 #[cfg_attr(target_os = "espidf", link_name = "lwip_connect")]
789 pub fn connect(socket: c_int, address: *const sockaddr, len: socklen_t) -> c_int;
790 #[cfg_attr(
791 all(target_os = "macos", target_arch = "x86"),
792 link_name = "listen$UNIX2003"
793 )]
794 #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")]
795 pub fn listen(socket: c_int, backlog: c_int) -> c_int;
796 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
797 #[cfg_attr(
798 all(target_os = "macos", target_arch = "x86"),
799 link_name = "accept$UNIX2003"
800 )]
801 #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")]
802 #[cfg_attr(target_os = "aix", link_name = "naccept")]
803 pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int;
804 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
805 #[cfg_attr(
806 all(target_os = "macos", target_arch = "x86"),
807 link_name = "getpeername$UNIX2003"
808 )]
809 #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")]
810 #[cfg_attr(target_os = "aix", link_name = "ngetpeername")]
811 pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t)
812 -> c_int;
813 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
814 #[cfg_attr(
815 all(target_os = "macos", target_arch = "x86"),
816 link_name = "getsockname$UNIX2003"
817 )]
818 #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")]
819 #[cfg_attr(target_os = "aix", link_name = "ngetsockname")]
820 pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t)
821 -> c_int;
822 #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")]
823 #[cfg_attr(gnu_time_bits64, link_name = "__setsockopt64")]
824 pub fn setsockopt(
825 socket: c_int,
826 level: c_int,
827 name: c_int,
828 value: *const c_void,
829 option_len: socklen_t,
830 ) -> c_int;
831 #[cfg_attr(
832 all(target_os = "macos", target_arch = "x86"),
833 link_name = "socketpair$UNIX2003"
834 )]
835 #[cfg_attr(
836 any(target_os = "illumos", target_os = "solaris"),
837 link_name = "__xnet_socketpair"
838 )]
839 pub fn socketpair(
840 domain: c_int,
841 type_: c_int,
842 protocol: c_int,
843 socket_vector: *mut c_int,
844 ) -> c_int;
845 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
846 #[cfg_attr(
847 all(target_os = "macos", target_arch = "x86"),
848 link_name = "sendto$UNIX2003"
849 )]
850 #[cfg_attr(
851 any(target_os = "illumos", target_os = "solaris"),
852 link_name = "__xnet_sendto"
853 )]
854 #[cfg_attr(target_os = "espidf", link_name = "lwip_sendto")]
855 pub fn sendto(
856 socket: c_int,
857 buf: *const c_void,
858 len: size_t,
859 flags: c_int,
860 addr: *const sockaddr,
861 addrlen: socklen_t,
862 ) -> ssize_t;
863 #[cfg_attr(target_os = "espidf", link_name = "lwip_shutdown")]
864 pub fn shutdown(socket: c_int, how: c_int) -> c_int;
865
866 #[cfg_attr(
867 all(target_os = "macos", target_arch = "x86"),
868 link_name = "chmod$UNIX2003"
869 )]
870 pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
871 #[cfg_attr(
872 all(target_os = "macos", target_arch = "x86"),
873 link_name = "fchmod$UNIX2003"
874 )]
875 pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
876
877 #[cfg_attr(
878 all(target_os = "macos", not(target_arch = "aarch64")),
879 link_name = "fstat$INODE64"
880 )]
881 #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
882 #[cfg_attr(
883 all(target_os = "freebsd", any(freebsd11, freebsd10)),
884 link_name = "fstat@FBSD_1.0"
885 )]
886 #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")]
887 #[cfg_attr(
888 all(not(gnu_time_bits64), gnu_file_offset_bits64),
889 link_name = "fstat64"
890 )]
891 #[cfg_attr(musl32_time64, link_name = "__fstat_time64")]
892 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
893
894 pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
895
896 #[cfg_attr(
897 all(target_os = "macos", not(target_arch = "aarch64")),
898 link_name = "stat$INODE64"
899 )]
900 #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
901 #[cfg_attr(
902 all(target_os = "freebsd", any(freebsd11, freebsd10)),
903 link_name = "stat@FBSD_1.0"
904 )]
905 #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")]
906 #[cfg_attr(
907 all(not(gnu_time_bits64), gnu_file_offset_bits64),
908 link_name = "stat64"
909 )]
910 #[cfg_attr(musl32_time64, link_name = "__stat_time64")]
911 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
912
913 pub fn pclose(stream: *mut crate::FILE) -> c_int;
914 #[cfg_attr(
915 all(target_os = "macos", target_arch = "x86"),
916 link_name = "fdopen$UNIX2003"
917 )]
918 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE;
919 pub fn fileno(stream: *mut crate::FILE) -> c_int;
920
921 #[cfg_attr(
922 all(target_os = "macos", target_arch = "x86"),
923 link_name = "open$UNIX2003"
924 )]
925 #[cfg_attr(gnu_file_offset_bits64, link_name = "open64")]
926 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
927 #[cfg_attr(
928 all(target_os = "macos", target_arch = "x86"),
929 link_name = "creat$UNIX2003"
930 )]
931 #[cfg_attr(gnu_file_offset_bits64, link_name = "creat64")]
932 pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
933 #[cfg_attr(
934 all(target_os = "macos", target_arch = "x86"),
935 link_name = "fcntl$UNIX2003"
936 )]
937 #[cfg_attr(gnu_time_bits64, link_name = "__fcntl_time64")]
938 #[cfg_attr(
939 all(not(gnu_time_bits64), gnu_file_offset_bits64),
940 link_name = "__fcntl_time64"
941 )]
942 pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
943
944 #[cfg_attr(
945 all(target_os = "macos", target_arch = "x86_64"),
946 link_name = "opendir$INODE64"
947 )]
948 #[cfg_attr(
949 all(target_os = "macos", target_arch = "x86"),
950 link_name = "opendir$INODE64$UNIX2003"
951 )]
952 #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
953 pub fn opendir(dirname: *const c_char) -> *mut crate::DIR;
954
955 #[cfg_attr(
956 all(target_os = "macos", not(target_arch = "aarch64")),
957 link_name = "readdir$INODE64"
958 )]
959 #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
960 #[cfg_attr(
961 all(target_os = "freebsd", any(freebsd11, freebsd10)),
962 link_name = "readdir@FBSD_1.0"
963 )]
964 #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64")]
965 pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent;
966 #[cfg_attr(
967 all(target_os = "macos", target_arch = "x86"),
968 link_name = "closedir$UNIX2003"
969 )]
970 pub fn closedir(dirp: *mut crate::DIR) -> c_int;
971 #[cfg_attr(
972 all(target_os = "macos", target_arch = "x86_64"),
973 link_name = "rewinddir$INODE64"
974 )]
975 #[cfg_attr(
976 all(target_os = "macos", target_arch = "x86"),
977 link_name = "rewinddir$INODE64$UNIX2003"
978 )]
979 pub fn rewinddir(dirp: *mut crate::DIR);
980
981 pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int;
982 pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
983 #[cfg(not(target_os = "l4re"))]
984 pub fn fchownat(
985 dirfd: c_int,
986 pathname: *const c_char,
987 owner: crate::uid_t,
988 group: crate::gid_t,
989 flags: c_int,
990 ) -> c_int;
991 #[cfg_attr(
992 all(target_os = "macos", not(target_arch = "aarch64")),
993 link_name = "fstatat$INODE64"
994 )]
995 #[cfg_attr(
996 all(target_os = "freebsd", any(freebsd11, freebsd10)),
997 link_name = "fstatat@FBSD_1.1"
998 )]
999 #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")]
1000 #[cfg_attr(
1001 all(not(gnu_time_bits64), gnu_file_offset_bits64),
1002 link_name = "fstatat64"
1003 )]
1004 #[cfg(not(target_os = "l4re"))]
1005 #[cfg_attr(musl32_time64, link_name = "__fstatat_time64")]
1006 pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int;
1007 #[cfg(not(target_os = "l4re"))]
1008 pub fn linkat(
1009 olddirfd: c_int,
1010 oldpath: *const c_char,
1011 newdirfd: c_int,
1012 newpath: *const c_char,
1013 flags: c_int,
1014 ) -> c_int;
1015 #[cfg(not(target_os = "l4re"))]
1016 pub fn renameat(
1017 olddirfd: c_int,
1018 oldpath: *const c_char,
1019 newdirfd: c_int,
1020 newpath: *const c_char,
1021 ) -> c_int;
1022 #[cfg(not(target_os = "l4re"))]
1023 pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int;
1024 #[cfg(not(target_os = "l4re"))]
1025 pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int;
1026
1027 pub fn access(path: *const c_char, amode: c_int) -> c_int;
1028 pub fn alarm(seconds: c_uint) -> c_uint;
1029 pub fn chdir(dir: *const c_char) -> c_int;
1030 pub fn fchdir(dirfd: c_int) -> c_int;
1031 pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int;
1032 #[cfg_attr(
1033 all(target_os = "macos", target_arch = "x86"),
1034 link_name = "lchown$UNIX2003"
1035 )]
1036 pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int;
1037 #[cfg_attr(
1038 all(target_os = "macos", target_arch = "x86"),
1039 link_name = "close$NOCANCEL$UNIX2003"
1040 )]
1041 #[cfg_attr(
1042 all(target_os = "macos", target_arch = "x86_64"),
1043 link_name = "close$NOCANCEL"
1044 )]
1045 pub fn close(fd: c_int) -> c_int;
1046 pub fn dup(fd: c_int) -> c_int;
1047 pub fn dup2(src: c_int, dst: c_int) -> c_int;
1048
1049 pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int;
1050 pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int;
1051 pub fn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int;
1052
1053 pub fn execv(prog: *const c_char, argv: *const *const c_char) -> c_int;
1055 pub fn execve(
1056 prog: *const c_char,
1057 argv: *const *const c_char,
1058 envp: *const *const c_char,
1059 ) -> c_int;
1060 pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int;
1061
1062 pub fn fork() -> pid_t;
1063 pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
1064 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
1065 pub fn getegid() -> gid_t;
1066 pub fn geteuid() -> uid_t;
1067 pub fn getgid() -> gid_t;
1068 pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int;
1069 #[cfg_attr(target_os = "illumos", link_name = "getloginx")]
1070 pub fn getlogin() -> *mut c_char;
1071 #[cfg_attr(
1072 all(target_os = "macos", target_arch = "x86"),
1073 link_name = "getopt$UNIX2003"
1074 )]
1075 pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int;
1076 pub fn getpgid(pid: pid_t) -> pid_t;
1077 pub fn getpgrp() -> pid_t;
1078 pub fn getpid() -> pid_t;
1079 pub fn getppid() -> pid_t;
1080 pub fn getuid() -> uid_t;
1081 pub fn isatty(fd: c_int) -> c_int;
1082 #[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")]
1083 pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
1084 #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")]
1085 pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
1086 pub fn pathconf(path: *const c_char, name: c_int) -> c_long;
1087 pub fn pipe(fds: *mut c_int) -> c_int;
1088 pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int;
1089 pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void;
1090 #[cfg_attr(
1091 all(target_os = "macos", target_arch = "x86"),
1092 link_name = "read$UNIX2003"
1093 )]
1094 pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t;
1095 pub fn rmdir(path: *const c_char) -> c_int;
1096 pub fn seteuid(uid: uid_t) -> c_int;
1097 pub fn setegid(gid: gid_t) -> c_int;
1098 pub fn setgid(gid: gid_t) -> c_int;
1099 pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
1100 pub fn setsid() -> pid_t;
1101 pub fn setuid(uid: uid_t) -> c_int;
1102 pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int;
1103 pub fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
1104 #[cfg_attr(
1105 all(target_os = "macos", target_arch = "x86"),
1106 link_name = "sleep$UNIX2003"
1107 )]
1108 pub fn sleep(secs: c_uint) -> c_uint;
1109 #[cfg_attr(
1110 all(target_os = "macos", target_arch = "x86"),
1111 link_name = "nanosleep$UNIX2003"
1112 )]
1113 #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
1114 #[cfg_attr(gnu_time_bits64, link_name = "__nanosleep64")]
1115 #[cfg_attr(musl32_time64, link_name = "__nanosleep_time64")]
1116 pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int;
1117 pub fn tcgetpgrp(fd: c_int) -> pid_t;
1118 pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int;
1119 pub fn ttyname(fd: c_int) -> *mut c_char;
1120 #[cfg_attr(
1121 all(target_os = "macos", target_arch = "x86"),
1122 link_name = "ttyname_r$UNIX2003"
1123 )]
1124 #[cfg_attr(
1125 any(target_os = "illumos", target_os = "solaris"),
1126 link_name = "__posix_ttyname_r"
1127 )]
1128 pub fn ttyname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
1129 pub fn unlink(c: *const c_char) -> c_int;
1130 #[cfg_attr(
1131 all(target_os = "macos", target_arch = "x86"),
1132 link_name = "wait$UNIX2003"
1133 )]
1134 pub fn wait(status: *mut c_int) -> pid_t;
1135 #[cfg_attr(
1136 all(target_os = "macos", target_arch = "x86"),
1137 link_name = "waitpid$UNIX2003"
1138 )]
1139 pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t;
1140 #[cfg_attr(
1141 all(target_os = "macos", target_arch = "x86"),
1142 link_name = "write$UNIX2003"
1143 )]
1144 pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t;
1145 #[cfg_attr(
1146 all(target_os = "macos", target_arch = "x86"),
1147 link_name = "pread$UNIX2003"
1148 )]
1149 #[cfg_attr(gnu_file_offset_bits64, link_name = "pread64")]
1150 pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t;
1151 #[cfg_attr(
1152 all(target_os = "macos", target_arch = "x86"),
1153 link_name = "pwrite$UNIX2003"
1154 )]
1155 #[cfg_attr(gnu_file_offset_bits64, link_name = "pwrite64")]
1156 pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t;
1157 pub fn umask(mask: mode_t) -> mode_t;
1158
1159 #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
1160 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__utime64")]
1161 pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
1162
1163 #[cfg_attr(
1164 all(target_os = "macos", target_arch = "x86"),
1165 link_name = "kill$UNIX2003"
1166 )]
1167 pub fn kill(pid: pid_t, sig: c_int) -> c_int;
1168 #[cfg_attr(
1169 all(target_os = "macos", target_arch = "x86"),
1170 link_name = "killpg$UNIX2003"
1171 )]
1172 pub fn killpg(pgrp: pid_t, sig: c_int) -> c_int;
1173
1174 pub fn mlock(addr: *const c_void, len: size_t) -> c_int;
1175 pub fn munlock(addr: *const c_void, len: size_t) -> c_int;
1176 pub fn mlockall(flags: c_int) -> c_int;
1177 pub fn munlockall() -> c_int;
1178
1179 #[cfg_attr(
1180 all(target_os = "macos", target_arch = "x86"),
1181 link_name = "mmap$UNIX2003"
1182 )]
1183 #[cfg_attr(gnu_file_offset_bits64, link_name = "mmap64")]
1184 pub fn mmap(
1185 addr: *mut c_void,
1186 len: size_t,
1187 prot: c_int,
1188 flags: c_int,
1189 fd: c_int,
1190 offset: off_t,
1191 ) -> *mut c_void;
1192 #[cfg_attr(
1193 all(target_os = "macos", target_arch = "x86"),
1194 link_name = "munmap$UNIX2003"
1195 )]
1196 pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
1197
1198 pub fn if_nametoindex(ifname: *const c_char) -> c_uint;
1199 pub fn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char;
1200
1201 #[cfg_attr(
1202 all(target_os = "macos", not(target_arch = "aarch64")),
1203 link_name = "lstat$INODE64"
1204 )]
1205 #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
1206 #[cfg_attr(
1207 all(target_os = "freebsd", any(freebsd11, freebsd10)),
1208 link_name = "lstat@FBSD_1.0"
1209 )]
1210 #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")]
1211 #[cfg_attr(
1212 all(not(gnu_time_bits64), gnu_file_offset_bits64),
1213 link_name = "lstat64"
1214 )]
1215 #[cfg_attr(musl32_time64, link_name = "__lstat_time64")]
1216 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
1217
1218 #[cfg_attr(
1219 all(target_os = "macos", target_arch = "x86"),
1220 link_name = "fsync$UNIX2003"
1221 )]
1222 pub fn fsync(fd: c_int) -> c_int;
1223
1224 #[cfg_attr(
1225 all(target_os = "macos", target_arch = "x86"),
1226 link_name = "setenv$UNIX2003"
1227 )]
1228 pub fn setenv(name: *const c_char, val: *const c_char, overwrite: c_int) -> c_int;
1229 #[cfg_attr(
1230 all(target_os = "macos", target_arch = "x86"),
1231 link_name = "unsetenv$UNIX2003"
1232 )]
1233 #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
1234 pub fn unsetenv(name: *const c_char) -> c_int;
1235
1236 pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int;
1237
1238 #[cfg_attr(gnu_file_offset_bits64, link_name = "truncate64")]
1239 pub fn truncate(path: *const c_char, length: off_t) -> c_int;
1240 #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")]
1241 pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
1242
1243 pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
1244
1245 #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
1246 #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")]
1247 #[cfg_attr(musl32_time64, link_name = "__getrusage_time64")]
1248 pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int;
1249
1250 #[cfg_attr(
1251 any(
1252 target_os = "macos",
1253 target_os = "ios",
1254 target_os = "tvos",
1255 target_os = "watchos",
1256 target_os = "visionos"
1257 ),
1258 link_name = "realpath$DARWIN_EXTSN"
1259 )]
1260 pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char;
1261
1262 #[cfg_attr(target_os = "netbsd", link_name = "__times13")]
1263 pub fn times(buf: *mut crate::tms) -> crate::clock_t;
1264
1265 pub fn pthread_self() -> crate::pthread_t;
1266 pub fn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int;
1267 #[cfg_attr(
1268 all(target_os = "macos", target_arch = "x86"),
1269 link_name = "pthread_join$UNIX2003"
1270 )]
1271 pub fn pthread_join(native: crate::pthread_t, value: *mut *mut c_void) -> c_int;
1272 pub fn pthread_exit(value: *mut c_void) -> !;
1273 pub fn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int;
1274 pub fn pthread_attr_destroy(attr: *mut crate::pthread_attr_t) -> c_int;
1275 pub fn pthread_attr_getstacksize(
1276 attr: *const crate::pthread_attr_t,
1277 stacksize: *mut size_t,
1278 ) -> c_int;
1279 pub fn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stack_size: size_t)
1280 -> c_int;
1281 pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int;
1282 pub fn pthread_detach(thread: crate::pthread_t) -> c_int;
1283 #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
1284 pub fn sched_yield() -> c_int;
1285 pub fn pthread_key_create(
1286 key: *mut crate::pthread_key_t,
1287 dtor: Option<unsafe extern "C" fn(*mut c_void)>,
1288 ) -> c_int;
1289 pub fn pthread_key_delete(key: crate::pthread_key_t) -> c_int;
1290 pub fn pthread_getspecific(key: crate::pthread_key_t) -> *mut c_void;
1291 pub fn pthread_setspecific(key: crate::pthread_key_t, value: *const c_void) -> c_int;
1292 pub fn pthread_mutex_init(
1293 lock: *mut crate::pthread_mutex_t,
1294 attr: *const crate::pthread_mutexattr_t,
1295 ) -> c_int;
1296 pub fn pthread_mutex_destroy(lock: *mut crate::pthread_mutex_t) -> c_int;
1297 pub fn pthread_mutex_lock(lock: *mut crate::pthread_mutex_t) -> c_int;
1298 pub fn pthread_mutex_trylock(lock: *mut crate::pthread_mutex_t) -> c_int;
1299 pub fn pthread_mutex_unlock(lock: *mut crate::pthread_mutex_t) -> c_int;
1300
1301 pub fn pthread_mutexattr_init(attr: *mut crate::pthread_mutexattr_t) -> c_int;
1302 #[cfg_attr(
1303 all(target_os = "macos", target_arch = "x86"),
1304 link_name = "pthread_mutexattr_destroy$UNIX2003"
1305 )]
1306 pub fn pthread_mutexattr_destroy(attr: *mut crate::pthread_mutexattr_t) -> c_int;
1307 pub fn pthread_mutexattr_settype(attr: *mut crate::pthread_mutexattr_t, _type: c_int) -> c_int;
1308
1309 #[cfg_attr(
1310 all(target_os = "macos", target_arch = "x86"),
1311 link_name = "pthread_cond_init$UNIX2003"
1312 )]
1313 pub fn pthread_cond_init(
1314 cond: *mut crate::pthread_cond_t,
1315 attr: *const crate::pthread_condattr_t,
1316 ) -> c_int;
1317 #[cfg_attr(
1318 all(target_os = "macos", target_arch = "x86"),
1319 link_name = "pthread_cond_wait$UNIX2003"
1320 )]
1321 pub fn pthread_cond_wait(
1322 cond: *mut crate::pthread_cond_t,
1323 lock: *mut crate::pthread_mutex_t,
1324 ) -> c_int;
1325 #[cfg_attr(
1326 all(target_os = "macos", target_arch = "x86"),
1327 link_name = "pthread_cond_timedwait$UNIX2003"
1328 )]
1329 #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")]
1330 #[cfg_attr(musl32_time64, link_name = "__pthread_cond_timedwait_time64")]
1331 pub fn pthread_cond_timedwait(
1332 cond: *mut crate::pthread_cond_t,
1333 lock: *mut crate::pthread_mutex_t,
1334 abstime: *const crate::timespec,
1335 ) -> c_int;
1336 pub fn pthread_cond_signal(cond: *mut crate::pthread_cond_t) -> c_int;
1337 pub fn pthread_cond_broadcast(cond: *mut crate::pthread_cond_t) -> c_int;
1338 pub fn pthread_cond_destroy(cond: *mut crate::pthread_cond_t) -> c_int;
1339 pub fn pthread_condattr_init(attr: *mut crate::pthread_condattr_t) -> c_int;
1340 pub fn pthread_condattr_destroy(attr: *mut crate::pthread_condattr_t) -> c_int;
1341 #[cfg_attr(
1342 all(target_os = "macos", target_arch = "x86"),
1343 link_name = "pthread_rwlock_init$UNIX2003"
1344 )]
1345 pub fn pthread_rwlock_init(
1346 lock: *mut crate::pthread_rwlock_t,
1347 attr: *const crate::pthread_rwlockattr_t,
1348 ) -> c_int;
1349 #[cfg_attr(
1350 all(target_os = "macos", target_arch = "x86"),
1351 link_name = "pthread_rwlock_destroy$UNIX2003"
1352 )]
1353 pub fn pthread_rwlock_destroy(lock: *mut crate::pthread_rwlock_t) -> c_int;
1354 #[cfg_attr(
1355 all(target_os = "macos", target_arch = "x86"),
1356 link_name = "pthread_rwlock_rdlock$UNIX2003"
1357 )]
1358 pub fn pthread_rwlock_rdlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1359 #[cfg_attr(
1360 all(target_os = "macos", target_arch = "x86"),
1361 link_name = "pthread_rwlock_tryrdlock$UNIX2003"
1362 )]
1363 pub fn pthread_rwlock_tryrdlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1364 #[cfg_attr(
1365 all(target_os = "macos", target_arch = "x86"),
1366 link_name = "pthread_rwlock_wrlock$UNIX2003"
1367 )]
1368 pub fn pthread_rwlock_wrlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1369 #[cfg_attr(
1370 all(target_os = "macos", target_arch = "x86"),
1371 link_name = "pthread_rwlock_trywrlock$UNIX2003"
1372 )]
1373 pub fn pthread_rwlock_trywrlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1374 #[cfg_attr(
1375 all(target_os = "macos", target_arch = "x86"),
1376 link_name = "pthread_rwlock_unlock$UNIX2003"
1377 )]
1378 pub fn pthread_rwlock_unlock(lock: *mut crate::pthread_rwlock_t) -> c_int;
1379 pub fn pthread_rwlockattr_init(attr: *mut crate::pthread_rwlockattr_t) -> c_int;
1380 pub fn pthread_rwlockattr_destroy(attr: *mut crate::pthread_rwlockattr_t) -> c_int;
1381
1382 #[cfg_attr(
1383 any(target_os = "illumos", target_os = "solaris"),
1384 link_name = "__xnet_getsockopt"
1385 )]
1386 #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")]
1387 #[cfg_attr(gnu_time_bits64, link_name = "__getsockopt64")]
1388 pub fn getsockopt(
1389 sockfd: c_int,
1390 level: c_int,
1391 optname: c_int,
1392 optval: *mut c_void,
1393 optlen: *mut crate::socklen_t,
1394 ) -> c_int;
1395 pub fn raise(signum: c_int) -> c_int;
1396
1397 #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
1398 #[cfg_attr(gnu_time_bits64, link_name = "__utimes64")]
1399 #[cfg_attr(musl32_time64, link_name = "__utimes_time64")]
1400 pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int;
1401 pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
1402 pub fn dlerror() -> *mut c_char;
1403 #[cfg_attr(musl32_time64, link_name = "__dlsym_time64")]
1404 pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
1405 pub fn dlclose(handle: *mut c_void) -> c_int;
1406
1407 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
1408 #[cfg_attr(
1409 any(target_os = "illumos", target_os = "solaris"),
1410 link_name = "__xnet_getaddrinfo"
1411 )]
1412 #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")]
1413 pub fn getaddrinfo(
1414 node: *const c_char,
1415 service: *const c_char,
1416 hints: *const addrinfo,
1417 res: *mut *mut addrinfo,
1418 ) -> c_int;
1419 #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
1420 #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")]
1421 pub fn freeaddrinfo(res: *mut addrinfo);
1422 pub fn hstrerror(errcode: c_int) -> *const c_char;
1423 pub fn gai_strerror(errcode: c_int) -> *const c_char;
1424 #[cfg_attr(
1425 any(
1426 all(
1427 target_os = "linux",
1428 not(any(target_env = "musl", target_env = "ohos"))
1429 ),
1430 target_os = "freebsd",
1431 target_os = "cygwin",
1432 target_os = "dragonfly",
1433 target_os = "haiku"
1434 ),
1435 link_name = "__res_init"
1436 )]
1437 #[cfg_attr(
1438 any(
1439 target_os = "macos",
1440 target_os = "ios",
1441 target_os = "tvos",
1442 target_os = "watchos",
1443 target_os = "visionos"
1444 ),
1445 link_name = "res_9_init"
1446 )]
1447 #[cfg_attr(target_os = "aix", link_name = "_res_init")]
1448 #[cfg(not(target_os = "l4re"))]
1449 pub fn res_init() -> c_int;
1450
1451 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
1452 #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64_r")]
1453 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1454 #[cfg_attr(musl32_time64, link_name = "__gmtime64_r")]
1455 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1456 #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
1457 #[cfg_attr(gnu_time_bits64, link_name = "__localtime64_r")]
1458 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1459 #[cfg_attr(musl32_time64, link_name = "__localtime64_r")]
1460 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1461 #[cfg_attr(
1462 all(target_os = "macos", target_arch = "x86"),
1463 link_name = "mktime$UNIX2003"
1464 )]
1465 #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
1466 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__mktime64")]
1467 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1468 pub fn mktime(tm: *mut tm) -> time_t;
1469 #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
1470 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__time64")]
1471 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1472 pub fn time(time: *mut time_t) -> time_t;
1473 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
1474 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__gmtime64")]
1475 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1476 pub fn gmtime(time_p: *const time_t) -> *mut tm;
1477 #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
1478 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__localtime64")]
1479 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1480 pub fn localtime(time_p: *const time_t) -> *mut tm;
1481 #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
1482 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__difftime64")]
1483 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1484 pub fn difftime(time1: time_t, time0: time_t) -> c_double;
1485 #[cfg(not(target_os = "aix"))]
1486 #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
1487 #[cfg_attr(gnu_time_bits64, link_name = "__timegm64")]
1488 #[cfg_attr(not(musl32_time64), allow(deprecated))]
1489 #[cfg_attr(musl32_time64, link_name = "__timegm_time64")]
1490 pub fn timegm(tm: *mut crate::tm) -> time_t;
1491
1492 #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
1493 #[cfg_attr(
1494 all(target_os = "freebsd", any(freebsd11, freebsd10)),
1495 link_name = "mknod@FBSD_1.0"
1496 )]
1497 pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int;
1498 #[cfg(not(target_os = "espidf"))]
1499 pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
1500 pub fn endservent();
1501 pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent;
1502 pub fn getservbyport(port: c_int, proto: *const c_char) -> *mut servent;
1503 pub fn getservent() -> *mut servent;
1504 pub fn setservent(stayopen: c_int);
1505 pub fn getprotobyname(name: *const c_char) -> *mut protoent;
1506 pub fn getprotobynumber(proto: c_int) -> *mut protoent;
1507 pub fn chroot(name: *const c_char) -> c_int;
1508 #[cfg(target_os = "cygwin")]
1509 pub fn usleep(secs: useconds_t) -> c_int;
1510 #[cfg_attr(
1511 all(target_os = "macos", target_arch = "x86"),
1512 link_name = "usleep$UNIX2003"
1513 )]
1514 #[cfg(not(target_os = "cygwin"))]
1515 pub fn usleep(secs: c_uint) -> c_int;
1516 #[cfg_attr(
1517 all(target_os = "macos", target_arch = "x86"),
1518 link_name = "send$UNIX2003"
1519 )]
1520 #[cfg_attr(target_os = "espidf", link_name = "lwip_send")]
1521 pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t;
1522 #[cfg_attr(
1523 all(target_os = "macos", target_arch = "x86"),
1524 link_name = "recv$UNIX2003"
1525 )]
1526 #[cfg_attr(target_os = "espidf", link_name = "lwip_recv")]
1527 pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t;
1528 #[cfg_attr(
1529 all(target_os = "macos", target_arch = "x86"),
1530 link_name = "putenv$UNIX2003"
1531 )]
1532 #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
1533 pub fn putenv(string: *mut c_char) -> c_int;
1534 #[cfg_attr(
1535 all(target_os = "macos", target_arch = "x86"),
1536 link_name = "poll$UNIX2003"
1537 )]
1538 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int;
1539 #[cfg_attr(
1540 all(target_os = "macos", target_arch = "x86_64"),
1541 link_name = "select$1050"
1542 )]
1543 #[cfg_attr(
1544 all(target_os = "macos", target_arch = "x86"),
1545 link_name = "select$UNIX2003"
1546 )]
1547 #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
1548 #[cfg_attr(target_os = "aix", link_name = "__fd_select")]
1549 #[cfg_attr(gnu_time_bits64, link_name = "__select64")]
1550 #[cfg_attr(musl32_time64, link_name = "__select_time64")]
1551 pub fn select(
1552 nfds: c_int,
1553 readfds: *mut fd_set,
1554 writefds: *mut fd_set,
1555 errorfds: *mut fd_set,
1556 timeout: *mut timeval,
1557 ) -> c_int;
1558 #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
1559 pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char;
1560 pub fn localeconv() -> *mut lconv;
1561
1562 #[cfg_attr(
1563 all(target_os = "macos", target_arch = "x86"),
1564 link_name = "sem_wait$UNIX2003"
1565 )]
1566 pub fn sem_wait(sem: *mut sem_t) -> c_int;
1567 pub fn sem_trywait(sem: *mut sem_t) -> c_int;
1568 pub fn sem_post(sem: *mut sem_t) -> c_int;
1569 #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")]
1570 pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int;
1571 #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")]
1572 pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int;
1573
1574 #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
1575 pub fn sigemptyset(set: *mut sigset_t) -> c_int;
1576 #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
1577 pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int;
1578 #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
1579 pub fn sigfillset(set: *mut sigset_t) -> c_int;
1580 #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
1581 pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int;
1582 #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
1583 pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int;
1584
1585 #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
1586 pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
1587 #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
1588 pub fn sigpending(set: *mut sigset_t) -> c_int;
1589
1590 #[cfg_attr(target_os = "solaris", link_name = "__sysconf_xpg7")]
1591 pub fn sysconf(name: c_int) -> c_long;
1592
1593 pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
1594
1595 #[cfg_attr(gnu_file_offset_bits64, link_name = "fseeko64")]
1596 pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int;
1597 #[cfg_attr(gnu_file_offset_bits64, link_name = "ftello64")]
1598 pub fn ftello(stream: *mut crate::FILE) -> off_t;
1599 #[cfg_attr(
1600 all(target_os = "macos", target_arch = "x86"),
1601 link_name = "tcdrain$UNIX2003"
1602 )]
1603 pub fn tcdrain(fd: c_int) -> c_int;
1604 #[cfg_attr(
1605 all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1606 link_name = "cfgetispeed@GLIBC_2.4"
1607 )]
1608 #[cfg_attr(
1609 all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1610 link_name = "cfgetispeed@GLIBC_2.29"
1611 )]
1612 #[cfg_attr(
1613 all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1614 link_name = "cfgetispeed@GLIBC_2.0"
1615 )]
1616 #[cfg_attr(
1617 all(
1618 target_os = "linux",
1619 target_env = "gnu",
1620 any(target_arch = "mips", target_arch = "mips32r6")
1621 ),
1622 link_name = "cfgetispeed@GLIBC_2.0"
1623 )]
1624 #[cfg_attr(
1625 all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1626 link_name = "cfgetispeed@GLIBC_2.0"
1627 )]
1628 #[cfg_attr(
1629 all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1630 link_name = "cfgetispeed@GLIBC_2.33"
1631 )]
1632 #[cfg_attr(
1633 all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1634 link_name = "cfgetispeed@GLIBC_2.0"
1635 )]
1636 #[cfg_attr(
1637 all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1638 link_name = "cfgetispeed@GLIBC_2.0"
1639 )]
1640 #[cfg_attr(
1641 all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1642 link_name = "cfgetispeed@GLIBC_2.17"
1643 )]
1644 #[cfg_attr(
1645 all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1646 link_name = "cfgetispeed@GLIBC_2.36"
1647 )]
1648 #[cfg_attr(
1649 all(
1650 target_os = "linux",
1651 target_env = "gnu",
1652 any(target_arch = "mips64", target_arch = "mips64r6")
1653 ),
1654 link_name = "cfgetispeed@GLIBC_2.0"
1655 )]
1656 #[cfg_attr(
1657 all(
1658 target_os = "linux",
1659 target_env = "gnu",
1660 target_arch = "powerpc64",
1661 target_endian = "big"
1662 ),
1663 link_name = "cfgetispeed@GLIBC_2.3"
1664 )]
1665 #[cfg_attr(
1666 all(
1667 target_os = "linux",
1668 target_env = "gnu",
1669 target_arch = "powerpc64",
1670 target_endian = "little"
1671 ),
1672 link_name = "cfgetispeed@GLIBC_2.17"
1673 )]
1674 #[cfg_attr(
1675 all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1676 link_name = "cfgetispeed@GLIBC_2.27"
1677 )]
1678 #[cfg_attr(
1679 all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1680 link_name = "cfgetispeed@GLIBC_2.2"
1681 )]
1682 #[cfg_attr(
1683 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1684 link_name = "cfgetispeed@GLIBC_2.2"
1685 )]
1686 #[cfg_attr(
1687 all(
1688 target_os = "linux",
1689 target_env = "gnu",
1690 target_arch = "x86_64",
1691 target_pointer_width = "64"
1692 ),
1693 link_name = "cfgetispeed@GLIBC_2.2.5"
1694 )]
1695 #[cfg_attr(
1696 all(
1697 target_os = "linux",
1698 target_env = "gnu",
1699 target_arch = "x86_64",
1700 target_pointer_width = "32"
1701 ),
1702 link_name = "cfgetispeed@GLIBC_2.16"
1703 )]
1704 pub fn cfgetispeed(termios: *const crate::termios) -> crate::speed_t;
1705 #[cfg_attr(
1706 all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1707 link_name = "cfgetospeed@GLIBC_2.4"
1708 )]
1709 #[cfg_attr(
1710 all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1711 link_name = "cfgetospeed@GLIBC_2.29"
1712 )]
1713 #[cfg_attr(
1714 all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1715 link_name = "cfgetospeed@GLIBC_2.0"
1716 )]
1717 #[cfg_attr(
1718 all(
1719 target_os = "linux",
1720 target_env = "gnu",
1721 any(target_arch = "mips", target_arch = "mips32r6")
1722 ),
1723 link_name = "cfgetospeed@GLIBC_2.0"
1724 )]
1725 #[cfg_attr(
1726 all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1727 link_name = "cfgetospeed@GLIBC_2.0"
1728 )]
1729 #[cfg_attr(
1730 all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1731 link_name = "cfgetospeed@GLIBC_2.33"
1732 )]
1733 #[cfg_attr(
1734 all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1735 link_name = "cfgetospeed@GLIBC_2.0"
1736 )]
1737 #[cfg_attr(
1738 all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1739 link_name = "cfgetospeed@GLIBC_2.0"
1740 )]
1741 #[cfg_attr(
1742 all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1743 link_name = "cfgetospeed@GLIBC_2.17"
1744 )]
1745 #[cfg_attr(
1746 all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1747 link_name = "cfgetospeed@GLIBC_2.36"
1748 )]
1749 #[cfg_attr(
1750 all(
1751 target_os = "linux",
1752 target_env = "gnu",
1753 any(target_arch = "mips64", target_arch = "mips64r6")
1754 ),
1755 link_name = "cfgetospeed@GLIBC_2.0"
1756 )]
1757 #[cfg_attr(
1758 all(
1759 target_os = "linux",
1760 target_env = "gnu",
1761 target_arch = "powerpc64",
1762 target_endian = "big"
1763 ),
1764 link_name = "cfgetospeed@GLIBC_2.3"
1765 )]
1766 #[cfg_attr(
1767 all(
1768 target_os = "linux",
1769 target_env = "gnu",
1770 target_arch = "powerpc64",
1771 target_endian = "little"
1772 ),
1773 link_name = "cfgetospeed@GLIBC_2.17"
1774 )]
1775 #[cfg_attr(
1776 all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1777 link_name = "cfgetospeed@GLIBC_2.27"
1778 )]
1779 #[cfg_attr(
1780 all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1781 link_name = "cfgetospeed@GLIBC_2.2"
1782 )]
1783 #[cfg_attr(
1784 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1785 link_name = "cfgetospeed@GLIBC_2.2"
1786 )]
1787 #[cfg_attr(
1788 all(
1789 target_os = "linux",
1790 target_env = "gnu",
1791 target_arch = "x86_64",
1792 target_pointer_width = "64"
1793 ),
1794 link_name = "cfgetospeed@GLIBC_2.2.5"
1795 )]
1796 #[cfg_attr(
1797 all(
1798 target_os = "linux",
1799 target_env = "gnu",
1800 target_arch = "x86_64",
1801 target_pointer_width = "32"
1802 ),
1803 link_name = "cfgetospeed@GLIBC_2.16"
1804 )]
1805 pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t;
1806 #[cfg_attr(
1807 all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1808 link_name = "cfsetispeed@GLIBC_2.4"
1809 )]
1810 #[cfg_attr(
1811 all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1812 link_name = "cfsetispeed@GLIBC_2.29"
1813 )]
1814 #[cfg_attr(
1815 all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1816 link_name = "cfsetispeed@GLIBC_2.0"
1817 )]
1818 #[cfg_attr(
1819 all(
1820 target_os = "linux",
1821 target_env = "gnu",
1822 any(target_arch = "mips", target_arch = "mips32r6")
1823 ),
1824 link_name = "cfsetispeed@GLIBC_2.0"
1825 )]
1826 #[cfg_attr(
1827 all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1828 link_name = "cfsetispeed@GLIBC_2.0"
1829 )]
1830 #[cfg_attr(
1831 all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1832 link_name = "cfsetispeed@GLIBC_2.33"
1833 )]
1834 #[cfg_attr(
1835 all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1836 link_name = "cfsetispeed@GLIBC_2.0"
1837 )]
1838 #[cfg_attr(
1839 all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1840 link_name = "cfsetispeed@GLIBC_2.0"
1841 )]
1842 #[cfg_attr(
1843 all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1844 link_name = "cfsetispeed@GLIBC_2.17"
1845 )]
1846 #[cfg_attr(
1847 all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1848 link_name = "cfsetispeed@GLIBC_2.36"
1849 )]
1850 #[cfg_attr(
1851 all(
1852 target_os = "linux",
1853 target_env = "gnu",
1854 any(target_arch = "mips64", target_arch = "mips64r6")
1855 ),
1856 link_name = "cfsetispeed@GLIBC_2.0"
1857 )]
1858 #[cfg_attr(
1859 all(
1860 target_os = "linux",
1861 target_env = "gnu",
1862 target_arch = "powerpc64",
1863 target_endian = "big"
1864 ),
1865 link_name = "cfsetispeed@GLIBC_2.3"
1866 )]
1867 #[cfg_attr(
1868 all(
1869 target_os = "linux",
1870 target_env = "gnu",
1871 target_arch = "powerpc64",
1872 target_endian = "little"
1873 ),
1874 link_name = "cfsetispeed@GLIBC_2.17"
1875 )]
1876 #[cfg_attr(
1877 all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1878 link_name = "cfsetispeed@GLIBC_2.27"
1879 )]
1880 #[cfg_attr(
1881 all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1882 link_name = "cfsetispeed@GLIBC_2.2"
1883 )]
1884 #[cfg_attr(
1885 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1886 link_name = "cfsetispeed@GLIBC_2.2"
1887 )]
1888 #[cfg_attr(
1889 all(
1890 target_os = "linux",
1891 target_env = "gnu",
1892 target_arch = "x86_64",
1893 target_pointer_width = "64"
1894 ),
1895 link_name = "cfsetispeed@GLIBC_2.2.5"
1896 )]
1897 #[cfg_attr(
1898 all(
1899 target_os = "linux",
1900 target_env = "gnu",
1901 target_arch = "x86_64",
1902 target_pointer_width = "32"
1903 ),
1904 link_name = "cfsetispeed@GLIBC_2.16"
1905 )]
1906 pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
1907 #[cfg_attr(
1908 all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
1909 link_name = "cfsetospeed@GLIBC_2.4"
1910 )]
1911 #[cfg_attr(
1912 all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
1913 link_name = "cfsetospeed@GLIBC_2.29"
1914 )]
1915 #[cfg_attr(
1916 all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
1917 link_name = "cfsetospeed@GLIBC_2.0"
1918 )]
1919 #[cfg_attr(
1920 all(
1921 target_os = "linux",
1922 target_env = "gnu",
1923 any(target_arch = "mips", target_arch = "mips32r6")
1924 ),
1925 link_name = "cfsetospeed@GLIBC_2.0"
1926 )]
1927 #[cfg_attr(
1928 all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
1929 link_name = "cfsetospeed@GLIBC_2.0"
1930 )]
1931 #[cfg_attr(
1932 all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
1933 link_name = "cfsetospeed@GLIBC_2.33"
1934 )]
1935 #[cfg_attr(
1936 all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
1937 link_name = "cfsetospeed@GLIBC_2.0"
1938 )]
1939 #[cfg_attr(
1940 all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
1941 link_name = "cfsetospeed@GLIBC_2.0"
1942 )]
1943 #[cfg_attr(
1944 all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
1945 link_name = "cfsetospeed@GLIBC_2.17"
1946 )]
1947 #[cfg_attr(
1948 all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
1949 link_name = "cfsetospeed@GLIBC_2.36"
1950 )]
1951 #[cfg_attr(
1952 all(
1953 target_os = "linux",
1954 target_env = "gnu",
1955 any(target_arch = "mips64", target_arch = "mips64r6")
1956 ),
1957 link_name = "cfsetospeed@GLIBC_2.0"
1958 )]
1959 #[cfg_attr(
1960 all(
1961 target_os = "linux",
1962 target_env = "gnu",
1963 target_arch = "powerpc64",
1964 target_endian = "big"
1965 ),
1966 link_name = "cfsetospeed@GLIBC_2.3"
1967 )]
1968 #[cfg_attr(
1969 all(
1970 target_os = "linux",
1971 target_env = "gnu",
1972 target_arch = "powerpc64",
1973 target_endian = "little"
1974 ),
1975 link_name = "cfsetospeed@GLIBC_2.17"
1976 )]
1977 #[cfg_attr(
1978 all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
1979 link_name = "cfsetospeed@GLIBC_2.27"
1980 )]
1981 #[cfg_attr(
1982 all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
1983 link_name = "cfsetospeed@GLIBC_2.2"
1984 )]
1985 #[cfg_attr(
1986 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
1987 link_name = "cfsetospeed@GLIBC_2.2"
1988 )]
1989 #[cfg_attr(
1990 all(
1991 target_os = "linux",
1992 target_env = "gnu",
1993 target_arch = "x86_64",
1994 target_pointer_width = "64"
1995 ),
1996 link_name = "cfsetospeed@GLIBC_2.2.5"
1997 )]
1998 #[cfg_attr(
1999 all(
2000 target_os = "linux",
2001 target_env = "gnu",
2002 target_arch = "x86_64",
2003 target_pointer_width = "32"
2004 ),
2005 link_name = "cfsetospeed@GLIBC_2.16"
2006 )]
2007 pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2008 #[cfg_attr(
2009 all(
2010 target_os = "linux",
2011 target_env = "gnu",
2012 any(
2013 target_arch = "mips",
2014 target_arch = "mips32r6",
2015 target_arch = "mips64",
2016 target_arch = "mips64r6",
2017 target_arch = "sparc"
2018 ),
2019 ),
2020 link_name = "tcgetattr@GLIBC_2.0"
2021 )]
2022 #[cfg_attr(
2023 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2024 link_name = "tcgetattr@GLIBC_2.2"
2025 )]
2026 pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int;
2027 #[cfg_attr(
2028 all(
2029 target_os = "linux",
2030 target_env = "gnu",
2031 any(
2032 target_arch = "mips",
2033 target_arch = "mips32r6",
2034 target_arch = "mips64",
2035 target_arch = "mips64r6",
2036 target_arch = "sparc"
2037 ),
2038 ),
2039 link_name = "tcsetattr@GLIBC_2.0"
2040 )]
2041 #[cfg_attr(
2042 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2043 link_name = "tcsetattr@GLIBC_2.2"
2044 )]
2045 pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int;
2046 pub fn tcflow(fd: c_int, action: c_int) -> c_int;
2047 pub fn tcflush(fd: c_int, action: c_int) -> c_int;
2048 pub fn tcgetsid(fd: c_int) -> crate::pid_t;
2049 pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
2050 #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemp64")]
2051 pub fn mkstemp(template: *mut c_char) -> c_int;
2052 pub fn mkdtemp(template: *mut c_char) -> *mut c_char;
2053
2054 pub fn tmpnam(ptr: *mut c_char) -> *mut c_char;
2055
2056 pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int);
2057 pub fn closelog();
2058 pub fn setlogmask(maskpri: c_int) -> c_int;
2059 #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")]
2060 pub fn syslog(priority: c_int, message: *const c_char, ...);
2061 #[cfg_attr(
2062 all(target_os = "macos", target_arch = "x86"),
2063 link_name = "nice$UNIX2003"
2064 )]
2065 pub fn nice(incr: c_int) -> c_int;
2066
2067 #[cfg(not(target_os = "l4re"))]
2068 pub fn grantpt(fd: c_int) -> c_int;
2069 #[cfg(not(target_os = "l4re"))]
2070 pub fn posix_openpt(flags: c_int) -> c_int;
2071 #[cfg(not(target_os = "l4re"))]
2072 pub fn ptsname(fd: c_int) -> *mut c_char;
2073 #[cfg(not(target_os = "l4re"))]
2074 pub fn unlockpt(fd: c_int) -> c_int;
2075
2076 #[cfg(not(target_os = "aix"))]
2077 pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
2078 pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
2079
2080 #[cfg_attr(gnu_file_offset_bits64, link_name = "lockf64")]
2081 pub fn lockf(fd: c_int, cmd: c_int, len: off_t) -> c_int;
2082
2083}
2084
2085safe_f! {
2086 pub const fn htonl(hostlong: u32) -> u32 {
2089 u32::to_be(hostlong)
2090 }
2091 pub const fn htons(hostshort: u16) -> u16 {
2092 u16::to_be(hostshort)
2093 }
2094 pub const fn ntohl(netlong: u32) -> u32 {
2095 u32::from_be(netlong)
2096 }
2097 pub const fn ntohs(netshort: u16) -> u16 {
2098 u16::from_be(netshort)
2099 }
2100}
2101
2102cfg_if! {
2103 if #[cfg(not(any(
2104 target_os = "emscripten",
2105 target_os = "android",
2106 target_os = "haiku",
2107 target_os = "nto",
2108 target_os = "solaris",
2109 target_os = "cygwin",
2110 target_os = "aix",
2111 target_os = "l4re",
2112 )))] {
2113 extern "C" {
2114 #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")]
2115 #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__adjtime64")]
2116 pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int;
2117 }
2118 } else if #[cfg(target_os = "solaris")] {
2119 extern "C" {
2120 pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> c_int;
2121 }
2122 }
2123}
2124
2125cfg_if! {
2126 if #[cfg(not(any(
2127 target_os = "emscripten",
2128 target_os = "android",
2129 target_os = "nto"
2130 )))] {
2131 extern "C" {
2132 pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
2133 }
2134 }
2135}
2136
2137cfg_if! {
2138 if #[cfg(not(any(
2139 target_os = "dragonfly",
2140 target_os = "emscripten",
2141 target_os = "hurd",
2142 target_os = "macos",
2143 target_os = "openbsd",
2144 target_os = "l4re",
2145 )))] {
2146 extern "C" {
2147 pub fn sigqueue(pid: pid_t, sig: c_int, value: crate::sigval) -> c_int;
2148 }
2149 }
2150}
2151
2152cfg_if! {
2153 if #[cfg(not(target_os = "android"))] {
2154 extern "C" {
2155 #[cfg_attr(
2156 all(target_os = "macos", target_arch = "x86"),
2157 link_name = "confstr$UNIX2003"
2158 )]
2159 #[cfg_attr(target_os = "solaris", link_name = "__confstr_xpg7")]
2160 pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t;
2161 }
2162 }
2163}
2164
2165cfg_if! {
2166 if #[cfg(not(target_os = "aix"))] {
2167 extern "C" {
2168 pub fn dladdr(addr: *const c_void, info: *mut Dl_info) -> c_int;
2169 }
2170 }
2171}
2172
2173cfg_if! {
2174 if #[cfg(not(target_os = "solaris"))] {
2175 extern "C" {
2176 pub fn flock(fd: c_int, operation: c_int) -> c_int;
2177 }
2178 }
2179}
2180
2181cfg_if! {
2182 if #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] {
2183 extern "C" {
2184 pub fn open_wmemstream(ptr: *mut *mut wchar_t, sizeloc: *mut size_t) -> *mut FILE;
2185 }
2186 }
2187}
2188
2189cfg_if! {
2190 if #[cfg(not(target_os = "redox"))] {
2191 extern "C" {
2192 pub fn getsid(pid: pid_t) -> pid_t;
2193 #[cfg_attr(
2194 all(target_os = "macos", target_arch = "x86"),
2195 link_name = "pause$UNIX2003"
2196 )]
2197 pub fn pause() -> c_int;
2198
2199 #[cfg(not(target_os = "l4re"))]
2200 pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
2201 #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")]
2202 pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
2203
2204 #[cfg_attr(
2205 all(target_os = "macos", target_arch = "x86_64"),
2206 link_name = "fdopendir$INODE64"
2207 )]
2208 #[cfg_attr(
2209 all(target_os = "macos", target_arch = "x86"),
2210 link_name = "fdopendir$INODE64$UNIX2003"
2211 )]
2212 pub fn fdopendir(fd: c_int) -> *mut crate::DIR;
2213
2214 #[cfg_attr(
2215 all(target_os = "macos", not(target_arch = "aarch64")),
2216 link_name = "readdir_r$INODE64"
2217 )]
2218 #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
2219 #[cfg_attr(
2220 all(target_os = "freebsd", any(freebsd11, freebsd10)),
2221 link_name = "readdir_r@FBSD_1.0"
2222 )]
2223 #[cfg_attr(
2224 all(target_os = "freebsd", not(any(freebsd11, freebsd10))),
2225 link_name = "readdir_r@FBSD_1.5"
2226 )]
2227 #[allow(non_autolinks)] #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64_r")]
2235 pub fn readdir_r(
2236 dirp: *mut crate::DIR,
2237 entry: *mut crate::dirent,
2238 result: *mut *mut crate::dirent,
2239 ) -> c_int;
2240 }
2241 }
2242}
2243
2244cfg_if! {
2245 if #[cfg(target_os = "nto")] {
2246 extern "C" {
2247 pub fn readlinkat(
2248 dirfd: c_int,
2249 pathname: *const c_char,
2250 buf: *mut c_char,
2251 bufsiz: size_t,
2252 ) -> c_int;
2253 pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> c_int;
2254 pub fn pselect(
2255 nfds: c_int,
2256 readfds: *mut fd_set,
2257 writefds: *mut fd_set,
2258 errorfds: *mut fd_set,
2259 timeout: *mut timespec,
2260 sigmask: *const sigset_t,
2261 ) -> c_int;
2262 pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction)
2263 -> c_int;
2264 }
2265 } else {
2266 extern "C" {
2267 #[cfg(not(target_os = "l4re"))]
2268 pub fn readlinkat(
2269 dirfd: c_int,
2270 pathname: *const c_char,
2271 buf: *mut c_char,
2272 bufsiz: size_t,
2273 ) -> ssize_t;
2274 #[cfg(not(target_os = "l4re"))]
2275 pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE;
2276 #[cfg(not(target_os = "l4re"))]
2277 pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE;
2278 pub fn atexit(cb: extern "C" fn()) -> c_int;
2279 #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
2280 pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction)
2281 -> c_int;
2282 pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> ssize_t;
2283 #[cfg_attr(
2284 all(target_os = "macos", target_arch = "x86_64"),
2285 link_name = "pselect$1050"
2286 )]
2287 #[cfg_attr(
2288 all(target_os = "macos", target_arch = "x86"),
2289 link_name = "pselect$UNIX2003"
2290 )]
2291 #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
2292 #[cfg_attr(gnu_time_bits64, link_name = "__pselect64")]
2293 #[cfg_attr(musl32_time64, link_name = "__pselect_time64")]
2294 pub fn pselect(
2295 nfds: c_int,
2296 readfds: *mut fd_set,
2297 writefds: *mut fd_set,
2298 errorfds: *mut fd_set,
2299 timeout: *const timespec,
2300 sigmask: *const sigset_t,
2301 ) -> c_int;
2302 }
2303 }
2304}
2305
2306cfg_if! {
2307 if #[cfg(any(target_os = "aix", target_os = "nto"))] {
2308 extern "C" {
2309 pub fn cfmakeraw(termios: *mut crate::termios) -> c_int;
2310 }
2311 } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] {
2312 extern "C" {
2313 pub fn cfmakeraw(termios: *mut crate::termios);
2314 }
2315 }
2316}
2317
2318cfg_if! {
2319 if #[cfg(any(
2320 target_os = "aix",
2321 all(target_os = "nto", target_env = "nto80")
2322 ))] {
2323 extern "C" {
2324 pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2325 }
2326 } else if #[cfg(not(any(
2327 target_os = "solaris",
2328 target_os = "illumos",
2329 target_os = "nto"
2330 )))] {
2331 extern "C" {
2332 #[cfg(not(target_os = "l4re"))]
2333 #[cfg_attr(
2334 all(target_os = "linux", target_env = "gnu", target_arch = "arm"),
2335 link_name = "cfsetspeed@GLIBC_2.4"
2336 )]
2337 #[cfg_attr(
2338 all(target_os = "linux", target_env = "gnu", target_arch = "csky"),
2339 link_name = "cfsetspeed@GLIBC_2.29"
2340 )]
2341 #[cfg_attr(
2342 all(target_os = "linux", target_env = "gnu", target_arch = "m68k"),
2343 link_name = "cfsetspeed@GLIBC_2.0"
2344 )]
2345 #[cfg_attr(
2346 all(
2347 target_os = "linux",
2348 target_env = "gnu",
2349 any(target_arch = "mips", target_arch = "mips32r6")
2350 ),
2351 link_name = "cfsetspeed@GLIBC_2.0"
2352 )]
2353 #[cfg_attr(
2354 all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"),
2355 link_name = "cfsetspeed@GLIBC_2.0"
2356 )]
2357 #[cfg_attr(
2358 all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"),
2359 link_name = "cfsetspeed@GLIBC_2.33"
2360 )]
2361 #[cfg_attr(
2362 all(target_os = "linux", target_env = "gnu", target_arch = "sparc"),
2363 link_name = "cfsetspeed@GLIBC_2.0"
2364 )]
2365 #[cfg_attr(
2366 all(target_os = "linux", target_env = "gnu", target_arch = "x86"),
2367 link_name = "cfsetspeed@GLIBC_2.0"
2368 )]
2369 #[cfg_attr(
2370 all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"),
2371 link_name = "cfsetspeed@GLIBC_2.17"
2372 )]
2373 #[cfg_attr(
2374 all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"),
2375 link_name = "cfsetspeed@GLIBC_2.36"
2376 )]
2377 #[cfg_attr(
2378 all(
2379 target_os = "linux",
2380 target_env = "gnu",
2381 any(target_arch = "mips64", target_arch = "mips64r6")
2382 ),
2383 link_name = "cfsetspeed@GLIBC_2.0"
2384 )]
2385 #[cfg_attr(
2386 all(
2387 target_os = "linux",
2388 target_env = "gnu",
2389 target_arch = "powerpc64",
2390 target_endian = "big"
2391 ),
2392 link_name = "cfsetspeed@GLIBC_2.3"
2393 )]
2394 #[cfg_attr(
2395 all(
2396 target_os = "linux",
2397 target_env = "gnu",
2398 target_arch = "powerpc64",
2399 target_endian = "little"
2400 ),
2401 link_name = "cfsetspeed@GLIBC_2.17"
2402 )]
2403 #[cfg_attr(
2404 all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"),
2405 link_name = "cfsetspeed@GLIBC_2.27"
2406 )]
2407 #[cfg_attr(
2408 all(target_os = "linux", target_env = "gnu", target_arch = "s390x"),
2409 link_name = "cfsetspeed@GLIBC_2.2"
2410 )]
2411 #[cfg_attr(
2412 all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"),
2413 link_name = "cfsetspeed@GLIBC_2.2"
2414 )]
2415 #[cfg_attr(
2416 all(
2417 target_os = "linux",
2418 target_env = "gnu",
2419 target_arch = "x86_64",
2420 target_pointer_width = "64"
2421 ),
2422 link_name = "cfsetspeed@GLIBC_2.2.5"
2423 )]
2424 #[cfg_attr(
2425 all(
2426 target_os = "linux",
2427 target_env = "gnu",
2428 target_arch = "x86_64",
2429 target_pointer_width = "32"
2430 ),
2431 link_name = "cfsetspeed@GLIBC_2.16"
2432 )]
2433 pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int;
2434 }
2435 }
2436}
2437
2438extern "C" {
2439 pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int;
2440}
2441
2442cfg_if! {
2443 if #[cfg(target_env = "newlib")] {
2444 mod newlib;
2445 pub use self::newlib::*;
2446 } else if #[cfg(any(
2447 target_os = "linux",
2448 target_os = "l4re",
2449 target_os = "android",
2450 target_os = "emscripten"
2451 ))] {
2452 mod linux_like;
2453 pub use self::linux_like::*;
2454 } else if #[cfg(any(
2455 target_os = "macos",
2456 target_os = "ios",
2457 target_os = "tvos",
2458 target_os = "watchos",
2459 target_os = "visionos",
2460 target_os = "freebsd",
2461 target_os = "dragonfly",
2462 target_os = "openbsd",
2463 target_os = "netbsd"
2464 ))] {
2465 mod bsd;
2466 pub use self::bsd::*;
2467 } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
2468 mod solarish;
2469 pub use self::solarish::*;
2470 } else if #[cfg(target_os = "haiku")] {
2471 mod haiku;
2472 pub use self::haiku::*;
2473 } else if #[cfg(target_os = "redox")] {
2474 mod redox;
2475 pub use self::redox::*;
2476 } else if #[cfg(target_os = "cygwin")] {
2477 mod cygwin;
2478 pub use self::cygwin::*;
2479 } else if #[cfg(target_os = "nto")] {
2480 mod nto;
2481 pub use self::nto::*;
2482 } else if #[cfg(target_os = "aix")] {
2483 mod aix;
2484 pub use self::aix::*;
2485 } else if #[cfg(target_os = "hurd")] {
2486 mod hurd;
2487 pub use self::hurd::*;
2488 } else if #[cfg(target_os = "nuttx")] {
2489 mod nuttx;
2490 pub use self::nuttx::*;
2491 } else {
2492 }
2494}