]> git.proxmox.com Git - rustc.git/blame - src/libstd/sys/windows/c.rs
Imported Upstream version 1.10.0+dfsg1
[rustc.git] / src / libstd / sys / windows / c.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11//! C definitions used by libnative that don't belong in liblibc
12
7453a54e
SL
13#![allow(bad_style)]
14#![cfg_attr(test, allow(dead_code))]
54a0048b 15#![unstable(issue = "0", feature = "windows_c")]
1a4d82fc 16
54a0048b 17use os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort,};
7453a54e 18use os::raw::{c_char, c_ulonglong};
92a42be0 19use libc::{wchar_t, size_t, c_void};
e9174d1e 20use ptr;
9cc50fc6
SL
21
22#[repr(simd)]
23#[repr(C)]
7453a54e 24#[cfg(target_arch = "x86_64")]
9cc50fc6 25struct u64x2(u64, u64);
1a4d82fc 26
85aaf69f 27pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
92a42be0 28pub use self::EXCEPTION_DISPOSITION::*;
85aaf69f 29
92a42be0
SL
30pub type DWORD = c_ulong;
31pub type HANDLE = LPVOID;
32pub type HINSTANCE = HANDLE;
33pub type HMODULE = HINSTANCE;
34pub type BOOL = c_int;
35pub type BYTE = u8;
36pub type BOOLEAN = BYTE;
37pub type GROUP = c_uint;
38pub type LONG_PTR = isize;
39pub type LARGE_INTEGER = c_longlong;
40pub type LONG = c_long;
41pub type UINT = c_uint;
42pub type WCHAR = u16;
43pub type USHORT = c_ushort;
44pub type SIZE_T = usize;
45pub type WORD = u16;
46pub type CHAR = c_char;
47pub type HCRYPTPROV = LONG_PTR;
48pub type ULONG_PTR = c_ulonglong;
49pub type ULONG = c_ulong;
50pub type ULONGLONG = u64;
51pub type DWORDLONG = ULONGLONG;
52
53pub type LPBOOL = *mut BOOL;
54pub type LPBYTE = *mut BYTE;
55pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION;
56pub type LPCSTR = *const CHAR;
57pub type LPCVOID = *const c_void;
58pub type LPCWSTR = *const WCHAR;
59pub type LPDWORD = *mut DWORD;
60pub type LPHANDLE = *mut HANDLE;
61pub type LPOVERLAPPED = *mut OVERLAPPED;
62pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
63pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
64pub type LPSTARTUPINFO = *mut STARTUPINFO;
65pub type LPVOID = *mut c_void;
66pub type LPWCH = *mut WCHAR;
67pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
68pub type LPWSADATA = *mut WSADATA;
92a42be0
SL
69pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
70pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
71pub type LPWSTR = *mut WCHAR;
72pub type LPFILETIME = *mut FILETIME;
73
74pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
75pub type PLARGE_INTEGER = *mut c_longlong;
76pub type PSRWLOCK = *mut SRWLOCK;
77
78pub type SOCKET = ::os::windows::raw::SOCKET;
79pub type socklen_t = c_int;
80pub type ADDRESS_FAMILY = USHORT;
81
82pub const TRUE: BOOL = 1;
83pub const FALSE: BOOL = 0;
84
85pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
86pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
92a42be0 87pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
7453a54e 88
92a42be0
SL
89pub const FILE_SHARE_DELETE: DWORD = 0x4;
90pub const FILE_SHARE_READ: DWORD = 0x1;
91pub const FILE_SHARE_WRITE: DWORD = 0x2;
7453a54e 92
92a42be0
SL
93pub const CREATE_ALWAYS: DWORD = 2;
94pub const CREATE_NEW: DWORD = 1;
95pub const OPEN_ALWAYS: DWORD = 4;
96pub const OPEN_EXISTING: DWORD = 3;
97pub const TRUNCATE_EXISTING: DWORD = 5;
7453a54e 98
92a42be0 99pub const FILE_WRITE_DATA: DWORD = 0x00000002;
7453a54e 100pub const FILE_APPEND_DATA: DWORD = 0x00000004;
92a42be0 101pub const FILE_WRITE_EA: DWORD = 0x00000010;
92a42be0 102pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
7453a54e
SL
103pub const READ_CONTROL: DWORD = 0x00020000;
104pub const SYNCHRONIZE: DWORD = 0x00100000;
105pub const GENERIC_READ: DWORD = 0x80000000;
106pub const GENERIC_WRITE: DWORD = 0x40000000;
107pub const STANDARD_RIGHTS_WRITE: DWORD = READ_CONTROL;
92a42be0
SL
108pub const FILE_GENERIC_WRITE: DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
109 FILE_WRITE_ATTRIBUTES |
110 FILE_WRITE_EA |
111 FILE_APPEND_DATA |
112 SYNCHRONIZE;
113
7453a54e
SL
114pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
115pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
116pub const SECURITY_SQOS_PRESENT: DWORD = 0x00100000;
117
54a0048b
SL
118pub const FIONBIO: c_ulong = 0x8004667e;
119
92a42be0
SL
120#[repr(C)]
121#[derive(Copy)]
122pub struct WIN32_FIND_DATAW {
123 pub dwFileAttributes: DWORD,
124 pub ftCreationTime: FILETIME,
125 pub ftLastAccessTime: FILETIME,
126 pub ftLastWriteTime: FILETIME,
127 pub nFileSizeHigh: DWORD,
128 pub nFileSizeLow: DWORD,
129 pub dwReserved0: DWORD,
130 pub dwReserved1: DWORD,
131 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
132 pub cAlternateFileName: [wchar_t; 14],
133}
134impl Clone for WIN32_FIND_DATAW {
135 fn clone(&self) -> Self { *self }
136}
137
92a42be0 138pub const WSA_FLAG_OVERLAPPED: DWORD = 0x01;
92a42be0
SL
139
140pub const WSADESCRIPTION_LEN: usize = 256;
141pub const WSASYS_STATUS_LEN: usize = 128;
142pub const WSAPROTOCOL_LEN: DWORD = 255;
143pub const INVALID_SOCKET: SOCKET = !0;
144
92a42be0 145pub const WSAEACCES: c_int = 10013;
92a42be0 146pub const WSAEINVAL: c_int = 10022;
92a42be0 147pub const WSAEWOULDBLOCK: c_int = 10035;
92a42be0
SL
148pub const WSAEADDRINUSE: c_int = 10048;
149pub const WSAEADDRNOTAVAIL: c_int = 10049;
92a42be0
SL
150pub const WSAECONNABORTED: c_int = 10053;
151pub const WSAECONNRESET: c_int = 10054;
92a42be0
SL
152pub const WSAENOTCONN: c_int = 10057;
153pub const WSAESHUTDOWN: c_int = 10058;
92a42be0
SL
154pub const WSAETIMEDOUT: c_int = 10060;
155pub const WSAECONNREFUSED: c_int = 10061;
7453a54e 156
92a42be0
SL
157pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
158
159pub const TOKEN_READ: DWORD = 0x20008;
9346a6ac 160pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: usize = 16 * 1024;
92a42be0
SL
161pub const FSCTL_GET_REPARSE_POINT: DWORD = 0x900a8;
162pub const IO_REPARSE_TAG_SYMLINK: DWORD = 0xa000000c;
163pub const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
7453a54e 164pub const SYMLINK_FLAG_RELATIVE: DWORD = 0x00000001;
92a42be0 165pub const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
1a4d82fc 166
92a42be0 167pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 0x1;
d9579d0f 168
c34b1796 169// Note that these are not actually HANDLEs, just values to pass to GetStdHandle
92a42be0
SL
170pub const STD_INPUT_HANDLE: DWORD = -10i32 as DWORD;
171pub const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
172pub const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
173
174pub const HANDLE_FLAG_INHERIT: DWORD = 0x00000001;
175
176pub const PROGRESS_CONTINUE: DWORD = 0;
92a42be0 177
92a42be0
SL
178pub const ERROR_FILE_NOT_FOUND: DWORD = 2;
179pub const ERROR_PATH_NOT_FOUND: DWORD = 3;
180pub const ERROR_ACCESS_DENIED: DWORD = 5;
181pub const ERROR_INVALID_HANDLE: DWORD = 6;
182pub const ERROR_NO_MORE_FILES: DWORD = 18;
54a0048b 183pub const ERROR_HANDLE_EOF: DWORD = 38;
92a42be0 184pub const ERROR_BROKEN_PIPE: DWORD = 109;
92a42be0
SL
185pub const ERROR_CALL_NOT_IMPLEMENTED: DWORD = 120;
186pub const ERROR_INSUFFICIENT_BUFFER: DWORD = 122;
92a42be0 187pub const ERROR_ALREADY_EXISTS: DWORD = 183;
92a42be0 188pub const ERROR_NO_DATA: DWORD = 232;
92a42be0 189pub const ERROR_ENVVAR_NOT_FOUND: DWORD = 203;
92a42be0 190pub const ERROR_OPERATION_ABORTED: DWORD = 995;
54a0048b 191pub const ERROR_IO_PENDING: DWORD = 997;
92a42be0
SL
192pub const ERROR_TIMEOUT: DWORD = 0x5B4;
193
194pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
195
196pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
197pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
198
199pub const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF;
200
201pub const DLL_THREAD_DETACH: DWORD = 3;
202pub const DLL_PROCESS_DETACH: DWORD = 0;
203
204pub const INFINITE: DWORD = !0;
205
206pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
207
208pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE {
209 ptr: ptr::null_mut(),
210};
211pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: ptr::null_mut() };
c1a9b12d 212
92a42be0
SL
213pub const DETACHED_PROCESS: DWORD = 0x00000008;
214pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
215pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
216pub const STARTF_USESTDHANDLES: DWORD = 0x00000100;
217
218pub const AF_INET: c_int = 2;
219pub const AF_INET6: c_int = 23;
220pub const SD_BOTH: c_int = 2;
221pub const SD_RECEIVE: c_int = 0;
222pub const SD_SEND: c_int = 1;
223pub const SOCK_DGRAM: c_int = 2;
224pub const SOCK_STREAM: c_int = 1;
225pub const SOL_SOCKET: c_int = 0xffff;
226pub const SO_RCVTIMEO: c_int = 0x1006;
227pub const SO_SNDTIMEO: c_int = 0x1005;
228pub const SO_REUSEADDR: c_int = 0x0004;
54a0048b
SL
229pub const IPPROTO_IP: c_int = 0;
230pub const IPPROTO_TCP: c_int = 6;
231pub const IPPROTO_IPV6: c_int = 41;
232pub const TCP_NODELAY: c_int = 0x0001;
233pub const IP_TTL: c_int = 4;
234pub const IPV6_V6ONLY: c_int = 27;
235pub const SO_ERROR: c_int = 0x1007;
236pub const SO_BROADCAST: c_int = 0x0020;
237pub const IP_MULTICAST_LOOP: c_int = 11;
238pub const IPV6_MULTICAST_LOOP: c_int = 11;
239pub const IP_MULTICAST_TTL: c_int = 10;
240pub const IP_ADD_MEMBERSHIP: c_int = 12;
241pub const IP_DROP_MEMBERSHIP: c_int = 13;
242pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
243pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
244
245#[repr(C)]
246pub struct ip_mreq {
247 pub imr_multiaddr: in_addr,
248 pub imr_interface: in_addr,
249}
250
251#[repr(C)]
252pub struct ipv6_mreq {
253 pub ipv6mr_multiaddr: in6_addr,
254 pub ipv6mr_interface: c_uint,
255}
92a42be0
SL
256
257pub const VOLUME_NAME_DOS: DWORD = 0x0;
258pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
259
260pub const FILE_BEGIN: DWORD = 0;
261pub const FILE_CURRENT: DWORD = 1;
262pub const FILE_END: DWORD = 2;
263
92a42be0 264pub const WAIT_OBJECT_0: DWORD = 0x00000000;
92a42be0 265
7453a54e 266#[cfg(target_env = "msvc")]
92a42be0 267pub const MAX_SYM_NAME: usize = 2000;
7453a54e 268#[cfg(target_arch = "x86")]
92a42be0 269pub const IMAGE_FILE_MACHINE_I386: DWORD = 0x014c;
7453a54e 270#[cfg(target_arch = "x86_64")]
92a42be0
SL
271pub const IMAGE_FILE_MACHINE_AMD64: DWORD = 0x8664;
272
273pub const PROV_RSA_FULL: DWORD = 1;
274pub const CRYPT_SILENT: DWORD = 64;
275pub const CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000;
c1a9b12d 276
e9174d1e 277pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
e9174d1e 278pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
92a42be0 279pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
b039eaaf 280
54a0048b
SL
281pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
282pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
283pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
284pub const PIPE_WAIT: DWORD = 0x00000000;
285pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
286pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
287pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
288
1a4d82fc
JJ
289#[repr(C)]
290#[cfg(target_arch = "x86")]
291pub struct WSADATA {
92a42be0
SL
292 pub wVersion: WORD,
293 pub wHighVersion: WORD,
1a4d82fc
JJ
294 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
295 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
296 pub iMaxSockets: u16,
297 pub iMaxUdpDg: u16,
298 pub lpVendorInfo: *mut u8,
299}
300#[repr(C)]
301#[cfg(target_arch = "x86_64")]
302pub struct WSADATA {
92a42be0
SL
303 pub wVersion: WORD,
304 pub wHighVersion: WORD,
1a4d82fc
JJ
305 pub iMaxSockets: u16,
306 pub iMaxUdpDg: u16,
307 pub lpVendorInfo: *mut u8,
308 pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
309 pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
310}
311
92a42be0 312pub type WSAEVENT = HANDLE;
1a4d82fc 313
85aaf69f 314#[repr(C)]
85aaf69f 315pub struct WSAPROTOCOL_INFO {
92a42be0
SL
316 pub dwServiceFlags1: DWORD,
317 pub dwServiceFlags2: DWORD,
318 pub dwServiceFlags3: DWORD,
319 pub dwServiceFlags4: DWORD,
320 pub dwProviderFlags: DWORD,
85aaf69f 321 pub ProviderId: GUID,
92a42be0 322 pub dwCatalogEntryId: DWORD,
85aaf69f 323 pub ProtocolChain: WSAPROTOCOLCHAIN,
92a42be0
SL
324 pub iVersion: c_int,
325 pub iAddressFamily: c_int,
326 pub iMaxSockAddr: c_int,
327 pub iMinSockAddr: c_int,
328 pub iSocketType: c_int,
329 pub iProtocol: c_int,
330 pub iProtocolMaxOffset: c_int,
331 pub iNetworkByteOrder: c_int,
332 pub iSecurityScheme: c_int,
333 pub dwMessageSize: DWORD,
334 pub dwProviderReserved: DWORD,
85aaf69f
SL
335 pub szProtocol: [u16; (WSAPROTOCOL_LEN as usize) + 1],
336}
337
85aaf69f 338#[repr(C)]
92a42be0 339#[derive(Copy, Clone)]
85aaf69f 340pub struct WIN32_FILE_ATTRIBUTE_DATA {
92a42be0
SL
341 pub dwFileAttributes: DWORD,
342 pub ftCreationTime: FILETIME,
343 pub ftLastAccessTime: FILETIME,
344 pub ftLastWriteTime: FILETIME,
345 pub nFileSizeHigh: DWORD,
346 pub nFileSizeLow: DWORD,
85aaf69f
SL
347}
348
349#[repr(C)]
350pub struct BY_HANDLE_FILE_INFORMATION {
92a42be0
SL
351 pub dwFileAttributes: DWORD,
352 pub ftCreationTime: FILETIME,
353 pub ftLastAccessTime: FILETIME,
354 pub ftLastWriteTime: FILETIME,
355 pub dwVolumeSerialNumber: DWORD,
356 pub nFileSizeHigh: DWORD,
357 pub nFileSizeLow: DWORD,
358 pub nNumberOfLinks: DWORD,
359 pub nFileIndexHigh: DWORD,
360 pub nFileIndexLow: DWORD,
85aaf69f
SL
361}
362
85aaf69f 363#[repr(C)]
7453a54e 364#[allow(dead_code)] // we only use some variants
85aaf69f
SL
365pub enum FILE_INFO_BY_HANDLE_CLASS {
366 FileBasicInfo = 0,
367 FileStandardInfo = 1,
368 FileNameInfo = 2,
369 FileRenameInfo = 3,
370 FileDispositionInfo = 4,
371 FileAllocationInfo = 5,
372 FileEndOfFileInfo = 6,
373 FileStreamInfo = 7,
374 FileCompressionInfo = 8,
375 FileAttributeTagInfo = 9,
376 FileIdBothDirectoryInfo = 10, // 0xA
377 FileIdBothDirectoryRestartInfo = 11, // 0xB
378 FileIoPriorityHintInfo = 12, // 0xC
379 FileRemoteProtocolInfo = 13, // 0xD
380 FileFullDirectoryInfo = 14, // 0xE
381 FileFullDirectoryRestartInfo = 15, // 0xF
382 FileStorageInfo = 16, // 0x10
383 FileAlignmentInfo = 17, // 0x11
384 FileIdInfo = 18, // 0x12
385 FileIdExtdDirectoryInfo = 19, // 0x13
386 FileIdExtdDirectoryRestartInfo = 20, // 0x14
387 MaximumFileInfoByHandlesClass
388}
389
390#[repr(C)]
391pub struct FILE_END_OF_FILE_INFO {
92a42be0 392 pub EndOfFile: LARGE_INTEGER,
85aaf69f
SL
393}
394
9346a6ac
AL
395#[repr(C)]
396pub struct REPARSE_DATA_BUFFER {
92a42be0
SL
397 pub ReparseTag: c_uint,
398 pub ReparseDataLength: c_ushort,
399 pub Reserved: c_ushort,
9346a6ac
AL
400 pub rest: (),
401}
402
403#[repr(C)]
404pub struct SYMBOLIC_LINK_REPARSE_BUFFER {
92a42be0
SL
405 pub SubstituteNameOffset: c_ushort,
406 pub SubstituteNameLength: c_ushort,
407 pub PrintNameOffset: c_ushort,
408 pub PrintNameLength: c_ushort,
409 pub Flags: c_ulong,
410 pub PathBuffer: WCHAR,
9346a6ac
AL
411}
412
7453a54e
SL
413#[repr(C)]
414pub struct MOUNT_POINT_REPARSE_BUFFER {
415 pub SubstituteNameOffset: c_ushort,
416 pub SubstituteNameLength: c_ushort,
417 pub PrintNameOffset: c_ushort,
418 pub PrintNameLength: c_ushort,
419 pub PathBuffer: WCHAR,
420}
421
c1a9b12d 422pub type LPPROGRESS_ROUTINE = ::option::Option<unsafe extern "system" fn(
92a42be0
SL
423 TotalFileSize: LARGE_INTEGER,
424 TotalBytesTransferred: LARGE_INTEGER,
425 StreamSize: LARGE_INTEGER,
426 StreamBytesTransferred: LARGE_INTEGER,
c1a9b12d
SL
427 dwStreamNumber: DWORD,
428 dwCallbackReason: DWORD,
429 hSourceFile: HANDLE,
430 hDestinationFile: HANDLE,
431 lpData: LPVOID,
432) -> DWORD>;
433
434#[repr(C)]
435pub struct CONDITION_VARIABLE { pub ptr: LPVOID }
436#[repr(C)]
437pub struct SRWLOCK { pub ptr: LPVOID }
438#[repr(C)]
439pub struct CRITICAL_SECTION {
440 CriticalSectionDebug: LPVOID,
441 LockCount: LONG,
442 RecursionCount: LONG,
443 OwningThread: HANDLE,
444 LockSemaphore: HANDLE,
445 SpinCount: ULONG_PTR
446}
447
c1a9b12d
SL
448#[repr(C)]
449pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
92a42be0
SL
450 pub ReparseTag: DWORD,
451 pub ReparseDataLength: DWORD,
452 pub Reserved: WORD,
453 pub ReparseTargetLength: WORD,
454 pub ReparseTargetMaximumLength: WORD,
455 pub Reserved1: WORD,
456 pub ReparseTarget: WCHAR,
c1a9b12d
SL
457}
458
e9174d1e
SL
459#[repr(C)]
460pub struct EXCEPTION_RECORD {
461 pub ExceptionCode: DWORD,
462 pub ExceptionFlags: DWORD,
463 pub ExceptionRecord: *mut EXCEPTION_RECORD,
464 pub ExceptionAddress: LPVOID,
465 pub NumberParameters: DWORD,
466 pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
467}
468
469#[repr(C)]
470pub struct EXCEPTION_POINTERS {
471 pub ExceptionRecord: *mut EXCEPTION_RECORD,
92a42be0 472 pub ContextRecord: *mut CONTEXT,
e9174d1e
SL
473}
474
475pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
476 fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
c1a9b12d 477
92a42be0
SL
478#[repr(C)]
479pub struct GUID {
480 pub Data1: DWORD,
481 pub Data2: WORD,
482 pub Data3: WORD,
483 pub Data4: [BYTE; 8],
484}
485
486#[repr(C)]
487pub struct WSAPROTOCOLCHAIN {
488 pub ChainLen: c_int,
489 pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
490}
491
492#[repr(C)]
493pub struct SECURITY_ATTRIBUTES {
494 pub nLength: DWORD,
495 pub lpSecurityDescriptor: LPVOID,
496 pub bInheritHandle: BOOL,
497}
498
499#[repr(C)]
500pub struct PROCESS_INFORMATION {
501 pub hProcess: HANDLE,
502 pub hThread: HANDLE,
503 pub dwProcessId: DWORD,
504 pub dwThreadId: DWORD,
505}
506
507#[repr(C)]
508pub struct STARTUPINFO {
509 pub cb: DWORD,
510 pub lpReserved: LPWSTR,
511 pub lpDesktop: LPWSTR,
512 pub lpTitle: LPWSTR,
513 pub dwX: DWORD,
514 pub dwY: DWORD,
515 pub dwXSize: DWORD,
516 pub dwYSize: DWORD,
517 pub dwXCountChars: DWORD,
518 pub dwYCountCharts: DWORD,
519 pub dwFillAttribute: DWORD,
520 pub dwFlags: DWORD,
521 pub wShowWindow: WORD,
522 pub cbReserved2: WORD,
523 pub lpReserved2: LPBYTE,
524 pub hStdInput: HANDLE,
525 pub hStdOutput: HANDLE,
526 pub hStdError: HANDLE,
527}
528
529#[repr(C)]
530pub struct SOCKADDR {
531 pub sa_family: ADDRESS_FAMILY,
532 pub sa_data: [CHAR; 14],
533}
534
535#[repr(C)]
536#[derive(Copy, Clone)]
537pub struct FILETIME {
538 pub dwLowDateTime: DWORD,
539 pub dwHighDateTime: DWORD,
540}
541
542#[repr(C)]
543pub struct OVERLAPPED {
544 pub Internal: *mut c_ulong,
545 pub InternalHigh: *mut c_ulong,
546 pub Offset: DWORD,
547 pub OffsetHigh: DWORD,
548 pub hEvent: HANDLE,
549}
550
551#[repr(C)]
7453a54e 552#[cfg(target_env = "msvc")]
92a42be0
SL
553pub struct SYMBOL_INFO {
554 pub SizeOfStruct: c_ulong,
555 pub TypeIndex: c_ulong,
556 pub Reserved: [u64; 2],
557 pub Index: c_ulong,
558 pub Size: c_ulong,
559 pub ModBase: u64,
560 pub Flags: c_ulong,
561 pub Value: u64,
562 pub Address: u64,
563 pub Register: c_ulong,
564 pub Scope: c_ulong,
565 pub Tag: c_ulong,
566 pub NameLen: c_ulong,
567 pub MaxNameLen: c_ulong,
568 // note that windows has this as 1, but it basically just means that
569 // the name is inline at the end of the struct. For us, we just bump
570 // the struct size up to MAX_SYM_NAME.
571 pub Name: [c_char; MAX_SYM_NAME],
572}
573
574#[repr(C)]
7453a54e 575#[cfg(target_env = "msvc")]
92a42be0
SL
576pub struct IMAGEHLP_LINE64 {
577 pub SizeOfStruct: u32,
578 pub Key: *const c_void,
579 pub LineNumber: u32,
580 pub Filename: *const c_char,
581 pub Address: u64,
582}
583
584#[repr(C)]
7453a54e 585#[allow(dead_code)] // we only use some variants
92a42be0
SL
586pub enum ADDRESS_MODE {
587 AddrMode1616,
588 AddrMode1632,
589 AddrModeReal,
590 AddrModeFlat,
591}
592
593#[repr(C)]
594pub struct ADDRESS64 {
595 pub Offset: u64,
596 pub Segment: u16,
597 pub Mode: ADDRESS_MODE,
598}
599
600#[repr(C)]
601pub struct STACKFRAME64 {
602 pub AddrPC: ADDRESS64,
603 pub AddrReturn: ADDRESS64,
604 pub AddrFrame: ADDRESS64,
605 pub AddrStack: ADDRESS64,
606 pub AddrBStore: ADDRESS64,
607 pub FuncTableEntry: *mut c_void,
608 pub Params: [u64; 4],
609 pub Far: BOOL,
610 pub Virtual: BOOL,
611 pub Reserved: [u64; 3],
612 pub KdHelp: KDHELP64,
613}
614
615#[repr(C)]
616pub struct KDHELP64 {
617 pub Thread: u64,
618 pub ThCallbackStack: DWORD,
619 pub ThCallbackBStore: DWORD,
620 pub NextCallback: DWORD,
621 pub FramePointer: DWORD,
622 pub KiCallUserMode: u64,
623 pub KeUserCallbackDispatcher: u64,
624 pub SystemRangeStart: u64,
625 pub KiUserExceptionDispatcher: u64,
626 pub StackBase: u64,
627 pub StackLimit: u64,
628 pub Reserved: [u64; 5],
629}
630
631#[cfg(target_arch = "x86")]
632#[repr(C)]
633pub struct CONTEXT {
634 pub ContextFlags: DWORD,
635 pub Dr0: DWORD,
636 pub Dr1: DWORD,
637 pub Dr2: DWORD,
638 pub Dr3: DWORD,
639 pub Dr6: DWORD,
640 pub Dr7: DWORD,
641 pub FloatSave: FLOATING_SAVE_AREA,
642 pub SegGs: DWORD,
643 pub SegFs: DWORD,
644 pub SegEs: DWORD,
645 pub SegDs: DWORD,
646 pub Edi: DWORD,
647 pub Esi: DWORD,
648 pub Ebx: DWORD,
649 pub Edx: DWORD,
650 pub Ecx: DWORD,
651 pub Eax: DWORD,
652 pub Ebp: DWORD,
653 pub Eip: DWORD,
654 pub SegCs: DWORD,
655 pub EFlags: DWORD,
656 pub Esp: DWORD,
657 pub SegSs: DWORD,
658 pub ExtendedRegisters: [u8; 512],
659}
660
661#[cfg(target_arch = "x86")]
662#[repr(C)]
663pub struct FLOATING_SAVE_AREA {
664 pub ControlWord: DWORD,
665 pub StatusWord: DWORD,
666 pub TagWord: DWORD,
667 pub ErrorOffset: DWORD,
668 pub ErrorSelector: DWORD,
669 pub DataOffset: DWORD,
670 pub DataSelector: DWORD,
671 pub RegisterArea: [u8; 80],
672 pub Cr0NpxState: DWORD,
673}
674
675#[cfg(target_arch = "x86_64")]
676#[repr(C)]
677pub struct CONTEXT {
9cc50fc6 678 _align_hack: [u64x2; 0], // FIXME align on 16-byte
92a42be0
SL
679 pub P1Home: DWORDLONG,
680 pub P2Home: DWORDLONG,
681 pub P3Home: DWORDLONG,
682 pub P4Home: DWORDLONG,
683 pub P5Home: DWORDLONG,
684 pub P6Home: DWORDLONG,
685
686 pub ContextFlags: DWORD,
687 pub MxCsr: DWORD,
688
689 pub SegCs: WORD,
690 pub SegDs: WORD,
691 pub SegEs: WORD,
692 pub SegFs: WORD,
693 pub SegGs: WORD,
694 pub SegSs: WORD,
695 pub EFlags: DWORD,
696
697 pub Dr0: DWORDLONG,
698 pub Dr1: DWORDLONG,
699 pub Dr2: DWORDLONG,
700 pub Dr3: DWORDLONG,
701 pub Dr6: DWORDLONG,
702 pub Dr7: DWORDLONG,
703
704 pub Rax: DWORDLONG,
705 pub Rcx: DWORDLONG,
706 pub Rdx: DWORDLONG,
707 pub Rbx: DWORDLONG,
708 pub Rsp: DWORDLONG,
709 pub Rbp: DWORDLONG,
710 pub Rsi: DWORDLONG,
711 pub Rdi: DWORDLONG,
712 pub R8: DWORDLONG,
713 pub R9: DWORDLONG,
714 pub R10: DWORDLONG,
715 pub R11: DWORDLONG,
716 pub R12: DWORDLONG,
717 pub R13: DWORDLONG,
718 pub R14: DWORDLONG,
719 pub R15: DWORDLONG,
720
721 pub Rip: DWORDLONG,
722
723 pub FltSave: FLOATING_SAVE_AREA,
724
725 pub VectorRegister: [M128A; 26],
726 pub VectorControl: DWORDLONG,
727
728 pub DebugControl: DWORDLONG,
729 pub LastBranchToRip: DWORDLONG,
730 pub LastBranchFromRip: DWORDLONG,
731 pub LastExceptionToRip: DWORDLONG,
732 pub LastExceptionFromRip: DWORDLONG,
733}
734
735#[cfg(target_arch = "x86_64")]
736#[repr(C)]
737pub struct M128A {
9cc50fc6 738 _align_hack: [u64x2; 0], // FIXME align on 16-byte
92a42be0
SL
739 pub Low: c_ulonglong,
740 pub High: c_longlong
741}
742
743#[cfg(target_arch = "x86_64")]
744#[repr(C)]
745pub struct FLOATING_SAVE_AREA {
9cc50fc6 746 _align_hack: [u64x2; 0], // FIXME align on 16-byte
92a42be0
SL
747 _Dummy: [u8; 512] // FIXME: Fill this out
748}
749
750#[repr(C)]
751pub struct SOCKADDR_STORAGE_LH {
752 pub ss_family: ADDRESS_FAMILY,
753 pub __ss_pad1: [CHAR; 6],
754 pub __ss_align: i64,
755 pub __ss_pad2: [CHAR; 112],
756}
757
758#[repr(C)]
759pub struct ADDRINFOA {
760 pub ai_flags: c_int,
761 pub ai_family: c_int,
762 pub ai_socktype: c_int,
763 pub ai_protocol: c_int,
764 pub ai_addrlen: size_t,
765 pub ai_canonname: *mut c_char,
766 pub ai_addr: *mut SOCKADDR,
767 pub ai_next: *mut ADDRINFOA,
768}
769
770#[repr(C)]
771#[derive(Copy, Clone)]
772pub struct sockaddr_in {
773 pub sin_family: ADDRESS_FAMILY,
774 pub sin_port: USHORT,
775 pub sin_addr: in_addr,
776 pub sin_zero: [CHAR; 8],
777}
778
779#[repr(C)]
780#[derive(Copy, Clone)]
781pub struct sockaddr_in6 {
782 pub sin6_family: ADDRESS_FAMILY,
783 pub sin6_port: USHORT,
784 pub sin6_flowinfo: c_ulong,
785 pub sin6_addr: in6_addr,
786 pub sin6_scope_id: c_ulong,
787}
788
789#[repr(C)]
790#[derive(Copy, Clone)]
791pub struct in_addr {
792 pub s_addr: u32,
793}
794
795#[repr(C)]
796#[derive(Copy, Clone)]
797pub struct in6_addr {
798 pub s6_addr: [u8; 16],
799}
800
92a42be0
SL
801#[repr(C)]
802#[derive(Copy, Clone)]
7453a54e 803#[allow(dead_code)] // we only use some variants
92a42be0
SL
804pub enum EXCEPTION_DISPOSITION {
805 ExceptionContinueExecution,
806 ExceptionContinueSearch,
807 ExceptionNestedException,
808 ExceptionCollidedUnwind
809}
810
1a4d82fc 811#[link(name = "ws2_32")]
c1a9b12d 812#[link(name = "userenv")]
92a42be0
SL
813#[link(name = "shell32")]
814#[link(name = "advapi32")]
7453a54e
SL
815#[cfg(not(cargobuild))]
816extern {}
817
1a4d82fc 818extern "system" {
92a42be0
SL
819 pub fn WSAStartup(wVersionRequested: WORD,
820 lpWSAData: LPWSADATA) -> c_int;
821 pub fn WSACleanup() -> c_int;
822 pub fn WSAGetLastError() -> c_int;
823 pub fn WSADuplicateSocketW(s: SOCKET,
824 dwProcessId: DWORD,
85aaf69f 825 lpProtocolInfo: LPWSAPROTOCOL_INFO)
92a42be0
SL
826 -> c_int;
827 pub fn GetCurrentProcessId() -> DWORD;
828 pub fn WSASocketW(af: c_int,
829 kind: c_int,
830 protocol: c_int,
85aaf69f
SL
831 lpProtocolInfo: LPWSAPROTOCOL_INFO,
832 g: GROUP,
92a42be0 833 dwFlags: DWORD) -> SOCKET;
54a0048b 834 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
c1a9b12d
SL
835 pub fn InitializeCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
836 pub fn EnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
837 pub fn TryEnterCriticalSection(CriticalSection: *mut CRITICAL_SECTION) -> BOOLEAN;
838 pub fn LeaveCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
839 pub fn DeleteCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
1a4d82fc 840
1a4d82fc 841 // FIXME - pInputControl should be PCONSOLE_READCONSOLE_CONTROL
92a42be0
SL
842 pub fn ReadConsoleW(hConsoleInput: HANDLE,
843 lpBuffer: LPVOID,
844 nNumberOfCharsToRead: DWORD,
845 lpNumberOfCharsRead: LPDWORD,
846 pInputControl: LPVOID) -> BOOL;
847
848 pub fn WriteConsoleW(hConsoleOutput: HANDLE,
849 lpBuffer: LPCVOID,
850 nNumberOfCharsToWrite: DWORD,
851 lpNumberOfCharsWritten: LPDWORD,
852 lpReserved: LPVOID) -> BOOL;
853
854 pub fn GetConsoleMode(hConsoleHandle: HANDLE,
855 lpMode: LPDWORD) -> BOOL;
92a42be0
SL
856 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
857 pub fn SetFileAttributesW(lpFileName: LPCWSTR,
858 dwFileAttributes: DWORD) -> BOOL;
859 pub fn GetFileInformationByHandle(hFile: HANDLE,
85aaf69f 860 lpFileInformation: LPBY_HANDLE_FILE_INFORMATION)
92a42be0
SL
861 -> BOOL;
862
863 pub fn SetLastError(dwErrCode: DWORD);
864 pub fn GetCommandLineW() -> *mut LPCWSTR;
865 pub fn LocalFree(ptr: *mut c_void);
866 pub fn CommandLineToArgvW(lpCmdLine: *mut LPCWSTR,
867 pNumArgs: *mut c_int) -> *mut *mut u16;
868 pub fn GetTempPathW(nBufferLength: DWORD,
869 lpBuffer: LPCWSTR) -> DWORD;
870 pub fn OpenProcessToken(ProcessHandle: HANDLE,
871 DesiredAccess: DWORD,
872 TokenHandle: *mut HANDLE) -> BOOL;
873 pub fn GetCurrentProcess() -> HANDLE;
874 pub fn GetCurrentThread() -> HANDLE;
875 pub fn GetStdHandle(which: DWORD) -> HANDLE;
876 pub fn ExitProcess(uExitCode: c_uint) -> !;
877 pub fn DeviceIoControl(hDevice: HANDLE,
878 dwIoControlCode: DWORD,
879 lpInBuffer: LPVOID,
880 nInBufferSize: DWORD,
881 lpOutBuffer: LPVOID,
882 nOutBufferSize: DWORD,
883 lpBytesReturned: LPDWORD,
884 lpOverlapped: LPOVERLAPPED) -> BOOL;
92a42be0
SL
885 pub fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES,
886 dwStackSize: SIZE_T,
887 lpStartAddress: extern "system" fn(*mut c_void)
888 -> DWORD,
889 lpParameter: LPVOID,
890 dwCreationFlags: DWORD,
891 lpThreadId: LPDWORD) -> HANDLE;
892 pub fn WaitForSingleObject(hHandle: HANDLE,
893 dwMilliseconds: DWORD) -> DWORD;
894 pub fn SwitchToThread() -> BOOL;
895 pub fn Sleep(dwMilliseconds: DWORD);
896 pub fn GetProcessId(handle: HANDLE) -> DWORD;
897 pub fn GetUserProfileDirectoryW(hToken: HANDLE,
898 lpProfileDir: LPCWSTR,
899 lpcchSize: *mut DWORD) -> BOOL;
900 pub fn SetHandleInformation(hObject: HANDLE,
901 dwMask: DWORD,
902 dwFlags: DWORD) -> BOOL;
903 pub fn CopyFileExW(lpExistingFileName: LPCWSTR,
904 lpNewFileName: LPCWSTR,
c1a9b12d 905 lpProgressRoutine: LPPROGRESS_ROUTINE,
92a42be0 906 lpData: LPVOID,
c1a9b12d 907 pbCancel: LPBOOL,
92a42be0 908 dwCopyFlags: DWORD) -> BOOL;
e9174d1e
SL
909 pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
910 VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
911 -> LPVOID;
92a42be0
SL
912 pub fn FormatMessageW(flags: DWORD,
913 lpSrc: LPVOID,
914 msgId: DWORD,
915 langId: DWORD,
916 buf: LPWSTR,
917 nsize: DWORD,
918 args: *const c_void)
919 -> DWORD;
920 pub fn TlsAlloc() -> DWORD;
921 pub fn TlsFree(dwTlsIndex: DWORD) -> BOOL;
922 pub fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID;
923 pub fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
924 pub fn GetLastError() -> DWORD;
925 pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
926 pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER)
927 -> BOOL;
928 pub fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL;
929 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL;
930 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
931 lpCommandLine: LPWSTR,
932 lpProcessAttributes: LPSECURITY_ATTRIBUTES,
933 lpThreadAttributes: LPSECURITY_ATTRIBUTES,
934 bInheritHandles: BOOL,
935 dwCreationFlags: DWORD,
936 lpEnvironment: LPVOID,
937 lpCurrentDirectory: LPCWSTR,
938 lpStartupInfo: LPSTARTUPINFO,
939 lpProcessInformation: LPPROCESS_INFORMATION)
940 -> BOOL;
941 pub fn GetEnvironmentVariableW(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD;
942 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) -> BOOL;
943 pub fn GetEnvironmentStringsW() -> LPWCH;
944 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
945 pub fn GetModuleFileNameW(hModule: HMODULE,
946 lpFilename: LPWSTR,
947 nSize: DWORD)
948 -> DWORD;
949 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
950 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
951 -> BOOL;
952 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
953 pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD;
954 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
955
956 pub fn closesocket(socket: SOCKET) -> c_int;
957 pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
958 flags: c_int) -> c_int;
959 pub fn send(socket: SOCKET, buf: *const c_void, len: c_int,
960 flags: c_int) -> c_int;
961 pub fn recvfrom(socket: SOCKET,
962 buf: *mut c_void,
963 len: c_int,
964 flags: c_int,
965 addr: *mut SOCKADDR,
966 addrlen: *mut c_int)
967 -> c_int;
968 pub fn sendto(socket: SOCKET,
969 buf: *const c_void,
970 len: c_int,
971 flags: c_int,
972 addr: *const SOCKADDR,
973 addrlen: c_int)
974 -> c_int;
975 pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
976 pub fn accept(socket: SOCKET,
977 address: *mut SOCKADDR,
978 address_len: *mut c_int)
979 -> SOCKET;
980 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
981 hSourceHandle: HANDLE,
982 hTargetProcessHandle: HANDLE,
983 lpTargetHandle: LPHANDLE,
984 dwDesiredAccess: DWORD,
985 bInheritHandle: BOOL,
986 dwOptions: DWORD)
987 -> BOOL;
988 pub fn ReadFile(hFile: HANDLE,
989 lpBuffer: LPVOID,
990 nNumberOfBytesToRead: DWORD,
991 lpNumberOfBytesRead: LPDWORD,
992 lpOverlapped: LPOVERLAPPED)
993 -> BOOL;
994 pub fn WriteFile(hFile: HANDLE,
995 lpBuffer: LPVOID,
996 nNumberOfBytesToWrite: DWORD,
997 lpNumberOfBytesWritten: LPDWORD,
998 lpOverlapped: LPOVERLAPPED)
999 -> BOOL;
1000 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
1001 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
1002 lpTargetFileName: LPCWSTR,
1003 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1004 -> BOOL;
1005 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
1006 lpNewFileName: LPCWSTR,
1007 dwFlags: DWORD)
1008 -> BOOL;
1009 pub fn SetFilePointerEx(hFile: HANDLE,
1010 liDistanceToMove: LARGE_INTEGER,
1011 lpNewFilePointer: PLARGE_INTEGER,
1012 dwMoveMethod: DWORD)
1013 -> BOOL;
1014 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
1015 pub fn CreateFileW(lpFileName: LPCWSTR,
1016 dwDesiredAccess: DWORD,
1017 dwShareMode: DWORD,
1018 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
1019 dwCreationDisposition: DWORD,
1020 dwFlagsAndAttributes: DWORD,
1021 hTemplateFile: HANDLE)
1022 -> HANDLE;
1023
1024 pub fn FindFirstFileW(fileName: LPCWSTR,
1025 findFileData: LPWIN32_FIND_DATAW)
1026 -> HANDLE;
1027 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
1028 -> BOOL;
1029 pub fn FindClose(findFile: HANDLE) -> BOOL;
1030 pub fn RtlCaptureContext(ctx: *mut CONTEXT);
1031 pub fn getsockopt(s: SOCKET,
1032 level: c_int,
1033 optname: c_int,
1034 optval: *mut c_char,
1035 optlen: *mut c_int)
1036 -> c_int;
1037 pub fn setsockopt(s: SOCKET,
1038 level: c_int,
1039 optname: c_int,
1040 optval: *const c_void,
1041 optlen: c_int)
1042 -> c_int;
1043 pub fn getsockname(socket: SOCKET,
1044 address: *mut SOCKADDR,
1045 address_len: *mut c_int)
1046 -> c_int;
1047 pub fn getpeername(socket: SOCKET,
1048 address: *mut SOCKADDR,
1049 address_len: *mut c_int)
1050 -> c_int;
1051 pub fn bind(socket: SOCKET, address: *const SOCKADDR,
1052 address_len: socklen_t) -> c_int;
1053 pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
1054 pub fn connect(socket: SOCKET, address: *const SOCKADDR, len: c_int)
1055 -> c_int;
1056 pub fn getaddrinfo(node: *const c_char, service: *const c_char,
1057 hints: *const ADDRINFOA,
1058 res: *mut *mut ADDRINFOA) -> c_int;
1059 pub fn freeaddrinfo(res: *mut ADDRINFOA);
92a42be0
SL
1060
1061 pub fn LoadLibraryW(name: LPCWSTR) -> HMODULE;
54a0048b 1062 pub fn FreeLibrary(handle: HMODULE) -> BOOL;
92a42be0
SL
1063 pub fn GetProcAddress(handle: HMODULE,
1064 name: LPCSTR) -> *mut c_void;
92a42be0
SL
1065 pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
1066 pub fn CryptAcquireContextA(phProv: *mut HCRYPTPROV,
1067 pszContainer: LPCSTR,
1068 pszProvider: LPCSTR,
1069 dwProvType: DWORD,
1070 dwFlags: DWORD) -> BOOL;
1071 pub fn CryptGenRandom(hProv: HCRYPTPROV,
1072 dwLen: DWORD,
1073 pbBuffer: *mut BYTE) -> BOOL;
1074 pub fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL;
1075
92a42be0 1076 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
54a0048b
SL
1077
1078 pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
1079 bManualReset: BOOL,
1080 bInitialState: BOOL,
1081 lpName: LPCWSTR) -> HANDLE;
1082 pub fn WaitForMultipleObjects(nCount: DWORD,
1083 lpHandles: *const HANDLE,
1084 bWaitAll: BOOL,
1085 dwMilliseconds: DWORD) -> DWORD;
1086 pub fn CreateNamedPipeW(lpName: LPCWSTR,
1087 dwOpenMode: DWORD,
1088 dwPipeMode: DWORD,
1089 nMaxInstances: DWORD,
1090 nOutBufferSize: DWORD,
1091 nInBufferSize: DWORD,
1092 nDefaultTimeOut: DWORD,
1093 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
1094 -> HANDLE;
1095 pub fn CancelIo(handle: HANDLE) -> BOOL;
1096 pub fn GetOverlappedResult(hFile: HANDLE,
1097 lpOverlapped: LPOVERLAPPED,
1098 lpNumberOfBytesTransferred: LPDWORD,
1099 bWait: BOOL) -> BOOL;
c1a9b12d
SL
1100}
1101
1102// Functions that aren't available on Windows XP, but we still use them and just
1103// provide some form of a fallback implementation.
1104compat_fn! {
1105 kernel32:
1106
1107 pub fn CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
1108 _lpTargetFileName: LPCWSTR,
1109 _dwFlags: DWORD) -> BOOLEAN {
1110 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1111 }
1112 pub fn GetFinalPathNameByHandleW(_hFile: HANDLE,
1113 _lpszFilePath: LPCWSTR,
1114 _cchFilePath: DWORD,
1115 _dwFlags: DWORD) -> DWORD {
1116 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1117 }
c1a9b12d
SL
1118 pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL {
1119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1120 }
1121 pub fn SetFileInformationByHandle(_hFile: HANDLE,
1122 _FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
1123 _lpFileInformation: LPVOID,
1124 _dwBufferSize: DWORD) -> BOOL {
1125 SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
1126 }
1127 pub fn SleepConditionVariableSRW(ConditionVariable: PCONDITION_VARIABLE,
1128 SRWLock: PSRWLOCK,
1129 dwMilliseconds: DWORD,
1130 Flags: ULONG) -> BOOL {
1131 panic!("condition variables not available")
1132 }
1133 pub fn WakeConditionVariable(ConditionVariable: PCONDITION_VARIABLE)
1134 -> () {
1135 panic!("condition variables not available")
1136 }
1137 pub fn WakeAllConditionVariable(ConditionVariable: PCONDITION_VARIABLE)
1138 -> () {
1139 panic!("condition variables not available")
1140 }
1141 pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> () {
1142 panic!("rwlocks not available")
1143 }
1144 pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK) -> () {
1145 panic!("rwlocks not available")
1146 }
1147 pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK) -> () {
1148 panic!("rwlocks not available")
1149 }
1150 pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK) -> () {
1151 panic!("rwlocks not available")
1152 }
1153 pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN {
1154 panic!("rwlocks not available")
1155 }
1156 pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN {
1157 panic!("rwlocks not available")
1158 }
1a4d82fc 1159}