git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Zoltán Füzesi" <zfuzesi@eaglet.hu>
To: git@vger.kernel.org
Cc: j.sixt@viscovery.net, "Zoltán Füzesi" <zfuzesi@eaglet.hu>
Subject: [RFC/PATCH] MSVC: Windows-native implementation of pthread_cond_broadcast
Date: Fri, 29 Jan 2010 20:26:53 +0100	[thread overview]
Message-ID: <1264793213-8805-1-git-send-email-zfuzesi@eaglet.hu> (raw)
In-Reply-To: <4B62CEAB.5050608@viscovery.net>
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

  reply	other threads:[~2010-01-29 19:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 10:27 threaded-grep cause msys build failure Zoltán Füzesi
2010-01-29 12:03 ` Johannes Sixt
2010-01-29 19:26   ` Zoltán Füzesi [this message]
2010-01-29 20:02     ` [RFC/PATCH] MSVC: Windows-native implementation of pthread_cond_broadcast Johannes Sixt
2010-01-29 22:16       ` [PATCH] Windows: a minimal pthread_cond_broadcast Johannes Sixt
2010-01-29 23:54         ` [PATCH] Implement pthread_cond_broadcast on Windows Johannes Sixt
2010-01-30  2:28           ` Johannes Schindelin
2010-01-30  9:30             ` Johannes Sixt
2010-01-30 10:50               ` Johannes Schindelin
2010-01-29 20:13     ` [RFC/PATCH] MSVC: Windows-native implementation of pthread_cond_broadcast Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264793213-8805-1-git-send-email-zfuzesi@eaglet.hu \
    --to=zfuzesi@eaglet.hu \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).