Go to the documentation of this file.
29 #ifndef COMPAT_W32PTHREADS_H
30 #define COMPAT_W32PTHREADS_H
50 void *(*func)(
void*
arg);
59 #define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT
60 #define PTHREAD_COND_INITIALIZER CONDITION_VARIABLE_INIT
62 #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
63 #define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
65 #define PTHREAD_CANCEL_ENABLE 1
66 #define PTHREAD_CANCEL_DISABLE 0
69 #define THREADFUNC_RETTYPE DWORD
71 #define THREADFUNC_RETTYPE unsigned
78 h->ret =
h->func(
h->arg);
83 void *(*start_routine)(
void*),
void *
arg)
91 ret->func = start_routine;
114 if (
ret != WAIT_OBJECT_0) {
115 if (
ret == WAIT_ABANDONED)
121 *value_ptr = thread->
ret;
122 CloseHandle(thread->
handle);
129 InitializeSRWLock(m);
139 AcquireSRWLockExclusive(m);
144 ReleaseSRWLockExclusive(m);
149 #define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
153 BOOL pending = FALSE;
154 InitOnceBeginInitialize(once_control, 0, &pending,
NULL);
157 InitOnceComplete(once_control, 0,
NULL);
163 InitializeConditionVariable(
cond);
175 WakeAllConditionVariable(
cond);
181 SleepConditionVariableSRW(
cond,
mutex, INFINITE, 0);
186 const struct timespec *abstime)
188 int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000;
191 if (!SleepConditionVariableSRW(
cond,
mutex, t, 0)) {
192 DWORD err = GetLastError();
193 if (err == ERROR_TIMEOUT)
203 WakeConditionVariable(
cond);
static int pthread_mutex_lock(pthread_mutex_t *m)
static av_unused THREADFUNC_RETTYPE __stdcall attribute_align_arg win32thread_worker(void *arg)
static int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
static int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
static int pthread_cond_broadcast(pthread_cond_t *cond)
static int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static int pthread_cond_destroy(pthread_cond_t *cond)
static av_unused int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
#define THREADFUNC_RETTYPE
static int pthread_mutex_destroy(pthread_mutex_t *m)
CONDITION_VARIABLE pthread_cond_t
#define attribute_align_arg
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr, void *(*start_routine)(void *), void *arg)
static int pthread_cond_signal(pthread_cond_t *cond)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static av_unused int pthread_join(pthread_t thread, void **value_ptr)
static int pthread_setcancelstate(int state, int *oldstate)
static int pthread_mutex_init(pthread_mutex_t *m, void *attr)
#define INIT_ONCE(id, name)
int64_t av_gettime(void)
Get the current time in microseconds.
#define WaitForSingleObject(a, b)
static int pthread_mutex_unlock(pthread_mutex_t *m)
int(* cond)(enum AVPixelFormat pix_fmt)