1 //! Windows CRT definitions
2 
3 pub type c_schar = i8;
4 pub type c_uchar = u8;
5 pub type c_short = i16;
6 pub type c_ushort = u16;
7 pub type c_int = i32;
8 pub type c_uint = u32;
9 pub type c_float = f32;
10 pub type c_double = f64;
11 pub type c_longlong = i64;
12 pub type c_ulonglong = u64;
13 pub type intmax_t = i64;
14 pub type uintmax_t = u64;
15 
16 pub type size_t = usize;
17 pub type ptrdiff_t = isize;
18 pub type intptr_t = isize;
19 pub type uintptr_t = usize;
20 pub type ssize_t = isize;
21 pub type sighandler_t = usize;
22 
23 pub type c_char = i8;
24 pub type c_long = i32;
25 pub type c_ulong = u32;
26 pub type wchar_t = u16;
27 
28 pub type clock_t = i32;
29 
30 cfg_if! {
31     if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
32         pub type time_t = i32;
33     } else {
34         pub type time_t = i64;
35     }
36 }
37 
38 pub type off_t = i32;
39 pub type dev_t = u32;
40 pub type ino_t = u16;
41 #[cfg_attr(feature = "extra_traits", derive(Debug))]
42 pub enum timezone {}
43 impl ::Copy for timezone {}
44 impl ::Clone for timezone {
clone(&self) -> timezone45     fn clone(&self) -> timezone {
46         *self
47     }
48 }
49 pub type time64_t = i64;
50 
51 pub type SOCKET = ::uintptr_t;
52 
53 s! {
54     // note this is the struct called stat64 in Windows. Not stat, nor stati64.
55     pub struct stat {
56         pub st_dev: dev_t,
57         pub st_ino: ino_t,
58         pub st_mode: u16,
59         pub st_nlink: ::c_short,
60         pub st_uid: ::c_short,
61         pub st_gid: ::c_short,
62         pub st_rdev: dev_t,
63         pub st_size: i64,
64         pub st_atime: time64_t,
65         pub st_mtime: time64_t,
66         pub st_ctime: time64_t,
67     }
68 
69     // note that this is called utimbuf64 in Windows
70     pub struct utimbuf {
71         pub actime: time64_t,
72         pub modtime: time64_t,
73     }
74 
75     pub struct tm {
76         pub tm_sec: ::c_int,
77         pub tm_min: ::c_int,
78         pub tm_hour: ::c_int,
79         pub tm_mday: ::c_int,
80         pub tm_mon: ::c_int,
81         pub tm_year: ::c_int,
82         pub tm_wday: ::c_int,
83         pub tm_yday: ::c_int,
84         pub tm_isdst: ::c_int,
85     }
86 
87     pub struct timeval {
88         pub tv_sec: c_long,
89         pub tv_usec: c_long,
90     }
91 
92     pub struct timespec {
93         pub tv_sec: time_t,
94         pub tv_nsec: c_long,
95     }
96 
97     pub struct sockaddr {
98         pub sa_family: c_ushort,
99         pub sa_data: [c_char; 14],
100     }
101 }
102 
103 pub const INT_MIN: c_int = -2147483648;
104 pub const INT_MAX: c_int = 2147483647;
105 
106 pub const EXIT_FAILURE: ::c_int = 1;
107 pub const EXIT_SUCCESS: ::c_int = 0;
108 pub const RAND_MAX: ::c_int = 32767;
109 pub const EOF: ::c_int = -1;
110 pub const SEEK_SET: ::c_int = 0;
111 pub const SEEK_CUR: ::c_int = 1;
112 pub const SEEK_END: ::c_int = 2;
113 pub const _IOFBF: ::c_int = 0;
114 pub const _IONBF: ::c_int = 4;
115 pub const _IOLBF: ::c_int = 64;
116 pub const BUFSIZ: ::c_uint = 512;
117 pub const FOPEN_MAX: ::c_uint = 20;
118 pub const FILENAME_MAX: ::c_uint = 260;
119 
120 // fcntl.h
121 pub const O_RDONLY: ::c_int = 0x0000;
122 pub const O_WRONLY: ::c_int = 0x0001;
123 pub const O_RDWR: ::c_int = 0x0002;
124 pub const O_APPEND: ::c_int = 0x0008;
125 pub const O_CREAT: ::c_int = 0x0100;
126 pub const O_TRUNC: ::c_int = 0x0200;
127 pub const O_EXCL: ::c_int = 0x0400;
128 pub const O_TEXT: ::c_int = 0x4000;
129 pub const O_BINARY: ::c_int = 0x8000;
130 pub const _O_WTEXT: ::c_int = 0x10000;
131 pub const _O_U16TEXT: ::c_int = 0x20000;
132 pub const _O_U8TEXT: ::c_int = 0x40000;
133 pub const O_RAW: ::c_int = O_BINARY;
134 pub const O_NOINHERIT: ::c_int = 0x0080;
135 pub const O_TEMPORARY: ::c_int = 0x0040;
136 pub const _O_SHORT_LIVED: ::c_int = 0x1000;
137 pub const _O_OBTAIN_DIR: ::c_int = 0x2000;
138 pub const O_SEQUENTIAL: ::c_int = 0x0020;
139 pub const O_RANDOM: ::c_int = 0x0010;
140 
141 pub const S_IFCHR: ::c_int = 8192;
142 pub const S_IFDIR: ::c_int = 16384;
143 pub const S_IFREG: ::c_int = 32768;
144 pub const S_IFMT: ::c_int = 61440;
145 pub const S_IEXEC: ::c_int = 64;
146 pub const S_IWRITE: ::c_int = 128;
147 pub const S_IREAD: ::c_int = 256;
148 
149 pub const LC_ALL: ::c_int = 0;
150 pub const LC_COLLATE: ::c_int = 1;
151 pub const LC_CTYPE: ::c_int = 2;
152 pub const LC_MONETARY: ::c_int = 3;
153 pub const LC_NUMERIC: ::c_int = 4;
154 pub const LC_TIME: ::c_int = 5;
155 
156 pub const EPERM: ::c_int = 1;
157 pub const ENOENT: ::c_int = 2;
158 pub const ESRCH: ::c_int = 3;
159 pub const EINTR: ::c_int = 4;
160 pub const EIO: ::c_int = 5;
161 pub const ENXIO: ::c_int = 6;
162 pub const E2BIG: ::c_int = 7;
163 pub const ENOEXEC: ::c_int = 8;
164 pub const EBADF: ::c_int = 9;
165 pub const ECHILD: ::c_int = 10;
166 pub const EAGAIN: ::c_int = 11;
167 pub const ENOMEM: ::c_int = 12;
168 pub const EACCES: ::c_int = 13;
169 pub const EFAULT: ::c_int = 14;
170 pub const EBUSY: ::c_int = 16;
171 pub const EEXIST: ::c_int = 17;
172 pub const EXDEV: ::c_int = 18;
173 pub const ENODEV: ::c_int = 19;
174 pub const ENOTDIR: ::c_int = 20;
175 pub const EISDIR: ::c_int = 21;
176 pub const EINVAL: ::c_int = 22;
177 pub const ENFILE: ::c_int = 23;
178 pub const EMFILE: ::c_int = 24;
179 pub const ENOTTY: ::c_int = 25;
180 pub const EFBIG: ::c_int = 27;
181 pub const ENOSPC: ::c_int = 28;
182 pub const ESPIPE: ::c_int = 29;
183 pub const EROFS: ::c_int = 30;
184 pub const EMLINK: ::c_int = 31;
185 pub const EPIPE: ::c_int = 32;
186 pub const EDOM: ::c_int = 33;
187 pub const ERANGE: ::c_int = 34;
188 pub const EDEADLK: ::c_int = 36;
189 pub const EDEADLOCK: ::c_int = 36;
190 pub const ENAMETOOLONG: ::c_int = 38;
191 pub const ENOLCK: ::c_int = 39;
192 pub const ENOSYS: ::c_int = 40;
193 pub const ENOTEMPTY: ::c_int = 41;
194 pub const EILSEQ: ::c_int = 42;
195 pub const STRUNCATE: ::c_int = 80;
196 
197 // POSIX Supplement (from errno.h)
198 pub const EADDRINUSE: ::c_int = 100;
199 pub const EADDRNOTAVAIL: ::c_int = 101;
200 pub const EAFNOSUPPORT: ::c_int = 102;
201 pub const EALREADY: ::c_int = 103;
202 pub const EBADMSG: ::c_int = 104;
203 pub const ECANCELED: ::c_int = 105;
204 pub const ECONNABORTED: ::c_int = 106;
205 pub const ECONNREFUSED: ::c_int = 107;
206 pub const ECONNRESET: ::c_int = 108;
207 pub const EDESTADDRREQ: ::c_int = 109;
208 pub const EHOSTUNREACH: ::c_int = 110;
209 pub const EIDRM: ::c_int = 111;
210 pub const EINPROGRESS: ::c_int = 112;
211 pub const EISCONN: ::c_int = 113;
212 pub const ELOOP: ::c_int = 114;
213 pub const EMSGSIZE: ::c_int = 115;
214 pub const ENETDOWN: ::c_int = 116;
215 pub const ENETRESET: ::c_int = 117;
216 pub const ENETUNREACH: ::c_int = 118;
217 pub const ENOBUFS: ::c_int = 119;
218 pub const ENODATA: ::c_int = 120;
219 pub const ENOLINK: ::c_int = 121;
220 pub const ENOMSG: ::c_int = 122;
221 pub const ENOPROTOOPT: ::c_int = 123;
222 pub const ENOSR: ::c_int = 124;
223 pub const ENOSTR: ::c_int = 125;
224 pub const ENOTCONN: ::c_int = 126;
225 pub const ENOTRECOVERABLE: ::c_int = 127;
226 pub const ENOTSOCK: ::c_int = 128;
227 pub const ENOTSUP: ::c_int = 129;
228 pub const EOPNOTSUPP: ::c_int = 130;
229 pub const EOVERFLOW: ::c_int = 132;
230 pub const EOWNERDEAD: ::c_int = 133;
231 pub const EPROTO: ::c_int = 134;
232 pub const EPROTONOSUPPORT: ::c_int = 135;
233 pub const EPROTOTYPE: ::c_int = 136;
234 pub const ETIME: ::c_int = 137;
235 pub const ETIMEDOUT: ::c_int = 138;
236 pub const ETXTBSY: ::c_int = 139;
237 pub const EWOULDBLOCK: ::c_int = 140;
238 
239 // signal codes
240 pub const SIGINT: ::c_int = 2;
241 pub const SIGILL: ::c_int = 4;
242 pub const SIGFPE: ::c_int = 8;
243 pub const SIGSEGV: ::c_int = 11;
244 pub const SIGTERM: ::c_int = 15;
245 pub const SIGABRT: ::c_int = 22;
246 pub const NSIG: ::c_int = 23;
247 
248 pub const SIG_ERR: ::c_int = -1;
249 pub const SIG_DFL: ::sighandler_t = 0;
250 pub const SIG_IGN: ::sighandler_t = 1;
251 pub const SIG_GET: ::sighandler_t = 2;
252 pub const SIG_SGE: ::sighandler_t = 3;
253 pub const SIG_ACK: ::sighandler_t = 4;
254 
255 // inline comment below appeases style checker
256 #[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
257 #[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
258 #[link(name = "libcmt", cfg(target_feature = "crt-static"))]
259 extern "C" {}
260 
261 #[cfg_attr(feature = "extra_traits", derive(Debug))]
262 pub enum FILE {}
263 impl ::Copy for FILE {}
264 impl ::Clone for FILE {
clone(&self) -> FILE265     fn clone(&self) -> FILE {
266         *self
267     }
268 }
269 #[cfg_attr(feature = "extra_traits", derive(Debug))]
270 pub enum fpos_t {} // FIXME: fill this out with a struct
271 impl ::Copy for fpos_t {}
272 impl ::Clone for fpos_t {
clone(&self) -> fpos_t273     fn clone(&self) -> fpos_t {
274         *self
275     }
276 }
277 
278 extern "C" {
isalnum(c: c_int) -> c_int279     pub fn isalnum(c: c_int) -> c_int;
isalpha(c: c_int) -> c_int280     pub fn isalpha(c: c_int) -> c_int;
iscntrl(c: c_int) -> c_int281     pub fn iscntrl(c: c_int) -> c_int;
isdigit(c: c_int) -> c_int282     pub fn isdigit(c: c_int) -> c_int;
isgraph(c: c_int) -> c_int283     pub fn isgraph(c: c_int) -> c_int;
islower(c: c_int) -> c_int284     pub fn islower(c: c_int) -> c_int;
isprint(c: c_int) -> c_int285     pub fn isprint(c: c_int) -> c_int;
ispunct(c: c_int) -> c_int286     pub fn ispunct(c: c_int) -> c_int;
isspace(c: c_int) -> c_int287     pub fn isspace(c: c_int) -> c_int;
isupper(c: c_int) -> c_int288     pub fn isupper(c: c_int) -> c_int;
isxdigit(c: c_int) -> c_int289     pub fn isxdigit(c: c_int) -> c_int;
isblank(c: c_int) -> c_int290     pub fn isblank(c: c_int) -> c_int;
tolower(c: c_int) -> c_int291     pub fn tolower(c: c_int) -> c_int;
toupper(c: c_int) -> c_int292     pub fn toupper(c: c_int) -> c_int;
fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE293     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 FILE294     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
fflush(file: *mut FILE) -> c_int295     pub fn fflush(file: *mut FILE) -> c_int;
fclose(file: *mut FILE) -> c_int296     pub fn fclose(file: *mut FILE) -> c_int;
remove(filename: *const c_char) -> c_int297     pub fn remove(filename: *const c_char) -> c_int;
rename(oldname: *const c_char, newname: *const c_char) -> c_int298     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
tmpfile() -> *mut FILE299     pub fn tmpfile() -> *mut FILE;
setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int300     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)301     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
getchar() -> c_int302     pub fn getchar() -> c_int;
putchar(c: c_int) -> c_int303     pub fn putchar(c: c_int) -> c_int;
fgetc(stream: *mut FILE) -> c_int304     pub fn fgetc(stream: *mut FILE) -> c_int;
fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char305     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
fputc(c: c_int, stream: *mut FILE) -> c_int306     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
fputs(s: *const c_char, stream: *mut FILE) -> c_int307     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
puts(s: *const c_char) -> c_int308     pub fn puts(s: *const c_char) -> c_int;
ungetc(c: c_int, stream: *mut FILE) -> c_int309     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_t310     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_t311     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_int312     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
ftell(stream: *mut FILE) -> c_long313     pub fn ftell(stream: *mut FILE) -> c_long;
rewind(stream: *mut FILE)314     pub fn rewind(stream: *mut FILE);
fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int315     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int316     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
feof(stream: *mut FILE) -> c_int317     pub fn feof(stream: *mut FILE) -> c_int;
ferror(stream: *mut FILE) -> c_int318     pub fn ferror(stream: *mut FILE) -> c_int;
perror(s: *const c_char)319     pub fn perror(s: *const c_char);
atoi(s: *const c_char) -> c_int320     pub fn atoi(s: *const c_char) -> c_int;
strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double321     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long322     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong323     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
calloc(nobj: size_t, size: size_t) -> *mut c_void324     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
malloc(size: size_t) -> *mut c_void325     pub fn malloc(size: size_t) -> *mut c_void;
realloc(p: *mut c_void, size: size_t) -> *mut c_void326     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
free(p: *mut c_void)327     pub fn free(p: *mut c_void);
abort() -> !328     pub fn abort() -> !;
exit(status: c_int) -> !329     pub fn exit(status: c_int) -> !;
_exit(status: c_int) -> !330     pub fn _exit(status: c_int) -> !;
atexit(cb: extern "C" fn()) -> c_int331     pub fn atexit(cb: extern "C" fn()) -> c_int;
system(s: *const c_char) -> c_int332     pub fn system(s: *const c_char) -> c_int;
getenv(s: *const c_char) -> *mut c_char333     pub fn getenv(s: *const c_char) -> *mut c_char;
334 
strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char335     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_char336     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_char337     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_char338     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_int339     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_int340     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_int341     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
strchr(cs: *const c_char, c: c_int) -> *mut c_char342     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
strrchr(cs: *const c_char, c: c_int) -> *mut c_char343     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
strspn(cs: *const c_char, ct: *const c_char) -> size_t344     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
strcspn(cs: *const c_char, ct: *const c_char) -> size_t345     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
strdup(cs: *const c_char) -> *mut c_char346     pub fn strdup(cs: *const c_char) -> *mut c_char;
strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char347     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_char348     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strlen(cs: *const c_char) -> size_t349     pub fn strlen(cs: *const c_char) -> size_t;
strnlen(cs: *const c_char, maxlen: size_t) -> size_t350     pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
strerror(n: c_int) -> *mut c_char351     pub fn strerror(n: c_int) -> *mut c_char;
strtok(s: *mut c_char, t: *const c_char) -> *mut c_char352     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_t353     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
wcslen(buf: *const wchar_t) -> size_t354     pub fn wcslen(buf: *const wchar_t) -> size_t;
wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t355     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t;
356 
memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void357     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_int358     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_void359     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_void360     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_void361     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
362 
abs(i: c_int) -> c_int363     pub fn abs(i: c_int) -> c_int;
atof(s: *const c_char) -> c_double364     pub fn atof(s: *const c_char) -> c_double;
labs(i: c_long) -> c_long365     pub fn labs(i: c_long) -> c_long;
rand() -> c_int366     pub fn rand() -> c_int;
srand(seed: c_uint)367     pub fn srand(seed: c_uint);
368 
signal(signum: c_int, handler: sighandler_t) -> sighandler_t369     pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
raise(signum: c_int) -> c_int370     pub fn raise(signum: c_int) -> c_int;
371 
372     #[link_name = "_gmtime64_s"]
gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> ::c_int373     pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> ::c_int;
374     #[link_name = "_time64"]
time(destTime: *mut time_t) -> time_t375     pub fn time(destTime: *mut time_t) -> time_t;
376     #[link_name = "_chmod"]
chmod(path: *const c_char, mode: ::c_int) -> ::c_int377     pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int;
378     #[link_name = "_wchmod"]
wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int379     pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int;
380     #[link_name = "_mkdir"]
mkdir(path: *const c_char) -> ::c_int381     pub fn mkdir(path: *const c_char) -> ::c_int;
382     #[link_name = "_wrmdir"]
wrmdir(path: *const wchar_t) -> ::c_int383     pub fn wrmdir(path: *const wchar_t) -> ::c_int;
384     #[link_name = "_fstat64"]
fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int385     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
386     #[link_name = "_stat64"]
stat(path: *const c_char, buf: *mut stat) -> ::c_int387     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
388     #[link_name = "_wstat64"]
wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int389     pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int;
390     #[link_name = "_wutime64"]
wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int391     pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int;
392     #[link_name = "_popen"]
popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE393     pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
394     #[link_name = "_pclose"]
pclose(stream: *mut ::FILE) -> ::c_int395     pub fn pclose(stream: *mut ::FILE) -> ::c_int;
396     #[link_name = "_fdopen"]
fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE397     pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
398     #[link_name = "_fileno"]
fileno(stream: *mut ::FILE) -> ::c_int399     pub fn fileno(stream: *mut ::FILE) -> ::c_int;
400     #[link_name = "_open"]
open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int401     pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
402     #[link_name = "_wopen"]
wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int403     pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int;
404     #[link_name = "_creat"]
creat(path: *const c_char, mode: ::c_int) -> ::c_int405     pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int;
406     #[link_name = "_access"]
access(path: *const c_char, amode: ::c_int) -> ::c_int407     pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
408     #[link_name = "_chdir"]
chdir(dir: *const c_char) -> ::c_int409     pub fn chdir(dir: *const c_char) -> ::c_int;
410     #[link_name = "_close"]
close(fd: ::c_int) -> ::c_int411     pub fn close(fd: ::c_int) -> ::c_int;
412     #[link_name = "_dup"]
dup(fd: ::c_int) -> ::c_int413     pub fn dup(fd: ::c_int) -> ::c_int;
414     #[link_name = "_dup2"]
dup2(src: ::c_int, dst: ::c_int) -> ::c_int415     pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
416     #[link_name = "_execl"]
execl(path: *const c_char, arg0: *const c_char, ...) -> intptr_t417     pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
418     #[link_name = "_wexecl"]
wexecl(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t419     pub fn wexecl(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
420     #[link_name = "_execle"]
execle(path: *const c_char, arg0: *const c_char, ...) -> intptr_t421     pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
422     #[link_name = "_wexecle"]
wexecle(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t423     pub fn wexecle(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
424     #[link_name = "_execlp"]
execlp(path: *const c_char, arg0: *const c_char, ...) -> intptr_t425     pub fn execlp(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
426     #[link_name = "_wexeclp"]
wexeclp(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t427     pub fn wexeclp(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
428     #[link_name = "_execlpe"]
execlpe(path: *const c_char, arg0: *const c_char, ...) -> intptr_t429     pub fn execlpe(path: *const c_char, arg0: *const c_char, ...) -> intptr_t;
430     #[link_name = "_wexeclpe"]
wexeclpe(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t431     pub fn wexeclpe(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t;
432     #[link_name = "_execv"]
execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t433     pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t;
434     #[link_name = "_execve"]
execve( prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> ::c_int435     pub fn execve(
436         prog: *const c_char,
437         argv: *const *const c_char,
438         envp: *const *const c_char,
439     ) -> ::c_int;
440     #[link_name = "_execvp"]
execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int441     pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int;
442     #[link_name = "_execvpe"]
execvpe( c: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> ::c_int443     pub fn execvpe(
444         c: *const c_char,
445         argv: *const *const c_char,
446         envp: *const *const c_char,
447     ) -> ::c_int;
448     #[link_name = "_wexecv"]
wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t449     pub fn wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t;
450     #[link_name = "_wexecve"]
wexecve( prog: *const wchar_t, argv: *const *const wchar_t, envp: *const *const wchar_t, ) -> ::intptr_t451     pub fn wexecve(
452         prog: *const wchar_t,
453         argv: *const *const wchar_t,
454         envp: *const *const wchar_t,
455     ) -> ::intptr_t;
456     #[link_name = "_wexecvp"]
wexecvp(c: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t457     pub fn wexecvp(c: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t;
458     #[link_name = "_wexecvpe"]
wexecvpe( c: *const wchar_t, argv: *const *const wchar_t, envp: *const *const wchar_t, ) -> ::intptr_t459     pub fn wexecvpe(
460         c: *const wchar_t,
461         argv: *const *const wchar_t,
462         envp: *const *const wchar_t,
463     ) -> ::intptr_t;
464     #[link_name = "_getcwd"]
getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char465     pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char;
466     #[link_name = "_getpid"]
getpid() -> ::c_int467     pub fn getpid() -> ::c_int;
468     #[link_name = "_isatty"]
isatty(fd: ::c_int) -> ::c_int469     pub fn isatty(fd: ::c_int) -> ::c_int;
470     #[link_name = "_lseek"]
lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long471     pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long;
472     #[link_name = "_lseeki64"]
lseek64(fd: ::c_int, offset: c_longlong, origin: ::c_int) -> c_longlong473     pub fn lseek64(fd: ::c_int, offset: c_longlong, origin: ::c_int) -> c_longlong;
474     #[link_name = "_pipe"]
pipe(fds: *mut ::c_int, psize: ::c_uint, textmode: ::c_int) -> ::c_int475     pub fn pipe(fds: *mut ::c_int, psize: ::c_uint, textmode: ::c_int) -> ::c_int;
476     #[link_name = "_read"]
read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int477     pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int;
478     #[link_name = "_rmdir"]
rmdir(path: *const c_char) -> ::c_int479     pub fn rmdir(path: *const c_char) -> ::c_int;
480     #[link_name = "_unlink"]
unlink(c: *const c_char) -> ::c_int481     pub fn unlink(c: *const c_char) -> ::c_int;
482     #[link_name = "_write"]
write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int483     pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int;
484     #[link_name = "_commit"]
commit(fd: ::c_int) -> ::c_int485     pub fn commit(fd: ::c_int) -> ::c_int;
486     #[link_name = "_get_osfhandle"]
get_osfhandle(fd: ::c_int) -> ::intptr_t487     pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t;
488     #[link_name = "_open_osfhandle"]
open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int489     pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int;
setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char490     pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char;
491     #[link_name = "_wsetlocale"]
wsetlocale(category: ::c_int, locale: *const wchar_t) -> *mut wchar_t492     pub fn wsetlocale(category: ::c_int, locale: *const wchar_t) -> *mut wchar_t;
493     #[link_name = "_aligned_malloc"]
aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void494     pub fn aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void;
495 }
496 
497 extern "system" {
listen(s: SOCKET, backlog: ::c_int) -> ::c_int498     pub fn listen(s: SOCKET, backlog: ::c_int) -> ::c_int;
accept(s: SOCKET, addr: *mut ::sockaddr, addrlen: *mut ::c_int) -> SOCKET499     pub fn accept(s: SOCKET, addr: *mut ::sockaddr, addrlen: *mut ::c_int) -> SOCKET;
bind(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int500     pub fn bind(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int;
connect(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int501     pub fn connect(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int;
getpeername(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int502     pub fn getpeername(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int;
getsockname(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int503     pub fn getsockname(s: SOCKET, name: *mut ::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_int504     pub fn getsockopt(
505         s: SOCKET,
506         level: ::c_int,
507         optname: ::c_int,
508         optval: *mut ::c_char,
509         optlen: *mut ::c_int,
510     ) -> ::c_int;
recvfrom( s: SOCKET, buf: *mut ::c_char, len: ::c_int, flags: ::c_int, from: *mut ::sockaddr, fromlen: *mut ::c_int, ) -> ::c_int511     pub fn recvfrom(
512         s: SOCKET,
513         buf: *mut ::c_char,
514         len: ::c_int,
515         flags: ::c_int,
516         from: *mut ::sockaddr,
517         fromlen: *mut ::c_int,
518     ) -> ::c_int;
sendto( s: SOCKET, buf: *const ::c_char, len: ::c_int, flags: ::c_int, to: *const ::sockaddr, tolen: ::c_int, ) -> ::c_int519     pub fn sendto(
520         s: SOCKET,
521         buf: *const ::c_char,
522         len: ::c_int,
523         flags: ::c_int,
524         to: *const ::sockaddr,
525         tolen: ::c_int,
526     ) -> ::c_int;
setsockopt( s: SOCKET, level: ::c_int, optname: ::c_int, optval: *const ::c_char, optlen: ::c_int, ) -> ::c_int527     pub fn setsockopt(
528         s: SOCKET,
529         level: ::c_int,
530         optname: ::c_int,
531         optval: *const ::c_char,
532         optlen: ::c_int,
533     ) -> ::c_int;
socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET534     pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET;
535 }
536 
537 cfg_if! {
538     if #[cfg(libc_core_cvoid)] {
539         pub use ::ffi::c_void;
540     } else {
541         // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
542         // enable more optimization opportunities around it recognizing things
543         // like malloc/free.
544         #[repr(u8)]
545         #[allow(missing_copy_implementations)]
546         #[allow(missing_debug_implementations)]
547         pub enum c_void {
548             // Two dummy variants so the #[repr] attribute can be used.
549             #[doc(hidden)]
550             __variant1,
551             #[doc(hidden)]
552             __variant2,
553         }
554     }
555 }
556 
557 cfg_if! {
558     if #[cfg(all(target_env = "gnu"))] {
559         mod gnu;
560         pub use self::gnu::*;
561     } else if #[cfg(all(target_env = "msvc"))] {
562         mod msvc;
563         pub use self::msvc::*;
564     } else {
565         // Unknown target_env
566     }
567 }
568