From 64cee5537d293bad92e1a1567aecaa5ea8efdbc3 Mon Sep 17 00:00:00 2001 From: Tom M Date: Tue, 22 Oct 2019 17:39:08 +0200 Subject: [PATCH] Handle deprecation of GTimeVal (#575) `GTimeVal` has been deprecated in glib 2.62 . While switching to `g_get_monotonic_time()`, I realized that we could simply reuse `fluid_utime()` for that purpose. --- src/utils/fluid_sys.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index 1d28802a..2248f16a 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -313,22 +313,21 @@ void fluid_msleep(unsigned int msecs) /** * Get time in milliseconds to be used in relative timing operations. - * @return Unix time in milliseconds. + * @return Monotonic time in milliseconds. */ unsigned int fluid_curtime(void) { - static glong initial_seconds = 0; - GTimeVal timeval; + float now; + static float initial_time = 0; - if(initial_seconds == 0) + if(initial_time == 0) { - g_get_current_time(&timeval); - initial_seconds = timeval.tv_sec; + initial_time = (float)fluid_utime(); } - g_get_current_time(&timeval); + now = (float)fluid_utime(); - return (unsigned int)((timeval.tv_sec - initial_seconds) * 1000.0 + timeval.tv_usec / 1000.0); + return (unsigned int)((now - initial_time) / 1000.0f); } /**