Skip to contentSkip to conversation

qemu-thread-posix: Fix build for OpenBSD

RFC PATCH In review Andreas Färber 4 participants 7 messages Jan 18, 2013 – Jan 19, 2013

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 qemu-thread-posix: Fix build for OpenBSD

Avoid an undefined reference to sem_timedwait.

---
 include/qemu/thread-posix.h |    2 +-
 util/qemu-thread-posix.c    |   10 +++++-----

2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

include/qemu/thread-posix.h +1 -1
index 0f30dcc..772d925 100644
@@ -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;
util/qemu-thread-posix.c +5 -5
index 4489abf..fa8a3d8 100644
@@ -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) {
Signature · 1 line
1.7.10.4
#1 lore raw

Il 18/01/2013 16:58, Andreas Färber ha scritto:

Quoted 63 lines

Avoid an undefined reference to sem_timedwait.

---
 include/qemu/thread-posix.h |    2 +-
 util/qemu-thread-posix.c    |   10 +++++-----

2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

include/qemu/thread-posix.h +1 -1
index 0f30dcc..772d925 100644
@@ -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;
util/qemu-thread-posix.c +4 -4
index 4489abf..fa8a3d8 100644
@@ -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;

util/qemu-thread-posix.c int qemu_sem_timedwait(QemuSemaphore *sem, int ms) · line 255

Quoted 8 lines
util/qemu-thread-posix.c +1 -1
@@ -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...

Paolo

#2 lore raw

Am 18.01.2013 17:05, schrieb Paolo Bonzini:

Quoted 64 lines

Il 18/01/2013 16:58, Andreas Färber ha scritto:

Quoted 63 lines

Avoid an undefined reference to sem_timedwait.

---
 include/qemu/thread-posix.h |    2 +-
 util/qemu-thread-posix.c    |   10 +++++-----

2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

include/qemu/thread-posix.h +1 -1
index 0f30dcc..772d925 100644
@@ -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;
util/qemu-thread-posix.c +4 -4
index 4489abf..fa8a3d8 100644
@@ -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)
 
Quoted 11 lines

util/qemu-thread-posix.c int qemu_sem_timedwait(QemuSemaphore *sem, int ms) · line 255

Quoted 8 lines
util/qemu-thread-posix.c +1 -1
 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.

Andreas

#3 lore raw

Il 18/01/2013 17:07, Andreas Färber ha scritto:

Quoted 77 lines

Am 18.01.2013 17:05, schrieb Paolo Bonzini:

Quoted 64 lines

Il 18/01/2013 16:58, Andreas Färber ha scritto:

Quoted 63 lines

Avoid an undefined reference to sem_timedwait.

---
 include/qemu/thread-posix.h |    2 +-
 util/qemu-thread-posix.c    |   10 +++++-----

2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

include/qemu/thread-posix.h +1 -1
index 0f30dcc..772d925 100644
@@ -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;
util/qemu-thread-posix.c +4 -4
index 4489abf..fa8a3d8 100644
@@ -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)
 
Quoted 11 lines

util/qemu-thread-posix.c int qemu_sem_timedwait(QemuSemaphore *sem, int ms) · line 255

Quoted 8 lines
util/qemu-thread-posix.c +1 -1
 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...

Quoted 1 line

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

#4 lore raw
Quoted 78 lines · Paolo Bonzini

Il 18/01/2013 17:07, Andreas Färber ha scritto:

Quoted 77 lines

Am 18.01.2013 17:05, schrieb Paolo Bonzini:

Quoted 75 lines

Il 18/01/2013 16:58, Andreas Färber ha scritto:

Quoted 63 lines

Avoid an undefined reference to sem_timedwait.

---
 include/qemu/thread-posix.h |    2 +-
 util/qemu-thread-posix.c    |   10 +++++-----

2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

include/qemu/thread-posix.h +1 -1
index 0f30dcc..772d925 100644
@@ -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;
util/qemu-thread-posix.c +4 -4
index 4489abf..fa8a3d8 100644
@@ -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;

util/qemu-thread-posix.c int qemu_sem_timedwait(QemuSemaphore *sem, int ms) · line 255

Quoted 8 lines
util/qemu-thread-posix.c +1 -1
@@ -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...

Quoted 5 lines
Quoted 1 line

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/

Brad, please correct me if I'm wrong, but I don't think OpenBSD supports the previous releases, only the last release (5.2 was released in November, 2012), -stable and -current:
http://www.openbsd.org/stable.html
http://www.openbsd.org/errata52.html

This is a different approach to for example Ubuntu LTS, Debian stable or RHEL.

Quoted 6 lines

Paolo

Paolo

#5 lore raw

Am 19.01.2013 10:44, schrieb Blue Swirl:

Quoted 25 lines · Paolo Bonzini
Quoted 24 lines

Il 18/01/2013 17:07, Andreas Färber ha scritto:

Quoted 23 lines

Am 18.01.2013 17:05, schrieb Paolo Bonzini:

Quoted 22 lines

Il 18/01/2013 16:58, Andreas Färber ha scritto:

Quoted 21 lines

Avoid an undefined reference to sem_timedwait.

---
 include/qemu/thread-posix.h |    2 +-
 util/qemu-thread-posix.c    |   10 +++++-----

2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

include/qemu/thread-posix.h +1 -1
index 0f30dcc..772d925 100644
@@ -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;

[...]

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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/

Quoted 5 lines

Brad, please correct me if I'm wrong, but I don't think OpenBSD supports the previous releases, only the last release (5.2 was released in November, 2012), -stable and -current:
http://www.openbsd.org/stable.html
http://www.openbsd.org/errata52.html

Forgot to reply: I upgraded to 5.2 yesterday and that did fix this issue for me! Please drop this patch. I just need *some* working BSD system to test bsd-user with my upcoming CPU changes.

Andreas

Quoted 9 lines

This is a different approach to for example Ubuntu LTS, Debian stable or RHEL.

Quoted 6 lines

Paolo

Paolo

#6 lore raw
In reply to Paolo Bonzini
Quoted 5 lines · Paolo Bonzini

Il 18/01/2013 16:58, Andreas Färber ha scritto:

Quoted 1 line

Avoid an undefined reference to sem_timedwait.

This was reverted recently. Apparently your OpenBSD is too old compared to what Brad wants to support...

I suggest getting rid of all the os ifdefs and writing a configure check for sem_timedwait(). Then we use the fallback code on exactly the systems where we need to and we don't have to start wondering about which versions of which BSDs introduced the feature.

-- PMM