]>
git.proxmox.com Git - rustc.git/blob - vendor/libc/src/windows/mod.rs
1 //! Windows CRT definitions
5 pub type c_short
= i16;
6 pub type c_ushort
= u16;
9 pub type c_float
= f32;
10 pub type c_double
= f64;
11 pub type c_longlong
= i64;
12 pub type c_ulonglong
= u64;
13 pub type intmax_t
= i64;
14 pub type uintmax_t
= u64;
16 pub type size_t
= usize;
17 pub type ptrdiff_t
= isize;
18 pub type intptr_t
= isize;
19 pub type uintptr_t
= usize;
20 pub type ssize_t
= isize;
21 pub type sighandler_t
= usize;
24 pub type c_long
= i32;
25 pub type c_ulong
= u32;
26 pub type wchar_t
= u16;
28 pub type clock_t
= i32;
31 if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
32 pub type time_t
= i32;
34 pub type time_t
= i64;
41 #[cfg_attr(feature = "extra_traits", derive(Debug))]
43 impl ::Copy
for timezone {}
44 impl ::Clone
for timezone
{
45 fn clone(&self) -> timezone
{
49 pub type time64_t
= i64;
51 pub type SOCKET
= ::uintptr_t
;
54 // note this is the struct called stat64 in Windows. Not stat, nor stati64.
59 pub st_nlink
: ::c_short
,
60 pub st_uid
: ::c_short
,
61 pub st_gid
: ::c_short
,
64 pub st_atime
: time64_t
,
65 pub st_mtime
: time64_t
,
66 pub st_ctime
: time64_t
,
69 // note that this is called utimbuf64 in Windows
72 pub modtime
: time64_t
,
84 pub tm_isdst
: ::c_int
,
98 pub sa_family
: c_ushort
,
99 pub sa_data
: [c_char
; 14],
103 pub const INT_MIN
: c_int
= -2147483648;
104 pub const INT_MAX
: c_int
= 2147483647;
106 pub const EXIT_FAILURE
: ::c_int
= 1;
107 pub const EXIT_SUCCESS
: ::c_int
= 0;
108 pub const RAND_MAX
: ::c_int
= 32767;
109 pub const EOF
: ::c_int
= -1;
110 pub const SEEK_SET
: ::c_int
= 0;
111 pub const SEEK_CUR
: ::c_int
= 1;
112 pub const SEEK_END
: ::c_int
= 2;
113 pub const _IOFBF
: ::c_int
= 0;
114 pub const _IONBF
: ::c_int
= 4;
115 pub const _IOLBF
: ::c_int
= 64;
116 pub const BUFSIZ
: ::c_uint
= 512;
117 pub const FOPEN_MAX
: ::c_uint
= 20;
118 pub const FILENAME_MAX
: ::c_uint
= 260;
120 pub const O_RDONLY
: ::c_int
= 0;
121 pub const O_WRONLY
: ::c_int
= 1;
122 pub const O_RDWR
: ::c_int
= 2;
123 pub const O_APPEND
: ::c_int
= 8;
124 pub const O_CREAT
: ::c_int
= 256;
125 pub const O_EXCL
: ::c_int
= 1024;
126 pub const O_TEXT
: ::c_int
= 16384;
127 pub const O_BINARY
: ::c_int
= 32768;
128 pub const O_NOINHERIT
: ::c_int
= 128;
129 pub const O_TRUNC
: ::c_int
= 512;
130 pub const S_IFCHR
: ::c_int
= 8192;
131 pub const S_IFDIR
: ::c_int
= 16384;
132 pub const S_IFREG
: ::c_int
= 32768;
133 pub const S_IFMT
: ::c_int
= 61440;
134 pub const S_IEXEC
: ::c_int
= 64;
135 pub const S_IWRITE
: ::c_int
= 128;
136 pub const S_IREAD
: ::c_int
= 256;
138 pub const LC_ALL
: ::c_int
= 0;
139 pub const LC_COLLATE
: ::c_int
= 1;
140 pub const LC_CTYPE
: ::c_int
= 2;
141 pub const LC_MONETARY
: ::c_int
= 3;
142 pub const LC_NUMERIC
: ::c_int
= 4;
143 pub const LC_TIME
: ::c_int
= 5;
145 pub const EPERM
: ::c_int
= 1;
146 pub const ENOENT
: ::c_int
= 2;
147 pub const ESRCH
: ::c_int
= 3;
148 pub const EINTR
: ::c_int
= 4;
149 pub const EIO
: ::c_int
= 5;
150 pub const ENXIO
: ::c_int
= 6;
151 pub const E2BIG
: ::c_int
= 7;
152 pub const ENOEXEC
: ::c_int
= 8;
153 pub const EBADF
: ::c_int
= 9;
154 pub const ECHILD
: ::c_int
= 10;
155 pub const EAGAIN
: ::c_int
= 11;
156 pub const ENOMEM
: ::c_int
= 12;
157 pub const EACCES
: ::c_int
= 13;
158 pub const EFAULT
: ::c_int
= 14;
159 pub const EBUSY
: ::c_int
= 16;
160 pub const EEXIST
: ::c_int
= 17;
161 pub const EXDEV
: ::c_int
= 18;
162 pub const ENODEV
: ::c_int
= 19;
163 pub const ENOTDIR
: ::c_int
= 20;
164 pub const EISDIR
: ::c_int
= 21;
165 pub const EINVAL
: ::c_int
= 22;
166 pub const ENFILE
: ::c_int
= 23;
167 pub const EMFILE
: ::c_int
= 24;
168 pub const ENOTTY
: ::c_int
= 25;
169 pub const EFBIG
: ::c_int
= 27;
170 pub const ENOSPC
: ::c_int
= 28;
171 pub const ESPIPE
: ::c_int
= 29;
172 pub const EROFS
: ::c_int
= 30;
173 pub const EMLINK
: ::c_int
= 31;
174 pub const EPIPE
: ::c_int
= 32;
175 pub const EDOM
: ::c_int
= 33;
176 pub const ERANGE
: ::c_int
= 34;
177 pub const EDEADLK
: ::c_int
= 36;
178 pub const EDEADLOCK
: ::c_int
= 36;
179 pub const ENAMETOOLONG
: ::c_int
= 38;
180 pub const ENOLCK
: ::c_int
= 39;
181 pub const ENOSYS
: ::c_int
= 40;
182 pub const ENOTEMPTY
: ::c_int
= 41;
183 pub const EILSEQ
: ::c_int
= 42;
184 pub const STRUNCATE
: ::c_int
= 80;
186 // POSIX Supplement (from errno.h)
187 pub const EADDRINUSE
: ::c_int
= 100;
188 pub const EADDRNOTAVAIL
: ::c_int
= 101;
189 pub const EAFNOSUPPORT
: ::c_int
= 102;
190 pub const EALREADY
: ::c_int
= 103;
191 pub const EBADMSG
: ::c_int
= 104;
192 pub const ECANCELED
: ::c_int
= 105;
193 pub const ECONNABORTED
: ::c_int
= 106;
194 pub const ECONNREFUSED
: ::c_int
= 107;
195 pub const ECONNRESET
: ::c_int
= 108;
196 pub const EDESTADDRREQ
: ::c_int
= 109;
197 pub const EHOSTUNREACH
: ::c_int
= 110;
198 pub const EIDRM
: ::c_int
= 111;
199 pub const EINPROGRESS
: ::c_int
= 112;
200 pub const EISCONN
: ::c_int
= 113;
201 pub const ELOOP
: ::c_int
= 114;
202 pub const EMSGSIZE
: ::c_int
= 115;
203 pub const ENETDOWN
: ::c_int
= 116;
204 pub const ENETRESET
: ::c_int
= 117;
205 pub const ENETUNREACH
: ::c_int
= 118;
206 pub const ENOBUFS
: ::c_int
= 119;
207 pub const ENODATA
: ::c_int
= 120;
208 pub const ENOLINK
: ::c_int
= 121;
209 pub const ENOMSG
: ::c_int
= 122;
210 pub const ENOPROTOOPT
: ::c_int
= 123;
211 pub const ENOSR
: ::c_int
= 124;
212 pub const ENOSTR
: ::c_int
= 125;
213 pub const ENOTCONN
: ::c_int
= 126;
214 pub const ENOTRECOVERABLE
: ::c_int
= 127;
215 pub const ENOTSOCK
: ::c_int
= 128;
216 pub const ENOTSUP
: ::c_int
= 129;
217 pub const EOPNOTSUPP
: ::c_int
= 130;
218 pub const EOVERFLOW
: ::c_int
= 132;
219 pub const EOWNERDEAD
: ::c_int
= 133;
220 pub const EPROTO
: ::c_int
= 134;
221 pub const EPROTONOSUPPORT
: ::c_int
= 135;
222 pub const EPROTOTYPE
: ::c_int
= 136;
223 pub const ETIME
: ::c_int
= 137;
224 pub const ETIMEDOUT
: ::c_int
= 138;
225 pub const ETXTBSY
: ::c_int
= 139;
226 pub const EWOULDBLOCK
: ::c_int
= 140;
229 pub const SIGINT
: ::c_int
= 2;
230 pub const SIGILL
: ::c_int
= 4;
231 pub const SIGFPE
: ::c_int
= 8;
232 pub const SIGSEGV
: ::c_int
= 11;
233 pub const SIGTERM
: ::c_int
= 15;
234 pub const SIGABRT
: ::c_int
= 22;
235 pub const NSIG
: ::c_int
= 23;
236 pub const SIG_ERR
: ::c_int
= -1;
238 // inline comment below appeases style checker
239 #[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
240 #[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
241 #[link(name = "libcmt", cfg(target_feature = "crt-static"))]
244 #[cfg_attr(feature = "extra_traits", derive(Debug))]
246 impl ::Copy
for FILE {}
247 impl ::Clone
for FILE
{
248 fn clone(&self) -> FILE
{
252 #[cfg_attr(feature = "extra_traits", derive(Debug))]
253 pub enum fpos_t {}
// TODO: fill this out with a struct
254 impl ::Copy
for fpos_t {}
255 impl ::Clone
for fpos_t
{
256 fn clone(&self) -> fpos_t
{
262 pub fn isalnum(c
: c_int
) -> c_int
;
263 pub fn isalpha(c
: c_int
) -> c_int
;
264 pub fn iscntrl(c
: c_int
) -> c_int
;
265 pub fn isdigit(c
: c_int
) -> c_int
;
266 pub fn isgraph(c
: c_int
) -> c_int
;
267 pub fn islower(c
: c_int
) -> c_int
;
268 pub fn isprint(c
: c_int
) -> c_int
;
269 pub fn ispunct(c
: c_int
) -> c_int
;
270 pub fn isspace(c
: c_int
) -> c_int
;
271 pub fn isupper(c
: c_int
) -> c_int
;
272 pub fn isxdigit(c
: c_int
) -> c_int
;
273 pub fn isblank(c
: c_int
) -> c_int
;
274 pub fn tolower(c
: c_int
) -> c_int
;
275 pub fn toupper(c
: c_int
) -> c_int
;
276 pub fn fopen(filename
: *const c_char
, mode
: *const c_char
) -> *mut FILE
;
278 filename
: *const c_char
,
282 pub fn fflush(file
: *mut FILE
) -> c_int
;
283 pub fn fclose(file
: *mut FILE
) -> c_int
;
284 pub fn remove(filename
: *const c_char
) -> c_int
;
285 pub fn rename(oldname
: *const c_char
, newname
: *const c_char
) -> c_int
;
286 pub fn tmpfile() -> *mut FILE
;
293 pub fn setbuf(stream
: *mut FILE
, buf
: *mut c_char
);
294 pub fn getchar() -> c_int
;
295 pub fn putchar(c
: c_int
) -> c_int
;
296 pub fn fgetc(stream
: *mut FILE
) -> c_int
;
297 pub fn fgets(buf
: *mut c_char
, n
: c_int
, stream
: *mut FILE
)
299 pub fn fputc(c
: c_int
, stream
: *mut FILE
) -> c_int
;
300 pub fn fputs(s
: *const c_char
, stream
: *mut FILE
) -> c_int
;
301 pub fn puts(s
: *const c_char
) -> c_int
;
302 pub fn ungetc(c
: c_int
, stream
: *mut FILE
) -> c_int
;
315 pub fn fseek(stream
: *mut FILE
, offset
: c_long
, whence
: c_int
) -> c_int
;
316 pub fn ftell(stream
: *mut FILE
) -> c_long
;
317 pub fn rewind(stream
: *mut FILE
);
318 pub fn fgetpos(stream
: *mut FILE
, ptr
: *mut fpos_t
) -> c_int
;
319 pub fn fsetpos(stream
: *mut FILE
, ptr
: *const fpos_t
) -> c_int
;
320 pub fn feof(stream
: *mut FILE
) -> c_int
;
321 pub fn ferror(stream
: *mut FILE
) -> c_int
;
322 pub fn perror(s
: *const c_char
);
323 pub fn atoi(s
: *const c_char
) -> c_int
;
324 pub fn strtod(s
: *const c_char
, endp
: *mut *mut c_char
) -> c_double
;
327 endp
: *mut *mut c_char
,
332 endp
: *mut *mut c_char
,
335 pub fn calloc(nobj
: size_t
, size
: size_t
) -> *mut c_void
;
336 pub fn malloc(size
: size_t
) -> *mut c_void
;
337 pub fn realloc(p
: *mut c_void
, size
: size_t
) -> *mut c_void
;
338 pub fn free(p
: *mut c_void
);
340 pub fn exit(status
: c_int
) -> !;
341 pub fn _exit(status
: c_int
) -> !;
342 pub fn atexit(cb
: extern "C" fn()) -> c_int
;
343 pub fn system(s
: *const c_char
) -> c_int
;
344 pub fn getenv(s
: *const c_char
) -> *mut c_char
;
346 pub fn strcpy(dst
: *mut c_char
, src
: *const c_char
) -> *mut c_char
;
352 pub fn strcat(s
: *mut c_char
, ct
: *const c_char
) -> *mut c_char
;
358 pub fn strcmp(cs
: *const c_char
, ct
: *const c_char
) -> c_int
;
359 pub fn strncmp(cs
: *const c_char
, ct
: *const c_char
, n
: size_t
) -> c_int
;
360 pub fn strcoll(cs
: *const c_char
, ct
: *const c_char
) -> c_int
;
361 pub fn strchr(cs
: *const c_char
, c
: c_int
) -> *mut c_char
;
362 pub fn strrchr(cs
: *const c_char
, c
: c_int
) -> *mut c_char
;
363 pub fn strspn(cs
: *const c_char
, ct
: *const c_char
) -> size_t
;
364 pub fn strcspn(cs
: *const c_char
, ct
: *const c_char
) -> size_t
;
365 pub fn strdup(cs
: *const c_char
) -> *mut c_char
;
366 pub fn strpbrk(cs
: *const c_char
, ct
: *const c_char
) -> *mut c_char
;
367 pub fn strstr(cs
: *const c_char
, ct
: *const c_char
) -> *mut c_char
;
368 pub fn strlen(cs
: *const c_char
) -> size_t
;
369 pub fn strnlen(cs
: *const c_char
, maxlen
: size_t
) -> size_t
;
370 pub fn strerror(n
: c_int
) -> *mut c_char
;
371 pub fn strtok(s
: *mut c_char
, t
: *const c_char
) -> *mut c_char
;
372 pub fn strxfrm(s
: *mut c_char
, ct
: *const c_char
, n
: size_t
) -> size_t
;
373 pub fn wcslen(buf
: *const wchar_t
) -> size_t
;
380 pub fn memchr(cx
: *const c_void
, c
: c_int
, n
: size_t
) -> *mut c_void
;
381 pub fn memcmp(cx
: *const c_void
, ct
: *const c_void
, n
: size_t
) -> c_int
;
392 pub fn memset(dest
: *mut c_void
, c
: c_int
, n
: size_t
) -> *mut c_void
;
394 pub fn abs(i
: c_int
) -> c_int
;
395 pub fn atof(s
: *const c_char
) -> c_double
;
396 pub fn labs(i
: c_long
) -> c_long
;
397 pub fn rand() -> c_int
;
398 pub fn srand(seed
: c_uint
);
400 pub fn signal(signum
: c_int
, handler
: sighandler_t
) -> sighandler_t
;
401 pub fn raise(signum
: c_int
) -> c_int
;
403 #[link_name = "_time64"]
404 pub fn time(destTime
: *mut time_t
) -> time_t
;
405 #[link_name = "_chmod"]
406 pub fn chmod(path
: *const c_char
, mode
: ::c_int
) -> ::c_int
;
407 #[link_name = "_wchmod"]
408 pub fn wchmod(path
: *const wchar_t
, mode
: ::c_int
) -> ::c_int
;
409 #[link_name = "_mkdir"]
410 pub fn mkdir(path
: *const c_char
) -> ::c_int
;
411 #[link_name = "_wrmdir"]
412 pub fn wrmdir(path
: *const wchar_t
) -> ::c_int
;
413 #[link_name = "_fstat64"]
414 pub fn fstat(fildes
: ::c_int
, buf
: *mut stat
) -> ::c_int
;
415 #[link_name = "_stat64"]
416 pub fn stat(path
: *const c_char
, buf
: *mut stat
) -> ::c_int
;
417 #[link_name = "_wstat64"]
418 pub fn wstat(path
: *const wchar_t
, buf
: *mut stat
) -> ::c_int
;
419 #[link_name = "_wutime64"]
420 pub fn wutime(file
: *const wchar_t
, buf
: *mut utimbuf
) -> ::c_int
;
421 #[link_name = "_popen"]
422 pub fn popen(command
: *const c_char
, mode
: *const c_char
) -> *mut ::FILE
;
423 #[link_name = "_pclose"]
424 pub fn pclose(stream
: *mut ::FILE
) -> ::c_int
;
425 #[link_name = "_fdopen"]
426 pub fn fdopen(fd
: ::c_int
, mode
: *const c_char
) -> *mut ::FILE
;
427 #[link_name = "_fileno"]
428 pub fn fileno(stream
: *mut ::FILE
) -> ::c_int
;
429 #[link_name = "_open"]
430 pub fn open(path
: *const c_char
, oflag
: ::c_int
, ...) -> ::c_int
;
431 #[link_name = "_wopen"]
432 pub fn wopen(path
: *const wchar_t
, oflag
: ::c_int
, ...) -> ::c_int
;
433 #[link_name = "_creat"]
434 pub fn creat(path
: *const c_char
, mode
: ::c_int
) -> ::c_int
;
435 #[link_name = "_access"]
436 pub fn access(path
: *const c_char
, amode
: ::c_int
) -> ::c_int
;
437 #[link_name = "_chdir"]
438 pub fn chdir(dir
: *const c_char
) -> ::c_int
;
439 #[link_name = "_close"]
440 pub fn close(fd
: ::c_int
) -> ::c_int
;
441 #[link_name = "_dup"]
442 pub fn dup(fd
: ::c_int
) -> ::c_int
;
443 #[link_name = "_dup2"]
444 pub fn dup2(src
: ::c_int
, dst
: ::c_int
) -> ::c_int
;
445 #[link_name = "_execv"]
448 argv
: *const *const c_char
,
450 #[link_name = "_execve"]
453 argv
: *const *const c_char
,
454 envp
: *const *const c_char
,
456 #[link_name = "_execvp"]
457 pub fn execvp(c
: *const c_char
, argv
: *const *const c_char
) -> ::c_int
;
458 #[link_name = "_execvpe"]
461 argv
: *const *const c_char
,
462 envp
: *const *const c_char
,
464 #[link_name = "_getcwd"]
465 pub fn getcwd(buf
: *mut c_char
, size
: ::c_int
) -> *mut c_char
;
466 #[link_name = "_getpid"]
467 pub fn getpid() -> ::c_int
;
468 #[link_name = "_isatty"]
469 pub fn isatty(fd
: ::c_int
) -> ::c_int
;
470 #[link_name = "_lseek"]
471 pub fn lseek(fd
: ::c_int
, offset
: c_long
, origin
: ::c_int
) -> c_long
;
472 #[link_name = "_lseeki64"]
478 #[link_name = "_pipe"]
484 #[link_name = "_read"]
485 pub fn read(fd
: ::c_int
, buf
: *mut ::c_void
, count
: ::c_uint
) -> ::c_int
;
486 #[link_name = "_rmdir"]
487 pub fn rmdir(path
: *const c_char
) -> ::c_int
;
488 #[link_name = "_unlink"]
489 pub fn unlink(c
: *const c_char
) -> ::c_int
;
490 #[link_name = "_write"]
493 buf
: *const ::c_void
,
496 #[link_name = "_commit"]
497 pub fn commit(fd
: ::c_int
) -> ::c_int
;
498 #[link_name = "_get_osfhandle"]
499 pub fn get_osfhandle(fd
: ::c_int
) -> ::intptr_t
;
500 #[link_name = "_open_osfhandle"]
501 pub fn open_osfhandle(osfhandle
: ::intptr_t
, flags
: ::c_int
) -> ::c_int
;
502 pub fn setlocale(category
: ::c_int
, locale
: *const c_char
) -> *mut c_char
;
503 #[link_name = "_wsetlocale"]
506 locale
: *const wchar_t
,
511 pub fn listen(s
: SOCKET
, backlog
: ::c_int
) -> ::c_int
;
514 addr
: *mut ::sockaddr
,
515 addrlen
: *mut ::c_int
,
519 name
: *const ::sockaddr
,
524 name
: *const ::sockaddr
,
529 name
: *mut ::sockaddr
,
530 nameln
: *mut ::c_int
,
534 name
: *mut ::sockaddr
,
535 nameln
: *mut ::c_int
,
541 optval
: *mut ::c_char
,
542 optlen
: *mut ::c_int
,
549 from
: *mut ::sockaddr
,
550 fromlen
: *mut ::c_int
,
554 buf
: *const ::c_char
,
557 to
: *const ::sockaddr
,
564 optval
: *const ::c_char
,
569 socket_type
: ::c_int
,
575 if #[cfg(libc_core_cvoid)] {
576 pub use ::ffi
::c_void
;
578 // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
579 // enable more optimization opportunities around it recognizing things
582 #[allow(missing_copy_implementations)]
583 #[allow(missing_debug_implementations)]
585 // Two dummy variants so the #[repr] attribute can be used.
595 if #[cfg(all(target_env = "gnu"))] {
597 pub use self::gnu
::*;
598 } else if #[cfg(all(target_env = "msvc"))] {
600 pub use self::msvc
::*;
602 // Unknown target_env