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