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