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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]