blob: 0c38bef301a280aff7595b9786a47e660a20d780 [file] [log] [blame]
Alex Crichtond3d77922015-09-11 17:03:39 -07001//! Windows CRT definitions
2
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -07003pub type c_char = i8;
4pub type c_schar = i8;
5pub type c_uchar = u8;
6pub type c_short = i16;
7pub type c_ushort = u16;
8pub type c_int = i32;
9pub type c_uint = u32;
10pub type c_long = i32;
11pub type c_ulong = u32;
12pub type c_float = f32;
13pub type c_double = f64;
14pub type wchar_t = u16;
15pub type c_longlong = i64;
16pub type c_ulonglong = u64;
17pub type intmax_t = i64;
18pub type uintmax_t = u64;
Alex Crichton5d6cf052015-09-11 14:52:34 -070019
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070020cfg_if! {
21 if #[cfg(target_arch = "x86")] {
22 pub type intptr_t = i32;
23 pub type ptrdiff_t = i32;
24 pub type size_t = u32;
25 pub type ssize_t = i32;
26 pub type uintptr_t = u32;
27 pub type LONG_PTR = c_long;
28 } else if #[cfg(target_arch = "x86_64")] {
29 pub type intptr_t = i64;
30 pub type ptrdiff_t = i64;
31 pub type size_t = u64;
32 pub type ssize_t = i64;
33 pub type uintptr_t = u64;
34 pub type LONG_PTR = i64;
35 } else {
36 // unknown arch
Alex Crichton5d6cf052015-09-11 14:52:34 -070037 }
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070038}
Alex Crichton5d6cf052015-09-11 14:52:34 -070039
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070040pub type clock_t = i32;
Alex Crichton5d6cf052015-09-11 14:52:34 -070041
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070042cfg_if! {
43 if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
44 pub type time_t = i32;
45 } else {
46 pub type time_t = i64;
47 }
48}
Alex Crichton5d6cf052015-09-11 14:52:34 -070049
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070050pub type off_t = i32;
51pub type dev_t = u32;
52pub type ino_t = u16;
53pub enum timezone {}
54pub type time64_t = i64;
Alex Crichton5d6cf052015-09-11 14:52:34 -070055
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070056pub type BOOL = c_int;
57pub type BYTE = u8;
58pub type BOOLEAN = BYTE;
59pub type CCHAR = c_char;
60pub type CHAR = c_char;
61pub type DWORD = c_ulong;
62pub type DWORDLONG = c_ulonglong;
63pub type HANDLE = LPVOID;
64pub type HINSTANCE = HANDLE;
65pub type HMODULE = HINSTANCE;
66pub type LONG = c_long;
67pub type PLONG = *mut c_long;
68pub type LARGE_INTEGER = c_longlong;
69pub type PLARGE_INTEGER = *mut c_longlong;
70pub type LPCWSTR = *const WCHAR;
71pub type LPCSTR = *const CHAR;
72pub type LPWSTR = *mut WCHAR;
73pub type LPSTR = *mut CHAR;
74pub type LPWCH = *mut WCHAR;
75pub type LPCH = *mut CHAR;
76pub type SOCKET = uintptr_t;
77pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
78pub type LPVOID = *mut ::c_void;
79pub type LPCVOID = *const ::c_void;
80pub type LPBYTE = *mut BYTE;
81pub type LPWORD = *mut WORD;
82pub type LPDWORD = *mut DWORD;
83pub type LPHANDLE = *mut HANDLE;
84pub type LRESULT = LONG_PTR;
85pub type PBOOL = *mut BOOL;
86pub type WCHAR = wchar_t;
87pub type WORD = u16;
88pub type SIZE_T = size_t;
89pub type GROUP = c_uint;
90pub type LPSTARTUPINFOW = *mut STARTUPINFOW;
91pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
92pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
93pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
94pub type LPOVERLAPPED = *mut OVERLAPPED;
95pub type LPFILETIME = *mut FILETIME;
96pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
97pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
98pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
Alex Crichton2de0b8b2015-09-16 18:43:20 -070099pub type UCHAR = c_uchar;
100pub type ULONG = c_ulong;
101cfg_if! {
102 if #[cfg(target_arch = "x86_64")] {
103 pub type ULONG_PTR = u64;
104 } else {
105 pub type ULONG_PTR = c_ulong;
106 }
107}
Alex Crichton5d6cf052015-09-11 14:52:34 -0700108
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700109s! {
110 // note this is the struct called stat64 in Windows. Not stat, nor stati64.
111 pub struct stat {
112 pub st_dev: dev_t,
113 pub st_ino: ino_t,
114 pub st_mode: u16,
115 pub st_nlink: c_short,
116 pub st_uid: c_short,
117 pub st_gid: c_short,
118 pub st_rdev: dev_t,
119 pub st_size: i64,
120 pub st_atime: time64_t,
121 pub st_mtime: time64_t,
122 pub st_ctime: time64_t,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700123 }
124
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700125 // note that this is called utimbuf64 in Windows
126 pub struct utimbuf {
127 pub actime: time64_t,
128 pub modtime: time64_t,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700129 }
130
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700131 pub struct timeval {
132 pub tv_sec: c_long,
133 pub tv_usec: c_long,
134 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700135
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700136 pub struct timespec {
137 pub tv_sec: time_t,
138 pub tv_nsec: c_long,
139 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700140
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700141 pub struct sockaddr {
142 pub sa_family: u16,
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700143 pub sa_data: [CHAR; 14],
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700144 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700145
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700146 pub struct sockaddr_storage {
Alex Crichton3abaff12015-09-16 22:59:53 -0700147 #[cfg(target_env = "msvc")]
148 pub ss_family: c_ushort,
149 #[cfg(not(target_env = "msvc"))]
150 pub ss_family: c_short,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700151 __ss_pad1: [u8; 6],
152 __ss_align: i64,
153 __ss_pad2: [u8; 112],
154 }
155
156 pub struct sockaddr_in {
Alex Crichton3abaff12015-09-16 22:59:53 -0700157 #[cfg(target_env = "msvc")]
158 pub sin_family: c_ushort,
159 #[cfg(not(target_env = "msvc"))]
160 pub sin_family: c_short,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700161 pub sin_port: u16,
162 pub sin_addr: in_addr,
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700163 pub sin_zero: [CHAR; 8],
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700164 }
165
166 pub struct in_addr {
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700167 pub s_addr: ULONG,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700168 }
169
170 pub struct sockaddr_in6 {
Alex Crichton3abaff12015-09-16 22:59:53 -0700171 #[cfg(target_env = "msvc")]
172 pub sin6_family: c_ushort,
173 #[cfg(not(target_env = "msvc"))]
174 pub sin6_family: c_short,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700175 pub sin6_port: u16,
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700176 pub sin6_flowinfo: ULONG,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700177 pub sin6_addr: in6_addr,
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700178 pub sin6_scope_id: ULONG,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700179 }
180
181 pub struct in6_addr {
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700182 pub s6_addr: [UCHAR; 16],
Alex Crichton4f04e232015-09-16 22:54:38 -0700183 _align: [u16; 0],
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700184 }
185
186 pub struct ip_mreq {
187 pub imr_multiaddr: in_addr,
188 pub imr_interface: in_addr,
189 }
190
191 pub struct ipv6_mreq {
192 pub ipv6mr_multiaddr: in6_addr,
Alex Crichton3abaff12015-09-16 22:59:53 -0700193 #[cfg(target_env = "msvc")]
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700194 pub ipv6mr_interface: ULONG,
Alex Crichton3abaff12015-09-16 22:59:53 -0700195 #[cfg(not(target_env = "msvc"))]
196 pub ipv6mr_interface: c_uint,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700197 }
198
199 pub struct addrinfo {
200 pub ai_flags: c_int,
201 pub ai_family: c_int,
202 pub ai_socktype: c_int,
203 pub ai_protocol: c_int,
204 pub ai_addrlen: size_t,
205 pub ai_canonname: *mut c_char,
206 pub ai_addr: *mut sockaddr,
207 pub ai_next: *mut addrinfo,
208 }
209
210 pub struct SECURITY_ATTRIBUTES {
211 pub nLength: DWORD,
212 pub lpSecurityDescriptor: LPVOID,
213 pub bInheritHandle: BOOL,
214 }
215
216 pub struct STARTUPINFOW {
217 pub cb: DWORD,
218 pub lpReserved: LPWSTR,
219 pub lpDesktop: LPWSTR,
220 pub lpTitle: LPWSTR,
221 pub dwX: DWORD,
222 pub dwY: DWORD,
223 pub dwXSize: DWORD,
224 pub dwYSize: DWORD,
225 pub dwXCountChars: DWORD,
226 pub dwYCountChars: DWORD,
227 pub dwFillAttribute: DWORD,
228 pub dwFlags: DWORD,
229 pub wShowWindow: WORD,
230 pub cbReserved2: WORD,
231 pub lpReserved2: LPBYTE,
232 pub hStdInput: HANDLE,
233 pub hStdOutput: HANDLE,
234 pub hStdError: HANDLE,
235 }
236
237 pub struct PROCESS_INFORMATION {
238 pub hProcess: HANDLE,
239 pub hThread: HANDLE,
240 pub dwProcessId: DWORD,
241 pub dwThreadId: DWORD,
242 }
243
244 pub struct SYSTEM_INFO {
245 pub wProcessorArchitecture: WORD,
246 pub wReserved: WORD,
247 pub dwPageSize: DWORD,
248 pub lpMinimumApplicationAddress: LPVOID,
249 pub lpMaximumApplicationAddress: LPVOID,
250 pub dwActiveProcessorMask: uintptr_t,
251 pub dwNumberOfProcessors: DWORD,
252 pub dwProcessorType: DWORD,
253 pub dwAllocationGranularity: DWORD,
254 pub wProcessorLevel: WORD,
255 pub wProcessorRevision: WORD,
256 }
257
258 pub struct MEMORY_BASIC_INFORMATION {
259 pub BaseAddress: LPVOID,
260 pub AllocationBase: LPVOID,
261 pub AllocationProtect: DWORD,
262 pub RegionSize: SIZE_T,
263 pub State: DWORD,
264 pub Protect: DWORD,
265 pub Type: DWORD,
266 }
267
268 pub struct OVERLAPPED {
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700269 pub Internal: ULONG_PTR,
270 pub InternalHigh: ULONG_PTR,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700271 pub Offset: DWORD,
272 pub OffsetHigh: DWORD,
273 pub hEvent: HANDLE,
274 }
275
276 pub struct FILETIME {
277 pub dwLowDateTime: DWORD,
278 pub dwHighDateTime: DWORD,
279 }
280
281 pub struct GUID {
282 pub Data1: DWORD,
283 pub Data2: WORD,
284 pub Data3: WORD,
285 pub Data4: [BYTE; 8],
286 }
287
288 pub struct WSAPROTOCOLCHAIN {
289 pub ChainLen: c_int,
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700290 pub ChainEntries: [DWORD; 7],
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700291 }
292
293 pub struct WSAPROTOCOL_INFO {
294 pub dwServiceFlags1: DWORD,
295 pub dwServiceFlags2: DWORD,
296 pub dwServiceFlags3: DWORD,
297 pub dwServiceFlags4: DWORD,
298 pub dwProviderFlags: DWORD,
299 pub ProviderId: GUID,
300 pub dwCatalogEntryId: DWORD,
301 pub ProtocolChain: WSAPROTOCOLCHAIN,
302 pub iVersion: c_int,
303 pub iAddressFamily: c_int,
304 pub iMaxSockAddr: c_int,
305 pub iMinSockAddr: c_int,
306 pub iSocketType: c_int,
307 pub iProtocol: c_int,
308 pub iProtocolMaxOffset: c_int,
309 pub iNetworkByteOrder: c_int,
310 pub iSecurityScheme: c_int,
311 pub dwMessageSize: DWORD,
312 pub dwProviderReserved: DWORD,
Alex Crichton2de0b8b2015-09-16 18:43:20 -0700313 pub szProtocol: [CHAR; 256],
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700314 }
315
316 pub struct WIN32_FIND_DATAW {
317 pub dwFileAttributes: DWORD,
318 pub ftCreationTime: FILETIME,
319 pub ftLastAccessTime: FILETIME,
320 pub ftLastWriteTime: FILETIME,
321 pub nFileSizeHigh: DWORD,
322 pub nFileSizeLow: DWORD,
323 pub dwReserved0: DWORD,
324 pub dwReserved1: DWORD,
325 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
326 pub cAlternateFileName: [wchar_t; 14],
327 }
328}
329
330pub const EXIT_FAILURE: c_int = 1;
331pub const EXIT_SUCCESS: c_int = 0;
332pub const RAND_MAX: c_int = 32767;
333pub const EOF: c_int = -1;
334pub const SEEK_SET: c_int = 0;
335pub const SEEK_CUR: c_int = 1;
336pub const SEEK_END: c_int = 2;
337pub const _IOFBF: c_int = 0;
338pub const _IONBF: c_int = 4;
339pub const _IOLBF: c_int = 64;
340pub const BUFSIZ: c_uint = 512;
341pub const FOPEN_MAX: c_uint = 20;
342pub const FILENAME_MAX: c_uint = 260;
343
344pub const WSAEINTR: c_int = 10004;
345pub const WSAEBADF: c_int = 10009;
346pub const WSAEACCES: c_int = 10013;
347pub const WSAEFAULT: c_int = 10014;
348pub const WSAEINVAL: c_int = 10022;
349pub const WSAEMFILE: c_int = 10024;
350pub const WSAEWOULDBLOCK: c_int = 10035;
351pub const WSAEINPROGRESS: c_int = 10036;
352pub const WSAEALREADY: c_int = 10037;
353pub const WSAENOTSOCK: c_int = 10038;
354pub const WSAEDESTADDRREQ: c_int = 10039;
355pub const WSAEMSGSIZE: c_int = 10040;
356pub const WSAEPROTOTYPE: c_int = 10041;
357pub const WSAENOPROTOOPT: c_int = 10042;
358pub const WSAEPROTONOSUPPORT: c_int = 10043;
359pub const WSAESOCKTNOSUPPORT: c_int = 10044;
360pub const WSAEOPNOTSUPP: c_int = 10045;
361pub const WSAEPFNOSUPPORT: c_int = 10046;
362pub const WSAEAFNOSUPPORT: c_int = 10047;
363pub const WSAEADDRINUSE: c_int = 10048;
364pub const WSAEADDRNOTAVAIL: c_int = 10049;
365pub const WSAENETDOWN: c_int = 10050;
366pub const WSAENETUNREACH: c_int = 10051;
367pub const WSAENETRESET: c_int = 10052;
368pub const WSAECONNABORTED: c_int = 10053;
369pub const WSAECONNRESET: c_int = 10054;
370pub const WSAENOBUFS: c_int = 10055;
371pub const WSAEISCONN: c_int = 10056;
372pub const WSAENOTCONN: c_int = 10057;
373pub const WSAESHUTDOWN: c_int = 10058;
374pub const WSAETOOMANYREFS: c_int = 10059;
375pub const WSAETIMEDOUT: c_int = 10060;
376pub const WSAECONNREFUSED: c_int = 10061;
377pub const WSAELOOP: c_int = 10062;
378pub const WSAENAMETOOLONG: c_int = 10063;
379pub const WSAEHOSTDOWN: c_int = 10064;
380pub const WSAEHOSTUNREACH: c_int = 10065;
381pub const WSAENOTEMPTY: c_int = 10066;
382pub const WSAEPROCLIM: c_int = 10067;
383pub const WSAEUSERS: c_int = 10068;
384pub const WSAEDQUOT: c_int = 10069;
385pub const WSAESTALE: c_int = 10070;
386pub const WSAEREMOTE: c_int = 10071;
387pub const WSASYSNOTREADY: c_int = 10091;
388pub const WSAVERNOTSUPPORTED: c_int = 10092;
389pub const WSANOTINITIALISED: c_int = 10093;
390pub const WSAEDISCON: c_int = 10101;
391pub const WSAENOMORE: c_int = 10102;
392pub const WSAECANCELLED: c_int = 10103;
393pub const WSAEINVALIDPROCTABLE: c_int = 10104;
394pub const WSAEINVALIDPROVIDER: c_int = 10105;
395pub const WSAEPROVIDERFAILEDINIT: c_int = 10106;
396
397cfg_if! {
398 if #[cfg(all(target_env = "gnu"))] {
399 pub const L_tmpnam: c_uint = 14;
400 pub const TMP_MAX: c_uint = 0x7fff;
401 } else {
402 pub const L_tmpnam: c_uint = 260;
403 pub const TMP_MAX: c_uint = 0x7fff_ffff;
404 }
405}
406
407pub const O_RDONLY: c_int = 0;
408pub const O_WRONLY: c_int = 1;
409pub const O_RDWR: c_int = 2;
410pub const O_APPEND: c_int = 8;
411pub const O_CREAT: c_int = 256;
412pub const O_EXCL: c_int = 1024;
413pub const O_TRUNC: c_int = 512;
414pub const S_IFCHR: c_int = 8192;
415pub const S_IFDIR: c_int = 16384;
416pub const S_IFREG: c_int = 32768;
417pub const S_IFMT: c_int = 61440;
418pub const S_IEXEC: c_int = 64;
419pub const S_IWRITE: c_int = 128;
420pub const S_IREAD: c_int = 256;
421
422pub const AF_INET: c_int = 2;
423pub const AF_INET6: c_int = 23;
424pub const SOCK_STREAM: c_int = 1;
425pub const SOCK_DGRAM: c_int = 2;
426pub const SOCK_RAW: c_int = 3;
427pub const IPPROTO_TCP: c_int = 6;
428pub const IPPROTO_IP: c_int = 0;
429pub const IPPROTO_IPV6: c_int = 41;
430pub const IP_MULTICAST_TTL: c_int = 10;
431pub const IP_MULTICAST_LOOP: c_int = 11;
432pub const IP_ADD_MEMBERSHIP: c_int = 12;
433pub const IP_DROP_MEMBERSHIP: c_int = 13;
434pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
435pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
436pub const IP_TTL: c_int = 4;
437pub const IP_HDRINCL: c_int = 2;
438
439pub const TCP_NODELAY: c_int = 0x0001;
440pub const SOL_SOCKET: c_int = 0xffff;
441
442pub const SO_DEBUG: c_int = 0x0001;
443pub const SO_ACCEPTCONN: c_int = 0x0002;
444pub const SO_REUSEADDR: c_int = 0x0004;
445pub const SO_KEEPALIVE: c_int = 0x0008;
446pub const SO_DONTROUTE: c_int = 0x0010;
447pub const SO_BROADCAST: c_int = 0x0020;
448pub const SO_USELOOPBACK: c_int = 0x0040;
449pub const SO_LINGER: c_int = 0x0080;
450pub const SO_OOBINLINE: c_int = 0x0100;
451pub const SO_SNDBUF: c_int = 0x1001;
452pub const SO_RCVBUF: c_int = 0x1002;
453pub const SO_SNDLOWAT: c_int = 0x1003;
454pub const SO_RCVLOWAT: c_int = 0x1004;
455pub const SO_SNDTIMEO: c_int = 0x1005;
456pub const SO_RCVTIMEO: c_int = 0x1006;
457pub const SO_ERROR: c_int = 0x1007;
458pub const SO_TYPE: c_int = 0x1008;
459
460pub const IFF_LOOPBACK: c_int = 4;
461
462pub const SD_RECEIVE: c_int = 0;
463pub const SD_SEND: c_int = 1;
464pub const SD_BOTH: c_int = 2;
465
466pub const TRUE: BOOL = 1;
467pub const FALSE: BOOL = 0;
468
469pub const O_TEXT: c_int = 16384;
470pub const O_BINARY: c_int = 32768;
471pub const O_NOINHERIT: c_int = 128;
472
473pub const ERROR_SUCCESS: c_int = 0;
474pub const ERROR_INVALID_FUNCTION: c_int = 1;
475pub const ERROR_FILE_NOT_FOUND: c_int = 2;
476pub const ERROR_ACCESS_DENIED: c_int = 5;
477pub const ERROR_INVALID_HANDLE: c_int = 6;
478pub const ERROR_BROKEN_PIPE: c_int = 109;
479pub const ERROR_DISK_FULL: c_int = 112;
480pub const ERROR_CALL_NOT_IMPLEMENTED: c_int = 120;
481pub const ERROR_INSUFFICIENT_BUFFER: c_int = 122;
482pub const ERROR_INVALID_NAME: c_int = 123;
483pub const ERROR_ALREADY_EXISTS: c_int = 183;
484pub const ERROR_PIPE_BUSY: c_int = 231;
485pub const ERROR_NO_DATA: c_int = 232;
486pub const ERROR_INVALID_ADDRESS: c_int = 487;
487pub const ERROR_PIPE_CONNECTED: c_int = 535;
488pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758;
489pub const ERROR_OPERATION_ABORTED: c_int = 995;
490pub const ERROR_IO_PENDING: c_int = 997;
491pub const ERROR_FILE_INVALID: c_int = 1006;
492pub const ERROR_NOT_FOUND: c_int = 1168;
493pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
494
495pub const DELETE: DWORD = 0x00010000;
496pub const READ_CONTROL: DWORD = 0x00020000;
497pub const SYNCHRONIZE: DWORD = 0x00100000;
498pub const WRITE_DAC: DWORD = 0x00040000;
499pub const WRITE_OWNER: DWORD = 0x00080000;
500
501pub const PROCESS_CREATE_PROCESS: DWORD = 0x0080;
502pub const PROCESS_CREATE_THREAD: DWORD = 0x0002;
503pub const PROCESS_DUP_HANDLE: DWORD = 0x0040;
504pub const PROCESS_QUERY_INFORMATION: DWORD = 0x0400;
505pub const PROCESS_QUERY_LIMITED_INFORMATION: DWORD = 0x1000;
506pub const PROCESS_SET_INFORMATION: DWORD = 0x0200;
507pub const PROCESS_SET_QUOTA: DWORD = 0x0100;
508pub const PROCESS_SUSPEND_RESUME: DWORD = 0x0800;
509pub const PROCESS_TERMINATE: DWORD = 0x0001;
510pub const PROCESS_VM_OPERATION: DWORD = 0x0008;
511pub const PROCESS_VM_READ: DWORD = 0x0010;
512pub const PROCESS_VM_WRITE: DWORD = 0x0020;
513
514pub const STARTF_FORCEONFEEDBACK: DWORD = 0x00000040;
515pub const STARTF_FORCEOFFFEEDBACK: DWORD = 0x00000080;
516pub const STARTF_PREVENTPINNING: DWORD = 0x00002000;
517pub const STARTF_RUNFULLSCREEN: DWORD = 0x00000020;
518pub const STARTF_TITLEISAPPID: DWORD = 0x00001000;
519pub const STARTF_TITLEISLINKNAME: DWORD = 0x00000800;
520pub const STARTF_USECOUNTCHARS: DWORD = 0x00000008;
521pub const STARTF_USEFILLATTRIBUTE: DWORD = 0x00000010;
522pub const STARTF_USEHOTKEY: DWORD = 0x00000200;
523pub const STARTF_USEPOSITION: DWORD = 0x00000004;
524pub const STARTF_USESHOWWINDOW: DWORD = 0x00000001;
525pub const STARTF_USESIZE: DWORD = 0x00000002;
526pub const STARTF_USESTDHANDLES: DWORD = 0x00000100;
527
528pub const WAIT_ABANDONED: DWORD = 0x00000080;
529pub const WAIT_OBJECT_0: DWORD = 0x00000000;
530pub const WAIT_TIMEOUT: DWORD = 0x00000102;
531pub const WAIT_FAILED: DWORD = !0;
532
533pub const DUPLICATE_CLOSE_SOURCE: DWORD = 0x00000001;
534pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
535
536pub const INFINITE: DWORD = !0;
537pub const STILL_ACTIVE: DWORD = 259;
538
539pub const MEM_COMMIT: DWORD = 0x00001000;
540pub const MEM_RESERVE: DWORD = 0x00002000;
541pub const MEM_DECOMMIT: DWORD = 0x00004000;
542pub const MEM_RELEASE: DWORD = 0x00008000;
543pub const MEM_RESET: DWORD = 0x00080000;
544pub const MEM_RESET_UNDO: DWORD = 0x1000000;
545pub const MEM_LARGE_PAGES: DWORD = 0x20000000;
546pub const MEM_PHYSICAL: DWORD = 0x00400000;
547pub const MEM_TOP_DOWN: DWORD = 0x00100000;
548pub const MEM_WRITE_WATCH: DWORD = 0x00200000;
549
550pub const PAGE_EXECUTE: DWORD = 0x10;
551pub const PAGE_EXECUTE_READ: DWORD = 0x20;
552pub const PAGE_EXECUTE_READWRITE: DWORD = 0x40;
553pub const PAGE_EXECUTE_WRITECOPY: DWORD = 0x80;
554pub const PAGE_NOACCESS: DWORD = 0x01;
555pub const PAGE_READONLY: DWORD = 0x02;
556pub const PAGE_READWRITE: DWORD = 0x04;
557pub const PAGE_WRITECOPY: DWORD = 0x08;
558pub const PAGE_GUARD: DWORD = 0x100;
559pub const PAGE_NOCACHE: DWORD = 0x200;
560pub const PAGE_WRITECOMBINE: DWORD = 0x400;
561
562pub const SEC_COMMIT: DWORD = 0x8000000;
563pub const SEC_IMAGE: DWORD = 0x1000000;
564pub const SEC_IMAGE_NO_EXECUTE: DWORD = 0x11000000;
565pub const SEC_LARGE_PAGES: DWORD = 0x80000000;
566pub const SEC_NOCACHE: DWORD = 0x10000000;
567pub const SEC_RESERVE: DWORD = 0x4000000;
568pub const SEC_WRITECOMBINE: DWORD = 0x40000000;
569
570pub const FILE_MAP_ALL_ACCESS: DWORD = 0xf001f;
571pub const FILE_MAP_READ: DWORD = 0x4;
572pub const FILE_MAP_WRITE: DWORD = 0x2;
573pub const FILE_MAP_COPY: DWORD = 0x1;
574pub const FILE_MAP_EXECUTE: DWORD = 0x20;
575
576pub const PROCESSOR_ARCHITECTURE_INTEL: WORD = 0;
577pub const PROCESSOR_ARCHITECTURE_ARM: WORD = 5;
578pub const PROCESSOR_ARCHITECTURE_IA64: WORD = 6;
579pub const PROCESSOR_ARCHITECTURE_AMD64: WORD = 9;
580pub const PROCESSOR_ARCHITECTURE_UNKNOWN: WORD = 0xffff;
581
582pub const MOVEFILE_COPY_ALLOWED: DWORD = 2;
583pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16;
584pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4;
585pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32;
586pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
587pub const MOVEFILE_WRITE_THROUGH: DWORD = 8;
588
589pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1;
590
591pub const FILE_SHARE_DELETE: DWORD = 0x4;
592pub const FILE_SHARE_READ: DWORD = 0x1;
593pub const FILE_SHARE_WRITE: DWORD = 0x2;
594
595pub const CREATE_ALWAYS: DWORD = 2;
596pub const CREATE_NEW: DWORD = 1;
597pub const OPEN_ALWAYS: DWORD = 4;
598pub const OPEN_EXISTING: DWORD = 3;
599pub const TRUNCATE_EXISTING: DWORD = 5;
600
601pub const FILE_APPEND_DATA: DWORD = 0x00000004;
602pub const FILE_READ_DATA: DWORD = 0x00000001;
603pub const FILE_WRITE_DATA: DWORD = 0x00000002;
604
605pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20;
606pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800;
607pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40;
608pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
609pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000;
610pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2;
611pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000;
612pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80;
613pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000;
614pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000;
615pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000;
616pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
617pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
618pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200;
619pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4;
620pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100;
621pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000;
622
623pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
624pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000;
625pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000;
626pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000;
627pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
628pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
629pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000;
630pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000;
631pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000;
632pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000;
633pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000;
634pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
635
636pub const FILE_NAME_NORMALIZED: DWORD = 0x0;
637pub const FILE_NAME_OPENED: DWORD = 0x8;
638
639pub const VOLUME_NAME_DOS: DWORD = 0x0;
640pub const VOLUME_NAME_GUID: DWORD = 0x1;
641pub const VOLUME_NAME_NONE: DWORD = 0x4;
642pub const VOLUME_NAME_NT: DWORD = 0x2;
643
644pub const GENERIC_READ: DWORD = 0x80000000;
645pub const GENERIC_WRITE: DWORD = 0x40000000;
646pub const GENERIC_EXECUTE: DWORD = 0x20000000;
647pub const GENERIC_ALL: DWORD = 0x10000000;
648pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
649pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080;
650
651pub const STANDARD_RIGHTS_READ: DWORD = 0x20000;
652pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000;
653pub const FILE_WRITE_EA: DWORD = 0x00000010;
654pub const FILE_READ_EA: DWORD = 0x00000008;
655pub const FILE_GENERIC_READ: DWORD =
656 STANDARD_RIGHTS_READ | FILE_READ_DATA |
657 FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE;
658pub const FILE_GENERIC_WRITE: DWORD =
659 STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
660 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA |
661 SYNCHRONIZE;
662
663pub const FILE_BEGIN: DWORD = 0;
664pub const FILE_CURRENT: DWORD = 1;
665pub const FILE_END: DWORD = 2;
666
667pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
668pub const WSAPROTOCOL_LEN: DWORD = 255;
669pub const INVALID_SOCKET: SOCKET = !0;
670
671pub const DETACHED_PROCESS: DWORD = 0x00000008;
672pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
673pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
674
675pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003;
676pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
677pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
678pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
679pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004;
680pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
681pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002;
682pub const PIPE_WAIT: DWORD = 0x00000000;
683pub const PIPE_NOWAIT: DWORD = 0x00000001;
684pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000;
685pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
686pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255;
687
688pub const IPPROTO_RAW: c_int = 255;
689
690pub const FIONBIO: c_long = -0x7FFB9982;
691
Alex Crichton2c57e362015-09-15 17:30:53 -0700692#[cfg(target_env = "msvc")]
693#[link(name = "kernel32")]
694#[link(name = "shell32")]
695#[link(name = "msvcrt")]
696extern {}
697
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700698extern {
699 #[link_name = "_chmod"]
700 pub fn chmod(path: *const c_char, mode: c_int) -> c_int;
701 #[link_name = "_wchmod"]
702 pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int;
703 #[link_name = "_mkdir"]
704 pub fn mkdir(path: *const c_char) -> c_int;
705 #[link_name = "_wrmdir"]
706 pub fn wrmdir(path: *const wchar_t) -> c_int;
707 #[link_name = "_fstat64"]
708 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
709 #[link_name = "_stat64"]
710 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
711 #[link_name = "_wstat64"]
712 pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int;
713 #[link_name = "_wutime64"]
714 pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int;
715 #[link_name = "_popen"]
716 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
717 #[link_name = "_pclose"]
718 pub fn pclose(stream: *mut ::FILE) -> c_int;
719 #[link_name = "_fdopen"]
720 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE;
721 #[link_name = "_fileno"]
722 pub fn fileno(stream: *mut ::FILE) -> c_int;
723 #[link_name = "_open"]
724 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
725 #[link_name = "_wopen"]
726 pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int;
727 #[link_name = "_creat"]
728 pub fn creat(path: *const c_char, mode: c_int) -> c_int;
729 #[link_name = "_access"]
730 pub fn access(path: *const c_char, amode: c_int) -> c_int;
731 #[link_name = "_chdir"]
732 pub fn chdir(dir: *const c_char) -> c_int;
733 #[link_name = "_close"]
734 pub fn close(fd: c_int) -> c_int;
735 #[link_name = "_dup"]
736 pub fn dup(fd: c_int) -> c_int;
737 #[link_name = "_dup2"]
738 pub fn dup2(src: c_int, dst: c_int) -> c_int;
739 #[link_name = "_execv"]
740 pub fn execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t;
741 #[link_name = "_execve"]
742 pub fn execve(prog: *const c_char, argv: *const *const c_char,
743 envp: *const *const c_char) -> c_int;
744 #[link_name = "_execvp"]
745 pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int;
746 #[link_name = "_execvpe"]
747 pub fn execvpe(c: *const c_char, argv: *const *const c_char,
748 envp: *const *const c_char) -> c_int;
749 #[link_name = "_getcwd"]
750 pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char;
751 #[link_name = "_getpid"]
752 pub fn getpid() -> c_int;
753 #[link_name = "_isatty"]
754 pub fn isatty(fd: c_int) -> c_int;
755 #[link_name = "_lseek"]
756 pub fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long;
757 #[link_name = "_pipe"]
758 pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int;
759 #[link_name = "_read"]
760 pub fn read(fd: c_int, buf: *mut ::c_void, count: c_uint) -> c_int;
761 #[link_name = "_rmdir"]
762 pub fn rmdir(path: *const c_char) -> c_int;
763 #[link_name = "_unlink"]
764 pub fn unlink(c: *const c_char) -> c_int;
765 #[link_name = "_write"]
766 pub fn write(fd: c_int, buf: *const ::c_void, count: c_uint) -> c_int;
767 #[link_name = "_commit"]
768 pub fn commit(fd: c_int) -> c_int;
769 #[link_name = "_get_osfhandle"]
770 pub fn get_osfhandle(fd: c_int) -> intptr_t;
771 #[link_name = "_open_osfhandle"]
772 pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int;
773}
774
775extern "system" {
776 pub fn GetEnvironmentVariableW(n: LPCWSTR,
777 v: LPWSTR,
778 nsize: DWORD)
779 -> DWORD;
780 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700781 -> BOOL;
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700782 pub fn GetEnvironmentStringsW() -> LPWCH;
783 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
784 pub fn GetModuleFileNameW(hModule: HMODULE,
785 lpFilename: LPWSTR,
786 nSize: DWORD)
787 -> DWORD;
788 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
789 lpSecurityAttributes:
790 LPSECURITY_ATTRIBUTES)
791 -> BOOL;
792 pub fn CopyFileW(lpExistingFileName: LPCWSTR,
793 lpNewFileName: LPCWSTR,
794 bFailIfExists: BOOL)
795 -> BOOL;
796 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
797 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
798 pub fn GetCurrentDirectoryW(nBufferLength: DWORD,
799 lpBuffer: LPWSTR)
800 -> DWORD;
801 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
802 pub fn GetLastError() -> DWORD;
803 pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW)
804 -> HANDLE;
805 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
806 -> BOOL;
807 pub fn FindClose(findFile: HANDLE) -> BOOL;
808 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
809 hSourceHandle: HANDLE,
810 hTargetProcessHandle: HANDLE,
811 lpTargetHandle: LPHANDLE,
812 dwDesiredAccess: DWORD,
813 bInheritHandle: BOOL,
814 dwOptions: DWORD)
815 -> BOOL;
816 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
817 pub fn OpenProcess(dwDesiredAccess: DWORD,
818 bInheritHandle: BOOL,
819 dwProcessId: DWORD)
820 -> HANDLE;
821 pub fn GetCurrentProcess() -> HANDLE;
822 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
823 lpCommandLine: LPWSTR,
824 lpProcessAttributes:
825 LPSECURITY_ATTRIBUTES,
826 lpThreadAttributes:
827 LPSECURITY_ATTRIBUTES,
828 bInheritHandles: BOOL,
829 dwCreationFlags: DWORD,
830 lpEnvironment: LPVOID,
831 lpCurrentDirectory: LPCWSTR,
832 lpStartupInfo: LPSTARTUPINFOW,
833 lpProcessInformation:
834 LPPROCESS_INFORMATION)
835 -> BOOL;
836 pub fn WaitForSingleObject(hHandle: HANDLE,
837 dwMilliseconds: DWORD)
838 -> DWORD;
839 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint)
840 -> BOOL;
841 pub fn GetExitCodeProcess(hProcess: HANDLE,
842 lpExitCode: LPDWORD)
843 -> BOOL;
844 pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
845 pub fn VirtualAlloc(lpAddress: LPVOID,
846 dwSize: SIZE_T,
847 flAllocationType: DWORD,
848 flProtect: DWORD)
849 -> LPVOID;
850 pub fn VirtualFree(lpAddress: LPVOID,
851 dwSize: SIZE_T,
852 dwFreeType: DWORD)
853 -> BOOL;
854 pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL;
855 pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T)
856 -> BOOL;
857 pub fn VirtualProtect(lpAddress: LPVOID,
858 dwSize: SIZE_T,
859 flNewProtect: DWORD,
860 lpflOldProtect: LPDWORD)
861 -> BOOL;
862 pub fn VirtualQuery(lpAddress: LPCVOID,
863 lpBuffer: PMEMORY_BASIC_INFORMATION,
864 dwLength: SIZE_T)
865 -> SIZE_T;
866 pub fn CreateFileMappingW(hFile: HANDLE,
867 lpAttributes: LPSECURITY_ATTRIBUTES,
868 flProtect: DWORD,
869 dwMaximumSizeHigh: DWORD,
870 dwMaximumSizeLow: DWORD,
871 lpName: LPCWSTR)
872 -> HANDLE;
873 pub fn MapViewOfFile(hFileMappingObject: HANDLE,
874 dwDesiredAccess: DWORD,
875 dwFileOffsetHigh: DWORD,
876 dwFileOffsetLow: DWORD,
877 dwNumberOfBytesToMap: SIZE_T)
878 -> LPVOID;
879 pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
880 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
881 lpNewFileName: LPCWSTR,
882 dwFlags: DWORD) -> BOOL;
883 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
884 lpTargetFileName: LPCWSTR,
885 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
886 -> BOOL;
887 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
888 pub fn CreateFileW(lpFileName: LPCWSTR,
889 dwDesiredAccess: DWORD,
890 dwShareMode: DWORD,
891 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
892 dwCreationDisposition: DWORD,
893 dwFlagsAndAttributes: DWORD,
894 hTemplateFile: HANDLE) -> HANDLE;
895 pub fn ReadFile(hFile: HANDLE,
896 lpBuffer: LPVOID,
897 nNumberOfBytesToRead: DWORD,
898 lpNumberOfBytesRead: LPDWORD,
899 lpOverlapped: LPOVERLAPPED) -> BOOL;
900 pub fn WriteFile(hFile: HANDLE,
901 lpBuffer: LPCVOID,
902 nNumberOfBytesToWrite: DWORD,
903 lpNumberOfBytesWritten: LPDWORD,
904 lpOverlapped: LPOVERLAPPED) -> BOOL;
905 pub fn SetFilePointerEx(hFile: HANDLE,
906 liDistanceToMove: LARGE_INTEGER,
907 lpNewFilePointer: PLARGE_INTEGER,
908 dwMoveMethod: DWORD) -> BOOL;
909 pub fn SetEndOfFile(hFile: HANDLE) -> BOOL;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700910
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700911 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700912
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700913 pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
914 pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER)
915 -> BOOL;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700916
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700917 pub fn GetCurrentProcessId() -> DWORD;
918 pub fn CreateNamedPipeW(
919 lpName: LPCWSTR,
920 dwOpenMode: DWORD,
921 dwPipeMode: DWORD,
922 nMaxInstances: DWORD,
923 nOutBufferSize: DWORD,
924 nInBufferSize: DWORD,
925 nDefaultTimeOut: DWORD,
926 lpSecurityAttributes: LPSECURITY_ATTRIBUTES
927 ) -> HANDLE;
928 pub fn ConnectNamedPipe(hNamedPipe: HANDLE,
929 lpOverlapped: LPOVERLAPPED) -> BOOL;
930 pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR,
931 nTimeOut: DWORD) -> BOOL;
932 pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE,
933 lpMode: LPDWORD,
934 lpMaxCollectionCount: LPDWORD,
935 lpCollectDataTimeout: LPDWORD)
936 -> BOOL;
937 pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
938 bManualReset: BOOL,
939 bInitialState: BOOL,
940 lpName: LPCWSTR) -> HANDLE;
941 pub fn GetOverlappedResult(hFile: HANDLE,
942 lpOverlapped: LPOVERLAPPED,
943 lpNumberOfBytesTransferred: LPDWORD,
944 bWait: BOOL) -> BOOL;
945 pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700946
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700947 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
948 pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET;
949 pub fn connect(socket: SOCKET, address: *const sockaddr,
950 len: c_int) -> c_int;
951 pub fn bind(socket: SOCKET, address: *const sockaddr,
952 address_len: c_int) -> c_int;
953 pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
954 pub fn accept(socket: SOCKET, address: *mut sockaddr,
955 address_len: *mut c_int) -> SOCKET;
956 pub fn getpeername(socket: SOCKET, address: *mut sockaddr,
957 address_len: *mut c_int) -> c_int;
958 pub fn getsockname(socket: SOCKET, address: *mut sockaddr,
959 address_len: *mut c_int) -> c_int;
960 pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int,
961 value: *const c_char,
962 option_len: c_int) -> c_int;
963 pub fn closesocket(socket: SOCKET) -> c_int;
964 pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int,
965 flags: c_int) -> c_int;
966 pub fn send(socket: SOCKET, buf: *const c_char, len: c_int,
967 flags: c_int) -> c_int;
968 pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int,
969 flags: c_int, addr: *mut sockaddr,
970 addrlen: *mut c_int) -> c_int;
971 pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int,
972 flags: c_int, addr: *const sockaddr,
973 addrlen: c_int) -> c_int;
974 pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
975}