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