29 #ifndef FFMPEG_COMPAT_W32PTHREADS_H
30 #define FFMPEG_COMPAT_W32PTHREADS_H
38 #define WIN32_LEAN_AND_MEAN
49 void *(*func)(
void*
arg);
60 #if HAVE_CONDITION_VARIABLE_PTR
68 #if _WIN32_WINNT >= 0x0600
69 #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
70 #define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
81 void *(*start_routine)(
void*),
void *
arg)
83 thread->
func = start_routine;
93 if (ret != WAIT_OBJECT_0)
96 *value_ptr = thread.
ret;
97 CloseHandle(thread.
handle);
102 InitializeCriticalSection(m);
107 DeleteCriticalSection(m);
112 EnterCriticalSection(m);
117 LeaveCriticalSection(m);
121 #if _WIN32_WINNT >= 0x0600
124 InitializeConditionVariable(cond);
136 WakeAllConditionVariable(cond);
141 SleepConditionVariableCS(cond, mutex, INFINITE);
147 WakeConditionVariable(cond);
150 #else // _WIN32_WINNT < 0x0600
181 cond->
Ptr = win32_cond;
215 if (cond_broadcast) {
216 cond_broadcast(cond);
233 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
246 cond_wait(cond, mutex, INFINITE);
259 WaitForSingleObject(win32_cond->
semaphore, INFINITE);
291 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
301 #if _WIN32_WINNT < 0x0600
302 HANDLE kernel_dll = GetModuleHandle(TEXT(
"kernel32.dll"));
static av_unused void pthread_cond_signal(pthread_cond_t *cond)
static av_unused void w32thread_init(void)
volatile int is_broadcast
static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
memory handling functions
static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
volatile int waiter_count
Macro definitions for various function/variable attributes.
static pthread_mutex_t DWORD milliseconds
CRITICAL_SECTION pthread_mutex_t
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr, void *(*start_routine)(void *), void *arg)
static int pthread_mutex_init(pthread_mutex_t *m, void *attr)
void *(* func)(void *arg)
static int pthread_mutex_unlock(pthread_mutex_t *m)
static av_unused void pthread_join(pthread_t thread, void **value_ptr)
common internal API header
static int pthread_mutex_destroy(pthread_mutex_t *m)
static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static pthread_mutex_t * mutex
pthread_mutex_t mtx_broadcast
static int pthread_mutex_lock(pthread_mutex_t *m)
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
common internal and external API header
pthread_mutex_t mtx_waiter_count
static BOOL(WINAPI *cond_wait)(pthread_cond_t *cond
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...