55#![ unstable( issue = "none" , feature = "windows_c" ) ]
66
77use crate :: os:: raw:: { c_char, c_int, c_long, c_longlong, c_uint, c_ulong, c_ushort} ;
8- use crate :: ptr;
98
109use libc:: { c_void, size_t, wchar_t} ;
1110
@@ -37,6 +36,7 @@ pub type LPBYTE = *mut BYTE;
3736pub type LPCSTR = * const CHAR ;
3837pub type LPCWSTR = * const WCHAR ;
3938pub type LPDWORD = * mut DWORD ;
39+ pub type LPLONG = * mut LONG ;
4040pub type LPHANDLE = * mut HANDLE ;
4141pub type LPOVERLAPPED = * mut OVERLAPPED ;
4242pub type LPPROCESS_INFORMATION = * mut PROCESS_INFORMATION ;
@@ -54,9 +54,7 @@ pub type LPWSABUF = *mut WSABUF;
5454pub type LPWSAOVERLAPPED = * mut c_void ;
5555pub type LPWSAOVERLAPPED_COMPLETION_ROUTINE = * mut c_void ;
5656
57- pub type PCONDITION_VARIABLE = * mut CONDITION_VARIABLE ;
5857pub type PLARGE_INTEGER = * mut c_longlong ;
59- pub type PSRWLOCK = * mut SRWLOCK ;
6058
6159pub type SOCKET = crate :: os:: windows:: raw:: SOCKET ;
6260pub type socklen_t = c_int ;
@@ -198,9 +196,6 @@ pub const INFINITE: DWORD = !0;
198196
199197pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002 ;
200198
201- pub const CONDITION_VARIABLE_INIT : CONDITION_VARIABLE = CONDITION_VARIABLE { ptr : ptr:: null_mut ( ) } ;
202- pub const SRWLOCK_INIT : SRWLOCK = SRWLOCK { ptr : ptr:: null_mut ( ) } ;
203-
204199pub const DETACHED_PROCESS : DWORD = 0x00000008 ;
205200pub const CREATE_NEW_PROCESS_GROUP : DWORD = 0x00000200 ;
206201pub const CREATE_UNICODE_ENVIRONMENT : DWORD = 0x00000400 ;
@@ -245,7 +240,6 @@ pub struct ipv6_mreq {
245240 pub ipv6mr_interface : c_uint ,
246241}
247242
248- pub const VOLUME_NAME_DOS : DWORD = 0x0 ;
249243pub const MOVEFILE_REPLACE_EXISTING : DWORD = 1 ;
250244
251245pub const FILE_BEGIN : DWORD = 0 ;
@@ -418,14 +412,6 @@ pub type LPPROGRESS_ROUTINE = crate::option::Option<
418412 ) -> DWORD ,
419413> ;
420414
421- #[ repr( C ) ]
422- pub struct CONDITION_VARIABLE {
423- pub ptr : LPVOID ,
424- }
425- #[ repr( C ) ]
426- pub struct SRWLOCK {
427- pub ptr : LPVOID ,
428- }
429415#[ repr( C ) ]
430416pub struct CRITICAL_SECTION {
431417 CriticalSectionDebug : LPVOID ,
@@ -738,6 +724,21 @@ if #[cfg(target_vendor = "uwp")] {
738724}
739725
740726// Shared between Desktop & UWP
727+ pub type NTSTATUS = LONG ;
728+
729+ #[ repr( C ) ]
730+ union IO_STATUS_BLOCK_u {
731+ Status : NTSTATUS ,
732+ Pointer : LPVOID ,
733+ }
734+
735+ #[ repr( C ) ]
736+ pub struct IO_STATUS_BLOCK {
737+ u : IO_STATUS_BLOCK_u ,
738+ Information : ULONG_PTR ,
739+ }
740+ pub type PIO_STATUS_BLOCK = * mut IO_STATUS_BLOCK ;
741+
741742extern "system" {
742743 pub fn WSAStartup ( wVersionRequested : WORD , lpWSAData : LPWSADATA ) -> c_int ;
743744 pub fn WSACleanup ( ) -> c_int ;
@@ -775,7 +776,7 @@ extern "system" {
775776 dwFlags : DWORD ,
776777 ) -> SOCKET ;
777778 pub fn ioctlsocket ( s : SOCKET , cmd : c_long , argp : * mut c_ulong ) -> c_int ;
778- pub fn InitializeCriticalSection ( CriticalSection : * mut CRITICAL_SECTION ) ;
779+ pub fn InitializeCriticalSectionAndSpinCount ( CriticalSection : * mut CRITICAL_SECTION , dwSpinCount : DWORD ) -> BOOL ;
779780 pub fn EnterCriticalSection ( CriticalSection : * mut CRITICAL_SECTION ) ;
780781 pub fn TryEnterCriticalSection ( CriticalSection : * mut CRITICAL_SECTION ) -> BOOL ;
781782 pub fn LeaveCriticalSection ( CriticalSection : * mut CRITICAL_SECTION ) ;
@@ -809,6 +810,10 @@ extern "system" {
809810 lpThreadId : LPDWORD ,
810811 ) -> HANDLE ;
811812 pub fn WaitForSingleObject ( hHandle : HANDLE , dwMilliseconds : DWORD ) -> DWORD ;
813+ pub fn SetEvent ( hEvent : HANDLE ) -> BOOL ;
814+ pub fn CreateSemaphoreW ( lpSemaphoreAttributes : LPSECURITY_ATTRIBUTES , lInitialCount : LONG , lMaximumCount : LONG , lpName : LPCWSTR ) -> HANDLE ;
815+ pub fn ReleaseSemaphore ( hSemaphore : HANDLE , lReleaseCount : LONG , lpPreviousCount : LPLONG ) -> BOOL ;
816+ pub fn ResetEvent ( hEvent : HANDLE ) -> BOOL ;
812817 pub fn SwitchToThread ( ) -> BOOL ;
813818 pub fn Sleep ( dwMilliseconds : DWORD ) ;
814819 pub fn GetProcessId ( handle : HANDLE ) -> DWORD ;
@@ -1012,6 +1017,10 @@ extern "system" {
10121017 pub fn HeapAlloc ( hHeap : HANDLE , dwFlags : DWORD , dwBytes : SIZE_T ) -> LPVOID ;
10131018 pub fn HeapReAlloc ( hHeap : HANDLE , dwFlags : DWORD , lpMem : LPVOID , dwBytes : SIZE_T ) -> LPVOID ;
10141019 pub fn HeapFree ( hHeap : HANDLE , dwFlags : DWORD , lpMem : LPVOID ) -> BOOL ;
1020+ pub fn NtSetInformationFile ( hFile : HANDLE , IoStatusBlock : PIO_STATUS_BLOCK , FileInformation : LPVOID , Length : ULONG , FileInformationClass : UINT ) -> NTSTATUS ;
1021+ pub fn NtQueryObject ( Handle : HANDLE , ObjectInformationClass : UINT , ObjectInformation : LPCWSTR , ObjectInformationLength : ULONG , ReturnLength : * mut ULONG ) -> NTSTATUS ;
1022+ pub fn QueryDosDeviceW ( lpDeviceName : LPCWSTR , lpTargetPath : LPWSTR , ucchMax : DWORD ) -> DWORD ;
1023+ pub fn GetLogicalDriveStringsW ( nBufferLength : DWORD , lpBuffer : LPWSTR ) -> DWORD ;
10151024}
10161025
10171026// Functions that aren't available on every version of Windows that we support,
@@ -1024,12 +1033,6 @@ compat_fn! {
10241033 _dwFlags: DWORD ) -> BOOLEAN {
10251034 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; 0
10261035 }
1027- pub fn GetFinalPathNameByHandleW ( _hFile: HANDLE ,
1028- _lpszFilePath: LPCWSTR ,
1029- _cchFilePath: DWORD ,
1030- _dwFlags: DWORD ) -> DWORD {
1031- SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; 0
1032- }
10331036 #[ cfg( not( target_vendor = "uwp" ) ) ]
10341037 pub fn SetThreadStackGuarantee ( _size: * mut c_ulong) -> BOOL {
10351038 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; 0
@@ -1038,46 +1041,8 @@ compat_fn! {
10381041 lpThreadDescription: LPCWSTR ) -> HRESULT {
10391042 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; E_NOTIMPL
10401043 }
1041- pub fn SetFileInformationByHandle ( _hFile: HANDLE ,
1042- _FileInformationClass: FILE_INFO_BY_HANDLE_CLASS ,
1043- _lpFileInformation: LPVOID ,
1044- _dwBufferSize: DWORD ) -> BOOL {
1045- SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as DWORD ) ; 0
1046- }
10471044 pub fn GetSystemTimePreciseAsFileTime ( lpSystemTimeAsFileTime: LPFILETIME )
10481045 -> ( ) {
10491046 GetSystemTimeAsFileTime ( lpSystemTimeAsFileTime)
10501047 }
1051- pub fn SleepConditionVariableSRW ( ConditionVariable : PCONDITION_VARIABLE ,
1052- SRWLock : PSRWLOCK ,
1053- dwMilliseconds: DWORD ,
1054- Flags : ULONG ) -> BOOL {
1055- panic!( "condition variables not available" )
1056- }
1057- pub fn WakeConditionVariable ( ConditionVariable : PCONDITION_VARIABLE )
1058- -> ( ) {
1059- panic!( "condition variables not available" )
1060- }
1061- pub fn WakeAllConditionVariable ( ConditionVariable : PCONDITION_VARIABLE )
1062- -> ( ) {
1063- panic!( "condition variables not available" )
1064- }
1065- pub fn AcquireSRWLockExclusive ( SRWLock : PSRWLOCK ) -> ( ) {
1066- panic!( "rwlocks not available" )
1067- }
1068- pub fn AcquireSRWLockShared ( SRWLock : PSRWLOCK ) -> ( ) {
1069- panic!( "rwlocks not available" )
1070- }
1071- pub fn ReleaseSRWLockExclusive ( SRWLock : PSRWLOCK ) -> ( ) {
1072- panic!( "rwlocks not available" )
1073- }
1074- pub fn ReleaseSRWLockShared ( SRWLock : PSRWLOCK ) -> ( ) {
1075- panic!( "rwlocks not available" )
1076- }
1077- pub fn TryAcquireSRWLockExclusive ( SRWLock : PSRWLOCK ) -> BOOLEAN {
1078- panic!( "rwlocks not available" )
1079- }
1080- pub fn TryAcquireSRWLockShared ( SRWLock : PSRWLOCK ) -> BOOLEAN {
1081- panic!( "rwlocks not available" )
1082- }
10831048}
0 commit comments