From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33894 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzUmS-0002zS-MH for qemu-devel@nongnu.org; Tue, 15 Mar 2011 09:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzUmR-0008Qk-EU for qemu-devel@nongnu.org; Tue, 15 Mar 2011 09:59:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzUmR-0008Q0-5t for qemu-devel@nongnu.org; Tue, 15 Mar 2011 09:59:23 -0400 Message-ID: <4D7F709F.8080204@redhat.com> Date: Tue, 15 Mar 2011 14:58:55 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1300195001-51765-1-git-send-email-gingold@adacore.com> <4D7F6AE3.7020301@redhat.com> <1DE9D55B-9D5D-4A58-8BA5-0D32DF4A9E05@adacore.com> In-Reply-To: <1DE9D55B-9D5D-4A58-8BA5-0D32DF4A9E05@adacore.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Autodetect clock_gettime List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tristan Gingold Cc: qemu-devel@nongnu.org On 03/15/2011 02:47 PM, Tristan Gingold wrote: > > On Mar 15, 2011, at 2:34 PM, Paolo Bonzini wrote: > >> On 03/15/2011 02:16 PM, Tristan Gingold wrote: >>> Some POSIX OSes (such as Darwin) doesn't have clock_gettime. This patch >>> falls back on gettimeofday if clock_gettime is not available. >> >> This may be okay as a stopgap measure, but any sane porting target for QEMU should have a monotonic clock. In fact, Darwin has it. > > Yes mach primitives could be used. But why isn't a monotonic clock used on Linux ? According to man, CLOCK_MONOTONIC is monotonic > while CLOCK_REALTIME isn't. /me rereads the patch Unfortunately, pthread timed wait/lock functions are documented to use the realtime clock by default. Using pthread_condattr_setclock is probably not portable enough, and anyway there is no such function for mutexes so we're stuck with CLOCK_REALTIME. What you're patching is fine, but those functions might actually go away soon as they're not supported on Win32. So, in addition to what you've done, you should probably use those Mach primitives in qemu-timer.h. Paolo