Skip to content

Commit

Permalink
Disable semaphores fallback code for OpenBSD
Browse files Browse the repository at this point in the history
Disable the semaphores fallback code for OpenBSD as modern OpenBSD
releases now have sem_timedwait().

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
  • Loading branch information
brad0 authored and blueswirl committed Dec 28, 2012
1 parent 62054c0 commit 927fa90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/qemu/thread-posix.h
Expand Up @@ -12,7 +12,7 @@ struct QemuCond {
};

struct QemuSemaphore {
#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__NetBSD__)
pthread_mutex_t lock;
pthread_cond_t cond;
int count;
Expand Down
10 changes: 5 additions & 5 deletions qemu-thread-posix.c
Expand Up @@ -122,7 +122,7 @@ void qemu_sem_init(QemuSemaphore *sem, int init)
{
int rc;

#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__NetBSD__)
rc = pthread_mutex_init(&sem->lock, NULL);
if (rc != 0) {
error_exit(rc, __func__);
Expand All @@ -147,7 +147,7 @@ void qemu_sem_destroy(QemuSemaphore *sem)
{
int rc;

#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__NetBSD__)
rc = pthread_cond_destroy(&sem->cond);
if (rc < 0) {
error_exit(rc, __func__);
Expand All @@ -168,7 +168,7 @@ void qemu_sem_post(QemuSemaphore *sem)
{
int rc;

#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__NetBSD__)
pthread_mutex_lock(&sem->lock);
if (sem->count == INT_MAX) {
rc = EINVAL;
Expand Down Expand Up @@ -206,7 +206,7 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
int rc;
struct timespec ts;

#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__NetBSD__)
compute_abs_deadline(&ts, ms);
pthread_mutex_lock(&sem->lock);
--sem->count;
Expand Down Expand Up @@ -248,7 +248,7 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)

void qemu_sem_wait(QemuSemaphore *sem)
{
#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__NetBSD__)
pthread_mutex_lock(&sem->lock);
--sem->count;
while (sem->count < 0) {
Expand Down

0 comments on commit 927fa90

Please sign in to comment.