[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/16] qemu/timer.h : Adding function to second scal
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PATCH 03/16] qemu/timer.h : Adding function to second scale |
Date: |
Sun, 17 Nov 2013 16:04:35 +0100 |
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 <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
include/qemu/timer.h | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 5afcffc..7376c0a 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.8.4.2
- [Qemu-devel] [PATCHv2 00/16] slirp: Adding IPv6 support to Qemu -net user mode, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 02/16] slirp: Generalizing and neutralizing code before adding IPv6 stuff, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 03/16] qemu/timer.h : Adding function to second scale,
Samuel Thibault <=
- [Qemu-devel] [PATCH 09/16] slirp: Make udp_attach IPv6 compatible, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 06/16] slirp: Make Socket structure IPv6 compatible, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 08/16] slirp: Factorizing and cleaning solookup(), Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 04/16] slirp: Adding IPv6, ICMPv6 Echo and NDP autoconfiguration, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 01/16] slirp: goto bad in udp_input if sosendto fails, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 07/16] slirp: Factorizing address translation, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 10/16] slirp: Adding IPv6 UDP support, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 15/16] slirp: Adding IPv6 address for DNS relay, Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 11/16] slirp: Adding family argument to tcp_fconnect(), Samuel Thibault, 2013/11/17
- [Qemu-devel] [PATCH 12/16] slirp: Factorizing tcpiphdr structure with an union, Samuel Thibault, 2013/11/17