[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] Autodetect clock_gettime

From: Paolo Bonzini
Subject: [Qemu-devel] Re: [PATCH] Autodetect clock_gettime
Date: Tue, 15 Mar 2011 14:34:27 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

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 <mach/mach_time.h>

    uint64_t t = mach_absolute_time();
    static mach_timebase_info_data_t info;
    if (info.denom == 0) {
    return muldiv64(t, info.numer, info.denom);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]