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