Skip to content
Snippets Groups Projects
Commit 0c069493 authored by James Almer's avatar James Almer
Browse files

compat/w32pthreads: use the CONDITION_VARIABLE typedef if available


This silences warnings about passing arguments from incompatible pointer type
when targeting Windows Vista or newer.

Tested-by: default avatarMatt Oliver <protogonoi@gmail.com>
Reviewed-by: default avatarMichael Niedermayer <michaelni@gmx.at>
Signed-off-by: default avatarJames Almer <jamrial@gmail.com>
parent 99afec08
No related branches found
No related tags found
No related merge requests found
...@@ -55,12 +55,15 @@ typedef struct pthread_t { ...@@ -55,12 +55,15 @@ typedef struct pthread_t {
* not mutexes */ * not mutexes */
typedef CRITICAL_SECTION pthread_mutex_t; typedef CRITICAL_SECTION pthread_mutex_t;
/* This is the CONDITIONAL_VARIABLE typedef for using Window's native /* This is the CONDITION_VARIABLE typedef for using Windows' native
* conditional variables on kernels 6.0+. * conditional variables on kernels 6.0+. */
* MinGW does not currently have this typedef. */ #if HAVE_CONDITION_VARIABLE_PTR
typedef CONDITION_VARIABLE pthread_cond_t;
#else
typedef struct pthread_cond_t { typedef struct pthread_cond_t {
void *ptr; void *Ptr;
} pthread_cond_t; } pthread_cond_t;
#endif
/* function pointers to conditional variable API on windows 6.0+ kernels */ /* function pointers to conditional variable API on windows 6.0+ kernels */
#if _WIN32_WINNT < 0x0600 #if _WIN32_WINNT < 0x0600
...@@ -159,7 +162,7 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_ ...@@ -159,7 +162,7 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
win32_cond = av_mallocz(sizeof(win32_cond_t)); win32_cond = av_mallocz(sizeof(win32_cond_t));
if (!win32_cond) if (!win32_cond)
return ENOMEM; return ENOMEM;
cond->ptr = win32_cond; cond->Ptr = win32_cond;
win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
if (!win32_cond->semaphore) if (!win32_cond->semaphore)
return ENOMEM; return ENOMEM;
...@@ -174,7 +177,7 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_ ...@@ -174,7 +177,7 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
static av_unused void pthread_cond_destroy(pthread_cond_t *cond) static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
{ {
win32_cond_t *win32_cond = cond->ptr; win32_cond_t *win32_cond = cond->Ptr;
/* native condition variables do not destroy */ /* native condition variables do not destroy */
if (cond_init) if (cond_init)
return; return;
...@@ -185,12 +188,12 @@ static av_unused void pthread_cond_destroy(pthread_cond_t *cond) ...@@ -185,12 +188,12 @@ static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
pthread_mutex_destroy(&win32_cond->mtx_waiter_count); pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
pthread_mutex_destroy(&win32_cond->mtx_broadcast); pthread_mutex_destroy(&win32_cond->mtx_broadcast);
av_freep(&win32_cond); av_freep(&win32_cond);
cond->ptr = NULL; cond->Ptr = NULL;
} }
static av_unused void pthread_cond_broadcast(pthread_cond_t *cond) static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
{ {
win32_cond_t *win32_cond = cond->ptr; win32_cond_t *win32_cond = cond->Ptr;
int have_waiter; int have_waiter;
if (cond_broadcast) { if (cond_broadcast) {
...@@ -221,7 +224,7 @@ static av_unused void pthread_cond_broadcast(pthread_cond_t *cond) ...@@ -221,7 +224,7 @@ static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{ {
win32_cond_t *win32_cond = cond->ptr; win32_cond_t *win32_cond = cond->Ptr;
int last_waiter; int last_waiter;
if (cond_wait) { if (cond_wait) {
cond_wait(cond, mutex, INFINITE); cond_wait(cond, mutex, INFINITE);
...@@ -253,7 +256,7 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu ...@@ -253,7 +256,7 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu
static av_unused void pthread_cond_signal(pthread_cond_t *cond) static av_unused void pthread_cond_signal(pthread_cond_t *cond)
{ {
win32_cond_t *win32_cond = cond->ptr; win32_cond_t *win32_cond = cond->Ptr;
int have_waiter; int have_waiter;
if (cond_signal) { if (cond_signal) {
cond_signal(cond); cond_signal(cond);
......
...@@ -1767,6 +1767,7 @@ TOOLCHAIN_FEATURES=" ...@@ -1767,6 +1767,7 @@ TOOLCHAIN_FEATURES="
" "
TYPES_LIST=" TYPES_LIST="
CONDITION_VARIABLE_Ptr
socklen_t socklen_t
struct_addrinfo struct_addrinfo
struct_group_source_req struct_group_source_req
...@@ -4719,6 +4720,7 @@ check_func_headers windows.h PeekNamedPipe ...@@ -4719,6 +4720,7 @@ check_func_headers windows.h PeekNamedPipe
check_func_headers windows.h SetConsoleTextAttribute check_func_headers windows.h SetConsoleTextAttribute
check_func_headers windows.h Sleep check_func_headers windows.h Sleep
check_func_headers windows.h VirtualAlloc check_func_headers windows.h VirtualAlloc
check_struct windows.h "CONDITION_VARIABLE" Ptr
check_func_headers glob.h glob check_func_headers glob.h glob
enabled xlib && enabled xlib &&
check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment