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