diff options
author | wm4 <wm4@nowhere> | 2015-01-01 15:10:42 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-01 15:10:42 +0100 |
commit | bafb9b22715313ef0049630228a744d7f2c9363b (patch) | |
tree | a1bd25023be5840467291dbe9876dd7c30bc2034 /osdep/win32/include/semaphore.h | |
parent | 64b6b2ea458f679ec0370878b1e54b2b1822c4b1 (diff) | |
download | mpv-bafb9b22715313ef0049630228a744d7f2c9363b.tar.bz2 mpv-bafb9b22715313ef0049630228a744d7f2c9363b.tar.xz |
win32: add native wrappers for pthread functions
Off by default, use --enable-win32-internal-pthreads .
This probably still needs a lot more testing. It also won't work on
Windows XP.
Diffstat (limited to 'osdep/win32/include/semaphore.h')
-rw-r--r-- | osdep/win32/include/semaphore.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/osdep/win32/include/semaphore.h b/osdep/win32/include/semaphore.h new file mode 100644 index 0000000000..49670fc7a5 --- /dev/null +++ b/osdep/win32/include/semaphore.h @@ -0,0 +1,29 @@ +#ifndef MP_WRAP_SEMAPHORE_H_ +#define MP_WRAP_SEMAPHORE_H_ + +#include <pthread.h> + +// See pthread.h for rationale. +#define sem_init m_sem_init +#define sem_destroy m_sem_destroy +#define sem_wait m_sem_wait +#define sem_trywait m_sem_trywait +#define sem_timedwait m_sem_timedwait +#define sem_post m_sem_post + +#define SEM_VALUE_MAX 100 + +typedef struct { + pthread_mutex_t lock; + pthread_cond_t wakeup; + unsigned int value; +} sem_t; + +int sem_init(sem_t *sem, int pshared, unsigned int value); +int sem_destroy(sem_t *sem); +int sem_wait(sem_t *sem); +int sem_trywait(sem_t *sem); +int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout); +int sem_post(sem_t *sem); + +#endif |