[glib] gmain: abort if monotonic time is unsupported



commit 03a43c290e470c67015d01237c5d81ea81a7b129
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Feb 21 10:20:11 2014 -0500

    gmain: abort if monotonic time is unsupported
    
    We now depend on CLOCK_MONOTONIC, but it's possible that people may
    attempt to run GLib on systems where it isn't supported at runtime.
    
    Check the return value of clock_gettime() and abort() if it fails in
    order to save these people from wasting time on debugging a tricky
    issue.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670144

 glib/gmain.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index e74590a..dbbc63d 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -2715,8 +2715,12 @@ gint64
 g_get_monotonic_time (void)
 {
   struct timespec ts;
+  gint result;
 
-  clock_gettime (CLOCK_MONOTONIC, &ts);
+  result = clock_gettime (CLOCK_MONOTONIC, &ts);
+
+  if G_UNLIKELY (result != 0)
+    g_error ("GLib requires working CLOCK_MONOTONIC");
 
   return (((gint64) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]