1//! Windows CRT definitions 2 3pub type c_schar = i8; 4pub type c_uchar = u8; 5pub type c_short = i16; 6pub type c_ushort = u16; 7pub type c_int = i32; 8pub type c_uint = u32; 9pub type c_float = f32; 10pub type c_double = f64; 11pub type c_longlong = i64; 12pub type c_ulonglong = u64; 13pub type intmax_t = i64; 14pub type uintmax_t = u64; 15 16pub type size_t = usize; 17pub type ptrdiff_t = isize; 18pub type intptr_t = isize; 19pub type uintptr_t = usize; 20pub type ssize_t = isize; 21pub type sighandler_t = usize; 22 23pub type c_char = i8; 24pub type c_long = i32; 25pub type c_ulong = u32; 26pub type wchar_t = u16; 27 28pub type clock_t = i32; 29 30pub type errno_t = ::c_int; 31 32cfg_if! { 33 if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { 34 pub type time_t = i32; 35 } else { 36 pub type time_t = i64; 37 } 38} 39 40pub type off_t = i32; 41pub type dev_t = u32; 42pub type ino_t = u16; 43#[cfg_attr(feature = "extra_traits", derive(Debug))] 44pub enum timezone {} 45impl ::Copy for timezone {} 46impl ::Clone for timezone { 47 fn clone(&self) -> timezone { 48 *self 49 } 50} 51pub type time64_t = i64; 52 53pub type SOCKET = ::uintptr_t; 54 55s! { 56 // note this is the struct called stat64 in Windows. Not stat, nor stati64. 57 pub struct stat { 58 pub st_dev: dev_t, 59 pub st_ino: ino_t, 60 pub st_mode: u16, 61 pub st_nlink: ::c_short, 62 pub st_uid: ::c_short, 63 pub st_gid: ::c_short, 64 pub st_rdev: dev_t, 65 pub st_size: i64, 66 pub st_atime: time64_t, 67 pub st_mtime: time64_t, 68 pub st_ctime: time64_t, 69 } 70 71 // note that this is called utimbuf64 in Windows 72 pub struct utimbuf { 73 pub actime: time64_t, 74 pub modtime: time64_t, 75 } 76 77 pub struct tm { 78 pub tm_sec: ::c_int, 79 pub tm_min: ::c_int, 80 pub tm_hour: ::c_int, 81 pub tm_mday: ::c_int, 82 pub tm_mon: ::c_int, 83 pub tm_year: ::c_int, 84 pub tm_wday: ::c_int, 85 pub tm_yday: ::c_int, 86 pub tm_isdst: ::c_int, 87 } 88 89 pub struct timeval { 90 pub tv_sec: c_long, 91 pub tv_usec: c_long, 92 } 93 94 pub struct timespec { 95 pub tv_sec: time_t, 96 pub tv_nsec: c_long, 97 } 98 99 pub struct sockaddr { 100 pub sa_family: c_ushort, 101 pub sa_data: [c_char; 14], 102 } 103} 104 105pub const INT_MIN: c_int = -2147483648; 106pub const INT_MAX: c_int = 2147483647; 107 108pub const EXIT_FAILURE: ::c_int = 1; 109pub const EXIT_SUCCESS: ::c_int = 0; 110pub const RAND_MAX: ::c_int = 32767; 111pub const EOF: ::c_int = -1; 112pub const SEEK_SET: ::c_int = 0; 113pub const SEEK_CUR: ::c_int = 1; 114pub const SEEK_END: ::c_int = 2; 115pub const _IOFBF: ::c_int = 0; 116pub const _IONBF: ::c_int = 4; 117pub const _IOLBF: ::c_int = 64; 118pub const BUFSIZ: ::c_uint = 512; 119pub const FOPEN_MAX: ::c_uint = 20; 120pub const FILENAME_MAX: ::c_uint = 260; 121 122// fcntl.h 123pub const O_RDONLY: ::c_int = 0x0000; 124pub const O_WRONLY: ::c_int = 0x0001; 125pub const O_RDWR: ::c_int = 0x0002; 126pub const O_APPEND: ::c_int = 0x0008; 127pub const O_CREAT: ::c_int = 0x0100; 128pub const O_TRUNC: ::c_int = 0x0200; 129pub const O_EXCL: ::c_int = 0x0400; 130pub const O_TEXT: ::c_int = 0x4000; 131pub const O_BINARY: ::c_int = 0x8000; 132pub const _O_WTEXT: ::c_int = 0x10000; 133pub const _O_U16TEXT: ::c_int = 0x20000; 134pub const _O_U8TEXT: ::c_int = 0x40000; 135pub const O_RAW: ::c_int = O_BINARY; 136pub const O_NOINHERIT: ::c_int = 0x0080; 137pub const O_TEMPORARY: ::c_int = 0x0040; 138pub const _O_SHORT_LIVED: ::c_int = 0x1000; 139pub const _O_OBTAIN_DIR: ::c_int = 0x2000; 140pub const O_SEQUENTIAL: ::c_int = 0x0020; 141pub const O_RANDOM: ::c_int = 0x0010; 142 143pub const S_IFCHR: ::c_int = 8192; 144pub const S_IFDIR: ::c_int = 16384; 145pub const S_IFREG: ::c_int = 32768; 146pub const S_IFMT: ::c_int = 61440; 147pub const S_IEXEC: ::c_int = 64; 148pub const S_IWRITE: ::c_int = 128; 149pub const S_IREAD: ::c_int = 256; 150 151pub const LC_ALL: ::c_int = 0; 152pub const LC_COLLATE: ::c_int = 1; 153pub const LC_CTYPE: ::c_int = 2; 154pub const LC_MONETARY: ::c_int = 3; 155pub const LC_NUMERIC: ::c_int = 4; 156pub const LC_TIME: ::c_int = 5; 157 158pub const EPERM: ::c_int = 1; 159pub const ENOENT: ::c_int = 2; 160pub const ESRCH: ::c_int = 3; 161pub const EINTR: ::c_int = 4; 162pub const EIO: ::c_int = 5; 163pub const ENXIO: ::c_int = 6; 164pub const E2BIG: ::c_int = 7; 165pub const ENOEXEC: ::c_int = 8; 166pub const EBADF: ::c_int = 9; 167pub const ECHILD: ::c_int = 10; 168pub const EAGAIN: ::c_int = 11; 169pub const ENOMEM: ::c_int = 12; 170pub const EACCES: ::c_int = 13; 171pub const EFAULT: ::c_int = 14; 172pub const EBUSY: ::c_int = 16; 173pub const EEXIST: ::c_int = 17; 174pub const EXDEV: ::c_int = 18; 175pub const ENODEV: ::c_int = 19; 176pub const ENOTDIR: ::c_int = 20; 177pub const EISDIR: ::c_int = 21; 178pub const EINVAL: ::c_int = 22; 179pub const ENFILE: ::c_int = 23; 180pub const EMFILE: ::c_int = 24; 181pub const ENOTTY: ::c_int = 25; 182pub const EFBIG: ::c_int = 27; 183pub const ENOSPC: ::c_int = 28; 184pub const ESPIPE: ::c_int = 29; 185pub const EROFS: ::c_int = 30; 186pub const EMLINK: ::c_int = 31; 187pub const EPIPE: ::c_int = 32; 188pub const EDOM: ::c_int = 33; 189pub const ERANGE: ::c_int = 34; 190pub const EDEADLK: ::c_int = 36; 191pub const EDEADLOCK: ::c_int = 36; 192pub const ENAMETOOLONG: ::c_int = 38; 193pub const ENOLCK: ::c_int = 39; 194pub const ENOSYS: ::c_int = 40; 195pub const ENOTEMPTY: ::c_int = 41; 196pub const EILSEQ: ::c_int = 42; 197pub const STRUNCATE: ::c_int = 80; 198 199// POSIX Supplement (from errno.h) 200pub const EADDRINUSE: ::c_int = 100; 201pub const EADDRNOTAVAIL: ::c_int = 101; 202pub const EAFNOSUPPORT: ::c_int = 102; 203pub const EALREADY: ::c_int = 103; 204pub const EBADMSG: ::c_int = 104; 205pub const ECANCELED: ::c_int = 105; 206pub const ECONNABORTED: ::c_int = 106; 207pub const ECONNREFUSED: ::c_int = 107; 208pub const ECONNRESET: ::c_int = 108; 209pub const EDESTADDRREQ: ::c_int = 109; 210pub const EHOSTUNREACH: ::c_int = 110; 211pub const EIDRM: ::c_int = 111; 212pub const EINPROGRESS: ::c_int = 112; 213pub const EISCONN: ::c_int = 113; 214pub const ELOOP: ::c_int = 114; 215pub const EMSGSIZE: ::c_int = 115; 216pub const ENETDOWN: ::c_int = 116; 217pub const ENETRESET: ::c_int = 117; 218pub const ENETUNREACH: ::c_int = 118; 219pub const ENOBUFS: ::c_int = 119; 220pub const ENODATA: ::c_int = 120; 221pub const ENOLINK: ::c_int = 121; 222pub const ENOMSG: ::c_int = 122; 223pub const ENOPROTOOPT: ::c_int = 123; 224pub const ENOSR: ::c_int = 124; 225pub const ENOSTR: ::c_int = 125; 226pub const ENOTCONN: ::c_int = 126; 227pub const ENOTRECOVERABLE: ::c_int = 127; 228pub const ENOTSOCK: ::c_int = 128; 229pub const ENOTSUP: ::c_int = 129; 230pub const EOPNOTSUPP: ::c_int = 130; 231pub const EOVERFLOW: ::c_int = 132; 232pub const EOWNERDEAD: ::c_int = 133; 233pub const EPROTO: ::c_int = 134; 234pub const EPROTONOSUPPORT: ::c_int = 135; 235pub const EPROTOTYPE: ::c_int = 136; 236pub const ETIME: ::c_int = 137; 237pub const ETIMEDOUT: ::c_int = 138; 238pub const ETXTBSY: ::c_int = 139; 239pub const EWOULDBLOCK: ::c_int = 140; 240 241// signal codes 242pub const SIGINT: ::c_int = 2; 243pub const SIGILL: ::c_int = 4; 244pub const SIGFPE: ::c_int = 8; 245pub const SIGSEGV: ::c_int = 11; 246pub const SIGTERM: ::c_int = 15; 247pub const SIGABRT: ::c_int = 22; 248pub const NSIG: ::c_int = 23; 249 250pub const SIG_ERR: ::c_int = -1; 251pub const SIG_DFL: ::sighandler_t = 0; 252pub const SIG_IGN: ::sighandler_t = 1; 253pub const SIG_GET: ::sighandler_t = 2; 254pub const SIG_SGE: ::sighandler_t = 3; 255pub const SIG_ACK: ::sighandler_t = 4; 256 257// inline comment below appeases style checker 258#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if " 259#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] 260#[link(name = "libcmt", cfg(target_feature = "crt-static"))] 261extern "C" {} 262 263#[cfg_attr(feature = "extra_traits", derive(Debug))] 264pub enum FILE {} 265impl ::Copy for FILE {} 266impl ::Clone for FILE { 267 fn clone(&self) -> FILE { 268 *self 269 } 270} 271#[cfg_attr(feature = "extra_traits", derive(Debug))] 272pub enum fpos_t {} // FIXME: fill this out with a struct 273impl ::Copy for fpos_t {} 274impl ::Clone for fpos_t { 275 fn clone(&self) -> fpos_t { 276 *self 277 } 278} 279 280// Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860 281#[cfg_attr( 282 all(windows, target_env = "msvc"), 283 link(name = "legacy_stdio_definitions") 284)] 285extern "C" { 286 pub fn printf(format: *const c_char, ...) -> ::c_int; 287 pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int; 288} 289 290extern "C" { 291 pub fn isalnum(c: c_int) -> c_int; 292 pub fn isalpha(c: c_int) -> c_int; 293 pub fn iscntrl(c: c_int) -> c_int; 294 pub fn isdigit(c: c_int) -> c_int; 295 pub fn isgraph(c: c_int) -> c_int; 296 pub fn islower(c: c_int) -> c_int; 297 pub fn isprint(c: c_int) -> c_int; 298 pub fn ispunct(c: c_int) -> c_int; 299 pub fn isspace(c: c_int) -> c_int; 300 pub fn isupper(c: c_int) -> c_int; 301 pub fn isxdigit(c: c_int) -> c_int; 302 pub fn isblank(c: c_int) -> c_int; 303 pub fn tolower(c: c_int) -> c_int; 304 pub fn toupper(c: c_int) -> c_int; 305 pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; 306 pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; 307 pub fn fflush(file: *mut FILE) -> c_int; 308 pub fn fclose(file: *mut FILE) -> c_int; 309 pub fn remove(filename: *const c_char) -> c_int; 310 pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; 311 pub fn tmpfile() -> *mut FILE; 312 pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; 313 pub fn setbuf(stream: *mut FILE, buf: *mut c_char); 314 pub fn getchar() -> c_int; 315 pub fn putchar(c: c_int) -> c_int; 316 pub fn fgetc(stream: *mut FILE) -> c_int; 317 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; 318 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; 319 pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; 320 pub fn puts(s: *const c_char) -> c_int; 321 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; 322 pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; 323 pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; 324 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; 325 pub fn ftell(stream: *mut FILE) -> c_long; 326 pub fn rewind(stream: *mut FILE); 327 pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; 328 pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; 329 pub fn feof(stream: *mut FILE) -> c_int; 330 pub fn ferror(stream: *mut FILE) -> c_int; 331 pub fn perror(s: *const c_char); 332 pub fn atof(s: *const c_char) -> c_double; 333 pub fn atoi(s: *const c_char) -> c_int; 334 pub fn atol(s: *const c_char) -> c_long; 335 pub fn atoll(s: *const c_char) -> c_longlong; 336 pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; 337 pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; 338 pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; 339 pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; 340 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; 341 pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; 342 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; 343 pub fn malloc(size: size_t) -> *mut c_void; 344 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; 345 pub fn free(p: *mut c_void); 346 pub fn abort() -> !; 347 pub fn exit(status: c_int) -> !; 348 pub fn _exit(status: c_int) -> !; 349 pub fn atexit(cb: extern "C" fn()) -> c_int; 350 pub fn system(s: *const c_char) -> c_int; 351 pub fn getenv(s: *const c_char) -> *mut c_char; 352 353 pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; 354 pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; 355 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; 356 pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; 357 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; 358 pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; 359 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; 360 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; 361 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; 362 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; 363 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; 364 pub fn strdup(cs: *const c_char) -> *mut c_char; 365 pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; 366 pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; 367 pub fn strlen(cs: *const c_char) -> size_t; 368 pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; 369 pub fn strerror(n: c_int) -> *mut c_char; 370 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; 371 pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; 372 pub fn wcslen(buf: *const wchar_t) -> size_t; 373 pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t; 374 375 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; 376 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; 377 pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; 378 pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; 379 pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; 380 381 pub fn abs(i: c_int) -> c_int; 382 pub fn labs(i: c_long) -> c_long; 383 pub fn rand() -> c_int; 384 pub fn srand(seed: c_uint); 385 386 pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; 387 pub fn raise(signum: c_int) -> c_int; 388 389 #[link_name = "_gmtime64_s"] 390 pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> ::c_int; 391 #[link_name = "_localtime64_s"] 392 pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> ::errno_t; 393 #[link_name = "_time64"] 394 pub fn time(destTime: *mut time_t) -> time_t; 395 #[link_name = "_chmod"] 396 pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; 397 #[link_name = "_wchmod"] 398 pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int; 399 #[link_name = "_mkdir"] 400 pub fn mkdir(path: *const c_char) -> ::c_int; 401 #[link_name = "_wrmdir"] 402 pub fn wrmdir(path: *const wchar_t) -> ::c_int; 403 #[link_name = "_fstat64"] 404 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; 405 #[link_name = "_stat64"] 406 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; 407 #[link_name = "_wstat64"] 408 pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int; 409 #[link_name = "_wutime64"] 410 pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int; 411 #[link_name = "_popen"] 412 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; 413 #[link_name = "_pclose"] 414 pub fn pclose(stream: *mut ::FILE) -> ::c_int; 415 #[link_name = "_fdopen"] 416 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; 417 #[link_name = "_fileno"] 418 pub fn fileno(stream: *mut ::FILE) -> ::c_int; 419 #[link_name = "_open"] 420 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; 421 #[link_name = "_wopen"] 422 pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int; 423 #[link_name = "_creat"] 424 pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int; 425 #[link_name = "_access"] 426 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; 427 #[link_name = "_chdir"] 428 pub fn chdir(dir: *const c_char) -> ::c_int; 429 #[link_name = "_close"] 430 pub fn close(fd: ::c_int) -> ::c_int; 431 #[link_name = "_dup"] 432 pub fn dup(fd: ::c_int) -> ::c_int; 433 #[link_name = "_dup2"] 434 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; 435 #[link_name = "_execl"] 436 pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; 437 #[link_name = "_wexecl"] 438 pub fn wexecl(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; 439 #[link_name = "_execle"] 440 pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; 441 #[link_name = "_wexecle"] 442 pub fn wexecle(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; 443 #[link_name = "_execlp"] 444 pub fn execlp(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; 445 #[link_name = "_wexeclp"] 446 pub fn wexeclp(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; 447 #[link_name = "_execlpe"] 448 pub fn execlpe(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; 449 #[link_name = "_wexeclpe"] 450 pub fn wexeclpe(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; 451 #[link_name = "_execv"] 452 pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t; 453 #[link_name = "_execve"] 454 pub fn execve( 455 prog: *const c_char, 456 argv: *const *const c_char, 457 envp: *const *const c_char, 458 ) -> ::c_int; 459 #[link_name = "_execvp"] 460 pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; 461 #[link_name = "_execvpe"] 462 pub fn execvpe( 463 c: *const c_char, 464 argv: *const *const c_char, 465 envp: *const *const c_char, 466 ) -> ::c_int; 467 #[link_name = "_wexecv"] 468 pub fn wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t; 469 #[link_name = "_wexecve"] 470 pub fn wexecve( 471 prog: *const wchar_t, 472 argv: *const *const wchar_t, 473 envp: *const *const wchar_t, 474 ) -> ::intptr_t; 475 #[link_name = "_wexecvp"] 476 pub fn wexecvp(c: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t; 477 #[link_name = "_wexecvpe"] 478 pub fn wexecvpe( 479 c: *const wchar_t, 480 argv: *const *const wchar_t, 481 envp: *const *const wchar_t, 482 ) -> ::intptr_t; 483 #[link_name = "_getcwd"] 484 pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char; 485 #[link_name = "_getpid"] 486 pub fn getpid() -> ::c_int; 487 #[link_name = "_isatty"] 488 pub fn isatty(fd: ::c_int) -> ::c_int; 489 #[link_name = "_lseek"] 490 pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; 491 #[link_name = "_lseeki64"] 492 pub fn lseek64(fd: ::c_int, offset: c_longlong, origin: ::c_int) -> c_longlong; 493 #[link_name = "_pipe"] 494 pub fn pipe(fds: *mut ::c_int, psize: ::c_uint, textmode: ::c_int) -> ::c_int; 495 #[link_name = "_read"] 496 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int; 497 #[link_name = "_rmdir"] 498 pub fn rmdir(path: *const c_char) -> ::c_int; 499 #[link_name = "_unlink"] 500 pub fn unlink(c: *const c_char) -> ::c_int; 501 #[link_name = "_write"] 502 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int; 503 #[link_name = "_commit"] 504 pub fn commit(fd: ::c_int) -> ::c_int; 505 #[link_name = "_get_osfhandle"] 506 pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t; 507 #[link_name = "_open_osfhandle"] 508 pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int; 509 pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char; 510 #[link_name = "_wsetlocale"] 511 pub fn wsetlocale(category: ::c_int, locale: *const wchar_t) -> *mut wchar_t; 512 #[link_name = "_aligned_malloc"] 513 pub fn aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void; 514 #[link_name = "_aligned_free"] 515 pub fn aligned_free(ptr: *mut ::c_void); 516 #[link_name = "_putenv"] 517 pub fn putenv(envstring: *const ::c_char) -> ::c_int; 518 #[link_name = "_wputenv"] 519 pub fn wputenv(envstring: *const ::wchar_t) -> ::c_int; 520 #[link_name = "_putenv_s"] 521 pub fn putenv_s(envstring: *const ::c_char, value_string: *const ::c_char) -> ::errno_t; 522 #[link_name = "_wputenv_s"] 523 pub fn wputenv_s(envstring: *const ::wchar_t, value_string: *const ::wchar_t) -> ::errno_t; 524} 525 526extern "system" { 527 pub fn listen(s: SOCKET, backlog: ::c_int) -> ::c_int; 528 pub fn accept(s: SOCKET, addr: *mut ::sockaddr, addrlen: *mut ::c_int) -> SOCKET; 529 pub fn bind(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int; 530 pub fn connect(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int; 531 pub fn getpeername(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int; 532 pub fn getsockname(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int; 533 pub fn getsockopt( 534 s: SOCKET, 535 level: ::c_int, 536 optname: ::c_int, 537 optval: *mut ::c_char, 538 optlen: *mut ::c_int, 539 ) -> ::c_int; 540 pub fn recvfrom( 541 s: SOCKET, 542 buf: *mut ::c_char, 543 len: ::c_int, 544 flags: ::c_int, 545 from: *mut ::sockaddr, 546 fromlen: *mut ::c_int, 547 ) -> ::c_int; 548 pub fn sendto( 549 s: SOCKET, 550 buf: *const ::c_char, 551 len: ::c_int, 552 flags: ::c_int, 553 to: *const ::sockaddr, 554 tolen: ::c_int, 555 ) -> ::c_int; 556 pub fn setsockopt( 557 s: SOCKET, 558 level: ::c_int, 559 optname: ::c_int, 560 optval: *const ::c_char, 561 optlen: ::c_int, 562 ) -> ::c_int; 563 pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET; 564} 565 566cfg_if! { 567 if #[cfg(libc_core_cvoid)] { 568 pub use ::ffi::c_void; 569 } else { 570 // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help 571 // enable more optimization opportunities around it recognizing things 572 // like malloc/free. 573 #[repr(u8)] 574 #[allow(missing_copy_implementations)] 575 #[allow(missing_debug_implementations)] 576 pub enum c_void { 577 // Two dummy variants so the #[repr] attribute can be used. 578 #[doc(hidden)] 579 __variant1, 580 #[doc(hidden)] 581 __variant2, 582 } 583 } 584} 585 586cfg_if! { 587 if #[cfg(all(target_env = "gnu"))] { 588 mod gnu; 589 pub use self::gnu::*; 590 } else if #[cfg(all(target_env = "msvc"))] { 591 mod msvc; 592 pub use self::msvc::*; 593 } else { 594 // Unknown target_env 595 } 596} 597