29#ifndef COMPAT_W32PTHREADS_H
30#define COMPAT_W32PTHREADS_H
51 void *(*func)(
void*
arg);
60#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT
61#define PTHREAD_COND_INITIALIZER CONDITION_VARIABLE_INIT
63#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
64#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
66#define PTHREAD_CANCEL_ENABLE 1
67#define PTHREAD_CANCEL_DISABLE 0
70#define THREADFUNC_RETTYPE DWORD
72#define THREADFUNC_RETTYPE unsigned
79 h->ret =
h->func(
h->arg);
84 void *(*start_routine)(
void*),
void *
arg)
92 ret->func = start_routine;
115 if (ret != WAIT_OBJECT_0) {
116 if (ret == WAIT_ABANDONED)
122 *value_ptr = thread->ret;
123 CloseHandle(thread->handle);
130 InitializeSRWLock(m);
140 AcquireSRWLockExclusive(m);
145 ReleaseSRWLockExclusive(m);
151 return TryAcquireSRWLockExclusive(m) == 0 ? EBUSY : 0;
155#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
159 BOOL pending = FALSE;
160 InitOnceBeginInitialize(once_control, 0, &pending,
NULL);
163 InitOnceComplete(once_control, 0,
NULL);
169 InitializeConditionVariable(
cond);
181 WakeAllConditionVariable(
cond);
187 SleepConditionVariableSRW(
cond,
mutex, INFINITE, 0);
192 const struct timespec *abstime)
194 int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000;
197 if (!SleepConditionVariableSRW(
cond,
mutex, t, 0)) {
198 DWORD err = GetLastError();
199 if (err == ERROR_TIMEOUT)
209 WakeConditionVariable(
cond);
221 typedef HRESULT (WINAPI *SetThreadDescriptionFn)(HANDLE, PCWSTR);
226 HMODULE kernelbase = GetModuleHandleW(
L"kernelbase.dll");
230 SetThreadDescriptionFn pSetThreadDescription =
231 (SetThreadDescriptionFn)GetProcAddress(kernelbase,
"SetThreadDescription");
232 if (!pSetThreadDescription)
236 if (utf8towchar(
name, &wname) < 0)
239 HRESULT hr = pSetThreadDescription(GetCurrentThread(), wname);
241 return SUCCEEDED(hr) ? 0 :
AVERROR(EINVAL);
common internal and external API header
static struct @346255127015250356166251341105367306144006377143 state
Macro definitions for various function/variable attributes.
common internal API header
#define attribute_align_arg
Memory handling functions.
int(* cond)(enum AVPixelFormat pix_fmt)
int64_t av_gettime(void)
Get the current time in microseconds.
static int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static int pthread_mutex_unlock(pthread_mutex_t *m)
static int win32_thread_setname(const char *name)
static int pthread_setcancelstate(int state, int *oldstate)
static int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
static int pthread_mutex_trylock(pthread_mutex_t *m)
static av_unused THREADFUNC_RETTYPE __stdcall attribute_align_arg win32thread_worker(void *arg)
static int pthread_cond_destroy(pthread_cond_t *cond)
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr, void *(*start_routine)(void *), void *arg)
static int pthread_mutex_destroy(pthread_mutex_t *m)
static av_unused int pthread_join(pthread_t thread, void **value_ptr)
static av_unused int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
static int pthread_cond_signal(pthread_cond_t *cond)
static int pthread_mutex_lock(pthread_mutex_t *m)
#define WaitForSingleObject(a, b)
static int pthread_mutex_init(pthread_mutex_t *m, void *attr)
static int pthread_cond_broadcast(pthread_cond_t *cond)
#define THREADFUNC_RETTYPE
static int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)