]> git.proxmox.com Git - cargo.git/blob - vendor/libc-0.2.31/src/windows.rs
New upstream version 0.23.0
[cargo.git] / vendor / libc-0.2.31 / src / windows.rs
1 //! Windows CRT definitions
2
3 pub type c_char = i8;
4 pub type c_long = i32;
5 pub type c_ulong = u32;
6 pub type wchar_t = u16;
7
8 pub type clock_t = i32;
9
10 cfg_if! {
11 if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
12 pub type time_t = i32;
13 } else {
14 pub type time_t = i64;
15 }
16 }
17
18 pub type off_t = i32;
19 pub type dev_t = u32;
20 pub type ino_t = u16;
21 pub enum timezone {}
22 pub type time64_t = i64;
23
24 s! {
25 // note this is the struct called stat64 in Windows. Not stat, nor stati64.
26 pub struct stat {
27 pub st_dev: dev_t,
28 pub st_ino: ino_t,
29 pub st_mode: u16,
30 pub st_nlink: ::c_short,
31 pub st_uid: ::c_short,
32 pub st_gid: ::c_short,
33 pub st_rdev: dev_t,
34 pub st_size: i64,
35 pub st_atime: time64_t,
36 pub st_mtime: time64_t,
37 pub st_ctime: time64_t,
38 }
39
40 // note that this is called utimbuf64 in Windows
41 pub struct utimbuf {
42 pub actime: time64_t,
43 pub modtime: time64_t,
44 }
45
46 pub struct tm {
47 tm_sec: ::c_int,
48 tm_min: ::c_int,
49 tm_hour: ::c_int,
50 tm_mday: ::c_int,
51 tm_mon: ::c_int,
52 tm_year: ::c_int,
53 tm_wday: ::c_int,
54 tm_yday: ::c_int,
55 tm_isdst: ::c_int,
56 }
57
58 pub struct timeval {
59 pub tv_sec: c_long,
60 pub tv_usec: c_long,
61 }
62
63 pub struct timespec {
64 pub tv_sec: time_t,
65 pub tv_nsec: c_long,
66 }
67 }
68
69 pub const EXIT_FAILURE: ::c_int = 1;
70 pub const EXIT_SUCCESS: ::c_int = 0;
71 pub const RAND_MAX: ::c_int = 32767;
72 pub const EOF: ::c_int = -1;
73 pub const SEEK_SET: ::c_int = 0;
74 pub const SEEK_CUR: ::c_int = 1;
75 pub const SEEK_END: ::c_int = 2;
76 pub const _IOFBF: ::c_int = 0;
77 pub const _IONBF: ::c_int = 4;
78 pub const _IOLBF: ::c_int = 64;
79 pub const BUFSIZ: ::c_uint = 512;
80 pub const FOPEN_MAX: ::c_uint = 20;
81 pub const FILENAME_MAX: ::c_uint = 260;
82
83 cfg_if! {
84 if #[cfg(all(target_env = "gnu"))] {
85 pub const L_tmpnam: ::c_uint = 14;
86 pub const TMP_MAX: ::c_uint = 0x7fff;
87 } else if #[cfg(all(target_env = "msvc"))] {
88 pub const L_tmpnam: ::c_uint = 260;
89 pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
90 } else {
91 // Unknown target_env
92 }
93 }
94
95 pub const O_RDONLY: ::c_int = 0;
96 pub const O_WRONLY: ::c_int = 1;
97 pub const O_RDWR: ::c_int = 2;
98 pub const O_APPEND: ::c_int = 8;
99 pub const O_CREAT: ::c_int = 256;
100 pub const O_EXCL: ::c_int = 1024;
101 pub const O_TEXT: ::c_int = 16384;
102 pub const O_BINARY: ::c_int = 32768;
103 pub const O_NOINHERIT: ::c_int = 128;
104 pub const O_TRUNC: ::c_int = 512;
105 pub const S_IFCHR: ::c_int = 8192;
106 pub const S_IFDIR: ::c_int = 16384;
107 pub const S_IFREG: ::c_int = 32768;
108 pub const S_IFMT: ::c_int = 61440;
109 pub const S_IEXEC: ::c_int = 64;
110 pub const S_IWRITE: ::c_int = 128;
111 pub const S_IREAD: ::c_int = 256;
112
113 pub const LC_ALL: ::c_int = 0;
114 pub const LC_COLLATE: ::c_int = 1;
115 pub const LC_CTYPE: ::c_int = 2;
116 pub const LC_MONETARY: ::c_int = 3;
117 pub const LC_NUMERIC: ::c_int = 4;
118 pub const LC_TIME: ::c_int = 5;
119
120 pub const EPERM: ::c_int = 1;
121 pub const ENOENT: ::c_int = 2;
122 pub const ESRCH: ::c_int = 3;
123 pub const EINTR: ::c_int = 4;
124 pub const EIO: ::c_int = 5;
125 pub const ENXIO: ::c_int = 6;
126 pub const E2BIG: ::c_int = 7;
127 pub const ENOEXEC: ::c_int = 8;
128 pub const EBADF: ::c_int = 9;
129 pub const ECHILD: ::c_int = 10;
130 pub const EAGAIN: ::c_int = 11;
131 pub const ENOMEM: ::c_int = 12;
132 pub const EACCES: ::c_int = 13;
133 pub const EFAULT: ::c_int = 14;
134 pub const EBUSY: ::c_int = 16;
135 pub const EEXIST: ::c_int = 17;
136 pub const EXDEV: ::c_int = 18;
137 pub const ENODEV: ::c_int = 19;
138 pub const ENOTDIR: ::c_int = 20;
139 pub const EISDIR: ::c_int = 21;
140 pub const EINVAL: ::c_int = 22;
141 pub const ENFILE: ::c_int = 23;
142 pub const EMFILE: ::c_int = 24;
143 pub const ENOTTY: ::c_int = 25;
144 pub const EFBIG: ::c_int = 27;
145 pub const ENOSPC: ::c_int = 28;
146 pub const ESPIPE: ::c_int = 29;
147 pub const EROFS: ::c_int = 30;
148 pub const EMLINK: ::c_int = 31;
149 pub const EPIPE: ::c_int = 32;
150 pub const EDOM: ::c_int = 33;
151 pub const ERANGE: ::c_int = 34;
152 pub const EDEADLK: ::c_int = 36;
153 pub const EDEADLOCK: ::c_int = 36;
154 pub const ENAMETOOLONG: ::c_int = 38;
155 pub const ENOLCK: ::c_int = 39;
156 pub const ENOSYS: ::c_int = 40;
157 pub const ENOTEMPTY: ::c_int = 41;
158 pub const EILSEQ: ::c_int = 42;
159 pub const STRUNCATE: ::c_int = 80;
160
161 // inline comment below appeases style checker
162 #[cfg(all(target_env = "msvc", feature = "stdbuild"))] // " if "
163 #[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
164 #[link(name = "libcmt", cfg(target_feature = "crt-static"))]
165 extern {}
166
167 extern {
168 #[link_name = "_chmod"]
169 pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int;
170 #[link_name = "_wchmod"]
171 pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int;
172 #[link_name = "_mkdir"]
173 pub fn mkdir(path: *const c_char) -> ::c_int;
174 #[link_name = "_wrmdir"]
175 pub fn wrmdir(path: *const wchar_t) -> ::c_int;
176 #[link_name = "_fstat64"]
177 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
178 #[link_name = "_stat64"]
179 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
180 #[link_name = "_wstat64"]
181 pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int;
182 #[link_name = "_wutime64"]
183 pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int;
184 #[link_name = "_popen"]
185 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
186 #[link_name = "_pclose"]
187 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
188 #[link_name = "_fdopen"]
189 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
190 #[link_name = "_fileno"]
191 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
192 #[link_name = "_open"]
193 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
194 #[link_name = "_wopen"]
195 pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int;
196 #[link_name = "_creat"]
197 pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int;
198 #[link_name = "_access"]
199 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
200 #[link_name = "_chdir"]
201 pub fn chdir(dir: *const c_char) -> ::c_int;
202 #[link_name = "_close"]
203 pub fn close(fd: ::c_int) -> ::c_int;
204 #[link_name = "_dup"]
205 pub fn dup(fd: ::c_int) -> ::c_int;
206 #[link_name = "_dup2"]
207 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
208 #[link_name = "_execv"]
209 pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t;
210 #[link_name = "_execve"]
211 pub fn execve(prog: *const c_char, argv: *const *const c_char,
212 envp: *const *const c_char) -> ::c_int;
213 #[link_name = "_execvp"]
214 pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int;
215 #[link_name = "_execvpe"]
216 pub fn execvpe(c: *const c_char, argv: *const *const c_char,
217 envp: *const *const c_char) -> ::c_int;
218 #[link_name = "_getcwd"]
219 pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char;
220 #[link_name = "_getpid"]
221 pub fn getpid() -> ::c_int;
222 #[link_name = "_isatty"]
223 pub fn isatty(fd: ::c_int) -> ::c_int;
224 #[link_name = "_lseek"]
225 pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long;
226 #[link_name = "_pipe"]
227 pub fn pipe(fds: *mut ::c_int,
228 psize: ::c_uint,
229 textmode: ::c_int) -> ::c_int;
230 #[link_name = "_read"]
231 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int;
232 #[link_name = "_rmdir"]
233 pub fn rmdir(path: *const c_char) -> ::c_int;
234 #[link_name = "_unlink"]
235 pub fn unlink(c: *const c_char) -> ::c_int;
236 #[link_name = "_write"]
237 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int;
238 #[link_name = "_commit"]
239 pub fn commit(fd: ::c_int) -> ::c_int;
240 #[link_name = "_get_osfhandle"]
241 pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t;
242 #[link_name = "_open_osfhandle"]
243 pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int;
244 pub fn setlocale(category: ::c_int, locale: *const c_char) -> *mut c_char;
245 #[link_name = "_wsetlocale"]
246 pub fn wsetlocale(category: ::c_int,
247 locale: *const wchar_t) -> *mut wchar_t;
248 }