Add threading.h condition variables
This commit is contained in:
parent
d132433534
commit
4204e03e77
@ -15,7 +15,7 @@
|
|||||||
* This file will hold wrapper for systems, which do not support Pthreads
|
* 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 :
|
* Windows minimalist Pthread Wrapper, based on :
|
||||||
|
@ -24,24 +24,42 @@ extern "C" {
|
|||||||
* Windows minimalist Pthread Wrapper, based on :
|
* Windows minimalist Pthread Wrapper, based on :
|
||||||
* http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
|
* 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
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
/* mutex */
|
/* mutex */
|
||||||
#define pthread_mutex_t CRITICAL_SECTION
|
#define pthread_mutex_t CRITICAL_SECTION
|
||||||
#define pthread_mutex_init(a,b) InitializeCriticalSection((a))
|
#define pthread_mutex_init(a,b) InitializeCriticalSection((a))
|
||||||
#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
|
#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
|
||||||
#define pthread_mutex_lock EnterCriticalSection
|
#define pthread_mutex_lock(a) EnterCriticalSection((a))
|
||||||
#define pthread_mutex_unlock LeaveCriticalSection
|
#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() */
|
/* pthread_create() and pthread_join() */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
void* (*start_routine)(void*);
|
void* (*start_routine)(void*);
|
||||||
void*varg;
|
void* arg;
|
||||||
} pthread_t;
|
} pthread_t;
|
||||||
|
|
||||||
int pthread_create(pthread_t* thread, const void* unused,
|
int pthread_create(pthread_t* thread, const void* unused,
|
||||||
@ -68,6 +86,13 @@ typedef int pthread_mutex_t;
|
|||||||
#define pthread_mutex_lock(a)
|
#define pthread_mutex_lock(a)
|
||||||
#define pthread_mutex_unlock(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 */
|
/* do not use pthread_t */
|
||||||
|
|
||||||
#endif /* ZSTD_PTHREAD */
|
#endif /* ZSTD_PTHREAD */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user