Commit ac7367d8 authored by James Almer's avatar James Almer

threads: Inline some Windows pthreads compat wrappers in the header

They are all single line functions.
parent 755fcdf8
......@@ -42,23 +42,52 @@ typedef void *pthread_mutexattr_t;
typedef void *pthread_condattr_t;
typedef void *pthread_attr_t;
void pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr);
void pthread_mutex_destroy(pthread_mutex_t* mutex);
void pthread_mutex_lock(pthread_mutex_t* mutex);
void pthread_mutex_unlock(pthread_mutex_t* mutex);
void pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr);
void pthread_cond_destroy(pthread_cond_t* cond);
void pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex);
void pthread_cond_signal(pthread_cond_t* cond);
void pthread_cond_broadcast(pthread_cond_t* cond);
int pthread_create(pthread_t* thread, const pthread_attr_t* attr,
void*(*proc)(void*), void* param);
void pthread_join(pthread_t thread, void** res);
int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
static inline void pthread_mutex_init(pthread_mutex_t* mutex,
const pthread_mutexattr_t* attr)
{
(void)attr;
InitializeCriticalSection(mutex);
}
static inline void pthread_mutex_destroy(pthread_mutex_t* mutex) {
DeleteCriticalSection(mutex);
}
static inline void pthread_mutex_lock(pthread_mutex_t* mutex) {
EnterCriticalSection(mutex);
}
static inline void pthread_mutex_unlock(pthread_mutex_t* mutex) {
LeaveCriticalSection(mutex);
}
static inline void pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) {
(void)attr;
InitializeConditionVariable(cond);
}
static inline void pthread_cond_destroy(pthread_cond_t* cond) {
(void)cond;
}
static inline void pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) {
SleepConditionVariableCS(cond, mutex, INFINITE);
}
static inline void pthread_cond_signal(pthread_cond_t* cond) {
WakeConditionVariable(cond);
}
static inline void pthread_cond_broadcast(pthread_cond_t* cond) {
WakeAllConditionVariable(cond);
}
#else
#include <pthread.h>
......
......@@ -36,46 +36,6 @@
#include "config.h"
#include "src/thread.h"
void pthread_mutex_init(pthread_mutex_t* mutex,
const pthread_mutexattr_t* attr)
{
(void)attr;
InitializeCriticalSection(mutex);
}
void pthread_mutex_destroy(pthread_mutex_t* mutex) {
DeleteCriticalSection(mutex);
}
void pthread_mutex_lock(pthread_mutex_t* mutex) {
EnterCriticalSection(mutex);
}
void pthread_mutex_unlock(pthread_mutex_t* mutex) {
LeaveCriticalSection(mutex);
}
void pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) {
(void)attr;
InitializeConditionVariable(cond);
}
void pthread_cond_destroy(pthread_cond_t* cond) {
(void)cond;
}
void pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) {
SleepConditionVariableCS(cond, mutex, INFINITE);
}
void pthread_cond_signal(pthread_cond_t* cond) {
WakeConditionVariable(cond);
}
void pthread_cond_broadcast(pthread_cond_t* cond) {
WakeAllConditionVariable(cond);
}
typedef struct dav1d_win32_thread_t {
HANDLE h;
void* param;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment