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