win32: return error if SleepConditionVariableCS fails

If it fails, return an error. Signed-off-by: Greg Funni <gfunni234@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Greg Funni committed Nov 18, 2025 at 15:41 UTC 2367c6bcd600882d0ea70d4f654c8cfa5c1f53ac
2 files changed +9 -1
compat/win32/pthread.c
+7
@@ -59,3 +59,10 @@ pthread_t pthread_self(void)
59 t.tid = GetCurrentThreadId();
60 return t;
61 }
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
+2 -1
@@ -36,7 +36,6 @@ typedef int pthread_mutexattr_t;
36
37 #define pthread_cond_init(a,b) InitializeConditionVariable((a))
38 #define pthread_cond_destroy(a) do {} while (0)
39 -#define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
39 #define pthread_cond_signal WakeConditionVariable
40 #define pthread_cond_broadcast WakeAllConditionVariable
41
@@ -64,6 +63,8 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr);
63 #define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
64 pthread_t pthread_self(void);
65
66 +int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
67 +
68 static inline void NORETURN pthread_exit(void *ret)
69 {
70 _endthreadex((unsigned)(uintptr_t)ret);