Skip to content

Commit

Permalink
Fix mutex and wait signatures for Win32.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed May 18, 2024
1 parent a16d41a commit 9297998
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/std/os/win32/process.c3
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions lib/std/threads/os/thread_win32.c3
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9297998

Please sign in to comment.