git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH] MSVC: Windows-native implementation of pthread_cond_broadcast

From
ZFZoltán Füzesi <zfuzesi@eaglet.hu>
Date
Jan 29, 2010, 19:26 UTC
Message-ID
<1264793213-8805-1-git-send-email-zfuzesi@eaglet.hu>
In-Reply-To
<4B62CEAB.5050608@viscovery.net>

Threaded grep feature relies on this function, but its implementation was missing from the Win32 Pthreads API.

Signed-off-by: Zoltán Füzesi <zfuzesi@eaglet.hu>
---
Johannes, how about this? I haven't tested it.
 compat/win32/pthread.c |   12 ++++++++++++
 compat/win32/pthread.h |    2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c
index 631c0a4..498b552 100644
--- a/compat/win32/pthread.c
+++ b/compat/win32/pthread.c
@@ -108,3 +108,15 @@ int pthread_cond_signal(pthread_cond_t *cond)
 	else
 		return 0;
 }
+
+int pthread_cond_broadcast(pthread_cond_t *cond)
+{
+	LONG prev_count;
+	while (cond->waiters) {
+		if (!ReleaseSemaphore(cond->sema, 1, &prev_count))
+			return err_win_to_posix(GetLastError());
+		if (prev_count == LONG_MAX - 1)
+			break;
+	}
+	return 0;
+}
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index b8e1bcb..11426f5 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -44,6 +44,8 @@ extern int pthread_cond_wait(pthread_cond_t *cond, CRITICAL_SECTION *mutex);
 
 extern int pthread_cond_signal(pthread_cond_t *cond);
 
+extern int pthread_cond_broadcast(pthread_cond_t *cond);
+
 /*
  * Simple thread creation implementation using pthread API
  */
-- 
1.7.0.rc0.48.gdace5.dirty
Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 10 in “threaded-grep cause msys build failure”
  1. Zoltán FüzesiJan 29, 2010
  2. Johannes SixtJan 29, 2010
  3. MSVC: Windows-native implementation of pthread_cond_broadcastZoltán Füzesi, Jan 29, 2010
  4. Johannes SixtJan 29, 2010
  5. Windows: a minimal pthread_cond_broadcastJohannes Sixt, Jan 29, 2010
  6. Implement pthread_cond_broadcast on WindowsJohannes Sixt, Jan 29, 2010
  7. Johannes SchindelinJan 30, 2010
  8. Johannes SixtJan 30, 2010
  9. Johannes SchindelinJan 30, 2010
  10. Johannes SchindelinJan 29, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.