summaryrefslogtreecommitdiff
path: root/compat/w32pthreads.h
diff options
context:
space:
mode:
authorMatt Oliver <protogonoi@gmail.com>2015-09-30 13:41:33 +1000
committerMatt Oliver <protogonoi@gmail.com>2015-09-30 13:41:33 +1000
commitae58abeabbfc15eddff0e23cbf1a62c7bc50d3c8 (patch)
tree532841439425056dc3f5c419235d7147b60ee09e /compat/w32pthreads.h
parent733475160a0a8a2a9d8888f6dbc0188454c3c4d6 (diff)
downloadffmpeg-ae58abeabbfc15eddff0e23cbf1a62c7bc50d3c8.tar.gz
compat/w32pthreads: Add return values to match the simulated pthread functions.
Diffstat (limited to 'compat/w32pthreads.h')
-rw-r--r--compat/w32pthreads.h36
1 files changed, 23 insertions, 13 deletions
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 87e816ff6e..deb1c536af 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -87,14 +87,19 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
return !thread->handle;
}
-static av_unused void pthread_join(pthread_t thread, void **value_ptr)
+static av_unused int pthread_join(pthread_t thread, void **value_ptr)
{
DWORD ret = WaitForSingleObject(thread.handle, INFINITE);
- if (ret != WAIT_OBJECT_0)
- return;
+ if (ret != WAIT_OBJECT_0) {
+ if (ret == WAIT_ABANDONED)
+ return EINVAL;
+ else
+ return EDEADLK;
+ }
if (value_ptr)
*value_ptr = thread.ret;
CloseHandle(thread.handle);
+ return 0;
}
static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr)
@@ -126,14 +131,15 @@ static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_att
}
/* native condition variables do not destroy */
-static inline void pthread_cond_destroy(pthread_cond_t *cond)
+static inline int pthread_cond_destroy(pthread_cond_t *cond)
{
- return;
+ return 0;
}
-static inline void pthread_cond_broadcast(pthread_cond_t *cond)
+static inline int pthread_cond_broadcast(pthread_cond_t *cond)
{
WakeAllConditionVariable(cond);
+ return 0;
}
static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
@@ -142,9 +148,10 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex
return 0;
}
-static inline void pthread_cond_signal(pthread_cond_t *cond)
+static inline int pthread_cond_signal(pthread_cond_t *cond)
{
WakeConditionVariable(cond);
+ return 0;
}
#else // _WIN32_WINNT < 0x0600
@@ -191,12 +198,12 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
return 0;
}
-static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
+static av_unused int pthread_cond_destroy(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->Ptr;
/* native condition variables do not destroy */
if (cond_init)
- return;
+ return 0;
/* non native condition variables */
CloseHandle(win32_cond->semaphore);
@@ -205,16 +212,17 @@ static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
pthread_mutex_destroy(&win32_cond->mtx_broadcast);
av_freep(&win32_cond);
cond->Ptr = NULL;
+ return 0;
}
-static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
+static av_unused int pthread_cond_broadcast(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->Ptr;
int have_waiter;
if (cond_broadcast) {
cond_broadcast(cond);
- return;
+ return 0;
}
/* non native condition variables */
@@ -236,6 +244,7 @@ static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
} else
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
+ return 0;
}
static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
@@ -270,13 +279,13 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu
return pthread_mutex_lock(mutex);
}
-static av_unused void pthread_cond_signal(pthread_cond_t *cond)
+static av_unused int pthread_cond_signal(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->Ptr;
int have_waiter;
if (cond_signal) {
cond_signal(cond);
- return;
+ return 0;
}
pthread_mutex_lock(&win32_cond->mtx_broadcast);
@@ -293,6 +302,7 @@ static av_unused void pthread_cond_signal(pthread_cond_t *cond)
}
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
+ return 0;
}
#endif