summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2014-02-21 10:20:11 -0500
committerRyan Lortie <desrt@desrt.ca>2014-02-21 16:42:21 -0500
commit03a43c290e470c67015d01237c5d81ea81a7b129 (patch)
tree26176095bfb8018d6893fe66bb31e56cd289ab3a /glib
parent6fcaa7aa96fc4b274a4358f2cec3a4075568d343 (diff)
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
Diffstat (limited to 'glib')
-rw-r--r--glib/gmain.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/glib/gmain.c b/glib/gmain.c
index e74590a86..dbbc63de7 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);
}