From e7bfb7fe88bdab5e0d68a1a1036f5cb32306a311 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 30 Nov 2000 23:12:42 +0000 Subject: added g_timeval_cmp() git-svn-id: http://svn.irssi.org/repos/irssi/trunk@904 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/misc.c | 11 +++++++++++ src/core/misc.h | 1 + 2 files changed, 12 insertions(+) (limited to 'src') 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' */ -- cgit v1.2.3