[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC for-1.4] qemu-thread-posix: Fix build for Op
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH RFC for-1.4] qemu-thread-posix: Fix build for OpenBSD |
Date: |
Fri, 18 Jan 2013 17:16:00 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
Il 18/01/2013 17:07, Andreas Färber ha scritto:
> Am 18.01.2013 17:05, schrieb Paolo Bonzini:
>> Il 18/01/2013 16:58, Andreas Färber ha scritto:
>>> Avoid an undefined reference to sem_timedwait.
>>>
>>> Signed-off-by: Andreas Färber <address@hidden>
>>> ---
>>> include/qemu/thread-posix.h | 2 +-
>>> util/qemu-thread-posix.c | 10 +++++-----
>>> 2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
>>>
>>> diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h
>>> index 0f30dcc..772d925 100644
>>> --- a/include/qemu/thread-posix.h
>>> +++ b/include/qemu/thread-posix.h
>>> @@ -12,7 +12,7 @@ struct QemuCond {
>>> };
>>>
>>> struct QemuSemaphore {
>>> -#if defined(__APPLE__) || defined(__NetBSD__)
>>> +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
>>> pthread_mutex_t lock;
>>> pthread_cond_t cond;
>>> int count;
>>> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
>>> index 4489abf..fa8a3d8 100644
>>> --- a/util/qemu-thread-posix.c
>>> +++ b/util/qemu-thread-posix.c
>>> @@ -122,7 +122,7 @@ void qemu_sem_init(QemuSemaphore *sem, int init)
>>> {
>>> int rc;
>>>
>>> -#if defined(__APPLE__) || defined(__NetBSD__)
>>> +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
>>> rc = pthread_mutex_init(&sem->lock, NULL);
>>> if (rc != 0) {
>>> error_exit(rc, __func__);
>>> @@ -147,7 +147,7 @@ void qemu_sem_destroy(QemuSemaphore *sem)
>>> {
>>> int rc;
>>>
>>> -#if defined(__APPLE__) || defined(__NetBSD__)
>>> +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
>>> rc = pthread_cond_destroy(&sem->cond);
>>> if (rc < 0) {
>>> error_exit(rc, __func__);
>>> @@ -168,7 +168,7 @@ void qemu_sem_post(QemuSemaphore *sem)
>>> {
>>> int rc;
>>>
>>> -#if defined(__APPLE__) || defined(__NetBSD__)
>>> +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
>>> pthread_mutex_lock(&sem->lock);
>>> if (sem->count == INT_MAX) {
>>> rc = EINVAL;
>>> @@ -206,7 +206,7 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
>>> int rc;
>>> struct timespec ts;
>>>
>>> -#if defined(__APPLE__) || defined(__NetBSD__)
>>> +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
>>> compute_abs_deadline(&ts, ms);
>>> pthread_mutex_lock(&sem->lock);
>>> --sem->count;
>>> @@ -249,7 +249,7 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
>>>
>>> void qemu_sem_wait(QemuSemaphore *sem)
>>> {
>>> -#if defined(__APPLE__) || defined(__NetBSD__)
>>> +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
>>> pthread_mutex_lock(&sem->lock);
>>> --sem->count;
>>> while (sem->count < 0) {
>>>
>>
>> This was reverted recently. Apparently your OpenBSD is too old compared
>> to what Brad wants to support...
>
> This is 5.1 from 2012.
2012 does sound a bit too recent, but then maybe not considering OpenBSD
is only now getting a decent threading library. I suggest this
approach: http://lwn.net/Articles/527216/
Paolo
Paolo