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