Add threading.h condition variables
diff --git a/lib/common/threading.c b/lib/common/threading.c
index 1725650..abad2c1 100644
--- a/lib/common/threading.c
+++ b/lib/common/threading.c
@@ -15,7 +15,7 @@
  * This file will hold wrapper for systems, which do not support Pthreads
  */
 
-#ifdef _WIN32
+#if defined(ZSTD_PTHREAD) && defined(_WIN32)
 
 /**
  * Windows minimalist Pthread Wrapper, based on :
diff --git a/lib/common/threading.h b/lib/common/threading.h
index a8126eb..d5dc8f7 100644
--- a/lib/common/threading.h
+++ b/lib/common/threading.h
@@ -24,24 +24,42 @@
  * Windows minimalist Pthread Wrapper, based on :
  * http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
  */
+#ifdef WINVER
+#  undef WINVER
+#endif
+#define WINVER       0x0600
+
+#ifdef _WIN32_WINNT
+#  undef _WIN32_WINNT
+#endif
+#define _WIN32_WINNT 0x0600
 
 #ifndef WIN32_LEAN_AND_MEAN
 #  define WIN32_LEAN_AND_MEAN
 #endif
+
 #include <windows.h>
 
 /* mutex */
 #define pthread_mutex_t           CRITICAL_SECTION
 #define pthread_mutex_init(a,b)   InitializeCriticalSection((a))
 #define pthread_mutex_destroy(a)  DeleteCriticalSection((a))
-#define pthread_mutex_lock        EnterCriticalSection
-#define pthread_mutex_unlock      LeaveCriticalSection
+#define pthread_mutex_lock(a)     EnterCriticalSection((a))
+#define pthread_mutex_unlock(a)   LeaveCriticalSection((a))
+
+/* condition variable */
+#define pthread_cond_t             CONDITION_VARIABLE
+#define pthread_cond_init(a, b)    InitializeConditionVariable((a))
+#define pthread_cond_destroy(a)    /* No delete */
+#define pthread_cond_wait(a, b)    SleepConditionVariableCS((a), (b), INFINITE)
+#define pthread_cond_signal(a)     WakeConditionVariable((a))
+#define pthread_cond_broadcast(a)  WakeAllConditionVariable((a))
 
 /* pthread_create() and pthread_join() */
 typedef struct {
     HANDLE handle;
     void* (*start_routine)(void*);
-    void*varg;
+    void* arg;
 } pthread_t;
 
 int pthread_create(pthread_t* thread, const void* unused,
@@ -68,6 +86,13 @@
 #define pthread_mutex_lock(a)
 #define pthread_mutex_unlock(a)
 
+typedef int pthread_cond_t;
+#define pthread_cond_init(a,b)
+#define pthread_cond_destroy(a)
+#define pthread_cond_wait(a,b)
+#define pthread_cond_signal(a)
+#define pthread_cond_broadcast(a)
+
 /* do not use pthread_t */
 
 #endif /* ZSTD_PTHREAD */