1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 09:32:40 +00:00
mpv/osdep/win32/include/semaphore.h
wm4 bafb9b2271 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.
2015-01-01 15:10:42 +01:00

30 lines
679 B
C

#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