semaphore: implement fallback counting semaphores with mutex+condvar

OpenBSD and Darwin do not have sem_timedwait.  Implement a fallback
for them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Paolo Bonzini 2012-11-02 15:43:21 +01:00 committed by Anthony Liguori
parent 1f001dc7bc
commit c166cb72f1
2 changed files with 87 additions and 9 deletions

View file

@ -12,7 +12,13 @@ struct QemuCond {
};
struct QemuSemaphore {
#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
pthread_mutex_t lock;
pthread_cond_t cond;
int count;
#else
sem_t sem;
#endif
};
struct QemuThread {