Debian Codegraph @

debian/rust-vendor/libc/src/windows/mod.rs

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