xref: /rust-libc-0.2.174/src/windows/mod.rs (revision 28e6ae29)
1 //! Windows CRT definitions
2 
3 use crate::prelude::*;
4 
5 pub type intmax_t = i64;
6 pub type uintmax_t = u64;
7 
8 pub type size_t = usize;
9 pub type ptrdiff_t = isize;
10 pub type intptr_t = isize;
11 pub type uintptr_t = usize;
12 pub type ssize_t = isize;
13 pub type sighandler_t = usize;
14 
15 pub type wchar_t = u16;
16 
17 pub type clock_t = i32;
18 
19 pub type errno_t = c_int;
20 
21 cfg_if! {
22     if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
23         pub type time_t = i32;
24     } else {
25         pub type time_t = i64;
26     }
27 }
28 
29 pub type off_t = i32;
30 pub type dev_t = u32;
31 pub type ino_t = u16;
32 #[cfg_attr(feature = "extra_traits", derive(Debug))]
33 pub enum timezone {}
34 impl Copy for timezone {}
35 impl Clone for timezone {
clone(&self) -> timezone36     fn clone(&self) -> timezone {
37         *self
38     }
39 }
40 pub type time64_t = i64;
41 
42 pub type SOCKET = crate::uintptr_t;
43 
44 s! {
45     // note this is the struct called stat64 in Windows. Not stat, nor stati64.
46     pub struct stat {
47         pub st_dev: dev_t,
48         pub st_ino: ino_t,
49         pub st_mode: u16,
50         pub st_nlink: c_short,
51         pub st_uid: c_short,
52         pub st_gid: c_short,
53         pub st_rdev: dev_t,
54         pub st_size: i64,
55         pub st_atime: time64_t,
56         pub st_mtime: time64_t,
57         pub st_ctime: time64_t,
58     }
59 
60     // note that this is called utimbuf64 in Windows
61     pub struct utimbuf {
62         pub actime: time64_t,
63         pub modtime: time64_t,
64     }
65 
66     pub struct tm {
67         pub tm_sec: c_int,
68         pub tm_min: c_int,
69         pub tm_hour: c_int,
70         pub tm_mday: c_int,
71         pub tm_mon: c_int,
72         pub tm_year: c_int,
73         pub tm_wday: c_int,
74         pub tm_yday: c_int,
75         pub tm_isdst: c_int,
76     }
77 
78     pub struct timeval {
79         pub tv_sec: c_long,
80         pub tv_usec: c_long,
81     }
82 
83     pub struct timespec {
84         pub tv_sec: time_t,
85         pub tv_nsec: c_long,
86     }
87 
88     pub struct sockaddr {
89         pub sa_family: c_ushort,
90         pub sa_data: [c_char; 14],
91     }
92 }
93 
94 pub const INT_MIN: c_int = -2147483648;
95 pub const INT_MAX: c_int = 2147483647;
96 
97 pub const EXIT_FAILURE: c_int = 1;
98 pub const EXIT_SUCCESS: c_int = 0;
99 pub const RAND_MAX: c_int = 32767;
100 pub const EOF: c_int = -1;
101 pub const SEEK_SET: c_int = 0;
102 pub const SEEK_CUR: c_int = 1;
103 pub const SEEK_END: c_int = 2;
104 pub const _IOFBF: c_int = 0;
105 pub const _IONBF: c_int = 4;
106 pub const _IOLBF: c_int = 64;
107 pub const BUFSIZ: c_uint = 512;
108 pub const FOPEN_MAX: c_uint = 20;
109 pub const FILENAME_MAX: c_uint = 260;
110 
111 // fcntl.h
112 pub const O_RDONLY: c_int = 0x0000;
113 pub const O_WRONLY: c_int = 0x0001;
114 pub const O_RDWR: c_int = 0x0002;
115 pub const O_APPEND: c_int = 0x0008;
116 pub const O_CREAT: c_int = 0x0100;
117 pub const O_TRUNC: c_int = 0x0200;
118 pub const O_EXCL: c_int = 0x0400;
119 pub const O_TEXT: c_int = 0x4000;
120 pub const O_BINARY: c_int = 0x8000;
121 pub const _O_WTEXT: c_int = 0x10000;
122 pub const _O_U16TEXT: c_int = 0x20000;
123 pub const _O_U8TEXT: c_int = 0x40000;
124 pub const O_RAW: c_int = O_BINARY;
125 pub const O_NOINHERIT: c_int = 0x0080;
126 pub const O_TEMPORARY: c_int = 0x0040;
127 pub const _O_SHORT_LIVED: c_int = 0x1000;
128 pub const _O_OBTAIN_DIR: c_int = 0x2000;
129 pub const O_SEQUENTIAL: c_int = 0x0020;
130 pub const O_RANDOM: c_int = 0x0010;
131 
132 pub const S_IFCHR: c_int = 0o2_0000;
133 pub const S_IFDIR: c_int = 0o4_0000;
134 pub const S_IFREG: c_int = 0o10_0000;
135 pub const S_IFMT: c_int = 0o17_0000;
136 pub const S_IEXEC: c_int = 0o0100;
137 pub const S_IWRITE: c_int = 0o0200;
138 pub const S_IREAD: c_int = 0o0400;
139 
140 pub const LC_ALL: c_int = 0;
141 pub const LC_COLLATE: c_int = 1;
142 pub const LC_CTYPE: c_int = 2;
143 pub const LC_MONETARY: c_int = 3;
144 pub const LC_NUMERIC: c_int = 4;
145 pub const LC_TIME: c_int = 5;
146 
147 pub const EPERM: c_int = 1;
148 pub const ENOENT: c_int = 2;
149 pub const ESRCH: c_int = 3;
150 pub const EINTR: c_int = 4;
151 pub const EIO: c_int = 5;
152 pub const ENXIO: c_int = 6;
153 pub const E2BIG: c_int = 7;
154 pub const ENOEXEC: c_int = 8;
155 pub const EBADF: c_int = 9;
156 pub const ECHILD: c_int = 10;
157 pub const EAGAIN: c_int = 11;
158 pub const ENOMEM: c_int = 12;
159 pub const EACCES: c_int = 13;
160 pub const EFAULT: c_int = 14;
161 pub const EBUSY: c_int = 16;
162 pub const EEXIST: c_int = 17;
163 pub const EXDEV: c_int = 18;
164 pub const ENODEV: c_int = 19;
165 pub const ENOTDIR: c_int = 20;
166 pub const EISDIR: c_int = 21;
167 pub const EINVAL: c_int = 22;
168 pub const ENFILE: c_int = 23;
169 pub const EMFILE: c_int = 24;
170 pub const ENOTTY: c_int = 25;
171 pub const EFBIG: c_int = 27;
172 pub const ENOSPC: c_int = 28;
173 pub const ESPIPE: c_int = 29;
174 pub const EROFS: c_int = 30;
175 pub const EMLINK: c_int = 31;
176 pub const EPIPE: c_int = 32;
177 pub const EDOM: c_int = 33;
178 pub const ERANGE: c_int = 34;
179 pub const EDEADLK: c_int = 36;
180 pub const EDEADLOCK: c_int = 36;
181 pub const ENAMETOOLONG: c_int = 38;
182 pub const ENOLCK: c_int = 39;
183 pub const ENOSYS: c_int = 40;
184 pub const ENOTEMPTY: c_int = 41;
185 pub const EILSEQ: c_int = 42;
186 pub const STRUNCATE: c_int = 80;
187 
188 // POSIX Supplement (from errno.h)
189 pub const EADDRINUSE: c_int = 100;
190 pub const EADDRNOTAVAIL: c_int = 101;
191 pub const EAFNOSUPPORT: c_int = 102;
192 pub const EALREADY: c_int = 103;
193 pub const EBADMSG: c_int = 104;
194 pub const ECANCELED: c_int = 105;
195 pub const ECONNABORTED: c_int = 106;
196 pub const ECONNREFUSED: c_int = 107;
197 pub const ECONNRESET: c_int = 108;
198 pub const EDESTADDRREQ: c_int = 109;
199 pub const EHOSTUNREACH: c_int = 110;
200 pub const EIDRM: c_int = 111;
201 pub const EINPROGRESS: c_int = 112;
202 pub const EISCONN: c_int = 113;
203 pub const ELOOP: c_int = 114;
204 pub const EMSGSIZE: c_int = 115;
205 pub const ENETDOWN: c_int = 116;
206 pub const ENETRESET: c_int = 117;
207 pub const ENETUNREACH: c_int = 118;
208 pub const ENOBUFS: c_int = 119;
209 pub const ENODATA: c_int = 120;
210 pub const ENOLINK: c_int = 121;
211 pub const ENOMSG: c_int = 122;
212 pub const ENOPROTOOPT: c_int = 123;
213 pub const ENOSR: c_int = 124;
214 pub const ENOSTR: c_int = 125;
215 pub const ENOTCONN: c_int = 126;
216 pub const ENOTRECOVERABLE: c_int = 127;
217 pub const ENOTSOCK: c_int = 128;
218 pub const ENOTSUP: c_int = 129;
219 pub const EOPNOTSUPP: c_int = 130;
220 pub const EOVERFLOW: c_int = 132;
221 pub const EOWNERDEAD: c_int = 133;
222 pub const EPROTO: c_int = 134;
223 pub const EPROTONOSUPPORT: c_int = 135;
224 pub const EPROTOTYPE: c_int = 136;
225 pub const ETIME: c_int = 137;
226 pub const ETIMEDOUT: c_int = 138;
227 pub const ETXTBSY: c_int = 139;
228 pub const EWOULDBLOCK: c_int = 140;
229 
230 // signal codes
231 pub const SIGINT: c_int = 2;
232 pub const SIGILL: c_int = 4;
233 pub const SIGFPE: c_int = 8;
234 pub const SIGSEGV: c_int = 11;
235 pub const SIGTERM: c_int = 15;
236 pub const SIGABRT: c_int = 22;
237 pub const NSIG: c_int = 23;
238 
239 pub const SIG_ERR: c_int = -1;
240 pub const SIG_DFL: crate::sighandler_t = 0;
241 pub const SIG_IGN: crate::sighandler_t = 1;
242 pub const SIG_GET: crate::sighandler_t = 2;
243 pub const SIG_SGE: crate::sighandler_t = 3;
244 pub const SIG_ACK: crate::sighandler_t = 4;
245 
246 // DIFF(main): removed in 458c58f409
247 // FIXME(msrv): done by `std` starting in 1.79.0
248 // inline comment below appeases style checker
249 #[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
250 #[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
251 #[link(name = "libcmt", cfg(target_feature = "crt-static"))]
252 extern "C" {}
253 
254 #[cfg_attr(feature = "extra_traits", derive(Debug))]
255 pub enum FILE {}
256 impl Copy for FILE {}
257 impl Clone for FILE {
clone(&self) -> FILE258     fn clone(&self) -> FILE {
259         *self
260     }
261 }
262 #[cfg_attr(feature = "extra_traits", derive(Debug))]
263 pub enum fpos_t {} // FIXME(windows): fill this out with a struct
264 impl Copy for fpos_t {}
265 impl Clone for fpos_t {
clone(&self) -> fpos_t266     fn clone(&self) -> fpos_t {
267         *self
268     }
269 }
270 
271 // Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860
272 cfg_if! {
273     if #[cfg(not(feature = "rustc-dep-of-std"))] {
274         #[cfg_attr(
275             all(windows, target_env = "msvc"),
276             link(name = "legacy_stdio_definitions")
277         )]
278         extern "C" {
279             pub fn printf(format: *const c_char, ...) -> c_int;
280             pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> c_int;
281         }
282     }
283 }
284 
285 extern "C" {
isalnum(c: c_int) -> c_int286     pub fn isalnum(c: c_int) -> c_int;
isalpha(c: c_int) -> c_int287     pub fn isalpha(c: c_int) -> c_int;
iscntrl(c: c_int) -> c_int288     pub fn iscntrl(c: c_int) -> c_int;
isdigit(c: c_int) -> c_int289     pub fn isdigit(c: c_int) -> c_int;
isgraph(c: c_int) -> c_int290     pub fn isgraph(c: c_int) -> c_int;
islower(c: c_int) -> c_int291     pub fn islower(c: c_int) -> c_int;
isprint(c: c_int) -> c_int292     pub fn isprint(c: c_int) -> c_int;
ispunct(c: c_int) -> c_int293     pub fn ispunct(c: c_int) -> c_int;
isspace(c: c_int) -> c_int294     pub fn isspace(c: c_int) -> c_int;
isupper(c: c_int) -> c_int295     pub fn isupper(c: c_int) -> c_int;
isxdigit(c: c_int) -> c_int296     pub fn isxdigit(c: c_int) -> c_int;
isblank(c: c_int) -> c_int297     pub fn isblank(c: c_int) -> c_int;
tolower(c: c_int) -> c_int298     pub fn tolower(c: c_int) -> c_int;
toupper(c: c_int) -> c_int299     pub fn toupper(c: c_int) -> c_int;
fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE300     pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE301     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
fflush(file: *mut FILE) -> c_int302     pub fn fflush(file: *mut FILE) -> c_int;
fclose(file: *mut FILE) -> c_int303     pub fn fclose(file: *mut FILE) -> c_int;
remove(filename: *const c_char) -> c_int304     pub fn remove(filename: *const c_char) -> c_int;
rename(oldname: *const c_char, newname: *const c_char) -> c_int305     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
tmpfile() -> *mut FILE306     pub fn tmpfile() -> *mut FILE;
setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int307     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
setbuf(stream: *mut FILE, buf: *mut c_char)308     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
getchar() -> c_int309     pub fn getchar() -> c_int;
putchar(c: c_int) -> c_int310     pub fn putchar(c: c_int) -> c_int;
fgetc(stream: *mut FILE) -> c_int311     pub fn fgetc(stream: *mut FILE) -> c_int;
fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char312     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
fputc(c: c_int, stream: *mut FILE) -> c_int313     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
fputs(s: *const c_char, stream: *mut FILE) -> c_int314     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
puts(s: *const c_char) -> c_int315     pub fn puts(s: *const c_char) -> c_int;
ungetc(c: c_int, stream: *mut FILE) -> c_int316     pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t317     pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t318     pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int319     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
ftell(stream: *mut FILE) -> c_long320     pub fn ftell(stream: *mut FILE) -> c_long;
rewind(stream: *mut FILE)321     pub fn rewind(stream: *mut FILE);
fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int322     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int323     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
feof(stream: *mut FILE) -> c_int324     pub fn feof(stream: *mut FILE) -> c_int;
ferror(stream: *mut FILE) -> c_int325     pub fn ferror(stream: *mut FILE) -> c_int;
perror(s: *const c_char)326     pub fn perror(s: *const c_char);
atof(s: *const c_char) -> c_double327     pub fn atof(s: *const c_char) -> c_double;
atoi(s: *const c_char) -> c_int328     pub fn atoi(s: *const c_char) -> c_int;
atol(s: *const c_char) -> c_long329     pub fn atol(s: *const c_char) -> c_long;
atoll(s: *const c_char) -> c_longlong330     pub fn atoll(s: *const c_char) -> c_longlong;
strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double331     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float332     pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long333     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong334     pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong335     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong336     pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
calloc(nobj: size_t, size: size_t) -> *mut c_void337     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
malloc(size: size_t) -> *mut c_void338     pub fn malloc(size: size_t) -> *mut c_void;
_msize(p: *mut c_void) -> size_t339     pub fn _msize(p: *mut c_void) -> size_t;
realloc(p: *mut c_void, size: size_t) -> *mut c_void340     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
free(p: *mut c_void)341     pub fn free(p: *mut c_void);
abort() -> !342     pub fn abort() -> !;
exit(status: c_int) -> !343     pub fn exit(status: c_int) -> !;
_exit(status: c_int) -> !344     pub fn _exit(status: c_int) -> !;
atexit(cb: extern "C" fn()) -> c_int345     pub fn atexit(cb: extern "C" fn()) -> c_int;
system(s: *const c_char) -> c_int346     pub fn system(s: *const c_char) -> c_int;
getenv(s: *const c_char) -> *mut c_char347     pub fn getenv(s: *const c_char) -> *mut c_char;
348 
strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char349     pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char350     pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char351     pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char352     pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
strcmp(cs: *const c_char, ct: *const c_char) -> c_int353     pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int354     pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
strcoll(cs: *const c_char, ct: *const c_char) -> c_int355     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
strchr(cs: *const c_char, c: c_int) -> *mut c_char356     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
strrchr(cs: *const c_char, c: c_int) -> *mut c_char357     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
strspn(cs: *const c_char, ct: *const c_char) -> size_t358     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
strcspn(cs: *const c_char, ct: *const c_char) -> size_t359     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
strdup(cs: *const c_char) -> *mut c_char360     pub fn strdup(cs: *const c_char) -> *mut c_char;
strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char361     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char362     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strlen(cs: *const c_char) -> size_t363     pub fn strlen(cs: *const c_char) -> size_t;
strnlen(cs: *const c_char, maxlen: size_t) -> size_t364     pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
strerror(n: c_int) -> *mut c_char365     pub fn strerror(n: c_int) -> *mut c_char;
strtok(s: *mut c_char, t: *const c_char) -> *mut c_char366     pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t367     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
wcslen(buf: *const wchar_t) -> size_t368     pub fn wcslen(buf: *const wchar_t) -> size_t;
wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t369     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t;
370 
memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void371     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int372     pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void373     pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void374     pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void375     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
376 
abs(i: c_int) -> c_int377     pub fn abs(i: c_int) -> c_int;
labs(i: c_long) -> c_long378     pub fn labs(i: c_long) -> c_long;
rand() -> c_int379     pub fn rand() -> c_int;
srand(seed: c_uint)380     pub fn srand(seed: c_uint);
381 
signal(signum: c_int, handler: sighandler_t) -> sighandler_t382     pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
raise(signum: c_int) -> c_int383     pub fn raise(signum: c_int) -> c_int;
384 
clock() -> clock_t385     pub fn clock() -> clock_t;
ctime(sourceTime: *const time_t) -> *mut c_char386     pub fn ctime(sourceTime: *const time_t) -> *mut c_char;
difftime(timeEnd: time_t, timeStart: time_t) -> c_double387     pub fn difftime(timeEnd: time_t, timeStart: time_t) -> c_double;
388     #[link_name = "_gmtime64_s"]
gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> c_int389     pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> c_int;
390     #[link_name = "_get_daylight"]
get_daylight(hours: *mut c_int) -> errno_t391     pub fn get_daylight(hours: *mut c_int) -> errno_t;
392     #[link_name = "_get_dstbias"]
get_dstbias(seconds: *mut c_long) -> errno_t393     pub fn get_dstbias(seconds: *mut c_long) -> errno_t;
394     #[link_name = "_get_timezone"]
get_timezone(seconds: *mut c_long) -> errno_t395     pub fn get_timezone(seconds: *mut c_long) -> errno_t;
396     #[link_name = "_get_tzname"]
get_tzname( p_return_value: *mut size_t, time_zone_name: *mut c_char, size_in_bytes: size_t, index: c_int, ) -> errno_t397     pub fn get_tzname(
398         p_return_value: *mut size_t,
399         time_zone_name: *mut c_char,
400         size_in_bytes: size_t,
401         index: c_int,
402     ) -> errno_t;
403     #[link_name = "_localtime64_s"]
localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> crate::errno_t404     pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> crate::errno_t;
405     #[link_name = "_time64"]
time(destTime: *mut time_t) -> time_t406     pub fn time(destTime: *mut time_t) -> time_t;
407     #[link_name = "_tzset"]
tzset()408     pub fn tzset();
409     #[link_name = "_chmod"]
chmod(path: *const c_char, mode: c_int) -> c_int410     pub fn chmod(path: *const c_char, mode: c_int) -> c_int;
411     #[link_name = "_wchmod"]
wchmod(path: *const wchar_t, mode: c_int) -> c_int412     pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int;
413     #[link_name = "_mkdir"]
mkdir(path: *const c_char) -> c_int414     pub fn mkdir(path: *const c_char) -> c_int;
415     #[link_name = "_wrmdir"]
wrmdir(path: *const wchar_t) -> c_int416     pub fn wrmdir(path: *const wchar_t) -> c_int;
417     #[link_name = "_fstat64"]
fstat(fildes: c_int, buf: *mut stat) -> c_int418     pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
419     #[link_name = "_stat64"]
stat(path: *const c_char, buf: *mut stat) -> c_int420     pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
421     #[link_name = "_wstat64"]
wstat(path: *const wchar_t, buf: *mut stat) -> c_int422     pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int;
423     #[link_name = "_wutime64"]
wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int424     pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int;
425     #[link_name = "_popen"]
popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE426     pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE;
427     #[link_name = "_pclose"]
pclose(stream: *mut crate::FILE) -> c_int428     pub fn pclose(stream: *mut crate::FILE) -> c_int;
429     #[link_name = "_fdopen"]
fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE430     pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE;
431     #[link_name = "_fileno"]
fileno(stream: *mut crate::FILE) -> c_int432     pub fn fileno(stream: *mut crate::FILE) -> c_int;
433     #[link_name = "_open"]
open(path: *const c_char, oflag: c_int, ...) -> c_int434     pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
435     #[link_name = "_wopen"]
wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int436     pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int;
437     #[link_name = "_creat"]
creat(path: *const c_char, mode: c_int) -> c_int438     pub fn creat(path: *const c_char, mode: c_int) -> c_int;
439     #[link_name = "_access"]
access(path: *const c_char, amode: c_int) -> c_int440     pub fn access(path: *const c_char, amode: c_int) -> c_int;
441     #[link_name = "_chdir"]
chdir(dir: *const c_char) -> c_int442     pub fn chdir(dir: *const c_char) -> c_int;
443     #[link_name = "_close"]
close(fd: c_int) -> c_int444     pub fn close(fd: c_int) -> c_int;
445     #[link_name = "_dup"]
dup(fd: c_int) -> c_int446     pub fn dup(fd: c_int) -> c_int;
447     #[link_name = "_dup2"]
dup2(src: c_int, dst: c_int) -> c_int448     pub fn dup2(src: c_int, dst: c_int) -> c_int;
449     #[link_name = "_execl"]
execl(path: *const c_char, arg0: *const c_char, ...) -> intptr_t450     pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
451     #[link_name = "_wexecl"]
wexecl(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t452     pub fn wexecl(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
453     #[link_name = "_execle"]
execle(path: *const c_char, arg0: *const c_char, ...) -> intptr_t454     pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
455     #[link_name = "_wexecle"]
wexecle(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t456     pub fn wexecle(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
457     #[link_name = "_execlp"]
execlp(path: *const c_char, arg0: *const c_char, ...) -> intptr_t458     pub fn execlp(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
459     #[link_name = "_wexeclp"]
wexeclp(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t460     pub fn wexeclp(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
461     #[link_name = "_execlpe"]
execlpe(path: *const c_char, arg0: *const c_char, ...) -> intptr_t462     pub fn execlpe(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
463     #[link_name = "_wexeclpe"]
wexeclpe(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t464     pub fn wexeclpe(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
465     #[link_name = "_execv"]
466     // DIFF(main): changed to `intptr_t` in e77f551de9
execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t467     pub fn execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t;
468     #[link_name = "_execve"]
execve( prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> c_int469     pub fn execve(
470         prog: *const c_char,
471         argv: *const *const c_char,
472         envp: *const *const c_char,
473     ) -> c_int;
474     #[link_name = "_execvp"]
execvp(c: *const c_char, argv: *const *const c_char) -> c_int475     pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int;
476     #[link_name = "_execvpe"]
execvpe( c: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> c_int477     pub fn execvpe(
478         c: *const c_char,
479         argv: *const *const c_char,
480         envp: *const *const c_char,
481     ) -> c_int;
482 
483     #[link_name = "_wexecv"]
wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> intptr_t484     pub fn wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> intptr_t;
485     #[link_name = "_wexecve"]
wexecve( prog: *const wchar_t, argv: *const *const wchar_t, envp: *const *const wchar_t, ) -> intptr_t486     pub fn wexecve(
487         prog: *const wchar_t,
488         argv: *const *const wchar_t,
489         envp: *const *const wchar_t,
490     ) -> intptr_t;
491     #[link_name = "_wexecvp"]
wexecvp(c: *const wchar_t, argv: *const *const wchar_t) -> intptr_t492     pub fn wexecvp(c: *const wchar_t, argv: *const *const wchar_t) -> intptr_t;
493     #[link_name = "_wexecvpe"]
wexecvpe( c: *const wchar_t, argv: *const *const wchar_t, envp: *const *const wchar_t, ) -> intptr_t494     pub fn wexecvpe(
495         c: *const wchar_t,
496         argv: *const *const wchar_t,
497         envp: *const *const wchar_t,
498     ) -> intptr_t;
499     #[link_name = "_getcwd"]
getcwd(buf: *mut c_char, size: c_int) -> *mut c_char500     pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char;
501     #[link_name = "_getpid"]
getpid() -> c_int502     pub fn getpid() -> c_int;
503     #[link_name = "_isatty"]
isatty(fd: c_int) -> c_int504     pub fn isatty(fd: c_int) -> c_int;
505     #[link_name = "_lseek"]
lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long506     pub fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long;
507     #[link_name = "_lseeki64"]
lseek64(fd: c_int, offset: c_longlong, origin: c_int) -> c_longlong508     pub fn lseek64(fd: c_int, offset: c_longlong, origin: c_int) -> c_longlong;
509     #[link_name = "_pipe"]
pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int510     pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int;
511     #[link_name = "_read"]
read(fd: c_int, buf: *mut c_void, count: c_uint) -> c_int512     pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) -> c_int;
513     #[link_name = "_rmdir"]
rmdir(path: *const c_char) -> c_int514     pub fn rmdir(path: *const c_char) -> c_int;
515     #[link_name = "_unlink"]
unlink(c: *const c_char) -> c_int516     pub fn unlink(c: *const c_char) -> c_int;
517     #[link_name = "_write"]
write(fd: c_int, buf: *const c_void, count: c_uint) -> c_int518     pub fn write(fd: c_int, buf: *const c_void, count: c_uint) -> c_int;
519     #[link_name = "_commit"]
commit(fd: c_int) -> c_int520     pub fn commit(fd: c_int) -> c_int;
521     #[link_name = "_get_osfhandle"]
get_osfhandle(fd: c_int) -> intptr_t522     pub fn get_osfhandle(fd: c_int) -> intptr_t;
523     #[link_name = "_open_osfhandle"]
open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int524     pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int;
setlocale(category: c_int, locale: *const c_char) -> *mut c_char525     pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char;
526     #[link_name = "_wsetlocale"]
wsetlocale(category: c_int, locale: *const wchar_t) -> *mut wchar_t527     pub fn wsetlocale(category: c_int, locale: *const wchar_t) -> *mut wchar_t;
528     #[link_name = "_aligned_malloc"]
aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void529     pub fn aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void;
530     #[link_name = "_aligned_free"]
aligned_free(ptr: *mut c_void)531     pub fn aligned_free(ptr: *mut c_void);
532     #[link_name = "_aligned_realloc"]
aligned_realloc(memblock: *mut c_void, size: size_t, alignment: size_t) -> *mut c_void533     pub fn aligned_realloc(memblock: *mut c_void, size: size_t, alignment: size_t) -> *mut c_void;
534     #[link_name = "_putenv"]
putenv(envstring: *const c_char) -> c_int535     pub fn putenv(envstring: *const c_char) -> c_int;
536     #[link_name = "_wputenv"]
wputenv(envstring: *const crate::wchar_t) -> c_int537     pub fn wputenv(envstring: *const crate::wchar_t) -> c_int;
538     #[link_name = "_putenv_s"]
putenv_s(envstring: *const c_char, value_string: *const c_char) -> crate::errno_t539     pub fn putenv_s(envstring: *const c_char, value_string: *const c_char) -> crate::errno_t;
540     #[link_name = "_wputenv_s"]
wputenv_s( envstring: *const crate::wchar_t, value_string: *const crate::wchar_t, ) -> crate::errno_t541     pub fn wputenv_s(
542         envstring: *const crate::wchar_t,
543         value_string: *const crate::wchar_t,
544     ) -> crate::errno_t;
545 }
546 
547 extern "system" {
listen(s: SOCKET, backlog: c_int) -> c_int548     pub fn listen(s: SOCKET, backlog: c_int) -> c_int;
accept(s: SOCKET, addr: *mut crate::sockaddr, addrlen: *mut c_int) -> SOCKET549     pub fn accept(s: SOCKET, addr: *mut crate::sockaddr, addrlen: *mut c_int) -> SOCKET;
bind(s: SOCKET, name: *const crate::sockaddr, namelen: c_int) -> c_int550     pub fn bind(s: SOCKET, name: *const crate::sockaddr, namelen: c_int) -> c_int;
connect(s: SOCKET, name: *const crate::sockaddr, namelen: c_int) -> c_int551     pub fn connect(s: SOCKET, name: *const crate::sockaddr, namelen: c_int) -> c_int;
getpeername(s: SOCKET, name: *mut crate::sockaddr, nameln: *mut c_int) -> c_int552     pub fn getpeername(s: SOCKET, name: *mut crate::sockaddr, nameln: *mut c_int) -> c_int;
getsockname(s: SOCKET, name: *mut crate::sockaddr, nameln: *mut c_int) -> c_int553     pub fn getsockname(s: SOCKET, name: *mut crate::sockaddr, nameln: *mut c_int) -> c_int;
getsockopt( s: SOCKET, level: c_int, optname: c_int, optval: *mut c_char, optlen: *mut c_int, ) -> c_int554     pub fn getsockopt(
555         s: SOCKET,
556         level: c_int,
557         optname: c_int,
558         optval: *mut c_char,
559         optlen: *mut c_int,
560     ) -> c_int;
recvfrom( s: SOCKET, buf: *mut c_char, len: c_int, flags: c_int, from: *mut crate::sockaddr, fromlen: *mut c_int, ) -> c_int561     pub fn recvfrom(
562         s: SOCKET,
563         buf: *mut c_char,
564         len: c_int,
565         flags: c_int,
566         from: *mut crate::sockaddr,
567         fromlen: *mut c_int,
568     ) -> c_int;
sendto( s: SOCKET, buf: *const c_char, len: c_int, flags: c_int, to: *const crate::sockaddr, tolen: c_int, ) -> c_int569     pub fn sendto(
570         s: SOCKET,
571         buf: *const c_char,
572         len: c_int,
573         flags: c_int,
574         to: *const crate::sockaddr,
575         tolen: c_int,
576     ) -> c_int;
setsockopt( s: SOCKET, level: c_int, optname: c_int, optval: *const c_char, optlen: c_int, ) -> c_int577     pub fn setsockopt(
578         s: SOCKET,
579         level: c_int,
580         optname: c_int,
581         optval: *const c_char,
582         optlen: c_int,
583     ) -> c_int;
socket(af: c_int, socket_type: c_int, protocol: c_int) -> SOCKET584     pub fn socket(af: c_int, socket_type: c_int, protocol: c_int) -> SOCKET;
585 }
586 
587 cfg_if! {
588     if #[cfg(all(target_env = "gnu"))] {
589         mod gnu;
590         pub use self::gnu::*;
591     } else if #[cfg(all(target_env = "msvc"))] {
592         mod msvc;
593         pub use self::msvc::*;
594     } else {
595         // Unknown target_env
596     }
597 }
598