summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/misc.c11
-rw-r--r--src/core/misc.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 37e6a001..938f2a40 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -94,6 +94,17 @@ int g_input_add(int source, int condition,
function, data);
}
+int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2)
+{
+ if (tv1->tv_sec < tv2->tv_sec)
+ return -1;
+ if (tv1->tv_sec > tv2->tv_sec)
+ return 1;
+
+ return tv1->tv_usec < tv2->tv_usec ? -1 :
+ tv1->tv_usec > tv2->tv_usec ? 1 : 0;
+}
+
long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2)
{
long secs, usecs;
diff --git a/src/core/misc.h b/src/core/misc.h
index 2bcdb67c..176c7a3d 100644
--- a/src/core/misc.h
+++ b/src/core/misc.h
@@ -7,6 +7,7 @@
typedef void* (*FOREACH_FIND_FUNC) (void *item, void *data);
+int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2);
long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2);
/* find `item' from a space separated `list' */