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