1 //! Windows CRT definitions
2 
3 pub type int8_t = i8;
4 pub type int16_t = i16;
5 pub type int32_t = i32;
6 pub type int64_t = i64;
7 pub type uint8_t = u8;
8 pub type uint16_t = u16;
9 pub type uint32_t = u32;
10 pub type uint64_t = u64;
11 
12 pub type c_schar = i8;
13 pub type c_uchar = u8;
14 pub type c_short = i16;
15 pub type c_ushort = u16;
16 pub type c_int = i32;
17 pub type c_uint = u32;
18 pub type c_float = f32;
19 pub type c_double = f64;
20 pub type c_longlong = i64;
21 pub type c_ulonglong = u64;
22 pub type intmax_t = i64;
23 pub type uintmax_t = u64;
24 
25 pub type size_t = usize;
26 pub type ptrdiff_t = isize;
27 pub type intptr_t = isize;
28 pub type uintptr_t = usize;
29 pub type ssize_t = isize;
30 pub type sighandler_t = usize;
31 
32 pub type c_char = i8;
33 pub type c_long = i32;
34 pub type c_ulong = u32;
35 pub type wchar_t = u16;
36 
37 pub type clock_t = i32;
38 
39 cfg_if! {
40     if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
41         pub type time_t = i32;
42     } else {
43         pub type time_t = i64;
44     }
45 }
46 
47 pub type off_t = i32;
48 pub type dev_t = u32;
49 pub type ino_t = u16;
50 #[cfg_attr(feature = "extra_traits", derive(Debug))]
51 pub enum timezone {}
52 impl ::Copy for timezone {}
53 impl ::Clone for timezone {
clone(&self) -> timezone54     fn clone(&self) -> timezone { *self }
55 }
56 pub type time64_t = i64;
57 
58 pub type SOCKET = ::uintptr_t;
59 
60 s! {
61     // note this is the struct called stat64 in Windows. Not stat, nor stati64.
62     pub struct stat {
63         pub st_dev: dev_t,
64         pub st_ino: ino_t,
65         pub st_mode: u16,
66         pub st_nlink: ::c_short,
67         pub st_uid: ::c_short,
68         pub st_gid: ::c_short,
69         pub st_rdev: dev_t,
70         pub st_size: i64,
71         pub st_atime: time64_t,
72         pub st_mtime: time64_t,
73         pub st_ctime: time64_t,
74     }
75 
76     // note that this is called utimbuf64 in Windows
77     pub struct utimbuf {
78         pub actime: time64_t,
79         pub modtime: time64_t,
80     }
81 
82     pub struct tm {
83         pub tm_sec: ::c_int,
84         pub tm_min: ::c_int,
85         pub tm_hour: ::c_int,
86         pub tm_mday: ::c_int,
87         pub tm_mon: ::c_int,
88         pub tm_year: ::c_int,
89         pub tm_wday: ::c_int,
90         pub tm_yday: ::c_int,
91         pub tm_isdst: ::c_int,
92     }
93 
94     pub struct timeval {
95         pub tv_sec: c_long,
96         pub tv_usec: c_long,
97     }
98 
99     pub struct timespec {
100         pub tv_sec: time_t,
101         pub tv_nsec: c_long,
102     }
103 
104     pub struct sockaddr {
105         pub sa_family: c_ushort,
106         pub sa_data: [c_char; 14],
107     }
108 }
109 
110 pub const INT_MIN: c_int = -2147483648;
111 pub const INT_MAX: c_int = 2147483647;
112 
113 pub const EXIT_FAILURE: ::c_int = 1;
114 pub const EXIT_SUCCESS: ::c_int = 0;
115 pub const RAND_MAX: ::c_int = 32767;
116 pub const EOF: ::c_int = -1;
117 pub const SEEK_SET: ::c_int = 0;
118 pub const SEEK_CUR: ::c_int = 1;
119 pub const SEEK_END: ::c_int = 2;
120 pub const _IOFBF: ::c_int = 0;
121 pub const _IONBF: ::c_int = 4;
122 pub const _IOLBF: ::c_int = 64;
123 pub const BUFSIZ: ::c_uint = 512;
124 pub const FOPEN_MAX: ::c_uint = 20;
125 pub const FILENAME_MAX: ::c_uint = 260;
126 
127 pub const O_RDONLY: ::c_int = 0;
128 pub const O_WRONLY: ::c_int = 1;
129 pub const O_RDWR: ::c_int = 2;
130 pub const O_APPEND: ::c_int = 8;
131 pub const O_CREAT: ::c_int = 256;
132 pub const O_EXCL: ::c_int = 1024;
133 pub const O_TEXT: ::c_int = 16384;
134 pub const O_BINARY: ::c_int = 32768;
135 pub const O_NOINHERIT: ::c_int = 128;
136 pub const O_TRUNC: ::c_int = 512;
137 pub const S_IFCHR: ::c_int = 8192;
138 pub const S_IFDIR: ::c_int = 16384;
139 pub const S_IFREG: ::c_int = 32768;
140 pub const S_IFMT: ::c_int = 61440;
141 pub const S_IEXEC: ::c_int = 64;
142 pub const S_IWRITE: ::c_int = 128;
143 pub const S_IREAD: ::c_int = 256;
144 
145 pub const LC_ALL: ::c_int = 0;
146 pub const LC_COLLATE: ::c_int = 1;
147 pub const LC_CTYPE: ::c_int = 2;
148 pub const LC_MONETARY: ::c_int = 3;
149 pub const LC_NUMERIC: ::c_int = 4;
150 pub const LC_TIME: ::c_int = 5;
151 
152 pub const EPERM: ::c_int = 1;
153 pub const ENOENT: ::c_int = 2;
154 pub const ESRCH: ::c_int = 3;
155 pub const EINTR: ::c_int = 4;
156 pub const EIO: ::c_int = 5;
157 pub const ENXIO: ::c_int = 6;
158 pub const E2BIG: ::c_int = 7;
159 pub const ENOEXEC: ::c_int = 8;
160 pub const EBADF: ::c_int = 9;
161 pub const ECHILD: ::c_int = 10;
162 pub const EAGAIN: ::c_int = 11;
163 pub const ENOMEM: ::c_int = 12;
164 pub const EACCES: ::c_int = 13;
165 pub const EFAULT: ::c_int = 14;
166 pub const EBUSY: ::c_int = 16;
167 pub const EEXIST: ::c_int = 17;
168 pub const EXDEV: ::c_int = 18;
169 pub const ENODEV: ::c_int = 19;
170 pub const ENOTDIR: ::c_int = 20;
171 pub const EISDIR: ::c_int = 21;
172 pub const EINVAL: ::c_int = 22;
173 pub const ENFILE: ::c_int = 23;
174 pub const EMFILE: ::c_int = 24;
175 pub const ENOTTY: ::c_int = 25;
176 pub const EFBIG: ::c_int = 27;
177 pub const ENOSPC: ::c_int = 28;
178 pub const ESPIPE: ::c_int = 29;
179 pub const EROFS: ::c_int = 30;
180 pub const EMLINK: ::c_int = 31;
181 pub const EPIPE: ::c_int = 32;
182 pub const EDOM: ::c_int = 33;
183 pub const ERANGE: ::c_int = 34;
184 pub const EDEADLK: ::c_int = 36;
185 pub const EDEADLOCK: ::c_int = 36;
186 pub const ENAMETOOLONG: ::c_int = 38;
187 pub const ENOLCK: ::c_int = 39;
188 pub const ENOSYS: ::c_int = 40;
189 pub const ENOTEMPTY: ::c_int = 41;
190 pub const EILSEQ: ::c_int = 42;
191 pub const STRUNCATE: ::c_int = 80;
192 
193 // signal codes
194 pub const SIGINT: ::c_int = 2;
195 pub const SIGILL: ::c_int = 4;
196 pub const SIGFPE: ::c_int = 8;
197 pub const SIGSEGV: ::c_int = 11;
198 pub const SIGTERM: ::c_int = 15;
199 pub const SIGABRT: ::c_int = 22;
200 pub const NSIG: ::c_int = 23;
201 pub const SIG_ERR: ::c_int = -1;
202 
203 // inline comment below appeases style checker
204 #[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
205 #[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
206 #[link(name = "libcmt", cfg(target_feature = "crt-static"))]
207 extern {}
208 
209 #[cfg_attr(feature = "extra_traits", derive(Debug))]
210 pub enum FILE {}
211 impl ::Copy for FILE {}
212 impl ::Clone for FILE {
clone(&self) -> FILE213     fn clone(&self) -> FILE { *self }
214 }
215 #[cfg_attr(feature = "extra_traits", derive(Debug))]
216 pub enum fpos_t {} // TODO: fill this out with a struct
217 impl ::Copy for fpos_t {}
218 impl ::Clone for fpos_t {
clone(&self) -> fpos_t219     fn clone(&self) -> fpos_t { *self }
220 }
221 
222 extern {
isalnum(c: c_int) -> c_int223     pub fn isalnum(c: c_int) -> c_int;
isalpha(c: c_int) -> c_int224     pub fn isalpha(c: c_int) -> c_int;
iscntrl(c: c_int) -> c_int225     pub fn iscntrl(c: c_int) -> c_int;
isdigit(c: c_int) -> c_int226     pub fn isdigit(c: c_int) -> c_int;
isgraph(c: c_int) -> c_int227     pub fn isgraph(c: c_int) -> c_int;
islower(c: c_int) -> c_int228     pub fn islower(c: c_int) -> c_int;
isprint(c: c_int) -> c_int229     pub fn isprint(c: c_int) -> c_int;
ispunct(c: c_int) -> c_int230     pub fn ispunct(c: c_int) -> c_int;
isspace(c: c_int) -> c_int231     pub fn isspace(c: c_int) -> c_int;
isupper(c: c_int) -> c_int232     pub fn isupper(c: c_int) -> c_int;
isxdigit(c: c_int) -> c_int233     pub fn isxdigit(c: c_int) -> c_int;
tolower(c: c_int) -> c_int234     pub fn tolower(c: c_int) -> c_int;
toupper(c: c_int) -> c_int235     pub fn toupper(c: c_int) -> c_int;
fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE236     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 FILE237     pub fn freopen(filename: *const c_char, mode: *const c_char,
238                    file: *mut FILE) -> *mut FILE;
fflush(file: *mut FILE) -> c_int239     pub fn fflush(file: *mut FILE) -> c_int;
fclose(file: *mut FILE) -> c_int240     pub fn fclose(file: *mut FILE) -> c_int;
remove(filename: *const c_char) -> c_int241     pub fn remove(filename: *const c_char) -> c_int;
rename(oldname: *const c_char, newname: *const c_char) -> c_int242     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
tmpfile() -> *mut FILE243     pub fn tmpfile() -> *mut FILE;
setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int244     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int,
245                    size: size_t) -> c_int;
setbuf(stream: *mut FILE, buf: *mut c_char)246     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
getchar() -> c_int247     pub fn getchar() -> c_int;
putchar(c: c_int) -> c_int248     pub fn putchar(c: c_int) -> c_int;
fgetc(stream: *mut FILE) -> c_int249     pub fn fgetc(stream: *mut FILE) -> c_int;
fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char250     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
fputc(c: c_int, stream: *mut FILE) -> c_int251     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
fputs(s: *const c_char, stream: *mut FILE) -> c_int252     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
puts(s: *const c_char) -> c_int253     pub fn puts(s: *const c_char) -> c_int;
ungetc(c: c_int, stream: *mut FILE) -> c_int254     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_t255     pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t,
256                  stream: *mut FILE) -> size_t;
fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t257     pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t,
258                   stream: *mut FILE) -> size_t;
fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int259     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
ftell(stream: *mut FILE) -> c_long260     pub fn ftell(stream: *mut FILE) -> c_long;
rewind(stream: *mut FILE)261     pub fn rewind(stream: *mut FILE);
fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int262     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int263     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
feof(stream: *mut FILE) -> c_int264     pub fn feof(stream: *mut FILE) -> c_int;
ferror(stream: *mut FILE) -> c_int265     pub fn ferror(stream: *mut FILE) -> c_int;
perror(s: *const c_char)266     pub fn perror(s: *const c_char);
atoi(s: *const c_char) -> c_int267     pub fn atoi(s: *const c_char) -> c_int;
strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double268     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_long269     pub fn strtol(s: *const c_char, endp: *mut *mut c_char,
270                   base: c_int) -> c_long;
strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong271     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
272                    base: c_int) -> c_ulong;
calloc(nobj: size_t, size: size_t) -> *mut c_void273     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
malloc(size: size_t) -> *mut c_void274     pub fn malloc(size: size_t) -> *mut c_void;
realloc(p: *mut c_void, size: size_t) -> *mut c_void275     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
free(p: *mut c_void)276     pub fn free(p: *mut c_void);
abort() -> !277     pub fn abort() -> !;
exit(status: c_int) -> !278     pub fn exit(status: c_int) -> !;
_exit(status: c_int) -> !279     pub fn _exit(status: c_int) -> !;
atexit(cb: extern fn()) -> c_int280     pub fn atexit(cb: extern fn()) -> c_int;
system(s: *const c_char) -> c_int281     pub fn system(s: *const c_char) -> c_int;
getenv(s: *const c_char) -> *mut c_char282     pub fn getenv(s: *const c_char) -> *mut c_char;
283 
strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char284     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_char285     pub fn strncpy(dst: *mut c_char, src: *const c_char,
286                    n: size_t) -> *mut c_char;
strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char287     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_char288     pub fn strncat(s: *mut c_char, ct: *const c_char,
289                    n: size_t) -> *mut c_char;
strcmp(cs: *const c_char, ct: *const c_char) -> c_int290     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_int291     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_int292     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
strchr(cs: *const c_char, c: c_int) -> *mut c_char293     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
strrchr(cs: *const c_char, c: c_int) -> *mut c_char294     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
strspn(cs: *const c_char, ct: *const c_char) -> size_t295     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
strcspn(cs: *const c_char, ct: *const c_char) -> size_t296     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
strdup(cs: *const c_char) -> *mut c_char297     pub fn strdup(cs: *const c_char) -> *mut c_char;
strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char298     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_char299     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strlen(cs: *const c_char) -> size_t300     pub fn strlen(cs: *const c_char) -> size_t;
strnlen(cs: *const c_char, maxlen: size_t) -> size_t301     pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
strerror(n: c_int) -> *mut c_char302     pub fn strerror(n: c_int) -> *mut c_char;
strtok(s: *mut c_char, t: *const c_char) -> *mut c_char303     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_t304     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
wcslen(buf: *const wchar_t) -> size_t305     pub fn wcslen(buf: *const wchar_t) -> size_t;
wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t306     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t,
307                     n: size_t) -> ::size_t;
308 
memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void309     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_int310     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_void311     pub fn memcpy(dest: *mut c_void, src: *const c_void,
312                   n: size_t) -> *mut c_void;
memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void313     pub fn memmove(dest: *mut c_void, src: *const c_void,
314                    n: size_t) -> *mut c_void;
memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void315     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
316 
abs(i: c_int) -> c_int317     pub fn abs(i: c_int) -> c_int;
atof(s: *const c_char) -> c_double318     pub fn atof(s: *const c_char) -> c_double;
labs(i: c_long) -> c_long319     pub fn labs(i: c_long) -> c_long;
rand() -> c_int320     pub fn rand() -> c_int;
srand(seed: c_uint)321     pub fn srand(seed: c_uint);
322 
signal(signum: c_int, handler: sighandler_t) -> sighandler_t323     pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
raise(signum: c_int) -> c_int324     pub fn raise(signum: c_int) -> c_int;
325 
326     #[link_name = "_chmod"]
chmod(path: *const c_char, mode: ::c_int) -> ::c_int327     pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int;
328     #[link_name = "_wchmod"]
wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int329     pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int;
330     #[link_name = "_mkdir"]
mkdir(path: *const c_char) -> ::c_int331     pub fn mkdir(path: *const c_char) -> ::c_int;
332     #[link_name = "_wrmdir"]
wrmdir(path: *const wchar_t) -> ::c_int333     pub fn wrmdir(path: *const wchar_t) -> ::c_int;
334     #[link_name = "_fstat64"]
fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int335     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
336     #[link_name = "_stat64"]
stat(path: *const c_char, buf: *mut stat) -> ::c_int337     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
338     #[link_name = "_wstat64"]
wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int339     pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int;
340     #[link_name = "_wutime64"]
wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int341     pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int;
342     #[link_name = "_popen"]
popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE343     pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
344     #[link_name = "_pclose"]
pclose(stream: *mut ::FILE) -> ::c_int345     pub fn pclose(stream: *mut ::FILE) -> ::c_int;
346     #[link_name = "_fdopen"]
fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE347     pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
348     #[link_name = "_fileno"]
fileno(stream: *mut ::FILE) -> ::c_int349     pub fn fileno(stream: *mut ::FILE) -> ::c_int;
350     #[link_name = "_open"]
open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int351     pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
352     #[link_name = "_wopen"]
wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int353     pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int;
354     #[link_name = "_creat"]
creat(path: *const c_char, mode: ::c_int) -> ::c_int355     pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int;
356     #[link_name = "_access"]
access(path: *const c_char, amode: ::c_int) -> ::c_int357     pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
358     #[link_name = "_chdir"]
chdir(dir: *const c_char) -> ::c_int359     pub fn chdir(dir: *const c_char) -> ::c_int;
360     #[link_name = "_close"]
close(fd: ::c_int) -> ::c_int361     pub fn close(fd: ::c_int) -> ::c_int;
362     #[link_name = "_dup"]
dup(fd: ::c_int) -> ::c_int363     pub fn dup(fd: ::c_int) -> ::c_int;
364     #[link_name = "_dup2"]
dup2(src: ::c_int, dst: ::c_int) -> ::c_int365     pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
366     #[link_name = "_execv"]
execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t367     pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t;
368     #[link_name = "_execve"]
execve(prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> ::c_int369     pub fn execve(prog: *const c_char, argv: *const *const c_char,
370                   envp: *const *const c_char) -> ::c_int;
371     #[link_name = "_execvp"]
execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int372     pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int;
373     #[link_name = "_execvpe"]
execvpe(c: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> ::c_int374     pub fn execvpe(c: *const c_char, argv: *const *const c_char,
375                    envp: *const *const c_char) -> ::c_int;
376     #[link_name = "_getcwd"]
getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char377     pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char;
378     #[link_name = "_getpid"]
getpid() -> ::c_int379     pub fn getpid() -> ::c_int;
380     #[link_name = "_isatty"]
isatty(fd: ::c_int) -> ::c_int381     pub fn isatty(fd: ::c_int) -> ::c_int;
382     #[link_name = "_lseek"]
lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long383     pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long;
384     #[link_name = "_pipe"]
pipe(fds: *mut ::c_int, psize: ::c_uint, textmode: ::c_int) -> ::c_int385     pub fn pipe(fds: *mut ::c_int,
386                 psize: ::c_uint,
387                 textmode: ::c_int) -> ::c_int;
388     #[link_name = "_read"]
read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int389     pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int;
390     #[link_name = "_rmdir"]
rmdir(path: *const c_char) -> ::c_int391     pub fn rmdir(path: *const c_char) -> ::c_int;
392     #[link_name = "_unlink"]
unlink(c: *const c_char) -> ::c_int393     pub fn unlink(c: *const c_char) -> ::c_int;
394     #[link_name = "_write"]
write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int395     pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int;
396     #[link_name = "_commit"]
commit(fd: ::c_int) -> ::c_int397     pub fn commit(fd: ::c_int) -> ::c_int;
398     #[link_name = "_get_osfhandle"]
get_osfhandle(fd: ::c_int) -> ::intptr_t399     pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t;
400     #[link_name = "_open_osfhandle"]
open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int401     pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int;
setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char402     pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char;
403     #[link_name = "_wsetlocale"]
wsetlocale(category: ::c_int, locale: *const wchar_t) -> *mut wchar_t404     pub fn wsetlocale(category: ::c_int,
405                       locale: *const wchar_t) -> *mut wchar_t;
406 }
407 
408 extern "system" {
listen(s: SOCKET, backlog: ::c_int) -> ::c_int409     pub fn listen(s: SOCKET, backlog: ::c_int) -> ::c_int;
accept(s: SOCKET, addr: *mut ::sockaddr, addrlen: *mut ::c_int) -> SOCKET410     pub fn accept(s: SOCKET, addr: *mut ::sockaddr,
411                   addrlen: *mut ::c_int) -> SOCKET;
bind(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int412     pub fn bind(s: SOCKET, name: *const ::sockaddr,
413                 namelen: ::c_int) -> ::c_int;
connect(s: SOCKET, name: *const ::sockaddr, namelen: ::c_int) -> ::c_int414     pub fn connect(s: SOCKET, name: *const ::sockaddr,
415                    namelen: ::c_int) -> ::c_int;
getpeername(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int416     pub fn getpeername(s: SOCKET, name: *mut ::sockaddr,
417                        nameln: *mut ::c_int) -> ::c_int;
getsockname(s: SOCKET, name: *mut ::sockaddr, nameln: *mut ::c_int) -> ::c_int418     pub fn getsockname(s: SOCKET, name: *mut ::sockaddr,
419                        nameln: *mut ::c_int) -> ::c_int;
getsockopt(s: SOCKET, level: ::c_int, optname: ::c_int, optval: *mut ::c_char, optlen: *mut ::c_int) -> ::c_int420     pub fn getsockopt(s: SOCKET, level: ::c_int, optname: ::c_int,
421                       optval: *mut ::c_char,
422                       optlen: *mut ::c_int) -> ::c_int;
recvfrom(s: SOCKET, buf: *mut ::c_char, len: ::c_int, flags: ::c_int, from: *mut ::sockaddr, fromlen: *mut ::c_int) -> ::c_int423     pub fn recvfrom(s: SOCKET, buf: *mut  ::c_char, len: ::c_int,
424                     flags: ::c_int, from: *mut ::sockaddr,
425                     fromlen: *mut ::c_int) -> ::c_int;
sendto(s: SOCKET, buf: *const ::c_char, len: ::c_int, flags: ::c_int, to: *const ::sockaddr, tolen: ::c_int) -> ::c_int426     pub fn sendto(s: SOCKET, buf: *const  ::c_char, len: ::c_int,
427                   flags: ::c_int, to: *const ::sockaddr,
428                   tolen: ::c_int) -> ::c_int;
setsockopt(s: SOCKET, level: ::c_int, optname: ::c_int, optval: *const ::c_char, optlen: ::c_int) -> ::c_int429     pub fn setsockopt(s: SOCKET, level: ::c_int, optname: ::c_int,
430                       optval: *const  ::c_char,
431                       optlen: ::c_int) -> ::c_int;
socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET432     pub fn socket(af: ::c_int, socket_type: ::c_int,
433                   protocol: ::c_int) -> SOCKET;
434 }
435 
436 cfg_if! {
437     if #[cfg(libc_core_cvoid)] {
438         pub use ::ffi::c_void;
439     } else {
440         // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
441         // enable more optimization opportunities around it recognizing things
442         // like malloc/free.
443         #[repr(u8)]
444         #[allow(missing_copy_implementations)]
445         #[allow(missing_debug_implementations)]
446         pub enum c_void {
447             // Two dummy variants so the #[repr] attribute can be used.
448             #[doc(hidden)]
449             __variant1,
450             #[doc(hidden)]
451             __variant2,
452         }
453     }
454 }
455 
456 cfg_if! {
457     if #[cfg(all(target_env = "gnu"))] {
458         mod gnu;
459         pub use self::gnu::*;
460     } else if #[cfg(all(target_env = "msvc"))] {
461         mod msvc;
462         pub use self::msvc::*;
463     } else {
464         // Unknown target_env
465     }
466 }
467