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.
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.
11 use libc
::{BOOL, DWORD, LPVOID, LONG, HANDLE, c_ulong}
;
12 use libc
::types
::os
::arch
::extra
::BOOLEAN
;
14 pub type PCONDITION_VARIABLE
= *mut CONDITION_VARIABLE
;
15 pub type PSRWLOCK
= *mut SRWLOCK
;
16 pub type ULONG
= c_ulong
;
17 pub type ULONG_PTR
= c_ulong
;
20 pub struct CONDITION_VARIABLE { pub ptr: LPVOID }
22 pub struct SRWLOCK { pub ptr: LPVOID }
24 pub struct CRITICAL_SECTION
{
25 CriticalSectionDebug
: LPVOID
,
29 LockSemaphore
: HANDLE
,
33 pub const CONDITION_VARIABLE_INIT
: CONDITION_VARIABLE
= CONDITION_VARIABLE
{
36 pub const SRWLOCK_INIT
: SRWLOCK
= SRWLOCK { ptr: 0 as *mut _ }
;
39 // condition variables
40 pub fn SleepConditionVariableSRW(ConditionVariable
: PCONDITION_VARIABLE
,
42 dwMilliseconds
: DWORD
,
43 Flags
: ULONG
) -> BOOL
;
44 pub fn WakeConditionVariable(ConditionVariable
: PCONDITION_VARIABLE
);
45 pub fn WakeAllConditionVariable(ConditionVariable
: PCONDITION_VARIABLE
);
48 pub fn AcquireSRWLockExclusive(SRWLock
: PSRWLOCK
);
49 pub fn AcquireSRWLockShared(SRWLock
: PSRWLOCK
);
50 pub fn ReleaseSRWLockExclusive(SRWLock
: PSRWLOCK
);
51 pub fn ReleaseSRWLockShared(SRWLock
: PSRWLOCK
);
52 pub fn TryAcquireSRWLockExclusive(SRWLock
: PSRWLOCK
) -> BOOLEAN
;
53 pub fn TryAcquireSRWLockShared(SRWLock
: PSRWLOCK
) -> BOOLEAN
;
55 pub fn InitializeCriticalSection(CriticalSection
: *mut CRITICAL_SECTION
);
56 pub fn EnterCriticalSection(CriticalSection
: *mut CRITICAL_SECTION
);
57 pub fn TryEnterCriticalSection(CriticalSection
: *mut CRITICAL_SECTION
) -> BOOLEAN
;
58 pub fn LeaveCriticalSection(CriticalSection
: *mut CRITICAL_SECTION
);
59 pub fn DeleteCriticalSection(CriticalSection
: *mut CRITICAL_SECTION
);