From 8638eb91c78cd773b59636bc40642a0ae0e55409 Mon Sep 17 00:00:00 2001 From: Martin Mathieson Date: Wed, 3 May 2017 22:56:55 +0100 Subject: Add g_get_monotonic_time() to glib-compat and use Change-Id: If41dab19692516270e8b4bcf1a8a954bb8dc3ccc Reviewed-on: https://code.wireshark.org/review/21480 Petri-Dish: Martin Mathieson Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- wsutil/glib-compat.c | 14 ++++++++++++++ wsutil/glib-compat.h | 1 + 2 files changed, 15 insertions(+) (limited to 'wsutil') diff --git a/wsutil/glib-compat.c b/wsutil/glib-compat.c index 5d3cec8374..8acc520b49 100644 --- a/wsutil/glib-compat.c +++ b/wsutil/glib-compat.c @@ -62,6 +62,20 @@ g_list_free_full(GList *list, g_list_free(list); } +/** +* g_get_monotonic_time: +* +* Queries the system monotonic time. Returns value in microseconds. +* +* Since: 2.28 +*/ +gint64 g_get_monotonic_time (void) +{ + GTimeVal result; + g_get_current_time(&result); + return result.tv_sec*1000000 + result.tv_usec; +} + #endif /* * Editor modelines - http://www.wireshark.org/tools/modelines.html diff --git a/wsutil/glib-compat.h b/wsutil/glib-compat.h index 378a020b0d..adaa630f8e 100644 --- a/wsutil/glib-compat.h +++ b/wsutil/glib-compat.h @@ -27,6 +27,7 @@ #if !GLIB_CHECK_VERSION(2, 28, 0) WS_DLL_PUBLIC void g_slist_free_full(GSList *list, GDestroyNotify free_func); WS_DLL_PUBLIC void g_list_free_full(GList *list, GDestroyNotify free_func); +WS_DLL_PUBLIC gint64 g_get_monotonic_time (void); #endif #endif /* GLIB_COMPAT_H */ -- cgit v1.2.1