Fix mutex and wait signatures for Win32.

This commit is contained in:
Christoffer Lerno
2024-05-18 22:24:45 +02:00
parent a16d41a1e1
commit 92979984ea
3 changed files with 5 additions and 4 deletions

View File

@@ -48,14 +48,14 @@ const UNDNAME_COMPLETE = 0x0000;
extern fn void initializeCriticalSection(Win32_CRITICAL_SECTION* section) @extern("InitializeCriticalSection");
extern fn void deleteCriticalSection(Win32_CRITICAL_SECTION* section) @extern("DeleteCriticalSection");
extern fn Win32_HANDLE createMutex(void*, bool, void*) @extern("CreateMutexA");
extern fn Win32_HANDLE createMutex(void*, Win32_BOOL, void*) @extern("CreateMutexA");
extern fn Win32_BOOL releaseMutex(Win32_HANDLE) @extern("ReleaseMutex");
extern fn void enterCriticalSection(Win32_CRITICAL_SECTION* section) @extern("EnterCriticalSection");
extern fn void leaveCriticalSection(Win32_CRITICAL_SECTION* section) @extern("LeaveCriticalSection");
extern fn Win32_BOOL tryEnterCriticalSection(Win32_CRITICAL_SECTION* section) @extern("TryEnterCriticalSection");
extern fn uint waitForSingleObject(Win32_HANDLE, uint milliseconds) @extern("WaitForSingleObject");
extern fn void sleep(uint ms) @extern("Sleep");
extern fn uint waitForMultipleObjects(uint count, Win32_HANDLE* handles, bool wait_all, uint ms) @extern("WaitForMultipleObjects");
extern fn uint waitForMultipleObjects(uint count, Win32_HANDLE* handles, Win32_BOOL wait_all, uint ms) @extern("WaitForMultipleObjects");
extern fn Win32_BOOL resetEvent(Win32_HANDLE event) @extern("ResetEvent");
extern fn Win32_BOOL setEvent(Win32_HANDLE handle) @extern("SetEvent");
extern fn long interlockedCompareExchange(int* dest, int exchange, int comperand) @extern("InterlockedCompareExchange");

View File

@@ -48,7 +48,7 @@ fn void! NativeMutex.init(&mtx, MutexType type)
win32::initializeCriticalSection(&(mtx.critical_section));
return;
}
if (!(mtx.handle = win32::createMutex(null, false, null))) return ThreadFault.INIT_FAILED?;
if (!(mtx.handle = win32::createMutex(null, 0, null))) return ThreadFault.INIT_FAILED?;
}
fn void! NativeMutex.destroy(&mtx)
@@ -208,7 +208,7 @@ fn void! timedwait(NativeConditionVariable* cond, NativeMutex* mtx, uint timeout
mtx.unlock()!;
uint result = win32::waitForMultipleObjects(2, &cond.events, false, timeout);
uint result = win32::waitForMultipleObjects(2, &cond.events, 0, timeout);
switch (result)
{
case win32::WAIT_TIMEOUT:

View File

@@ -23,6 +23,7 @@
### Stdlib changes
- Add 'zstr' variants for `string::new_format` / `string::tformat`.
- Fix mutex and wait signatures for Win32.
## 0.5.5 Change list