27 #if defined(__MINGW32__) 29 typedef struct _RTL_SRWLOCK {
31 } RTL_SRWLOCK, *PRTL_SRWLOCK;
34 typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
37 static VOID (WINAPI *fpInitializeSRWLock)(PSRWLOCK lock) = NULL;
38 static VOID (WINAPI *fpAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
39 static VOID (WINAPI *fpAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
40 static VOID (WINAPI *fpReleaseSRWLockExclusive)(PSRWLOCK lock) = NULL;
41 static VOID (WINAPI *fpReleaseSRWLockShared)(PSRWLOCK lock) = NULL;
43 static bool sHasSRW =
false;
45 static bool loadSRW() {
46 static bool sChecked =
false;
50 if (HMODULE hLib = ::GetModuleHandleW(L
"Kernel32.dll")) {
52 (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
54 fpAcquireSRWLockExclusive =
55 (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
56 "AcquireSRWLockExclusive");
57 fpAcquireSRWLockShared =
58 (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
59 "AcquireSRWLockShared");
60 fpReleaseSRWLockExclusive =
61 (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
62 "ReleaseSRWLockExclusive");
63 fpReleaseSRWLockShared =
64 (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
65 "ReleaseSRWLockShared");
67 if (fpInitializeSRWLock != NULL) {
78 fpInitializeSRWLock(static_cast<PSRWLOCK>(data_));
81 InitializeCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
87 DeleteCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
94 fpAcquireSRWLockShared(static_cast<PSRWLOCK>(data_));
96 EnterCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
103 fpReleaseSRWLockShared(static_cast<PSRWLOCK>(data_));
105 LeaveCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
112 fpAcquireSRWLockExclusive(static_cast<PSRWLOCK>(data_));
114 EnterCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
121 fpReleaseSRWLockExclusive(static_cast<PSRWLOCK>(data_));
123 LeaveCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));
This class represents lattice values for constants.
bool reader_release()
Attempts to release the lock in reader mode.
bool writer_acquire()
Attempts to unconditionally acquire the lock in reader mode.
bool reader_acquire()
Attempts to unconditionally acquire the lock in reader mode.
RWMutexImpl()
Initializes the lock but doesn't acquire it.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
bool writer_release()
Attempts to release the lock in writer mode.
~RWMutexImpl()
Releases and removes the lock Destructor.