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;
182 win32_cond->
semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
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);
290 ReleaseSemaphore(win32_cond->
semaphore, 1, NULL);
291 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
301 #if _WIN32_WINNT < 0x0600
302 HANDLE kernel_dll = GetModuleHandle(TEXT(
"kernel32.dll"));