From patchwork Tue Jul 28 22:57:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 501500 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 F0B39140E31 for ; Wed, 29 Jul 2015 08:58:16 +1000 (AEST) Received: from localhost ([::1]:60930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKDp8-0000ON-Un for incoming@patchwork.ozlabs.org; Tue, 28 Jul 2015 18:58:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKDoT-0007W3-O4 for qemu-devel@nongnu.org; Tue, 28 Jul 2015 18:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKDoQ-0007Hh-Hi for qemu-devel@nongnu.org; Tue, 28 Jul 2015 18:57:33 -0400 Received: from sonata.ens-lyon.org ([140.77.166.138]:59320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKDoQ-0007Fd-CA for qemu-devel@nongnu.org; Tue, 28 Jul 2015 18:57:30 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 023332009D; Wed, 29 Jul 2015 00:57:30 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jz1YlEaD3KfR; Wed, 29 Jul 2015 00:57:29 +0200 (CEST) Received: from type.youpi.perso.aquilenet.fr (ABordeaux-652-1-60-186.w92-146.abo.wanadoo.fr [92.146.211.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 56A5A200BC; Wed, 29 Jul 2015 00:57:29 +0200 (CEST) Received: from samy by type.youpi.perso.aquilenet.fr with local (Exim 4.86_RC5) (envelope-from ) id 1ZKDoO-00033X-9y; Wed, 29 Jul 2015 00:57:28 +0200 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Wed, 29 Jul 2015 00:57:16 +0200 Message-Id: <1438124245-11667-9-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1438124245-11667-1-git-send-email-samuel.thibault@ens-lyon.org> References: <20150728225701.GK3467@type.home> <1438124245-11667-1-git-send-email-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 140.77.166.138 Cc: zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , Dave Gilbert , Vasiliy Tolstov , Huangpeng , Gonglei , Jan Kiszka , Samuel Thibault , Yang Hongyang , Guillaume Subiron Subject: [Qemu-devel] [PATCH 09/18] 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 5923d60..9530824 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -9,6 +9,7 @@ /* timers */ +#define SCALE_S 1000000000 #define SCALE_MS 1000000 #define SCALE_US 1000 #define SCALE_NS 1 @@ -91,6 +92,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 * @@ -597,6 +612,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_deinit: * @ts: the timer to be de-initialised *