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