From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUO8l-0006Sd-L1 for qemu-devel@nongnu.org; Sun, 30 Mar 2014 18:23:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUO8c-0002a2-VA for qemu-devel@nongnu.org; Sun, 30 Mar 2014 18:23:43 -0400 Received: from toccata.ens-lyon.org ([140.77.166.68]:40668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUO8c-0002Zu-OG for qemu-devel@nongnu.org; Sun, 30 Mar 2014 18:23:34 -0400 From: Samuel Thibault Date: Mon, 31 Mar 2014 00:23:00 +0200 Message-Id: <1396218189-14422-10-git-send-email-samuel.thibault@ens-lyon.org> In-Reply-To: <1396218189-14422-1-git-send-email-samuel.thibault@ens-lyon.org> References: <1396218189-14422-1-git-send-email-samuel.thibault@ens-lyon.org> Subject: [Qemu-devel] [PATCH 09/18] qemu/timer.h : Adding function to second scale List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Jan Kiszka , Samuel Thibault , 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 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 * -- 1.9.0