From patchwork Tue Feb 11 13:08:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 319271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8C2FB2C00B0 for ; Wed, 12 Feb 2014 00:09:16 +1100 (EST) Received: from localhost ([::1]:33470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDD5I-0006hq-Rk for incoming@patchwork.ozlabs.org; Tue, 11 Feb 2014 08:09:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDD4e-0006fM-OI for qemu-devel@nongnu.org; Tue, 11 Feb 2014 08:08:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDD4Z-0000xC-C0 for qemu-devel@nongnu.org; Tue, 11 Feb 2014 08:08:28 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:46006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDD4Z-0000x3-5S for qemu-devel@nongnu.org; Tue, 11 Feb 2014 08:08:23 -0500 X-IronPort-AV: E=Sophos;i="4.95,825,1384297200"; d="scan'208";a="48626201" Received: from unknown (HELO type.ipv6) ([193.50.110.152]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 11 Feb 2014 14:08:21 +0100 Received: from samy by type.ipv6 with local (Exim 4.82) (envelope-from ) id 1WDD4X-0002ma-Bt; Tue, 11 Feb 2014 14:08:21 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Tue, 11 Feb 2014 14:08:04 +0100 Message-Id: <1392124097-10618-4-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1392124097-10618-1-git-send-email-samuel.thibault@ens-lyon.org> References: <1384700688-30377-1-git-send-email-samuel.thibault@ens-lyon.org> <1392124097-10618-1-git-send-email-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.104 Cc: Jan Kiszka , Samuel Thibault , Guillaume Subiron Subject: [Qemu-devel] [PATCH 03/16] qemu/timer.h : Adding function to second scale 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 This patch adds SCALE_S, timer_new_s(), and qemu_clock_get_s in qemu/timer.h to manage second-scale timers. Signed-off-by: Guillaume Subiron Signed-off-by: Samuel Thibault --- include/qemu/timer.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 7f9a074..b46601c 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -7,6 +7,7 @@ /* timers */ +#define SCALE_S 1000000000 #define SCALE_MS 1000000 #define SCALE_US 1000 #define SCALE_NS 1 @@ -81,6 +82,20 @@ extern QEMUTimerListGroup main_loop_tlg; int64_t qemu_clock_get_ns(QEMUClockType type); /** + * qemu_clock_get_s; + * @type: the clock type + * + * Get the second value of a clock with + * type @type + * + * Returns: the clock value in seconds + */ +static inline int64_t qemu_clock_get_s(QEMUClockType type) +{ + return qemu_clock_get_ns(type) / SCALE_S; +} + +/** * qemu_clock_get_ms; * @type: the clock type * @@ -514,6 +529,23 @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb, } /** + * timer_new_s: + * @clock: the clock to associate with the timer + * @callback: the callback to call when the timer expires + * @opaque: the opaque pointer to pass to the callback + * + * Create a new timer with second scale on the default timer list + * associated with the clock. + * + * Returns: a pointer to the newly created timer + */ +static inline QEMUTimer *timer_new_s(QEMUClockType type, QEMUTimerCB *cb, + void *opaque) +{ + return timer_new(type, SCALE_S, cb, opaque); +} + +/** * timer_free: * @ts: the timer *