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