[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: Threads and win32
From: |
Sebastian Herbszt |
Subject: |
[Qemu-devel] Re: Threads and win32 |
Date: |
Mon, 20 Jul 2009 21:09:47 +0200 |
Marcelo Tosatti wrote:
On Sun, Jul 19, 2009 at 02:11:09PM +0200, Sebastian Herbszt wrote:
Marcelo, can gettimeofday be used instead of clock_gettime?
Sure, gettimeofday instead of clock_gettime is fine.
If clock_gettime() is replaced by gettimeofday() qemu-thread.c does compile on
MinGW if
also the pthread_equal patch [1] is applied. Unfortunatelly there is a ton of
compile errors
in vl.c due to incomplete signal support (?).
[1] http://lists.gnu.org/archive/html/qemu-devel/2009-07/msg01514.html
- Sebastian
[PATCH] qemu-thread: replace clock_gettime() by gettimeofday()
Replace clock_gettime() which is not available on MinGW by gettimeofday().
Signed-off-by: Sebastian Herbszt <address@hidden>
--- qemu-c62bb/qemu-thread.c.orig Mon Jul 20 18:38:24 2009
+++ qemu-c62bb/qemu-thread.c Mon Jul 20 18:53:53 2009
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <errno.h>
#include <time.h>
+#include <sys/time.h>
#include <signal.h>
#include <stdint.h>
#include <string.h>
@@ -62,8 +63,11 @@ int qemu_mutex_timedlock(QemuMutex *mute
{
int err;
struct timespec ts;
+ struct timeval now;
- clock_gettime(CLOCK_REALTIME, &ts);
+ gettimeofday(&now, NULL);
+ ts.tv_sec = now.tv_sec;
+ ts.tv_nsec = now.tv_usec * 1000;
timespec_add_ms(&ts, msecs);
err = pthread_mutex_timedlock(&mutex->lock, &ts);
@@ -120,9 +124,12 @@ void qemu_cond_wait(QemuCond *cond, Qemu
int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs)
{
struct timespec ts;
+ struct timeval now;
int err;
- clock_gettime(CLOCK_REALTIME, &ts);
+ gettimeofday(&now, NULL);
+ ts.tv_sec = now.tv_sec;
+ ts.tv_nsec = now.tv_usec * 1000;
timespec_add_ms(&ts, msecs);
err = pthread_cond_timedwait(&cond->cond, &mutex->lock, &ts);