From patchwork Fri Apr 5 00:37:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 234009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 397352C00A4 for ; Fri, 5 Apr 2013 11:38:45 +1100 (EST) Received: from localhost ([::1]:36290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNufz-0001Ko-6F for incoming@patchwork.ozlabs.org; Thu, 04 Apr 2013 20:38:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNufa-0001KM-TF for qemu-devel@nongnu.org; Thu, 04 Apr 2013 20:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UNufV-0000vf-WE for qemu-devel@nongnu.org; Thu, 04 Apr 2013 20:38:18 -0400 Received: from speedy.comstyle.com ([2001:470:1d:8c::2]:3717 helo=mail.comstyle.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNufV-0000tC-Rw for qemu-devel@nongnu.org; Thu, 04 Apr 2013 20:38:13 -0400 Received: from rox.home.comstyle.com (unknown [IPv6:2001:470:b01e:3:9cf8:c543:f1e9:d4d]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: brad) by mail.comstyle.com (Postfix) with ESMTPSA id 1A9033FED9 for ; Thu, 4 Apr 2013 20:37:55 -0400 (EDT) Date: Thu, 4 Apr 2013 20:37:53 -0400 From: Brad Smith To: qemu-devel@nongnu.org Message-ID: <20130405003748.GH884@rox.home.comstyle.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-comstyle-MailScanner-Information: Please contact the ISP for more information X-comstyle-MailScanner-ID: 1A9033FED9.A90C5 X-comstyle-MailScanner: Found to be clean X-comstyle-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not cached, score=-2.9, required 6, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90) X-comstyle-MailScanner-From: brad@comstyle.com X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:1d:8c::2 Subject: [Qemu-devel] [PATCH] Allow clock_gettime() monotonic clock to be utilized on more OS's X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Allow the clock_gettime() code using monotonic clock to be utilized on more POSIX compliannt OS's. This started as a fix for OpenBSD which was listed in one function as part of the previous hard coded list of OS's for the functions to support but not in the other. Signed-off-by: Brad Smith Reviewed-by: Paolo Bonzini diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 1766b2d..c363190 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -117,8 +117,7 @@ extern int use_rt_clock; static inline int64_t get_clock(void) { -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ - || defined(__DragonFly__) || defined(__FreeBSD_kernel__) +#ifdef CLOCK_MONOTONIC if (use_rt_clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c index 16f5e75..95e0847 100644 --- a/util/qemu-timer-common.c +++ b/util/qemu-timer-common.c @@ -49,9 +49,7 @@ int use_rt_clock; static void __attribute__((constructor)) init_get_clock(void) { use_rt_clock = 0; -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ - || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \ - || defined(__OpenBSD__) +#ifdef CLOCK_MONOTONIC { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {