Skip to content

Commit c3f4709

Browse files
committed
Merge branch 'gf/win32-pthread-cond-wait-err' into seen
Emulation code clean-up. * gf/win32-pthread-cond-wait-err: win32: return error if SleepConditionVariableCS fails
2 parents b871fe5 + 2367c6b commit c3f4709

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compat/win32/pthread.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,10 @@ pthread_t pthread_self(void)
5959
t.tid = GetCurrentThreadId();
6060
return t;
6161
}
62+
63+
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
64+
{
65+
if (SleepConditionVariableCS(cond, mutex, INFINITE) == 0)
66+
return err_win_to_posix(GetLastError());
67+
return 0;
68+
}

compat/win32/pthread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ typedef int pthread_mutexattr_t;
3636

3737
#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))
3838
#define pthread_cond_destroy(a) do {} while (0)
39-
#define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
4039
#define pthread_cond_signal WakeConditionVariable
4140
#define pthread_cond_broadcast WakeAllConditionVariable
4241

@@ -64,6 +63,8 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr);
6463
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
6564
pthread_t pthread_self(void);
6665

66+
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
67+
6768
static inline void NORETURN pthread_exit(void *ret)
6869
{
6970
_endthreadex((unsigned)(uintptr_t)ret);

0 commit comments

Comments
 (0)