diff options
| author | Stefan Hajnoczi | 2014-10-15 14:29:30 +0200 |
|---|---|---|
| committer | Peter Maydell | 2014-10-15 14:43:35 +0200 |
| commit | 89b516d8b9444ece8ccabb322a9389587c7a7b83 (patch) | |
| tree | 8b0c3c1356d83914dfbf2bbd666a720596b87d20 /include | |
| parent | Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20141015' i... (diff) | |
| download | qemu-89b516d8b9444ece8ccabb322a9389587c7a7b83.tar.gz qemu-89b516d8b9444ece8ccabb322a9389587c7a7b83.tar.xz qemu-89b516d8b9444ece8ccabb322a9389587c7a7b83.zip | |
glib: add compatibility interface for g_get_monotonic_time()
This patch fixes compilation errors when building against glib <2.28.0
due to the missing g_get_monotonic_time() function.
The compilation error in tests/libqos/virtio.c was introduced in commit
70556264a89a268efba1d7e8e341adcdd7881eb4 ("libqos: use microseconds
instead of iterations for virtio timeout").
Add a simple g_get_monotonic_time() implementation to glib-compat.h
based on code from vhost-user-test.c.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
[Igor: add G_TIME_SPAN_SECOND, include glib-compat.h in libqtest.h]
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/glib-compat.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/glib-compat.h b/include/glib-compat.h index 4ae0671a8e..e29bf69849 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -18,6 +18,11 @@ #include <glib.h> +/* GLIB version compatibility flags */ +#if !GLIB_CHECK_VERSION(2, 26, 0) +#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000)) +#endif + #if !GLIB_CHECK_VERSION(2, 14, 0) static inline guint g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) @@ -26,6 +31,20 @@ static inline guint g_timeout_add_seconds(guint interval, GSourceFunc function, } #endif +#if !GLIB_CHECK_VERSION(2, 28, 0) +static inline gint64 g_get_monotonic_time(void) +{ + /* g_get_monotonic_time() is best-effort so we can use the wall clock as a + * fallback. + */ + + GTimeVal time; + g_get_current_time(&time); + + return time.tv_sec * G_TIME_SPAN_SECOND + time.tv_usec; +} +#endif + #ifdef _WIN32 /* * g_poll has a problem on Windows when using |
