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