From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MT2iJ-0007v7-A0 for qemu-devel@nongnu.org; Mon, 20 Jul 2009 19:56:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MT2iE-0007tu-LV for qemu-devel@nongnu.org; Mon, 20 Jul 2009 19:56:10 -0400 Received: from [199.232.76.173] (port=40259 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MT2iE-0007tr-Dy for qemu-devel@nongnu.org; Mon, 20 Jul 2009 19:56:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:39645) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MT2iD-0008OO-UT for qemu-devel@nongnu.org; Mon, 20 Jul 2009 19:56:06 -0400 Date: Mon, 20 Jul 2009 20:52:47 -0300 From: Marcelo Tosatti Message-ID: <20090720235246.GA15189@amt.cnet> References: <385029.79398.qm@web30605.mail.mud.yahoo.com> <8A1471B6F57949CE81CD32AA843C1E14@FSCPC> <20090720160729.GA9738@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] Re: Threads and win32 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sebastian Herbszt Cc: Anthony Liguori , qemu-devel@nongnu.org, Teemu =?iso-8859-1?Q?N=E4tkinniemi?= On Mon, Jul 20, 2009 at 09:09:47PM +0200, Sebastian Herbszt wrote: > 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(). Sweet. Have you tested it? Do the signal warnings make any sense?? > > 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);