Mesa (master): os: Implement pipe_condvar on Windows Vista and later

Jose Fonseca jrfonseca at kemper.freedesktop.org
Mon Jul 12 14:41:21 UTC 2010


Module: Mesa
Branch: master
Commit: f321d5c38ae704a6cb2252c7a78a69c367db00fc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f321d5c38ae704a6cb2252c7a78a69c367db00fc

Author: nobled <nobled at dreamwidth.org>
Date:   Sat Jul  3 13:48:58 2010 -0700

os: Implement pipe_condvar on Windows Vista and later

Unfortunately compiling with these defines enabled would mean
Gallium can't run on Windows XP/2003 or older.

Todo: Need a macro to declare if we don't care about WinXP
compatibililty.

---

 src/gallium/auxiliary/os/os_thread.h |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index 40cfa41..c23ae80 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -168,6 +168,35 @@ typedef CRITICAL_SECTION pipe_mutex;
 #define pipe_mutex_unlock(mutex) \
    LeaveCriticalSection(&mutex)
 
+/* TODO: Need a macro to declare "I don't care about WinXP compatibilty" */
+#if 0 && defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
+/* CONDITION_VARIABLE is only available on newer versions of Windows
+ * (Server 2008/Vista or later).
+ * http://msdn.microsoft.com/en-us/library/ms682052(VS.85).aspx
+ *
+ * pipe_condvar
+ */
+typedef CONDITION_VARIABLE pipe_condvar;
+
+#define pipe_static_condvar(cond) \
+   /*static*/ pipe_condvar cond = CONDITION_VARIABLE_INIT
+
+#define pipe_condvar_init(cond) \
+   InitializeConditionVariable(&(cond))
+
+#define pipe_condvar_destroy(cond) \
+   (void) cond /* nothing to do */
+
+#define pipe_condvar_wait(cond, mutex) \
+   SleepConditionVariableCS(&(cond), &(mutex), INFINITE)
+
+#define pipe_condvar_signal(cond) \
+   WakeConditionVariable(&(cond))
+
+#define pipe_condvar_broadcast(cond) \
+   WakeAllConditionVariable(&(cond))
+
+#else /* need compatibility with pre-Vista Win32 */
 
 /* pipe_condvar (XXX FIX THIS)
  * See http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
@@ -199,6 +228,7 @@ typedef DWORD pipe_condvar;
 #define pipe_condvar_broadcast(cond) \
    (void) cond
 
+#endif /* pre-Vista win32 */
 
 #else
 




More information about the mesa-commit mailing list