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