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