From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MSyGT-0002YI-Uy for qemu-devel@nongnu.org; Mon, 20 Jul 2009 15:11:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MSyGP-0002Po-5s for qemu-devel@nongnu.org; Mon, 20 Jul 2009 15:11:09 -0400 Received: from [199.232.76.173] (port=50239 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSyGO-0002PY-Vn for qemu-devel@nongnu.org; Mon, 20 Jul 2009 15:11:05 -0400 Received: from mail.gmx.net ([213.165.64.20]:39696) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1MSyGO-0006Ht-DO for qemu-devel@nongnu.org; Mon, 20 Jul 2009 15:11:04 -0400 Message-ID: From: "Sebastian Herbszt" References: <385029.79398.qm@web30605.mail.mud.yahoo.com> <8A1471B6F57949CE81CD32AA843C1E14@FSCPC> <20090720160729.GA9738@amt.cnet> In-Reply-To: <20090720160729.GA9738@amt.cnet> Date: Mon, 20 Jul 2009 21:09:47 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: Threads and win32 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: Anthony Liguori , qemu-devel@nongnu.org, =?iso-8859-1?Q?Teemu_N=E4tkinniemi?= 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 --- 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 #include #include +#include #include #include #include @@ -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);