* [PATCH] win32: return error if SleepConditionVariableCS fails
@ 2025-11-18 0:59 AZero13 via GitGitGadget
2025-11-18 15:41 ` [PATCH v2] " AZero13 via GitGitGadget
0 siblings, 1 reply; 2+ messages in thread
From: AZero13 via GitGitGadget @ 2025-11-18 0:59 UTC (permalink / raw)
To: git; +Cc: AZero13, AZero13
From: AZero13 <gfunni234@gmail.com>
If it fails, return an error.
Signed-off-by: Greg Funni <gfunni234@gmail.com>
---
win32: return error if SleepConditionVariableCS fails
If it fails, return an error.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2104%2FAZero13%2Fsleep-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2104/AZero13/sleep-v1
Pull-Request: https://github.com/git/git/pull/2104
compat/win32/pthread.c | 7 +++++++
compat/win32/pthread.h | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c
index 58980a529c..7e93146963 100644
--- a/compat/win32/pthread.c
+++ b/compat/win32/pthread.c
@@ -59,3 +59,10 @@ pthread_t pthread_self(void)
t.tid = GetCurrentThreadId();
return t;
}
+
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ if (SleepConditionVariableCS(cond, mutex, INFINITE) == 0)
+ return err_win_to_posix(GetLastError());
+ return 0;
+}
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index e2b5c4f64c..859e1d9021 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -36,7 +36,6 @@ typedef int pthread_mutexattr_t;
#define pthread_cond_init(a,b) InitializeConditionVariable((a))
#define pthread_cond_destroy(a) do {} while (0)
-#define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
#define pthread_cond_signal WakeConditionVariable
#define pthread_cond_broadcast WakeAllConditionVariable
@@ -64,6 +63,8 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr);
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
pthread_t pthread_self(void);
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
+
static inline void NORETURN pthread_exit(void *ret)
{
_endthreadex((unsigned)(uintptr_t)ret);
base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
--
gitgitgadget
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2] win32: return error if SleepConditionVariableCS fails
2025-11-18 0:59 [PATCH] win32: return error if SleepConditionVariableCS fails AZero13 via GitGitGadget
@ 2025-11-18 15:41 ` AZero13 via GitGitGadget
0 siblings, 0 replies; 2+ messages in thread
From: AZero13 via GitGitGadget @ 2025-11-18 15:41 UTC (permalink / raw)
To: git; +Cc: AZero13, Greg Funni
From: Greg Funni <gfunni234@gmail.com>
If it fails, return an error.
Signed-off-by: Greg Funni <gfunni234@gmail.com>
---
win32: return error if SleepConditionVariableCS fails
If it fails, return an error.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2104%2FAZero13%2Fsleep-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2104/AZero13/sleep-v2
Pull-Request: https://github.com/git/git/pull/2104
Range-diff vs v1:
1: 35384a6aa3 ! 1: 7bdcd55664 win32: return error if SleepConditionVariableCS fails
@@
## Metadata ##
-Author: AZero13 <gfunni234@gmail.com>
+Author: Greg Funni <gfunni234@gmail.com>
## Commit message ##
win32: return error if SleepConditionVariableCS fails
compat/win32/pthread.c | 7 +++++++
compat/win32/pthread.h | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c
index 58980a529c..7e93146963 100644
--- a/compat/win32/pthread.c
+++ b/compat/win32/pthread.c
@@ -59,3 +59,10 @@ pthread_t pthread_self(void)
t.tid = GetCurrentThreadId();
return t;
}
+
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ if (SleepConditionVariableCS(cond, mutex, INFINITE) == 0)
+ return err_win_to_posix(GetLastError());
+ return 0;
+}
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index e2b5c4f64c..859e1d9021 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -36,7 +36,6 @@ typedef int pthread_mutexattr_t;
#define pthread_cond_init(a,b) InitializeConditionVariable((a))
#define pthread_cond_destroy(a) do {} while (0)
-#define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
#define pthread_cond_signal WakeConditionVariable
#define pthread_cond_broadcast WakeAllConditionVariable
@@ -64,6 +63,8 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr);
#define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
pthread_t pthread_self(void);
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
+
static inline void NORETURN pthread_exit(void *ret)
{
_endthreadex((unsigned)(uintptr_t)ret);
base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
--
gitgitgadget
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-18 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 0:59 [PATCH] win32: return error if SleepConditionVariableCS fails AZero13 via GitGitGadget
2025-11-18 15:41 ` [PATCH v2] " AZero13 via GitGitGadget
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).