From patchwork Fri Dec 11 00:15:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 555421 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 BE285140281 for ; Fri, 11 Dec 2015 11:20:40 +1100 (AEDT) Received: from localhost ([::1]:45140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7BRu-0001If-CI for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2015 19:20:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7BNe-00025O-St for qemu-devel@nongnu.org; Thu, 10 Dec 2015 19:16:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7BNb-0007if-Lk for qemu-devel@nongnu.org; Thu, 10 Dec 2015 19:16:14 -0500 Received: from domu-toccata.ens-lyon.fr ([140.77.166.138]:52807 helo=sonata.ens-lyon.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7BNb-0007hw-DG for qemu-devel@nongnu.org; Thu, 10 Dec 2015 19:16:11 -0500 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 7437E200DB; Fri, 11 Dec 2015 01:16:10 +0100 (CET) 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 hMEe3t8Q22WW; Fri, 11 Dec 2015 01:16:10 +0100 (CET) Received: from var.ipv6 (ABordeaux-655-1-21-73.w86-222.abo.wanadoo.fr [86.222.244.73]) (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 4D6A7200DD; Fri, 11 Dec 2015 01:16:09 +0100 (CET) Received: from samy by var.ipv6 with local (Exim 4.86) (envelope-from ) id 1a7BMy-00077O-G7; Fri, 11 Dec 2015 01:15:32 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Fri, 11 Dec 2015 01:15:21 +0100 Message-Id: <1449792930-27293-9-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449792930-27293-1-git-send-email-samuel.thibault@ens-lyon.org> References: <20151211001505.GV2905@var.home> <1449792930-27293-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: Thomas Huth , 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 From: Guillaume Subiron 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 d0946cb..0078e6f 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -10,6 +10,7 @@ /* timers */ +#define SCALE_S 1000000000 #define SCALE_MS 1000000 #define SCALE_US 1000 #define SCALE_NS 1 @@ -92,6 +93,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 * @@ -598,6 +613,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 *