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 | pub const FNM_PERIOD: c_int = 1 << 2; |
338 | pub const FNM_NOMATCH: c_int = 1; |
339 | |
340 | cfg_if! { |
341 | if #[cfg(any(target_os = "illumos" , target_os = "solaris" ,))] { |
342 | pub const FNM_CASEFOLD: c_int = 1 << 3; |
343 | } else { |
344 | pub const FNM_CASEFOLD: c_int = 1 << 4; |
345 | } |
346 | } |
347 | |
348 | cfg_if! { |
349 | if #[cfg(any( |
350 | target_os = "macos" , |
351 | target_os = "freebsd" , |
352 | target_os = "android" , |
353 | target_os = "openbsd" , |
354 | ))] { |
355 | pub const FNM_PATHNAME: c_int = 1 << 1; |
356 | pub const FNM_NOESCAPE: c_int = 1 << 0; |
357 | } else { |
358 | pub const FNM_PATHNAME: c_int = 1 << 0; |
359 | pub const FNM_NOESCAPE: c_int = 1 << 1; |
360 | } |
361 | } |
362 | |
363 | unsafeextern "C" { |
364 | pub unsafestatic in6addr_loopback: in6_addr; |
365 | pub unsafestatic in6addr_any: in6_addr; |
366 | } |
367 | |
368 | cfg_if! { |
369 | if #[cfg(any( |
370 | target_os = "l4re" , |
371 | target_os = "espidf" , |
372 | target_os = "nuttx" |
373 | ))] { |
374 | // required libraries are linked externally for these platforms: |
375 | // * L4Re |
376 | // * ESP-IDF |
377 | // * NuttX |
378 | } else if #[cfg(feature = "std" )] { |
379 | // cargo build, don't pull in anything extra as the std dep |
380 | // already pulls in all libs. |
381 | } else if #[cfg(all( |
382 | any( |
383 | all( |
384 | target_os = "linux" , |
385 | any(target_env = "gnu" , target_env = "uclibc" ) |
386 | ), |
387 | target_os = "cygwin" |
388 | ), |
389 | feature = "rustc-dep-of-std" |
390 | ))] { |
391 | #[link ( |
392 | name = "util" , |
393 | kind = "static" , |
394 | modifiers = "-bundle" , |
395 | cfg(target_feature = "crt-static" ) |
396 | )] |
397 | #[link ( |
398 | name = "rt" , |
399 | kind = "static" , |
400 | modifiers = "-bundle" , |
401 | cfg(target_feature = "crt-static" ) |
402 | )] |
403 | #[link ( |
404 | name = "pthread" , |
405 | kind = "static" , |
406 | modifiers = "-bundle" , |
407 | cfg(target_feature = "crt-static" ) |
408 | )] |
409 | #[link ( |
410 | name = "m" , |
411 | kind = "static" , |
412 | modifiers = "-bundle" , |
413 | cfg(target_feature = "crt-static" ) |
414 | )] |
415 | #[link ( |
416 | name = "dl" , |
417 | kind = "static" , |
418 | modifiers = "-bundle" , |
419 | cfg(target_feature = "crt-static" ) |
420 | )] |
421 | #[link ( |
422 | name = "c" , |
423 | kind = "static" , |
424 | modifiers = "-bundle" , |
425 | cfg(target_feature = "crt-static" ) |
426 | )] |
427 | #[link ( |
428 | name = "gcc_eh" , |
429 | kind = "static" , |
430 | modifiers = "-bundle" , |
431 | cfg(target_feature = "crt-static" ) |
432 | )] |
433 | #[link ( |
434 | name = "gcc" , |
435 | kind = "static" , |
436 | modifiers = "-bundle" , |
437 | cfg(target_feature = "crt-static" ) |
438 | )] |
439 | #[link ( |
440 | name = "c" , |
441 | kind = "static" , |
442 | modifiers = "-bundle" , |
443 | cfg(target_feature = "crt-static" ) |
444 | )] |
445 | #[link (name = "util" , cfg(not(target_feature = "crt-static" )))] |
446 | #[link (name = "rt" , cfg(not(target_feature = "crt-static" )))] |
447 | #[link (name = "pthread" , cfg(not(target_feature = "crt-static" )))] |
448 | #[link (name = "m" , cfg(not(target_feature = "crt-static" )))] |
449 | #[link (name = "dl" , cfg(not(target_feature = "crt-static" )))] |
450 | #[link (name = "c" , cfg(not(target_feature = "crt-static" )))] |
451 | extern "C" {} |
452 | } else if #[cfg(any(target_env = "musl" , target_env = "ohos" ))] { |
453 | #[cfg_attr ( |
454 | feature = "rustc-dep-of-std" , |
455 | link( |
456 | name = "c" , |
457 | kind = "static" , |
458 | modifiers = "-bundle" , |
459 | cfg(target_feature = "crt-static" ) |
460 | ) |
461 | )] |
462 | #[cfg_attr ( |
463 | feature = "rustc-dep-of-std" , |
464 | link(name = "c" , cfg(not(target_feature = "crt-static" ))) |
465 | )] |
466 | extern "C" {} |
467 | } else if #[cfg(target_os = "emscripten" )] { |
468 | // Don't pass -lc to Emscripten, it breaks. See: |
469 | // https://github.com/emscripten-core/emscripten/issues/22758 |
470 | } else if #[cfg(all(target_os = "android" , feature = "rustc-dep-of-std" ))] { |
471 | #[link ( |
472 | name = "c" , |
473 | kind = "static" , |
474 | modifiers = "-bundle" , |
475 | cfg(target_feature = "crt-static" ) |
476 | )] |
477 | #[link ( |
478 | name = "m" , |
479 | kind = "static" , |
480 | modifiers = "-bundle" , |
481 | cfg(target_feature = "crt-static" ) |
482 | )] |
483 | #[link (name = "m" , cfg(not(target_feature = "crt-static" )))] |
484 | #[link (name = "c" , cfg(not(target_feature = "crt-static" )))] |
485 | extern "C" {} |
486 | } else if #[cfg(any( |
487 | target_os = "macos" , |
488 | target_os = "ios" , |
489 | target_os = "tvos" , |
490 | target_os = "watchos" , |
491 | target_os = "visionos" , |
492 | target_os = "android" , |
493 | target_os = "openbsd" , |
494 | target_os = "nto" , |
495 | ))] { |
496 | #[link (name = "c" )] |
497 | #[link (name = "m" )] |
498 | extern "C" {} |
499 | } else if #[cfg(target_os = "haiku" )] { |
500 | #[link (name = "root" )] |
501 | #[link (name = "network" )] |
502 | extern "C" {} |
503 | } else if #[cfg(target_env = "newlib" )] { |
504 | #[link (name = "c" )] |
505 | #[link (name = "m" )] |
506 | extern "C" {} |
507 | } else if #[cfg(target_env = "illumos" )] { |
508 | #[link (name = "c" )] |
509 | #[link (name = "m" )] |
510 | extern "C" {} |
511 | } else if #[cfg(target_os = "redox" )] { |
512 | #[cfg_attr ( |
513 | feature = "rustc-dep-of-std" , |
514 | link( |
515 | name = "c" , |
516 | kind = "static" , |
517 | modifiers = "-bundle" , |
518 | cfg(target_feature = "crt-static" ) |
519 | ) |
520 | )] |
521 | #[cfg_attr ( |
522 | feature = "rustc-dep-of-std" , |
523 | link(name = "c" , cfg(not(target_feature = "crt-static" ))) |
524 | )] |
525 | extern "C" {} |
526 | } else if #[cfg(target_os = "aix" )] { |
527 | #[link (name = "c" )] |
528 | #[link (name = "m" )] |
529 | #[link (name = "bsd" )] |
530 | #[link (name = "pthread" )] |
531 | extern "C" {} |
532 | } else { |
533 | #[link (name = "c" )] |
534 | #[link (name = "m" )] |
535 | #[link (name = "rt" )] |
536 | #[link (name = "pthread" )] |
537 | extern "C" {} |
538 | } |
539 | } |
540 | |
541 | missing! { |
542 | #[cfg_attr (feature = "extra_traits" , derive(Debug))] |
543 | pub enum FILE {} |
544 | #[cfg_attr (feature = "extra_traits" , derive(Debug))] |
545 | pub enum fpos_t {} // FIXME(unix): fill this out with a struct |
546 | } |
547 | |
548 | unsafeextern "C" { |
549 | pub unsafefn isalnum(c: c_int) -> c_int; |
550 | pub unsafefn isalpha(c: c_int) -> c_int; |
551 | pub unsafefn iscntrl(c: c_int) -> c_int; |
552 | pub unsafefn isdigit(c: c_int) -> c_int; |
553 | pub unsafefn isgraph(c: c_int) -> c_int; |
554 | pub unsafefn islower(c: c_int) -> c_int; |
555 | pub unsafefn isprint(c: c_int) -> c_int; |
556 | pub unsafefn ispunct(c: c_int) -> c_int; |
557 | pub unsafefn isspace(c: c_int) -> c_int; |
558 | pub unsafefn isupper(c: c_int) -> c_int; |
559 | pub unsafefn isxdigit(c: c_int) -> c_int; |
560 | pub unsafefn isblank(c: c_int) -> c_int; |
561 | pub unsafefn tolower(c: c_int) -> c_int; |
562 | pub unsafefn toupper(c: c_int) -> c_int; |
563 | pub unsafefn qsort( |
564 | base: *mut c_void, |
565 | num: size_t, |
566 | size: size_t, |
567 | compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>, |
568 | ); |
569 | pub unsafefn bsearch( |
570 | key: *const c_void, |
571 | base: *const c_void, |
572 | num: size_t, |
573 | size: size_t, |
574 | compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>, |
575 | ) -> *mut c_void; |
576 | #[cfg_attr ( |
577 | all(target_os = "macos" , target_arch = "x86" ), |
578 | link_name = "fopen$UNIX2003" |
579 | )] |
580 | pub unsafefn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; |
581 | #[cfg_attr ( |
582 | all(target_os = "macos" , target_arch = "x86" ), |
583 | link_name = "freopen$UNIX2003" |
584 | )] |
585 | pub unsafefn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; |
586 | |
587 | pub unsafefn fflush(file: *mut FILE) -> c_int; |
588 | pub unsafefn fclose(file: *mut FILE) -> c_int; |
589 | pub unsafefn remove(filename: *const c_char) -> c_int; |
590 | pub unsafefn rename(oldname: *const c_char, newname: *const c_char) -> c_int; |
591 | pub unsafefn tmpfile() -> *mut FILE; |
592 | pub unsafefn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; |
593 | pub unsafefn setbuf(stream: *mut FILE, buf: *mut c_char); |
594 | pub unsafefn getchar() -> c_int; |
595 | pub unsafefn putchar(c: c_int) -> c_int; |
596 | pub unsafefn fgetc(stream: *mut FILE) -> c_int; |
597 | pub unsafefn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; |
598 | pub unsafefn fputc(c: c_int, stream: *mut FILE) -> c_int; |
599 | #[cfg_attr ( |
600 | all(target_os = "macos" , target_arch = "x86" ), |
601 | link_name = "fputs$UNIX2003" |
602 | )] |
603 | pub unsafefn fputs(s: *const c_char, stream: *mut FILE) -> c_int; |
604 | pub unsafefn puts(s: *const c_char) -> c_int; |
605 | pub unsafefn ungetc(c: c_int, stream: *mut FILE) -> c_int; |
606 | pub unsafefn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; |
607 | #[cfg_attr ( |
608 | all(target_os = "macos" , target_arch = "x86" ), |
609 | link_name = "fwrite$UNIX2003" |
610 | )] |
611 | pub unsafefn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; |
612 | pub unsafefn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; |
613 | pub unsafefn ftell(stream: *mut FILE) -> c_long; |
614 | pub unsafefn rewind(stream: *mut FILE); |
615 | #[cfg_attr (target_os = "netbsd" , link_name = "__fgetpos50" )] |
616 | pub unsafefn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; |
617 | #[cfg_attr (target_os = "netbsd" , link_name = "__fsetpos50" )] |
618 | pub unsafefn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; |
619 | pub unsafefn feof(stream: *mut FILE) -> c_int; |
620 | pub unsafefn ferror(stream: *mut FILE) -> c_int; |
621 | pub unsafefn clearerr(stream: *mut FILE); |
622 | pub unsafefn perror(s: *const c_char); |
623 | pub unsafefn atof(s: *const c_char) -> c_double; |
624 | pub unsafefn atoi(s: *const c_char) -> c_int; |
625 | pub unsafefn atol(s: *const c_char) -> c_long; |
626 | pub unsafefn atoll(s: *const c_char) -> c_longlong; |
627 | #[cfg_attr ( |
628 | all(target_os = "macos" , target_arch = "x86" ), |
629 | link_name = "strtod$UNIX2003" |
630 | )] |
631 | pub unsafefn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; |
632 | pub unsafefn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; |
633 | pub unsafefn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; |
634 | pub unsafefn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; |
635 | pub unsafefn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; |
636 | pub unsafefn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; |
637 | pub unsafefn calloc(nobj: size_t, size: size_t) -> *mut c_void; |
638 | pub unsafefn malloc(size: size_t) -> *mut c_void; |
639 | pub unsafefn realloc(p: *mut c_void, size: size_t) -> *mut c_void; |
640 | pub unsafefn free(p: *mut c_void); |
641 | pub unsafefn abort() -> !; |
642 | pub unsafefn exit(status: c_int) -> !; |
643 | pub unsafefn _exit(status: c_int) -> !; |
644 | #[cfg_attr ( |
645 | all(target_os = "macos" , target_arch = "x86" ), |
646 | link_name = "system$UNIX2003" |
647 | )] |
648 | pub unsafefn system(s: *const c_char) -> c_int; |
649 | pub unsafefn getenv(s: *const c_char) -> *mut c_char; |
650 | |
651 | pub unsafefn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; |
652 | pub unsafefn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; |
653 | pub unsafefn stpcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; |
654 | pub unsafefn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; |
655 | pub unsafefn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; |
656 | pub unsafefn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; |
657 | pub unsafefn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; |
658 | pub unsafefn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; |
659 | pub unsafefn strchr(cs: *const c_char, c: c_int) -> *mut c_char; |
660 | pub unsafefn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; |
661 | pub unsafefn strspn(cs: *const c_char, ct: *const c_char) -> size_t; |
662 | pub unsafefn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; |
663 | pub unsafefn strdup(cs: *const c_char) -> *mut c_char; |
664 | pub unsafefn strndup(cs: *const c_char, n: size_t) -> *mut c_char; |
665 | pub unsafefn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; |
666 | pub unsafefn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; |
667 | pub unsafefn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; |
668 | pub unsafefn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; |
669 | pub unsafefn strlen(cs: *const c_char) -> size_t; |
670 | pub unsafefn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; |
671 | #[cfg_attr ( |
672 | all(target_os = "macos" , target_arch = "x86" ), |
673 | link_name = "strerror$UNIX2003" |
674 | )] |
675 | pub unsafefn strerror(n: c_int) -> *mut c_char; |
676 | pub unsafefn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; |
677 | pub unsafefn strtok_r(s: *mut c_char, t: *const c_char, p: *mut *mut c_char) -> *mut c_char; |
678 | pub unsafefn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; |
679 | pub unsafefn strsignal(sig: c_int) -> *mut c_char; |
680 | pub unsafefn wcslen(buf: *const wchar_t) -> size_t; |
681 | pub unsafefn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t; |
682 | |
683 | pub unsafefn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; |
684 | pub unsafefn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; |
685 | pub unsafefn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; |
686 | pub unsafefn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; |
687 | pub unsafefn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; |
688 | pub unsafefn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; |
689 | pub unsafefn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void; |
690 | } |
691 | |
692 | unsafeextern "C" { |
693 | #[cfg_attr (target_os = "netbsd" , link_name = "__getpwnam50" )] |
694 | pub unsafefn getpwnam(name: *const c_char) -> *mut passwd; |
695 | #[cfg_attr (target_os = "netbsd" , link_name = "__getpwuid50" )] |
696 | pub unsafefn getpwuid(uid: crate::uid_t) -> *mut passwd; |
697 | |
698 | pub unsafefn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; |
699 | pub unsafefn printf(format: *const c_char, ...) -> c_int; |
700 | pub unsafefn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int; |
701 | pub unsafefn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; |
702 | #[cfg_attr ( |
703 | all(target_os = "linux" , not(target_env = "uclibc" )), |
704 | link_name = "__isoc99_fscanf" |
705 | )] |
706 | pub unsafefn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; |
707 | #[cfg_attr ( |
708 | all(target_os = "linux" , not(target_env = "uclibc" )), |
709 | link_name = "__isoc99_scanf" |
710 | )] |
711 | pub unsafefn scanf(format: *const c_char, ...) -> c_int; |
712 | #[cfg_attr ( |
713 | all(target_os = "linux" , not(target_env = "uclibc" )), |
714 | link_name = "__isoc99_sscanf" |
715 | )] |
716 | pub unsafefn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int; |
717 | pub unsafefn getchar_unlocked() -> c_int; |
718 | pub unsafefn putchar_unlocked(c: c_int) -> c_int; |
719 | |
720 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
721 | #[cfg_attr (target_os = "netbsd" , link_name = "__socket30" )] |
722 | #[cfg_attr (target_os = "illumos" , link_name = "__xnet_socket" )] |
723 | #[cfg_attr (target_os = "solaris" , link_name = "__xnet7_socket" )] |
724 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_socket" )] |
725 | pub unsafefn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; |
726 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
727 | #[cfg_attr ( |
728 | all(target_os = "macos" , target_arch = "x86" ), |
729 | link_name = "connect$UNIX2003" |
730 | )] |
731 | #[cfg_attr ( |
732 | any(target_os = "illumos" , target_os = "solaris" ), |
733 | link_name = "__xnet_connect" |
734 | )] |
735 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_connect" )] |
736 | pub unsafefn connect(socket: c_int, address: *const sockaddr, len: socklen_t) -> c_int; |
737 | #[cfg_attr ( |
738 | all(target_os = "macos" , target_arch = "x86" ), |
739 | link_name = "listen$UNIX2003" |
740 | )] |
741 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_listen" )] |
742 | pub unsafefn listen(socket: c_int, backlog: c_int) -> c_int; |
743 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
744 | #[cfg_attr ( |
745 | all(target_os = "macos" , target_arch = "x86" ), |
746 | link_name = "accept$UNIX2003" |
747 | )] |
748 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_accept" )] |
749 | pub unsafefn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; |
750 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
751 | #[cfg_attr ( |
752 | all(target_os = "macos" , target_arch = "x86" ), |
753 | link_name = "getpeername$UNIX2003" |
754 | )] |
755 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_getpeername" )] |
756 | pub unsafefn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) |
757 | -> 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 = "getsockname$UNIX2003" |
762 | )] |
763 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_getsockname" )] |
764 | pub unsafefn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) |
765 | -> c_int; |
766 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_setsockopt" )] |
767 | pub unsafefn setsockopt( |
768 | socket: c_int, |
769 | level: c_int, |
770 | name: c_int, |
771 | value: *const c_void, |
772 | option_len: socklen_t, |
773 | ) -> c_int; |
774 | #[cfg_attr ( |
775 | all(target_os = "macos" , target_arch = "x86" ), |
776 | link_name = "socketpair$UNIX2003" |
777 | )] |
778 | #[cfg_attr ( |
779 | any(target_os = "illumos" , target_os = "solaris" ), |
780 | link_name = "__xnet_socketpair" |
781 | )] |
782 | pub unsafefn socketpair( |
783 | domain: c_int, |
784 | type_: c_int, |
785 | protocol: c_int, |
786 | socket_vector: *mut c_int, |
787 | ) -> c_int; |
788 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
789 | #[cfg_attr ( |
790 | all(target_os = "macos" , target_arch = "x86" ), |
791 | link_name = "sendto$UNIX2003" |
792 | )] |
793 | #[cfg_attr ( |
794 | any(target_os = "illumos" , target_os = "solaris" ), |
795 | link_name = "__xnet_sendto" |
796 | )] |
797 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_sendto" )] |
798 | pub unsafefn sendto( |
799 | socket: c_int, |
800 | buf: *const c_void, |
801 | len: size_t, |
802 | flags: c_int, |
803 | addr: *const sockaddr, |
804 | addrlen: socklen_t, |
805 | ) -> ssize_t; |
806 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_shutdown" )] |
807 | pub unsafefn shutdown(socket: c_int, how: c_int) -> c_int; |
808 | |
809 | #[cfg_attr ( |
810 | all(target_os = "macos" , target_arch = "x86" ), |
811 | link_name = "chmod$UNIX2003" |
812 | )] |
813 | pub unsafefn chmod(path: *const c_char, mode: mode_t) -> c_int; |
814 | #[cfg_attr ( |
815 | all(target_os = "macos" , target_arch = "x86" ), |
816 | link_name = "fchmod$UNIX2003" |
817 | )] |
818 | pub unsafefn fchmod(fd: c_int, mode: mode_t) -> c_int; |
819 | |
820 | #[cfg_attr ( |
821 | all(target_os = "macos" , not(target_arch = "aarch64" )), |
822 | link_name = "fstat$INODE64" |
823 | )] |
824 | #[cfg_attr (target_os = "netbsd" , link_name = "__fstat50" )] |
825 | #[cfg_attr ( |
826 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
827 | link_name = "fstat@FBSD_1.0" |
828 | )] |
829 | pub unsafefn fstat(fildes: c_int, buf: *mut stat) -> c_int; |
830 | |
831 | pub unsafefn mkdir(path: *const c_char, mode: mode_t) -> c_int; |
832 | |
833 | #[cfg_attr ( |
834 | all(target_os = "macos" , not(target_arch = "aarch64" )), |
835 | link_name = "stat$INODE64" |
836 | )] |
837 | #[cfg_attr (target_os = "netbsd" , link_name = "__stat50" )] |
838 | #[cfg_attr ( |
839 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
840 | link_name = "stat@FBSD_1.0" |
841 | )] |
842 | pub unsafefn stat(path: *const c_char, buf: *mut stat) -> c_int; |
843 | |
844 | pub unsafefn pclose(stream: *mut crate::FILE) -> c_int; |
845 | #[cfg_attr ( |
846 | all(target_os = "macos" , target_arch = "x86" ), |
847 | link_name = "fdopen$UNIX2003" |
848 | )] |
849 | pub unsafefn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE; |
850 | pub unsafefn fileno(stream: *mut crate::FILE) -> c_int; |
851 | |
852 | #[cfg_attr ( |
853 | all(target_os = "macos" , target_arch = "x86" ), |
854 | link_name = "open$UNIX2003" |
855 | )] |
856 | pub unsafefn open(path: *const c_char, oflag: c_int, ...) -> c_int; |
857 | #[cfg_attr ( |
858 | all(target_os = "macos" , target_arch = "x86" ), |
859 | link_name = "creat$UNIX2003" |
860 | )] |
861 | pub unsafefn creat(path: *const c_char, mode: mode_t) -> c_int; |
862 | #[cfg_attr ( |
863 | all(target_os = "macos" , target_arch = "x86" ), |
864 | link_name = "fcntl$UNIX2003" |
865 | )] |
866 | pub unsafefn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; |
867 | |
868 | #[cfg_attr ( |
869 | all(target_os = "macos" , target_arch = "x86_64" ), |
870 | link_name = "opendir$INODE64" |
871 | )] |
872 | #[cfg_attr ( |
873 | all(target_os = "macos" , target_arch = "x86" ), |
874 | link_name = "opendir$INODE64$UNIX2003" |
875 | )] |
876 | #[cfg_attr (target_os = "netbsd" , link_name = "__opendir30" )] |
877 | pub unsafefn opendir(dirname: *const c_char) -> *mut crate::DIR; |
878 | |
879 | #[cfg_attr ( |
880 | all(target_os = "macos" , not(target_arch = "aarch64" )), |
881 | link_name = "readdir$INODE64" |
882 | )] |
883 | #[cfg_attr (target_os = "netbsd" , link_name = "__readdir30" )] |
884 | #[cfg_attr ( |
885 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
886 | link_name = "readdir@FBSD_1.0" |
887 | )] |
888 | pub unsafefn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; |
889 | #[cfg_attr ( |
890 | all(target_os = "macos" , target_arch = "x86" ), |
891 | link_name = "closedir$UNIX2003" |
892 | )] |
893 | pub unsafefn closedir(dirp: *mut crate::DIR) -> c_int; |
894 | #[cfg_attr ( |
895 | all(target_os = "macos" , target_arch = "x86_64" ), |
896 | link_name = "rewinddir$INODE64" |
897 | )] |
898 | #[cfg_attr ( |
899 | all(target_os = "macos" , target_arch = "x86" ), |
900 | link_name = "rewinddir$INODE64$UNIX2003" |
901 | )] |
902 | pub unsafefn rewinddir(dirp: *mut crate::DIR); |
903 | |
904 | pub unsafefn fchmodat( |
905 | dirfd: c_int, |
906 | pathname: *const c_char, |
907 | mode: crate::mode_t, |
908 | flags: c_int, |
909 | ) -> c_int; |
910 | pub unsafefn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; |
911 | pub unsafefn fchownat( |
912 | dirfd: c_int, |
913 | pathname: *const c_char, |
914 | owner: crate::uid_t, |
915 | group: crate::gid_t, |
916 | flags: c_int, |
917 | ) -> c_int; |
918 | #[cfg_attr ( |
919 | all(target_os = "macos" , not(target_arch = "aarch64" )), |
920 | link_name = "fstatat$INODE64" |
921 | )] |
922 | #[cfg_attr ( |
923 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
924 | link_name = "fstatat@FBSD_1.1" |
925 | )] |
926 | pub unsafefn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; |
927 | pub unsafefn linkat( |
928 | olddirfd: c_int, |
929 | oldpath: *const c_char, |
930 | newdirfd: c_int, |
931 | newpath: *const c_char, |
932 | flags: c_int, |
933 | ) -> c_int; |
934 | pub unsafefn renameat( |
935 | olddirfd: c_int, |
936 | oldpath: *const c_char, |
937 | newdirfd: c_int, |
938 | newpath: *const c_char, |
939 | ) -> c_int; |
940 | pub unsafefn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; |
941 | pub unsafefn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; |
942 | |
943 | pub unsafefn access(path: *const c_char, amode: c_int) -> c_int; |
944 | pub unsafefn alarm(seconds: c_uint) -> c_uint; |
945 | pub unsafefn chdir(dir: *const c_char) -> c_int; |
946 | pub unsafefn fchdir(dirfd: c_int) -> c_int; |
947 | pub unsafefn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; |
948 | #[cfg_attr ( |
949 | all(target_os = "macos" , target_arch = "x86" ), |
950 | link_name = "lchown$UNIX2003" |
951 | )] |
952 | pub unsafefn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; |
953 | #[cfg_attr ( |
954 | all(target_os = "macos" , target_arch = "x86" ), |
955 | link_name = "close$NOCANCEL$UNIX2003" |
956 | )] |
957 | #[cfg_attr ( |
958 | all(target_os = "macos" , target_arch = "x86_64" ), |
959 | link_name = "close$NOCANCEL" |
960 | )] |
961 | pub unsafefn close(fd: c_int) -> c_int; |
962 | pub unsafefn dup(fd: c_int) -> c_int; |
963 | pub unsafefn dup2(src: c_int, dst: c_int) -> c_int; |
964 | |
965 | pub unsafefn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int; |
966 | pub unsafefn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int; |
967 | pub unsafefn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int; |
968 | |
969 | // DIFF(main): changed to `*const *mut` in e77f551de9 |
970 | pub unsafefn execv(prog: *const c_char, argv: *const *const c_char) -> c_int; |
971 | pub unsafefn execve( |
972 | prog: *const c_char, |
973 | argv: *const *const c_char, |
974 | envp: *const *const c_char, |
975 | ) -> c_int; |
976 | pub unsafefn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; |
977 | |
978 | pub unsafefn fork() -> pid_t; |
979 | pub unsafefn fpathconf(filedes: c_int, name: c_int) -> c_long; |
980 | pub unsafefn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; |
981 | pub unsafefn getegid() -> gid_t; |
982 | pub unsafefn geteuid() -> uid_t; |
983 | pub unsafefn getgid() -> gid_t; |
984 | pub unsafefn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; |
985 | #[cfg_attr (target_os = "illumos" , link_name = "getloginx" )] |
986 | pub unsafefn getlogin() -> *mut c_char; |
987 | #[cfg_attr ( |
988 | all(target_os = "macos" , target_arch = "x86" ), |
989 | link_name = "getopt$UNIX2003" |
990 | )] |
991 | pub unsafefn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; |
992 | pub unsafefn getpgid(pid: pid_t) -> pid_t; |
993 | pub unsafefn getpgrp() -> pid_t; |
994 | pub unsafefn getpid() -> pid_t; |
995 | pub unsafefn getppid() -> pid_t; |
996 | pub unsafefn getuid() -> uid_t; |
997 | pub unsafefn isatty(fd: c_int) -> c_int; |
998 | #[cfg_attr (target_os = "solaris" , link_name = "__link_xpg4" )] |
999 | pub unsafefn link(src: *const c_char, dst: *const c_char) -> c_int; |
1000 | pub unsafefn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; |
1001 | pub unsafefn pathconf(path: *const c_char, name: c_int) -> c_long; |
1002 | pub unsafefn pipe(fds: *mut c_int) -> c_int; |
1003 | pub unsafefn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; |
1004 | pub unsafefn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; |
1005 | #[cfg_attr ( |
1006 | all(target_os = "macos" , target_arch = "x86" ), |
1007 | link_name = "read$UNIX2003" |
1008 | )] |
1009 | pub unsafefn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; |
1010 | pub unsafefn rmdir(path: *const c_char) -> c_int; |
1011 | pub unsafefn seteuid(uid: uid_t) -> c_int; |
1012 | pub unsafefn setegid(gid: gid_t) -> c_int; |
1013 | pub unsafefn setgid(gid: gid_t) -> c_int; |
1014 | pub unsafefn setpgid(pid: pid_t, pgid: pid_t) -> c_int; |
1015 | pub unsafefn setsid() -> pid_t; |
1016 | pub unsafefn setuid(uid: uid_t) -> c_int; |
1017 | pub unsafefn setreuid(ruid: uid_t, euid: uid_t) -> c_int; |
1018 | pub unsafefn setregid(rgid: gid_t, egid: gid_t) -> c_int; |
1019 | #[cfg_attr ( |
1020 | all(target_os = "macos" , target_arch = "x86" ), |
1021 | link_name = "sleep$UNIX2003" |
1022 | )] |
1023 | pub unsafefn sleep(secs: c_uint) -> c_uint; |
1024 | #[cfg_attr ( |
1025 | all(target_os = "macos" , target_arch = "x86" ), |
1026 | link_name = "nanosleep$UNIX2003" |
1027 | )] |
1028 | #[cfg_attr (target_os = "netbsd" , link_name = "__nanosleep50" )] |
1029 | pub unsafefn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int; |
1030 | pub unsafefn tcgetpgrp(fd: c_int) -> pid_t; |
1031 | pub unsafefn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int; |
1032 | pub unsafefn ttyname(fd: c_int) -> *mut c_char; |
1033 | #[cfg_attr ( |
1034 | all(target_os = "macos" , target_arch = "x86" ), |
1035 | link_name = "ttyname_r$UNIX2003" |
1036 | )] |
1037 | #[cfg_attr ( |
1038 | any(target_os = "illumos" , target_os = "solaris" ), |
1039 | link_name = "__posix_ttyname_r" |
1040 | )] |
1041 | pub unsafefn ttyname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; |
1042 | pub unsafefn unlink(c: *const c_char) -> c_int; |
1043 | #[cfg_attr ( |
1044 | all(target_os = "macos" , target_arch = "x86" ), |
1045 | link_name = "wait$UNIX2003" |
1046 | )] |
1047 | pub unsafefn wait(status: *mut c_int) -> pid_t; |
1048 | #[cfg_attr ( |
1049 | all(target_os = "macos" , target_arch = "x86" ), |
1050 | link_name = "waitpid$UNIX2003" |
1051 | )] |
1052 | pub unsafefn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; |
1053 | #[cfg_attr ( |
1054 | all(target_os = "macos" , target_arch = "x86" ), |
1055 | link_name = "write$UNIX2003" |
1056 | )] |
1057 | pub unsafefn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; |
1058 | #[cfg_attr ( |
1059 | all(target_os = "macos" , target_arch = "x86" ), |
1060 | link_name = "pread$UNIX2003" |
1061 | )] |
1062 | pub unsafefn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; |
1063 | #[cfg_attr ( |
1064 | all(target_os = "macos" , target_arch = "x86" ), |
1065 | link_name = "pwrite$UNIX2003" |
1066 | )] |
1067 | pub unsafefn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; |
1068 | pub unsafefn umask(mask: mode_t) -> mode_t; |
1069 | |
1070 | #[cfg_attr (target_os = "netbsd" , link_name = "__utime50" )] |
1071 | pub unsafefn utime(file: *const c_char, buf: *const utimbuf) -> c_int; |
1072 | |
1073 | #[cfg_attr ( |
1074 | all(target_os = "macos" , target_arch = "x86" ), |
1075 | link_name = "kill$UNIX2003" |
1076 | )] |
1077 | pub unsafefn kill(pid: pid_t, sig: c_int) -> c_int; |
1078 | #[cfg_attr ( |
1079 | all(target_os = "macos" , target_arch = "x86" ), |
1080 | link_name = "killpg$UNIX2003" |
1081 | )] |
1082 | pub unsafefn killpg(pgrp: pid_t, sig: c_int) -> c_int; |
1083 | |
1084 | pub unsafefn mlock(addr: *const c_void, len: size_t) -> c_int; |
1085 | pub unsafefn munlock(addr: *const c_void, len: size_t) -> c_int; |
1086 | pub unsafefn mlockall(flags: c_int) -> c_int; |
1087 | pub unsafefn munlockall() -> c_int; |
1088 | |
1089 | #[cfg_attr ( |
1090 | all(target_os = "macos" , target_arch = "x86" ), |
1091 | link_name = "mmap$UNIX2003" |
1092 | )] |
1093 | pub unsafefn mmap( |
1094 | addr: *mut c_void, |
1095 | len: size_t, |
1096 | prot: c_int, |
1097 | flags: c_int, |
1098 | fd: c_int, |
1099 | offset: off_t, |
1100 | ) -> *mut c_void; |
1101 | #[cfg_attr ( |
1102 | all(target_os = "macos" , target_arch = "x86" ), |
1103 | link_name = "munmap$UNIX2003" |
1104 | )] |
1105 | pub unsafefn munmap(addr: *mut c_void, len: size_t) -> c_int; |
1106 | |
1107 | pub unsafefn if_nametoindex(ifname: *const c_char) -> c_uint; |
1108 | pub unsafefn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char; |
1109 | |
1110 | #[cfg_attr ( |
1111 | all(target_os = "macos" , not(target_arch = "aarch64" )), |
1112 | link_name = "lstat$INODE64" |
1113 | )] |
1114 | #[cfg_attr (target_os = "netbsd" , link_name = "__lstat50" )] |
1115 | #[cfg_attr ( |
1116 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
1117 | link_name = "lstat@FBSD_1.0" |
1118 | )] |
1119 | pub unsafefn lstat(path: *const c_char, buf: *mut stat) -> c_int; |
1120 | |
1121 | #[cfg_attr ( |
1122 | all(target_os = "macos" , target_arch = "x86" ), |
1123 | link_name = "fsync$UNIX2003" |
1124 | )] |
1125 | pub unsafefn fsync(fd: c_int) -> c_int; |
1126 | |
1127 | #[cfg_attr ( |
1128 | all(target_os = "macos" , target_arch = "x86" ), |
1129 | link_name = "setenv$UNIX2003" |
1130 | )] |
1131 | pub unsafefn setenv(name: *const c_char, val: *const c_char, overwrite: c_int) -> c_int; |
1132 | #[cfg_attr ( |
1133 | all(target_os = "macos" , target_arch = "x86" ), |
1134 | link_name = "unsetenv$UNIX2003" |
1135 | )] |
1136 | #[cfg_attr (target_os = "netbsd" , link_name = "__unsetenv13" )] |
1137 | pub unsafefn unsetenv(name: *const c_char) -> c_int; |
1138 | |
1139 | pub unsafefn symlink(path1: *const c_char, path2: *const c_char) -> c_int; |
1140 | |
1141 | pub unsafefn truncate(path: *const c_char, length: off_t) -> c_int; |
1142 | pub unsafefn ftruncate(fd: c_int, length: off_t) -> c_int; |
1143 | |
1144 | pub unsafefn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; |
1145 | |
1146 | #[cfg_attr (target_os = "netbsd" , link_name = "__getrusage50" )] |
1147 | pub unsafefn getrusage(resource: c_int, usage: *mut rusage) -> c_int; |
1148 | |
1149 | #[cfg_attr ( |
1150 | any( |
1151 | target_os = "macos" , |
1152 | target_os = "ios" , |
1153 | target_os = "tvos" , |
1154 | target_os = "watchos" , |
1155 | target_os = "visionos" |
1156 | ), |
1157 | link_name = "realpath$DARWIN_EXTSN" |
1158 | )] |
1159 | pub unsafefn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; |
1160 | |
1161 | #[cfg_attr (target_os = "netbsd" , link_name = "__times13" )] |
1162 | pub unsafefn times(buf: *mut crate::tms) -> crate::clock_t; |
1163 | |
1164 | pub unsafefn pthread_self() -> crate::pthread_t; |
1165 | pub unsafefn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int; |
1166 | #[cfg_attr ( |
1167 | all(target_os = "macos" , target_arch = "x86" ), |
1168 | link_name = "pthread_join$UNIX2003" |
1169 | )] |
1170 | pub unsafefn pthread_join(native: crate::pthread_t, value: *mut *mut c_void) -> c_int; |
1171 | pub unsafefn pthread_exit(value: *mut c_void) -> !; |
1172 | pub unsafefn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int; |
1173 | pub unsafefn pthread_attr_destroy(attr: *mut crate::pthread_attr_t) -> c_int; |
1174 | pub unsafefn pthread_attr_getstacksize( |
1175 | attr: *const crate::pthread_attr_t, |
1176 | stacksize: *mut size_t, |
1177 | ) -> c_int; |
1178 | pub unsafefn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stack_size: size_t) |
1179 | -> c_int; |
1180 | pub unsafefn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int; |
1181 | pub unsafefn pthread_detach(thread: crate::pthread_t) -> c_int; |
1182 | #[cfg_attr (target_os = "netbsd" , link_name = "__libc_thr_yield" )] |
1183 | pub unsafefn sched_yield() -> c_int; |
1184 | pub unsafefn pthread_key_create( |
1185 | key: *mut pthread_key_t, |
1186 | dtor: Option<unsafe extern "C" fn(*mut c_void)>, |
1187 | ) -> c_int; |
1188 | pub unsafefn pthread_key_delete(key: pthread_key_t) -> c_int; |
1189 | pub unsafefn pthread_getspecific(key: pthread_key_t) -> *mut c_void; |
1190 | pub unsafefn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; |
1191 | pub unsafefn pthread_mutex_init( |
1192 | lock: *mut pthread_mutex_t, |
1193 | attr: *const pthread_mutexattr_t, |
1194 | ) -> c_int; |
1195 | pub unsafefn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; |
1196 | pub unsafefn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; |
1197 | pub unsafefn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; |
1198 | pub unsafefn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; |
1199 | |
1200 | pub unsafefn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; |
1201 | #[cfg_attr ( |
1202 | all(target_os = "macos" , target_arch = "x86" ), |
1203 | link_name = "pthread_mutexattr_destroy$UNIX2003" |
1204 | )] |
1205 | pub unsafefn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; |
1206 | pub unsafefn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; |
1207 | |
1208 | #[cfg_attr ( |
1209 | all(target_os = "macos" , target_arch = "x86" ), |
1210 | link_name = "pthread_cond_init$UNIX2003" |
1211 | )] |
1212 | pub unsafefn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; |
1213 | #[cfg_attr ( |
1214 | all(target_os = "macos" , target_arch = "x86" ), |
1215 | link_name = "pthread_cond_wait$UNIX2003" |
1216 | )] |
1217 | pub unsafefn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; |
1218 | #[cfg_attr ( |
1219 | all(target_os = "macos" , target_arch = "x86" ), |
1220 | link_name = "pthread_cond_timedwait$UNIX2003" |
1221 | )] |
1222 | pub unsafefn pthread_cond_timedwait( |
1223 | cond: *mut pthread_cond_t, |
1224 | lock: *mut pthread_mutex_t, |
1225 | abstime: *const crate::timespec, |
1226 | ) -> c_int; |
1227 | pub unsafefn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; |
1228 | pub unsafefn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; |
1229 | pub unsafefn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; |
1230 | pub unsafefn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; |
1231 | pub unsafefn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; |
1232 | #[cfg_attr ( |
1233 | all(target_os = "macos" , target_arch = "x86" ), |
1234 | link_name = "pthread_rwlock_init$UNIX2003" |
1235 | )] |
1236 | pub unsafefn pthread_rwlock_init( |
1237 | lock: *mut pthread_rwlock_t, |
1238 | attr: *const pthread_rwlockattr_t, |
1239 | ) -> c_int; |
1240 | #[cfg_attr ( |
1241 | all(target_os = "macos" , target_arch = "x86" ), |
1242 | link_name = "pthread_rwlock_destroy$UNIX2003" |
1243 | )] |
1244 | pub unsafefn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; |
1245 | #[cfg_attr ( |
1246 | all(target_os = "macos" , target_arch = "x86" ), |
1247 | link_name = "pthread_rwlock_rdlock$UNIX2003" |
1248 | )] |
1249 | pub unsafefn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; |
1250 | #[cfg_attr ( |
1251 | all(target_os = "macos" , target_arch = "x86" ), |
1252 | link_name = "pthread_rwlock_tryrdlock$UNIX2003" |
1253 | )] |
1254 | pub unsafefn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; |
1255 | #[cfg_attr ( |
1256 | all(target_os = "macos" , target_arch = "x86" ), |
1257 | link_name = "pthread_rwlock_wrlock$UNIX2003" |
1258 | )] |
1259 | pub unsafefn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; |
1260 | #[cfg_attr ( |
1261 | all(target_os = "macos" , target_arch = "x86" ), |
1262 | link_name = "pthread_rwlock_trywrlock$UNIX2003" |
1263 | )] |
1264 | pub unsafefn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; |
1265 | #[cfg_attr ( |
1266 | all(target_os = "macos" , target_arch = "x86" ), |
1267 | link_name = "pthread_rwlock_unlock$UNIX2003" |
1268 | )] |
1269 | pub unsafefn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; |
1270 | pub unsafefn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; |
1271 | pub unsafefn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; |
1272 | |
1273 | #[cfg_attr ( |
1274 | any(target_os = "illumos" , target_os = "solaris" ), |
1275 | link_name = "__xnet_getsockopt" |
1276 | )] |
1277 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_getsockopt" )] |
1278 | pub unsafefn getsockopt( |
1279 | sockfd: c_int, |
1280 | level: c_int, |
1281 | optname: c_int, |
1282 | optval: *mut c_void, |
1283 | optlen: *mut crate::socklen_t, |
1284 | ) -> c_int; |
1285 | pub unsafefn raise(signum: c_int) -> c_int; |
1286 | |
1287 | #[cfg_attr (target_os = "netbsd" , link_name = "__utimes50" )] |
1288 | pub unsafefn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; |
1289 | pub unsafefn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; |
1290 | pub unsafefn dlerror() -> *mut c_char; |
1291 | pub unsafefn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; |
1292 | pub unsafefn dlclose(handle: *mut c_void) -> c_int; |
1293 | |
1294 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
1295 | #[cfg_attr ( |
1296 | any(target_os = "illumos" , target_os = "solaris" ), |
1297 | link_name = "__xnet_getaddrinfo" |
1298 | )] |
1299 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_getaddrinfo" )] |
1300 | pub unsafefn getaddrinfo( |
1301 | node: *const c_char, |
1302 | service: *const c_char, |
1303 | hints: *const addrinfo, |
1304 | res: *mut *mut addrinfo, |
1305 | ) -> c_int; |
1306 | #[cfg (not(all(target_arch = "powerpc" , target_vendor = "nintendo" )))] |
1307 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_freeaddrinfo" )] |
1308 | pub unsafefn freeaddrinfo(res: *mut addrinfo); |
1309 | pub unsafefn hstrerror(errcode: c_int) -> *const c_char; |
1310 | pub unsafefn gai_strerror(errcode: c_int) -> *const c_char; |
1311 | #[cfg_attr ( |
1312 | any( |
1313 | all( |
1314 | target_os = "linux" , |
1315 | not(any(target_env = "musl" , target_env = "ohos" )) |
1316 | ), |
1317 | target_os = "freebsd" , |
1318 | target_os = "cygwin" , |
1319 | target_os = "dragonfly" , |
1320 | target_os = "haiku" |
1321 | ), |
1322 | link_name = "__res_init" |
1323 | )] |
1324 | #[cfg_attr ( |
1325 | any( |
1326 | target_os = "macos" , |
1327 | target_os = "ios" , |
1328 | target_os = "tvos" , |
1329 | target_os = "watchos" , |
1330 | target_os = "visionos" |
1331 | ), |
1332 | link_name = "res_9_init" |
1333 | )] |
1334 | pub unsafefn res_init() -> c_int; |
1335 | |
1336 | #[cfg_attr (target_os = "netbsd" , link_name = "__gmtime_r50" )] |
1337 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1338 | // FIXME(time): for `time_t` |
1339 | pub unsafefn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; |
1340 | #[cfg_attr (target_os = "netbsd" , link_name = "__localtime_r50" )] |
1341 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1342 | // FIXME(time): for `time_t` |
1343 | pub unsafefn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; |
1344 | #[cfg_attr ( |
1345 | all(target_os = "macos" , target_arch = "x86" ), |
1346 | link_name = "mktime$UNIX2003" |
1347 | )] |
1348 | #[cfg_attr (target_os = "netbsd" , link_name = "__mktime50" )] |
1349 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1350 | // FIXME: for `time_t` |
1351 | pub unsafefn mktime(tm: *mut tm) -> time_t; |
1352 | #[cfg_attr (target_os = "netbsd" , link_name = "__time50" )] |
1353 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1354 | // FIXME: for `time_t` |
1355 | pub unsafefn time(time: *mut time_t) -> time_t; |
1356 | #[cfg_attr (target_os = "netbsd" , link_name = "__gmtime50" )] |
1357 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1358 | // FIXME(time): for `time_t` |
1359 | pub unsafefn gmtime(time_p: *const time_t) -> *mut tm; |
1360 | #[cfg_attr (target_os = "netbsd" , link_name = "__locatime50" )] |
1361 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1362 | // FIXME(time): for `time_t` |
1363 | pub unsafefn localtime(time_p: *const time_t) -> *mut tm; |
1364 | #[cfg_attr (target_os = "netbsd" , link_name = "__difftime50" )] |
1365 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1366 | // FIXME(time): for `time_t` |
1367 | pub unsafefn difftime(time1: time_t, time0: time_t) -> c_double; |
1368 | #[cfg_attr (target_os = "netbsd" , link_name = "__timegm50" )] |
1369 | #[cfg_attr (any(target_env = "musl" , target_env = "ohos" ), allow(deprecated))] |
1370 | // FIXME(time): for `time_t` |
1371 | pub unsafefn timegm(tm: *mut crate::tm) -> time_t; |
1372 | |
1373 | #[cfg_attr (target_os = "netbsd" , link_name = "__mknod50" )] |
1374 | #[cfg_attr ( |
1375 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
1376 | link_name = "mknod@FBSD_1.0" |
1377 | )] |
1378 | pub unsafefn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int; |
1379 | pub unsafefn gethostname(name: *mut c_char, len: size_t) -> c_int; |
1380 | pub unsafefn endservent(); |
1381 | pub unsafefn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; |
1382 | pub unsafefn getservbyport(port: c_int, proto: *const c_char) -> *mut servent; |
1383 | pub unsafefn getservent() -> *mut servent; |
1384 | pub unsafefn setservent(stayopen: c_int); |
1385 | pub unsafefn getprotobyname(name: *const c_char) -> *mut protoent; |
1386 | pub unsafefn getprotobynumber(proto: c_int) -> *mut protoent; |
1387 | pub unsafefn chroot(name: *const c_char) -> c_int; |
1388 | #[cfg (target_os = "cygwin" )] |
1389 | pub fn usleep(secs: useconds_t) -> c_int; |
1390 | #[cfg_attr ( |
1391 | all(target_os = "macos" , target_arch = "x86" ), |
1392 | link_name = "usleep$UNIX2003" |
1393 | )] |
1394 | #[cfg (not(target_os = "cygwin" ))] |
1395 | pub unsafefn usleep(secs: c_uint) -> c_int; |
1396 | #[cfg_attr ( |
1397 | all(target_os = "macos" , target_arch = "x86" ), |
1398 | link_name = "send$UNIX2003" |
1399 | )] |
1400 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_send" )] |
1401 | pub unsafefn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t; |
1402 | #[cfg_attr ( |
1403 | all(target_os = "macos" , target_arch = "x86" ), |
1404 | link_name = "recv$UNIX2003" |
1405 | )] |
1406 | #[cfg_attr (target_os = "espidf" , link_name = "lwip_recv" )] |
1407 | pub unsafefn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t; |
1408 | #[cfg_attr ( |
1409 | all(target_os = "macos" , target_arch = "x86" ), |
1410 | link_name = "putenv$UNIX2003" |
1411 | )] |
1412 | #[cfg_attr (target_os = "netbsd" , link_name = "__putenv50" )] |
1413 | pub unsafefn putenv(string: *mut c_char) -> c_int; |
1414 | #[cfg_attr ( |
1415 | all(target_os = "macos" , target_arch = "x86" ), |
1416 | link_name = "poll$UNIX2003" |
1417 | )] |
1418 | pub unsafefn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int; |
1419 | #[cfg_attr ( |
1420 | all(target_os = "macos" , target_arch = "x86_64" ), |
1421 | link_name = "select$1050" |
1422 | )] |
1423 | #[cfg_attr ( |
1424 | all(target_os = "macos" , target_arch = "x86" ), |
1425 | link_name = "select$UNIX2003" |
1426 | )] |
1427 | #[cfg_attr (target_os = "netbsd" , link_name = "__select50" )] |
1428 | pub unsafefn select( |
1429 | nfds: c_int, |
1430 | readfds: *mut fd_set, |
1431 | writefds: *mut fd_set, |
1432 | errorfds: *mut fd_set, |
1433 | timeout: *mut timeval, |
1434 | ) -> c_int; |
1435 | #[cfg_attr (target_os = "netbsd" , link_name = "__setlocale50" )] |
1436 | pub unsafefn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; |
1437 | pub unsafefn localeconv() -> *mut lconv; |
1438 | |
1439 | #[cfg_attr ( |
1440 | all(target_os = "macos" , target_arch = "x86" ), |
1441 | link_name = "sem_wait$UNIX2003" |
1442 | )] |
1443 | pub unsafefn sem_wait(sem: *mut sem_t) -> c_int; |
1444 | pub unsafefn sem_trywait(sem: *mut sem_t) -> c_int; |
1445 | pub unsafefn sem_post(sem: *mut sem_t) -> c_int; |
1446 | pub unsafefn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; |
1447 | pub unsafefn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; |
1448 | |
1449 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigemptyset14" )] |
1450 | pub unsafefn sigemptyset(set: *mut sigset_t) -> c_int; |
1451 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigaddset14" )] |
1452 | pub unsafefn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int; |
1453 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigfillset14" )] |
1454 | pub unsafefn sigfillset(set: *mut sigset_t) -> c_int; |
1455 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigdelset14" )] |
1456 | pub unsafefn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; |
1457 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigismember14" )] |
1458 | pub unsafefn sigismember(set: *const sigset_t, signum: c_int) -> c_int; |
1459 | |
1460 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigprocmask14" )] |
1461 | pub unsafefn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; |
1462 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigpending14" )] |
1463 | pub unsafefn sigpending(set: *mut sigset_t) -> c_int; |
1464 | |
1465 | #[cfg_attr (target_os = "solaris" , link_name = "__sysconf_xpg7" )] |
1466 | pub unsafefn sysconf(name: c_int) -> c_long; |
1467 | |
1468 | pub unsafefn mkfifo(path: *const c_char, mode: mode_t) -> c_int; |
1469 | |
1470 | pub unsafefn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; |
1471 | pub unsafefn ftello(stream: *mut crate::FILE) -> off_t; |
1472 | #[cfg_attr ( |
1473 | all(target_os = "macos" , target_arch = "x86" ), |
1474 | link_name = "tcdrain$UNIX2003" |
1475 | )] |
1476 | pub unsafefn tcdrain(fd: c_int) -> c_int; |
1477 | pub unsafefn cfgetispeed(termios: *const crate::termios) -> crate::speed_t; |
1478 | pub unsafefn cfgetospeed(termios: *const crate::termios) -> crate::speed_t; |
1479 | pub unsafefn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; |
1480 | pub unsafefn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; |
1481 | pub unsafefn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; |
1482 | pub unsafefn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; |
1483 | pub unsafefn tcflow(fd: c_int, action: c_int) -> c_int; |
1484 | pub unsafefn tcflush(fd: c_int, action: c_int) -> c_int; |
1485 | pub unsafefn tcgetsid(fd: c_int) -> crate::pid_t; |
1486 | pub unsafefn tcsendbreak(fd: c_int, duration: c_int) -> c_int; |
1487 | pub unsafefn mkstemp(template: *mut c_char) -> c_int; |
1488 | pub unsafefn mkdtemp(template: *mut c_char) -> *mut c_char; |
1489 | |
1490 | pub unsafefn tmpnam(ptr: *mut c_char) -> *mut c_char; |
1491 | |
1492 | pub unsafefn openlog(ident: *const c_char, logopt: c_int, facility: c_int); |
1493 | pub unsafefn closelog(); |
1494 | pub unsafefn setlogmask(maskpri: c_int) -> c_int; |
1495 | #[cfg_attr (target_os = "macos" , link_name = "syslog$DARWIN_EXTSN" )] |
1496 | pub unsafefn syslog(priority: c_int, message: *const c_char, ...); |
1497 | #[cfg_attr ( |
1498 | all(target_os = "macos" , target_arch = "x86" ), |
1499 | link_name = "nice$UNIX2003" |
1500 | )] |
1501 | pub unsafefn nice(incr: c_int) -> c_int; |
1502 | |
1503 | pub unsafefn grantpt(fd: c_int) -> c_int; |
1504 | pub unsafefn posix_openpt(flags: c_int) -> c_int; |
1505 | pub unsafefn ptsname(fd: c_int) -> *mut c_char; |
1506 | pub unsafefn unlockpt(fd: c_int) -> c_int; |
1507 | |
1508 | pub unsafefn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; |
1509 | pub unsafefn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; |
1510 | |
1511 | pub unsafefn lockf(fd: c_int, cmd: c_int, len: off_t) -> c_int; |
1512 | |
1513 | } |
1514 | |
1515 | safe_f! { |
1516 | // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's |
1517 | // reimplement them for all UNIX platforms |
1518 | pub {const} fn htonl(hostlong: u32) -> u32 { |
1519 | u32::to_be(hostlong) |
1520 | } |
1521 | pub {const} fn htons(hostshort: u16) -> u16 { |
1522 | u16::to_be(hostshort) |
1523 | } |
1524 | pub {const} fn ntohl(netlong: u32) -> u32 { |
1525 | u32::from_be(netlong) |
1526 | } |
1527 | pub {const} fn ntohs(netshort: u16) -> u16 { |
1528 | u16::from_be(netshort) |
1529 | } |
1530 | } |
1531 | |
1532 | cfg_if! { |
1533 | if #[cfg(not(any( |
1534 | target_os = "emscripten" , |
1535 | target_os = "android" , |
1536 | target_os = "haiku" , |
1537 | target_os = "nto" , |
1538 | target_os = "solaris" , |
1539 | target_os = "cygwin" |
1540 | )))] { |
1541 | extern "C" { |
1542 | pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; |
1543 | } |
1544 | } else if #[cfg(target_os = "solaris" )] { |
1545 | extern "C" { |
1546 | pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> c_int; |
1547 | } |
1548 | } |
1549 | } |
1550 | |
1551 | cfg_if! { |
1552 | if #[cfg(not(any( |
1553 | target_os = "emscripten" , |
1554 | target_os = "android" , |
1555 | target_os = "nto" |
1556 | )))] { |
1557 | extern "C" { |
1558 | pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; |
1559 | } |
1560 | } |
1561 | } |
1562 | |
1563 | cfg_if! { |
1564 | if #[cfg(not(target_os = "android" ))] { |
1565 | extern "C" { |
1566 | #[cfg_attr ( |
1567 | all(target_os = "macos" , target_arch = "x86" ), |
1568 | link_name = "confstr$UNIX2003" |
1569 | )] |
1570 | #[cfg_attr (target_os = "solaris" , link_name = "__confstr_xpg7" )] |
1571 | pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t; |
1572 | } |
1573 | } |
1574 | } |
1575 | |
1576 | cfg_if! { |
1577 | if #[cfg(not(target_os = "aix" ))] { |
1578 | extern "C" { |
1579 | pub fn dladdr(addr: *const c_void, info: *mut Dl_info) -> c_int; |
1580 | } |
1581 | } |
1582 | } |
1583 | |
1584 | cfg_if! { |
1585 | if #[cfg(not(target_os = "solaris" ))] { |
1586 | extern "C" { |
1587 | pub fn flock(fd: c_int, operation: c_int) -> c_int; |
1588 | } |
1589 | } |
1590 | } |
1591 | |
1592 | cfg_if! { |
1593 | if #[cfg(not(any(target_env = "uclibc" , target_os = "nto" )))] { |
1594 | extern "C" { |
1595 | pub fn open_wmemstream(ptr: *mut *mut wchar_t, sizeloc: *mut size_t) -> *mut FILE; |
1596 | } |
1597 | } |
1598 | } |
1599 | |
1600 | cfg_if! { |
1601 | if #[cfg(not(target_os = "redox" ))] { |
1602 | extern "C" { |
1603 | pub fn getsid(pid: pid_t) -> pid_t; |
1604 | #[cfg_attr ( |
1605 | all(target_os = "macos" , target_arch = "x86" ), |
1606 | link_name = "pause$UNIX2003" |
1607 | )] |
1608 | pub fn pause() -> c_int; |
1609 | |
1610 | pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; |
1611 | pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; |
1612 | |
1613 | #[cfg_attr ( |
1614 | all(target_os = "macos" , target_arch = "x86_64" ), |
1615 | link_name = "fdopendir$INODE64" |
1616 | )] |
1617 | #[cfg_attr ( |
1618 | all(target_os = "macos" , target_arch = "x86" ), |
1619 | link_name = "fdopendir$INODE64$UNIX2003" |
1620 | )] |
1621 | pub fn fdopendir(fd: c_int) -> *mut crate::DIR; |
1622 | |
1623 | #[cfg_attr ( |
1624 | all(target_os = "macos" , not(target_arch = "aarch64" )), |
1625 | link_name = "readdir_r$INODE64" |
1626 | )] |
1627 | #[cfg_attr (target_os = "netbsd" , link_name = "__readdir_r30" )] |
1628 | #[cfg_attr ( |
1629 | all(target_os = "freebsd" , any(freebsd11, freebsd10)), |
1630 | link_name = "readdir_r@FBSD_1.0" |
1631 | )] |
1632 | #[allow (non_autolinks)] // FIXME(docs): `<>` breaks line length limit. |
1633 | /// The 64-bit libc on Solaris and illumos only has readdir_r. If a |
1634 | /// 32-bit Solaris or illumos target is ever created, it should use |
1635 | /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos: |
1636 | /// https://illumos.org/man/3lib/libc |
1637 | /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html |
1638 | /// https://www.unix.com/man-page/opensolaris/3LIB/libc/ |
1639 | pub fn readdir_r( |
1640 | dirp: *mut crate::DIR, |
1641 | entry: *mut crate::dirent, |
1642 | result: *mut *mut crate::dirent, |
1643 | ) -> c_int; |
1644 | } |
1645 | } |
1646 | } |
1647 | |
1648 | cfg_if! { |
1649 | if #[cfg(target_os = "nto" )] { |
1650 | extern "C" { |
1651 | pub fn readlinkat( |
1652 | dirfd: c_int, |
1653 | pathname: *const c_char, |
1654 | buf: *mut c_char, |
1655 | bufsiz: size_t, |
1656 | ) -> c_int; |
1657 | pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> c_int; |
1658 | pub fn pselect( |
1659 | nfds: c_int, |
1660 | readfds: *mut fd_set, |
1661 | writefds: *mut fd_set, |
1662 | errorfds: *mut fd_set, |
1663 | timeout: *mut timespec, |
1664 | sigmask: *const sigset_t, |
1665 | ) -> c_int; |
1666 | pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) |
1667 | -> c_int; |
1668 | } |
1669 | } else { |
1670 | extern "C" { |
1671 | pub fn readlinkat( |
1672 | dirfd: c_int, |
1673 | pathname: *const c_char, |
1674 | buf: *mut c_char, |
1675 | bufsiz: size_t, |
1676 | ) -> ssize_t; |
1677 | pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE; |
1678 | pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE; |
1679 | pub fn atexit(cb: extern "C" fn()) -> c_int; |
1680 | #[cfg_attr (target_os = "netbsd" , link_name = "__sigaction14" )] |
1681 | pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) |
1682 | -> c_int; |
1683 | pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> ssize_t; |
1684 | #[cfg_attr ( |
1685 | all(target_os = "macos" , target_arch = "x86_64" ), |
1686 | link_name = "pselect$1050" |
1687 | )] |
1688 | #[cfg_attr ( |
1689 | all(target_os = "macos" , target_arch = "x86" ), |
1690 | link_name = "pselect$UNIX2003" |
1691 | )] |
1692 | #[cfg_attr (target_os = "netbsd" , link_name = "__pselect50" )] |
1693 | pub fn pselect( |
1694 | nfds: c_int, |
1695 | readfds: *mut fd_set, |
1696 | writefds: *mut fd_set, |
1697 | errorfds: *mut fd_set, |
1698 | timeout: *const timespec, |
1699 | sigmask: *const sigset_t, |
1700 | ) -> c_int; |
1701 | } |
1702 | } |
1703 | } |
1704 | |
1705 | cfg_if! { |
1706 | if #[cfg(not(any( |
1707 | target_os = "solaris" , |
1708 | target_os = "illumos" , |
1709 | target_os = "nto" , |
1710 | )))] { |
1711 | extern "C" { |
1712 | pub fn cfmakeraw(termios: *mut crate::termios); |
1713 | pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; |
1714 | } |
1715 | } |
1716 | } |
1717 | |
1718 | unsafeextern "C" { |
1719 | pub unsafefn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int; |
1720 | } |
1721 | |
1722 | cfg_if! { |
1723 | if #[cfg(target_env = "newlib" )] { |
1724 | mod newlib; |
1725 | pub use self::newlib::*; |
1726 | } else if #[cfg(any( |
1727 | target_os = "linux" , |
1728 | target_os = "l4re" , |
1729 | target_os = "android" , |
1730 | target_os = "emscripten" |
1731 | ))] { |
1732 | mod linux_like; |
1733 | pub use self::linux_like::*; |
1734 | } else if #[cfg(any( |
1735 | target_os = "macos" , |
1736 | target_os = "ios" , |
1737 | target_os = "tvos" , |
1738 | target_os = "watchos" , |
1739 | target_os = "visionos" , |
1740 | target_os = "freebsd" , |
1741 | target_os = "dragonfly" , |
1742 | target_os = "openbsd" , |
1743 | target_os = "netbsd" |
1744 | ))] { |
1745 | mod bsd; |
1746 | pub use self::bsd::*; |
1747 | } else if #[cfg(any(target_os = "solaris" , target_os = "illumos" ))] { |
1748 | mod solarish; |
1749 | pub use self::solarish::*; |
1750 | } else if #[cfg(target_os = "haiku" )] { |
1751 | mod haiku; |
1752 | pub use self::haiku::*; |
1753 | } else if #[cfg(target_os = "redox" )] { |
1754 | mod redox; |
1755 | pub use self::redox::*; |
1756 | } else if #[cfg(target_os = "cygwin" )] { |
1757 | mod cygwin; |
1758 | pub use self::cygwin::*; |
1759 | } else if #[cfg(target_os = "nto" )] { |
1760 | mod nto; |
1761 | pub use self::nto::*; |
1762 | } else if #[cfg(target_os = "aix" )] { |
1763 | mod aix; |
1764 | pub use self::aix::*; |
1765 | } else if #[cfg(target_os = "hurd" )] { |
1766 | mod hurd; |
1767 | pub use self::hurd::*; |
1768 | } else if #[cfg(target_os = "nuttx" )] { |
1769 | mod nuttx; |
1770 | pub use self::nuttx::*; |
1771 | } else { |
1772 | // Unknown target_os |
1773 | } |
1774 | } |
1775 | |