[glib] Add g_get_real_time() for wall-clock int64 micros
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add g_get_real_time() for wall-clock int64 micros
- Date: Wed, 3 Nov 2010 02:40:08 +0000 (UTC)
commit 5dab4727ee604d3a7a2be3aa7dde739b71d7f5df
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Nov 1 16:40:36 2010 -0400
Add g_get_real_time() for wall-clock int64 micros
Similar in spirit to g_get_monotonic_time().
docs/reference/glib/glib-sections.txt | 1 +
glib/glib.symbols | 1 +
glib/gmain.c | 31 ++++++++++++++++++++++++++++++-
glib/gmain.h | 1 +
4 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 113d595..d2f7422 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1322,6 +1322,7 @@ g_time_val_to_iso8601
<SUBSECTION>
g_get_monotonic_time
+g_get_real_time
<SUBSECTION>
GDate
diff --git a/glib/glib.symbols b/glib/glib.symbols
index b421788..232e12a 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -685,6 +685,7 @@ g_child_watch_add_full
g_child_watch_source_new
g_get_current_time
g_get_monotonic_time
+g_get_real_time
g_main_context_acquire
g_main_context_add_poll
g_main_context_check
diff --git a/glib/gmain.c b/glib/gmain.c
index 9468e68..1b84dd8 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -1777,8 +1777,10 @@ g_source_remove_by_funcs_user_data (GSourceFuncs *funcs,
/**
* g_get_current_time:
* @result: #GTimeVal structure in which to store current time.
- *
+ *
* Equivalent to the UNIX gettimeofday() function, but portable.
+ *
+ * You may find g_get_real_time() to be more convenient.
**/
void
g_get_current_time (GTimeVal *result)
@@ -1814,6 +1816,33 @@ g_get_current_time (GTimeVal *result)
}
/**
+ * g_get_real_time:
+ *
+ * Queries the system wall-clock time.
+ *
+ * This call is functionally equivalent to g_get_current_time() except
+ * that the return value is often more convenient than dealing with a
+ * #GTimeVal.
+ *
+ * You should only use this call if you are actually interested in the real
+ * wall-clock time. g_get_monotonic_time() is probably more useful for
+ * measuring intervals.
+ *
+ * Returns: the number of microseconds since January 1, 1970 UTC.
+ *
+ * Since: 2.28
+ **/
+gint64
+g_get_real_time (void)
+{
+ GTimeVal tv;
+
+ g_get_current_time (&tv);
+
+ return (((gint64) tv.tv_sec) * 1000000) + tv.tv_usec;
+}
+
+/**
* g_get_monotonic_time:
*
* Queries the system monotonic time, if available.
diff --git a/glib/gmain.h b/glib/gmain.h
index c87a762..3a7bba0 100644
--- a/glib/gmain.h
+++ b/glib/gmain.h
@@ -384,6 +384,7 @@ GSource *g_timeout_source_new_seconds (guint interval);
*/
void g_get_current_time (GTimeVal *result);
gint64 g_get_monotonic_time (void);
+gint64 g_get_real_time (void);
/* ============== Compat main loop stuff ================== */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]