On Mon, Mar 14, 2011 at 11:21 PM, François Revol <re...@free.fr> wrote:
> The OSX build has been broken for some time now...
>
> * qemu-thread-posix.c:
> both qemu_mutex_timedlock and qemu_cond_timedwait make use of clock_gettime() 
> and CLOCK_REALTIME, which OSX doesn't have.
> It seems like both functions are nowhere found. Can they be removed then ?

This patch should fix the problem.
From 8bc9b2c313bea3536ba258a16f211a8585c494f3 Mon Sep 17 00:00:00 2001
Message-Id: <8bc9b2c313bea3536ba258a16f211a8585c494f3.1300222948.git.blauwir...@gmail.com>
From: Blue Swirl <blauwir...@gmail.com>
Date: Tue, 15 Mar 2011 20:48:52 +0000
Subject: [PATCH] qemu-thread: delete unused functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

qemu_mutex_timedlock() and qemu_cond_timedwait() are no longer used.

Remove them and their helper timespec_add_ms().

Reported-by: François Revol <re...@free.fr>
Signed-off-by: Blue Swirl <blauwir...@gmail.com>
---
 qemu-thread-posix.c |   38 --------------------------------------
 qemu-thread.h       |    2 --
 2 files changed, 0 insertions(+), 40 deletions(-)

diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c
index 87c1a9f..2bd02ef 100644
--- a/qemu-thread-posix.c
+++ b/qemu-thread-posix.c
@@ -61,30 +61,6 @@ int qemu_mutex_trylock(QemuMutex *mutex)
     return pthread_mutex_trylock(&mutex->lock);
 }
 
-static void timespec_add_ms(struct timespec *ts, uint64_t msecs)
-{
-    ts->tv_sec = ts->tv_sec + (long)(msecs / 1000);
-    ts->tv_nsec = (ts->tv_nsec + ((long)msecs % 1000) * 1000000);
-    if (ts->tv_nsec >= 1000000000) {
-        ts->tv_nsec -= 1000000000;
-        ts->tv_sec++;
-    }
-}
-
-int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs)
-{
-    int err;
-    struct timespec ts;
-
-    clock_gettime(CLOCK_REALTIME, &ts);
-    timespec_add_ms(&ts, msecs);
-
-    err = pthread_mutex_timedlock(&mutex->lock, &ts);
-    if (err && err != ETIMEDOUT)
-        error_exit(err, __func__);
-    return err;
-}
-
 void qemu_mutex_unlock(QemuMutex *mutex)
 {
     int err;
@@ -139,20 +115,6 @@ void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex)
         error_exit(err, __func__);
 }
 
-int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs)
-{
-    struct timespec ts;
-    int err;
-
-    clock_gettime(CLOCK_REALTIME, &ts);
-    timespec_add_ms(&ts, msecs);
-
-    err = pthread_cond_timedwait(&cond->cond, &mutex->lock, &ts);
-    if (err && err != ETIMEDOUT)
-        error_exit(err, __func__);
-    return err;
-}
-
 void qemu_thread_create(QemuThread *thread,
                        void *(*start_routine)(void*),
                        void *arg)
diff --git a/qemu-thread.h b/qemu-thread.h
index acdb6b2..edc7ab6 100644
--- a/qemu-thread.h
+++ b/qemu-thread.h
@@ -15,7 +15,6 @@ void qemu_mutex_init(QemuMutex *mutex);
 void qemu_mutex_destroy(QemuMutex *mutex);
 void qemu_mutex_lock(QemuMutex *mutex);
 int qemu_mutex_trylock(QemuMutex *mutex);
-int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
 void qemu_mutex_unlock(QemuMutex *mutex);
 
 void qemu_cond_init(QemuCond *cond);
@@ -29,7 +28,6 @@ void qemu_cond_destroy(QemuCond *cond);
 void qemu_cond_signal(QemuCond *cond);
 void qemu_cond_broadcast(QemuCond *cond);
 void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
-int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
 
 void qemu_thread_create(QemuThread *thread,
                        void *(*start_routine)(void*),
-- 
1.7.2.3

Reply via email to