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