void qemu_sem_wait(QemuSemaphore *sem)

{

#if defined(__APPLE__) || defined(__NetBSD__)

    pthread_mutex_lock(&sem->lock);

    --sem->count;

    while (sem->count < 0) {

        pthread_cond_wait(&sem->cond, &sem->lock);

    }

    pthread_mutex_unlock(&sem->lock);

#else

    int rc;



    do {

        rc = sem_wait(&sem->sem);

    } while (rc == -1 && errno == EINTR);

    if (rc < 0) {

        error_exit(errno, __func__);

    }

#endif

}

void qemu_sem_wait(QemuSemaphore *sem)

{

#if defined(__APPLE__) || defined(__NetBSD__)

    pthread_mutex_lock(&sem->lock);

    --sem->count;

    while (sem->count < 0) {

        pthread_cond_wait(&sem->cond, &sem->lock);

    }

    pthread_mutex_unlock(&sem->lock);

#else

    int rc;



    do {

        rc = sem_wait(&sem->sem);

    } while (rc == -1 && errno == EINTR);

    if (rc < 0) {

        error_exit(errno, __func__);

    }

#endif

}

    --sem->count;     while (sem->count < 0) {     --sem->count;     while (sem->count < 0) {         pthread_cond_wait(&sem->cond, &sem->lock);     int rc;
void FUNC_0(QemuSemaphore *VAR_0)

{

#if defined(__APPLE__) || defined(__NetBSD__)

    pthread_mutex_lock(&VAR_0->lock);

    --VAR_0->count;

    while (VAR_0->count < 0) {

        pthread_cond_wait(&VAR_0->cond, &VAR_0->lock);

    }

    pthread_mutex_unlock(&VAR_0->lock);

#else

    int rc;



    do {

        rc = sem_wait(&VAR_0->VAR_0);

    } while (rc == -1 && errno == EINTR);

    if (rc < 0) {

        error_exit(errno, __func__);

    }

#endif

}

void FUNC_0(QemuSemaphore *VAR_0)
{ #if defined(__APPLE__) || defined(__NetBSD__)
pthread_mutex_lock(&VAR_0->lock); --VAR_0->count; while (VAR_0->count < 0) { pthread_cond_wait(&VAR_0->cond, &VAR_0->lock); } pthread_mutex_unlock(&VAR_0->lock); #else
int rc; do { rc = sem_wait(&VAR_0->VAR_0); } while (rc == -1 && errno == EINTR); if (rc < 0) { error_exit(errno, __func__); } #endif
}