29 #ifndef FFMPEG_COMPAT_W32PTHREADS_H
30 #define FFMPEG_COMPAT_W32PTHREADS_H
38 #define WIN32_LEAN_AND_MEAN
49 void *(*func)(
void*
arg);
66 #if _WIN32_WINNT < 0x0600
73 #define cond_init InitializeConditionVariable
74 #define cond_broadcast WakeAllConditionVariable
75 #define cond_signal WakeConditionVariable
76 #define cond_wait SleepConditionVariableCS
78 #define CreateEvent(a, reset, init, name) \
79 CreateEventEx(a, name, \
80 (reset ? CREATE_EVENT_MANUAL_RESET : 0) | \
81 (init ? CREATE_EVENT_INITIAL_SET : 0), \
85 #define CreateSemaphore(a, b, c, d) \
86 CreateSemaphoreExW(a, b, c, d, 0, SEMAPHORE_ALL_ACCESS)
87 #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
88 #define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
99 void *(*start_routine)(
void*),
void *
arg)
101 thread->
func = start_routine;
111 if (ret != WAIT_OBJECT_0)
114 *value_ptr = thread.
ret;
115 CloseHandle(thread.
handle);
120 InitializeCriticalSection(m);
125 DeleteCriticalSection(m);
130 EnterCriticalSection(m);
135 LeaveCriticalSection(m);
162 cond->
ptr = win32_cond;
163 win32_cond->
semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
196 if (cond_broadcast) {
197 cond_broadcast(cond);
214 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
227 cond_wait(cond, mutex, INFINITE);
240 WaitForSingleObject(win32_cond->
semaphore, INFINITE);
271 ReleaseSemaphore(win32_cond->
semaphore, 1, NULL);
272 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
281 #if _WIN32_WINNT < 0x0600
282 HANDLE kernel_dll = GetModuleHandle(TEXT(
"kernel32.dll"));