8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use libc:: { BOOL , DWORD , c_void, LPVOID } ;
11
+ use libc:: { BOOL , DWORD , c_void, LPVOID , c_ulong } ;
12
12
use libc:: types:: os:: arch:: extra:: BOOLEAN ;
13
13
14
- pub type LPCRITICAL_SECTION = * mut c_void ;
15
- pub type LPCONDITION_VARIABLE = * mut CONDITION_VARIABLE ;
16
- pub type LPSRWLOCK = * mut SRWLOCK ;
17
-
18
- #[ cfg( target_arch = "x86" ) ]
19
- pub const CRITICAL_SECTION_SIZE : uint = 24 ;
20
- #[ cfg( target_arch = "x86_64" ) ]
21
- pub const CRITICAL_SECTION_SIZE : uint = 40 ;
14
+ pub type PCONDITION_VARIABLE = * mut CONDITION_VARIABLE ;
15
+ pub type PSRWLOCK = * mut SRWLOCK ;
16
+ pub type ULONG = c_ulong ;
22
17
23
18
#[ repr( C ) ]
24
19
pub struct CONDITION_VARIABLE { pub ptr : LPVOID }
@@ -31,28 +26,19 @@ pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE {
31
26
pub const SRWLOCK_INIT : SRWLOCK = SRWLOCK { ptr : 0 as * mut _ } ;
32
27
33
28
extern "system" {
34
- // critical sections
35
- pub fn InitializeCriticalSectionAndSpinCount (
36
- lpCriticalSection : LPCRITICAL_SECTION ,
37
- dwSpinCount : DWORD ) -> BOOL ;
38
- pub fn DeleteCriticalSection ( lpCriticalSection : LPCRITICAL_SECTION ) ;
39
- pub fn EnterCriticalSection ( lpCriticalSection : LPCRITICAL_SECTION ) ;
40
- pub fn LeaveCriticalSection ( lpCriticalSection : LPCRITICAL_SECTION ) ;
41
- pub fn TryEnterCriticalSection ( lpCriticalSection : LPCRITICAL_SECTION ) -> BOOL ;
42
-
43
29
// condition variables
44
- pub fn SleepConditionVariableCS ( ConditionVariable : LPCONDITION_VARIABLE ,
45
- CriticalSection : LPCRITICAL_SECTION ,
46
- dwMilliseconds : DWORD ) -> BOOL ;
47
- pub fn WakeConditionVariable ( ConditionVariable : LPCONDITION_VARIABLE ) ;
48
- pub fn WakeAllConditionVariable ( ConditionVariable : LPCONDITION_VARIABLE ) ;
30
+ pub fn SleepConditionVariableSRW ( ConditionVariable : PCONDITION_VARIABLE ,
31
+ SRWLock : PSRWLOCK ,
32
+ dwMilliseconds : DWORD ,
33
+ Flags : ULONG ) -> BOOL ;
34
+ pub fn WakeConditionVariable ( ConditionVariable : PCONDITION_VARIABLE ) ;
35
+ pub fn WakeAllConditionVariable ( ConditionVariable : PCONDITION_VARIABLE ) ;
49
36
50
37
// slim rwlocks
51
- pub fn AcquireSRWLockExclusive ( SRWLock : LPSRWLOCK ) ;
52
- pub fn AcquireSRWLockShared ( SRWLock : LPSRWLOCK ) ;
53
- pub fn ReleaseSRWLockExclusive ( SRWLock : LPSRWLOCK ) ;
54
- pub fn ReleaseSRWLockShared ( SRWLock : LPSRWLOCK ) ;
55
- pub fn TryAcquireSRWLockExclusive ( SRWLock : LPSRWLOCK ) -> BOOLEAN ;
56
- pub fn TryAcquireSRWLockShared ( SRWLock : LPSRWLOCK ) -> BOOLEAN ;
38
+ pub fn AcquireSRWLockExclusive ( SRWLock : PSRWLOCK ) ;
39
+ pub fn AcquireSRWLockShared ( SRWLock : PSRWLOCK ) ;
40
+ pub fn ReleaseSRWLockExclusive ( SRWLock : PSRWLOCK ) ;
41
+ pub fn ReleaseSRWLockShared ( SRWLock : PSRWLOCK ) ;
42
+ pub fn TryAcquireSRWLockExclusive ( SRWLock : PSRWLOCK ) -> BOOLEAN ;
43
+ pub fn TryAcquireSRWLockShared ( SRWLock : PSRWLOCK ) -> BOOLEAN ;
57
44
}
58
-
0 commit comments