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