summaryrefslogtreecommitdiffstats
path: root/src/libutil/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-15 13:38:30 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-15 13:38:30 +0100
commitd0863a174ad1a9d91f3123164bcccc9621f427ed (patch)
tree4a240533927c1437559b469d471784ff8498cf97 /src/libutil/util.c
parent7330952d4fb455c073376745776ac771e6882c0a (diff)
downloadrspamd-d0863a174ad1a9d91f3123164bcccc9621f427ed.tar.gz
rspamd-d0863a174ad1a9d91f3123164bcccc9621f427ed.zip
Add utility to get calendar ticks.
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r--src/libutil/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index b537643ca..983accf62 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1856,6 +1856,22 @@ rspamd_get_virtual_ticks (void)
return res;
}
+gdouble
+rspamd_get_calendar_ticks (void)
+{
+ gdouble res;
+ struct timeval tv;
+
+ if (gettimeofday (&tv, NULL) == 0) {
+ res = (gdouble)tv.tv_sec + tv.tv_usec / 1e6f;
+ }
+ else {
+ res = time (NULL);
+ }
+
+ return res;
+}
+
/* Required for tweetnacl */
void
randombytes (guchar *buf, guint64 len)