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