From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53372 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzUOS-0002TK-Eh for qemu-devel@nongnu.org; Tue, 15 Mar 2011 09:34:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzUOQ-0000uq-PY for qemu-devel@nongnu.org; Tue, 15 Mar 2011 09:34:36 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:37085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzUOQ-0000uR-MN for qemu-devel@nongnu.org; Tue, 15 Mar 2011 09:34:34 -0400 Received: by ywl41 with SMTP id 41so289196ywl.4 for ; Tue, 15 Mar 2011 06:34:33 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4D7F6AE3.7020301@redhat.com> Date: Tue, 15 Mar 2011 14:34:27 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1300195001-51765-1-git-send-email-gingold@adacore.com> In-Reply-To: <1300195001-51765-1-git-send-email-gingold@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: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. http://www.wand.net.nz/~smr26/wordpress/2009/01/19/monotonic-time-in-mac-os-x/ hints that code such as the following should work and return nanoseconds: #import uint64_t t = mach_absolute_time(); static mach_timebase_info_data_t info; if (info.denom == 0) { mach_timebase_info(&info); } return muldiv64(t, info.numer, info.denom); Paolo